diff --git a/package.json b/package.json index a2042a8..5c7c359 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tanglelabs/iota-identity-adapter", - "version": "0.4.2", + "version": "0.4.3", "main": "dist/index.js", "types": "dist/index.d.ts", "type": "module", diff --git a/src/index.ts b/src/index.ts index c3b52d2..caadbdc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,7 @@ import Module from "node:module"; const require = Module.createRequire(import.meta.url); import { getPublicKeyAsync } from "@noble/ed25519"; import { IotaJwkStore, IotaKidStore } from "./iota-store"; -import { Client, SecretManager, Utils } from "@iota/sdk-wasm/node"; +import { Client, SecretManager, Utils } from "@iota/sdk-wasm/node/lib/index.js"; import { IotaDID, IotaDocument, diff --git a/src/iota-resolver.ts b/src/iota-resolver.ts index f0e49b1..d0bbdf2 100644 --- a/src/iota-resolver.ts +++ b/src/iota-resolver.ts @@ -1,4 +1,4 @@ -import { Client } from "@iota/sdk-wasm/node"; +import { Client } from "@iota/sdk-wasm/node/lib/index.js"; import { type DIDResolutionOptions, type DIDDocument, diff --git a/src/utils.ts b/src/utils.ts index 7262064..dccafcc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,59 +1,39 @@ // Copyright 2020-2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { - IotaDID, - IotaDocument, - IotaIdentityClient, - JwkMemStore, - JwsAlgorithm, - KeyIdMemStore, - MethodScope, - Storage, - Credential, - JwsSignatureOptions, -} from "@iota/identity-wasm/node"; -import { - AliasOutput, - Client, - IOutputsResponse, - MnemonicSecretManager, - SecretManager, - SeedSecretManager, - Utils, -} from "@iota/sdk-wasm/node"; +import { Client, IOutputsResponse } from "@iota/sdk-wasm/node/lib/index.js"; import { InsufficientBalanceError } from "./errors/BalanceErorr"; export async function ensureAddressHasFunds( - client: Client, - addressBech32: string, - amount: string, - seed: string + client: Client, + addressBech32: string, + amount: string, + seed: string ) { - let balance = await getAddressBalance(client, addressBech32); - if (balance >= BigInt(amount)) { - return; - } - throw new InsufficientBalanceError(addressBech32, parseInt(amount), seed); + let balance = await getAddressBalance(client, addressBech32); + if (balance >= BigInt(amount)) { + return; + } + throw new InsufficientBalanceError(addressBech32, parseInt(amount), seed); } /** Returns the balance of the given Bech32-encoded address. */ async function getAddressBalance( - client: Client, - addressBech32: string + client: Client, + addressBech32: string ): Promise { - const outputIds: IOutputsResponse = await client.basicOutputIds([ - { address: addressBech32 }, - { hasExpiration: false }, - { hasTimelock: false }, - { hasStorageDepositReturn: false }, - ]); - const outputs = await client.getOutputs(outputIds.items); + const outputIds: IOutputsResponse = await client.basicOutputIds([ + { address: addressBech32 }, + { hasExpiration: false }, + { hasTimelock: false }, + { hasStorageDepositReturn: false }, + ]); + const outputs = await client.getOutputs(outputIds.items); - let totalAmount = BigInt(0); - for (const output of outputs) { - totalAmount += output.output.getAmount(); - } + let totalAmount = BigInt(0); + for (const output of outputs) { + totalAmount += output.output.getAmount(); + } - return totalAmount; + return totalAmount; }