Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dfx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
{
"dfx": "0.26.1",
"canisters": {
"plug_helper": {
"type": "custom",
"build": "scripts/build.plug_helper.sh",
"candid": "target/plug_helper.did",
"wasm": "target/plug_helper.wasm.gz",
"specified_id": "ajx4k-liaaa-aaaal-ajqfq-cai",
"shrink": false,
"remote": {
"id": {
"ic": "ajx4k-liaaa-aaaal-ajqfq-cai",
"beta": "ajx4k-liaaa-aaaal-ajqfq-cai",
"staging": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_be_1": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_1": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_2": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_3": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_4": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_5": "ajx4k-liaaa-aaaal-ajqfq-cai",
"test_fe_6": "ajx4k-liaaa-aaaal-ajqfq-cai",
"e2e": "ajx4k-liaaa-aaaal-ajqfq-cai",
"audit": "ajx4k-liaaa-aaaal-ajqfq-cai"
}
}
},
"signer": {
"type": "custom",
"build": "scripts/build.signer.sh",
Expand Down
57 changes: 57 additions & 0 deletions scripts/build.plug_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail

print_help() {
cat <<-EOF
Creates the Plug helper canister installation files:

- The Candid file is fetched from the canister itself.

The files are installed at the locations defined for 'plug_helper' in 'dfx.json'.

Unlike the other third-party canisters here, this interface is not published in
any public repository, so there is no URL to download. The canister does expose
its own interface via '__get_candid_interface_tmp_hack', which makes the
deployed canister the only authoritative source — and fetching from it keeps
the checked-in bindings honest about what is actually live.
EOF
}

[[ "${1:-}" != "--help" ]] || {
print_help
exit 0
}

PLUG_HELPER_BUILDENV="$DFX_NETWORK"
export PLUG_HELPER_BUILDENV

CANISTER_ID="$(jq -r .canisters.plug_helper.remote.id.ic dfx.json)"
CANDID_FILE="$(jq -r .canisters.plug_helper.candid dfx.json)"

mkdir -p "$(dirname "$CANDID_FILE")"

if test -e "$CANDID_FILE"; then
echo "Candid file already exists, keeping it: $CANDID_FILE"
else
# dfx warns that it cannot fetch the Candid interface for this very call; that is
# expected and harmless, so stderr is dropped. The reply is a Candid text value,
# which `--output json` renders as a JSON string that jq can unescape faithfully —
# doing the unescaping by hand would mangle the embedded newlines.
DFX_WARNING=-mainnet_plaintext_identity dfx canister --network "$DFX_NETWORK" \
call "$CANISTER_ID" __get_candid_interface_tmp_hack "()" --output json 2>/dev/null |
jq -r . >"$CANDID_FILE"

# A truncated or empty reply must fail the build rather than silently produce
# bindings for an empty service.
if ! grep -q "^service :" "$CANDID_FILE"; then
echo "ERROR: fetched Candid does not declare a service: $CANDID_FILE" >&2
exit 1
fi
fi

####
# Success
cat <<EOF
SUCCESS: The plug_helper installation files have been created:
plug_helper candid: $CANDID_FILE
EOF
3 changes: 2 additions & 1 deletion scripts/did.delete.types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const promises = Object.keys(canisters)
'dip721',
'icpunks',
'icrc7',
'icrc3'
'icrc3',
'plug_helper'
].includes(canister)
)
.map(deleteFolder);
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ DFX_NETWORK=ic ./scripts/build.icpunks.sh
DFX_NETWORK=ic ./scripts/build.icrc7.sh
# .. creates candid for icrc3
DFX_NETWORK=ic ./scripts/build.icrc3.sh
# .. fetches candid for the plug_helper from the canister itself
DFX_NETWORK=ic ./scripts/build.plug_helper.sh
# Download .did files listed in dfx.json
install_did_files
# Generate Rust bindings
Expand Down
93 changes: 93 additions & 0 deletions src/declarations/plug_helper/plug_helper.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
type BtcNetwork = variant { Mainnet; Testnet };
type CallType = variant { Send; Sign };
type Icrc21ConsentInfo = record {
metadata : Icrc21ConsentMessageMetadata;
consent_message : Icrc21ConsentMessage
};
type Icrc21ConsentMessage = variant {
FieldsDisplayMessage : record {
fields : vec record { text; Value };
intent : text
};
GenericDisplayMessage : text
};
type Icrc21ConsentMessageMetadata = record {
utc_offset_minutes : opt int16;
language : text
};
type Icrc21ConsentMessageRequest = record {
arg : blob;
method : text;
user_preferences : Icrc21ConsentMessageSpec
};
type Icrc21ConsentMessageSpec = record {
metadata : Icrc21ConsentMessageMetadata;
device_spec : opt Icrc21DeviceSpec
};
type Icrc21DeviceSpec = variant { GenericDisplay; FieldsDisplay };
type Icrc21ErrorInfo = record { description : text };
type Outpoint = record { txid : blob; vout : nat32 };
type Result = variant { Ok : text; Err : text };
type Result_1 = variant { Ok : Icrc21ConsentInfo; Err : Icrc21ErrorInfo };
type Result_2 = variant { Ok : SchnorrPublicKeyResponse; Err : text };
type Result_3 = variant { Ok : blob; Err : text };
type Result_4 = variant { Ok : nat; Err : text };
type SchnorrAlgorithm = variant { ed25519; bip340secp256k1 };
type SchnorrPublicKeyResponse = record { public_key : blob; chain_code : blob };
type Utxo = record { height : nat32; value : nat64; outpoint : Outpoint };
type Value = variant {
Text : record { content : text };
TokenAmount : record { decimals : nat8; amount : nat64; symbol : text };
TimestampSeconds : record { amount : nat64 };
DurationSeconds : record { amount : nat64 }
};
service : {
approve_erc20 : (CallType, nat, nat, nat, nat, nat, nat64, text) -> (Result);
btc_p2tr_raw_key_address : (principal, BtcNetwork) -> (Result);
custom_approve_erc20 : (
CallType,
nat,
nat,
nat,
nat,
nat,
nat64,
text,
text
) -> (Result);
custom_deposit_erc20 : (CallType, nat, nat, nat, nat, nat, nat64, text) -> (
Result
);
deposit_erc20 : (CallType, nat, nat, nat, nat, nat, nat64, text) -> (Result);
doge_address : (opt principal, bool) -> (text);
eth_address : (opt principal) -> (text);
eth_call_contract : (
CallType,
nat,
nat,
nat,
nat,
nat,
nat64,
text,
text
) -> (Result);
icrc21_canister_call_consent_message : (Icrc21ConsentMessageRequest) -> (
Result_1
);
mint_cketh : (CallType, nat, nat, nat, nat, nat, nat64) -> (Result);
personal_sign : (text) -> (Result);
public_key : (SchnorrAlgorithm) -> (Result_2);
send_btc : (CallType, text, nat64, nat64, BtcNetwork, vec Utxo) -> (Result);
send_erc20 : (CallType, nat, nat, nat, nat, nat, nat64, text, text) -> (
Result
);
send_eth : (CallType, text, nat, nat, nat, nat, nat, nat64) -> (Result);
send_ordinal : (CallType, text, nat64, BtcNetwork, Utxo, Utxo) -> (Result);
sign_doge : (text, nat64, nat64, vec Utxo, bool) -> (Result);
sign_hash : (blob) -> (Result);
sign_sol : (blob) -> (Result_3);
solana_address : (principal) -> (Result);
ton_address : (principal) -> (Result);
transaction_count : (opt principal, nat64) -> (Result_4)
}
117 changes: 117 additions & 0 deletions src/declarations/plug_helper/plug_helper.did.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* eslint-disable */

// @ts-nocheck

// This file was automatically generated by @icp-sdk/bindgen@0.2.3.
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import type { ActorMethod } from '@icp-sdk/core/agent';
import type { IDL } from '@icp-sdk/core/candid';
import type { Principal } from '@icp-sdk/core/principal';

export type BtcNetwork = { Mainnet: null } | { Testnet: null };
export type CallType = { Send: null } | { Sign: null };
export interface Icrc21ConsentInfo {
metadata: Icrc21ConsentMessageMetadata;
consent_message: Icrc21ConsentMessage;
}
export type Icrc21ConsentMessage =
| {
FieldsDisplayMessage: {
fields: Array<[string, Value]>;
intent: string;
};
}
| { GenericDisplayMessage: string };
export interface Icrc21ConsentMessageMetadata {
utc_offset_minutes: [] | [number];
language: string;
}
export interface Icrc21ConsentMessageRequest {
arg: Uint8Array;
method: string;
user_preferences: Icrc21ConsentMessageSpec;
}
export interface Icrc21ConsentMessageSpec {
metadata: Icrc21ConsentMessageMetadata;
device_spec: [] | [Icrc21DeviceSpec];
}
export type Icrc21DeviceSpec = { GenericDisplay: null } | { FieldsDisplay: null };
export interface Icrc21ErrorInfo {
description: string;
}
export interface Outpoint {
txid: Uint8Array;
vout: number;
}
export type Result = { Ok: string } | { Err: string };
export type Result_1 = { Ok: Icrc21ConsentInfo } | { Err: Icrc21ErrorInfo };
export type Result_2 = { Ok: SchnorrPublicKeyResponse } | { Err: string };
export type Result_3 = { Ok: Uint8Array } | { Err: string };
export type Result_4 = { Ok: bigint } | { Err: string };
export type SchnorrAlgorithm = { ed25519: null } | { bip340secp256k1: null };
export interface SchnorrPublicKeyResponse {
public_key: Uint8Array;
chain_code: Uint8Array;
}
export interface Utxo {
height: number;
value: bigint;
outpoint: Outpoint;
}
export type Value =
| { Text: { content: string } }
| {
TokenAmount: {
decimals: number;
amount: bigint;
symbol: string;
};
}
| { TimestampSeconds: { amount: bigint } }
| { DurationSeconds: { amount: bigint } };
export interface _SERVICE {
approve_erc20: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string],
Result
>;
btc_p2tr_raw_key_address: ActorMethod<[Principal, BtcNetwork], Result>;
custom_approve_erc20: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string, string],
Result
>;
custom_deposit_erc20: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string],
Result
>;
deposit_erc20: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string],
Result
>;
doge_address: ActorMethod<[[] | [Principal], boolean], string>;
eth_address: ActorMethod<[[] | [Principal]], string>;
eth_call_contract: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string, string],
Result
>;
icrc21_canister_call_consent_message: ActorMethod<[Icrc21ConsentMessageRequest], Result_1>;
mint_cketh: ActorMethod<[CallType, bigint, bigint, bigint, bigint, bigint, bigint], Result>;
personal_sign: ActorMethod<[string], Result>;
public_key: ActorMethod<[SchnorrAlgorithm], Result_2>;
send_btc: ActorMethod<[CallType, string, bigint, bigint, BtcNetwork, Array<Utxo>], Result>;
send_erc20: ActorMethod<
[CallType, bigint, bigint, bigint, bigint, bigint, bigint, string, string],
Result
>;
send_eth: ActorMethod<[CallType, string, bigint, bigint, bigint, bigint, bigint, bigint], Result>;
send_ordinal: ActorMethod<[CallType, string, bigint, BtcNetwork, Utxo, Utxo], Result>;
sign_doge: ActorMethod<[string, bigint, bigint, Array<Utxo>, boolean], Result>;
sign_hash: ActorMethod<[Uint8Array], Result>;
sign_sol: ActorMethod<[Uint8Array], Result_3>;
solana_address: ActorMethod<[Principal], Result>;
ton_address: ActorMethod<[Principal], Result>;
transaction_count: ActorMethod<[[] | [Principal], bigint], Result_4>;
}
export declare const idlFactory: IDL.InterfaceFactory;
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
Loading
Loading