Skip to content

Commit 4251f63

Browse files
committed
cleanup
1 parent 129edb4 commit 4251f63

File tree

1 file changed

+50
-42
lines changed
  • src/chain-wallet-libs/bindings/wallet-wasm-js/js

1 file changed

+50
-42
lines changed

src/chain-wallet-libs/bindings/wallet-wasm-js/js/index.js

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,89 +21,97 @@ module.exports.Settings = Settings;
2121

2222
class Vote {
2323
constructor(
24-
spending_counter,
25-
spending_counter_lane,
26-
valid_until,
27-
vote_plan,
28-
proposal_index,
24+
spendingCounter,
25+
spendingCounterLane,
26+
validUntil,
27+
votePlan,
28+
proposalIndex,
2929
choice,
3030
options,
31-
public_key
31+
publicKey
3232
) {
33-
this.spending_counter = spending_counter;
34-
this.spending_counter_lane = spending_counter_lane;
35-
this.valid_until = valid_until;
36-
if (options != undefined && public_key != undefined) {
33+
this.spendingCounter = spendingCounter;
34+
this.spendingCounterLane = spendingCounterLane;
35+
this.validUntil = validUntil;
36+
if (options != undefined && publicKey != undefined) {
3737
let payload = wasm.Payload.new_private(
38-
vote_plan,
38+
wasm.VotePlanId.from_bytes(votePlan),
3939
options,
4040
choice,
41-
public_key
41+
publicKey
42+
);
43+
this.voteCast = wasm.VoteCast.new(
44+
wasm.VotePlanId.from_bytes(votePlan),
45+
proposalIndex,
46+
payload
4247
);
43-
this.vote_cast = wasm.VoteCast.new(vote_plan, proposal_index, payload);
4448
} else {
4549
let payload = wasm.Payload.new_public(choice);
46-
this.vote_cast = wasm.VoteCast.new(vote_plan, proposal_index, payload);
50+
this.voteCast = wasm.VoteCast.new(
51+
wasm.VotePlanId.from_bytes(votePlan),
52+
proposalIndex,
53+
payload
54+
);
4755
}
4856
}
4957
}
5058
module.exports.Vote = Vote;
5159

5260
class Proposal {
5361
constructor(
54-
vote_plan_bytes,
55-
options_count,
56-
vote_public,
57-
proposal_index,
62+
votePlan,
63+
voteOptions,
64+
votePublic,
65+
proposalIndex,
5866
committee_public_key
5967
) {
60-
this.vote_plan = wasm.VotePlanId.from_bytes(vote_plan_bytes);
61-
this.options_count = options_count;
62-
this.vote_public = vote_public;
63-
this.proposal_index = proposal_index;
68+
this.votePlan = votePlan;
69+
this.voteOptions = voteOptions;
70+
this.votePublic = votePublic;
71+
this.proposalIndex = proposalIndex;
6472
this.committee_public_key = committee_public_key;
6573
}
6674

67-
vote(spending_counter, spending_counter_lane, valid_until, choice) {
68-
if (this.vote_public) {
75+
vote(spendingCounter, spendingCounterLane, validUntil, choice) {
76+
if (this.votePublic) {
6977
return new Vote(
70-
spending_counter,
71-
spending_counter_lane,
72-
valid_until,
73-
this.vote_plan,
74-
this.proposal_index,
78+
spendingCounter,
79+
spendingCounterLane,
80+
validUntil,
81+
this.votePlan,
82+
this.proposalIndex,
7583
choice
7684
);
7785
} else {
7886
return new Vote(
79-
spending_counter,
80-
spending_counter_lane,
81-
valid_until,
82-
this.vote_plan,
83-
this.proposal_index,
87+
spendingCounter,
88+
spendingCounterLane,
89+
validUntil,
90+
this.votePlan,
91+
this.proposalIndex,
8492
choice,
85-
this.options_count,
93+
this.voteOptions,
8694
this.committee_public_key
8795
);
8896
}
8997
}
9098
}
9199
module.exports.Proposal = Proposal;
92100

93-
function signVotes(votes, settings, private_key) {
101+
function signVotes(votes, settings, privateKey) {
94102
let fragments = [];
95103
for (let i = 0; i < votes.length; i++) {
96104
let builder = wasm.VoteCastTxBuilder.new(
97105
settings.settings,
98-
votes[i].valid_until.epoch,
99-
votes[i].valid_until.slot,
100-
votes[i].vote_cast
106+
votes[i].validUntil.epoch,
107+
votes[i].validUntil.slot,
108+
votes[i].voteCast
101109
);
102110
let fragment = builder
103111
.build_tx(
104-
private_key,
105-
votes[i].spending_counter,
106-
votes[i].spending_counter_lane
112+
privateKey,
113+
votes[i].spendingCounter,
114+
votes[i].spendingCounterLane
107115
)
108116
.finalize_tx();
109117
fragments.push(fragment);

0 commit comments

Comments
 (0)