@dfinity/ledger-icrc 1.0.0

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.
Files changed (42) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +291 -0
  3. package/dist/candid/icrc_index.certified.idl.d.ts +2 -0
  4. package/dist/candid/icrc_index.certified.idl.js +89 -0
  5. package/dist/candid/icrc_index.d.ts +83 -0
  6. package/dist/candid/icrc_index.did +97 -0
  7. package/dist/candid/icrc_index.idl.d.ts +2 -0
  8. package/dist/candid/icrc_index.idl.js +89 -0
  9. package/dist/candid/icrc_ledger.certified.idl.d.ts +2 -0
  10. package/dist/candid/icrc_ledger.certified.idl.js +335 -0
  11. package/dist/candid/icrc_ledger.d.ts +262 -0
  12. package/dist/candid/icrc_ledger.did +380 -0
  13. package/dist/candid/icrc_ledger.idl.d.ts +2 -0
  14. package/dist/candid/icrc_ledger.idl.js +343 -0
  15. package/dist/cjs/index.cjs.js +2 -0
  16. package/dist/cjs/index.cjs.js.map +7 -0
  17. package/dist/esm/chunk-XVPR4TJN.js +2 -0
  18. package/dist/esm/chunk-XVPR4TJN.js.map +7 -0
  19. package/dist/esm/chunk-Y76HDAJ2.js +2 -0
  20. package/dist/esm/chunk-Y76HDAJ2.js.map +7 -0
  21. package/dist/esm/index.canister.js +2 -0
  22. package/dist/esm/index.canister.js.map +7 -0
  23. package/dist/esm/index.js +2 -0
  24. package/dist/esm/index.js.map +7 -0
  25. package/dist/esm/ledger.canister.js +2 -0
  26. package/dist/esm/ledger.canister.js.map +7 -0
  27. package/dist/index.cjs.js +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/types/converters/index.converters.d.ts +3 -0
  30. package/dist/types/converters/ledger.converters.d.ts +5 -0
  31. package/dist/types/errors/index.errors.d.ts +2 -0
  32. package/dist/types/errors/ledger.errors.d.ts +7 -0
  33. package/dist/types/index.canister.d.ts +16 -0
  34. package/dist/types/index.d.ts +11 -0
  35. package/dist/types/ledger.canister.d.ts +68 -0
  36. package/dist/types/types/canister.options.d.ts +5 -0
  37. package/dist/types/types/index.params.d.ts +7 -0
  38. package/dist/types/types/ledger.params.d.ts +63 -0
  39. package/dist/types/types/ledger.responses.d.ts +17 -0
  40. package/dist/types/utils/ledger.utils.d.ts +18 -0
  41. package/dist/types/utils/payment.utils.d.ts +28 -0
  42. package/package.json +45 -0
@@ -0,0 +1,343 @@
1
+ /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_ledger.did */
2
+ export const idlFactory = ({ IDL }) => {
3
+ const Value = IDL.Rec();
4
+ const MetadataValue = IDL.Variant({
5
+ 'Int' : IDL.Int,
6
+ 'Nat' : IDL.Nat,
7
+ 'Blob' : IDL.Vec(IDL.Nat8),
8
+ 'Text' : IDL.Text,
9
+ });
10
+ const Subaccount = IDL.Vec(IDL.Nat8);
11
+ const Account = IDL.Record({
12
+ 'owner' : IDL.Principal,
13
+ 'subaccount' : IDL.Opt(Subaccount),
14
+ });
15
+ const ChangeFeeCollector = IDL.Variant({
16
+ 'SetTo' : Account,
17
+ 'Unset' : IDL.Null,
18
+ });
19
+ const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
20
+ const UpgradeArgs = IDL.Record({
21
+ 'token_symbol' : IDL.Opt(IDL.Text),
22
+ 'transfer_fee' : IDL.Opt(IDL.Nat),
23
+ 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
24
+ 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
25
+ 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
26
+ 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
27
+ 'max_memo_length' : IDL.Opt(IDL.Nat16),
28
+ 'token_name' : IDL.Opt(IDL.Text),
29
+ 'feature_flags' : IDL.Opt(FeatureFlags),
30
+ });
31
+ const InitArgs = IDL.Record({
32
+ 'decimals' : IDL.Opt(IDL.Nat8),
33
+ 'token_symbol' : IDL.Text,
34
+ 'transfer_fee' : IDL.Nat,
35
+ 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),
36
+ 'minting_account' : Account,
37
+ 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),
38
+ 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
39
+ 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
40
+ 'fee_collector_account' : IDL.Opt(Account),
41
+ 'archive_options' : IDL.Record({
42
+ 'num_blocks_to_archive' : IDL.Nat64,
43
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
44
+ 'trigger_threshold' : IDL.Nat64,
45
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
46
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
47
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
48
+ 'controller_id' : IDL.Principal,
49
+ }),
50
+ 'max_memo_length' : IDL.Opt(IDL.Nat16),
51
+ 'token_name' : IDL.Text,
52
+ 'feature_flags' : IDL.Opt(FeatureFlags),
53
+ });
54
+ const LedgerArg = IDL.Variant({
55
+ 'Upgrade' : IDL.Opt(UpgradeArgs),
56
+ 'Init' : InitArgs,
57
+ });
58
+ const BlockIndex = IDL.Nat;
59
+ const GetBlocksArgs = IDL.Record({
60
+ 'start' : BlockIndex,
61
+ 'length' : IDL.Nat,
62
+ });
63
+ const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
64
+ Value.fill(
65
+ IDL.Variant({
66
+ 'Int' : IDL.Int,
67
+ 'Map' : Map,
68
+ 'Nat' : IDL.Nat,
69
+ 'Nat64' : IDL.Nat64,
70
+ 'Blob' : IDL.Vec(IDL.Nat8),
71
+ 'Text' : IDL.Text,
72
+ 'Array' : IDL.Vec(Value),
73
+ })
74
+ );
75
+ const Block = Value;
76
+ const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });
77
+ const QueryBlockArchiveFn = IDL.Func(
78
+ [GetBlocksArgs],
79
+ [BlockRange],
80
+ ['query'],
81
+ );
82
+ const GetBlocksResponse = IDL.Record({
83
+ 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
84
+ 'first_index' : BlockIndex,
85
+ 'blocks' : IDL.Vec(Block),
86
+ 'chain_length' : IDL.Nat64,
87
+ 'archived_blocks' : IDL.Vec(
88
+ IDL.Record({
89
+ 'callback' : QueryBlockArchiveFn,
90
+ 'start' : BlockIndex,
91
+ 'length' : IDL.Nat,
92
+ })
93
+ ),
94
+ });
95
+ const DataCertificate = IDL.Record({
96
+ 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
97
+ 'hash_tree' : IDL.Vec(IDL.Nat8),
98
+ });
99
+ const TxIndex = IDL.Nat;
100
+ const GetTransactionsRequest = IDL.Record({
101
+ 'start' : TxIndex,
102
+ 'length' : IDL.Nat,
103
+ });
104
+ const Burn = IDL.Record({
105
+ 'from' : Account,
106
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
107
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
108
+ 'amount' : IDL.Nat,
109
+ 'spender' : IDL.Opt(Account),
110
+ });
111
+ const Mint = IDL.Record({
112
+ 'to' : Account,
113
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
114
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
115
+ 'amount' : IDL.Nat,
116
+ });
117
+ const Approve = IDL.Record({
118
+ 'fee' : IDL.Opt(IDL.Nat),
119
+ 'from' : Account,
120
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
121
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
122
+ 'amount' : IDL.Nat,
123
+ 'expected_allowance' : IDL.Opt(IDL.Nat),
124
+ 'expires_at' : IDL.Opt(IDL.Nat64),
125
+ 'spender' : Account,
126
+ });
127
+ const Transfer = IDL.Record({
128
+ 'to' : Account,
129
+ 'fee' : IDL.Opt(IDL.Nat),
130
+ 'from' : Account,
131
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
132
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
133
+ 'amount' : IDL.Nat,
134
+ 'spender' : IDL.Opt(Account),
135
+ });
136
+ const Transaction = IDL.Record({
137
+ 'burn' : IDL.Opt(Burn),
138
+ 'kind' : IDL.Text,
139
+ 'mint' : IDL.Opt(Mint),
140
+ 'approve' : IDL.Opt(Approve),
141
+ 'timestamp' : IDL.Nat64,
142
+ 'transfer' : IDL.Opt(Transfer),
143
+ });
144
+ const TransactionRange = IDL.Record({
145
+ 'transactions' : IDL.Vec(Transaction),
146
+ });
147
+ const QueryArchiveFn = IDL.Func(
148
+ [GetTransactionsRequest],
149
+ [TransactionRange],
150
+ ['query'],
151
+ );
152
+ const GetTransactionsResponse = IDL.Record({
153
+ 'first_index' : TxIndex,
154
+ 'log_length' : IDL.Nat,
155
+ 'transactions' : IDL.Vec(Transaction),
156
+ 'archived_transactions' : IDL.Vec(
157
+ IDL.Record({
158
+ 'callback' : QueryArchiveFn,
159
+ 'start' : TxIndex,
160
+ 'length' : IDL.Nat,
161
+ })
162
+ ),
163
+ });
164
+ const Tokens = IDL.Nat;
165
+ const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });
166
+ const Timestamp = IDL.Nat64;
167
+ const TransferArg = IDL.Record({
168
+ 'to' : Account,
169
+ 'fee' : IDL.Opt(Tokens),
170
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
171
+ 'from_subaccount' : IDL.Opt(Subaccount),
172
+ 'created_at_time' : IDL.Opt(Timestamp),
173
+ 'amount' : Tokens,
174
+ });
175
+ const TransferError = IDL.Variant({
176
+ 'GenericError' : IDL.Record({
177
+ 'message' : IDL.Text,
178
+ 'error_code' : IDL.Nat,
179
+ }),
180
+ 'TemporarilyUnavailable' : IDL.Null,
181
+ 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
182
+ 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
183
+ 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
184
+ 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
185
+ 'TooOld' : IDL.Null,
186
+ 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
187
+ });
188
+ const TransferResult = IDL.Variant({
189
+ 'Ok' : BlockIndex,
190
+ 'Err' : TransferError,
191
+ });
192
+ const AllowanceArgs = IDL.Record({
193
+ 'account' : Account,
194
+ 'spender' : Account,
195
+ });
196
+ const Allowance = IDL.Record({
197
+ 'allowance' : IDL.Nat,
198
+ 'expires_at' : IDL.Opt(IDL.Nat64),
199
+ });
200
+ const ApproveArgs = IDL.Record({
201
+ 'fee' : IDL.Opt(IDL.Nat),
202
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
203
+ 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
204
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
205
+ 'amount' : IDL.Nat,
206
+ 'expected_allowance' : IDL.Opt(IDL.Nat),
207
+ 'expires_at' : IDL.Opt(IDL.Nat64),
208
+ 'spender' : Account,
209
+ });
210
+ const ApproveError = IDL.Variant({
211
+ 'GenericError' : IDL.Record({
212
+ 'message' : IDL.Text,
213
+ 'error_code' : IDL.Nat,
214
+ }),
215
+ 'TemporarilyUnavailable' : IDL.Null,
216
+ 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }),
217
+ 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),
218
+ 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),
219
+ 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
220
+ 'TooOld' : IDL.Null,
221
+ 'Expired' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
222
+ 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),
223
+ });
224
+ const ApproveResult = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : ApproveError });
225
+ const TransferFromArgs = IDL.Record({
226
+ 'to' : Account,
227
+ 'fee' : IDL.Opt(Tokens),
228
+ 'spender_subaccount' : IDL.Opt(Subaccount),
229
+ 'from' : Account,
230
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
231
+ 'created_at_time' : IDL.Opt(Timestamp),
232
+ 'amount' : Tokens,
233
+ });
234
+ const TransferFromError = IDL.Variant({
235
+ 'GenericError' : IDL.Record({
236
+ 'message' : IDL.Text,
237
+ 'error_code' : IDL.Nat,
238
+ }),
239
+ 'TemporarilyUnavailable' : IDL.Null,
240
+ 'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),
241
+ 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
242
+ 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
243
+ 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
244
+ 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
245
+ 'TooOld' : IDL.Null,
246
+ 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
247
+ });
248
+ const TransferFromResult = IDL.Variant({
249
+ 'Ok' : BlockIndex,
250
+ 'Err' : TransferFromError,
251
+ });
252
+ return IDL.Service({
253
+ 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], ['query']),
254
+ 'get_data_certificate' : IDL.Func([], [DataCertificate], ['query']),
255
+ 'get_transactions' : IDL.Func(
256
+ [GetTransactionsRequest],
257
+ [GetTransactionsResponse],
258
+ ['query'],
259
+ ),
260
+ 'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),
261
+ 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']),
262
+ 'icrc1_fee' : IDL.Func([], [Tokens], ['query']),
263
+ 'icrc1_metadata' : IDL.Func(
264
+ [],
265
+ [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],
266
+ ['query'],
267
+ ),
268
+ 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], ['query']),
269
+ 'icrc1_name' : IDL.Func([], [IDL.Text], ['query']),
270
+ 'icrc1_supported_standards' : IDL.Func(
271
+ [],
272
+ [IDL.Vec(StandardRecord)],
273
+ ['query'],
274
+ ),
275
+ 'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']),
276
+ 'icrc1_total_supply' : IDL.Func([], [Tokens], ['query']),
277
+ 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),
278
+ 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], ['query']),
279
+ 'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),
280
+ 'icrc2_transfer_from' : IDL.Func(
281
+ [TransferFromArgs],
282
+ [TransferFromResult],
283
+ [],
284
+ ),
285
+ });
286
+ };
287
+ export const init = ({ IDL }) => {
288
+ const MetadataValue = IDL.Variant({
289
+ 'Int' : IDL.Int,
290
+ 'Nat' : IDL.Nat,
291
+ 'Blob' : IDL.Vec(IDL.Nat8),
292
+ 'Text' : IDL.Text,
293
+ });
294
+ const Subaccount = IDL.Vec(IDL.Nat8);
295
+ const Account = IDL.Record({
296
+ 'owner' : IDL.Principal,
297
+ 'subaccount' : IDL.Opt(Subaccount),
298
+ });
299
+ const ChangeFeeCollector = IDL.Variant({
300
+ 'SetTo' : Account,
301
+ 'Unset' : IDL.Null,
302
+ });
303
+ const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
304
+ const UpgradeArgs = IDL.Record({
305
+ 'token_symbol' : IDL.Opt(IDL.Text),
306
+ 'transfer_fee' : IDL.Opt(IDL.Nat),
307
+ 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
308
+ 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
309
+ 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
310
+ 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
311
+ 'max_memo_length' : IDL.Opt(IDL.Nat16),
312
+ 'token_name' : IDL.Opt(IDL.Text),
313
+ 'feature_flags' : IDL.Opt(FeatureFlags),
314
+ });
315
+ const InitArgs = IDL.Record({
316
+ 'decimals' : IDL.Opt(IDL.Nat8),
317
+ 'token_symbol' : IDL.Text,
318
+ 'transfer_fee' : IDL.Nat,
319
+ 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),
320
+ 'minting_account' : Account,
321
+ 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),
322
+ 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
323
+ 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
324
+ 'fee_collector_account' : IDL.Opt(Account),
325
+ 'archive_options' : IDL.Record({
326
+ 'num_blocks_to_archive' : IDL.Nat64,
327
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
328
+ 'trigger_threshold' : IDL.Nat64,
329
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
330
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
331
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
332
+ 'controller_id' : IDL.Principal,
333
+ }),
334
+ 'max_memo_length' : IDL.Opt(IDL.Nat16),
335
+ 'token_name' : IDL.Text,
336
+ 'feature_flags' : IDL.Opt(FeatureFlags),
337
+ });
338
+ const LedgerArg = IDL.Variant({
339
+ 'Upgrade' : IDL.Opt(UpgradeArgs),
340
+ 'Init' : InitArgs,
341
+ });
342
+ return [LedgerArg];
343
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";var I=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ut=(t,c)=>{for(var a in c)I(t,a,{get:c[a],enumerable:!0})},_t=(t,c,a,r)=>{if(c&&typeof c=="object"||typeof c=="function")for(let e of mt(c))!dt.call(t,e)&&e!==a&&I(t,e,{get:()=>c[e],enumerable:!(r=lt(c,e))||r.enumerable});return t};var ft=t=>_t(I({},"__esModule",{value:!0}),t);var Rt={};ut(Rt,{IcrcIndexCanister:()=>F,IcrcLedgerCanister:()=>v,IcrcMetadataResponseEntries:()=>it,IcrcTransferError:()=>g,IndexError:()=>b,decodeIcrcAccount:()=>gt,decodePayment:()=>xt,encodeIcrcAccount:()=>Tt});module.exports=ft(Rt);var b=class extends Error{};var g=class extends Error{constructor({msg:a,errorType:r}){super(a);this.errorType=r}};var h=require("@dfinity/utils");var tt=({IDL:t})=>{let c=t.Record({ledger_id:t.Principal}),a=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(a),account:r}),n=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),i=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),_=t.Record({fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:r}),f=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),R=t.Record({burn:t.Opt(n),kind:t.Text,mint:t.Opt(i),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:a,transaction:R}),m=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(a)}),N=t.Record({message:t.Text}),d=t.Variant({Ok:m,Err:N}),u=t.Vec(t.Nat8),O=t.Record({owner:t.Principal,start:t.Opt(u)});return t.Service({get_account_transactions:t.Func([e],[d],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([O],[t.Vec(u)],[])})};var et=({IDL:t})=>{let c=t.Record({ledger_id:t.Principal}),a=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(a),account:r}),n=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),i=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),_=t.Record({fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:r}),f=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),R=t.Record({burn:t.Opt(n),kind:t.Text,mint:t.Opt(i),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:a,transaction:R}),m=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(a)}),N=t.Record({message:t.Text}),d=t.Variant({Ok:m,Err:N}),u=t.Vec(t.Nat8),O=t.Record({owner:t.Principal,start:t.Opt(u)});return t.Service({get_account_transactions:t.Func([e],[d],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([O],[t.Vec(u)],["query"])})};var L=require("@dfinity/utils"),Nt=({owner:t,subaccount:c})=>({owner:t,subaccount:(0,L.toNullable)(c)}),rt=({account:t,max_results:c,start:a})=>({account:Nt(t),max_results:c,start:(0,L.toNullable)(a)});var F=class t extends h.Canister{constructor(){super(...arguments);this.getTransactions=async a=>{let r=await this.caller({certified:!0}).get_account_transactions(rt(a));if("Err"in r)throw new b(r.Err.message);return r.Ok}}static create(a){let{service:r,certifiedService:e,canisterId:n}=(0,h.createServices)({options:a,idlFactory:et,certifiedIdlFactory:tt});return new t(n,r,e)}};var x=require("@dfinity/utils");var at=({IDL:t})=>{let c=t.Rec(),a=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),r=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(r)}),n=t.Variant({SetTo:e,Unset:t.Null}),i=t.Record({icrc2:t.Bool}),_=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,a))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(n),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(i)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,a)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(i)}),R=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,m=t.Record({start:s,length:t.Nat}),N=t.Vec(t.Tuple(t.Text,c));c.fill(t.Variant({Int:t.Int,Map:N,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(c)}));let d=c,u=t.Record({blocks:t.Vec(d)}),O=t.Func([m],[u],[]),w=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:s,blocks:t.Vec(d),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:O,start:s,length:t.Nat}))}),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,y=t.Record({start:T,length:t.Nat}),B=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),E=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),S=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),G=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),A=t.Record({burn:t.Opt(B),kind:t.Text,mint:t.Opt(E),approve:t.Opt(S),timestamp:t.Nat64,transfer:t.Opt(G)}),C=t.Record({transactions:t.Vec(A)}),q=t.Func([y],[C],[]),U=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(A),archived_transactions:t.Vec(t.Record({callback:q,start:T,length:t.Nat}))}),o=t.Nat,M=t.Record({url:t.Text,name:t.Text}),V=t.Nat64,z=t.Record({to:e,fee:t.Opt(o),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(V),amount:o}),Q=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:o}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:o}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:o})}),H=t.Variant({Ok:s,Err:Q}),W=t.Record({account:e,spender:e}),Z=t.Record({allowance:t.Nat,expires_at:t.Opt(t.Nat64)}),$=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:t.Nat}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,Expired:t.Record({ledger_time:t.Nat64}),InsufficientFunds:t.Record({balance:t.Nat})}),j=t.Variant({Ok:t.Nat,Err:X}),Y=t.Record({to:e,fee:t.Opt(o),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(V),amount:o}),J=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:o}),BadBurn:t.Record({min_burn_amount:o}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:o}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:o})}),K=t.Variant({Ok:s,Err:J});return t.Service({get_blocks:t.Func([m],[w],[]),get_data_certificate:t.Func([],[P],[]),get_transactions:t.Func([y],[U],[]),icrc1_balance_of:t.Func([e],[o],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[o],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,a))],[]),icrc1_minting_account:t.Func([],[t.Opt(e)],[]),icrc1_name:t.Func([],[t.Text],[]),icrc1_supported_standards:t.Func([],[t.Vec(M)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[o],[]),icrc1_transfer:t.Func([z],[H],[]),icrc2_allowance:t.Func([W],[Z],[]),icrc2_approve:t.Func([$],[j],[]),icrc2_transfer_from:t.Func([Y],[K],[])})};var ct=({IDL:t})=>{let c=t.Rec(),a=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),r=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(r)}),n=t.Variant({SetTo:e,Unset:t.Null}),i=t.Record({icrc2:t.Bool}),_=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,a))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(n),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(i)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,a)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(i)}),R=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,m=t.Record({start:s,length:t.Nat}),N=t.Vec(t.Tuple(t.Text,c));c.fill(t.Variant({Int:t.Int,Map:N,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(c)}));let d=c,u=t.Record({blocks:t.Vec(d)}),O=t.Func([m],[u],["query"]),w=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:s,blocks:t.Vec(d),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:O,start:s,length:t.Nat}))}),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,y=t.Record({start:T,length:t.Nat}),B=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),E=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),S=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),G=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),A=t.Record({burn:t.Opt(B),kind:t.Text,mint:t.Opt(E),approve:t.Opt(S),timestamp:t.Nat64,transfer:t.Opt(G)}),C=t.Record({transactions:t.Vec(A)}),q=t.Func([y],[C],["query"]),U=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(A),archived_transactions:t.Vec(t.Record({callback:q,start:T,length:t.Nat}))}),o=t.Nat,M=t.Record({url:t.Text,name:t.Text}),V=t.Nat64,z=t.Record({to:e,fee:t.Opt(o),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(V),amount:o}),Q=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:o}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:o}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:o})}),H=t.Variant({Ok:s,Err:Q}),W=t.Record({account:e,spender:e}),Z=t.Record({allowance:t.Nat,expires_at:t.Opt(t.Nat64)}),$=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:t.Nat}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,Expired:t.Record({ledger_time:t.Nat64}),InsufficientFunds:t.Record({balance:t.Nat})}),j=t.Variant({Ok:t.Nat,Err:X}),Y=t.Record({to:e,fee:t.Opt(o),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(V),amount:o}),J=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:o}),BadBurn:t.Record({min_burn_amount:o}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:o}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:o})}),K=t.Variant({Ok:s,Err:J});return t.Service({get_blocks:t.Func([m],[w],["query"]),get_data_certificate:t.Func([],[P],["query"]),get_transactions:t.Func([y],[U],["query"]),icrc1_balance_of:t.Func([e],[o],["query"]),icrc1_decimals:t.Func([],[t.Nat8],["query"]),icrc1_fee:t.Func([],[o],["query"]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,a))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(e)],["query"]),icrc1_name:t.Func([],[t.Text],["query"]),icrc1_supported_standards:t.Func([],[t.Vec(M)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[o],["query"]),icrc1_transfer:t.Func([z],[H],[]),icrc2_allowance:t.Func([W],[Z],["query"]),icrc2_approve:t.Func([$],[j],[]),icrc2_transfer_from:t.Func([Y],[K],[])})};var p=require("@dfinity/utils"),ot=({from_subaccount:t,fee:c,created_at_time:a,memo:r,...e})=>({...e,fee:(0,p.toNullable)(c),memo:(0,p.toNullable)(r),from_subaccount:(0,p.toNullable)(t),created_at_time:(0,p.toNullable)(a)}),nt=({spender_subaccount:t,fee:c,created_at_time:a,memo:r,...e})=>({...e,fee:(0,p.toNullable)(c),memo:(0,p.toNullable)(r),spender_subaccount:(0,p.toNullable)(t),created_at_time:(0,p.toNullable)(a)}),st=({fee:t,created_at_time:c,memo:a,from_subaccount:r,expected_allowance:e,expires_at:n,...i})=>({...i,fee:(0,p.toNullable)(t),memo:(0,p.toNullable)(a),from_subaccount:(0,p.toNullable)(r),created_at_time:(0,p.toNullable)(c),expected_allowance:(0,p.toNullable)(e),expires_at:(0,p.toNullable)(n)});var v=class t extends x.Canister{constructor(){super(...arguments);this.metadata=a=>this.caller(a).icrc1_metadata();this.transactionFee=a=>this.caller(a).icrc1_fee();this.balance=a=>this.caller({certified:a.certified}).icrc1_balance_of({owner:a.owner,subaccount:(0,x.toNullable)(a.subaccount)});this.transfer=async a=>{let r=await this.caller({certified:!0}).icrc1_transfer(ot(a));if("Err"in r)throw new g({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};this.totalTokensSupply=a=>this.caller(a).icrc1_total_supply();this.transferFrom=async a=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(nt(a));if("Err"in r)throw new g({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};this.approve=async a=>{let r=await this.caller({certified:!0}).icrc2_approve(st(a));if("Err"in r)throw new g({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};this.allowance=async a=>{let{certified:r,...e}=a;return this.caller({certified:r}).icrc2_allowance({...e})}}static create(a){let{service:r,certifiedService:e,canisterId:n}=(0,x.createServices)({options:a,idlFactory:ct,certifiedIdlFactory:at});return new t(n,r,e)}};var it=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(it||{});var D=require("@dfinity/principal"),l=require("@dfinity/utils"),Ot=64,Tt=({owner:t,subaccount:c})=>{if((0,l.isNullish)(c))return t.toText();let r=(e=>e.replace(/^0+/,""))((0,l.uint8ArrayToHexString)(c));return r.length===0?t.toText():`${t.toText()}-${pt({owner:t,subaccount:c})}.${r}`},pt=({owner:t,subaccount:c})=>{let a=(0,l.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...c]));return(0,l.encodeBase32)(a)},gt=t=>{let[c,a]=t.split(".");if(!(0,l.notEmptyString)(c))throw new Error("Invalid account. No string provided.");if((0,l.isNullish)(a))return{owner:D.Principal.fromText(t)};let[r,...e]=c.split("-").reverse(),n=e.reverse().join("-"),i={owner:D.Principal.fromText(n),subaccount:(0,l.hexStringToUint8Array)(a.padStart(Ot,"0"))};if(pt(i)!==r)throw new Error("Invalid account. Invalid checksum.");return i};var k=require("@dfinity/utils"),xt=t=>{let c=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,a=t.match(c);if((0,k.isNullish)(a))return;let[r,e,n,i]=a;return{token:e,identifier:n,...(0,k.nonNullish)(i)&&!isNaN(parseFloat(i))&&{amount:parseFloat(i)}}};0&&(module.exports={IcrcIndexCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts", "../../src/errors/index.errors.ts", "../../src/errors/ledger.errors.ts", "../../src/index.canister.ts", "../../candid/icrc_index.certified.idl.js", "../../candid/icrc_index.idl.js", "../../src/converters/index.converters.ts", "../../src/ledger.canister.ts", "../../candid/icrc_ledger.certified.idl.js", "../../candid/icrc_ledger.idl.js", "../../src/converters/ledger.converters.ts", "../../src/types/ledger.responses.ts", "../../src/utils/ledger.utils.ts", "../../src/utils/payment.utils.ts"],
4
+ "sourcesContent": ["export type {\n GetTransactions as IcrcGetTransactions,\n Transaction as IcrcTransaction,\n TransactionWithId as IcrcTransactionWithId,\n TxId as IcrcTxId,\n} from \"../candid/icrc_index\";\nexport type {\n BlockIndex as IcrcBlockIndex,\n Subaccount as IcrcSubaccount,\n Tokens as IcrcTokens,\n TransferArg as IcrcTransferArg,\n TransferError as IcrcTransferVariatError,\n Value as IcrcValue,\n} from \"../candid/icrc_ledger\";\nexport * from \"./errors/index.errors\";\nexport * from \"./errors/ledger.errors\";\nexport { IcrcIndexCanister } from \"./index.canister\";\nexport { IcrcLedgerCanister } from \"./ledger.canister\";\nexport * from \"./types/index.params\";\nexport * from \"./types/ledger.params\";\nexport * from \"./types/ledger.responses\";\nexport * from \"./utils/ledger.utils\";\nexport * from \"./utils/payment.utils\";\n", "export class IndexError extends Error {}\n", "export class IcrcTransferError<T> extends Error {\n public errorType: T;\n constructor({ msg, errorType }: { msg?: string; errorType: T }) {\n super(msg);\n this.errorType = errorType;\n }\n}\n", "import { Canister, createServices } from \"@dfinity/utils\";\nimport type {\n GetTransactions,\n _SERVICE as IcrcIndexService,\n} from \"../candid/icrc_index\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_index.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_index.idl\";\nimport { toGetTransactionsArgs } from \"./converters/index.converters\";\nimport { IndexError } from \"./errors/index.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type { GetAccountTransactionsParams } from \"./types/index.params\";\n\nexport class IcrcIndexCanister extends Canister<IcrcIndexService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcIndexService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcIndexService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcIndexCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Get the transactions of an account\n *\n * Always certified.\n * `get_account_transactions` needs to be called with an update\n * because the index canisters makes a call to the ledger canister to get the transaction data.\n * Index Canister only holds the transactions ids in state, not the whole transaction data.\n */\n getTransactions = async (\n params: GetAccountTransactionsParams,\n ): Promise<GetTransactions> => {\n const response = await this.caller({\n certified: true,\n }).get_account_transactions(toGetTransactionsArgs(params));\n\n if (\"Err\" in response) {\n throw new IndexError(response.Err.message);\n }\n\n return response.Ok;\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], []),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n ['query'],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "import { toNullable } from \"@dfinity/utils\";\nimport type {\n Account,\n GetAccountTransactionsArgs,\n} from \"../../candid/icrc_index\";\nimport type { GetAccountTransactionsParams } from \"../types/index.params\";\nimport type { IcrcAccount } from \"../types/ledger.responses\";\n\nconst toCandidAccount = ({ owner, subaccount }: IcrcAccount): Account => ({\n owner,\n subaccount: toNullable(subaccount),\n});\n\nexport const toGetTransactionsArgs = ({\n account,\n max_results,\n start,\n}: GetAccountTransactionsParams): GetAccountTransactionsArgs => ({\n account: toCandidAccount(account),\n max_results,\n start: toNullable(start),\n});\n", "import type { QueryParams } from \"@dfinity/utils\";\nimport { Canister, createServices, toNullable } from \"@dfinity/utils\";\nimport type {\n Allowance,\n BlockIndex,\n _SERVICE as IcrcLedgerService,\n Tokens,\n} from \"../candid/icrc_ledger\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_ledger.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_ledger.idl\";\nimport {\n toApproveArgs,\n toTransferArg,\n toTransferFromArgs,\n} from \"./converters/ledger.converters\";\nimport { IcrcTransferError } from \"./errors/ledger.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type {\n AllowanceParams,\n ApproveParams,\n BalanceParams,\n TransferFromParams,\n TransferParams,\n} from \"./types/ledger.params\";\nimport type { IcrcTokenMetadataResponse } from \"./types/ledger.responses\";\n\nexport class IcrcLedgerCanister extends Canister<IcrcLedgerService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcLedgerService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcLedgerService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcLedgerCanister(canisterId, service, certifiedService);\n }\n\n /**\n * The token metadata (name, symbol, etc.).\n */\n metadata = (params: QueryParams): Promise<IcrcTokenMetadataResponse> =>\n this.caller(params).icrc1_metadata();\n\n /**\n * The ledger transaction fees.\n *\n * @returns {Tokens} The ledger transaction fees in Tokens\n */\n transactionFee = (params: QueryParams): Promise<Tokens> =>\n this.caller(params).icrc1_fee();\n\n /**\n * Returns the balance for a given account provided as owner and with optional subaccount.\n *\n * @param {BalanceParams} params The parameters to get the balance of an account.\n * @returns {Promise<Tokens>} The balance of the given account.\n */\n balance = (params: BalanceParams): Promise<Tokens> =>\n this.caller({ certified: params.certified }).icrc1_balance_of({\n owner: params.owner,\n subaccount: toNullable(params.subaccount),\n });\n\n /**\n * Transfers tokens from the sender to the given account.\n *\n * @param {TransferArg} params The parameters to transfer tokens.\n *\n * @throws {IcrcTransferError} If the transfer fails.\n */\n transfer = async (params: TransferParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc1_transfer(\n toTransferArg(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to transfer\",\n });\n }\n return response.Ok;\n };\n\n /**\n * Returns the total supply of tokens.\n */\n totalTokensSupply = (params: QueryParams): Promise<Tokens> => {\n return this.caller(params).icrc1_total_supply();\n };\n\n /**\n * 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.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_transfer_from\n *\n * @param {TransferFromParams} params The parameters to transfer tokens from to.\n *\n * @throws {IcrcTransferError} If the transfer from fails.\n */\n transferFrom = async (params: TransferFromParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc2_transfer_from(\n toTransferFromArgs(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to transfer from\",\n });\n }\n return response.Ok;\n };\n\n /**\n * This method entitles the `spender` to transfer token `amount` on behalf of the caller from account `{ owner = caller; subaccount = from_subaccount }`.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_approve\n *\n * @param {ApproveParams} params The parameters to approve.\n *\n * @throws {IcrcTransferError} If the approval fails.\n */\n approve = async (params: ApproveParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc2_approve(\n toApproveArgs(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to entitle the spender to transfer the amount\",\n });\n }\n return response.Ok;\n };\n\n /**\n * Returns the token allowance that the `spender` account can transfer from the specified `account`, and the expiration time for that allowance, if any.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_allowance\n *\n * @param {AllowanceParams} params The parameters to call the allowance.\n *\n * @returns {Allowance} The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.\n */\n allowance = async (params: AllowanceParams): Promise<Allowance> => {\n const { certified, ...rest } = params;\n return this.caller({ certified }).icrc2_allowance({ ...rest });\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_ledger.did */\nexport const idlFactory = ({ IDL }) => {\n const Value = IDL.Rec();\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n const BlockIndex = IDL.Nat;\n const GetBlocksArgs = IDL.Record({\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n });\n const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));\n Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : Map,\n 'Nat' : IDL.Nat,\n 'Nat64' : IDL.Nat64,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(Value),\n })\n );\n const Block = Value;\n const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });\n const QueryBlockArchiveFn = IDL.Func([GetBlocksArgs], [BlockRange], []);\n const GetBlocksResponse = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'first_index' : BlockIndex,\n 'blocks' : IDL.Vec(Block),\n 'chain_length' : IDL.Nat64,\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryBlockArchiveFn,\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const DataCertificate = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const TxIndex = IDL.Nat;\n const GetTransactionsRequest = IDL.Record({\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionRange = IDL.Record({\n 'transactions' : IDL.Vec(Transaction),\n });\n const QueryArchiveFn = IDL.Func(\n [GetTransactionsRequest],\n [TransactionRange],\n [],\n );\n const GetTransactionsResponse = IDL.Record({\n 'first_index' : TxIndex,\n 'log_length' : IDL.Nat,\n 'transactions' : IDL.Vec(Transaction),\n 'archived_transactions' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryArchiveFn,\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const Tokens = IDL.Nat;\n const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });\n const Timestamp = IDL.Nat64;\n const TransferArg = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(Subaccount),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferError,\n });\n const AllowanceArgs = IDL.Record({\n 'account' : Account,\n 'spender' : Account,\n });\n const Allowance = IDL.Record({\n 'allowance' : IDL.Nat,\n 'expires_at' : IDL.Opt(IDL.Nat64),\n });\n const ApproveArgs = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const ApproveError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }),\n 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),\n 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'Expired' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),\n });\n const ApproveResult = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : ApproveError });\n const TransferFromArgs = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'spender_subaccount' : IDL.Opt(Subaccount),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferFromError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferFromResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferFromError,\n });\n return IDL.Service({\n 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], []),\n 'get_data_certificate' : IDL.Func([], [DataCertificate], []),\n 'get_transactions' : IDL.Func(\n [GetTransactionsRequest],\n [GetTransactionsResponse],\n [],\n ),\n 'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),\n 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], []),\n 'icrc1_fee' : IDL.Func([], [Tokens], []),\n 'icrc1_metadata' : IDL.Func(\n [],\n [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],\n [],\n ),\n 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], []),\n 'icrc1_name' : IDL.Func([], [IDL.Text], []),\n 'icrc1_supported_standards' : IDL.Func([], [IDL.Vec(StandardRecord)], []),\n 'icrc1_symbol' : IDL.Func([], [IDL.Text], []),\n 'icrc1_total_supply' : IDL.Func([], [Tokens], []),\n 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),\n 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], []),\n 'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),\n 'icrc2_transfer_from' : IDL.Func(\n [TransferFromArgs],\n [TransferFromResult],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n return [LedgerArg];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_ledger.did */\nexport const idlFactory = ({ IDL }) => {\n const Value = IDL.Rec();\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n const BlockIndex = IDL.Nat;\n const GetBlocksArgs = IDL.Record({\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n });\n const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));\n Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : Map,\n 'Nat' : IDL.Nat,\n 'Nat64' : IDL.Nat64,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(Value),\n })\n );\n const Block = Value;\n const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });\n const QueryBlockArchiveFn = IDL.Func(\n [GetBlocksArgs],\n [BlockRange],\n ['query'],\n );\n const GetBlocksResponse = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'first_index' : BlockIndex,\n 'blocks' : IDL.Vec(Block),\n 'chain_length' : IDL.Nat64,\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryBlockArchiveFn,\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const DataCertificate = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const TxIndex = IDL.Nat;\n const GetTransactionsRequest = IDL.Record({\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionRange = IDL.Record({\n 'transactions' : IDL.Vec(Transaction),\n });\n const QueryArchiveFn = IDL.Func(\n [GetTransactionsRequest],\n [TransactionRange],\n ['query'],\n );\n const GetTransactionsResponse = IDL.Record({\n 'first_index' : TxIndex,\n 'log_length' : IDL.Nat,\n 'transactions' : IDL.Vec(Transaction),\n 'archived_transactions' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryArchiveFn,\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const Tokens = IDL.Nat;\n const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });\n const Timestamp = IDL.Nat64;\n const TransferArg = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(Subaccount),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferError,\n });\n const AllowanceArgs = IDL.Record({\n 'account' : Account,\n 'spender' : Account,\n });\n const Allowance = IDL.Record({\n 'allowance' : IDL.Nat,\n 'expires_at' : IDL.Opt(IDL.Nat64),\n });\n const ApproveArgs = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const ApproveError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }),\n 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),\n 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'Expired' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),\n });\n const ApproveResult = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : ApproveError });\n const TransferFromArgs = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'spender_subaccount' : IDL.Opt(Subaccount),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferFromError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferFromResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferFromError,\n });\n return IDL.Service({\n 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], ['query']),\n 'get_data_certificate' : IDL.Func([], [DataCertificate], ['query']),\n 'get_transactions' : IDL.Func(\n [GetTransactionsRequest],\n [GetTransactionsResponse],\n ['query'],\n ),\n 'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),\n 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']),\n 'icrc1_fee' : IDL.Func([], [Tokens], ['query']),\n 'icrc1_metadata' : IDL.Func(\n [],\n [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],\n ['query'],\n ),\n 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], ['query']),\n 'icrc1_name' : IDL.Func([], [IDL.Text], ['query']),\n 'icrc1_supported_standards' : IDL.Func(\n [],\n [IDL.Vec(StandardRecord)],\n ['query'],\n ),\n 'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']),\n 'icrc1_total_supply' : IDL.Func([], [Tokens], ['query']),\n 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),\n 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], ['query']),\n 'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),\n 'icrc2_transfer_from' : IDL.Func(\n [TransferFromArgs],\n [TransferFromResult],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n return [LedgerArg];\n};\n", "import { toNullable } from \"@dfinity/utils\";\nimport type {\n ApproveArgs,\n TransferArg,\n TransferFromArgs,\n} from \"../../candid/icrc_ledger\";\nimport type {\n ApproveParams,\n TransferFromParams,\n TransferParams,\n} from \"../types/ledger.params\";\n\n// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no\n// relationship between the memo and the icrc1Memo of a transaction. The ICRC-1\n// interface simply cannot set the memo field and the non-ICRC-1 interface\n// cannot set the icrc1Memo field, even though the icrc1Memo field is called\n// just \"memo\" in canister method params.\nexport const toTransferArg = ({\n from_subaccount,\n fee,\n created_at_time,\n memo,\n ...rest\n}: TransferParams): TransferArg => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n from_subaccount: toNullable(from_subaccount),\n created_at_time: toNullable(created_at_time),\n});\n\nexport const toTransferFromArgs = ({\n spender_subaccount,\n fee,\n created_at_time,\n memo,\n ...rest\n}: TransferFromParams): TransferFromArgs => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n spender_subaccount: toNullable(spender_subaccount),\n created_at_time: toNullable(created_at_time),\n});\n\nexport const toApproveArgs = ({\n fee,\n created_at_time,\n memo,\n from_subaccount,\n expected_allowance,\n expires_at,\n ...rest\n}: ApproveParams): ApproveArgs => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n from_subaccount: toNullable(from_subaccount),\n created_at_time: toNullable(created_at_time),\n expected_allowance: toNullable(expected_allowance),\n expires_at: toNullable(expires_at),\n});\n", "import type { Principal } from \"@dfinity/principal\";\nimport type { Subaccount, Value } from \"../../candid/icrc_ledger\";\n\n// Source: https://github.com/dfinity/icrc-1#standard-metadata-entries\nexport enum IcrcMetadataResponseEntries {\n SYMBOL = \"icrc1:symbol\",\n NAME = \"icrc1:name\",\n DECIMALS = \"icrc1:decimals\",\n FEE = \"icrc1:fee\",\n LOGO = \"icrc1:logo\",\n}\n\nexport type IcrcTokenMetadataResponse = [\n string | IcrcMetadataResponseEntries,\n Value,\n][];\n\nexport interface IcrcAccount {\n owner: Principal;\n subaccount?: Subaccount;\n}\n", "import { Principal } from \"@dfinity/principal\";\nimport {\n bigEndianCrc32,\n encodeBase32,\n hexStringToUint8Array,\n isNullish,\n notEmptyString,\n uint8ArrayToHexString,\n} from \"@dfinity/utils\";\nimport type { IcrcAccount } from \"../types/ledger.responses\";\n\nconst MAX_SUBACCOUNT_HEX_LENGTH = 64;\n\n/**\n * Encodes an Icrc-1 account compatible into a string.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param account { owner: Principal, subaccount?: Uint8Array }\n * @returns string\n */\nexport const encodeIcrcAccount = ({\n owner,\n subaccount,\n}: IcrcAccount): string => {\n if (isNullish(subaccount)) {\n return owner.toText();\n }\n\n const removeLeadingZeros = (text: string): string => text.replace(/^0+/, \"\");\n\n const subaccountText = removeLeadingZeros(uint8ArrayToHexString(subaccount));\n\n if (subaccountText.length === 0) {\n return owner.toText();\n }\n\n return `${owner.toText()}-${encodeCrc({\n owner,\n subaccount,\n })}.${subaccountText}`;\n};\n\nconst encodeCrc = ({ owner, subaccount }: Required<IcrcAccount>): string => {\n const crc = bigEndianCrc32(\n Uint8Array.from([...owner.toUint8Array(), ...subaccount]),\n );\n\n return encodeBase32(crc);\n};\n\n/**\n * Decodes a string into an Icrc-1 compatible account.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param accountString string\n * @throws Error if the string is not a valid Icrc-1 account\n * @returns IcrcAccount { owner: Principal, subaccount?: Uint8Array }\n */\nexport const decodeIcrcAccount = (accountString: string): IcrcAccount => {\n const [principalAndMaybeCheckSum, subaccountHex] = accountString.split(\".\");\n\n if (!notEmptyString(principalAndMaybeCheckSum)) {\n throw new Error(\"Invalid account. No string provided.\");\n }\n\n if (isNullish(subaccountHex)) {\n return {\n owner: Principal.fromText(accountString),\n };\n }\n\n const [checksum, ...rest] = principalAndMaybeCheckSum.split(\"-\").reverse();\n const principalText = rest.reverse().join(\"-\");\n\n const account = {\n owner: Principal.fromText(principalText),\n subaccount: hexStringToUint8Array(\n subaccountHex.padStart(MAX_SUBACCOUNT_HEX_LENGTH, \"0\"),\n ),\n };\n\n const crcText = encodeCrc(account);\n\n if (crcText !== checksum) {\n throw new Error(\"Invalid account. Invalid checksum.\");\n }\n\n return account;\n};\n", "import { isNullish, nonNullish } from \"@dfinity/utils\";\n\n/**\n * \uD83D\uDC40 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22.\n *\n * 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.\n *\n * If the code doesn't match the expected pattern, `undefined` is returned for simplicity.\n * Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`.\n *\n * Please note that this function doesn't perform any validity checks on the extracted information.\n * It does not verify if the token is known or if the identifier is a valid address.\n *\n * ```\n * urn = token \":\" address [ \"?\" params]\n * token = [ ckbtc / icp / chat / bitcoin / ethereum ... ]\n * address = STRING\n * params = param [ \"&\" params ]\n * param = [ amountparam ]\n * amountparam = \"amount=\" *digit [ \".\" *digit ]\n * ```\n *\n * @param code string\n * @returns { token: string; identifier: string; amount?: number } | undefined\n */\nexport const decodePayment = (\n code: string,\n): { token: string; identifier: string; amount?: number } | undefined => {\n const regex =\n /^([a-zA-Z]+):([A-Za-z0-9:\\-.]+).*?(?:[?&](?:amount|value)=(\\d+(?:\\.\\d+)?))?$/;\n\n const match = code.match(regex);\n if (isNullish(match)) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, token, identifier, amount] = match;\n\n return {\n token,\n identifier,\n ...(nonNullish(amount) &&\n !isNaN(parseFloat(amount)) && { amount: parseFloat(amount) }),\n };\n};\n"],
5
+ "mappings": "mbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uBAAAE,EAAA,uBAAAC,EAAA,gCAAAC,GAAA,sBAAAC,EAAA,eAAAC,EAAA,sBAAAC,GAAA,kBAAAC,GAAA,sBAAAC,KAAA,eAAAC,GAAAV,ICAO,IAAMW,EAAN,cAAyB,KAAM,CAAC,ECAhC,IAAMC,EAAN,cAAmC,KAAM,CAE9C,YAAY,CAAE,IAAAC,EAAK,UAAAC,CAAU,EAAmC,CAC9D,MAAMD,CAAG,EACT,KAAK,UAAYC,CACnB,CACF,ECNA,IAAAC,EAAyC,0BCClC,IAAMC,GAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAWD,EA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CAAE,MAAAJ,EAAO,WAAAC,CAAW,IAAqC,CAC1E,IAAMI,KAAM,kBACV,WAAW,KAAK,CAAC,GAAGL,EAAM,aAAa,EAAG,GAAGC,CAAU,CAAC,CAC1D,EAEA,SAAO,gBAAaI,CAAG,CACzB,EAUaC,GAAqBC,GAAuC,CACvE,GAAM,CAACC,EAA2BC,CAAa,EAAIF,EAAc,MAAM,GAAG,EAE1E,GAAI,IAAC,kBAAeC,CAAyB,EAC3C,MAAM,IAAI,MAAM,sCAAsC,EAGxD,MAAI,aAAUC,CAAa,EACzB,MAAO,CACL,MAAO,YAAU,SAASF,CAAa,CACzC,EAGF,GAAM,CAACG,EAAU,GAAGC,CAAI,EAAIH,EAA0B,MAAM,GAAG,EAAE,QAAQ,EACnEI,EAAgBD,EAAK,QAAQ,EAAE,KAAK,GAAG,EAEvCE,EAAU,CACd,MAAO,YAAU,SAASD,CAAa,EACvC,cAAY,yBACVH,EAAc,SAASX,GAA2B,GAAG,CACvD,CACF,EAIA,GAFgBM,GAAUS,CAAO,IAEjBH,EACd,MAAM,IAAI,MAAM,oCAAoC,EAGtD,OAAOG,CACT,ECxFA,IAAAC,EAAsC,0BAyBzBC,GACXC,GACuE,CACvE,IAAMC,EACJ,+EAEIC,EAAQF,EAAK,MAAMC,CAAK,EAC9B,MAAI,aAAUC,CAAK,EACjB,OAIF,GAAM,CAACC,EAAGC,EAAOC,EAAYC,CAAM,EAAIJ,EAEvC,MAAO,CACL,MAAAE,EACA,WAAAC,EACA,MAAI,cAAWC,CAAM,GACnB,CAAC,MAAM,WAAWA,CAAM,CAAC,GAAK,CAAE,OAAQ,WAAWA,CAAM,CAAE,CAC/D,CACF",
6
+ "names": ["src_exports", "__export", "IcrcIndexCanister", "IcrcLedgerCanister", "IcrcMetadataResponseEntries", "IcrcTransferError", "IndexError", "decodeIcrcAccount", "decodePayment", "encodeIcrcAccount", "__toCommonJS", "IndexError", "IcrcTransferError", "msg", "errorType", "import_utils", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "import_utils", "toCandidAccount", "owner", "subaccount", "toGetTransactionsArgs", "account", "max_results", "start", "IcrcIndexCanister", "_IcrcIndexCanister", "params", "response", "toGetTransactionsArgs", "IndexError", "options", "service", "certifiedService", "canisterId", "idlFactory", "import_utils", "idlFactory", "IDL", "Value", "MetadataValue", "Subaccount", "Account", "ChangeFeeCollector", "FeatureFlags", "UpgradeArgs", "InitArgs", "LedgerArg", "BlockIndex", "GetBlocksArgs", "Map", "Block", "BlockRange", "QueryBlockArchiveFn", "GetBlocksResponse", "DataCertificate", "TxIndex", "GetTransactionsRequest", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionRange", "QueryArchiveFn", "GetTransactionsResponse", "Tokens", "StandardRecord", "Timestamp", "TransferArg", "TransferError", "TransferResult", "AllowanceArgs", "Allowance", "ApproveArgs", "ApproveError", "ApproveResult", "TransferFromArgs", "TransferFromError", "TransferFromResult", "idlFactory", "IDL", "Value", "MetadataValue", "Subaccount", "Account", "ChangeFeeCollector", "FeatureFlags", "UpgradeArgs", "InitArgs", "LedgerArg", "BlockIndex", "GetBlocksArgs", "Map", "Block", "BlockRange", "QueryBlockArchiveFn", "GetBlocksResponse", "DataCertificate", "TxIndex", "GetTransactionsRequest", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionRange", "QueryArchiveFn", "GetTransactionsResponse", "Tokens", "StandardRecord", "Timestamp", "TransferArg", "TransferError", "TransferResult", "AllowanceArgs", "Allowance", "ApproveArgs", "ApproveError", "ApproveResult", "TransferFromArgs", "TransferFromError", "TransferFromResult", "import_utils", "toTransferArg", "from_subaccount", "fee", "created_at_time", "memo", "rest", "toTransferFromArgs", "spender_subaccount", "toApproveArgs", "expected_allowance", "expires_at", "IcrcLedgerCanister", "_IcrcLedgerCanister", "params", "response", "toTransferArg", "IcrcTransferError", "toTransferFromArgs", "toApproveArgs", "certified", "rest", "options", "service", "certifiedService", "canisterId", "idlFactory", "IcrcMetadataResponseEntries", "import_principal", "import_utils", "MAX_SUBACCOUNT_HEX_LENGTH", "encodeIcrcAccount", "owner", "subaccount", "subaccountText", "text", "encodeCrc", "crc", "decodeIcrcAccount", "accountString", "principalAndMaybeCheckSum", "subaccountHex", "checksum", "rest", "principalText", "account", "import_utils", "decodePayment", "code", "regex", "match", "_", "token", "identifier", "amount"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Canister as V,createServices as y}from"@dfinity/utils";var A=({IDL:t})=>{let r=t.Record({ledger_id:t.Principal}),c=t.Nat,e=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(c),account:e}),a=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),i=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),p=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),d=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),m=t.Record({burn:t.Opt(a),kind:t.Text,mint:t.Opt(i),approve:t.Opt(p),timestamp:t.Nat64,transfer:t.Opt(d)}),u=t.Record({id:c,transaction:m}),O=t.Record({transactions:t.Vec(u),oldest_tx_id:t.Opt(c)}),N=t.Record({message:t.Text}),_=t.Variant({Ok:O,Err:N}),o=t.Vec(t.Nat8),l=t.Record({owner:t.Principal,start:t.Opt(o)});return t.Service({get_account_transactions:t.Func([n],[_],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([l],[t.Vec(o)],[])})};var T=({IDL:t})=>{let r=t.Record({ledger_id:t.Principal}),c=t.Nat,e=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(c),account:e}),a=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),i=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),p=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),d=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),m=t.Record({burn:t.Opt(a),kind:t.Text,mint:t.Opt(i),approve:t.Opt(p),timestamp:t.Nat64,transfer:t.Opt(d)}),u=t.Record({id:c,transaction:m}),O=t.Record({transactions:t.Vec(u),oldest_tx_id:t.Opt(c)}),N=t.Record({message:t.Text}),_=t.Variant({Ok:O,Err:N}),o=t.Vec(t.Nat8),l=t.Record({owner:t.Principal,start:t.Opt(o)});return t.Service({get_account_transactions:t.Func([n],[_],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([l],[t.Vec(o)],["query"])})};import{toNullable as f}from"@dfinity/utils";var R=({owner:t,subaccount:r})=>({owner:t,subaccount:f(r)}),g=({account:t,max_results:r,start:c})=>({account:R(t),max_results:r,start:f(c)});var s=class extends Error{};var x=class t extends V{constructor(){super(...arguments);this.getTransactions=async c=>{let e=await this.caller({certified:!0}).get_account_transactions(g(c));if("Err"in e)throw new s(e.Err.message);return e.Ok}}static create(c){let{service:e,certifiedService:n,canisterId:a}=y({options:c,idlFactory:T,certifiedIdlFactory:A});return new t(a,e,n)}};export{s as a,x as b};
2
+ //# sourceMappingURL=chunk-XVPR4TJN.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.canister.ts", "../../candid/icrc_index.certified.idl.js", "../../candid/icrc_index.idl.js", "../../src/converters/index.converters.ts", "../../src/errors/index.errors.ts"],
4
+ "sourcesContent": ["import { Canister, createServices } from \"@dfinity/utils\";\nimport type {\n GetTransactions,\n _SERVICE as IcrcIndexService,\n} from \"../candid/icrc_index\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_index.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_index.idl\";\nimport { toGetTransactionsArgs } from \"./converters/index.converters\";\nimport { IndexError } from \"./errors/index.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type { GetAccountTransactionsParams } from \"./types/index.params\";\n\nexport class IcrcIndexCanister extends Canister<IcrcIndexService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcIndexService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcIndexService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcIndexCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Get the transactions of an account\n *\n * Always certified.\n * `get_account_transactions` needs to be called with an update\n * because the index canisters makes a call to the ledger canister to get the transaction data.\n * Index Canister only holds the transactions ids in state, not the whole transaction data.\n */\n getTransactions = async (\n params: GetAccountTransactionsParams,\n ): Promise<GetTransactions> => {\n const response = await this.caller({\n certified: true,\n }).get_account_transactions(toGetTransactionsArgs(params));\n\n if (\"Err\" in response) {\n throw new IndexError(response.Err.message);\n }\n\n return response.Ok;\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], []),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n ['query'],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "import { toNullable } from \"@dfinity/utils\";\nimport type {\n Account,\n GetAccountTransactionsArgs,\n} from \"../../candid/icrc_index\";\nimport type { GetAccountTransactionsParams } from \"../types/index.params\";\nimport type { IcrcAccount } from \"../types/ledger.responses\";\n\nconst toCandidAccount = ({ owner, subaccount }: IcrcAccount): Account => ({\n owner,\n subaccount: toNullable(subaccount),\n});\n\nexport const toGetTransactionsArgs = ({\n account,\n max_results,\n start,\n}: GetAccountTransactionsParams): GetAccountTransactionsArgs => ({\n account: toCandidAccount(account),\n max_results,\n start: toNullable(start),\n});\n", "export class IndexError extends Error {}\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,EAAU,kBAAAC,MAAsB,iBCClC,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAWD,EAAI,OAAO,CAAE,UAAcA,EAAI,SAAU,CAAC,EACrDE,EAAOF,EAAI,IACXG,EAAUH,EAAI,OAAO,CACzB,MAAUA,EAAI,UACd,WAAeA,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,CAC1C,CAAC,EACKI,EAA6BJ,EAAI,OAAO,CAC5C,YAAgBA,EAAI,IACpB,MAAUA,EAAI,IAAIE,CAAI,EACtB,QAAYC,CACd,CAAC,EACKE,EAAOL,EAAI,OAAO,CACtB,KAASG,EACT,KAASH,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,EAClC,gBAAoBA,EAAI,IAAIA,EAAI,KAAK,EACrC,OAAWA,EAAI,IACf,QAAYA,EAAI,IAAIG,CAAO,CAC7B,CAAC,EACKG,EAAON,EAAI,OAAO,CACtB,GAAOG,EACP,KAASH,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,EAClC,gBAAoBA,EAAI,IAAIA,EAAI,KAAK,EACrC,OAAWA,EAAI,GACjB,CAAC,EACKO,EAAUP,EAAI,OAAO,CACzB,IAAQA,EAAI,IAAIA,EAAI,GAAG,EACvB,KAASG,EACT,KAASH,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,EAClC,gBAAoBA,EAAI,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C,EACA,MAAAC,CACF,KAAiE,CAC/D,QAASN,EAAgBI,CAAO,EAChC,YAAAC,EACA,MAAON,EAAWO,CAAK,CACzB,GCrBO,IAAMC,EAAN,cAAyB,KAAM,CAAC,EJYhC,IAAMC,EAAN,MAAMC,UAA0BC,CAA2B,CAA3D,kCAoBL,qBAAkB,MAChBC,GAC6B,CAC7B,IAAMC,EAAW,MAAM,KAAK,OAAO,CACjC,UAAW,EACb,CAAC,EAAE,yBAAyBC,EAAsBF,CAAM,CAAC,EAEzD,GAAI,QAASC,EACX,MAAM,IAAIE,EAAWF,EAAS,IAAI,OAAO,EAG3C,OAAOA,EAAS,EAClB,EA/BA,OAAO,OAAOG,EAAsD,CAClE,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,WAAAC,CAAW,EAC5CC,EAAiC,CAC/B,QAAAJ,EACA,WAAAK,EACA,oBAAAA,CACF,CAAC,EAEH,OAAO,IAAIX,EAAkBS,EAAYF,EAASC,CAAgB,CACpE,CAuBF",
6
+ "names": ["Canister", "createServices", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "toNullable", "toCandidAccount", "owner", "subaccount", "toGetTransactionsArgs", "account", "max_results", "start", "IndexError", "IcrcIndexCanister", "_IcrcIndexCanister", "Canister", "params", "response", "toGetTransactionsArgs", "IndexError", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory"]
7
+ }