aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
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/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
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/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts')
-rw-r--r--packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
index f2bdda3cd..61dcbf6da 100644
--- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
+++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
@@ -47,6 +47,13 @@ describe('MnemonicWalletSubprovider', () => {
const txHex = await subprovider.signTransactionAsync(txData);
expect(txHex).to.be.equal(fixtureData.TX_DATA_ACCOUNT_1_SIGNED_RESULT);
});
+ it('signs an EIP712 sign typed data message', async () => {
+ const signature = await subprovider.signTypedDataAsync(
+ fixtureData.TEST_RPC_ACCOUNT_0,
+ fixtureData.EIP712_TEST_TYPED_DATA,
+ );
+ expect(signature).to.be.equal(fixtureData.EIP712_TEST_TYPED_DATA_SIGNED_RESULT);
+ });
});
describe('failure cases', () => {
it('throws an error if address is invalid ', async () => {
@@ -118,6 +125,20 @@ describe('MnemonicWalletSubprovider', () => {
});
provider.sendAsync(payload, callback);
});
+ it('signs an EIP712 sign typed data message with eth_signTypedData', (done: DoneCallback) => {
+ const payload = {
+ jsonrpc: '2.0',
+ method: 'eth_signTypedData',
+ params: [fixtureData.TEST_RPC_ACCOUNT_0, fixtureData.EIP712_TEST_TYPED_DATA],
+ id: 1,
+ };
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
+ expect(err).to.be.a('null');
+ expect(response.result).to.be.equal(fixtureData.EIP712_TEST_TYPED_DATA_SIGNED_RESULT);
+ done();
+ });
+ provider.sendAsync(payload, callback);
+ });
});
describe('failure cases', () => {
it('should throw if `data` param not hex when calling eth_sign', (done: DoneCallback) => {