diff --git a/packages/ledger-icrc/src/ledger.canister.spec.ts b/packages/ledger-icrc/src/ledger.canister.spec.ts index c73c251b4..918a06284 100644 --- a/packages/ledger-icrc/src/ledger.canister.spec.ts +++ b/packages/ledger-icrc/src/ledger.canister.spec.ts @@ -1,4 +1,4 @@ -import { arrayOfNumberToUint8Array, toNullable } from "@dfinity/utils"; +import { toNullable } from "@dfinity/utils"; import type { ActorSubclass } from "@icp-sdk/core/agent"; import { Principal } from "@icp-sdk/core/principal"; import { mock } from "vitest-mock-extended"; @@ -87,47 +87,6 @@ describe("Ledger canister", () => { }); }); - describe("balance", () => { - it("should return the balance of main account", async () => { - const service = mock>(); - const balance = BigInt(100); - service.icrc1_balance_of.mockResolvedValue(balance); - - const canister = IcrcLedgerCanister.create({ - canisterId: ledgerCanisterIdMock, - certifiedServiceOverride: service, - }); - - const owner = Principal.fromText("aaaaa-aa"); - const res = await canister.balance({ - owner, - }); - - expect(service.icrc1_balance_of).toHaveBeenCalled(); - expect(res).toEqual(balance); - }); - - it("should return the balance of subaccount", async () => { - const service = mock>(); - const balance = BigInt(100); - service.icrc1_balance_of.mockResolvedValue(balance); - - const canister = IcrcLedgerCanister.create({ - canisterId: ledgerCanisterIdMock, - certifiedServiceOverride: service, - }); - - const owner = Principal.fromText("aaaaa-aa"); - const subaccount = arrayOfNumberToUint8Array([0, 0, 1]); - const res = await canister.balance({ - owner, - subaccount, - }); - - expect(res).toEqual(balance); - }); - }); - describe("transfer", () => { const transferParams: TransferParams = { to: { diff --git a/packages/ledger-icrc/src/ledger.canister.ts b/packages/ledger-icrc/src/ledger.canister.ts index 528f4a5e2..b919a3777 100644 --- a/packages/ledger-icrc/src/ledger.canister.ts +++ b/packages/ledger-icrc/src/ledger.canister.ts @@ -1,7 +1,5 @@ import { - Canister, createServices, - toNullable, type Nullable, type QueryParams, } from "@dfinity/utils"; @@ -18,6 +16,7 @@ import type { } from "./candid/icrc_ledger"; import { idlFactory as certifiedIdlFactory } from "./candid/icrc_ledger.certified.idl"; import { idlFactory } from "./candid/icrc_ledger.idl"; +import { IcrcCanister } from "./canister"; import { toApproveArgs, toIcrc21ConsentMessageArgs, @@ -33,7 +32,6 @@ import type { IcrcLedgerCanisterOptions } from "./types/canister.options"; import type { AllowanceParams, ApproveParams, - BalanceParams, GetBlocksParams, Icrc21ConsentMessageParams, TransferFromParams, @@ -41,7 +39,7 @@ import type { } from "./types/ledger.params"; import type { IcrcTokenMetadataResponse } from "./types/ledger.responses"; -export class IcrcLedgerCanister extends Canister { +export class IcrcLedgerCanister extends IcrcCanister { static create(options: IcrcLedgerCanisterOptions) { const { service, certifiedService, canisterId } = createServices({ @@ -67,18 +65,6 @@ export class IcrcLedgerCanister extends Canister { transactionFee = (params: QueryParams): Promise => this.caller(params).icrc1_fee(); - /** - * Returns the balance for a given account provided as owner and with optional subaccount. - * - * @param {BalanceParams} params The parameters to get the balance of an account. - * @returns {Promise} The balance of the given account. - */ - balance = (params: BalanceParams): Promise => - this.caller({ certified: params.certified }).icrc1_balance_of({ - owner: params.owner, - subaccount: toNullable(params.subaccount), - }); - /** * Transfers tokens from the sender to the given account. *