Skip to content

Commit

Permalink
Use more updated did file from src
Browse files Browse the repository at this point in the history
  • Loading branch information
ninegua committed Jun 10, 2021
1 parent 4c97d3b commit 7aecc5e
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
SRC=src/index.js src/bare-agent.js src/index.html
DID_SRC=src/ledger.did src/governance.did
NNS_IFACES ?= $(shell nix-prefetch-url --print-path https://codeload.github.com/dfinity/nns-ifaces/tar.gz/refs/tags/v0.8.1 | tail -n1)
#NNS_IFACES ?= $(shell nix-prefetch-url --print-path https://codeload.github.com/dfinity/nns-ifaces/tar.gz/refs/tags/v0.8.1 | tail -n1)

all: fmt build

build: dist/main.bundle.js

$(DID_SRC) &:
cd src && cat $(NNS_IFACES) |tar zx --wildcards --strip-components=1 */ledger.did */governance.did
#$(DID_SRC) &:
# cd src && cat $(NNS_IFACES) |tar zx --wildcards --strip-components=1 */ledger.did */governance.did

dist/index.html dist/main.bundle.js &: $(SRC) $(DID_SRC) webpack.config.js src/simple.min.css
npm run-script build
Expand All @@ -29,7 +29,7 @@ install: dist/monic.wasm
install -D dist/monic.wasm ${out}/bin/ic-qr-scanner.wasm

clean:
rm -rf dist $(DID_SRC)
rm -rf dist

nix-build:
cp `nix-build ic-qr-scanner.nix`/bin/* .
Expand Down
4 changes: 3 additions & 1 deletion ic-qr-scanner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
}) { } }:
with pkgs;
let
/*
nns-ifaces = builtins.fetchurl {
url =
"https://github.com/dfinity/nns-ifaces/archive/d18437c46c180f26e09f97eb764cf65165563517.tar.gz";
sha256 = "08pry53rbwrfjphsxji9h5jjlk8k1qwfrwl1vna3709vl9z68z4i";
};
*/
filter = name: type:
let baseName = baseNameOf (toString name);
in !(baseName == "dist" || baseName == "node_modules"
Expand All @@ -33,7 +35,7 @@ in stdenv.mkDerivation {
lld_10
pkgsCross.wasi32.buildPackages.clang_10
];
NNS_IFACES = nns-ifaces;
/* NNS_IFACES = nns-ifaces; */
src = cleanSource ./.;
buildPhase = ''
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
Expand Down
250 changes: 250 additions & 0 deletions src/governance.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
type AccountIdentifier = record { hash : vec nat8 };
type Action = variant {
ManageNeuron : ManageNeuron;
ExecuteNnsFunction : ExecuteNnsFunction;
RewardNodeProvider : RewardNodeProvider;
SetDefaultFollowees : SetDefaultFollowees;
ManageNetworkEconomics : NetworkEconomics;
ApproveGenesisKyc : ApproveGenesisKyc;
AddOrRemoveNodeProvider : AddOrRemoveNodeProvider;
Motion : Motion;
};
type AddHotKey = record { new_hot_key : opt principal };
type AddOrRemoveNodeProvider = record { change : opt Change };
type Amount = record { e8s : nat64 };
type ApproveGenesisKyc = record { principals : vec principal };
type Ballot = record { vote : int32; voting_power : nat64 };
type BallotInfo = record { vote : int32; proposal_id : opt NeuronId };
type Change = variant { ToRemove : NodeProvider; ToAdd : NodeProvider };
type ClaimOrRefreshNeuronFromAccount = record {
controller : opt principal;
memo : nat64;
};
type ClaimOrRefreshNeuronFromAccountResponse = record { result : opt Result_1 };
type Command = variant {
Spawn : Spawn;
Split : Split;
Follow : Follow;
Configure : Configure;
RegisterVote : RegisterVote;
DisburseToNeuron : DisburseToNeuron;
MakeProposal : Proposal;
Disburse : Disburse;
};
type Command_1 = variant {
Error : GovernanceError;
Spawn : SpawnResponse;
Split : SpawnResponse;
Follow : record {};
Configure : record {};
RegisterVote : record {};
DisburseToNeuron : SpawnResponse;
MakeProposal : MakeProposalResponse;
Disburse : DisburseResponse;
};
type Command_2 = variant {
Spawn : Spawn;
Split : Split;
ClaimOrRefresh : ClaimOrRefreshNeuronFromAccount;
DisburseToNeuron : DisburseToNeuron;
Disburse : Disburse;
};
type Configure = record { operation : opt Operation };
type Disburse = record {
to_account : opt AccountIdentifier;
amount : opt Amount;
};
type DisburseResponse = record { transfer_block_height : nat64 };
type DisburseToNeuron = record {
dissolve_delay_seconds : nat64;
kyc_verified : bool;
amount_e8s : nat64;
new_controller : opt principal;
nonce : nat64;
};
type DissolveState = variant {
DissolveDelaySeconds : nat64;
WhenDissolvedTimestampSeconds : nat64;
};
type ExecuteNnsFunction = record { nns_function : int32; payload : vec nat8 };
type Follow = record { topic : int32; followees : vec NeuronId };
type Followees = record { followees : vec NeuronId };
type Governance = record {
default_followees : vec record { int32; Followees };
wait_for_quiet_threshold_seconds : nat64;
node_providers : vec NodeProvider;
economics : opt NetworkEconomics;
latest_reward_event : opt RewardEvent;
to_claim_transfers : vec NeuronStakeTransfer;
short_voting_period_seconds : nat64;
proposals : vec record { nat64; ProposalData };
in_flight_commands : vec record { nat64; NeuronInFlightCommand };
neurons : vec record { nat64; Neuron };
genesis_timestamp_seconds : nat64;
};
type GovernanceError = record { error_message : text; error_type : int32 };
type IncreaseDissolveDelay = record {
additional_dissolve_delay_seconds : nat32;
};
type ListNeurons = record {
neuron_ids : vec nat64;
include_neurons_readable_by_caller : bool;
};
type ListNeuronsResponse = record {
neuron_infos : vec record { nat64; NeuronInfo };
full_neurons : vec Neuron;
};
type ListProposalInfo = record {
include_reward_status : vec int32;
before_proposal : opt NeuronId;
limit : nat32;
exclude_topic : vec int32;
include_status : vec int32;
};
type ListProposalInfoResponse = record { proposal_info : vec ProposalInfo };
type MakeProposalResponse = record { proposal_id : opt NeuronId };
type ManageNeuron = record { id : opt NeuronId; command : opt Command };
type ManageNeuronResponse = record { command : opt Command_1 };
type Motion = record { motion_text : text };
type NetworkEconomics = record {
neuron_minimum_stake_e8s : nat64;
max_proposals_to_keep_per_topic : nat32;
neuron_management_fee_per_proposal_e8s : nat64;
reject_cost_e8s : nat64;
transaction_fee_e8s : nat64;
neuron_spawn_dissolve_delay_seconds : nat64;
minimum_icp_xdr_rate : nat64;
maximum_node_provider_rewards_e8s : nat64;
};
type Neuron = record {
id : opt NeuronId;
controller : opt principal;
recent_ballots : vec BallotInfo;
kyc_verified : bool;
not_for_profit : bool;
maturity_e8s_equivalent : nat64;
cached_neuron_stake_e8s : nat64;
created_timestamp_seconds : nat64;
aging_since_timestamp_seconds : nat64;
hot_keys : vec principal;
account : vec nat8;
dissolve_state : opt DissolveState;
followees : vec record { int32; Followees };
neuron_fees_e8s : nat64;
transfer : opt NeuronStakeTransfer;
};
type NeuronId = record { id : nat64 };
type NeuronInFlightCommand = record {
command : opt Command_2;
timestamp : nat64;
};
type NeuronInfo = record {
dissolve_delay_seconds : nat64;
recent_ballots : vec BallotInfo;
created_timestamp_seconds : nat64;
state : int32;
retrieved_at_timestamp_seconds : nat64;
voting_power : nat64;
age_seconds : nat64;
};
type NeuronStakeTransfer = record {
to_subaccount : vec nat8;
neuron_stake_e8s : nat64;
from : opt principal;
memo : nat64;
from_subaccount : vec nat8;
transfer_timestamp : nat64;
block_height : nat64;
};
type NodeProvider = record { id : opt principal };
type Operation = variant {
RemoveHotKey : RemoveHotKey;
AddHotKey : AddHotKey;
StopDissolving : record {};
StartDissolving : record {};
IncreaseDissolveDelay : IncreaseDissolveDelay;
SetDissolveTimestamp : SetDissolveTimestamp;
};
type Proposal = record { url : text; action : opt Action; summary : text };
type ProposalData = record {
id : opt NeuronId;
failure_reason : opt GovernanceError;
ballots : vec record { nat64; Ballot };
proposal_timestamp_seconds : nat64;
reward_event_round : nat64;
failed_timestamp_seconds : nat64;
reject_cost_e8s : nat64;
latest_tally : opt Tally;
decided_timestamp_seconds : nat64;
proposal : opt Proposal;
proposer : opt NeuronId;
executed_timestamp_seconds : nat64;
};
type ProposalInfo = record {
id : opt NeuronId;
status : int32;
topic : int32;
failure_reason : opt GovernanceError;
ballots : vec record { nat64; Ballot };
proposal_timestamp_seconds : nat64;
reward_event_round : nat64;
failed_timestamp_seconds : nat64;
reject_cost_e8s : nat64;
latest_tally : opt Tally;
reward_status : int32;
decided_timestamp_seconds : nat64;
proposal : opt Proposal;
proposer : opt NeuronId;
executed_timestamp_seconds : nat64;
};
type RegisterVote = record { vote : int32; proposal : opt NeuronId };
type RemoveHotKey = record { hot_key_to_remove : opt principal };
type Result = variant { Ok; Err : GovernanceError };
type Result_1 = variant { Error : GovernanceError; NeuronId : NeuronId };
type Result_2 = variant { Ok : Neuron; Err : GovernanceError };
type Result_3 = variant { Ok : NeuronInfo; Err : GovernanceError };
type RewardEvent = record {
day_after_genesis : nat64;
actual_timestamp_seconds : nat64;
distributed_e8s_equivalent : nat64;
settled_proposals : vec NeuronId;
};
type RewardMode = variant {
RewardToNeuron : RewardToNeuron;
RewardToAccount : RewardToAccount;
};
type RewardNodeProvider = record {
node_provider : opt NodeProvider;
reward_mode : opt RewardMode;
amount_e8s : nat64;
};
type RewardToAccount = record { to_account : opt AccountIdentifier };
type RewardToNeuron = record { dissolve_delay_seconds : nat64 };
type SetDefaultFollowees = record {
default_followees : vec record { int32; Followees };
};
type SetDissolveTimestamp = record { dissolve_timestamp_seconds : nat64 };
type Spawn = record { new_controller : opt principal };
type SpawnResponse = record { created_neuron_id : opt NeuronId };
type Split = record { amount_e8s : nat64 };
type Tally = record {
no : nat64;
yes : nat64;
total : nat64;
timestamp_seconds : nat64;
};
service : (Governance) -> {
claim_gtc_neurons : (principal, vec NeuronId) -> (Result);
claim_or_refresh_neuron_from_account : (ClaimOrRefreshNeuronFromAccount) -> (
ClaimOrRefreshNeuronFromAccountResponse,
);
get_full_neuron : (nat64) -> (Result_2) query;
get_neuron_ids : () -> (vec nat64) query;
get_neuron_info : (nat64) -> (Result_3) query;
get_pending_proposals : () -> (vec ProposalInfo) query;
get_proposal_info : (nat64) -> (opt ProposalInfo) query;
list_neurons : (ListNeurons) -> (ListNeuronsResponse) query;
list_proposals : (ListProposalInfo) -> (ListProposalInfoResponse) query;
manage_neuron : (ManageNeuron) -> (ManageNeuronResponse);
transfer_gtc_neuron : (NeuronId, NeuronId) -> (Result);
}
85 changes: 85 additions & 0 deletions src/ledger.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
type AccountBalanceArgs = record {
account: AccountIdentifier;
};
type AccountIdentifier = text;
type ArchiveOptions = record {
node_max_memory_size_bytes: opt nat32;
max_message_size_bytes: opt nat32;
controller_id: principal;
};
type CanisterId = principal;
type BlockHeight = nat64;
type Duration = record {
secs: nat64;
nanos: nat32;
};
type ICPTs = record {
e8s : nat64;
};
type LedgerCanisterInitPayload = record {
minting_account: AccountIdentifier;
initial_values: vec record {AccountIdentifier; ICPTs};
max_message_size_bytes: opt nat32;
transaction_window: opt Duration;
archive_options: opt ArchiveOptions;
send_whitelist: vec record {principal};
};
type Memo = nat64;
type NotifyCanisterArgs = record {
block_height: BlockHeight;
max_fee: ICPTs;
from_subaccount: opt SubAccount;
to_canister: principal;
to_subaccount: opt SubAccount;
};
type SendArgs = record {
memo: Memo;
amount: ICPTs;
fee: ICPTs;
from_subaccount: opt SubAccount;
to: AccountIdentifier;
created_at_time: opt TimeStamp;
};
type SubAccount = vec nat8;
type TimeStamp = record {
timestamp_nanos: nat64;
};
type Transaction = record {
transfer: Transfer;
memo: Memo;
created_at: BlockHeight;
};
type Transfer = variant {
Burn: record {
from: AccountIdentifier;
amount: ICPTs;
};
Mint: record {
to: AccountIdentifier;
amount: ICPTs;
};
Send: record {
from: AccountIdentifier;
to: AccountIdentifier;
amount: ICPTs;
};
};
type HeaderField = record {text; text};
type HttpRequest = record {
url: text;
method: text;
body: vec nat8;
headers: vec HeaderField;
};
type HttpResponse = record {
body: vec nat8;
headers: vec HeaderField;
status_code: nat16;
};
service: (LedgerCanisterInitPayload) -> {
send_dfx : (SendArgs) -> (BlockHeight);
notify_dfx: (NotifyCanisterArgs) -> ();
account_balance_dfx : (AccountBalanceArgs) -> (ICPTs) query;
get_nodes : () -> (vec CanisterId) query;
http_request: (HttpRequest) -> (HttpResponse) query;
}

0 comments on commit 7aecc5e

Please sign in to comment.