Skip to content

Commit

Permalink
Merge branch 'main' into update-ic
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine authored Nov 21, 2023
2 parents f72fb74 + cf6314e commit f9edbc5
Show file tree
Hide file tree
Showing 39 changed files with 343 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Install didc
run: |
mkdir -p .bin
curl -L https://github.com/dfinity/candid/releases/download/2022-08-09/didc-linux64 > .bin/didc
curl -L https://github.com/dfinity/candid/releases/download/2023-09-27/didc-linux64 > .bin/didc
chmod +x .bin/didc
- name: Add didc to the PATH
run: echo "${PWD}/.bin" >> $GITHUB_PATH
Expand Down
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
# Unreleased
# Release.XX.YY

## Overview

## Features

# Release.2023.11.21-1400Z

## Overview

The current status of the libraries at the time of the release is as follows:

| Library | Version | Status |
| ------------------------ | ------- | ----------- |
| `@dfinity/ckbtc` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/cmc` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/ic-management` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/ledger-icp` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/ledger-icrc` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/nns` | v3.0.0 | Enhanced 🔧 |
| `@dfinity/nns-proto` | v1.0.0 | Unchanged |
| `@dfinity/sns` | v2.0.0 | Enhanced 🔧 |
| `@dfinity/utils` | v1.1.0 | Unchanged |

## Features

- Include timestamp and tags in the candid provenance record.
- Update ckbtc candid to ic commit `4de99bc27be74048f80d13200f3c75cf2a43438c`.
- Include pending UTXOs in MinterNoNewUtxosError.
- Upgrade `didc` to `0.3.5` that converts candid files into JS and TS.

# 2023.10.15-0600Z

Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/ic-js",
"version": "2023.10.15-0600Z",
"version": "2023.11.21-1400Z",
"description": "A collection of library for interfacing with the Internet Computer.",
"license": "Apache-2.0",
"workspaces": [
Expand Down
6 changes: 6 additions & 0 deletions packages/ckbtc/candid/minter.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ export const idlFactory = ({ IDL }) => {
}),
'Checked' : Utxo,
});
const PendingUtxo = IDL.Record({
'confirmations' : IDL.Nat32,
'value' : IDL.Nat64,
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
});
const UpdateBalanceError = IDL.Variant({
'GenericError' : IDL.Record({
'error_message' : IDL.Text,
Expand All @@ -207,6 +212,7 @@ export const idlFactory = ({ IDL }) => {
'AlreadyProcessing' : IDL.Null,
'NoNewUtxos' : IDL.Record({
'required_confirmations' : IDL.Nat32,
'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
'current_confirmations' : IDL.Opt(IDL.Nat32),
}),
});
Expand Down
54 changes: 35 additions & 19 deletions packages/ckbtc/candid/minter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type { Principal } from "@dfinity/principal";

export interface Account {
owner: Principal;
subaccount: [] | [Uint8Array];
subaccount: [] | [Uint8Array | number[]];
}
export type BitcoinAddress =
| { p2wsh_v0: Uint8Array }
| { p2tr_v1: Uint8Array }
| { p2sh: Uint8Array }
| { p2wpkh_v0: Uint8Array }
| { p2pkh: Uint8Array };
| { p2wsh_v0: Uint8Array | number[] }
| { p2tr_v1: Uint8Array | number[] }
| { p2sh: Uint8Array | number[] }
| { p2wpkh_v0: Uint8Array | number[] }
| { p2pkh: Uint8Array | number[] };
export type BtcNetwork =
| { Mainnet: null }
| { Regtest: null }
Expand All @@ -21,7 +21,7 @@ export interface CanisterStatusResponse {
cycles: bigint;
settings: DefiniteCanisterSettings;
idle_cycles_burned_per_day: bigint;
module_hash: [] | [Uint8Array];
module_hash: [] | [Uint8Array | number[]];
}
export type CanisterStatusType =
| { stopped: null }
Expand Down Expand Up @@ -53,9 +53,9 @@ export type Event =
sent_transaction: {
fee: [] | [bigint];
change_output: [] | [{ value: bigint; vout: number }];
txid: Uint8Array;
txid: Uint8Array | number[];
utxos: Array<Utxo>;
requests: BigUint64Array;
requests: BigUint64Array | bigint[];
submitted_at: bigint;
};
}
Expand Down Expand Up @@ -96,13 +96,13 @@ export type Event =
};
}
| { removed_retrieve_btc_request: { block_index: bigint } }
| { confirmed_transaction: { txid: Uint8Array } }
| { confirmed_transaction: { txid: Uint8Array | number[] } }
| {
replaced_transaction: {
fee: bigint;
change_output: { value: bigint; vout: number };
old_txid: Uint8Array;
new_txid: Uint8Array;
old_txid: Uint8Array | number[];
new_txid: Uint8Array | number[];
submitted_at: bigint;
};
}
Expand Down Expand Up @@ -135,6 +135,11 @@ export type Mode =
| { DepositsRestrictedTo: Array<Principal> }
| { ReadOnly: null }
| { GeneralAvailability: null };
export interface PendingUtxo {
confirmations: number;
value: bigint;
outpoint: { txid: Uint8Array | number[]; vout: number };
}
export type ReimbursementReason =
| { CallFailed: null }
| { TaintedDestination: { kyt_fee: bigint; kyt_provider: Principal } };
Expand All @@ -154,14 +159,14 @@ export interface RetrieveBtcOk {
}
export type RetrieveBtcStatus =
| { Signing: null }
| { Confirmed: { txid: Uint8Array } }
| { Sending: { txid: Uint8Array } }
| { Confirmed: { txid: Uint8Array | number[] } }
| { Sending: { txid: Uint8Array | number[] } }
| { AmountTooLow: null }
| { Unknown: null }
| { Submitted: { txid: Uint8Array } }
| { Submitted: { txid: Uint8Array | number[] } }
| { Pending: null };
export interface RetrieveBtcWithApprovalArgs {
from_subaccount: [] | [Uint8Array];
from_subaccount: [] | [Uint8Array | number[]];
address: string;
amount: bigint;
}
Expand All @@ -182,6 +187,7 @@ export type UpdateBalanceError =
| {
NoNewUtxos: {
required_confirmations: number;
pending_utxos: [] | [Array<PendingUtxo>];
current_confirmations: [] | [number];
};
};
Expand All @@ -196,7 +202,7 @@ export interface UpgradeArgs {
export interface Utxo {
height: number;
value: bigint;
outpoint: { txid: Uint8Array; vout: number };
outpoint: { txid: Uint8Array | number[]; vout: number };
}
export type UtxoStatus =
| { ValueTooSmall: Utxo }
Expand All @@ -215,7 +221,12 @@ export interface _SERVICE {
{ minter_fee: bigint; bitcoin_fee: bigint }
>;
get_btc_address: ActorMethod<
[{ owner: [] | [Principal]; subaccount: [] | [Uint8Array] }],
[
{
owner: [] | [Principal];
subaccount: [] | [Uint8Array | number[]];
},
],
string
>;
get_canister_status: ActorMethod<[], CanisterStatusResponse>;
Expand All @@ -236,7 +247,12 @@ export interface _SERVICE {
{ Ok: RetrieveBtcOk } | { Err: RetrieveBtcWithApprovalError }
>;
update_balance: ActorMethod<
[{ owner: [] | [Principal]; subaccount: [] | [Uint8Array] }],
[
{
owner: [] | [Principal];
subaccount: [] | [Uint8Array | number[]];
},
],
{ Ok: Array<UtxoStatus> } | { Err: UpdateBalanceError }
>;
}
12 changes: 10 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 8be68bc88db7332dd39a26509ddf62c564ca3415 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
// Generated from IC repo commit 4de99bc27b (2023-11-20) '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 @@ -101,11 +101,19 @@ type UtxoStatus = variant {
};
};

// Utxos that don't have enough confirmations to be processed.
type PendingUtxo = record {
outpoint : record { txid : vec nat8; vout : nat32 };
value : nat64;
confirmations: nat32;
};

type UpdateBalanceError = variant {
// There are no new UTXOs to process.
NoNewUtxos : record {
current_confirmations: opt nat32;
required_confirmations: nat32
required_confirmations: nat32;
pending_utxos: opt vec PendingUtxo;
};
// The minter is already processing another update balance request for the caller.
AlreadyProcessing;
Expand Down
6 changes: 6 additions & 0 deletions packages/ckbtc/candid/minter.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ export const idlFactory = ({ IDL }) => {
}),
'Checked' : Utxo,
});
const PendingUtxo = IDL.Record({
'confirmations' : IDL.Nat32,
'value' : IDL.Nat64,
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
});
const UpdateBalanceError = IDL.Variant({
'GenericError' : IDL.Record({
'error_message' : IDL.Text,
Expand All @@ -207,6 +212,7 @@ export const idlFactory = ({ IDL }) => {
'AlreadyProcessing' : IDL.Null,
'NoNewUtxos' : IDL.Record({
'required_confirmations' : IDL.Nat32,
'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
'current_confirmations' : IDL.Opt(IDL.Nat32),
}),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ckbtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/ckbtc",
"version": "1.1.0",
"version": "2.0.0",
"description": "A library for interfacing with ckBTC.",
"license": "Apache-2.0",
"main": "dist/cjs/index.cjs.js",
Expand Down
21 changes: 18 additions & 3 deletions packages/ckbtc/src/errors/minter.errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { nonNullish } from "@dfinity/utils";
import { fromNullable, nonNullish } from "@dfinity/utils";
import type {
PendingUtxo,
RetrieveBtcError,
RetrieveBtcWithApprovalError,
UpdateBalanceError,
Expand All @@ -10,7 +11,21 @@ export class MinterTemporaryUnavailableError extends MinterGenericError {}
export class MinterAlreadyProcessingError extends MinterGenericError {}

export class MinterUpdateBalanceError extends MinterGenericError {}
export class MinterNoNewUtxosError extends MinterUpdateBalanceError {}
export class MinterNoNewUtxosError extends MinterUpdateBalanceError {
readonly pendingUtxos: PendingUtxo[];
readonly requiredConfirmations: number;
constructor({
pending_utxos,
required_confirmations,
}: {
pending_utxos: [] | [PendingUtxo[]];
required_confirmations: number;
}) {
super();
this.pendingUtxos = fromNullable(pending_utxos) || [];
this.requiredConfirmations = required_confirmations;
}
}

export class MinterRetrieveBtcError extends MinterGenericError {}
export class MinterMalformedAddressError extends MinterRetrieveBtcError {}
Expand Down Expand Up @@ -49,7 +64,7 @@ export const createUpdateBalanceError = (
}

if ("NoNewUtxos" in Err) {
return new MinterNoNewUtxosError();
return new MinterNoNewUtxosError(Err.NoNewUtxos);
}

// Handle types added in the backend but not yet added in the frontend
Expand Down
Loading

0 comments on commit f9edbc5

Please sign in to comment.