From d3b60d8283bd2cdf0952358cc7589cdc677643f9 Mon Sep 17 00:00:00 2001 From: himanshu Date: Fri, 2 Aug 2024 15:43:09 +0530 Subject: [PATCH] fix bs58 import --- src/helpers/keyUtils.ts | 4 ++-- test/sapphire_devnet_ed25519.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers/keyUtils.ts b/src/helpers/keyUtils.ts index 12810c6..461b081 100644 --- a/src/helpers/keyUtils.ts +++ b/src/helpers/keyUtils.ts @@ -1,7 +1,7 @@ import { INodePub, KEY_TYPE } from "@toruslabs/constants"; import { Ecies, encrypt } from "@toruslabs/eccrypto"; import BN from "bn.js"; -import base58 from "bs58"; +import * as base58 from "bs58"; import { curve, ec as EC } from "elliptic"; import { keccak256 as keccakHash } from "ethereum-cryptography/keccak"; import { sha512 } from "ethereum-cryptography/sha512"; @@ -142,7 +142,7 @@ function generateAddressFromEcKey(keyType: KeyType, key: EC.KeyPair): string { return toChecksumAddress(evmAddressLower); } else if (keyType === KEY_TYPE.ED25519) { const publicKey = encodeEd25519Point(key.getPublic()); - const address = base58.encode(publicKey); + const address = base58.default.encode(publicKey); return address; } throw new Error(`Invalid keyType: ${keyType}`); diff --git a/test/sapphire_devnet_ed25519.test.ts b/test/sapphire_devnet_ed25519.test.ts index c8021a7..7fc1b58 100644 --- a/test/sapphire_devnet_ed25519.test.ts +++ b/test/sapphire_devnet_ed25519.test.ts @@ -1,7 +1,7 @@ import { TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants"; import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; -import base58 from "bs58"; +import * as base58 from "bs58"; import { expect } from "chai"; import faker from "faker"; @@ -74,7 +74,7 @@ describe("torus utils ed25519 sapphire devnet", function () { const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails({ verifier: TORUS_TEST_VERIFIER, verifierId: email }); const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints; - const decodedKey = Buffer.from(base58.decode(privB58)); + const decodedKey = Buffer.from(base58.default.decode(privB58)); const seedKey = decodedKey.subarray(0, 32).toString("hex"); const result = await torus.importPrivateKey( getImportKeyParams(