Skip to content

Commit 5b013b0

Browse files
authored
Merge pull request #397 from cdc-Hitesh/feature/#391/support-MsgUnjail
Bug: Add missing typeurl mapping for MsgUnjailV2
2 parents d53efe7 + fbf50bb commit 5b013b0

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## v1.1.1
6+
- Bugfix for `MsgUnjailV2` transaction management
7+
58
## v1.1.0
69
- Added support for `MsgUnjail`
710

lib/src/transaction/common/constants/typeurl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const typeUrlToMsgClassMapping = (cro: any, typeUrl: string) => {
139139

140140
// slashing
141141
case COSMOS_MSG_TYPEURL.slashing.MsgUnjail:
142-
return cro.v2.slashing.MsgUnjail;
142+
return cro.v2.slashing.MsgUnjailV2;
143143
default:
144144
throw new Error(`${typeUrl} not supported.`);
145145
}

lib/src/transaction/msg/slashing/MsgUnjail.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@ describe('Testing MsgUnjail', function () {
8787
);
8888
});
8989

90+
it('Should not throw on using V2 methods for transaction management', function () {
91+
const anyKeyPair = Secp256k1KeyPair.fromPrivKey(
92+
Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'),
93+
);
94+
95+
const MsgUnjail = new cro.v2.slashing.MsgUnjailV2({
96+
validatorAddress: 'tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr',
97+
});
98+
99+
const anySigner = {
100+
publicKey: anyKeyPair.getPubKey(),
101+
accountNumber: new Big(0),
102+
accountSequence: new Big(2),
103+
};
104+
105+
const rawTx = new cro.v2.RawTransactionV2();
106+
107+
const signableTxV2 = rawTx.appendMessage(MsgUnjail).addSigner(anySigner).toSignable();
108+
109+
const signedTx = signableTxV2.setSignature(0, anyKeyPair.sign(signableTxV2.toSignDocumentHash(0))).toSigned();
110+
111+
const signedTxHex = signedTx.encode().toHexString();
112+
expect(signedTxHex).to.be.eql(
113+
'0a590a570a222f636f736d6f732e736c617368696e672e763162657461312e4d7367556e6a61696c12310a2f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e767212580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40186e87b0b41928e69a1211c1fb5ebcb4c11fa6350f5cc830fa5f38f36f37f66e00d062707672b5d4ebf98cd5e3c7c4b40562707321bb9e8f2d3d605d8beb7b13',
114+
);
115+
});
116+
90117
it('Should validate MsgUnjail provided addresses with network config', function () {
91118
const params2 = {
92119
validatorAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3',

package-lock.json

Lines changed: 2 additions & 2 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": "@crypto-org-chain/chain-jslib",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Crypto.org Chain JavaScript library",
55
"author": "Crypto.org <[email protected]>",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)