aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/test
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-10-04 15:32:54 +0800
committerJacob Evans <jacob@dekz.net>2018-10-05 10:02:09 +0800
commit3e2fe40a11919f09f1f454c71f02aaa147b46b0c (patch)
tree0ff88e480944cfab0cefd211f5623f2870462351 /packages/utils/test
parent2a82ff48c061eacb3b6f9fb36eeae7f515b6d11d (diff)
downloaddexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar.gz
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar.bz2
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar.lz
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar.xz
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.tar.zst
dexon-sol-tools-3e2fe40a11919f09f1f454c71f02aaa147b46b0c.zip
Add eth_signTypedData support to our wallet subproviders
Diffstat (limited to 'packages/utils/test')
-rw-r--r--packages/utils/test/sign_typed_data_utils_test.ts45
1 files changed, 39 insertions, 6 deletions
diff --git a/packages/utils/test/sign_typed_data_utils_test.ts b/packages/utils/test/sign_typed_data_utils_test.ts
index b21ffefa0..e1cb4f6e1 100644
--- a/packages/utils/test/sign_typed_data_utils_test.ts
+++ b/packages/utils/test/sign_typed_data_utils_test.ts
@@ -7,8 +7,37 @@ const expect = chai.expect;
describe('signTypedDataUtils', () => {
describe('signTypedDataHash', () => {
- const signTypedDataHashHex = '0x55eaa6ec02f3224d30873577e9ddd069a288c16d6fb407210eecbc501fa76692';
- const signTypedData = {
+ const simpleSignTypedDataHashHex = '0xb460d69ca60383293877cd765c0f97bd832d66bca720f7e32222ce1118832493';
+ const simpleSignTypedData = {
+ types: {
+ EIP712Domain: [
+ {
+ name: 'name',
+ type: 'string',
+ },
+ ],
+ Test: [
+ {
+ name: 'testAddress',
+ type: 'address',
+ },
+ {
+ name: 'testNumber',
+ type: 'uint256',
+ },
+ ],
+ },
+ domain: {
+ name: 'Test',
+ },
+ message: {
+ testAddress: '0x0000000000000000000000000000000000000000',
+ testNumber: '12345',
+ },
+ primaryType: 'Test',
+ };
+ const orderSignTypedDataHashHex = '0x55eaa6ec02f3224d30873577e9ddd069a288c16d6fb407210eecbc501fa76692';
+ const orderSignTypedData = {
types: {
EIP712Domain: [
{
@@ -97,11 +126,15 @@ describe('signTypedDataUtils', () => {
},
primaryType: 'Order',
};
- it.only('creates a known hash of the sign typed data', () => {
- const hash = signTypedDataUtils.signTypedDataHash(signTypedData).toString('hex');
+ it('creates a hash of the test sign typed data', () => {
+ const hash = signTypedDataUtils.signTypedDataHash(simpleSignTypedData).toString('hex');
+ const hashHex = `0x${hash}`;
+ expect(hashHex).to.be.eq(simpleSignTypedDataHashHex);
+ });
+ it('creates a hash of the order sign typed data', () => {
+ const hash = signTypedDataUtils.signTypedDataHash(orderSignTypedData).toString('hex');
const hashHex = `0x${hash}`;
- expect(hashHex).to.be.eq(signTypedDataHashHex);
- console.log(hash);
+ expect(hashHex).to.be.eq(orderSignTypedDataHashHex);
});
});
});