diff --git a/src/tokens/Datatoken.ts b/src/tokens/Datatoken.ts index d5ce6f2e..86a910ed 100644 --- a/src/tokens/Datatoken.ts +++ b/src/tokens/Datatoken.ts @@ -847,13 +847,7 @@ export class Datatoken { address: string, consumer: string, serviceIndex: number, - providerFeeAddress: string, - providerFeeToken: string, - providerFeeAmount: string, - v: string, - r: string, - s: string, - providerDatas: string, + providerFees: ProviderFees, contractInstance?: Contract ): Promise { const dtContract = @@ -864,17 +858,7 @@ export class Datatoken { let estGas try { estGas = await dtContract.methods - .startOrder( - consumer, - serviceIndex, - providerFeeAddress, - providerFeeToken, - providerFeeAmount, - v, - r, - s, - providerDatas - ) + .startOrder(consumer, serviceIndex, providerFees) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -901,17 +885,9 @@ export class Datatoken { address: string, consumer: string, serviceIndex: number, - providerFeeAddress: string, - providerFeeToken: string, - providerFeeAmount: string, - v: string, - r: string, - s: string, - providerDatas: string + providerFees: ProviderFees ): Promise { const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress) - if (!providerFeeAddress) - providerFeeAddress = '0x0000000000000000000000000000000000000000' try { const estGas = await this.estGasStartOrder( @@ -919,28 +895,12 @@ export class Datatoken { address, consumer, serviceIndex, - providerFeeAddress, - providerFeeToken, - providerFeeAmount, - v, - r, - s, - providerDatas, + providerFees, dtContract ) const trxReceipt = await dtContract.methods - .startOrder( - consumer, - serviceIndex, - providerFeeAddress, - providerFeeToken, - providerFeeAmount, - v, - r, - s, - providerDatas - ) + .startOrder(consumer, serviceIndex, providerFees) .send({ from: address, gas: estGas + 1, diff --git a/test/unit/NftFactory.test.ts b/test/unit/NftFactory.test.ts index 0c49e7db..75343c25 100644 --- a/test/unit/NftFactory.test.ts +++ b/test/unit/NftFactory.test.ts @@ -377,15 +377,16 @@ describe('Nft Factory test', () => { expect(await dtContract2.methods.balanceOf(user2).call()).to.equal(dtAmount) 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 }, { t: 'address', v: consumeFeeToken }, - { t: 'uint256', v: web3.utils.toWei(consumeFeeAmount) } + { t: 'uint256', v: web3.utils.toWei(consumeFeeAmount) }, + { t: 'uint256', v: providerValidUntil } ) const { v, r, s } = await signHash(web3, message, consumeFeeAddress) - const providerValidUntil = '0' const providerFees: ProviderFees = { providerFeeAddress: consumeFeeAddress, providerFeeToken: consumeFeeToken, @@ -410,11 +411,11 @@ describe('Nft Factory test', () => { _providerFees: providerFees } ] - // console.log('orders', orders) - // await nftFactory.startMultipleTokenOrder(user2, orders) - // // we check user2 has no more DTs - // expect(await dtContract.methods.balanceOf(user2).call()).to.equal('0') - // expect(await dtContract2.methods.balanceOf(user2).call()).to.equal('0') + console.log('orders', orders) + await nftFactory.startMultipleTokenOrder(user2, orders) + // we check user2 has no more DTs + expect(await dtContract.methods.balanceOf(user2).call()).to.equal('0') + expect(await dtContract2.methods.balanceOf(user2).call()).to.equal('0') }) it('#checkDatatoken - should confirm if DT is from the factory', async () => { diff --git a/test/unit/pools/ssContracts/SideStaking.test.ts b/test/unit/pools/ssContracts/SideStaking.test.ts index ac9d1ce7..6210814b 100644 --- a/test/unit/pools/ssContracts/SideStaking.test.ts +++ b/test/unit/pools/ssContracts/SideStaking.test.ts @@ -202,7 +202,7 @@ describe('SideStaking unit test', () => { contracts.sideStakingAddress, erc20Token ) - ).to.equal(web3.utils.toWei('12000')) + ).to.equal(web3.utils.toWei('2000')) }) it('#getDatatokenCurrentCirculatingSupply - should get datatoken supply in circulation ', async () => { expect( @@ -235,7 +235,7 @@ describe('SideStaking unit test', () => { it('#getDatatokenBalance ', async () => { expect( await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token) - ).to.equal('988000') + ).to.equal('997999.9999999999') }) it('#getvestingAmount ', async () => { @@ -495,7 +495,7 @@ describe('SideStaking unit test', () => { it('#getDatatokenBalance ', async () => { expect( await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token) - ).to.equal('988000') + ).to.equal('997999.9999999999') }) it('#getvestingAmount ', async () => { diff --git a/test/unit/tokens/Datatoken.test.ts b/test/unit/tokens/Datatoken.test.ts index a80608a5..93f787a7 100644 --- a/test/unit/tokens/Datatoken.test.ts +++ b/test/unit/tokens/Datatoken.test.ts @@ -345,25 +345,31 @@ describe('Datatoken', () => { const providerData = JSON.stringify({ timeout: 0 }) const providerFeeToken = ZERO_ADDRESS const providerFeeAmount = '0' + const providerValidUntil = '0' const message = web3.utils.soliditySha3( { t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) }, { t: 'address', v: user3 }, { t: 'address', v: providerFeeToken }, - { t: 'uint256', v: providerFeeAmount } + { t: 'uint256', v: providerFeeAmount }, + { t: 'uint256', v: providerValidUntil } ) const { v, r, s } = await signHash(web3, message, user3) + const providerFees: ProviderFees = { + providerFeeAddress: user3, + providerFeeToken: providerFeeToken, + providerFeeAmount: providerFeeAmount, + v: v, + r: r, + s: s, + providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)), + validUntil: providerValidUntil + } const order = await datatoken.startOrder( datatokenAddress, user1, user2, 1, - user3, - providerFeeToken, - providerFeeAmount, - v, - r, - s, - web3.utils.toHex(web3.utils.asciiToHex(providerData)) + providerFees ) assert(order !== null)