diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..80ff6c9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Multisig Vault Tests +on: + push: + branches: + - main + pull_request: # Runs on pull requests to any branch +jobs: + basic-integration-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: DFX_VERSION=0.11.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" + - name: Install Rust ${{ matrix.rust }} + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - uses: Swatinem/rust-cache@v2 # TODO The Rust cache is not working at all + # - name: Rust cache # TODO I can't figure out how to actually get the cache to work + # uses: actions/cache@v2 + # continue-on-error: false + # with: + # path: target + # key: multisig_vault_cache_${{ hashFiles('target/azle/Cargo.lock') }} + # # restore-keys: multisig_vault-cache # TODO might need to be more intelligent and hash files here + - run: dfx start --clean --background + - shell: bash -l {0} + run: npm install + - shell: bash -l {0} + run: cd canisters/frontend && npm install + - shell: bash -l {0} + run: npm test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 42452e9..837c4f4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ target node_modules build -canisters/icp_ledger -canisters/internet_identity \ No newline at end of file +canisters/icp_ledger/*.wasm +canisters/internet_identity/*.wasm diff --git a/README.md b/README.md index 017dfb2..89f6e0d 100644 --- a/README.md +++ b/README.md @@ -65,4 +65,4 @@ dfx canister --network ic update-settings --add-controller $(dfx canister id bac # TODO not yet sure what this command is ``` -TODO test +TODO diff --git a/canisters/frontend/dfx_generated/backend/backend.did.d.ts b/canisters/frontend/dfx_generated/backend/backend.did.d.ts index 561bc66..b97d367 100644 --- a/canisters/frontend/dfx_generated/backend/backend.did.d.ts +++ b/canisters/frontend/dfx_generated/backend/backend.did.d.ts @@ -1,291 +1,238 @@ import type { Principal } from '@dfinity/principal'; import type { ActorMethod } from '@dfinity/agent'; -export interface AccountBalanceArgs { - account: Array; -} -export interface Archive { - canister_id: Principal; -} -export interface Archives { - archives: Array; -} +export interface AccountBalanceArgs { 'account' : Array } +export interface Archive { 'canister_id' : Principal } +export interface Archives { 'archives' : Array } export interface Block { - transaction: Transaction; - timestamp: TimeStamp; - parent_hash: [] | [Array]; -} -export interface BlockRange { - blocks: Array; + 'transaction' : Transaction, + 'timestamp' : TimeStamp, + 'parent_hash' : [] | [Array], } +export interface BlockRange { 'blocks' : Array } export interface CanisterSettings { - freezing_threshold: [] | [bigint]; - controllers: [] | [Array]; - memory_allocation: [] | [bigint]; - compute_allocation: [] | [bigint]; -} -export type CanisterStatus = - | { stopped: null } - | { stopping: null } - | { running: null }; -export interface CanisterStatusArgs { - canister_id: Principal; -} + 'freezing_threshold' : [] | [bigint], + 'controllers' : [] | [Array], + 'memory_allocation' : [] | [bigint], + 'compute_allocation' : [] | [bigint], +} +export type CanisterStatus = { 'stopped' : null } | + { 'stopping' : null } | + { 'running' : null }; +export interface CanisterStatusArgs { 'canister_id' : Principal } export interface CanisterStatusResult { - status: CanisterStatus; - memory_size: bigint; - cycles: bigint; - settings: DefiniteCanisterSettings; - module_hash: [] | [Array]; + 'status' : CanisterStatus, + 'memory_size' : bigint, + 'cycles' : bigint, + 'settings' : DefiniteCanisterSettings, + 'module_hash' : [] | [Array], } export interface ControllersInfo { - frontend: Array; - backend: Array; -} -export type ControllersInfoResult = { ok: ControllersInfo } | { err: string }; -export interface CreateCanisterArgs { - settings: [] | [CanisterSettings]; -} -export interface CreateCanisterResult { - canister_id: Principal; + 'frontend' : Array, + 'backend' : Array, } +export type ControllersInfoResult = { 'ok' : ControllersInfo } | + { 'err' : string }; +export interface CreateCanisterArgs { 'settings' : [] | [CanisterSettings] } +export interface CreateCanisterResult { 'canister_id' : Principal } export interface CycleStatsInfo { - frontend: { - cycles_remaining: bigint; - cycles_per_day: bigint; - cycles_per_min: bigint; - cycles_per_sec: bigint; - cycles_per_month: bigint; - cycles_per_hour: bigint; - cycles_per_week: bigint; - cycles_per_year: bigint; - cycle_time_remaining: bigint; - }; - backend: { - cycles_remaining: bigint; - cycles_per_day: bigint; - cycles_per_min: bigint; - cycles_per_sec: bigint; - cycles_per_month: bigint; - cycles_per_hour: bigint; - cycles_per_week: bigint; - cycles_per_year: bigint; - cycle_time_remaining: bigint; - }; -} -export interface DecimalsResult { - decimals: number; -} -export type DefaultResult = { ok: boolean } | { err: string }; + 'frontend' : { + 'cycles_remaining' : bigint, + 'cycles_per_day' : bigint, + 'cycles_per_min' : bigint, + 'cycles_per_sec' : bigint, + 'cycles_per_month' : bigint, + 'cycles_per_hour' : bigint, + 'cycles_per_week' : bigint, + 'cycles_per_year' : bigint, + 'cycle_time_remaining' : bigint, + }, + 'backend' : { + 'cycles_remaining' : bigint, + 'cycles_per_day' : bigint, + 'cycles_per_min' : bigint, + 'cycles_per_sec' : bigint, + 'cycles_per_month' : bigint, + 'cycles_per_hour' : bigint, + 'cycles_per_week' : bigint, + 'cycles_per_year' : bigint, + 'cycle_time_remaining' : bigint, + }, +} +export interface DecimalsResult { 'decimals' : number } +export type DefaultResult = { 'ok' : boolean } | + { 'err' : string }; export interface DefiniteCanisterSettings { - freezing_threshold: bigint; - controllers: Array; - memory_allocation: bigint; - compute_allocation: bigint; -} -export interface DeleteCanisterArgs { - canister_id: Principal; -} -export interface DepositCyclesArgs { - canister_id: Principal; -} -export interface GetBlocksArgs { - start: bigint; - length: bigint; -} + 'freezing_threshold' : bigint, + 'controllers' : Array, + 'memory_allocation' : bigint, + 'compute_allocation' : bigint, +} +export interface DeleteCanisterArgs { 'canister_id' : Principal } +export interface DepositCyclesArgs { 'canister_id' : Principal } +export interface GetBlocksArgs { 'start' : bigint, 'length' : bigint } export interface InstallCodeArgs { - arg: Array; - wasm_module: Array; - mode: InstallCodeMode; - canister_id: Principal; -} -export type InstallCodeMode = - | { reinstall: null } - | { upgrade: null } - | { install: null }; -export interface NameResult { - name: string; -} -export type Operation = - | { - Burn: { from: Array; amount: Tokens }; - } - | { Mint: { to: Array; amount: Tokens } } - | { - Transfer: { - to: Array; - fee: Tokens; - from: Array; - amount: Tokens; - }; - }; + 'arg' : Array, + 'wasm_module' : Array, + 'mode' : InstallCodeMode, + 'canister_id' : Principal, +} +export type InstallCodeMode = { 'reinstall' : null } | + { 'upgrade' : null } | + { 'install' : null }; +export interface NameResult { 'name' : string } +export type Operation = { + 'Burn' : { 'from' : Array, 'amount' : Tokens } + } | + { 'Mint' : { 'to' : Array, 'amount' : Tokens } } | + { + 'Transfer' : { + 'to' : Array, + 'fee' : Tokens, + 'from' : Array, + 'amount' : Tokens, + } + }; export interface ProvisionalCreateCanisterWithCyclesArgs { - settings: [] | [CanisterSettings]; - amount: [] | [bigint]; + 'settings' : [] | [CanisterSettings], + 'amount' : [] | [bigint], } export interface ProvisionalCreateCanisterWithCyclesResult { - canister_id: Principal; + 'canister_id' : Principal, } export interface ProvisionalTopUpCanisterArgs { - canister_id: Principal; - amount: bigint; -} -export type QueryArchiveError = - | { - BadFirstBlockIndex: { - requested_index: bigint; - first_valid_index: bigint; - }; - } - | { Other: { error_message: string; error_code: bigint } }; + 'canister_id' : Principal, + 'amount' : bigint, +} +export type QueryArchiveError = { + 'BadFirstBlockIndex' : { + 'requested_index' : bigint, + 'first_valid_index' : bigint, + } + } | + { 'Other' : { 'error_message' : string, 'error_code' : bigint } }; export type QueryArchiveFn = ActorMethod<[GetBlocksArgs], QueryArchiveResult>; -export type QueryArchiveResult = - | { Ok: BlockRange } - | { Err: QueryArchiveError }; +export type QueryArchiveResult = { 'Ok' : BlockRange } | + { 'Err' : QueryArchiveError }; export interface QueryBlocksResponse { - certificate: [] | [Array]; - blocks: Array; - chain_length: bigint; - first_block_index: bigint; - archived_blocks: Array<{ - callback: QueryArchiveFn; - start: bigint; - length: bigint; - }>; + 'certificate' : [] | [Array], + 'blocks' : Array, + 'chain_length' : bigint, + 'first_block_index' : bigint, + 'archived_blocks' : Array< + { 'callback' : QueryArchiveFn, 'start' : bigint, 'length' : bigint } + >, } export interface SignerProposal { - id: string; - remove: boolean; - rejected_at: [] | [bigint]; - adopted_at: [] | [bigint]; - votes: Array; - description: string; - created_at: bigint; - rejected: boolean; - proposer: Principal; - signer: Principal; - adopted: boolean; -} -export interface StartCanisterArgs { - canister_id: Principal; -} -export interface StopCanisterArgs { - canister_id: Principal; -} -export interface SymbolResult { - symbol: string; -} + 'id' : string, + 'remove' : boolean, + 'rejected_at' : [] | [bigint], + 'adopted_at' : [] | [bigint], + 'votes' : Array, + 'description' : string, + 'created_at' : bigint, + 'rejected' : boolean, + 'proposer' : Principal, + 'signer' : Principal, + 'adopted' : boolean, +} +export interface StartCanisterArgs { 'canister_id' : Principal } +export interface StopCanisterArgs { 'canister_id' : Principal } +export interface SymbolResult { 'symbol' : string } export interface ThresholdProposal { - id: string; - rejected_at: [] | [bigint]; - adopted_at: [] | [bigint]; - threshold: number; - votes: Array; - description: string; - created_at: bigint; - rejected: boolean; - proposer: Principal; - adopted: boolean; -} -export interface TimeStamp { - timestamp_nanos: bigint; -} -export interface Tokens { - e8s: bigint; -} + 'id' : string, + 'rejected_at' : [] | [bigint], + 'adopted_at' : [] | [bigint], + 'threshold' : number, + 'votes' : Array, + 'description' : string, + 'created_at' : bigint, + 'rejected' : boolean, + 'proposer' : Principal, + 'adopted' : boolean, +} +export interface TimeStamp { 'timestamp_nanos' : bigint } +export interface Tokens { 'e8s' : bigint } export interface Transaction { - memo: bigint; - operation: [] | [Operation]; - created_at_time: TimeStamp; -} -export interface Transfer { - id: string; - to: Principal; - amount: bigint; + 'memo' : bigint, + 'operation' : [] | [Operation], + 'created_at_time' : TimeStamp, } +export interface Transfer { 'id' : string, 'to' : Principal, 'amount' : bigint } export interface TransferArgs { - to: Array; - fee: Tokens; - memo: bigint; - from_subaccount: [] | [Array]; - created_at_time: [] | [TimeStamp]; - amount: Tokens; -} -export type TransferError = - | { - TxTooOld: { allowed_window_nanos: bigint }; - } - | { BadFee: { expected_fee: Tokens } } - | { TxDuplicate: { duplicate_of: bigint } } - | { TxCreatedInFuture: null } - | { InsufficientFunds: { balance: Tokens } }; -export interface TransferFee { - transfer_fee: Tokens; -} + 'to' : Array, + 'fee' : Tokens, + 'memo' : bigint, + 'from_subaccount' : [] | [Array], + 'created_at_time' : [] | [TimeStamp], + 'amount' : Tokens, +} +export type TransferError = { + 'TxTooOld' : { 'allowed_window_nanos' : bigint } + } | + { 'BadFee' : { 'expected_fee' : Tokens } } | + { 'TxDuplicate' : { 'duplicate_of' : bigint } } | + { 'TxCreatedInFuture' : null } | + { 'InsufficientFunds' : { 'balance' : Tokens } }; +export interface TransferFee { 'transfer_fee' : Tokens } export type TransferFeeArg = {}; export interface TransferProposal { - id: string; - destination_address: string; - rejected_at: [] | [bigint]; - adopted_at: [] | [bigint]; - votes: Array; - description: string; - created_at: bigint; - rejected: boolean; - proposer: Principal; - amount: bigint; - adopted: boolean; -} -export type TransferResult = { Ok: bigint } | { Err: TransferError }; -export interface UninstallCodeArgs { - canister_id: Principal; -} + 'id' : string, + 'destination_address' : string, + 'rejected_at' : [] | [bigint], + 'adopted_at' : [] | [bigint], + 'votes' : Array, + 'description' : string, + 'created_at' : bigint, + 'rejected' : boolean, + 'proposer' : Principal, + 'amount' : bigint, + 'adopted' : boolean, +} +export type TransferResult = { 'Ok' : bigint } | + { 'Err' : TransferError }; +export interface UninstallCodeArgs { 'canister_id' : Principal } export interface UpdateSettingsArgs { - canister_id: Principal; - settings: CanisterSettings; -} -export type VaultBalanceResult = { ok: bigint } | { err: string }; -export interface Vote { - adopt: boolean; - voter: Principal; -} -export type VoteOnProposalAction = - | { voted: null } - | { rejected: null } - | { adopted: null }; -export type VoteOnProposalResult = - | { ok: VoteOnProposalAction } - | { err: string }; -export type VoteOnTransferProposalResult = - | { ok: VoteOnProposalAction } - | { err: { transfer_error: TransferError } | { message: string } }; + 'canister_id' : Principal, + 'settings' : CanisterSettings, +} +export type VaultBalanceResult = { 'ok' : bigint } | + { 'err' : string }; +export interface Vote { 'adopt' : boolean, 'voter' : Principal } +export type VoteOnProposalAction = { 'voted' : null } | + { 'rejected' : null } | + { 'adopted' : null }; +export type VoteOnProposalResult = { 'ok' : VoteOnProposalAction } | + { 'err' : string }; +export type VoteOnTransferProposalResult = { 'ok' : VoteOnProposalAction } | + { 'err' : { 'transfer_error' : TransferError } | { 'message' : string } }; export interface _SERVICE { - get_address_from_principal: ActorMethod<[Principal], string>; - get_canister_address: ActorMethod<[], string>; - get_canister_principal: ActorMethod<[], Principal>; - get_controllers_info: ActorMethod<[], ControllersInfoResult>; - get_cycle_stats_info: ActorMethod<[], CycleStatsInfo>; - get_signer_proposals: ActorMethod<[], Array>; - get_signers: ActorMethod<[], Array>; - get_threshold: ActorMethod<[], number>; - get_threshold_proposals: ActorMethod<[], Array>; - get_transfer_proposals: ActorMethod<[], Array>; - get_transfers: ActorMethod<[], Array>; - get_vault_balance: ActorMethod<[], VaultBalanceResult>; - propose_signer: ActorMethod<[string, Principal, boolean], DefaultResult>; - propose_threshold: ActorMethod<[string, number], DefaultResult>; - propose_transfer: ActorMethod<[string, string, bigint], DefaultResult>; - snapshot_cycles: ActorMethod<[], DefaultResult>; - vote_on_signer_proposal: ActorMethod< - [string, boolean], - VoteOnProposalResult - >; - vote_on_threshold_proposal: ActorMethod< - [string, boolean], - VoteOnProposalResult - >; - vote_on_transfer_proposal: ActorMethod< - [string, boolean], - VoteOnTransferProposalResult - >; + 'get_address_from_principal' : ActorMethod<[Principal], string>, + 'get_canister_address' : ActorMethod<[], string>, + 'get_canister_principal' : ActorMethod<[], Principal>, + 'get_controllers_info' : ActorMethod<[], ControllersInfoResult>, + 'get_cycle_stats_info' : ActorMethod<[], CycleStatsInfo>, + 'get_signer_proposals' : ActorMethod<[], Array>, + 'get_signers' : ActorMethod<[], Array>, + 'get_threshold' : ActorMethod<[], number>, + 'get_threshold_proposals' : ActorMethod<[], Array>, + 'get_transfer_proposals' : ActorMethod<[], Array>, + 'get_transfers' : ActorMethod<[], Array>, + 'get_vault_balance' : ActorMethod<[], VaultBalanceResult>, + 'propose_signer' : ActorMethod<[string, Principal, boolean], DefaultResult>, + 'propose_threshold' : ActorMethod<[string, number], DefaultResult>, + 'propose_transfer' : ActorMethod<[string, string, bigint], DefaultResult>, + 'snapshot_cycles' : ActorMethod<[], DefaultResult>, + 'vote_on_signer_proposal' : ActorMethod< + [string, boolean], + VoteOnProposalResult, + >, + 'vote_on_threshold_proposal' : ActorMethod< + [string, boolean], + VoteOnProposalResult, + >, + 'vote_on_transfer_proposal' : ActorMethod< + [string, boolean], + VoteOnTransferProposalResult, + >, } diff --git a/canisters/frontend/dfx_generated/backend/backend.did.js b/canisters/frontend/dfx_generated/backend/backend.did.js index ae18bec..1d80a50 100644 --- a/canisters/frontend/dfx_generated/backend/backend.did.js +++ b/canisters/frontend/dfx_generated/backend/backend.did.js @@ -1,167 +1,161 @@ export const idlFactory = ({ IDL }) => { - const ControllersInfo = IDL.Record({ - frontend: IDL.Vec(IDL.Principal), - backend: IDL.Vec(IDL.Principal) - }); - const ControllersInfoResult = IDL.Variant({ - ok: ControllersInfo, - err: IDL.Text - }); - const CycleStatsInfo = IDL.Record({ - frontend: IDL.Record({ - cycles_remaining: IDL.Nat64, - cycles_per_day: IDL.Nat64, - cycles_per_min: IDL.Nat64, - cycles_per_sec: IDL.Nat64, - cycles_per_month: IDL.Nat64, - cycles_per_hour: IDL.Nat64, - cycles_per_week: IDL.Nat64, - cycles_per_year: IDL.Nat64, - cycle_time_remaining: IDL.Nat64 - }), - backend: IDL.Record({ - cycles_remaining: IDL.Nat64, - cycles_per_day: IDL.Nat64, - cycles_per_min: IDL.Nat64, - cycles_per_sec: IDL.Nat64, - cycles_per_month: IDL.Nat64, - cycles_per_hour: IDL.Nat64, - cycles_per_week: IDL.Nat64, - cycles_per_year: IDL.Nat64, - cycle_time_remaining: IDL.Nat64 - }) - }); - const Vote = IDL.Record({ adopt: IDL.Bool, voter: IDL.Principal }); - const SignerProposal = IDL.Record({ - id: IDL.Text, - remove: IDL.Bool, - rejected_at: IDL.Opt(IDL.Nat64), - adopted_at: IDL.Opt(IDL.Nat64), - votes: IDL.Vec(Vote), - description: IDL.Text, - created_at: IDL.Nat64, - rejected: IDL.Bool, - proposer: IDL.Principal, - signer: IDL.Principal, - adopted: IDL.Bool - }); - const ThresholdProposal = IDL.Record({ - id: IDL.Text, - rejected_at: IDL.Opt(IDL.Nat64), - adopted_at: IDL.Opt(IDL.Nat64), - threshold: IDL.Nat8, - votes: IDL.Vec(Vote), - description: IDL.Text, - created_at: IDL.Nat64, - rejected: IDL.Bool, - proposer: IDL.Principal, - adopted: IDL.Bool - }); - const TransferProposal = IDL.Record({ - id: IDL.Text, - destination_address: IDL.Text, - rejected_at: IDL.Opt(IDL.Nat64), - adopted_at: IDL.Opt(IDL.Nat64), - votes: IDL.Vec(Vote), - description: IDL.Text, - created_at: IDL.Nat64, - rejected: IDL.Bool, - proposer: IDL.Principal, - amount: IDL.Nat64, - adopted: IDL.Bool - }); - const Transfer = IDL.Record({ - id: IDL.Text, - to: IDL.Principal, - amount: IDL.Nat64 - }); - const VaultBalanceResult = IDL.Variant({ - ok: IDL.Nat64, - err: IDL.Text - }); - const DefaultResult = IDL.Variant({ ok: IDL.Bool, err: IDL.Text }); - const VoteOnProposalAction = IDL.Variant({ - voted: IDL.Null, - rejected: IDL.Null, - adopted: IDL.Null - }); - const VoteOnProposalResult = IDL.Variant({ - ok: VoteOnProposalAction, - err: IDL.Text - }); - const Tokens = IDL.Record({ e8s: IDL.Nat64 }); - const TransferError = IDL.Variant({ - TxTooOld: IDL.Record({ allowed_window_nanos: IDL.Nat64 }), - BadFee: IDL.Record({ expected_fee: Tokens }), - TxDuplicate: IDL.Record({ duplicate_of: IDL.Nat64 }), - TxCreatedInFuture: IDL.Null, - InsufficientFunds: IDL.Record({ balance: Tokens }) - }); - const VoteOnTransferProposalResult = IDL.Variant({ - ok: VoteOnProposalAction, - err: IDL.Variant({ - transfer_error: TransferError, - message: IDL.Text - }) - }); - return IDL.Service({ - get_address_from_principal: IDL.Func( - [IDL.Principal], - [IDL.Text], - ['query'] - ), - get_canister_address: IDL.Func([], [IDL.Text], ['query']), - get_canister_principal: IDL.Func([], [IDL.Principal], ['query']), - get_controllers_info: IDL.Func([], [ControllersInfoResult], []), - get_cycle_stats_info: IDL.Func([], [CycleStatsInfo], ['query']), - get_signer_proposals: IDL.Func( - [], - [IDL.Vec(SignerProposal)], - ['query'] - ), - get_signers: IDL.Func([], [IDL.Vec(IDL.Principal)], ['query']), - get_threshold: IDL.Func([], [IDL.Nat8], ['query']), - get_threshold_proposals: IDL.Func( - [], - [IDL.Vec(ThresholdProposal)], - ['query'] - ), - get_transfer_proposals: IDL.Func( - [], - [IDL.Vec(TransferProposal)], - ['query'] - ), - get_transfers: IDL.Func([], [IDL.Vec(Transfer)], ['query']), - get_vault_balance: IDL.Func([], [VaultBalanceResult], []), - propose_signer: IDL.Func( - [IDL.Text, IDL.Principal, IDL.Bool], - [DefaultResult], - [] - ), - propose_threshold: IDL.Func([IDL.Text, IDL.Nat8], [DefaultResult], []), - propose_transfer: IDL.Func( - [IDL.Text, IDL.Text, IDL.Nat64], - [DefaultResult], - [] - ), - snapshot_cycles: IDL.Func([], [DefaultResult], []), - vote_on_signer_proposal: IDL.Func( - [IDL.Text, IDL.Bool], - [VoteOnProposalResult], - [] - ), - vote_on_threshold_proposal: IDL.Func( - [IDL.Text, IDL.Bool], - [VoteOnProposalResult], - [] - ), - vote_on_transfer_proposal: IDL.Func( - [IDL.Text, IDL.Bool], - [VoteOnTransferProposalResult], - [] - ) - }); -}; -export const init = ({ IDL }) => { - return [IDL.Vec(IDL.Principal), IDL.Nat8]; + const ControllersInfo = IDL.Record({ + 'frontend' : IDL.Vec(IDL.Principal), + 'backend' : IDL.Vec(IDL.Principal), + }); + const ControllersInfoResult = IDL.Variant({ + 'ok' : ControllersInfo, + 'err' : IDL.Text, + }); + const CycleStatsInfo = IDL.Record({ + 'frontend' : IDL.Record({ + 'cycles_remaining' : IDL.Nat64, + 'cycles_per_day' : IDL.Nat64, + 'cycles_per_min' : IDL.Nat64, + 'cycles_per_sec' : IDL.Nat64, + 'cycles_per_month' : IDL.Nat64, + 'cycles_per_hour' : IDL.Nat64, + 'cycles_per_week' : IDL.Nat64, + 'cycles_per_year' : IDL.Nat64, + 'cycle_time_remaining' : IDL.Nat64, + }), + 'backend' : IDL.Record({ + 'cycles_remaining' : IDL.Nat64, + 'cycles_per_day' : IDL.Nat64, + 'cycles_per_min' : IDL.Nat64, + 'cycles_per_sec' : IDL.Nat64, + 'cycles_per_month' : IDL.Nat64, + 'cycles_per_hour' : IDL.Nat64, + 'cycles_per_week' : IDL.Nat64, + 'cycles_per_year' : IDL.Nat64, + 'cycle_time_remaining' : IDL.Nat64, + }), + }); + const Vote = IDL.Record({ 'adopt' : IDL.Bool, 'voter' : IDL.Principal }); + const SignerProposal = IDL.Record({ + 'id' : IDL.Text, + 'remove' : IDL.Bool, + 'rejected_at' : IDL.Opt(IDL.Nat64), + 'adopted_at' : IDL.Opt(IDL.Nat64), + 'votes' : IDL.Vec(Vote), + 'description' : IDL.Text, + 'created_at' : IDL.Nat64, + 'rejected' : IDL.Bool, + 'proposer' : IDL.Principal, + 'signer' : IDL.Principal, + 'adopted' : IDL.Bool, + }); + const ThresholdProposal = IDL.Record({ + 'id' : IDL.Text, + 'rejected_at' : IDL.Opt(IDL.Nat64), + 'adopted_at' : IDL.Opt(IDL.Nat64), + 'threshold' : IDL.Nat8, + 'votes' : IDL.Vec(Vote), + 'description' : IDL.Text, + 'created_at' : IDL.Nat64, + 'rejected' : IDL.Bool, + 'proposer' : IDL.Principal, + 'adopted' : IDL.Bool, + }); + const TransferProposal = IDL.Record({ + 'id' : IDL.Text, + 'destination_address' : IDL.Text, + 'rejected_at' : IDL.Opt(IDL.Nat64), + 'adopted_at' : IDL.Opt(IDL.Nat64), + 'votes' : IDL.Vec(Vote), + 'description' : IDL.Text, + 'created_at' : IDL.Nat64, + 'rejected' : IDL.Bool, + 'proposer' : IDL.Principal, + 'amount' : IDL.Nat64, + 'adopted' : IDL.Bool, + }); + const Transfer = IDL.Record({ + 'id' : IDL.Text, + 'to' : IDL.Principal, + 'amount' : IDL.Nat64, + }); + const VaultBalanceResult = IDL.Variant({ + 'ok' : IDL.Nat64, + 'err' : IDL.Text, + }); + const DefaultResult = IDL.Variant({ 'ok' : IDL.Bool, 'err' : IDL.Text }); + const VoteOnProposalAction = IDL.Variant({ + 'voted' : IDL.Null, + 'rejected' : IDL.Null, + 'adopted' : IDL.Null, + }); + const VoteOnProposalResult = IDL.Variant({ + 'ok' : VoteOnProposalAction, + 'err' : IDL.Text, + }); + const Tokens = IDL.Record({ 'e8s' : IDL.Nat64 }); + const TransferError = IDL.Variant({ + 'TxTooOld' : IDL.Record({ 'allowed_window_nanos' : IDL.Nat64 }), + 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }), + 'TxDuplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat64 }), + 'TxCreatedInFuture' : IDL.Null, + 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }), + }); + const VoteOnTransferProposalResult = IDL.Variant({ + 'ok' : VoteOnProposalAction, + 'err' : IDL.Variant({ + 'transfer_error' : TransferError, + 'message' : IDL.Text, + }), + }); + return IDL.Service({ + 'get_address_from_principal' : IDL.Func( + [IDL.Principal], + [IDL.Text], + ['query'], + ), + 'get_canister_address' : IDL.Func([], [IDL.Text], ['query']), + 'get_canister_principal' : IDL.Func([], [IDL.Principal], ['query']), + 'get_controllers_info' : IDL.Func([], [ControllersInfoResult], []), + 'get_cycle_stats_info' : IDL.Func([], [CycleStatsInfo], ['query']), + 'get_signer_proposals' : IDL.Func([], [IDL.Vec(SignerProposal)], ['query']), + 'get_signers' : IDL.Func([], [IDL.Vec(IDL.Principal)], ['query']), + 'get_threshold' : IDL.Func([], [IDL.Nat8], ['query']), + 'get_threshold_proposals' : IDL.Func( + [], + [IDL.Vec(ThresholdProposal)], + ['query'], + ), + 'get_transfer_proposals' : IDL.Func( + [], + [IDL.Vec(TransferProposal)], + ['query'], + ), + 'get_transfers' : IDL.Func([], [IDL.Vec(Transfer)], ['query']), + 'get_vault_balance' : IDL.Func([], [VaultBalanceResult], []), + 'propose_signer' : IDL.Func( + [IDL.Text, IDL.Principal, IDL.Bool], + [DefaultResult], + [], + ), + 'propose_threshold' : IDL.Func([IDL.Text, IDL.Nat8], [DefaultResult], []), + 'propose_transfer' : IDL.Func( + [IDL.Text, IDL.Text, IDL.Nat64], + [DefaultResult], + [], + ), + 'snapshot_cycles' : IDL.Func([], [DefaultResult], []), + 'vote_on_signer_proposal' : IDL.Func( + [IDL.Text, IDL.Bool], + [VoteOnProposalResult], + [], + ), + 'vote_on_threshold_proposal' : IDL.Func( + [IDL.Text, IDL.Bool], + [VoteOnProposalResult], + [], + ), + 'vote_on_transfer_proposal' : IDL.Func( + [IDL.Text, IDL.Bool], + [VoteOnTransferProposalResult], + [], + ), + }); }; +export const init = ({ IDL }) => { return [IDL.Vec(IDL.Principal), IDL.Nat8]; }; diff --git a/canisters/frontend/dfx_generated/backend/index.js b/canisters/frontend/dfx_generated/backend/index.js index f23eda6..95c92b8 100644 --- a/canisters/frontend/dfx_generated/backend/index.js +++ b/canisters/frontend/dfx_generated/backend/index.js @@ -1,4 +1,4 @@ -import { Actor, HttpAgent } from '@dfinity/agent'; +import { Actor, HttpAgent } from "@dfinity/agent"; // Imports and re-exports candid interface import { idlFactory } from './backend.did.js'; @@ -7,34 +7,32 @@ export { idlFactory } from './backend.did.js'; export const canisterId = process.env.BACKEND_CANISTER_ID; /** - * + * * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] * @return {import("@dfinity/agent").ActorSubclass} */ -export const createActor = (canisterId, options) => { - const agent = new HttpAgent({ ...options?.agentOptions }); - - // Fetch root key for certificate validation during development - if (process.env.NODE_ENV !== 'production') { - agent.fetchRootKey().catch((err) => { - console.warn( - 'Unable to fetch root key. Check to ensure that your local replica is running' - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options?.actorOptions + export const createActor = (canisterId, options) => { + const agent = new HttpAgent({ ...options?.agentOptions }); + + // Fetch root key for certificate validation during development + if(process.env.NODE_ENV !== "production") { + agent.fetchRootKey().catch(err=>{ + console.warn("Unable to fetch root key. Check to ensure that your local replica is running"); + console.error(err); }); -}; + } + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options?.actorOptions, + }); +}; + /** * A ready-to-use agent for the backend canister * @type {import("@dfinity/agent").ActorSubclass} */ -export const backend = createActor(canisterId); +// export const backend = createActor(canisterId); diff --git a/canisters/frontend/package-lock.json b/canisters/frontend/package-lock.json index 904b69b..2e71581 100755 --- a/canisters/frontend/package-lock.json +++ b/canisters/frontend/package-lock.json @@ -5,8 +5,8 @@ "packages": { "": { "dependencies": { - "@dfinity/agent": "0.11.0", - "@dfinity/auth-client": "0.11.0", + "@dfinity/agent": "0.12.1", + "@dfinity/auth-client": "0.12.1", "@spectrum-web-components/number-field": "0.3.9", "@spectrum-web-components/radio": "0.9.9", "@spectrum-web-components/slider": "0.12.9", @@ -67,9 +67,9 @@ } }, "node_modules/@dfinity/agent": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.11.0.tgz", - "integrity": "sha512-4O2b5aYAqfjvkI4GF4Zm3cufdsa8DjHBWqvhnowlNynu5fpJgAXdHAclDcRiuaCY8xzaf9pCwER19h1+Yeux2Q==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.12.1.tgz", + "integrity": "sha512-/KSKh248k4pjzvqCzIgYNNi3pTv+DBZ40+QiTBQeFzp6VEg3gfSv5bK2UwC0Plq9xwk7TeeeGLiTv6DI3RjCOQ==", "dependencies": { "base64-arraybuffer": "^0.2.0", "bignumber.js": "^9.0.0", @@ -78,42 +78,42 @@ "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@dfinity/candid": "^0.11.0", - "@dfinity/principal": "^0.11.0" + "@dfinity/candid": "^0.12.1", + "@dfinity/principal": "^0.12.1" } }, "node_modules/@dfinity/auth-client": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.11.0.tgz", - "integrity": "sha512-6ez+Hjt9WbHTgtY9CTeh09kwIVSuaJFPImkiJd6uGOFxv7trTgFFRwABsUJkiGm0dg4xjqDrk+gHYJW4h07Tnw==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.12.1.tgz", + "integrity": "sha512-iZKSVjk9K+35jp+AY3QfGAv0jBfn5LZTwpSXgBKVqZCez3GRniGJirJVTvk7t9yOj4BXN8tuvjIKxTsezPpgLQ==", "peerDependencies": { - "@dfinity/agent": "^0.11.0", - "@dfinity/authentication": "^0.11.0", - "@dfinity/identity": "^0.11.0", - "@dfinity/principal": "^0.11.0" + "@dfinity/agent": "^0.12.1", + "@dfinity/authentication": "^0.12.1", + "@dfinity/identity": "^0.12.1", + "@dfinity/principal": "^0.12.1" } }, "node_modules/@dfinity/authentication": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/authentication/-/authentication-0.11.0.tgz", - "integrity": "sha512-/7X548i8TPt2j2elYs2msgUkdrOIL0U0jAjk1HJ6/9+hq4KscvC+sKn+MpuE+socY9cF2rpgjywvK1WJ2e6u7Q==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/authentication/-/authentication-0.12.1.tgz", + "integrity": "sha512-krHR48HNqTOp2NwHoKHirTUXHDfHttWZfSmwBCsQa0xwWkrrLSGb3u+9e1oQjDK1G1eK2TP7T1W2duZmmmrZkg==", "peer": true, "peerDependencies": { - "@dfinity/agent": "^0.11.0", - "@dfinity/identity": "^0.11.0", - "@dfinity/principal": "^0.11.0" + "@dfinity/agent": "^0.12.1", + "@dfinity/identity": "^0.12.1", + "@dfinity/principal": "^0.12.1" } }, "node_modules/@dfinity/candid": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.11.0.tgz", - "integrity": "sha512-UFSKi4RGOr+H8l0Z19uo7yDfDJFoSNL8zNi2zVSW22J+f17c3y1wRAasY6g3FS/UlLl/b+32WXO6KxHt+K0/2g==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.12.1.tgz", + "integrity": "sha512-YX8jfyy/8Qmz4f1mbjqXUqOmtYcGru1gfYWxlRhKFSkeLH0VeZkfPEmD6EQ25k+18ATPk83MQiZnu0b6AWxBUw==", "peer": true }, "node_modules/@dfinity/identity": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.11.0.tgz", - "integrity": "sha512-lf316nHLxEIyTrShd6OCLFLP0dnmfcXEe+n+wbXbWsA+9MCBhO2V2RZ+Q1urghY4GiN6ewb4oK8lxOZNQjk6yg==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.12.1.tgz", + "integrity": "sha512-FNrjV4/gG9PjQfGLIoH1DycqSAMaoTZCxB+cSVJRFCvGQKc3F3kn5tj6rIv9LV+NNV1f1qfmTXE8rYsMCmEecg==", "peer": true, "dependencies": { "@types/webappsec-credential-management": "^0.6.2", @@ -123,8 +123,8 @@ "tweetnacl": "^1.0.1" }, "peerDependencies": { - "@dfinity/agent": "^0.11.0", - "@dfinity/principal": "^0.11.0" + "@dfinity/agent": "^0.12.1", + "@dfinity/principal": "^0.12.1" } }, "node_modules/@dfinity/identity/node_modules/tweetnacl": { @@ -134,9 +134,9 @@ "peer": true }, "node_modules/@dfinity/principal": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.0.tgz", - "integrity": "sha512-yTKTaxjDP5EHgzzu8lmNnHhUUH5rQQ0L/qUA04VJHuSCb4OweEWKD9/qSPueWhdJJZ94MU3Pp56ORNK3Cs1qQA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.12.1.tgz", + "integrity": "sha512-aL5y0mpzRex6LRSc4LUZyhn2GTFfHyxkakkOZxEM7+ecz8HsKKK+mSo78gL1TCso2QkCL4BqZzxnoIxxKqM1cw==", "peer": true }, "node_modules/@gar/promisify": { @@ -1337,7 +1337,7 @@ "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", "peer": true }, "node_modules/buffer": { @@ -2540,7 +2540,7 @@ "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", "peer": true, "dependencies": { "hash.js": "^1.0.3", @@ -3381,7 +3381,7 @@ "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", "peer": true }, "node_modules/minimatch": { @@ -5380,9 +5380,9 @@ } }, "@dfinity/agent": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.11.0.tgz", - "integrity": "sha512-4O2b5aYAqfjvkI4GF4Zm3cufdsa8DjHBWqvhnowlNynu5fpJgAXdHAclDcRiuaCY8xzaf9pCwER19h1+Yeux2Q==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.12.1.tgz", + "integrity": "sha512-/KSKh248k4pjzvqCzIgYNNi3pTv+DBZ40+QiTBQeFzp6VEg3gfSv5bK2UwC0Plq9xwk7TeeeGLiTv6DI3RjCOQ==", "requires": { "base64-arraybuffer": "^0.2.0", "bignumber.js": "^9.0.0", @@ -5392,28 +5392,28 @@ } }, "@dfinity/auth-client": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.11.0.tgz", - "integrity": "sha512-6ez+Hjt9WbHTgtY9CTeh09kwIVSuaJFPImkiJd6uGOFxv7trTgFFRwABsUJkiGm0dg4xjqDrk+gHYJW4h07Tnw==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.12.1.tgz", + "integrity": "sha512-iZKSVjk9K+35jp+AY3QfGAv0jBfn5LZTwpSXgBKVqZCez3GRniGJirJVTvk7t9yOj4BXN8tuvjIKxTsezPpgLQ==", "requires": {} }, "@dfinity/authentication": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/authentication/-/authentication-0.11.0.tgz", - "integrity": "sha512-/7X548i8TPt2j2elYs2msgUkdrOIL0U0jAjk1HJ6/9+hq4KscvC+sKn+MpuE+socY9cF2rpgjywvK1WJ2e6u7Q==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/authentication/-/authentication-0.12.1.tgz", + "integrity": "sha512-krHR48HNqTOp2NwHoKHirTUXHDfHttWZfSmwBCsQa0xwWkrrLSGb3u+9e1oQjDK1G1eK2TP7T1W2duZmmmrZkg==", "peer": true, "requires": {} }, "@dfinity/candid": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.11.0.tgz", - "integrity": "sha512-UFSKi4RGOr+H8l0Z19uo7yDfDJFoSNL8zNi2zVSW22J+f17c3y1wRAasY6g3FS/UlLl/b+32WXO6KxHt+K0/2g==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.12.1.tgz", + "integrity": "sha512-YX8jfyy/8Qmz4f1mbjqXUqOmtYcGru1gfYWxlRhKFSkeLH0VeZkfPEmD6EQ25k+18ATPk83MQiZnu0b6AWxBUw==", "peer": true }, "@dfinity/identity": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.11.0.tgz", - "integrity": "sha512-lf316nHLxEIyTrShd6OCLFLP0dnmfcXEe+n+wbXbWsA+9MCBhO2V2RZ+Q1urghY4GiN6ewb4oK8lxOZNQjk6yg==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.12.1.tgz", + "integrity": "sha512-FNrjV4/gG9PjQfGLIoH1DycqSAMaoTZCxB+cSVJRFCvGQKc3F3kn5tj6rIv9LV+NNV1f1qfmTXE8rYsMCmEecg==", "peer": true, "requires": { "@types/webappsec-credential-management": "^0.6.2", @@ -5432,9 +5432,9 @@ } }, "@dfinity/principal": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.0.tgz", - "integrity": "sha512-yTKTaxjDP5EHgzzu8lmNnHhUUH5rQQ0L/qUA04VJHuSCb4OweEWKD9/qSPueWhdJJZ94MU3Pp56ORNK3Cs1qQA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.12.1.tgz", + "integrity": "sha512-aL5y0mpzRex6LRSc4LUZyhn2GTFfHyxkakkOZxEM7+ecz8HsKKK+mSo78gL1TCso2QkCL4BqZzxnoIxxKqM1cw==", "peer": true }, "@gar/promisify": { @@ -6493,7 +6493,7 @@ "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", "peer": true }, "buffer": { @@ -7426,7 +7426,7 @@ "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", "peer": true, "requires": { "hash.js": "^1.0.3", @@ -8085,7 +8085,7 @@ "minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", "peer": true }, "minimatch": { diff --git a/canisters/frontend/package.json b/canisters/frontend/package.json index 762aaea..6362d54 100755 --- a/canisters/frontend/package.json +++ b/canisters/frontend/package.json @@ -3,8 +3,8 @@ "build": "snowpack build --polyfill-node" }, "dependencies": { - "@dfinity/agent": "0.11.0", - "@dfinity/auth-client": "0.11.0", + "@dfinity/agent": "0.12.1", + "@dfinity/auth-client": "0.12.1", "@spectrum-web-components/number-field": "0.3.9", "@spectrum-web-components/radio": "0.9.9", "@spectrum-web-components/slider": "0.12.9", diff --git a/canisters/icp_ledger/install.sh b/canisters/icp_ledger/install.sh new file mode 100755 index 0000000..555b62d --- /dev/null +++ b/canisters/icp_ledger/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +FILE=./ledger.wasm +if test -f "$FILE"; then + echo "./ledger.wasm exists" +else + echo "./ledger.wasm doesn't exist, downloading" + export IC_VERSION=dd3a710b03bd3ae10368a91b255571d012d1ec2f + + curl -o ledger.wasm.gz https://download.dfinity.systems/ic/${IC_VERSION}/canisters/ledger-canister_notify-method.wasm.gz + gunzip ledger.wasm.gz + curl -o ledger.private.did https://raw.githubusercontent.com/dfinity/ic/${IC_VERSION}/rs/rosetta-api/ledger.did + curl -o ledger.public.did https://raw.githubusercontent.com/dfinity/ic/${IC_VERSION}/rs/rosetta-api/ledger_canister/ledger.did +fi diff --git a/canisters/icp_ledger/ledger.private.did b/canisters/icp_ledger/ledger.private.did new file mode 100755 index 0000000..537315c --- /dev/null +++ b/canisters/icp_ledger/ledger.private.did @@ -0,0 +1,103 @@ +type Tokens = record { + e8s : nat64; +}; + +type Duration = record { + secs: nat64; + nanos: nat32; +}; + +// Number of nanoseconds from the UNIX epoch in UTC timezone. +type TimeStamp = record { + timestamp_nanos: nat64; +}; + +type ArchiveOptions = record { + trigger_threshold : nat64; + num_blocks_to_archive : nat64; + node_max_memory_size_bytes: opt nat64; + max_message_size_bytes: opt nat64; + controller_id: principal; + cycles_for_archive_creation: opt nat64; +}; + +// Height of a ledger block. +type BlockHeight = nat64; + +// A number associated with a transaction. +// Can be set by the caller in `send` call as a correlation identifier. +type Memo = nat64; + +// Account identifier encoded as a 64-byte ASCII hex string. +type AccountIdentifier = text; + +// Subaccount is an arbitrary 32-byte byte array. +type SubAccount = blob; + +type Transfer = variant { + Burn: record { + from: AccountIdentifier; + amount: Tokens; + }; + Mint: record { + to: AccountIdentifier; + amount: Tokens; + }; + Send: record { + from: AccountIdentifier; + to: AccountIdentifier; + amount: Tokens; + }; +}; + +type Transaction = record { + transfer: Transfer; + memo: Memo; + created_at: BlockHeight; +}; + +// Arguments for the `send_dfx` call. +type SendArgs = record { + memo: Memo; + amount: Tokens; + fee: Tokens; + from_subaccount: opt SubAccount; + to: AccountIdentifier; + created_at_time: opt TimeStamp; +}; + +// Arguments for the `notify` call. +type NotifyCanisterArgs = record { + // The of the block to send a notification about. + block_height: BlockHeight; + // Max fee, should be 10000 e8s. + max_fee: Tokens; + // Subaccount the payment came from. + from_subaccount: opt SubAccount; + // Canister that received the payment. + to_canister: principal; + // Subaccount that received the payment. + to_subaccount: opt SubAccount; +}; + +type AccountBalanceArgs = record { + account: AccountIdentifier; +}; + +type LedgerCanisterInitPayload = record { + minting_account: AccountIdentifier; + initial_values: vec record {AccountIdentifier; Tokens}; + max_message_size_bytes: opt nat64; + transaction_window: opt Duration; + archive_options: opt ArchiveOptions; + send_whitelist: vec principal; + transfer_fee: opt Tokens; + token_symbol: opt text; + token_name: opt text; +}; + +service: (LedgerCanisterInitPayload) -> { + send_dfx : (SendArgs) -> (BlockHeight); + notify_dfx: (NotifyCanisterArgs) -> (); + account_balance_dfx : (AccountBalanceArgs) -> (Tokens) query; +} diff --git a/canisters/icp_ledger/ledger.public.did b/canisters/icp_ledger/ledger.public.did new file mode 100755 index 0000000..155ea76 --- /dev/null +++ b/canisters/icp_ledger/ledger.public.did @@ -0,0 +1,249 @@ +// This is the official Ledger interface that is guaranteed to be backward compatible. + +// Amount of tokens, measured in 10^-8 of a token. +type Tokens = record { + e8s : nat64; +}; + +// Number of nanoseconds from the UNIX epoch in UTC timezone. +type TimeStamp = record { + timestamp_nanos: nat64; +}; + +// AccountIdentifier is a 32-byte array. +// The first 4 bytes is big-endian encoding of a CRC32 checksum of the last 28 bytes. +type AccountIdentifier = blob; + +// Subaccount is an arbitrary 32-byte byte array. +// Ledger uses subaccounts to compute the source address, which enables one +// principal to control multiple ledger accounts. +type SubAccount = blob; + +// Sequence number of a block produced by the ledger. +type BlockIndex = nat64; + +// An arbitrary number associated with a transaction. +// The caller can set it in a `transfer` call as a correlation identifier. +type Memo = nat64; + +// Arguments for the `transfer` call. +type TransferArgs = record { + // Transaction memo. + // See comments for the `Memo` type. + memo: Memo; + // The amount that the caller wants to transfer to the destination address. + amount: Tokens; + // The amount that the caller pays for the transaction. + // Must be 10000 e8s. + fee: Tokens; + // The subaccount from which the caller wants to transfer funds. + // If null, the ledger uses the default (all zeros) subaccount to compute the source address. + // See comments for the `SubAccount` type. + from_subaccount: opt SubAccount; + // The destination account. + // If the transfer is successful, the balance of this address increases by `amount`. + to: AccountIdentifier; + // The point in time when the caller created this request. + // If null, the ledger uses current IC time as the timestamp. + created_at_time: opt TimeStamp; +}; + +type TransferError = variant { + // The fee that the caller specified in the transfer request was not the one that ledger expects. + // The caller can change the transfer fee to the `expected_fee` and retry the request. + BadFee : record { expected_fee : Tokens; }; + // The account specified by the caller doesn't have enough funds. + InsufficientFunds : record { balance: Tokens; }; + // The request is too old. + // The ledger only accepts requests created within 24 hours window. + // This is a non-recoverable error. + TxTooOld : record { allowed_window_nanos: nat64 }; + // The caller specified `created_at_time` that is too far in future. + // The caller can retry the request later. + TxCreatedInFuture : null; + // The ledger has already executed the request. + // `duplicate_of` field is equal to the index of the block containing the original transaction. + TxDuplicate : record { duplicate_of: BlockIndex; } +}; + +type TransferResult = variant { + Ok : BlockIndex; + Err : TransferError; +}; + +// Arguments for the `account_balance` call. +type AccountBalanceArgs = record { + account: AccountIdentifier; +}; + +type TransferFeeArg = record {}; + +type TransferFee = record { + // The fee to pay to perform a transfer + transfer_fee: Tokens; +}; + +type GetBlocksArgs = record { + // The index of the first block to fetch. + start : BlockIndex; + // Max number of blocks to fetch. + length : nat64; +}; + +type Operation = variant { + Mint : record { + to : AccountIdentifier; + amount : Tokens; + }; + Burn : record { + from : AccountIdentifier; + amount : Tokens; + }; + Transfer : record { + from : AccountIdentifier; + to : AccountIdentifier; + amount : Tokens; + fee : Tokens; + }; +}; + +type Transaction = record { + memo : Memo; + operation : opt Operation; + created_at_time : TimeStamp; +}; + +type Block = record { + parent_hash : opt blob; + transaction : Transaction; + timestamp : TimeStamp; +}; + +// A prefix of the block range specified in the [GetBlocksArgs] request. +type BlockRange = record { + // A prefix of the requested block range. + // The index of the first block is equal to [GetBlocksArgs.from]. + // + // Note that the number of blocks might be less than the requested + // [GetBlocksArgs.len] for various reasons, for example: + // + // 1. The query might have hit the replica with an outdated state + // that doesn't have the full block range yet. + // 2. The requested range is too large to fit into a single reply. + // + // NOTE: the list of blocks can be empty if: + // 1. [GetBlocksArgs.len] was zero. + // 2. [GetBlocksArgs.from] was larger than the last block known to the canister. + blocks : vec Block; +}; + +// An error indicating that the arguments passed to [QueryArchiveFn] were invalid. +type QueryArchiveError = variant { + // [GetBlocksArgs.from] argument was smaller than the first block + // served by the canister that received the request. + BadFirstBlockIndex : record { + requested_index : BlockIndex; + first_valid_index : BlockIndex; + }; + + // Reserved for future use. + Other : record { + error_code : nat64; + error_message : text; + }; +}; + +type QueryArchiveResult = variant { + // Successfully fetched zero or more blocks. + Ok : BlockRange; + // The [GetBlocksArgs] request was invalid. + Err : QueryArchiveError; +}; + +// A function that is used for fetching archived ledger blocks. +type QueryArchiveFn = func (GetBlocksArgs) -> (QueryArchiveResult) query; + +// The result of a "query_blocks" call. +// +// The structure of the result is somewhat complicated because the main ledger canister might +// not have all the blocks that the caller requested: One or more "archive" canisters might +// store some of the requested blocks. +// +// Note: as of Q4 2021 when this interface is authored, the IC doesn't support making nested +// query calls within a query call. +type QueryBlocksResponse = record { + // The total number of blocks in the chain. + // If the chain length is positive, the index of the last block is `chain_len - 1`. + chain_length : nat64; + + // System certificate for the hash of the latest block in the chain. + // Only present if `query_blocks` is called in a non-replicated query context. + certificate : opt blob; + + // List of blocks that were available in the ledger when it processed the call. + // + // The blocks form a contiguous range, with the first block having index + // [first_block_index] (see below), and the last block having index + // [first_block_index] + len(blocks) - 1. + // + // The block range can be an arbitrary sub-range of the originally requested range. + blocks : vec Block; + + // The index of the first block in "blocks". + // If the blocks vector is empty, the exact value of this field is not specified. + first_block_index : BlockIndex; + + // Encoding of instructions for fetching archived blocks whose indices fall into the + // requested range. + // + // For each entry `e` in [archived_blocks], `[e.from, e.from + len)` is a sub-range + // of the originally requested block range. + archived_blocks : vec record { + // The index of the first archived block that can be fetched using the callback. + start : BlockIndex; + + // The number of blocks that can be fetch using the callback. + length : nat64; + + // The function that should be called to fetch the archived blocks. + // The range of the blocks accessible using this function is given by [from] + // and [len] fields above. + callback : QueryArchiveFn; + }; +}; + +type Archive = record { + canister_id: principal; +}; + +type Archives = record { + archives: vec Archive; +}; + +service : { + // Transfers tokens from a subaccount of the caller to the destination address. + // The source address is computed from the principal of the caller and the specified subaccount. + // When successful, returns the index of the block containing the transaction. + transfer : (TransferArgs) -> (TransferResult); + + // Returns the amount of Tokens on the specified account. + account_balance : (AccountBalanceArgs) -> (Tokens) query; + + // Returns the current transfer_fee. + transfer_fee : (TransferFeeArg) -> (TransferFee) query; + + // Queries blocks in the specified range. + query_blocks : (GetBlocksArgs) -> (QueryBlocksResponse) query; + + // Returns token symbol. + symbol : () -> (record { symbol: text }) query; + + // Returns token name. + name : () -> (record { name: text }) query; + + // Returns token decimals. + decimals : () -> (record { decimals: nat32 }) query; + + // Returns the existing archive canisters information. + archives : () -> (Archives) query; +} diff --git a/canisters/internet_identity/install.sh b/canisters/internet_identity/install.sh new file mode 100755 index 0000000..dafa419 --- /dev/null +++ b/canisters/internet_identity/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +FILE=./internet_identity_test.wasm +if test -f "$FILE"; then + echo "./internet_identity_test.wasm exists" +else + echo "./internet_identity_test.wasm doesn't exist, downloading" + curl -o internet_identity_test.wasm -sSL https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_test.wasm +fi diff --git a/local_first_deploy.sh b/local_first_deploy.sh index 26a173c..ffc95b7 100755 --- a/local_first_deploy.sh +++ b/local_first_deploy.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # backend canister dfx canister create backend dfx build backend diff --git a/local_upgrade.sh b/local_upgrade.sh index df331d0..9fa8781 100755 --- a/local_upgrade.sh +++ b/local_upgrade.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # frontend dfx deploy frontend diff --git a/modify_last_line.sh b/modify_last_line.sh new file mode 100755 index 0000000..142c32a --- /dev/null +++ b/modify_last_line.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# For a given directory loop through all agent folders and comment out the last line in the index.js file. +cd $1 +for directory in */; do + echo "Processing $directory" + STORED_LAST_LINE=$(tail --lines=1 "$directory"/index.js) + echo "The saved text is: $STORED_LAST_LINE" + sed -i '$ d' "$directory"/index.js + echo "// $STORED_LAST_LINE" >> "$directory"/index.js +done \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4ab5d11..3bf2bdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,14 @@ "hash.js": "1.1.7" }, "devDependencies": { + "@dfinity/agent": "^0.12.1", + "@dfinity/identity": "^0.12.1", "eslint": "8.11.0", "eslint-config-prettier": "8.5.0", "husky": "7.0.4", "lint-staged": "12.3.7", "prettier": "2.6.1", + "ts-node": "10.7.0", "typescript": "4.4.4" } }, @@ -36,10 +39,53 @@ "node": ">=12" } }, + "node_modules/@dfinity/agent": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.12.1.tgz", + "integrity": "sha512-/KSKh248k4pjzvqCzIgYNNi3pTv+DBZ40+QiTBQeFzp6VEg3gfSv5bK2UwC0Plq9xwk7TeeeGLiTv6DI3RjCOQ==", + "dev": true, + "dependencies": { + "base64-arraybuffer": "^0.2.0", + "bignumber.js": "^9.0.0", + "borc": "^2.1.1", + "js-sha256": "0.9.0", + "simple-cbor": "^0.4.1" + }, + "peerDependencies": { + "@dfinity/candid": "^0.12.1", + "@dfinity/principal": "^0.12.1" + } + }, + "node_modules/@dfinity/candid": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.12.1.tgz", + "integrity": "sha512-YX8jfyy/8Qmz4f1mbjqXUqOmtYcGru1gfYWxlRhKFSkeLH0VeZkfPEmD6EQ25k+18ATPk83MQiZnu0b6AWxBUw==", + "dev": true, + "peer": true + }, + "node_modules/@dfinity/identity": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.12.1.tgz", + "integrity": "sha512-FNrjV4/gG9PjQfGLIoH1DycqSAMaoTZCxB+cSVJRFCvGQKc3F3kn5tj6rIv9LV+NNV1f1qfmTXE8rYsMCmEecg==", + "dev": true, + "dependencies": { + "@types/webappsec-credential-management": "^0.6.2", + "borc": "^2.1.1", + "js-sha256": "^0.9.0", + "secp256k1": "^4.0.2", + "tweetnacl": "^1.0.1" + }, + "peerDependencies": { + "@dfinity/agent": "^0.12.1", + "@dfinity/principal": "^0.12.1" + } + }, "node_modules/@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.12.1.tgz", + "integrity": "sha512-aL5y0mpzRex6LRSc4LUZyhn2GTFfHyxkakkOZxEM7+ecz8HsKKK+mSo78gL1TCso2QkCL4BqZzxnoIxxKqM1cw==", + "dev": true, + "peer": true }, "node_modules/@eslint/eslintrc": { "version": "1.3.0", @@ -332,6 +378,12 @@ "integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==", "peer": true }, + "node_modules/@types/webappsec-credential-management": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@types/webappsec-credential-management/-/webappsec-credential-management-0.6.2.tgz", + "integrity": "sha512-/6w8wmKQOFh+1CL99fcFhH7lli1/ExBdAawXsVPXFC5MBOS6ww/4cmK4crpCw51RaG6sTr477N17Y84l0G69IA==", + "dev": true + }, "node_modules/acorn": { "version": "8.8.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", @@ -485,6 +537,11 @@ "resolved": "https://registry.npmjs.org/azle-syn/-/azle-syn-0.0.0.tgz", "integrity": "sha512-fWExJb5/hOEJOuBQ8hMMHRs9WryYeLLa9/ydqPWxbwjMEpE8RKdU1dTK6mdZtzNMhbeHdyne2pU1iVKiKmImGw==" }, + "node_modules/azle/node_modules/@dfinity/principal": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", + "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + }, "node_modules/azle/node_modules/azle": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/azle/-/azle-0.3.1.tgz", @@ -502,12 +559,120 @@ "azle": "bin.js" } }, + "node_modules/azle/node_modules/ts-node": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", + "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", + "dependencies": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/base64-arraybuffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", + "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/borc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz", + "integrity": "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==", + "dev": true, + "dependencies": { + "bignumber.js": "^9.0.0", + "buffer": "^5.5.0", + "commander": "^2.15.0", + "ieee754": "^1.1.13", + "iso-url": "~0.4.7", + "json-text-sequence": "~0.1.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/borc/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -530,6 +695,36 @@ "node": ">=8" } }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -673,6 +868,12 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/delimit-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", + "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", + "dev": true + }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -699,6 +900,21 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -1411,6 +1627,17 @@ "minimalistic-assert": "^1.0.1" } }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -1435,6 +1662,26 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ignore": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", @@ -1553,6 +1800,15 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "node_modules/iso-url": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/iso-url/-/iso-url-0.4.7.tgz", + "integrity": "sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/js-sha256": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", @@ -1582,6 +1838,15 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/json-text-sequence": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", + "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", + "dev": true, + "dependencies": { + "delimit-stream": "0.1.0" + } + }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -1866,6 +2131,12 @@ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "dev": true + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -1890,6 +2161,23 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==", + "dev": true + }, + "node_modules/node-gyp-build": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", + "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", + "dev": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -2063,6 +2351,20 @@ "node": ">=6" } }, + "node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -2127,6 +2429,41 @@ "tslib": "^2.1.0" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/secp256k1": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", + "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "elliptic": "^6.5.4", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2154,6 +2491,12 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/simple-cbor": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/simple-cbor/-/simple-cbor-0.4.1.tgz", + "integrity": "sha512-rijcxtwx2b4Bje3sqeIqw5EeW7UlOIC4YfOdwqIKacpvRQ/D78bWg/4/0m5e0U91oKvlGh7LlJuZCu07ISCC7w==", + "dev": true + }, "node_modules/slice-ansi": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", @@ -2182,6 +2525,15 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/string-argv": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", @@ -2305,9 +2657,10 @@ } }, "node_modules/ts-node": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", - "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", + "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "dev": true, "dependencies": { "@cspotcode/source-map-support": "0.7.0", "@tsconfig/node10": "^1.0.7", @@ -2320,11 +2673,13 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.0", "yn": "3.1.1" }, "bin": { "ts-node": "dist/bin.js", "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", "ts-node-script": "dist/bin-script.js", "ts-node-transpile-only": "dist/bin-transpile.js", "ts-script": "dist/bin-script-deprecated.js" @@ -2350,6 +2705,12 @@ "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", "dev": true }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "dev": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -2403,12 +2764,24 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2517,10 +2890,45 @@ "@cspotcode/source-map-consumer": "0.8.0" } }, + "@dfinity/agent": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.12.1.tgz", + "integrity": "sha512-/KSKh248k4pjzvqCzIgYNNi3pTv+DBZ40+QiTBQeFzp6VEg3gfSv5bK2UwC0Plq9xwk7TeeeGLiTv6DI3RjCOQ==", + "dev": true, + "requires": { + "base64-arraybuffer": "^0.2.0", + "bignumber.js": "^9.0.0", + "borc": "^2.1.1", + "js-sha256": "0.9.0", + "simple-cbor": "^0.4.1" + } + }, + "@dfinity/candid": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.12.1.tgz", + "integrity": "sha512-YX8jfyy/8Qmz4f1mbjqXUqOmtYcGru1gfYWxlRhKFSkeLH0VeZkfPEmD6EQ25k+18ATPk83MQiZnu0b6AWxBUw==", + "dev": true, + "peer": true + }, + "@dfinity/identity": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.12.1.tgz", + "integrity": "sha512-FNrjV4/gG9PjQfGLIoH1DycqSAMaoTZCxB+cSVJRFCvGQKc3F3kn5tj6rIv9LV+NNV1f1qfmTXE8rYsMCmEecg==", + "dev": true, + "requires": { + "@types/webappsec-credential-management": "^0.6.2", + "borc": "^2.1.1", + "js-sha256": "^0.9.0", + "secp256k1": "^4.0.2", + "tweetnacl": "^1.0.1" + } + }, "@dfinity/principal": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", - "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.12.1.tgz", + "integrity": "sha512-aL5y0mpzRex6LRSc4LUZyhn2GTFfHyxkakkOZxEM7+ecz8HsKKK+mSo78gL1TCso2QkCL4BqZzxnoIxxKqM1cw==", + "dev": true, + "peer": true }, "@eslint/eslintrc": { "version": "1.3.0", @@ -2680,6 +3088,12 @@ "integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==", "peer": true }, + "@types/webappsec-credential-management": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@types/webappsec-credential-management/-/webappsec-credential-management-0.6.2.tgz", + "integrity": "sha512-/6w8wmKQOFh+1CL99fcFhH7lli1/ExBdAawXsVPXFC5MBOS6ww/4cmK4crpCw51RaG6sTr477N17Y84l0G69IA==", + "dev": true + }, "acorn": { "version": "8.8.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", @@ -2785,6 +3199,11 @@ "typescript": "4.4.4" }, "dependencies": { + "@dfinity/principal": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.11.2.tgz", + "integrity": "sha512-vReWruqIl16yQeKOrCLDLDf2aTEJsXcKeW9qbwVfmV0kwLNE3B2Z6tbRjYbY7s+KwpysD5B1b48ZbIwI00BeyQ==" + }, "azle": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/azle/-/azle-0.3.1.tgz", @@ -2798,6 +3217,25 @@ "ts-node": "10.3.1", "typescript": "4.4.4" } + }, + "ts-node": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", + "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", + "requires": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + } } } }, @@ -2812,6 +3250,53 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "base64-arraybuffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", + "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", + "dev": true + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true + }, + "bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "dev": true + }, + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "borc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz", + "integrity": "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==", + "dev": true, + "requires": { + "bignumber.js": "^9.0.0", + "buffer": "^5.5.0", + "commander": "^2.15.0", + "ieee754": "^1.1.13", + "iso-url": "~0.4.7", + "json-text-sequence": "~0.1.0", + "readable-stream": "^3.6.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2831,6 +3316,22 @@ "fill-range": "^7.0.1" } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2936,6 +3437,12 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "delimit-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", + "integrity": "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==", + "dev": true + }, "diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -2956,6 +3463,21 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, + "elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "requires": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -3388,6 +3910,17 @@ "minimalistic-assert": "^1.0.1" } }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -3400,6 +3933,12 @@ "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", "dev": true }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true + }, "ignore": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", @@ -3482,6 +4021,12 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "iso-url": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/iso-url/-/iso-url-0.4.7.tgz", + "integrity": "sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog==", + "dev": true + }, "js-sha256": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", @@ -3508,6 +4053,15 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "json-text-sequence": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", + "integrity": "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==", + "dev": true, + "requires": { + "delimit-stream": "0.1.0" + } + }, "jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -3722,6 +4276,12 @@ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "dev": true + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3743,6 +4303,18 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==", + "dev": true + }, + "node-gyp-build": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", + "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", + "dev": true + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -3856,6 +4428,17 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, "regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -3902,6 +4485,23 @@ "tslib": "^2.1.0" } }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "secp256k1": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", + "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", + "dev": true, + "requires": { + "elliptic": "^6.5.4", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + } + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3923,6 +4523,12 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "simple-cbor": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/simple-cbor/-/simple-cbor-0.4.1.tgz", + "integrity": "sha512-rijcxtwx2b4Bje3sqeIqw5EeW7UlOIC4YfOdwqIKacpvRQ/D78bWg/4/0m5e0U91oKvlGh7LlJuZCu07ISCC7w==", + "dev": true + }, "slice-ansi": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", @@ -3941,6 +4547,15 @@ } } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + }, "string-argv": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", @@ -4027,9 +4642,10 @@ } }, "ts-node": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.3.1.tgz", - "integrity": "sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==", + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", + "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "dev": true, "requires": { "@cspotcode/source-map-support": "0.7.0", "@tsconfig/node10": "^1.0.7", @@ -4042,6 +4658,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.0", "yn": "3.1.1" } }, @@ -4051,6 +4668,12 @@ "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", "dev": true }, + "tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "dev": true + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -4085,12 +4708,24 @@ "punycode": "^2.1.0" } }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index a85541c..8f02954 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "dfx generate backend && cd canisters/frontend && npm install && npm run build", + "build": "dfx generate backend && ./modify_last_line.sh canisters/frontend/dfx_generated && cd canisters/frontend && npm install && npm run build", "typecheck": "tsc --noEmit", - "test": "node test/test.js", + "test": "ts-node --transpile-only --ignore=false test/test.ts", "prepare": "husky install" }, "dependencies": { @@ -10,11 +10,14 @@ "hash.js": "1.1.7" }, "devDependencies": { + "@dfinity/agent": "0.12.1", + "@dfinity/identity": "0.12.1", "eslint": "8.11.0", "eslint-config-prettier": "8.5.0", "husky": "7.0.4", "lint-staged": "12.3.7", "prettier": "2.6.1", + "ts-node": "10.7.0", "typescript": "4.4.4" }, "lint-staged": { diff --git a/test/signers/index.ts b/test/signers/index.ts new file mode 100644 index 0000000..0e7ae75 --- /dev/null +++ b/test/signers/index.ts @@ -0,0 +1,9 @@ +export { + get_propose_signer_valid_tests, + get_propose_signer_invalid_tests +} from './propose'; + +export { + get_vote_signer_valid_tests, + get_vote_signer_invalid_tests +} from './vote'; \ No newline at end of file diff --git a/test/signers/propose.ts b/test/signers/propose.ts new file mode 100644 index 0000000..9572900 --- /dev/null +++ b/test/signers/propose.ts @@ -0,0 +1,55 @@ +import { Test } from 'azle/test'; +import { backend_canister } from '../test'; +import { Principal } from '@dfinity/principal'; +import { createActor } from '../../canisters/frontend/dfx_generated/backend'; +import { Ed25519KeyIdentity } from '@dfinity/identity'; + +export function get_propose_signer_valid_tests(): Test[] { + return []; +} + +export function get_propose_signer_invalid_tests(): Test[] { + return [ + { + name: 'non-signer attempting to create a signer proposal', + test: async () => { + const result = await backend_canister.propose_signer( + 'propose rrkah-fqaaa-aaaaa-aaaaq-cai', + Principal.fromText('rrkah-fqaaa-aaaaa-aaaaq-cai'), + false + ); + + return { + ok: 'err' in result && result.err === 'Only signers can create a proposal' + }; + } + }, + // { + // name: 'attempt to remove non-signer', + // test: async () => { + // // TODO to get this to work I might have to do this: https://forum.dfinity.org/t/using-dfinity-agent-in-node-js/6169/50 + // const identityJSONString = require('fs').readFileSync('/home/lastmjs/.config/dfx/identity/demergent-labs-lastmjs-0/identity.pem'); + // const identity = Ed25519KeyIdentity.fromSecretKey(identityJSONString); + + // const backend_canister_authenticated = createActor('rrkah-fqaaa-aaaaa-aaaaq-cai', { + // agentOptions: { + // host: 'http://127.0.0.1:8000', + // identity + // } + // }); + + // const result = await backend_canister_authenticated.propose_signer( + // 'propose rrkah-fqaaa-aaaaa-aaaaq-cai', + // Principal.fromText('rrkah-fqaaa-aaaaa-aaaaq-cai'), + // true + // ); + + // console.log('result', result); + + // return { + // ok: 'err' in result && result.err === 'Signer rrkah-fqaaa-aaaaa-aaaaq-cai does not exist' + // }; + // } + // } + ]; +} \ No newline at end of file diff --git a/test/signers/vote.ts b/test/signers/vote.ts new file mode 100644 index 0000000..ac13a7c --- /dev/null +++ b/test/signers/vote.ts @@ -0,0 +1,9 @@ +import { Test } from 'azle/test'; + +export function get_vote_signer_valid_tests(): Test[] { + return []; +} + +export function get_vote_signer_invalid_tests(): Test[] { + return []; +} \ No newline at end of file diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36d6a0a..0000000 --- a/test/test.js +++ /dev/null @@ -1 +0,0 @@ -require('azle/test/test.js'); diff --git a/test/test.json b/test/test.json deleted file mode 100644 index e36f793..0000000 --- a/test/test.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "tests": [ - { - "bash": "dfx deploy --argument='(vec { principal \"'$(dfx identity get-principal)'\" }, 1)' backend", - "skip": false - }, - { - "bash": "dfx deploy frontend", - "skip": false - }, - { - "bash": "dfx deploy --argument='(null)' internet_identity", - "skip": false - }, - { - "bash": "dfx deploy icp_ledger --argument='(record {minting_account = \"'$(dfx ledger account-id)'\"; initial_values = vec { record { \"'$(dfx ledger account-id --of-canister backend)'\"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}})'", - "skip": false - }, - { - "bash": "dfx canister update-settings --add-controller $(dfx canister id backend) frontend", - "skip": false - }, - { - "bash": "dfx canister update-settings --add-controller $(dfx canister id backend) backend", - "skip": false - }, - { - "canisterName": "backend", - "canisterMethod": "get_vault_balance", - "methodArgs": "()", - "expectedOutput": "(variant { ok = 100_000_000_000 : nat64 })" - }, - { - "canisterName": "backend", - "canisterMethod": "get_canister_principal", - "methodArgs": "()", - "expectedOutput": "(\"rrkah-fqaaa-aaaaa-aaaaq-cai\")" - }, - { - "canisterName": "backend", - "canisterMethod": "get_canister_address", - "methodArgs": "()", - "expectedOutput": "(\"082ecf2e3f647ac600f43f38a68342fba5b8e68b085f02592b77f39808a8d2b5\")" - }, - { - "canisterName": "backend", - "canisterMethod": "get_signers", - "methodArgs": "()", - "expectedOutputBash": "echo \"(\n vec {\n principal \\\"$(dfx identity get-principal)\\\";\n },\n)\"" - }, - { - "canisterName": "backend", - "canisterMethod": "get_signer_proposals", - "methodArgs": "()", - "expectedOutput": "(vec {})" - } - ] -} diff --git a/test/test.ts b/test/test.ts new file mode 100644 index 0000000..8fbb5b8 --- /dev/null +++ b/test/test.ts @@ -0,0 +1,449 @@ +import { run_tests, Test } from 'azle/test'; +import { createActor } from '../canisters/frontend/dfx_generated/backend'; +import { Principal } from '@dfinity/principal'; +import { execSync } from 'child_process'; +import { + get_propose_signer_valid_tests, + get_propose_signer_invalid_tests, + get_vote_signer_valid_tests, + get_vote_signer_invalid_tests +} from './signers'; + +export const backend_canister = createActor('rrkah-fqaaa-aaaaa-aaaaq-cai', { + agentOptions: { + host: 'http://127.0.0.1:8000' + } +}); + +const SKIP_DEPLOY = process.argv[2] === 'no-setup'; + +const tests: Test[] = [ + ...get_setup(), + ...initial_state_tests(), + ...get_address_from_principal_tests(), + ...get_propose_signer_valid_tests(), + ...get_propose_signer_invalid_tests(), + ...get_vote_signer_valid_tests(), + ...get_vote_signer_invalid_tests() +]; + +run_tests(tests); + +// TODO test signers +// TODO test threshold +// TODO test ICP transfer +// TODO test attempting to create proposals, failing in every way possible +// TODO test creating a valid proposal +// TODO check state after creation of valid proposal +// TODO test voting in every way possible that is bad +// TODO test voting correctly +// TODO check state after correct vote + +function get_setup(): Test[] { + return [ + { + // TODO hopefully we can get rid of this: https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/16?u=lastmjs + name: 'waiting for createActor fetchRootKey', + wait: 5000 + }, + { + name: 'deploy backend canister', + prep: async () => { + execSync(`dfx canister create backend`, { + stdio: 'inherit' + }); + + execSync(`dfx canister uninstall-code backend`, { + stdio: 'inherit' + }); + + execSync(`dfx build backend`, { + stdio: 'inherit' + }); + + execSync( + `dfx canister install backend --argument '(vec { principal "'$(dfx identity get-principal)'" }, 1: nat8)' --wasm target/wasm32-unknown-unknown/release/backend.wasm.gz`, + { + stdio: 'inherit' + } + ); + }, + skip: SKIP_DEPLOY + }, + { + name: 'deploy frontend canister', + prep: async () => { + execSync(`dfx deploy frontend`, { + stdio: 'inherit' + }); + }, + skip: SKIP_DEPLOY + }, + { + name: 'download Internet Identity canister Wasm', + prep: async () => { + execSync(`cd canisters/internet_identity && ./install.sh`, { + stdio: 'inherit' + }); + } + }, + { + name: 'deploy Internet Identity canister', + prep: async () => { + execSync(`dfx deploy internet_identity --argument '(null)'`, { + stdio: 'inherit' + }); + }, + skip: SKIP_DEPLOY + }, + { + name: 'download ICP Ledger canister', + prep: async () => { + execSync(`cd canisters/icp_ledger && ./install.sh`, { + stdio: 'inherit' + }); + } + }, + { + name: 'deploy ICP Ledger canister', + prep: async () => { + execSync( + `dfx deploy icp_ledger --argument='(record {minting_account = "'$(dfx ledger account-id)'"; initial_values = vec { record { "'$(dfx ledger account-id --of-canister backend)'"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}})'`, + { + stdio: 'inherit' + } + ); + }, + skip: SKIP_DEPLOY + }, + { + name: 'set controllers', + prep: async () => { + execSync( + `dfx canister update-settings --add-controller $(dfx canister id backend) frontend`, + { + stdio: 'inherit' + } + ); + + execSync( + `dfx canister update-settings --add-controller $(dfx canister id backend) backend`, + { + stdio: 'inherit' + } + ); + }, + skip: SKIP_DEPLOY + } + ]; +} + +function initial_state_tests(): Test[] { + return [ + { + name: 'check vault balance', + test: async () => { + const result = await backend_canister.get_vault_balance(); + + return { + ok: 'ok' in result && result.ok === 100_000_000_000n + }; + } + }, + { + name: 'check canister principal', + test: async () => { + const result = await backend_canister.get_canister_principal(); + + return { + ok: result.toText() === 'rrkah-fqaaa-aaaaa-aaaaq-cai' + }; + } + }, + { + name: 'check canister address', + test: async () => { + const result = await backend_canister.get_canister_address(); + + return { + ok: + result === + '082ecf2e3f647ac600f43f38a68342fba5b8e68b085f02592b77f39808a8d2b5' + }; + } + }, + { + name: 'check controllers info', + test: async () => { + const result = await backend_canister.get_controllers_info(); + + return { + ok: + 'ok' in result && + result.ok.frontend + .map((principal) => principal.toText()) + .includes('rrkah-fqaaa-aaaaa-aaaaq-cai') && + result.ok.backend + .map((principal) => principal.toText()) + .includes('rrkah-fqaaa-aaaaa-aaaaq-cai') + }; + } + }, + { + name: 'check signers', + test: async () => { + const result = await backend_canister.get_signers(); + const signer = execSync('dfx identity get-principal') + .toString() + .trim(); + + return { + ok: result.length === 1 && result[0].toText() === signer + }; + } + }, + { + name: 'check signer proposals', + test: async () => { + const result = await backend_canister.get_signer_proposals(); + + return { + ok: result.length === 0 + }; + } + }, + { + name: 'check threshold', + test: async () => { + const result = await backend_canister.get_threshold(); + + return { + ok: result === 1 + }; + } + }, + { + name: 'check threshold proposals', + test: async () => { + const result = await backend_canister.get_threshold_proposals(); + + return { + ok: result.length === 0 + }; + } + }, + { + name: 'check transfers', + test: async () => { + const result = await backend_canister.get_transfers(); + + return { + ok: result.length === 0 + }; + } + }, + { + name: 'check transfer proposals', + test: async () => { + const result = await backend_canister.get_transfer_proposals(); + + return { + ok: result.length === 0 + }; + } + } + ]; +} + +function get_address_from_principal_tests(): Test[] { + return [ + { + name: 'get_address_from_principal rrkah-fqaaa-aaaaa-aaaaq-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('rrkah-fqaaa-aaaaa-aaaaq-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal rrkah-fqaaa-aaaaa-aaaaq-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal ryjl3-tyaaa-aaaaa-aaaba-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('ryjl3-tyaaa-aaaaa-aaaba-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal ryjl3-tyaaa-aaaaa-aaaba-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal rno2w-sqaaa-aaaaa-aaacq-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('rno2w-sqaaa-aaaaa-aaacq-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal rno2w-sqaaa-aaaaa-aaacq-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal rkp4c-7iaaa-aaaaa-aaaca-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('rkp4c-7iaaa-aaaaa-aaaca-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal rkp4c-7iaaa-aaaaa-aaaca-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal r7inp-6aaaa-aaaaa-aaabq-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('r7inp-6aaaa-aaaaa-aaabq-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal r7inp-6aaaa-aaaaa-aaabq-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal rwlgt-iiaaa-aaaaa-aaaaa-cai', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText('rwlgt-iiaaa-aaaaa-aaaaa-cai') + ); + const address = execSync( + `dfx ledger account-id --of-principal rwlgt-iiaaa-aaaaa-aaaaa-cai` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal 3zjeh-xtbtx-mwebn-37a43-7nbck-qgquk-xtrny-42ujn-gzaxw-ncbzw-kqe', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText( + '3zjeh-xtbtx-mwebn-37a43-7nbck-qgquk-xtrny-42ujn-gzaxw-ncbzw-kqe' + ) + ); + const address = execSync( + `dfx ledger account-id --of-principal 3zjeh-xtbtx-mwebn-37a43-7nbck-qgquk-xtrny-42ujn-gzaxw-ncbzw-kqe` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal o2ivq-5dsz3-nba5d-pwbk2-hdd3i-vybeq-qfz35-rqg27-lyesf-xghzc-3ae', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText( + 'o2ivq-5dsz3-nba5d-pwbk2-hdd3i-vybeq-qfz35-rqg27-lyesf-xghzc-3ae' + ) + ); + const address = execSync( + `dfx ledger account-id --of-principal o2ivq-5dsz3-nba5d-pwbk2-hdd3i-vybeq-qfz35-rqg27-lyesf-xghzc-3ae` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal cb53b-qsf7f-isr4v-tco56-pu475-66ehq-cfkko-doax3-xrnjh-pdo57-zae', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText( + 'cb53b-qsf7f-isr4v-tco56-pu475-66ehq-cfkko-doax3-xrnjh-pdo57-zae' + ) + ); + const address = execSync( + `dfx ledger account-id --of-principal cb53b-qsf7f-isr4v-tco56-pu475-66ehq-cfkko-doax3-xrnjh-pdo57-zae` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + }, + { + name: 'get_address_from_principal fhzp2-mb4kr-hm4io-32js7-oketg-gdi73-4pqb4-6jyxp-ajbhd-tuiwt-bqe', + test: async () => { + const result = + await backend_canister.get_address_from_principal( + Principal.fromText( + 'fhzp2-mb4kr-hm4io-32js7-oketg-gdi73-4pqb4-6jyxp-ajbhd-tuiwt-bqe' + ) + ); + const address = execSync( + `dfx ledger account-id --of-principal fhzp2-mb4kr-hm4io-32js7-oketg-gdi73-4pqb4-6jyxp-ajbhd-tuiwt-bqe` + ) + .toString() + .trim(); + + return { + ok: result === address + }; + } + } + ]; +} diff --git a/tsconfig.json b/tsconfig.json index 11c0cbb..2638f0d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,8 @@ "compilerOptions": { "strict": true, "target": "ES2020", - "moduleResolution": "node" + "moduleResolution": "node", + "allowJs": true, + "outDir": "HACK_BECAUSE_OF_ALLOW_JS" } }