Skip to content

Commit

Permalink
fix: fix ethers utils dynamic imports (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Nov 18, 2023
1 parent 483b1eb commit d5c232f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/api/appDataHexToCid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ async function _toCidBytes({
hashingLength,
multihashHex,
}: ToCidParmams): Promise<Uint8Array> {
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
Expand Down
3 changes: 2 additions & 1 deletion src/api/appDataToCid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export async function _appDataToCidAux(
* @returns the IPFS CID v0 of the content
*/
async function _appDataToCid(fullAppDataJson: string): Promise<string> {
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)
Expand Down

0 comments on commit d5c232f

Please sign in to comment.