diff options
author | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-10-24 00:08:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 00:08:16 +0800 |
commit | 1f0c7f8fbeba90ac1f65c57ff58782051c751b3d (patch) | |
tree | c5239e139729d6e4e63454c24679e8559f7c7560 /packages/order-utils | |
parent | 1ba207f1fef4338682b4cc7e45af8c073e63d263 (diff) | |
download | dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar.gz dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar.bz2 dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar.lz dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar.xz dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.tar.zst dexon-sol-tools-1f0c7f8fbeba90ac1f65c57ff58782051c751b3d.zip |
feat(order_utils.py): ERC20 asset data encoding and decoding
In addition to the ERC20 codec, also:
Stopped ignoring type errors on 3rd party imports, by including
interface stubs for them;
Removed the unimplemented signature-utils module, which was just a
stand-in when the python project support was first put in place.
https://github.com/0xProject/0x-monorepo/pull/1144
Diffstat (limited to 'packages/order-utils')
-rw-r--r-- | packages/order-utils/test/asset_data_utils_test.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/order-utils/test/asset_data_utils_test.ts b/packages/order-utils/test/asset_data_utils_test.ts new file mode 100644 index 000000000..f8b850604 --- /dev/null +++ b/packages/order-utils/test/asset_data_utils_test.ts @@ -0,0 +1,31 @@ +import * as chai from 'chai'; + +import { ERC20AssetData } from '@0x/types'; + +import { assetDataUtils } from '../src/asset_data_utils'; + +import { chaiSetup } from './utils/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +const KNOWN_ENCODINGS = [ + { + address: '0x1dc4c1cefef38a777b15aa20260a54e584b16c48', + assetData: '0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48', + }, +]; + +const ERC20_ASSET_PROXY_ID = '0xf47261b0'; + +describe('assetDataUtils', () => { + it('should encode', () => { + const assetData = assetDataUtils.encodeERC20AssetData(KNOWN_ENCODINGS[0].address); + expect(assetData).to.equal(KNOWN_ENCODINGS[0].assetData); + }); + it('should decode', () => { + const assetData: ERC20AssetData = assetDataUtils.decodeERC20AssetData(KNOWN_ENCODINGS[0].assetData); + expect(assetData.tokenAddress).to.equal(KNOWN_ENCODINGS[0].address); + expect(assetData.assetProxyId).to.equal(ERC20_ASSET_PROXY_ID); + }); +}); |