mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix order, update contracts (#1240)
* fix order, update contracts * remove console.log * remove force contracts install
This commit is contained in:
parent
1b0fb28e76
commit
be7adcb6f8
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -27,7 +27,6 @@ jobs:
|
||||
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
|
||||
- run: npm ci
|
||||
- run: npm i --verbose --force @oceanprotocol/contracts@"github:oceanprotocol/contracts#v4main_postaudit"
|
||||
- run: npm run lint
|
||||
|
||||
test_unit:
|
||||
@ -61,7 +60,6 @@ jobs:
|
||||
cd ..
|
||||
|
||||
- run: npm ci
|
||||
- run: npm i --verbose --force @oceanprotocol/contracts@"github:oceanprotocol/contracts#v4main_postaudit"
|
||||
- run: npm run build:metadata
|
||||
- run: npm run test:unit:cover
|
||||
- uses: actions/upload-artifact@v2
|
||||
@ -86,7 +84,6 @@ jobs:
|
||||
key: ${{ runner.os }}-test-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-test-integration-${{ env.cache-name }}-
|
||||
- run: npm ci
|
||||
- run: npm i --verbose --force @oceanprotocol/contracts@"github:oceanprotocol/contracts#v4main_postaudit"
|
||||
- run: npm run build:metadata
|
||||
|
||||
# Env var expansion workaround
|
||||
@ -149,7 +146,6 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}-
|
||||
- run: npm ci
|
||||
- run: npm i --verbose --force @oceanprotocol/contracts@"github:oceanprotocol/contracts#v4main_postaudit"
|
||||
- run: npm run build
|
||||
- run: npm run doc:json
|
||||
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"version": "1.0.0-next.8",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.1",
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.15",
|
||||
"bignumber.js": "^9.0.2",
|
||||
"cross-fetch": "^3.1.4",
|
||||
"crypto-js": "^4.0.0",
|
||||
@ -3016,9 +3016,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oceanprotocol/contracts": {
|
||||
"name": "hardhat-project",
|
||||
"version": "v1.0.0-alpha.1",
|
||||
"resolved": "git+ssh://git@github.com/oceanprotocol/contracts.git#36e8bf296163690a23cfe012c4468caba4504709",
|
||||
"version": "1.0.0-alpha.15",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.15.tgz",
|
||||
"integrity": "sha512-m8vF38uKKCZTRnNE84xQEL81hCpGvhWqbMMqkuJqdJTeRoLoJJmHqHMi3xqkferMrH7Bmt4znuRSiWnbd75s3A==",
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "^4.3.3",
|
||||
"@openzeppelin/test-helpers": "^0.5.15",
|
||||
@ -27489,8 +27489,9 @@
|
||||
}
|
||||
},
|
||||
"@oceanprotocol/contracts": {
|
||||
"version": "git+ssh://git@github.com/oceanprotocol/contracts.git#36e8bf296163690a23cfe012c4468caba4504709",
|
||||
"from": "@oceanprotocol/contracts@^1.0.0-alpha.1",
|
||||
"version": "1.0.0-alpha.15",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.15.tgz",
|
||||
"integrity": "sha512-m8vF38uKKCZTRnNE84xQEL81hCpGvhWqbMMqkuJqdJTeRoLoJJmHqHMi3xqkferMrH7Bmt4znuRSiWnbd75s3A==",
|
||||
"requires": {
|
||||
"@openzeppelin/contracts": "^4.3.3",
|
||||
"@openzeppelin/test-helpers": "^0.5.15",
|
||||
|
@ -57,7 +57,7 @@
|
||||
"web3": ">=1.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.1",
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.15",
|
||||
"bignumber.js": "^9.0.2",
|
||||
"cross-fetch": "^3.1.4",
|
||||
"crypto-js": "^4.0.0",
|
||||
@ -81,10 +81,10 @@
|
||||
"chai-spies": "^1.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^7.17.0",
|
||||
"fs": "0.0.1-security",
|
||||
"eslint-config-oceanprotocol": "^1.5.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"fs": "0.0.1-security",
|
||||
"microbundle": "^0.14.2",
|
||||
"mocha": "^9.1.2",
|
||||
"mock-local-storage": "^1.1.17",
|
||||
|
@ -30,6 +30,7 @@ interface Template {
|
||||
export interface TokenOrder {
|
||||
tokenAddress: string
|
||||
consumer: string
|
||||
ammount: string
|
||||
serviceIndex: number
|
||||
_providerFees: ProviderFees
|
||||
}
|
||||
|
@ -521,16 +521,16 @@ export class Router {
|
||||
}
|
||||
|
||||
/** Get OPF Fee per token
|
||||
* @return {Promise<number>} OPF fee for a specific baseToken
|
||||
* @return {Promise<number>} OPC fee for a specific baseToken
|
||||
*/
|
||||
public async getOPFFee(baseToken: string): Promise<number> {
|
||||
return await this.router.methods.getOPFFee(baseToken).call()
|
||||
public async getOPCFee(baseToken: string): Promise<number> {
|
||||
return await this.router.methods.getOPCFee(baseToken).call()
|
||||
}
|
||||
|
||||
/** Get Current OPF Fee
|
||||
* @return {Promise<number>} OPF fee
|
||||
*/
|
||||
public async getCurrentOPFFee(): Promise<number> {
|
||||
public async getCurrentOPCFee(): Promise<number> {
|
||||
return await this.router.methods.swapOceanFee().call()
|
||||
}
|
||||
|
||||
@ -540,12 +540,18 @@ export class Router {
|
||||
* @param {String} newFee new OPF Fee
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasUpdateOPFFee(address: string, newFee: number): Promise<any> {
|
||||
public async estGasUpdateOPCFee(
|
||||
address: string,
|
||||
newSwapOceanFee: number,
|
||||
newSwapNonOceanFee: number,
|
||||
newConsumeFee: number,
|
||||
newProviderFee: number
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.updateOPFFee(newFee)
|
||||
.updateOPCFee(newSwapOceanFee, newSwapNonOceanFee, newConsumeFee, newProviderFee)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
@ -557,26 +563,39 @@ export class Router {
|
||||
/**
|
||||
* Add a new contract to fixedRate list, after is added, can be used when deploying a new pool
|
||||
* @param {String} address
|
||||
* @param {String} newFee new OPF Fee
|
||||
* @param {number} newSwapOceanFee Amount charged for swapping with ocean approved tokens
|
||||
* @param {number} newSwapNonOceanFee Amount charged for swapping with non ocean approved tokens
|
||||
* @param {number} newConsumeFee Amount charged from consumeFees
|
||||
* @param {number} newProviderFee Amount charged for providerFees
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async updateOPFFee(
|
||||
public async updateOPCFee(
|
||||
address: string,
|
||||
newFee: number
|
||||
newSwapOceanFee: number,
|
||||
newSwapNonOceanFee: number,
|
||||
newConsumeFee: number,
|
||||
newProviderFee: number
|
||||
): Promise<TransactionReceipt> {
|
||||
if ((await this.getOwner()) !== address) {
|
||||
throw new Error(`Caller is not Router Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
const estGas = await this.estGasUpdateOPFFee(address, newFee)
|
||||
const estGas = await this.estGasUpdateOPCFee(
|
||||
address,
|
||||
newSwapOceanFee,
|
||||
newSwapNonOceanFee,
|
||||
newConsumeFee,
|
||||
newProviderFee
|
||||
)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.updateOPFFee(newFee, newFee).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.router.methods
|
||||
.updateOPCFee(newSwapOceanFee, newSwapNonOceanFee, newConsumeFee, newProviderFee)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
|
||||
return trxReceipt
|
||||
}
|
||||
|
@ -290,18 +290,18 @@ export class Pool {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OPF Collector of this pool
|
||||
* Get OPC Collector of this pool
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
async getOPFCollector(poolAddress: string): Promise<string> {
|
||||
async getOPCCollector(poolAddress: string): Promise<string> {
|
||||
const pool = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||
this.config
|
||||
)
|
||||
let result = null
|
||||
try {
|
||||
result = await pool.methods._opfCollector().call()
|
||||
result = await pool.methods._opcCollector().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get OPF Collector address: ${e.message}`)
|
||||
}
|
||||
@ -483,7 +483,7 @@ export class Pool {
|
||||
this.config
|
||||
)
|
||||
try {
|
||||
const currentMarketFees = await pool.methods.getCurrentOPFFees().call()
|
||||
const currentMarketFees = await pool.methods.getCurrentOPCFees().call()
|
||||
return currentMarketFees
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get community fees for a token: ${e.message}`)
|
||||
@ -494,13 +494,13 @@ export class Pool {
|
||||
* Get getCurrentOPFFees Get the current amount of fees which can be withdrawned by OPF
|
||||
* @return {CurrentFees}
|
||||
*/
|
||||
async getCurrentOPFFees(poolAddress: string): Promise<CurrentFees> {
|
||||
async getCurrentOPCFees(poolAddress: string): Promise<CurrentFees> {
|
||||
const pool = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||
this.config
|
||||
)
|
||||
try {
|
||||
const currentMarketFees = await pool.methods.getCurrentOPFFees().call()
|
||||
const currentMarketFees = await pool.methods.getCurrentOPCFees().call()
|
||||
return currentMarketFees
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get community fees for a token: ${e.message}`)
|
||||
@ -535,7 +535,7 @@ export class Pool {
|
||||
* @param {Contract} contractInstance optional contract instance
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
public async estCollectOPF(
|
||||
public async estCollectOPC(
|
||||
address: string,
|
||||
poolAddress: string,
|
||||
contractInstance?: Contract
|
||||
@ -551,7 +551,7 @@ export class Pool {
|
||||
let estGas
|
||||
try {
|
||||
estGas = await poolContract.methods
|
||||
.collectOPF()
|
||||
.collectOPC()
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
@ -565,16 +565,16 @@ export class Pool {
|
||||
* @param {String} poolAddress
|
||||
* @return {TransactionReceipt}
|
||||
*/
|
||||
async collectOPF(address: string, poolAddress: string): Promise<TransactionReceipt> {
|
||||
async collectOPC(address: string, poolAddress: string): Promise<TransactionReceipt> {
|
||||
const pool = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||
this.config
|
||||
)
|
||||
let result = null
|
||||
const estGas = await this.estCollectOPF(address, poolAddress)
|
||||
const estGas = await this.estCollectOPC(address, poolAddress)
|
||||
|
||||
try {
|
||||
result = await pool.methods.collectOPF().send({
|
||||
result = await pool.methods.collectOPC().send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
|
@ -31,7 +31,7 @@ export interface FixedPriceExchange {
|
||||
}
|
||||
|
||||
export interface FeesInfo {
|
||||
opfFee: string
|
||||
opcFee: string
|
||||
marketFee: string
|
||||
marketFeeCollector: string
|
||||
marketFeeAvailable: string
|
||||
@ -640,7 +640,7 @@ export class FixedRateExchange {
|
||||
*/
|
||||
public async getFeesInfo(exchangeId: string): Promise<FeesInfo> {
|
||||
const result: FeesInfo = await this.contract.methods.getFeesInfo(exchangeId).call()
|
||||
result.opfFee = this.web3.utils.fromWei(result.opfFee.toString())
|
||||
result.opcFee = this.web3.utils.fromWei(result.opcFee.toString())
|
||||
result.marketFee = this.web3.utils.fromWei(result.marketFee.toString())
|
||||
|
||||
result.marketFeeAvailable = await this.unitsToAmount(
|
||||
@ -974,12 +974,12 @@ export class FixedRateExchange {
|
||||
* Get OPF Collector of fixed rate contract
|
||||
* @return {String}
|
||||
*/
|
||||
async getOPFCollector(): Promise<string> {
|
||||
async getOPCCollector(): Promise<string> {
|
||||
let result = null
|
||||
try {
|
||||
result = await this.contract.methods.opfCollector().call()
|
||||
result = await this.contract.methods.opcCollector().call()
|
||||
} catch (e) {
|
||||
LoggerInstance.error(`ERROR: Failed to get OPF Collector address: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get OPC Collector address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ interface Roles {
|
||||
export interface OrderParams {
|
||||
consumer: string
|
||||
serviceIndex: number
|
||||
ammount: string
|
||||
_providerFees: ProviderFees
|
||||
}
|
||||
|
||||
|
@ -378,6 +378,7 @@ describe('Nft Factory test', () => {
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerValidUntil = '0'
|
||||
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: consumeFeeAddress },
|
||||
@ -402,13 +403,15 @@ describe('Nft Factory test', () => {
|
||||
tokenAddress: dtAddress,
|
||||
consumer: consumer,
|
||||
serviceIndex: serviceIndex,
|
||||
_providerFees: providerFees
|
||||
_providerFees: providerFees,
|
||||
ammount: dtAmount
|
||||
},
|
||||
{
|
||||
tokenAddress: dtAddress2,
|
||||
consumer: consumer,
|
||||
serviceIndex: serviceIndex,
|
||||
_providerFees: providerFees
|
||||
_providerFees: providerFees,
|
||||
ammount: dtAmount
|
||||
}
|
||||
]
|
||||
await nftFactory.startMultipleTokenOrder(user2, orders)
|
||||
|
@ -122,23 +122,29 @@ describe('Router unit test', () => {
|
||||
expect(await router.isFixedPrice(contracts.daiAddress)).to.equal(true)
|
||||
})
|
||||
|
||||
it('#getOPFFee - should return actual OPF fee for a given baseToken', async () => {
|
||||
const opfFee = 1e15
|
||||
expect(await router.getOPFFee(contracts.oceanAddress)).to.equal('0')
|
||||
expect(await router.getOPFFee(contracts.daiAddress)).to.equal(opfFee.toString())
|
||||
it('#getOPCFee - should return actual OPF fee for a given baseToken', async () => {
|
||||
const opcFee = 1e15
|
||||
expect(await router.getOPCFee(contracts.oceanAddress)).to.equal('0')
|
||||
expect(await router.getOPCFee(contracts.daiAddress)).to.equal(opcFee.toString())
|
||||
})
|
||||
|
||||
it('#getCurrentOPFFee - should return actual OPF Fee', async () => {
|
||||
const opfFee = 0
|
||||
expect(await router.getCurrentOPFFee()).to.equal(opfFee.toString())
|
||||
expect(await router.getCurrentOPCFee()).to.equal(opfFee.toString())
|
||||
})
|
||||
|
||||
it('#updateOPFFee - should update opf fee if Router Owner', async () => {
|
||||
it('#updateOPCFee - should update opf fee if Router Owner', async () => {
|
||||
const opfFee = 0
|
||||
expect(await router.getCurrentOPFFee()).to.equal(opfFee.toString())
|
||||
expect(await router.getCurrentOPCFee()).to.equal(opfFee.toString())
|
||||
const newOPFFee = 1e14
|
||||
await router.updateOPFFee(contracts.accounts[0], 1e14)
|
||||
expect(await router.getCurrentOPFFee()).to.equal(newOPFFee.toString())
|
||||
await router.updateOPCFee(
|
||||
contracts.accounts[0],
|
||||
newOPFFee,
|
||||
newOPFFee,
|
||||
newOPFFee,
|
||||
newOPFFee
|
||||
)
|
||||
expect(await router.getCurrentOPCFee()).to.equal(newOPFFee.toString())
|
||||
})
|
||||
|
||||
it('#addPoolTemplate - should add a new token into poolTemplates mapping if Router Owner', async () => {
|
||||
|
@ -549,8 +549,8 @@ describe('Pool unit test', () => {
|
||||
assert((await pool.getMarketFeeCollector(poolAddress)) === contracts.accounts[0])
|
||||
})
|
||||
|
||||
it('#getOPFCollector- should get market fees for each token', async () => {
|
||||
assert((await pool.getOPFCollector(poolAddress)) === contracts.opfCollectorAddress)
|
||||
it('#getOPCCollector- should get market fees for each token', async () => {
|
||||
assert((await pool.getOPCCollector(poolAddress)) === contracts.opfCollectorAddress)
|
||||
})
|
||||
|
||||
it('#collectCommunityFee- should get community fees for each token', async () => {
|
||||
@ -568,7 +568,7 @@ describe('Pool unit test', () => {
|
||||
'0'
|
||||
)
|
||||
// anyone can call callectOPF
|
||||
await pool.collectOPF(contracts.accounts[0], poolAddress)
|
||||
await pool.collectOPC(contracts.accounts[0], poolAddress)
|
||||
// DAI fees have been collected
|
||||
assert((await pool.getCommunityFees(poolAddress, contracts.daiAddress)) === '0')
|
||||
// OPF collector got DAI
|
||||
@ -1101,8 +1101,8 @@ describe('Pool unit test', () => {
|
||||
assert((await pool.getMarketFeeCollector(poolAddress)) === contracts.accounts[0])
|
||||
})
|
||||
|
||||
it('#getOPFCollector- should get market fees for each token', async () => {
|
||||
assert((await pool.getOPFCollector(poolAddress)) === contracts.opfCollectorAddress)
|
||||
it('#getOPCCollector- should get market fees for each token', async () => {
|
||||
assert((await pool.getOPCCollector(poolAddress)) === contracts.opfCollectorAddress)
|
||||
})
|
||||
|
||||
it('#getCurrentMarketFees- should get curent market fees for each token', async () => {
|
||||
@ -1111,7 +1111,7 @@ describe('Pool unit test', () => {
|
||||
})
|
||||
|
||||
it('#getCurrentOPFFees- should get curent market fees for each token', async () => {
|
||||
const curentOPFFees: CurrentFees = await pool.getCurrentOPFFees(poolAddress)
|
||||
const curentOPFFees: CurrentFees = await pool.getCurrentOPCFees(poolAddress)
|
||||
assert(curentOPFFees !== null)
|
||||
})
|
||||
|
||||
@ -1130,7 +1130,7 @@ describe('Pool unit test', () => {
|
||||
'0'
|
||||
)
|
||||
// anyone can call callectOPF
|
||||
await pool.collectOPF(contracts.accounts[0], poolAddress)
|
||||
await pool.collectOPC(contracts.accounts[0], poolAddress)
|
||||
// USDC fees have been collected
|
||||
assert((await pool.getCommunityFees(poolAddress, contracts.usdcAddress)) === '0')
|
||||
// OPF collector got USDC
|
||||
|
@ -160,7 +160,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(await fixedRate.getExchangeOwner(exchangeId)).to.equal(exchangeOwner)
|
||||
})
|
||||
it('#getOPFCollector - should get OPF collector', async () => {
|
||||
expect(await fixedRate.getOPFCollector()).to.equal(contracts.opfCollectorAddress)
|
||||
expect(await fixedRate.getOPCCollector()).to.equal(contracts.opfCollectorAddress)
|
||||
})
|
||||
it('#getRouter - should get Router address', async () => {
|
||||
expect(await fixedRate.getRouter()).to.equal(contracts.routerAddress)
|
||||
@ -325,7 +325,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(result.marketFeeAvailable).to.equal('0.02') // formatted for baseToken decimals
|
||||
expect(result.oceanFeeAvailable).to.equal('0.02') // formatted for baseToken decimals
|
||||
expect(result.marketFeeCollector).to.equal(user3)
|
||||
expect(result.opfFee).to.equal('0.001')
|
||||
expect(result.opcFee).to.equal('0.001')
|
||||
})
|
||||
|
||||
it('#getAllowedSwapper- should return address(0) if not set, if exchangeOwner', async () => {
|
||||
@ -396,7 +396,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(result.oceanFeeAvailable).to.equal('0')
|
||||
// OPF collector got the fee
|
||||
expect(
|
||||
await daiContract.methods.balanceOf(await fixedRate.getOPFCollector()).call()
|
||||
await daiContract.methods.balanceOf(await fixedRate.getOPCCollector()).call()
|
||||
).to.equal(web3.utils.toWei('0.021'))
|
||||
})
|
||||
|
||||
@ -488,7 +488,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(await fixedRate.getExchangeOwner(exchangeId)).to.equal(exchangeOwner)
|
||||
})
|
||||
it('#getOPFCollector - should get OPF collector', async () => {
|
||||
expect(await fixedRate.getOPFCollector()).to.equal(contracts.opfCollectorAddress)
|
||||
expect(await fixedRate.getOPCCollector()).to.equal(contracts.opfCollectorAddress)
|
||||
})
|
||||
it('#getRouter - should get Router address', async () => {
|
||||
expect(await fixedRate.getRouter()).to.equal(contracts.routerAddress)
|
||||
@ -655,7 +655,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(result.marketFeeAvailable).to.equal('0.02') // formatted for baseToken decimals
|
||||
expect(result.oceanFeeAvailable).to.equal('0.02') // formatted for baseToken decimals
|
||||
expect(result.marketFeeCollector).to.equal(user3)
|
||||
expect(result.opfFee).to.equal('0.001')
|
||||
expect(result.opcFee).to.equal('0.001')
|
||||
})
|
||||
|
||||
it('#getAllowedSwapper- should return address(0) if not set, if exchangeOwner', async () => {
|
||||
@ -726,7 +726,7 @@ describe('Fixed Rate unit test', () => {
|
||||
expect(result.oceanFeeAvailable).to.equal('0')
|
||||
// OPF collector got the fee
|
||||
expect(
|
||||
await usdcContract.methods.balanceOf(await fixedRate.getOPFCollector()).call()
|
||||
await usdcContract.methods.balanceOf(await fixedRate.getOPCCollector()).call()
|
||||
).to.equal((0.021 * 1e6).toString())
|
||||
})
|
||||
|
||||
|
@ -390,6 +390,7 @@ describe('Datatoken', () => {
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
const providerFeeAmount = '0'
|
||||
const dtAmount = web3.utils.toWei('1')
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
@ -411,7 +412,8 @@ describe('Datatoken', () => {
|
||||
const order: OrderParams = {
|
||||
consumer: user1,
|
||||
serviceIndex: 1,
|
||||
_providerFees: providerFees
|
||||
_providerFees: providerFees,
|
||||
ammount: dtAmount
|
||||
}
|
||||
const buyFromDispenseTx = await datatoken.buyFromDispenserAndOrder(
|
||||
datatokenAddress,
|
||||
@ -426,6 +428,7 @@ describe('Datatoken', () => {
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
const providerFeeAmount = '0'
|
||||
const dtAmount = web3.utils.toWei('1')
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
@ -447,6 +450,7 @@ describe('Datatoken', () => {
|
||||
const order: OrderParams = {
|
||||
consumer: user1,
|
||||
serviceIndex: 1,
|
||||
ammount: dtAmount,
|
||||
_providerFees: providerFees
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,6 @@ describe('NFT', () => {
|
||||
it('#getTokenURI', async () => {
|
||||
const tokenURI = await nftDatatoken.getTokenURI(nftAddress, 1)
|
||||
assert(tokenURI === 'https://oceanprotocol.com/nft/')
|
||||
console.log(tokenURI)
|
||||
})
|
||||
|
||||
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user