From 2d05c39d61a7613126586ec35a323fc95efb0adf Mon Sep 17 00:00:00 2001 From: wabiwabo <68363074+wabicai@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:33:53 +0800 Subject: [PATCH] fix: optimize hardware example (#392) * fix: optimize hardware example * fix: fix passphrases & mnemonicAddress * fix: remove source map loader * fix: eslint fix --- .eslintrc | 5 +- .husky/pre-commit | 3 + .../addressTest/MnemonicAddressValidation.tsx | 4 ++ .../src/testTools/addressTest/baseParams.ts | 4 ++ .../data/count12_one/passphrase_1.ts | 10 +++ .../data/count12_one/passphrase_2.ts | 10 +++ .../data/count12_one/passphrase_empty.ts | 10 +++ .../data/count12_three/passphrase12_1.ts | 10 +++ .../data/count12_three/passphrase12_2.ts | 10 +++ .../data/count12_three/passphrase12_empty.ts | 10 +++ .../data/count12_two/passphrase_1.ts | 10 +++ .../data/count12_two/passphrase_2.ts | 10 +++ .../data/count12_two/passphrase_empty.ts | 10 +++ .../data/count18_one/passphrase_1.ts | 10 +++ .../data/count18_one/passphrase_2.ts | 10 +++ .../data/count18_one/passphrase_empty.ts | 10 +++ .../data/count18_three/passphrase_1.ts | 10 +++ .../data/count18_three/passphrase_2.ts | 10 +++ .../data/count18_three/passphrase_empty.ts | 10 +++ .../data/count18_two/passphrase_1.ts | 10 +++ .../data/count18_two/passphrase_2.ts | 10 +++ .../data/count18_two/passphrase_empty.ts | 10 +++ .../data/count24_one/passphrase_1.ts | 10 +++ .../data/count24_one/passphrase_2.ts | 10 +++ .../data/count24_one/passphrase_empty.ts | 10 +++ .../data/count24_three/passphrase_1.ts | 10 +++ .../data/count24_three/passphrase_2.ts | 10 +++ .../data/count24_three/passphrase_empty.ts | 10 +++ .../data/count24_two/passphrase_1.ts | 10 +++ .../data/count24_two/passphrase_2.ts | 10 +++ .../data/count24_two/passphrase_empty.ts | 10 +++ .../src/testTools/addressTest/data/index.ts | 1 - .../src/testTools/addressTest/data/utils.ts | 7 ++ .../expo-example/webpack.config.js | 12 +++- packages/core/__tests__/benfen.test.ts | 72 ++++++++++++++++--- ...test.js => checkBootloaderReleast.test.ts} | 6 +- tsconfig.json | 16 ++--- 37 files changed, 370 insertions(+), 30 deletions(-) rename packages/core/__tests__/{checkBootloaderReleast.test.js => checkBootloaderReleast.test.ts} (94%) diff --git a/.eslintrc b/.eslintrc index f3faba36d..4dc931867 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,9 @@ { - "extends": [ - "wesbos/typescript" - ], + "extends": ["wesbos/typescript"], "env": { "jest": true }, + "root": true, "plugins": ["jest"], "rules": { "no-console": "off", diff --git a/.husky/pre-commit b/.husky/pre-commit index a686a5aff..92c76aae0 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,7 @@ +# Run tests +yarn test + # Run lint:fix yarn lint:staged diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/MnemonicAddressValidation.tsx b/packages/connect-examples/expo-example/src/testTools/addressTest/MnemonicAddressValidation.tsx index 953728c2f..86eba2a98 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/MnemonicAddressValidation.tsx +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/MnemonicAddressValidation.tsx @@ -144,6 +144,10 @@ const testCase: MnemonicAddressTestCase = { hrp: 'osmosis', }, }, + { + id: 'benfenGetaddress', + method: 'benfenGetaddress', + }, ], }; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/baseParams.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/baseParams.ts index d6cc79f47..64787306a 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/baseParams.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/baseParams.ts @@ -128,4 +128,8 @@ export const baseParams = { path: `m/44'/195'/0'/0/${INDEX_MARK}`, showOnOneKey: false, }, + benfenGetAddress: { + path: `m/44'/728'/${INDEX_MARK}'/0'/0'`, + showOnOneKey: false, + }, }; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_1.ts index 510bb5b16..29c180dd6 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_1.ts @@ -562,5 +562,15 @@ export default { '2147483647': 'TBnXbdxn35DuECbDdr2uppdTYDHJLSGA3h', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCdd98e1e3b1d9e019c82374bc82bc6b5d653d0bcbb1eb1bfccd8d25ddd6f83a5db214', + '1': 'BFC92f4902024981228033ed15b26cdc6930fcf319c14ad0e95edd25bfde0d172d70569', + '25': 'BFC40c1e4c622c3356845bb9f2eee09aefb5261ebfc1e16fa7590cb1c1057b6582bcb41', + '2147483646': 'BFCab460b81e58239d806fb671bc7700e7142b61c6500fccae190e8dc8174587dac197f', + '2147483647': 'BFC5ff2b3a34047f48caad8962a5a1baf237953db19e4b6c6867fe6994c078d8443e735', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_2.ts index 1e7efbada..5c469fbba 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TTpd2BUBaCuMqHtBhTCJe9dgXVnHBtbqXf', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCf0544bfaea4439a347834b19f513ba833083715d1904e4ddd37f7af8b1736cd50a0a', + '1': 'BFCe6d2d32fc97c3bede6215d069e6fd33fe11c1dbc7894727eff9a18516480dfbddcf2', + '25': 'BFCa9e0144e421bea592796f99e34e3edb555bdc5f3848870cc4f05cc0fca8768b1f1ac', + '2147483646': 'BFC87c31999cb11b361372198e60e5d39509767d48c79db65efacb805b83822848cf21d', + '2147483647': 'BFCbfccaaa7c3e488af03164d2d7d1a20cc2ee7a008505d36bd60b74ad70c4588569018', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_empty.ts index 6f88aad6b..2c7a68590 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_one/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TUKjDFGmLHw6NLbYuy4bpt2d6MBpKYtiYR', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC1c5404fc4c215d1f9d0630c61691b588bbd88fd4a2bcdc2fd74689720bb6cfb84820', + '1': 'BFCff2d2498ce365a4ba6b5e90edf54bb174798540493c15af1910375d958f1ddf8f3f4', + '25': 'BFC7774cf91db3f17c19ccb8783654191c2519a7041057ca5c5aaa192c715a3018dbec3', + '2147483646': 'BFCf0960edd2ef00bd36e6b4190d1cd8e98ad4a37a90fe1ec7ef8964b223cda3a6d50fd', + '2147483647': 'BFC28834bfc0be1b5eed1583b814fb4a698e56850ce3a603eafbd91c57542b6f17ec0f6', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_1.ts index b2582a307..baaf00f33 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_1.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TLJQqC8iAMVXsCDZxqSraTTFz7KU9CvfTx', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC5996d4c6a609a4046a55de8cf69adc17b3d8b34eea8fe908a684df69f8d238c4c57f', + '1': 'BFCfd971b4be078ba5a8fbdfedbd9683dbc637ce70f90b29c05510b90cc12ba71174654', + '21234567': 'BFC0751e3c028b24b6f0468ec1d4a6ca8faac3dfe902990eab63b2554bfa4a21efe06e6', + '2147483646': 'BFC451eb6959283fb3e7e1815e3e82d12c54029f8894129c15b9643fc3ff17d63144e58', + '2147483647': 'BFC6552ce65776890a22cd85d878a18dc3bfbcd0475433d63fe4f6e48ab3d62144dd16a', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_2.ts index 146700b48..c3b5643a9 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_2.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TS8C5VCCCR83yqRvrLx2sj23k9EHsnbnC6', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCc3f6d4edd2c00125fb4aeb58c54d1b06626b685bf1be2a16a600e29713a2f67ea7e8', + '1': 'BFCc1f9138bdc1d03cc47ab9cc909c6ec704b09444ee7610dedd0ed0dd7a39f4869596b', + '21234567': 'BFCa16113164db28e788422fb265dc08ae0a30b647602714f59da188c024a392d396fe6', + '2147483646': 'BFC8ff609bf6e3b87965f4d2e8dd3f57d19d4c65ad71133c4e7a8348bade49c0f695831', + '2147483647': 'BFC5b8bdd12050906421fde23d116e702f0dbd6362c92f4b0e77a3b227fba2ac2475439', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_empty.ts index 57372d5ef..97868bdba 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_three/passphrase12_empty.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TZGDfP18VzGXFseZzF4LAgKrEXXBvhmbXb', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC9a7a4db1fa7347ad924fdce215badaef6f0d03717a3c0dc68e85a006fb137aea325d', + '1': 'BFC97c73d847bc5d544988e5f5667d86d42660111f1ade5606b2453d19f57fbda1142b7', + '21234567': 'BFC5fad91679c71ef7e4514164bef941bfc042034b479c980cf480eb71f3edef66c5d36', + '2147483646': 'BFC1208c96e3a449aa4c2d704152d08df20b75d6e1c27750f4d9dc69dc1d7298b18ffbf', + '2147483647': 'BFCa893f9639eb206c4631e2edbcb23e24a1d3cf0ff5f9391c821c59e99129262a79052', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_1.ts index ce35e7a5d..3eb592a8f 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TPu6YTHSMkUtLvh1Rs6k47NtTx1c1JyLhY', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC54b56e9154ddfef6b5c24cd3dc6c27d47e4ca0009aff7539de26e9a29b39082bdf53', + '1': 'BFCd7390848080ed9eb8abf26b8a7fc1642362747e44dbf0ec7ba21b8a6a81ab772baaf', + '35': 'BFCc5bb39f5af2d76c1a856fbab810f47fd8099db3c038e0ab8cf8e27bb1a4212bce39d', + '2147483646': 'BFCa49bf90d5deaf2376e80540029f27107fae8435f982ac7c2e0e054df4b1321c70a2f', + '2147483647': 'BFC914ac4146474c24667b2ce5fc6d32e3b81903e0554244c84fcac804531c63cb61d2b', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_2.ts index cab51a785..f9e3d2659 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TEePSjxw7nRVSK1h7UomM3EemD2XDNtrWu', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCa32b60d9a0b34ef459fa7793ab9f5aed9612938685125e35a9108edaa407079f5705', + '1': 'BFC4e45a44f602b492fe9911d05a244005f552e453c3ae23662cec070c2d95d10a9cad0', + '35': 'BFC65b4573af540203ec787e89b83f9109967087ebef6fa0b7dcf09aa76db30e3d4d8cc', + '2147483646': 'BFC8de6066df665b2db260a04f9a1e62a8cdc13d1adb726da3f5367f02d1dde1c8e053c', + '2147483647': 'BFCe1c2bbeb28573fcbe001d1406395eda3b942d51bcc3f914b8272f120e58388b0dd50', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_empty.ts index 3f7cf7562..631d1b407 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count12_two/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TTXTCwxbw4VJ65Exq9mWsARPP5FMmnuRGD', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC1541833f3508db54b734dadffffe5008d55bc970ed7c3e07d1927bec53fd08b58a62', + '1': 'BFC8408d30e070805c12cd7bb6e4576786f4220fa36e9e46442a00f5b9cabb286d0ae37', + '35': 'BFCab52788ef7ea21c51ff832d84eba25170d1876a23950d3cf744a4e02c406085b5736', + '2147483646': 'BFCc242e3886a5a7914e966fbe228b27fd4619016d27c2836adf9ff5865919cb35f7ea9', + '2147483647': 'BFCfc09750a594f84e6added92ba364e3ff0f52a1fb3533313f6e02870c34015c3ae9f0', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_1.ts index 4274b00e3..1f2090689 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_1.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TAaHzHQ54vL3L1TeGNpRxNZiH5KJZRtPUn', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCee6a5283888f7f7c46e358dbd1fe92a8a02b1e8a21707628c4dd70bd38555e1a7897', + '1': 'BFC124d4767cc262b4d0e65ddc8e4eca0e0d7d17757d7410f1356caa14ced4c38d3c685', + '100': 'BFCed5c785d7acc5deae1fc13891d179439f507cbd273e9c1a449dc7d842fa17db8b6fa', + '2147483646': 'BFC6e40b1acb326f3940feba6bb4a9bc4dda53f3d2baee7c4766b9498b5794d457af99e', + '2147483647': 'BFCc566b7a58c668e33cde4e5955758b34f2a11333062224fb7f8d4e9c11d365d768548', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_2.ts index 103b787e1..9622e941b 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_2.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TP3cQWgbq2kopNkXHjHDvJXGo6a15j3zmi', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC5a6464236476bf2bedd6eba0629d83aa0f7c8ce74e51733a8b1f20081fc279ef66b0', + '1': 'BFC8c9f9d4cf8c9828379c0744d68b0d3478b17989e42d9d80aab0bd0a66f4f93dda2b8', + '100': 'BFCfca709d9c44629f4a9a1b6b5c9458b3735c4fc8b872ff36a6f32325550725aac4a6a', + '2147483646': 'BFCd136df3783e0902d4673bcaf51911eb326be16cde4941e624da998d75f72641d0882', + '2147483647': 'BFC702b092829741fd123e5054168f66ca53b19aa6ed626e84b3d3f1489889b98fcf33e', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_empty.ts index e58317425..dfbc9b037 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_one/passphrase_empty.ts @@ -563,5 +563,15 @@ export default { '2147483647': 'TXY2yvcT2aJHiyMk5iyjp2UrvcbtDLDZ8w', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC83f730a437993aeef2583c40590f7fed5e7a0e12b4ff5fdda7a45573a67fc6c61a67', + '1': 'BFC73778847fba09d97951d1f7abe30c134d17c53eac8a0cd3db9ba008a39c2c45e8c84', + '100': 'BFCe3404af3aa3a5d3985cf544f8795c817dafe92e3036f19deae2aa7402e1b33ec58f8', + '2147483646': 'BFCac0d5396b5bfeff5477a74dbfe1ef56c74487801adedf05d94a05530c2a45f5a3eda', + '2147483647': 'BFCff18b9e9a501e044569d86db9bfed749c6ebd776d23b3d8790039eee4a60aca1f946', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_1.ts index 5ed3860ce..e0367585d 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TBzaCCL1tFkncWwMdvgiC9R1V76VW59pEB', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC40f466801bd4c9e98e46898c1ae72474fa12ba931ab65c6628515c35873427620469', + '1': 'BFC01aae53e15ee0b50510ba2e1e73aa41f44893d9a0825b67c25444524c1ced8ff0655', + '30': 'BFCe2c14591424f3295f38f4479ceb976b815a4f54e29551b80d0c126b66ef1b8f964dc', + '2147483646': 'BFC5e9e1b64c4b1b95c9dc01ed72fb350fcbf4c30b90262bf3a06d5adbb308c7e386779', + '2147483647': 'BFC6cc46b63073b89b96499a43c3b78826260ea41df042ecd3101f4240e7193fea42fc5', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_2.ts index 83c7c3d2e..d8efc3410 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TBuVXCRn5o2aKHr5TdMvF9FW2vPtuh5Zt1', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC69cb6a70063f981a57103c76a423b8f4fecc37bf56c813b16a88acb4bb2257b8a0e0', + '1': 'BFCf17e507399aff90e272df0f2a7cf7be774bc4e1c35f4459696061ea4e1f13c8dd0b8', + '30': 'BFC2b7b8a95b25dd93002aa951b3b3446d257c7edba2ba868025ec3630eaba4146b3f01', + '2147483646': 'BFC61825bd07fdf7818e07b8fba1e42323a0582e16d7b4b1b9d15bcdb0ecd8638c8a6b9', + '2147483647': 'BFCed94a37303493de54a50f3923b7e7bdc393fdeb010f9321b4fd84ca0222a5c72cdcf', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_empty.ts index 693bc313a..8575b8c25 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_three/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TRHTunHUuBLnu9VQWmjmAWVaYkX2urbxSm', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC30f7e71df92d63d524e98aea15a106a63f5f18223776a1e810b0fb4327d99b8dd101', + '1': 'BFC0ed930f0c49924d6e4f62880a474f03f3bd4d60a20424f5b6e80fd0d387018b22894', + '30': 'BFCada2b8aec4f0f561bc86b5646bd65d80444dc25538eb8d4c93ca4e6bc1d41ac96865', + '2147483646': 'BFC085052bc29615c966efbca4f04e7b8af6419558f9af817af186a2ddfe3bbd37fd46b', + '2147483647': 'BFC29185aca50b33e1f65b562df6892f2c2c2b85ded61bf8cdba13d05d829bf521f2719', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_1.ts index 916b5dfe5..9ec0ab59f 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TUDLQpX75UCku4vCAYccj29GC563dH33bZ', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC6e8c7669699bbafdaeec84c45d67c7609370b451b1ffd3a558b365afa9993ac710fd', + '1': 'BFC647a389509d9d5dda09c4589b1fcb1c27939107f205e6d47fddf01604c779bd697c5', + '30': 'BFC065be1986b4f63876ca30a7daedf53fcea31e9716e86b455789199ef1ab0c46c908f', + '2147483646': 'BFC82327c80577de309ad9db82fe8fef7ed63fa4251c6748ce322051df9214fa7b9f86d', + '2147483647': 'BFC4ab98edf626afd04d154cd96bf21b0dd94dd9427cc77ffa1af15f09e6e56727c2e6e', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_2.ts index 4ee46487e..90d0d9bce 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TCMV5P7heGwMHpNVkog4Lp2nuAaLLaWN7m', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCa75c4c5ddcd017834182027275c26fca46352656c90728420d28572c95230a4ca657', + '1': 'BFC9b4847215d382925f86f3b7267938d6c8b758cbc88b2508863ac15bcfb1af7697dcf', + '30': 'BFCa01b41114a135a7052e3b864f74e1a2adf83cc20ce07ab5a2cc0e966a0d746687bd3', + '2147483646': 'BFC54bc2f7d6d9786700bd2f70aeb2124cb4fae317a4753e191a55a72678995b728edc9', + '2147483647': 'BFC7331a87c101f58a34570795119d21d12458fe41dd33be20c12568c0fcaa1cf14fc60', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_empty.ts index 6cc871d8d..819ec9e32 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count18_two/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'THdRd5GWRMpf32ZnYKmPo1s2yJMvxPBmF9', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC97c42f5a908e5c83400e4ff8773eb51ac04429cad5ea9f9b120da1b5d53292745bf2', + '1': 'BFC5f6bc37eef82eb31bfd4034e39951db4cf88d6473767f75a4e0c72cc6ed7477e79d1', + '30': 'BFCf4d6422ef88f266b16167f701ebcef3b585f864d051e1717a4e10eada45a85158a1e', + '2147483646': 'BFC2647af48534dc90414821a9966b82349b3efe3adbf4f4e32ad9942da0750dc9b066c', + '2147483647': 'BFC77f256580e81bf98f4bc922e97db12c2d7a236d659029a8e82a27525ea400988f458', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_1.ts index a7f4af437..3ca45d5f0 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TSwbjougp8YbQj68kNFRdtnsXcwmc3GZmp', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCf7180c8ab5c320dfce5d3632782035120af4f841071acccebb38e35bbf8c583f5ca6', + '1': 'BFCee22a51a0c4ee53c595b198baba1338e56035873eb9459db39dc26ba4fd0de8877c7', + '10': 'BFC24c71ca4ad2263f0be2ae79c64992536c47bfb0198126df543f1870b7a4f93845c2d', + '2147483646': 'BFCb1a7b539b6f92be4b0f6905a63bcf3d6ab84b244503528cfe33cbf164bcc7fe646f3', + '2147483647': 'BFCf3c6f566a5fc4bde7674bd9cbfd6cdd5c7e199fa1cbe65e461a21ef6a68df76a3ff5', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_2.ts index 4b84c1d8b..9061c2bca 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TS9XAR3tKoiGMdDJm6ijVCgdvt6SmTLbJY', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCcd484bb0ba4124e9807036bd75d061747fdf3ae354c88a5ca5e376d41c0076a0fc4b', + '1': 'BFC7b7e6512f23b452be033c83ddc5e117bebf7d68d65b69dce9ddeba6eba24edfb1ded', + '10': 'BFCb129cc97a1064ce0f12074af5b4bb5ff372e005e0c5e8cb2aa15da326b3d3af8ed59', + '2147483646': 'BFC88fbab6fad925c6f49ff010d8108849f4fa8d5fabb9d8a58188dbc08fdd0a7019bc8', + '2147483647': 'BFC07d877cc034c72b678d8cb9d0f8221138b70435e6ef31bc50610e478dcd41216fcbc', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_empty.ts index 2d1323696..eb921506a 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_one/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TWFjr4of4Zc9QdFjNiksWpmTkfb3f7wSvF', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC3b9ac1cd4a3b45b12ef6f9f1d8725f64ce816cd077593891bc9da30db09212d09fbf', + '1': 'BFC8be3cfc82fb0b818dfb7a276d30436e30ae76f600b9664ad09deb767bf6fbefa9420', + '10': 'BFC6aed3d7f0377d7f644e8ef59897c7e805ac4f5012ac064e814c85b30f6a6d1c2417d', + '2147483646': 'BFC9146b417b0a161b53ccb36597b9319af663860a0c5f2fbdc6b773cc1d545d06cfd36', + '2147483647': 'BFC0fff21df0a8cfc8314128c751ba14aa24674837dd3e929946cae1f4a3aaa14592036', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_1.ts index 47b39fc30..a16803a24 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TZBvNVzxT5vVH9HPMYS9XBBTaH8qJZnDv1', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCd249c6e9952b34e340790036c5a88cbe20a073ad0a30b2ff0cec1454cb50ddfe448d', + '1': 'BFCbc42e9b7df88ad8f21348ca3fb4e3331a8cd1a106cf2a25e3661e96a27b67f53cf9e', + '50': 'BFCdfe80d60fd9ac32af434e2e189533048c01dbf548a388ece8d6747f0a89c1cc786c4', + '2147483646': 'BFC0107f5de1176bb285962dd7fe9972c4fb76a81de38f3ed008dfaf4815f4a711133f2', + '2147483647': 'BFC46b509433b912ad94b3de282ff7f125a490eebe657ddb8cc431ae528d69a25e39472', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_2.ts index df9041baf..3056badf5 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TLLpBsrj1uuLtQZTPWfqBm2zLX5Nqt3rkK', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC3292ff0343a6f2e4a7a250192614ff3cb873c53304f96641b7f00fea93324b0d8849', + '1': 'BFC1a04bc27d5aa745d777fe296f292735b18b23893c1c70028b492e70efc68aeb84a44', + '50': 'BFCdea5cb9a0bb5a8397072c188b7cdeb5d62795a6424e8b95f64b0f4a8320925fdb587', + '2147483646': 'BFCe2ea2aa744d5cc9ba7bef4753348fb70058674155914ebace7fbf8795b94d60fd227', + '2147483647': 'BFC87d56413307c7c309573ea8b49ad9e2bfbd27d456c4e52eba3859f8af2c994fe5388', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_empty.ts index 01aa46da5..8f49158ba 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_three/passphrase_empty.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TFdzHfhH8iFpVn3AoLT9RS87wvCbjCqz5W', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC77acda4bbe8920d0f9e5e9b4c4a4006e57f1fd84c023d69fcdb64cafdb585324fbf0', + '1': 'BFCf6398a5695e85fa2e8192e945773d365932359b97e888e2b76cb1faa329459831806', + '50': 'BFC26b8587918330db992a94e317e69bd22d73625e30aae947255a9484ab946a1cb9606', + '2147483646': 'BFC33c99c276e8c835409e82f62f808efd87e367be57029eb4d56f00836e0bf015d9abc', + '2147483647': 'BFC630e7bc49aef80e4700a8a8dd0fb3e5ee8a23f36c66f6031b5e8df5a847df0e16536', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_1.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_1.ts index 866fb8656..beb01775a 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_1.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_1.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TKZCWFt83akRsGXhjFpLyaVSAMBxqxF3Yh', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCd5cc46c64f7e8bbb9d50e99b0dd40bda3cd8490337bb80c319126ada717b705d95b8', + '1': 'BFCd9eff94a747c0b1bce4f13c6fb24dfa0c0d433c6f102f10dc4d796a71afae446606c', + '30': 'BFC16a3b29584c406323a1398b4455f1f237f59e35c3f7ff446231bf9cb398809f3470b', + '2147483646': 'BFCa205e7a1ea51ee7b84ba9e012486be5e126c75f26112f8ed0f25e3222c0054782e3b', + '2147483647': 'BFC837db56a0b9d9474074e28cc674d47c9f364c5aab53a6c1efe203dd45d64ad086aac', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_2.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_2.ts index 36fd02263..7a0d26067 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_2.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_2.ts @@ -561,5 +561,15 @@ export default { '2147483647': 'TSq7txCpfWUD5jUcrq2y94MrbvGZBedeRE', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFCf534f5b046394ef3f3729143b3ed4d2fe707a453b25f24fc57b11232778c5ce838fe', + '1': 'BFCccc3b2219f21a38d3b89a2e4c60fdfdbfb01ae9d6dff5d48613d0071748eb5df8d37', + '30': 'BFCf0d2047827f39c8ed3b455a241a23fa37b342e1511a81d2359f54c60bac12717155d', + '2147483646': 'BFCbc239c2e55318a9a29ce14fc37060a3fcd31bb382dbd329179762e13b141ea5ddf76', + '2147483647': 'BFC369ebea105e90abe002403854095bccda6032d95a62a4f0cbee647fb96b072b90344', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_empty.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_empty.ts index 45430ebf9..a59f2d83e 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_empty.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/count24_two/passphrase_empty.ts @@ -560,5 +560,15 @@ export default { '2147483647': 'TMW7V8hWGYHo76k3MkkCwV3PXzmPV46FDE', }, }, + { + method: 'benfenGetAddress', + expectedAddress: { + '0': 'BFC38eea6f527d9c7af1fc6b83401a07eb31d7336751b1644ed708f002140e94d3bb9c6', + '1': 'BFC30f4eccaa5fa0a12708a2d6bf6879b35ee9b42c5e209c6219f41f6fb089685eb3b26', + '30': 'BFCc88c66b96afc1cdd42bec62d0765c53cc1ec03628152362313aa9b3471f883a6d730', + '2147483646': 'BFCbb62823ef854276107b020039f1a8a0ecbd53dd55485e2be435c3d5ad939d21e4eb5', + '2147483647': 'BFCa9a2c081b09103758dcd3934e5f6d9dd867e047feccdb9baee68253bb59f6ce4aae3', + }, + }, ], } as AddressTestCaseData; diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/index.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/index.ts index 963db4e13..5e060d48e 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/index.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/index.ts @@ -20,7 +20,6 @@ export const testCases: AddressTestCase[] = [ ...singleAddressTestCount18Three, ...singleAddressTestCount24Three, ]; - export const batchTestCases: AddressBatchTestCase[] = [ ...batchAddressTestCount12One, ...batchAddressTestCount18One, diff --git a/packages/connect-examples/expo-example/src/testTools/addressTest/data/utils.ts b/packages/connect-examples/expo-example/src/testTools/addressTest/data/utils.ts index f1b08b0a0..8159dce69 100644 --- a/packages/connect-examples/expo-example/src/testTools/addressTest/data/utils.ts +++ b/packages/connect-examples/expo-example/src/testTools/addressTest/data/utils.ts @@ -68,6 +68,10 @@ export function convertTestSingleData( ): AddressTestCase { const testCase = fullPath(data); + // only in local test + // let testCase = fullPath(data); + // testCase.data = testCase.data.filter(item => item.method === 'benfenGetAddress'); + const dataList: AddressCaseData[] = []; for (const item of testCase.data) { const keys = Object.keys(item.expectedAddress); @@ -132,6 +136,9 @@ export function convertTestSingleData( export function convertTestBatchData(data: AddressTestCaseData): AddressBatchTestCase { const testCase = fullPath(data); + // only in local test + // let testCase = fullPath(data); + // testCase.data = testCase.data.filter(item => item.method === 'benfenGetAddress'); const dataList: AddressBatchCaseData[] = []; for (const item of testCase.data) { if (item.params?.addressParameters?.path) { diff --git a/packages/connect-examples/expo-example/webpack.config.js b/packages/connect-examples/expo-example/webpack.config.js index f0f7a89ec..4928cd3cd 100644 --- a/packages/connect-examples/expo-example/webpack.config.js +++ b/packages/connect-examples/expo-example/webpack.config.js @@ -5,7 +5,17 @@ const createExpoWebpackConfigAsync = require('@expo/webpack-config'); module.exports = async function (env, argv) { const config = await createExpoWebpackConfigAsync(env, argv); - // Customize the config before returning it. + // 只为我们自己的代码启用 source map + config.module.rules = config.module.rules.filter(rule => { + if (!rule || !rule.use) return true; + const uses = Array.isArray(rule.use) ? rule.use : [rule.use]; + return !uses.some(use => { + const loader = typeof use === 'string' ? use : use.loader; + return loader && loader.includes('source-map-loader'); + }); + }); + + // 保持其他配置不变 config.resolve.fallback = { crypto: require.resolve('./shim/crypto'), stream: require.resolve('stream-browserify'), diff --git a/packages/core/__tests__/benfen.test.ts b/packages/core/__tests__/benfen.test.ts index e63198688..cbb2d6faf 100644 --- a/packages/core/__tests__/benfen.test.ts +++ b/packages/core/__tests__/benfen.test.ts @@ -1,16 +1,68 @@ import { publicKeyToAddress, hex2BfcAddress } from '../src/api/benfen/normalize'; +export const TEST_FIXTURES = [ + // 12 位助记词 + { + publicKey: '554652d41f799d254b6f9f34a52b1b10be217ccf0ddcc8bf2389747099d53e3d', + hexAddress: '0x2d6e023ee0f3763c95e8b55621dec35e41cdc1438f3716588628f3a1a41e005d', + bfcAddress: 'BFC2d6e023ee0f3763c95e8b55621dec35e41cdc1438f3716588628f3a1a41e005d8fc4', + }, + { + publicKey: 'f199d06ee5abd9055143af7c14e98d9fce7bd08c4de9a20ab18205d467350ca4', + hexAddress: '0x8e6de169f88b291a03070a99ed8f1ccb61046fa5a07e760c860501689bd41346', + bfcAddress: 'BFC8e6de169f88b291a03070a99ed8f1ccb61046fa5a07e760c860501689bd4134662c1', + }, + { + publicKey: '12ee1cee9f0fa0016db328a5d3e5a3979a9c3ec4f2a85efde473f4575727ab5b', + hexAddress: '0x2b2253617385ee359d87860d1e9fc1e461223f0695ecbd67407878d48fcd10dc', + bfcAddress: 'BFC2b2253617385ee359d87860d1e9fc1e461223f0695ecbd67407878d48fcd10dc7099', + }, + // 18 位助记词 + { + publicKey: 'c556f258d4840fe69826f58dfa9cd20df604a2a2f4b1af57c82f72c1e96c0fd6', + hexAddress: '0xe94f5633460f2d2b851837ebacfa21fcaad6390044190afe889d31f0544f2e77', + bfcAddress: 'BFCe94f5633460f2d2b851837ebacfa21fcaad6390044190afe889d31f0544f2e773e53', + }, + { + publicKey: '852f3b4496eb533282d2dcbf536cebdd372d8d8cf106677e91f40f7e694dd724', + hexAddress: '0xa37f1d6df2c75464608c850faa601522d03fbd02e406ffee2cf0bcdae3cb5f39', + bfcAddress: 'BFCa37f1d6df2c75464608c850faa601522d03fbd02e406ffee2cf0bcdae3cb5f399914', + }, + { + publicKey: 'cd6f02eec5c5cc0eaa8c9da78a1e7f2dc69481b64030d130c3f2fe4f24dfe6e8', + hexAddress: '0x763ca26a1b55f3b5386ba61befb7b3110a424ff70a18f003205465e576699e9b', + bfcAddress: 'BFC763ca26a1b55f3b5386ba61befb7b3110a424ff70a18f003205465e576699e9bf887', + }, + + // 24 位助记词 + // "path": "m/44'/728'/0'/0'/0'", + { + publicKey: 'd59fc3edda0e16a8b5b827829b97a65398223e319cf3a8afeb482f5c6f6653c6', + hexAddress: '0x7356158f73e541ff7eb1a1aa97341d414fbc35fc7710e138e2d2d31207a41e6a', + bfcAddress: 'BFC7356158f73e541ff7eb1a1aa97341d414fbc35fc7710e138e2d2d31207a41e6a6a90', + }, + // "path": "m/44'/728'/0'/0'", + { + publicKey: 'a3600ca62a50a9650ac26f9b8b731eea83afca735ddbd83e688121e0f74fceb6', + hexAddress: '0x1a4889f782d427a863b69086840128e5308a2c071935d6c7e079a4ad4d136ebc', + bfcAddress: 'BFC1a4889f782d427a863b69086840128e5308a2c071935d6c7e079a4ad4d136ebce4d2', + }, + // "path": "m/44'/728'/0'/0'/1'", + { + publicKey: '8e0411e3059c9339038d927049ae79ccf4f2f5339a923aef258a1e69f70f733f', + hexAddress: '0x67f30006ee36ae36f6e3203f88fb8a48b08756144cf02a64137627d45c504e24', + bfcAddress: 'BFC67f30006ee36ae36f6e3203f88fb8a48b08756144cf02a64137627d45c504e244dd2', + }, +]; + describe('Benfen Address Normalization', () => { - it('publicKeyToBFCAddress', () => { - // Test case with a known public key and its expected address - const publicKey = '6e9c9ef745cc3a250168db15526d18075dc52849d49f8a6ea5477c1c264b4848'; - const expectedHexAddress = '0xb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa'; - const expectedAddress = - 'BFCb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa2e35'; + TEST_FIXTURES.forEach(({ publicKey, hexAddress, bfcAddress }) => { + it(`should correctly convert public key ${publicKey.slice(0, 8)}... to BFC address`, () => { + const generatedHexAddress = publicKeyToAddress(publicKey); + const generatedBfcAddress = hex2BfcAddress(generatedHexAddress); - const hexAddress = publicKeyToAddress(publicKey); - const bfcAddress = hex2BfcAddress(hexAddress); - expect(hexAddress).toBe(expectedHexAddress); - expect(bfcAddress).toBe(expectedAddress); + expect(generatedHexAddress).toBe(hexAddress); + expect(generatedBfcAddress).toBe(bfcAddress); + }); }); }); diff --git a/packages/core/__tests__/checkBootloaderReleast.test.js b/packages/core/__tests__/checkBootloaderReleast.test.ts similarity index 94% rename from packages/core/__tests__/checkBootloaderReleast.test.js rename to packages/core/__tests__/checkBootloaderReleast.test.ts index e6b2ee107..4d354e8cb 100644 --- a/packages/core/__tests__/checkBootloaderReleast.test.js +++ b/packages/core/__tests__/checkBootloaderReleast.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ +import { IVersionArray } from '../src'; import { shouldUpdateBootloaderForClassicAndMini } from '../src/api/firmware/bootloaderHelper'; // Add mock for config module @@ -105,8 +105,8 @@ describe('CheckBootloaderReleast', () => { currentVersion, bootloaderVersion, willUpdateFirmware, - targetBootloaderVersion, - bootloaderRelatedFirmwareVersion, + targetBootloaderVersion: targetBootloaderVersion as IVersionArray, + bootloaderRelatedFirmwareVersion: bootloaderRelatedFirmwareVersion as IVersionArray, }); expect(shouldUpdateBootloader).toBe(data.shouldUpdateBootloader); }); diff --git a/tsconfig.json b/tsconfig.json index e36443f7e..9615edb4b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,22 +21,14 @@ "resolveJsonModule": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, - "types": [ - "jest", - "node" - ], + "types": ["jest", "node"], "esModuleInterop": true, "composite": true, "declaration": true, "declarationMap": true, - "noEmit": false + "noEmit": false, + "outDir": "./dist" }, - "exclude": [ - "**/node_modules", - "**/lib", - "**/dist", - "**/coverage", - "**/public" - ], + "exclude": ["**/node_modules", "**/lib", "**/dist", "**/coverage", "**/public"], "extends": "expo/tsconfig.base" }