A proxy canister that can help query the protobuf interfaces of NNS canisters

Hello everyone, because some canister interfaces in NNS use protobuf as the data communication standard, so these interfaces to be unable to use dfx or candid-based canister to directly access.

And exporting the state in NNS is a just-needed:

So I made a tool: A proxy canister that can help query the protobuf interfaces of NNS canisters.

Part of the interface of Ledger canister and registry canister is currently implemented, such as:

  • get balance in Ledger canister:

    dfx canister --no-wallet --network ic call read_rs account_balance_pb '(record {account="073ca335431d6b6f6916068b5784a241730d2e3452ae650025b4bf7a975a81f0"})'
    (record { e8s = 47_110_000 : nat64 })
    
  • get transaction record block in Ledger canister:

    dfx canister --no-wallet --network ic call read_rs block_pb '(507504:nat64)'
    (
      record {
        transaction = record {
          memo = 182_884_116_570_714_352 : nat64;
          created_at_time = record {
            timestamp_nanos = 1_630_776_083_125_587_176 : nat64;
          };
          transfer = variant {
            Send = record {
              to = "4dfa940def17f1427ae47378c440f10185867677109a02bc8374fc25b9dee8af";
              fee = record { e8s = 10_000 : nat64 };
              from = "4acd7ec9e1411fd23b2ed84fc173aacd220872408c1ff77a29961ab0f70d6ef6";
              amount = record { e8s = 32_616_390_000 : nat64 };
            }
          };
        };
        timestamp = record { timestamp_nanos = 1_630_776_086_437_763_870 : nat64 };
        parent_hash = opt record {
          inner = blob "\eaJ!\c8\17H\94\89\d8\d0z\e9\a0$.\12\d2\d8\0d?\c4\84\be\f3n\a2\8e\14u\0a\af)";
        };
      },
    )
    ```
    
  • get the totalSupply in Ledger canister:

    dfx canister --no-wallet --network ic call read_rs total_supply_pb
    (record { e8s = 47_278_350_104_315_648 : nat64 })
    
  • get the latest version in Registry canister:

    dfx canister --no-wallet --network ic call read_rs get_latest_version
    (record { version = 17_011 : nat64 })
    

The canister id is chu2x-jyaaa-aaaah-aaqra-cai, which you can use to replace the read_rs in the command above to call the read_rs canister:

dfx canister --no-wallet --network ic call chu2x-jyaaa-aaaah-aaqra-cai get_latest_version
(record { version = 17_016 : nat64 })

next to do

  • support more protobuf interfaces
  • change update to query after inter canister query calls enabled:
3 Likes