Skip to content

Commit

Permalink
Fix to handle metadata amino fields as undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed May 22, 2024
1 parent aedd4a6 commit acab3a6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
15 changes: 9 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.2.2",
"version": "0.2.3",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down
6 changes: 3 additions & 3 deletions src/core/gov/msgs/MsgSubmitProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MsgSubmitProposal extends JSONSerializable<
messages.map(Msg.fromAmino),
Coins.fromAmino(initial_deposit),
proposer,
metadata,
metadata ?? '',
title,
summary,
expedited
Expand All @@ -75,7 +75,7 @@ export class MsgSubmitProposal extends JSONSerializable<
messages: messages.map(msg => msg.toAmino()),
initial_deposit: initial_deposit.toAmino(),
proposer,
metadata,
metadata: metadata && metadata !== '' ? metadata : undefined,
title,
summary,
expedited,
Expand Down Expand Up @@ -183,7 +183,7 @@ export namespace MsgSubmitProposal {
messages: Msg.Amino[];
initial_deposit: Coins.Amino;
proposer: AccAddress;
metadata: string;
metadata?: string;
title: string;
summary: string;
expedited: boolean;
Expand Down
11 changes: 8 additions & 3 deletions src/core/gov/msgs/MsgVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export class MsgVote extends JSONSerializable<
const {
value: { proposal_id, voter, option, metadata },
} = data;
return new MsgVote(Number.parseInt(proposal_id), voter, option, metadata);
return new MsgVote(
Number.parseInt(proposal_id),
voter,
option,
metadata ?? ''
);
}

public toAmino(): MsgVote.Amino {
Expand All @@ -43,7 +48,7 @@ export class MsgVote extends JSONSerializable<
proposal_id: proposal_id.toString(),
voter,
option,
metadata,
metadata: metadata && metadata !== '' ? metadata : undefined,
},
};
}
Expand Down Expand Up @@ -105,7 +110,7 @@ export namespace MsgVote {
proposal_id: string;
voter: AccAddress;
option: VoteOption;
metadata: string;
metadata?: string;
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/gov/msgs/MsgVoteWeighted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MsgVoteWeighted extends JSONSerializable<
Number.parseInt(proposal_id),
voter,
options.map(o => WeightedVoteOption.fromAmino(o)),
metadata
metadata ?? ''
);
}

Expand All @@ -48,7 +48,7 @@ export class MsgVoteWeighted extends JSONSerializable<
proposal_id: proposal_id.toFixed(),
voter,
options: options.map(o => o.toAmino()),
metadata,
metadata: metadata && metadata !== '' ? metadata : undefined,
},
};
}
Expand Down Expand Up @@ -112,7 +112,7 @@ export namespace MsgVoteWeighted {
proposal_id: string;
voter: AccAddress;
options: WeightedVoteOption.Amino[];
metadata: string;
metadata?: string;
};
}

Expand Down

0 comments on commit acab3a6

Please sign in to comment.