From 7c4ba81df9b37d47d8bf8f7994dc52152cbc889f Mon Sep 17 00:00:00 2001 From: wabiwabo <68363074+wabicai@users.noreply.github.com> Date: Thu, 28 Nov 2024 01:19:23 -0600 Subject: [PATCH] Feat: add benfen chain (#383) * feat: add benfen chain * fix: remove publickey, add benfen big data transaction * fix: delete benfen skipForceUpdateCheck * fix: delete support detection * chore: delete unuse code * fix: lint --- .../electron-example/package.json | 2 +- .../expo-example/package.json | 10 +- .../expo-example/src/data/allnetwork.ts | 5 + .../expo-example/src/data/benfen.ts | 113 +++++++++++++++ .../src/views/ApiPayloadScreen.tsx | 4 + packages/core/package.json | 6 +- .../api/allnetwork/AllNetworkGetAddress.ts | 3 + .../core/src/api/benfen/BenfenGetAddress.ts | 119 ++++++++++++++++ .../core/src/api/benfen/BenfenGetPublicKey.ts | 64 +++++++++ .../core/src/api/benfen/BenfenSignMessage.ts | 46 ++++++ .../src/api/benfen/BenfenSignTransaction.ts | 105 ++++++++++++++ packages/core/src/api/benfen/normalize.ts | 27 ++++ packages/core/src/api/index.ts | 5 + packages/core/src/data/messages/messages.json | 134 ++++++++++++++++++ packages/core/src/inject.ts | 9 ++ .../src/types/api/allNetworkGetAddress.ts | 3 +- .../core/src/types/api/benfenGetAddress.ts | 24 ++++ .../core/src/types/api/benfenGetPublicKey.ts | 23 +++ .../core/src/types/api/benfenSignMessage.ts | 13 ++ .../src/types/api/benfenSignTransaction.ts | 18 +++ packages/core/src/types/api/export.ts | 5 + packages/core/src/types/api/index.ts | 13 ++ packages/hd-ble-sdk/package.json | 8 +- packages/hd-common-connect-sdk/package.json | 12 +- packages/hd-transport-http/package.json | 6 +- packages/hd-transport-lowlevel/package.json | 6 +- .../hd-transport-react-native/package.json | 6 +- packages/hd-transport-webusb/package.json | 6 +- packages/hd-transport/package.json | 2 +- packages/hd-transport/src/types/messages.ts | 58 ++++++++ packages/hd-web-sdk/package.json | 10 +- packages/shared/package.json | 2 +- 32 files changed, 828 insertions(+), 39 deletions(-) create mode 100644 packages/connect-examples/expo-example/src/data/benfen.ts create mode 100644 packages/core/src/api/benfen/BenfenGetAddress.ts create mode 100644 packages/core/src/api/benfen/BenfenGetPublicKey.ts create mode 100644 packages/core/src/api/benfen/BenfenSignMessage.ts create mode 100644 packages/core/src/api/benfen/BenfenSignTransaction.ts create mode 100644 packages/core/src/api/benfen/normalize.ts create mode 100644 packages/core/src/types/api/benfenGetAddress.ts create mode 100644 packages/core/src/types/api/benfenGetPublicKey.ts create mode 100644 packages/core/src/types/api/benfenSignMessage.ts create mode 100644 packages/core/src/types/api/benfenSignTransaction.ts diff --git a/packages/connect-examples/electron-example/package.json b/packages/connect-examples/electron-example/package.json index cba255fe3..1bdf2aa73 100644 --- a/packages/connect-examples/electron-example/package.json +++ b/packages/connect-examples/electron-example/package.json @@ -2,7 +2,7 @@ "name": "hardware-example", "productName": "HardwareExample", "executableName": "onekey-hardware-example", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "author": "OneKey", "description": "End-to-end encrypted workspaces for teams", "main": "dist/index.js", diff --git a/packages/connect-examples/expo-example/package.json b/packages/connect-examples/expo-example/package.json index a898aee25..0dd07181c 100644 --- a/packages/connect-examples/expo-example/package.json +++ b/packages/connect-examples/expo-example/package.json @@ -1,6 +1,6 @@ { "name": "expo-example", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "scripts": { "start": "CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client", "android": "yarn expo run:android", @@ -19,10 +19,10 @@ "@noble/ed25519": "^2.1.0", "@noble/hashes": "^1.3.3", "@noble/secp256k1": "^1.7.1", - "@onekeyfe/hd-ble-sdk": "^1.0.14", - "@onekeyfe/hd-common-connect-sdk": "^1.0.14", - "@onekeyfe/hd-core": "^1.0.14", - "@onekeyfe/hd-web-sdk": "^1.0.14", + "@onekeyfe/hd-ble-sdk": "^1.0.15-alpha.0", + "@onekeyfe/hd-common-connect-sdk": "^1.0.15-alpha.0", + "@onekeyfe/hd-core": "^1.0.15-alpha.0", + "@onekeyfe/hd-web-sdk": "^1.0.15-alpha.0", "@onekeyfe/react-native-ble-plx": "3.0.0", "@polkadot/util-crypto": "13.1.1", "@react-native-async-storage/async-storage": "1.21.0", diff --git a/packages/connect-examples/expo-example/src/data/allnetwork.ts b/packages/connect-examples/expo-example/src/data/allnetwork.ts index 40aa776a7..0ab0124dd 100644 --- a/packages/connect-examples/expo-example/src/data/allnetwork.ts +++ b/packages/connect-examples/expo-example/src/data/allnetwork.ts @@ -188,6 +188,11 @@ const api: PlaygroundProps[] = [ path: "m/44'/784'/0'/0'/0'", showOnOneKey: false, }, + { + network: 'benfen', + path: "m/44'/728'/0'/0'/0'", + showOnOneKey: false, + }, { network: 'tron', path: "m/44'/195'/0'/0/0", diff --git a/packages/connect-examples/expo-example/src/data/benfen.ts b/packages/connect-examples/expo-example/src/data/benfen.ts new file mode 100644 index 000000000..509089905 --- /dev/null +++ b/packages/connect-examples/expo-example/src/data/benfen.ts @@ -0,0 +1,113 @@ +import { type PlaygroundProps } from '../components/Playground'; + +const api: PlaygroundProps[] = [ + { + method: 'benfenGetAddress', + description: 'Get address', + presupposes: [ + { + title: 'Get address', + value: { + path: "m/44'/728'/0'/0'/0'", + showOnOneKey: false, + }, + }, + { + title: 'Batch Get Address', + value: { + bundle: [ + { + path: "m/44'/728'/0'/0'/0'", + showOnOneKey: false, + }, + { + path: "m/44'/728'/1'/0'/0'", + showOnOneKey: false, + }, + { + path: "m/44'/728'/2'/0'/0'", + showOnOneKey: false, + }, + ], + }, + }, + ], + }, + { + method: 'benfenGetPublicKey', + description: 'Get PublicKey', + presupposes: [ + { + title: 'Get PublicKey', + value: { + path: "m/44'/728'/0'/0'/0'", + showOnOneKey: false, + }, + }, + { + title: 'Batch Get PublicKey', + value: { + bundle: [ + { + path: "m/44'/728'/0'/0'/0'", + showOnOneKey: false, + }, + { + path: "m/44'/728'/1'/0'/0'", + showOnOneKey: false, + }, + { + path: "m/44'/728'/2'/0'/0'", + showOnOneKey: false, + }, + ], + }, + }, + ], + }, + { + method: 'benfenSignMessage', + description: 'Sign Message', + presupposes: [ + { + title: 'Sign Message', + value: { + path: "m/44'/728'/0'/0'/0'", + // hello, world 的hex 格式 + messageHex: '48656c6c6f2c20576f726c6421', + }, + }, + ], + }, + { + method: 'benfenSignTransaction', + description: 'Sign Transaction', + presupposes: [ + { + title: 'Sign Transaction', + value: { + path: "m/44'/728'/0'/0'/0'", + rawTx: + '0x00000000000200088096980000000000002017f3a9bd36da0639153d3c38032217ea298eb1991e0a62cc5924e2dd712937350202000101000001010300000000010100b4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa0183006eb3c5499c3cb4b022f20955f387312ed312389c552fa39e35d6423d0c74f785b7000000000020497f41fdfb22d2ae32111dcdc21c16d27f48f47b7ca7aba240b684db5ca74c0fb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa640000000000000060ad38000000000000', + // coinType: '3078323a3a6266633a3a424643', + // coinType:'42464330303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030306338653330613a3a627573643a3a42555344' + // coinType:'42464330303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030306338653330613a3a626a70793a3a424a5059' + // coinType:'42464337303263306439363736386366353964323563396462616532313862303637386665316565353939616637613234333766373737306465643735326439613161333930393a3a6c6f6e673a3a4c4f4e47' + coinType: + '42464364393037326533366563626136336236306437323439373832393636373736303162313637316336303639336166333466373761383665663934643637643165383231303a3a62665f757364633a3a42465f55534443', + }, + }, + { + title: 'Sign Transaction(Big 7K)', + value: { + path: "m/44'/728'/0'/0'/0'", + coinType: '3078323a3a6266633a3a424643', + rawTx: + '0000000000340100027e179b5d888d95a9852e5503dd0730ab78f35412c9065f7df1c5c3acd874a0e273b9000000000020793e8072a90e63db0efa50b37834671aed7640c10bfa01994d0363679d5bf11501000358128f4617c9cf8446cc597b0b34c34ade63f3d0709c8ab088de66f14a496de273b90000000000209ebfc4f3eafd4065ea2c3e9ed775335e96ae04e6ae8706aa5537b508ee3492c8010004009983de3452c5876fed1eb2e4c5280dc650b76d852301b20ec0e92972dfa4e273b9000000000020530b7457e63ba4bab6845836f937813ab3d8b5ce16d194a5ab6fdb8fcd3067840100042f3df005ddedf662428dd90c5e673be607e9c21b4b4250c51b46ceb81c8412e273b9000000000020d5fde14f91325f4d6a19dce5f6707947eea55fcbac92a011405f89ac54c79b3b010005d298d667e608d100ebba1ae5f4972e0c9f3c1f6c72dc44c42890ffd3f938a6e273b9000000000020237b4fa3c15ac6719a08afb4ecb86a8ecd407cc4f31a4204f498c97f461b34a001000698cbcbc5ea23f2bacd1e13d3354fa618069fa718268c15b7fd8f71171364fce273b9000000000020d033e3f0583e1a8b24fbb56a3c6ecc83af490abcdbd1ff994825884ee302751001000b33a803b5f130a75abb315f442298de353aa42c601d0e4b9adfda9b38dbfb81e273b90000000000207c06ff991eba0ae44e21322756aaffef2c1338099556cefb0d68b7bf589475c501000c9e5bf27ccc253d1efab83a71effa3b861f364a889b224e133c5ca793038fabe273b90000000000203e0d9f4c3700bd9a6cf8296b9450b7916a932f21faa1c0d7eb50d79a3d36feee01000e1f77b40a60207d1581c2e1fd8e86b7c01971d0e63aa1a667388eae70ee68d2e273b9000000000020895c6c7d89a13c0d83f7fa8586b047bda112717f2852c1cc48a1f43141a1b56901000f226eab7f4b603c678ed99f535b2f19046c070e86f7d642f1b51bb6b482504ae273b9000000000020bff05f3301abdcd654a18cf5840e0fb2fd6c40f09ff3319c4071422aafc43c190100128faa41a63dd4f06713011be96438c77374ad64e98aaf1de209103f310442aae273b9000000000020fc4d72254ecd63aaf55c2c8de8dec8c96864705dd0f8bb1646702bf550ae3685010013dac3b35caa38198b2d8e718b875002fe8c0281bd843bbba0a36fb75ae102a0e273b9000000000020f2a3538920917503a54569fb2746c299b9e3f2ffe4584b011263efd99d8b4c87010015789455d7b055ecdfb5829fb61d403853c27638b81caf487ded28c8f6996273e273b9000000000020bb3d0ee3786a7117f7d27b89f9254c1ebf2a7fd2332ff8f44d4a7a17332092d4010015b5f497001ef7bb58bb6979c1b6ab4616d33ff217fd11ba14c91ef446bb473fe273b90000000000201d17f049ddffe45a186ba982c2edadc075b073d6cfa762c018f7a4a53d41ea0b010015e3f573e6342a7cbaf55bada270589ebf4d2510436209e794e537315a18ad9be273b9000000000020b577d4d1771c5c80811a422d4476e5048c5c28536894c64a99ca9f9e33c5bb9301001623a6b745769cf9655ea2076671c32b76e71802b410d0ddfe84dda7082acc5de273b9000000000020e444e22d3cea6691cc7a79e83127e82bb5857925d80fbf786f513688531dd01f0100186cb833953d0e691b11701aec483fab4b40234d65c831b3086166ce824dc0b3e273b900000000002043bb814ae1fc409ec1ee06c9e6b60ced084b50146f7ef06af4595157143800f70100212f3db5c4979cbb9bd8ebbada41814cf00776380c15dc1ec4e34f9c6b7dc563e273b90000000000201a4d27ee8ace85f9939ed3896e7774eb858056275d08c3dc333aed6319a8b3030100293e3fcacfb6d605c28408f3498df2271d99e289168d2f3599e6d97274377c4ce273b90000000000206a26e8cf00d7941424b111bf98790d4056d9b2d5d1c9fa72e7bda61041b6321301002952997d8174dcdd166685c031cac390e799a3ceda17e4ea817ce514fadc555ce273b90000000000204725ba6978cdc83f353dcdd9c15015011e0f11828bd6540abe313649776fae3e01002b3b3797d15b9852828d908603056fa5a80cb00b1da6ed0c4645ad1bd3a3d6b6e273b9000000000020fcff637e481a0bbdcecfec84290f2e23b531cca2bb661a73e69de16e28c5e23a01002c221e14b6533b4162babe18f963de27006e321eea4f9205251c4795d373170fe273b9000000000020028a00e881a3f32438ae753df6810b91a90d19f9a941033d3a9fb5468cb9de8801002da1ee19f20a5ea20d5d9ea102d813d0c933aac2ac9b3e2800f9aca093cd36fbe273b9000000000020004b4fb4c2f1f4348f96b64e6c90779af3a5ecbecc5bf98b849e5726394e83e701002fe45725a5ecd03e32ab4d757be0eaca09efa69acf304aa51141b2905dbd974fe273b9000000000020fe2759c7921d88e8d097c7800d6c69a33f012a114a7e0e9f0e4f9eaf0456142101003574ba403edcabd7a9d7c0863e1114a663d671a9c8d1fab1f84e876e377175eee273b90000000000203b300da63687034548e825b85eebc16478736da946a7ede0999c8c257399094b010035a91b4e477dae85fb1e37de096ef59c89c983f3a4c438da5dae39d1ab2d2b1be273b9000000000020672302b843ba690de34b519db7ff770978c4376b49d7c8c7f489fe5b85ceec59010038bb12f11c9e6447214277ad0f248f284faf5d44e86729bf6c2fcbad12713702e273b900000000002021913542bc4fea33b764664135e03b0015b91507c761af3bfb6af9737334742f0100474e05d02af596bcdf82ca2b86c186d2969bb8c18aebcf01a9080a9a3bb90574e273b900000000002026d26d0ea7b84a03e79e478eec1dee75423617660d01d6d25c7251ff27f1724e010049925c1511bd7fc50f00165000259f1b1da15eb8c3e3884055874fc5beea90f6e273b9000000000020e7a587f8263b1b57d5da4c261957de77636b6e2804fc0e225f2f6209202b2f9201004bf4b3524d31425d1d6d433bfc3f253e79fdac086b6fb48846bbffc7f25d035de273b9000000000020442c0ca1bc3e28862fd903ccaea3b99b4f1a450c6b3717a594259c0fe960693401004e472d7321d02ba73ec083f0a643839ed0165f46bf54b0b25876f0a7a3af3b08e273b9000000000020ee36bccf8c285ef88e3bbd98502f6b49390cfd1aad8255d1de01654691bd5b00010052e063cd1118874019aac418672f65a27d06e017bd62082e21320071247f009ce273b9000000000020225869d4ba6d33b960420ae129da71525cdb41eb8801a857e1f975f167381d9301005366bd23401ed7c877e6485d4d8ab449cefc22c4d496dc791b55d44cb66e8c91e273b90000000000201f25937e0bf0437dcab239a9f25d5e5aae8f657d38c28dc0cca73bc5e4e656ac0100568ba56d14dd9213727bd02885cfd259c7ef945d49411dddd0b3a859d88eb5ade273b900000000002053d638e8aa16ebb81725453faa18f3354d1d61dedcec63134a05672e7d6700980100585191234b8949f3747b39513c0a23065f325137ab617888e52532683c148ec2e273b9000000000020f859811059a1f247b54893ba47811fd6c0898e73fb194b848e9bb603238a402b01005e83f4463ffab97d063a57e105b780cdfd47c7661dfc404ffbe67df0f08589f5e273b90000000000205958a0e72bacd618b93a6c9759f91471d734c8a82e86e79a3fc9ae5c3cc3ab4501005f9ab3544276860e67fc5abc413b8efdab6b2c5bb50d1c012d1fef0ce775e802e273b9000000000020da0f17909301e4615157f84dfee88fa5a3beefffaaca82c29f7b34e9706f9f37010060a9c9cdc052f1b11eb294d3bd401c092e457cd87942a3c4e226eae035862f5de273b9000000000020a3f19cfa4642881c8115cab006f98a736da24bfc7644a9e69dc04769a9ab03bd0100634d47cb70bb95d50dcbbf3925664ffce3add3de12d3528f8f99b7a1968df99de273b90000000000201f33640c725bc3bcbe3db47a4faf99d82c4017086f684d805aaa8fa50f778ac7010063d08ebe3ae73d0de9488f68a509f7c431416a943624bea4812c89347dacc3a7e273b900000000002006aa44f56271039f32cdaec4881ae45c0b9946c8ae6346b8258458480f80b3d301006b8ae976f5a425ae0c042ac3e1b8cb318a19933a1e60e04901f9b1486a66c552e273b900000000002061d7db3d1e7fe7bdcf58dbbe92c554246d67ee406bcbb2a6e0b0e40445392b8101006c0f706931d5da9f19e23412c425fbdea70e5b3416f1e2210f283c3347d9f8fee273b90000000000209a63f2e6ea804fa307cdf5ca1faf212fcdd4a5f45a731711c45669a40dc3d7aa010071685038f12b2cdda527521b6227b1e4ea5bf37a64e5e8afeac03db00ddd010be273b9000000000020138206a1bcdf4614f38ecd4b1110368f8a0f957961f346c8762a9c9d45a755800100745d53ec4e5d31d368f3e1873ef1566bd8c4eda89975e198461bbb797a1e48f9e273b9000000000020b5276852c344be0a47b1ba32b5007bba018b247d91a7614484fea181d423665e0100746b5c4732a096773985e3e4ea043757bb30afd09175cc185ca97686f27bff7be273b9000000000020650c9d4b2ff086f6e9027a126007b235789833da5734c2a3a6cb36e294ca1911010076ec74eba40aacd18446c95459ad8a8a7125106bd0ecb237eaf26152be5d5f21e273b9000000000020cff4549a2e23ecba7c0db3b51c744712429ad4901689abf145737c377ee40189010078be0fd6761aca67fcd1a6e3efe0b57665628908b2496619a3bbad85a3ab5a87e273b9000000000020168c57e1f6aede8d9fe2b1c6bbb832e29e5f1d8149ff79e6e40e92f17efb29f0010079cdd7bdca5cc6da211db3c479edc3ef0b8d551d7ddc6b7fd78494413ff5ed49e273b90000000000204474d30207b91fb6eca9b9c233a7087d8b4e7855768d1e76c48c33c0f64b9faf0100020189fad2c9fe78631fd61eb5c980ca6714bb5c1315fa406991fa10b69baed3e173b9000000000020bda2eb813d1e942886398e77db0dd860f7e769daf38fc9030870d4bddbdfc4b100080a00000000000000010000b800b7fef1f3c18eeac265b8eebee9e65bee6ee435af02453bf39b58a8f452e273b9000000000020e1b441b0b5b4cdaf46f7acba2b7e0262620fd5b2ceb6e2ca7ef9d45cbb47e3c1002017f3a9bd36da0639153d3c38032217ea298eb1991e0a62cc5924e2dd71293735030301300030010000010100010200010300010400010500010600010700010800010900010a00010b00010c00010d00010e00010f00011000011100011200011300011400011500011600011700011800011900011a00011b00011c00011d00011e00011f00012000012100012200012300012400012500012600012700012800012900012a00012b00012c00012d00012e00012f00020132000101310001010301000000013300b4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa0183006eb3c5499c3cb4b022f20955f387312ed312389c552fa39e35d6423d0c74e273b90000000000208c1c43b2ac96240becd2db8f69b348109a0cf3604af4ac2bbf1d43e88d1196deb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa6400000000000000004461000000000000', + }, + }, + ], + }, +]; + +export default api; diff --git a/packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx b/packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx index c53da540c..fca03bd36 100644 --- a/packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx +++ b/packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx @@ -33,6 +33,10 @@ const playgroundConfig = [ title: 'Bitcoin API', data: require('../data/bitcoin').default, }, + { + title: 'Benfen API', + data: require('../data/benfen').default, + }, { title: 'Ethereum API', data: require('../data/ethereum').default, diff --git a/packages/core/package.json b/packages/core/package.json index c7b481d80..5134763b8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-core", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "description": "> TODO: description", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", @@ -25,8 +25,8 @@ "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport": "^1.0.14", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport": "^1.0.15-alpha.0", "axios": "^0.27.2", "bignumber.js": "^9.0.2", "bytebuffer": "^5.0.1", diff --git a/packages/core/src/api/allnetwork/AllNetworkGetAddress.ts b/packages/core/src/api/allnetwork/AllNetworkGetAddress.ts index 1c1d39c45..e6120cc3e 100644 --- a/packages/core/src/api/allnetwork/AllNetworkGetAddress.ts +++ b/packages/core/src/api/allnetwork/AllNetworkGetAddress.ts @@ -143,6 +143,9 @@ const networkConfigMap: NetworkConfigMap = { sui: { methodName: 'suiGetAddress', }, + benfen: { + methodName: 'benfenGetAddress', + }, fil: { methodName: 'filecoinGetAddress', getParams: (baseParams: AllNetworkAddressParams, chainName?: string) => { diff --git a/packages/core/src/api/benfen/BenfenGetAddress.ts b/packages/core/src/api/benfen/BenfenGetAddress.ts new file mode 100644 index 000000000..41c0f22fe --- /dev/null +++ b/packages/core/src/api/benfen/BenfenGetAddress.ts @@ -0,0 +1,119 @@ +import { BenfenGetAddress as HardwareBenfenGetAddress } from '@onekeyfe/hd-transport'; + +import { BaseMethod } from '../BaseMethod'; +import { validateParams, validateResult } from '../helpers/paramsValidator'; +import { serializedPath, validatePath } from '../helpers/pathUtils'; +import { UI_REQUEST } from '../../constants/ui-request'; +import { publicKeyToAddress } from './normalize'; +import { BenfenAddress, BenfenGetAddressParams } from '../../types'; +import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils'; + +export default class BenfenGetAddress extends BaseMethod { + hasBundle = false; + + shouldConfirm = false; + + init() { + this.checkDeviceId = true; + this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE]; + + this.hasBundle = !!this.payload?.bundle; + const payload = this.hasBundle ? this.payload : { bundle: [this.payload] }; + + this.shouldConfirm = + this.payload.showOnOneKey || + this.payload.bundle?.some((i: BenfenGetAddressParams) => !!i.showOnOneKey); + + validateParams(payload, [{ name: 'bundle', type: 'array' }]); + + this.params = []; + payload.bundle.forEach((batch: BenfenGetAddressParams) => { + const addressN = validatePath(batch.path, 3); + + validateParams(batch, [ + { name: 'path', required: true }, + { name: 'showOnOneKey', type: 'boolean' }, + ]); + + const showOnOneKey = batch.showOnOneKey ?? true; + + this.params.push({ + address_n: addressN, + show_display: showOnOneKey, + }); + }); + } + + getVersionRange() { + return { + model_touch: { + min: '4.10.3', + }, + }; + } + + async run() { + const supportsBatchPublicKey = supportBatchPublicKey(this.device?.features); + let responses: BenfenAddress[] = []; + + if (supportsBatchPublicKey) { + const publicKeyRes = await this.device.commands.typedCall( + 'BatchGetPublickeys', + 'EcdsaPublicKeys', + { + paths: this.params, + ecdsa_curve_name: 'ed25519', + } + ); + + for (let i = 0; i < this.params.length; i++) { + const param = this.params[i]; + const publicKey = publicKeyRes.message.public_keys[i]; + let address: string; + + if (this.shouldConfirm) { + const addressRes = await this.device.commands.typedCall( + 'BenfenGetAddress', + 'Address', + param + ); + address = addressRes.message.address?.toLowerCase() ?? ''; + } else { + address = publicKeyToAddress(publicKey); + } + + const result = { + path: serializedPath(param.address_n), + address, + pub: publicKey, + }; + + if (this.shouldConfirm) { + this.postPreviousAddressMessage(result); + } + + responses.push(result); + } + } else { + responses = await Promise.all( + this.params.map(async param => { + const res = await this.device.commands.typedCall('BenfenGetAddress', 'Address', param); + const result = { + path: serializedPath(param.address_n), + address: res.message.address?.toLowerCase() ?? '', + }; + if (this.shouldConfirm) { + this.postPreviousAddressMessage(result); + } + return result; + }) + ); + } + + validateResult(responses, ['address'], { + expectedLength: this.params.length, + }); + + return this.hasBundle ? responses : responses[0]; + } +} diff --git a/packages/core/src/api/benfen/BenfenGetPublicKey.ts b/packages/core/src/api/benfen/BenfenGetPublicKey.ts new file mode 100644 index 000000000..affd76320 --- /dev/null +++ b/packages/core/src/api/benfen/BenfenGetPublicKey.ts @@ -0,0 +1,64 @@ +import { BaseMethod } from '../BaseMethod'; +import { validateParams, validateResult } from '../helpers/paramsValidator'; +import { serializedPath, validatePath } from '../helpers/pathUtils'; +import { UI_REQUEST } from '../../constants/ui-request'; +import { BenfenPublicKey, BenfenGetPublicKeyParams } from '../../types'; + +export default class BenfenGetPublicKey extends BaseMethod { + hasBundle = false; + + init() { + this.checkDeviceId = true; + this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE]; + + this.hasBundle = !!this.payload?.bundle; + const payload = this.hasBundle ? this.payload : { bundle: [this.payload] }; + + validateParams(payload, [{ name: 'bundle', type: 'array' }]); + + this.params = []; + payload.bundle.forEach((batch: BenfenGetPublicKeyParams) => { + const addressN = validatePath(batch.path, 3); + + validateParams(batch, [ + { name: 'path', required: true }, + { name: 'showOnOneKey', type: 'boolean' }, + ]); + + const showOnOneKey = batch.showOnOneKey ?? true; + + this.params.push({ + address_n: addressN, + show_display: showOnOneKey, + }); + }); + } + + getVersionRange() { + return { + model_touch: { + min: '4.10.3', + }, + }; + } + + async run() { + const res = await this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', { + paths: this.params, + ecdsa_curve_name: 'ed25519', + }); + + const responses: BenfenPublicKey[] = res.message.public_keys.map( + (publicKey: string, index: number) => ({ + path: serializedPath((this.params as any[])[index].address_n), + pub: publicKey, + }) + ); + + validateResult(responses, ['pub'], { + expectedLength: this.params.length, + }); + + return Promise.resolve(this.hasBundle ? responses : responses[0]); + } +} diff --git a/packages/core/src/api/benfen/BenfenSignMessage.ts b/packages/core/src/api/benfen/BenfenSignMessage.ts new file mode 100644 index 000000000..6c55284ba --- /dev/null +++ b/packages/core/src/api/benfen/BenfenSignMessage.ts @@ -0,0 +1,46 @@ +import { BenfenSignMessage as HardwareBenfenSignMessage } from '@onekeyfe/hd-transport'; +import { UI_REQUEST } from '../../constants/ui-request'; +import { validatePath } from '../helpers/pathUtils'; +import { BaseMethod } from '../BaseMethod'; +import { validateParams } from '../helpers/paramsValidator'; +import { stripHexPrefix } from '../helpers/hexUtils'; + +export default class BenfenSignMessage extends BaseMethod { + init() { + this.checkDeviceId = true; + this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE]; + + validateParams(this.payload, [ + { name: 'path', required: true }, + { name: 'messageHex', type: 'hexString', required: true }, + ]); + + const { path, messageHex } = this.payload; + const addressN = validatePath(path, 3); + + this.params = { + address_n: addressN, + message: stripHexPrefix(messageHex), + }; + } + + getVersionRange() { + return { + model_touch: { + min: '4.10.3', + }, + }; + } + + async run() { + const response = await this.device.commands.typedCall( + 'BenfenSignMessage', + 'BenfenMessageSignature', + { + ...this.params, + } + ); + + return Promise.resolve(response.message); + } +} diff --git a/packages/core/src/api/benfen/BenfenSignTransaction.ts b/packages/core/src/api/benfen/BenfenSignTransaction.ts new file mode 100644 index 000000000..d2c18e20b --- /dev/null +++ b/packages/core/src/api/benfen/BenfenSignTransaction.ts @@ -0,0 +1,105 @@ +import { + BenfenSignTx as HardwareBenfenSignTx, + TypedCall, + BenfenSignedTx, + MessageType, +} from '@onekeyfe/hd-transport'; +import { bytesToHex } from '@noble/hashes/utils'; +import { UI_REQUEST } from '../../constants/ui-request'; +import { validatePath } from '../helpers/pathUtils'; +import { BaseMethod } from '../BaseMethod'; +import { validateParams } from '../helpers/paramsValidator'; +import { formatAnyHex } from '../helpers/hexUtils'; +import type { TypedResponseMessage } from '../../device/DeviceCommands'; + +type BenfenSignTx = Omit & + HardwareBenfenSignTx; + +export default class BenfenSignTransaction extends BaseMethod { + init() { + this.checkDeviceId = true; + this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE]; + + validateParams(this.payload, [ + { name: 'path', required: true }, + { name: 'rawTx', type: 'hexString', required: true }, + { name: 'coinType', type: 'hexString', required: true }, + ]); + + const { path, rawTx, coinType } = this.payload; + const addressN = validatePath(path, 3); + + this.params = { + address_n: addressN, + raw_tx: formatAnyHex(rawTx), + coin_type: formatAnyHex(coinType), + }; + } + + getVersionRange() { + return { + model_touch: { + min: '4.10.2', + }, + }; + } + + chunkByteSize = 1024; + + processTxRequest = async ( + typedCall: TypedCall, + res: TypedResponseMessage<'BenfenSignedTx'> | TypedResponseMessage<'BenfenTxRequest'>, + data: Buffer, + offset = 0 + ): Promise => { + if (res.type === 'BenfenSignedTx') { + return res.message; + } + + const { data_length } = res.message; + + if (!data_length) { + return res.message; + } + + const payload = data.subarray(offset, offset + data_length); + const newOffset = offset + payload.length; + const resourceAckParams = { + data_chunk: bytesToHex(new Uint8Array(payload)), + }; + + const response = await typedCall( + 'BenfenTxAck', + ['BenfenSignedTx', 'BenfenTxRequest'] as unknown as keyof MessageType, + { + ...resourceAckParams, + } + ); + + return this.processTxRequest( + typedCall, + response as TypedResponseMessage<'BenfenSignedTx'> | TypedResponseMessage<'BenfenTxRequest'>, + data, + newOffset + ); + }; + + async run() { + const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands()); + const offset = this.chunkByteSize; + const data = Buffer.from(this.params.raw_tx, 'hex'); + this.params = { + address_n: this.params.address_n, + coin_type: this.params.coin_type, + raw_tx: '', + data_initial_chunk: bytesToHex(new Uint8Array(data.buffer).subarray(0, this.chunkByteSize)), + data_length: data.length, + }; + + const res = await typedCall('BenfenSignTx', ['BenfenSignedTx', 'BenfenTxRequest'], { + ...this.params, + }); + + return this.processTxRequest(typedCall, res, data, offset); + } +} diff --git a/packages/core/src/api/benfen/normalize.ts b/packages/core/src/api/benfen/normalize.ts new file mode 100644 index 000000000..e0ec6e4a1 --- /dev/null +++ b/packages/core/src/api/benfen/normalize.ts @@ -0,0 +1,27 @@ +import { bytesToHex, hexToBytes } from '@noble/hashes/utils'; +import { blake2b } from '@noble/hashes/blake2b'; + +export const BENFEN_ADDRESS_LENGTH = 32; +export const PUBLIC_KEY_SIZE = 32; + +export const SIGNATURE_SCHEME_TO_FLAG = { + ED25519: 0x00, +}; + +export function normalizeBenfenAddress(value: string, forceAdd0x = false): string { + let address = value.toLowerCase(); + if (!forceAdd0x && address.startsWith('0x')) { + address = address.slice(2); + } + return `0x${address.padStart(BENFEN_ADDRESS_LENGTH * 2, '0')}`.toLowerCase(); +} + +export function publicKeyToAddress(publicKey: string) { + const tmp = new Uint8Array(PUBLIC_KEY_SIZE + 1); + tmp.set([SIGNATURE_SCHEME_TO_FLAG.ED25519]); + tmp.set(hexToBytes(publicKey), 1); + + return normalizeBenfenAddress( + bytesToHex(blake2b(tmp, { dkLen: 32 })).slice(0, BENFEN_ADDRESS_LENGTH * 2) + ); +} diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts index f465bc7ed..17880b093 100644 --- a/packages/core/src/api/index.ts +++ b/packages/core/src/api/index.ts @@ -145,3 +145,8 @@ export { default as scdoSignMessage } from './scdo/ScdoSignMessage'; export { default as alephiumGetAddress } from './alephium/AlephiumGetAddress'; export { default as alephiumSignTransaction } from './alephium/AlephiumSignTransaction'; export { default as alephiumSignMessage } from './alephium/AlephiumSignMessage'; + +export { default as benfenGetAddress } from './benfen/BenfenGetAddress'; +export { default as benfenGetPublicKey } from './benfen/BenfenGetPublicKey'; +export { default as benfenSignMessage } from './benfen/BenfenSignMessage'; +export { default as benfenSignTransaction } from './benfen/BenfenSignTransaction'; diff --git a/packages/core/src/data/messages/messages.json b/packages/core/src/data/messages/messages.json index 4edfd12a1..dd2bbc8d6 100644 --- a/packages/core/src/data/messages/messages.json +++ b/packages/core/src/data/messages/messages.json @@ -326,6 +326,132 @@ } } }, + "BenfenGetAddress": { + "fields": { + "address_n": { + "rule": "repeated", + "type": "uint32", + "id": 1, + "options": { + "packed": false + } + }, + "show_display": { + "type": "bool", + "id": 2 + } + } + }, + "BenfenAddress": { + "fields": { + "address": { + "type": "string", + "id": 1 + } + } + }, + "BenfenSignTx": { + "fields": { + "address_n": { + "rule": "repeated", + "type": "uint32", + "id": 1, + "options": { + "packed": false + } + }, + "raw_tx": { + "rule": "required", + "type": "bytes", + "id": 2 + }, + "data_initial_chunk": { + "type": "bytes", + "id": 3, + "options": { + "default": "" + } + }, + "coin_type": { + "type": "bytes", + "id": 4 + }, + "data_length": { + "type": "uint32", + "id": 5 + } + } + }, + "BenfenSignedTx": { + "fields": { + "public_key": { + "rule": "required", + "type": "bytes", + "id": 1 + }, + "signature": { + "rule": "required", + "type": "bytes", + "id": 2 + } + } + }, + "BenfenTxRequest": { + "fields": { + "data_length": { + "type": "uint32", + "id": 1 + }, + "public_key": { + "type": "bytes", + "id": 2 + }, + "signature": { + "type": "bytes", + "id": 3 + } + } + }, + "BenfenTxAck": { + "fields": { + "data_chunk": { + "rule": "required", + "type": "bytes", + "id": 1 + } + } + }, + "BenfenSignMessage": { + "fields": { + "address_n": { + "rule": "repeated", + "type": "uint32", + "id": 1, + "options": { + "packed": false + } + }, + "message": { + "rule": "required", + "type": "bytes", + "id": 2 + } + } + }, + "BenfenMessageSignature": { + "fields": { + "signature": { + "rule": "required", + "type": "bytes", + "id": 1 + }, + "address": { + "rule": "required", + "type": "string", + "id": 2 + } + } + }, "BinanceGetAddress": { "fields": { "address_n": { @@ -11584,6 +11710,14 @@ "MessageType_AlephiumBytecodeAck": 12108, "MessageType_AlephiumSignMessage": 12109, "MessageType_AlephiumMessageSignature": 12110, + "MessageType_BenfenGetAddress": 13100, + "MessageType_BenfenAddress": 13101, + "MessageType_BenfenSignTx": 13102, + "MessageType_BenfenSignedTx": 13103, + "MessageType_BenfenSignMessage": 13104, + "MessageType_BenfenMessageSignature": 13105, + "MessageType_BenfenTxRequest": 13106, + "MessageType_BenfenTxAck": 13107, "MessageType_DeviceBackToBoot": 903, "MessageType_DeviceInfoSettings": 10001, "MessageType_GetDeviceInfo": 10002, diff --git a/packages/core/src/inject.ts b/packages/core/src/inject.ts index 26867d8ea..8a183554b 100644 --- a/packages/core/src/inject.ts +++ b/packages/core/src/inject.ts @@ -332,4 +332,13 @@ export const createCoreApi = ( call({ ...params, connectId, deviceId, method: 'alephiumSignMessage' }), alephiumSignTransaction: (connectId, deviceId, params) => call({ ...params, connectId, deviceId, method: 'alephiumSignTransaction' }), + + benfenGetAddress: (connectId, deviceId, params) => + call({ ...params, connectId, deviceId, method: 'benfenGetAddress' }), + benfenGetPublicKey: (connectId, deviceId, params) => + call({ ...params, connectId, deviceId, method: 'benfenGetPublicKey' }), + benfenSignTransaction: (connectId, deviceId, params) => + call({ ...params, connectId, deviceId, method: 'benfenSignTransaction' }), + benfenSignMessage: (connectId, deviceId, params) => + call({ ...params, connectId, deviceId, method: 'benfenSignMessage' }), }); diff --git a/packages/core/src/types/api/allNetworkGetAddress.ts b/packages/core/src/types/api/allNetworkGetAddress.ts index 11774d41a..13154dd56 100644 --- a/packages/core/src/types/api/allNetworkGetAddress.ts +++ b/packages/core/src/types/api/allNetworkGetAddress.ts @@ -31,7 +31,8 @@ export type INetwork = | 'scdo' | 'ton' | 'alph' - | 'nostr'; + | 'nostr' + | 'benfen'; export type CommonResponseParams = { path: string; diff --git a/packages/core/src/types/api/benfenGetAddress.ts b/packages/core/src/types/api/benfenGetAddress.ts new file mode 100644 index 000000000..7a97f93fe --- /dev/null +++ b/packages/core/src/types/api/benfenGetAddress.ts @@ -0,0 +1,24 @@ +import { BenfenAddress as HardwareBenfenAddress } from '@onekeyfe/hd-transport'; +import type { CommonParams, Response } from '../params'; + +export type BenfenAddress = { + path: string; + pub?: string; +} & HardwareBenfenAddress; + +export type BenfenGetAddressParams = { + path: string | number[]; + showOnOneKey?: boolean; +}; + +export declare function benfenGetAddress( + connectId: string, + deviceId: string, + params: CommonParams & BenfenGetAddressParams +): Response; + +export declare function benfenGetAddress( + connectId: string, + deviceId: string, + params: CommonParams & { bundle?: BenfenGetAddressParams[] } +): Response>; diff --git a/packages/core/src/types/api/benfenGetPublicKey.ts b/packages/core/src/types/api/benfenGetPublicKey.ts new file mode 100644 index 000000000..014056270 --- /dev/null +++ b/packages/core/src/types/api/benfenGetPublicKey.ts @@ -0,0 +1,23 @@ +import type { CommonParams, Response } from '../params'; + +export type BenfenPublicKey = { + path: string; + pub: string; +}; + +export type BenfenGetPublicKeyParams = { + path: string | number[]; + showOnOneKey?: boolean; +}; + +export declare function benfenGetPublicKey( + connectId: string, + deviceId: string, + params: CommonParams & BenfenGetPublicKeyParams +): Response; + +export declare function benfenGetPublicKey( + connectId: string, + deviceId: string, + params: CommonParams & { bundle?: BenfenGetPublicKeyParams[] } +): Response>; diff --git a/packages/core/src/types/api/benfenSignMessage.ts b/packages/core/src/types/api/benfenSignMessage.ts new file mode 100644 index 000000000..b36fc270d --- /dev/null +++ b/packages/core/src/types/api/benfenSignMessage.ts @@ -0,0 +1,13 @@ +import { BenfenMessageSignature } from '@onekeyfe/hd-transport'; +import type { CommonParams, Response } from '../params'; + +export type BenfenSignMessageParams = { + path: string | number[]; + messageHex: string; +}; + +export declare function benfenSignMessage( + connectId: string, + deviceId: string, + params: CommonParams & BenfenSignMessageParams +): Response; diff --git a/packages/core/src/types/api/benfenSignTransaction.ts b/packages/core/src/types/api/benfenSignTransaction.ts new file mode 100644 index 000000000..17f63919e --- /dev/null +++ b/packages/core/src/types/api/benfenSignTransaction.ts @@ -0,0 +1,18 @@ +import { AptosSignedTx as HardwareAptosSignedTx } from '@onekeyfe/hd-transport'; +import type { CommonParams, Response } from '../params'; + +export type BenfenSignedTx = { + path: string; + coinType?: string; +} & HardwareAptosSignedTx; + +export type BenfenSignTransactionParams = { + path: string | number[]; + rawTx?: string; +}; + +export declare function benfenSignTransaction( + connectId: string, + deviceId: string, + params: CommonParams & BenfenSignTransactionParams +): Response; diff --git a/packages/core/src/types/api/export.ts b/packages/core/src/types/api/export.ts index 3561d78fe..d3caf954d 100644 --- a/packages/core/src/types/api/export.ts +++ b/packages/core/src/types/api/export.ts @@ -166,3 +166,8 @@ export type { ScdoSignTransactionParams, ScdoSignedTx } from './scdoSignTransact export type { AlephiumAddress, AlephiumGetAddressParams } from './alephiumGetAddress'; export type { AlephiumSignMessageParams } from './alephiumSignMessage'; export type { AlephiumSignTransactionParams, AlephiumSignedTx } from './alephiumSignTransaction'; + +export type { BenfenAddress, BenfenGetAddressParams } from './benfenGetAddress'; +export type { BenfenPublicKey, BenfenGetPublicKeyParams } from './benfenGetPublicKey'; +export type { BenfenSignMessageParams } from './benfenSignMessage'; +export type { BenfenSignedTx, BenfenSignTransactionParams } from './benfenSignTransaction'; diff --git a/packages/core/src/types/api/index.ts b/packages/core/src/types/api/index.ts index 9675e99b0..968894351 100644 --- a/packages/core/src/types/api/index.ts +++ b/packages/core/src/types/api/index.ts @@ -148,6 +148,11 @@ import { alephiumGetAddress } from './alephiumGetAddress'; import { alephiumSignMessage } from './alephiumSignMessage'; import { alephiumSignTransaction } from './alephiumSignTransaction'; +import { benfenGetAddress } from './benfenGetAddress'; +import { benfenGetPublicKey } from './benfenGetPublicKey'; +import { benfenSignTransaction } from './benfenSignTransaction'; +import { benfenSignMessage } from './benfenSignMessage'; + export * from './export'; export type CoreApi = { @@ -401,4 +406,12 @@ export type CoreApi = { alephiumGetAddress: typeof alephiumGetAddress; alephiumSignMessage: typeof alephiumSignMessage; alephiumSignTransaction: typeof alephiumSignTransaction; + + /** + * Benfen Network + */ + benfenGetAddress: typeof benfenGetAddress; + benfenGetPublicKey: typeof benfenGetPublicKey; + benfenSignTransaction: typeof benfenSignTransaction; + benfenSignMessage: typeof benfenSignMessage; }; diff --git a/packages/hd-ble-sdk/package.json b/packages/hd-ble-sdk/package.json index 97643a67d..000bfdc05 100644 --- a/packages/hd-ble-sdk/package.json +++ b/packages/hd-ble-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-ble-sdk", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -20,8 +20,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-core": "^1.0.14", - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport-react-native": "^1.0.14" + "@onekeyfe/hd-core": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-react-native": "^1.0.15-alpha.0" } } diff --git a/packages/hd-common-connect-sdk/package.json b/packages/hd-common-connect-sdk/package.json index 75dafa4f7..b1d229f71 100644 --- a/packages/hd-common-connect-sdk/package.json +++ b/packages/hd-common-connect-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-common-connect-sdk", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -20,10 +20,10 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-core": "^1.0.14", - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport-http": "^1.0.14", - "@onekeyfe/hd-transport-lowlevel": "^1.0.14", - "@onekeyfe/hd-transport-webusb": "^1.0.14" + "@onekeyfe/hd-core": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-http": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-lowlevel": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.0" } } diff --git a/packages/hd-transport-http/package.json b/packages/hd-transport-http/package.json index 05822e8d6..85c4e95ae 100644 --- a/packages/hd-transport-http/package.json +++ b/packages/hd-transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-http", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "description": "hardware http transport", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", @@ -24,8 +24,8 @@ "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport": "^1.0.14", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport": "^1.0.15-alpha.0", "axios": "^0.27.2" } } diff --git a/packages/hd-transport-lowlevel/package.json b/packages/hd-transport-lowlevel/package.json index 83ae9cba0..b5e156fca 100644 --- a/packages/hd-transport-lowlevel/package.json +++ b/packages/hd-transport-lowlevel/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-lowlevel", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", "main": "dist/index.js", @@ -19,7 +19,7 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport": "^1.0.14" + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport": "^1.0.15-alpha.0" } } diff --git a/packages/hd-transport-react-native/package.json b/packages/hd-transport-react-native/package.json index d6ee9d559..db8103903 100644 --- a/packages/hd-transport-react-native/package.json +++ b/packages/hd-transport-react-native/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-react-native", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", "main": "dist/index.js", @@ -19,8 +19,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport": "^1.0.14", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport": "^1.0.15-alpha.0", "@onekeyfe/react-native-ble-plx": "3.0.1", "react-native-ble-manager": "^8.1.0" } diff --git a/packages/hd-transport-webusb/package.json b/packages/hd-transport-webusb/package.json index 00dc21263..f20ce9fbd 100644 --- a/packages/hd-transport-webusb/package.json +++ b/packages/hd-transport-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-webusb", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", @@ -20,8 +20,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport": "^1.0.14" + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport": "^1.0.15-alpha.0" }, "devDependencies": { "@types/w3c-web-usb": "^1.0.6" diff --git a/packages/hd-transport/package.json b/packages/hd-transport/package.json index d3eaed418..521c7826b 100644 --- a/packages/hd-transport/package.json +++ b/packages/hd-transport/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "description": "> TODO: description", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", diff --git a/packages/hd-transport/src/types/messages.ts b/packages/hd-transport/src/types/messages.ts index 4d84ad1f8..f28300082 100644 --- a/packages/hd-transport/src/types/messages.ts +++ b/packages/hd-transport/src/types/messages.ts @@ -133,6 +133,56 @@ export type AptosMessageSignature = { address: string; }; +// BenfenGetAddress +export type BenfenGetAddress = { + address_n: number[]; + show_display?: boolean; +}; + +// BenfenAddress +export type BenfenAddress = { + address?: string; +}; + +// BenfenSignTx +export type BenfenSignTx = { + address_n: number[]; + raw_tx: string; + data_initial_chunk?: string; + coin_type?: string; + data_length?: number; +}; + +// BenfenSignedTx +export type BenfenSignedTx = { + public_key: string; + signature: string; +}; + +// BenfenTxRequest +export type BenfenTxRequest = { + data_length?: number; + public_key: string; + signature: string; +}; + +// BenfenTxAck +export type BenfenTxAck = { + data_chunk: string; +}; + +// BenfenSignMessage +export type BenfenSignMessage = { + address_n: number[]; + message: string; +}; + +// BenfenMessageSignature +export type BenfenMessageSignature = { + signature: string; + address: string; +}; + // BinanceGetAddress export type BinanceGetAddress = { address_n: number[]; @@ -4055,6 +4105,14 @@ export type MessageType = { AptosMessagePayload: AptosMessagePayload; AptosSignMessage: AptosSignMessage; AptosMessageSignature: AptosMessageSignature; + BenfenGetAddress: BenfenGetAddress; + BenfenAddress: BenfenAddress; + BenfenSignTx: BenfenSignTx; + BenfenSignedTx: BenfenSignedTx; + BenfenTxRequest: BenfenTxRequest; + BenfenTxAck: BenfenTxAck; + BenfenSignMessage: BenfenSignMessage; + BenfenMessageSignature: BenfenMessageSignature; BinanceGetAddress: BinanceGetAddress; BinanceAddress: BinanceAddress; BinanceGetPublicKey: BinanceGetPublicKey; diff --git a/packages/hd-web-sdk/package.json b/packages/hd-web-sdk/package.json index 5fe9a6ed6..6183c68a0 100644 --- a/packages/hd-web-sdk/package.json +++ b/packages/hd-web-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-web-sdk", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -21,10 +21,10 @@ }, "dependencies": { "@onekeyfe/cross-inpage-provider-core": "^0.0.17", - "@onekeyfe/hd-core": "^1.0.14", - "@onekeyfe/hd-shared": "^1.0.14", - "@onekeyfe/hd-transport-http": "^1.0.14", - "@onekeyfe/hd-transport-webusb": "^1.0.14" + "@onekeyfe/hd-core": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-http": "^1.0.15-alpha.0", + "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.0" }, "devDependencies": { "@babel/plugin-proposal-optional-chaining": "^7.17.12", diff --git a/packages/shared/package.json b/packages/shared/package.json index a1e9258c2..fc0acc608 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-shared", - "version": "1.0.14", + "version": "1.0.15-alpha.0", "description": "Hardware SDK's shared tool library", "keywords": [ "Hardware-SDK",