-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around list_neuron not working with HW (#673)
# Motivation `list_neurons` is broken with the Ledger HW (current version 2.4.9) because it does not accept a `ListNeurons` with the `include_empty_neurons_readable_by_caller` even if the field itself is not set. The (temporary?) work-around added in this PR is to keep a service which uses an old version of the `ListNeurons` type to use when the field is not set anyway. # Changes 1. Add `old_list_neurons_service.certified.idl.js` which just has what's necessary for the `list_neurons` method without `include_empty_neurons_readable_by_caller`. 2. Use this service when calling `list_neurons` with `certified: true` and `include_empty_neurons_readable_by_caller: undefined`. # Tests 1. Unit tests added/adapted. 2. Tested manually at https://qsgjb-riaaa-aaaaa-aaaga-cai.dskloet-ingress.devenv.dfinity.network/ # Todos - [x] Add entry to changelog (if necessary). --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0d0ff13
commit e8a6a20
Showing
7 changed files
with
206 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
packages/nns/candid/old_list_neurons_service.certified.idl.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { IDL } from "@dfinity/candid"; | ||
export const idlFactory: IDL.InterfaceFactory; |
78 changes: 78 additions & 0 deletions
78
packages/nns/candid/old_list_neurons_service.certified.idl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// This file was created manually by taking governance.certified.idl.js and | ||
// removing everything that isn't needed for `list_neurons` and then removing | ||
// `include_empty_neurons_readable_by_caller` from `ListNeurons`. | ||
// The Ledger hardware wallet doesn't support the | ||
// `include_empty_neurons_readable_by_caller` field, even when it's not set, so | ||
// we use this service for compatibility with the hardware wallet. | ||
export const idlFactory = ({ IDL }) => { | ||
const NeuronId = IDL.Record({ id: IDL.Nat64 }); | ||
const Followees = IDL.Record({ followees: IDL.Vec(NeuronId) }); | ||
const KnownNeuronData = IDL.Record({ | ||
name: IDL.Text, | ||
description: IDL.Opt(IDL.Text), | ||
}); | ||
const NeuronStakeTransfer = IDL.Record({ | ||
to_subaccount: IDL.Vec(IDL.Nat8), | ||
neuron_stake_e8s: IDL.Nat64, | ||
from: IDL.Opt(IDL.Principal), | ||
memo: IDL.Nat64, | ||
from_subaccount: IDL.Vec(IDL.Nat8), | ||
transfer_timestamp: IDL.Nat64, | ||
block_height: IDL.Nat64, | ||
}); | ||
const BallotInfo = IDL.Record({ | ||
vote: IDL.Int32, | ||
proposal_id: IDL.Opt(NeuronId), | ||
}); | ||
const DissolveState = IDL.Variant({ | ||
DissolveDelaySeconds: IDL.Nat64, | ||
WhenDissolvedTimestampSeconds: IDL.Nat64, | ||
}); | ||
const Neuron = IDL.Record({ | ||
id: IDL.Opt(NeuronId), | ||
staked_maturity_e8s_equivalent: IDL.Opt(IDL.Nat64), | ||
controller: IDL.Opt(IDL.Principal), | ||
recent_ballots: IDL.Vec(BallotInfo), | ||
kyc_verified: IDL.Bool, | ||
neuron_type: IDL.Opt(IDL.Int32), | ||
not_for_profit: IDL.Bool, | ||
maturity_e8s_equivalent: IDL.Nat64, | ||
cached_neuron_stake_e8s: IDL.Nat64, | ||
created_timestamp_seconds: IDL.Nat64, | ||
auto_stake_maturity: IDL.Opt(IDL.Bool), | ||
aging_since_timestamp_seconds: IDL.Nat64, | ||
hot_keys: IDL.Vec(IDL.Principal), | ||
account: IDL.Vec(IDL.Nat8), | ||
joined_community_fund_timestamp_seconds: IDL.Opt(IDL.Nat64), | ||
dissolve_state: IDL.Opt(DissolveState), | ||
followees: IDL.Vec(IDL.Tuple(IDL.Int32, Followees)), | ||
neuron_fees_e8s: IDL.Nat64, | ||
transfer: IDL.Opt(NeuronStakeTransfer), | ||
known_neuron_data: IDL.Opt(KnownNeuronData), | ||
spawn_at_timestamp_seconds: IDL.Opt(IDL.Nat64), | ||
}); | ||
const NeuronInfo = IDL.Record({ | ||
dissolve_delay_seconds: IDL.Nat64, | ||
recent_ballots: IDL.Vec(BallotInfo), | ||
neuron_type: IDL.Opt(IDL.Int32), | ||
created_timestamp_seconds: IDL.Nat64, | ||
state: IDL.Int32, | ||
stake_e8s: IDL.Nat64, | ||
joined_community_fund_timestamp_seconds: IDL.Opt(IDL.Nat64), | ||
retrieved_at_timestamp_seconds: IDL.Nat64, | ||
known_neuron_data: IDL.Opt(KnownNeuronData), | ||
voting_power: IDL.Nat64, | ||
age_seconds: IDL.Nat64, | ||
}); | ||
const ListNeurons = IDL.Record({ | ||
neuron_ids: IDL.Vec(IDL.Nat64), | ||
include_neurons_readable_by_caller: IDL.Bool, | ||
}); | ||
const ListNeuronsResponse = IDL.Record({ | ||
neuron_infos: IDL.Vec(IDL.Tuple(IDL.Nat64, NeuronInfo)), | ||
full_neurons: IDL.Vec(Neuron), | ||
}); | ||
return IDL.Service({ | ||
list_neurons: IDL.Func([ListNeurons], [ListNeuronsResponse], []), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters