Skip to content

Commit

Permalink
Merge pull request #397 from cdc-Hitesh/feature/#391/support-MsgUnjail
Browse files Browse the repository at this point in the history
Bug: Add missing typeurl mapping for MsgUnjailV2
  • Loading branch information
cdc-Hitesh authored Nov 23, 2022
2 parents d53efe7 + fbf50bb commit 5b013b0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

## v1.1.1
- Bugfix for `MsgUnjailV2` transaction management

## v1.1.0
- Added support for `MsgUnjail`

Expand Down
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
4 changes: 2 additions & 2 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": "@crypto-org-chain/chain-jslib",
"version": "1.1.0",
"version": "1.1.1",
"description": "Crypto.org Chain JavaScript library",
"author": "Crypto.org <[email protected]>",
"license": "Apache-2.0",
Expand Down

0 comments on commit 5b013b0

Please sign in to comment.