mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix start order and multi order
This commit is contained in:
parent
6c9746a8ad
commit
8c9e21f309
@ -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<any> {
|
||||
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<TransactionReceipt> {
|
||||
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,
|
||||
|
@ -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 () => {
|
||||
|
@ -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 () => {
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user