@dfinity/ledger-icrc 2.1.3-next-2024-02-21 → 2.1.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.
- package/README.md +31 -15
- package/dist/candid/icrc_index.certified.idl.js +9 -47
- package/dist/candid/icrc_index.d.ts +6 -40
- package/dist/candid/icrc_index.did +13 -60
- package/dist/candid/icrc_index.idl.js +10 -48
- package/dist/candid/icrc_ledger.did +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +4 -4
- package/dist/esm/chunk-MJQNXPUY.js +2 -0
- package/dist/esm/chunk-MJQNXPUY.js.map +7 -0
- package/dist/esm/chunk-UACBN2PF.js +2 -0
- package/dist/esm/chunk-UACBN2PF.js.map +7 -0
- package/dist/esm/index.canister.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ledger.canister.js +1 -1
- package/dist/types/index.canister.d.ts +3 -9
- package/dist/types/index.d.ts +2 -2
- package/dist/types/ledger.canister.d.ts +10 -3
- package/dist/types/types/index.params.d.ts +4 -5
- package/package.json +6 -6
- package/dist/esm/canister.js +0 -2
- package/dist/esm/canister.js.map +0 -7
- package/dist/esm/chunk-353GLO44.js +0 -2
- package/dist/esm/chunk-353GLO44.js.map +0 -7
- package/dist/esm/chunk-O2PAS3NQ.js +0 -2
- package/dist/esm/chunk-O2PAS3NQ.js.map +0 -7
- package/dist/esm/chunk-OETW2SKE.js +0 -2
- package/dist/esm/chunk-OETW2SKE.js.map +0 -7
- package/dist/types/canister.d.ts +0 -13
- package/dist/types/types/index.types.d.ts +0 -1
package/README.md
CHANGED
|
@@ -130,6 +130,7 @@ Parameters:
|
|
|
130
130
|
- [create](#gear-create)
|
|
131
131
|
- [metadata](#gear-metadata)
|
|
132
132
|
- [transactionFee](#gear-transactionfee)
|
|
133
|
+
- [balance](#gear-balance)
|
|
133
134
|
- [transfer](#gear-transfer)
|
|
134
135
|
- [totalTokensSupply](#gear-totaltokenssupply)
|
|
135
136
|
- [transferFrom](#gear-transferfrom)
|
|
@@ -164,6 +165,20 @@ The ledger transaction fees.
|
|
|
164
165
|
|
|
165
166
|
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L50)
|
|
166
167
|
|
|
168
|
+
##### :gear: balance
|
|
169
|
+
|
|
170
|
+
Returns the balance for a given account provided as owner and with optional subaccount.
|
|
171
|
+
|
|
172
|
+
| Method | Type |
|
|
173
|
+
| --------- | -------------------------------------------- |
|
|
174
|
+
| `balance` | `(params: BalanceParams) => Promise<bigint>` |
|
|
175
|
+
|
|
176
|
+
Parameters:
|
|
177
|
+
|
|
178
|
+
- `params`: The parameters to get the balance of an account.
|
|
179
|
+
|
|
180
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L59)
|
|
181
|
+
|
|
167
182
|
##### :gear: transfer
|
|
168
183
|
|
|
169
184
|
Transfers tokens from the sender to the given account.
|
|
@@ -176,7 +191,7 @@ Parameters:
|
|
|
176
191
|
|
|
177
192
|
- `params`: The parameters to transfer tokens.
|
|
178
193
|
|
|
179
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#
|
|
194
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L72)
|
|
180
195
|
|
|
181
196
|
##### :gear: totalTokensSupply
|
|
182
197
|
|
|
@@ -186,7 +201,7 @@ Returns the total supply of tokens.
|
|
|
186
201
|
| ------------------- | ------------------------------------------ |
|
|
187
202
|
| `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |
|
|
188
203
|
|
|
189
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#
|
|
204
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L88)
|
|
190
205
|
|
|
191
206
|
##### :gear: transferFrom
|
|
192
207
|
|
|
@@ -202,7 +217,7 @@ Parameters:
|
|
|
202
217
|
|
|
203
218
|
- `params`: The parameters to transfer tokens from to.
|
|
204
219
|
|
|
205
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#
|
|
220
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L101)
|
|
206
221
|
|
|
207
222
|
##### :gear: approve
|
|
208
223
|
|
|
@@ -218,7 +233,7 @@ Parameters:
|
|
|
218
233
|
|
|
219
234
|
- `params`: The parameters to approve.
|
|
220
235
|
|
|
221
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#
|
|
236
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L123)
|
|
222
237
|
|
|
223
238
|
##### :gear: allowance
|
|
224
239
|
|
|
@@ -234,11 +249,11 @@ Parameters:
|
|
|
234
249
|
|
|
235
250
|
- `params`: The parameters to call the allowance.
|
|
236
251
|
|
|
237
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#
|
|
252
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L145)
|
|
238
253
|
|
|
239
254
|
### :factory: IcrcIndexCanister
|
|
240
255
|
|
|
241
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#
|
|
256
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L13)
|
|
242
257
|
|
|
243
258
|
#### Methods
|
|
244
259
|
|
|
@@ -251,21 +266,22 @@ Parameters:
|
|
|
251
266
|
| -------- | --------------------------------------------------------------------- |
|
|
252
267
|
| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` |
|
|
253
268
|
|
|
254
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#
|
|
269
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
|
|
255
270
|
|
|
256
271
|
##### :gear: getTransactions
|
|
257
272
|
|
|
258
|
-
Get the transactions of an account
|
|
259
|
-
|
|
260
|
-
| Method | Type |
|
|
261
|
-
| ----------------- | ------------------------------------------------------------------------------------ |
|
|
262
|
-
| `getTransactions` | `({ certified, ...rest }: GetAccountTransactionsParams) => Promise<GetTransactions>` |
|
|
273
|
+
Get the transactions of an account
|
|
263
274
|
|
|
264
|
-
|
|
275
|
+
Always certified.
|
|
276
|
+
`get_account_transactions` needs to be called with an update
|
|
277
|
+
because the index canisters makes a call to the ledger canister to get the transaction data.
|
|
278
|
+
Index Canister only holds the transactions ids in state, not the whole transaction data.
|
|
265
279
|
|
|
266
|
-
|
|
280
|
+
| Method | Type |
|
|
281
|
+
| ----------------- | -------------------------------------------------------------------- |
|
|
282
|
+
| `getTransactions` | `(params: GetAccountTransactionsParams) => Promise<GetTransactions>` |
|
|
267
283
|
|
|
268
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#
|
|
284
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L33)
|
|
269
285
|
|
|
270
286
|
<!-- TSDOC_END -->
|
|
271
287
|
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
|
|
2
2
|
export const idlFactory = ({ IDL }) => {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
6
|
-
const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
|
|
7
|
-
const BlockIndex = IDL.Nat;
|
|
8
|
-
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
3
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
4
|
+
const TxId = IDL.Nat;
|
|
9
5
|
const Account = IDL.Record({
|
|
10
6
|
'owner' : IDL.Principal,
|
|
11
|
-
'subaccount' : IDL.Opt(
|
|
7
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
12
8
|
});
|
|
13
9
|
const GetAccountTransactionsArgs = IDL.Record({
|
|
14
10
|
'max_results' : IDL.Nat,
|
|
15
|
-
'start' : IDL.Opt(
|
|
11
|
+
'start' : IDL.Opt(TxId),
|
|
16
12
|
'account' : Account,
|
|
17
13
|
});
|
|
18
|
-
const Tokens = IDL.Nat;
|
|
19
14
|
const Burn = IDL.Record({
|
|
20
15
|
'from' : Account,
|
|
21
16
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
@@ -57,71 +52,38 @@ export const idlFactory = ({ IDL }) => {
|
|
|
57
52
|
'transfer' : IDL.Opt(Transfer),
|
|
58
53
|
});
|
|
59
54
|
const TransactionWithId = IDL.Record({
|
|
60
|
-
'id' :
|
|
55
|
+
'id' : TxId,
|
|
61
56
|
'transaction' : Transaction,
|
|
62
57
|
});
|
|
63
58
|
const GetTransactions = IDL.Record({
|
|
64
|
-
'balance' : Tokens,
|
|
65
59
|
'transactions' : IDL.Vec(TransactionWithId),
|
|
66
|
-
'oldest_tx_id' : IDL.Opt(
|
|
60
|
+
'oldest_tx_id' : IDL.Opt(TxId),
|
|
67
61
|
});
|
|
68
62
|
const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
|
|
69
63
|
const GetTransactionsResult = IDL.Variant({
|
|
70
64
|
'Ok' : GetTransactions,
|
|
71
65
|
'Err' : GetTransactionsErr,
|
|
72
66
|
});
|
|
73
|
-
const
|
|
74
|
-
'start' : IDL.Nat,
|
|
75
|
-
'length' : IDL.Nat,
|
|
76
|
-
});
|
|
77
|
-
const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
|
|
78
|
-
Value.fill(
|
|
79
|
-
IDL.Variant({
|
|
80
|
-
'Int' : IDL.Int,
|
|
81
|
-
'Map' : Map,
|
|
82
|
-
'Nat' : IDL.Nat,
|
|
83
|
-
'Nat64' : IDL.Nat64,
|
|
84
|
-
'Blob' : IDL.Vec(IDL.Nat8),
|
|
85
|
-
'Text' : IDL.Text,
|
|
86
|
-
'Array' : IDL.Vec(Value),
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
const Block = Value;
|
|
90
|
-
const GetBlocksResponse = IDL.Record({
|
|
91
|
-
'blocks' : IDL.Vec(Block),
|
|
92
|
-
'chain_length' : IDL.Nat64,
|
|
93
|
-
});
|
|
94
|
-
const FeeCollectorRanges = IDL.Record({
|
|
95
|
-
'ranges' : IDL.Vec(
|
|
96
|
-
IDL.Tuple(Account, IDL.Vec(IDL.Tuple(BlockIndex, BlockIndex)))
|
|
97
|
-
),
|
|
98
|
-
});
|
|
67
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
99
68
|
const ListSubaccountsArgs = IDL.Record({
|
|
100
69
|
'owner' : IDL.Principal,
|
|
101
70
|
'start' : IDL.Opt(SubAccount),
|
|
102
71
|
});
|
|
103
|
-
const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
|
|
104
72
|
return IDL.Service({
|
|
105
73
|
'get_account_transactions' : IDL.Func(
|
|
106
74
|
[GetAccountTransactionsArgs],
|
|
107
75
|
[GetTransactionsResult],
|
|
108
76
|
[],
|
|
109
77
|
),
|
|
110
|
-
'get_blocks' : IDL.Func([GetBlocksRequest], [GetBlocksResponse], []),
|
|
111
|
-
'get_fee_collectors_ranges' : IDL.Func([], [FeeCollectorRanges], []),
|
|
112
|
-
'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),
|
|
113
78
|
'ledger_id' : IDL.Func([], [IDL.Principal], []),
|
|
114
79
|
'list_subaccounts' : IDL.Func(
|
|
115
80
|
[ListSubaccountsArgs],
|
|
116
81
|
[IDL.Vec(SubAccount)],
|
|
117
82
|
[],
|
|
118
83
|
),
|
|
119
|
-
'status' : IDL.Func([], [Status], []),
|
|
120
84
|
});
|
|
121
85
|
};
|
|
122
86
|
export const init = ({ IDL }) => {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
|
|
126
|
-
return [IDL.Opt(IndexArg)];
|
|
87
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
88
|
+
return [InitArgs];
|
|
127
89
|
};
|
|
@@ -3,7 +3,7 @@ import type { Principal } from "@dfinity/principal";
|
|
|
3
3
|
|
|
4
4
|
export interface Account {
|
|
5
5
|
owner: Principal;
|
|
6
|
-
subaccount: [] | [
|
|
6
|
+
subaccount: [] | [Uint8Array | number[]];
|
|
7
7
|
}
|
|
8
8
|
export interface Approve {
|
|
9
9
|
fee: [] | [bigint];
|
|
@@ -15,8 +15,6 @@ export interface Approve {
|
|
|
15
15
|
expires_at: [] | [bigint];
|
|
16
16
|
spender: Account;
|
|
17
17
|
}
|
|
18
|
-
export type Block = Value;
|
|
19
|
-
export type BlockIndex = bigint;
|
|
20
18
|
export interface Burn {
|
|
21
19
|
from: Account;
|
|
22
20
|
memo: [] | [Uint8Array | number[]];
|
|
@@ -24,26 +22,14 @@ export interface Burn {
|
|
|
24
22
|
amount: bigint;
|
|
25
23
|
spender: [] | [Account];
|
|
26
24
|
}
|
|
27
|
-
export interface FeeCollectorRanges {
|
|
28
|
-
ranges: Array<[Account, Array<[BlockIndex, BlockIndex]>]>;
|
|
29
|
-
}
|
|
30
25
|
export interface GetAccountTransactionsArgs {
|
|
31
26
|
max_results: bigint;
|
|
32
|
-
start: [] | [
|
|
27
|
+
start: [] | [TxId];
|
|
33
28
|
account: Account;
|
|
34
29
|
}
|
|
35
|
-
export interface GetBlocksRequest {
|
|
36
|
-
start: bigint;
|
|
37
|
-
length: bigint;
|
|
38
|
-
}
|
|
39
|
-
export interface GetBlocksResponse {
|
|
40
|
-
blocks: Array<Block>;
|
|
41
|
-
chain_length: bigint;
|
|
42
|
-
}
|
|
43
30
|
export interface GetTransactions {
|
|
44
|
-
balance: Tokens;
|
|
45
31
|
transactions: Array<TransactionWithId>;
|
|
46
|
-
oldest_tx_id: [] | [
|
|
32
|
+
oldest_tx_id: [] | [TxId];
|
|
47
33
|
}
|
|
48
34
|
export interface GetTransactionsErr {
|
|
49
35
|
message: string;
|
|
@@ -51,26 +37,20 @@ export interface GetTransactionsErr {
|
|
|
51
37
|
export type GetTransactionsResult =
|
|
52
38
|
| { Ok: GetTransactions }
|
|
53
39
|
| { Err: GetTransactionsErr };
|
|
54
|
-
export
|
|
55
|
-
export interface InitArg {
|
|
40
|
+
export interface InitArgs {
|
|
56
41
|
ledger_id: Principal;
|
|
57
42
|
}
|
|
58
43
|
export interface ListSubaccountsArgs {
|
|
59
44
|
owner: Principal;
|
|
60
45
|
start: [] | [SubAccount];
|
|
61
46
|
}
|
|
62
|
-
export type Map = Array<[string, Value]>;
|
|
63
47
|
export interface Mint {
|
|
64
48
|
to: Account;
|
|
65
49
|
memo: [] | [Uint8Array | number[]];
|
|
66
50
|
created_at_time: [] | [bigint];
|
|
67
51
|
amount: bigint;
|
|
68
52
|
}
|
|
69
|
-
export interface Status {
|
|
70
|
-
num_blocks_synced: BlockIndex;
|
|
71
|
-
}
|
|
72
53
|
export type SubAccount = Uint8Array | number[];
|
|
73
|
-
export type Tokens = bigint;
|
|
74
54
|
export interface Transaction {
|
|
75
55
|
burn: [] | [Burn];
|
|
76
56
|
kind: string;
|
|
@@ -80,7 +60,7 @@ export interface Transaction {
|
|
|
80
60
|
transfer: [] | [Transfer];
|
|
81
61
|
}
|
|
82
62
|
export interface TransactionWithId {
|
|
83
|
-
id:
|
|
63
|
+
id: TxId;
|
|
84
64
|
transaction: Transaction;
|
|
85
65
|
}
|
|
86
66
|
export interface Transfer {
|
|
@@ -92,26 +72,12 @@ export interface Transfer {
|
|
|
92
72
|
amount: bigint;
|
|
93
73
|
spender: [] | [Account];
|
|
94
74
|
}
|
|
95
|
-
export
|
|
96
|
-
ledger_id: [] | [Principal];
|
|
97
|
-
}
|
|
98
|
-
export type Value =
|
|
99
|
-
| { Int: bigint }
|
|
100
|
-
| { Map: Map }
|
|
101
|
-
| { Nat: bigint }
|
|
102
|
-
| { Nat64: bigint }
|
|
103
|
-
| { Blob: Uint8Array | number[] }
|
|
104
|
-
| { Text: string }
|
|
105
|
-
| { Array: Array<Value> };
|
|
75
|
+
export type TxId = bigint;
|
|
106
76
|
export interface _SERVICE {
|
|
107
77
|
get_account_transactions: ActorMethod<
|
|
108
78
|
[GetAccountTransactionsArgs],
|
|
109
79
|
GetTransactionsResult
|
|
110
80
|
>;
|
|
111
|
-
get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
|
|
112
|
-
get_fee_collectors_ranges: ActorMethod<[], FeeCollectorRanges>;
|
|
113
|
-
icrc1_balance_of: ActorMethod<[Account], Tokens>;
|
|
114
81
|
ledger_id: ActorMethod<[], Principal>;
|
|
115
82
|
list_subaccounts: ActorMethod<[ListSubaccountsArgs], Array<SubAccount>>;
|
|
116
|
-
status: ActorMethod<[], Status>;
|
|
117
83
|
}
|
|
@@ -1,49 +1,10 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
2
|
-
type
|
|
1
|
+
// Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
|
|
2
|
+
type TxId = nat;
|
|
3
3
|
|
|
4
|
-
type
|
|
5
|
-
ledger_id: principal;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type UpgradeArg = record {
|
|
9
|
-
ledger_id: opt principal;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type IndexArg = variant {
|
|
13
|
-
Init: InitArg;
|
|
14
|
-
Upgrade: UpgradeArg;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type GetBlocksRequest = record {
|
|
18
|
-
start : nat;
|
|
19
|
-
length : nat;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type Value = variant {
|
|
23
|
-
Blob : blob;
|
|
24
|
-
Text : text;
|
|
25
|
-
Nat : nat;
|
|
26
|
-
Nat64: nat64;
|
|
27
|
-
Int : int;
|
|
28
|
-
Array : vec Value;
|
|
29
|
-
Map : Map;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type Map = vec record { text; Value };
|
|
33
|
-
|
|
34
|
-
type Block = Value;
|
|
35
|
-
|
|
36
|
-
type GetBlocksResponse = record {
|
|
37
|
-
chain_length: nat64;
|
|
38
|
-
blocks: vec Block;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type BlockIndex = nat;
|
|
4
|
+
type Account = record { owner : principal; subaccount : opt blob };
|
|
42
5
|
|
|
43
6
|
type SubAccount = blob;
|
|
44
7
|
|
|
45
|
-
type Account = record { owner : principal; subaccount : opt SubAccount };
|
|
46
|
-
|
|
47
8
|
type Transaction = record {
|
|
48
9
|
burn : opt Burn;
|
|
49
10
|
kind : text;
|
|
@@ -94,21 +55,20 @@ type GetAccountTransactionsArgs = record {
|
|
|
94
55
|
// The txid of the last transaction seen by the client.
|
|
95
56
|
// If None then the results will start from the most recent
|
|
96
57
|
// txid.
|
|
97
|
-
start : opt
|
|
58
|
+
start : opt TxId;
|
|
98
59
|
// Maximum number of transactions to fetch.
|
|
99
60
|
max_results : nat;
|
|
100
61
|
};
|
|
101
62
|
|
|
102
63
|
type TransactionWithId = record {
|
|
103
|
-
id :
|
|
64
|
+
id : TxId;
|
|
104
65
|
transaction : Transaction;
|
|
105
66
|
};
|
|
106
67
|
|
|
107
68
|
type GetTransactions = record {
|
|
108
|
-
balance : Tokens;
|
|
109
69
|
transactions : vec TransactionWithId;
|
|
110
70
|
// The txid of the oldest transaction the account has
|
|
111
|
-
oldest_tx_id : opt
|
|
71
|
+
oldest_tx_id : opt TxId;
|
|
112
72
|
};
|
|
113
73
|
|
|
114
74
|
type GetTransactionsErr = record {
|
|
@@ -125,20 +85,13 @@ type ListSubaccountsArgs = record {
|
|
|
125
85
|
start: opt SubAccount;
|
|
126
86
|
};
|
|
127
87
|
|
|
128
|
-
|
|
129
|
-
|
|
88
|
+
// The initialization parameters of the Index canister.
|
|
89
|
+
type InitArgs = record {
|
|
90
|
+
ledger_id : principal;
|
|
130
91
|
};
|
|
131
92
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
service : (index_arg: opt IndexArg) -> {
|
|
137
|
-
get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult) query;
|
|
138
|
-
get_blocks : (GetBlocksRequest) -> (GetBlocksResponse) query;
|
|
139
|
-
get_fee_collectors_ranges : () -> (FeeCollectorRanges) query;
|
|
140
|
-
icrc1_balance_of : (Account) -> (Tokens) query;
|
|
141
|
-
ledger_id : () -> (principal) query;
|
|
142
|
-
list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
|
|
143
|
-
status : () -> (Status) query;
|
|
93
|
+
service : (InitArgs) -> {
|
|
94
|
+
get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult);
|
|
95
|
+
ledger_id : () -> (principal) query;
|
|
96
|
+
list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
|
|
144
97
|
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
|
|
2
2
|
export const idlFactory = ({ IDL }) => {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
6
|
-
const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
|
|
7
|
-
const BlockIndex = IDL.Nat;
|
|
8
|
-
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
3
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
4
|
+
const TxId = IDL.Nat;
|
|
9
5
|
const Account = IDL.Record({
|
|
10
6
|
'owner' : IDL.Principal,
|
|
11
|
-
'subaccount' : IDL.Opt(
|
|
7
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
12
8
|
});
|
|
13
9
|
const GetAccountTransactionsArgs = IDL.Record({
|
|
14
10
|
'max_results' : IDL.Nat,
|
|
15
|
-
'start' : IDL.Opt(
|
|
11
|
+
'start' : IDL.Opt(TxId),
|
|
16
12
|
'account' : Account,
|
|
17
13
|
});
|
|
18
|
-
const Tokens = IDL.Nat;
|
|
19
14
|
const Burn = IDL.Record({
|
|
20
15
|
'from' : Account,
|
|
21
16
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
@@ -57,71 +52,38 @@ export const idlFactory = ({ IDL }) => {
|
|
|
57
52
|
'transfer' : IDL.Opt(Transfer),
|
|
58
53
|
});
|
|
59
54
|
const TransactionWithId = IDL.Record({
|
|
60
|
-
'id' :
|
|
55
|
+
'id' : TxId,
|
|
61
56
|
'transaction' : Transaction,
|
|
62
57
|
});
|
|
63
58
|
const GetTransactions = IDL.Record({
|
|
64
|
-
'balance' : Tokens,
|
|
65
59
|
'transactions' : IDL.Vec(TransactionWithId),
|
|
66
|
-
'oldest_tx_id' : IDL.Opt(
|
|
60
|
+
'oldest_tx_id' : IDL.Opt(TxId),
|
|
67
61
|
});
|
|
68
62
|
const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
|
|
69
63
|
const GetTransactionsResult = IDL.Variant({
|
|
70
64
|
'Ok' : GetTransactions,
|
|
71
65
|
'Err' : GetTransactionsErr,
|
|
72
66
|
});
|
|
73
|
-
const
|
|
74
|
-
'start' : IDL.Nat,
|
|
75
|
-
'length' : IDL.Nat,
|
|
76
|
-
});
|
|
77
|
-
const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
|
|
78
|
-
Value.fill(
|
|
79
|
-
IDL.Variant({
|
|
80
|
-
'Int' : IDL.Int,
|
|
81
|
-
'Map' : Map,
|
|
82
|
-
'Nat' : IDL.Nat,
|
|
83
|
-
'Nat64' : IDL.Nat64,
|
|
84
|
-
'Blob' : IDL.Vec(IDL.Nat8),
|
|
85
|
-
'Text' : IDL.Text,
|
|
86
|
-
'Array' : IDL.Vec(Value),
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
const Block = Value;
|
|
90
|
-
const GetBlocksResponse = IDL.Record({
|
|
91
|
-
'blocks' : IDL.Vec(Block),
|
|
92
|
-
'chain_length' : IDL.Nat64,
|
|
93
|
-
});
|
|
94
|
-
const FeeCollectorRanges = IDL.Record({
|
|
95
|
-
'ranges' : IDL.Vec(
|
|
96
|
-
IDL.Tuple(Account, IDL.Vec(IDL.Tuple(BlockIndex, BlockIndex)))
|
|
97
|
-
),
|
|
98
|
-
});
|
|
67
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
99
68
|
const ListSubaccountsArgs = IDL.Record({
|
|
100
69
|
'owner' : IDL.Principal,
|
|
101
70
|
'start' : IDL.Opt(SubAccount),
|
|
102
71
|
});
|
|
103
|
-
const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
|
|
104
72
|
return IDL.Service({
|
|
105
73
|
'get_account_transactions' : IDL.Func(
|
|
106
74
|
[GetAccountTransactionsArgs],
|
|
107
75
|
[GetTransactionsResult],
|
|
108
|
-
[
|
|
76
|
+
[],
|
|
109
77
|
),
|
|
110
|
-
'get_blocks' : IDL.Func([GetBlocksRequest], [GetBlocksResponse], ['query']),
|
|
111
|
-
'get_fee_collectors_ranges' : IDL.Func([], [FeeCollectorRanges], ['query']),
|
|
112
|
-
'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),
|
|
113
78
|
'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),
|
|
114
79
|
'list_subaccounts' : IDL.Func(
|
|
115
80
|
[ListSubaccountsArgs],
|
|
116
81
|
[IDL.Vec(SubAccount)],
|
|
117
82
|
['query'],
|
|
118
83
|
),
|
|
119
|
-
'status' : IDL.Func([], [Status], ['query']),
|
|
120
84
|
});
|
|
121
85
|
};
|
|
122
86
|
export const init = ({ IDL }) => {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
|
|
126
|
-
return [IDL.Opt(IndexArg)];
|
|
87
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
88
|
+
return [InitArgs];
|
|
127
89
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
|
|
2
2
|
type BlockIndex = nat;
|
|
3
3
|
type Subaccount = blob;
|
|
4
4
|
// Number of nanoseconds since the UNIX epoch in UTC timezone.
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var Ne=(e,c)=>{for(var r in c)L(e,r,{get:c[r],enumerable:!0})},ge=(e,c,r,a)=>{if(c&&typeof c=="object"||typeof c=="function")for(let t of _e(c))!fe.call(e,t)&&t!==r&&L(e,t,{get:()=>c[t],enumerable:!(a=ue(c,t))||a.enumerable});return e};var Oe=e=>ge(L({},"__esModule",{value:!0}),e);var Ae={};Ne(Ae,{IcrcIndexCanister:()=>E,IcrcLedgerCanister:()=>G,IcrcMetadataResponseEntries:()=>de,IcrcTransferError:()=>v,IndexError:()=>P,decodeIcrcAccount:()=>ye,decodePayment:()=>Ve,encodeIcrcAccount:()=>Re});module.exports=Oe(Ae);var P=class extends Error{};var v=class extends Error{constructor({msg:c,errorType:r}){super(c),this.errorType=r}};var ae=require("@dfinity/utils");var te=({IDL:e})=>{let c=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal)}),a=e.Record({ledger_id:e.Principal}),t=e.Variant({Upgrade:r,Init:a}),n=e.Nat,l=e.Vec(e.Nat8),i=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:i}),O=e.Nat,p=e.Record({from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),T=e.Record({to:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),_=e.Record({fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:i}),x=e.Record({to:i,fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),f=e.Record({burn:e.Opt(p),kind:e.Text,mint:e.Opt(T),approve:e.Opt(_),timestamp:e.Nat64,transfer:e.Opt(x)}),R=e.Record({id:n,transaction:f}),y=e.Record({balance:O,transactions:e.Vec(R),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),A=e.Variant({Ok:y,Err:V}),u=e.Record({start:e.Nat,length:e.Nat}),N=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:N,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let o=c,b=e.Record({blocks:e.Vec(o),chain_length:e.Nat64}),F=e.Record({ranges:e.Vec(e.Tuple(i,e.Vec(e.Tuple(n,n))))}),h=e.Record({owner:e.Principal,start:e.Opt(l)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[A],[]),get_blocks:e.Func([u],[b],[]),get_fee_collectors_ranges:e.Func([],[F],[]),icrc1_balance_of:e.Func([i],[O],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([h],[e.Vec(l)],[]),status:e.Func([],[k],[])})};var re=({IDL:e})=>{let c=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal)}),a=e.Record({ledger_id:e.Principal}),t=e.Variant({Upgrade:r,Init:a}),n=e.Nat,l=e.Vec(e.Nat8),i=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:i}),O=e.Nat,p=e.Record({from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),T=e.Record({to:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),_=e.Record({fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:i}),x=e.Record({to:i,fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),f=e.Record({burn:e.Opt(p),kind:e.Text,mint:e.Opt(T),approve:e.Opt(_),timestamp:e.Nat64,transfer:e.Opt(x)}),R=e.Record({id:n,transaction:f}),y=e.Record({balance:O,transactions:e.Vec(R),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),A=e.Variant({Ok:y,Err:V}),u=e.Record({start:e.Nat,length:e.Nat}),N=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:N,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let o=c,b=e.Record({blocks:e.Vec(o),chain_length:e.Nat64}),F=e.Record({ranges:e.Vec(e.Tuple(i,e.Vec(e.Tuple(n,n))))}),h=e.Record({owner:e.Principal,start:e.Opt(l)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[A],["query"]),get_blocks:e.Func([u],[b],["query"]),get_fee_collectors_ranges:e.Func([],[F],["query"]),icrc1_balance_of:e.Func([i],[O],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([h],[e.Vec(l)],["query"]),status:e.Func([],[k],["query"])})};var S=require("@dfinity/utils"),w=class extends S.Canister{constructor(){super(...arguments);this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,S.toNullable)(r.subaccount)})}};var D=require("@dfinity/utils"),Te=({owner:e,subaccount:c})=>({owner:e,subaccount:(0,D.toNullable)(c)}),ce=({account:e,max_results:c,start:r})=>({account:Te(e),max_results:c,start:(0,D.toNullable)(r)});var E=class e extends w{constructor(){super(...arguments);this.getTransactions=async({certified:r,...a})=>{let t=await this.caller({certified:r}).get_account_transactions(ce(a));if("Err"in t)throw new P(t.Err.message);return t.Ok}}static create(r){let{service:a,certifiedService:t,canisterId:n}=(0,ae.createServices)({options:r,idlFactory:re,certifiedIdlFactory:te});return new e(n,a,t)}};var le=require("@dfinity/utils");var oe=({IDL:e})=>{let c=e.Rec(),r=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),a=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(a)}),n=e.Variant({SetTo:t,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),i=e.Record({token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,r))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(n),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,r)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(l)}),O=e.Variant({Upgrade:e.Opt(i),Init:g}),p=e.Nat,T=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),x=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:x,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let f=c,R=e.Record({blocks:e.Vec(f)}),y=e.Func([_],[R],[]),V=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(f),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:y,start:p,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),u=e.Nat,N=e.Record({start:u,length:e.Nat}),o=e.Nat64,b=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),F=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),h=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),k=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),B=e.Record({burn:e.Opt(b),kind:e.Text,mint:e.Opt(F),approve:e.Opt(h),timestamp:o,transfer:e.Opt(k)}),q=e.Record({transactions:e.Vec(B)}),U=e.Func([N],[q],[]),M=e.Record({first_index:u,log_length:e.Nat,transactions:e.Vec(B),archived_transactions:e.Vec(e.Record({callback:U,start:u,length:e.Nat}))}),s=e.Nat,z=e.Record({url:e.Text,name:e.Text}),Q=e.Record({to:t,fee:e.Opt(s),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(a),created_at_time:e.Opt(o),amount:s}),H=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),Z=e.Variant({Ok:p,Err:H}),$=e.Record({account:t,spender:t}),W=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),X=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),j=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),Y=e.Variant({Ok:p,Err:j}),J=e.Record({to:t,fee:e.Opt(s),spender_subaccount:e.Opt(a),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:s}),K=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:s}),BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),I=e.Variant({Ok:p,Err:K});return e.Service({archives:e.Func([],[e.Vec(T)],[]),get_blocks:e.Func([_],[V],[]),get_data_certificate:e.Func([],[A],[]),get_transactions:e.Func([N],[M],[]),icrc1_balance_of:e.Func([t],[s],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[s],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,r))],[]),icrc1_minting_account:e.Func([],[e.Opt(t)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(z)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[s],[]),icrc1_transfer:e.Func([Q],[Z],[]),icrc2_allowance:e.Func([$],[W],[]),icrc2_approve:e.Func([X],[Y],[]),icrc2_transfer_from:e.Func([J],[I],[])})};var ne=({IDL:e})=>{let c=e.Rec(),r=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),a=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(a)}),n=e.Variant({SetTo:t,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),i=e.Record({token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,r))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(n),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,r)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(l)}),O=e.Variant({Upgrade:e.Opt(i),Init:g}),p=e.Nat,T=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),x=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:x,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let f=c,R=e.Record({blocks:e.Vec(f)}),y=e.Func([_],[R],["query"]),V=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(f),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:y,start:p,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),u=e.Nat,N=e.Record({start:u,length:e.Nat}),o=e.Nat64,b=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),F=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),h=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),k=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),B=e.Record({burn:e.Opt(b),kind:e.Text,mint:e.Opt(F),approve:e.Opt(h),timestamp:o,transfer:e.Opt(k)}),q=e.Record({transactions:e.Vec(B)}),U=e.Func([N],[q],["query"]),M=e.Record({first_index:u,log_length:e.Nat,transactions:e.Vec(B),archived_transactions:e.Vec(e.Record({callback:U,start:u,length:e.Nat}))}),s=e.Nat,z=e.Record({url:e.Text,name:e.Text}),Q=e.Record({to:t,fee:e.Opt(s),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(a),created_at_time:e.Opt(o),amount:s}),H=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),Z=e.Variant({Ok:p,Err:H}),$=e.Record({account:t,spender:t}),W=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),X=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),j=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),Y=e.Variant({Ok:p,Err:j}),J=e.Record({to:t,fee:e.Opt(s),spender_subaccount:e.Opt(a),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:s}),K=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:s}),BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),I=e.Variant({Ok:p,Err:K});return e.Service({archives:e.Func([],[e.Vec(T)],["query"]),get_blocks:e.Func([_],[V],["query"]),get_data_certificate:e.Func([],[A],["query"]),get_transactions:e.Func([N],[M],["query"]),icrc1_balance_of:e.Func([t],[s],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[s],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,r))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(t)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(z)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[s],["query"]),icrc1_transfer:e.Func([Q],[Z],[]),icrc2_allowance:e.Func([$],[W],["query"]),icrc2_approve:e.Func([X],[Y],[]),icrc2_transfer_from:e.Func([J],[I],[])})};var d=require("@dfinity/utils"),se=({from_subaccount:e,fee:c,created_at_time:r,memo:a,...t})=>({...t,fee:(0,d.toNullable)(c),memo:(0,d.toNullable)(a),from_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),ie=({spender_subaccount:e,fee:c,created_at_time:r,memo:a,...t})=>({...t,fee:(0,d.toNullable)(c),memo:(0,d.toNullable)(a),spender_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),pe=({fee:e,created_at_time:c,memo:r,from_subaccount:a,expected_allowance:t,expires_at:n,...l})=>({...l,fee:(0,d.toNullable)(e),memo:(0,d.toNullable)(r),from_subaccount:(0,d.toNullable)(a),created_at_time:(0,d.toNullable)(c),expected_allowance:(0,d.toNullable)(t),expires_at:(0,d.toNullable)(n)});var G=class e extends w{constructor(){super(...arguments);this.metadata=r=>this.caller(r).icrc1_metadata();this.transactionFee=r=>this.caller(r).icrc1_fee();this.transfer=async r=>{let a=await this.caller({certified:!0}).icrc1_transfer(se(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to transfer"});return a.Ok};this.totalTokensSupply=r=>this.caller(r).icrc1_total_supply();this.transferFrom=async r=>{let a=await this.caller({certified:!0}).icrc2_transfer_from(ie(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to transfer from"});return a.Ok};this.approve=async r=>{let a=await this.caller({certified:!0}).icrc2_approve(pe(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to entitle the spender to transfer the amount"});return a.Ok};this.allowance=async r=>{let{certified:a,...t}=r;return this.caller({certified:a}).icrc2_allowance({...t})}}static create(r){let{service:a,certifiedService:t,canisterId:n}=(0,le.createServices)({options:r,idlFactory:ne,certifiedIdlFactory:oe});return new e(n,a,t)}};var de=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(de||{});var ee=require("@dfinity/principal"),m=require("@dfinity/utils"),xe=64,Re=({owner:e,subaccount:c})=>{if((0,m.isNullish)(c))return e.toText();let a=(t=>t.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(Uint8Array.from(c)));return a.length===0?e.toText():`${e.toText()}-${me({owner:e,subaccount:c})}.${a}`},me=({owner:e,subaccount:c})=>{let r=(0,m.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...c]));return(0,m.encodeBase32)(r)},ye=e=>{let[c,r]=e.split(".");if(!(0,m.notEmptyString)(c))throw new Error("Invalid account. No string provided.");if((0,m.isNullish)(r))return{owner:ee.Principal.fromText(e)};let[a,...t]=c.split("-").reverse(),n=t.reverse().join("-"),l={owner:ee.Principal.fromText(n),subaccount:(0,m.hexStringToUint8Array)(r.padStart(xe,"0"))};if(me(l)!==a)throw new Error("Invalid account. Invalid checksum.");return l};var C=require("@dfinity/utils"),Ve=e=>{let c=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,r=e.match(c);if((0,C.isNullish)(r))return;let[a,t,n,l]=r;return{token:t,identifier:n,...(0,C.nonNullish)(l)&&!isNaN(parseFloat(l))&&{amount:parseFloat(l)}}};0&&(module.exports={IcrcIndexCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
|
|
1
|
+
"use strict";var L=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var _t=(t,a)=>{for(var c in a)L(t,c,{get:a[c],enumerable:!0})},ft=(t,a,c,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of dt(a))!ut.call(t,e)&&e!==c&&L(t,e,{get:()=>a[e],enumerable:!(r=mt(a,e))||r.enumerable});return t};var Nt=t=>ft(L({},"__esModule",{value:!0}),t);var yt={};_t(yt,{IcrcIndexCanister:()=>F,IcrcLedgerCanister:()=>v,IcrcMetadataResponseEntries:()=>pt,IcrcTransferError:()=>x,IndexError:()=>b,decodeIcrcAccount:()=>xt,decodePayment:()=>Rt,encodeIcrcAccount:()=>Tt});module.exports=Nt(yt);var b=class extends Error{};var x=class extends Error{constructor({msg:a,errorType:c}){super(a),this.errorType=c}};var h=require("@dfinity/utils");var et=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),c=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(c),account:r}),i=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)}),p=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)}),y=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(p),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:c,transaction:y}),N=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(c)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:N,Err:u}),d=t.Vec(t.Nat8),g=t.Record({owner:t.Principal,start:t.Opt(d)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([g],[t.Vec(d)],[])})};var rt=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),c=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(c),account:r}),i=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)}),p=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)}),y=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(p),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:c,transaction:y}),N=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(c)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:N,Err:u}),d=t.Vec(t.Nat8),g=t.Record({owner:t.Principal,start:t.Opt(d)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([g],[t.Vec(d)],["query"])})};var D=require("@dfinity/utils"),Ot=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,D.toNullable)(a)}),ct=({account:t,max_results:a,start:c})=>({account:Ot(t),max_results:a,start:(0,D.toNullable)(c)});var F=class t extends h.Canister{constructor(){super(...arguments);this.getTransactions=async c=>{let r=await this.caller({certified:!0}).get_account_transactions(ct(c));if("Err"in r)throw new b(r.Err.message);return r.Ok}}static create(c){let{service:r,certifiedService:e,canisterId:i}=(0,h.createServices)({options:c,idlFactory:rt,certifiedIdlFactory:et});return new t(i,r,e)}};var R=require("@dfinity/utils");var at=({IDL:t})=>{let a=t.Rec(),c=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)}),i=t.Variant({SetTo:e,Unset:t.Null}),p=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,c))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(i),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,c)),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(p)}),y=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,N=t.Record({block_range_end:s,canister_id:t.Principal,block_range_start:s}),u=t.Record({start:s,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let d=a,g=t.Record({blocks:t.Vec(d)}),w=t.Func([u],[g],[]),P=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:w,start:s,length:t.Nat}))}),B=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,A=t.Record({start:T,length:t.Nat}),o=t.Nat64,E=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),S=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat}),G=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),C=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(E),kind:t.Text,mint:t.Opt(S),approve:t.Opt(G),timestamp:o,transfer:t.Opt(C)}),q=t.Record({transactions:t.Vec(V)}),U=t.Func([A],[q],[]),M=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:U,start:T,length:t.Nat}))}),n=t.Nat,z=t.Record({url:t.Text,name:t.Text}),Q=t.Record({to:e,fee:t.Opt(n),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(o),amount:n}),H=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),W=t.Variant({Ok:s,Err:H}),Z=t.Record({account:e,spender:e}),$=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),X=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(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),j=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,Expired:t.Record({ledger_time:o}),InsufficientFunds:t.Record({balance:t.Nat})}),Y=t.Variant({Ok:s,Err:j}),J=t.Record({to:e,fee:t.Opt(n),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:n}),K=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:n}),BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),I=t.Variant({Ok:s,Err:K});return t.Service({archives:t.Func([],[t.Vec(N)],[]),get_blocks:t.Func([u],[P],[]),get_data_certificate:t.Func([],[B],[]),get_transactions:t.Func([A],[M],[]),icrc1_balance_of:t.Func([e],[n],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[n],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,c))],[]),icrc1_minting_account:t.Func([],[t.Opt(e)],[]),icrc1_name:t.Func([],[t.Text],[]),icrc1_supported_standards:t.Func([],[t.Vec(z)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[n],[]),icrc1_transfer:t.Func([Q],[W],[]),icrc2_allowance:t.Func([Z],[$],[]),icrc2_approve:t.Func([X],[Y],[]),icrc2_transfer_from:t.Func([J],[I],[])})};var ot=({IDL:t})=>{let a=t.Rec(),c=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)}),i=t.Variant({SetTo:e,Unset:t.Null}),p=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,c))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(i),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,c)),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(p)}),y=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,N=t.Record({block_range_end:s,canister_id:t.Principal,block_range_start:s}),u=t.Record({start:s,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let d=a,g=t.Record({blocks:t.Vec(d)}),w=t.Func([u],[g],["query"]),P=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:w,start:s,length:t.Nat}))}),B=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,A=t.Record({start:T,length:t.Nat}),o=t.Nat64,E=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),S=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat}),G=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),C=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(E),kind:t.Text,mint:t.Opt(S),approve:t.Opt(G),timestamp:o,transfer:t.Opt(C)}),q=t.Record({transactions:t.Vec(V)}),U=t.Func([A],[q],["query"]),M=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:U,start:T,length:t.Nat}))}),n=t.Nat,z=t.Record({url:t.Text,name:t.Text}),Q=t.Record({to:e,fee:t.Opt(n),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(o),amount:n}),H=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),W=t.Variant({Ok:s,Err:H}),Z=t.Record({account:e,spender:e}),$=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),X=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(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),j=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,Expired:t.Record({ledger_time:o}),InsufficientFunds:t.Record({balance:t.Nat})}),Y=t.Variant({Ok:s,Err:j}),J=t.Record({to:e,fee:t.Opt(n),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:n}),K=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:n}),BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),I=t.Variant({Ok:s,Err:K});return t.Service({archives:t.Func([],[t.Vec(N)],["query"]),get_blocks:t.Func([u],[P],["query"]),get_data_certificate:t.Func([],[B],["query"]),get_transactions:t.Func([A],[M],["query"]),icrc1_balance_of:t.Func([e],[n],["query"]),icrc1_decimals:t.Func([],[t.Nat8],["query"]),icrc1_fee:t.Func([],[n],["query"]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,c))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(e)],["query"]),icrc1_name:t.Func([],[t.Text],["query"]),icrc1_supported_standards:t.Func([],[t.Vec(z)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[n],["query"]),icrc1_transfer:t.Func([Q],[W],[]),icrc2_allowance:t.Func([Z],[$],["query"]),icrc2_approve:t.Func([X],[Y],[]),icrc2_transfer_from:t.Func([J],[I],[])})};var l=require("@dfinity/utils"),nt=({from_subaccount:t,fee:a,created_at_time:c,memo:r,...e})=>({...e,fee:(0,l.toNullable)(a),memo:(0,l.toNullable)(r),from_subaccount:(0,l.toNullable)(t),created_at_time:(0,l.toNullable)(c)}),st=({spender_subaccount:t,fee:a,created_at_time:c,memo:r,...e})=>({...e,fee:(0,l.toNullable)(a),memo:(0,l.toNullable)(r),spender_subaccount:(0,l.toNullable)(t),created_at_time:(0,l.toNullable)(c)}),it=({fee:t,created_at_time:a,memo:c,from_subaccount:r,expected_allowance:e,expires_at:i,...p})=>({...p,fee:(0,l.toNullable)(t),memo:(0,l.toNullable)(c),from_subaccount:(0,l.toNullable)(r),created_at_time:(0,l.toNullable)(a),expected_allowance:(0,l.toNullable)(e),expires_at:(0,l.toNullable)(i)});var v=class t extends R.Canister{constructor(){super(...arguments);this.metadata=c=>this.caller(c).icrc1_metadata();this.transactionFee=c=>this.caller(c).icrc1_fee();this.balance=c=>this.caller({certified:c.certified}).icrc1_balance_of({owner:c.owner,subaccount:(0,R.toNullable)(c.subaccount)});this.transfer=async c=>{let r=await this.caller({certified:!0}).icrc1_transfer(nt(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};this.totalTokensSupply=c=>this.caller(c).icrc1_total_supply();this.transferFrom=async c=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(st(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};this.approve=async c=>{let r=await this.caller({certified:!0}).icrc2_approve(it(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};this.allowance=async c=>{let{certified:r,...e}=c;return this.caller({certified:r}).icrc2_allowance({...e})}}static create(c){let{service:r,certifiedService:e,canisterId:i}=(0,R.createServices)({options:c,idlFactory:ot,certifiedIdlFactory:at});return new t(i,r,e)}};var pt=(i=>(i.SYMBOL="icrc1:symbol",i.NAME="icrc1:name",i.DECIMALS="icrc1:decimals",i.FEE="icrc1:fee",i.LOGO="icrc1:logo",i))(pt||{});var tt=require("@dfinity/principal"),m=require("@dfinity/utils"),gt=64,Tt=({owner:t,subaccount:a})=>{if((0,m.isNullish)(a))return t.toText();let r=(e=>e.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(Uint8Array.from(a)));return r.length===0?t.toText():`${t.toText()}-${lt({owner:t,subaccount:a})}.${r}`},lt=({owner:t,subaccount:a})=>{let c=(0,m.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,m.encodeBase32)(c)},xt=t=>{let[a,c]=t.split(".");if(!(0,m.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,m.isNullish)(c))return{owner:tt.Principal.fromText(t)};let[r,...e]=a.split("-").reverse(),i=e.reverse().join("-"),p={owner:tt.Principal.fromText(i),subaccount:(0,m.hexStringToUint8Array)(c.padStart(gt,"0"))};if(lt(p)!==r)throw new Error("Invalid account. Invalid checksum.");return p};var k=require("@dfinity/utils"),Rt=t=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=t.match(a);if((0,k.isNullish)(c))return;let[r,e,i,p]=c;return{token:e,identifier:i,...(0,k.nonNullish)(p)&&!isNaN(parseFloat(p))&&{amount:parseFloat(p)}}};0&&(module.exports={IcrcIndexCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|