From 8876d6457be3bfffd8bb4cbe833e7d4c45c1c26c Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 4 Mar 2020 09:43:06 -0700 Subject: [PATCH 1/3] Update to solana v1.0 --- .../blockchains/solana/TestSolanaSigner.kt | 8 ++--- src/Solana/Transaction.h | 17 +++++----- swift/Tests/Blockchains/SolanaTests.swift | 31 ++++++++++--------- tests/Solana/SignerTests.cpp | 29 ++++++++--------- tests/Solana/TWAnySignerTests.cpp | 31 ++++++++++--------- tests/Solana/TWSolanaAddressTests.cpp | 2 +- tests/Solana/TransactionTests.cpp | 31 ++++++++++--------- 7 files changed, 77 insertions(+), 72 deletions(-) diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt index e0ea476f521..168a67ca609 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt @@ -34,7 +34,7 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x01fda1c8ad8872d94f7eab52f9c38dc77e1061f4897e3de2b8469eb0992269f6fa1f173e93dbb2da738ab4e8959ffa50cd087cdfa889f3a1b8acdd62552f7c1d070100020366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001020200010c020000002a00000000000000" + val expectedHexString = "0x0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001020200010c020000002a00000000000000" assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) } @@ -52,7 +52,7 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x01be20567f2db0b09802bf70bbaf397d819c29496c6472a70e2db5c92dff1b666f5f5a4787b07d951bf46435c84248a974bb417c789041fbc512d0a06869fb1d0e010006080eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a93ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc000000000000000000000000000000000000000000000000000000000000000000000000003060200015c030000002000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d00700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc000000000070201026c000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000000000000000000000000000000000070501030405000402000000" + val expectedHexString = "0x01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a93ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc000000000000000000000000000000000000000000000000000000000000000000000000003060200017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab82000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070501030405000402000000" assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) } @@ -69,7 +69,7 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x014a85ccf3aa7e684b3352ed825dc4517daf3a95565d6ce0fcab0a7747bac87749c99e428e9ae7f42d38bc265b45811a03b649e5d98fc5b0ecbff60c783bfc470e010102040eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000000000000103030102000406000000" + val expectedHexString = "0x01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000000000000103030102000405000000" assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) } @@ -87,7 +87,7 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x014e808302fa771ccccfa4e82280bfd4b4ec267dc5107ff5baa8b718f6dae13aa23b888c1b7f44e8c8ea5fb750955af4e5b8187ca10d16922bf5af01b5897bfb03010003050eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c050000002a00000000000000" + val expectedHexString = "0x015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c040000002a00000000000000" assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) } } diff --git a/src/Solana/Transaction.h b/src/Solana/Transaction.h index 17c16cc082f..6f2cd149cae 100644 --- a/src/Solana/Transaction.h +++ b/src/Solana/Transaction.h @@ -39,8 +39,8 @@ enum SystemInstruction { CreateAccount, Assign, Transfer, CreateAccountWithSeed enum StakeInstruction { Initialize = 0, DelegateStake = 2, - Withdraw = 5, - Deactivate = 6, + Withdraw = 4, + Deactivate = 5, }; // An instruction to execute a program @@ -68,9 +68,9 @@ struct CompiledInstruction { this->data = data; } - // This constructor creates a System CreateAccount instruction + // This constructor creates a System CreateAccountWithSeed instruction CompiledInstruction(uint8_t programIdIndex, uint64_t value, uint64_t space, Address programId, - Address voteAddress, uint64_t seedLength) + Address voteAddress, uint64_t seedLength, Address signer) : programIdIndex(programIdIndex) { std::vector accounts = {0, 1}; this->accounts = accounts; @@ -80,6 +80,7 @@ struct CompiledInstruction { Data vecSeed(seed.begin(), seed.end()); vecSeed.resize(static_cast(seedLength)); encode32LE(static_cast(type), data); + append(data, signer.vector()); encode64LE(static_cast(seedLength), data); append(data, vecSeed); encode64LE(static_cast(value), data); @@ -97,7 +98,7 @@ struct CompiledInstruction { encode32LE(static_cast(type), data); append(data, signer.vector()); append(data, signer.vector()); - auto lockup = Data(40); + auto lockup = Data(48); append(data, lockup); this->data = data; } @@ -194,7 +195,7 @@ class Message { // This constructor creates a default single-signer Transfer message Message(Address from, Address to, uint64_t value, Hash recentBlockhash) : recentBlockhash(recentBlockhash) { - MessageHeader header = {1, 0, 2}; + MessageHeader header = {1, 0, 1}; this->header = header; auto programId = Address("11111111111111111111111111111111"); std::vector
accountKeys = {from, to, programId}; @@ -225,7 +226,7 @@ class Message { std::vector instructions; // create_account_with_seed instruction auto createAccountInstruction = - CompiledInstruction(6, value, 2000, stakeProgramId, voteAddress, 32); + CompiledInstruction(6, value, 2008, stakeProgramId, voteAddress, 32, signer); instructions.push_back(createAccountInstruction); // initialize instruction auto initializeInstruction = CompiledInstruction(7, Initialize, signer); @@ -240,7 +241,7 @@ class Message { // This constructor creates a deactivate_stake message Message(Address signer, Address stakeAddress, StakeInstruction type, Hash recentBlockhash) : recentBlockhash(recentBlockhash) { - MessageHeader header = {1, 1, 2}; + MessageHeader header = {1, 0, 2}; this->header = header; auto sysvarClockId = Address("SysvarC1ock11111111111111111111111111111111"); diff --git a/swift/Tests/Blockchains/SolanaTests.swift b/swift/Tests/Blockchains/SolanaTests.swift index b4b2c860c9d..1aa9f603d7c 100644 --- a/swift/Tests/Blockchains/SolanaTests.swift +++ b/swift/Tests/Blockchains/SolanaTests.swift @@ -44,8 +44,8 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) let expectedHexString = """ - 01fda1c8ad8872d94f7eab52f9c38dc77e1061f4897e3de2b8469eb0992269f6fa1f173e93dbb2da738ab4e895\ - 9ffa50cd087cdfa889f3a1b8acdd62552f7c1d070100020366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8\ + 0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e\ + 1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8\ bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000\ 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\ 000000000000000000000000000000000001020200010c020000002a00000000000000 @@ -68,19 +68,20 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) let expectedHexString = """ - 01be20567f2db0b09802bf70bbaf397d819c29496c6472a70e2db5c92dff1b666f5f5a4787b07d951bf46435c8\ - 4248a974bb417c789041fbc512d0a06869fb1d0e010006080eba44e56f060007284dc037275a15094c1d6c0697\ + 01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83\ + dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697\ ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9\ 3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21\ 0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000\ 000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78\ 722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602\ - 00015c030000002000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e\ - 616b2a00000000000000d00700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49d\ - c000000000070201026c000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4ba\ - b80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000\ - 00000000000000000000000000000000000000000000000000000000070501030405000402000000 + 00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000\ + 0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700\ + 000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000\ + 000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037\ + 275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000\ + 0000000000000000000000000000000000000000000000070501030405000402000000 """ XCTAssertEqual(output.encoded.hexString, expectedHexString) @@ -99,12 +100,12 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) let expectedHexString = """ - 014a85ccf3aa7e684b3352ed825dc4517daf3a95565d6ce0fcab0a7747bac87749c99e428e9ae7f42d38bc265b\ - 45811a03b649e5d98fc5b0ecbff60c783bfc470e010102040eba44e56f060007284dc037275a15094c1d6c0697\ + 01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63\ + dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697\ ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7a\ b2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000\ - 000000000103030102000406000000 + 000000000103030102000405000000 """ XCTAssertEqual(output.encoded.hexString, expectedHexString) @@ -124,12 +125,12 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) let expectedHexString = """ - 014e808302fa771ccccfa4e82280bfd4b4ec267dc5107ff5baa8b718f6dae13aa23b888c1b7f44e8c8ea5fb750\ - 955af4e5b8187ca10d16922bf5af01b5897bfb03010003050eba44e56f060007284dc037275a15094c1d6c0697\ + 015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025\ + 471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697\ ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13\ 206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0\ - 000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c05\ + 000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c04\ 0000002a00000000000000 """ diff --git a/tests/Solana/SignerTests.cpp b/tests/Solana/SignerTests.cpp index 0deb840fc7f..bb832247d6b 100644 --- a/tests/Solana/SignerTests.cpp +++ b/tests/Solana/SignerTests.cpp @@ -32,13 +32,13 @@ TEST(SolanaSigner, SingleSignTransaction) { std::vector expectedSignatures; Signature expectedSignature( - "657ZT4gMXRVQZz1mqzcWbP6sDx6ziM41HMpZRMrZYYP2CaEU3QMj8jxV6xRwM3rUKiXnihXLsXWEPRyw7nn4Ssst"); + "5T6uZBHnHFd8uWErDBTFRVkbKuhbcm94K5MJ2beTYDruzqv4FjS7EMKvC94ZfxNAiWUXZ6bZxS3WXUbhJwYNPWn"); expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); auto expectedHex = - "01fda1c8ad8872d94f7eab52f9c38dc77e1061f4897e3de2b8469eb0992269f6fa1f173e93dbb2da738ab4e895" - "9ffa50cd087cdfa889f3a1b8acdd62552f7c1d070100020366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" + "0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e" + "1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" "bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000" "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000001020200010c020000002a00000000000000"; @@ -129,13 +129,13 @@ TEST(SolanaSigner, SignUpdateBlockhash) { std::vector expectedSignatures; Signature expectedSignature( - "5aYWTCsc9UZibHcGLxA7SMJ6gJ4KNJovnR8VWTf4m35nHb28wh5LYdN9B48mC1FXVe8zSj3GBNyJyLPLTzWuRYnP"); + "5AFhXjvGdENXCAe9MPvUA2qjoL4XtZwZKG7kK2HmZf1ibpxjx5kzogHZjN39uYB9J33UFJN15KhSggBZhzyNQmta"); expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); auto expectedHex = - "01e4fe918e5b3fdb97bd0e02665d8f92465938bdfd4542181366aee0de676e2668184fe3a59d35dbbcdb7fcedd" - "b7155d740c4917f3eafc5bfd76cb1dd4b9c1d004010002032cb8775e08dca27a9b723611f42d474c5e809df576" + "01d00c3c7f97e4a22f2c2db7835aa0a524fc115c49f8acc361d724aa40a5e320718793b2648d0efed7227a45a4" + "36276d054aecc32c9d08f1d4b7a96069bee5e507010001032cb8775e08dca27a9b723611f42d474c5e809df576" "e242816cfee4bfc56835da373109b0e40ba3d915ac3ae2417dfd0544369bf31f5ce6e3b8329cdf4e6b058a0000" "000000000000000000000000000000000000000000000000000000000000040404040404040404040404040404" "040404040404040404040404040404040401020200010c020000002a00000000000000"; @@ -190,23 +190,24 @@ TEST(SolanaSigner, SignDelegateStake) { std::vector expectedSignatures; Signature expectedSignature( - "4oUMPVJ6NHGX1DFaxnDKSyZkxuN4osjqZE4mzA4iiNHd9kub3RtVKi3SUvRPsB5x2kB6EuRmBcWR4nbiKeoKF9os"); + "4Q3ctvLybffZJBGdvrnEg171AjZeiMPGf3rVfGCpDVZRq9QaKVw8jWTMqHzZckGi2yXbGoQdBgeua24iMfPGHTtV"); expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); auto expectedHex = - "01be20567f2db0b09802bf70bbaf397d819c29496c6472a70e2db5c92dff1b666f5f5a4787b07d951bf46435c8" - "4248a974bb417c789041fbc512d0a06869fb1d0e010006080eba44e56f060007284dc037275a15094c1d6c0697" + "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" + "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00015c030000002000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e" - "616b2a00000000000000d00700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49d" - "c000000000070201026c000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4ba" - "b80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000070501030405000402000000"; + "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" + "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" + "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" + "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" + "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000070501030405000402000000"; ASSERT_EQ(hex(transaction.serialize()), expectedHex); } diff --git a/tests/Solana/TWAnySignerTests.cpp b/tests/Solana/TWAnySignerTests.cpp index 5e893b17400..998062b9c4c 100644 --- a/tests/Solana/TWAnySignerTests.cpp +++ b/tests/Solana/TWAnySignerTests.cpp @@ -29,8 +29,8 @@ TEST(TWAnySignerSolana, SignTransfer) { ANY_SIGN(input, TWCoinTypeSolana); auto expectedHex = - "01fda1c8ad8872d94f7eab52f9c38dc77e1061f4897e3de2b8469eb0992269f6fa1f173e93dbb2da738ab4e895" - "9ffa50cd087cdfa889f3a1b8acdd62552f7c1d070100020366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" + "0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e" + "1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" "bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000" "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000001020200010c020000002a00000000000000"; @@ -51,19 +51,20 @@ TEST(TWAnySignerSolana, SignDelegateStakeTransaction) { ANY_SIGN(input, TWCoinTypeSolana); auto expectedHex = - "01be20567f2db0b09802bf70bbaf397d819c29496c6472a70e2db5c92dff1b666f5f5a4787b07d951bf46435c8" - "4248a974bb417c789041fbc512d0a06869fb1d0e010006080eba44e56f060007284dc037275a15094c1d6c0697" + "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" + "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00015c030000002000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e" - "616b2a00000000000000d00700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49d" - "c000000000070201026c000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4ba" - "b80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000070501030405000402000000"; + "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" + "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" + "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" + "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" + "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000070501030405000402000000"; ASSERT_EQ(hex(output.encoded()), expectedHex); } @@ -80,12 +81,12 @@ TEST(TWAnySignerSolana, SignDeactivateStakeTransaction) { ANY_SIGN(input, TWCoinTypeSolana); auto expectedHex = - "014a85ccf3aa7e684b3352ed825dc4517daf3a95565d6ce0fcab0a7747bac87749c99e428e9ae7f42d38bc265b" - "45811a03b649e5d98fc5b0ecbff60c783bfc470e010102040eba44e56f060007284dc037275a15094c1d6c0697" + "01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63" + "dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697" "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" "d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7a" "b2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000" - "000000000103030102000406000000"; + "000000000103030102000405000000"; ASSERT_EQ(hex(output.encoded()), expectedHex); } @@ -103,12 +104,12 @@ TEST(TWAnySignerSolana, SignWithdrawStakeTransaction) { ANY_SIGN(input, TWCoinTypeSolana); auto expectedHex = - "014e808302fa771ccccfa4e82280bfd4b4ec267dc5107ff5baa8b718f6dae13aa23b888c1b7f44e8c8ea5fb750" - "955af4e5b8187ca10d16922bf5af01b5897bfb03010003050eba44e56f060007284dc037275a15094c1d6c0697" + "015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025" + "471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697" "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" "d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13" "206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0" - "000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c05" + "000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c04" "0000002a00000000000000"; ASSERT_EQ(hex(output.encoded()), expectedHex); } diff --git a/tests/Solana/TWSolanaAddressTests.cpp b/tests/Solana/TWSolanaAddressTests.cpp index a27baa3a642..5af3bfa161f 100644 --- a/tests/Solana/TWSolanaAddressTests.cpp +++ b/tests/Solana/TWSolanaAddressTests.cpp @@ -6,8 +6,8 @@ #include "../interface/TWTestUtilities.h" -#include #include +#include #include diff --git a/tests/Solana/TransactionTests.cpp b/tests/Solana/TransactionTests.cpp index 196b729d2b1..4809693d058 100644 --- a/tests/Solana/TransactionTests.cpp +++ b/tests/Solana/TransactionTests.cpp @@ -23,7 +23,7 @@ TEST(SolanaTransaction, TransferMessageData) { auto transaction = Transaction(from, to, 42, recentBlockhash); auto expectedHex = - "0100020353f9d600fe925083bb399907ea648d23a6a081fc7e9059202fd725f7edd281dd3cc1ff9ba3c7a876c8" + "0100010353f9d600fe925083bb399907ea648d23a6a081fc7e9059202fd725f7edd281dd3cc1ff9ba3c7a876c8" "082df2f8a36ea9342ce3819dd4b6fa72d4a18e04a5363a00000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000000000000000000000000000000000010202" "00010c020000002a00000000000000"; @@ -31,19 +31,19 @@ TEST(SolanaTransaction, TransferMessageData) { } TEST(SolanaTransaction, TransferSerializeTransaction) { - auto from = Address("C9oZKzj7ajgu9vgV1evHrwrN6Yw22LtpwXEKoS4omZoi"); - auto to = Address("DvCpXoxoSAyoUgHWEe8M6LaD225798tYgFE7T3r4Z2iu"); + auto from = Address("41a5jYky56M6EWDsFfLaZRxoRtgAJSRWxJnxaJNJELn5"); + auto to = Address("4iSnyfDKaejniaPc2pBBckwQqV3mDS93go15NdxWJq2y"); Solana::Hash recentBlockhash("11111111111111111111111111111111"); auto transaction = Transaction(from, to, 42, recentBlockhash); Signature signature( - "5KZjkbW2KD1rViggHNoU4YqBVhfmpBY6YY5obM9qjSfC5QH1uFWUEbWgUPtrREEdyP3LLEjjrd1XhXVTSk34ma4d"); + "46SRiQGvtPb1iivDfnuC3dW1GzXkfQPTjdUyvFqF2sdPvFrsfx94fys2xpNKR6UiAj7RgKWdJG6mEfe85up6i1JT"); transaction.signatures.clear(); transaction.signatures.push_back(signature); auto expectedHex = - "01d813c70630e70f8a57a47f4bf63cf3eb0e43b9f2daa43bd4dfcbefd562dddd06d8dc37ad7bd941edd2c5c91f" - "e94d92ed6a91a39cecf231f007ea4ff0c358c10601000203a5b1d862445be46611868cd435ab63c9d5dbb403c2" - "918ac7f24c4180d70c02f5bfed63ee22636b105131aba9ad2667a9fe345edbff08cdc22fa3fab6e20fdbf20000" + "019abda83fb68c77c698cba9ae8e7c21b06cbe39aca3bb34deb3dbcd061683bd47371d2eec06417e203ee19d88" + "672819ee3319e7089ee0117128d95bf5ba57460c010001032cb8775e08dca27a9b723611f42d474c5e809df576" + "e242816cfee4bfc56835da373109b0e40ba3d915ac3ae2417dfd0544369bf31f5ce6e3b8329cdf4e6b058a0000" "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000001020200010c020000002a00000000000000"; ASSERT_EQ(hex(transaction.serialize()), expectedHex); @@ -58,23 +58,24 @@ TEST(SolanaTransaction, StakeSerializeTransaction) { auto message = Message(signer, stakeAddress, voteAddress, 42, recentBlockhash); auto transaction = Transaction(message); Signature signature( - "4oUMPVJ6NHGX1DFaxnDKSyZkxuN4osjqZE4mzA4iiNHd9kub3RtVKi3SUvRPsB5x2kB6EuRmBcWR4nbiKeoKF9os"); + "4Q3ctvLybffZJBGdvrnEg171AjZeiMPGf3rVfGCpDVZRq9QaKVw8jWTMqHzZckGi2yXbGoQdBgeua24iMfPGHTtV"); transaction.signatures.clear(); transaction.signatures.push_back(signature); auto expectedHex = - "01be20567f2db0b09802bf70bbaf397d819c29496c6472a70e2db5c92dff1b666f5f5a4787b07d951bf46435c8" - "4248a974bb417c789041fbc512d0a06869fb1d0e010006080eba44e56f060007284dc037275a15094c1d6c0697" + "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" + "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00015c030000002000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e" - "616b2a00000000000000d00700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49d" - "c000000000070201026c000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4ba" - "b80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000" - "00000000000000000000000000000000000000000000000000000000070501030405000402000000"; + "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" + "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" + "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" + "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" + "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000070501030405000402000000"; ASSERT_EQ(hex(transaction.serialize()), expectedHex); } From 3658eba05bb6a505c46d58a041775316e6241413 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 4 Mar 2020 14:13:00 -0700 Subject: [PATCH 2/3] Return serialized transaction as base-58-encoded string --- .../blockchains/solana/TestSolanaSigner.kt | 16 ++--- src/Solana/Signer.cpp | 3 +- src/Solana/Transaction.cpp | 4 +- src/Solana/Transaction.h | 2 +- src/proto/Solana.proto | 2 +- swift/Tests/Blockchains/SolanaTests.swift | 71 ++++++++----------- tests/Solana/SignerTests.cpp | 70 ++++++++---------- tests/Solana/TWAnySignerTests.cpp | 71 ++++++++----------- tests/Solana/TransactionTests.cpp | 41 +++++------ 9 files changed, 125 insertions(+), 155 deletions(-) diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt index 168a67ca609..8a6e543eaab 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/solana/TestSolanaSigner.kt @@ -34,8 +34,8 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001020200010c020000002a00000000000000" - assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) + val expectedString = "3p2kzZ1DvquqC6LApPuxpTg5CCDVPqJFokGSnGhnBHrta4uq7S2EyehV1XNUVXp51D69GxGzQZUjikfDzbWBG2aFtG3gHT1QfLzyFKHM4HQtMQMNXqay1NAeiiYZjNhx9UvMX4uAQZ4Q6rx6m2AYfQ7aoMUrejq298q1wBFdtS9XVB5QTiStnzC7zs97FUEK2T4XapjF1519EyFBViTfHpGpnf5bfizDzsW9kYUtRDW1UC2LgHr7npgq5W9TBmHf9hSmRgM9XXucjXLqubNWE7HUMhbKjuBqkirRM" + assertEquals(output.encoded, expectedString) } @Test @@ -52,8 +52,8 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a93ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc000000000000000000000000000000000000000000000000000000000000000000000000003060200017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab82000000000000000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070501030405000402000000" - assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) + val expectedString = "7gcsGMV8fPkuSDegrBk5KF4eZtmGqdixEr5Kxx7m74nErH5EWxkKcvy5LKg3kqKHLMtzqGXrM8EdVskLu5k6cQUVmznfd6iGpuDkn4BWi8HaqSoaeL7DCx6QHLUwcyvorfqPkgSaYopY9MeB6MGKS4bKCQi1paP7eEKZj9JgAZTHnpzAuFzqE5dC98MrbThoBmHqfybw1jHssp4NZjrxsuMz4oYcHe837WmnpinE68QEVf9FzuoXKrMDwYZQYogJHUZgxghvMmJu3XVZk7hL1h7SgE9ow2SvvNfAUYfUTuz8N9m6JcXgwmNL51ZweW9F1fekmSKE3vLEAaVvvYFsDxn1gt4bXuTdAMuUDKdH33YMLQr8eEsdUDZUm33KtuE7Ddy84NEg3KbpWAy8T4vkwiLyvoyjmMdzCkMuobyXWQV1rfRk5vTJ4x6dMgznfAeKEqmd6xZ2hN8JBmTenP5dsvZCCSCf4G7cUkdndKu552KALqiNHd5msgLJvJKSHmZjFhS43fDCvkG7njF8yaZzWjmAknWUBbV6YaGmD3XmcWfJgvB1zivZJhiMbzopP8Nm5wL5iDbCrSZTGq2tzEsTvje75wv2RtuAcgiicEPTuPAin9fKyMbCpf67pGgWPwH5DwYumMwd8zwoJyuakyqFsFLnBKTvp8pFCijdj7fEhyC31xuMV7crwyrN5X3y7QKCE7PZcBP637YHEPtTvt1ECp4CqBSnvPc8vRD8EMhHe5jRFSDkQriUenEPFc51dTDTJWL26xuiTivktEm6ahHq5d6MPr4NRDvcRG2cZvEgxHBLpKfuB5XL3JfQZ3Nn3B916gaK8owz9Rk2e3" + assertEquals(output.encoded, expectedString) } @Test @@ -69,8 +69,8 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000000000000103030102000405000000" - assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) + val expectedString = "AhfB77PTGTKBfbGPGuEz2khbBy8m8Kou1zqZST9dP7PLJNSeEze5NJuCh5qecPLa3S8xAQ6mTULmnAWiW81ib87nhywFtx5nKiUvmhdXsvKCSX6NNtNXdRz5yZi3UEop4obco85SY2czS6n4SJwmtDedHLtg9urqdZVth7AUM8KAtrRsksyvZRYXh64Z8QGyNY7ekj31ae11avGiSDNWYZZHqx7VPWRsKeatGyGk5zPmnRdL8ABMQgJ1Te7wAWwVnNn5QcoAxDuPw6uDctP8Q5S4TieRVatCnukQFj5BTJisez3E2ZJPWhVrMh4K3wEFkPHA7dR" + assertEquals(output.encoded, expectedString) } @Test @@ -87,7 +87,7 @@ class TestSolanaSigner { val output = AnySigner.sign(signingInput, SOLANA, SigningOutput.parser()) - val expectedHexString = "0x015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c040000002a00000000000000" - assertEquals(output.encoded.toByteArray().toHex(), expectedHexString) + val expectedString = "7Y1Wg1yHNs8MgWFiFSfcsRtqdMwZg8oGeQnTABYDfyDnof4VSFw63s3PuSxvUCJqqHKgYNVb8UTNcNiYHY8kng4NqTcVV5SA1KAWRzKHVGUxNWioAEXXVot5iJ1XbUWuuZUZBtsraaBjNyfmgWEDje3ESdGhiVL7vadU1uHeBuUKwM3nqB6yoeggeNyzmT34hs9utyehTFg48MAfrKEFKxaby7YZD6JbXFS1SyG1kxKWnCpoPgX3efwDwukmyDwxrKdABt9eTwmaiXKbTnK1hzBTatNfnJ9ePuWkhWFrjyDrGdx5S5KpybxET2vV9CSpExcD51BA6NPemTpjbhLYnJEzHWBGfYqfxu7p3257NHhpQQrSU56adk4dAQFjEYP" + assertEquals(output.encoded, expectedString) } } diff --git a/src/Solana/Signer.cpp b/src/Solana/Signer.cpp index 7e1a1ed5d5d..a7b13bdd6e3 100644 --- a/src/Solana/Signer.cpp +++ b/src/Solana/Signer.cpp @@ -5,6 +5,7 @@ // file LICENSE at the root of the source code distribution tree. #include "Signer.h" +#include "../Base58.h" #include #include @@ -82,7 +83,7 @@ Proto::SigningOutput Signer::sign(const Proto::SigningInput& input) noexcept { auto protoOutput = Proto::SigningOutput(); auto encoded = transaction.serialize(); - protoOutput.set_encoded(encoded.data(), encoded.size()); + protoOutput.set_encoded(encoded); return protoOutput; } diff --git a/src/Solana/Transaction.cpp b/src/Solana/Transaction.cpp index 111fa725d3e..25143ad5cc2 100644 --- a/src/Solana/Transaction.cpp +++ b/src/Solana/Transaction.cpp @@ -14,7 +14,7 @@ using namespace TW; using namespace TW::Solana; -Data Transaction::serialize() const { +std::string Transaction::serialize() const { Data buffer; append(buffer, shortVecLength(this->signatures)); @@ -24,7 +24,7 @@ Data Transaction::serialize() const { } append(buffer, this->messageData()); - return buffer; + return Base58::bitcoin.encode(buffer); } Data Transaction::messageData() const { diff --git a/src/Solana/Transaction.h b/src/Solana/Transaction.h index 6f2cd149cae..12ffdbe9c6f 100644 --- a/src/Solana/Transaction.h +++ b/src/Solana/Transaction.h @@ -292,7 +292,7 @@ class Transaction { } public: - std::vector serialize() const; + std::string serialize() const; std::vector messageData() const; uint8_t getAccountIndex(Address publicKey); diff --git a/src/proto/Solana.proto b/src/proto/Solana.proto index 3a521e9620d..79298c92961 100644 --- a/src/proto/Solana.proto +++ b/src/proto/Solana.proto @@ -36,5 +36,5 @@ message SigningInput { // Transaction signing output. message SigningOutput { - bytes encoded = 1; + string encoded = 1; } diff --git a/swift/Tests/Blockchains/SolanaTests.swift b/swift/Tests/Blockchains/SolanaTests.swift index 1aa9f603d7c..c5eadf4b6d2 100644 --- a/swift/Tests/Blockchains/SolanaTests.swift +++ b/swift/Tests/Blockchains/SolanaTests.swift @@ -43,15 +43,14 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) - let expectedHexString = """ - 0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e\ - 1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8\ - bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000\ - 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\ - 000000000000000000000000000000000001020200010c020000002a00000000000000 + let expectedString = """ + 3p2kzZ1DvquqC6LApPuxpTg5CCDVPqJFokGSnGhnBHrta4uq7S2EyehV1XNUVXp51D69GxGzQZU\ + jikfDzbWBG2aFtG3gHT1QfLzyFKHM4HQtMQMNXqay1NAeiiYZjNhx9UvMX4uAQZ4Q6rx6m2AYfQ\ + 7aoMUrejq298q1wBFdtS9XVB5QTiStnzC7zs97FUEK2T4XapjF1519EyFBViTfHpGpnf5bfizDz\ + sW9kYUtRDW1UC2LgHr7npgq5W9TBmHf9hSmRgM9XXucjXLqubNWE7HUMhbKjuBqkirRM """ - XCTAssertEqual(output.encoded.hexString, expectedHexString) + XCTAssertEqual(output.encoded, expectedString) } func testDelegateStakeSigner() throws { @@ -67,24 +66,20 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) - let expectedHexString = """ - 01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83\ - dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697\ - ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ - d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9\ - 3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21\ - 0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000\ - 000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78\ - 722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602\ - 00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000\ - 0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700\ - 000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000\ - 000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037\ - 275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000\ - 0000000000000000000000000000000000000000000000070501030405000402000000 + let expectedString = """ + 7gcsGMV8fPkuSDegrBk5KF4eZtmGqdixEr5Kxx7m74nErH5EWxkKcvy5LKg3kqKHLMtzqGXrM8EdVskLu5k6cQUVmz\ + nfd6iGpuDkn4BWi8HaqSoaeL7DCx6QHLUwcyvorfqPkgSaYopY9MeB6MGKS4bKCQi1paP7eEKZj9JgAZTHnpzAuFzq\ + E5dC98MrbThoBmHqfybw1jHssp4NZjrxsuMz4oYcHe837WmnpinE68QEVf9FzuoXKrMDwYZQYogJHUZgxghvMmJu3X\ + VZk7hL1h7SgE9ow2SvvNfAUYfUTuz8N9m6JcXgwmNL51ZweW9F1fekmSKE3vLEAaVvvYFsDxn1gt4bXuTdAMuUDKdH\ + 33YMLQr8eEsdUDZUm33KtuE7Ddy84NEg3KbpWAy8T4vkwiLyvoyjmMdzCkMuobyXWQV1rfRk5vTJ4x6dMgznfAeKEq\ + md6xZ2hN8JBmTenP5dsvZCCSCf4G7cUkdndKu552KALqiNHd5msgLJvJKSHmZjFhS43fDCvkG7njF8yaZzWjmAknWU\ + BbV6YaGmD3XmcWfJgvB1zivZJhiMbzopP8Nm5wL5iDbCrSZTGq2tzEsTvje75wv2RtuAcgiicEPTuPAin9fKyMbCpf\ + 67pGgWPwH5DwYumMwd8zwoJyuakyqFsFLnBKTvp8pFCijdj7fEhyC31xuMV7crwyrN5X3y7QKCE7PZcBP637YHEPtT\ + vt1ECp4CqBSnvPc8vRD8EMhHe5jRFSDkQriUenEPFc51dTDTJWL26xuiTivktEm6ahHq5d6MPr4NRDvcRG2cZvEgxH\ + BLpKfuB5XL3JfQZ3Nn3B916gaK8owz9Rk2e3 """ - XCTAssertEqual(output.encoded.hexString, expectedHexString) + XCTAssertEqual(output.encoded, expectedString) } func testDeactivateStakeSigner() throws { @@ -99,16 +94,14 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) - let expectedHexString = """ - 01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63\ - dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697\ - ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ - d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7a\ - b2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000\ - 000000000103030102000405000000 + let expectedString = """ + AhfB77PTGTKBfbGPGuEz2khbBy8m8Kou1zqZST9dP7PLJNSeEze5NJuCh5qecPLa3S8xAQ6mTULmnAWiW81ib87nhy\ + wFtx5nKiUvmhdXsvKCSX6NNtNXdRz5yZi3UEop4obco85SY2czS6n4SJwmtDedHLtg9urqdZVth7AUM8KAtrRsksyv\ + ZRYXh64Z8QGyNY7ekj31ae11avGiSDNWYZZHqx7VPWRsKeatGyGk5zPmnRdL8ABMQgJ1Te7wAWwVnNn5QcoAxDuPw6\ + uDctP8Q5S4TieRVatCnukQFj5BTJisez3E2ZJPWhVrMh4K3wEFkPHA7dR """ - XCTAssertEqual(output.encoded.hexString, expectedHexString) + XCTAssertEqual(output.encoded, expectedString) } func testWithdrawStakeSigner() throws { @@ -124,17 +117,15 @@ class SolanaTests: XCTestCase { let output: SolanaSigningOutput = AnySigner.sign(input: input, coin: .solana) - let expectedHexString = """ - 015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025\ - 471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697\ - ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7\ - d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13\ - 206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0\ - 000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c04\ - 0000002a00000000000000 + let expectedString = """ + 7Y1Wg1yHNs8MgWFiFSfcsRtqdMwZg8oGeQnTABYDfyDnof4VSFw63s3PuSxvUCJqqHKgYNVb8UTNcNiYHY8kng4NqT\ + cVV5SA1KAWRzKHVGUxNWioAEXXVot5iJ1XbUWuuZUZBtsraaBjNyfmgWEDje3ESdGhiVL7vadU1uHeBuUKwM3nqB6y\ + oeggeNyzmT34hs9utyehTFg48MAfrKEFKxaby7YZD6JbXFS1SyG1kxKWnCpoPgX3efwDwukmyDwxrKdABt9eTwmaiX\ + KbTnK1hzBTatNfnJ9ePuWkhWFrjyDrGdx5S5KpybxET2vV9CSpExcD51BA6NPemTpjbhLYnJEzHWBGfYqfxu7p3257\ + NHhpQQrSU56adk4dAQFjEYP """ - XCTAssertEqual(output.encoded.hexString, expectedHexString) + XCTAssertEqual(output.encoded, expectedString) } } diff --git a/tests/Solana/SignerTests.cpp b/tests/Solana/SignerTests.cpp index bb832247d6b..10a83837729 100644 --- a/tests/Solana/SignerTests.cpp +++ b/tests/Solana/SignerTests.cpp @@ -36,13 +36,12 @@ TEST(SolanaSigner, SingleSignTransaction) { expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); - auto expectedHex = - "0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e" - "1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" - "bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000" - "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000001020200010c020000002a00000000000000"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "3p2kzZ1DvquqC6LApPuxpTg5CCDVPqJFokGSnGhnBHrta4uq7S2EyehV1XNUVXp51D69GxGzQZU" + "jikfDzbWBG2aFtG3gHT1QfLzyFKHM4HQtMQMNXqay1NAeiiYZjNhx9UvMX4uAQZ4Q6rx6m2AYfQ" + "7aoMUrejq298q1wBFdtS9XVB5QTiStnzC7zs97FUEK2T4XapjF1519EyFBViTfHpGpnf5bfizDz" + "sW9kYUtRDW1UC2LgHr7npgq5W9TBmHf9hSmRgM9XXucjXLqubNWE7HUMhbKjuBqkirRM"; + ASSERT_EQ(transaction.serialize(), expectedString); const auto additionalPrivateKey = PrivateKey(Base58::bitcoin.decode("96PKHuMPtniu1T74RvUNkbDPXPPRZ8Mg1zXwciCAyaDq")); @@ -97,15 +96,13 @@ TEST(SolanaSigner, MultipleSignTransaction) { expectedSignatures.push_back(expectedSignature1); ASSERT_EQ(transaction.signatures, expectedSignatures); - auto expectedHex = - "0269b92a9c9200611a8860844c834ba572dc1b867593c9ab15316e517b9834e0046fab1668b1bb9bf34d5a948d" - "ca4c46923690ffad3fe8e877ee9c920a0adbbf06db00609388620b50a174c518e240f5de00ac5f019c834aa8bb" - "10d51b73c723e496e4dee8218370a46dde5f834816e3848e32f20baa9b521cfe6ced01f962230b02000103ed69" - "c4e13965c8d4df50c63287b392072333fb4fe2eead3ff926d07ec80a44c41ab9aa05053f7941592cd027d40810" - "96f820b28012aa07d2274b3dfd1cdec30400000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000000010202000104000000" - "00"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "oL2CmkcP9xf2DiU7eo6hh3JdHnX3NGjunheXYo6SjVchzc8LtFJpPs4jccWUd7oPZUPQNTcR7Ee" + "Hn259ror9A7aXgJdP4djhntoD8irF1kuBZCj7pubtoWfiAKzagSL4hChQsTSe7e9jaGtoXu58mP" + "HCMKTz55TLjhdmCj7ixoWRowWEzkrF49MxXnurb4yf6ASru1XdHPFn3DdzkRHgypYwvRM6ci8p2" + "7trQvXFukhWX6qG6JkxqsWYSzACcAAGGWfAxSi63Yx1RxkxGUzyxy5f2thQhWZ6Nx6pR1im65yV" + "YMYPXj94kgtHxXw9h5V4p7xSAwRpmhw4jewYyQVX4jmnfro3gFNdX9AqpqMs4uGHA4rZM"; + ASSERT_EQ(transaction.serialize(), expectedString); } TEST(SolanaSigner, SignUpdateBlockhash) { @@ -133,13 +130,12 @@ TEST(SolanaSigner, SignUpdateBlockhash) { expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); - auto expectedHex = - "01d00c3c7f97e4a22f2c2db7835aa0a524fc115c49f8acc361d724aa40a5e320718793b2648d0efed7227a45a4" - "36276d054aecc32c9d08f1d4b7a96069bee5e507010001032cb8775e08dca27a9b723611f42d474c5e809df576" - "e242816cfee4bfc56835da373109b0e40ba3d915ac3ae2417dfd0544369bf31f5ce6e3b8329cdf4e6b058a0000" - "000000000000000000000000000000000000000000000000000000000000040404040404040404040404040404" - "040404040404040404040404040404040401020200010c020000002a00000000000000"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "62ABadDCoPfGGRnhLoBhfcPekMHyN5ee8DgTY8wD4iwKDjyFAsNbsaahTcqMWxmwa61q9iAGCQB" + "v1bETcYzWsTwLKMVGLoEpwqA84mPjqHyr5sQD5dcghyQiQ1ckYNub9K7s8FspVwwowK8gJG69xe" + "DEaqi7G1zrChBVbQYTmVUwJETyDmP1Vs8QU3CaxBs8qwcxoziU52KWLBpRj9o38QVBdxJtJ7hig" + "hgPKJubfqUfTWdN94PzqEfyPqwoCpFD39nvBn8C5xe1caPKivicg6U7Lzm9s8RYTLCEB"; + ASSERT_EQ(transaction.serialize(), expectedString); } TEST(SolanaSigner, SignRawMessage) { @@ -194,20 +190,16 @@ TEST(SolanaSigner, SignDelegateStake) { expectedSignatures.push_back(expectedSignature); ASSERT_EQ(transaction.signatures, expectedSignatures); - auto expectedHex = - "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" - "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" - "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" - "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" - "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" - "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" - "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" - "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" - "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" - "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" - "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" - "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000070501030405000402000000"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "7gcsGMV8fPkuSDegrBk5KF4eZtmGqdixEr5Kxx7m74nErH5EWxkKcvy5LKg3kqKHLMtzqGXrM8EdVskLu5k6cQUVmz" + "nfd6iGpuDkn4BWi8HaqSoaeL7DCx6QHLUwcyvorfqPkgSaYopY9MeB6MGKS4bKCQi1paP7eEKZj9JgAZTHnpzAuFzq" + "E5dC98MrbThoBmHqfybw1jHssp4NZjrxsuMz4oYcHe837WmnpinE68QEVf9FzuoXKrMDwYZQYogJHUZgxghvMmJu3X" + "VZk7hL1h7SgE9ow2SvvNfAUYfUTuz8N9m6JcXgwmNL51ZweW9F1fekmSKE3vLEAaVvvYFsDxn1gt4bXuTdAMuUDKdH" + "33YMLQr8eEsdUDZUm33KtuE7Ddy84NEg3KbpWAy8T4vkwiLyvoyjmMdzCkMuobyXWQV1rfRk5vTJ4x6dMgznfAeKEq" + "md6xZ2hN8JBmTenP5dsvZCCSCf4G7cUkdndKu552KALqiNHd5msgLJvJKSHmZjFhS43fDCvkG7njF8yaZzWjmAknWU" + "BbV6YaGmD3XmcWfJgvB1zivZJhiMbzopP8Nm5wL5iDbCrSZTGq2tzEsTvje75wv2RtuAcgiicEPTuPAin9fKyMbCpf" + "67pGgWPwH5DwYumMwd8zwoJyuakyqFsFLnBKTvp8pFCijdj7fEhyC31xuMV7crwyrN5X3y7QKCE7PZcBP637YHEPtT" + "vt1ECp4CqBSnvPc8vRD8EMhHe5jRFSDkQriUenEPFc51dTDTJWL26xuiTivktEm6ahHq5d6MPr4NRDvcRG2cZvEgxH" + "BLpKfuB5XL3JfQZ3Nn3B916gaK8owz9Rk2e3"; + ASSERT_EQ(transaction.serialize(), expectedString); } diff --git a/tests/Solana/TWAnySignerTests.cpp b/tests/Solana/TWAnySignerTests.cpp index 998062b9c4c..c8a31c3230b 100644 --- a/tests/Solana/TWAnySignerTests.cpp +++ b/tests/Solana/TWAnySignerTests.cpp @@ -28,13 +28,12 @@ TEST(TWAnySignerSolana, SignTransfer) { Proto::SigningOutput output; ANY_SIGN(input, TWCoinTypeSolana); - auto expectedHex = - "0103d668e8bb74c7664295e2f07c9040ac22a887edae0d628064311ad65e4f9d24b27e30027c87e03b43ae492e" - "1347ea831f342d3a782f034df5ae38d12ae6a00f0100010366c2f508c9c555cacc9fb26d88e88dd54e210bb5a8" - "bce5687f60d7e75c4cd07fc68b3c894c782b05a9c27fc6c66eb14d4e7d31de9086ab7d2129bcb0493afa020000" - "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000001020200010c020000002a00000000000000"; - ASSERT_EQ(hex(output.encoded()), expectedHex); + auto expectedString = + "3p2kzZ1DvquqC6LApPuxpTg5CCDVPqJFokGSnGhnBHrta4uq7S2EyehV1XNUVXp51D69GxGzQZU" + "jikfDzbWBG2aFtG3gHT1QfLzyFKHM4HQtMQMNXqay1NAeiiYZjNhx9UvMX4uAQZ4Q6rx6m2AYfQ" + "7aoMUrejq298q1wBFdtS9XVB5QTiStnzC7zs97FUEK2T4XapjF1519EyFBViTfHpGpnf5bfizDz" + "sW9kYUtRDW1UC2LgHr7npgq5W9TBmHf9hSmRgM9XXucjXLqubNWE7HUMhbKjuBqkirRM"; + ASSERT_EQ(output.encoded(), expectedString); } TEST(TWAnySignerSolana, SignDelegateStakeTransaction) { @@ -50,22 +49,18 @@ TEST(TWAnySignerSolana, SignDelegateStakeTransaction) { Proto::SigningOutput output; ANY_SIGN(input, TWCoinTypeSolana); - auto expectedHex = - "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" - "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" - "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" - "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" - "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" - "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" - "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" - "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" - "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" - "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" - "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" - "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000070501030405000402000000"; - ASSERT_EQ(hex(output.encoded()), expectedHex); + auto expectedString = + "7gcsGMV8fPkuSDegrBk5KF4eZtmGqdixEr5Kxx7m74nErH5EWxkKcvy5LKg3kqKHLMtzqGXrM8EdVskLu5k6cQUVmz" + "nfd6iGpuDkn4BWi8HaqSoaeL7DCx6QHLUwcyvorfqPkgSaYopY9MeB6MGKS4bKCQi1paP7eEKZj9JgAZTHnpzAuFzq" + "E5dC98MrbThoBmHqfybw1jHssp4NZjrxsuMz4oYcHe837WmnpinE68QEVf9FzuoXKrMDwYZQYogJHUZgxghvMmJu3X" + "VZk7hL1h7SgE9ow2SvvNfAUYfUTuz8N9m6JcXgwmNL51ZweW9F1fekmSKE3vLEAaVvvYFsDxn1gt4bXuTdAMuUDKdH" + "33YMLQr8eEsdUDZUm33KtuE7Ddy84NEg3KbpWAy8T4vkwiLyvoyjmMdzCkMuobyXWQV1rfRk5vTJ4x6dMgznfAeKEq" + "md6xZ2hN8JBmTenP5dsvZCCSCf4G7cUkdndKu552KALqiNHd5msgLJvJKSHmZjFhS43fDCvkG7njF8yaZzWjmAknWU" + "BbV6YaGmD3XmcWfJgvB1zivZJhiMbzopP8Nm5wL5iDbCrSZTGq2tzEsTvje75wv2RtuAcgiicEPTuPAin9fKyMbCpf" + "67pGgWPwH5DwYumMwd8zwoJyuakyqFsFLnBKTvp8pFCijdj7fEhyC31xuMV7crwyrN5X3y7QKCE7PZcBP637YHEPtT" + "vt1ECp4CqBSnvPc8vRD8EMhHe5jRFSDkQriUenEPFc51dTDTJWL26xuiTivktEm6ahHq5d6MPr4NRDvcRG2cZvEgxH" + "BLpKfuB5XL3JfQZ3Nn3B916gaK8owz9Rk2e3"; + ASSERT_EQ(output.encoded(), expectedString); } TEST(TWAnySignerSolana, SignDeactivateStakeTransaction) { @@ -80,14 +75,12 @@ TEST(TWAnySignerSolana, SignDeactivateStakeTransaction) { Proto::SigningOutput output; ANY_SIGN(input, TWCoinTypeSolana); - auto expectedHex = - "01f8edf7c745a5ac56682800b79ca94a2ca890e642f391b90e4f130119254d3b5e61bdec185b3650c5ec4e9b63" - "dd62b553809d9a960b947e7c0c4ad1b23a2cba07010002040eba44e56f060007284dc037275a15094c1d6c0697" - "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" - "d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a1d8179137542a983437bdfe2a7a" - "b2557f535c8a78722b68a49dc00000000000000000000000000000000000000000000000000000000000000000" - "000000000103030102000405000000"; - ASSERT_EQ(hex(output.encoded()), expectedHex); + auto expectedString = + "AhfB77PTGTKBfbGPGuEz2khbBy8m8Kou1zqZST9dP7PLJNSeEze5NJuCh5qecPLa3S8xAQ6mTULmnAWiW81ib87nhy" + "wFtx5nKiUvmhdXsvKCSX6NNtNXdRz5yZi3UEop4obco85SY2czS6n4SJwmtDedHLtg9urqdZVth7AUM8KAtrRsksyv" + "ZRYXh64Z8QGyNY7ekj31ae11avGiSDNWYZZHqx7VPWRsKeatGyGk5zPmnRdL8ABMQgJ1Te7wAWwVnNn5QcoAxDuPw6" + "uDctP8Q5S4TieRVatCnukQFj5BTJisez3E2ZJPWhVrMh4K3wEFkPHA7dR"; + ASSERT_EQ(output.encoded(), expectedString); } TEST(TWAnySignerSolana, SignWithdrawStakeTransaction) { @@ -103,13 +96,11 @@ TEST(TWAnySignerSolana, SignWithdrawStakeTransaction) { Proto::SigningOutput output; ANY_SIGN(input, TWCoinTypeSolana); - auto expectedHex = - "015f5eb11f1e3416c38d30bc9d966948ff58dc56849bf4b58e2538e2ab3bd7e951aeca5a317518dee81da76025" - "471435257cde34a5d8ed8745e4abd7c7d3d9af0d010003050eba44e56f060007284dc037275a15094c1d6c0697" - "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" - "d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13" - "206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0" - "000000000000000000000000000000000000000000000000000000000000000000000000010404010002030c04" - "0000002a00000000000000"; - ASSERT_EQ(hex(output.encoded()), expectedHex); + auto expectedString = + "7Y1Wg1yHNs8MgWFiFSfcsRtqdMwZg8oGeQnTABYDfyDnof4VSFw63s3PuSxvUCJqqHKgYNVb8UTNcNiYHY8kng4NqT" + "cVV5SA1KAWRzKHVGUxNWioAEXXVot5iJ1XbUWuuZUZBtsraaBjNyfmgWEDje3ESdGhiVL7vadU1uHeBuUKwM3nqB6y" + "oeggeNyzmT34hs9utyehTFg48MAfrKEFKxaby7YZD6JbXFS1SyG1kxKWnCpoPgX3efwDwukmyDwxrKdABt9eTwmaiX" + "KbTnK1hzBTatNfnJ9ePuWkhWFrjyDrGdx5S5KpybxET2vV9CSpExcD51BA6NPemTpjbhLYnJEzHWBGfYqfxu7p3257" + "NHhpQQrSU56adk4dAQFjEYP"; + ASSERT_EQ(output.encoded(), expectedString); } diff --git a/tests/Solana/TransactionTests.cpp b/tests/Solana/TransactionTests.cpp index 4809693d058..635e87f32a3 100644 --- a/tests/Solana/TransactionTests.cpp +++ b/tests/Solana/TransactionTests.cpp @@ -40,13 +40,12 @@ TEST(SolanaTransaction, TransferSerializeTransaction) { transaction.signatures.clear(); transaction.signatures.push_back(signature); - auto expectedHex = - "019abda83fb68c77c698cba9ae8e7c21b06cbe39aca3bb34deb3dbcd061683bd47371d2eec06417e203ee19d88" - "672819ee3319e7089ee0117128d95bf5ba57460c010001032cb8775e08dca27a9b723611f42d474c5e809df576" - "e242816cfee4bfc56835da373109b0e40ba3d915ac3ae2417dfd0544369bf31f5ce6e3b8329cdf4e6b058a0000" - "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000001020200010c020000002a00000000000000"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "5SiHeYyuDgjHxWHbYXSSPfmYc8s7EYZ8bdZ7j15z9Bj1yyZA3Bia9uWkRdXVkuqifXiiQj6fVKy" + "7UkCL5kvv6iKrfjWTZ3szMVssTFxgJ7p8UJ7Mgg2uhHejVJvbzbiHHLbNVuJFs6kBxddnJ2yjWU" + "Cp2dYJgjmphfA8hRHHdPH4Rv6znxEhD8q9XY4nByRPL7oMCo32oxeJn5rGbUZdCkapRUXG7zU9w" + "hv6KjBktcUQZRCahhowGJT4UM5yCNCsUcqY9yan7UxqPyJgaFPuq4duqWJtQ39bTQ36X"; + ASSERT_EQ(transaction.serialize(), expectedString); } TEST(SolanaTransaction, StakeSerializeTransaction) { @@ -62,20 +61,16 @@ TEST(SolanaTransaction, StakeSerializeTransaction) { transaction.signatures.clear(); transaction.signatures.push_back(signature); - auto expectedHex = - "01a9ec9c553c565d232ac98892a1d926ccedb50b85ea227f3d2acef5a5e203573de157d843e578f0c01f2d9f83" - "dd70e6adcc396ee474626e3168bb6b93176be602010006080eba44e56f060007284dc037275a15094c1d6c0697" - "ddb28b2be661dfb0f4bab857a6b8aba83da905fff9c3e62acc748cf497bd503f11b7f9c337b7f35346df0306a7" - "d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000378ba8d9f9881e9be69cf1d70ee0a9" - "3ed0378b83203f42fa29f9df5c887f1c0d06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b21" - "0000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d100000000000000000000000000" - "000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78" - "722b68a49dc0000000000000000000000000000000000000000000000000000000000000000000000000030602" - "00017c030000000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab8200000000000" - "0000346a707754717431715a6f52377536753633397a32416e675946474e336e616b2a00000000000000d80700" - "000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000702010274000000" - "000eba44e56f060007284dc037275a15094c1d6c0697ddb28b2be661dfb0f4bab80eba44e56f060007284dc037" - "275a15094c1d6c0697ddb28b2be661dfb0f4bab800000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000070501030405000402000000"; - ASSERT_EQ(hex(transaction.serialize()), expectedHex); + auto expectedString = + "7gcsGMV8fPkuSDegrBk5KF4eZtmGqdixEr5Kxx7m74nErH5EWxkKcvy5LKg3kqKHLMtzqGXrM8EdVskLu5k6cQUVmz" + "nfd6iGpuDkn4BWi8HaqSoaeL7DCx6QHLUwcyvorfqPkgSaYopY9MeB6MGKS4bKCQi1paP7eEKZj9JgAZTHnpzAuFzq" + "E5dC98MrbThoBmHqfybw1jHssp4NZjrxsuMz4oYcHe837WmnpinE68QEVf9FzuoXKrMDwYZQYogJHUZgxghvMmJu3X" + "VZk7hL1h7SgE9ow2SvvNfAUYfUTuz8N9m6JcXgwmNL51ZweW9F1fekmSKE3vLEAaVvvYFsDxn1gt4bXuTdAMuUDKdH" + "33YMLQr8eEsdUDZUm33KtuE7Ddy84NEg3KbpWAy8T4vkwiLyvoyjmMdzCkMuobyXWQV1rfRk5vTJ4x6dMgznfAeKEq" + "md6xZ2hN8JBmTenP5dsvZCCSCf4G7cUkdndKu552KALqiNHd5msgLJvJKSHmZjFhS43fDCvkG7njF8yaZzWjmAknWU" + "BbV6YaGmD3XmcWfJgvB1zivZJhiMbzopP8Nm5wL5iDbCrSZTGq2tzEsTvje75wv2RtuAcgiicEPTuPAin9fKyMbCpf" + "67pGgWPwH5DwYumMwd8zwoJyuakyqFsFLnBKTvp8pFCijdj7fEhyC31xuMV7crwyrN5X3y7QKCE7PZcBP637YHEPtT" + "vt1ECp4CqBSnvPc8vRD8EMhHe5jRFSDkQriUenEPFc51dTDTJWL26xuiTivktEm6ahHq5d6MPr4NRDvcRG2cZvEgxH" + "BLpKfuB5XL3JfQZ3Nn3B916gaK8owz9Rk2e3"; + ASSERT_EQ(transaction.serialize(), expectedString); } From 113d5566072b5f70a276d6fd95690e3b820dc1b2 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 4 Mar 2020 12:41:16 -0700 Subject: [PATCH 3/3] Update coin info --- coins.json | 6 +++--- tests/Solana/TWCoinTypeTests.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coins.json b/coins.json index 63b7547b798..ce5f36a5e3b 100644 --- a/coins.json +++ b/coins.json @@ -1113,7 +1113,7 @@ "id": "solana", "name": "Solana", "symbol": "SOL", - "decimals": 13, + "decimals": 10, "blockchain": "Solana", "derivationPath": "m/44'/501'/0'", "curve": "ed25519", @@ -1126,8 +1126,8 @@ "info": { "url": "https://solana.com", "client": "https://github.com/solana-labs/solana", - "clientPublic": "http://api.mainnet.solana.com", - "clientDocs": "https://solana-labs.github.io/book/" + "clientPublic": "https://api.mainnet-beta.solana.com", + "clientDocs": "https://docs.solana.com" } }, { diff --git a/tests/Solana/TWCoinTypeTests.cpp b/tests/Solana/TWCoinTypeTests.cpp index 713c8d594c3..7d6b28e5671 100644 --- a/tests/Solana/TWCoinTypeTests.cpp +++ b/tests/Solana/TWCoinTypeTests.cpp @@ -21,7 +21,7 @@ TEST(TWSolanaCoinType, TWCoinType) { auto id = WRAPS(TWCoinTypeConfigurationGetID(TWCoinTypeSolana)); auto name = WRAPS(TWCoinTypeConfigurationGetName(TWCoinTypeSolana)); - ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(TWCoinTypeSolana), 13); + ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(TWCoinTypeSolana), 10); ASSERT_EQ(TWBlockchainSolana, TWCoinTypeBlockchain(TWCoinTypeSolana)); ASSERT_EQ(0x0, TWCoinTypeP2shPrefix(TWCoinTypeSolana)); ASSERT_EQ(0x0, TWCoinTypeStaticPrefix(TWCoinTypeSolana));