Skip to content

Commit

Permalink
Chore: Upgrade didc (#474)
Browse files Browse the repository at this point in the history
# Motivation

Keep tools up to date.

In this PR, upgrade `didc` to latest version `0.3.5`.

The change is that types of `Uint8Array` are now `Uint8Array |
number[]`.

Which means that in some places I had to convert to `Uint8Array` to have
a common type for simplicity.

# Changes

## Automatic changes

* All files in `*/candid/*` directories. By running `compile-idl-js`
with the new `didc` version.
* Readme files with the docs workflow.

## Manual changes

* `compile-idl-js` to expect latest `didc`.
* Convert types `Uint8Array | number[]` to `Uint8array` with
`Uint8Array.from` where needed.

# Tests

Still passing.

# Todos

- [x] Add entry to changelog (if necessary).

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
lmuntaner and github-actions[bot] authored Nov 20, 2023
1 parent 0d5b5c9 commit 3076126
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 176 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features

- Include timestamp and tags in the candid provenance record.
- Upgrade `didc` to `0.3.5`.

# 2023.10.15-0600Z

Expand Down
48 changes: 29 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 @@ -154,14 +154,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 Down Expand Up @@ -196,7 +196,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 +215,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 +241,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 }
>;
}
6 changes: 3 additions & 3 deletions packages/cmc/candid/cmc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ActorMethod } from "@dfinity/agent";
import type { Principal } from "@dfinity/principal";

export interface AccountIdentifier {
bytes: Uint8Array;
bytes: Uint8Array | number[];
}
export type BlockIndex = bigint;
export type Cycles = bigint;
Expand All @@ -19,9 +19,9 @@ export interface IcpXdrConversionRate {
timestamp_seconds: bigint;
}
export interface IcpXdrConversionRateResponse {
certificate: Uint8Array;
certificate: Uint8Array | number[];
data: IcpXdrConversionRate;
hash_tree: Uint8Array;
hash_tree: Uint8Array | number[];
}
export interface NotifyCreateCanisterArg {
controller: Principal;
Expand Down
6 changes: 3 additions & 3 deletions packages/ic-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ Get canister details (memory size, status, etc.)

Get canister info (controllers, module hash, changes, etc.)

| Method | Type |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `canisterInfo` | `({ canisterId, numRequestChanges, }: CanisterInfoParams) => Promise<{ controllers: Principal[]; module_hash: [] or [Uint8Array]; recent_changes: change[]; total_num_changes: bigint; }>` |
| Method | Type |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `canisterInfo` | `({ canisterId, numRequestChanges, }: CanisterInfoParams) => Promise<{ controllers: Principal[]; module_hash: [] or [Uint8Array | number[]]; recent_changes: change[]; total_num_changes: bigint; }>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L182)

Expand Down
50 changes: 30 additions & 20 deletions packages/ic-management/candid/ic-management.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Principal } from "@dfinity/principal";

export type bitcoin_address = string;
export type bitcoin_network = { mainnet: null } | { testnet: null };
export type block_hash = Uint8Array;
export type block_hash = Uint8Array | number[];
export type canister_id = Principal;
export interface canister_settings {
freezing_threshold: [] | [bigint];
Expand All @@ -24,7 +24,7 @@ export type change_details =
| {
code_deployment: {
mode: { reinstall: null } | { upgrade: null } | { install: null };
module_hash: Uint8Array;
module_hash: Uint8Array | number[];
};
}
| { controllers_change: { controllers: Array<Principal> } }
Expand Down Expand Up @@ -54,11 +54,13 @@ export interface get_current_fee_percentiles_request {
}
export interface get_utxos_request {
network: bitcoin_network;
filter: [] | [{ page: Uint8Array } | { min_confirmations: number }];
filter:
| []
| [{ page: Uint8Array | number[] } | { min_confirmations: number }];
address: bitcoin_address;
}
export interface get_utxos_response {
next_page: [] | [Uint8Array];
next_page: [] | [Uint8Array | number[]];
tip_height: number;
tip_block_hash: block_hash;
utxos: Array<utxo>;
Expand All @@ -69,38 +71,38 @@ export interface http_header {
}
export interface http_response {
status: bigint;
body: Uint8Array;
body: Uint8Array | number[];
headers: Array<http_header>;
}
export type millisatoshi_per_byte = bigint;
export interface outpoint {
txid: Uint8Array;
txid: Uint8Array | number[];
vout: number;
}
export type satoshi = bigint;
export interface send_transaction_request {
transaction: Uint8Array;
transaction: Uint8Array | number[];
network: bitcoin_network;
}
export interface utxo {
height: number;
value: satoshi;
outpoint: outpoint;
}
export type wasm_module = Uint8Array;
export type wasm_module = Uint8Array | number[];
export interface _SERVICE {
bitcoin_get_balance: ActorMethod<[get_balance_request], satoshi>;
bitcoin_get_current_fee_percentiles: ActorMethod<
[get_current_fee_percentiles_request],
BigUint64Array
BigUint64Array | bigint[]
>;
bitcoin_get_utxos: ActorMethod<[get_utxos_request], get_utxos_response>;
bitcoin_send_transaction: ActorMethod<[send_transaction_request], undefined>;
canister_info: ActorMethod<
[{ canister_id: canister_id; num_requested_changes: [] | [bigint] }],
{
controllers: Array<Principal>;
module_hash: [] | [Uint8Array];
module_hash: [] | [Uint8Array | number[]];
recent_changes: Array<change>;
total_num_changes: bigint;
}
Expand All @@ -113,7 +115,7 @@ export interface _SERVICE {
cycles: bigint;
settings: definite_canister_settings;
idle_cycles_burned_per_day: bigint;
module_hash: [] | [Uint8Array];
module_hash: [] | [Uint8Array | number[]];
}
>;
create_canister: ActorMethod<
Expand All @@ -132,21 +134,29 @@ export interface _SERVICE {
{
key_id: { name: string; curve: ecdsa_curve };
canister_id: [] | [canister_id];
derivation_path: Array<Uint8Array>;
derivation_path: Array<Uint8Array | number[]>;
},
],
{ public_key: Uint8Array; chain_code: Uint8Array }
{
public_key: Uint8Array | number[];
chain_code: Uint8Array | number[];
}
>;
http_request: ActorMethod<
[
{
url: string;
method: { get: null } | { head: null } | { post: null };
max_response_bytes: [] | [bigint];
body: [] | [Uint8Array];
body: [] | [Uint8Array | number[]];
transform:
| []
| [{ function: [Principal, string]; context: Uint8Array }];
| [
{
function: [Principal, string];
context: Uint8Array | number[];
},
];
headers: Array<http_header>;
},
],
Expand All @@ -155,7 +165,7 @@ export interface _SERVICE {
install_code: ActorMethod<
[
{
arg: Uint8Array;
arg: Uint8Array | number[];
wasm_module: wasm_module;
mode: { reinstall: null } | { upgrade: null } | { install: null };
canister_id: canister_id;
Expand All @@ -179,16 +189,16 @@ export interface _SERVICE {
[{ canister_id: canister_id; amount: bigint }],
undefined
>;
raw_rand: ActorMethod<[], Uint8Array>;
raw_rand: ActorMethod<[], Uint8Array | number[]>;
sign_with_ecdsa: ActorMethod<
[
{
key_id: { name: string; curve: ecdsa_curve };
derivation_path: Array<Uint8Array>;
message_hash: Uint8Array;
derivation_path: Array<Uint8Array | number[]>;
message_hash: Uint8Array | number[];
},
],
{ signature: Uint8Array }
{ signature: Uint8Array | number[] }
>;
start_canister: ActorMethod<[{ canister_id: canister_id }], undefined>;
stop_canister: ActorMethod<[{ canister_id: canister_id }], undefined>;
Expand Down
10 changes: 5 additions & 5 deletions packages/ledger-icp/candid/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Principal } from "@dfinity/principal";

export interface Account {
owner: Principal;
subaccount: [] | [Uint8Array];
subaccount: [] | [Uint8Array | number[]];
}
export interface GetAccountIdentifierTransactionsArgs {
max_results: bigint;
Expand Down Expand Up @@ -33,17 +33,17 @@ export interface GetBlocksRequest {
length: bigint;
}
export interface GetBlocksResponse {
blocks: Array<Uint8Array>;
blocks: Array<Uint8Array | number[]>;
chain_length: bigint;
}
export interface HttpRequest {
url: string;
method: string;
body: Uint8Array;
body: Uint8Array | number[];
headers: Array<[string, string]>;
}
export interface HttpResponse {
body: Uint8Array;
body: Uint8Array | number[];
headers: Array<[string, string]>;
status_code: number;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ export interface Tokens {
}
export interface Transaction {
memo: bigint;
icrc1_memo: [] | [Uint8Array];
icrc1_memo: [] | [Uint8Array | number[]];
operation: Operation;
created_at_time: [] | [TimeStamp];
}
Expand Down
Loading

0 comments on commit 3076126

Please sign in to comment.