Skip to content

Commit

Permalink
Update ckbtc candid (#502)
Browse files Browse the repository at this point in the history
# Motivation

I want to use the new `retrieve_btc_status_v2_by_account` method on the
ckbtc minter.

# Changes

Ran the following to update only the ckbtc candid:
```
scripts/import-candid ../../ic
scripts/compile-idl-js
git checkout packages/{cmc,ic-management,ledger-icp,ledger-icrc,nns,sns}
```

# Tests

Installed `utils` and `ckbtc` in `nns-dapp` and ran all the unit and e2e
tests there.

# Todos

- [ ] Add entry to changelog (if necessary).
Will add when I implement the method in the `ckbtc` package.
  • Loading branch information
dskloetd authored Dec 13, 2023
1 parent d9ac8f1 commit 1b26a64
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 2 deletions.
40 changes: 40 additions & 0 deletions packages/ckbtc/candid/minter.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const idlFactory = ({ IDL }) => {
'received_at' : IDL.Nat64,
'block_index' : IDL.Nat64,
'address' : BitcoinAddress,
'reimbursement_account' : IDL.Opt(Account),
'amount' : IDL.Nat64,
'kyt_provider' : IDL.Opt(IDL.Principal),
}),
Expand Down Expand Up @@ -171,6 +172,28 @@ export const idlFactory = ({ IDL }) => {
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Pending' : IDL.Null,
});
const ReimbursementRequest = IDL.Record({
'account' : Account,
'amount' : IDL.Nat64,
'reason' : ReimbursementReason,
});
const ReimbursedDeposit = IDL.Record({
'account' : Account,
'mint_block_index' : IDL.Nat64,
'amount' : IDL.Nat64,
'reason' : ReimbursementReason,
});
const RetrieveBtcStatusV2 = IDL.Variant({
'Signing' : IDL.Null,
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'AmountTooLow' : IDL.Null,
'WillReimburse' : ReimbursementRequest,
'Unknown' : IDL.Null,
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Reimbursed' : ReimbursedDeposit,
'Pending' : IDL.Null,
});
const RetrieveBtcWithApprovalArgs = IDL.Record({
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'address' : IDL.Text,
Expand Down Expand Up @@ -251,6 +274,23 @@ export const idlFactory = ({ IDL }) => {
[RetrieveBtcStatus],
[],
),
'retrieve_btc_status_v2' : IDL.Func(
[IDL.Record({ 'block_index' : IDL.Nat64 })],
[RetrieveBtcStatusV2],
[],
),
'retrieve_btc_status_v2_by_account' : IDL.Func(
[IDL.Opt(Account)],
[
IDL.Vec(
IDL.Record({
'block_index' : IDL.Nat64,
'status_v2' : IDL.Opt(RetrieveBtcStatusV2),
})
),
],
[],
),
'retrieve_btc_with_approval' : IDL.Func(
[RetrieveBtcWithApprovalArgs],
[
Expand Down
30 changes: 30 additions & 0 deletions packages/ckbtc/candid/minter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type Event =
received_at: bigint;
block_index: bigint;
address: BitcoinAddress;
reimbursement_account: [] | [Account];
amount: bigint;
kyt_provider: [] | [Principal];
};
Expand Down Expand Up @@ -140,9 +141,20 @@ export interface PendingUtxo {
value: bigint;
outpoint: { txid: Uint8Array | number[]; vout: number };
}
export interface ReimbursedDeposit {
account: Account;
mint_block_index: bigint;
amount: bigint;
reason: ReimbursementReason;
}
export type ReimbursementReason =
| { CallFailed: null }
| { TaintedDestination: { kyt_fee: bigint; kyt_provider: Principal } };
export interface ReimbursementRequest {
account: Account;
amount: bigint;
reason: ReimbursementReason;
}
export interface RetrieveBtcArgs {
address: string;
amount: bigint;
Expand All @@ -165,6 +177,16 @@ export type RetrieveBtcStatus =
| { Unknown: null }
| { Submitted: { txid: Uint8Array | number[] } }
| { Pending: null };
export type RetrieveBtcStatusV2 =
| { Signing: null }
| { Confirmed: { txid: Uint8Array | number[] } }
| { Sending: { txid: Uint8Array | number[] } }
| { AmountTooLow: null }
| { WillReimburse: ReimbursementRequest }
| { Unknown: null }
| { Submitted: { txid: Uint8Array | number[] } }
| { Reimbursed: ReimbursedDeposit }
| { Pending: null };
export interface RetrieveBtcWithApprovalArgs {
from_subaccount: [] | [Uint8Array | number[]];
address: string;
Expand Down Expand Up @@ -242,6 +264,14 @@ export interface _SERVICE {
[{ block_index: bigint }],
RetrieveBtcStatus
>;
retrieve_btc_status_v2: ActorMethod<
[{ block_index: bigint }],
RetrieveBtcStatusV2
>;
retrieve_btc_status_v2_by_account: ActorMethod<
[[] | [Account]],
Array<{ block_index: bigint; status_v2: [] | [RetrieveBtcStatusV2] }>
>;
retrieve_btc_with_approval: ActorMethod<
[RetrieveBtcWithApprovalArgs],
{ Ok: RetrieveBtcOk } | { Err: RetrieveBtcWithApprovalError }
Expand Down
59 changes: 57 additions & 2 deletions packages/ckbtc/candid/minter.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from IC repo commit 4de99bc27b (2023-11-20) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
// Generated from IC repo commit a8e25a31a (2023-12-12) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
// Represents an account on the ckBTC ledger.
type Account = record { owner : principal; subaccount : opt blob };

Expand Down Expand Up @@ -233,6 +233,48 @@ type RetrieveBtcStatus = variant {
Confirmed : record { txid : blob };
};

type ReimbursementRequest = record {
account : Account;
amount : nat64;
reason : ReimbursementReason;
};

type ReimbursedDeposit = record {
account : Account;
mint_block_index : nat64;
amount : nat64;
reason : ReimbursementReason;
};

type RetrieveBtcStatusV2 = variant {
// The minter does not have any information on the specified
// retrieval request. It can be that nobody submitted the
// request or the minter pruned the relevant information from the
// history to save space.
Unknown;
// The minter did not send a Bitcoin transaction for this request yet.
Pending;
// The minter is obtaining all required ECDSA signatures on the
// Bitcoin transaction for this request.
Signing;
// The minter signed the transaction and is waiting for a reply
// from the Bitcoin canister.
Sending : record { txid : blob };
// The minter sent a transaction for the retrieve request.
// The payload contains the identifier of the transaction on the Bitcoin network.
Submitted : record { txid : blob };
// The amount was too low to cover the transaction fees.
AmountTooLow;
// The minter received enough confirmations for the Bitcoin
// transaction for this request. The payload contains the
// identifier of the transaction on the Bitcoin network.
Confirmed : record { txid : blob };
/// The retrieve bitcoin request has been reimbursed.
Reimbursed : ReimbursedDeposit;
/// The minter will try to reimburse this transaction.
WillReimburse : ReimbursementRequest;
};

type Utxo = record {
outpoint : record { txid : vec nat8; vout : nat32 };
value : nat64;
Expand Down Expand Up @@ -271,6 +313,7 @@ type Event = variant {
block_index : nat64;
received_at : nat64;
kyt_provider : opt principal;
reimbursement_account : opt Account;
};
distributed_kyt_fee : record {
kyt_provider : principal;
Expand Down Expand Up @@ -389,9 +432,21 @@ service : (minter_arg : MinterArg) -> {
// using [icrc2_approve] on the ckBTC ledger.
retrieve_btc_with_approval : (RetrieveBtcWithApprovalArgs) -> (variant { Ok : RetrieveBtcOk; Err : RetrieveBtcWithApprovalError });

/// Returns the status of a [retrieve_btc] request.
/// [deprecated] Returns the status of a withdrawal request.
/// You should use retrieve_btc_status_v2 to retrieve the status of your withdrawal request.
retrieve_btc_status : (record { block_index : nat64 }) -> (RetrieveBtcStatus) query;

/// Returns the status of a withdrawal request request using the RetrieveBtcStatusV2 type.
retrieve_btc_status_v2 : (record { block_index : nat64 }) -> (RetrieveBtcStatusV2) query;

// Returns the withdrawal statues by account.
//
// # Note
// The _v2_ part indicates that you get a response in line with the retrieve_btc_status_v2 endpoint,
// i.e., you get a vector of RetrieveBtcStatusV2 and not RetrieveBtcStatus.
//
retrieve_btc_status_v2_by_account : (opt Account) -> (vec record { block_index: nat64; status_v2: opt RetrieveBtcStatusV2; }) query;

// }}} Section "Convert ckBTC to BTC"

// Section "Minter Information" {{{
Expand Down
40 changes: 40 additions & 0 deletions packages/ckbtc/candid/minter.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const idlFactory = ({ IDL }) => {
'received_at' : IDL.Nat64,
'block_index' : IDL.Nat64,
'address' : BitcoinAddress,
'reimbursement_account' : IDL.Opt(Account),
'amount' : IDL.Nat64,
'kyt_provider' : IDL.Opt(IDL.Principal),
}),
Expand Down Expand Up @@ -171,6 +172,28 @@ export const idlFactory = ({ IDL }) => {
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Pending' : IDL.Null,
});
const ReimbursementRequest = IDL.Record({
'account' : Account,
'amount' : IDL.Nat64,
'reason' : ReimbursementReason,
});
const ReimbursedDeposit = IDL.Record({
'account' : Account,
'mint_block_index' : IDL.Nat64,
'amount' : IDL.Nat64,
'reason' : ReimbursementReason,
});
const RetrieveBtcStatusV2 = IDL.Variant({
'Signing' : IDL.Null,
'Confirmed' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Sending' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'AmountTooLow' : IDL.Null,
'WillReimburse' : ReimbursementRequest,
'Unknown' : IDL.Null,
'Submitted' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8) }),
'Reimbursed' : ReimbursedDeposit,
'Pending' : IDL.Null,
});
const RetrieveBtcWithApprovalArgs = IDL.Record({
'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'address' : IDL.Text,
Expand Down Expand Up @@ -251,6 +274,23 @@ export const idlFactory = ({ IDL }) => {
[RetrieveBtcStatus],
['query'],
),
'retrieve_btc_status_v2' : IDL.Func(
[IDL.Record({ 'block_index' : IDL.Nat64 })],
[RetrieveBtcStatusV2],
['query'],
),
'retrieve_btc_status_v2_by_account' : IDL.Func(
[IDL.Opt(Account)],
[
IDL.Vec(
IDL.Record({
'block_index' : IDL.Nat64,
'status_v2' : IDL.Opt(RetrieveBtcStatusV2),
})
),
],
['query'],
),
'retrieve_btc_with_approval' : IDL.Func(
[RetrieveBtcWithApprovalArgs],
[
Expand Down

0 comments on commit 1b26a64

Please sign in to comment.