@dfinity/ckbtc 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -9
- package/dist/candid/minter.certified.idl.js +40 -0
- package/dist/candid/minter.d.ts +30 -0
- package/dist/candid/minter.did +57 -2
- package/dist/candid/minter.idl.js +40 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-GAS5QHUV.js +2 -0
- package/dist/esm/chunk-GAS5QHUV.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/minter.canister.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/minter.canister.d.ts +23 -2
- package/dist/types/types/minter.responses.d.ts +5 -1
- package/package.json +5 -5
- package/dist/esm/chunk-VQD66NVJ.js +0 -2
- package/dist/esm/chunk-VQD66NVJ.js.map +0 -7
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ Parameters:
|
|
|
78
78
|
|
|
79
79
|
### :factory: CkBTCMinterCanister
|
|
80
80
|
|
|
81
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
81
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L38)
|
|
82
82
|
|
|
83
83
|
#### Methods
|
|
84
84
|
|
|
@@ -88,6 +88,8 @@ Parameters:
|
|
|
88
88
|
- [getWithdrawalAccount](#gear-getwithdrawalaccount)
|
|
89
89
|
- [retrieveBtc](#gear-retrievebtc)
|
|
90
90
|
- [retrieveBtcWithApproval](#gear-retrievebtcwithapproval)
|
|
91
|
+
- [retrieveBtcStatus](#gear-retrievebtcstatus)
|
|
92
|
+
- [retrieveBtcStatusV2ByAccount](#gear-retrievebtcstatusv2byaccount)
|
|
91
93
|
- [estimateWithdrawalFee](#gear-estimatewithdrawalfee)
|
|
92
94
|
- [getMinterInfo](#gear-getminterinfo)
|
|
93
95
|
|
|
@@ -97,7 +99,7 @@ Parameters:
|
|
|
97
99
|
| -------- | ------------------------------------------------------------------------ |
|
|
98
100
|
| `create` | `(options: CkBTCMinterCanisterOptions<_SERVICE>) => CkBTCMinterCanister` |
|
|
99
101
|
|
|
100
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
102
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L39)
|
|
101
103
|
|
|
102
104
|
##### :gear: getBtcAddress
|
|
103
105
|
|
|
@@ -115,7 +117,7 @@ Parameters:
|
|
|
115
117
|
- `params.owner`: The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.
|
|
116
118
|
- `params.subaccount`: An optional subaccount to compute the address.
|
|
117
119
|
|
|
118
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
120
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L60)
|
|
119
121
|
|
|
120
122
|
##### :gear: updateBalance
|
|
121
123
|
|
|
@@ -133,7 +135,7 @@ Parameters:
|
|
|
133
135
|
- `params.owner`: The owner of the address. If not provided, the `caller` will be use instead.
|
|
134
136
|
- `params.subaccount`: An optional subaccount of the address.
|
|
135
137
|
|
|
136
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
138
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L79)
|
|
137
139
|
|
|
138
140
|
##### :gear: getWithdrawalAccount
|
|
139
141
|
|
|
@@ -143,7 +145,7 @@ Returns the account to which the caller should deposit ckBTC before withdrawing
|
|
|
143
145
|
| ---------------------- | ------------------------ |
|
|
144
146
|
| `getWithdrawalAccount` | `() => Promise<Account>` |
|
|
145
147
|
|
|
146
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
148
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L102)
|
|
147
149
|
|
|
148
150
|
##### :gear: retrieveBtc
|
|
149
151
|
|
|
@@ -167,7 +169,7 @@ Parameters:
|
|
|
167
169
|
- `params.address`: The bitcoin address.
|
|
168
170
|
- `params.amount`: The ckBTC amount.
|
|
169
171
|
|
|
170
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
172
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L121)
|
|
171
173
|
|
|
172
174
|
##### :gear: retrieveBtcWithApproval
|
|
173
175
|
|
|
@@ -193,7 +195,37 @@ Parameters:
|
|
|
193
195
|
- `params.fromSubaccount`: An optional subaccount from which
|
|
194
196
|
the ckBTC should be transferred.
|
|
195
197
|
|
|
196
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
198
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L151)
|
|
199
|
+
|
|
200
|
+
##### :gear: retrieveBtcStatus
|
|
201
|
+
|
|
202
|
+
Returns the status of a specific BTC withdrawal based on the transaction ID
|
|
203
|
+
of the corresponding burn transaction.
|
|
204
|
+
|
|
205
|
+
| Method | Type |
|
|
206
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| `retrieveBtcStatus` | `({ transactionId, certified, }: { transactionId: bigint; certified: boolean; }) => Promise<RetrieveBtcStatus>` |
|
|
208
|
+
|
|
209
|
+
Parameters:
|
|
210
|
+
|
|
211
|
+
- `transactionId`: The ID of the corresponding burn transaction.
|
|
212
|
+
- `certified`: query or update call
|
|
213
|
+
|
|
214
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L183)
|
|
215
|
+
|
|
216
|
+
##### :gear: retrieveBtcStatusV2ByAccount
|
|
217
|
+
|
|
218
|
+
Returns the status of all BTC withdrawals for the user's main account.
|
|
219
|
+
|
|
220
|
+
| Method | Type |
|
|
221
|
+
| ------------------------------ | ----------------------------------------------------------------------------------- |
|
|
222
|
+
| `retrieveBtcStatusV2ByAccount` | `({ certified, }: { certified: boolean; }) => Promise<RetrieveBtcStatusV2WithId[]>` |
|
|
223
|
+
|
|
224
|
+
Parameters:
|
|
225
|
+
|
|
226
|
+
- `certified`: query or update call
|
|
227
|
+
|
|
228
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L200)
|
|
197
229
|
|
|
198
230
|
##### :gear: estimateWithdrawalFee
|
|
199
231
|
|
|
@@ -209,7 +241,7 @@ Parameters:
|
|
|
209
241
|
- `params.certified`: query or update call
|
|
210
242
|
- `params.amount`: The optional amount for which the fee should be estimated.
|
|
211
243
|
|
|
212
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
244
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L221)
|
|
213
245
|
|
|
214
246
|
##### :gear: getMinterInfo
|
|
215
247
|
|
|
@@ -224,7 +256,7 @@ Parameters:
|
|
|
224
256
|
- `params`: The parameters to get the deposit fee.
|
|
225
257
|
- `params.certified`: query or update call
|
|
226
258
|
|
|
227
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
259
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L235)
|
|
228
260
|
|
|
229
261
|
<!-- TSDOC_END -->
|
|
230
262
|
|
|
@@ -117,6 +117,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
117
117
|
'received_at' : IDL.Nat64,
|
|
118
118
|
'block_index' : IDL.Nat64,
|
|
119
119
|
'address' : BitcoinAddress,
|
|
120
|
+
'reimbursement_account' : IDL.Opt(Account),
|
|
120
121
|
'amount' : IDL.Nat64,
|
|
121
122
|
'kyt_provider' : IDL.Opt(IDL.Principal),
|
|
122
123
|
}),
|
|
@@ -171,6 +172,28 @@ export const idlFactory = ({ IDL }) => {
|
|
|
171
172
|
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
172
173
|
'Pending' : IDL.Null,
|
|
173
174
|
});
|
|
175
|
+
const ReimbursementRequest = IDL.Record({
|
|
176
|
+
'account' : Account,
|
|
177
|
+
'amount' : IDL.Nat64,
|
|
178
|
+
'reason' : ReimbursementReason,
|
|
179
|
+
});
|
|
180
|
+
const ReimbursedDeposit = IDL.Record({
|
|
181
|
+
'account' : Account,
|
|
182
|
+
'mint_block_index' : IDL.Nat64,
|
|
183
|
+
'amount' : IDL.Nat64,
|
|
184
|
+
'reason' : ReimbursementReason,
|
|
185
|
+
});
|
|
186
|
+
const RetrieveBtcStatusV2 = IDL.Variant({
|
|
187
|
+
'Signing' : IDL.Null,
|
|
188
|
+
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
189
|
+
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
190
|
+
'AmountTooLow' : IDL.Null,
|
|
191
|
+
'WillReimburse' : ReimbursementRequest,
|
|
192
|
+
'Unknown' : IDL.Null,
|
|
193
|
+
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
194
|
+
'Reimbursed' : ReimbursedDeposit,
|
|
195
|
+
'Pending' : IDL.Null,
|
|
196
|
+
});
|
|
174
197
|
const RetrieveBtcWithApprovalArgs = IDL.Record({
|
|
175
198
|
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
176
199
|
'address' : IDL.Text,
|
|
@@ -251,6 +274,23 @@ export const idlFactory = ({ IDL }) => {
|
|
|
251
274
|
[RetrieveBtcStatus],
|
|
252
275
|
[],
|
|
253
276
|
),
|
|
277
|
+
'retrieve_btc_status_v2' : IDL.Func(
|
|
278
|
+
[IDL.Record({ 'block_index' : IDL.Nat64 })],
|
|
279
|
+
[RetrieveBtcStatusV2],
|
|
280
|
+
[],
|
|
281
|
+
),
|
|
282
|
+
'retrieve_btc_status_v2_by_account' : IDL.Func(
|
|
283
|
+
[IDL.Opt(Account)],
|
|
284
|
+
[
|
|
285
|
+
IDL.Vec(
|
|
286
|
+
IDL.Record({
|
|
287
|
+
'block_index' : IDL.Nat64,
|
|
288
|
+
'status_v2' : IDL.Opt(RetrieveBtcStatusV2),
|
|
289
|
+
})
|
|
290
|
+
),
|
|
291
|
+
],
|
|
292
|
+
[],
|
|
293
|
+
),
|
|
254
294
|
'retrieve_btc_with_approval' : IDL.Func(
|
|
255
295
|
[RetrieveBtcWithApprovalArgs],
|
|
256
296
|
[
|
package/dist/candid/minter.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export type Event =
|
|
|
83
83
|
received_at: bigint;
|
|
84
84
|
block_index: bigint;
|
|
85
85
|
address: BitcoinAddress;
|
|
86
|
+
reimbursement_account: [] | [Account];
|
|
86
87
|
amount: bigint;
|
|
87
88
|
kyt_provider: [] | [Principal];
|
|
88
89
|
};
|
|
@@ -140,9 +141,20 @@ export interface PendingUtxo {
|
|
|
140
141
|
value: bigint;
|
|
141
142
|
outpoint: { txid: Uint8Array | number[]; vout: number };
|
|
142
143
|
}
|
|
144
|
+
export interface ReimbursedDeposit {
|
|
145
|
+
account: Account;
|
|
146
|
+
mint_block_index: bigint;
|
|
147
|
+
amount: bigint;
|
|
148
|
+
reason: ReimbursementReason;
|
|
149
|
+
}
|
|
143
150
|
export type ReimbursementReason =
|
|
144
151
|
| { CallFailed: null }
|
|
145
152
|
| { TaintedDestination: { kyt_fee: bigint; kyt_provider: Principal } };
|
|
153
|
+
export interface ReimbursementRequest {
|
|
154
|
+
account: Account;
|
|
155
|
+
amount: bigint;
|
|
156
|
+
reason: ReimbursementReason;
|
|
157
|
+
}
|
|
146
158
|
export interface RetrieveBtcArgs {
|
|
147
159
|
address: string;
|
|
148
160
|
amount: bigint;
|
|
@@ -165,6 +177,16 @@ export type RetrieveBtcStatus =
|
|
|
165
177
|
| { Unknown: null }
|
|
166
178
|
| { Submitted: { txid: Uint8Array | number[] } }
|
|
167
179
|
| { Pending: null };
|
|
180
|
+
export type RetrieveBtcStatusV2 =
|
|
181
|
+
| { Signing: null }
|
|
182
|
+
| { Confirmed: { txid: Uint8Array | number[] } }
|
|
183
|
+
| { Sending: { txid: Uint8Array | number[] } }
|
|
184
|
+
| { AmountTooLow: null }
|
|
185
|
+
| { WillReimburse: ReimbursementRequest }
|
|
186
|
+
| { Unknown: null }
|
|
187
|
+
| { Submitted: { txid: Uint8Array | number[] } }
|
|
188
|
+
| { Reimbursed: ReimbursedDeposit }
|
|
189
|
+
| { Pending: null };
|
|
168
190
|
export interface RetrieveBtcWithApprovalArgs {
|
|
169
191
|
from_subaccount: [] | [Uint8Array | number[]];
|
|
170
192
|
address: string;
|
|
@@ -242,6 +264,14 @@ export interface _SERVICE {
|
|
|
242
264
|
[{ block_index: bigint }],
|
|
243
265
|
RetrieveBtcStatus
|
|
244
266
|
>;
|
|
267
|
+
retrieve_btc_status_v2: ActorMethod<
|
|
268
|
+
[{ block_index: bigint }],
|
|
269
|
+
RetrieveBtcStatusV2
|
|
270
|
+
>;
|
|
271
|
+
retrieve_btc_status_v2_by_account: ActorMethod<
|
|
272
|
+
[[] | [Account]],
|
|
273
|
+
Array<{ block_index: bigint; status_v2: [] | [RetrieveBtcStatusV2] }>
|
|
274
|
+
>;
|
|
245
275
|
retrieve_btc_with_approval: ActorMethod<
|
|
246
276
|
[RetrieveBtcWithApprovalArgs],
|
|
247
277
|
{ Ok: RetrieveBtcOk } | { Err: RetrieveBtcWithApprovalError }
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit a8e25a31a (2023-12-12) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
|
|
2
2
|
// Represents an account on the ckBTC ledger.
|
|
3
3
|
type Account = record { owner : principal; subaccount : opt blob };
|
|
4
4
|
|
|
@@ -233,6 +233,48 @@ type RetrieveBtcStatus = variant {
|
|
|
233
233
|
Confirmed : record { txid : blob };
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
type ReimbursementRequest = record {
|
|
237
|
+
account : Account;
|
|
238
|
+
amount : nat64;
|
|
239
|
+
reason : ReimbursementReason;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type ReimbursedDeposit = record {
|
|
243
|
+
account : Account;
|
|
244
|
+
mint_block_index : nat64;
|
|
245
|
+
amount : nat64;
|
|
246
|
+
reason : ReimbursementReason;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
type RetrieveBtcStatusV2 = variant {
|
|
250
|
+
// The minter does not have any information on the specified
|
|
251
|
+
// retrieval request. It can be that nobody submitted the
|
|
252
|
+
// request or the minter pruned the relevant information from the
|
|
253
|
+
// history to save space.
|
|
254
|
+
Unknown;
|
|
255
|
+
// The minter did not send a Bitcoin transaction for this request yet.
|
|
256
|
+
Pending;
|
|
257
|
+
// The minter is obtaining all required ECDSA signatures on the
|
|
258
|
+
// Bitcoin transaction for this request.
|
|
259
|
+
Signing;
|
|
260
|
+
// The minter signed the transaction and is waiting for a reply
|
|
261
|
+
// from the Bitcoin canister.
|
|
262
|
+
Sending : record { txid : blob };
|
|
263
|
+
// The minter sent a transaction for the retrieve request.
|
|
264
|
+
// The payload contains the identifier of the transaction on the Bitcoin network.
|
|
265
|
+
Submitted : record { txid : blob };
|
|
266
|
+
// The amount was too low to cover the transaction fees.
|
|
267
|
+
AmountTooLow;
|
|
268
|
+
// The minter received enough confirmations for the Bitcoin
|
|
269
|
+
// transaction for this request. The payload contains the
|
|
270
|
+
// identifier of the transaction on the Bitcoin network.
|
|
271
|
+
Confirmed : record { txid : blob };
|
|
272
|
+
/// The retrieve bitcoin request has been reimbursed.
|
|
273
|
+
Reimbursed : ReimbursedDeposit;
|
|
274
|
+
/// The minter will try to reimburse this transaction.
|
|
275
|
+
WillReimburse : ReimbursementRequest;
|
|
276
|
+
};
|
|
277
|
+
|
|
236
278
|
type Utxo = record {
|
|
237
279
|
outpoint : record { txid : vec nat8; vout : nat32 };
|
|
238
280
|
value : nat64;
|
|
@@ -271,6 +313,7 @@ type Event = variant {
|
|
|
271
313
|
block_index : nat64;
|
|
272
314
|
received_at : nat64;
|
|
273
315
|
kyt_provider : opt principal;
|
|
316
|
+
reimbursement_account : opt Account;
|
|
274
317
|
};
|
|
275
318
|
distributed_kyt_fee : record {
|
|
276
319
|
kyt_provider : principal;
|
|
@@ -389,9 +432,21 @@ service : (minter_arg : MinterArg) -> {
|
|
|
389
432
|
// using [icrc2_approve] on the ckBTC ledger.
|
|
390
433
|
retrieve_btc_with_approval : (RetrieveBtcWithApprovalArgs) -> (variant { Ok : RetrieveBtcOk; Err : RetrieveBtcWithApprovalError });
|
|
391
434
|
|
|
392
|
-
/// Returns the status of a
|
|
435
|
+
/// [deprecated] Returns the status of a withdrawal request.
|
|
436
|
+
/// You should use retrieve_btc_status_v2 to retrieve the status of your withdrawal request.
|
|
393
437
|
retrieve_btc_status : (record { block_index : nat64 }) -> (RetrieveBtcStatus) query;
|
|
394
438
|
|
|
439
|
+
/// Returns the status of a withdrawal request request using the RetrieveBtcStatusV2 type.
|
|
440
|
+
retrieve_btc_status_v2 : (record { block_index : nat64 }) -> (RetrieveBtcStatusV2) query;
|
|
441
|
+
|
|
442
|
+
// Returns the withdrawal statues by account.
|
|
443
|
+
//
|
|
444
|
+
// # Note
|
|
445
|
+
// The _v2_ part indicates that you get a response in line with the retrieve_btc_status_v2 endpoint,
|
|
446
|
+
// i.e., you get a vector of RetrieveBtcStatusV2 and not RetrieveBtcStatus.
|
|
447
|
+
//
|
|
448
|
+
retrieve_btc_status_v2_by_account : (opt Account) -> (vec record { block_index: nat64; status_v2: opt RetrieveBtcStatusV2; }) query;
|
|
449
|
+
|
|
395
450
|
// }}} Section "Convert ckBTC to BTC"
|
|
396
451
|
|
|
397
452
|
// Section "Minter Information" {{{
|
|
@@ -117,6 +117,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
117
117
|
'received_at' : IDL.Nat64,
|
|
118
118
|
'block_index' : IDL.Nat64,
|
|
119
119
|
'address' : BitcoinAddress,
|
|
120
|
+
'reimbursement_account' : IDL.Opt(Account),
|
|
120
121
|
'amount' : IDL.Nat64,
|
|
121
122
|
'kyt_provider' : IDL.Opt(IDL.Principal),
|
|
122
123
|
}),
|
|
@@ -171,6 +172,28 @@ export const idlFactory = ({ IDL }) => {
|
|
|
171
172
|
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
172
173
|
'Pending' : IDL.Null,
|
|
173
174
|
});
|
|
175
|
+
const ReimbursementRequest = IDL.Record({
|
|
176
|
+
'account' : Account,
|
|
177
|
+
'amount' : IDL.Nat64,
|
|
178
|
+
'reason' : ReimbursementReason,
|
|
179
|
+
});
|
|
180
|
+
const ReimbursedDeposit = IDL.Record({
|
|
181
|
+
'account' : Account,
|
|
182
|
+
'mint_block_index' : IDL.Nat64,
|
|
183
|
+
'amount' : IDL.Nat64,
|
|
184
|
+
'reason' : ReimbursementReason,
|
|
185
|
+
});
|
|
186
|
+
const RetrieveBtcStatusV2 = IDL.Variant({
|
|
187
|
+
'Signing' : IDL.Null,
|
|
188
|
+
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
189
|
+
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
190
|
+
'AmountTooLow' : IDL.Null,
|
|
191
|
+
'WillReimburse' : ReimbursementRequest,
|
|
192
|
+
'Unknown' : IDL.Null,
|
|
193
|
+
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
|
|
194
|
+
'Reimbursed' : ReimbursedDeposit,
|
|
195
|
+
'Pending' : IDL.Null,
|
|
196
|
+
});
|
|
174
197
|
const RetrieveBtcWithApprovalArgs = IDL.Record({
|
|
175
198
|
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
176
199
|
'address' : IDL.Text,
|
|
@@ -251,6 +274,23 @@ export const idlFactory = ({ IDL }) => {
|
|
|
251
274
|
[RetrieveBtcStatus],
|
|
252
275
|
['query'],
|
|
253
276
|
),
|
|
277
|
+
'retrieve_btc_status_v2' : IDL.Func(
|
|
278
|
+
[IDL.Record({ 'block_index' : IDL.Nat64 })],
|
|
279
|
+
[RetrieveBtcStatusV2],
|
|
280
|
+
['query'],
|
|
281
|
+
),
|
|
282
|
+
'retrieve_btc_status_v2_by_account' : IDL.Func(
|
|
283
|
+
[IDL.Opt(Account)],
|
|
284
|
+
[
|
|
285
|
+
IDL.Vec(
|
|
286
|
+
IDL.Record({
|
|
287
|
+
'block_index' : IDL.Nat64,
|
|
288
|
+
'status_v2' : IDL.Opt(RetrieveBtcStatusV2),
|
|
289
|
+
})
|
|
290
|
+
),
|
|
291
|
+
],
|
|
292
|
+
['query'],
|
|
293
|
+
),
|
|
254
294
|
'retrieve_btc_with_approval' : IDL.Func(
|
|
255
295
|
[RetrieveBtcWithApprovalArgs],
|
|
256
296
|
[
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var We=Object.create;var W=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!je.call(e,o)&&o!==r&&W(e,o,{get:()=>t[o],enumerable:!(n=Ge(t,o))||n.enumerable});return e};var be=(e,t,r)=>(r=e!=null?We(He(e)):{},Ne(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),Xe=e=>Ne(W({},"__esModule",{value:!0}),e);var L=A((qt,ve)=>{"use strict";var et="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ve.exports=et});var Ae=A((Wt,ke)=>{"use strict";var tt=L(),rt=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map(o=>tt.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let a=i*58+c;return c=a>>8,a}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};ke.exports=rt});var Pe=A((Gt,Ve)=>{"use strict";var Oe=L(),nt=()=>{let e=Array(256).fill(-1);for(let t=0;t<Oe.length;++t)e[Oe.charCodeAt(t)]=t;return e};Ve.exports=nt});var Ee=A(($t,Be)=>{"use strict";var Te=L(),ot=Pe(),it=ot(),ct=e=>{let t=[];for(let r of e){let n=r;for(let o=0;o<t.length;++o){let c=(it[t[o]]<<8)+n;t[o]=Te.charCodeAt(c%58),n=c/58|0}for(;n;)t.push(Te.charCodeAt(n%58)),n=n/58|0}for(let r of e){if(r)break;t.push("1".charCodeAt(0))}return t.reverse(),String.fromCharCode(...t)};Be.exports=ct});var Ue=A(he=>{"use strict";he.base58_to_binary=Ae();he.binary_to_base58=Ee()});var Se=A(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bech32m=B.bech32=void 0;var D="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Fe={};for(let e=0;e<D.length;e++){let t=D.charAt(e);Fe[t]=e}function T(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ce(e){let t=1;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=T(t)^n>>5}t=T(t);for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);t=T(t)^n&31}return t}function xe(e,t,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(o=o<<t|e[u],c+=t;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=t)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function at(e){return xe(e,8,5,!0)}function st(e){let t=xe(e,5,8,!1);if(Array.isArray(t))return t}function dt(e){let t=xe(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Me(e){let t;e==="bech32"?t=1:t=734539939;function r(i,a,u){if(u=u||90,i.length+7+a.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Ce(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let s=0;s<a.length;++s){let p=a[s];if(p>>5)throw new Error("Non 5-bit word");l=T(l)^p,d+=D.charAt(p)}for(let s=0;s<6;++s)l=T(l);l^=t;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=D.charAt(p)}return d}function n(i,a){if(a=a||90,i.length<8)return i+" too short";if(i.length>a)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let s=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Ce(s);if(typeof f=="string")return f;let h=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),g=Fe[b];if(g===void 0)return"Unknown character "+b;f=T(f)^g,!(_+6>=p.length)&&h.push(g)}return f!==t?"Invalid checksum for "+i:{prefix:s,words:h}}function o(i,a){let u=n(i,a);if(typeof u=="object")return u}function c(i,a){let u=n(i,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:c,encode:r,toWords:at,fromWordsUnsafe:st,fromWords:dt}}B.bech32=Me("bech32");B.bech32m=Me("bech32m")});var Nt={};ze(Nt,{BtcAddressType:()=>ae,BtcNetwork:()=>ce,CkBTCMinterCanister:()=>K,MinterAlreadyProcessingError:()=>$,MinterAmountTooLowError:()=>z,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>X,MinterMalformedAddressError:()=>j,MinterNoNewUtxosError:()=>H,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>G,MinterUpdateBalanceError:()=>S,ParseBtcAddressBadWitnessLengthError:()=>U,ParseBtcAddressError:()=>x,ParseBtcAddressInvalidError:()=>O,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>F,ParseBtcAddressUnsupportedAddressTypeError:()=>V,ParseBtcAddressUnsupportedWitnessVersionError:()=>C,ParseBtcAddressWrongNetworkError:()=>M,createRetrieveBtcError:()=>Q,createRetrieveBtcWithApprovalError:()=>ue,createUpdateBalanceError:()=>de,parseBtcAddress:()=>mt});module.exports=Xe(Nt);var ce=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ce||{}),ae=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(ae||{});var x=class extends Error{},O=class extends x{},E=class extends x{},V=class extends x{},U=class extends x{},C=class extends x{},F=class extends x{},k=class extends x{},M=class extends x{};var P=require("@dfinity/utils"),w=class extends Error{},G=class extends w{},$=class extends w{},S=class extends w{},H=class extends S{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,P.fromNullable)(r)||[],this.requiredConfirmations=n}},y=class extends w{},j=class extends y{},z=class extends y{},X=class extends y{},J=class extends y{},se=e=>{if("GenericError"in e){let{GenericError:{error_message:t,error_code:r}}=e;return new w(`${t} (${r})`)}if("TemporarilyUnavailable"in e)return new G(e.TemporarilyUnavailable);if("AlreadyProcessing"in e)return new $},de=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"NoNewUtxos"in e?new H(e.NoNewUtxos):new S(`Unsupported response type in minter.updateBalance ${JSON.stringify(e)}`)},Q=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"MalformedAddress"in e?new j(e.MalformedAddress):"AmountTooLow"in e?new z(`${e.AmountTooLow}`):"InsufficientFunds"in e?new X(`${e.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(e)}`)},ue=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"InsufficientAllowance"in e?new J(`${e.InsufficientAllowance.allowance}`):Q(e)};var m=require("@dfinity/utils");var ge=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),g=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})}),ee=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}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Record({confirmations:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),ie=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,pending_utxos:e.Opt(e.Vec(oe)),current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],[]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],[]),get_minter_info:e.Func([],[h],[]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],[]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:ie})],[])})};var we=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),g=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})}),ee=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}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Record({confirmations:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),ie=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,pending_utxos:e.Opt(e.Vec(oe)),current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],["query"]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],["query"]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],["query"]),get_minter_info:e.Func([],[h],["query"]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],["query"]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:ie})],[])})};var K=class e extends m.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});if("Err"in o)throw de(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw Q(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,m.toNullable)(o)});if("Err"in c)throw ue(c.Err);return c.Ok};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,m.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,m.createServices)({options:r,idlFactory:we,certifiedIdlFactory:ge});return new e(c,n,o)}};var me=require("@dfinity/utils");function Je(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function le(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ye(e,t){Je(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Qe=e=>e instanceof Uint8Array;var Z=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),N=(e,t)=>e<<32-t|e>>>t,Ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ke)throw new Error("Non little-endian hardware is not supported");function Ye(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function pe(e){if(typeof e=="string"&&(e=Ye(e)),!Qe(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var Y=class{clone(){return this._cloneInto()}},Tt={}.toString;function Re(e){let t=n=>e().update(pe(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ze(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),a=Number(r&c),u=n?4:0,l=n?0:4;e.setUint32(t+u,i,n),e.setUint32(t+l,a,n)}var I=class extends Y{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Z(this.buffer)}update(t){le(this);let{view:r,buffer:n,blockLen:o}=this;t=pe(t);let c=t.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=Z(t);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){le(this),ye(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let s=i;s<o;s++)r[s]=0;Ze(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=Z(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<l;s++)a.setUint32(4*s,d[s],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=c,t.destroyed=i,o%r&&t.buffer.set(n),t}};var Ie=(e,t,r)=>e&t^~e&r,Le=(e,t,r)=>e&t^e&r^t&r,De=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),fe=class extends I{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:t,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[t,r,n,o,c,i,a,u]}set(t,r,n,o,c,i,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=a|0,this.H=u|0}process(t,r){for(let s=0;s<16;s++,r+=4)v[s]=t.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],h=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+h+v[s-16]|0}let{A:n,B:o,C:c,D:i,E:a,F:u,G:l,H:d}=this;for(let s=0;s<64;s++){let p=N(a,6)^N(a,11)^N(a,25),f=d+p+Ie(a,u,l)+De[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+Le(n,o,c)|0;d=l,l=u,u=a,a=i+f|0,i=c,c=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,c,i,a,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var _e=Re(()=>new fe);var qe=be(Ue()),q=be(Se());var ut=0,lt=5,pt=111,ft=196,_t={[ut]:{type:1,networks:[0]},[pt]:{type:1,networks:[2,1]},[lt]:{type:2,networks:[0]},[ft]:{type:2,networks:[2,1]}},ht=({address:e,network:t})=>{let n=(d=>{try{return(0,qe.base58_to_binary)(d)}catch{throw new O}})(e),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let s=d.slice(o-4,o),p=d.slice(0,o-4),f=_e.create();f.update(p);let h=_e.create();h.update(f.digest());let _=h.digest().slice(0,4);if(s.some((b,g)=>b!==_[g]))throw new k(`Checksum mismatch expected ${s}, got ${_}.`)})(n);let i=n[0],a=_t[i];if((0,me.isNullish)(a))throw new V;let{type:u,networks:l}=a;if(!l.includes(t))throw new M;return{address:e,network:t,type:u,parser:"base58"}},xt=({address:e,network:t})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?q.bech32m.decode(d):q.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(e),i={bc:0,tb:2,bcrt:1}[n];if((0,me.isNullish)(i))throw new O;if(i!==t)throw new F;let[a,...u]=o;if(a>1)throw new C;switch(q.bech32.fromWords(u).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:a===0?3:4,parser:"bip-173"};default:throw new U}},mt=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ht({address:e,network:t});case"b":case"B":case"t":case"T":return xt({address:e,network:t});case"":throw new E;default:throw new V}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
1
|
+
"use strict";var Ht=Object.create;var G=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=jt(e,o))||n.enumerable});return t};var yt=(t,e,r)=>(r=t!=null?Ht(Xt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Kt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A(($e,Vt)=>{"use strict";var ne="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Vt.exports=ne});var Bt=A((He,Ot)=>{"use strict";var oe=D(),ie=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>oe.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let a=i*58+c;return c=a>>8,a}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};Ot.exports=ie});var Ut=A((je,Tt)=>{"use strict";var Pt=D(),ce=()=>{let t=Array(256).fill(-1);for(let e=0;e<Pt.length;++e)t[Pt.charCodeAt(e)]=e;return t};Tt.exports=ce});var Ft=A((ze,Ct)=>{"use strict";var Et=D(),ae=Ut(),se=ae(),de=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let c=(se[e[o]]<<8)+n;e[o]=Et.charCodeAt(c%58),n=c/58|0}for(;n;)e.push(Et.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push("1".charCodeAt(0))}return e.reverse(),String.fromCharCode(...e)};Ct.exports=de});var St=A(Nt=>{"use strict";Nt.base58_to_binary=Bt();Nt.binary_to_base58=Ft()});var Gt=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",qt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);qt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function bt(t,e,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<t.length;++u)for(o=o<<e|t[u],c+=e;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=e)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function ue(t){return bt(t,8,5,!0)}function le(t){let e=bt(t,5,8,!1);if(Array.isArray(e))return e}function pe(t){let e=bt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Wt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,a,u){if(u=u||90,i.length+7+a.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let s=0;s<a.length;++s){let p=a[s];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,d+=tt.charAt(p)}for(let s=0;s<6;++s)l=P(l);l^=e;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=tt.charAt(p)}return d}function n(i,a){if(a=a||90,i.length<8)return i+" too short";if(i.length>a)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let s=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Mt(s);if(typeof f=="string")return f;let x=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),g=qt[b];if(g===void 0)return"Unknown character "+b;f=P(f)^g,!(_+6>=p.length)&&x.push(g)}return f!==e?"Invalid checksum for "+i:{prefix:s,words:x}}function o(i,a){let u=n(i,a);if(typeof u=="object")return u}function c(i,a){let u=n(i,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:c,encode:r,toWords:ue,fromWordsUnsafe:le,fromWords:pe}}T.bech32=Wt("bech32");T.bech32m=Wt("bech32m")});var we={};Qt(we,{BtcAddressType:()=>ut,BtcNetwork:()=>dt,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>Q,MinterInsufficientFundsError:()=>J,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>q,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>h,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>M,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>ft,createUpdateBalanceError:()=>pt,parseBtcAddress:()=>ge});module.exports=Kt(we);var dt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(dt||{}),ut=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(ut||{});var h=class extends Error{},V=class extends h{},E=class extends h{},O=class extends h{},C=class extends h{},F=class extends h{},S=class extends h{},k=class extends h{},M=class extends h{};var B=require("@dfinity/utils"),w=class extends Error{},$=class extends w{},H=class extends w{},q=class extends w{},j=class extends q{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,B.fromNullable)(r)||[],this.requiredConfirmations=n}},y=class extends w{},z=class extends y{},X=class extends y{},J=class extends y{},Q=class extends y{},lt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new w(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},pt=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new q(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new J(`${t.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},ft=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new Q(`${t.InsufficientAllowance.allowance}`):K(t)};var m=require("@dfinity/utils");var Rt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),a=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:a,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),d=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),s=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),f=t.Variant({received_utxos:t.Record({to_account:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(d)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:s}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(d),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:d,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),x=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),_=t.Record({address:t.Text,amount:t.Nat64}),b=t.Record({block_index:t.Nat64}),g=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),et=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),rt=t.Record({account:l,amount:t.Nat64,reason:s}),nt=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:s}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:rt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:nt,Pending:t.Null}),ot=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),it=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),ct=t.Variant({ValueTooSmall:d,Tainted:d,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:d}),Checked:d}),at=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(at)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[u],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],[]),get_minter_info:t.Func([],[x],[]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([_],[t.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[et],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([ot],[t.Variant({Ok:b,Err:it})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:st})],[])})};var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),a=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:a,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),d=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),s=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),f=t.Variant({received_utxos:t.Record({to_account:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(d)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:s}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(d),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:d,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),x=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),_=t.Record({address:t.Text,amount:t.Nat64}),b=t.Record({block_index:t.Nat64}),g=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),et=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),rt=t.Record({account:l,amount:t.Nat64,reason:s}),nt=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:s}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:rt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:nt,Pending:t.Null}),ot=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),it=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),ct=t.Variant({ValueTooSmall:d,Tainted:d,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:d}),Checked:d}),at=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(at)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[u],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],["query"]),get_minter_info:t.Func([],[x],["query"]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([_],[t.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[et],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([ot],[t.Variant({Ok:b,Err:it})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:st})],[])})};var Y=class t extends m.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});if("Err"in o)throw pt(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw K(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,m.toNullable)(o)});if("Err"in c)throw ft(c.Err);return c.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({certified:r})=>(await this.caller({certified:r}).retrieve_btc_status_v2_by_account([])).map(({block_index:o,status_v2:c})=>({id:o,status:(0,m.fromNullable)(c)}));this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,m.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,m.createServices)({options:r,idlFactory:vt,certifiedIdlFactory:Rt});return new t(c,n,o)}};var gt=require("@dfinity/utils");function Yt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function _t(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kt(t,e){Yt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Zt=t=>t instanceof Uint8Array;var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),N=(t,e)=>t<<32-e|t>>>e,It=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!It)throw new Error("Non little-endian hardware is not supported");function Lt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function mt(t){if(typeof t=="string"&&(t=Lt(t)),!Zt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Ee={}.toString;function At(t){let e=n=>t().update(mt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Dt(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),a=Number(r&c),u=n?4:0,l=n?0:4;t.setUint32(e+u,i,n),t.setUint32(e+l,a,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){_t(this);let{view:r,buffer:n,blockLen:o}=this;e=mt(e);let c=e.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=I(e);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_t(this),kt(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let s=i;s<o;s++)r[s]=0;Dt(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=I(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<l;s++)a.setUint32(4*s,d[s],c)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=c,e.destroyed=i,o%r&&e.buffer.set(n),e}};var te=(t,e,r)=>t&e^~t&r,ee=(t,e,r)=>t&e^t&r^e&r,re=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),xt=class extends L{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:e,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[e,r,n,o,c,i,a,u]}set(e,r,n,o,c,i,a,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=a|0,this.H=u|0}process(e,r){for(let s=0;s<16;s++,r+=4)v[s]=e.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],x=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+x+v[s-16]|0}let{A:n,B:o,C:c,D:i,E:a,F:u,G:l,H:d}=this;for(let s=0;s<64;s++){let p=N(a,6)^N(a,11)^N(a,25),f=d+p+te(a,u,l)+re[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+ee(n,o,c)|0;d=l,l=u,u=a,a=i+f|0,i=c,c=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,c,i,a,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ht=At(()=>new xt);var $t=yt(St()),W=yt(Gt());var fe=0,_e=5,me=111,xe=196,he={[fe]:{type:1,networks:[0]},[me]:{type:1,networks:[2,1]},[_e]:{type:2,networks:[0]},[xe]:{type:2,networks:[2,1]}},Ne=({address:t,network:e})=>{let n=(d=>{try{return(0,$t.base58_to_binary)(d)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let s=d.slice(o-4,o),p=d.slice(0,o-4),f=ht.create();f.update(p);let x=ht.create();x.update(f.digest());let _=x.digest().slice(0,4);if(s.some((b,g)=>b!==_[g]))throw new k(`Checksum mismatch expected ${s}, got ${_}.`)})(n);let i=n[0],a=he[i];if((0,gt.isNullish)(a))throw new O;let{type:u,networks:l}=a;if(!l.includes(e))throw new M;return{address:t,network:e,type:u,parser:"base58"}},be=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?W.bech32m.decode(d):W.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,gt.isNullish)(i))throw new V;if(i!==e)throw new S;let[a,...u]=o;if(a>1)throw new F;switch(W.bech32.fromWords(u).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:a===0?3:4,parser:"bip-173"};default:throw new C}},ge=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Ne({address:t,network:e});case"b":case"B":case"t":case"T":return be({address:t,network:e});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|