diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/theopennetwork/TestTheOpenNetworkSigner.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/theopennetwork/TestTheOpenNetworkSigner.kt index fcc1336c954..f229ac373f3 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/theopennetwork/TestTheOpenNetworkSigner.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/theopennetwork/TestTheOpenNetworkSigner.kt @@ -33,6 +33,7 @@ class TestTheOpenNetworkSigner { .setSequenceNumber(6) .setMode(TheOpenNetwork.SendMode.PAY_FEES_SEPARATELY_VALUE or TheOpenNetwork.SendMode.IGNORE_ACTION_PHASE_ERRORS_VALUE) .setExpireAt(1671132440) + .setBounceable(true) .build() val input = TheOpenNetwork.SigningInput.newBuilder() diff --git a/src/TheOpenNetwork/Address.cpp b/src/TheOpenNetwork/Address.cpp index 80caaea58de..28d35e2c40b 100644 --- a/src/TheOpenNetwork/Address.cpp +++ b/src/TheOpenNetwork/Address.cpp @@ -70,7 +70,7 @@ bool Address::isValid(const std::string& string) noexcept { return true; } -Address::Address(const std::string& string) { +Address::Address(const std::string& string, std::optional bounceable) { if (!Address::isValid(string)) { throw std::invalid_argument("Invalid address string"); } @@ -83,12 +83,16 @@ Address::Address(const std::string& string) { Data decoded = decodeUserFriendlyAddress(string); addressData.workchainId = decoded[1]; - byte tag = decoded[0]; - if (tag & AddressTag::TEST_ONLY) { - isTestOnly = true; - tag ^= AddressTag::TEST_ONLY; + if (!bounceable.has_value()) { + byte tag = decoded[0]; + if (tag & AddressTag::TEST_ONLY) { + isTestOnly = true; + tag ^= AddressTag::TEST_ONLY; + } + isBounceable = (tag == AddressTag::BOUNCEABLE); + } else { + isBounceable = *bounceable; } - isBounceable = (tag == AddressTag::BOUNCEABLE); std::copy(decoded.begin() + 2, decoded.end() - 2, addressData.hash.begin()); } diff --git a/src/TheOpenNetwork/Address.h b/src/TheOpenNetwork/Address.h index a456d261551..de61607cc01 100644 --- a/src/TheOpenNetwork/Address.h +++ b/src/TheOpenNetwork/Address.h @@ -10,6 +10,7 @@ #include "PublicKey.h" #include "Everscale/CommonTON/RawAddress.h" +#include #include @@ -44,7 +45,7 @@ class Address { [[nodiscard]] static bool isValid(const std::string& string) noexcept; /// Initializes an address with a string representation. - explicit Address(const std::string& string); + explicit Address(const std::string& string, std::optional bounceable = std::nullopt); /// Initializes an address with its parts explicit Address( diff --git a/src/TheOpenNetwork/Signer.cpp b/src/TheOpenNetwork/Signer.cpp index a33b01853be..96e69cb872e 100644 --- a/src/TheOpenNetwork/Signer.cpp +++ b/src/TheOpenNetwork/Signer.cpp @@ -16,7 +16,7 @@ namespace TW::TheOpenNetwork { Data Signer::createTransferMessage(std::shared_ptr wallet, const PrivateKey& privateKey, const Proto::Transfer& transfer) { const auto msg = wallet->createTransferMessage( privateKey, - Address(transfer.dest()), + Address(transfer.dest(), transfer.bounceable()), transfer.amount(), transfer.sequence_number(), static_cast(transfer.mode()), diff --git a/src/proto/TheOpenNetwork.proto b/src/proto/TheOpenNetwork.proto index 995bd3d3f82..73017fdb941 100644 --- a/src/proto/TheOpenNetwork.proto +++ b/src/proto/TheOpenNetwork.proto @@ -50,6 +50,9 @@ message Transfer { // Transfer comment message (optional, empty by default) string comment = 7; + + // If the address is bounceable + bool bounceable = 8; } message SigningInput { diff --git a/swift/Tests/Blockchains/TheOpenNetworkTests.swift b/swift/Tests/Blockchains/TheOpenNetworkTests.swift index 506d007fb9d..7508efab6c9 100644 --- a/swift/Tests/Blockchains/TheOpenNetworkTests.swift +++ b/swift/Tests/Blockchains/TheOpenNetworkTests.swift @@ -45,6 +45,7 @@ class TheOpenNetworkTests: XCTestCase { $0.sequenceNumber = 6 $0.mode = UInt32(TheOpenNetworkSendMode.payFeesSeparately.rawValue | TheOpenNetworkSendMode.ignoreActionPhaseErrors.rawValue) $0.expireAt = 1671132440 + $0.bounceable = true } let input = TheOpenNetworkSigningInput.with { diff --git a/tests/chains/TheOpenNetwork/SignerTests.cpp b/tests/chains/TheOpenNetwork/SignerTests.cpp index 3398bf1df5e..44c49f9724a 100644 --- a/tests/chains/TheOpenNetwork/SignerTests.cpp +++ b/tests/chains/TheOpenNetwork/SignerTests.cpp @@ -22,6 +22,7 @@ TEST(TheOpenNetworkSigner, TransferAndDeploy) { transfer.set_amount(10); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1671135440); + transfer.set_bounceable(true); const auto privateKey = parse_hex("63474e5fe9511f1526a50567ce142befc343e71a49b865ac3908f58667319cb8"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -44,6 +45,7 @@ TEST(TheOpenNetworkSigner, TransferOrdinary) { transfer.set_sequence_number(6); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1671132440); + transfer.set_bounceable(true); const auto privateKey = parse_hex("c38f49de2fb13223a9e7d37d5d0ffbdd89a5eb7c8b0ee4d1c299f2cefe7dc4a0"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -66,6 +68,7 @@ TEST(TheOpenNetworkSigner, TransferAllBalance) { transfer.set_sequence_number(7); transfer.set_mode(Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1681102222); + transfer.set_bounceable(true); const auto privateKey = parse_hex("c38f49de2fb13223a9e7d37d5d0ffbdd89a5eb7c8b0ee4d1c299f2cefe7dc4a0"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -88,6 +91,7 @@ TEST(TheOpenNetworkSigner, TransferAllBalanceNonBounceable) { transfer.set_sequence_number(8); transfer.set_mode(Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1681102222); + transfer.set_bounceable(false); const auto privateKey = parse_hex("c38f49de2fb13223a9e7d37d5d0ffbdd89a5eb7c8b0ee4d1c299f2cefe7dc4a0"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -111,6 +115,7 @@ TEST(TheOpenNetworkSigner, TransferWithASCIIComment) { transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1681102222); transfer.set_comment("test comment"); + transfer.set_bounceable(true); const auto privateKey = parse_hex("c38f49de2fb13223a9e7d37d5d0ffbdd89a5eb7c8b0ee4d1c299f2cefe7dc4a0"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -134,6 +139,7 @@ TEST(TheOpenNetworkSigner, TransferWithUTF8Comment) { transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1681102222); transfer.set_comment("тестовый комментарий"); + transfer.set_bounceable(true); const auto privateKey = parse_hex("c38f49de2fb13223a9e7d37d5d0ffbdd89a5eb7c8b0ee4d1c299f2cefe7dc4a0"); input.set_private_key(privateKey.data(), privateKey.size()); @@ -155,6 +161,7 @@ TEST(TheOpenNetworkSigner, InvalidWalletVersion) { transfer.set_amount(10); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1671135440); + transfer.set_bounceable(true); const auto privateKey = parse_hex("63474e5fe9511f1526a50567ce142befc343e71a49b865ac3908f58667319cb8"); input.set_private_key(privateKey.data(), privateKey.size()); diff --git a/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp b/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp index 884e174632b..ee7695a4e9c 100644 --- a/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp +++ b/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp @@ -23,6 +23,7 @@ TEST(TWAnySignerTheOpenNetwork, SingMessageToTransferAndDeployWallet) { transfer.set_amount(10); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_expire_at(1671135440); + transfer.set_bounceable(true); const auto privateKey = parse_hex("63474e5fe9511f1526a50567ce142befc343e71a49b865ac3908f58667319cb8"); input.set_private_key(privateKey.data(), privateKey.size()); diff --git a/wasm/tests/Blockchain/TheOpenNetwork.test.ts b/wasm/tests/Blockchain/TheOpenNetwork.test.ts index 81ce7f523ff..ffbec7723d9 100644 --- a/wasm/tests/Blockchain/TheOpenNetwork.test.ts +++ b/wasm/tests/Blockchain/TheOpenNetwork.test.ts @@ -78,7 +78,8 @@ describe("TheOpenNetwork", () => { amount: new Long(10), sequenceNumber: 6, mode: (TW.TheOpenNetwork.Proto.SendMode.PAY_FEES_SEPARATELY | TW.TheOpenNetwork.Proto.SendMode.IGNORE_ACTION_PHASE_ERRORS), - expireAt: 1671132440 + expireAt: 1671132440, + bounceable: true }); let input = TW.TheOpenNetwork.Proto.SigningInput.create({