From 8f74a3482600fc9a9373017b8205d90cd268c321 Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:16:09 +0100 Subject: [PATCH 1/7] chore: package updates courtesy of npm --- package-lock.json | 148 ++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 70 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f6c285c..863eab79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3988,34 +3988,6 @@ "rollup": "^1.20.0 || ^2.0.0" } }, - "node_modules/@rollup/plugin-node-resolve": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", - "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", - "dev": true, - "dependencies": { - "@rollup/pluginutils": "^3.0.0", - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1" - }, - "engines": { - "node": ">= 8.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0" - } - }, - "node_modules/@rollup/plugin-node-resolve/node_modules/builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -7118,10 +7090,9 @@ "dev": true }, "node_modules/fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", - "deprecated": "\"Please update to latest v2.3 or v2.2\"", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, "hasInstallScript": true, "optional": true, @@ -10866,6 +10837,25 @@ "to-fast-properties": "^2.0.0" } }, + "node_modules/microbundle/node_modules/@rollup/plugin-node-resolve": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", + "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.0.0", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0" + } + }, "node_modules/microbundle/node_modules/builtin-modules": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", @@ -10911,6 +10901,20 @@ "node": ">=6" } }, + "node_modules/microbundle/node_modules/rollup": { + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + }, + "bin": { + "rollup": "dist/bin/rollup" + } + }, "node_modules/microbundle/node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -13170,17 +13174,19 @@ } }, "node_modules/rollup": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", - "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "version": "2.70.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", + "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", "dev": true, - "dependencies": { - "@types/estree": "*", - "@types/node": "*", - "acorn": "^7.1.0" - }, + "peer": true, "bin": { "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" } }, "node_modules/rollup-plugin-bundle-size": { @@ -19286,27 +19292,6 @@ "@rollup/pluginutils": "^3.0.8" } }, - "@rollup/plugin-node-resolve": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", - "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.0.0", - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1" - }, - "dependencies": { - "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", - "dev": true - } - } - }, "@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -21902,9 +21887,9 @@ "dev": true }, "fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, "optional": true }, @@ -24861,6 +24846,19 @@ "to-fast-properties": "^2.0.0" } }, + "@rollup/plugin-node-resolve": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", + "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.0", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1" + } + }, "builtin-modules": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", @@ -24891,6 +24889,17 @@ "minimist": "^1.2.5" } }, + "rollup": { + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -26742,14 +26751,13 @@ "integrity": "sha512-+GcJgQivhs6S9qvLogusiTcS9kQUfgR75whKuy5jIhuiOfQuJ8fjqxV6EGD5duH1Y/FawFUMtMhyeq3Fbnib8A==" }, "rollup": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", - "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "version": "2.70.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", + "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", "dev": true, + "peer": true, "requires": { - "@types/estree": "*", - "@types/node": "*", - "acorn": "^7.1.0" + "fsevents": "~2.3.2" } }, "rollup-plugin-bundle-size": { From 839012a676a7f6c2150e8666e1a7a1288b0168e6 Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:24:59 +0100 Subject: [PATCH 2/7] chore: ignore vim swp files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7721b4b7..3dcc52de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules lib .DS_Store +*.swp From 10c9a0099533d21e06aaa8c102d14c81791286f2 Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:25:42 +0100 Subject: [PATCH 3/7] feat: support AVAX X- & P- chain IDs AVAX uses bech32 for its X & P chains. A valid address format includes the 'X-' or 'P-' ID prepended to the address. This adds a custom decoder to strip the ID and decode the leftover address with bech32. Change is backwards compatible with existing functionality. --- src/__tests__/index.test.ts | 12 +++++++++++- src/index.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 283994c8..e8731407 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -1070,6 +1070,16 @@ const vectors: Array = [ coinType: 9000, passingVectors: [ { text: 'avax1a5h6v9weng8guuah6aamagea0xhsd04mvs2zun', hex: 'ed2fa615d99a0e8e73b7d77bbea33d79af06bebb' }, + { + text: 'P-avax1a5h6v9weng8guuah6aamagea0xhsd04mvs2zun', + hex: 'ed2fa615d99a0e8e73b7d77bbea33d79af06bebb', + canonical: 'avax1a5h6v9weng8guuah6aamagea0xhsd04mvs2zun' + }, + { + text: 'X-avax1a5h6v9weng8guuah6aamagea0xhsd04mvs2zun', + hex: 'ed2fa615d99a0e8e73b7d77bbea33d79af06bebb', + canonical: 'avax1a5h6v9weng8guuah6aamagea0xhsd04mvs2zun' + }, ], }, { @@ -1293,4 +1303,4 @@ test("Convert cointype to evm chain id and convert back", () => { const xdai = 61 const coinType = convertEVMChainIdToCoinType(xdai) expect(convertCoinTypeToEVMChainId(coinType)).toBe(xdai) -}) \ No newline at end of file +}) diff --git a/src/index.ts b/src/index.ts index 017ee202..ec7bdfb1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -310,6 +310,15 @@ const cardanoChain = ( name, }); +function makeAvaxDecoder (hrp: string): (data: string) => Buffer { + const decodeBech32 = makeBech32Decoder(hrp) + return (data: string) => { + let [id, address] = data.split('-') + if (!address) address = id + return decodeBech32(address) + } +} + function decodeNearAddr(data: string): Buffer { const regex = /(^(([a-z\d]+[\-_])*[a-z\d]+\.)*([a-z\d]+[\-_])*[a-z\d]+$)/g; if(!regex.test(data)) { @@ -1549,7 +1558,7 @@ export const formats: IFormat[] = [ hexChecksumChain('GO_LEGACY', 6060), bech32mChain('XCH', 8444, 'xch', 90), getConfig('NULS', 8964, nulsAddressEncoder, nulsAddressDecoder), - bech32Chain('AVAX', 9000, 'avax'), + getConfig('AVAX', 9000, makeBech32Encoder('avax'), makeAvaxDecoder('avax')), hexChecksumChain('NRG_LEGACY', 9797), getConfig('ARDR', 16754, ardrAddressEncoder, ardrAddressDecoder), zcashChain('ZEL', 19167, 'za', [[0x1c, 0xb8]], [[0x1c, 0xbd]]), From 7e40a18d448ba4597ff52800b08176d8ccbed473 Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:54:05 +0100 Subject: [PATCH 4/7] feat: Avalanche C-Chain support The Avalanche C-Chain (AVAXC) uses the EVM addressing system. That being said, on Avalanche, it is valid to have the chain ID prepended to the address. This decoder does some preparsing to strip the ID and pass the leftover address to a decoder. --- src/__tests__/index.test.ts | 12 ++++++++++++ src/index.ts | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index e8731407..b3f4fe4f 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -1082,6 +1082,18 @@ const vectors: Array = [ }, ], }, + { + name: 'AVAXC', + coinType: 9005, + passingVectors: [ + { text: '0x572f4D80f10f663B5049F789546f25f70Bb62a7F', hex: '572f4d80f10f663b5049f789546f25f70bb62a7f' }, + { + text: 'C-0x572f4D80f10f663B5049F789546f25f70Bb62a7F', + hex: '572f4d80f10f663b5049f789546f25f70bb62a7f', + canonical: '0x572f4D80f10f663B5049F789546f25f70Bb62a7F' + }, + ] + }, { name: 'NRG_LEGACY', coinType: 9797, diff --git a/src/index.ts b/src/index.ts index ec7bdfb1..95d71737 100644 --- a/src/index.ts +++ b/src/index.ts @@ -319,6 +319,15 @@ function makeAvaxDecoder (hrp: string): (data: string) => Buffer { } } +function makeAvaxcDecoder (): (data: string) => Buffer { + const decode = makeChecksummedHexDecoder() + return (data: string) => { + let [id, address] = data.split('-') + if (!address) address = id + return decode(address) + } +} + function decodeNearAddr(data: string): Buffer { const regex = /(^(([a-z\d]+[\-_])*[a-z\d]+\.)*([a-z\d]+[\-_])*[a-z\d]+$)/g; if(!regex.test(data)) { @@ -1559,6 +1568,7 @@ export const formats: IFormat[] = [ bech32mChain('XCH', 8444, 'xch', 90), getConfig('NULS', 8964, nulsAddressEncoder, nulsAddressDecoder), getConfig('AVAX', 9000, makeBech32Encoder('avax'), makeAvaxDecoder('avax')), + getConfig('AVAXC', 9005, makeChecksummedHexEncoder(), makeAvaxcDecoder()), hexChecksumChain('NRG_LEGACY', 9797), getConfig('ARDR', 16754, ardrAddressEncoder, ardrAddressDecoder), zcashChain('ZEL', 19167, 'za', [[0x1c, 0xb8]], [[0x1c, 0xbd]]), From 19b4004f2a738b4f14b40af55f3e96321c3c6fdc Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Mon, 25 Apr 2022 23:19:23 +0100 Subject: [PATCH 5/7] fix: linting rules --- src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 95d71737..d1ab11ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -313,8 +313,11 @@ const cardanoChain = ( function makeAvaxDecoder (hrp: string): (data: string) => Buffer { const decodeBech32 = makeBech32Decoder(hrp) return (data: string) => { - let [id, address] = data.split('-') - if (!address) address = id + let address + const [id, possibleAddr] = data.split('-') + if (!possibleAddr) { address = id } + else { address = possibleAddr } + return decodeBech32(address) } } @@ -322,8 +325,11 @@ function makeAvaxDecoder (hrp: string): (data: string) => Buffer { function makeAvaxcDecoder (): (data: string) => Buffer { const decode = makeChecksummedHexDecoder() return (data: string) => { - let [id, address] = data.split('-') - if (!address) address = id + let address + const [id, possibleAddr] = data.split('-') + if (!possibleAddr) { address = id } + else { address = possibleAddr } + return decode(address) } } From c4c0147fecf90498c7e99b7ff65cfa0019e8c300 Mon Sep 17 00:00:00 2001 From: charchar <87212793+0xcharchar@users.noreply.github.com> Date: Tue, 14 Jun 2022 19:37:43 +0100 Subject: [PATCH 6/7] Revert "chore: package updates courtesy of npm" This reverts commit 8f74a3482600fc9a9373017b8205d90cd268c321. --- package-lock.json | 148 ++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 78 deletions(-) diff --git a/package-lock.json b/package-lock.json index 863eab79..7f6c285c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3988,6 +3988,34 @@ "rollup": "^1.20.0 || ^2.0.0" } }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", + "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.0.0", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0" + } + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -7090,9 +7118,10 @@ "dev": true }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "deprecated": "\"Please update to latest v2.3 or v2.2\"", "dev": true, "hasInstallScript": true, "optional": true, @@ -10837,25 +10866,6 @@ "to-fast-properties": "^2.0.0" } }, - "node_modules/microbundle/node_modules/@rollup/plugin-node-resolve": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", - "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", - "dev": true, - "dependencies": { - "@rollup/pluginutils": "^3.0.0", - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1" - }, - "engines": { - "node": ">= 8.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0" - } - }, "node_modules/microbundle/node_modules/builtin-modules": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", @@ -10901,20 +10911,6 @@ "node": ">=6" } }, - "node_modules/microbundle/node_modules/rollup": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", - "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", - "dev": true, - "dependencies": { - "@types/estree": "*", - "@types/node": "*", - "acorn": "^7.1.0" - }, - "bin": { - "rollup": "dist/bin/rollup" - } - }, "node_modules/microbundle/node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -13174,19 +13170,17 @@ } }, "node_modules/rollup": { - "version": "2.70.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", - "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", "dev": true, - "peer": true, + "dependencies": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + }, "bin": { "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=10.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" } }, "node_modules/rollup-plugin-bundle-size": { @@ -19292,6 +19286,27 @@ "@rollup/pluginutils": "^3.0.8" } }, + "@rollup/plugin-node-resolve": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", + "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.0", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1" + }, + "dependencies": { + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + } + } + }, "@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -21887,9 +21902,9 @@ "dev": true }, "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", "dev": true, "optional": true }, @@ -24846,19 +24861,6 @@ "to-fast-properties": "^2.0.0" } }, - "@rollup/plugin-node-resolve": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", - "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.0.0", - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1" - } - }, "builtin-modules": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", @@ -24889,17 +24891,6 @@ "minimist": "^1.2.5" } }, - "rollup": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", - "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", - "dev": true, - "requires": { - "@types/estree": "*", - "@types/node": "*", - "acorn": "^7.1.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -26751,13 +26742,14 @@ "integrity": "sha512-+GcJgQivhs6S9qvLogusiTcS9kQUfgR75whKuy5jIhuiOfQuJ8fjqxV6EGD5duH1Y/FawFUMtMhyeq3Fbnib8A==" }, "rollup": { - "version": "2.70.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", - "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", "dev": true, - "peer": true, "requires": { - "fsevents": "~2.3.2" + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" } }, "rollup-plugin-bundle-size": { From e1ab7ddb60b5c526c1caeb676fce0bc970a27ff3 Mon Sep 17 00:00:00 2001 From: Makoto Inoue <2630+makoto@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:46:29 +0100 Subject: [PATCH 7/7] Remove avax-c implementation --- src/__tests__/index.test.ts | 12 ------------ src/index.ts | 13 ------------- 2 files changed, 25 deletions(-) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 11243609..0ba2d52f 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -1089,18 +1089,6 @@ const vectors: Array = [ }, ], }, - { - name: 'AVAXC', - coinType: 9005, - passingVectors: [ - { text: '0x572f4D80f10f663B5049F789546f25f70Bb62a7F', hex: '572f4d80f10f663b5049f789546f25f70bb62a7f' }, - { - text: 'C-0x572f4D80f10f663B5049F789546f25f70Bb62a7F', - hex: '572f4d80f10f663b5049f789546f25f70bb62a7f', - canonical: '0x572f4D80f10f663B5049F789546f25f70Bb62a7F' - }, - ] - }, { name: 'NRG_LEGACY', coinType: 9797, diff --git a/src/index.ts b/src/index.ts index aa5d5a42..2fecefcf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -322,18 +322,6 @@ function makeAvaxDecoder (hrp: string): (data: string) => Buffer { } } -function makeAvaxcDecoder (): (data: string) => Buffer { - const decode = makeChecksummedHexDecoder() - return (data: string) => { - let address - const [id, possibleAddr] = data.split('-') - if (!possibleAddr) { address = id } - else { address = possibleAddr } - - return decode(address) - } -} - function decodeNearAddr(data: string): Buffer { const regex = /(^(([a-z\d]+[\-_])*[a-z\d]+\.)*([a-z\d]+[\-_])*[a-z\d]+$)/g; if(!regex.test(data)) { @@ -1575,7 +1563,6 @@ export const formats: IFormat[] = [ bech32mChain('XCH', 8444, 'xch', 90), getConfig('NULS', 8964, nulsAddressEncoder, nulsAddressDecoder), getConfig('AVAX', 9000, makeBech32Encoder('avax'), makeAvaxDecoder('avax')), - getConfig('AVAXC', 9005, makeChecksummedHexEncoder(), makeAvaxcDecoder()), hexChecksumChain('NRG_LEGACY', 9797), getConfig('ARDR', 16754, ardrAddressEncoder, ardrAddressDecoder), zcashChain('ZEL', 19167, 'za', [[0x1c, 0xb8]], [[0x1c, 0xbd]]),