@dfinity/ledger-icrc 6.0.1-next-2025-12-08 → 6.0.1-next-2025-12-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -18
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +4 -4
- package/package.json +3 -4
- package/dist/candid/icrc_icrc-1.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_icrc-1.certified.idl.js +0 -68
- package/dist/candid/icrc_icrc-1.d.ts +0 -69
- package/dist/candid/icrc_icrc-1.did +0 -54
- package/dist/candid/icrc_icrc-1.idl.d.ts +0 -2
- package/dist/candid/icrc_icrc-1.idl.js +0 -72
- package/dist/candid/icrc_icrc-10.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_icrc-10.certified.idl.js +0 -20
- package/dist/candid/icrc_icrc-10.d.ts +0 -21
- package/dist/candid/icrc_icrc-10.did +0 -8
- package/dist/candid/icrc_icrc-10.idl.d.ts +0 -2
- package/dist/candid/icrc_icrc-10.idl.js +0 -24
- package/dist/candid/icrc_index-ng.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_index-ng.certified.idl.js +0 -157
- package/dist/candid/icrc_index-ng.d.ts +0 -160
- package/dist/candid/icrc_index-ng.did +0 -163
- package/dist/candid/icrc_index-ng.idl.d.ts +0 -2
- package/dist/candid/icrc_index-ng.idl.js +0 -157
- package/dist/candid/icrc_index.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_index.certified.idl.js +0 -99
- package/dist/candid/icrc_index.d.ts +0 -108
- package/dist/candid/icrc_index.did +0 -98
- package/dist/candid/icrc_index.idl.d.ts +0 -2
- package/dist/candid/icrc_index.idl.js +0 -99
- package/dist/candid/icrc_ledger.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_ledger.certified.idl.js +0 -531
- package/dist/candid/icrc_ledger.d.ts +0 -596
- package/dist/candid/icrc_ledger.did +0 -586
- package/dist/candid/icrc_ledger.idl.d.ts +0 -2
- package/dist/candid/icrc_ledger.idl.js +0 -551
- package/dist/candid/icrc_nft-ledger.certified.idl.d.ts +0 -2
- package/dist/candid/icrc_nft-ledger.certified.idl.js +0 -102
- package/dist/candid/icrc_nft-ledger.d.ts +0 -80
- package/dist/candid/icrc_nft-ledger.did +0 -67
- package/dist/candid/icrc_nft-ledger.idl.d.ts +0 -2
- package/dist/candid/icrc_nft-ledger.idl.js +0 -106
- package/dist/canister.d.ts +0 -13
- package/dist/converters/converters.d.ts +0 -16
- package/dist/converters/index.converters.d.ts +0 -6
- package/dist/converters/ledger.converters.d.ts +0 -6
- package/dist/errors/index.errors.d.ts +0 -2
- package/dist/errors/ledger.errors.d.ts +0 -25
- package/dist/index-ng.canister.d.ts +0 -43
- package/dist/index.canister.d.ts +0 -21
- package/dist/ledger.canister.d.ts +0 -121
- package/dist/nft-ledger.canister.d.ts +0 -16
- package/dist/types/canister.options.d.ts +0 -5
- package/dist/types/canister.types.d.ts +0 -2
- package/dist/types/index-ng.params.d.ts +0 -12
- package/dist/types/index-ng.types.d.ts +0 -1
- package/dist/types/index.params.d.ts +0 -7
- package/dist/types/index.types.d.ts +0 -1
- package/dist/types/ledger.params.d.ts +0 -109
- package/dist/types/ledger.responses.d.ts +0 -24
- package/dist/utils/ledger.utils.d.ts +0 -31
- package/dist/utils/payment.utils.d.ts +0 -28
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { QueryParams } from "@dfinity/utils";
|
|
2
|
-
import type { Account, AllowanceArgs, icrc21_consent_message_request as ConsentMessageArgs, GetBlocksArgs, Subaccount, Timestamp, Tokens } from "../candid/icrc_ledger";
|
|
3
|
-
import type { IcrcAccount } from "./ledger.responses";
|
|
4
|
-
/**
|
|
5
|
-
* Params to get the balance of an ICRC-1 account.
|
|
6
|
-
*/
|
|
7
|
-
export type BalanceParams = IcrcAccount & QueryParams;
|
|
8
|
-
/**
|
|
9
|
-
* Params to make a transfer in an ICRC-1 ledger
|
|
10
|
-
*
|
|
11
|
-
* @param {Account} to The account to transfer tokens to.
|
|
12
|
-
* @param {Tokens} amount The Amount of tokens to transfer.
|
|
13
|
-
* @param {Subaccount?} from_subaccount The subaccount to transfer tokens to.
|
|
14
|
-
* @param {Uint8Array?} memo Transfer memo.
|
|
15
|
-
* @param {Timestamp?} created_at_time nanoseconds since unix epoc to trigger deduplication and avoid other issues
|
|
16
|
-
* See the link for more details on deduplication
|
|
17
|
-
* https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/README.md#transaction_deduplication
|
|
18
|
-
* @param {Tokens?} fee The fee of the transfer when it's not the default fee.
|
|
19
|
-
*/
|
|
20
|
-
export interface TransferParams {
|
|
21
|
-
to: Account;
|
|
22
|
-
fee?: Tokens;
|
|
23
|
-
memo?: Uint8Array;
|
|
24
|
-
from_subaccount?: Subaccount;
|
|
25
|
-
created_at_time?: Timestamp;
|
|
26
|
-
amount: Tokens;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Params for an icrc2_transfer_from.
|
|
30
|
-
*
|
|
31
|
-
* @param {Account} to The account to transfer tokens to.
|
|
32
|
-
* @param {Account} from The account to transfer tokens from.
|
|
33
|
-
* @param {Subaccount?} spender_subaccount A spender subaccount.
|
|
34
|
-
* @param {Tokens} amount The Amount of tokens to transfer.
|
|
35
|
-
* @param {Uint8Array?} memo Transfer memo.
|
|
36
|
-
* @param {Timestamp?} created_at_time nanoseconds since unix epoc to trigger deduplication and avoid other issues
|
|
37
|
-
* @param {Tokens?} fee The fee of the transfer when it's not the default fee.
|
|
38
|
-
*/
|
|
39
|
-
export type TransferFromParams = Omit<TransferParams, "from_subaccount"> & {
|
|
40
|
-
spender_subaccount?: Subaccount;
|
|
41
|
-
from: Account;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Params for an icrc2_approve.
|
|
45
|
-
*
|
|
46
|
-
* @param {Account} spender The account of the spender.
|
|
47
|
-
* @param {Tokens} amount The Amount of tokens to approve.
|
|
48
|
-
* @param {Subaccount?} from_subaccount The subaccount to transfer tokens from.
|
|
49
|
-
* @param {Uint8Array?} memo Transfer memo.
|
|
50
|
-
* @param {Timestamp?} created_at_time nanoseconds since unix epoc to trigger deduplication and avoid other issues
|
|
51
|
-
* @param {Tokens?} fee The fee of the transfer when it's not the default fee.
|
|
52
|
-
* @param {Tokens?} expected_allowance The optional allowance expected. If the expected_allowance field is set, the ledger MUST ensure that the current allowance for the spender from the caller's account is equal to the given value and return the AllowanceChanged error otherwise.
|
|
53
|
-
* @param {Timestamp?} expires_at When the approval expires. If the field is set, it's greater than the current ledger time.
|
|
54
|
-
*/
|
|
55
|
-
export type ApproveParams = Omit<TransferParams, "to"> & {
|
|
56
|
-
expected_allowance?: Tokens;
|
|
57
|
-
expires_at?: Timestamp;
|
|
58
|
-
spender: Account;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Params to get the token allowance that the spender account can transfer from the specified account
|
|
62
|
-
*/
|
|
63
|
-
export type AllowanceParams = AllowanceArgs & QueryParams;
|
|
64
|
-
/**
|
|
65
|
-
* Metadata for the consent message in ICRC-21 specification.
|
|
66
|
-
* @param {number} [utcOffsetMinutes] - The user's local timezone offset in minutes from UTC. If absent, the default is UTC.
|
|
67
|
-
* @param {string} language - BCP-47 language tag. See https://www.rfc-editor.org/rfc/bcp/bcp47.txt
|
|
68
|
-
*/
|
|
69
|
-
export interface Icrc21ConsentMessageMetadata {
|
|
70
|
-
utcOffsetMinutes?: number;
|
|
71
|
-
language: string;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Device specification for displaying the consent message.
|
|
75
|
-
*
|
|
76
|
-
* @param {null} [GenericDisplay] - A generic display able to handle large documents and do line wrapping and pagination / scrolling. Text must be Markdown formatted, no external resources (e.g. images) are allowed.
|
|
77
|
-
* @param {Object} [FieldsDisplay] - A simple display able to handle multiple fields with a title and content.
|
|
78
|
-
*/
|
|
79
|
-
export type Icrc21ConsentMessageDeviceSpec = {
|
|
80
|
-
GenericDisplay: null;
|
|
81
|
-
} | {
|
|
82
|
-
FieldsDisplay: null;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Specification for the consent message, including metadata and device preferences.
|
|
86
|
-
*
|
|
87
|
-
* @param {Icrc21ConsentMessageMetadata} metadata - Metadata of the consent message.
|
|
88
|
-
* @param {Icrc21ConsentMessageDeviceSpec} [deviceSpec] - Information about the device responsible for presenting the consent message to the user.
|
|
89
|
-
*/
|
|
90
|
-
export interface Icrc21ConsentMessageSpec {
|
|
91
|
-
metadata: Icrc21ConsentMessageMetadata;
|
|
92
|
-
deriveSpec?: Icrc21ConsentMessageDeviceSpec;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Parameters for the consent message request.
|
|
96
|
-
*
|
|
97
|
-
* @param {string} method - Method name of the canister call.
|
|
98
|
-
* @param {Uint8Array} arg - Argument of the canister call.
|
|
99
|
-
* @param {Icrc21ConsentMessageSpec} userPreferences - User preferences with regards to the consent message presented to the end-user.
|
|
100
|
-
*/
|
|
101
|
-
export type Icrc21ConsentMessageParams = Omit<ConsentMessageArgs, "user_preferences"> & {
|
|
102
|
-
userPreferences: Icrc21ConsentMessageSpec;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Parameters to get the canister blocks.
|
|
106
|
-
*/
|
|
107
|
-
export type GetBlocksParams = QueryParams & {
|
|
108
|
-
args: GetBlocksArgs[];
|
|
109
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Principal } from "@icp-sdk/core/principal";
|
|
2
|
-
import type { Subaccount, Value } from "../candid/icrc_ledger";
|
|
3
|
-
export declare enum IcrcMetadataResponseEntries {
|
|
4
|
-
SYMBOL = "icrc1:symbol",
|
|
5
|
-
NAME = "icrc1:name",
|
|
6
|
-
DECIMALS = "icrc1:decimals",
|
|
7
|
-
FEE = "icrc1:fee",
|
|
8
|
-
LOGO = "icrc1:logo"
|
|
9
|
-
}
|
|
10
|
-
export type IcrcTokenMetadataResponse = [
|
|
11
|
-
string | IcrcMetadataResponseEntries,
|
|
12
|
-
Value
|
|
13
|
-
][];
|
|
14
|
-
export interface IcrcAccount {
|
|
15
|
-
owner: Principal;
|
|
16
|
-
subaccount?: Subaccount;
|
|
17
|
-
}
|
|
18
|
-
export interface IcrcTokenMetadata {
|
|
19
|
-
name: string;
|
|
20
|
-
symbol: string;
|
|
21
|
-
fee: bigint;
|
|
22
|
-
decimals: number;
|
|
23
|
-
icon?: string;
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type IcrcAccount, type IcrcTokenMetadata, type IcrcTokenMetadataResponse } from "../types/ledger.responses";
|
|
2
|
-
/**
|
|
3
|
-
* Encodes an Icrc-1 account compatible into a string.
|
|
4
|
-
* Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md
|
|
5
|
-
*
|
|
6
|
-
* @param account { owner: Principal, subaccount?: Uint8Array }
|
|
7
|
-
* @returns string
|
|
8
|
-
*/
|
|
9
|
-
export declare const encodeIcrcAccount: ({ owner, subaccount, }: IcrcAccount) => string;
|
|
10
|
-
/**
|
|
11
|
-
* Decodes a string into an Icrc-1 compatible account.
|
|
12
|
-
* Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md
|
|
13
|
-
*
|
|
14
|
-
* @param accountString string
|
|
15
|
-
* @throws Error if the string is not a valid Icrc-1 account
|
|
16
|
-
* @returns IcrcAccount { owner: Principal, subaccount?: Uint8Array }
|
|
17
|
-
*/
|
|
18
|
-
export declare const decodeIcrcAccount: (accountString: string) => IcrcAccount;
|
|
19
|
-
/**
|
|
20
|
-
* Maps the token metadata information from a ledger response into a structured record.
|
|
21
|
-
*
|
|
22
|
-
* This utility processes an array of metadata key-value pairs provided by the ledger
|
|
23
|
-
* and extracts specific fields, such as symbol, name, fee, decimals, and logo. It then
|
|
24
|
-
* constructs a `IcrcTokenMetadata` record. If any required fields are missing,
|
|
25
|
-
* the function returns `undefined`.
|
|
26
|
-
*
|
|
27
|
-
* @param {IcrcTokenMetadataResponse} response - An array of key-value pairs representing token metadata.
|
|
28
|
-
*
|
|
29
|
-
* @returns {IcrcTokenMetadata | undefined} - A structured metadata record or `undefined` if required fields are missing.
|
|
30
|
-
*/
|
|
31
|
-
export declare const mapTokenMetadata: (response: IcrcTokenMetadataResponse) => IcrcTokenMetadata | undefined;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 👀 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22.
|
|
3
|
-
*
|
|
4
|
-
* A naive implementation of a payment parser. Given a code, the function attempts to extract a token name, account identifier (textual representation), and an optional amount.
|
|
5
|
-
*
|
|
6
|
-
* If the code doesn't match the expected pattern, `undefined` is returned for simplicity.
|
|
7
|
-
* Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`.
|
|
8
|
-
*
|
|
9
|
-
* Please note that this function doesn't perform any validity checks on the extracted information.
|
|
10
|
-
* It does not verify if the token is known or if the identifier is a valid address.
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* urn = token ":" address [ "?" params]
|
|
14
|
-
* token = [ ckbtc / icp / chat / bitcoin / ethereum ... ]
|
|
15
|
-
* address = STRING
|
|
16
|
-
* params = param [ "&" params ]
|
|
17
|
-
* param = [ amountparam ]
|
|
18
|
-
* amountparam = "amount=" *digit [ "." *digit ]
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @param code string
|
|
22
|
-
* @returns { token: string; identifier: string; amount?: number } | undefined
|
|
23
|
-
*/
|
|
24
|
-
export declare const decodePayment: (code: string) => {
|
|
25
|
-
token: string;
|
|
26
|
-
identifier: string;
|
|
27
|
-
amount?: number;
|
|
28
|
-
} | undefined;
|