From 3772536bd3de5cf3a8b412f598823fc6ea5285fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=22Doom=22=20Doumergue?= Date: Wed, 13 Nov 2024 20:18:38 +0100 Subject: [PATCH] Update Polkadot extrinsic encoding to support new spec for Acala (#4107) * Update Polkadot extrinsic encoding to support new spec for Acala * Make Test Fail * Fix Acala test --------- Co-authored-by: jaimeToca --- src/Polkadot/Extrinsic.cpp | 2 +- tests/chains/Acala/TWAnySignerTests.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Polkadot/Extrinsic.cpp b/src/Polkadot/Extrinsic.cpp index b88e5e9a843..dcd0b31a308 100644 --- a/src/Polkadot/Extrinsic.cpp +++ b/src/Polkadot/Extrinsic.cpp @@ -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 { diff --git a/tests/chains/Acala/TWAnySignerTests.cpp b/tests/chains/Acala/TWAnySignerTests.cpp index c69ada618f0..cf8cb5f1641 100644 --- a/tests/chains/Acala/TWAnySignerTests.cpp +++ b/tests/chains/Acala/TWAnySignerTests.cpp @@ -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); @@ -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