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 69dd91abada..635d615734a 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 @@ -26,7 +26,7 @@ class TestTheOpenNetworkSigner { val transfer = TheOpenNetwork.Transfer.newBuilder() .setDest("EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q") - .setAmount(10) + .setAmount(ByteString.copyFrom("0A".toHexByteArray())) // 10 .setMode(TheOpenNetwork.SendMode.PAY_FEES_SEPARATELY_VALUE or TheOpenNetwork.SendMode.IGNORE_ACTION_PHASE_ERRORS_VALUE) .setBounceable(true) .build() @@ -52,15 +52,15 @@ class TestTheOpenNetworkSigner { val privateKey = PrivateKey("c054900a527538c1b4325688a421c0469b171c29f23a62da216e90b0df2412ee".toHexByteArray()) val jettonTransfer = TheOpenNetwork.JettonTransfer.newBuilder() - .setJettonAmount(500 * 1000 * 1000) + .setJettonAmount(ByteString.copyFrom("1DCD6500".toHexByteArray())) // 500 * 1000 * 1000 .setToOwner("EQAFwMs5ha8OgZ9M4hQr80z9NkE7rGxUpE1hCFndiY6JnDx8") .setResponseAddress("EQBaKIMq5Am2p_rfR1IFTwsNWHxBkOpLTmwUain5Fj4llTXk") - .setForwardAmount(1) + .setForwardAmount(ByteString.copyFrom("01".toHexByteArray())) // 1 .build() val transfer = TheOpenNetwork.Transfer.newBuilder() .setDest("EQBiaD8PO1NwfbxSkwbcNT9rXDjqhiIvXWymNO-edV0H5lja") - .setAmount(100 * 1000 * 1000) + .setAmount(ByteString.copyFrom("05F5E100".toHexByteArray())) // 100 * 1000 * 1000 .setMode(TheOpenNetwork.SendMode.PAY_FEES_SEPARATELY_VALUE or TheOpenNetwork.SendMode.IGNORE_ACTION_PHASE_ERRORS_VALUE) .setComment("test comment") .setBounceable(true) @@ -100,7 +100,7 @@ class TestTheOpenNetworkSigner { val transfer = TheOpenNetwork.Transfer.newBuilder() .setDest(dogeChatbotDeployingAddress) // 0.069 TON - .setAmount(69_000_000) + .setAmount(ByteString.copyFrom("041CDB40".toHexByteArray())) // 69_000_000 .setMode(TheOpenNetwork.SendMode.PAY_FEES_SEPARATELY_VALUE or TheOpenNetwork.SendMode.IGNORE_ACTION_PHASE_ERRORS_VALUE) .setBounceable(false) .setStateInit(dogeChatbotStateInit) diff --git a/rust/chains/tw_ton/src/signing_request/builder.rs b/rust/chains/tw_ton/src/signing_request/builder.rs index 167fd290895..59acc26baf3 100644 --- a/rust/chains/tw_ton/src/signing_request/builder.rs +++ b/rust/chains/tw_ton/src/signing_request/builder.rs @@ -116,9 +116,13 @@ impl SigningRequestBuilder { PayloadType::None => None, }; + let ton_amount = U256::from_big_endian_slice(input.amount.as_ref()) + .tw_err(SigningErrorType::Error_invalid_params) + .context("Invalid 'amount'")?; + Ok(TransferRequest { dest, - ton_amount: U256::from(input.amount), + ton_amount, mode, comment, state_init, @@ -141,13 +145,21 @@ impl SigningRequestBuilder { Some(input.custom_payload.to_string()) }; + let jetton_amount = U256::from_big_endian_slice(input.jetton_amount.as_ref()) + .tw_err(SigningErrorType::Error_invalid_params) + .context("Invalid 'jetton_amount'")?; + + let forward_ton_amount = U256::from_big_endian_slice(input.forward_amount.as_ref()) + .tw_err(SigningErrorType::Error_invalid_params) + .context("Invalid 'forward_amount'")?; + let jetton_payload = JettonTransferRequest { query_id: input.query_id, - jetton_amount: U256::from(input.jetton_amount), + jetton_amount, dest, response_address, custom_payload, - forward_ton_amount: U256::from(input.forward_amount), + forward_ton_amount, }; Ok(TransferPayload::JettonTransfer(jetton_payload)) diff --git a/rust/tw_tests/tests/chains/ton/ton_compile.rs b/rust/tw_tests/tests/chains/ton/ton_compile.rs index b13d6fc472e..110edf7f86d 100644 --- a/rust/tw_tests/tests/chains/ton/ton_compile.rs +++ b/rust/tw_tests/tests/chains/ton/ton_compile.rs @@ -6,6 +6,7 @@ use crate::chains::ton::ton_sign::assert_eq_boc; use tw_any_coin::test_utils::sign_utils::{CompilerHelper, PreImageHelper}; use tw_coin_registry::coin_type::CoinType; use tw_encoding::hex::{DecodeHex, ToHex}; +use tw_number::U256; use tw_proto::Common::Proto::SigningError; use tw_proto::TheOpenNetwork::Proto; use tw_proto::TxCompiler::Proto as CompilerProto; @@ -16,7 +17,7 @@ fn test_ton_compile_wallet_v4r2_transfer_and_deploy() { let transfer = Proto::Transfer { dest: "EQDYW_1eScJVxtitoBRksvoV9cCYo4uKGWLVNIHB1JqRR3n0".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -63,7 +64,7 @@ fn test_ton_compile_wallet_v5r1_transfer_and_deploy() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, diff --git a/rust/tw_tests/tests/chains/ton/ton_sign.rs b/rust/tw_tests/tests/chains/ton/ton_sign.rs index 7b5e3024755..00aafeef940 100644 --- a/rust/tw_tests/tests/chains/ton/ton_sign.rs +++ b/rust/tw_tests/tests/chains/ton/ton_sign.rs @@ -8,6 +8,7 @@ use crate::chains::ton::cell_example::{ use tw_any_coin::test_utils::sign_utils::AnySignerHelper; use tw_coin_registry::coin_type::CoinType; use tw_encoding::hex::{DecodeHex, ToHex}; +use tw_number::U256; use tw_proto::Common::Proto::SigningError; use tw_proto::TheOpenNetwork::Proto; use tw_proto::TheOpenNetwork::Proto::mod_Transfer::OneOfpayload as PayloadType; @@ -30,7 +31,7 @@ fn test_ton_sign_transfer_and_deploy() { let transfer = Proto::Transfer { dest: "EQDYW_1eScJVxtitoBRksvoV9cCYo4uKGWLVNIHB1JqRR3n0".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -65,7 +66,7 @@ fn test_ton_sign_transfer_and_deploy_4b1d9f() { let transfer = Proto::Transfer { dest: "UQA6whN_oU5h9jPljnlDSWRYQNDPkLaUqqaEWULNB_Zoykuu".into(), // 0.0001 TON - amount: 100_000, + amount: U256::encode_be_compact(100_000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -98,7 +99,7 @@ fn test_ton_sign_transfer_ordinary() { let transfer = Proto::Transfer { dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -132,7 +133,7 @@ fn test_ton_sign_transfer_all_balance() { let transfer = Proto::Transfer { dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q".into(), - amount: 0, + amount: U256::encode_be_compact(0), mode: Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -166,7 +167,7 @@ fn test_ton_sign_transfer_all_balance_non_bounceable() { let transfer = Proto::Transfer { dest: "UQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts4DV".into(), - amount: 0, + amount: U256::encode_be_compact(0), mode: Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: false, @@ -200,7 +201,7 @@ fn test_ton_sign_transfer_with_ascii_comment() { let transfer = Proto::Transfer { dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -235,7 +236,7 @@ fn test_ton_sign_transfer_with_utf8_comment() { let transfer = Proto::Transfer { dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -270,7 +271,7 @@ fn test_ton_sign_transfer_invalid_wallet_version() { let transfer = Proto::Transfer { dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -298,17 +299,17 @@ fn test_ton_sign_transfer_jettons() { let jetton_transfer = Proto::JettonTransfer { query_id: 69, // Transfer 1 testtwt (decimal precision is 9). - jetton_amount: 1000 * 1000 * 1000, + jetton_amount: U256::encode_be_compact(1000 * 1000 * 1000), to_owner: "EQAFwMs5ha8OgZ9M4hQr80z9NkE7rGxUpE1hCFndiY6JnDx8".into(), // Send unused toncoins back to sender. response_address: "EQBaKIMq5Am2p_rfR1IFTwsNWHxBkOpLTmwUain5Fj4llTXk".into(), - forward_amount: 1, + forward_amount: U256::encode_be_compact(1), ..Proto::JettonTransfer::default() }; let transfer = Proto::Transfer { dest: "EQBiaD8PO1NwfbxSkwbcNT9rXDjqhiIvXWymNO-edV0H5lja".into(), - amount: 100 * 1000 * 1000, + amount: U256::encode_be_compact(100 * 1000 * 1000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -344,17 +345,17 @@ fn test_ton_sign_transfer_jettons_with_comment() { let jetton_transfer = Proto::JettonTransfer { query_id: 0, // Transfer 0.5 testtwt (decimal precision is 9). - jetton_amount: 500 * 1000 * 1000, + jetton_amount: U256::encode_be_compact(500 * 1000 * 1000), to_owner: "EQAFwMs5ha8OgZ9M4hQr80z9NkE7rGxUpE1hCFndiY6JnDx8".into(), // Send unused toncoins back to sender. response_address: "EQBaKIMq5Am2p_rfR1IFTwsNWHxBkOpLTmwUain5Fj4llTXk".into(), - forward_amount: 1, + forward_amount: U256::encode_be_compact(1), ..Proto::JettonTransfer::default() }; let transfer = Proto::Transfer { dest: "EQBiaD8PO1NwfbxSkwbcNT9rXDjqhiIvXWymNO-edV0H5lja".into(), - amount: 100 * 1000 * 1000, + amount: U256::encode_be_compact(100 * 1000 * 1000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -392,7 +393,7 @@ fn test_ton_sign_transfer_custom_payload() { let transfer = Proto::Transfer { dest: "UQA6whN_oU5h9jPljnlDSWRYQNDPkLaUqqaEWULNB_Zoykuu".into(), // 0.00025 TON - amount: 250_000, + amount: U256::encode_be_compact(250_000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -443,7 +444,7 @@ fn test_ton_sign_transfer_custom_payload_with_state_init() { let transfer = Proto::Transfer { dest: doge_contract_address.into(), // 0.069 TON - amount: 69_000_000, + amount: U256::encode_be_compact(69_000_000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: false, diff --git a/rust/tw_tests/tests/chains/ton/ton_sign_wallet_v5r1.rs b/rust/tw_tests/tests/chains/ton/ton_sign_wallet_v5r1.rs index f6c8a5ec3eb..e45dec25ea6 100644 --- a/rust/tw_tests/tests/chains/ton/ton_sign_wallet_v5r1.rs +++ b/rust/tw_tests/tests/chains/ton/ton_sign_wallet_v5r1.rs @@ -9,6 +9,7 @@ use crate::chains::ton::ton_sign::assert_eq_boc; use tw_any_coin::test_utils::sign_utils::AnySignerHelper; use tw_coin_registry::coin_type::CoinType; use tw_encoding::hex::{DecodeHex, ToHex}; +use tw_number::U256; use tw_proto::Common::Proto::SigningError; use tw_proto::TheOpenNetwork::Proto; use tw_proto::TheOpenNetwork::Proto::mod_Transfer::OneOfpayload as PayloadType; @@ -19,7 +20,7 @@ fn test_ton_sign_wallet_v5r1_transfer_and_deploy() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -52,7 +53,7 @@ fn test_ton_sign_wallet_v5r1_transfer_ordinary() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -87,7 +88,7 @@ fn test_ton_sign_wallet_v5r1_transfer_all_balance() { let transfer = Proto::Transfer { dest: "UQAU3o5-Sp1MYRpw3U7b_wmARxqI49LxiFhEoVCxpUKjTYXk".into(), - amount: 0, + amount: U256::encode_be_compact(0), mode: Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -121,7 +122,7 @@ fn test_ton_sign_wallet_v5r1_transfer_all_balance_non_bounceable() { let transfer = Proto::Transfer { dest: "UQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQa2r".into(), - amount: 0, + amount: U256::encode_be_compact(0), mode: Proto::SendMode::ATTACH_ALL_CONTRACT_BALANCE as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: false, @@ -155,7 +156,7 @@ fn test_ton_sign_wallet_v5r1_transfer_with_ascii_comment() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -190,7 +191,7 @@ fn test_ton_sign_wallet_v5r1_transfer_with_utf8_comment() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -226,17 +227,17 @@ fn test_ton_sign_wallet_v5r1_transfer_jettons() { let jetton_transfer = Proto::JettonTransfer { query_id: 69, // Transfer 0.12 USDT (decimal precision is 6). - jetton_amount: 120000, + jetton_amount: U256::encode_be_compact(120000), to_owner: "UQAU3o5-Sp1MYRpw3U7b_wmARxqI49LxiFhEoVCxpUKjTYXk".into(), // Send unused toncoins back to sender. response_address: "UQCh41gQP1A4I0lnAn6yAfitDAIYpXG6UFIXqeSz1TVxNOJ_".into(), - forward_amount: 1, + forward_amount: U256::encode_be_compact(1), ..Default::default() }; let transfer = Proto::Transfer { dest: "EQDg4AjfaxQBVsUFueenkKlHLhhYWrcBvCEzbEgfrT0nxuGC".into(), - amount: 100 * 1000 * 1000, + amount: U256::encode_be_compact(100 * 1000 * 1000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -272,17 +273,17 @@ fn test_ton_sign_wallet_v5r1_transfer_jettons_with_comment() { let jetton_transfer = Proto::JettonTransfer { query_id: 0, // Transfer 0.11 USDT (decimal precision is 6). - jetton_amount: 110000, + jetton_amount: U256::encode_be_compact(110000), to_owner: "UQAU3o5-Sp1MYRpw3U7b_wmARxqI49LxiFhEoVCxpUKjTYXk".into(), // Send unused toncoins back to sender. response_address: "UQCh41gQP1A4I0lnAn6yAfitDAIYpXG6UFIXqeSz1TVxNOJ_".into(), - forward_amount: 1, + forward_amount: U256::encode_be_compact(1), ..Default::default() }; let transfer = Proto::Transfer { dest: "EQDg4AjfaxQBVsUFueenkKlHLhhYWrcBvCEzbEgfrT0nxuGC".into(), - amount: 100 * 1000 * 1000, + amount: U256::encode_be_compact(100 * 1000 * 1000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -320,7 +321,7 @@ fn test_ton_sign_wallet_v5r1_transfer_custom_payload() { let transfer = Proto::Transfer { dest: "UQAU3o5-Sp1MYRpw3U7b_wmARxqI49LxiFhEoVCxpUKjTYXk".into(), // 0.00025 TON - amount: 250_000, + amount: U256::encode_be_compact(250_000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, @@ -371,7 +372,7 @@ fn test_ton_sign_wallet_v5r1_transfer_custom_payload_with_state_init() { let transfer = Proto::Transfer { dest: doge_contract_address.into(), // 0.0069 TON - amount: 6_900_000, + amount: U256::encode_be_compact(6_900_000), mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: false, @@ -409,7 +410,7 @@ fn test_ton_sign_wallet_v5r1_missing_required_send_mode() { let transfer = Proto::Transfer { dest: "EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu".into(), - amount: 10, + amount: U256::encode_be_compact(10), // Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS is required for wallet v5r1 external messages. mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32, bounceable: true, @@ -438,17 +439,17 @@ fn test_ton_sign_wallet_v5r1_mintless_jetton() { let jetton_transfer = Proto::JettonTransfer { query_id: 1, // Transfer 0 mintless jetton to self. - jetton_amount: 0, + jetton_amount: U256::encode_be_compact(0), to_owner: "UQCh41gQP1A4I0lnAn6yAfitDAIYpXG6UFIXqeSz1TVxNOJ_".into(), // Send unused toncoins back to sender. response_address: "UQCh41gQP1A4I0lnAn6yAfitDAIYpXG6UFIXqeSz1TVxNOJ_".into(), - forward_amount: 1, + forward_amount: U256::encode_be_compact(1), custom_payload: "te6ccgECNQEABJMAAQgN9gLWAQlGA6+1FWXC4ss/wvDOFwMk2bVM97AUEWqaUhh63uWfQ26nAB4CIgWBcAIDBChIAQEZG2ZqtEYGAq27TvzHdGuGrhhKoICBU+Zg9Xq/qRMHGAAdIgEgBQYiASAHCChIAQEV0tdPcZG01smq0thhsmqf9ZzE0QqpP3c+ERvuHF1JDgAbKEgBAf3dO8qdKoPys7AWvavs1wMNWCOq5XashXaRopmksx/LABsiASAJCiIBIAsMKEgBAWP0xUs9JBrfQRl1FkF2tIfIDYpwLdf3fXqMi6BqxNtmABoiASANDihIAQFOErI5E7ld/nTAgHXdGI74UH8kxIaFyAkH42P54tEC9QAYIgEgDxAoSAEBrF16Czdlg18FB467CrR6Ucwxb8H+Z1e4qDeFWbkz1WEAFyIBIBESKEgBAXeWzg9xTFO6z0FP+axi8Njuxxp0zPrAUs4vnmt/dE3xABYoSAEBEZ7KazNpaWJoInmqO4II/AfncyhMNWxh6BE2qFU7/9wAFCIBIBMUKEgBAZleZTNXbgCF+8G08kiQeDPanQtNCVakzEU3g9GKB+K2ABQiASAVFihIAQFeCM83J7sm36g24qFeEDvStahHWn6SsEk+Wii49rzBiAASIgEgFxgoSAEBfV9jrgSeiAKVqeeLliXdoLrxFWe2HK0f4SG5h4kfb8YAESIBIBkaIgEgGxwoSAEBImHhXIbOHuOnOgE5f0KLqoXDB7/ZLQQGiHysuulUq2IAECIBIB0eKEgBAXT+qb5w1+qtvbJ1Fbn8y6IhO85YfxKIgKBga6ROO/yQAA8iASAfIChIAQGoJHXWXWRQGZdP9xIUrMowhvgnf+CwKTIIOBxlDiKgcAANKEgBAZ6tCuDr89HFRz3WwwK+wW4XmkE+O7Hf+NgUDI+uqnAJAAwiASAhIihIAQHtasTLBAw7MZHpRTsKyC47E1PZ/LAtF3n2Y2b5ThX0VgALIgEgIyQiASAlJihIAQGumGRf7UXrpK12Cuvj06565IC0Kbd4i2XoG6dnqC+uQAAJKEgBAXM19HUUkz6ns7o/2x45kQ2iLj8gl3zYhrAhISEUg0O1AAgiASAnKCIBICkqKEgBAa7kNA+lev+Z5T/xqKBbO648BvnLL6/hAp1auOiZTWRhAAcoSAEBxn19AKZGAUPYWs8pTpNQrCB4Ap0KfzyjOgB1Mc9PbIUABSIBICssKEgBAWarrCPqSS6+lq6NRcrWZ2/v6bN4b6Zd3GWAtN6j8a6BAAQiASAtLiIBIC8wKEgBAXYYqhLZ1tHg+HdKd8vLmTBsojkj61ZiafXB7pOt+hEFAAMiASAxMihIAQHt8p6qBiXtz+kKcgo13Udyh7Uo8irrdKlSSY2dOdALogAAIgFIMzQoSAEByacrlqsAKiFOlv4Rp4V1gNg2i4aVPkcHJq8Vug/89k4AAABduZA/UDgjSWcCfrIB+K0MAhilcbpQUhep5LPVNXE0Q7msoAAABm4N2AAABm9VrQgoSAEByIAktH0CNxT//QZ8Vgj68CApZON9XBKDfE0D2rY8Fx4AAA==".into() }; let transfer = Proto::Transfer { dest: "UQCn2lssMz09Gn60mBnv544DgiqIX3mK5cqGEPEPKxCNbE0E".into(), // jetton wallet address - amount: 90 * 1000 * 1000, // 0.09 TON as fee + amount: U256::encode_be_compact(90 * 1000 * 1000), // 0.09 TON as fee mode: Proto::SendMode::PAY_FEES_SEPARATELY as u32 | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS as u32, bounceable: true, diff --git a/src/proto/TheOpenNetwork.proto b/src/proto/TheOpenNetwork.proto index 4ef1ca11ac4..afcd7154286 100644 --- a/src/proto/TheOpenNetwork.proto +++ b/src/proto/TheOpenNetwork.proto @@ -30,7 +30,8 @@ message Transfer { string dest = 1; // Amount to send in nanotons - uint64 amount = 2; + // uint128 / big endian byte order + bytes amount = 2; // Send mode (optional, 0 by default) // Learn more: https://ton.org/docs/develop/func/stdlib#send_raw_message @@ -61,7 +62,8 @@ message JettonTransfer { uint64 query_id = 1; // Amount of transferred jettons in elementary integer units. The real value transferred is jetton_amount multiplied by ten to the power of token decimal precision - uint64 jetton_amount = 2; + // uint128 / big endian byte order + bytes jetton_amount = 2; // Address of the new owner of the jettons. string to_owner = 3; @@ -70,7 +72,8 @@ message JettonTransfer { string response_address = 4; // Amount in nanotons to forward to recipient. Basically minimum amount - 1 nanoton should be used - uint64 forward_amount = 5; + // uint128 / big endian byte order + bytes forward_amount = 5; // Optional raw one-cell BoC encoded in Base64. // Can be used in the case of mintless jetton transfers. diff --git a/swift/Tests/Blockchains/TheOpenNetworkTests.swift b/swift/Tests/Blockchains/TheOpenNetworkTests.swift index 797ae8334e0..841d79e54dd 100644 --- a/swift/Tests/Blockchains/TheOpenNetworkTests.swift +++ b/swift/Tests/Blockchains/TheOpenNetworkTests.swift @@ -83,7 +83,7 @@ class TheOpenNetworkTests: XCTestCase { let transfer = TheOpenNetworkTransfer.with { $0.dest = "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q" - $0.amount = 10 + $0.amount = Data(hexString: "0A")! $0.mode = UInt32(TheOpenNetworkSendMode.payFeesSeparately.rawValue | TheOpenNetworkSendMode.ignoreActionPhaseErrors.rawValue) $0.bounceable = true } @@ -108,15 +108,15 @@ class TheOpenNetworkTests: XCTestCase { let privateKeyData = Data(hexString: "c054900a527538c1b4325688a421c0469b171c29f23a62da216e90b0df2412ee")! let jettonTransfer = TheOpenNetworkJettonTransfer.with { - $0.jettonAmount = 500 * 1000 * 1000 + $0.jettonAmount = Data(hexString: "1DCD6500")! //500 * 1000 * 1000 $0.toOwner = "EQAFwMs5ha8OgZ9M4hQr80z9NkE7rGxUpE1hCFndiY6JnDx8" $0.responseAddress = "EQBaKIMq5Am2p_rfR1IFTwsNWHxBkOpLTmwUain5Fj4llTXk" - $0.forwardAmount = 1 + $0.forwardAmount = Data(hexString: "01")!; } let transfer = TheOpenNetworkTransfer.with { $0.dest = "EQBiaD8PO1NwfbxSkwbcNT9rXDjqhiIvXWymNO-edV0H5lja" - $0.amount = 100 * 1000 * 1000 + $0.amount = Data(hexString: "05F5E100")! //100 * 1000 * 1000 $0.mode = UInt32(TheOpenNetworkSendMode.payFeesSeparately.rawValue | TheOpenNetworkSendMode.ignoreActionPhaseErrors.rawValue) $0.comment = "test comment" $0.bounceable = true @@ -156,7 +156,7 @@ class TheOpenNetworkTests: XCTestCase { let transfer = TheOpenNetworkTransfer.with { $0.dest = dogeChatbotDeployingAddress // 0.069 TON - $0.amount = 69_000_000 + $0.amount = Data(hexString: "041CDB40")! //69_000_000 $0.mode = UInt32(TheOpenNetworkSendMode.payFeesSeparately.rawValue | TheOpenNetworkSendMode.ignoreActionPhaseErrors.rawValue) $0.bounceable = false $0.stateInit = dogeChatbotStateInit diff --git a/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp b/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp index ffd5d276a78..76139adb715 100644 --- a/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp +++ b/tests/chains/TheOpenNetwork/TWAnySignerTests.cpp @@ -8,6 +8,8 @@ #include #include "TestUtilities.h" +#include "uint256.h" + #include namespace TW::TheOpenNetwork::tests { @@ -17,7 +19,10 @@ TEST(TWAnySignerTheOpenNetwork, SignMessageToTransferAndDeployWalletV4R2) { auto& transfer = *input.add_messages(); transfer.set_dest("EQDYW_1eScJVxtitoBRksvoV9cCYo4uKGWLVNIHB1JqRR3n0"); - transfer.set_amount(10); + + Data amountData = store(uint256_t(10)); + std::string amountStr(amountData.begin(), amountData.end()); + transfer.set_amount(amountStr); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_bounceable(true); @@ -42,7 +47,9 @@ TEST(TWAnySignerTheOpenNetwork, SignMessageToTransferAndDeployWalletV5R1) { auto& transfer = *input.add_messages(); transfer.set_dest("EQBe6DtCpJZe8M4t-crMXe93JlEYgSl30S5OUuMSLOfeQfBu"); - transfer.set_amount(10); + Data amountData = store(uint256_t(10)); + std::string amountStr(amountData.begin(), amountData.end()); + transfer.set_amount(amountStr); transfer.set_mode(Proto::SendMode::PAY_FEES_SEPARATELY | Proto::SendMode::IGNORE_ACTION_PHASE_ERRORS); transfer.set_bounceable(true); diff --git a/wasm/tests/Blockchain/TheOpenNetwork.test.ts b/wasm/tests/Blockchain/TheOpenNetwork.test.ts index b96cb551675..da55da7cfca 100644 --- a/wasm/tests/Blockchain/TheOpenNetwork.test.ts +++ b/wasm/tests/Blockchain/TheOpenNetwork.test.ts @@ -72,7 +72,7 @@ describe("TheOpenNetwork", () => { let transfer = TW.TheOpenNetwork.Proto.Transfer.create({ dest: "EQBm--PFwDv1yCeS-QTJ-L8oiUpqo9IT1BwgVptlSq3ts90Q", - amount: new Long(10), + amount: Buffer.from("0A", "hex"), // 10 mode: (TW.TheOpenNetwork.Proto.SendMode.PAY_FEES_SEPARATELY | TW.TheOpenNetwork.Proto.SendMode.IGNORE_ACTION_PHASE_ERRORS), bounceable: true, }); @@ -101,15 +101,15 @@ describe("TheOpenNetwork", () => { let privateKeyData = HexCoding.decode("c054900a527538c1b4325688a421c0469b171c29f23a62da216e90b0df2412ee"); let jettonTransfer = TW.TheOpenNetwork.Proto.JettonTransfer.create({ - jettonAmount: new Long(500 * 1000 * 1000), + jettonAmount: Buffer.from("1DCD6500", "hex"), // 500 * 1000 * 1000, toOwner: "EQAFwMs5ha8OgZ9M4hQr80z9NkE7rGxUpE1hCFndiY6JnDx8", responseAddress: "EQBaKIMq5Am2p_rfR1IFTwsNWHxBkOpLTmwUain5Fj4llTXk", - forwardAmount: new Long(1) + forwardAmount: Buffer.from("01", "hex"), // 1 }); let transfer = TW.TheOpenNetwork.Proto.Transfer.create({ dest: "EQBiaD8PO1NwfbxSkwbcNT9rXDjqhiIvXWymNO-edV0H5lja", - amount: new Long(100 * 1000 * 1000), + amount: Buffer.from("05F5E100", "hex"), // 100 * 1000 * 1000, mode: (TW.TheOpenNetwork.Proto.SendMode.PAY_FEES_SEPARATELY | TW.TheOpenNetwork.Proto.SendMode.IGNORE_ACTION_PHASE_ERRORS), comment: "test comment", bounceable: true,