diff --git a/.changeset/neat-crabs-beam.md b/.changeset/neat-crabs-beam.md new file mode 100644 index 0000000000..abf47460b8 --- /dev/null +++ b/.changeset/neat-crabs-beam.md @@ -0,0 +1,7 @@ +--- +"@near-js/accounts": minor +"near-api-js": minor +"@near-js/utils": minor +--- + +Update base58 dependency diff --git a/packages/accounts/package.json b/packages/accounts/package.json index 244130c665..50645399b7 100644 --- a/packages/accounts/package.json +++ b/packages/accounts/package.json @@ -33,9 +33,9 @@ "devDependencies": { "@jest/globals": "^29.7.0", "@near-js/keystores": "workspace:*", + "@scure/base": "^1.2.0", "@types/json-schema": "^7.0.15", "@types/node": "20.0.0", - "bs58": "4.0.0", "build": "workspace:*", "jest": "29.7.0", "near-hello": "0.5.1", @@ -53,4 +53,4 @@ "require": "./lib/commonjs/index.cjs", "import": "./lib/esm/index.js" } -} +} \ No newline at end of file diff --git a/packages/accounts/test/account.access_key.test.ts b/packages/accounts/test/account.access_key.test.ts index a35286e7ad..cbf801d866 100644 --- a/packages/accounts/test/account.access_key.test.ts +++ b/packages/accounts/test/account.access_key.test.ts @@ -79,8 +79,9 @@ test('view account details after adding access keys', async() => { publicKey: keyPair2.getPublicKey().toString(), }]; - // @ts-expect-error test input - expect(JSON.stringify(details.authorizedApps.toSorted((a, b) => a.amount < b.amount))).toEqual(JSON.stringify(authorizedApps.toSorted((a, b) => a.amount < b.amount))); + expect(details.authorizedApps).toEqual(expect.arrayContaining(authorizedApps)); + expect(authorizedApps).toEqual(expect.arrayContaining(details.authorizedApps)); + expect(details.authorizedApps).toHaveLength(authorizedApps.length); }); test('loading account after adding a full key', async() => { diff --git a/packages/accounts/test/providers.test.ts b/packages/accounts/test/providers.test.ts index 82ce5395e5..eb966b30d5 100644 --- a/packages/accounts/test/providers.test.ts +++ b/packages/accounts/test/providers.test.ts @@ -1,7 +1,7 @@ import { beforeAll, describe, expect, jest, test } from '@jest/globals'; import { KeyPair } from '@near-js/crypto'; import { ErrorMessages } from '@near-js/utils'; -import base58 from 'bs58'; +import { base58 } from '@scure/base'; import { createAccount, deployContract, generateUniqueString, setUpTestConnection, sleep, waitFor } from './test-utils'; diff --git a/packages/near-api-js/package.json b/packages/near-api-js/package.json index 1e8aa0d292..94687e4bbd 100644 --- a/packages/near-api-js/package.json +++ b/packages/near-api-js/package.json @@ -32,7 +32,6 @@ "devDependencies": { "@types/http-errors": "1.6.1", "@types/node": "18.11.18", - "bs58": "4.0.0", "concurrently": "7.3.0", "in-publish": "2.0.0", "jest": "29.7.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index 7ba5a72574..a6a108573c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -17,7 +17,7 @@ "license": "ISC", "dependencies": { "@near-js/types": "workspace:*", - "bs58": "4.0.0", + "@scure/base": "^1.2.0", "depd": "2.0.0", "mustache": "4.0.0" }, diff --git a/packages/utils/src/format.ts b/packages/utils/src/format.ts index 56df34607c..9ab4236fca 100644 --- a/packages/utils/src/format.ts +++ b/packages/utils/src/format.ts @@ -1,4 +1,4 @@ -import bs58 from "bs58"; +import { base58 } from "@scure/base"; /** * Exponent for calculating how many indivisible units are there in one NEAR. See {@link NEAR_NOMINATION}. @@ -133,7 +133,7 @@ export function baseEncode(value: Uint8Array | string): string { } value = new Uint8Array(bytes); } - return bs58.encode(value); + return base58.encode(value); } /** @@ -142,5 +142,5 @@ export function baseEncode(value: Uint8Array | string): string { * @returns Uint8Array representing the decoded value */ export function baseDecode(value: string): Uint8Array { - return new Uint8Array(bs58.decode(value)); + return base58.decode(value); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fafe83ccdb..4c226d74c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -103,15 +103,15 @@ importers: '@near-js/keystores': specifier: workspace:* version: link:../keystores + '@scure/base': + specifier: ^1.2.0 + version: 1.2.0 '@types/json-schema': specifier: ^7.0.15 version: 7.0.15 '@types/node': specifier: 20.0.0 version: 20.0.0 - bs58: - specifier: 4.0.0 - version: 4.0.0 build: specifier: workspace:* version: link:../build @@ -488,9 +488,6 @@ importers: '@types/node': specifier: 18.11.18 version: 18.11.18 - bs58: - specifier: 4.0.0 - version: 4.0.0 concurrently: specifier: 7.3.0 version: 7.3.0 @@ -674,9 +671,9 @@ importers: '@near-js/types': specifier: workspace:* version: link:../types - bs58: - specifier: 4.0.0 - version: 4.0.0 + '@scure/base': + specifier: ^1.2.0 + version: 1.2.0 depd: specifier: 2.0.0 version: 2.0.0 @@ -1308,6 +1305,9 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} + '@scure/base@1.2.0': + resolution: {integrity: sha512-iGiGgAXDvDwiaBKbXbDL7hDGhKg9Shhd67GMalE/hkj9Vhf44+LoBNptn25vvw26+gO90rfsjHOuc7f/kGcMfg==} + '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} @@ -2093,6 +2093,7 @@ packages: eslint@8.20.0: resolution: {integrity: sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true espree@9.6.1: @@ -5047,6 +5048,8 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true + '@scure/base@1.2.0': {} + '@sinclair/typebox@0.27.8': {} '@sindresorhus/is@4.6.0': {}