@dfinity/sns 0.0.1-nightly-2022-07-14
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 +5 -0
- package/dist/candid/ledger.certified.idl.d.ts +2 -0
- package/dist/candid/ledger.certified.idl.js +97 -0
- package/dist/candid/ledger.d.ts +106 -0
- package/dist/candid/ledger.did +250 -0
- package/dist/candid/ledger.idl.d.ts +2 -0
- package/dist/candid/ledger.idl.js +109 -0
- package/dist/candid/sns_governance.certified.idl.d.ts +2 -0
- package/dist/candid/sns_governance.certified.idl.js +596 -0
- package/dist/candid/sns_governance.d.ts +366 -0
- package/dist/candid/sns_governance.did +303 -0
- package/dist/candid/sns_governance.idl.d.ts +2 -0
- package/dist/candid/sns_governance.idl.js +600 -0
- package/dist/candid/sns_root.certified.idl.d.ts +2 -0
- package/dist/candid/sns_root.certified.idl.js +34 -0
- package/dist/candid/sns_root.d.ts +28 -0
- package/dist/candid/sns_root.did +26 -0
- package/dist/candid/sns_root.idl.d.ts +2 -0
- package/dist/candid/sns_root.idl.js +34 -0
- package/dist/candid/sns_swap.certified.idl.d.ts +2 -0
- package/dist/candid/sns_swap.certified.idl.js +110 -0
- package/dist/candid/sns_swap.d.ts +81 -0
- package/dist/candid/sns_swap.did +61 -0
- package/dist/candid/sns_swap.idl.d.ts +2 -0
- package/dist/candid/sns_swap.idl.js +110 -0
- package/dist/cjs/index.cjs.js +853 -0
- package/dist/cjs/index.cjs.js.map +7 -0
- package/dist/esm/chunk-7F6PCBCJ.js +2 -0
- package/dist/esm/chunk-7F6PCBCJ.js.map +7 -0
- package/dist/esm/chunk-A576P2ZR.js +2 -0
- package/dist/esm/chunk-A576P2ZR.js.map +7 -0
- package/dist/esm/chunk-LXL5LYD3.js +2 -0
- package/dist/esm/chunk-LXL5LYD3.js.map +7 -0
- package/dist/esm/chunk-RB6XGLR7.js +2 -0
- package/dist/esm/chunk-RB6XGLR7.js.map +7 -0
- package/dist/esm/chunk-VMVMYL6O.js +840 -0
- package/dist/esm/chunk-VMVMYL6O.js.map +7 -0
- package/dist/esm/chunk-WPRZTZWQ.js +2 -0
- package/dist/esm/chunk-WPRZTZWQ.js.map +7 -0
- package/dist/esm/chunk-YKP66JDM.js +2 -0
- package/dist/esm/chunk-YKP66JDM.js.map +7 -0
- package/dist/esm/chunk-YL4WAPXH.js +2 -0
- package/dist/esm/chunk-YL4WAPXH.js.map +7 -0
- package/dist/esm/governance.canister.js +2 -0
- package/dist/esm/governance.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/esm/root.canister.js +2 -0
- package/dist/esm/root.canister.js.map +7 -0
- package/dist/esm/sns.js +2 -0
- package/dist/esm/sns.js.map +7 -0
- package/dist/esm/sns.wrapper.js +2 -0
- package/dist/esm/sns.wrapper.js.map +7 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/constants/governance.constants.d.ts +6 -0
- package/dist/types/governance.canister.d.ts +13 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/ledger.canister.d.ts +6 -0
- package/dist/types/root.canister.d.ts +22 -0
- package/dist/types/services/canister.d.ts +10 -0
- package/dist/types/sns.d.ts +21 -0
- package/dist/types/sns.wrapper.d.ts +43 -0
- package/dist/types/types/canister.options.d.ts +8 -0
- package/dist/types/types/governance.params.d.ts +14 -0
- package/dist/types/types/query.params.d.ts +7 -0
- package/dist/types/utils/actor.utils.d.ts +14 -0
- package/dist/types/utils/agent.utils.d.ts +5 -0
- package/dist/types/utils/asserts.utils.d.ts +3 -0
- package/dist/types/utils/did.utils.d.ts +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 DFINITY LLC.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/sns/candid/ledger.did */
|
|
2
|
+
export const idlFactory = ({ IDL }) => {
|
|
3
|
+
const BlockIndex = IDL.Nat64;
|
|
4
|
+
const GetBlocksArgs = IDL.Record({
|
|
5
|
+
'start' : BlockIndex,
|
|
6
|
+
'length' : IDL.Nat64,
|
|
7
|
+
});
|
|
8
|
+
const Memo = IDL.Nat64;
|
|
9
|
+
const AccountIdentifier = IDL.Vec(IDL.Nat8);
|
|
10
|
+
const Tokens = IDL.Record({ 'e8s' : IDL.Nat64 });
|
|
11
|
+
const Operation = IDL.Variant({
|
|
12
|
+
'Burn' : IDL.Record({ 'from' : AccountIdentifier, 'amount' : Tokens }),
|
|
13
|
+
'Mint' : IDL.Record({ 'to' : AccountIdentifier, 'amount' : Tokens }),
|
|
14
|
+
'Transfer' : IDL.Record({
|
|
15
|
+
'to' : AccountIdentifier,
|
|
16
|
+
'fee' : Tokens,
|
|
17
|
+
'from' : AccountIdentifier,
|
|
18
|
+
'amount' : Tokens,
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const TimeStamp = IDL.Record({ 'timestamp_nanos' : IDL.Nat64 });
|
|
22
|
+
const Transaction = IDL.Record({
|
|
23
|
+
'memo' : Memo,
|
|
24
|
+
'operation' : IDL.Opt(Operation),
|
|
25
|
+
'created_at_time' : TimeStamp,
|
|
26
|
+
});
|
|
27
|
+
const Block = IDL.Record({
|
|
28
|
+
'transaction' : Transaction,
|
|
29
|
+
'timestamp' : TimeStamp,
|
|
30
|
+
'parent_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
31
|
+
});
|
|
32
|
+
const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });
|
|
33
|
+
const QueryArchiveError = IDL.Variant({
|
|
34
|
+
'BadFirstBlockIndex' : IDL.Record({
|
|
35
|
+
'requested_index' : BlockIndex,
|
|
36
|
+
'first_valid_index' : BlockIndex,
|
|
37
|
+
}),
|
|
38
|
+
'Other' : IDL.Record({
|
|
39
|
+
'error_message' : IDL.Text,
|
|
40
|
+
'error_code' : IDL.Nat64,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
const QueryArchiveResult = IDL.Variant({
|
|
44
|
+
'Ok' : BlockRange,
|
|
45
|
+
'Err' : QueryArchiveError,
|
|
46
|
+
});
|
|
47
|
+
const QueryArchiveFn = IDL.Func([GetBlocksArgs], [QueryArchiveResult], []);
|
|
48
|
+
const QueryBlocksResponse = IDL.Record({
|
|
49
|
+
'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
50
|
+
'blocks' : IDL.Vec(Block),
|
|
51
|
+
'chain_length' : IDL.Nat64,
|
|
52
|
+
'first_block_index' : BlockIndex,
|
|
53
|
+
'archived_blocks' : IDL.Vec(
|
|
54
|
+
IDL.Record({
|
|
55
|
+
'callback' : QueryArchiveFn,
|
|
56
|
+
'start' : BlockIndex,
|
|
57
|
+
'length' : IDL.Nat64,
|
|
58
|
+
})
|
|
59
|
+
),
|
|
60
|
+
});
|
|
61
|
+
const AccountBalanceArgs = IDL.Record({ 'account' : AccountIdentifier });
|
|
62
|
+
const Archive = IDL.Record({ 'canister_id' : IDL.Principal });
|
|
63
|
+
const Archives = IDL.Record({ 'archives' : IDL.Vec(Archive) });
|
|
64
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
65
|
+
const TransferArgs = IDL.Record({
|
|
66
|
+
'to' : AccountIdentifier,
|
|
67
|
+
'fee' : Tokens,
|
|
68
|
+
'memo' : Memo,
|
|
69
|
+
'from_subaccount' : IDL.Opt(SubAccount),
|
|
70
|
+
'created_at_time' : IDL.Opt(TimeStamp),
|
|
71
|
+
'amount' : Tokens,
|
|
72
|
+
});
|
|
73
|
+
const TransferError = IDL.Variant({
|
|
74
|
+
'TxTooOld' : IDL.Record({ 'allowed_window_nanos' : IDL.Nat64 }),
|
|
75
|
+
'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
|
|
76
|
+
'TxDuplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
|
|
77
|
+
'TxCreatedInFuture' : IDL.Null,
|
|
78
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
|
|
79
|
+
});
|
|
80
|
+
const TransferResult = IDL.Variant({
|
|
81
|
+
'Ok' : BlockIndex,
|
|
82
|
+
'Err' : TransferError,
|
|
83
|
+
});
|
|
84
|
+
const TransferFeeArg = IDL.Record({});
|
|
85
|
+
const TransferFee = IDL.Record({ 'transfer_fee' : Tokens });
|
|
86
|
+
return IDL.Service({
|
|
87
|
+
'_blocks' : IDL.Func([GetBlocksArgs], [QueryBlocksResponse], []),
|
|
88
|
+
'account_balance' : IDL.Func([AccountBalanceArgs], [Tokens], []),
|
|
89
|
+
'archives' : IDL.Func([], [Archives], []),
|
|
90
|
+
'decimals' : IDL.Func([], [IDL.Record({ 'decimals' : IDL.Nat32 })], []),
|
|
91
|
+
'name' : IDL.Func([], [IDL.Record({ 'name' : IDL.Text })], []),
|
|
92
|
+
'symbol' : IDL.Func([], [IDL.Record({ 'symbol' : IDL.Text })], []),
|
|
93
|
+
'transfer' : IDL.Func([TransferArgs], [TransferResult], []),
|
|
94
|
+
'transfer_fee' : IDL.Func([TransferFeeArg], [TransferFee], []),
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export const init = ({ IDL }) => { return []; };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Principal } from "@dfinity/principal";
|
|
2
|
+
export interface AccountBalanceArgs {
|
|
3
|
+
account: AccountIdentifier;
|
|
4
|
+
}
|
|
5
|
+
export type AccountIdentifier = Array<number>;
|
|
6
|
+
export interface Archive {
|
|
7
|
+
canister_id: Principal;
|
|
8
|
+
}
|
|
9
|
+
export interface Archives {
|
|
10
|
+
archives: Array<Archive>;
|
|
11
|
+
}
|
|
12
|
+
export interface Block {
|
|
13
|
+
transaction: Transaction;
|
|
14
|
+
timestamp: TimeStamp;
|
|
15
|
+
parent_hash: [] | [Array<number>];
|
|
16
|
+
}
|
|
17
|
+
export type BlockIndex = bigint;
|
|
18
|
+
export interface BlockRange {
|
|
19
|
+
blocks: Array<Block>;
|
|
20
|
+
}
|
|
21
|
+
export interface GetBlocksArgs {
|
|
22
|
+
start: BlockIndex;
|
|
23
|
+
length: bigint;
|
|
24
|
+
}
|
|
25
|
+
export type Memo = bigint;
|
|
26
|
+
export type Operation =
|
|
27
|
+
| {
|
|
28
|
+
Burn: { from: AccountIdentifier; amount: Tokens };
|
|
29
|
+
}
|
|
30
|
+
| { Mint: { to: AccountIdentifier; amount: Tokens } }
|
|
31
|
+
| {
|
|
32
|
+
Transfer: {
|
|
33
|
+
to: AccountIdentifier;
|
|
34
|
+
fee: Tokens;
|
|
35
|
+
from: AccountIdentifier;
|
|
36
|
+
amount: Tokens;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type QueryArchiveError =
|
|
40
|
+
| {
|
|
41
|
+
BadFirstBlockIndex: {
|
|
42
|
+
requested_index: BlockIndex;
|
|
43
|
+
first_valid_index: BlockIndex;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
| { Other: { error_message: string; error_code: bigint } };
|
|
47
|
+
export type QueryArchiveFn = (
|
|
48
|
+
arg_0: GetBlocksArgs
|
|
49
|
+
) => Promise<QueryArchiveResult>;
|
|
50
|
+
export type QueryArchiveResult =
|
|
51
|
+
| { Ok: BlockRange }
|
|
52
|
+
| { Err: QueryArchiveError };
|
|
53
|
+
export interface QueryBlocksResponse {
|
|
54
|
+
certificate: [] | [Array<number>];
|
|
55
|
+
blocks: Array<Block>;
|
|
56
|
+
chain_length: bigint;
|
|
57
|
+
first_block_index: BlockIndex;
|
|
58
|
+
archived_blocks: Array<{
|
|
59
|
+
callback: QueryArchiveFn;
|
|
60
|
+
start: BlockIndex;
|
|
61
|
+
length: bigint;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export type SubAccount = Array<number>;
|
|
65
|
+
export interface TimeStamp {
|
|
66
|
+
timestamp_nanos: bigint;
|
|
67
|
+
}
|
|
68
|
+
export interface Tokens {
|
|
69
|
+
e8s: bigint;
|
|
70
|
+
}
|
|
71
|
+
export interface Transaction {
|
|
72
|
+
memo: Memo;
|
|
73
|
+
operation: [] | [Operation];
|
|
74
|
+
created_at_time: TimeStamp;
|
|
75
|
+
}
|
|
76
|
+
export interface TransferArgs {
|
|
77
|
+
to: AccountIdentifier;
|
|
78
|
+
fee: Tokens;
|
|
79
|
+
memo: Memo;
|
|
80
|
+
from_subaccount: [] | [SubAccount];
|
|
81
|
+
created_at_time: [] | [TimeStamp];
|
|
82
|
+
amount: Tokens;
|
|
83
|
+
}
|
|
84
|
+
export type TransferError =
|
|
85
|
+
| {
|
|
86
|
+
TxTooOld: { allowed_window_nanos: bigint };
|
|
87
|
+
}
|
|
88
|
+
| { BadFee: { expected_fee: Tokens } }
|
|
89
|
+
| { TxDuplicate: { duplicate_of: BlockIndex } }
|
|
90
|
+
| { TxCreatedInFuture: null }
|
|
91
|
+
| { InsufficientFunds: { balance: Tokens } };
|
|
92
|
+
export interface TransferFee {
|
|
93
|
+
transfer_fee: Tokens;
|
|
94
|
+
}
|
|
95
|
+
export type TransferFeeArg = {};
|
|
96
|
+
export type TransferResult = { Ok: BlockIndex } | { Err: TransferError };
|
|
97
|
+
export interface _SERVICE {
|
|
98
|
+
account_balance: (arg_0: AccountBalanceArgs) => Promise<Tokens>;
|
|
99
|
+
archives: () => Promise<Archives>;
|
|
100
|
+
decimals: () => Promise<{ decimals: number }>;
|
|
101
|
+
name: () => Promise<{ name: string }>;
|
|
102
|
+
query_blocks: (arg_0: GetBlocksArgs) => Promise<QueryBlocksResponse>;
|
|
103
|
+
symbol: () => Promise<{ symbol: string }>;
|
|
104
|
+
transfer: (arg_0: TransferArgs) => Promise<TransferResult>;
|
|
105
|
+
transfer_fee: (arg_0: TransferFeeArg) => Promise<TransferFee>;
|
|
106
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Generated from IC repo commit a1080f27696c890c19d7068f668bd062f3787564 'rs/rosetta-api/ledger_canister/ledger.did' by import-candid
|
|
2
|
+
// This is the official Ledger interface that is guaranteed to be backward compatible.
|
|
3
|
+
|
|
4
|
+
// Amount of tokens, measured in 10^-8 of a token.
|
|
5
|
+
type Tokens = record {
|
|
6
|
+
e8s : nat64;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// Number of nanoseconds from the UNIX epoch in UTC timezone.
|
|
10
|
+
type TimeStamp = record {
|
|
11
|
+
timestamp_nanos: nat64;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// AccountIdentifier is a 32-byte array.
|
|
15
|
+
// The first 4 bytes is big-endian encoding of a CRC32 checksum of the last 28 bytes.
|
|
16
|
+
type AccountIdentifier = blob;
|
|
17
|
+
|
|
18
|
+
// Subaccount is an arbitrary 32-byte byte array.
|
|
19
|
+
// Ledger uses subaccounts to compute the source address, which enables one
|
|
20
|
+
// principal to control multiple ledger accounts.
|
|
21
|
+
type SubAccount = blob;
|
|
22
|
+
|
|
23
|
+
// Sequence number of a block produced by the ledger.
|
|
24
|
+
type BlockIndex = nat64;
|
|
25
|
+
|
|
26
|
+
// An arbitrary number associated with a transaction.
|
|
27
|
+
// The caller can set it in a `transfer` call as a correlation identifier.
|
|
28
|
+
type Memo = nat64;
|
|
29
|
+
|
|
30
|
+
// Arguments for the `transfer` call.
|
|
31
|
+
type TransferArgs = record {
|
|
32
|
+
// Transaction memo.
|
|
33
|
+
// See comments for the `Memo` type.
|
|
34
|
+
memo: Memo;
|
|
35
|
+
// The amount that the caller wants to transfer to the destination address.
|
|
36
|
+
amount: Tokens;
|
|
37
|
+
// The amount that the caller pays for the transaction.
|
|
38
|
+
// Must be 10000 e8s.
|
|
39
|
+
fee: Tokens;
|
|
40
|
+
// The subaccount from which the caller wants to transfer funds.
|
|
41
|
+
// If null, the ledger uses the default (all zeros) subaccount to compute the source address.
|
|
42
|
+
// See comments for the `SubAccount` type.
|
|
43
|
+
from_subaccount: opt SubAccount;
|
|
44
|
+
// The destination account.
|
|
45
|
+
// If the transfer is successful, the balance of this address increases by `amount`.
|
|
46
|
+
to: AccountIdentifier;
|
|
47
|
+
// The point in time when the caller created this request.
|
|
48
|
+
// If null, the ledger uses current IC time as the timestamp.
|
|
49
|
+
created_at_time: opt TimeStamp;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type TransferError = variant {
|
|
53
|
+
// The fee that the caller specified in the transfer request was not the one that ledger expects.
|
|
54
|
+
// The caller can change the transfer fee to the `expected_fee` and retry the request.
|
|
55
|
+
BadFee : record { expected_fee : Tokens; };
|
|
56
|
+
// The account specified by the caller doesn't have enough funds.
|
|
57
|
+
InsufficientFunds : record { balance: Tokens; };
|
|
58
|
+
// The request is too old.
|
|
59
|
+
// The ledger only accepts requests created within 24 hours window.
|
|
60
|
+
// This is a non-recoverable error.
|
|
61
|
+
TxTooOld : record { allowed_window_nanos: nat64 };
|
|
62
|
+
// The caller specified `created_at_time` that is too far in future.
|
|
63
|
+
// The caller can retry the request later.
|
|
64
|
+
TxCreatedInFuture : null;
|
|
65
|
+
// The ledger has already executed the request.
|
|
66
|
+
// `duplicate_of` field is equal to the index of the block containing the original transaction.
|
|
67
|
+
TxDuplicate : record { duplicate_of: BlockIndex; }
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type TransferResult = variant {
|
|
71
|
+
Ok : BlockIndex;
|
|
72
|
+
Err : TransferError;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Arguments for the `account_balance` call.
|
|
76
|
+
type AccountBalanceArgs = record {
|
|
77
|
+
account: AccountIdentifier;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type TransferFeeArg = record {};
|
|
81
|
+
|
|
82
|
+
type TransferFee = record {
|
|
83
|
+
// The fee to pay to perform a transfer
|
|
84
|
+
transfer_fee: Tokens;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type GetBlocksArgs = record {
|
|
88
|
+
// The index of the first block to fetch.
|
|
89
|
+
start : BlockIndex;
|
|
90
|
+
// Max number of blocks to fetch.
|
|
91
|
+
length : nat64;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type Operation = variant {
|
|
95
|
+
Mint : record {
|
|
96
|
+
to : AccountIdentifier;
|
|
97
|
+
amount : Tokens;
|
|
98
|
+
};
|
|
99
|
+
Burn : record {
|
|
100
|
+
from : AccountIdentifier;
|
|
101
|
+
amount : Tokens;
|
|
102
|
+
};
|
|
103
|
+
Transfer : record {
|
|
104
|
+
from : AccountIdentifier;
|
|
105
|
+
to : AccountIdentifier;
|
|
106
|
+
amount : Tokens;
|
|
107
|
+
fee : Tokens;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type Transaction = record {
|
|
112
|
+
memo : Memo;
|
|
113
|
+
operation : opt Operation;
|
|
114
|
+
created_at_time : TimeStamp;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
type Block = record {
|
|
118
|
+
parent_hash : opt blob;
|
|
119
|
+
transaction : Transaction;
|
|
120
|
+
timestamp : TimeStamp;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// A prefix of the block range specified in the [GetBlocksArgs] request.
|
|
124
|
+
type BlockRange = record {
|
|
125
|
+
// A prefix of the requested block range.
|
|
126
|
+
// The index of the first block is equal to [GetBlocksArgs.from].
|
|
127
|
+
//
|
|
128
|
+
// Note that the number of blocks might be less than the requested
|
|
129
|
+
// [GetBlocksArgs.len] for various reasons, for example:
|
|
130
|
+
//
|
|
131
|
+
// 1. The query might have hit the replica with an outdated state
|
|
132
|
+
// that doesn't have the full block range yet.
|
|
133
|
+
// 2. The requested range is too large to fit into a single reply.
|
|
134
|
+
//
|
|
135
|
+
// NOTE: the list of blocks can be empty if:
|
|
136
|
+
// 1. [GetBlocksArgs.len] was zero.
|
|
137
|
+
// 2. [GetBlocksArgs.from] was larger than the last block known to the canister.
|
|
138
|
+
blocks : vec Block;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// An error indicating that the arguments passed to [QueryArchiveFn] were invalid.
|
|
142
|
+
type QueryArchiveError = variant {
|
|
143
|
+
// [GetBlocksArgs.from] argument was smaller than the first block
|
|
144
|
+
// served by the canister that received the request.
|
|
145
|
+
BadFirstBlockIndex : record {
|
|
146
|
+
requested_index : BlockIndex;
|
|
147
|
+
first_valid_index : BlockIndex;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Reserved for future use.
|
|
151
|
+
Other : record {
|
|
152
|
+
error_code : nat64;
|
|
153
|
+
error_message : text;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
type QueryArchiveResult = variant {
|
|
158
|
+
// Successfully fetched zero or more blocks.
|
|
159
|
+
Ok : BlockRange;
|
|
160
|
+
// The [GetBlocksArgs] request was invalid.
|
|
161
|
+
Err : QueryArchiveError;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// A function that is used for fetching archived ledger blocks.
|
|
165
|
+
type QueryArchiveFn = func (GetBlocksArgs) -> (QueryArchiveResult) query;
|
|
166
|
+
|
|
167
|
+
// The result of a "query_blocks" call.
|
|
168
|
+
//
|
|
169
|
+
// The structure of the result is somewhat complicated because the main ledger canister might
|
|
170
|
+
// not have all the blocks that the caller requested: One or more "archive" canisters might
|
|
171
|
+
// store some of the requested blocks.
|
|
172
|
+
//
|
|
173
|
+
// Note: as of Q4 2021 when this interface is authored, the IC doesn't support making nested
|
|
174
|
+
// query calls within a query call.
|
|
175
|
+
type QueryBlocksResponse = record {
|
|
176
|
+
// The total number of blocks in the chain.
|
|
177
|
+
// If the chain length is positive, the index of the last block is `chain_len - 1`.
|
|
178
|
+
chain_length : nat64;
|
|
179
|
+
|
|
180
|
+
// System certificate for the hash of the latest block in the chain.
|
|
181
|
+
// Only present if `query_blocks` is called in a non-replicated query context.
|
|
182
|
+
certificate : opt blob;
|
|
183
|
+
|
|
184
|
+
// List of blocks that were available in the ledger when it processed the call.
|
|
185
|
+
//
|
|
186
|
+
// The blocks form a contiguous range, with the first block having index
|
|
187
|
+
// [first_block_index] (see below), and the last block having index
|
|
188
|
+
// [first_block_index] + len(blocks) - 1.
|
|
189
|
+
//
|
|
190
|
+
// The block range can be an arbitrary sub-range of the originally requested range.
|
|
191
|
+
blocks : vec Block;
|
|
192
|
+
|
|
193
|
+
// The index of the first block in "blocks".
|
|
194
|
+
// If the blocks vector is empty, the exact value of this field is not specified.
|
|
195
|
+
first_block_index : BlockIndex;
|
|
196
|
+
|
|
197
|
+
// Encoding of instructions for fetching archived blocks whose indices fall into the
|
|
198
|
+
// requested range.
|
|
199
|
+
//
|
|
200
|
+
// For each entry `e` in [archived_blocks], `[e.from, e.from + len)` is a sub-range
|
|
201
|
+
// of the originally requested block range.
|
|
202
|
+
archived_blocks : vec record {
|
|
203
|
+
// The index of the first archived block that can be fetched using the callback.
|
|
204
|
+
start : BlockIndex;
|
|
205
|
+
|
|
206
|
+
// The number of blocks that can be fetch using the callback.
|
|
207
|
+
length : nat64;
|
|
208
|
+
|
|
209
|
+
// The function that should be called to fetch the archived blocks.
|
|
210
|
+
// The range of the blocks accessible using this function is given by [from]
|
|
211
|
+
// and [len] fields above.
|
|
212
|
+
callback : QueryArchiveFn;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
type Archive = record {
|
|
217
|
+
canister_id: principal;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
type Archives = record {
|
|
221
|
+
archives: vec Archive;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
service : {
|
|
225
|
+
// Transfers tokens from a subaccount of the caller to the destination address.
|
|
226
|
+
// The source address is computed from the principal of the caller and the specified subaccount.
|
|
227
|
+
// When successful, returns the index of the block containing the transaction.
|
|
228
|
+
transfer : (TransferArgs) -> (TransferResult);
|
|
229
|
+
|
|
230
|
+
// Returns the amount of Tokens on the specified account.
|
|
231
|
+
account_balance : (AccountBalanceArgs) -> (Tokens) query;
|
|
232
|
+
|
|
233
|
+
// Returns the current transfer_fee.
|
|
234
|
+
transfer_fee : (TransferFeeArg) -> (TransferFee) query;
|
|
235
|
+
|
|
236
|
+
// Queries blocks in the specified range.
|
|
237
|
+
query_blocks : (GetBlocksArgs) -> (QueryBlocksResponse) query;
|
|
238
|
+
|
|
239
|
+
// Returns token symbol.
|
|
240
|
+
symbol : () -> (record { symbol: text }) query;
|
|
241
|
+
|
|
242
|
+
// Returns token name.
|
|
243
|
+
name : () -> (record { name: text }) query;
|
|
244
|
+
|
|
245
|
+
// Returns token decimals.
|
|
246
|
+
decimals : () -> (record { decimals: nat32 }) query;
|
|
247
|
+
|
|
248
|
+
// Returns the existing archive canisters information.
|
|
249
|
+
archives : () -> (Archives) query;
|
|
250
|
+
}
|