Skip to content

Commit

Permalink
Merge pull request #1244 from demergent-labs/functional_syntax
Browse files Browse the repository at this point in the history
Functional syntax
  • Loading branch information
lastmjs authored Sep 22, 2023
2 parents 853a7f7 + f6c32c2 commit 303f71b
Show file tree
Hide file tree
Showing 36 changed files with 1,794 additions and 1,461 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# The check-basic-integration-tests-success job is designed to ensure that all jobs spun up from the matrix in the basic-integration-tests have succeeded

# All Examples TODO restore when https://github.com/demergent-labs/azle/issues/1192 is resolved
# "examples/async_await",
# "examples/audio_recorder",
# "examples/bitcoin",
# "examples/blob_array",
Expand Down Expand Up @@ -63,32 +62,13 @@
# "examples/optional_types",
# "examples/outgoing_http_requests",
# "examples/pre_and_post_upgrade",
# "examples/primitive_types",
# "examples/principal",
# "examples/query",
# "examples/randomness",
# "examples/rejections",
# "examples/robust_imports",
# "examples/run_time_errors",
# "examples/rust_type_conversions",
# "examples/service",
# "examples/simple_erc20",
# "examples/simple_user_accounts",
# "examples/stable_memory",
# "examples/stable_structures",
# "examples/timers",
# "examples/tuple_types",
# "examples/update"

# These are the ones that don't work
# "examples/func_types",
# "examples/generics",
# "examples/tuple_types",
# "examples/complex_types",
# "examples/motoko_examples/superheroes",
# "examples/motoko_examples/threshold_ecdsa",
# "examples/run_time_errors",
# "examples/robust_imports",

name: Azle Tests
on:
Expand Down Expand Up @@ -134,59 +114,14 @@ jobs:
run: |
EXAMPLE_DIRECTORIES=$(cat << END
[
"examples/audio_recorder",
"examples/async_await",
"examples/bitcoin",
"examples/blob_array",
"examples/bytes",
"examples/call_raw",
"examples/candid_encoding",
"examples/counter",
"examples/complex_init",
"examples/composite_queries",
"examples/cross_canister_calls",
"examples/cycles",
"examples/date",
"examples/ethereum_json_rpc",
"examples/guard_functions",
"examples/heartbeat",
"examples/ic_api",
"examples/imports",
"examples/init",
"examples/inspect_message",
"examples/key_value_store",
"examples/ledger_canister",
"examples/list_of_lists",
"examples/management_canister",
"examples/manual_reply",
"examples/motoko_examples/calc",
"examples/motoko_examples/counter",
"examples/motoko_examples/echo",
"examples/motoko_examples/factorial",
"examples/motoko_examples/hello",
"examples/motoko_examples/hello-world",
"examples/motoko_examples/http_counter",
"examples/motoko_examples/minimal-counter-dapp",
"examples/motoko_examples/persistent-storage",
"examples/motoko_examples/phone-book",
"examples/motoko_examples/quicksort",
"examples/motoko_examples/simple-to-do",
"examples/motoko_examples/whoami",
"examples/notify_raw",
"examples/null_example",
"examples/optional_types",
"examples/pre_and_post_upgrade",
"examples/outgoing_http_requests",
"examples/primitive_types",
"examples/principal",
"examples/query",
"examples/randomness",
"examples/rejections",
"examples/service",
"examples/simple_erc20",
"examples/simple_user_accounts",
"examples/stable_memory",
"examples/stable_structures",
"examples/timers",
"examples/update"
]
Expand Down
171 changes: 5 additions & 166 deletions canisters/management/index.ts
Original file line number Diff line number Diff line change
@@ -1,169 +1,8 @@
import {
blob,
Principal,
Record,
Service,
update,
Opt,
Vec,
Variant,
candid,
principal,
text,
Null,
Void
} from '../../src/lib_new';
import { HttpRequestArgs, HttpResponse } from './http_request';
import {
CanisterStatusArgs,
CanisterStatusResult,
CreateCanisterArgs,
CreateCanisterResult,
DeleteCanisterArgs,
DepositCyclesArgs,
InstallCodeArgs,
ProvisionalCreateCanisterWithCyclesArgs,
ProvisionalCreateCanisterWithCyclesResult,
ProvisionalTopUpCanisterArgs,
StartCanisterArgs,
StopCanisterArgs,
UninstallCodeArgs,
UpdateSettingsArgs
} from './canister_management';
import {
GetBalanceArgs,
GetCurrentFeePercentilesArgs,
GetUtxosArgs,
GetUtxosResult,
MillisatoshiPerByte,
Satoshi,
SendTransactionArgs
} from './bitcoin';
import { blob, Principal, Service, update } from '../../src/lib_functional';

export * from './http_request';
export * from './canister_management';
export * from './bitcoin';

export class EcdsaCurve extends Variant {
@candid(Null)
secp256k1: Null;
}

export class KeyId extends Record {
@candid(EcdsaCurve)
curve: EcdsaCurve;

@candid(text)
name: text;
}

export class EcdsaPublicKeyArgs extends Record {
@candid(Opt(principal))
canister_id: Opt<Principal>;

@candid(Vec(blob))
derivation_path: Vec<blob>;

@candid(KeyId)
key_id: KeyId;
}

export class EcdsaPublicKeyResult extends Record {
@candid(blob)
public_key: blob;

@candid(blob)
chain_code: blob;
}

export class SignWithEcdsaArgs extends Record {
@candid(blob)
message_hash: blob;

@candid(Vec(blob))
derivation_path: Vec<blob>;

@candid(KeyId)
key_id: KeyId;
}

export class SignWithEcdsaResult extends Record {
signature: blob;
}

class ManagementCanister extends Service {
@update([EcdsaPublicKeyArgs], EcdsaPublicKeyResult)
ecdsa_public_key: (
args: EcdsaPublicKeyArgs
) => Promise<EcdsaPublicKeyResult>;

@update([HttpRequestArgs], HttpResponse)
http_request: (args: HttpRequestArgs) => Promise<HttpResponse>;

@update([], blob)
raw_rand: () => Promise<blob>;

@update([SignWithEcdsaArgs], SignWithEcdsaResult)
sign_with_ecdsa: (args: SignWithEcdsaArgs) => Promise<SignWithEcdsaResult>;

@update([CreateCanisterArgs], CreateCanisterResult)
create_canister: (
args: CreateCanisterArgs
) => Promise<CreateCanisterResult>;

@update([UpdateSettingsArgs], Void)
update_settings: (args: UpdateSettingsArgs) => Void;

@update([InstallCodeArgs], Void)
install_code: (args: InstallCodeArgs) => Void;

@update([UninstallCodeArgs], Void)
uninstall_code: (args: UninstallCodeArgs) => Void;

@update([StartCanisterArgs], Void)
start_canister: (args: StartCanisterArgs) => Void;

@update([StopCanisterArgs], Void)
stop_canister: (args: StopCanisterArgs) => Void;

@update([CanisterStatusArgs], CanisterStatusResult)
canister_status: (args: CanisterStatusArgs) => CanisterStatusResult;

@update([DeleteCanisterArgs], Void)
delete_canister: (args: DeleteCanisterArgs) => Void;

@update([DepositCyclesArgs], Void)
deposit_cycles: (args: DepositCyclesArgs) => Void;

@update(
[ProvisionalCreateCanisterWithCyclesArgs],
ProvisionalCreateCanisterWithCyclesArgs
)
provisional_create_canister_with_cycles: (
args: ProvisionalCreateCanisterWithCyclesArgs
) => ProvisionalCreateCanisterWithCyclesResult;

@update([ProvisionalTopUpCanisterArgs], Void)
provisional_top_up_canister: (args: ProvisionalTopUpCanisterArgs) => Void;

@update([GetBalanceArgs], Satoshi)
bitcoin_get_balance: (args: GetBalanceArgs) => Satoshi;

@update([GetCurrentFeePercentilesArgs], Vec(MillisatoshiPerByte))
bitcoin_get_current_fee_percentiles: (
args: GetCurrentFeePercentilesArgs
) => Vec<MillisatoshiPerByte>;

@update([GetUtxosArgs], GetUtxosResult)
bitcoin_get_utxos: (args: GetUtxosArgs) => GetUtxosResult;

@update([SendTransactionArgs], Void)
bitcoin_send_transaction: (args: SendTransactionArgs) => Void;
}

/**
* A virtual canister with canister and user management functionality
*/
export const managementCanister = new ManagementCanister(
export const managementCanister = Service(
{
raw_rand: update([], blob)
},
Principal.fromText('aaaaa-aa')
);
Loading

0 comments on commit 303f71b

Please sign in to comment.