From e53732cf4637e49d0bc8adf481985c2bde1de0a1 Mon Sep 17 00:00:00 2001 From: S2kael Date: Sat, 27 Apr 2024 16:59:13 +0700 Subject: [PATCH 1/4] [Issue-41] Integrate with Avail Ledger App --- .../extension-koni-ui/src/constants/ledger.ts | 11 ++++++ .../extension-web-ui/src/constants/ledger.ts | 11 ++++++ patches/@polkadot+hw-ledger+12.6.2.patch | 12 +++++++ patches/@zondax+ledger-substrate+0.41.3.patch | 34 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 patches/@polkadot+hw-ledger+12.6.2.patch create mode 100644 patches/@zondax+ledger-substrate+0.41.3.patch diff --git a/packages/extension-koni-ui/src/constants/ledger.ts b/packages/extension-koni-ui/src/constants/ledger.ts index aa0e97ed6f..51d175da52 100644 --- a/packages/extension-koni-ui/src/constants/ledger.ts +++ b/packages/extension-koni-ui/src/constants/ledger.ts @@ -5,6 +5,17 @@ import { ChainInfoMap } from '@subwallet/chain-list'; import { ExtrinsicType, LedgerNetwork } from '@subwallet/extension-base/background/KoniTypes'; export const PredefinedLedgerNetwork: LedgerNetwork[] = [ + { + accountName: 'Avail', + appName: 'Avail', + networkName: 'Avail network', + genesisHash: ChainInfoMap.availTuringTest.substrateInfo?.genesisHash || '0xd3d2f3a3495dc597434a99d7d449ebad6616db45e4e4f178f31cc6fa14378b70', + icon: 'substrate', + network: 'avail', + slug: ChainInfoMap.availTuringTest.slug, + isDevMode: true, + isEthereum: false + }, { accountName: 'Polkadot', appName: 'Polkadot', diff --git a/packages/extension-web-ui/src/constants/ledger.ts b/packages/extension-web-ui/src/constants/ledger.ts index 490008c107..95a9512396 100644 --- a/packages/extension-web-ui/src/constants/ledger.ts +++ b/packages/extension-web-ui/src/constants/ledger.ts @@ -5,6 +5,17 @@ import { ChainInfoMap } from '@subwallet/chain-list'; import { ExtrinsicType, LedgerNetwork } from '@subwallet/extension-base/background/KoniTypes'; export const PredefinedLedgerNetwork: LedgerNetwork[] = [ + { + accountName: 'Avail', + appName: 'Avail', + networkName: 'Avail network', + genesisHash: ChainInfoMap.availTuringTest.substrateInfo?.genesisHash || '0xd3d2f3a3495dc597434a99d7d449ebad6616db45e4e4f178f31cc6fa14378b70', + icon: 'substrate', + network: 'avail', + slug: ChainInfoMap.availTuringTest.slug, + isDevMode: true, + isEthereum: false + }, { accountName: 'Polkadot', appName: 'Polkadot', diff --git a/patches/@polkadot+hw-ledger+12.6.2.patch b/patches/@polkadot+hw-ledger+12.6.2.patch new file mode 100644 index 0000000000..9dbdf99e5c --- /dev/null +++ b/patches/@polkadot+hw-ledger+12.6.2.patch @@ -0,0 +1,12 @@ +diff --git a/node_modules/@polkadot/hw-ledger/defaults.js b/node_modules/@polkadot/hw-ledger/defaults.js +index 9f06432..97efba8 100644 +--- a/node_modules/@polkadot/hw-ledger/defaults.js ++++ b/node_modules/@polkadot/hw-ledger/defaults.js +@@ -37,5 +37,6 @@ export const ledgerApps = { + unique: 'Unique', + vtb: 'VTB', + xxnetwork: 'XXNetwork', +- zeitgeist: 'Zeitgeist' ++ zeitgeist: 'Zeitgeist', ++ avail: 'Avail' + }; diff --git a/patches/@zondax+ledger-substrate+0.41.3.patch b/patches/@zondax+ledger-substrate+0.41.3.patch new file mode 100644 index 0000000000..3a19b2afee --- /dev/null +++ b/patches/@zondax+ledger-substrate+0.41.3.patch @@ -0,0 +1,34 @@ +diff --git a/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js b/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js +index 175ac7d..c0c189e 100644 +--- a/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js ++++ b/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js +@@ -107,4 +107,9 @@ function newBifrostKusamaApp(transport) { + return (0, supported_apps_1.newSubstrateApp)(transport, "BifrostKusama"); + } + exports.newBifrostKusamaApp = newBifrostKusamaApp; ++ ++function newAvailApp(transport) { ++ return (0, supported_apps_1.newSubstrateApp)(transport, "Avail"); ++} ++exports.newBifrostKusamaApp = newAvailApp; + //# sourceMappingURL=legacy_apps.js.map +diff --git a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js +index 5363e34..b68c5ce 100644 +--- a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js ++++ b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js +@@ -299,6 +299,6 @@ exports.supportedApps = [ + cla: 0xbc, + slip0044: 0x800002c5, + ss58_addr_type: 42, +- }, ++ } + ]; + //# sourceMappingURL=supported_apps.js.map +diff --git a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map +index 0ba007a..dc175f4 100644 +--- a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map ++++ b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map +@@ -1 +1 @@ +-{"version":3,"file":"supported_apps.js","sourceRoot":"","sources":["../src/supported_apps.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;mFAemF;AACnF,mDAA+C;AAI/C,SAAgB,eAAe,CAAC,SAAoB,EAAE,SAAiB;IACrE,MAAM,YAAY,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAClE,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,IAAI,YAAY,IAAI,IAAI,EAAE;QACxB,OAAO,IAAI,4BAAY,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC7E;IACD,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,gBAAgB,CAAC,CAAC;AACvD,CAAC;AARD,0CAQC;AAED,SAAgB,YAAY,CAAC,SAAiB;IAC5C,MAAM,MAAM,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAC5D,OAAO,GAA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IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;CACF,CAAC","sourcesContent":["/** ******************************************************************************\n * (c) 2019 - 2022 ZondaX AG\n * (c) 2016-2017 Ledger\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\nimport { SubstrateApp } from \"./substrate_app\";\nimport { type SubstrateAppParams } from \"./common\";\nimport type Transport from \"@ledgerhq/hw-transport\";\n\nexport function newSubstrateApp(transport: Transport, chainName: string) {\n const requestedApp = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n if (requestedApp != null) {\n return new SubstrateApp(transport, requestedApp.cla, requestedApp.slip0044);\n }\n throw new Error(`Error: ${chainName} not supported`);\n}\n\nexport function getAppParams(chainName: string) {\n const params = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n\n return params;\n}\n\nexport const supportedApps: SubstrateAppParams[] = [\n {\n name: \"Polkadot\",\n cla: 0x90,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Polymesh\",\n cla: 0x91,\n slip0044: 0x80000253,\n ss58_addr_type: 12,\n },\n {\n name: \"Dock\",\n cla: 0x92,\n slip0044: 0x80000252,\n ss58_addr_type: 22,\n },\n {\n name: \"Centrifuge\",\n cla: 0x93,\n slip0044: 0x800002eb,\n ss58_addr_type: 36,\n },\n {\n name: \"Edgeware\",\n cla: 0x94,\n slip0044: 0x8000020b,\n ss58_addr_type: 7,\n },\n {\n name: \"Equilibrium\",\n cla: 0x95,\n slip0044: 0x85f5e0fd,\n ss58_addr_type: 67,\n },\n {\n name: \"Statemint\",\n cla: 0x96,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Statemine\",\n cla: 0x97,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Nodle\",\n cla: 0x98,\n slip0044: 0x800003eb,\n ss58_addr_type: 37,\n },\n {\n name: \"Kusama\",\n cla: 0x99,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Karura\",\n cla: 0x9a,\n slip0044: 0x800002ae,\n ss58_addr_type: 8,\n },\n {\n name: \"Acala\",\n cla: 0x9b,\n slip0044: 0x80000313,\n ss58_addr_type: 10,\n },\n {\n name: \"VTB\",\n cla: 0x9c,\n slip0044: 0x800002b6,\n ss58_addr_type: 42,\n },\n {\n name: \"Peer\",\n cla: 0x9d,\n slip0044: 0x800002ce,\n ss58_addr_type: 42,\n },\n {\n name: \"Genshiro\",\n cla: 0x9e,\n slip0044: 0x85f5e0fc,\n ss58_addr_type: 67,\n },\n {\n name: \"Sora\",\n cla: 0x9f,\n slip0044: 0x80000269,\n ss58_addr_type: 69,\n },\n {\n name: \"Polkadex\",\n cla: 0xa0,\n slip0044: 0x8000031f,\n ss58_addr_type: 88,\n },\n {\n name: \"Bifrost\",\n cla: 0xa1,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Reef\",\n cla: 0xa2,\n slip0044: 0x80000333,\n ss58_addr_type: 42,\n },\n {\n name: \"XXNetwork\",\n cla: 0xa3,\n slip0044: 0x800007a3,\n ss58_addr_type: 55,\n },\n {\n name: \"AlephZero\",\n cla: 0xa4,\n slip0044: 0x80000283,\n ss58_addr_type: 42,\n },\n {\n name: \"Interlay\",\n cla: 0xa5,\n slip0044: 0x80000162,\n ss58_addr_type: 2032,\n },\n {\n name: \"Parallel\",\n cla: 0xa6,\n slip0044: 0x80000162,\n ss58_addr_type: 172,\n },\n {\n name: \"Picasso\",\n cla: 0xa7,\n slip0044: 0x800001b2,\n ss58_addr_type: 49,\n },\n {\n name: \"Composable\",\n cla: 0xa8,\n slip0044: 0x80000162,\n ss58_addr_type: 49,\n },\n {\n name: \"Astar\",\n cla: 0xa9,\n slip0044: 0x8000032a,\n ss58_addr_type: 5,\n },\n {\n name: \"OriginTrail\",\n cla: 0xaa,\n slip0044: 0x80000162,\n ss58_addr_type: 101,\n },\n {\n name: \"HydraDX\",\n cla: 0xab,\n slip0044: 0x80000162,\n ss58_addr_type: 63,\n },\n {\n name: \"Stafi\",\n cla: 0xac,\n slip0044: 0x8000038b,\n ss58_addr_type: 20,\n },\n {\n name: \"Unique\",\n cla: 0xad,\n slip0044: 0x80000295,\n ss58_addr_type: 7391,\n },\n {\n name: \"BifrostKusama\",\n cla: 0xae,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Phala\",\n cla: 0xaf,\n slip0044: 0x80000162,\n ss58_addr_type: 30,\n },\n {\n name: \"Khala\",\n cla: 0xb1,\n slip0044: 0x800001b2,\n ss58_addr_type: 30,\n },\n {\n name: \"Darwinia\",\n cla: 0xb2,\n slip0044: 0x80000162,\n ss58_addr_type: 18,\n },\n {\n name: \"Ajuna\",\n cla: 0xb3,\n slip0044: 0x80000162,\n ss58_addr_type: 1328,\n },\n {\n name: \"Bittensor\",\n cla: 0xb4,\n slip0044: 0x800003ed,\n ss58_addr_type: 42,\n },\n {\n name: \"Ternoa\",\n cla: 0xb5,\n slip0044: 0x800003e3,\n ss58_addr_type: 42,\n },\n {\n name: \"Pendulum\",\n cla: 0xb6,\n slip0044: 0x80000162,\n ss58_addr_type: 56,\n },\n {\n name: \"Zeitgeist\",\n cla: 0xb7,\n slip0044: 0x80000162,\n ss58_addr_type: 73,\n },\n {\n name: \"Joystream\",\n cla: 0xb8,\n slip0044: 0x80000219,\n ss58_addr_type: 126,\n },\n {\n name: \"Enjin\",\n cla: 0xb9,\n slip0044: 0x80000483,\n ss58_addr_type: 2135,\n },\n {\n name: \"Matrixchain\",\n cla: 0xba,\n slip0044: 0x80000483,\n ss58_addr_type: 1110,\n },\n {\n name: \"Quartz\",\n cla: 0xbb,\n slip0044: 0x80000277,\n ss58_addr_type: 255,\n },\n {\n name: \"Avail\",\n cla: 0xbc,\n slip0044: 0x800002c5,\n ss58_addr_type: 42,\n },\n];\n"]} +\ No newline at end of file ++{"version":3,"file":"supported_apps.js","sourceRoot":"","sources":["../src/supported_apps.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;mFAemF;AACnF,mDAA+C;AAI/C,SAAgB,eAAe,CAAC,SAAoB,EAAE,SAAiB;IACrE,MAAM,YAAY,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAClE,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,IAAI,YAAY,IAAI,IAAI,EAAE;QACxB,OAAO,IAAI,4BAAY,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC7E;IACD,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,gBAAgB,CAAC,CAAC;AACvD,CAAC;AARD,0CAQC;AAED,SAAgB,YAAY,CAAC,SAAiB;IAC5C,MAAM,MAAM,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAC5D,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,oCAMC;AAEY,QAAA,aAAa,GAAyB;IACjD;QACE,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,CAAC;KAClB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAA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AAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;CACF,CAAC","sourcesContent":["/** ******************************************************************************\n * (c) 2019 - 2022 ZondaX AG\n * (c) 2016-2017 Ledger\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\nimport { SubstrateApp } from \"./substrate_app\";\nimport { type SubstrateAppParams } from \"./common\";\nimport type Transport from \"@ledgerhq/hw-transport\";\n\nexport function newSubstrateApp(transport: Transport, chainName: string) {\n const requestedApp = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n if (requestedApp != null) {\n return new SubstrateApp(transport, requestedApp.cla, requestedApp.slip0044);\n }\n throw new Error(`Error: ${chainName} not supported`);\n}\n\nexport function getAppParams(chainName: string) {\n const params = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n\n return params;\n}\n\nexport const supportedApps: SubstrateAppParams[] = [\n {\n name: \"Polkadot\",\n cla: 0x90,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Polymesh\",\n cla: 0x91,\n slip0044: 0x80000253,\n ss58_addr_type: 12,\n },\n {\n name: \"Dock\",\n cla: 0x92,\n slip0044: 0x80000252,\n ss58_addr_type: 22,\n },\n {\n name: \"Centrifuge\",\n cla: 0x93,\n slip0044: 0x800002eb,\n ss58_addr_type: 36,\n },\n {\n name: \"Edgeware\",\n cla: 0x94,\n slip0044: 0x8000020b,\n ss58_addr_type: 7,\n },\n {\n name: \"Equilibrium\",\n cla: 0x95,\n slip0044: 0x85f5e0fd,\n ss58_addr_type: 67,\n },\n {\n name: \"Statemint\",\n cla: 0x96,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Statemine\",\n cla: 0x97,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Nodle\",\n cla: 0x98,\n slip0044: 0x800003eb,\n ss58_addr_type: 37,\n },\n {\n name: \"Kusama\",\n cla: 0x99,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Karura\",\n cla: 0x9a,\n slip0044: 0x800002ae,\n ss58_addr_type: 8,\n },\n {\n name: \"Acala\",\n cla: 0x9b,\n slip0044: 0x80000313,\n ss58_addr_type: 10,\n },\n {\n name: \"VTB\",\n cla: 0x9c,\n slip0044: 0x800002b6,\n ss58_addr_type: 42,\n },\n {\n name: \"Peer\",\n cla: 0x9d,\n slip0044: 0x800002ce,\n ss58_addr_type: 42,\n },\n {\n name: \"Genshiro\",\n cla: 0x9e,\n slip0044: 0x85f5e0fc,\n ss58_addr_type: 67,\n },\n {\n name: \"Sora\",\n cla: 0x9f,\n slip0044: 0x80000269,\n ss58_addr_type: 69,\n },\n {\n name: \"Polkadex\",\n cla: 0xa0,\n slip0044: 0x8000031f,\n ss58_addr_type: 88,\n },\n {\n name: \"Bifrost\",\n cla: 0xa1,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Reef\",\n cla: 0xa2,\n slip0044: 0x80000333,\n ss58_addr_type: 42,\n },\n {\n name: \"XXNetwork\",\n cla: 0xa3,\n slip0044: 0x800007a3,\n ss58_addr_type: 55,\n },\n {\n name: \"AlephZero\",\n cla: 0xa4,\n slip0044: 0x80000283,\n ss58_addr_type: 42,\n },\n {\n name: \"Interlay\",\n cla: 0xa5,\n slip0044: 0x80000162,\n ss58_addr_type: 2032,\n },\n {\n name: \"Parallel\",\n cla: 0xa6,\n slip0044: 0x80000162,\n ss58_addr_type: 172,\n },\n {\n name: \"Picasso\",\n cla: 0xa7,\n slip0044: 0x800001b2,\n ss58_addr_type: 49,\n },\n {\n name: \"Composable\",\n cla: 0xa8,\n slip0044: 0x80000162,\n ss58_addr_type: 49,\n },\n {\n name: \"Astar\",\n cla: 0xa9,\n slip0044: 0x8000032a,\n ss58_addr_type: 5,\n },\n {\n name: \"OriginTrail\",\n cla: 0xaa,\n slip0044: 0x80000162,\n ss58_addr_type: 101,\n },\n {\n name: \"HydraDX\",\n cla: 0xab,\n slip0044: 0x80000162,\n ss58_addr_type: 63,\n },\n {\n name: \"Stafi\",\n cla: 0xac,\n slip0044: 0x8000038b,\n ss58_addr_type: 20,\n },\n {\n name: \"Unique\",\n cla: 0xad,\n slip0044: 0x80000295,\n ss58_addr_type: 7391,\n },\n {\n name: \"BifrostKusama\",\n cla: 0xae,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Phala\",\n cla: 0xaf,\n slip0044: 0x80000162,\n ss58_addr_type: 30,\n },\n {\n name: \"Khala\",\n cla: 0xb1,\n slip0044: 0x800001b2,\n ss58_addr_type: 30,\n },\n {\n name: \"Darwinia\",\n cla: 0xb2,\n slip0044: 0x80000162,\n ss58_addr_type: 18,\n },\n {\n name: \"Ajuna\",\n cla: 0xb3,\n slip0044: 0x80000162,\n ss58_addr_type: 1328,\n },\n {\n name: \"Bittensor\",\n cla: 0xb4,\n slip0044: 0x800003ed,\n ss58_addr_type: 42,\n },\n {\n name: \"Ternoa\",\n cla: 0xb5,\n slip0044: 0x800003e3,\n ss58_addr_type: 42,\n },\n {\n name: \"Pendulum\",\n cla: 0xb6,\n slip0044: 0x80000162,\n ss58_addr_type: 56,\n },\n {\n name: \"Zeitgeist\",\n cla: 0xb7,\n slip0044: 0x80000162,\n ss58_addr_type: 73,\n },\n {\n name: \"Joystream\",\n cla: 0xb8,\n slip0044: 0x80000219,\n ss58_addr_type: 126,\n },\n {\n name: \"Enjin\",\n cla: 0xb9,\n slip0044: 0x80000483,\n ss58_addr_type: 2135,\n },\n {\n name: \"Matrixchain\",\n cla: 0xba,\n slip0044: 0x80000483,\n ss58_addr_type: 1110,\n },\n {\n name: \"Quartz\",\n cla: 0xbb,\n slip0044: 0x80000277,\n ss58_addr_type: 255,\n },\n {\n name: \"Avail\",\n cla: 0xbc,\n slip0044: 0x800002c5,\n ss58_addr_type: 42,\n }\n];\n"]} From 0707ef35c14dbf8dba903ddf5d5cce3ea915a246 Mon Sep 17 00:00:00 2001 From: S2kael Date: Thu, 2 May 2024 10:07:12 +0700 Subject: [PATCH 2/4] [Issue-41] Update lib --- package.json | 1 + patches/@zondax+ledger-substrate+0.41.3.patch | 34 ------ yarn.lock | 113 ++---------------- 3 files changed, 11 insertions(+), 137 deletions(-) delete mode 100644 patches/@zondax+ledger-substrate+0.41.3.patch diff --git a/package.json b/package.json index 697be3ee58..bb78c91cf5 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "@subwallet/chain-list": "0.2.57", "@subwallet/keyring": "^0.1.5", "@subwallet/ui-keyring": "^0.1.5", + "@zondax/ledger-substrate": "^0.42.1", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^29.3.1", "browserify-sign": "^4.2.2", diff --git a/patches/@zondax+ledger-substrate+0.41.3.patch b/patches/@zondax+ledger-substrate+0.41.3.patch deleted file mode 100644 index 3a19b2afee..0000000000 --- a/patches/@zondax+ledger-substrate+0.41.3.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js b/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js -index 175ac7d..c0c189e 100644 ---- a/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js -+++ b/node_modules/@zondax/ledger-substrate/dist/legacy_apps.js -@@ -107,4 +107,9 @@ function newBifrostKusamaApp(transport) { - return (0, supported_apps_1.newSubstrateApp)(transport, "BifrostKusama"); - } - exports.newBifrostKusamaApp = newBifrostKusamaApp; -+ -+function newAvailApp(transport) { -+ return (0, supported_apps_1.newSubstrateApp)(transport, "Avail"); -+} -+exports.newBifrostKusamaApp = newAvailApp; - //# sourceMappingURL=legacy_apps.js.map -diff --git a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js -index 5363e34..b68c5ce 100644 ---- a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js -+++ b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js -@@ -299,6 +299,6 @@ exports.supportedApps = [ - cla: 0xbc, - slip0044: 0x800002c5, - ss58_addr_type: 42, -- }, -+ } - ]; - //# sourceMappingURL=supported_apps.js.map -diff --git a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map -index 0ba007a..dc175f4 100644 ---- a/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map -+++ b/node_modules/@zondax/ledger-substrate/dist/supported_apps.js.map -@@ -1 +1 @@ --{"version":3,"file":"supported_apps.js","sourceRoot":"","sources":["../src/supported_apps.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;mFAemF;AACnF,mDAA+C;AAI/C,SAAgB,eAAe,CAAC,SAAoB,EAAE,SAAiB;IACrE,MAAM,YAAY,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,G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,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;CACF,CAAC","sourcesContent":["/** ******************************************************************************\n * (c) 2019 - 2022 ZondaX AG\n * (c) 2016-2017 Ledger\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\nimport { SubstrateApp } from \"./substrate_app\";\nimport { type SubstrateAppParams } from \"./common\";\nimport type Transport from \"@ledgerhq/hw-transport\";\n\nexport function newSubstrateApp(transport: Transport, chainName: string) {\n const requestedApp = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n if (requestedApp != null) {\n return new SubstrateApp(transport, requestedApp.cla, requestedApp.slip0044);\n }\n throw new Error(`Error: ${chainName} not supported`);\n}\n\nexport function getAppParams(chainName: string) {\n const params = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n\n return params;\n}\n\nexport const supportedApps: SubstrateAppParams[] = [\n {\n name: \"Polkadot\",\n cla: 0x90,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Polymesh\",\n cla: 0x91,\n slip0044: 0x80000253,\n ss58_addr_type: 12,\n },\n {\n name: \"Dock\",\n cla: 0x92,\n slip0044: 0x80000252,\n ss58_addr_type: 22,\n },\n {\n name: \"Centrifuge\",\n cla: 0x93,\n slip0044: 0x800002eb,\n ss58_addr_type: 36,\n },\n {\n name: \"Edgeware\",\n cla: 0x94,\n slip0044: 0x8000020b,\n ss58_addr_type: 7,\n },\n {\n name: \"Equilibrium\",\n cla: 0x95,\n slip0044: 0x85f5e0fd,\n ss58_addr_type: 67,\n },\n {\n name: \"Statemint\",\n cla: 0x96,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Statemine\",\n cla: 0x97,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Nodle\",\n cla: 0x98,\n slip0044: 0x800003eb,\n ss58_addr_type: 37,\n },\n {\n name: \"Kusama\",\n cla: 0x99,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Karura\",\n cla: 0x9a,\n slip0044: 0x800002ae,\n ss58_addr_type: 8,\n },\n {\n name: \"Acala\",\n cla: 0x9b,\n slip0044: 0x80000313,\n ss58_addr_type: 10,\n },\n {\n name: \"VTB\",\n cla: 0x9c,\n slip0044: 0x800002b6,\n ss58_addr_type: 42,\n },\n {\n name: \"Peer\",\n cla: 0x9d,\n slip0044: 0x800002ce,\n ss58_addr_type: 42,\n },\n {\n name: \"Genshiro\",\n cla: 0x9e,\n slip0044: 0x85f5e0fc,\n ss58_addr_type: 67,\n },\n {\n name: \"Sora\",\n cla: 0x9f,\n slip0044: 0x80000269,\n ss58_addr_type: 69,\n },\n {\n name: \"Polkadex\",\n cla: 0xa0,\n slip0044: 0x8000031f,\n ss58_addr_type: 88,\n },\n {\n name: \"Bifrost\",\n cla: 0xa1,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Reef\",\n cla: 0xa2,\n slip0044: 0x80000333,\n ss58_addr_type: 42,\n },\n {\n name: \"XXNetwork\",\n cla: 0xa3,\n slip0044: 0x800007a3,\n ss58_addr_type: 55,\n },\n {\n name: \"AlephZero\",\n cla: 0xa4,\n slip0044: 0x80000283,\n ss58_addr_type: 42,\n },\n {\n name: \"Interlay\",\n cla: 0xa5,\n slip0044: 0x80000162,\n ss58_addr_type: 2032,\n },\n {\n name: \"Parallel\",\n cla: 0xa6,\n slip0044: 0x80000162,\n ss58_addr_type: 172,\n },\n {\n name: \"Picasso\",\n cla: 0xa7,\n slip0044: 0x800001b2,\n ss58_addr_type: 49,\n },\n {\n name: \"Composable\",\n cla: 0xa8,\n slip0044: 0x80000162,\n ss58_addr_type: 49,\n },\n {\n name: \"Astar\",\n cla: 0xa9,\n slip0044: 0x8000032a,\n ss58_addr_type: 5,\n },\n {\n name: \"OriginTrail\",\n cla: 0xaa,\n slip0044: 0x80000162,\n ss58_addr_type: 101,\n },\n {\n name: \"HydraDX\",\n cla: 0xab,\n slip0044: 0x80000162,\n ss58_addr_type: 63,\n },\n {\n name: \"Stafi\",\n cla: 0xac,\n slip0044: 0x8000038b,\n ss58_addr_type: 20,\n },\n {\n name: \"Unique\",\n cla: 0xad,\n slip0044: 0x80000295,\n ss58_addr_type: 7391,\n },\n {\n name: \"BifrostKusama\",\n cla: 0xae,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Phala\",\n cla: 0xaf,\n slip0044: 0x80000162,\n ss58_addr_type: 30,\n },\n {\n name: \"Khala\",\n cla: 0xb1,\n slip0044: 0x800001b2,\n ss58_addr_type: 30,\n },\n {\n name: \"Darwinia\",\n cla: 0xb2,\n slip0044: 0x80000162,\n ss58_addr_type: 18,\n },\n {\n name: \"Ajuna\",\n cla: 0xb3,\n slip0044: 0x80000162,\n ss58_addr_type: 1328,\n },\n {\n name: \"Bittensor\",\n cla: 0xb4,\n slip0044: 0x800003ed,\n ss58_addr_type: 42,\n },\n {\n name: \"Ternoa\",\n cla: 0xb5,\n slip0044: 0x800003e3,\n ss58_addr_type: 42,\n },\n {\n name: \"Pendulum\",\n cla: 0xb6,\n slip0044: 0x80000162,\n ss58_addr_type: 56,\n },\n {\n name: \"Zeitgeist\",\n cla: 0xb7,\n slip0044: 0x80000162,\n ss58_addr_type: 73,\n },\n {\n name: \"Joystream\",\n cla: 0xb8,\n slip0044: 0x80000219,\n ss58_addr_type: 126,\n },\n {\n name: \"Enjin\",\n cla: 0xb9,\n slip0044: 0x80000483,\n ss58_addr_type: 2135,\n },\n {\n name: \"Matrixchain\",\n cla: 0xba,\n slip0044: 0x80000483,\n ss58_addr_type: 1110,\n },\n {\n name: \"Quartz\",\n cla: 0xbb,\n slip0044: 0x80000277,\n ss58_addr_type: 255,\n },\n {\n name: \"Avail\",\n cla: 0xbc,\n slip0044: 0x800002c5,\n ss58_addr_type: 42,\n },\n];\n"]} -\ No newline at end of file -+{"version":3,"file":"supported_apps.js","sourceRoot":"","sources":["../src/supported_apps.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;mFAemF;AACnF,mDAA+C;AAI/C,SAAgB,eAAe,CAAC,SAAoB,EAAE,SAAiB;IACrE,MAAM,YAAY,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAClE,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,IAAI,YAAY,IAAI,IAAI,EAAE;QACxB,OAAO,IAAI,4BAAY,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC7E;IACD,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,gBAAgB,CAAC,CAAC;AACvD,CAAC;AARD,0CAQC;AAED,SAAgB,YAAY,CAAC,SAAiB;IAC5C,MAAM,MAAM,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;QAC5D,OAAO,GAAG,CAAC,IAAI,CAAC,W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E,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,EAAE;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,IAAI;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,GAAG;KACpB;CACF,CAAC","sourcesContent":["/** ******************************************************************************\n * (c) 2019 - 2022 ZondaX AG\n * (c) 2016-2017 Ledger\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\nimport { SubstrateApp } from \"./substrate_app\";\nimport { type SubstrateAppParams } from \"./common\";\nimport type Transport from \"@ledgerhq/hw-transport\";\n\nexport function newSubstrateApp(transport: Transport, chainName: string) {\n const requestedApp = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n if (requestedApp != null) {\n return new SubstrateApp(transport, requestedApp.cla, requestedApp.slip0044);\n }\n throw new Error(`Error: ${chainName} not supported`);\n}\n\nexport function getAppParams(chainName: string) {\n const params = supportedApps.find((app: SubstrateAppParams) => {\n return app.name.toLowerCase() === chainName.toLowerCase();\n });\n\n return params;\n}\n\nexport const supportedApps: SubstrateAppParams[] = [\n {\n name: \"Polkadot\",\n cla: 0x90,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Polymesh\",\n cla: 0x91,\n slip0044: 0x80000253,\n ss58_addr_type: 12,\n },\n {\n name: \"Dock\",\n cla: 0x92,\n slip0044: 0x80000252,\n ss58_addr_type: 22,\n },\n {\n name: \"Centrifuge\",\n cla: 0x93,\n slip0044: 0x800002eb,\n ss58_addr_type: 36,\n },\n {\n name: \"Edgeware\",\n cla: 0x94,\n slip0044: 0x8000020b,\n ss58_addr_type: 7,\n },\n {\n name: \"Equilibrium\",\n cla: 0x95,\n slip0044: 0x85f5e0fd,\n ss58_addr_type: 67,\n },\n {\n name: \"Statemint\",\n cla: 0x96,\n slip0044: 0x80000162,\n ss58_addr_type: 0,\n },\n {\n name: \"Statemine\",\n cla: 0x97,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Nodle\",\n cla: 0x98,\n slip0044: 0x800003eb,\n ss58_addr_type: 37,\n },\n {\n name: \"Kusama\",\n cla: 0x99,\n slip0044: 0x800001b2,\n ss58_addr_type: 2,\n },\n {\n name: \"Karura\",\n cla: 0x9a,\n slip0044: 0x800002ae,\n ss58_addr_type: 8,\n },\n {\n name: \"Acala\",\n cla: 0x9b,\n slip0044: 0x80000313,\n ss58_addr_type: 10,\n },\n {\n name: \"VTB\",\n cla: 0x9c,\n slip0044: 0x800002b6,\n ss58_addr_type: 42,\n },\n {\n name: \"Peer\",\n cla: 0x9d,\n slip0044: 0x800002ce,\n ss58_addr_type: 42,\n },\n {\n name: \"Genshiro\",\n cla: 0x9e,\n slip0044: 0x85f5e0fc,\n ss58_addr_type: 67,\n },\n {\n name: \"Sora\",\n cla: 0x9f,\n slip0044: 0x80000269,\n ss58_addr_type: 69,\n },\n {\n name: \"Polkadex\",\n cla: 0xa0,\n slip0044: 0x8000031f,\n ss58_addr_type: 88,\n },\n {\n name: \"Bifrost\",\n cla: 0xa1,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Reef\",\n cla: 0xa2,\n slip0044: 0x80000333,\n ss58_addr_type: 42,\n },\n {\n name: \"XXNetwork\",\n cla: 0xa3,\n slip0044: 0x800007a3,\n ss58_addr_type: 55,\n },\n {\n name: \"AlephZero\",\n cla: 0xa4,\n slip0044: 0x80000283,\n ss58_addr_type: 42,\n },\n {\n name: \"Interlay\",\n cla: 0xa5,\n slip0044: 0x80000162,\n ss58_addr_type: 2032,\n },\n {\n name: \"Parallel\",\n cla: 0xa6,\n slip0044: 0x80000162,\n ss58_addr_type: 172,\n },\n {\n name: \"Picasso\",\n cla: 0xa7,\n slip0044: 0x800001b2,\n ss58_addr_type: 49,\n },\n {\n name: \"Composable\",\n cla: 0xa8,\n slip0044: 0x80000162,\n ss58_addr_type: 49,\n },\n {\n name: \"Astar\",\n cla: 0xa9,\n slip0044: 0x8000032a,\n ss58_addr_type: 5,\n },\n {\n name: \"OriginTrail\",\n cla: 0xaa,\n slip0044: 0x80000162,\n ss58_addr_type: 101,\n },\n {\n name: \"HydraDX\",\n cla: 0xab,\n slip0044: 0x80000162,\n ss58_addr_type: 63,\n },\n {\n name: \"Stafi\",\n cla: 0xac,\n slip0044: 0x8000038b,\n ss58_addr_type: 20,\n },\n {\n name: \"Unique\",\n cla: 0xad,\n slip0044: 0x80000295,\n ss58_addr_type: 7391,\n },\n {\n name: \"BifrostKusama\",\n cla: 0xae,\n slip0044: 0x80000314,\n ss58_addr_type: 6,\n },\n {\n name: \"Phala\",\n cla: 0xaf,\n slip0044: 0x80000162,\n ss58_addr_type: 30,\n },\n {\n name: \"Khala\",\n cla: 0xb1,\n slip0044: 0x800001b2,\n ss58_addr_type: 30,\n },\n {\n name: \"Darwinia\",\n cla: 0xb2,\n slip0044: 0x80000162,\n ss58_addr_type: 18,\n },\n {\n name: \"Ajuna\",\n cla: 0xb3,\n slip0044: 0x80000162,\n ss58_addr_type: 1328,\n },\n {\n name: \"Bittensor\",\n cla: 0xb4,\n slip0044: 0x800003ed,\n ss58_addr_type: 42,\n },\n {\n name: \"Ternoa\",\n cla: 0xb5,\n slip0044: 0x800003e3,\n ss58_addr_type: 42,\n },\n {\n name: \"Pendulum\",\n cla: 0xb6,\n slip0044: 0x80000162,\n ss58_addr_type: 56,\n },\n {\n name: \"Zeitgeist\",\n cla: 0xb7,\n slip0044: 0x80000162,\n ss58_addr_type: 73,\n },\n {\n name: \"Joystream\",\n cla: 0xb8,\n slip0044: 0x80000219,\n ss58_addr_type: 126,\n },\n {\n name: \"Enjin\",\n cla: 0xb9,\n slip0044: 0x80000483,\n ss58_addr_type: 2135,\n },\n {\n name: \"Matrixchain\",\n cla: 0xba,\n slip0044: 0x80000483,\n ss58_addr_type: 1110,\n },\n {\n name: \"Quartz\",\n cla: 0xbb,\n slip0044: 0x80000277,\n ss58_addr_type: 255,\n },\n {\n name: \"Avail\",\n cla: 0xbc,\n slip0044: 0x800002c5,\n ss58_addr_type: 42,\n }\n];\n"]} diff --git a/yarn.lock b/yarn.lock index e76cd21497..a3f5f7c5d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3481,18 +3481,6 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/devices@npm:^8.0.2": - version: 8.0.2 - resolution: "@ledgerhq/devices@npm:8.0.2" - dependencies: - "@ledgerhq/errors": ^6.12.5 - "@ledgerhq/logs": ^6.10.1 - rxjs: 6 - semver: ^7.3.5 - checksum: e6be750212c55f612f8802ee66b43b863358412da6872f11933a0d3a1d0056f5dabf34ad31561d1b3a6ce95c60c345211fb9079b0a59d39b86cd4495f6602076 - languageName: node - linkType: hard - "@ledgerhq/devices@npm:^8.2.0": version: 8.2.0 resolution: "@ledgerhq/devices@npm:8.2.0" @@ -3520,13 +3508,6 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/errors@npm:^6.12.5": - version: 6.12.5 - resolution: "@ledgerhq/errors@npm:6.12.5" - checksum: 7758d10ba80f4f0e14b58fc74b512210c6e6472a381b2395b1264090e57d96272967d4b43be1217bde1af69454772dd3cbcd8c283eabbcad6e3c3a86a0e0e089 - languageName: node - linkType: hard - "@ledgerhq/errors@npm:^6.12.6, @ledgerhq/errors@npm:^6.16.1": version: 6.16.1 resolution: "@ledgerhq/errors@npm:6.16.1" @@ -3616,17 +3597,6 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/hw-transport@npm:^6.27.1": - version: 6.28.3 - resolution: "@ledgerhq/hw-transport@npm:6.28.3" - dependencies: - "@ledgerhq/devices": ^8.0.2 - "@ledgerhq/errors": ^6.12.5 - events: ^3.3.0 - checksum: 0d69fba365296fb3647afe3ed766fc175d2145a8ec3d8fa88c040d7ab3ac5e8e79b2dfa18ca0d5fef265815cc139f2461342333c069568260e9815dd7c800333 - languageName: node - linkType: hard - "@ledgerhq/hw-transport@npm:^6.28.4, @ledgerhq/hw-transport@npm:^6.30.1": version: 6.30.1 resolution: "@ledgerhq/hw-transport@npm:6.30.1" @@ -8875,20 +8845,12 @@ __metadata: languageName: node linkType: hard -"@zondax/ledger-substrate@npm:^0.41.3": - version: 0.41.3 - resolution: "@zondax/ledger-substrate@npm:0.41.3" +"@zondax/ledger-substrate@npm:^0.42.1": + version: 0.42.1 + resolution: "@zondax/ledger-substrate@npm:0.42.1" dependencies: - "@ledgerhq/hw-transport": ^6.27.1 - bip32: ^4.0.0 - bip32-ed25519: "git+https://github.com/Zondax/bip32-ed25519.git" - bip39: ^3.0.4 - blakejs: ^1.2.1 - bs58: ^5.0.0 - hash.js: ^1.1.7 - bin: - ledger-substrate: dist/cmd/cli.js - checksum: 2c25cb9b28956a47d7152ef0494c8c5bf4c23a9b3afe1321c6fd0e1c1e531ea5d3325acc7666453b53da22aa7fd269d543d6a382848f9ad91cc554074c3d8eea + axios: ^1.6.8 + checksum: c55549f956b976b90753174a71196d6d0ab9d9c96f1534f22196cc5539e0e4dc29c3a79d1ce553bd7b0c76831e71c2fc080cb3c7475053a2054719eeaaea72c4 languageName: node linkType: hard @@ -10511,13 +10473,6 @@ __metadata: languageName: node linkType: hard -"base-x@npm:^4.0.0": - version: 4.0.0 - resolution: "base-x@npm:4.0.0" - checksum: b25db9e07eb1998472a20557c7f00c797dc0595f79df95155ab74274e7fa98b9f2659b3ee547ac8773666b7f69540656793aeb97ad2b1ceccdb6fa5faaf69ac0 - languageName: node - linkType: hard - "base64-js@npm:^1.3.1": version: 1.5.1 resolution: "base64-js@npm:1.5.1" @@ -10599,30 +10554,7 @@ __metadata: languageName: node linkType: hard -"bip32-ed25519@git+https://github.com/Zondax/bip32-ed25519.git": - version: 0.0.4 - resolution: "bip32-ed25519@https://github.com/Zondax/bip32-ed25519.git#commit=0949df01b5c93885339bc28116690292088f6134" - dependencies: - bn.js: ^5.1.1 - elliptic: ^6.4.1 - hash.js: ^1.1.7 - checksum: c0631f4c177b6a459968fb5653956749da1e692634b359155f1c41275eae7f42175629970aa23c1ba39f885b826c76319d03cc2135ae28735777e40e6fde2d7a - languageName: node - linkType: hard - -"bip32@npm:^4.0.0": - version: 4.0.0 - resolution: "bip32@npm:4.0.0" - dependencies: - "@noble/hashes": ^1.2.0 - "@scure/base": ^1.1.1 - typeforce: ^1.11.5 - wif: ^2.0.6 - checksum: a36253ac164db50a25e88effce84aec1eaba2ec2fbd7a19bc1f836f9b1c934fa148c3a01ddece7f136596330074d98c6b2a441e51914c302d130f56f0f893d0d - languageName: node - linkType: hard - -"bip39@npm:^3.0.4, bip39@npm:^3.1.0": +"bip39@npm:^3.1.0": version: 3.1.0 resolution: "bip39@npm:3.1.0" dependencies: @@ -10642,7 +10574,7 @@ __metadata: languageName: node linkType: hard -"blakejs@npm:^1.1.0, blakejs@npm:^1.2.1": +"blakejs@npm:^1.1.0": version: 1.2.1 resolution: "blakejs@npm:1.2.1" checksum: d699ba116cfa21d0b01d12014a03e484dd76d483133e6dc9eb415aa70a119f08beb3bcefb8c71840106a00b542cba77383f8be60cd1f0d4589cb8afb922eefbe @@ -10670,7 +10602,7 @@ __metadata: languageName: node linkType: hard -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.1, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0, bn.js@npm:^5.2.1": +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0, bn.js@npm:^5.2.1": version: 5.2.1 resolution: "bn.js@npm:5.2.1" checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 @@ -10936,16 +10868,7 @@ __metadata: languageName: node linkType: hard -"bs58@npm:^5.0.0": - version: 5.0.0 - resolution: "bs58@npm:5.0.0" - dependencies: - base-x: ^4.0.0 - checksum: 2475cb0684e07077521aac718e604a13e0f891d58cff923d437a2f7e9e28703ab39fce9f84c7c703ab369815a675f11e3bd394d38643bfe8969fbe42e6833d45 - languageName: node - linkType: hard - -"bs58check@npm:<3.0.0, bs58check@npm:^2.1.2": +"bs58check@npm:^2.1.2": version: 2.1.2 resolution: "bs58check@npm:2.1.2" dependencies: @@ -13025,7 +12948,7 @@ __metadata: languageName: node linkType: hard -"elliptic@npm:6.5.4, elliptic@npm:^6.4.0, elliptic@npm:^6.4.1, elliptic@npm:^6.5.2, elliptic@npm:^6.5.3, elliptic@npm:^6.5.4": +"elliptic@npm:6.5.4, elliptic@npm:^6.4.0, elliptic@npm:^6.5.2, elliptic@npm:^6.5.3, elliptic@npm:^6.5.4": version: 6.5.4 resolution: "elliptic@npm:6.5.4" dependencies: @@ -26112,13 +26035,6 @@ __metadata: languageName: node linkType: hard -"typeforce@npm:^1.11.5": - version: 1.18.0 - resolution: "typeforce@npm:1.18.0" - checksum: e3b21e27e76cb05f32285bef7c30a29760e79c622cfe4aa3c179ce49d1c7895b7154c8deedb9fe4599b1fd0428d35860d43e0776da1c04861168f3ad7ed99c70 - languageName: node - linkType: hard - "typescript@npm:^4.8.4": version: 4.8.4 resolution: "typescript@npm:4.8.4" @@ -27617,15 +27533,6 @@ __metadata: languageName: node linkType: hard -"wif@npm:^2.0.6": - version: 2.0.6 - resolution: "wif@npm:2.0.6" - dependencies: - bs58check: <3.0.0 - checksum: 8c3147ef98d56f394d66f0477f699fba7fc18dd0d1c2c5d0f8408be41acffed589fa82447d80eae5afc9a3cbd943bc3eebb337b9f114955adeaad02a244f4f9a - languageName: node - linkType: hard - "wildcard@npm:^2.0.0": version: 2.0.0 resolution: "wildcard@npm:2.0.0" From b6f3c34566a18a81d57ca111e7c957244a08a55c Mon Sep 17 00:00:00 2001 From: S2kael Date: Thu, 9 May 2024 19:16:38 +0700 Subject: [PATCH 3/4] [Issue-2982] Fix cannot sign transaction with Avail Ledger Signed-off-by: S2kael --- package.json | 3 +- packages/extension-base/package.json | 1 + .../src/background/KoniTypes.ts | 5 +++ .../src/koni/background/handlers/Extension.ts | 28 ++++++++---- .../src/koni/background/handlers/State.ts | 4 +- .../chain-service/handler/SubstrateApi.ts | 40 +++++++++++------ .../handler/SubstrateChainHandler.ts | 45 ++++++++++++------- .../scripts/ClearMetadataDatabase.ts | 13 ++++++ .../migration-service/scripts/index.ts | 10 +++-- packages/extension-base/src/utils/registry.ts | 10 ++--- .../useParseSubstrateRequestPayload.ts | 12 +++-- .../src/messaging/metadata/index.ts | 13 +++--- packages/webapp/package.json | 2 +- yarn.lock | 17 +++---- 14 files changed, 138 insertions(+), 65 deletions(-) create mode 100644 packages/extension-base/src/services/migration-service/scripts/ClearMetadataDatabase.ts diff --git a/package.json b/package.json index 4728786c52..3b73e389af 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,8 @@ "@polkadot/api-contract": "^10.12.4", "@polkadot/networks": "^12.6.2", "@polkadot/types": "^10.12.4", - "@polkadot/types-codec": "10.10.1", + "@polkadot/types-codec": "^10.12.4", + "@polkadot/types-known": "^10.12.4", "@polkadot/util": "^12.6.2", "@polkadot/util-crypto": "^12.6.2", "@subwallet/chain-list": "0.2.59", diff --git a/packages/extension-base/package.json b/packages/extension-base/package.json index 9ddb673ce7..786638b5d9 100644 --- a/packages/extension-base/package.json +++ b/packages/extension-base/package.json @@ -44,6 +44,7 @@ "@polkadot/rpc-provider": "^10.12.4", "@polkadot/types": "^10.12.4", "@polkadot/types-augment": "^10.12.4", + "@polkadot/types-known": "^10.12.4", "@polkadot/ui-settings": "^3.6.5", "@polkadot/util": "^12.6.2", "@polkadot/util-crypto": "^12.6.2", diff --git a/packages/extension-base/src/background/KoniTypes.ts b/packages/extension-base/src/background/KoniTypes.ts index 944152bcea..c177f7bbf0 100644 --- a/packages/extension-base/src/background/KoniTypes.ts +++ b/packages/extension-base/src/background/KoniTypes.ts @@ -22,6 +22,7 @@ import Web3 from 'web3'; import { RequestArguments, TransactionConfig } from 'web3-core'; import { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers'; +import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'; import { SignerResult } from '@polkadot/types/types/extrinsic'; import { HexString } from '@polkadot/util/types'; import { KeypairType } from '@polkadot/util-crypto/types'; @@ -283,6 +284,8 @@ export interface MetadataItem { genesisHash: string; specVersion: string; hexValue: HexString; + types: Record | string>; + userExtensions?: ExtDef; } export interface CrowdloanItem { @@ -2133,6 +2136,8 @@ export interface RequestFindRawMetadata { export interface ResponseFindRawMetadata { rawMetadata: string; specVersion: number; + types: Record | string>; + userExtensions?: ExtDef; } export interface ResolveDomainRequest { diff --git a/packages/extension-base/src/koni/background/handlers/Extension.ts b/packages/extension-base/src/koni/background/handlers/Extension.ts index 05b284fc33..3b7ee5792a 100644 --- a/packages/extension-base/src/koni/background/handlers/Extension.ts +++ b/packages/extension-base/src/koni/background/handlers/Extension.ts @@ -42,6 +42,7 @@ import { SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmit import { BN_ZERO, convertSubjectInfoToAddresses, createTransactionFromRLP, isSameAddress, reformatAddress, signatureToHex, Transaction as QrTransaction, uniqueStringArray } from '@subwallet/extension-base/utils'; import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction'; import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils/number'; +import { metadataExpand } from '@subwallet/extension-chains'; import { MetadataDef } from '@subwallet/extension-inject/types'; import { createPair } from '@subwallet/keyring'; import { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '@subwallet/keyring/types'; @@ -57,6 +58,7 @@ import { TransactionConfig } from 'web3-core'; import { SubmittableExtrinsic } from '@polkadot/api/types'; import { TypeRegistry } from '@polkadot/types'; +import { Registry } from '@polkadot/types/types'; import { assert, BN, hexStripPrefix, hexToU8a, isAscii, isHex, u8aToHex, u8aToString } from '@polkadot/util'; import { addressToEvm, base64Decode, decodeAddress, isAddress, isEthereumAddress, jsonDecrypt, keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@polkadot/util-crypto'; import { EncryptedJson, KeypairType, Prefix } from '@polkadot/util-crypto/types'; @@ -3149,20 +3151,25 @@ export default class KoniExtension { const { payload } = request; - let registry = new TypeRegistry(); + let registry: Registry; let isEvm = false; if (isJsonPayload(payload)) { // Get the metadata for the genesisHash - const currentMetadata = this.#koniState.knownMetadata.find((meta: MetadataDef) => + const metadata = this.#koniState.knownMetadata.find((meta: MetadataDef) => meta.genesisHash === payload.genesisHash); - // set the registry before calling the sign function - registry.setSignedExtensions(payload.signedExtensions, currentMetadata?.userExtensions); + if (metadata) { + // we have metadata, expand it and extract the info/registry + const expanded = metadataExpand(metadata, false); - if (currentMetadata) { - registry.register(currentMetadata?.types); + registry = expanded.registry; + registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions); + } else { + // we have no metadata, create a new registry + registry = new TypeRegistry(); + registry.setSignedExtensions(payload.signedExtensions); } const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash); @@ -3182,6 +3189,9 @@ export default class KoniExtension { if (chainInfo) { isEvm = _isChainEvmCompatible(chainInfo); } + } else { + // for non-payload, just create a registry to use + registry = new TypeRegistry(); } const result = request.sign(registry as unknown as TypeRegistry, pair); @@ -3930,11 +3940,13 @@ export default class KoniExtension { /// Metadata private async findRawMetadata ({ genesisHash }: RequestFindRawMetadata): Promise { - const { metadata, specVersion } = await this.#koniState.findMetadata(genesisHash); + const { metadata, specVersion, types, userExtensions } = await this.#koniState.findMetadata(genesisHash); return { rawMetadata: metadata, - specVersion + specVersion, + types, + userExtensions }; } diff --git a/packages/extension-base/src/koni/background/handlers/State.ts b/packages/extension-base/src/koni/background/handlers/State.ts index 8e2b716f32..8f6201a39a 100644 --- a/packages/extension-base/src/koni/background/handlers/State.ts +++ b/packages/extension-base/src/koni/background/handlers/State.ts @@ -2067,7 +2067,9 @@ export default class KoniState { return { metadata: metadata?.hexValue || '', - specVersion: parseInt(metadata?.specVersion || '0') + specVersion: parseInt(metadata?.specVersion || '0'), + types: metadata?.types || {}, + userExtensions: metadata?.userExtensions }; } diff --git a/packages/extension-base/src/services/chain-service/handler/SubstrateApi.ts b/packages/extension-base/src/services/chain-service/handler/SubstrateApi.ts index 282c969aa8..0a180ad915 100644 --- a/packages/extension-base/src/services/chain-service/handler/SubstrateApi.ts +++ b/packages/extension-base/src/services/chain-service/handler/SubstrateApi.ts @@ -18,13 +18,24 @@ import { BehaviorSubject } from 'rxjs'; import { ApiPromise, WsProvider } from '@polkadot/api'; import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types'; import { ApiOptions } from '@polkadot/api/types'; -import { typesBundle } from '@polkadot/apps-config/api'; +import { typesBundle as _typesBundle } from '@polkadot/apps-config/api'; import { ProviderInterface } from '@polkadot/rpc-provider/types'; import { TypeRegistry } from '@polkadot/types/create'; -import { Registry } from '@polkadot/types/types'; +import { OverrideBundleDefinition, Registry } from '@polkadot/types/types'; import { BN, formatBalance } from '@polkadot/util'; import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults'; +const typesBundle = { ..._typesBundle }; + +// Override avail spec for signedExtensions +const _availSpec: OverrideBundleDefinition = { + signedExtensions: availSpec.signedExtensions +}; + +if (typesBundle.spec) { + typesBundle.spec.avail = _availSpec; +} + export class SubstrateApi implements _SubstrateApi { chainSlug: string; api: ApiPromise; @@ -89,7 +100,7 @@ export class SubstrateApi implements _SubstrateApi { const apiOption: ApiOptions = { provider, typesBundle, - registry: this.registry, + registry: this.registry, // This line makes this object registry to be the same as the api registry noInitWarn: true }; @@ -108,29 +119,26 @@ export class SubstrateApi implements _SubstrateApi { if (externalApiPromise) { api = externalApiPromise; } else if (_API_OPTIONS_CHAIN_GROUP.acala.includes(this.chainSlug)) { - api = new ApiPromise(acalaOptions({ provider, noInitWarn: true })); + api = new ApiPromise(acalaOptions(apiOption)); } else if (_API_OPTIONS_CHAIN_GROUP.turing.includes(this.chainSlug)) { api = new ApiPromise({ - provider, + ...apiOption, rpc: oakRpc, - types: oakTypes, - noInitWarn: true + types: oakTypes }); } else if (_API_OPTIONS_CHAIN_GROUP.avail.includes(this.chainSlug)) { api = new ApiPromise({ - provider, + ...apiOption, rpc: availSpec.rpc, types: availSpec.types, - signedExtensions: availSpec.signedExtensions, - noInitWarn: true + signedExtensions: availSpec.signedExtensions }); } else if (_API_OPTIONS_CHAIN_GROUP.goldberg.includes(this.chainSlug)) { api = new ApiPromise({ - provider, + ...apiOption, rpc: goldbergRpc, types: goldbergTypes, - signedExtensions: availSpec.signedExtensions, - noInitWarn: true + signedExtensions: availSpec.signedExtensions }); } else { api = new ApiPromise(apiOption); @@ -272,7 +280,11 @@ export class SubstrateApi implements _SubstrateApi { this.systemName = systemName.toString(); this.systemVersion = systemVersion.toString(); - const properties = registry.createType('ChainProperties', { ss58Format: api.registry.chainSS58, tokenDecimals: api.registry.chainDecimals, tokenSymbol: api.registry.chainTokens }); + const properties = registry.createType('ChainProperties', { + ss58Format: api.registry.chainSS58, + tokenDecimals: api.registry.chainDecimals, + tokenSymbol: api.registry.chainTokens + }); const ss58Format = properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber(); const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]); const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]); diff --git a/packages/extension-base/src/services/chain-service/handler/SubstrateChainHandler.ts b/packages/extension-base/src/services/chain-service/handler/SubstrateChainHandler.ts index 5d7b869faa..2decb3017f 100644 --- a/packages/extension-base/src/services/chain-service/handler/SubstrateChainHandler.ts +++ b/packages/extension-base/src/services/chain-service/handler/SubstrateChainHandler.ts @@ -10,6 +10,7 @@ import { _ApiOptions, _SubstrateChainSpec } from '@subwallet/extension-base/serv import { _SmartContractTokenInfo, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types'; import { ContractPromise } from '@polkadot/api-contract'; +import { getSpecExtensions, getSpecTypes } from '@polkadot/types-known'; import { BN } from '@polkadot/util'; import { logger as createLogger } from '@polkadot/util/logger'; import { Logger } from '@polkadot/util/types'; @@ -203,6 +204,31 @@ export class SubstrateChainHandler extends AbstractChainHandler { public async initApi (chainSlug: string, apiUrl: string, { externalApiPromise, onUpdateStatus, providerName }: Omit<_ApiOptions, 'metadata'> = {}): Promise { const existed = this.substrateApiMap[chainSlug]; + const metadata = await this.parent?.getMetadata(chainSlug); + + const updateMetadata = (substrateApi: SubstrateApi) => { + // Update metadata to database with async methods + substrateApi.api.isReady.then(async (api) => { + const currentSpecVersion = api.runtimeVersion.specVersion.toString(); + const genesisHash = api.genesisHash.toHex(); + + // Avoid date existed metadata + if (metadata && metadata.specVersion === currentSpecVersion && metadata.genesisHash === genesisHash) { + return; + } + + const systemChain = await api.rpc.system.chain(); + + this.parent?.upsertMetadata(chainSlug, { + chain: chainSlug, + genesisHash: genesisHash, + specVersion: currentSpecVersion, + hexValue: api.runtimeMetadata.asCallsOnly.toHex(), // Shorten metadata to save space + types: getSpecTypes(api.registry, systemChain, api.runtimeVersion.specName, api.runtimeVersion.specVersion) as unknown as Record, + userExtensions: getSpecExtensions(api.registry, systemChain, api.runtimeVersion.specName) + }).catch(console.error); + }).catch(console.error); + }; // Return existed to avoid re-init metadata if (existed) { @@ -212,29 +238,18 @@ export class SubstrateChainHandler extends AbstractChainHandler { await existed.updateApiUrl(apiUrl); } + // Update data in case of existed api (if needed - old provider cannot connect) + updateMetadata(existed); + return existed; } - const metadata = await this.parent?.getMetadata(chainSlug); const apiObject = new SubstrateApi(chainSlug, apiUrl, { providerName, metadata, externalApiPromise }); apiObject.connectionStatusSubject.subscribe(this.handleConnection.bind(this, chainSlug)); onUpdateStatus && apiObject.connectionStatusSubject.subscribe(onUpdateStatus); - // Update metadata to database with async methods - apiObject.isReady.then((api) => { - // Avoid date existed metadata - if (metadata && metadata.specVersion === api.specVersion && metadata.genesisHash === api.api.genesisHash.toHex()) { - return; - } - - this.parent?.upsertMetadata(chainSlug, { - chain: chainSlug, - genesisHash: api.api.genesisHash.toHex(), - specVersion: api.specVersion, - hexValue: api.api.runtimeMetadata.toHex() - }).catch(console.error); - }).catch(console.error); + updateMetadata(apiObject); return apiObject; } diff --git a/packages/extension-base/src/services/migration-service/scripts/ClearMetadataDatabase.ts b/packages/extension-base/src/services/migration-service/scripts/ClearMetadataDatabase.ts new file mode 100644 index 0000000000..10228910bd --- /dev/null +++ b/packages/extension-base/src/services/migration-service/scripts/ClearMetadataDatabase.ts @@ -0,0 +1,13 @@ +// Copyright 2019-2022 @subwallet/extension-koni authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base'; + +export default class ClearMetadataDatabase extends BaseMigrationJob { + public override async run (): Promise { + // Clear all old metadata data + await this.state.dbService.stores.metadata.clear(); + + return Promise.resolve(); + } +} diff --git a/packages/extension-base/src/services/migration-service/scripts/index.ts b/packages/extension-base/src/services/migration-service/scripts/index.ts index 028f3fa36a..67599abcc6 100644 --- a/packages/extension-base/src/services/migration-service/scripts/index.ts +++ b/packages/extension-base/src/services/migration-service/scripts/index.ts @@ -1,12 +1,13 @@ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors // SPDX-License-Identifier: Apache-2.0 +import EnableAvailTuringChain from '@subwallet/extension-base/services/migration-service/scripts/EnableAvailTuringChain'; +import MigrateTransactionHistoryBySymbol from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol'; + import BaseMigrationJob from '../Base'; // import MigrateAssetSetting from './databases/MigrateAssetSetting'; import MigrateAssetSetting from './databases/MigrateAssetSetting'; -import MigrateTransactionHistoryBySymbol from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol'; -import EnableAvailTuringChain - from "@subwallet/extension-base/services/migration-service/scripts/EnableAvailTuringChain"; +import ClearMetadataDatabase from './ClearMetadataDatabase'; export const EVERYTIME = '__everytime__'; @@ -36,5 +37,6 @@ export default >{ // [`${EVERYTIME}-1`]: AutoEnableChainsTokens '1.1.53-01': MigrateAssetSetting, '1.1.53-02': MigrateTransactionHistoryBySymbol, - '1.1.58-0___AVAIL': EnableAvailTuringChain + '1.1.58-0___AVAIL': EnableAvailTuringChain, + '1.1.61-01___AVAIL': ClearMetadataDatabase }; diff --git a/packages/extension-base/src/utils/registry.ts b/packages/extension-base/src/utils/registry.ts index e05426e605..89c353e487 100644 --- a/packages/extension-base/src/utils/registry.ts +++ b/packages/extension-base/src/utils/registry.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { _ChainInfo } from '@subwallet/chain-list/types'; +import { ResponseFindRawMetadata } from '@subwallet/extension-base/background/KoniTypes'; import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils'; import { Metadata, TypeRegistry } from '@polkadot/types'; @@ -9,14 +10,13 @@ import { ChainProperties } from '@polkadot/types/interfaces'; import { Registry } from '@polkadot/types/types'; import { HexString } from '@polkadot/util/types'; -export const createRegistry = (chain: _ChainInfo, rawMetadata: HexString): Registry => { +export const createRegistry = (chain: _ChainInfo, data: ResponseFindRawMetadata): Registry => { const registry: Registry = new TypeRegistry(); - const metadata = new Metadata(registry, rawMetadata); - - registry.setMetadata(metadata); - + const metadata = new Metadata(registry, data.rawMetadata as HexString); const tokenInfo = _getChainNativeTokenBasicInfo(chain); + registry.register(data.types); + registry.setMetadata(metadata, undefined, data.userExtensions); registry.setChainProperties(registry.createType('ChainProperties', { ss58Format: chain.substrateInfo?.addressPrefix || 42, tokenDecimals: tokenInfo.decimals, diff --git a/packages/extension-koni-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts b/packages/extension-koni-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts index bbb1ac041a..412d0c8f76 100644 --- a/packages/extension-koni-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts +++ b/packages/extension-koni-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts @@ -2,15 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 import { RequestSign } from '@subwallet/extension-base/background/types'; +import { useMetadata } from '@subwallet/extension-koni-ui/hooks'; import { isRawPayload } from '@subwallet/extension-koni-ui/utils/confirmation/request/substrate'; import { useMemo } from 'react'; import { TypeRegistry } from '@polkadot/types'; import { ExtrinsicPayload } from '@polkadot/types/interfaces'; +import { SignerPayloadJSON } from '@polkadot/types/types'; const registry = new TypeRegistry(); const useParseSubstrateRequestPayload = (request?: RequestSign): ExtrinsicPayload | string => { + const chain = useMetadata((request?.payload as SignerPayloadJSON).genesisHash); + return useMemo(() => { if (!request) { return ''; @@ -21,11 +25,13 @@ const useParseSubstrateRequestPayload = (request?: RequestSign): ExtrinsicPayloa if (isRawPayload(payload)) { return payload.data; } else { - registry.setSignedExtensions(payload.signedExtensions); // Important + const _registry = chain?.registry || registry; + + _registry.setSignedExtensions(payload.signedExtensions, chain?.definition.userExtensions); // Important - return registry.createType('ExtrinsicPayload', payload, { version: payload.version }); + return _registry.createType('ExtrinsicPayload', payload, { version: payload.version }); } - }, [request]); + }, [chain, request]); }; export default useParseSubstrateRequestPayload; diff --git a/packages/extension-koni-ui/src/messaging/metadata/index.ts b/packages/extension-koni-ui/src/messaging/metadata/index.ts index f21cf0bd12..26fc9d4c5b 100644 --- a/packages/extension-koni-ui/src/messaging/metadata/index.ts +++ b/packages/extension-koni-ui/src/messaging/metadata/index.ts @@ -10,8 +10,6 @@ import { MetadataDef } from '@subwallet/extension-inject/types'; import { sendMessage } from '@subwallet/extension-koni-ui/messaging/base'; import { _getKnownHashes, _getKnownNetworks, findChainInfoByGenesisHash } from '@subwallet/extension-koni-ui/utils'; -import { HexString } from '@polkadot/util/types'; - import { getSavedMeta, setSavedMeta } from './MetadataCache'; export async function getAllMetadata (): Promise { @@ -59,7 +57,9 @@ export async function getMetadataRaw (chainInfoMap: Record, return null; } - const { rawMetadata, specVersion } = await sendMessage('pri(metadata.find)', { genesisHash }); + const data = await sendMessage('pri(metadata.find)', { genesisHash }); + + const { rawMetadata, specVersion } = data; if (!rawMetadata) { return null; @@ -71,7 +71,7 @@ export async function getMetadataRaw (chainInfoMap: Record, return null; } - const registry = createRegistry(chainInfo, rawMetadata as HexString); + const registry = createRegistry(chainInfo, data); const tokenInfo = _getChainNativeTokenBasicInfo(chainInfo); @@ -80,7 +80,10 @@ export async function getMetadataRaw (chainInfoMap: Record, genesisHash, name: chainInfo.name, hasMetadata: true, - definition: {} as MetadataDef, + definition: { + types: data.types, + userExtensions: data.userExtensions + } as MetadataDef, icon: chainInfo.icon, registry: registry, isUnknown: false, diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 3d0c0f8fc5..1f4cb7b561 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -49,4 +49,4 @@ "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.0.4" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 74be4a338c..db7545c97b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4878,14 +4878,14 @@ __metadata: languageName: node linkType: hard -"@polkadot/types-codec@npm:10.10.1": - version: 10.10.1 - resolution: "@polkadot/types-codec@npm:10.10.1" +"@polkadot/types-codec@npm:^10.12.4": + version: 10.13.1 + resolution: "@polkadot/types-codec@npm:10.13.1" dependencies: - "@polkadot/util": ^12.5.1 - "@polkadot/x-bigint": ^12.5.1 + "@polkadot/util": ^12.6.2 + "@polkadot/x-bigint": ^12.6.2 tslib: ^2.6.2 - checksum: 17ceb561e6a82784febd5c8b0219050a9b8aeeb766ffbae8255ab586120063ca9fea1c89df776047e861aba87e43048a8060d5c469bcd42c169830a69416d62f + checksum: 5f5dadd0cde5686c19aab5042180e54bd9496505063bd873014773c6304c57b80903876162a3e87183487570a6a3e69c707b1ca99f4e6272f7c2c1c9588b9b66 languageName: node linkType: hard @@ -4900,7 +4900,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/types-known@npm:10.13.1": +"@polkadot/types-known@npm:^10.12.4": version: 10.13.1 resolution: "@polkadot/types-known@npm:10.13.1" dependencies: @@ -5149,7 +5149,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-bigint@npm:12.6.2, @polkadot/x-bigint@npm:^12.5.1": +"@polkadot/x-bigint@npm:12.6.2, @polkadot/x-bigint@npm:^12.6.2": version: 12.6.2 resolution: "@polkadot/x-bigint@npm:12.6.2" dependencies: @@ -6165,6 +6165,7 @@ __metadata: "@polkadot/rpc-provider": ^10.12.4 "@polkadot/types": ^10.12.4 "@polkadot/types-augment": ^10.12.4 + "@polkadot/types-known": ^10.12.4 "@polkadot/ui-settings": ^3.6.5 "@polkadot/util": ^12.6.2 "@polkadot/util-crypto": ^12.6.2 From a26fd9d962cc76d28d74889e47d3cdcbe4d65c6e Mon Sep 17 00:00:00 2001 From: S2kael Date: Thu, 9 May 2024 20:08:35 +0700 Subject: [PATCH 4/4] [Issue-41] Fix cannot sign transaction with Avail Ledger --- .../confirmation/useParseSubstrateRequestPayload.ts | 12 +++++++++--- .../src/messaging/metadata/index.ts | 13 ++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/extension-web-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts b/packages/extension-web-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts index 6bb39aa78e..2b90848476 100644 --- a/packages/extension-web-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts +++ b/packages/extension-web-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts @@ -2,15 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 import { RequestSign } from '@subwallet/extension-base/background/types'; +import { useMetadata } from '@subwallet/extension-web-ui/hooks'; import { isRawPayload } from '@subwallet/extension-web-ui/utils/confirmation/request/substrate'; import { useMemo } from 'react'; import { TypeRegistry } from '@polkadot/types'; import { ExtrinsicPayload } from '@polkadot/types/interfaces'; +import { SignerPayloadJSON } from '@polkadot/types/types'; const registry = new TypeRegistry(); const useParseSubstrateRequestPayload = (request?: RequestSign): ExtrinsicPayload | string => { + const chain = useMetadata((request?.payload as SignerPayloadJSON).genesisHash); + return useMemo(() => { if (!request) { return ''; @@ -21,11 +25,13 @@ const useParseSubstrateRequestPayload = (request?: RequestSign): ExtrinsicPayloa if (isRawPayload(payload)) { return payload.data; } else { - registry.setSignedExtensions(payload.signedExtensions); // Important + const _registry = chain?.registry || registry; + + _registry.setSignedExtensions(payload.signedExtensions, chain?.definition.userExtensions); // Important - return registry.createType('ExtrinsicPayload', payload, { version: payload.version }); + return _registry.createType('ExtrinsicPayload', payload, { version: payload.version }); } - }, [request]); + }, [chain, request]); }; export default useParseSubstrateRequestPayload; diff --git a/packages/extension-web-ui/src/messaging/metadata/index.ts b/packages/extension-web-ui/src/messaging/metadata/index.ts index 089ef07d6c..2e90694c39 100644 --- a/packages/extension-web-ui/src/messaging/metadata/index.ts +++ b/packages/extension-web-ui/src/messaging/metadata/index.ts @@ -10,8 +10,6 @@ import { MetadataDef } from '@subwallet/extension-inject/types'; import { sendMessage } from '@subwallet/extension-web-ui/messaging/base'; import { _getKnownHashes, _getKnownNetworks, findChainInfoByGenesisHash } from '@subwallet/extension-web-ui/utils'; -import { HexString } from '@polkadot/util/types'; - import { getSavedMeta, setSavedMeta } from './MetadataCache'; export async function getAllMetadata (): Promise { @@ -59,7 +57,9 @@ export async function getMetadataRaw (chainInfoMap: Record, return null; } - const { rawMetadata, specVersion } = await sendMessage('pri(metadata.find)', { genesisHash }); + const data = await sendMessage('pri(metadata.find)', { genesisHash }); + + const { rawMetadata, specVersion } = data; if (!rawMetadata) { return null; @@ -71,7 +71,7 @@ export async function getMetadataRaw (chainInfoMap: Record, return null; } - const registry = createRegistry(chainInfo, rawMetadata as HexString); + const registry = createRegistry(chainInfo, data); const tokenInfo = _getChainNativeTokenBasicInfo(chainInfo); @@ -80,7 +80,10 @@ export async function getMetadataRaw (chainInfoMap: Record, genesisHash, name: chainInfo.name, hasMetadata: true, - definition: {} as MetadataDef, + definition: { + types: data.types, + userExtensions: data.userExtensions + } as MetadataDef, icon: chainInfo.icon, registry: registry, isUnknown: false,