@dfinity/ledger-icrc 1.0.0 → 1.0.1
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 +1 -1
- package/dist/candid/icrc_index.certified.idl.js +1 -1
- package/dist/candid/icrc_index.did +1 -1
- package/dist/candid/icrc_index.idl.js +1 -1
- package/dist/candid/icrc_ledger.certified.idl.js +20 -17
- package/dist/candid/icrc_ledger.d.ts +15 -15
- package/dist/candid/icrc_ledger.did +24 -24
- package/dist/candid/icrc_ledger.idl.js +20 -17
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-DXWXHYEN.js +2 -0
- package/dist/esm/chunk-DXWXHYEN.js.map +7 -0
- package/dist/esm/{chunk-XVPR4TJN.js → chunk-MJQNXPUY.js} +1 -1
- package/dist/esm/{chunk-XVPR4TJN.js.map → chunk-MJQNXPUY.js.map} +1 -1
- package/dist/esm/index.canister.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/ledger.canister.js +1 -1
- package/package.json +1 -1
- package/dist/esm/chunk-Y76HDAJ2.js +0 -2
- package/dist/esm/chunk-Y76HDAJ2.js.map +0 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/
|
|
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
3
|
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
4
4
|
const TxId = IDL.Nat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 695f05aacf69371fc5743fa6d1619f7d9993ea87 'rs/rosetta-api/icrc1/index/index.did' by import-candid
|
|
2
2
|
type TxId = nat;
|
|
3
3
|
|
|
4
4
|
type Account = record { owner : principal; subaccount : opt blob };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/
|
|
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
3
|
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
4
4
|
const TxId = IDL.Nat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */
|
|
2
2
|
export const idlFactory = ({ IDL }) => {
|
|
3
3
|
const Value = IDL.Rec();
|
|
4
4
|
const MetadataValue = IDL.Variant({
|
|
@@ -97,27 +97,28 @@ export const idlFactory = ({ IDL }) => {
|
|
|
97
97
|
'start' : TxIndex,
|
|
98
98
|
'length' : IDL.Nat,
|
|
99
99
|
});
|
|
100
|
+
const Timestamp = IDL.Nat64;
|
|
100
101
|
const Burn = IDL.Record({
|
|
101
102
|
'from' : Account,
|
|
102
103
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
103
|
-
'created_at_time' : IDL.Opt(
|
|
104
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
104
105
|
'amount' : IDL.Nat,
|
|
105
106
|
'spender' : IDL.Opt(Account),
|
|
106
107
|
});
|
|
107
108
|
const Mint = IDL.Record({
|
|
108
109
|
'to' : Account,
|
|
109
110
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
110
|
-
'created_at_time' : IDL.Opt(
|
|
111
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
111
112
|
'amount' : IDL.Nat,
|
|
112
113
|
});
|
|
113
114
|
const Approve = IDL.Record({
|
|
114
115
|
'fee' : IDL.Opt(IDL.Nat),
|
|
115
116
|
'from' : Account,
|
|
116
117
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
117
|
-
'created_at_time' : IDL.Opt(
|
|
118
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
118
119
|
'amount' : IDL.Nat,
|
|
119
120
|
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
120
|
-
'expires_at' : IDL.Opt(
|
|
121
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
121
122
|
'spender' : Account,
|
|
122
123
|
});
|
|
123
124
|
const Transfer = IDL.Record({
|
|
@@ -125,7 +126,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
125
126
|
'fee' : IDL.Opt(IDL.Nat),
|
|
126
127
|
'from' : Account,
|
|
127
128
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
128
|
-
'created_at_time' : IDL.Opt(
|
|
129
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
129
130
|
'amount' : IDL.Nat,
|
|
130
131
|
'spender' : IDL.Opt(Account),
|
|
131
132
|
});
|
|
@@ -134,7 +135,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
134
135
|
'kind' : IDL.Text,
|
|
135
136
|
'mint' : IDL.Opt(Mint),
|
|
136
137
|
'approve' : IDL.Opt(Approve),
|
|
137
|
-
'timestamp' :
|
|
138
|
+
'timestamp' : Timestamp,
|
|
138
139
|
'transfer' : IDL.Opt(Transfer),
|
|
139
140
|
});
|
|
140
141
|
const TransactionRange = IDL.Record({
|
|
@@ -159,7 +160,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
159
160
|
});
|
|
160
161
|
const Tokens = IDL.Nat;
|
|
161
162
|
const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });
|
|
162
|
-
const Timestamp = IDL.Nat64;
|
|
163
163
|
const TransferArg = IDL.Record({
|
|
164
164
|
'to' : Account,
|
|
165
165
|
'fee' : IDL.Opt(Tokens),
|
|
@@ -177,7 +177,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
177
177
|
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
178
178
|
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
179
179
|
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
180
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
180
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
181
181
|
'TooOld' : IDL.Null,
|
|
182
182
|
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
183
183
|
});
|
|
@@ -191,16 +191,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
191
191
|
});
|
|
192
192
|
const Allowance = IDL.Record({
|
|
193
193
|
'allowance' : IDL.Nat,
|
|
194
|
-
'expires_at' : IDL.Opt(
|
|
194
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
195
195
|
});
|
|
196
196
|
const ApproveArgs = IDL.Record({
|
|
197
197
|
'fee' : IDL.Opt(IDL.Nat),
|
|
198
198
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
199
199
|
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
200
|
-
'created_at_time' : IDL.Opt(
|
|
200
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
201
201
|
'amount' : IDL.Nat,
|
|
202
202
|
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
203
|
-
'expires_at' : IDL.Opt(
|
|
203
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
204
204
|
'spender' : Account,
|
|
205
205
|
});
|
|
206
206
|
const ApproveError = IDL.Variant({
|
|
@@ -209,15 +209,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
209
209
|
'error_code' : IDL.Nat,
|
|
210
210
|
}),
|
|
211
211
|
'TemporarilyUnavailable' : IDL.Null,
|
|
212
|
-
'Duplicate' : IDL.Record({ 'duplicate_of' :
|
|
212
|
+
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
213
213
|
'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),
|
|
214
214
|
'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),
|
|
215
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
215
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
216
216
|
'TooOld' : IDL.Null,
|
|
217
|
-
'Expired' : IDL.Record({ 'ledger_time' :
|
|
217
|
+
'Expired' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
218
218
|
'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),
|
|
219
219
|
});
|
|
220
|
-
const ApproveResult = IDL.Variant({
|
|
220
|
+
const ApproveResult = IDL.Variant({
|
|
221
|
+
'Ok' : BlockIndex,
|
|
222
|
+
'Err' : ApproveError,
|
|
223
|
+
});
|
|
221
224
|
const TransferFromArgs = IDL.Record({
|
|
222
225
|
'to' : Account,
|
|
223
226
|
'fee' : IDL.Opt(Tokens),
|
|
@@ -237,7 +240,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
237
240
|
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
238
241
|
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
239
242
|
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
240
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
243
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
241
244
|
'TooOld' : IDL.Null,
|
|
242
245
|
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
243
246
|
});
|
|
@@ -7,7 +7,7 @@ export interface Account {
|
|
|
7
7
|
}
|
|
8
8
|
export interface Allowance {
|
|
9
9
|
allowance: bigint;
|
|
10
|
-
expires_at: [] | [
|
|
10
|
+
expires_at: [] | [Timestamp];
|
|
11
11
|
}
|
|
12
12
|
export interface AllowanceArgs {
|
|
13
13
|
account: Account;
|
|
@@ -17,20 +17,20 @@ export interface Approve {
|
|
|
17
17
|
fee: [] | [bigint];
|
|
18
18
|
from: Account;
|
|
19
19
|
memo: [] | [Uint8Array];
|
|
20
|
-
created_at_time: [] | [
|
|
20
|
+
created_at_time: [] | [Timestamp];
|
|
21
21
|
amount: bigint;
|
|
22
22
|
expected_allowance: [] | [bigint];
|
|
23
|
-
expires_at: [] | [
|
|
23
|
+
expires_at: [] | [Timestamp];
|
|
24
24
|
spender: Account;
|
|
25
25
|
}
|
|
26
26
|
export interface ApproveArgs {
|
|
27
27
|
fee: [] | [bigint];
|
|
28
28
|
memo: [] | [Uint8Array];
|
|
29
29
|
from_subaccount: [] | [Uint8Array];
|
|
30
|
-
created_at_time: [] | [
|
|
30
|
+
created_at_time: [] | [Timestamp];
|
|
31
31
|
amount: bigint;
|
|
32
32
|
expected_allowance: [] | [bigint];
|
|
33
|
-
expires_at: [] | [
|
|
33
|
+
expires_at: [] | [Timestamp];
|
|
34
34
|
spender: Account;
|
|
35
35
|
}
|
|
36
36
|
export type ApproveError =
|
|
@@ -38,14 +38,14 @@ export type ApproveError =
|
|
|
38
38
|
GenericError: { message: string; error_code: bigint };
|
|
39
39
|
}
|
|
40
40
|
| { TemporarilyUnavailable: null }
|
|
41
|
-
| { Duplicate: { duplicate_of:
|
|
41
|
+
| { Duplicate: { duplicate_of: BlockIndex } }
|
|
42
42
|
| { BadFee: { expected_fee: bigint } }
|
|
43
43
|
| { AllowanceChanged: { current_allowance: bigint } }
|
|
44
|
-
| { CreatedInFuture: { ledger_time:
|
|
44
|
+
| { CreatedInFuture: { ledger_time: Timestamp } }
|
|
45
45
|
| { TooOld: null }
|
|
46
|
-
| { Expired: { ledger_time:
|
|
46
|
+
| { Expired: { ledger_time: Timestamp } }
|
|
47
47
|
| { InsufficientFunds: { balance: bigint } };
|
|
48
|
-
export type ApproveResult = { Ok:
|
|
48
|
+
export type ApproveResult = { Ok: BlockIndex } | { Err: ApproveError };
|
|
49
49
|
export type Block = Value;
|
|
50
50
|
export type BlockIndex = bigint;
|
|
51
51
|
export interface BlockRange {
|
|
@@ -54,7 +54,7 @@ export interface BlockRange {
|
|
|
54
54
|
export interface Burn {
|
|
55
55
|
from: Account;
|
|
56
56
|
memo: [] | [Uint8Array];
|
|
57
|
-
created_at_time: [] | [
|
|
57
|
+
created_at_time: [] | [Timestamp];
|
|
58
58
|
amount: bigint;
|
|
59
59
|
spender: [] | [Account];
|
|
60
60
|
}
|
|
@@ -140,7 +140,7 @@ export type MetadataValue =
|
|
|
140
140
|
export interface Mint {
|
|
141
141
|
to: Account;
|
|
142
142
|
memo: [] | [Uint8Array];
|
|
143
|
-
created_at_time: [] | [
|
|
143
|
+
created_at_time: [] | [Timestamp];
|
|
144
144
|
amount: bigint;
|
|
145
145
|
}
|
|
146
146
|
export type QueryArchiveFn = ActorMethod<
|
|
@@ -160,7 +160,7 @@ export interface Transaction {
|
|
|
160
160
|
kind: string;
|
|
161
161
|
mint: [] | [Mint];
|
|
162
162
|
approve: [] | [Approve];
|
|
163
|
-
timestamp:
|
|
163
|
+
timestamp: Timestamp;
|
|
164
164
|
transfer: [] | [Transfer];
|
|
165
165
|
}
|
|
166
166
|
export interface TransactionRange {
|
|
@@ -171,7 +171,7 @@ export interface Transfer {
|
|
|
171
171
|
fee: [] | [bigint];
|
|
172
172
|
from: Account;
|
|
173
173
|
memo: [] | [Uint8Array];
|
|
174
|
-
created_at_time: [] | [
|
|
174
|
+
created_at_time: [] | [Timestamp];
|
|
175
175
|
amount: bigint;
|
|
176
176
|
spender: [] | [Account];
|
|
177
177
|
}
|
|
@@ -191,7 +191,7 @@ export type TransferError =
|
|
|
191
191
|
| { BadBurn: { min_burn_amount: Tokens } }
|
|
192
192
|
| { Duplicate: { duplicate_of: BlockIndex } }
|
|
193
193
|
| { BadFee: { expected_fee: Tokens } }
|
|
194
|
-
| { CreatedInFuture: { ledger_time:
|
|
194
|
+
| { CreatedInFuture: { ledger_time: Timestamp } }
|
|
195
195
|
| { TooOld: null }
|
|
196
196
|
| { InsufficientFunds: { balance: Tokens } };
|
|
197
197
|
export interface TransferFromArgs {
|
|
@@ -212,7 +212,7 @@ export type TransferFromError =
|
|
|
212
212
|
| { BadBurn: { min_burn_amount: Tokens } }
|
|
213
213
|
| { Duplicate: { duplicate_of: BlockIndex } }
|
|
214
214
|
| { BadFee: { expected_fee: Tokens } }
|
|
215
|
-
| { CreatedInFuture: { ledger_time:
|
|
215
|
+
| { CreatedInFuture: { ledger_time: Timestamp } }
|
|
216
216
|
| { TooOld: null }
|
|
217
217
|
| { InsufficientFunds: { balance: Tokens } };
|
|
218
218
|
export type TransferFromResult =
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 695f05aacf69371fc5743fa6d1619f7d9993ea87 '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.
|
|
@@ -7,49 +7,49 @@ type Timestamp = nat64;
|
|
|
7
7
|
type Duration = nat64;
|
|
8
8
|
type Tokens = nat;
|
|
9
9
|
type TxIndex = nat;
|
|
10
|
-
type Allowance = record { allowance : nat; expires_at : opt
|
|
10
|
+
type Allowance = record { allowance : nat; expires_at : opt Timestamp };
|
|
11
11
|
type AllowanceArgs = record { account : Account; spender : Account };
|
|
12
12
|
type Approve = record {
|
|
13
13
|
fee : opt nat;
|
|
14
14
|
from : Account;
|
|
15
|
-
memo : opt
|
|
16
|
-
created_at_time : opt
|
|
15
|
+
memo : opt blob;
|
|
16
|
+
created_at_time : opt Timestamp;
|
|
17
17
|
amount : nat;
|
|
18
18
|
expected_allowance : opt nat;
|
|
19
|
-
expires_at : opt
|
|
19
|
+
expires_at : opt Timestamp;
|
|
20
20
|
spender : Account;
|
|
21
21
|
};
|
|
22
22
|
type ApproveArgs = record {
|
|
23
23
|
fee : opt nat;
|
|
24
|
-
memo : opt
|
|
25
|
-
from_subaccount : opt
|
|
26
|
-
created_at_time : opt
|
|
24
|
+
memo : opt blob;
|
|
25
|
+
from_subaccount : opt blob;
|
|
26
|
+
created_at_time : opt Timestamp;
|
|
27
27
|
amount : nat;
|
|
28
28
|
expected_allowance : opt nat;
|
|
29
|
-
expires_at : opt
|
|
29
|
+
expires_at : opt Timestamp;
|
|
30
30
|
spender : Account;
|
|
31
31
|
};
|
|
32
32
|
type ApproveError = variant {
|
|
33
33
|
GenericError : record { message : text; error_code : nat };
|
|
34
34
|
TemporarilyUnavailable;
|
|
35
|
-
Duplicate : record { duplicate_of :
|
|
35
|
+
Duplicate : record { duplicate_of : BlockIndex };
|
|
36
36
|
BadFee : record { expected_fee : nat };
|
|
37
37
|
AllowanceChanged : record { current_allowance : nat };
|
|
38
|
-
CreatedInFuture : record { ledger_time :
|
|
38
|
+
CreatedInFuture : record { ledger_time : Timestamp };
|
|
39
39
|
TooOld;
|
|
40
|
-
Expired : record { ledger_time :
|
|
40
|
+
Expired : record { ledger_time : Timestamp };
|
|
41
41
|
InsufficientFunds : record { balance : nat };
|
|
42
42
|
};
|
|
43
|
-
type ApproveResult = variant { Ok :
|
|
43
|
+
type ApproveResult = variant { Ok : BlockIndex; Err : ApproveError };
|
|
44
44
|
|
|
45
45
|
type HttpRequest = record {
|
|
46
46
|
url : text;
|
|
47
47
|
method : text;
|
|
48
|
-
body :
|
|
48
|
+
body : blob;
|
|
49
49
|
headers : vec record { text; text };
|
|
50
50
|
};
|
|
51
51
|
type HttpResponse = record {
|
|
52
|
-
body :
|
|
52
|
+
body : blob;
|
|
53
53
|
headers : vec record { text; text };
|
|
54
54
|
status_code : nat16;
|
|
55
55
|
};
|
|
@@ -73,7 +73,7 @@ type TransferError = variant {
|
|
|
73
73
|
BadBurn : record { min_burn_amount : Tokens };
|
|
74
74
|
InsufficientFunds : record { balance : Tokens };
|
|
75
75
|
TooOld;
|
|
76
|
-
CreatedInFuture : record { ledger_time :
|
|
76
|
+
CreatedInFuture : record { ledger_time : Timestamp };
|
|
77
77
|
TemporarilyUnavailable;
|
|
78
78
|
Duplicate : record { duplicate_of : BlockIndex };
|
|
79
79
|
GenericError : record { error_code : nat; message : text };
|
|
@@ -214,22 +214,22 @@ type Transaction = record {
|
|
|
214
214
|
kind : text;
|
|
215
215
|
mint : opt Mint;
|
|
216
216
|
approve : opt Approve;
|
|
217
|
-
timestamp :
|
|
217
|
+
timestamp : Timestamp;
|
|
218
218
|
transfer : opt Transfer;
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
type Burn = record {
|
|
222
222
|
from : Account;
|
|
223
|
-
memo : opt
|
|
224
|
-
created_at_time : opt
|
|
223
|
+
memo : opt blob;
|
|
224
|
+
created_at_time : opt Timestamp;
|
|
225
225
|
amount : nat;
|
|
226
226
|
spender : opt Account;
|
|
227
227
|
};
|
|
228
228
|
|
|
229
229
|
type Mint = record {
|
|
230
230
|
to : Account;
|
|
231
|
-
memo : opt
|
|
232
|
-
created_at_time : opt
|
|
231
|
+
memo : opt blob;
|
|
232
|
+
created_at_time : opt Timestamp;
|
|
233
233
|
amount : nat;
|
|
234
234
|
};
|
|
235
235
|
|
|
@@ -237,8 +237,8 @@ type Transfer = record {
|
|
|
237
237
|
to : Account;
|
|
238
238
|
fee : opt nat;
|
|
239
239
|
from : Account;
|
|
240
|
-
memo : opt
|
|
241
|
-
created_at_time : opt
|
|
240
|
+
memo : opt blob;
|
|
241
|
+
created_at_time : opt Timestamp;
|
|
242
242
|
amount : nat;
|
|
243
243
|
spender : opt Account;
|
|
244
244
|
};
|
|
@@ -352,7 +352,7 @@ type TransferFromError = variant {
|
|
|
352
352
|
InsufficientFunds : record { balance : Tokens };
|
|
353
353
|
InsufficientAllowance : record { allowance : Tokens };
|
|
354
354
|
TooOld;
|
|
355
|
-
CreatedInFuture : record { ledger_time :
|
|
355
|
+
CreatedInFuture : record { ledger_time : Timestamp };
|
|
356
356
|
Duplicate : record { duplicate_of : BlockIndex };
|
|
357
357
|
TemporarilyUnavailable;
|
|
358
358
|
GenericError : record { error_code : nat; message : text };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */
|
|
2
2
|
export const idlFactory = ({ IDL }) => {
|
|
3
3
|
const Value = IDL.Rec();
|
|
4
4
|
const MetadataValue = IDL.Variant({
|
|
@@ -101,27 +101,28 @@ export const idlFactory = ({ IDL }) => {
|
|
|
101
101
|
'start' : TxIndex,
|
|
102
102
|
'length' : IDL.Nat,
|
|
103
103
|
});
|
|
104
|
+
const Timestamp = IDL.Nat64;
|
|
104
105
|
const Burn = IDL.Record({
|
|
105
106
|
'from' : Account,
|
|
106
107
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
107
|
-
'created_at_time' : IDL.Opt(
|
|
108
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
108
109
|
'amount' : IDL.Nat,
|
|
109
110
|
'spender' : IDL.Opt(Account),
|
|
110
111
|
});
|
|
111
112
|
const Mint = IDL.Record({
|
|
112
113
|
'to' : Account,
|
|
113
114
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
114
|
-
'created_at_time' : IDL.Opt(
|
|
115
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
115
116
|
'amount' : IDL.Nat,
|
|
116
117
|
});
|
|
117
118
|
const Approve = IDL.Record({
|
|
118
119
|
'fee' : IDL.Opt(IDL.Nat),
|
|
119
120
|
'from' : Account,
|
|
120
121
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
121
|
-
'created_at_time' : IDL.Opt(
|
|
122
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
122
123
|
'amount' : IDL.Nat,
|
|
123
124
|
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
124
|
-
'expires_at' : IDL.Opt(
|
|
125
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
125
126
|
'spender' : Account,
|
|
126
127
|
});
|
|
127
128
|
const Transfer = IDL.Record({
|
|
@@ -129,7 +130,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
129
130
|
'fee' : IDL.Opt(IDL.Nat),
|
|
130
131
|
'from' : Account,
|
|
131
132
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
132
|
-
'created_at_time' : IDL.Opt(
|
|
133
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
133
134
|
'amount' : IDL.Nat,
|
|
134
135
|
'spender' : IDL.Opt(Account),
|
|
135
136
|
});
|
|
@@ -138,7 +139,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
138
139
|
'kind' : IDL.Text,
|
|
139
140
|
'mint' : IDL.Opt(Mint),
|
|
140
141
|
'approve' : IDL.Opt(Approve),
|
|
141
|
-
'timestamp' :
|
|
142
|
+
'timestamp' : Timestamp,
|
|
142
143
|
'transfer' : IDL.Opt(Transfer),
|
|
143
144
|
});
|
|
144
145
|
const TransactionRange = IDL.Record({
|
|
@@ -163,7 +164,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
163
164
|
});
|
|
164
165
|
const Tokens = IDL.Nat;
|
|
165
166
|
const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });
|
|
166
|
-
const Timestamp = IDL.Nat64;
|
|
167
167
|
const TransferArg = IDL.Record({
|
|
168
168
|
'to' : Account,
|
|
169
169
|
'fee' : IDL.Opt(Tokens),
|
|
@@ -181,7 +181,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
181
181
|
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
182
182
|
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
183
183
|
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
184
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
184
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
185
185
|
'TooOld' : IDL.Null,
|
|
186
186
|
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
187
187
|
});
|
|
@@ -195,16 +195,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
195
195
|
});
|
|
196
196
|
const Allowance = IDL.Record({
|
|
197
197
|
'allowance' : IDL.Nat,
|
|
198
|
-
'expires_at' : IDL.Opt(
|
|
198
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
199
199
|
});
|
|
200
200
|
const ApproveArgs = IDL.Record({
|
|
201
201
|
'fee' : IDL.Opt(IDL.Nat),
|
|
202
202
|
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
203
203
|
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
204
|
-
'created_at_time' : IDL.Opt(
|
|
204
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
205
205
|
'amount' : IDL.Nat,
|
|
206
206
|
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
207
|
-
'expires_at' : IDL.Opt(
|
|
207
|
+
'expires_at' : IDL.Opt(Timestamp),
|
|
208
208
|
'spender' : Account,
|
|
209
209
|
});
|
|
210
210
|
const ApproveError = IDL.Variant({
|
|
@@ -213,15 +213,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
213
213
|
'error_code' : IDL.Nat,
|
|
214
214
|
}),
|
|
215
215
|
'TemporarilyUnavailable' : IDL.Null,
|
|
216
|
-
'Duplicate' : IDL.Record({ 'duplicate_of' :
|
|
216
|
+
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
217
217
|
'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),
|
|
218
218
|
'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),
|
|
219
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
219
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
220
220
|
'TooOld' : IDL.Null,
|
|
221
|
-
'Expired' : IDL.Record({ 'ledger_time' :
|
|
221
|
+
'Expired' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
222
222
|
'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),
|
|
223
223
|
});
|
|
224
|
-
const ApproveResult = IDL.Variant({
|
|
224
|
+
const ApproveResult = IDL.Variant({
|
|
225
|
+
'Ok' : BlockIndex,
|
|
226
|
+
'Err' : ApproveError,
|
|
227
|
+
});
|
|
225
228
|
const TransferFromArgs = IDL.Record({
|
|
226
229
|
'to' : Account,
|
|
227
230
|
'fee' : IDL.Opt(Tokens),
|
|
@@ -241,7 +244,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
241
244
|
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
242
245
|
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
243
246
|
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
244
|
-
'CreatedInFuture' : IDL.Record({ 'ledger_time' :
|
|
247
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),
|
|
245
248
|
'TooOld' : IDL.Null,
|
|
246
249
|
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
247
250
|
});
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +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});
|
|
1
|
+
"use strict";var I=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ut=(t,a)=>{for(var c in a)I(t,c,{get:a[c],enumerable:!0})},_t=(t,a,c,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of mt(a))!dt.call(t,e)&&e!==c&&I(t,e,{get:()=>a[e],enumerable:!(r=lt(a,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:()=>x,IndexError:()=>b,decodeIcrcAccount:()=>gt,decodePayment:()=>xt,encodeIcrcAccount:()=>Tt});module.exports=ft(Rt);var b=class extends Error{};var x=class extends Error{constructor({msg:c,errorType:r}){super(c);this.errorType=r}};var h=require("@dfinity/utils");var tt=({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}),s=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}),f=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}),N=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(s),kind:t.Text,mint:t.Opt(p),approve:t.Opt(f),timestamp:t.Nat64,transfer:t.Opt(N)}),i=t.Record({id:c,transaction:y}),d=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(c)}),O=t.Record({message:t.Text}),u=t.Variant({Ok:d,Err:O}),_=t.Vec(t.Nat8),T=t.Record({owner:t.Principal,start:t.Opt(_)});return t.Service({get_account_transactions:t.Func([e],[u],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([T],[t.Vec(_)],[])})};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}),s=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}),f=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}),N=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(s),kind:t.Text,mint:t.Opt(p),approve:t.Opt(f),timestamp:t.Nat64,transfer:t.Opt(N)}),i=t.Record({id:c,transaction:y}),d=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(c)}),O=t.Record({message:t.Text}),u=t.Variant({Ok:d,Err:O}),_=t.Vec(t.Nat8),T=t.Record({owner:t.Principal,start:t.Opt(_)});return t.Service({get_account_transactions:t.Func([e],[u],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([T],[t.Vec(_)],["query"])})};var L=require("@dfinity/utils"),Nt=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,L.toNullable)(a)}),rt=({account:t,max_results:a,start:c})=>({account:Nt(t),max_results:a,start:(0,L.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(rt(c));if("Err"in r)throw new b(r.Err.message);return r.Ok}}static create(c){let{service:r,certifiedService:e,canisterId:s}=(0,h.createServices)({options:c,idlFactory:et,certifiedIdlFactory:tt});return new t(s,r,e)}};var R=require("@dfinity/utils");var ct=({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)}),s=t.Variant({SetTo:e,Unset:t.Null}),p=t.Record({icrc2:t.Bool}),f=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(s),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),N=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(f),Init:N}),i=t.Nat,d=t.Record({start:i,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 u=a,_=t.Record({blocks:t.Vec(u)}),T=t.Func([d],[_],[]),w=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(u),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:T,start:i,length:t.Nat}))}),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),g=t.Nat,A=t.Record({start:g,length:t.Nat}),o=t.Nat64,B=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),E=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),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(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),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(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(B),kind:t.Text,mint:t.Opt(E),approve:t.Opt(S),timestamp:o,transfer:t.Opt(G)}),C=t.Record({transactions:t.Vec(V)}),q=t.Func([A],[C],[]),U=t.Record({first_index:g,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:q,start:g,length:t.Nat}))}),n=t.Nat,M=t.Record({url:t.Text,name:t.Text}),z=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}),Q=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:i}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),H=t.Variant({Ok:i,Err:Q}),W=t.Record({account:e,spender:e}),Z=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),$=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}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:i}),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})}),j=t.Variant({Ok:i,Err:X}),Y=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}),J=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:i}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),K=t.Variant({Ok:i,Err:J});return t.Service({get_blocks:t.Func([d],[w],[]),get_data_certificate:t.Func([],[P],[]),get_transactions:t.Func([A],[U],[]),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(M)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[n],[]),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 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)}),s=t.Variant({SetTo:e,Unset:t.Null}),p=t.Record({icrc2:t.Bool}),f=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(s),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),N=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(f),Init:N}),i=t.Nat,d=t.Record({start:i,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 u=a,_=t.Record({blocks:t.Vec(u)}),T=t.Func([d],[_],["query"]),w=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(u),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:T,start:i,length:t.Nat}))}),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),g=t.Nat,A=t.Record({start:g,length:t.Nat}),o=t.Nat64,B=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),E=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),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(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),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(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(B),kind:t.Text,mint:t.Opt(E),approve:t.Opt(S),timestamp:o,transfer:t.Opt(G)}),C=t.Record({transactions:t.Vec(V)}),q=t.Func([A],[C],["query"]),U=t.Record({first_index:g,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:q,start:g,length:t.Nat}))}),n=t.Nat,M=t.Record({url:t.Text,name:t.Text}),z=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}),Q=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:i}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),H=t.Variant({Ok:i,Err:Q}),W=t.Record({account:e,spender:e}),Z=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),$=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}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:i}),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})}),j=t.Variant({Ok:i,Err:X}),Y=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}),J=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:i}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),K=t.Variant({Ok:i,Err:J});return t.Service({get_blocks:t.Func([d],[w],["query"]),get_data_certificate:t.Func([],[P],["query"]),get_transactions:t.Func([A],[U],["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(M)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[n],["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 l=require("@dfinity/utils"),ot=({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)}),nt=({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)}),st=({fee:t,created_at_time:a,memo:c,from_subaccount:r,expected_allowance:e,expires_at:s,...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)(s)});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(ot(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(nt(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(st(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:s}=(0,R.createServices)({options:c,idlFactory:at,certifiedIdlFactory:ct});return new t(s,r,e)}};var it=(s=>(s.SYMBOL="icrc1:symbol",s.NAME="icrc1:name",s.DECIMALS="icrc1:decimals",s.FEE="icrc1:fee",s.LOGO="icrc1:logo",s))(it||{});var D=require("@dfinity/principal"),m=require("@dfinity/utils"),Ot=64,Tt=({owner:t,subaccount:a})=>{if((0,m.isNullish)(a))return t.toText();let r=(e=>e.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(a));return r.length===0?t.toText():`${t.toText()}-${pt({owner:t,subaccount:a})}.${r}`},pt=({owner:t,subaccount:a})=>{let c=(0,m.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,m.encodeBase32)(c)},gt=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:D.Principal.fromText(t)};let[r,...e]=a.split("-").reverse(),s=e.reverse().join("-"),p={owner:D.Principal.fromText(s),subaccount:(0,m.hexStringToUint8Array)(c.padStart(Ot,"0"))};if(pt(p)!==r)throw new Error("Invalid account. Invalid checksum.");return p};var k=require("@dfinity/utils"),xt=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,s,p]=c;return{token:e,identifier:s,...(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
|