Skip to content

Commit

Permalink
Merge branch 'main' into feat/sign
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Sep 25, 2024
2 parents c041cb6 + 76061cb commit 5650340
Show file tree
Hide file tree
Showing 17 changed files with 900 additions and 57 deletions.
2 changes: 1 addition & 1 deletion scripts/build.signer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ print_help() {

DFX_NETWORK="${DFX_NETWORK:-local}"

SIGNER_RELEASE="v0.1.2"
SIGNER_RELEASE="v0.2.1"
SIGNER_RELEASE_URL="https://github.com/dfinity/chain-fusion-signer/releases/download/${SIGNER_RELEASE}"
CANDID_URL="${SIGNER_RELEASE_URL}/signer.did"
WASM_URL="${SIGNER_RELEASE_URL}/signer.wasm.gz"
Expand Down
135 changes: 131 additions & 4 deletions src/declarations/signer/signer.did
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
type Account = record { owner : principal; subaccount : opt blob };
type Arg = variant { Upgrade; Init : InitArg };
type BitcoinAddressType = variant { P2WPKH };
type BitcoinNetwork = variant { mainnet; regtest; testnet };
type BtcTxOutput = record { destination_address : text; sent_satoshis : nat64 };
type CallerPaysIcrc2Tokens = record { ledger : principal };
type CanisterStatusResultV2 = record {
controller : principal;
status : CanisterStatusType;
Expand All @@ -12,14 +16,40 @@ type CanisterStatusResultV2 = record {
module_hash : opt blob;
};
type CanisterStatusType = variant { stopped; stopping; running };
type Config = record { ecdsa_key_name : text; ic_root_key_raw : opt blob };
type Config = record {
ecdsa_key_name : text;
ic_root_key_raw : opt blob;
cycles_ledger : principal;
};
type DefiniteCanisterSettingsArgs = record {
controller : principal;
freezing_threshold : nat;
controllers : vec principal;
memory_allocation : nat;
compute_allocation : nat;
};
type EcdsaCurve = variant { secp256k1 };
type EcdsaKeyId = record { name : text; curve : EcdsaCurve };
type EcdsaPublicKeyArgument = record {
key_id : EcdsaKeyId;
canister_id : opt principal;
derivation_path : vec blob;
};
type EcdsaPublicKeyResponse = record { public_key : blob; chain_code : blob };
type GenericSigningError = variant {
SigningError : record { RejectionCode_1; text };
PaymentError : PaymentError;
};
type GetAddressError = variant {
InternalError : record { msg : text };
PaymentError : PaymentError;
};
type GetAddressRequest = record {
network : BitcoinNetwork;
address_type : BitcoinAddressType;
};
type GetAddressResponse = record { address : text };
type GetBalanceResponse = record { balance : nat64 };
type HttpRequest = record {
url : text;
method : text;
Expand All @@ -31,7 +61,68 @@ type HttpResponse = record {
headers : vec record { text; text };
status_code : nat16;
};
type InitArg = record { ecdsa_key_name : text; ic_root_key_der : opt blob };
type InitArg = record {
ecdsa_key_name : text;
ic_root_key_der : opt blob;
cycles_ledger : opt principal;
};
type Outpoint = record { txid : blob; vout : nat32 };
type PatronPaysIcrc2Tokens = record { ledger : principal; patron : Account };
type PaymentError = variant {
LedgerUnreachable : CallerPaysIcrc2Tokens;
UnsupportedPaymentType;
LedgerError : record { error : WithdrawFromError; ledger : principal };
InsufficientFunds : record { needed : nat64; available : nat64 };
};
type PaymentType = variant {
PatronPaysIcrc2Tokens : PatronPaysIcrc2Tokens;
AttachedCycles;
CallerPaysIcrc2Cycles;
CallerPaysIcrc2Tokens : CallerPaysIcrc2Tokens;
PatronPaysIcrc2Cycles : Account;
};
type RejectionCode = variant {
NoError;
CanisterError;
SysTransient;
DestinationInvalid;
Unknown;
SysFatal;
CanisterReject;
};
type RejectionCode_1 = variant {
NoError;
CanisterError;
SysTransient;
DestinationInvalid;
Unknown;
SysFatal;
CanisterReject;
};
type Result = variant { Ok : GetAddressResponse; Err : GetAddressError };
type Result_1 = variant { Ok : GetBalanceResponse; Err : GetAddressError };
type Result_2 = variant { Ok : SendBtcResponse; Err : SendBtcError };
type Result_3 = variant { Ok : text; Err : GenericSigningError };
type Result_4 = variant {
Ok : record { EcdsaPublicKeyResponse };
Err : GenericSigningError;
};
type Result_5 = variant {
Ok : record { SignWithEcdsaResponse };
Err : GenericSigningError;
};
type SendBtcError = variant {
InternalError : record { msg : text };
PaymentError : PaymentError;
};
type SendBtcRequest = record {
fee_satoshis : opt nat64;
network : BitcoinNetwork;
utxos_to_spend : vec Utxo;
address_type : BitcoinAddressType;
outputs : vec BtcTxOutput;
};
type SendBtcResponse = record { txid : text };
type SignRequest = record {
to : text;
gas : nat;
Expand All @@ -42,12 +133,48 @@ type SignRequest = record {
chain_id : nat;
nonce : nat;
};
type SignWithEcdsaArgument = record {
key_id : EcdsaKeyId;
derivation_path : vec blob;
message_hash : blob;
};
type SignWithEcdsaResponse = record { signature : blob };
type Utxo = record { height : nat32; value : nat64; outpoint : Outpoint };
type WithdrawFromError = variant {
GenericError : record { message : text; error_code : nat };
TemporarilyUnavailable;
InsufficientAllowance : record { allowance : nat };
Duplicate : record { duplicate_of : nat };
InvalidReceiver : record { receiver : principal };
CreatedInFuture : record { ledger_time : nat64 };
TooOld;
FailedToWithdrawFrom : record {
withdraw_from_block : opt nat;
rejection_code : RejectionCode_1;
refund_block : opt nat;
approval_refund_block : opt nat;
rejection_reason : text;
};
InsufficientFunds : record { balance : nat };
};
service : (Arg) -> {
caller_btc_address : (BitcoinNetwork) -> (text);
caller_btc_balance : (BitcoinNetwork) -> (nat64);
btc_caller_address : (GetAddressRequest, opt PaymentType) -> (Result);
btc_caller_balance : (GetAddressRequest, opt PaymentType) -> (Result_1);
btc_caller_send : (SendBtcRequest, opt PaymentType) -> (Result_2);
caller_eth_address : () -> (text);
config : () -> (Config) query;
eth_address_of : (principal) -> (text);
eth_address_of_caller : (opt PaymentType) -> (Result_3);
eth_address_of_principal : (principal, opt PaymentType) -> (Result_3);
eth_personal_sign : (text, opt PaymentType) -> (Result_3);
eth_sign_transaction : (SignRequest, opt PaymentType) -> (Result_3);
generic_caller_ecdsa_public_key : (
EcdsaPublicKeyArgument,
opt PaymentType,
) -> (Result_4);
generic_sign_with_ecdsa : (opt PaymentType, SignWithEcdsaArgument) -> (
Result_5,
);
get_canister_status : () -> (CanisterStatusResultV2);
http_request : (HttpRequest) -> (HttpResponse) query;
personal_sign : (text) -> (text);
Expand Down
143 changes: 141 additions & 2 deletions src/declarations/signer/signer.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@ import type { ActorMethod } from '@dfinity/agent';
import type { IDL } from '@dfinity/candid';
import type { Principal } from '@dfinity/principal';

export interface Account {
owner: Principal;
subaccount: [] | [Uint8Array | number[]];
}
export type Arg = { Upgrade: null } | { Init: InitArg };
export type BitcoinAddressType = { P2WPKH: null };
export type BitcoinNetwork = { mainnet: null } | { regtest: null } | { testnet: null };
export interface BtcTxOutput {
destination_address: string;
sent_satoshis: bigint;
}
export interface CallerPaysIcrc2Tokens {
ledger: Principal;
}
export interface CanisterStatusResultV2 {
controller: Principal;
status: CanisterStatusType;
Expand All @@ -19,6 +31,7 @@ export type CanisterStatusType = { stopped: null } | { stopping: null } | { runn
export interface Config {
ecdsa_key_name: string;
ic_root_key_raw: [] | [Uint8Array | number[]];
cycles_ledger: Principal;
}
export interface DefiniteCanisterSettingsArgs {
controller: Principal;
Expand All @@ -27,6 +40,36 @@ export interface DefiniteCanisterSettingsArgs {
memory_allocation: bigint;
compute_allocation: bigint;
}
export type EcdsaCurve = { secp256k1: null };
export interface EcdsaKeyId {
name: string;
curve: EcdsaCurve;
}
export interface EcdsaPublicKeyArgument {
key_id: EcdsaKeyId;
canister_id: [] | [Principal];
derivation_path: Array<Uint8Array | number[]>;
}
export interface EcdsaPublicKeyResponse {
public_key: Uint8Array | number[];
chain_code: Uint8Array | number[];
}
export type GenericSigningError =
| {
SigningError: [RejectionCode_1, string];
}
| { PaymentError: PaymentError };
export type GetAddressError = { InternalError: { msg: string } } | { PaymentError: PaymentError };
export interface GetAddressRequest {
network: BitcoinNetwork;
address_type: BitcoinAddressType;
}
export interface GetAddressResponse {
address: string;
}
export interface GetBalanceResponse {
balance: bigint;
}
export interface HttpRequest {
url: string;
method: string;
Expand All @@ -41,6 +84,59 @@ export interface HttpResponse {
export interface InitArg {
ecdsa_key_name: string;
ic_root_key_der: [] | [Uint8Array | number[]];
cycles_ledger: [] | [Principal];
}
export interface Outpoint {
txid: Uint8Array | number[];
vout: number;
}
export interface PatronPaysIcrc2Tokens {
ledger: Principal;
patron: Account;
}
export type PaymentError =
| { LedgerUnreachable: CallerPaysIcrc2Tokens }
| { UnsupportedPaymentType: null }
| { LedgerError: { error: WithdrawFromError; ledger: Principal } }
| { InsufficientFunds: { needed: bigint; available: bigint } };
export type PaymentType =
| { PatronPaysIcrc2Tokens: PatronPaysIcrc2Tokens }
| { AttachedCycles: null }
| { CallerPaysIcrc2Cycles: null }
| { CallerPaysIcrc2Tokens: CallerPaysIcrc2Tokens }
| { PatronPaysIcrc2Cycles: Account };
export type RejectionCode =
| { NoError: null }
| { CanisterError: null }
| { SysTransient: null }
| { DestinationInvalid: null }
| { Unknown: null }
| { SysFatal: null }
| { CanisterReject: null };
export type RejectionCode_1 =
| { NoError: null }
| { CanisterError: null }
| { SysTransient: null }
| { DestinationInvalid: null }
| { Unknown: null }
| { SysFatal: null }
| { CanisterReject: null };
export type Result = { Ok: GetAddressResponse } | { Err: GetAddressError };
export type Result_1 = { Ok: GetBalanceResponse } | { Err: GetAddressError };
export type Result_2 = { Ok: SendBtcResponse } | { Err: SendBtcError };
export type Result_3 = { Ok: string } | { Err: GenericSigningError };
export type Result_4 = { Ok: [EcdsaPublicKeyResponse] } | { Err: GenericSigningError };
export type Result_5 = { Ok: [SignWithEcdsaResponse] } | { Err: GenericSigningError };
export type SendBtcError = { InternalError: { msg: string } } | { PaymentError: PaymentError };
export interface SendBtcRequest {
fee_satoshis: [] | [bigint];
network: BitcoinNetwork;
utxos_to_spend: Array<Utxo>;
address_type: BitcoinAddressType;
outputs: Array<BtcTxOutput>;
}
export interface SendBtcResponse {
txid: string;
}
export interface SignRequest {
to: string;
Expand All @@ -52,12 +148,55 @@ export interface SignRequest {
chain_id: bigint;
nonce: bigint;
}
export interface SignWithEcdsaArgument {
key_id: EcdsaKeyId;
derivation_path: Array<Uint8Array | number[]>;
message_hash: Uint8Array | number[];
}
export interface SignWithEcdsaResponse {
signature: Uint8Array | number[];
}
export interface Utxo {
height: number;
value: bigint;
outpoint: Outpoint;
}
export type WithdrawFromError =
| {
GenericError: { message: string; error_code: bigint };
}
| { TemporarilyUnavailable: null }
| { InsufficientAllowance: { allowance: bigint } }
| { Duplicate: { duplicate_of: bigint } }
| { InvalidReceiver: { receiver: Principal } }
| { CreatedInFuture: { ledger_time: bigint } }
| { TooOld: null }
| {
FailedToWithdrawFrom: {
withdraw_from_block: [] | [bigint];
rejection_code: RejectionCode_1;
refund_block: [] | [bigint];
approval_refund_block: [] | [bigint];
rejection_reason: string;
};
}
| { InsufficientFunds: { balance: bigint } };
export interface _SERVICE {
caller_btc_address: ActorMethod<[BitcoinNetwork], string>;
caller_btc_balance: ActorMethod<[BitcoinNetwork], bigint>;
btc_caller_address: ActorMethod<[GetAddressRequest, [] | [PaymentType]], Result>;
btc_caller_balance: ActorMethod<[GetAddressRequest, [] | [PaymentType]], Result_1>;
btc_caller_send: ActorMethod<[SendBtcRequest, [] | [PaymentType]], Result_2>;
caller_eth_address: ActorMethod<[], string>;
config: ActorMethod<[], Config>;
eth_address_of: ActorMethod<[Principal], string>;
eth_address_of_caller: ActorMethod<[[] | [PaymentType]], Result_3>;
eth_address_of_principal: ActorMethod<[Principal, [] | [PaymentType]], Result_3>;
eth_personal_sign: ActorMethod<[string, [] | [PaymentType]], Result_3>;
eth_sign_transaction: ActorMethod<[SignRequest, [] | [PaymentType]], Result_3>;
generic_caller_ecdsa_public_key: ActorMethod<
[EcdsaPublicKeyArgument, [] | [PaymentType]],
Result_4
>;
generic_sign_with_ecdsa: ActorMethod<[[] | [PaymentType], SignWithEcdsaArgument], Result_5>;
get_canister_status: ActorMethod<[], CanisterStatusResultV2>;
http_request: ActorMethod<[HttpRequest], HttpResponse>;
personal_sign: ActorMethod<[string], string>;
Expand Down
Loading

0 comments on commit 5650340

Please sign in to comment.