Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

DutchAuctionWrapper is not decoding correctly #1814

Closed
fvictorio opened this issue May 14, 2019 · 0 comments · Fixed by #1815
Closed

DutchAuctionWrapper is not decoding correctly #1814

fvictorio opened this issue May 14, 2019 · 0 comments · Fixed by #1815
Assignees
Labels

Comments

@fvictorio
Copy link

Expected Behavior

Encoding some data with DutchAuctionWrapper.encodeDutchAuctionAssetData and then decoding it with DutchAuctionWrapper.decodeDutchAuctionAssetData should give back the same arguments that were used during the encoding.

Current Behavior

const data = DutchAuctionWrapper.encodeDutchAuctionAssetData(wethAssetData, new BigNumber('1557853498'), new BigNumber('1000000000000000000'))
// data is '0xf47261b00000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082000000000000000000000000000000000000000000000000000000005cdaf53a0000000000000000000000000000000000000000000000000de0b6b3a7640000'
const decoded = DutchAuctionWrapper.decodeDutchAuctionData(data)
// decoded is {
//    assetData: { assetProxyId: '0xf47261b0', tokenAddress: '0x0b1ba0af832d7c05fd64161e0db78e85978e8082' },
//    beginTimeSeconds: 91662660760,
//    beginAmount: 4722366482869645213696
// }

Notice that beginTimeSeconds is 1557853498 (the original argument) interpreted as hex:

> 0x1557853498
91662660760

The same happens with beginAmount.

Possible Solution

I think the problem might be here:

const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);

After getting the decoded data, a BigNumber is created by prepending 0x to it.

Your Environment

Package Version
0x.js 6.0.7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants