From d5c232f190c196843e6d7046102b16c35b82897f Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Sat, 18 Nov 2023 16:44:37 +0300 Subject: [PATCH] fix: fix ethers utils dynamic imports (#47) --- src/api/appDataHexToCid.ts | 3 ++- src/api/appDataToCid.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/appDataHexToCid.ts b/src/api/appDataHexToCid.ts index 66f247a..76c9945 100644 --- a/src/api/appDataHexToCid.ts +++ b/src/api/appDataHexToCid.ts @@ -68,7 +68,8 @@ async function _toCidBytes({ hashingLength, multihashHex, }: ToCidParmams): Promise { - const { arrayify } = await import('ethers/lib/utils') + const module = await import('ethers/lib/utils') + const { arrayify } = module.default || module const hashBytes = arrayify(multihashHex) // Concat prefix and multihash diff --git a/src/api/appDataToCid.ts b/src/api/appDataToCid.ts index bbb064d..b4b89d9 100644 --- a/src/api/appDataToCid.ts +++ b/src/api/appDataToCid.ts @@ -98,7 +98,8 @@ export async function _appDataToCidAux( * @returns the IPFS CID v0 of the content */ async function _appDataToCid(fullAppDataJson: string): Promise { - const { keccak256, toUtf8Bytes } = await import('ethers/lib/utils') + const module = await import('ethers/lib/utils') + const { keccak256, toUtf8Bytes } = module.default || module const appDataHex = await keccak256(toUtf8Bytes(fullAppDataJson)) return appDataHexToCid(appDataHex)