Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ledger transfer ci #611

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/provision-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm node.pkg

# Install DFINITY SDK.
curl --location --output install-dfx.sh "https://internetcomputer.org/install.sh"
DFX_VERSION=${DFX_VERSION:=0.12.0} bash install-dfx.sh < <(yes Y)
DFX_VERSION=${DFX_VERSION:=0.14.3} bash install-dfx.sh < <(yes Y)
rm install-dfx.sh
dfx cache install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/provision-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rm install-node.sh

# Install DFINITY SDK.
wget --output-document install-dfx.sh "https://internetcomputer.org/install.sh"
DFX_VERSION=${DFX_VERSION:=0.12.0} bash install-dfx.sh < <(yes Y)
DFX_VERSION=${DFX_VERSION:=0.14.3} bash install-dfx.sh < <(yes Y)
rm install-dfx.sh
dfx cache install

Expand Down
10 changes: 1 addition & 9 deletions motoko/ledger-transfer/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@ dfx stop
set -e
trap 'dfx stop' EXIT

export IC_VERSION=2cb0afe1f49b8bbd4e60db234ca1f4a6f68ea115
test -f ledger.wasm.gz || curl -o ledger.wasm.gz https://download.dfinity.systems/ic/${IC_VERSION}/canisters/ledger-canister_notify-method.wasm.gz
test -f ledger.wasm || gunzip ledger.wasm.gz
test -f ledger.private.did || curl -o ledger.private.did https://raw.githubusercontent.com/dfinity/ic/${IC_VERSION}/rs/rosetta-api/ledger.did
test -f ledger.public.did || curl -o ledger.public.did https://raw.githubusercontent.com/dfinity/ic/${IC_VERSION}/rs/rosetta-api/ledger_canister/ledger.did

dfx start --background --clean
dfx identity new alice --disable-encryption || true
cat <<<"$(jq '.canisters.ledger.candid="ledger.private.did"' dfx.json)" >dfx.json
export MINT_ACC=$(dfx --identity anonymous ledger account-id)
export LEDGER_ACC=$(dfx ledger account-id)
export ARCHIVE_CONTROLLER=$(dfx identity get-principal)
dfx deploy ledger --argument '(record {minting_account = "'${MINT_ACC}'"; initial_values = vec { record { "'${LEDGER_ACC}'"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}})'
cat <<<"$(jq '.canisters.ledger.candid="ledger.public.did"' dfx.json)" >dfx.json
dfx deploy ledger --argument '(variant { Init = record {minting_account = "'${MINT_ACC}'"; initial_values = vec { record { "'${LEDGER_ACC}'"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}}})'
dfx canister call ledger account_balance '(record { account = '$(python3 -c 'print("vec{" + ";".join([str(b) for b in bytes.fromhex("'$LEDGER_ACC'")]) + "}")')' })'

dfx deploy ledger_transfer
Expand Down
11 changes: 8 additions & 3 deletions motoko/ledger-transfer/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
},
"ledger": {
"type": "custom",
"candid": "ledger.public.did",
"wasm": "ledger.wasm"
"candid": "https://raw.githubusercontent.com/dfinity/ic/a17247bd86c7aa4e87742bf74d108614580f216d/rs/rosetta-api/icp_ledger/ledger.did",
"wasm": "https://download.dfinity.systems/ic/a17247bd86c7aa4e87742bf74d108614580f216d/canisters/ledger-canister.wasm.gz",
"remote": {
"id": {
"ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
}
}
}
},
"defaults": {
Expand All @@ -20,4 +25,4 @@
}
},
"version": 1
}
}
249 changes: 0 additions & 249 deletions motoko/ledger-transfer/ledger.public.did

This file was deleted.

5 changes: 3 additions & 2 deletions motoko/ledger-transfer/src/ledger_transfer/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Ledger "canister:ledger";

import Debug "mo:base/Debug";
import Error "mo:base/Error";
import Blob "mo:base/Blob";
import Int "mo:base/Int";
import HashMap "mo:base/HashMap";
import List "mo:base/List";
Expand Down Expand Up @@ -60,7 +61,7 @@ actor Self {

// Returns current balance on the default account of this canister.
public func canisterBalance() : async Ledger.Tokens {
await Ledger.account_balance({ account = myAccountId() })
await Ledger.account_balance({ account = Blob.toArray(myAccountId()) })
};

// Rewards the most prolific author of the last week with 1 token.
Expand Down Expand Up @@ -92,7 +93,7 @@ actor Self {
let res = await Ledger.transfer({
memo = Nat64.fromNat(maxPosts);
from_subaccount = null;
to = Account.accountIdentifier(principal, Account.defaultSubaccount());
to = Blob.toArray(Account.accountIdentifier(principal, Account.defaultSubaccount()));
amount = { e8s = 100_000_000 };
fee = { e8s = 10_000 };
created_at_time = ?{ timestamp_nanos = Nat64.fromNat(Int.abs(now)) };
Expand Down
Loading