hadronous / pic-js

An Internet Computer Protocol canister testing library for TypeScript and JavaScript.
https://hadronous.github.io/pic-js/
Apache License 2.0
11 stars 6 forks source link

Example with canister arguments #56

Closed baolongt closed 3 months ago

baolongt commented 3 months ago

Example I have this candid to put in --argument

opt record {
  name = opt \"Test Token\";
  symbol = opt \"TTT\";
  logo = opt \"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InJlZCIvPjwvc3ZnPg==\";
  decimals = 8;
  fee = opt variant { Fixed = 10000};
  minting_account = opt record{
    owner = principal \"$ADMIN_PRINCIPAL\";
    subaccount = null;
  };
  max_supply = null;
  min_burn_amount = opt 10000;
  max_memo = opt 64;
  advanced_settings = null;
  metadata = null;
  fee_collector = null;
  transaction_window = null;
  permitted_drift = null;
  max_accounts = opt 100000000;
  settle_to_accounts = opt 99999000;
}

But in this code Its type is ArrayBufferLike, do we have any example to convert above candid or typescript object like this below to ArrayBufferLike

[{
        name: ["Test Token"],
        symbol: ["TTT"],
        logo: ["data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InJlZCIvPjwvc3ZnPg=="],
        decimals: 8,
        fee: [{ Fixed: 10000 }],
        minting_account: [{
            owner: "$ADMIN_PRINCIPAL",
            subaccount: null,
        }],
        max_supply: [],
        min_burn_amount: [10000],
        max_memo: [64],
        advanced_settings: [],
        metadata: [],
        fee_collector: [],
        transaction_window: [],
        permitted_drift: [],
        max_accounts: [100000000],
        settle_to_accounts: [99999000],
    }]
nathanosdev commented 3 months ago

Yes, here: https://github.com/hadronous/pic-js/blob/694b0c3ff3171a17cf39d8040a9e7eb95c743875/examples/counter/tests/src/counter.spec.ts#L34.