1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
This commit is contained in:
Ahmed Ali 2020-06-29 18:20:56 +02:00
parent 5ac2a05172
commit 5f95c67e3e
2 changed files with 38 additions and 21 deletions

View File

@ -193,7 +193,11 @@ export class DataTokens {
* @param dataTokenAddress
* @param account
*/
public async allowance(dataTokenAddress: string, owner: string, spender: string): Promise<string> {
public async allowance(
dataTokenAddress: string,
owner: string,
spender: string
): Promise<string> {
const datatoken = new this.web3.eth.Contract(
this.datatokensABI,
dataTokenAddress,

View File

@ -98,12 +98,14 @@ describe('Marketplace flow', () => {
})
it('Alice allows marketplace to sell her datatokens', async () => {
await datatoken.approve(
await datatoken
.approve(
tokenAddress,
marketplace.getId(),
marketplaceAllowance,
alice.getId()
).then(async () => {
)
.then(async () => {
const allowance = await datatoken.allowance(
tokenAddress,
alice.getId(),
@ -119,10 +121,16 @@ describe('Marketplace flow', () => {
alice.getId(),
marketplace.getId()
)
await datatoken.transferFrom(tokenAddress, alice.getId(), allowance, marketplace.getId())
await datatoken
.transferFrom(tokenAddress, alice.getId(), allowance, marketplace.getId())
.then(async () => {
const marketplaceBalance = await datatoken.balance(tokenAddress, marketplace.getId())
assert(marketplaceBalance.toString() === marketplaceAllowance.toString())
const marketplaceBalance = await datatoken.balance(
tokenAddress,
marketplace.getId()
)
assert(
marketplaceBalance.toString() === marketplaceAllowance.toString()
)
})
})
@ -136,7 +144,12 @@ describe('Marketplace flow', () => {
// })
it('Bob gets datatokens', async () => {
const ts = await datatoken.transfer(tokenAddress, bob.getId(), transferAmount, alice.getId())
const ts = await datatoken.transfer(
tokenAddress,
bob.getId(),
transferAmount,
alice.getId()
)
transactionId = ts.transactionHash
})