From 3b8395318d40db7ed9794b2f03705f60962580bf Mon Sep 17 00:00:00 2001 From: Valentine Date: Mon, 22 Apr 2024 19:07:52 +0000 Subject: [PATCH] testnet-preview helper (#19) * testnet-preview helper * added tests --- .github/workflows/typescript-check.yml | 19 + npm/CHANGELOG.md | 6 + npm/package.json | 8 +- npm/pnpm-lock.yaml | 906 ++++++++++++++++++++++++- npm/src/client.ts | 7 + npm/src/utils.test.ts | 29 + npm/src/utils.ts | 13 + 7 files changed, 981 insertions(+), 7 deletions(-) create mode 100644 npm/src/utils.test.ts create mode 100644 npm/src/utils.ts diff --git a/.github/workflows/typescript-check.yml b/.github/workflows/typescript-check.yml index 2b3e119..0390945 100644 --- a/.github/workflows/typescript-check.yml +++ b/.github/workflows/typescript-check.yml @@ -49,3 +49,22 @@ jobs: - name: Build run: pnpm build + + test: + name: Test + runs-on: ubuntu-latest + defaults: + run: + working-directory: npm + + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm test diff --git a/npm/CHANGELOG.md b/npm/CHANGELOG.md index 60bb3ee..426fdcb 100644 --- a/npm/CHANGELOG.md +++ b/npm/CHANGELOG.md @@ -1,5 +1,11 @@ # @penumbra-labs/registry +## 4.1.0 + +### Minor Changes + +- Added registry for testnet-preview + ## 4.0.0 ### Major Changes diff --git a/npm/package.json b/npm/package.json index 782765d..5b2a882 100644 --- a/npm/package.json +++ b/npm/package.json @@ -11,18 +11,20 @@ "lint": "eslint . --max-warnings=0", "build": "tsup src/index.ts --format cjs,esm --dts", "changeset": "changeset", - "changeset:publish": "changeset publish" + "changeset:publish": "changeset publish", + "test": "vitest run" }, "devDependencies": { "@buf/penumbra-zone_penumbra.bufbuild_es": "1.8.0-20240415223544-c0a709144747.2", - "@eslint/eslintrc": "^3.0.2", "@changesets/cli": "^2.27.1", + "@eslint/eslintrc": "^3.0.2", "@eslint/js": "^9.0.0", "eslint": "^9.0.0", "prettier": "^3.2.5", "tsup": "^8.0.2", "typescript": "^5.4.5", - "typescript-eslint": "^7.7.0" + "typescript-eslint": "^7.7.0", + "vitest": "^1.5.0" }, "files": [ "dist", diff --git a/npm/pnpm-lock.yaml b/npm/pnpm-lock.yaml index c0af217..fcea19d 100644 --- a/npm/pnpm-lock.yaml +++ b/npm/pnpm-lock.yaml @@ -32,6 +32,9 @@ devDependencies: typescript-eslint: specifier: ^7.7.0 version: 7.7.0(eslint@9.0.0)(typescript@5.4.5) + vitest: + specifier: ^1.5.0 + version: 1.5.0 packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -475,6 +478,18 @@ packages: dev: true optional: true + /@esbuild/aix-ppc64@0.20.2: + resolution: + { + integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==, + } + engines: { node: '>=12' } + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm64@0.19.12: resolution: { @@ -487,6 +502,18 @@ packages: dev: true optional: true + /@esbuild/android-arm64@0.20.2: + resolution: + { + integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm@0.19.12: resolution: { @@ -499,6 +526,18 @@ packages: dev: true optional: true + /@esbuild/android-arm@0.20.2: + resolution: + { + integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==, + } + engines: { node: '>=12' } + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-x64@0.19.12: resolution: { @@ -511,6 +550,18 @@ packages: dev: true optional: true + /@esbuild/android-x64@0.20.2: + resolution: + { + integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-arm64@0.19.12: resolution: { @@ -523,6 +574,18 @@ packages: dev: true optional: true + /@esbuild/darwin-arm64@0.20.2: + resolution: + { + integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-x64@0.19.12: resolution: { @@ -535,6 +598,18 @@ packages: dev: true optional: true + /@esbuild/darwin-x64@0.20.2: + resolution: + { + integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-arm64@0.19.12: resolution: { @@ -547,6 +622,18 @@ packages: dev: true optional: true + /@esbuild/freebsd-arm64@0.20.2: + resolution: + { + integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-x64@0.19.12: resolution: { @@ -559,6 +646,18 @@ packages: dev: true optional: true + /@esbuild/freebsd-x64@0.20.2: + resolution: + { + integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm64@0.19.12: resolution: { @@ -571,6 +670,18 @@ packages: dev: true optional: true + /@esbuild/linux-arm64@0.20.2: + resolution: + { + integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm@0.19.12: resolution: { @@ -583,6 +694,18 @@ packages: dev: true optional: true + /@esbuild/linux-arm@0.20.2: + resolution: + { + integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==, + } + engines: { node: '>=12' } + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ia32@0.19.12: resolution: { @@ -595,6 +718,18 @@ packages: dev: true optional: true + /@esbuild/linux-ia32@0.20.2: + resolution: + { + integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==, + } + engines: { node: '>=12' } + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-loong64@0.19.12: resolution: { @@ -607,6 +742,18 @@ packages: dev: true optional: true + /@esbuild/linux-loong64@0.20.2: + resolution: + { + integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==, + } + engines: { node: '>=12' } + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-mips64el@0.19.12: resolution: { @@ -619,6 +766,18 @@ packages: dev: true optional: true + /@esbuild/linux-mips64el@0.20.2: + resolution: + { + integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==, + } + engines: { node: '>=12' } + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ppc64@0.19.12: resolution: { @@ -631,6 +790,18 @@ packages: dev: true optional: true + /@esbuild/linux-ppc64@0.20.2: + resolution: + { + integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==, + } + engines: { node: '>=12' } + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-riscv64@0.19.12: resolution: { @@ -643,6 +814,18 @@ packages: dev: true optional: true + /@esbuild/linux-riscv64@0.20.2: + resolution: + { + integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==, + } + engines: { node: '>=12' } + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-s390x@0.19.12: resolution: { @@ -655,6 +838,18 @@ packages: dev: true optional: true + /@esbuild/linux-s390x@0.20.2: + resolution: + { + integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==, + } + engines: { node: '>=12' } + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-x64@0.19.12: resolution: { @@ -667,6 +862,18 @@ packages: dev: true optional: true + /@esbuild/linux-x64@0.20.2: + resolution: + { + integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/netbsd-x64@0.19.12: resolution: { @@ -679,6 +886,18 @@ packages: dev: true optional: true + /@esbuild/netbsd-x64@0.20.2: + resolution: + { + integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/openbsd-x64@0.19.12: resolution: { @@ -691,6 +910,18 @@ packages: dev: true optional: true + /@esbuild/openbsd-x64@0.20.2: + resolution: + { + integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/sunos-x64@0.19.12: resolution: { @@ -703,6 +934,18 @@ packages: dev: true optional: true + /@esbuild/sunos-x64@0.20.2: + resolution: + { + integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-arm64@0.19.12: resolution: { @@ -715,6 +958,18 @@ packages: dev: true optional: true + /@esbuild/win32-arm64@0.20.2: + resolution: + { + integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-ia32@0.19.12: resolution: { @@ -727,6 +982,18 @@ packages: dev: true optional: true + /@esbuild/win32-ia32@0.20.2: + resolution: + { + integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==, + } + engines: { node: '>=12' } + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-x64@0.19.12: resolution: { @@ -739,6 +1006,18 @@ packages: dev: true optional: true + /@esbuild/win32-x64@0.20.2: + resolution: + { + integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@eslint-community/eslint-utils@4.4.0(eslint@9.0.0): resolution: { @@ -832,6 +1111,16 @@ packages: wrap-ansi-cjs: /wrap-ansi@7.0.0 dev: true + /@jest/schemas@29.6.3: + resolution: + { + integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + dependencies: + '@sinclair/typebox': 0.27.8 + dev: true + /@jridgewell/gen-mapping@0.3.5: resolution: { @@ -1119,6 +1408,13 @@ packages: dev: true optional: true + /@sinclair/typebox@0.27.8: + resolution: + { + integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==, + } + dev: true + /@types/estree@1.0.5: resolution: { @@ -1317,6 +1613,60 @@ packages: eslint-visitor-keys: 3.4.3 dev: true + /@vitest/expect@1.5.0: + resolution: + { + integrity: sha512-0pzuCI6KYi2SIC3LQezmxujU9RK/vwC1U9R0rLuGlNGcOuDWxqWKu6nUdFsX9tH1WU0SXtAxToOsEjeUn1s3hA==, + } + dependencies: + '@vitest/spy': 1.5.0 + '@vitest/utils': 1.5.0 + chai: 4.4.1 + dev: true + + /@vitest/runner@1.5.0: + resolution: + { + integrity: sha512-7HWwdxXP5yDoe7DTpbif9l6ZmDwCzcSIK38kTSIt6CFEpMjX4EpCgT6wUmS0xTXqMI6E/ONmfgRKmaujpabjZQ==, + } + dependencies: + '@vitest/utils': 1.5.0 + p-limit: 5.0.0 + pathe: 1.1.2 + dev: true + + /@vitest/snapshot@1.5.0: + resolution: + { + integrity: sha512-qpv3fSEuNrhAO3FpH6YYRdaECnnRjg9VxbhdtPwPRnzSfHVXnNzzrpX4cJxqiwgRMo7uRMWDFBlsBq4Cr+rO3A==, + } + dependencies: + magic-string: 0.30.10 + pathe: 1.1.2 + pretty-format: 29.7.0 + dev: true + + /@vitest/spy@1.5.0: + resolution: + { + integrity: sha512-vu6vi6ew5N5MMHJjD5PoakMRKYdmIrNJmyfkhRpQt5d9Ewhw9nZ5Aqynbi3N61bvk9UvZ5UysMT6ayIrZ8GA9w==, + } + dependencies: + tinyspy: 2.2.1 + dev: true + + /@vitest/utils@1.5.0: + resolution: + { + integrity: sha512-BDU0GNL8MWkRkSRdNFvCUCAVOeHaUlVJ9Tx0TYBZyXaaOTmGtUFObzchCivIBrIwKzvZA7A9sCejVhXM2aY98A==, + } + dependencies: + diff-sequences: 29.6.3 + estree-walker: 3.0.3 + loupe: 2.3.7 + pretty-format: 29.7.0 + dev: true + /acorn-jsx@5.3.2(acorn@8.11.3): resolution: { @@ -1328,6 +1678,14 @@ packages: acorn: 8.11.3 dev: true + /acorn-walk@8.3.2: + resolution: + { + integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==, + } + engines: { node: '>=0.4.0' } + dev: true + /acorn@8.11.3: resolution: { @@ -1393,6 +1751,14 @@ packages: color-convert: 2.0.1 dev: true + /ansi-styles@5.2.0: + resolution: + { + integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==, + } + engines: { node: '>=10' } + dev: true + /ansi-styles@6.2.1: resolution: { @@ -1492,6 +1858,13 @@ packages: engines: { node: '>=0.10.0' } dev: true + /assertion-error@1.1.0: + resolution: + { + integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==, + } + dev: true + /available-typed-arrays@1.0.7: resolution: { @@ -1628,6 +2001,22 @@ packages: engines: { node: '>=6' } dev: true + /chai@4.4.1: + resolution: + { + integrity: sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==, + } + engines: { node: '>=4' } + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.3 + deep-eql: 4.1.3 + get-func-name: 2.0.2 + loupe: 2.3.7 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + /chalk@2.4.2: resolution: { @@ -1658,6 +2047,15 @@ packages: } dev: true + /check-error@1.0.3: + resolution: + { + integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==, + } + dependencies: + get-func-name: 2.0.2 + dev: true + /chokidar@3.6.0: resolution: { @@ -1763,6 +2161,13 @@ packages: } dev: true + /confbox@0.1.7: + resolution: + { + integrity: sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==, + } + dev: true + /cross-spawn@5.1.0: resolution: { @@ -1890,6 +2295,16 @@ packages: engines: { node: '>=0.10.0' } dev: true + /deep-eql@4.1.3: + resolution: + { + integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==, + } + engines: { node: '>=6' } + dependencies: + type-detect: 4.0.8 + dev: true + /deep-is@0.1.4: resolution: { @@ -1938,6 +2353,14 @@ packages: engines: { node: '>=8' } dev: true + /diff-sequences@29.6.3: + resolution: + { + integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + dev: true + /dir-glob@3.0.1: resolution: { @@ -2139,6 +2562,40 @@ packages: '@esbuild/win32-x64': 0.19.12 dev: true + /esbuild@0.20.2: + resolution: + { + integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==, + } + engines: { node: '>=12' } + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/aix-ppc64': 0.20.2 + '@esbuild/android-arm': 0.20.2 + '@esbuild/android-arm64': 0.20.2 + '@esbuild/android-x64': 0.20.2 + '@esbuild/darwin-arm64': 0.20.2 + '@esbuild/darwin-x64': 0.20.2 + '@esbuild/freebsd-arm64': 0.20.2 + '@esbuild/freebsd-x64': 0.20.2 + '@esbuild/linux-arm': 0.20.2 + '@esbuild/linux-arm64': 0.20.2 + '@esbuild/linux-ia32': 0.20.2 + '@esbuild/linux-loong64': 0.20.2 + '@esbuild/linux-mips64el': 0.20.2 + '@esbuild/linux-ppc64': 0.20.2 + '@esbuild/linux-riscv64': 0.20.2 + '@esbuild/linux-s390x': 0.20.2 + '@esbuild/linux-x64': 0.20.2 + '@esbuild/netbsd-x64': 0.20.2 + '@esbuild/openbsd-x64': 0.20.2 + '@esbuild/sunos-x64': 0.20.2 + '@esbuild/win32-arm64': 0.20.2 + '@esbuild/win32-ia32': 0.20.2 + '@esbuild/win32-x64': 0.20.2 + dev: true + /escalade@3.1.2: resolution: { @@ -2285,6 +2742,15 @@ packages: engines: { node: '>=4.0' } dev: true + /estree-walker@3.0.3: + resolution: + { + integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==, + } + dependencies: + '@types/estree': 1.0.5 + dev: true + /esutils@2.0.3: resolution: { @@ -2305,10 +2771,28 @@ packages: human-signals: 2.1.0 is-stream: 2.0.1 merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.7 + strip-final-newline: 2.0.0 + dev: true + + /execa@8.0.1: + resolution: + { + integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==, + } + engines: { node: '>=16.17' } + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 dev: true /extendable-error@0.1.7: @@ -2534,6 +3018,13 @@ packages: engines: { node: 6.* || 8.* || >= 10.* } dev: true + /get-func-name@2.0.2: + resolution: + { + integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==, + } + dev: true + /get-intrinsic@1.2.4: resolution: { @@ -2556,6 +3047,14 @@ packages: engines: { node: '>=10' } dev: true + /get-stream@8.0.1: + resolution: + { + integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==, + } + engines: { node: '>=16' } + dev: true + /get-symbol-description@1.0.2: resolution: { @@ -2764,6 +3263,14 @@ packages: engines: { node: '>=10.17.0' } dev: true + /human-signals@5.0.0: + resolution: + { + integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==, + } + engines: { node: '>=16.17.0' } + dev: true + /iconv-lite@0.4.24: resolution: { @@ -3003,6 +3510,14 @@ packages: engines: { node: '>=8' } dev: true + /is-stream@3.0.0: + resolution: + { + integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==, + } + engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } + dev: true + /is-string@1.0.7: resolution: { @@ -3101,6 +3616,13 @@ packages: } dev: true + /js-tokens@9.0.0: + resolution: + { + integrity: sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==, + } + dev: true + /js-yaml@3.14.1: resolution: { @@ -3231,6 +3753,17 @@ packages: strip-bom: 3.0.0 dev: true + /local-pkg@0.5.0: + resolution: + { + integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==, + } + engines: { node: '>=14' } + dependencies: + mlly: 1.6.1 + pkg-types: 1.1.0 + dev: true + /locate-path@5.0.0: resolution: { @@ -3272,6 +3805,15 @@ packages: } dev: true + /loupe@2.3.7: + resolution: + { + integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==, + } + dependencies: + get-func-name: 2.0.2 + dev: true + /lru-cache@10.2.0: resolution: { @@ -3300,6 +3842,15 @@ packages: yallist: 4.0.0 dev: true + /magic-string@0.30.10: + resolution: + { + integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==, + } + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /map-obj@1.0.1: resolution: { @@ -3370,6 +3921,14 @@ packages: engines: { node: '>=6' } dev: true + /mimic-fn@4.0.0: + resolution: + { + integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==, + } + engines: { node: '>=12' } + dev: true + /min-indent@1.0.1: resolution: { @@ -3425,6 +3984,18 @@ packages: engines: { node: '>= 8.0.0' } dev: true + /mlly@1.6.1: + resolution: + { + integrity: sha512-vLgaHvaeunuOXHSmEbZ9izxPx3USsk8KCQ8iC+aTlp5sKRSoZvwhHh5L9VbKSaVC6sJDqbyohIS76E2VmHIPAA==, + } + dependencies: + acorn: 8.11.3 + pathe: 1.1.2 + pkg-types: 1.1.0 + ufo: 1.5.3 + dev: true + /ms@2.1.2: resolution: { @@ -3443,6 +4014,15 @@ packages: thenify-all: 1.6.0 dev: true + /nanoid@3.3.7: + resolution: + { + integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==, + } + engines: { node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1 } + hasBin: true + dev: true + /natural-compare@1.4.0: resolution: { @@ -3480,6 +4060,16 @@ packages: path-key: 3.1.1 dev: true + /npm-run-path@5.3.0: + resolution: + { + integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==, + } + engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } + dependencies: + path-key: 4.0.0 + dev: true + /object-assign@4.1.1: resolution: { @@ -3526,6 +4116,16 @@ packages: mimic-fn: 2.1.0 dev: true + /onetime@6.0.0: + resolution: + { + integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==, + } + engines: { node: '>=12' } + dependencies: + mimic-fn: 4.0.0 + dev: true + /optionator@0.9.3: resolution: { @@ -3586,6 +4186,16 @@ packages: yocto-queue: 0.1.0 dev: true + /p-limit@5.0.0: + resolution: + { + integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==, + } + engines: { node: '>=18' } + dependencies: + yocto-queue: 1.0.0 + dev: true + /p-locate@4.1.0: resolution: { @@ -3661,6 +4271,14 @@ packages: engines: { node: '>=8' } dev: true + /path-key@4.0.0: + resolution: + { + integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==, + } + engines: { node: '>=12' } + dev: true + /path-parse@1.0.7: resolution: { @@ -3687,6 +4305,20 @@ packages: engines: { node: '>=8' } dev: true + /pathe@1.1.2: + resolution: + { + integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==, + } + dev: true + + /pathval@1.1.1: + resolution: + { + integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==, + } + dev: true + /picocolors@1.0.0: resolution: { @@ -3728,6 +4360,17 @@ packages: find-up: 4.1.0 dev: true + /pkg-types@1.1.0: + resolution: + { + integrity: sha512-/RpmvKdxKf8uILTtoOhAgf30wYbP2Qw+L9p3Rvshx1JZVX+XQNZQFjlbmGHEGIm4CkVPlSn+NXmIM8+9oWQaSA==, + } + dependencies: + confbox: 0.1.7 + mlly: 1.6.1 + pathe: 1.1.2 + dev: true + /possible-typed-array-names@1.0.0: resolution: { @@ -3755,6 +4398,18 @@ packages: yaml: 2.4.1 dev: true + /postcss@8.4.38: + resolution: + { + integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==, + } + engines: { node: ^10 || ^12 || >=14 } + dependencies: + nanoid: 3.3.7 + picocolors: 1.0.0 + source-map-js: 1.2.0 + dev: true + /preferred-pm@3.1.3: resolution: { @@ -3794,6 +4449,18 @@ packages: hasBin: true dev: true + /pretty-format@29.7.0: + resolution: + { + integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.2.0 + dev: true + /pseudomap@1.0.2: resolution: { @@ -3824,6 +4491,13 @@ packages: engines: { node: '>=8' } dev: true + /react-is@18.2.0: + resolution: + { + integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==, + } + dev: true + /read-pkg-up@7.0.1: resolution: { @@ -4127,6 +4801,13 @@ packages: object-inspect: 1.13.1 dev: true + /siginfo@2.0.0: + resolution: + { + integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==, + } + dev: true + /signal-exit@3.0.7: resolution: { @@ -4166,6 +4847,14 @@ packages: yargs: 15.4.1 dev: true + /source-map-js@1.2.0: + resolution: + { + integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==, + } + engines: { node: '>=0.10.0' } + dev: true + /source-map@0.8.0-beta.0: resolution: { @@ -4227,6 +4916,20 @@ packages: } dev: true + /stackback@0.0.2: + resolution: + { + integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==, + } + dev: true + + /std-env@3.7.0: + resolution: + { + integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==, + } + dev: true + /stream-transform@2.1.3: resolution: { @@ -4332,6 +5035,14 @@ packages: engines: { node: '>=6' } dev: true + /strip-final-newline@3.0.0: + resolution: + { + integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==, + } + engines: { node: '>=12' } + dev: true + /strip-indent@3.0.0: resolution: { @@ -4350,6 +5061,15 @@ packages: engines: { node: '>=8' } dev: true + /strip-literal@2.1.0: + resolution: + { + integrity: sha512-Op+UycaUt/8FbN/Z2TWPBLge3jWrP3xj10f3fnYxf052bKuS3EKs1ZQcVGjnEMdsNVAM+plXRdmjrZ/KgG3Skw==, + } + dependencies: + js-tokens: 9.0.0 + dev: true + /sucrase@3.35.0: resolution: { @@ -4429,6 +5149,29 @@ packages: any-promise: 1.3.0 dev: true + /tinybench@2.8.0: + resolution: + { + integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==, + } + dev: true + + /tinypool@0.8.4: + resolution: + { + integrity: sha512-i11VH5gS6IFeLY3gMBQ00/MmLncVP7JLXOw1vlgkytLmJK7QnEr7NXf0LBdxfmNPAeyetukOk0bOYrJrFGjYJQ==, + } + engines: { node: '>=14.0.0' } + dev: true + + /tinyspy@2.2.1: + resolution: + { + integrity: sha512-KYad6Vy5VDWV4GH3fjpseMQ/XU2BhIYP7Vzd0LG44qRWm/Yt2WCOTicFdvmgo6gWaqooMQCawTtILVQJupKu7A==, + } + engines: { node: '>=14.0.0' } + dev: true + /tmp@0.0.33: resolution: { @@ -4562,6 +5305,14 @@ packages: prelude-ls: 1.2.1 dev: true + /type-detect@4.0.8: + resolution: + { + integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==, + } + engines: { node: '>=4' } + dev: true + /type-fest@0.13.1: resolution: { @@ -4673,6 +5424,13 @@ packages: hasBin: true dev: true + /ufo@1.5.3: + resolution: + { + integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==, + } + dev: true + /unbox-primitive@1.0.2: resolution: { @@ -4712,6 +5470,126 @@ packages: spdx-expression-parse: 3.0.1 dev: true + /vite-node@1.5.0: + resolution: + { + integrity: sha512-tV8h6gMj6vPzVCa7l+VGq9lwoJjW8Y79vst8QZZGiuRAfijU+EEWuc0kFpmndQrWhMMhet1jdSF+40KSZUqIIw==, + } + engines: { node: ^18.0.0 || >=20.0.0 } + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4 + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.2.10 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /vite@5.2.10: + resolution: + { + integrity: sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==, + } + engines: { node: ^18.0.0 || >=20.0.0 } + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.20.2 + postcss: 8.4.38 + rollup: 4.14.3 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /vitest@1.5.0: + resolution: + { + integrity: sha512-d8UKgR0m2kjdxDWX6911uwxout6GHS0XaGH1cksSIVVG8kRlE7G7aBw7myKQCvDI5dT4j7ZMa+l706BIORMDLw==, + } + engines: { node: ^18.0.0 || >=20.0.0 } + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': 1.5.0 + '@vitest/ui': 1.5.0 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@vitest/expect': 1.5.0 + '@vitest/runner': 1.5.0 + '@vitest/snapshot': 1.5.0 + '@vitest/spy': 1.5.0 + '@vitest/utils': 1.5.0 + acorn-walk: 8.3.2 + chai: 4.4.1 + debug: 4.3.4 + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.10 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 2.1.0 + tinybench: 2.8.0 + tinypool: 0.8.4 + vite: 5.2.10 + vite-node: 1.5.0 + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /wcwidth@1.0.1: resolution: { @@ -4805,6 +5683,18 @@ packages: isexe: 2.0.0 dev: true + /why-is-node-running@2.2.2: + resolution: + { + integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==, + } + engines: { node: '>=8' } + hasBin: true + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + dev: true + /wrap-ansi@6.2.0: resolution: { @@ -4941,3 +5831,11 @@ packages: } engines: { node: '>=10' } dev: true + + /yocto-queue@1.0.0: + resolution: + { + integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==, + } + engines: { node: '>=12.20' } + dev: true diff --git a/npm/src/client.ts b/npm/src/client.ts index 862ffb9..a4700a4 100644 --- a/npm/src/client.ts +++ b/npm/src/client.ts @@ -3,6 +3,7 @@ import { AssetId, Metadata, } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; +import { deriveTestnetChainIdFromPreview, isTestnetPreviewChainId } from './utils'; // @ts-expect-error alias for dev only // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -44,6 +45,12 @@ export class ChainRegistryClient { } async get(chainId: string): Promise { + if (isTestnetPreviewChainId(chainId)) { + const derivedChainId = deriveTestnetChainIdFromPreview(chainId); + if (derivedChainId) { + return this.github.fetchRegistryData(derivedChainId); + } + } return this.github.fetchRegistryData(chainId); } diff --git a/npm/src/utils.test.ts b/npm/src/utils.test.ts new file mode 100644 index 0000000..279b9f5 --- /dev/null +++ b/npm/src/utils.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, test } from 'vitest'; +import { deriveTestnetChainIdFromPreview, isTestnetPreviewChainId } from './utils'; + +describe('testnet-preview helper', () => { + test('should correctly identify testnet-preview chain-id', () => { + expect(isTestnetPreviewChainId('penumbra-testnet-deimos-6-711be12a')).toBeTruthy(); + expect(isTestnetPreviewChainId('penumbra-testnet-deimos-222-711be12a')).toBeTruthy(); + expect(isTestnetPreviewChainId('penumbra-testnet-rhea-8b2dfc5c')).toBeTruthy(); + expect(isTestnetPreviewChainId('penumbra-testnet-tethy12-8777cb20')).toBeTruthy(); + }); + + test('should not identify chain-id as testnet-preview', () => { + expect(isTestnetPreviewChainId('penumbra-mainnet')).toBeFalsy(); + expect(isTestnetPreviewChainId('penumbra-testnet-rhea')).toBeFalsy(); + expect(isTestnetPreviewChainId('penumbra-testnet-deimos-6')).toBeFalsy(); + }); + + test('should correctly derive testnet chain-id from testnet-preview chain-id', () => { + expect(deriveTestnetChainIdFromPreview('penumbra-testnet-deimos-6-711be12a')).toEqual( + 'penumbra-testnet-deimos-6', + ); + expect(deriveTestnetChainIdFromPreview('penumbra-testnet-rhea-8b2dfc5c')).toEqual( + 'penumbra-testnet-rhea', + ); + expect(deriveTestnetChainIdFromPreview('penumbra-testnet-tethys12-8777cb20')).toEqual( + 'penumbra-testnet-tethys12', + ); + }); +}); diff --git a/npm/src/utils.ts b/npm/src/utils.ts new file mode 100644 index 0000000..0b8a48c --- /dev/null +++ b/npm/src/utils.ts @@ -0,0 +1,13 @@ +const TESTNET_PREVIEW_PATTERN = /^(penumbra-testnet-(?:\w+-)*\w+)-[a-f0-9]{8}$/; + +export const isTestnetPreviewChainId = (chainId: string) => { + return TESTNET_PREVIEW_PATTERN.test(chainId); +}; + +export const deriveTestnetChainIdFromPreview = (previewChainId: string): string | undefined => { + const match = previewChainId.match(TESTNET_PREVIEW_PATTERN); + if (match) { + return match[1]; + } + return undefined; +};