@dfinity/ledger-icrc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +291 -0
- package/dist/candid/icrc_index.certified.idl.d.ts +2 -0
- package/dist/candid/icrc_index.certified.idl.js +89 -0
- package/dist/candid/icrc_index.d.ts +83 -0
- package/dist/candid/icrc_index.did +97 -0
- package/dist/candid/icrc_index.idl.d.ts +2 -0
- package/dist/candid/icrc_index.idl.js +89 -0
- package/dist/candid/icrc_ledger.certified.idl.d.ts +2 -0
- package/dist/candid/icrc_ledger.certified.idl.js +335 -0
- package/dist/candid/icrc_ledger.d.ts +262 -0
- package/dist/candid/icrc_ledger.did +380 -0
- package/dist/candid/icrc_ledger.idl.d.ts +2 -0
- package/dist/candid/icrc_ledger.idl.js +343 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +7 -0
- package/dist/esm/chunk-XVPR4TJN.js +2 -0
- package/dist/esm/chunk-XVPR4TJN.js.map +7 -0
- package/dist/esm/chunk-Y76HDAJ2.js +2 -0
- package/dist/esm/chunk-Y76HDAJ2.js.map +7 -0
- package/dist/esm/index.canister.js +2 -0
- package/dist/esm/index.canister.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/ledger.canister.js +2 -0
- package/dist/esm/ledger.canister.js.map +7 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/converters/index.converters.d.ts +3 -0
- package/dist/types/converters/ledger.converters.d.ts +5 -0
- package/dist/types/errors/index.errors.d.ts +2 -0
- package/dist/types/errors/ledger.errors.d.ts +7 -0
- package/dist/types/index.canister.d.ts +16 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/ledger.canister.d.ts +68 -0
- package/dist/types/types/canister.options.d.ts +5 -0
- package/dist/types/types/index.params.d.ts +7 -0
- package/dist/types/types/ledger.params.d.ts +63 -0
- package/dist/types/types/ledger.responses.d.ts +17 -0
- package/dist/types/utils/ledger.utils.d.ts +18 -0
- package/dist/types/utils/payment.utils.d.ts +28 -0
- package/package.json +45 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Generated from IC repo commit d2331ec4b3c60f408b876427d7238ec15fb16ad5 'rs/rosetta-api/icrc1/index/index.did' by import-candid
|
|
2
|
+
type TxId = nat;
|
|
3
|
+
|
|
4
|
+
type Account = record { owner : principal; subaccount : opt blob };
|
|
5
|
+
|
|
6
|
+
type SubAccount = blob;
|
|
7
|
+
|
|
8
|
+
type Transaction = record {
|
|
9
|
+
burn : opt Burn;
|
|
10
|
+
kind : text;
|
|
11
|
+
mint : opt Mint;
|
|
12
|
+
approve : opt Approve;
|
|
13
|
+
timestamp : nat64;
|
|
14
|
+
transfer : opt Transfer;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type Approve = record {
|
|
18
|
+
fee : opt nat;
|
|
19
|
+
from : Account;
|
|
20
|
+
memo : opt vec nat8;
|
|
21
|
+
created_at_time : opt nat64;
|
|
22
|
+
amount : nat;
|
|
23
|
+
expected_allowance : opt nat;
|
|
24
|
+
expires_at : opt nat64;
|
|
25
|
+
spender : Account;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type Burn = record {
|
|
29
|
+
from : Account;
|
|
30
|
+
memo : opt vec nat8;
|
|
31
|
+
created_at_time : opt nat64;
|
|
32
|
+
amount : nat;
|
|
33
|
+
spender : opt Account;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type Mint = record {
|
|
37
|
+
to : Account;
|
|
38
|
+
memo : opt vec nat8;
|
|
39
|
+
created_at_time : opt nat64;
|
|
40
|
+
amount : nat;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type Transfer = record {
|
|
44
|
+
to : Account;
|
|
45
|
+
fee : opt nat;
|
|
46
|
+
from : Account;
|
|
47
|
+
memo : opt vec nat8;
|
|
48
|
+
created_at_time : opt nat64;
|
|
49
|
+
amount : nat;
|
|
50
|
+
spender : opt Account;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type GetAccountTransactionsArgs = record {
|
|
54
|
+
account : Account;
|
|
55
|
+
// The txid of the last transaction seen by the client.
|
|
56
|
+
// If None then the results will start from the most recent
|
|
57
|
+
// txid.
|
|
58
|
+
start : opt TxId;
|
|
59
|
+
// Maximum number of transactions to fetch.
|
|
60
|
+
max_results : nat;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type TransactionWithId = record {
|
|
64
|
+
id : TxId;
|
|
65
|
+
transaction : Transaction;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type GetTransactions = record {
|
|
69
|
+
transactions : vec TransactionWithId;
|
|
70
|
+
// The txid of the oldest transaction the account has
|
|
71
|
+
oldest_tx_id : opt TxId;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type GetTransactionsErr = record {
|
|
75
|
+
message : text;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type GetTransactionsResult = variant {
|
|
79
|
+
Ok : GetTransactions;
|
|
80
|
+
Err : GetTransactionsErr;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
type ListSubaccountsArgs = record {
|
|
84
|
+
owner: principal;
|
|
85
|
+
start: opt SubAccount;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// The initialization parameters of the Index canister.
|
|
89
|
+
type InitArgs = record {
|
|
90
|
+
ledger_id : principal;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
service : (InitArgs) -> {
|
|
94
|
+
get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult);
|
|
95
|
+
ledger_id : () -> (principal) query;
|
|
96
|
+
list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
|
|
97
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_index.did */
|
|
2
|
+
export const idlFactory = ({ IDL }) => {
|
|
3
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
4
|
+
const TxId = IDL.Nat;
|
|
5
|
+
const Account = IDL.Record({
|
|
6
|
+
'owner' : IDL.Principal,
|
|
7
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
8
|
+
});
|
|
9
|
+
const GetAccountTransactionsArgs = IDL.Record({
|
|
10
|
+
'max_results' : IDL.Nat,
|
|
11
|
+
'start' : IDL.Opt(TxId),
|
|
12
|
+
'account' : Account,
|
|
13
|
+
});
|
|
14
|
+
const Burn = IDL.Record({
|
|
15
|
+
'from' : Account,
|
|
16
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
17
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
18
|
+
'amount' : IDL.Nat,
|
|
19
|
+
'spender' : IDL.Opt(Account),
|
|
20
|
+
});
|
|
21
|
+
const Mint = IDL.Record({
|
|
22
|
+
'to' : Account,
|
|
23
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
24
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
25
|
+
'amount' : IDL.Nat,
|
|
26
|
+
});
|
|
27
|
+
const Approve = IDL.Record({
|
|
28
|
+
'fee' : IDL.Opt(IDL.Nat),
|
|
29
|
+
'from' : Account,
|
|
30
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
31
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
32
|
+
'amount' : IDL.Nat,
|
|
33
|
+
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
34
|
+
'expires_at' : IDL.Opt(IDL.Nat64),
|
|
35
|
+
'spender' : Account,
|
|
36
|
+
});
|
|
37
|
+
const Transfer = IDL.Record({
|
|
38
|
+
'to' : Account,
|
|
39
|
+
'fee' : IDL.Opt(IDL.Nat),
|
|
40
|
+
'from' : Account,
|
|
41
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
42
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
43
|
+
'amount' : IDL.Nat,
|
|
44
|
+
'spender' : IDL.Opt(Account),
|
|
45
|
+
});
|
|
46
|
+
const Transaction = IDL.Record({
|
|
47
|
+
'burn' : IDL.Opt(Burn),
|
|
48
|
+
'kind' : IDL.Text,
|
|
49
|
+
'mint' : IDL.Opt(Mint),
|
|
50
|
+
'approve' : IDL.Opt(Approve),
|
|
51
|
+
'timestamp' : IDL.Nat64,
|
|
52
|
+
'transfer' : IDL.Opt(Transfer),
|
|
53
|
+
});
|
|
54
|
+
const TransactionWithId = IDL.Record({
|
|
55
|
+
'id' : TxId,
|
|
56
|
+
'transaction' : Transaction,
|
|
57
|
+
});
|
|
58
|
+
const GetTransactions = IDL.Record({
|
|
59
|
+
'transactions' : IDL.Vec(TransactionWithId),
|
|
60
|
+
'oldest_tx_id' : IDL.Opt(TxId),
|
|
61
|
+
});
|
|
62
|
+
const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
|
|
63
|
+
const GetTransactionsResult = IDL.Variant({
|
|
64
|
+
'Ok' : GetTransactions,
|
|
65
|
+
'Err' : GetTransactionsErr,
|
|
66
|
+
});
|
|
67
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
68
|
+
const ListSubaccountsArgs = IDL.Record({
|
|
69
|
+
'owner' : IDL.Principal,
|
|
70
|
+
'start' : IDL.Opt(SubAccount),
|
|
71
|
+
});
|
|
72
|
+
return IDL.Service({
|
|
73
|
+
'get_account_transactions' : IDL.Func(
|
|
74
|
+
[GetAccountTransactionsArgs],
|
|
75
|
+
[GetTransactionsResult],
|
|
76
|
+
[],
|
|
77
|
+
),
|
|
78
|
+
'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),
|
|
79
|
+
'list_subaccounts' : IDL.Func(
|
|
80
|
+
[ListSubaccountsArgs],
|
|
81
|
+
[IDL.Vec(SubAccount)],
|
|
82
|
+
['query'],
|
|
83
|
+
),
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export const init = ({ IDL }) => {
|
|
87
|
+
const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
|
|
88
|
+
return [InitArgs];
|
|
89
|
+
};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger/candid/icrc1_ledger.did */
|
|
2
|
+
export const idlFactory = ({ IDL }) => {
|
|
3
|
+
const Value = IDL.Rec();
|
|
4
|
+
const MetadataValue = IDL.Variant({
|
|
5
|
+
'Int' : IDL.Int,
|
|
6
|
+
'Nat' : IDL.Nat,
|
|
7
|
+
'Blob' : IDL.Vec(IDL.Nat8),
|
|
8
|
+
'Text' : IDL.Text,
|
|
9
|
+
});
|
|
10
|
+
const Subaccount = IDL.Vec(IDL.Nat8);
|
|
11
|
+
const Account = IDL.Record({
|
|
12
|
+
'owner' : IDL.Principal,
|
|
13
|
+
'subaccount' : IDL.Opt(Subaccount),
|
|
14
|
+
});
|
|
15
|
+
const ChangeFeeCollector = IDL.Variant({
|
|
16
|
+
'SetTo' : Account,
|
|
17
|
+
'Unset' : IDL.Null,
|
|
18
|
+
});
|
|
19
|
+
const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
|
|
20
|
+
const UpgradeArgs = IDL.Record({
|
|
21
|
+
'token_symbol' : IDL.Opt(IDL.Text),
|
|
22
|
+
'transfer_fee' : IDL.Opt(IDL.Nat),
|
|
23
|
+
'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
|
|
24
|
+
'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
|
|
25
|
+
'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
|
|
26
|
+
'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
|
|
27
|
+
'max_memo_length' : IDL.Opt(IDL.Nat16),
|
|
28
|
+
'token_name' : IDL.Opt(IDL.Text),
|
|
29
|
+
'feature_flags' : IDL.Opt(FeatureFlags),
|
|
30
|
+
});
|
|
31
|
+
const InitArgs = IDL.Record({
|
|
32
|
+
'decimals' : IDL.Opt(IDL.Nat8),
|
|
33
|
+
'token_symbol' : IDL.Text,
|
|
34
|
+
'transfer_fee' : IDL.Nat,
|
|
35
|
+
'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),
|
|
36
|
+
'minting_account' : Account,
|
|
37
|
+
'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),
|
|
38
|
+
'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
|
|
39
|
+
'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
|
|
40
|
+
'fee_collector_account' : IDL.Opt(Account),
|
|
41
|
+
'archive_options' : IDL.Record({
|
|
42
|
+
'num_blocks_to_archive' : IDL.Nat64,
|
|
43
|
+
'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
|
|
44
|
+
'trigger_threshold' : IDL.Nat64,
|
|
45
|
+
'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
|
|
46
|
+
'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
|
|
47
|
+
'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
|
|
48
|
+
'controller_id' : IDL.Principal,
|
|
49
|
+
}),
|
|
50
|
+
'max_memo_length' : IDL.Opt(IDL.Nat16),
|
|
51
|
+
'token_name' : IDL.Text,
|
|
52
|
+
'feature_flags' : IDL.Opt(FeatureFlags),
|
|
53
|
+
});
|
|
54
|
+
const LedgerArg = IDL.Variant({
|
|
55
|
+
'Upgrade' : IDL.Opt(UpgradeArgs),
|
|
56
|
+
'Init' : InitArgs,
|
|
57
|
+
});
|
|
58
|
+
const BlockIndex = IDL.Nat;
|
|
59
|
+
const GetBlocksArgs = IDL.Record({
|
|
60
|
+
'start' : BlockIndex,
|
|
61
|
+
'length' : IDL.Nat,
|
|
62
|
+
});
|
|
63
|
+
const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
|
|
64
|
+
Value.fill(
|
|
65
|
+
IDL.Variant({
|
|
66
|
+
'Int' : IDL.Int,
|
|
67
|
+
'Map' : Map,
|
|
68
|
+
'Nat' : IDL.Nat,
|
|
69
|
+
'Nat64' : IDL.Nat64,
|
|
70
|
+
'Blob' : IDL.Vec(IDL.Nat8),
|
|
71
|
+
'Text' : IDL.Text,
|
|
72
|
+
'Array' : IDL.Vec(Value),
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
const Block = Value;
|
|
76
|
+
const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });
|
|
77
|
+
const QueryBlockArchiveFn = IDL.Func([GetBlocksArgs], [BlockRange], []);
|
|
78
|
+
const GetBlocksResponse = IDL.Record({
|
|
79
|
+
'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
80
|
+
'first_index' : BlockIndex,
|
|
81
|
+
'blocks' : IDL.Vec(Block),
|
|
82
|
+
'chain_length' : IDL.Nat64,
|
|
83
|
+
'archived_blocks' : IDL.Vec(
|
|
84
|
+
IDL.Record({
|
|
85
|
+
'callback' : QueryBlockArchiveFn,
|
|
86
|
+
'start' : BlockIndex,
|
|
87
|
+
'length' : IDL.Nat,
|
|
88
|
+
})
|
|
89
|
+
),
|
|
90
|
+
});
|
|
91
|
+
const DataCertificate = IDL.Record({
|
|
92
|
+
'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
93
|
+
'hash_tree' : IDL.Vec(IDL.Nat8),
|
|
94
|
+
});
|
|
95
|
+
const TxIndex = IDL.Nat;
|
|
96
|
+
const GetTransactionsRequest = IDL.Record({
|
|
97
|
+
'start' : TxIndex,
|
|
98
|
+
'length' : IDL.Nat,
|
|
99
|
+
});
|
|
100
|
+
const Burn = IDL.Record({
|
|
101
|
+
'from' : Account,
|
|
102
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
103
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
104
|
+
'amount' : IDL.Nat,
|
|
105
|
+
'spender' : IDL.Opt(Account),
|
|
106
|
+
});
|
|
107
|
+
const Mint = IDL.Record({
|
|
108
|
+
'to' : Account,
|
|
109
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
110
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
111
|
+
'amount' : IDL.Nat,
|
|
112
|
+
});
|
|
113
|
+
const Approve = IDL.Record({
|
|
114
|
+
'fee' : IDL.Opt(IDL.Nat),
|
|
115
|
+
'from' : Account,
|
|
116
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
117
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
118
|
+
'amount' : IDL.Nat,
|
|
119
|
+
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
120
|
+
'expires_at' : IDL.Opt(IDL.Nat64),
|
|
121
|
+
'spender' : Account,
|
|
122
|
+
});
|
|
123
|
+
const Transfer = IDL.Record({
|
|
124
|
+
'to' : Account,
|
|
125
|
+
'fee' : IDL.Opt(IDL.Nat),
|
|
126
|
+
'from' : Account,
|
|
127
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
128
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
129
|
+
'amount' : IDL.Nat,
|
|
130
|
+
'spender' : IDL.Opt(Account),
|
|
131
|
+
});
|
|
132
|
+
const Transaction = IDL.Record({
|
|
133
|
+
'burn' : IDL.Opt(Burn),
|
|
134
|
+
'kind' : IDL.Text,
|
|
135
|
+
'mint' : IDL.Opt(Mint),
|
|
136
|
+
'approve' : IDL.Opt(Approve),
|
|
137
|
+
'timestamp' : IDL.Nat64,
|
|
138
|
+
'transfer' : IDL.Opt(Transfer),
|
|
139
|
+
});
|
|
140
|
+
const TransactionRange = IDL.Record({
|
|
141
|
+
'transactions' : IDL.Vec(Transaction),
|
|
142
|
+
});
|
|
143
|
+
const QueryArchiveFn = IDL.Func(
|
|
144
|
+
[GetTransactionsRequest],
|
|
145
|
+
[TransactionRange],
|
|
146
|
+
[],
|
|
147
|
+
);
|
|
148
|
+
const GetTransactionsResponse = IDL.Record({
|
|
149
|
+
'first_index' : TxIndex,
|
|
150
|
+
'log_length' : IDL.Nat,
|
|
151
|
+
'transactions' : IDL.Vec(Transaction),
|
|
152
|
+
'archived_transactions' : IDL.Vec(
|
|
153
|
+
IDL.Record({
|
|
154
|
+
'callback' : QueryArchiveFn,
|
|
155
|
+
'start' : TxIndex,
|
|
156
|
+
'length' : IDL.Nat,
|
|
157
|
+
})
|
|
158
|
+
),
|
|
159
|
+
});
|
|
160
|
+
const Tokens = IDL.Nat;
|
|
161
|
+
const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });
|
|
162
|
+
const Timestamp = IDL.Nat64;
|
|
163
|
+
const TransferArg = IDL.Record({
|
|
164
|
+
'to' : Account,
|
|
165
|
+
'fee' : IDL.Opt(Tokens),
|
|
166
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
167
|
+
'from_subaccount' : IDL.Opt(Subaccount),
|
|
168
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
169
|
+
'amount' : Tokens,
|
|
170
|
+
});
|
|
171
|
+
const TransferError = IDL.Variant({
|
|
172
|
+
'GenericError' : IDL.Record({
|
|
173
|
+
'message' : IDL.Text,
|
|
174
|
+
'error_code' : IDL.Nat,
|
|
175
|
+
}),
|
|
176
|
+
'TemporarilyUnavailable' : IDL.Null,
|
|
177
|
+
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
178
|
+
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
179
|
+
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
180
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
|
|
181
|
+
'TooOld' : IDL.Null,
|
|
182
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
183
|
+
});
|
|
184
|
+
const TransferResult = IDL.Variant({
|
|
185
|
+
'Ok' : BlockIndex,
|
|
186
|
+
'Err' : TransferError,
|
|
187
|
+
});
|
|
188
|
+
const AllowanceArgs = IDL.Record({
|
|
189
|
+
'account' : Account,
|
|
190
|
+
'spender' : Account,
|
|
191
|
+
});
|
|
192
|
+
const Allowance = IDL.Record({
|
|
193
|
+
'allowance' : IDL.Nat,
|
|
194
|
+
'expires_at' : IDL.Opt(IDL.Nat64),
|
|
195
|
+
});
|
|
196
|
+
const ApproveArgs = IDL.Record({
|
|
197
|
+
'fee' : IDL.Opt(IDL.Nat),
|
|
198
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
199
|
+
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
200
|
+
'created_at_time' : IDL.Opt(IDL.Nat64),
|
|
201
|
+
'amount' : IDL.Nat,
|
|
202
|
+
'expected_allowance' : IDL.Opt(IDL.Nat),
|
|
203
|
+
'expires_at' : IDL.Opt(IDL.Nat64),
|
|
204
|
+
'spender' : Account,
|
|
205
|
+
});
|
|
206
|
+
const ApproveError = IDL.Variant({
|
|
207
|
+
'GenericError' : IDL.Record({
|
|
208
|
+
'message' : IDL.Text,
|
|
209
|
+
'error_code' : IDL.Nat,
|
|
210
|
+
}),
|
|
211
|
+
'TemporarilyUnavailable' : IDL.Null,
|
|
212
|
+
'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }),
|
|
213
|
+
'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),
|
|
214
|
+
'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),
|
|
215
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
|
|
216
|
+
'TooOld' : IDL.Null,
|
|
217
|
+
'Expired' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
|
|
218
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),
|
|
219
|
+
});
|
|
220
|
+
const ApproveResult = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : ApproveError });
|
|
221
|
+
const TransferFromArgs = IDL.Record({
|
|
222
|
+
'to' : Account,
|
|
223
|
+
'fee' : IDL.Opt(Tokens),
|
|
224
|
+
'spender_subaccount' : IDL.Opt(Subaccount),
|
|
225
|
+
'from' : Account,
|
|
226
|
+
'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
227
|
+
'created_at_time' : IDL.Opt(Timestamp),
|
|
228
|
+
'amount' : Tokens,
|
|
229
|
+
});
|
|
230
|
+
const TransferFromError = IDL.Variant({
|
|
231
|
+
'GenericError' : IDL.Record({
|
|
232
|
+
'message' : IDL.Text,
|
|
233
|
+
'error_code' : IDL.Nat,
|
|
234
|
+
}),
|
|
235
|
+
'TemporarilyUnavailable' : IDL.Null,
|
|
236
|
+
'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),
|
|
237
|
+
'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),
|
|
238
|
+
'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
239
|
+
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
240
|
+
'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }),
|
|
241
|
+
'TooOld' : IDL.Null,
|
|
242
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
243
|
+
});
|
|
244
|
+
const TransferFromResult = IDL.Variant({
|
|
245
|
+
'Ok' : BlockIndex,
|
|
246
|
+
'Err' : TransferFromError,
|
|
247
|
+
});
|
|
248
|
+
return IDL.Service({
|
|
249
|
+
'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], []),
|
|
250
|
+
'get_data_certificate' : IDL.Func([], [DataCertificate], []),
|
|
251
|
+
'get_transactions' : IDL.Func(
|
|
252
|
+
[GetTransactionsRequest],
|
|
253
|
+
[GetTransactionsResponse],
|
|
254
|
+
[],
|
|
255
|
+
),
|
|
256
|
+
'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),
|
|
257
|
+
'icrc1_decimals' : IDL.Func([], [IDL.Nat8], []),
|
|
258
|
+
'icrc1_fee' : IDL.Func([], [Tokens], []),
|
|
259
|
+
'icrc1_metadata' : IDL.Func(
|
|
260
|
+
[],
|
|
261
|
+
[IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],
|
|
262
|
+
[],
|
|
263
|
+
),
|
|
264
|
+
'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], []),
|
|
265
|
+
'icrc1_name' : IDL.Func([], [IDL.Text], []),
|
|
266
|
+
'icrc1_supported_standards' : IDL.Func([], [IDL.Vec(StandardRecord)], []),
|
|
267
|
+
'icrc1_symbol' : IDL.Func([], [IDL.Text], []),
|
|
268
|
+
'icrc1_total_supply' : IDL.Func([], [Tokens], []),
|
|
269
|
+
'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),
|
|
270
|
+
'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], []),
|
|
271
|
+
'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),
|
|
272
|
+
'icrc2_transfer_from' : IDL.Func(
|
|
273
|
+
[TransferFromArgs],
|
|
274
|
+
[TransferFromResult],
|
|
275
|
+
[],
|
|
276
|
+
),
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
export const init = ({ IDL }) => {
|
|
280
|
+
const MetadataValue = IDL.Variant({
|
|
281
|
+
'Int' : IDL.Int,
|
|
282
|
+
'Nat' : IDL.Nat,
|
|
283
|
+
'Blob' : IDL.Vec(IDL.Nat8),
|
|
284
|
+
'Text' : IDL.Text,
|
|
285
|
+
});
|
|
286
|
+
const Subaccount = IDL.Vec(IDL.Nat8);
|
|
287
|
+
const Account = IDL.Record({
|
|
288
|
+
'owner' : IDL.Principal,
|
|
289
|
+
'subaccount' : IDL.Opt(Subaccount),
|
|
290
|
+
});
|
|
291
|
+
const ChangeFeeCollector = IDL.Variant({
|
|
292
|
+
'SetTo' : Account,
|
|
293
|
+
'Unset' : IDL.Null,
|
|
294
|
+
});
|
|
295
|
+
const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
|
|
296
|
+
const UpgradeArgs = IDL.Record({
|
|
297
|
+
'token_symbol' : IDL.Opt(IDL.Text),
|
|
298
|
+
'transfer_fee' : IDL.Opt(IDL.Nat),
|
|
299
|
+
'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
|
|
300
|
+
'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
|
|
301
|
+
'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
|
|
302
|
+
'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
|
|
303
|
+
'max_memo_length' : IDL.Opt(IDL.Nat16),
|
|
304
|
+
'token_name' : IDL.Opt(IDL.Text),
|
|
305
|
+
'feature_flags' : IDL.Opt(FeatureFlags),
|
|
306
|
+
});
|
|
307
|
+
const InitArgs = IDL.Record({
|
|
308
|
+
'decimals' : IDL.Opt(IDL.Nat8),
|
|
309
|
+
'token_symbol' : IDL.Text,
|
|
310
|
+
'transfer_fee' : IDL.Nat,
|
|
311
|
+
'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),
|
|
312
|
+
'minting_account' : Account,
|
|
313
|
+
'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),
|
|
314
|
+
'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
|
|
315
|
+
'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
|
|
316
|
+
'fee_collector_account' : IDL.Opt(Account),
|
|
317
|
+
'archive_options' : IDL.Record({
|
|
318
|
+
'num_blocks_to_archive' : IDL.Nat64,
|
|
319
|
+
'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
|
|
320
|
+
'trigger_threshold' : IDL.Nat64,
|
|
321
|
+
'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
|
|
322
|
+
'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
|
|
323
|
+
'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
|
|
324
|
+
'controller_id' : IDL.Principal,
|
|
325
|
+
}),
|
|
326
|
+
'max_memo_length' : IDL.Opt(IDL.Nat16),
|
|
327
|
+
'token_name' : IDL.Text,
|
|
328
|
+
'feature_flags' : IDL.Opt(FeatureFlags),
|
|
329
|
+
});
|
|
330
|
+
const LedgerArg = IDL.Variant({
|
|
331
|
+
'Upgrade' : IDL.Opt(UpgradeArgs),
|
|
332
|
+
'Init' : InitArgs,
|
|
333
|
+
});
|
|
334
|
+
return [LedgerArg];
|
|
335
|
+
};
|