1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge branch 'issue-1292-fix-compute-test-timeout' into issue-1356-rewrite-testcontracthandler-helper-class

This commit is contained in:
Miquel A. Cabot 2022-03-22 16:22:07 +01:00
commit d60c26be50
7 changed files with 1435 additions and 1394 deletions

File diff suppressed because it is too large Load Diff

77
package-lock.json generated
View File

@ -1,15 +1,15 @@
{ {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"version": "1.0.0-next.28", "version": "1.0.0-next.29",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"version": "1.0.0-next.28", "version": "1.0.0-next.29",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@oceanprotocol/contracts": "1.0.0-alpha.22", "@oceanprotocol/contracts": "1.0.0-alpha.26",
"bignumber.js": "^9.0.2", "bignumber.js": "^9.0.2",
"cross-fetch": "^3.1.5", "cross-fetch": "^3.1.5",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
@ -24,7 +24,7 @@
"@types/chai-spies": "^1.0.3", "@types/chai-spies": "^1.0.3",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/mocha": "^9.1.0", "@types/mocha": "^9.1.0",
"@types/node": "^17.0.21", "@types/node": "^17.0.22",
"@types/node-fetch": "^3.0.3", "@types/node-fetch": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "^4.33.0",
@ -42,8 +42,8 @@
"mock-local-storage": "^1.1.20", "mock-local-storage": "^1.1.20",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"ora": "5.4.1", "ora": "5.4.1",
"prettier": "^2.3.1", "prettier": "^2.6.0",
"release-it": "^14.12.5", "release-it": "^14.13.1",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"ts-node": "^10.7.0", "ts-node": "^10.7.0",
"ts-node-register": "^1.0.0", "ts-node-register": "^1.0.0",
@ -3071,9 +3071,9 @@
} }
}, },
"node_modules/@oceanprotocol/contracts": { "node_modules/@oceanprotocol/contracts": {
"version": "1.0.0-alpha.22", "version": "1.0.0-alpha.26",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.22.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.26.tgz",
"integrity": "sha512-+m0E2WgH9x66DCtoHB3aaJ69ep3sp/x+jjae50HVgvpw0I0fvatXn5jfHrBxRIBvu0ZIbj6Ct0En3N6h5Yi1vw==", "integrity": "sha512-PHmewip7ZnyMhdk/eLLaGGt4NB9j02haw6djyMB21jZVsqcXr5fLOfvAxra93H0ddkAFMK2valo5Ga+X9c3RMQ==",
"dependencies": { "dependencies": {
"@openzeppelin/contracts": "^4.3.3", "@openzeppelin/contracts": "^4.3.3",
"@openzeppelin/test-helpers": "^0.5.15", "@openzeppelin/test-helpers": "^0.5.15",
@ -4880,9 +4880,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "17.0.21", "version": "17.0.22",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.22.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==" "integrity": "sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw=="
}, },
"node_modules/@types/node-fetch": { "node_modules/@types/node-fetch": {
"version": "3.0.3", "version": "3.0.3",
@ -16299,15 +16299,18 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.5.1", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.0.tgz",
"integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", "integrity": "sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
}, },
"engines": { "engines": {
"node": ">=10.13.0" "node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
} }
}, },
"node_modules/prettier-linter-helpers": { "node_modules/prettier-linter-helpers": {
@ -16869,9 +16872,9 @@
} }
}, },
"node_modules/release-it": { "node_modules/release-it": {
"version": "14.12.5", "version": "14.13.1",
"resolved": "https://registry.npmjs.org/release-it/-/release-it-14.12.5.tgz", "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.13.1.tgz",
"integrity": "sha512-mGFbbX8eEKMOhfjq5mZAgGppT8CME1T+vj6xA5tAPYSCuPpcNEDjqiG1tJfPy/XImZI4uS3U6pNP5KyDpy9etg==", "integrity": "sha512-mrng5bqZDFMr/7oCH3kuflwjKpKki4dUp6yYGxs20scYCvvd8rHAI5pdQOJHwI5BKHAC/pad0UjAEycMWQnEIw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@iarna/toml": "2.2.5", "@iarna/toml": "2.2.5",
@ -16900,6 +16903,7 @@
"update-notifier": "5.1.0", "update-notifier": "5.1.0",
"url-join": "4.0.1", "url-join": "4.0.1",
"uuid": "8.3.2", "uuid": "8.3.2",
"wildcard-match": "5.1.2",
"yaml": "1.10.2", "yaml": "1.10.2",
"yargs-parser": "20.2.9" "yargs-parser": "20.2.9"
}, },
@ -20945,6 +20949,12 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/wildcard-match": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/wildcard-match/-/wildcard-match-5.1.2.tgz",
"integrity": "sha512-qNXwI591Z88c8bWxp+yjV60Ch4F8Riawe3iGxbzquhy8Xs9m+0+SLFBGb/0yCTIDElawtaImC37fYZ+dr32KqQ==",
"dev": true
},
"node_modules/window-size": { "node_modules/window-size": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz",
@ -23457,9 +23467,9 @@
} }
}, },
"@oceanprotocol/contracts": { "@oceanprotocol/contracts": {
"version": "1.0.0-alpha.22", "version": "1.0.0-alpha.26",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.22.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.26.tgz",
"integrity": "sha512-+m0E2WgH9x66DCtoHB3aaJ69ep3sp/x+jjae50HVgvpw0I0fvatXn5jfHrBxRIBvu0ZIbj6Ct0En3N6h5Yi1vw==", "integrity": "sha512-PHmewip7ZnyMhdk/eLLaGGt4NB9j02haw6djyMB21jZVsqcXr5fLOfvAxra93H0ddkAFMK2valo5Ga+X9c3RMQ==",
"requires": { "requires": {
"@openzeppelin/contracts": "^4.3.3", "@openzeppelin/contracts": "^4.3.3",
"@openzeppelin/test-helpers": "^0.5.15", "@openzeppelin/test-helpers": "^0.5.15",
@ -25019,9 +25029,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "17.0.21", "version": "17.0.22",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.22.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==" "integrity": "sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw=="
}, },
"@types/node-fetch": { "@types/node-fetch": {
"version": "3.0.3", "version": "3.0.3",
@ -33801,9 +33811,9 @@
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
}, },
"prettier": { "prettier": {
"version": "2.5.1", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.0.tgz",
"integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", "integrity": "sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==",
"dev": true "dev": true
}, },
"prettier-linter-helpers": { "prettier-linter-helpers": {
@ -34234,9 +34244,9 @@
} }
}, },
"release-it": { "release-it": {
"version": "14.12.5", "version": "14.13.1",
"resolved": "https://registry.npmjs.org/release-it/-/release-it-14.12.5.tgz", "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.13.1.tgz",
"integrity": "sha512-mGFbbX8eEKMOhfjq5mZAgGppT8CME1T+vj6xA5tAPYSCuPpcNEDjqiG1tJfPy/XImZI4uS3U6pNP5KyDpy9etg==", "integrity": "sha512-mrng5bqZDFMr/7oCH3kuflwjKpKki4dUp6yYGxs20scYCvvd8rHAI5pdQOJHwI5BKHAC/pad0UjAEycMWQnEIw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@iarna/toml": "2.2.5", "@iarna/toml": "2.2.5",
@ -34265,6 +34275,7 @@
"update-notifier": "5.1.0", "update-notifier": "5.1.0",
"url-join": "4.0.1", "url-join": "4.0.1",
"uuid": "8.3.2", "uuid": "8.3.2",
"wildcard-match": "5.1.2",
"yaml": "1.10.2", "yaml": "1.10.2",
"yargs-parser": "20.2.9" "yargs-parser": "20.2.9"
}, },
@ -37504,6 +37515,12 @@
"string-width": "^4.0.0" "string-width": "^4.0.0"
} }
}, },
"wildcard-match": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/wildcard-match/-/wildcard-match-5.1.2.tgz",
"integrity": "sha512-qNXwI591Z88c8bWxp+yjV60Ch4F8Riawe3iGxbzquhy8Xs9m+0+SLFBGb/0yCTIDElawtaImC37fYZ+dr32KqQ==",
"dev": true
},
"window-size": { "window-size": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz",

View File

@ -1,7 +1,7 @@
{ {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"source": "./src/index.ts", "source": "./src/index.ts",
"version": "1.0.0-next.28", "version": "1.0.0-next.29",
"description": "JavaScript client library for Ocean Protocol", "description": "JavaScript client library for Ocean Protocol",
"main": "./dist/lib.js", "main": "./dist/lib.js",
"umd:main": "dist/lib.umd.js", "umd:main": "dist/lib.umd.js",
@ -57,7 +57,7 @@
"web3": "^1.7.1" "web3": "^1.7.1"
}, },
"dependencies": { "dependencies": {
"@oceanprotocol/contracts": "1.0.0-alpha.22", "@oceanprotocol/contracts": "1.0.0-alpha.26",
"bignumber.js": "^9.0.2", "bignumber.js": "^9.0.2",
"cross-fetch": "^3.1.5", "cross-fetch": "^3.1.5",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
@ -72,7 +72,7 @@
"@types/chai-spies": "^1.0.3", "@types/chai-spies": "^1.0.3",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/mocha": "^9.1.0", "@types/mocha": "^9.1.0",
"@types/node": "^17.0.21", "@types/node": "^17.0.22",
"@types/node-fetch": "^3.0.3", "@types/node-fetch": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "^4.33.0",
@ -90,8 +90,8 @@
"mock-local-storage": "^1.1.20", "mock-local-storage": "^1.1.20",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"ora": "5.4.1", "ora": "5.4.1",
"prettier": "^2.3.1", "prettier": "^2.6.0",
"release-it": "^14.12.5", "release-it": "^14.13.1",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"ts-node": "^10.7.0", "ts-node": "^10.7.0",
"ts-node-register": "^1.0.0", "ts-node-register": "^1.0.0",

View File

@ -100,17 +100,13 @@ export class FixedRateExchange {
/** /**
* Creates unique exchange identifier. * Creates unique exchange identifier.
* @param {String} baseToken baseToken contract address
* @param {String} datatoken Datatoken contract address * @param {String} datatoken Datatoken contract address
* @param {String} owner Owner of the exchange
* @return {Promise<string>} exchangeId * @return {Promise<string>} exchangeId
*/ */
public async generateExchangeId( public async generateExchangeId(baseToken: string, datatoken: string): Promise<string> {
baseToken: string,
datatoken: string,
owner: string
): Promise<string> {
const exchangeId = await this.contract.methods const exchangeId = await this.contract.methods
.generateExchangeId(baseToken, datatoken, owner) .generateExchangeId(baseToken, datatoken)
.call() .call()
return exchangeId return exchangeId
} }
@ -816,20 +812,26 @@ export class FixedRateExchange {
* Estimate gas cost for collectBT * Estimate gas cost for collectBT
* @param {String} account * @param {String} account
* @param {String} exchangeId ExchangeId * @param {String} exchangeId ExchangeId
* @param {String} amount amount to be collected
* @param {Contract} contractInstance optional contract instance * @param {Contract} contractInstance optional contract instance
* @return {Promise<number>} * @return {Promise<number>}
*/ */
public async estCollectBT( public async estCollectBT(
account: string, account: string,
exchangeId: string, exchangeId: string,
amount: string,
contractInstance?: Contract contractInstance?: Contract
): Promise<number> { ): Promise<number> {
const fixedRate = contractInstance || this.fixedRateContract const fixedRate = contractInstance || this.fixedRateContract
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
const fixedrate: FixedPriceExchange = await this.contract.methods
.getExchange(exchangeId)
.call()
const amountWei = await this.amountToUnits(fixedrate.baseToken, amount)
try { try {
estGas = await fixedRate.methods estGas = await fixedRate.methods
.collectBT(exchangeId) .collectBT(exchangeId, amountWei)
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas)) .estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) { } catch (e) {
estGas = gasLimitDefault estGas = gasLimitDefault
@ -838,20 +840,26 @@ export class FixedRateExchange {
} }
/** /**
* Collect BaseTokens in the contract (only exchange owner) * Collect BaseTokens in the contract (anyone can call this, funds are sent to erc20.paymentCollector)
* @param {String} exchangeId ExchangeId
* @param {String} address User address * @param {String} address User address
* @param {String} exchangeId ExchangeId
* @param {String} amount amount to be collected
* @return {Promise<TransactionReceipt>} transaction receipt * @return {Promise<TransactionReceipt>} transaction receipt
*/ */
public async collectBT( public async collectBT(
address: string, address: string,
exchangeId: string exchangeId: string,
amount: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const exchange = await this.getExchange(exchangeId) const exchange = await this.getExchange(exchangeId)
if (!exchange) return null if (!exchange) return null
const estGas = await this.estCollectBT(address, exchangeId) const estGas = await this.estCollectBT(address, exchangeId, amount)
const trxReceipt = await this.contract.methods.collectBT(exchangeId).send({ const fixedrate: FixedPriceExchange = await this.contract.methods
.getExchange(exchangeId)
.call()
const amountWei = await this.amountToUnits(fixedrate.baseToken, amount)
const trxReceipt = await this.contract.methods.collectBT(exchangeId, amountWei).send({
from: address, from: address,
gas: estGas + 1, gas: estGas + 1,
gasPrice: await getFairGasPrice(this.web3, this.config) gasPrice: await getFairGasPrice(this.web3, this.config)
@ -863,20 +871,26 @@ export class FixedRateExchange {
* Estimate gas cost for collecDT * Estimate gas cost for collecDT
* @param {String} account * @param {String} account
* @param {String} exchangeId ExchangeId * @param {String} exchangeId ExchangeId
* @param {String} amount amount to be collected
* @param {Contract} contractInstance optional contract instance * @param {Contract} contractInstance optional contract instance
* @return {Promise<number>} * @return {Promise<number>}
*/ */
public async estCollectDT( public async estCollectDT(
account: string, account: string,
exchangeId: string, exchangeId: string,
amount: string,
contractInstance?: Contract contractInstance?: Contract
): Promise<number> { ): Promise<number> {
const fixedRate = contractInstance || this.fixedRateContract const fixedRate = contractInstance || this.fixedRateContract
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
const fixedrate: FixedPriceExchange = await this.contract.methods
.getExchange(exchangeId)
.call()
const amountWei = await this.amountToUnits(fixedrate.datatoken, amount)
try { try {
estGas = await fixedRate.methods estGas = await fixedRate.methods
.collectDT(exchangeId) .collectDT(exchangeId, amountWei)
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas)) .estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) { } catch (e) {
estGas = gasLimitDefault estGas = gasLimitDefault
@ -885,20 +899,26 @@ export class FixedRateExchange {
} }
/** /**
* Collect datatokens in the contract (only exchange owner) * Collect datatokens in the contract (anyone can call this, funds are sent to erc20.paymentCollector)
* @param {String} exchangeId ExchangeId
* @param {String} address User address * @param {String} address User address
* @param {String} exchangeId ExchangeId
* @param {String} amount amount to be collected
* @return {Promise<TransactionReceipt>} transaction receipt * @return {Promise<TransactionReceipt>} transaction receipt
*/ */
public async collectDT( public async collectDT(
address: string, address: string,
exchangeId: string exchangeId: string,
amount: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const exchange = await this.getExchange(exchangeId) const exchange = await this.getExchange(exchangeId)
if (!exchange) return null if (!exchange) return null
const estGas = await this.estCollectDT(address, exchangeId) const estGas = await this.estCollectDT(address, exchangeId, amount)
const trxReceipt = await this.contract.methods.collectDT(exchangeId).send({ const fixedrate: FixedPriceExchange = await this.contract.methods
.getExchange(exchangeId)
.call()
const amountWei = await this.amountToUnits(fixedrate.datatoken, amount)
const trxReceipt = await this.contract.methods.collectDT(exchangeId, amountWei).send({
from: address, from: address,
gas: estGas + 1, gas: estGas + 1,
gasPrice: await getFairGasPrice(this.web3, this.config) gasPrice: await getFairGasPrice(this.web3, this.config)

View File

@ -41,7 +41,8 @@ export const configHelperNetworks: Config[] = [
nodeUri: 'https://ropsten.infura.io/v3', nodeUri: 'https://ropsten.infura.io/v3',
providerUri: 'https://v4.provider.ropsten.oceanprotocol.com', providerUri: 'https://v4.provider.ropsten.oceanprotocol.com',
subgraphUri: 'https://v4.subgraph.ropsten.oceanprotocol.com', subgraphUri: 'https://v4.subgraph.ropsten.oceanprotocol.com',
explorerUri: 'https://ropsten.etherscan.io' explorerUri: 'https://ropsten.etherscan.io',
gasFeeMultiplier: 1.1
}, },
{ {
...configHelperNetworksBase, ...configHelperNetworksBase,
@ -50,7 +51,8 @@ export const configHelperNetworks: Config[] = [
nodeUri: 'https://rinkeby.infura.io/v3', nodeUri: 'https://rinkeby.infura.io/v3',
providerUri: 'https://v4.provider.rinkeby.oceanprotocol.com', providerUri: 'https://v4.provider.rinkeby.oceanprotocol.com',
subgraphUri: 'https://v4.subgraph.rinkeby.oceanprotocol.com', subgraphUri: 'https://v4.subgraph.rinkeby.oceanprotocol.com',
explorerUri: 'https://rinkeby.etherscan.io' explorerUri: 'https://rinkeby.etherscan.io',
gasFeeMultiplier: 1.1
}, },
{ {
...configHelperNetworksBase, ...configHelperNetworksBase,
@ -83,7 +85,8 @@ export const configHelperNetworks: Config[] = [
nodeUri: 'https://rpc.api.moonbase.moonbeam.network', nodeUri: 'https://rpc.api.moonbase.moonbeam.network',
providerUri: 'https://v4.provider.moonbase.oceanprotocol.com', providerUri: 'https://v4.provider.moonbase.oceanprotocol.com',
subgraphUri: 'https://v4.subgraph.moonbase.oceanprotocol.com', subgraphUri: 'https://v4.subgraph.moonbase.oceanprotocol.com',
explorerUri: 'https://moonbase.moonscan.io/' explorerUri: 'https://moonbase.moonscan.io/',
gasFeeMultiplier: 1.1
}, },
{ {
...configHelperNetworksBase, ...configHelperNetworksBase,
@ -101,7 +104,8 @@ export const configHelperNetworks: Config[] = [
nodeUri: 'https://polygon-mumbai.infura.io/v3', nodeUri: 'https://polygon-mumbai.infura.io/v3',
providerUri: 'https://v4.provider.mumbai.oceanprotocol.com', providerUri: 'https://v4.provider.mumbai.oceanprotocol.com',
subgraphUri: 'https://v4.subgraph.mumbai.oceanprotocol.com', subgraphUri: 'https://v4.subgraph.mumbai.oceanprotocol.com',
explorerUri: 'https://mumbai.polygonscan.com' explorerUri: 'https://mumbai.polygonscan.com',
gasFeeMultiplier: 1.1
}, },
{ {
...configHelperNetworksBase, ...configHelperNetworksBase,

View File

@ -139,11 +139,6 @@ describe('Dispenser flow', () => {
assert(tx, 'user3 failed to get 1DT') assert(tx, 'user3 failed to get 1DT')
}) })
it('tries to withdraw all datatokens', async () => {
const tx = await DispenserClass.ownerWithdraw(dtAddress, user3)
assert(tx === null, 'Request should fail')
})
it('user2 withdraws all datatokens', async () => { it('user2 withdraws all datatokens', async () => {
const tx = await DispenserClass.ownerWithdraw(dtAddress, factoryOwner) const tx = await DispenserClass.ownerWithdraw(dtAddress, factoryOwner)
assert(tx, 'user2 failed to withdraw all her tokens') assert(tx, 'user2 failed to withdraw all her tokens')

View File

@ -165,7 +165,7 @@ describe('Fixed Rate unit test', () => {
it('#generate exchangeId - should generate a specific exchangeId', async () => { it('#generate exchangeId - should generate a specific exchangeId', async () => {
expect( expect(
await fixedRate.generateExchangeId(contracts.daiAddress, dtAddress, exchangeOwner) await fixedRate.generateExchangeId(contracts.daiAddress, dtAddress)
).to.equal(exchangeId) ).to.equal(exchangeId)
}) })
@ -320,9 +320,10 @@ describe('Fixed Rate unit test', () => {
// user2 buys 1 DT // user2 buys 1 DT
await fixedRate.buyDT(user2, exchangeId, '1', '2') await fixedRate.buyDT(user2, exchangeId, '1', '2')
// 1 DAI in the contract // 1 DAI in the contract
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('1') const fixedRateDetails = await fixedRate.getExchange(exchangeId)
expect(fixedRateDetails.btBalance).to.equal('1')
// owner collects BTs // owner collects BTs
await fixedRate.collectBT(exchangeOwner, exchangeId) await fixedRate.collectBT(exchangeOwner, exchangeId, fixedRateDetails.btBalance)
// btBalance is zero // btBalance is zero
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0') expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0')
}) })
@ -331,7 +332,7 @@ describe('Fixed Rate unit test', () => {
// 9 dts left // 9 dts left
expect(result.dtBalance).to.equal('9') expect(result.dtBalance).to.equal('9')
// owner collects DTs // owner collects DTs
await fixedRate.collectDT(exchangeOwner, exchangeId) await fixedRate.collectDT(exchangeOwner, exchangeId, result.dtBalance)
// no more dts in the contract // no more dts in the contract
const result2 = await fixedRate.getExchange(exchangeId) const result2 = await fixedRate.getExchange(exchangeId)
expect(result2.dtBalance).to.equal('0') expect(result2.dtBalance).to.equal('0')
@ -355,7 +356,7 @@ describe('Fixed Rate unit test', () => {
expect(result.oceanFeeAvailable).to.equal('0.042') expect(result.oceanFeeAvailable).to.equal('0.042')
// user3 is the marketFeeCollector // user3 is the marketFeeCollector
expect(await daiContract.methods.balanceOf(user3).call()).to.equal( expect(await daiContract.methods.balanceOf(user3).call()).to.equal(
web3.utils.toWei('0.021') web3.utils.toWei('1.021')
) )
}) })
@ -482,11 +483,7 @@ describe('Fixed Rate unit test', () => {
it('#generate exchangeId - should generate a specific exchangeId', async () => { it('#generate exchangeId - should generate a specific exchangeId', async () => {
expect( expect(
await fixedRate.generateExchangeId( await fixedRate.generateExchangeId(contracts.usdcAddress, dtAddress)
contracts.usdcAddress,
dtAddress,
exchangeOwner
)
).to.equal(exchangeId) ).to.equal(exchangeId)
}) })
@ -635,9 +632,10 @@ describe('Fixed Rate unit test', () => {
// user2 buys 1 DT // user2 buys 1 DT
await fixedRate.buyDT(user2, exchangeId, '1', '2') await fixedRate.buyDT(user2, exchangeId, '1', '2')
// 1 DAI in the contract // 1 DAI in the contract
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('1') const exchangeDetails = await fixedRate.getExchange(exchangeId)
expect(exchangeDetails.btBalance).to.equal('1')
// owner collects BTs // owner collects BTs
await fixedRate.collectBT(exchangeOwner, exchangeId) await fixedRate.collectBT(exchangeOwner, exchangeId, exchangeDetails.btBalance)
// btBalance is zero // btBalance is zero
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0') expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0')
}) })
@ -646,7 +644,7 @@ describe('Fixed Rate unit test', () => {
// 9 dts left // 9 dts left
expect(result.dtBalance).to.equal('9') expect(result.dtBalance).to.equal('9')
// owner collects DTs // owner collects DTs
await fixedRate.collectDT(exchangeOwner, exchangeId) await fixedRate.collectDT(exchangeOwner, exchangeId, result.dtBalance)
// no more dts in the contract // no more dts in the contract
const result2 = await fixedRate.getExchange(exchangeId) const result2 = await fixedRate.getExchange(exchangeId)
expect(result2.dtBalance).to.equal('0') expect(result2.dtBalance).to.equal('0')