From 4b644d78cae3b862a42e19fe650e7c8679da58ab Mon Sep 17 00:00:00 2001 From: Pierre Troger Date: Mon, 19 Aug 2024 14:45:45 +0200 Subject: [PATCH] build json from map --- .../shared/core/resource/chain-registry.json | 515 ++++++++++++++++++ .../core/script/build-chains-resource.ts | 15 +- 2 files changed, 528 insertions(+), 2 deletions(-) create mode 100644 apps/armory/src/shared/core/resource/chain-registry.json diff --git a/apps/armory/src/shared/core/resource/chain-registry.json b/apps/armory/src/shared/core/resource/chain-registry.json new file mode 100644 index 000000000..0d5da97f1 --- /dev/null +++ b/apps/armory/src/shared/core/resource/chain-registry.json @@ -0,0 +1,515 @@ +{ + "1": { + "nativeSlip44": 60 + }, + "5": { + "nativeSlip44": 60 + }, + "10": { + "nativeSlip44": 60 + }, + "25": { + "nativeSlip44": 394 + }, + "30": { + "nativeSlip44": 137 + }, + "40": { + "nativeSlip44": 977 + }, + "41": { + "nativeSlip44": 977 + }, + "50": { + "nativeSlip44": 550 + }, + "56": { + "nativeSlip44": 714 + }, + "57": { + "nativeSlip44": 57 + }, + "61": { + "nativeSlip44": 61 + }, + "66": { + "nativeSlip44": 996 + }, + "71": { + "nativeSlip44": 503 + }, + "82": { + "nativeSlip44": 93 + }, + "83": { + "nativeSlip44": 93 + }, + "137": { + "nativeSlip44": 966 + }, + "148": { + "nativeSlip44": 4219 + }, + "153": { + "nativeSlip44": 824 + }, + "169": { + "nativeSlip44": 60 + }, + "199": { + "nativeSlip44": 34952 + }, + "204": { + "nativeSlip44": 714 + }, + "248": { + "nativeSlip44": 685 + }, + "250": { + "nativeSlip44": 1007 + }, + "255": { + "nativeSlip44": 60 + }, + "260": { + "nativeSlip44": 60 + }, + "270": { + "nativeSlip44": 60 + }, + "280": { + "nativeSlip44": 60 + }, + "288": { + "nativeSlip44": 60 + }, + "295": { + "nativeSlip44": 3030 + }, + "296": { + "nativeSlip44": 3030 + }, + "297": { + "nativeSlip44": 3030 + }, + "300": { + "nativeSlip44": 60 + }, + "314": { + "nativeSlip44": 461 + }, + "321": { + "nativeSlip44": 641 + }, + "324": { + "nativeSlip44": 60 + }, + "369": { + "nativeSlip44": 1028 + }, + "420": { + "nativeSlip44": 60 + }, + "424": { + "nativeSlip44": 60 + }, + "545": { + "nativeSlip44": 539 + }, + "570": { + "nativeSlip44": 57 + }, + "571": { + "nativeSlip44": 601 + }, + "592": { + "nativeSlip44": 810 + }, + "646": { + "nativeSlip44": 539 + }, + "686": { + "nativeSlip44": 686 + }, + "690": { + "nativeSlip44": 60 + }, + "747": { + "nativeSlip44": 539 + }, + "787": { + "nativeSlip44": 787 + }, + "888": { + "nativeSlip44": 5718350 + }, + "919": { + "nativeSlip44": 60 + }, + "999": { + "nativeSlip44": 60 + }, + "1001": { + "nativeSlip44": 8217 + }, + "1004": { + "nativeSlip44": 656 + }, + "1017": { + "nativeSlip44": 714 + }, + "1028": { + "nativeSlip44": 34952 + }, + "1030": { + "nativeSlip44": 503 + }, + "1073": { + "nativeSlip44": 4219 + }, + "1101": { + "nativeSlip44": 60 + }, + "1116": { + "nativeSlip44": 990 + }, + "1130": { + "nativeSlip44": 1129 + }, + "1131": { + "nativeSlip44": 1129 + }, + "1135": { + "nativeSlip44": 60 + }, + "1284": { + "nativeSlip44": 1284 + }, + "1285": { + "nativeSlip44": 1285 + }, + "1337": { + "nativeSlip44": 60 + }, + "1442": { + "nativeSlip44": 60 + }, + "1453": { + "nativeSlip44": 601 + }, + "1686": { + "nativeSlip44": 60 + }, + "1729": { + "nativeSlip44": 60 + }, + "1750": { + "nativeSlip44": 60 + }, + "1890": { + "nativeSlip44": 60 + }, + "1891": { + "nativeSlip44": 60 + }, + "1994": { + "nativeSlip44": 656 + }, + "2021": { + "nativeSlip44": 523 + }, + "2221": { + "nativeSlip44": 459 + }, + "2222": { + "nativeSlip44": 459 + }, + "2358": { + "nativeSlip44": 60 + }, + "2442": { + "nativeSlip44": 60 + }, + "2710": { + "nativeSlip44": 60 + }, + "3109": { + "nativeSlip44": 0 + }, + "3110": { + "nativeSlip44": 0 + }, + "3737": { + "nativeSlip44": 773 + }, + "3776": { + "nativeSlip44": 60 + }, + "3993": { + "nativeSlip44": 60 + }, + "4002": { + "nativeSlip44": 1007 + }, + "4200": { + "nativeSlip44": 0 + }, + "4202": { + "nativeSlip44": 60 + }, + "4242": { + "nativeSlip44": 2500 + }, + "4337": { + "nativeSlip44": 1533 + }, + "4689": { + "nativeSlip44": 304 + }, + "4690": { + "nativeSlip44": 304 + }, + "4759": { + "nativeSlip44": 7518 + }, + "4999": { + "nativeSlip44": 4999 + }, + "5112": { + "nativeSlip44": 60 + }, + "5700": { + "nativeSlip44": 57 + }, + "7000": { + "nativeSlip44": 7000 + }, + "7332": { + "nativeSlip44": 121 + }, + "7518": { + "nativeSlip44": 7518 + }, + "7560": { + "nativeSlip44": 60 + }, + "8082": { + "nativeSlip44": 95 + }, + "8217": { + "nativeSlip44": 8217 + }, + "8453": { + "nativeSlip44": 60 + }, + "11235": { + "nativeSlip44": 1348 + }, + "11501": { + "nativeSlip44": 0 + }, + "12324": { + "nativeSlip44": 60 + }, + "12325": { + "nativeSlip44": 60 + }, + "13337": { + "nativeSlip44": 1533 + }, + "13381": { + "nativeSlip44": 13381 + }, + "15557": { + "nativeSlip44": 194 + }, + "17000": { + "nativeSlip44": 60 + }, + "17777": { + "nativeSlip44": 194 + }, + "22222": { + "nativeSlip44": 883 + }, + "23294": { + "nativeSlip44": 474 + }, + "31337": { + "nativeSlip44": 60 + }, + "32769": { + "nativeSlip44": 313 + }, + "33101": { + "nativeSlip44": 313 + }, + "34443": { + "nativeSlip44": 60 + }, + "42161": { + "nativeSlip44": 60 + }, + "42170": { + "nativeSlip44": 60 + }, + "42220": { + "nativeSlip44": 52752 + }, + "43113": { + "nativeSlip44": 9000 + }, + "43114": { + "nativeSlip44": 9000 + }, + "48899": { + "nativeSlip44": 60 + }, + "50005": { + "nativeSlip44": 685 + }, + "50006": { + "nativeSlip44": 685 + }, + "57000": { + "nativeSlip44": 57 + }, + "58008": { + "nativeSlip44": 60 + }, + "59140": { + "nativeSlip44": 60 + }, + "59141": { + "nativeSlip44": 60 + }, + "59144": { + "nativeSlip44": 60 + }, + "60808": { + "nativeSlip44": 60 + }, + "64240": { + "nativeSlip44": 1007 + }, + "80001": { + "nativeSlip44": 966 + }, + "80002": { + "nativeSlip44": 966 + }, + "81457": { + "nativeSlip44": 60 + }, + "84531": { + "nativeSlip44": 60 + }, + "84532": { + "nativeSlip44": 60 + }, + "100009": { + "nativeSlip44": 818 + }, + "105105": { + "nativeSlip44": 105105 + }, + "128123": { + "nativeSlip44": 1729 + }, + "167000": { + "nativeSlip44": 60 + }, + "167005": { + "nativeSlip44": 60 + }, + "167007": { + "nativeSlip44": 60 + }, + "167008": { + "nativeSlip44": 60 + }, + "167009": { + "nativeSlip44": 60 + }, + "200810": { + "nativeSlip44": 60 + }, + "200901": { + "nativeSlip44": 60 + }, + "421613": { + "nativeSlip44": 60 + }, + "421614": { + "nativeSlip44": 60 + }, + "534351": { + "nativeSlip44": 60 + }, + "534352": { + "nativeSlip44": 60 + }, + "1612127": { + "nativeSlip44": 60 + }, + "3397901": { + "nativeSlip44": 60 + }, + "3441005": { + "nativeSlip44": 60 + }, + "3441006": { + "nativeSlip44": 60 + }, + "6038361": { + "nativeSlip44": 60 + }, + "7777777": { + "nativeSlip44": 60 + }, + "11155111": { + "nativeSlip44": 60 + }, + "11155420": { + "nativeSlip44": 60 + }, + "28122024": { + "nativeSlip44": 60 + }, + "41144114": { + "nativeSlip44": 60 + }, + "111557560": { + "nativeSlip44": 60 + }, + "161221135": { + "nativeSlip44": 60 + }, + "168587773": { + "nativeSlip44": 60 + }, + "888888888": { + "nativeSlip44": 60 + }, + "999999999": { + "nativeSlip44": 60 + }, + "1313161554": { + "nativeSlip44": 60 + }, + "1313161555": { + "nativeSlip44": 60 + }, + "1666600000": { + "nativeSlip44": 270 + }, + "1802203764": { + "nativeSlip44": 60 + }, + "2716446429837000": { + "nativeSlip44": 60 + }, + "2713017997578000": { + "nativeSlip44": 60 + } +} \ No newline at end of file diff --git a/apps/armory/src/shared/core/script/build-chains-resource.ts b/apps/armory/src/shared/core/script/build-chains-resource.ts index 4085202fb..ebcd5d0f5 100644 --- a/apps/armory/src/shared/core/script/build-chains-resource.ts +++ b/apps/armory/src/shared/core/script/build-chains-resource.ts @@ -4,10 +4,13 @@ import * as chainObject from 'viem/chains' import { registeredCoinTypes } from 'slip44'; import { HttpStatus } from '@nestjs/common'; import { ChainRegistry } from '@narval/transaction-request-intent'; +import * as fs from 'fs'; +import * as path from 'path'; export const buildNativeSlip44 = (): ChainRegistry => { const chains = Object.values(chainObject); + let count = 0; const chainRegistry: ChainRegistry = new Map(); chains.forEach((chain) => { const tokenSlip44 = registeredCoinTypes.find(([ @@ -23,16 +26,24 @@ export const buildNativeSlip44 = (): ChainRegistry => { nativeSlip44: tokenSlip44[0], }); } else { - console.warn(`Slip44 not found for native token: ${chain.nativeCurrency.symbol}`); + console.error(`Slip44 not found for native token: ${chain.nativeCurrency.symbol}`); + count++; } }); + console.log(`Slip44 not found for ${count} native tokens`); return chainRegistry; } const main = () => { + const fileName = 'chain-registry.json'; + const relativePath = '../resource'; + const filePath = path.resolve(__dirname, relativePath, fileName); + const registry = buildNativeSlip44(); - console.log(registry); + const obj = Object.fromEntries(registry); + fs.writeFileSync(filePath, JSON.stringify(obj, null, 2), 'utf8'); + console.log(`JSON written to ${filePath}`); }; main(); \ No newline at end of file