Skip to content

Commit

Permalink
Merge branch 'main' into feat/nowInBigIntNanoSeconds
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Nov 20, 2024
2 parents 5ffd4cb + 996f06e commit d34d044
Show file tree
Hide file tree
Showing 35 changed files with 361 additions and 59 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@size-limit/esbuild": "^11.1.2",
"@size-limit/preset-small-lib": "^11.1.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.5",
"@types/text-encoding": "^0.0.39",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"esbuild": "^0.20.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/ckbtc/candid/minter.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const idlFactory = ({ IDL }) => {
'kyt_principal' : IDL.Opt(IDL.Principal),
'mode' : IDL.Opt(Mode),
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
'min_confirmations' : IDL.Opt(IDL.Nat32),
'kyt_fee' : IDL.Opt(IDL.Nat64),
Expand All @@ -24,6 +25,7 @@ export const idlFactory = ({ IDL }) => {
'ecdsa_key_name' : IDL.Text,
'mode' : Mode,
'retrieve_btc_min_amount' : IDL.Nat64,
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'ledger_id' : IDL.Principal,
'max_time_in_queue_nanos' : IDL.Nat64,
'btc_network' : BtcNetwork,
Expand Down Expand Up @@ -354,6 +356,7 @@ export const init = ({ IDL }) => {
'kyt_principal' : IDL.Opt(IDL.Principal),
'mode' : IDL.Opt(Mode),
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
'min_confirmations' : IDL.Opt(IDL.Nat32),
'kyt_fee' : IDL.Opt(IDL.Nat64),
Expand All @@ -368,6 +371,7 @@ export const init = ({ IDL }) => {
'ecdsa_key_name' : IDL.Text,
'mode' : Mode,
'retrieve_btc_min_amount' : IDL.Nat64,
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'ledger_id' : IDL.Principal,
'max_time_in_queue_nanos' : IDL.Nat64,
'btc_network' : BtcNetwork,
Expand Down
2 changes: 2 additions & 0 deletions packages/ckbtc/candid/minter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface InitArgs {
ecdsa_key_name: string;
mode: Mode;
retrieve_btc_min_amount: bigint;
new_kyt_principal: [] | [Principal];
ledger_id: Principal;
max_time_in_queue_nanos: bigint;
btc_network: BtcNetwork;
Expand Down Expand Up @@ -230,6 +231,7 @@ export interface UpgradeArgs {
kyt_principal: [] | [Principal];
mode: [] | [Mode];
retrieve_btc_min_amount: [] | [bigint];
new_kyt_principal: [] | [Principal];
max_time_in_queue_nanos: [] | [bigint];
min_confirmations: [] | [number];
kyt_fee: [] | [bigint];
Expand Down
10 changes: 9 additions & 1 deletion packages/ckbtc/candid/minter.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from IC repo commit c47e172 (2024-10-25 tags: release-2024-11-07_03-07-6.11-kernel) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
// Generated from IC repo commit cb3cb61 (2024-11-14 tags: release-2024-11-14_03-07-base) '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 @@ -194,6 +194,9 @@ type InitArgs = record {

/// The canister id of the KYT canister.
kyt_principal: opt principal;

/// The canister id of the new KYT canister.
new_kyt_principal: opt principal;
};

// The upgrade parameters of the minter canister.
Expand All @@ -217,6 +220,9 @@ type UpgradeArgs = record {

/// The principal of the KYT canister.
kyt_principal : opt principal;

/// The principal of the new KYT canister.
new_kyt_principal : opt principal;
};

type RetrieveBtcStatus = variant {
Expand Down Expand Up @@ -308,6 +314,8 @@ type BitcoinAddress = variant {

type MinterInfo = record {
min_confirmations : nat32;
// This fee is based on the `retrieve_btc_min_amount` setting during canister
// initialization or upgrades, but may vary according to current network fees.
retrieve_btc_min_amount : nat64;
kyt_fee : nat64;
};
Expand Down
4 changes: 4 additions & 0 deletions packages/ckbtc/candid/minter.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const idlFactory = ({ IDL }) => {
'kyt_principal' : IDL.Opt(IDL.Principal),
'mode' : IDL.Opt(Mode),
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
'min_confirmations' : IDL.Opt(IDL.Nat32),
'kyt_fee' : IDL.Opt(IDL.Nat64),
Expand All @@ -24,6 +25,7 @@ export const idlFactory = ({ IDL }) => {
'ecdsa_key_name' : IDL.Text,
'mode' : Mode,
'retrieve_btc_min_amount' : IDL.Nat64,
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'ledger_id' : IDL.Principal,
'max_time_in_queue_nanos' : IDL.Nat64,
'btc_network' : BtcNetwork,
Expand Down Expand Up @@ -354,6 +356,7 @@ export const init = ({ IDL }) => {
'kyt_principal' : IDL.Opt(IDL.Principal),
'mode' : IDL.Opt(Mode),
'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
'min_confirmations' : IDL.Opt(IDL.Nat32),
'kyt_fee' : IDL.Opt(IDL.Nat64),
Expand All @@ -368,6 +371,7 @@ export const init = ({ IDL }) => {
'ecdsa_key_name' : IDL.Text,
'mode' : Mode,
'retrieve_btc_min_amount' : IDL.Nat64,
'new_kyt_principal' : IDL.Opt(IDL.Principal),
'ledger_id' : IDL.Principal,
'max_time_in_queue_nanos' : IDL.Nat64,
'btc_network' : BtcNetwork,
Expand Down
32 changes: 17 additions & 15 deletions packages/cketh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const address = await getSmartContractAddress({});

### :factory: CkETHMinterCanister

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L23)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L29)

#### Methods

Expand All @@ -71,7 +71,7 @@ const address = await getSmartContractAddress({});
| -------- | ------------------------------------------------------------------------ |
| `create` | `(options: CkETHMinterCanisterOptions<_SERVICE>) => CkETHMinterCanister` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L24)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L30)

##### :gear: getSmartContractAddress

Expand All @@ -86,7 +86,7 @@ Parameters:
- `params`: The parameters to resolve the ckETH smart contract address.
- `params.certified`: query or update call

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L42)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L48)

##### :gear: withdrawEth

Expand All @@ -97,17 +97,18 @@ Preconditions:
The caller allowed the minter's principal to spend its funds using
[icrc2_approve] on the ckETH ledger.

| Method | Type |
| ------------- | --------------------------------------------------------------------------------------------- |
| `withdrawEth` | `({ address, ...rest }: { address: string; amount: bigint; }) => Promise<RetrieveEthRequest>` |
| Method | Type |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `withdrawEth` | `({ address, fromSubaccount, ...rest }: { address: string; amount: bigint; fromSubaccount?: Subaccount or undefined; }) => Promise<RetrieveEthRequest>` |

Parameters:

- `params`: The parameters to withdrawal ckETH to ETH.
- `params.address`: The destination ETH address.
- `params.amount`: The ETH amount in wei.
- `params.fromSubaccount`: The optional subaccount to burn ckETH from.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L62)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L69)

##### :gear: withdrawErc20

Expand All @@ -118,18 +119,19 @@ Preconditions:
The caller allowed the minter's principal to spend its funds using
[icrc2_approve] on the ckErc20 ledger and to burn some of the user’s ckETH tokens to pay for the transaction fees on the CkETH ledger.

| Method | Type |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `withdrawErc20` | `({ address, ledgerCanisterId, ...rest }: { address: string; amount: bigint; ledgerCanisterId: Principal; }) => Promise<RetrieveErc20Request>` |
| Method | Type |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `withdrawErc20` | `({ address, ledgerCanisterId, fromCkEthSubaccount, fromCkErc20Subaccount, ...rest }: { address: string; amount: bigint; ledgerCanisterId: Principal; fromCkEthSubaccount?: Subaccount or undefined; fromCkErc20Subaccount?: Subaccount or undefined; }) => Promise<...>` |

Parameters:

- `params`: The parameters to withdrawal ckErc20 to Erc20.
- `params.address`: The destination ETH address.
- `params.amount`: The ETH amount in wei.
- `params.ledgerCanisterId`: The ledger canister ID of the ckErc20.
- `params.fromCkEthSubaccount`: The optional subaccount to burn ckETH from to pay for the transaction fee.
- `params.fromCkEthSubaccount`: The optional subaccount to burn ckERC20 from.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L99)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L110)

##### :gear: eip1559TransactionPrice

Expand All @@ -145,7 +147,7 @@ Parameters:
- `params.ckErc20LedgerId`: - The optional identifier for a particular ckERC20 ledger.
- `params.certified`: - Indicates whether this is a certified query or an update call.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L134)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L151)

##### :gear: retrieveEthStatus

Expand All @@ -155,7 +157,7 @@ Retrieve the status of a withdrawal request.
| ------------------- | ---------------------------------------------------- |
| `retrieveEthStatus` | `(blockIndex: bigint) => Promise<RetrieveEthStatus>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L149)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L166)

##### :gear: getMinterInfo

Expand All @@ -170,7 +172,7 @@ Parameters:
- `params`: The parameters to get the minter info.
- `params.certified`: query or update call

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L162)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cketh/src/minter.canister.ts#L179)

### :factory: CkETHOrchestratorCanister

Expand Down
4 changes: 4 additions & 0 deletions packages/cketh/candid/minter.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export const idlFactory = ({ IDL }) => {
)
),
'minter_address' : IDL.Opt(IDL.Text),
'last_deposit_with_subaccount_scraped_block_number' : IDL.Opt(IDL.Nat),
'ethereum_block_height' : IDL.Opt(BlockTag),
});
const EthTransaction = IDL.Record({ 'transaction_hash' : IDL.Text });
Expand All @@ -289,6 +290,8 @@ export const idlFactory = ({ IDL }) => {
const WithdrawErc20Arg = IDL.Record({
'ckerc20_ledger_id' : IDL.Principal,
'recipient' : IDL.Text,
'from_cketh_subaccount' : IDL.Opt(Subaccount),
'from_ckerc20_subaccount' : IDL.Opt(Subaccount),
'amount' : IDL.Nat,
});
const RetrieveErc20Request = IDL.Record({
Expand Down Expand Up @@ -330,6 +333,7 @@ export const idlFactory = ({ IDL }) => {
});
const WithdrawalArg = IDL.Record({
'recipient' : IDL.Text,
'from_subaccount' : IDL.Opt(Subaccount),
'amount' : IDL.Nat,
});
const RetrieveEthRequest = IDL.Record({ 'block_index' : IDL.Nat });
Expand Down
4 changes: 4 additions & 0 deletions packages/cketh/candid/minter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export interface MinterInfo {
| []
| [Array<{ balance: bigint; erc20_contract_address: string }>];
minter_address: [] | [string];
last_deposit_with_subaccount_scraped_block_number: [] | [bigint];
ethereum_block_height: [] | [BlockTag];
}
export interface QueryStats {
Expand Down Expand Up @@ -339,6 +340,8 @@ export interface UpgradeArg {
export interface WithdrawErc20Arg {
ckerc20_ledger_id: Principal;
recipient: string;
from_cketh_subaccount: [] | [Subaccount];
from_ckerc20_subaccount: [] | [Subaccount];
amount: bigint;
}
export type WithdrawErc20Error =
Expand All @@ -356,6 +359,7 @@ export type WithdrawErc20Error =
| { RecipientAddressBlocked: { address: string } };
export interface WithdrawalArg {
recipient: string;
from_subaccount: [] | [Subaccount];
amount: bigint;
}
export interface WithdrawalDetail {
Expand Down
22 changes: 20 additions & 2 deletions packages/cketh/candid/minter.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from IC repo commit c47e172 (2024-10-25 tags: release-2024-11-07_03-07-6.11-kernel) 'rs/ethereum/cketh/minter/cketh_minter.did' by import-candid
// Generated from IC repo commit cb3cb61 (2024-11-14 tags: release-2024-11-14_03-07-base) 'rs/ethereum/cketh/minter/cketh_minter.did' by import-candid
type EthereumNetwork = variant {
// The public Ethereum mainnet.
Mainnet;
Expand Down Expand Up @@ -202,6 +202,9 @@ type MinterInfo = record {
// Last scraped block number for logs of the ERC20 helper contract.
last_erc20_scraped_block_number: opt nat;

// Last scraped block number for logs of the deposit with subaccount helper contract.
last_deposit_with_subaccount_scraped_block_number: opt nat;

// Canister ID of the ckETH ledger.
cketh_ledger_id: opt principal;

Expand Down Expand Up @@ -263,7 +266,16 @@ type RetrieveEthStatus = variant {
TxFinalized : TxFinalizedStatus;
};

type WithdrawalArg = record { recipient : text; amount : nat };
type WithdrawalArg = record {
// The address to which the minter should deposit ETH.
recipient : text;

// The amount of ckETH in Wei that the client wants to withdraw.
amount : nat;

// The subaccount to burn ckETH from.
from_subaccount : opt Subaccount;
};

// Details of a withdrawal request and its status.
type WithdrawalDetail = record {
Expand Down Expand Up @@ -351,6 +363,12 @@ type WithdrawErc20Arg = record {

// Ethereum address to withdraw to.
recipient : text;

// The subaccount to burn ckETH from to pay for the transaction fee.
from_cketh_subaccount : opt Subaccount;

// The subaccount to burn ckERC20 from.
from_ckerc20_subaccount : opt Subaccount;
};

type RetrieveErc20Request = record {
Expand Down
4 changes: 4 additions & 0 deletions packages/cketh/candid/minter.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export const idlFactory = ({ IDL }) => {
)
),
'minter_address' : IDL.Opt(IDL.Text),
'last_deposit_with_subaccount_scraped_block_number' : IDL.Opt(IDL.Nat),
'ethereum_block_height' : IDL.Opt(BlockTag),
});
const EthTransaction = IDL.Record({ 'transaction_hash' : IDL.Text });
Expand All @@ -289,6 +290,8 @@ export const idlFactory = ({ IDL }) => {
const WithdrawErc20Arg = IDL.Record({
'ckerc20_ledger_id' : IDL.Principal,
'recipient' : IDL.Text,
'from_cketh_subaccount' : IDL.Opt(Subaccount),
'from_ckerc20_subaccount' : IDL.Opt(Subaccount),
'amount' : IDL.Nat,
});
const RetrieveErc20Request = IDL.Record({
Expand Down Expand Up @@ -330,6 +333,7 @@ export const idlFactory = ({ IDL }) => {
});
const WithdrawalArg = IDL.Record({
'recipient' : IDL.Text,
'from_subaccount' : IDL.Opt(Subaccount),
'amount' : IDL.Nat,
});
const RetrieveEthRequest = IDL.Record({ 'block_index' : IDL.Nat });
Expand Down
2 changes: 1 addition & 1 deletion packages/cketh/candid/orchestrator.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from IC repo commit c47e172 (2024-10-25 tags: release-2024-11-07_03-07-6.11-kernel) 'rs/ethereum/ledger-suite-orchestrator/ledger_suite_orchestrator.did' by import-candid
// Generated from IC repo commit cb3cb61 (2024-11-14 tags: release-2024-11-14_03-07-base) 'rs/ethereum/ledger-suite-orchestrator/ledger_suite_orchestrator.did' by import-candid
type OrchestratorArg = variant {
UpgradeArg : UpgradeArg;
InitArg : InitArg;
Expand Down
Loading

0 comments on commit d34d044

Please sign in to comment.