test-ic-wallet-middleware-icrc
Version:
Ic middleware wallet ICRC protocol
38 lines (37 loc) • 1.64 kB
TypeScript
import { HttpAgent } from "@dfinity/agent";
import { IcrcTokenMetadataResponse } from "@dfinity/ledger-icrc";
import { Principal } from "@dfinity/principal";
import { MetadataInfo, SubAccountId } from "../../../types";
import { AllowanceDataModel } from "../../../types/allowances/allowanceDataModel";
export declare class LedgerWrapper {
private icrcLedgerCanister;
private constructor();
static create(agent: HttpAgent, ledgerAddress: any): LedgerWrapper;
getBalance(subAccountId: SubAccountId, principal: Principal): Promise<bigint>;
transfer(info: TransferInfo): Promise<bigint>;
transferFrom(info: TransferFromInfo): Promise<bigint>;
getIcrcMetadataInfo(): Promise<MetadataInfo>;
getTransactionFee(): Promise<bigint>;
getAllowance(ownerPrincipal: Principal, spenderPrincipal: Principal, subaccount: SubAccountId, spenderSubaccount?: SubAccountId): Promise<{
allowance: bigint;
expiration: bigint | undefined;
}>;
private convertDate;
static approveAllowance(info: AllowanceDataModel, agent: HttpAgent): Promise<void>;
approveAllowance(info: AllowanceDataModel): Promise<bigint>;
static parseMetadataInfo(metadata: IcrcTokenMetadataResponse): MetadataInfo;
private static getIcrcLedgerCanister;
}
export interface TransferInfo {
fromSubAccountId: SubAccountId;
toAccountPrincipal: Principal;
toSubAccountId?: SubAccountId;
amount: bigint;
}
export interface TransferFromInfo {
fromAccountPrincipal: Principal;
fromSubAccountId: SubAccountId;
toAccountPrincipal: Principal;
toSubAccountId: SubAccountId;
amount: bigint;
}