Lines 31-100javascript
31test('should create a Wallet from mnemonic index 1', () => {
32 const expectedWalletAddress = "0x471E2Aa03dbDc153a92b89Fb10B67020b729BD98";
33 const mnemonic = "remain sorry remember trick purse also roast kidney history dragon fatigue chuckle";
34 const wallet = Wallet.fromMnemonic(mnemonic, null, {
35 path: `${thetajs.constants.DerivationPaths.Theta}1`
38 expect(wallet.address).toBe(expectedWalletAddress);
41test('should create a Wallet from private key', () => {
42 const expectedWalletAddress = "0x95944D0F9C86794284ABc375616C83B0E6A1A8B7";
43 const privateKey = "0x19f66b5f75f0cf6fe4fbbcca24aba2031031affef8b596b922b9dfd669f8f5ae";
44 const wallet = new Wallet(privateKey);
46 expect(wallet.address).toBe(expectedWalletAddress);
49test('should encrypt a Wallet to json with password qwertyuiop', async () => {
50 const privateKey = "0x19f66b5f75f0cf6fe4fbbcca24aba2031031affef8b596b922b9dfd669f8f5ae";
51 const password = "qwertyuiop";
52 const wallet = new Wallet(privateKey);
53 const json = await wallet.encryptToJson(password);
55 expect(json).not.toBe(null);
58test('should encrypt then decrypt a Wallet to json with password qwertyuiop', async () => {
59 const privateKey = "0x19f66b5f75f0cf6fe4fbbcca24aba2031031affef8b596b922b9dfd669f8f5ae";
60 const password = "qwertyuiop";
61 const wallet = new Wallet(privateKey);
62 const json = await wallet.encryptToJson(password);
63 const decryptedWallet = Wallet.fromEncryptedJson(json, password);
65 expect(decryptedWallet.getAddress()).toBe(wallet.getAddress());
68test('should decrypt a Wallet with password qwertyuiop', async () => {
69 const expectedWalletAddress = "0x95944D0F9C86794284ABc375616C83B0E6A1A8B7";
70 const json = "{\"version\":3,\"id\":\"65da41e2-4c0a-487a-b2a4-2e5785786917\",\"address\":\"95944d0f9c86794284abc375616c83b0e6a1a8b7\",\"crypto\":{\"ciphertext\":\"f50a7176a4b6fb2dd402a3cedb9a9b7660566e9f2d6c4a800c7f20fb061aecb2\",\"cipherparams\":{\"iv\":\"75f7c49fabc77fbc78177e86cc7c2ff2\"},\"cipher\":\"aes-128-ctr\",\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"salt\":\"68798f658e6adeeb2de05aaeaa9699c10281f9837966824f4d34a4b53bb4a7d3\",\"n\":8192,\"r\":8,\"p\":1},\"mac\":\"d46c1baa5228a8f31343f16bcccdb70adabbbd2b8577605c56e14dbc093f212c\"}}"
71 const password = "qwertyuiop";
72 const decryptedWallet = Wallet.fromEncryptedJson(json, password);
74 expect(decryptedWallet.address).toBe(expectedWalletAddress);
77test('should decrypt a Wallet with password qwertyuiop with a provider', async () => {
78 const expectedWalletAddress = "0x95944D0F9C86794284ABc375616C83B0E6A1A8B7";
79 const json = "{\"version\":3,\"id\":\"65da41e2-4c0a-487a-b2a4-2e5785786917\",\"address\":\"95944d0f9c86794284abc375616c83b0e6a1a8b7\",\"crypto\":{\"ciphertext\":\"f50a7176a4b6fb2dd402a3cedb9a9b7660566e9f2d6c4a800c7f20fb061aecb2\",\"cipherparams\":{\"iv\":\"75f7c49fabc77fbc78177e86cc7c2ff2\"},\"cipher\":\"aes-128-ctr\",\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"salt\":\"68798f658e6adeeb2de05aaeaa9699c10281f9837966824f4d34a4b53bb4a7d3\",\"n\":8192,\"r\":8,\"p\":1},\"mac\":\"d46c1baa5228a8f31343f16bcccdb70adabbbd2b8577605c56e14dbc093f212c\"}}"
80 const password = "qwertyuiop";
81 const provider = new HttpProvider(ChainIds.Mainnet);
82 const decryptedWallet = Wallet.fromEncryptedJson(json, password, provider);
84 expect(decryptedWallet.address).toBe(expectedWalletAddress);
85 expect(decryptedWallet.provider).not.toBe(null);
88test('should sign message "hello world"', () => {
89 const expectedSignature = "0xddd0a7290af9526056b4e35a077b9a11b513aa0028ec6c9880948544508f3c63265e99e47ad31bb2cab9646c504576b3abc6939a1710afc08cbf3034d73214b81c";
90 const privateKey = "0x0123456789012345678901234567890123456789012345678901234567890123";
91 const wallet = new Wallet(privateKey);
92 const signature = wallet.signMessage('hello world');
94 expect(signature).toBe(expectedSignature);
97test('should sign typed date', () => {
98 const expectedSignature = "0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c";
99 const privateKey = "0xc85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4";
100 const wallet = new Wallet(privateKey);