@dfinity/ledger-icrc 6.0.0 → 6.0.1-next-2025-12-03
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/README.md +5 -511
- package/dist/candid/icrc_icrc-1.certified.idl.d.ts +2 -0
- package/dist/candid/icrc_icrc-1.certified.idl.js +68 -0
- package/dist/candid/icrc_icrc-1.d.ts +69 -0
- package/dist/candid/icrc_icrc-1.did +54 -0
- package/dist/candid/icrc_icrc-1.idl.d.ts +2 -0
- package/dist/candid/icrc_icrc-1.idl.js +72 -0
- package/dist/candid/icrc_icrc-10.certified.idl.d.ts +2 -0
- package/dist/candid/icrc_icrc-10.certified.idl.js +20 -0
- package/dist/candid/icrc_icrc-10.d.ts +21 -0
- package/dist/candid/icrc_icrc-10.did +8 -0
- package/dist/candid/icrc_icrc-10.idl.d.ts +2 -0
- package/dist/candid/icrc_icrc-10.idl.js +24 -0
- package/dist/candid/icrc_index-ng.certified.idl.js +6 -0
- package/dist/candid/icrc_index-ng.d.ts +6 -0
- package/dist/candid/icrc_index-ng.did +8 -1
- package/dist/candid/icrc_index-ng.idl.js +6 -0
- package/dist/candid/icrc_ledger.certified.idl.js +6 -0
- package/dist/candid/icrc_ledger.d.ts +6 -0
- package/dist/candid/icrc_ledger.did +8 -1
- package/dist/candid/icrc_ledger.idl.js +6 -0
- package/dist/canister.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- 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/dist/ledger.canister.d.ts +4 -10
- package/dist/nft-ledger.canister.d.ts +16 -0
- package/dist/types/canister.types.d.ts +2 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ A library for interfacing with [ICRC ledger](https://github.com/dfinity/ic/tree/
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@dfinity/ledger-icrc) [](https://opensource.org/licenses/Apache-2.0)
|
|
6
6
|
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> Still using `@dfinity/ledger-icrc`? Upgrade to [`@icp-sdk/canisters/ledger/icrc`](https://js.icp.build/canisters/latest/upgrading/v1/)!
|
|
9
|
+
|
|
7
10
|
## Table of contents
|
|
8
11
|
|
|
9
12
|
- [Installation](#installation)
|
|
@@ -48,518 +51,9 @@ const { metadata } = IcrcLedgerCanister.create({
|
|
|
48
51
|
const data = await metadata({});
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
##
|
|
52
|
-
|
|
53
|
-
`ledger-icrc-js` implements following features:
|
|
54
|
-
|
|
55
|
-
<!-- TSDOC_START -->
|
|
56
|
-
|
|
57
|
-
### :toolbox: Functions
|
|
58
|
-
|
|
59
|
-
- [encodeIcrcAccount](#gear-encodeicrcaccount)
|
|
60
|
-
- [decodeIcrcAccount](#gear-decodeicrcaccount)
|
|
61
|
-
- [mapTokenMetadata](#gear-maptokenmetadata)
|
|
62
|
-
- [decodePayment](#gear-decodepayment)
|
|
63
|
-
|
|
64
|
-
#### :gear: encodeIcrcAccount
|
|
65
|
-
|
|
66
|
-
Encodes an Icrc-1 account compatible into a string.
|
|
67
|
-
Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md
|
|
68
|
-
|
|
69
|
-
| Function | Type |
|
|
70
|
-
| ------------------- | ------------------------------------------------- |
|
|
71
|
-
| `encodeIcrcAccount` | `({ owner, subaccount, }: IcrcAccount) => string` |
|
|
72
|
-
|
|
73
|
-
Parameters:
|
|
74
|
-
|
|
75
|
-
- `account`: : Principal, subaccount?: Uint8Array }
|
|
76
|
-
|
|
77
|
-
Returns:
|
|
78
|
-
|
|
79
|
-
string
|
|
80
|
-
|
|
81
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/utils/ledger.utils.ts#L27)
|
|
82
|
-
|
|
83
|
-
#### :gear: decodeIcrcAccount
|
|
84
|
-
|
|
85
|
-
Decodes a string into an Icrc-1 compatible account.
|
|
86
|
-
Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md
|
|
87
|
-
|
|
88
|
-
| Function | Type |
|
|
89
|
-
| ------------------- | ---------------------------------------- |
|
|
90
|
-
| `decodeIcrcAccount` | `(accountString: string) => IcrcAccount` |
|
|
91
|
-
|
|
92
|
-
Parameters:
|
|
93
|
-
|
|
94
|
-
- `accountString`: string
|
|
95
|
-
|
|
96
|
-
Returns:
|
|
97
|
-
|
|
98
|
-
IcrcAccount { owner: Principal, subaccount?: Uint8Array }
|
|
99
|
-
|
|
100
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/utils/ledger.utils.ts#L67)
|
|
101
|
-
|
|
102
|
-
#### :gear: mapTokenMetadata
|
|
103
|
-
|
|
104
|
-
Maps the token metadata information from a ledger response into a structured record.
|
|
105
|
-
|
|
106
|
-
This utility processes an array of metadata key-value pairs provided by the ledger
|
|
107
|
-
and extracts specific fields, such as symbol, name, fee, decimals, and logo. It then
|
|
108
|
-
constructs a `IcrcTokenMetadata` record. If any required fields are missing,
|
|
109
|
-
the function returns `undefined`.
|
|
110
|
-
|
|
111
|
-
| Function | Type |
|
|
112
|
-
| ------------------ | ------------------------------------------------------------------------- |
|
|
113
|
-
| `mapTokenMetadata` | `(response: IcrcTokenMetadataResponse) => IcrcTokenMetadata or undefined` |
|
|
114
|
-
|
|
115
|
-
Parameters:
|
|
116
|
-
|
|
117
|
-
- `response`: - An array of key-value pairs representing token metadata.
|
|
118
|
-
|
|
119
|
-
Returns:
|
|
120
|
-
|
|
121
|
-
- A structured metadata record or `undefined` if required fields are missing.
|
|
122
|
-
|
|
123
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/utils/ledger.utils.ts#L118)
|
|
124
|
-
|
|
125
|
-
#### :gear: decodePayment
|
|
126
|
-
|
|
127
|
-
👀 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22.
|
|
128
|
-
|
|
129
|
-
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.
|
|
130
|
-
|
|
131
|
-
If the code doesn't match the expected pattern, `undefined` is returned for simplicity.
|
|
132
|
-
Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`.
|
|
133
|
-
|
|
134
|
-
Please note that this function doesn't perform any validity checks on the extracted information.
|
|
135
|
-
It does not verify if the token is known or if the identifier is a valid address.
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
urn = token ":" address [ "?" params]
|
|
139
|
-
token = [ ckbtc / icp / chat / bitcoin / ethereum ... ]
|
|
140
|
-
address = STRING
|
|
141
|
-
params = param [ "&" params ]
|
|
142
|
-
param = [ amountparam ]
|
|
143
|
-
amountparam = "amount=" *digit [ "." *digit ]
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
| Function | Type |
|
|
147
|
-
| --------------- | ----------------------------------------------------------------------------------------------------- |
|
|
148
|
-
| `decodePayment` | `(code: string) => { token: string; identifier: string; amount?: number or undefined; } or undefined` |
|
|
149
|
-
|
|
150
|
-
Parameters:
|
|
151
|
-
|
|
152
|
-
- `code`: string
|
|
153
|
-
|
|
154
|
-
Returns:
|
|
155
|
-
|
|
156
|
-
: string; identifier: string; amount?: number } | undefined
|
|
157
|
-
|
|
158
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/utils/payment.utils.ts#L26)
|
|
159
|
-
|
|
160
|
-
### :factory: IcrcCanister
|
|
161
|
-
|
|
162
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/canister.ts#L9)
|
|
163
|
-
|
|
164
|
-
#### Methods
|
|
165
|
-
|
|
166
|
-
- [balance](#gear-balance)
|
|
167
|
-
|
|
168
|
-
##### :gear: balance
|
|
169
|
-
|
|
170
|
-
Returns the balance for a given account provided as owner and with optional subaccount.
|
|
171
|
-
|
|
172
|
-
| Method | Type |
|
|
173
|
-
| --------- | -------------------------------------------- |
|
|
174
|
-
| `balance` | `(params: BalanceParams) => Promise<bigint>` |
|
|
175
|
-
|
|
176
|
-
Parameters:
|
|
177
|
-
|
|
178
|
-
- `params`: The parameters to get the balance of an account.
|
|
179
|
-
|
|
180
|
-
Returns:
|
|
181
|
-
|
|
182
|
-
The balance of the given account.
|
|
183
|
-
|
|
184
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/canister.ts#L18)
|
|
185
|
-
|
|
186
|
-
### :factory: IcrcLedgerCanister
|
|
187
|
-
|
|
188
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L44)
|
|
189
|
-
|
|
190
|
-
#### Static Methods
|
|
191
|
-
|
|
192
|
-
- [create](#gear-create)
|
|
193
|
-
|
|
194
|
-
##### :gear: create
|
|
195
|
-
|
|
196
|
-
| Method | Type |
|
|
197
|
-
| -------- | ---------------------------------------------------------------------- |
|
|
198
|
-
| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcLedgerCanister` |
|
|
199
|
-
|
|
200
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L45)
|
|
201
|
-
|
|
202
|
-
#### Methods
|
|
203
|
-
|
|
204
|
-
- [metadata](#gear-metadata)
|
|
205
|
-
- [transactionFee](#gear-transactionfee)
|
|
206
|
-
- [balance](#gear-balance)
|
|
207
|
-
- [transfer](#gear-transfer)
|
|
208
|
-
- [totalTokensSupply](#gear-totaltokenssupply)
|
|
209
|
-
- [transferFrom](#gear-transferfrom)
|
|
210
|
-
- [approve](#gear-approve)
|
|
211
|
-
- [allowance](#gear-allowance)
|
|
212
|
-
- [consentMessage](#gear-consentmessage)
|
|
213
|
-
- [getBlocks](#gear-getblocks)
|
|
214
|
-
- [getIndexPrincipal](#gear-getindexprincipal)
|
|
215
|
-
- [icrc1SupportedStandards](#gear-icrc1supportedstandards)
|
|
216
|
-
- [icrc10SupportedStandards](#gear-icrc10supportedstandards)
|
|
217
|
-
- [getMintingAccount](#gear-getmintingaccount)
|
|
218
|
-
|
|
219
|
-
##### :gear: metadata
|
|
220
|
-
|
|
221
|
-
The token metadata (name, symbol, etc.).
|
|
222
|
-
|
|
223
|
-
| Method | Type |
|
|
224
|
-
| ---------- | ------------------------------------------------------------- |
|
|
225
|
-
| `metadata` | `(params: QueryParams) => Promise<IcrcTokenMetadataResponse>` |
|
|
226
|
-
|
|
227
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L59)
|
|
228
|
-
|
|
229
|
-
##### :gear: transactionFee
|
|
230
|
-
|
|
231
|
-
The ledger transaction fees.
|
|
232
|
-
|
|
233
|
-
| Method | Type |
|
|
234
|
-
| ---------------- | ------------------------------------------ |
|
|
235
|
-
| `transactionFee` | `(params: QueryParams) => Promise<bigint>` |
|
|
236
|
-
|
|
237
|
-
Returns:
|
|
238
|
-
|
|
239
|
-
The ledger transaction fees in Tokens
|
|
240
|
-
|
|
241
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L67)
|
|
242
|
-
|
|
243
|
-
##### :gear: balance
|
|
244
|
-
|
|
245
|
-
Returns the balance for a given account provided as owner and with optional subaccount.
|
|
246
|
-
|
|
247
|
-
| Method | Type |
|
|
248
|
-
| --------- | -------------------------------------------- |
|
|
249
|
-
| `balance` | `(params: BalanceParams) => Promise<bigint>` |
|
|
250
|
-
|
|
251
|
-
Parameters:
|
|
252
|
-
|
|
253
|
-
- `params`: The parameters to get the balance of an account.
|
|
254
|
-
|
|
255
|
-
Returns:
|
|
256
|
-
|
|
257
|
-
The balance of the given account.
|
|
258
|
-
|
|
259
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L76)
|
|
260
|
-
|
|
261
|
-
##### :gear: transfer
|
|
262
|
-
|
|
263
|
-
Transfers tokens from the sender to the given account.
|
|
264
|
-
|
|
265
|
-
| Method | Type |
|
|
266
|
-
| ---------- | --------------------------------------------- |
|
|
267
|
-
| `transfer` | `(params: TransferParams) => Promise<bigint>` |
|
|
268
|
-
|
|
269
|
-
Parameters:
|
|
270
|
-
|
|
271
|
-
- `params`: The parameters to transfer tokens.
|
|
272
|
-
|
|
273
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L89)
|
|
274
|
-
|
|
275
|
-
##### :gear: totalTokensSupply
|
|
276
|
-
|
|
277
|
-
Returns the total supply of tokens.
|
|
278
|
-
|
|
279
|
-
| Method | Type |
|
|
280
|
-
| ------------------- | ------------------------------------------ |
|
|
281
|
-
| `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |
|
|
282
|
-
|
|
283
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L105)
|
|
284
|
-
|
|
285
|
-
##### :gear: transferFrom
|
|
286
|
-
|
|
287
|
-
Transfers a token amount from the `from` account to the `to` account using the allowance of the spender's account (`SpenderAccount = { owner = caller; subaccount = spender_subaccount }`). The ledger draws the fees from the `from` account.
|
|
288
|
-
|
|
289
|
-
Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_transfer_from
|
|
290
|
-
|
|
291
|
-
| Method | Type |
|
|
292
|
-
| -------------- | ------------------------------------------------- |
|
|
293
|
-
| `transferFrom` | `(params: TransferFromParams) => Promise<bigint>` |
|
|
294
|
-
|
|
295
|
-
Parameters:
|
|
296
|
-
|
|
297
|
-
- `params`: The parameters to transfer tokens from to.
|
|
298
|
-
|
|
299
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L117)
|
|
300
|
-
|
|
301
|
-
##### :gear: approve
|
|
302
|
-
|
|
303
|
-
This method entitles the `spender` to transfer token `amount` on behalf of the caller from account `{ owner = caller; subaccount = from_subaccount }`.
|
|
304
|
-
|
|
305
|
-
Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_approve
|
|
306
|
-
|
|
307
|
-
| Method | Type |
|
|
308
|
-
| --------- | -------------------------------------------- |
|
|
309
|
-
| `approve` | `(params: ApproveParams) => Promise<bigint>` |
|
|
310
|
-
|
|
311
|
-
Parameters:
|
|
312
|
-
|
|
313
|
-
- `params`: The parameters to approve.
|
|
314
|
-
|
|
315
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L139)
|
|
316
|
-
|
|
317
|
-
##### :gear: allowance
|
|
318
|
-
|
|
319
|
-
Returns the token allowance that the `spender` account can transfer from the specified `account`, and the expiration time for that allowance, if any.
|
|
320
|
-
|
|
321
|
-
Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_allowance
|
|
322
|
-
|
|
323
|
-
| Method | Type |
|
|
324
|
-
| ----------- | ------------------------------------------------- |
|
|
325
|
-
| `allowance` | `(params: AllowanceParams) => Promise<Allowance>` |
|
|
326
|
-
|
|
327
|
-
Parameters:
|
|
328
|
-
|
|
329
|
-
- `params`: The parameters to call the allowance.
|
|
330
|
-
|
|
331
|
-
Returns:
|
|
332
|
-
|
|
333
|
-
The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.
|
|
334
|
-
|
|
335
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L161)
|
|
336
|
-
|
|
337
|
-
##### :gear: consentMessage
|
|
338
|
-
|
|
339
|
-
Fetches the consent message for a specified canister call, intended to provide a human-readable message that helps users make informed decisions.
|
|
340
|
-
|
|
341
|
-
| Method | Type |
|
|
342
|
-
| ---------------- | ---------------------------------------------------------------------- |
|
|
343
|
-
| `consentMessage` | `(params: Icrc21ConsentMessageParams) => Promise<icrc21_consent_info>` |
|
|
344
|
-
|
|
345
|
-
Parameters:
|
|
346
|
-
|
|
347
|
-
- `params`: - The request parameters containing the method name, arguments, and consent preferences (e.g., language).
|
|
348
|
-
|
|
349
|
-
Returns:
|
|
350
|
-
|
|
351
|
-
- A promise that resolves to the consent message response, which includes the consent message in the specified language and other related information.
|
|
352
|
-
|
|
353
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L179)
|
|
354
|
-
|
|
355
|
-
##### :gear: getBlocks
|
|
356
|
-
|
|
357
|
-
Fetches the blocks information from the ledger canister,
|
|
358
|
-
|
|
359
|
-
| Method | Type |
|
|
360
|
-
| ----------- | ------------------------------------------------------- |
|
|
361
|
-
| `getBlocks` | `(params: GetBlocksParams) => Promise<GetBlocksResult>` |
|
|
362
|
-
|
|
363
|
-
Parameters:
|
|
364
|
-
|
|
365
|
-
- `params`: The parameters to get the blocks.
|
|
366
|
-
|
|
367
|
-
Returns:
|
|
368
|
-
|
|
369
|
-
The list of blocks.
|
|
370
|
-
|
|
371
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L203)
|
|
372
|
-
|
|
373
|
-
##### :gear: getIndexPrincipal
|
|
374
|
-
|
|
375
|
-
Returns the principal of the index canister for the ledger, if one was defined as such.
|
|
376
|
-
|
|
377
|
-
| Method | Type |
|
|
378
|
-
| ------------------- | --------------------------------------------- |
|
|
379
|
-
| `getIndexPrincipal` | `(params: QueryParams) => Promise<Principal>` |
|
|
380
|
-
|
|
381
|
-
Returns:
|
|
382
|
-
|
|
383
|
-
The principal of the index canister.
|
|
384
|
-
|
|
385
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L216)
|
|
386
|
-
|
|
387
|
-
##### :gear: icrc1SupportedStandards
|
|
388
|
-
|
|
389
|
-
Returns the list of standards this ledger supports by using icrc1_supported_standards.
|
|
390
|
-
|
|
391
|
-
| Method | Type |
|
|
392
|
-
| ------------------------- | ---------------------------------------------------- |
|
|
393
|
-
| `icrc1SupportedStandards` | `(params: QueryParams) => Promise<StandardRecord[]>` |
|
|
394
|
-
|
|
395
|
-
Returns:
|
|
396
|
-
|
|
397
|
-
The list of standards.
|
|
398
|
-
|
|
399
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L235)
|
|
400
|
-
|
|
401
|
-
##### :gear: icrc10SupportedStandards
|
|
402
|
-
|
|
403
|
-
Returns the list of standards this ledger supports by using icrc10_supported_standards.
|
|
404
|
-
|
|
405
|
-
| Method | Type |
|
|
406
|
-
| -------------------------- | -------------------------------------------------------------------- |
|
|
407
|
-
| `icrc10SupportedStandards` | `(params: QueryParams) => Promise<{ url: string; name: string; }[]>` |
|
|
408
|
-
|
|
409
|
-
Returns:
|
|
410
|
-
|
|
411
|
-
The list of standards.
|
|
412
|
-
|
|
413
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L245)
|
|
414
|
-
|
|
415
|
-
##### :gear: getMintingAccount
|
|
416
|
-
|
|
417
|
-
Returns the minting account of the Ledger canister.
|
|
418
|
-
|
|
419
|
-
| Method | Type |
|
|
420
|
-
| ------------------- | ----------------------------------------------------- |
|
|
421
|
-
| `getMintingAccount` | `(params: QueryParams) => Promise<Nullable<Account>>` |
|
|
422
|
-
|
|
423
|
-
Returns:
|
|
424
|
-
|
|
425
|
-
The minting account as a Nullable object.
|
|
426
|
-
|
|
427
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L257)
|
|
428
|
-
|
|
429
|
-
### :factory: IcrcIndexCanister
|
|
430
|
-
|
|
431
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
|
|
432
|
-
|
|
433
|
-
#### Static Methods
|
|
434
|
-
|
|
435
|
-
- [create](#gear-create)
|
|
436
|
-
|
|
437
|
-
##### :gear: create
|
|
438
|
-
|
|
439
|
-
| Method | Type |
|
|
440
|
-
| -------- | --------------------------------------------------------------------- |
|
|
441
|
-
| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` |
|
|
442
|
-
|
|
443
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index.canister.ts#L15)
|
|
444
|
-
|
|
445
|
-
#### Methods
|
|
446
|
-
|
|
447
|
-
- [getTransactions](#gear-gettransactions)
|
|
448
|
-
- [ledgerId](#gear-ledgerid)
|
|
449
|
-
|
|
450
|
-
##### :gear: getTransactions
|
|
451
|
-
|
|
452
|
-
Get the transactions of an account
|
|
453
|
-
|
|
454
|
-
Always certified.
|
|
455
|
-
`get_account_transactions` needs to be called with an update
|
|
456
|
-
because the index canisters makes a call to the ledger canister to get the transaction data.
|
|
457
|
-
Index Canister only holds the transactions ids in state, not the whole transaction data.
|
|
458
|
-
|
|
459
|
-
| Method | Type |
|
|
460
|
-
| ----------------- | -------------------------------------------------------------------- |
|
|
461
|
-
| `getTransactions` | `(params: GetAccountTransactionsParams) => Promise<GetTransactions>` |
|
|
462
|
-
|
|
463
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index.canister.ts#L34)
|
|
464
|
-
|
|
465
|
-
##### :gear: ledgerId
|
|
466
|
-
|
|
467
|
-
Returns the ledger canister ID related to the index canister.
|
|
468
|
-
|
|
469
|
-
| Method | Type |
|
|
470
|
-
| ---------- | --------------------------------------------- |
|
|
471
|
-
| `ledgerId` | `(params: QueryParams) => Promise<Principal>` |
|
|
472
|
-
|
|
473
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index.canister.ts#L51)
|
|
474
|
-
|
|
475
|
-
### :factory: IcrcIndexNgCanister
|
|
476
|
-
|
|
477
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L23)
|
|
478
|
-
|
|
479
|
-
#### Static Methods
|
|
480
|
-
|
|
481
|
-
- [create](#gear-create)
|
|
482
|
-
|
|
483
|
-
##### :gear: create
|
|
484
|
-
|
|
485
|
-
| Method | Type |
|
|
486
|
-
| -------- | ----------------------------------------------------------------------- |
|
|
487
|
-
| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexNgCanister` |
|
|
488
|
-
|
|
489
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L24)
|
|
490
|
-
|
|
491
|
-
#### Methods
|
|
492
|
-
|
|
493
|
-
- [getTransactions](#gear-gettransactions)
|
|
494
|
-
- [ledgerId](#gear-ledgerid)
|
|
495
|
-
- [status](#gear-status)
|
|
496
|
-
- [listSubaccounts](#gear-listsubaccounts)
|
|
497
|
-
|
|
498
|
-
##### :gear: getTransactions
|
|
499
|
-
|
|
500
|
-
Get the transactions of an account.
|
|
501
|
-
|
|
502
|
-
| Method | Type |
|
|
503
|
-
| ----------------- | ------------------------------------------------------------------------------------------- |
|
|
504
|
-
| `getTransactions` | `({ certified, ...rest }: GetIndexNgAccountTransactionsParams) => Promise<GetTransactions>` |
|
|
505
|
-
|
|
506
|
-
Parameters:
|
|
507
|
-
|
|
508
|
-
- `params`: The parameters to get the transactions of an account.
|
|
509
|
-
|
|
510
|
-
Returns:
|
|
511
|
-
|
|
512
|
-
The list of transactions and further related information of the given account.
|
|
513
|
-
|
|
514
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L49)
|
|
515
|
-
|
|
516
|
-
##### :gear: ledgerId
|
|
517
|
-
|
|
518
|
-
Returns the ledger canister ID related to the index canister.
|
|
519
|
-
|
|
520
|
-
| Method | Type |
|
|
521
|
-
| ---------- | --------------------------------------------- |
|
|
522
|
-
| `ledgerId` | `(params: QueryParams) => Promise<Principal>` |
|
|
523
|
-
|
|
524
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L67)
|
|
525
|
-
|
|
526
|
-
##### :gear: status
|
|
527
|
-
|
|
528
|
-
Returns the status of the index canister.
|
|
529
|
-
|
|
530
|
-
| Method | Type |
|
|
531
|
-
| -------- | ------------------------------------------ |
|
|
532
|
-
| `status` | `(params: QueryParams) => Promise<Status>` |
|
|
533
|
-
|
|
534
|
-
Parameters:
|
|
535
|
-
|
|
536
|
-
- `params`: The parameters to get the status of the index canister.
|
|
537
|
-
|
|
538
|
-
Returns:
|
|
539
|
-
|
|
540
|
-
The status of the index canister.
|
|
541
|
-
|
|
542
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L78)
|
|
543
|
-
|
|
544
|
-
##### :gear: listSubaccounts
|
|
545
|
-
|
|
546
|
-
Returns the list of subaccounts for a given owner.
|
|
547
|
-
|
|
548
|
-
| Method | Type |
|
|
549
|
-
| ----------------- | -------------------------------------------------------------------------- |
|
|
550
|
-
| `listSubaccounts` | `({ certified, ...rest }: ListSubaccountsParams) => Promise<SubAccount[]>` |
|
|
551
|
-
|
|
552
|
-
Parameters:
|
|
553
|
-
|
|
554
|
-
- `params`: The parameters to get the list of subaccounts.
|
|
555
|
-
|
|
556
|
-
Returns:
|
|
557
|
-
|
|
558
|
-
The list of subaccounts.
|
|
559
|
-
|
|
560
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L87)
|
|
54
|
+
## Documentation
|
|
561
55
|
|
|
562
|
-
|
|
56
|
+
You can find the API docs [here](https://js.icp.build/canisters/latest/api/ledger/icrc/).
|
|
563
57
|
|
|
564
58
|
## Resources
|
|
565
59
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.2.0.
|
|
6
|
+
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
|
+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
|
+
|
|
9
|
+
export const idlFactory = ({ IDL }) => {
|
|
10
|
+
const Subaccount = IDL.Vec(IDL.Nat8);
|
|
11
|
+
const Account = IDL.Record({
|
|
12
|
+
owner: IDL.Principal,
|
|
13
|
+
subaccount: IDL.Opt(Subaccount),
|
|
14
|
+
});
|
|
15
|
+
const Value = IDL.Variant({
|
|
16
|
+
Int: IDL.Int,
|
|
17
|
+
Nat: IDL.Nat,
|
|
18
|
+
Blob: IDL.Vec(IDL.Nat8),
|
|
19
|
+
Text: IDL.Text,
|
|
20
|
+
});
|
|
21
|
+
const Timestamp = IDL.Nat64;
|
|
22
|
+
const TransferArgs = IDL.Record({
|
|
23
|
+
to: Account,
|
|
24
|
+
fee: IDL.Opt(IDL.Nat),
|
|
25
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
26
|
+
from_subaccount: IDL.Opt(Subaccount),
|
|
27
|
+
created_at_time: IDL.Opt(Timestamp),
|
|
28
|
+
amount: IDL.Nat,
|
|
29
|
+
});
|
|
30
|
+
const TransferError = IDL.Variant({
|
|
31
|
+
GenericError: IDL.Record({
|
|
32
|
+
message: IDL.Text,
|
|
33
|
+
error_code: IDL.Nat,
|
|
34
|
+
}),
|
|
35
|
+
TemporarilyUnavailable: IDL.Null,
|
|
36
|
+
BadBurn: IDL.Record({ min_burn_amount: IDL.Nat }),
|
|
37
|
+
Duplicate: IDL.Record({ duplicate_of: IDL.Nat }),
|
|
38
|
+
BadFee: IDL.Record({ expected_fee: IDL.Nat }),
|
|
39
|
+
CreatedInFuture: IDL.Record({ ledger_time: Timestamp }),
|
|
40
|
+
TooOld: IDL.Null,
|
|
41
|
+
InsufficientFunds: IDL.Record({ balance: IDL.Nat }),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return IDL.Service({
|
|
45
|
+
icrc1_balance_of: IDL.Func([Account], [IDL.Nat], []),
|
|
46
|
+
icrc1_decimals: IDL.Func([], [IDL.Nat8], []),
|
|
47
|
+
icrc1_fee: IDL.Func([], [IDL.Nat], []),
|
|
48
|
+
icrc1_metadata: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, Value))], []),
|
|
49
|
+
icrc1_minting_account: IDL.Func([], [IDL.Opt(Account)], []),
|
|
50
|
+
icrc1_name: IDL.Func([], [IDL.Text], []),
|
|
51
|
+
icrc1_supported_standards: IDL.Func(
|
|
52
|
+
[],
|
|
53
|
+
[IDL.Vec(IDL.Record({ url: IDL.Text, name: IDL.Text }))],
|
|
54
|
+
[],
|
|
55
|
+
),
|
|
56
|
+
icrc1_symbol: IDL.Func([], [IDL.Text], []),
|
|
57
|
+
icrc1_total_supply: IDL.Func([], [IDL.Nat], []),
|
|
58
|
+
icrc1_transfer: IDL.Func(
|
|
59
|
+
[TransferArgs],
|
|
60
|
+
[IDL.Variant({ Ok: IDL.Nat, Err: TransferError })],
|
|
61
|
+
[],
|
|
62
|
+
),
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const init = ({ IDL }) => {
|
|
67
|
+
return [];
|
|
68
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.2.0.
|
|
6
|
+
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
|
+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
|
+
|
|
9
|
+
import type { ActorMethod } from "@icp-sdk/core/agent";
|
|
10
|
+
import type { IDL } from "@icp-sdk/core/candid";
|
|
11
|
+
import type { Principal } from "@icp-sdk/core/principal";
|
|
12
|
+
|
|
13
|
+
export interface Account {
|
|
14
|
+
owner: Principal;
|
|
15
|
+
subaccount: [] | [Subaccount];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Number of nanoseconds between two [Timestamp]s.
|
|
19
|
+
*/
|
|
20
|
+
export type Duration = bigint;
|
|
21
|
+
export type Subaccount = Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* Number of nanoseconds since the UNIX epoch in UTC timezone.
|
|
24
|
+
*/
|
|
25
|
+
export type Timestamp = bigint;
|
|
26
|
+
export interface TransferArgs {
|
|
27
|
+
to: Account;
|
|
28
|
+
fee: [] | [bigint];
|
|
29
|
+
memo: [] | [Uint8Array];
|
|
30
|
+
from_subaccount: [] | [Subaccount];
|
|
31
|
+
created_at_time: [] | [Timestamp];
|
|
32
|
+
amount: bigint;
|
|
33
|
+
}
|
|
34
|
+
export type TransferError =
|
|
35
|
+
| {
|
|
36
|
+
GenericError: { message: string; error_code: bigint };
|
|
37
|
+
}
|
|
38
|
+
| { TemporarilyUnavailable: null }
|
|
39
|
+
| { BadBurn: { min_burn_amount: bigint } }
|
|
40
|
+
| { Duplicate: { duplicate_of: bigint } }
|
|
41
|
+
| { BadFee: { expected_fee: bigint } }
|
|
42
|
+
| { CreatedInFuture: { ledger_time: Timestamp } }
|
|
43
|
+
| { TooOld: null }
|
|
44
|
+
| { InsufficientFunds: { balance: bigint } };
|
|
45
|
+
export type Value =
|
|
46
|
+
| { Int: bigint }
|
|
47
|
+
| { Nat: bigint }
|
|
48
|
+
| { Blob: Uint8Array }
|
|
49
|
+
| { Text: string };
|
|
50
|
+
export interface _SERVICE {
|
|
51
|
+
icrc1_balance_of: ActorMethod<[Account], bigint>;
|
|
52
|
+
icrc1_decimals: ActorMethod<[], number>;
|
|
53
|
+
icrc1_fee: ActorMethod<[], bigint>;
|
|
54
|
+
icrc1_metadata: ActorMethod<[], Array<[string, Value]>>;
|
|
55
|
+
icrc1_minting_account: ActorMethod<[], [] | [Account]>;
|
|
56
|
+
icrc1_name: ActorMethod<[], string>;
|
|
57
|
+
icrc1_supported_standards: ActorMethod<
|
|
58
|
+
[],
|
|
59
|
+
Array<{ url: string; name: string }>
|
|
60
|
+
>;
|
|
61
|
+
icrc1_symbol: ActorMethod<[], string>;
|
|
62
|
+
icrc1_total_supply: ActorMethod<[], bigint>;
|
|
63
|
+
icrc1_transfer: ActorMethod<
|
|
64
|
+
[TransferArgs],
|
|
65
|
+
{ Ok: bigint } | { Err: TransferError }
|
|
66
|
+
>;
|
|
67
|
+
}
|
|
68
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
69
|
+
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|