@dfinity/ledger-icrc 4.0.1 → 4.0.3

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.
@@ -29,7 +29,16 @@ export interface FeeCollectorRanges {
29
29
  ranges: Array<[Account, Array<[BlockIndex, BlockIndex]>]>;
30
30
  }
31
31
  export interface GetAccountTransactionsArgs {
32
+ /**
33
+ * Maximum number of transactions to fetch.
34
+ */
32
35
  max_results: bigint;
36
+ /**
37
+ * The txid of the last transaction seen by the client.
38
+ * If None then the results will start from the most recent
39
+ * txid. If set then the results will start from the next
40
+ * most recent txid after start (start won't be included).
41
+ */
33
42
  start: [] | [BlockIndex];
34
43
  account: Account;
35
44
  }
@@ -44,6 +53,9 @@ export interface GetBlocksResponse {
44
53
  export interface GetTransactions {
45
54
  balance: Tokens;
46
55
  transactions: Array<TransactionWithId>;
56
+ /**
57
+ * The txid of the oldest transaction the account has
58
+ */
47
59
  oldest_tx_id: [] | [BlockIndex];
48
60
  }
49
61
  export interface GetTransactionsErr {
@@ -55,6 +67,11 @@ export type GetTransactionsResult =
55
67
  export type IndexArg = { Upgrade: UpgradeArg } | { Init: InitArg };
56
68
  export interface InitArg {
57
69
  ledger_id: Principal;
70
+ /**
71
+ * The interval in seconds in which to retrieve blocks from the ledger. A lower value makes the index more
72
+ * responsive in showing new blocks, but increases the consumption of cycles of both the index and ledger canisters.
73
+ * A higher values means that it takes longer for new blocks to show up in the index.
74
+ */
58
75
  retrieve_blocks_from_ledger_interval_seconds: [] | [bigint];
59
76
  }
60
77
  export interface ListSubaccountsArgs {
@@ -96,6 +113,11 @@ export interface Transfer {
96
113
  }
97
114
  export interface UpgradeArg {
98
115
  ledger_id: [] | [Principal];
116
+ /**
117
+ * The interval in seconds in which to retrieve blocks from the ledger. A lower value makes the index more
118
+ * responsive in showing new blocks, but increases the consumption of cycles of both the index and ledger canisters.
119
+ * A higher values means that it takes longer for new blocks to show up in the index.
120
+ */
99
121
  retrieve_blocks_from_ledger_interval_seconds: [] | [bigint];
100
122
  }
101
123
  export type Value =
@@ -1,4 +1,5 @@
1
- // Generated from IC repo commit 9173238 (2025-08-18 tags: release-2025-08-28_03-17-snapshot-feature) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit 206b61a (2025-09-25 tags: release-2025-09-25_09-52-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
2
+
2
3
  type Tokens = nat;
3
4
 
4
5
  type InitArg = record {
@@ -24,12 +24,23 @@ export interface Burn {
24
24
  spender: [] | [Account];
25
25
  }
26
26
  export interface GetAccountTransactionsArgs {
27
+ /**
28
+ * Maximum number of transactions to fetch.
29
+ */
27
30
  max_results: bigint;
31
+ /**
32
+ * The txid of the last transaction seen by the client.
33
+ * If None then the results will start from the most recent
34
+ * txid.
35
+ */
28
36
  start: [] | [TxId];
29
37
  account: Account;
30
38
  }
31
39
  export interface GetTransactions {
32
40
  transactions: Array<TransactionWithId>;
41
+ /**
42
+ * The txid of the oldest transaction the account has
43
+ */
33
44
  oldest_tx_id: [] | [TxId];
34
45
  }
35
46
  export interface GetTransactionsErr {
@@ -38,6 +49,9 @@ export interface GetTransactionsErr {
38
49
  export type GetTransactionsResult =
39
50
  | { Ok: GetTransactions }
40
51
  | { Err: GetTransactionsErr };
52
+ /**
53
+ * The initialization parameters of the Index canister.
54
+ */
41
55
  export interface InitArgs {
42
56
  ledger_id: Principal;
43
57
  }
@@ -1,4 +1,5 @@
1
1
  // Generated from IC repo commit d9fe207 (2024-12-06 tags: release-2024-12-06_03-16-base) 'rs/ledger_suite/icrc1/index/index.did' by import-candid
2
+
2
3
  type TxId = nat;
3
4
 
4
5
  type Account = record { owner : principal; subaccount : opt blob };
@@ -60,7 +60,27 @@ export interface ArchiveInfo {
60
60
  }
61
61
  export type Block = Value;
62
62
  export type BlockIndex = bigint;
63
+ /**
64
+ * A prefix of the block range specified in the [GetBlocksArgs] request.
65
+ */
63
66
  export interface BlockRange {
67
+ /**
68
+ * A prefix of the requested block range.
69
+ * The index of the first block is equal to [GetBlocksArgs.start].
70
+ *
71
+ * Note that the number of blocks might be less than the requested
72
+ * [GetBlocksArgs.length] for various reasons, for example:
73
+ *
74
+ * 1. The query might have hit the replica with an outdated state
75
+ * that doesn't have the whole range yet.
76
+ * 2. The requested range is too large to fit into a single reply.
77
+ *
78
+ * NOTE: the list of blocks can be empty if:
79
+ *
80
+ * 1. [GetBlocksArgs.length] was zero.
81
+ * 2. [GetBlocksArgs.start] was larger than the last block known to
82
+ * the canister.
83
+ */
64
84
  blocks: Array<Block>;
65
85
  }
66
86
  export interface Burn {
@@ -81,10 +101,16 @@ export interface ChangeArchiveOptions {
81
101
  controller_id: [] | [Principal];
82
102
  }
83
103
  export type ChangeFeeCollector = { SetTo: Account } | { Unset: null };
104
+ /**
105
+ * Certificate for the block at `block_index`.
106
+ */
84
107
  export interface DataCertificate {
85
108
  certificate: [] | [Uint8Array | number[]];
86
109
  hash_tree: Uint8Array | number[];
87
110
  }
111
+ /**
112
+ * Number of nanoseconds between two [Timestamp]s.
113
+ */
88
114
  export type Duration = bigint;
89
115
  export interface FeatureFlags {
90
116
  icrc2: boolean;
@@ -104,29 +130,90 @@ export type GetAllowancesError =
104
130
  }
105
131
  | { AccessDenied: { reason: string } };
106
132
  export interface GetArchivesArgs {
133
+ /**
134
+ * The last archive seen by the client.
135
+ * The Ledger will return archives coming
136
+ * after this one if set, otherwise it
137
+ * will return the first archives.
138
+ */
107
139
  from: [] | [Principal];
108
140
  }
109
141
  export type GetArchivesResult = Array<{
142
+ /**
143
+ * The last block in the archive
144
+ */
110
145
  end: bigint;
146
+ /**
147
+ * The id of the archive
148
+ */
111
149
  canister_id: Principal;
150
+ /**
151
+ * The first block in the archive
152
+ */
112
153
  start: bigint;
113
154
  }>;
114
155
  export interface GetBlocksArgs {
156
+ /**
157
+ * The index of the first block to fetch.
158
+ */
115
159
  start: BlockIndex;
160
+ /**
161
+ * Max number of blocks to fetch.
162
+ */
116
163
  length: bigint;
117
164
  }
165
+ /**
166
+ * The result of a "get_blocks" call.
167
+ */
118
168
  export interface GetBlocksResponse {
169
+ /**
170
+ * System certificate for the hash of the latest block in the chain.
171
+ * Only present if `get_blocks` is called in a non-replicated query context.
172
+ */
119
173
  certificate: [] | [Uint8Array | number[]];
174
+ /**
175
+ * The index of the first block in "blocks".
176
+ * If the blocks vector is empty, the exact value of this field is not specified.
177
+ */
120
178
  first_index: BlockIndex;
179
+ /**
180
+ * List of blocks that were available in the ledger when it processed the call.
181
+ *
182
+ * The blocks form a contiguous range, with the first block having index
183
+ * [first_block_index] (see below), and the last block having index
184
+ * [first_block_index] + len(blocks) - 1.
185
+ *
186
+ * The block range can be an arbitrary sub-range of the originally requested range.
187
+ */
121
188
  blocks: Array<Block>;
189
+ /**
190
+ * The total number of blocks in the chain.
191
+ * If the chain length is positive, the index of the last block is `chain_len - 1`.
192
+ */
122
193
  chain_length: bigint;
194
+ /**
195
+ * Encoding of instructions for fetching archived blocks.
196
+ */
123
197
  archived_blocks: Array<{
124
- callback: QueryBlockArchiveFn;
198
+ /**
199
+ * Callback to fetch the archived blocks.
200
+ */
201
+ callback: [Principal, string];
202
+ /**
203
+ * The index of the first archived block.
204
+ */
125
205
  start: BlockIndex;
206
+ /**
207
+ * The number of blocks that can be fetched.
208
+ */
126
209
  length: bigint;
127
210
  }>;
128
211
  }
129
212
  export interface GetBlocksResult {
213
+ /**
214
+ * Total number of blocks in the
215
+ * block log
216
+ */
130
217
  log_length: bigint;
131
218
  blocks: Array<{ id: bigint; block: ICRC3Value }>;
132
219
  archived_blocks: Array<{
@@ -136,6 +223,9 @@ export interface GetBlocksResult {
136
223
  }
137
224
  export type GetIndexPrincipalError =
138
225
  | {
226
+ /**
227
+ * Any error not covered by the above variants.
228
+ */
139
229
  GenericError: { description: string; error_code: bigint };
140
230
  }
141
231
  | { IndexPrincipalNotSet: null };
@@ -143,16 +233,56 @@ export type GetIndexPrincipalResult =
143
233
  | { Ok: Principal }
144
234
  | { Err: GetIndexPrincipalError };
145
235
  export interface GetTransactionsRequest {
236
+ /**
237
+ * The index of the first tx to fetch.
238
+ */
146
239
  start: TxIndex;
240
+ /**
241
+ * The number of transactions to fetch.
242
+ */
147
243
  length: bigint;
148
244
  }
149
245
  export interface GetTransactionsResponse {
246
+ /**
247
+ * The index of the first transaction in [transactions].
248
+ * If the transaction vector is empty, the exact value of this field is not specified.
249
+ */
150
250
  first_index: TxIndex;
251
+ /**
252
+ * The total number of transactions in the log.
253
+ */
151
254
  log_length: bigint;
255
+ /**
256
+ * List of transaction that were available in the ledger when it processed the call.
257
+ *
258
+ * The transactions form a contiguous range, with the first transaction having index
259
+ * [first_index] (see below), and the last transaction having index
260
+ * [first_index] + len(transactions) - 1.
261
+ *
262
+ * The transaction range can be an arbitrary sub-range of the originally requested range.
263
+ */
152
264
  transactions: Array<Transaction>;
265
+ /**
266
+ * Encoding of instructions for fetching archived transactions whose indices fall into the
267
+ * requested range.
268
+ *
269
+ * For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range
270
+ * of the originally requested transaction range.
271
+ */
153
272
  archived_transactions: Array<{
154
- callback: QueryArchiveFn;
273
+ /**
274
+ * The function you should call to fetch the archived transactions.
275
+ * The range of the transaction accessible using this function is given by [from]
276
+ * and [len] fields above.
277
+ */
278
+ callback: [Principal, string];
279
+ /**
280
+ * The index of the first archived transaction you can fetch using the [callback].
281
+ */
155
282
  start: TxIndex;
283
+ /**
284
+ * The number of transactions you can fetch using the callback.
285
+ */
156
286
  length: bigint;
157
287
  }>;
158
288
  }
@@ -168,7 +298,13 @@ export interface HttpResponse {
168
298
  status_code: number;
169
299
  }
170
300
  export interface ICRC3DataCertificate {
301
+ /**
302
+ * See https://internetcomputer.org/docs/current/references/ic-interface-spec#certification
303
+ */
171
304
  certificate: Uint8Array | number[];
305
+ /**
306
+ * CBOR encoded hash_tree
307
+ */
172
308
  hash_tree: Uint8Array | number[];
173
309
  }
174
310
  export type ICRC3Value =
@@ -189,6 +325,9 @@ export type Icrc21Value =
189
325
  }
190
326
  | { TimestampSeconds: { amount: bigint } }
191
327
  | { DurationSeconds: { amount: bigint } };
328
+ /**
329
+ * The initialization parameters of the Ledger
330
+ */
192
331
  export interface InitArgs {
193
332
  decimals: [] | [number];
194
333
  token_symbol: string;
@@ -214,6 +353,9 @@ export interface InitArgs {
214
353
  }
215
354
  export type LedgerArg = { Upgrade: [] | [UpgradeArgs] } | { Init: InitArgs };
216
355
  export type Map = Array<[string, Value]>;
356
+ /**
357
+ * The value returned from the [icrc1_metadata] endpoint.
358
+ */
217
359
  export type MetadataValue =
218
360
  | { Int: bigint }
219
361
  | { Nat: bigint }
@@ -225,16 +367,25 @@ export interface Mint {
225
367
  created_at_time: [] | [Timestamp];
226
368
  amount: bigint;
227
369
  }
370
+ /**
371
+ * A function for fetching archived transaction.
372
+ */
228
373
  export type QueryArchiveFn = ActorMethod<
229
374
  [GetTransactionsRequest],
230
375
  TransactionRange
231
376
  >;
377
+ /**
378
+ * A function for fetching archived blocks.
379
+ */
232
380
  export type QueryBlockArchiveFn = ActorMethod<[GetBlocksArgs], BlockRange>;
233
381
  export interface StandardRecord {
234
382
  url: string;
235
383
  name: string;
236
384
  }
237
385
  export type Subaccount = Uint8Array | number[];
386
+ /**
387
+ * Number of nanoseconds since the UNIX epoch in UTC timezone.
388
+ */
238
389
  export type Timestamp = bigint;
239
390
  export type Tokens = bigint;
240
391
  export interface Transaction {
@@ -245,7 +396,27 @@ export interface Transaction {
245
396
  timestamp: Timestamp;
246
397
  transfer: [] | [Transfer];
247
398
  }
399
+ /**
400
+ * A prefix of the transaction range specified in the [GetTransactionsRequest] request.
401
+ */
248
402
  export interface TransactionRange {
403
+ /**
404
+ * A prefix of the requested transaction range.
405
+ * The index of the first transaction is equal to [GetTransactionsRequest.from].
406
+ *
407
+ * Note that the number of transactions might be less than the requested
408
+ * [GetTransactionsRequest.length] for various reasons, for example:
409
+ *
410
+ * 1. The query might have hit the replica with an outdated state
411
+ * that doesn't have the whole range yet.
412
+ * 2. The requested range is too large to fit into a single reply.
413
+ *
414
+ * NOTE: the list of transactions can be empty if:
415
+ *
416
+ * 1. [GetTransactionsRequest.length] was zero.
417
+ * 2. [GetTransactionsRequest.from] was larger than the last transaction known to
418
+ * the canister.
419
+ */
249
420
  transactions: Array<Transaction>;
250
421
  }
251
422
  export interface Transfer {
@@ -351,6 +522,9 @@ export interface icrc21_consent_message_spec {
351
522
  }
352
523
  export type icrc21_error =
353
524
  | {
525
+ /**
526
+ * Any error not covered by the above variants.
527
+ */
354
528
  GenericError: { description: string; error_code: bigint };
355
529
  }
356
530
  | { InsufficientPayment: icrc21_error_info }
@@ -1,4 +1,5 @@
1
- // Generated from IC repo commit 9173238 (2025-08-18 tags: release-2025-08-28_03-17-snapshot-feature) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit 206b61a (2025-09-25 tags: release-2025-09-25_09-52-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
2
+
2
3
  type BlockIndex = nat;
3
4
  type Subaccount = blob;
4
5
  // Number of nanoseconds since the UNIX epoch in UTC timezone.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/ledger-icrc",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "A library for interfacing with ICRC ledgers on the Internet Computer.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",