Skip to content

Commit acab3a6

Browse files
committed
Fix to handle metadata amino fields as undefined
1 parent aedd4a6 commit acab3a6

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@initia/initia.js",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "The JavaScript SDK for Initia",
55
"license": "MIT",
66
"author": "InitiaLabs",

src/core/gov/msgs/MsgSubmitProposal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class MsgSubmitProposal extends JSONSerializable<
5151
messages.map(Msg.fromAmino),
5252
Coins.fromAmino(initial_deposit),
5353
proposer,
54-
metadata,
54+
metadata ?? '',
5555
title,
5656
summary,
5757
expedited
@@ -75,7 +75,7 @@ export class MsgSubmitProposal extends JSONSerializable<
7575
messages: messages.map(msg => msg.toAmino()),
7676
initial_deposit: initial_deposit.toAmino(),
7777
proposer,
78-
metadata,
78+
metadata: metadata && metadata !== '' ? metadata : undefined,
7979
title,
8080
summary,
8181
expedited,
@@ -183,7 +183,7 @@ export namespace MsgSubmitProposal {
183183
messages: Msg.Amino[];
184184
initial_deposit: Coins.Amino;
185185
proposer: AccAddress;
186-
metadata: string;
186+
metadata?: string;
187187
title: string;
188188
summary: string;
189189
expedited: boolean;

src/core/gov/msgs/MsgVote.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ export class MsgVote extends JSONSerializable<
3232
const {
3333
value: { proposal_id, voter, option, metadata },
3434
} = data;
35-
return new MsgVote(Number.parseInt(proposal_id), voter, option, metadata);
35+
return new MsgVote(
36+
Number.parseInt(proposal_id),
37+
voter,
38+
option,
39+
metadata ?? ''
40+
);
3641
}
3742

3843
public toAmino(): MsgVote.Amino {
@@ -43,7 +48,7 @@ export class MsgVote extends JSONSerializable<
4348
proposal_id: proposal_id.toString(),
4449
voter,
4550
option,
46-
metadata,
51+
metadata: metadata && metadata !== '' ? metadata : undefined,
4752
},
4853
};
4954
}
@@ -105,7 +110,7 @@ export namespace MsgVote {
105110
proposal_id: string;
106111
voter: AccAddress;
107112
option: VoteOption;
108-
metadata: string;
113+
metadata?: string;
109114
};
110115
}
111116

src/core/gov/msgs/MsgVoteWeighted.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class MsgVoteWeighted extends JSONSerializable<
3636
Number.parseInt(proposal_id),
3737
voter,
3838
options.map(o => WeightedVoteOption.fromAmino(o)),
39-
metadata
39+
metadata ?? ''
4040
);
4141
}
4242

@@ -48,7 +48,7 @@ export class MsgVoteWeighted extends JSONSerializable<
4848
proposal_id: proposal_id.toFixed(),
4949
voter,
5050
options: options.map(o => o.toAmino()),
51-
metadata,
51+
metadata: metadata && metadata !== '' ? metadata : undefined,
5252
},
5353
};
5454
}
@@ -112,7 +112,7 @@ export namespace MsgVoteWeighted {
112112
proposal_id: string;
113113
voter: AccAddress;
114114
options: WeightedVoteOption.Amino[];
115-
metadata: string;
115+
metadata?: string;
116116
};
117117
}
118118

0 commit comments

Comments
 (0)