Where is the up-to-date public did file of the ICP ledger?

Where is the up-to-date public did file of the ICP ledger?

Both https://raw.githubusercontent.com/dfinity/ic/dd3a710b03bd3ae10368a91b255571d012d1ec2f
/rs/rosetta-api/ledger.did
- displayed in the documentation - and https://github.com/dfinity/ic/blob/master/rs/rosetta-api/icp_ledger/ledger.did seem outdated are none contains the Icrc1 methods :thinking:.

Tautologically, the public interface of the ICP ledger is the public interface of the ICP ledger

2 Likes

Good point. I should have been more precise in my question. Where is the up-to-date public did fileā€¦so that I can continue to automatically download it with a bash script? :wink:

I use that script to download and install the ledger locally.

#!/usr/bin/env bash

IC_VERSION=f02cc38677905e24a9016637fddc697039930808
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/icp_ledger/ledger.did"

etc.

Hereā€™s a line that fetches the latest IC_VERSION: sdk/update-replica-version.yml at master Ā· dfinity/sdk Ā· GitHub

Thanks Severin. Not sure how I can get the path to the ICP ledger did file from there :sweat_smile:.

You have the curl command already there. It should never be outdated by more than a few days, and at the pace of ledger interface changes this shouldnā€™t be a problem.

I just remembered: You should be able to run dfx canister metadata <canister> candid:service to get the same interface the dashboard uses

Thatā€™s a nice command to know (:+1: ) but it gives back the replica version, not the did file Iā€™m looking for.

āÆ curl -s https://ic-api.internetcomputer.org/api/v3/subnet-replica-versions\?limit\=50\&offset\=0 | jq -r ā€˜.data[0].replica_version_idā€™
0a239c213c048563577969276739b090aa31c241

Sorry for not understanding fast, maybe Iā€™m missing something.

Thatā€™s another nice command but, it does not seem the generated did content was what I was looking for :thinking:. The ledger should now exposes Icrc1 function, as those Idisplayed on the dashboard - Canister: NNS ICP Ledger - ICP Dashboard - but strangly, even though I got these locally (I can use the function from my dapp, all good), these werenā€™t generated in the did file :man_shrugging:.

e.g. dashboard

service : (LedgerCanisterInitPayload) -> {
  account_balance : (BinaryAccountBalanceArgs) -> (Tokens) query;
  account_balance_dfx : (AccountBalanceArgs) -> (Tokens) query;
  archives : () -> (Archives) query;
  decimals : () -> (Decimals) query;
  icrc1_balance_of : (Account) -> (nat) query;
  icrc1_decimals : () -> (nat8) query;
  ...

locally:

  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;

  etc.

It looks like the ICP Ledger canisterā€™s Candid interface in custom section ā€˜icp:public candid:serviceā€™ is not up to date.

You can do this instead (not a recommended long-term solution) to get the correct Candid interface:

dfx canister --network ic call ryjl3-tyaaa-aaaaa-aaaba-cai __get_candid_interface_tmp_hack
2 Likes

What a cool hack, that would do the trick.

And thanks for confirming it is not up-to-date and therefore, not up-to-date in the doc (Ledger Local Setup) and in the repo as well.

1 Like