@dfinity/ckbtc 0.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/LICENSE +201 -0
- package/README.md +89 -0
- package/dist/candid/minter.certified.idl.d.ts +2 -0
- package/dist/candid/minter.certified.idl.js +170 -0
- package/dist/candid/minter.d.ts +117 -0
- package/dist/candid/minter.did +249 -0
- package/dist/candid/minter.idl.d.ts +2 -0
- package/dist/candid/minter.idl.js +170 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +7 -0
- package/dist/esm/chunk-7LX2K5RL.js +2 -0
- package/dist/esm/chunk-7LX2K5RL.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/minter.canister.js +2 -0
- package/dist/esm/minter.canister.js.map +7 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/minter.canister.d.ts +18 -0
- package/dist/types/types/canister.options.d.ts +5 -0
- package/dist/types/types/minter.params.d.ts +10 -0
- package/package.json +43 -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,89 @@
|
|
|
1
|
+
# ckbtc-js
|
|
2
|
+
|
|
3
|
+
A library for interfacing with [ckBTC](https://github.com/dfinity/ic/tree/master/rs/bitcoin/ckbtc/minter) on the Internet Computer.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@dfinity/ckbtc) [](https://opensource.org/licenses/Apache-2.0)
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can use `ckbtc-js` by installing it in your project.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i @dfinity/ckbtc
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The bundle needs peer dependencies, be sure that following resources are available in your project as well.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
The features are available through the class `LedgerCanister`. It has to be instantiated with a canister ID.
|
|
30
|
+
|
|
31
|
+
e.g. fetching a token metadata.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { CkBTCCanister } from "@dfinity/ckbtc";
|
|
35
|
+
import { createAgent } from "@dfinity/utils";
|
|
36
|
+
|
|
37
|
+
const agent = await createAgent({
|
|
38
|
+
identity,
|
|
39
|
+
host: HOST,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const { getBtcAddress } = CkBTCCanister.create({
|
|
43
|
+
agent,
|
|
44
|
+
canisterId: MY_CKBTC_MINTER_CANISTER_ID,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const btcAddress = await getBtcAddress({});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
`ckbtc-js` implements following features:
|
|
53
|
+
|
|
54
|
+
<!-- TSDOC_START -->
|
|
55
|
+
|
|
56
|
+
### :factory: CkBTCMinterCanister
|
|
57
|
+
|
|
58
|
+
#### Constructors
|
|
59
|
+
|
|
60
|
+
`public`
|
|
61
|
+
|
|
62
|
+
#### Methods
|
|
63
|
+
|
|
64
|
+
- [create](#gear-create)
|
|
65
|
+
- [getBtcAddress](#gear-getbtcaddress)
|
|
66
|
+
|
|
67
|
+
##### :gear: create
|
|
68
|
+
|
|
69
|
+
| Method | Type |
|
|
70
|
+
| -------- | ------------------------------------------------------------------------ |
|
|
71
|
+
| `create` | `(options: CkBTCMinterCanisterOptions<_SERVICE>) => CkBTCMinterCanister` |
|
|
72
|
+
|
|
73
|
+
##### :gear: getBtcAddress
|
|
74
|
+
|
|
75
|
+
Returns a BTC address for a given account.
|
|
76
|
+
|
|
77
|
+
Note: an update call is required by the Minter canister.
|
|
78
|
+
|
|
79
|
+
| Method | Type |
|
|
80
|
+
| --------------- | -------------------------------------------------- |
|
|
81
|
+
| `getBtcAddress` | `(params: GetBTCAddressParams) => Promise<string>` |
|
|
82
|
+
|
|
83
|
+
Parameters:
|
|
84
|
+
|
|
85
|
+
- `params`: The parameters for which a BTC address should be resolved.
|
|
86
|
+
- `params.owner`: The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.
|
|
87
|
+
- `params.subaccount`: An optional subaccount to compute the address.
|
|
88
|
+
|
|
89
|
+
<!-- TSDOC_END -->
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */
|
|
2
|
+
export const idlFactory = ({ IDL }) => {
|
|
3
|
+
const Mode = IDL.Variant({
|
|
4
|
+
'RestrictedTo' : IDL.Vec(IDL.Principal),
|
|
5
|
+
'ReadOnly' : IDL.Null,
|
|
6
|
+
'GeneralAvailability' : IDL.Null,
|
|
7
|
+
});
|
|
8
|
+
const BtcNetwork = IDL.Variant({
|
|
9
|
+
'Mainnet' : IDL.Null,
|
|
10
|
+
'Regtest' : IDL.Null,
|
|
11
|
+
'Testnet' : IDL.Null,
|
|
12
|
+
});
|
|
13
|
+
const InitArgs = IDL.Record({
|
|
14
|
+
'ecdsa_key_name' : IDL.Text,
|
|
15
|
+
'mode' : Mode,
|
|
16
|
+
'retrieve_btc_min_amount' : IDL.Nat64,
|
|
17
|
+
'ledger_id' : IDL.Principal,
|
|
18
|
+
'max_time_in_queue_nanos' : IDL.Nat64,
|
|
19
|
+
'btc_network' : BtcNetwork,
|
|
20
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
21
|
+
});
|
|
22
|
+
const Account = IDL.Record({
|
|
23
|
+
'owner' : IDL.Principal,
|
|
24
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
25
|
+
});
|
|
26
|
+
const Utxo = IDL.Record({
|
|
27
|
+
'height' : IDL.Nat32,
|
|
28
|
+
'value' : IDL.Nat64,
|
|
29
|
+
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
|
|
30
|
+
});
|
|
31
|
+
const UpgradeArgs = IDL.Record({
|
|
32
|
+
'mode' : IDL.Opt(Mode),
|
|
33
|
+
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
|
|
34
|
+
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
|
|
35
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
36
|
+
});
|
|
37
|
+
const BitcoinAddress = IDL.Variant({
|
|
38
|
+
'p2sh' : IDL.Vec(IDL.Nat8),
|
|
39
|
+
'p2wpkh_v0' : IDL.Vec(IDL.Nat8),
|
|
40
|
+
'p2pkh' : IDL.Vec(IDL.Nat8),
|
|
41
|
+
});
|
|
42
|
+
const Event = IDL.Variant({
|
|
43
|
+
'received_utxos' : IDL.Record({
|
|
44
|
+
'to_account' : Account,
|
|
45
|
+
'utxos' : IDL.Vec(Utxo),
|
|
46
|
+
}),
|
|
47
|
+
'sent_transaction' : IDL.Record({
|
|
48
|
+
'change_output' : IDL.Opt(
|
|
49
|
+
IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })
|
|
50
|
+
),
|
|
51
|
+
'txid' : IDL.Vec(IDL.Nat8),
|
|
52
|
+
'utxos' : IDL.Vec(Utxo),
|
|
53
|
+
'requests' : IDL.Vec(IDL.Nat64),
|
|
54
|
+
'submitted_at' : IDL.Nat64,
|
|
55
|
+
}),
|
|
56
|
+
'init' : InitArgs,
|
|
57
|
+
'upgrade' : UpgradeArgs,
|
|
58
|
+
'accepted_retrieve_btc_request' : IDL.Record({
|
|
59
|
+
'received_at' : IDL.Nat64,
|
|
60
|
+
'block_index' : IDL.Nat64,
|
|
61
|
+
'address' : BitcoinAddress,
|
|
62
|
+
'amount' : IDL.Nat64,
|
|
63
|
+
}),
|
|
64
|
+
'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),
|
|
65
|
+
'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
66
|
+
});
|
|
67
|
+
const RetrieveBtcArgs = IDL.Record({
|
|
68
|
+
'address' : IDL.Text,
|
|
69
|
+
'amount' : IDL.Nat64,
|
|
70
|
+
});
|
|
71
|
+
const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });
|
|
72
|
+
const RetrieveBtcError = IDL.Variant({
|
|
73
|
+
'MalformedAddress' : IDL.Text,
|
|
74
|
+
'GenericError' : IDL.Record({
|
|
75
|
+
'error_message' : IDL.Text,
|
|
76
|
+
'error_code' : IDL.Nat64,
|
|
77
|
+
}),
|
|
78
|
+
'TemporarilyUnavailable' : IDL.Text,
|
|
79
|
+
'AlreadyProcessing' : IDL.Null,
|
|
80
|
+
'AmountTooLow' : IDL.Nat64,
|
|
81
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),
|
|
82
|
+
});
|
|
83
|
+
const RetrieveBtcStatus = IDL.Variant({
|
|
84
|
+
'Signing' : IDL.Null,
|
|
85
|
+
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
86
|
+
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
87
|
+
'AmountTooLow' : IDL.Null,
|
|
88
|
+
'Unknown' : IDL.Null,
|
|
89
|
+
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
90
|
+
'Pending' : IDL.Null,
|
|
91
|
+
});
|
|
92
|
+
const UpdateBalanceResult = IDL.Record({
|
|
93
|
+
'block_index' : IDL.Nat64,
|
|
94
|
+
'amount' : IDL.Nat64,
|
|
95
|
+
});
|
|
96
|
+
const UpdateBalanceError = IDL.Variant({
|
|
97
|
+
'GenericError' : IDL.Record({
|
|
98
|
+
'error_message' : IDL.Text,
|
|
99
|
+
'error_code' : IDL.Nat64,
|
|
100
|
+
}),
|
|
101
|
+
'TemporarilyUnavailable' : IDL.Text,
|
|
102
|
+
'AlreadyProcessing' : IDL.Null,
|
|
103
|
+
'NoNewUtxos' : IDL.Null,
|
|
104
|
+
});
|
|
105
|
+
return IDL.Service({
|
|
106
|
+
'get_btc_address' : IDL.Func(
|
|
107
|
+
[
|
|
108
|
+
IDL.Record({
|
|
109
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
110
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
[IDL.Text],
|
|
114
|
+
[],
|
|
115
|
+
),
|
|
116
|
+
'get_events' : IDL.Func(
|
|
117
|
+
[IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],
|
|
118
|
+
[IDL.Vec(Event)],
|
|
119
|
+
[],
|
|
120
|
+
),
|
|
121
|
+
'get_withdrawal_account' : IDL.Func([], [Account], []),
|
|
122
|
+
'retrieve_btc' : IDL.Func(
|
|
123
|
+
[RetrieveBtcArgs],
|
|
124
|
+
[IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],
|
|
125
|
+
[],
|
|
126
|
+
),
|
|
127
|
+
'retrieve_btc_status' : IDL.Func(
|
|
128
|
+
[IDL.Record({ 'block_index' : IDL.Nat64 })],
|
|
129
|
+
[RetrieveBtcStatus],
|
|
130
|
+
[],
|
|
131
|
+
),
|
|
132
|
+
'update_balance' : IDL.Func(
|
|
133
|
+
[
|
|
134
|
+
IDL.Record({
|
|
135
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
136
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
IDL.Variant({
|
|
141
|
+
'Ok' : UpdateBalanceResult,
|
|
142
|
+
'Err' : UpdateBalanceError,
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
[],
|
|
146
|
+
),
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export const init = ({ IDL }) => {
|
|
150
|
+
const Mode = IDL.Variant({
|
|
151
|
+
'RestrictedTo' : IDL.Vec(IDL.Principal),
|
|
152
|
+
'ReadOnly' : IDL.Null,
|
|
153
|
+
'GeneralAvailability' : IDL.Null,
|
|
154
|
+
});
|
|
155
|
+
const BtcNetwork = IDL.Variant({
|
|
156
|
+
'Mainnet' : IDL.Null,
|
|
157
|
+
'Regtest' : IDL.Null,
|
|
158
|
+
'Testnet' : IDL.Null,
|
|
159
|
+
});
|
|
160
|
+
const InitArgs = IDL.Record({
|
|
161
|
+
'ecdsa_key_name' : IDL.Text,
|
|
162
|
+
'mode' : Mode,
|
|
163
|
+
'retrieve_btc_min_amount' : IDL.Nat64,
|
|
164
|
+
'ledger_id' : IDL.Principal,
|
|
165
|
+
'max_time_in_queue_nanos' : IDL.Nat64,
|
|
166
|
+
'btc_network' : BtcNetwork,
|
|
167
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
168
|
+
});
|
|
169
|
+
return [InitArgs];
|
|
170
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ActorMethod } from "@dfinity/agent";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
|
+
|
|
4
|
+
export interface Account {
|
|
5
|
+
owner: Principal;
|
|
6
|
+
subaccount: [] | [Uint8Array];
|
|
7
|
+
}
|
|
8
|
+
export type BitcoinAddress =
|
|
9
|
+
| { p2sh: Uint8Array }
|
|
10
|
+
| { p2wpkh_v0: Uint8Array }
|
|
11
|
+
| { p2pkh: Uint8Array };
|
|
12
|
+
export type BtcNetwork =
|
|
13
|
+
| { Mainnet: null }
|
|
14
|
+
| { Regtest: null }
|
|
15
|
+
| { Testnet: null };
|
|
16
|
+
export type Event =
|
|
17
|
+
| {
|
|
18
|
+
received_utxos: { to_account: Account; utxos: Array<Utxo> };
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
sent_transaction: {
|
|
22
|
+
change_output: [] | [{ value: bigint; vout: number }];
|
|
23
|
+
txid: Uint8Array;
|
|
24
|
+
utxos: Array<Utxo>;
|
|
25
|
+
requests: BigUint64Array;
|
|
26
|
+
submitted_at: bigint;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
| { init: InitArgs }
|
|
30
|
+
| { upgrade: UpgradeArgs }
|
|
31
|
+
| {
|
|
32
|
+
accepted_retrieve_btc_request: {
|
|
33
|
+
received_at: bigint;
|
|
34
|
+
block_index: bigint;
|
|
35
|
+
address: BitcoinAddress;
|
|
36
|
+
amount: bigint;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
| { removed_retrieve_btc_request: { block_index: bigint } }
|
|
40
|
+
| { confirmed_transaction: { txid: Uint8Array } };
|
|
41
|
+
export interface InitArgs {
|
|
42
|
+
ecdsa_key_name: string;
|
|
43
|
+
mode: Mode;
|
|
44
|
+
retrieve_btc_min_amount: bigint;
|
|
45
|
+
ledger_id: Principal;
|
|
46
|
+
max_time_in_queue_nanos: bigint;
|
|
47
|
+
btc_network: BtcNetwork;
|
|
48
|
+
min_confirmations: [] | [number];
|
|
49
|
+
}
|
|
50
|
+
export type Mode =
|
|
51
|
+
| { RestrictedTo: Array<Principal> }
|
|
52
|
+
| { ReadOnly: null }
|
|
53
|
+
| { GeneralAvailability: null };
|
|
54
|
+
export interface RetrieveBtcArgs {
|
|
55
|
+
address: string;
|
|
56
|
+
amount: bigint;
|
|
57
|
+
}
|
|
58
|
+
export type RetrieveBtcError =
|
|
59
|
+
| { MalformedAddress: string }
|
|
60
|
+
| { GenericError: { error_message: string; error_code: bigint } }
|
|
61
|
+
| { TemporarilyUnavailable: string }
|
|
62
|
+
| { AlreadyProcessing: null }
|
|
63
|
+
| { AmountTooLow: bigint }
|
|
64
|
+
| { InsufficientFunds: { balance: bigint } };
|
|
65
|
+
export interface RetrieveBtcOk {
|
|
66
|
+
block_index: bigint;
|
|
67
|
+
}
|
|
68
|
+
export type RetrieveBtcStatus =
|
|
69
|
+
| { Signing: null }
|
|
70
|
+
| { Confirmed: { txid: Uint8Array } }
|
|
71
|
+
| { Sending: { txid: Uint8Array } }
|
|
72
|
+
| { AmountTooLow: null }
|
|
73
|
+
| { Unknown: null }
|
|
74
|
+
| { Submitted: { txid: Uint8Array } }
|
|
75
|
+
| { Pending: null };
|
|
76
|
+
export type UpdateBalanceError =
|
|
77
|
+
| {
|
|
78
|
+
GenericError: { error_message: string; error_code: bigint };
|
|
79
|
+
}
|
|
80
|
+
| { TemporarilyUnavailable: string }
|
|
81
|
+
| { AlreadyProcessing: null }
|
|
82
|
+
| { NoNewUtxos: null };
|
|
83
|
+
export interface UpdateBalanceResult {
|
|
84
|
+
block_index: bigint;
|
|
85
|
+
amount: bigint;
|
|
86
|
+
}
|
|
87
|
+
export interface UpgradeArgs {
|
|
88
|
+
mode: [] | [Mode];
|
|
89
|
+
retrieve_btc_min_amount: [] | [bigint];
|
|
90
|
+
max_time_in_queue_nanos: [] | [bigint];
|
|
91
|
+
min_confirmations: [] | [number];
|
|
92
|
+
}
|
|
93
|
+
export interface Utxo {
|
|
94
|
+
height: number;
|
|
95
|
+
value: bigint;
|
|
96
|
+
outpoint: { txid: Uint8Array; vout: number };
|
|
97
|
+
}
|
|
98
|
+
export interface _SERVICE {
|
|
99
|
+
get_btc_address: ActorMethod<
|
|
100
|
+
[{ owner: [] | [Principal]; subaccount: [] | [Uint8Array] }],
|
|
101
|
+
string
|
|
102
|
+
>;
|
|
103
|
+
get_events: ActorMethod<[{ start: bigint; length: bigint }], Array<Event>>;
|
|
104
|
+
get_withdrawal_account: ActorMethod<[], Account>;
|
|
105
|
+
retrieve_btc: ActorMethod<
|
|
106
|
+
[RetrieveBtcArgs],
|
|
107
|
+
{ Ok: RetrieveBtcOk } | { Err: RetrieveBtcError }
|
|
108
|
+
>;
|
|
109
|
+
retrieve_btc_status: ActorMethod<
|
|
110
|
+
[{ block_index: bigint }],
|
|
111
|
+
RetrieveBtcStatus
|
|
112
|
+
>;
|
|
113
|
+
update_balance: ActorMethod<
|
|
114
|
+
[{ owner: [] | [Principal]; subaccount: [] | [Uint8Array] }],
|
|
115
|
+
{ Ok: UpdateBalanceResult } | { Err: UpdateBalanceError }
|
|
116
|
+
>;
|
|
117
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// Generated from IC repo commit 8b84d3d05843f1dfacf3ec65ada559acccd6ec14 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
|
|
2
|
+
// Represents an account on the ckBTC ledger.
|
|
3
|
+
type Account = record { owner : principal; subaccount : opt blob };
|
|
4
|
+
|
|
5
|
+
type RetrieveBtcArgs = record {
|
|
6
|
+
// The address to which the ckBTC minter should deposit BTC.
|
|
7
|
+
// Currently, the minter understands only the following types of addresses:
|
|
8
|
+
// * P2WPKH addresses (they start with the "bc1q" prefix on the Bitcoin mainnet).
|
|
9
|
+
// * P2PKH addresses (they start with the "1" prefix on the Bitcoin mainnet).
|
|
10
|
+
// * P2SH addresses (they start with the "3" prefix on the Bitcoin mainnet).
|
|
11
|
+
address : text;
|
|
12
|
+
// The amount of BTC in Satoshis that the client wants to withdraw.
|
|
13
|
+
amount : nat64;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type RetrieveBtcError = variant {
|
|
17
|
+
// The minter failed to parse the destination address.
|
|
18
|
+
MalformedAddress : text;
|
|
19
|
+
// The minter is already processing another retrieval request for the same
|
|
20
|
+
// principal.
|
|
21
|
+
AlreadyProcessing;
|
|
22
|
+
// The withdrawal amount is too low.
|
|
23
|
+
// The payload contains the minimal withdrawal amount.
|
|
24
|
+
AmountTooLow : nat64;
|
|
25
|
+
// The ckBTC balance of the withdrawal account is too low.
|
|
26
|
+
InsufficientFunds : record { balance : nat64 };
|
|
27
|
+
// The minter is overloaded, retry the request.
|
|
28
|
+
// The payload contains a human-readable message explaining what caused the unavailability.
|
|
29
|
+
TemporarilyUnavailable : text;
|
|
30
|
+
// A generic error reserved for future extensions.
|
|
31
|
+
GenericError : record { error_message : text; error_code : nat64 };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RetrieveBtcOk = record {
|
|
35
|
+
// Returns the burn transaction index corresponding to the withdrawal.
|
|
36
|
+
// You can use this index to query the withdrawal status.
|
|
37
|
+
block_index : nat64
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// The result of an [update_balance] call.
|
|
41
|
+
type UpdateBalanceResult = record {
|
|
42
|
+
// Returns the identifier of the mint transaction on the ckBTC ledger.
|
|
43
|
+
block_index : nat64;
|
|
44
|
+
// Returns the amount of newly minted ckBTC tokens.
|
|
45
|
+
amount : nat64;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type UpdateBalanceError = variant {
|
|
49
|
+
// There are no new UTXOs to process.
|
|
50
|
+
NoNewUtxos;
|
|
51
|
+
// The minter is already processing another update balance request for the caller.
|
|
52
|
+
AlreadyProcessing;
|
|
53
|
+
// The minter is overloaded, retry the request.
|
|
54
|
+
// The payload contains a human-readable message explaining what caused the unavailability.
|
|
55
|
+
TemporarilyUnavailable : text;
|
|
56
|
+
// A generic error reserved for future extensions.
|
|
57
|
+
GenericError : record { error_message : text; error_code : nat64 };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type BtcNetwork = variant {
|
|
61
|
+
// The public Bitcoin mainnet.
|
|
62
|
+
Mainnet;
|
|
63
|
+
// The public Bitcoin testnet.
|
|
64
|
+
Testnet;
|
|
65
|
+
// A local Bitcoin regtest installation.
|
|
66
|
+
Regtest;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type Mode = variant {
|
|
70
|
+
// The minter does not allow any state modifications.
|
|
71
|
+
ReadOnly;
|
|
72
|
+
// Only specified principals can modify minter's state.
|
|
73
|
+
RestrictedTo : vec principal;
|
|
74
|
+
// Anyone can interact with the minter.
|
|
75
|
+
GeneralAvailability;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// The initialization parameters of the minter canister.
|
|
79
|
+
type InitArgs = record {
|
|
80
|
+
// The minter will interact with this Bitcoin network.
|
|
81
|
+
btc_network : BtcNetwork;
|
|
82
|
+
|
|
83
|
+
// The principal of the ledger that handles ckBTC transfers.
|
|
84
|
+
// The default account of the ckBTC minter must be configured as
|
|
85
|
+
// the minting account of the ledger.
|
|
86
|
+
ledger_id : principal;
|
|
87
|
+
|
|
88
|
+
// The name of the ECDSA key to use.
|
|
89
|
+
// E.g., "dfx_test_key" on the local replica.
|
|
90
|
+
ecdsa_key_name : text;
|
|
91
|
+
|
|
92
|
+
// The minimal amount of ckBTC that can be converted to BTC.
|
|
93
|
+
retrieve_btc_min_amount : nat64;
|
|
94
|
+
|
|
95
|
+
/// Maximum time in nanoseconds that a transaction should spend in the queue
|
|
96
|
+
/// before being sent.
|
|
97
|
+
max_time_in_queue_nanos : nat64;
|
|
98
|
+
|
|
99
|
+
/// The minimum number of confirmations required for the minter to
|
|
100
|
+
/// accept a Bitcoin transaction.
|
|
101
|
+
min_confirmations : opt nat32;
|
|
102
|
+
|
|
103
|
+
/// The minter's operation mode.
|
|
104
|
+
mode : Mode;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// The upgrade parameters of the minter canister.
|
|
108
|
+
type UpgradeArgs = record {
|
|
109
|
+
// The minimal amount of ckBTC that the minter converts to BTC.
|
|
110
|
+
retrieve_btc_min_amount : opt nat64;
|
|
111
|
+
|
|
112
|
+
/// Maximum time in nanoseconds that a transaction should spend in the queue
|
|
113
|
+
/// before being sent.
|
|
114
|
+
max_time_in_queue_nanos : opt nat64;
|
|
115
|
+
|
|
116
|
+
/// The minimum number of confirmations required for the minter to
|
|
117
|
+
/// accept a Bitcoin transaction.
|
|
118
|
+
min_confirmations : opt nat32;
|
|
119
|
+
|
|
120
|
+
/// If set, overrides the current minter's operation mode.
|
|
121
|
+
mode : opt Mode;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
type RetrieveBtcStatus = variant {
|
|
125
|
+
// The minter does not have any information on the specified
|
|
126
|
+
// retrieval request. It can be that nobody submitted the
|
|
127
|
+
// request or the minter pruned the relevant information from the
|
|
128
|
+
// history to save space.
|
|
129
|
+
Unknown;
|
|
130
|
+
|
|
131
|
+
// The minter did not send a Bitcoin transaction for this request yet.
|
|
132
|
+
Pending;
|
|
133
|
+
|
|
134
|
+
// The minter is obtaining all required ECDSA signatures on the
|
|
135
|
+
// Bitcoin transaction for this request.
|
|
136
|
+
Signing;
|
|
137
|
+
|
|
138
|
+
// The minter signed the transaction and is waiting for a reply
|
|
139
|
+
// from the Bitcoin canister.
|
|
140
|
+
Sending : record { txid : blob };
|
|
141
|
+
|
|
142
|
+
// The minter sent a transaction for the retrieve request.
|
|
143
|
+
// The payload contains the identifier of the transaction on the Bitcoin network.
|
|
144
|
+
Submitted : record { txid : blob };
|
|
145
|
+
|
|
146
|
+
// The amount was too low to cover the transaction fees.
|
|
147
|
+
AmountTooLow;
|
|
148
|
+
|
|
149
|
+
// The minter received enough confirmations for the Bitcoin
|
|
150
|
+
// transaction for this request. The payload contains the
|
|
151
|
+
// identifier of the transaction on the Bitcoin network.
|
|
152
|
+
Confirmed : record { txid : blob };
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
type Utxo = record {
|
|
156
|
+
outpoint : record { txid : blob; vout : nat32 };
|
|
157
|
+
value : nat64;
|
|
158
|
+
height : nat32;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
type BitcoinAddress = variant {
|
|
162
|
+
p2wpkh_v0 : blob;
|
|
163
|
+
p2pkh : blob;
|
|
164
|
+
p2sh : blob;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
type Event = variant {
|
|
168
|
+
init : InitArgs;
|
|
169
|
+
upgrade : UpgradeArgs;
|
|
170
|
+
received_utxos : record { to_account : Account; utxos : vec Utxo };
|
|
171
|
+
accepted_retrieve_btc_request : record {
|
|
172
|
+
amount : nat64;
|
|
173
|
+
address : BitcoinAddress;
|
|
174
|
+
block_index : nat64;
|
|
175
|
+
received_at : nat64;
|
|
176
|
+
};
|
|
177
|
+
removed_retrieve_btc_request : record { block_index : nat64 };
|
|
178
|
+
sent_transaction : record {
|
|
179
|
+
requests : vec nat64;
|
|
180
|
+
txid : blob;
|
|
181
|
+
utxos : vec Utxo;
|
|
182
|
+
change_output : opt record { vout : nat32; value : nat64 };
|
|
183
|
+
submitted_at : nat64;
|
|
184
|
+
};
|
|
185
|
+
confirmed_transaction : record { txid : blob };
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
service : (InitArgs) -> {
|
|
189
|
+
// Section "Convert BTC to ckBTC" {{{
|
|
190
|
+
|
|
191
|
+
// Returns the bitcoin address to which the owner should send BTC
|
|
192
|
+
// before converting the amount to ckBTC using the [update_balance]
|
|
193
|
+
// endpoint.
|
|
194
|
+
//
|
|
195
|
+
// If the owner is not set, it defaults to the caller's principal.
|
|
196
|
+
get_btc_address : (record { owner: opt principal; subaccount : opt blob }) -> (text);
|
|
197
|
+
|
|
198
|
+
// Mints ckBTC for newly deposited UTXOs.
|
|
199
|
+
//
|
|
200
|
+
// If the owner is not set, it defaults to the caller's principal.
|
|
201
|
+
//
|
|
202
|
+
// # Preconditions
|
|
203
|
+
//
|
|
204
|
+
// * The owner deposited some BTC to the address that the
|
|
205
|
+
// [get_btc_address] endpoint returns.
|
|
206
|
+
update_balance : (record { owner: opt principal; subaccount : opt blob }) -> (variant { Ok : UpdateBalanceResult; Err : UpdateBalanceError });
|
|
207
|
+
|
|
208
|
+
// }}} Section "Convert BTC to ckBTC"
|
|
209
|
+
|
|
210
|
+
// Section "Convert ckBTC to BTC" {{{
|
|
211
|
+
|
|
212
|
+
// Returns the account to which the caller should deposit ckBTC
|
|
213
|
+
// before withdrawing BTC using the [retrieve_btc] endpoint.
|
|
214
|
+
get_withdrawal_account : () -> (Account);
|
|
215
|
+
|
|
216
|
+
// Submits a request to convert ckBTC to BTC.
|
|
217
|
+
//
|
|
218
|
+
// # Note
|
|
219
|
+
//
|
|
220
|
+
// The BTC retrieval process is slow. Instead of
|
|
221
|
+
// synchronously waiting for a BTC transaction to settle, this
|
|
222
|
+
// method returns a request ([block_index]) that the caller can use
|
|
223
|
+
// to query the request status.
|
|
224
|
+
//
|
|
225
|
+
// # Preconditions
|
|
226
|
+
//
|
|
227
|
+
// * The caller deposited the requested amount in ckBTC to the account
|
|
228
|
+
// that the [get_withdrawal_account] endpoint returns.
|
|
229
|
+
retrieve_btc : (RetrieveBtcArgs) -> (variant { Ok : RetrieveBtcOk; Err : RetrieveBtcError });
|
|
230
|
+
|
|
231
|
+
/// Returns the status of a [retrieve_btc] request.
|
|
232
|
+
retrieve_btc_status : (record { block_index : nat64 }) -> (RetrieveBtcStatus) query;
|
|
233
|
+
|
|
234
|
+
// }}} Section "Convert ckBTC to BTC"
|
|
235
|
+
|
|
236
|
+
// Section "Event log" {{{
|
|
237
|
+
|
|
238
|
+
// The minter keeps track of all state modifications in an internal event log.
|
|
239
|
+
//
|
|
240
|
+
// This method returns a list of events in the specified range.
|
|
241
|
+
// The minter can return fewer events than requested. The result is
|
|
242
|
+
// an empty vector if the start position is greater than the total
|
|
243
|
+
// number of events.
|
|
244
|
+
//
|
|
245
|
+
// NOTE: this method exists for debugging purposes.
|
|
246
|
+
// The ckBTC minter authors do not guarantee backward compatibility for this method.
|
|
247
|
+
get_events : (record { start: nat64; length : nat64 }) -> (vec Event) query;
|
|
248
|
+
// }}} Section "Event log"
|
|
249
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */
|
|
2
|
+
export const idlFactory = ({ IDL }) => {
|
|
3
|
+
const Mode = IDL.Variant({
|
|
4
|
+
'RestrictedTo' : IDL.Vec(IDL.Principal),
|
|
5
|
+
'ReadOnly' : IDL.Null,
|
|
6
|
+
'GeneralAvailability' : IDL.Null,
|
|
7
|
+
});
|
|
8
|
+
const BtcNetwork = IDL.Variant({
|
|
9
|
+
'Mainnet' : IDL.Null,
|
|
10
|
+
'Regtest' : IDL.Null,
|
|
11
|
+
'Testnet' : IDL.Null,
|
|
12
|
+
});
|
|
13
|
+
const InitArgs = IDL.Record({
|
|
14
|
+
'ecdsa_key_name' : IDL.Text,
|
|
15
|
+
'mode' : Mode,
|
|
16
|
+
'retrieve_btc_min_amount' : IDL.Nat64,
|
|
17
|
+
'ledger_id' : IDL.Principal,
|
|
18
|
+
'max_time_in_queue_nanos' : IDL.Nat64,
|
|
19
|
+
'btc_network' : BtcNetwork,
|
|
20
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
21
|
+
});
|
|
22
|
+
const Account = IDL.Record({
|
|
23
|
+
'owner' : IDL.Principal,
|
|
24
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
25
|
+
});
|
|
26
|
+
const Utxo = IDL.Record({
|
|
27
|
+
'height' : IDL.Nat32,
|
|
28
|
+
'value' : IDL.Nat64,
|
|
29
|
+
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
|
|
30
|
+
});
|
|
31
|
+
const UpgradeArgs = IDL.Record({
|
|
32
|
+
'mode' : IDL.Opt(Mode),
|
|
33
|
+
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
|
|
34
|
+
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
|
|
35
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
36
|
+
});
|
|
37
|
+
const BitcoinAddress = IDL.Variant({
|
|
38
|
+
'p2sh' : IDL.Vec(IDL.Nat8),
|
|
39
|
+
'p2wpkh_v0' : IDL.Vec(IDL.Nat8),
|
|
40
|
+
'p2pkh' : IDL.Vec(IDL.Nat8),
|
|
41
|
+
});
|
|
42
|
+
const Event = IDL.Variant({
|
|
43
|
+
'received_utxos' : IDL.Record({
|
|
44
|
+
'to_account' : Account,
|
|
45
|
+
'utxos' : IDL.Vec(Utxo),
|
|
46
|
+
}),
|
|
47
|
+
'sent_transaction' : IDL.Record({
|
|
48
|
+
'change_output' : IDL.Opt(
|
|
49
|
+
IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })
|
|
50
|
+
),
|
|
51
|
+
'txid' : IDL.Vec(IDL.Nat8),
|
|
52
|
+
'utxos' : IDL.Vec(Utxo),
|
|
53
|
+
'requests' : IDL.Vec(IDL.Nat64),
|
|
54
|
+
'submitted_at' : IDL.Nat64,
|
|
55
|
+
}),
|
|
56
|
+
'init' : InitArgs,
|
|
57
|
+
'upgrade' : UpgradeArgs,
|
|
58
|
+
'accepted_retrieve_btc_request' : IDL.Record({
|
|
59
|
+
'received_at' : IDL.Nat64,
|
|
60
|
+
'block_index' : IDL.Nat64,
|
|
61
|
+
'address' : BitcoinAddress,
|
|
62
|
+
'amount' : IDL.Nat64,
|
|
63
|
+
}),
|
|
64
|
+
'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),
|
|
65
|
+
'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
66
|
+
});
|
|
67
|
+
const RetrieveBtcArgs = IDL.Record({
|
|
68
|
+
'address' : IDL.Text,
|
|
69
|
+
'amount' : IDL.Nat64,
|
|
70
|
+
});
|
|
71
|
+
const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });
|
|
72
|
+
const RetrieveBtcError = IDL.Variant({
|
|
73
|
+
'MalformedAddress' : IDL.Text,
|
|
74
|
+
'GenericError' : IDL.Record({
|
|
75
|
+
'error_message' : IDL.Text,
|
|
76
|
+
'error_code' : IDL.Nat64,
|
|
77
|
+
}),
|
|
78
|
+
'TemporarilyUnavailable' : IDL.Text,
|
|
79
|
+
'AlreadyProcessing' : IDL.Null,
|
|
80
|
+
'AmountTooLow' : IDL.Nat64,
|
|
81
|
+
'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),
|
|
82
|
+
});
|
|
83
|
+
const RetrieveBtcStatus = IDL.Variant({
|
|
84
|
+
'Signing' : IDL.Null,
|
|
85
|
+
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
86
|
+
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
87
|
+
'AmountTooLow' : IDL.Null,
|
|
88
|
+
'Unknown' : IDL.Null,
|
|
89
|
+
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
90
|
+
'Pending' : IDL.Null,
|
|
91
|
+
});
|
|
92
|
+
const UpdateBalanceResult = IDL.Record({
|
|
93
|
+
'block_index' : IDL.Nat64,
|
|
94
|
+
'amount' : IDL.Nat64,
|
|
95
|
+
});
|
|
96
|
+
const UpdateBalanceError = IDL.Variant({
|
|
97
|
+
'GenericError' : IDL.Record({
|
|
98
|
+
'error_message' : IDL.Text,
|
|
99
|
+
'error_code' : IDL.Nat64,
|
|
100
|
+
}),
|
|
101
|
+
'TemporarilyUnavailable' : IDL.Text,
|
|
102
|
+
'AlreadyProcessing' : IDL.Null,
|
|
103
|
+
'NoNewUtxos' : IDL.Null,
|
|
104
|
+
});
|
|
105
|
+
return IDL.Service({
|
|
106
|
+
'get_btc_address' : IDL.Func(
|
|
107
|
+
[
|
|
108
|
+
IDL.Record({
|
|
109
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
110
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
[IDL.Text],
|
|
114
|
+
[],
|
|
115
|
+
),
|
|
116
|
+
'get_events' : IDL.Func(
|
|
117
|
+
[IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],
|
|
118
|
+
[IDL.Vec(Event)],
|
|
119
|
+
['query'],
|
|
120
|
+
),
|
|
121
|
+
'get_withdrawal_account' : IDL.Func([], [Account], []),
|
|
122
|
+
'retrieve_btc' : IDL.Func(
|
|
123
|
+
[RetrieveBtcArgs],
|
|
124
|
+
[IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],
|
|
125
|
+
[],
|
|
126
|
+
),
|
|
127
|
+
'retrieve_btc_status' : IDL.Func(
|
|
128
|
+
[IDL.Record({ 'block_index' : IDL.Nat64 })],
|
|
129
|
+
[RetrieveBtcStatus],
|
|
130
|
+
['query'],
|
|
131
|
+
),
|
|
132
|
+
'update_balance' : IDL.Func(
|
|
133
|
+
[
|
|
134
|
+
IDL.Record({
|
|
135
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
136
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
IDL.Variant({
|
|
141
|
+
'Ok' : UpdateBalanceResult,
|
|
142
|
+
'Err' : UpdateBalanceError,
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
[],
|
|
146
|
+
),
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export const init = ({ IDL }) => {
|
|
150
|
+
const Mode = IDL.Variant({
|
|
151
|
+
'RestrictedTo' : IDL.Vec(IDL.Principal),
|
|
152
|
+
'ReadOnly' : IDL.Null,
|
|
153
|
+
'GeneralAvailability' : IDL.Null,
|
|
154
|
+
});
|
|
155
|
+
const BtcNetwork = IDL.Variant({
|
|
156
|
+
'Mainnet' : IDL.Null,
|
|
157
|
+
'Regtest' : IDL.Null,
|
|
158
|
+
'Testnet' : IDL.Null,
|
|
159
|
+
});
|
|
160
|
+
const InitArgs = IDL.Record({
|
|
161
|
+
'ecdsa_key_name' : IDL.Text,
|
|
162
|
+
'mode' : Mode,
|
|
163
|
+
'retrieve_btc_min_amount' : IDL.Nat64,
|
|
164
|
+
'ledger_id' : IDL.Principal,
|
|
165
|
+
'max_time_in_queue_nanos' : IDL.Nat64,
|
|
166
|
+
'btc_network' : BtcNetwork,
|
|
167
|
+
'min_confirmations' : IDL.Opt(IDL.Nat32),
|
|
168
|
+
});
|
|
169
|
+
return [InitArgs];
|
|
170
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of g(t))!T.call(e,a)&&a!==r&&x(e,a,{get:()=>t[a],enumerable:!(n=b(t,a))||n.enumerable});return e};var y=e=>O(x({},"__esModule",{value:!0}),e);var w={};k(w,{CkBTCMinterCanister:()=>i});module.exports=y(w);var o=require("@dfinity/utils");var v=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),m=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),p=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],[]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[m],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:p,Err:R})],[])})};var V=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),m=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),p=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],["query"]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[m],["query"]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:p,Err:R})],[])})};var i=class extends o.Canister{constructor(){super(...arguments);this.getBtcAddress=r=>this.caller({certified:!0}).get_btc_address({owner:(0,o.toNullable)(r.owner),subaccount:(0,o.toNullable)(r.subaccount)})}static create(r){let{service:n,certifiedService:a,canisterId:c}=(0,o.createServices)({options:r,idlFactory:V,certifiedIdlFactory:v});return new i(c,n,a)}};0&&(module.exports={CkBTCMinterCanister});
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../src/minter.canister.ts", "../../candid/minter.certified.idl.js", "../../candid/minter.idl.js"],
|
|
4
|
+
"sourcesContent": ["export { CkBTCMinterCanister } from \"./minter.canister\";\nexport * from \"./types/minter.params\";\n", "import { Canister, createServices, toNullable } from \"@dfinity/utils\";\nimport type { _SERVICE as CkBTCMinterService } from \"../candid/minter\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/minter.certified.idl\";\nimport { idlFactory } from \"../candid/minter.idl\";\nimport type { CkBTCMinterCanisterOptions } from \"./types/canister.options\";\nimport type { GetBTCAddressParams } from \"./types/minter.params\";\n\nexport class CkBTCMinterCanister extends Canister<CkBTCMinterService> {\n static create(options: CkBTCMinterCanisterOptions<CkBTCMinterService>) {\n const { service, certifiedService, canisterId } =\n createServices<CkBTCMinterService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new CkBTCMinterCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Returns a BTC address for a given account.\n *\n * Note: an update call is required by the Minter canister.\n *\n * @param {GetBTCAddressParams} params The parameters for which a BTC address should be resolved.\n * @param {Principal} params.owner The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.\n * @param {Principal} params.subaccount An optional subaccount to compute the address.\n * @returns {Promise<string>} The BTC address of the given account.\n */\n getBtcAddress = (params: GetBTCAddressParams): Promise<string> =>\n this.caller({ certified: true }).get_btc_address({\n owner: toNullable(params.owner),\n subaccount: toNullable(params.subaccount),\n });\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n 'height' : IDL.Nat32,\n 'value' : IDL.Nat64,\n 'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),\n });\n const UpgradeArgs = IDL.Record({\n 'mode' : IDL.Opt(Mode),\n 'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),\n 'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const BitcoinAddress = IDL.Variant({\n 'p2sh' : IDL.Vec(IDL.Nat8),\n 'p2wpkh_v0' : IDL.Vec(IDL.Nat8),\n 'p2pkh' : IDL.Vec(IDL.Nat8),\n });\n const Event = IDL.Variant({\n 'received_utxos' : IDL.Record({\n 'to_account' : Account,\n 'utxos' : IDL.Vec(Utxo),\n }),\n 'sent_transaction' : IDL.Record({\n 'change_output' : IDL.Opt(\n IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })\n ),\n 'txid' : IDL.Vec(IDL.Nat8),\n 'utxos' : IDL.Vec(Utxo),\n 'requests' : IDL.Vec(IDL.Nat64),\n 'submitted_at' : IDL.Nat64,\n }),\n 'init' : InitArgs,\n 'upgrade' : UpgradeArgs,\n 'accepted_retrieve_btc_request' : IDL.Record({\n 'received_at' : IDL.Nat64,\n 'block_index' : IDL.Nat64,\n 'address' : BitcoinAddress,\n 'amount' : IDL.Nat64,\n }),\n 'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),\n 'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n });\n const RetrieveBtcArgs = IDL.Record({\n 'address' : IDL.Text,\n 'amount' : IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n 'MalformedAddress' : IDL.Text,\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'AmountTooLow' : IDL.Nat64,\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n 'Signing' : IDL.Null,\n 'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'AmountTooLow' : IDL.Null,\n 'Unknown' : IDL.Null,\n 'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Pending' : IDL.Null,\n });\n const UpdateBalanceResult = IDL.Record({\n 'block_index' : IDL.Nat64,\n 'amount' : IDL.Nat64,\n });\n const UpdateBalanceError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'NoNewUtxos' : IDL.Null,\n });\n return IDL.Service({\n 'get_btc_address' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n 'get_events' : IDL.Func(\n [IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],\n [IDL.Vec(Event)],\n [],\n ),\n 'get_withdrawal_account' : IDL.Func([], [Account], []),\n 'retrieve_btc' : IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],\n [],\n ),\n 'retrieve_btc_status' : IDL.Func(\n [IDL.Record({ 'block_index' : IDL.Nat64 })],\n [RetrieveBtcStatus],\n [],\n ),\n 'update_balance' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n 'Ok' : UpdateBalanceResult,\n 'Err' : UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n 'height' : IDL.Nat32,\n 'value' : IDL.Nat64,\n 'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),\n });\n const UpgradeArgs = IDL.Record({\n 'mode' : IDL.Opt(Mode),\n 'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),\n 'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const BitcoinAddress = IDL.Variant({\n 'p2sh' : IDL.Vec(IDL.Nat8),\n 'p2wpkh_v0' : IDL.Vec(IDL.Nat8),\n 'p2pkh' : IDL.Vec(IDL.Nat8),\n });\n const Event = IDL.Variant({\n 'received_utxos' : IDL.Record({\n 'to_account' : Account,\n 'utxos' : IDL.Vec(Utxo),\n }),\n 'sent_transaction' : IDL.Record({\n 'change_output' : IDL.Opt(\n IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })\n ),\n 'txid' : IDL.Vec(IDL.Nat8),\n 'utxos' : IDL.Vec(Utxo),\n 'requests' : IDL.Vec(IDL.Nat64),\n 'submitted_at' : IDL.Nat64,\n }),\n 'init' : InitArgs,\n 'upgrade' : UpgradeArgs,\n 'accepted_retrieve_btc_request' : IDL.Record({\n 'received_at' : IDL.Nat64,\n 'block_index' : IDL.Nat64,\n 'address' : BitcoinAddress,\n 'amount' : IDL.Nat64,\n }),\n 'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),\n 'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n });\n const RetrieveBtcArgs = IDL.Record({\n 'address' : IDL.Text,\n 'amount' : IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n 'MalformedAddress' : IDL.Text,\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'AmountTooLow' : IDL.Nat64,\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n 'Signing' : IDL.Null,\n 'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'AmountTooLow' : IDL.Null,\n 'Unknown' : IDL.Null,\n 'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Pending' : IDL.Null,\n });\n const UpdateBalanceResult = IDL.Record({\n 'block_index' : IDL.Nat64,\n 'amount' : IDL.Nat64,\n });\n const UpdateBalanceError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'NoNewUtxos' : IDL.Null,\n });\n return IDL.Service({\n 'get_btc_address' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n 'get_events' : IDL.Func(\n [IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],\n [IDL.Vec(Event)],\n ['query'],\n ),\n 'get_withdrawal_account' : IDL.Func([], [Account], []),\n 'retrieve_btc' : IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],\n [],\n ),\n 'retrieve_btc_status' : IDL.Func(\n [IDL.Record({ 'block_index' : IDL.Nat64 })],\n [RetrieveBtcStatus],\n ['query'],\n ),\n 'update_balance' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n 'Ok' : UpdateBalanceResult,\n 'Err' : UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n return [InitArgs];\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAqD,0BCC9C,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAOD,EAAI,QAAQ,CACvB,aAAiBA,EAAI,IAAIA,EAAI,SAAS,EACtC,SAAaA,EAAI,KACjB,oBAAwBA,EAAI,IAC9B,CAAC,EACKE,EAAaF,EAAI,QAAQ,CAC7B,QAAYA,EAAI,KAChB,QAAYA,EAAI,KAChB,QAAYA,EAAI,IAClB,CAAC,EACKG,EAAWH,EAAI,OAAO,CAC1B,eAAmBA,EAAI,KACvB,KAASC,EACT,wBAA4BD,EAAI,MAChC,UAAcA,EAAI,UAClB,wBAA4BA,EAAI,MAChC,YAAgBE,EAChB,kBAAsBF,EAAI,IAAIA,EAAI,KAAK,CACzC,CAAC,EACKI,EAAUJ,EAAI,OAAO,CACzB,MAAUA,EAAI,UACd,WAAeA,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,CAC1C,CAAC,EACKK,EAAOL,EAAI,OAAO,CACtB,OAAWA,EAAI,MACf,MAAUA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,CAAC,EAC1D,CAACA,EAAI,IAAIQ,CAAK,CAAC,EACf,CAAC,OAAO,CACV,EACF,uBAA2BR,EAAI,KAAK,CAAC,EAAG,CAACI,CAAO,EAAG,CAAC,CAAC,EACrD,aAAiBJ,EAAI,KACjB,CAACS,CAAe,EAChB,CAACT,EAAI,QAAQ,CAAE,GAAOU,EAAe,IAAQC,CAAiB,CAAC,CAAC,EAChE,CAAC,CACH,EACF,oBAAwBX,EAAI,KACxB,CAACA,EAAI,OAAO,CAAE,YAAgBA,EAAI,KAAM,CAAC,CAAC,EAC1C,CAACY,CAAiB,EAClB,CAAC,OAAO,CACV,EACF,eAAmBZ,EAAI,KACnB,CACEA,EAAI,OAAO,CACT,MAAUA,EAAI,IAAIA,EAAI,SAAS,EAC/B,WAAeA,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,CAC1C,CAAC,CACH,EACA,CACEA,EAAI,QAAQ,CACV,GAAOa,EACP,IAAQC,CACV,CAAC,CACH,EACA,CAAC,CACH,CACJ,CAAC,CACH,EF5IO,IAAMC,EAAN,cAAkC,UAA6B,CAA/D,kCAsBL,mBAAiBC,GACf,KAAK,OAAO,CAAE,UAAW,EAAK,CAAC,EAAE,gBAAgB,CAC/C,SAAO,cAAWA,EAAO,KAAK,EAC9B,cAAY,cAAWA,EAAO,UAAU,CAC1C,CAAC,EAzBH,OAAO,OAAOC,EAAyD,CACrE,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,WAAAC,CAAW,KAC5C,kBAAmC,CACjC,QAAAH,EACA,WAAAI,EACA,oBAAAA,CACF,CAAC,EAEH,OAAO,IAAIN,EAAoBK,EAAYF,EAASC,CAAgB,CACtE,CAiBF",
|
|
6
|
+
"names": ["src_exports", "__export", "CkBTCMinterCanister", "__toCommonJS", "import_utils", "idlFactory", "IDL", "Mode", "BtcNetwork", "InitArgs", "Account", "Utxo", "UpgradeArgs", "BitcoinAddress", "Event", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "UpdateBalanceResult", "UpdateBalanceError", "idlFactory", "IDL", "Mode", "BtcNetwork", "InitArgs", "Account", "Utxo", "UpgradeArgs", "BitcoinAddress", "Event", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "UpdateBalanceResult", "UpdateBalanceError", "CkBTCMinterCanister", "params", "options", "service", "certifiedService", "canisterId", "idlFactory"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Canister as V,createServices as b,toNullable as v}from"@dfinity/utils";var R=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),a=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:a,min_confirmations:e.Opt(e.Nat32)}),r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),i=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),s=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),d=e.Variant({received_utxos:e.Record({to_account:r,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:i,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:s,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),l=e.Record({address:e.Text,amount:e.Nat64}),u=e.Record({block_index:e.Nat64}),_=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),N=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),m=e.Record({block_index:e.Nat64,amount:e.Nat64}),p=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(d)],[]),get_withdrawal_account:e.Func([],[r],[]),retrieve_btc:e.Func([l],[e.Variant({Ok:u,Err:_})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[N],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:m,Err:p})],[])})};var x=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),a=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:a,min_confirmations:e.Opt(e.Nat32)}),r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),i=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),s=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),d=e.Variant({received_utxos:e.Record({to_account:r,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:i,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:s,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),l=e.Record({address:e.Text,amount:e.Nat64}),u=e.Record({block_index:e.Nat64}),_=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),N=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),m=e.Record({block_index:e.Nat64,amount:e.Nat64}),p=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(d)],["query"]),get_withdrawal_account:e.Func([],[r],[]),retrieve_btc:e.Func([l],[e.Variant({Ok:u,Err:_})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[N],["query"]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:m,Err:p})],[])})};var o=class extends V{static create(t){let{service:a,certifiedService:n,canisterId:r}=b({options:t,idlFactory:x,certifiedIdlFactory:R});return new o(r,a,n)}getBtcAddress=t=>this.caller({certified:!0}).get_btc_address({owner:v(t.owner),subaccount:v(t.subaccount)})};export{o as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7LX2K5RL.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/minter.canister.ts", "../../candid/minter.certified.idl.js", "../../candid/minter.idl.js"],
|
|
4
|
+
"sourcesContent": ["import { Canister, createServices, toNullable } from \"@dfinity/utils\";\nimport type { _SERVICE as CkBTCMinterService } from \"../candid/minter\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/minter.certified.idl\";\nimport { idlFactory } from \"../candid/minter.idl\";\nimport type { CkBTCMinterCanisterOptions } from \"./types/canister.options\";\nimport type { GetBTCAddressParams } from \"./types/minter.params\";\n\nexport class CkBTCMinterCanister extends Canister<CkBTCMinterService> {\n static create(options: CkBTCMinterCanisterOptions<CkBTCMinterService>) {\n const { service, certifiedService, canisterId } =\n createServices<CkBTCMinterService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new CkBTCMinterCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Returns a BTC address for a given account.\n *\n * Note: an update call is required by the Minter canister.\n *\n * @param {GetBTCAddressParams} params The parameters for which a BTC address should be resolved.\n * @param {Principal} params.owner The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.\n * @param {Principal} params.subaccount An optional subaccount to compute the address.\n * @returns {Promise<string>} The BTC address of the given account.\n */\n getBtcAddress = (params: GetBTCAddressParams): Promise<string> =>\n this.caller({ certified: true }).get_btc_address({\n owner: toNullable(params.owner),\n subaccount: toNullable(params.subaccount),\n });\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n 'height' : IDL.Nat32,\n 'value' : IDL.Nat64,\n 'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),\n });\n const UpgradeArgs = IDL.Record({\n 'mode' : IDL.Opt(Mode),\n 'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),\n 'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const BitcoinAddress = IDL.Variant({\n 'p2sh' : IDL.Vec(IDL.Nat8),\n 'p2wpkh_v0' : IDL.Vec(IDL.Nat8),\n 'p2pkh' : IDL.Vec(IDL.Nat8),\n });\n const Event = IDL.Variant({\n 'received_utxos' : IDL.Record({\n 'to_account' : Account,\n 'utxos' : IDL.Vec(Utxo),\n }),\n 'sent_transaction' : IDL.Record({\n 'change_output' : IDL.Opt(\n IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })\n ),\n 'txid' : IDL.Vec(IDL.Nat8),\n 'utxos' : IDL.Vec(Utxo),\n 'requests' : IDL.Vec(IDL.Nat64),\n 'submitted_at' : IDL.Nat64,\n }),\n 'init' : InitArgs,\n 'upgrade' : UpgradeArgs,\n 'accepted_retrieve_btc_request' : IDL.Record({\n 'received_at' : IDL.Nat64,\n 'block_index' : IDL.Nat64,\n 'address' : BitcoinAddress,\n 'amount' : IDL.Nat64,\n }),\n 'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),\n 'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n });\n const RetrieveBtcArgs = IDL.Record({\n 'address' : IDL.Text,\n 'amount' : IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n 'MalformedAddress' : IDL.Text,\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'AmountTooLow' : IDL.Nat64,\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n 'Signing' : IDL.Null,\n 'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'AmountTooLow' : IDL.Null,\n 'Unknown' : IDL.Null,\n 'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Pending' : IDL.Null,\n });\n const UpdateBalanceResult = IDL.Record({\n 'block_index' : IDL.Nat64,\n 'amount' : IDL.Nat64,\n });\n const UpdateBalanceError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'NoNewUtxos' : IDL.Null,\n });\n return IDL.Service({\n 'get_btc_address' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n 'get_events' : IDL.Func(\n [IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],\n [IDL.Vec(Event)],\n [],\n ),\n 'get_withdrawal_account' : IDL.Func([], [Account], []),\n 'retrieve_btc' : IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],\n [],\n ),\n 'retrieve_btc_status' : IDL.Func(\n [IDL.Record({ 'block_index' : IDL.Nat64 })],\n [RetrieveBtcStatus],\n [],\n ),\n 'update_balance' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n 'Ok' : UpdateBalanceResult,\n 'Err' : UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ckbtc/candid/minter.did */\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n 'height' : IDL.Nat32,\n 'value' : IDL.Nat64,\n 'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),\n });\n const UpgradeArgs = IDL.Record({\n 'mode' : IDL.Opt(Mode),\n 'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),\n 'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n const BitcoinAddress = IDL.Variant({\n 'p2sh' : IDL.Vec(IDL.Nat8),\n 'p2wpkh_v0' : IDL.Vec(IDL.Nat8),\n 'p2pkh' : IDL.Vec(IDL.Nat8),\n });\n const Event = IDL.Variant({\n 'received_utxos' : IDL.Record({\n 'to_account' : Account,\n 'utxos' : IDL.Vec(Utxo),\n }),\n 'sent_transaction' : IDL.Record({\n 'change_output' : IDL.Opt(\n IDL.Record({ 'value' : IDL.Nat64, 'vout' : IDL.Nat32 })\n ),\n 'txid' : IDL.Vec(IDL.Nat8),\n 'utxos' : IDL.Vec(Utxo),\n 'requests' : IDL.Vec(IDL.Nat64),\n 'submitted_at' : IDL.Nat64,\n }),\n 'init' : InitArgs,\n 'upgrade' : UpgradeArgs,\n 'accepted_retrieve_btc_request' : IDL.Record({\n 'received_at' : IDL.Nat64,\n 'block_index' : IDL.Nat64,\n 'address' : BitcoinAddress,\n 'amount' : IDL.Nat64,\n }),\n 'removed_retrieve_btc_request' : IDL.Record({ 'block_index' : IDL.Nat64 }),\n 'confirmed_transaction' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n });\n const RetrieveBtcArgs = IDL.Record({\n 'address' : IDL.Text,\n 'amount' : IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ 'block_index' : IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n 'MalformedAddress' : IDL.Text,\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'AmountTooLow' : IDL.Nat64,\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n 'Signing' : IDL.Null,\n 'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'AmountTooLow' : IDL.Null,\n 'Unknown' : IDL.Null,\n 'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),\n 'Pending' : IDL.Null,\n });\n const UpdateBalanceResult = IDL.Record({\n 'block_index' : IDL.Nat64,\n 'amount' : IDL.Nat64,\n });\n const UpdateBalanceError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'TemporarilyUnavailable' : IDL.Text,\n 'AlreadyProcessing' : IDL.Null,\n 'NoNewUtxos' : IDL.Null,\n });\n return IDL.Service({\n 'get_btc_address' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n 'get_events' : IDL.Func(\n [IDL.Record({ 'start' : IDL.Nat64, 'length' : IDL.Nat64 })],\n [IDL.Vec(Event)],\n ['query'],\n ),\n 'get_withdrawal_account' : IDL.Func([], [Account], []),\n 'retrieve_btc' : IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ 'Ok' : RetrieveBtcOk, 'Err' : RetrieveBtcError })],\n [],\n ),\n 'retrieve_btc_status' : IDL.Func(\n [IDL.Record({ 'block_index' : IDL.Nat64 })],\n [RetrieveBtcStatus],\n ['query'],\n ),\n 'update_balance' : IDL.Func(\n [\n IDL.Record({\n 'owner' : IDL.Opt(IDL.Principal),\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n 'Ok' : UpdateBalanceResult,\n 'Err' : UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n 'RestrictedTo' : IDL.Vec(IDL.Principal),\n 'ReadOnly' : IDL.Null,\n 'GeneralAvailability' : IDL.Null,\n });\n const BtcNetwork = IDL.Variant({\n 'Mainnet' : IDL.Null,\n 'Regtest' : IDL.Null,\n 'Testnet' : IDL.Null,\n });\n const InitArgs = IDL.Record({\n 'ecdsa_key_name' : IDL.Text,\n 'mode' : Mode,\n 'retrieve_btc_min_amount' : IDL.Nat64,\n 'ledger_id' : IDL.Principal,\n 'max_time_in_queue_nanos' : IDL.Nat64,\n 'btc_network' : BtcNetwork,\n 'min_confirmations' : IDL.Opt(IDL.Nat32),\n });\n return [InitArgs];\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,EAAU,kBAAAC,EAAgB,cAAAC,MAAkB,iBCC9C,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IA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MC,EAAN,cAAkCC,CAA6B,CACpE,OAAO,OAAOC,EAAyD,CACrE,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,WAAAC,CAAW,EAC5CC,EAAmC,CACjC,QAAAJ,EACA,WAAAK,EACA,oBAAAA,CACF,CAAC,EAEH,OAAO,IAAIP,EAAoBK,EAAYF,EAASC,CAAgB,CACtE,CAYA,cAAiBI,GACf,KAAK,OAAO,CAAE,UAAW,EAAK,CAAC,EAAE,gBAAgB,CAC/C,MAAOC,EAAWD,EAAO,KAAK,EAC9B,WAAYC,EAAWD,EAAO,UAAU,CAC1C,CAAC,CACL",
|
|
6
|
+
"names": ["Canister", "createServices", "toNullable", "idlFactory", "IDL", "Mode", "BtcNetwork", "InitArgs", "Account", "Utxo", "UpgradeArgs", "BitcoinAddress", "Event", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "UpdateBalanceResult", "UpdateBalanceError", "idlFactory", "IDL", "Mode", "BtcNetwork", "InitArgs", "Account", "Utxo", "UpgradeArgs", "BitcoinAddress", "Event", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "UpdateBalanceResult", "UpdateBalanceError", "CkBTCMinterCanister", "Canister", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory", "params", "toNullable"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./cjs/index.cjs.js');
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './esm/index.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Canister } from "@dfinity/utils";
|
|
2
|
+
import type { _SERVICE as CkBTCMinterService } from "../candid/minter";
|
|
3
|
+
import type { CkBTCMinterCanisterOptions } from "./types/canister.options";
|
|
4
|
+
import type { GetBTCAddressParams } from "./types/minter.params";
|
|
5
|
+
export declare class CkBTCMinterCanister extends Canister<CkBTCMinterService> {
|
|
6
|
+
static create(options: CkBTCMinterCanisterOptions<CkBTCMinterService>): CkBTCMinterCanister;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a BTC address for a given account.
|
|
9
|
+
*
|
|
10
|
+
* Note: an update call is required by the Minter canister.
|
|
11
|
+
*
|
|
12
|
+
* @param {GetBTCAddressParams} params The parameters for which a BTC address should be resolved.
|
|
13
|
+
* @param {Principal} params.owner The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.
|
|
14
|
+
* @param {Principal} params.subaccount An optional subaccount to compute the address.
|
|
15
|
+
* @returns {Promise<string>} The BTC address of the given account.
|
|
16
|
+
*/
|
|
17
|
+
getBtcAddress: (params: GetBTCAddressParams) => Promise<string>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Subaccount } from "@dfinity/ledger/candid/icrc1_ledger";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
|
+
import type { QueryParams } from "@dfinity/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Params to get a BTC address.
|
|
6
|
+
*/
|
|
7
|
+
export interface GetBTCAddressParams extends Omit<QueryParams, "certified"> {
|
|
8
|
+
owner?: Principal;
|
|
9
|
+
subaccount?: Subaccount;
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dfinity/ckbtc",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A library for interfacing with ckBTC.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/cjs/index.cjs.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"rmdir": "node ../../scripts/rmdir.mjs",
|
|
16
|
+
"ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
17
|
+
"build": "npm run rmdir && mkdir -p dist && cp -R candid dist && node esbuild.mjs && npm run ts-declaration",
|
|
18
|
+
"prepack": "npm run build",
|
|
19
|
+
"test": "jest"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/dfinity/ic-js.git",
|
|
24
|
+
"directory": "packages/ckbtc"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/dfinity/ic-js"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"internet computer",
|
|
31
|
+
"internet-computer",
|
|
32
|
+
"ic",
|
|
33
|
+
"dfinity",
|
|
34
|
+
"ckbtc",
|
|
35
|
+
"bitcoin",
|
|
36
|
+
"minter",
|
|
37
|
+
"token"
|
|
38
|
+
],
|
|
39
|
+
"homepage": "https://github.com/dfinity/ic-js#readme",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@dfinity/utils": "^0.0.12"
|
|
42
|
+
}
|
|
43
|
+
}
|