mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
send OCEAN tokens to consumer account
This commit is contained in:
parent
431808777c
commit
8e1e3ec06b
@ -67,7 +67,9 @@
|
|||||||
|
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { SHA256 } from 'crypto-js'
|
import { SHA256 } from 'crypto-js'
|
||||||
|
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||||
import {
|
import {
|
||||||
AmountsOutMaxFee,
|
AmountsOutMaxFee,
|
||||||
approve,
|
approve,
|
||||||
@ -297,24 +299,34 @@ describe('Marketplace flow tests', async () => {
|
|||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
const datatoken = new Datatoken(web3)
|
const datatoken = new Datatoken(web3)
|
||||||
|
|
||||||
|
// we send some OCEAN to consumer account
|
||||||
|
const oceanContract = new web3.eth.Contract(
|
||||||
|
MockERC20.abi as AbiItem[],
|
||||||
|
contracts.daiAddress
|
||||||
|
)
|
||||||
|
|
||||||
|
await oceanContract.methods
|
||||||
|
.transfer(consumerAccount, web3.utils.toWei('2'))
|
||||||
|
.send({ from: publisherAccount })
|
||||||
|
|
||||||
const consumerETHBalance = await web3.eth.getBalance(consumerAccount)
|
const consumerETHBalance = await web3.eth.getBalance(consumerAccount)
|
||||||
console.log(`Consumer ETH balance: ${consumerETHBalance}`)
|
console.log(`Consumer ETH balance: ${consumerETHBalance}`)
|
||||||
let consumerOCEANBalance = await balance(
|
let consumerOCEANBalance = await balance(
|
||||||
web3,
|
web3,
|
||||||
contracts.oceanAddress,
|
contracts.oceanAddress,
|
||||||
publisherAccount
|
consumerAccount
|
||||||
)
|
)
|
||||||
console.log(`Consumer OCEAN balance before swap: ${consumerOCEANBalance}`)
|
console.log(`Consumer OCEAN balance before swap: ${consumerOCEANBalance}`)
|
||||||
let consumerDTBalance = await balance(web3, datatokenAddress, publisherAccount)
|
let consumerDTBalance = await balance(web3, datatokenAddress, consumerAccount)
|
||||||
console.log(`Consumer ${NFT_SYMBOL} balance before swap: ${consumerDTBalance}`)
|
console.log(`Consumer ${NFT_SYMBOL} balance before swap: ${consumerDTBalance}`)
|
||||||
|
|
||||||
await approve(web3, publisherAccount, contracts.oceanAddress, poolAddress, '100')
|
await approve(web3, consumerAccount, contracts.oceanAddress, poolAddress, '100')
|
||||||
|
|
||||||
const pool = new Pool(web3)
|
const pool = new Pool(web3)
|
||||||
const tokenInOutMarket: TokenInOutMarket = {
|
const tokenInOutMarket: TokenInOutMarket = {
|
||||||
tokenIn: contracts.oceanAddress,
|
tokenIn: contracts.oceanAddress,
|
||||||
tokenOut: datatokenAddress,
|
tokenOut: datatokenAddress,
|
||||||
marketFeeAddress: publisherAccount
|
marketFeeAddress: consumerAccount
|
||||||
}
|
}
|
||||||
const amountsInOutMaxFee: AmountsOutMaxFee = {
|
const amountsInOutMaxFee: AmountsOutMaxFee = {
|
||||||
maxAmountIn: '10',
|
maxAmountIn: '10',
|
||||||
@ -322,15 +334,15 @@ describe('Marketplace flow tests', async () => {
|
|||||||
swapMarketFee: '0.1'
|
swapMarketFee: '0.1'
|
||||||
}
|
}
|
||||||
await pool.swapExactAmountOut(
|
await pool.swapExactAmountOut(
|
||||||
publisherAccount,
|
consumerAccount,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenInOutMarket,
|
tokenInOutMarket,
|
||||||
amountsInOutMaxFee
|
amountsInOutMaxFee
|
||||||
)
|
)
|
||||||
|
|
||||||
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, publisherAccount)
|
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, consumerAccount)
|
||||||
console.log(`Consumer OCEAN balance after swap: ${consumerOCEANBalance}`)
|
console.log(`Consumer OCEAN balance after swap: ${consumerOCEANBalance}`)
|
||||||
consumerDTBalance = await balance(web3, datatokenAddress, publisherAccount)
|
consumerDTBalance = await balance(web3, datatokenAddress, consumerAccount)
|
||||||
console.log(`Consumer ${NFT_SYMBOL} balance after swap: ${consumerDTBalance}`)
|
console.log(`Consumer ${NFT_SYMBOL} balance after swap: ${consumerDTBalance}`)
|
||||||
|
|
||||||
const resolvedDDO = await aquarius.waitForAqua(DDO.id)
|
const resolvedDDO = await aquarius.waitForAqua(DDO.id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user