Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bugfix- add MsgUnjailV2 to the typeurl mapping
  • Loading branch information
cdc-Hitesh committed Nov 23, 2022
1 parent 55daba9 commit c88ab19
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/transaction/common/constants/typeurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const typeUrlToMsgClassMapping = (cro: any, typeUrl: string) => {

// slashing
case COSMOS_MSG_TYPEURL.slashing.MsgUnjail:
return cro.v2.slashing.MsgUnjail;
return cro.v2.slashing.MsgUnjailV2;
default:
throw new Error(`${typeUrl} not supported.`);
}
Expand Down
27 changes: 27 additions & 0 deletions lib/src/transaction/msg/slashing/MsgUnjail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ describe('Testing MsgUnjail', function () {
);
});

it('Should not throw on using V2 methods for transaction management', function () {
const anyKeyPair = Secp256k1KeyPair.fromPrivKey(
Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'),
);

const MsgUnjail = new cro.v2.slashing.MsgUnjailV2({
validatorAddress: 'tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr',
});

const anySigner = {
publicKey: anyKeyPair.getPubKey(),
accountNumber: new Big(0),
accountSequence: new Big(2),
};

const rawTx = new cro.v2.RawTransactionV2();

const signableTxV2 = rawTx.appendMessage(MsgUnjail).addSigner(anySigner).toSignable();

const signedTx = signableTxV2.setSignature(0, anyKeyPair.sign(signableTxV2.toSignDocumentHash(0))).toSigned();

const signedTxHex = signedTx.encode().toHexString();
expect(signedTxHex).to.be.eql(
'0a590a570a222f636f736d6f732e736c617368696e672e763162657461312e4d7367556e6a61696c12310a2f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e767212580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40186e87b0b41928e69a1211c1fb5ebcb4c11fa6350f5cc830fa5f38f36f37f66e00d062707672b5d4ebf98cd5e3c7c4b40562707321bb9e8f2d3d605d8beb7b13',
);
});

it('Should validate MsgUnjail provided addresses with network config', function () {
const params2 = {
validatorAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3',
Expand Down

0 comments on commit c88ab19

Please sign in to comment.