Skip to content

Commit

Permalink
Update Polkadot extrinsic encoding to support new spec for Acala (#4107)
Browse files Browse the repository at this point in the history
* Update Polkadot extrinsic encoding to support new spec for Acala

* Make Test Fail

* Fix Acala test

---------

Co-authored-by: jaimeToca <[email protected]>
  • Loading branch information
doom and JaimeToca authored Nov 13, 2024
1 parent 6be89c9 commit 3772536
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Polkadot/Extrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ Data Extrinsic::encodeIdentityAddAuthorization(const Proto::Identity::AddAuthori

static bool requires_new_spec_compatbility(uint32_t network, uint32_t specVersion) noexcept {
// version 1002005 introduces a breaking change for Polkadot and Kusama
return ((network == 0 || network == 2) && specVersion >= 1002005);
return ((network == 0 || network == 2) && specVersion >= 1002005) || (network == 10 && specVersion >= 2270);
}

Data Extrinsic::encodePayload() const {
Expand Down
6 changes: 3 additions & 3 deletions tests/chains/Acala/TWAnySignerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(TWAnySignerAcala, Sign) {
input.set_block_hash(blockHash.data(), blockHash.size());

input.set_nonce(0);
input.set_spec_version(2170);
input.set_spec_version(2270);
input.set_private_key(secret.data(), secret.size());
input.set_network(10); // Acala
input.set_transaction_version(2);
Expand All @@ -48,12 +48,12 @@ TEST(TWAnySignerAcala, Sign) {

auto extrinsic = Extrinsic(input);
auto preimage = extrinsic.encodePayload();
EXPECT_EQ(hex(preimage), "0a0000c8c602ded977c56076ae38d98026fa669ca10d6a2b5a0bfc4086ae7668ed1c60070010a5d4e8d50200007a08000002000000fc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c707ffa05b7dc6cdb6356bd8bd51ff20b2757c3214a76277516080a10f1bc7537");
EXPECT_EQ(hex(preimage), "0a0000c8c602ded977c56076ae38d98026fa669ca10d6a2b5a0bfc4086ae7668ed1c60070010a5d4e8d502000000de08000002000000fc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c707ffa05b7dc6cdb6356bd8bd51ff20b2757c3214a76277516080a10f1bc753700");

Proto::SigningOutput output;
ANY_SIGN(input, TWCoinTypePolkadot);

EXPECT_EQ(hex(output.encoded()), "41028400e9590e4d99264a14a85e21e69537e4a64f66a875d38cb8f76b305f41fabe24a900dd54466dffd1e3c80b76013e9459fbdcd17805bd5fdbca0961a643bad1cbd2b7fe005c62c51c18b67f31eb9e61b187a911952fee172ef18402d07c703eec3100d50200000a0000c8c602ded977c56076ae38d98026fa669ca10d6a2b5a0bfc4086ae7668ed1c60070010a5d4e8");
EXPECT_EQ(hex(output.encoded()), "45028400e9590e4d99264a14a85e21e69537e4a64f66a875d38cb8f76b305f41fabe24a900a9c3111fb98507f929e4da9aea30f996c69d2790e5a1e789f91634dc5d4f6afb155e0f1ea623498c04778f06dbc698109c3490c3e6b4c33d8e58ebab82a0f40bd5020000000a0000c8c602ded977c56076ae38d98026fa669ca10d6a2b5a0bfc4086ae7668ed1c60070010a5d4e8");
}

} // namespace TW::Polkadot::tests

0 comments on commit 3772536

Please sign in to comment.