Skip to content

Commit

Permalink
Add ckUSDC canisters to snapshot (#351)
Browse files Browse the repository at this point in the history
# Motivation

We want to add ckUSDC to NNS dapp and should have a way to test it.

# Changes

1. Add a logo file (copied from metadata of current mainnet
ckSepoliaUSDC).
2. Add a flag to `bin/dfx-token-deploy` to allow specifying a logo file.
3. Create ckUSDC canisters in `bin/dfx-stock-deploy`.
4. Add 10M ckUSDC to the faucet.

# Tested

Created a snapshot and used it in NNS dapp
  • Loading branch information
dskloetd authored May 16, 2024
1 parent b89ac10 commit 5e24c0b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
14 changes: 13 additions & 1 deletion bin/dfx-stock-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,24 @@ dfx-token-deploy \
--network "$DFX_NETWORK" \
--yes

: Mint 10M ckETH into the faucet address.
: Set up ckUSDC canisters
dfx-token-import --prefix ckusdc_ --commit "$DFX_IC_COMMIT"
dfx-token-deploy \
--prefix ckusdc_ \
--token ckUSDC \
--decimals 6 \
--fee 4000 \
--logo-svg-file "$SOURCE_DIR/../ckUSDC-logo.svg" \
--network "$DFX_NETWORK" \
--yes

: Mint 10M ckETH into the faucet addresses.
# See https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/api/dev.api.ts
FAUCET_ADDRESS="jg6qm-uw64t-m6ppo-oluwn-ogr5j-dc5pm-lgy2p-eh6px-hebcd-5v73i-nqe"
# The current identity was set as minting account and minting is done by
# transferring from the minting account.
dfx canister call cketh_ledger icrc1_transfer "(record {to=record{owner=principal \"$FAUCET_ADDRESS\"}; amount=10_000_000_000_000_000_000_000_000:nat})"
dfx canister call ckusdc_ledger icrc1_transfer "(record {to=record{owner=principal \"$FAUCET_ADDRESS\"}; amount=10_000_000_000_000:nat})"

: Add the nns root as a controller to the frontend canisters
NNS_ROOT="$(dfx canister id nns-root --network "$DFX_NETWORK")"
Expand Down
9 changes: 8 additions & 1 deletion bin/dfx-token-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ clap.define short=p long=prefix desc="Prefix for the local canister names" varia
clap.define long=token desc="The token name/symbol" variable=TOKEN default="MyToken"
clap.define long=decimals desc="Number of decimals to use in ledger canister" variable=DECIMALS default="8"
clap.define long=fee desc="The transaction fee to set" variable=FEE default="10"
clap.define long=logo-svg-file desc="SVG file to use as token logo" variable=LOGO_SVG_FILE default=""
clap.define short=y long=yes desc="Deploy even if there are existing canisters." variable=DFX_YES nargs=0
clap.define short=c long=check desc="Check that the canisters are present and correct." variable=DFX_CHECK nargs=0
clap.define short=m long=mode desc="Canister install mode." variable=DFX_MODE default="reinstall"
Expand All @@ -47,6 +48,12 @@ deploy_token() {

echo "Step 1: deploying ledger canister..."
DFX_IDENTITY_PRINCIPAL="$(dfx identity get-principal)"
if [[ -n "${LOGO_SVG_FILE:-}" ]]; then
LOGO_BASE64="$(base64 -i "$LOGO_SVG_FILE")"
TOKEN_METADATA="vec { record { \"icrc1:logo\"; variant { Text = \"data:image/svg+xml;base64,${LOGO_BASE64}\" }; } }"
else
TOKEN_METADATA="vec {}"
fi
dfx deploy "${LOCAL_PREFIX}ledger" --network "$DFX_NETWORK" --argument "(variant {
Init = record {
token_symbol = \"$TOKEN\";
Expand All @@ -55,7 +62,7 @@ deploy_token() {
transfer_fee = $FEE;
max_memo_length = opt 64;
decimals = opt $DECIMALS;
metadata = vec {};
metadata = $TOKEN_METADATA;
initial_balances = vec { record { record { owner = principal \"$DFX_IDENTITY_PRINCIPAL\"; }; 10_000_000; }; };
archive_options = record {
num_blocks_to_archive = 10_000;
Expand Down
52 changes: 52 additions & 0 deletions ckUSDC-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e24c0b

Please sign in to comment.