Skip to content

Commit

Permalink
Merge branch 'master' into s/kotlin-update-yarn-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan authored Dec 21, 2023
2 parents f2576fe + 949b0c3 commit b9ef4ab
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ class CoinAddressDerivationTests {
CALLISTO -> assertEquals("0x3E6FFC80745E6669135a76F4A7ce6BCF02436e04", address)
DASH -> assertEquals("XqHiz8EXYbTAtBEYs4pWTHh7ipEDQcNQeT", address)
DIGIBYTE -> assertEquals("dgb1qtjgmerfqwdffyf8ghcrkgy52cghsqptynmyswu", address)

ETHEREUM, SMARTCHAIN, POLYGON, OPTIMISM, ZKSYNC, ARBITRUM, ARBITRUMNOVA, ECOCHAIN, AVALANCHECCHAIN, XDAI,
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KLAYTN, METER, OKXCHAIN, POLYGONZKEVM, SCROLL,
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA, GREENFIELD, MANTLE, ZENEON -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA, GREENFIELD, MANTLE, ZENEON, MANTAPACIFIC,
-> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)

RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)
ETHEREUMCLASSIC -> assertEquals("0x078bA3228F3E6C08bEEac9A005de0b7e7089aD1c", address)
GOCHAIN -> assertEquals("0x5940ce4A14210d4Ccd0ac206CE92F21828016aC2", address)
Expand Down
2 changes: 1 addition & 1 deletion codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST(TW{COIN_TYPE}CoinType, TWCoinType) {
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "{COIN_ID}");
assertStringsEqual(name, "{COIN_TYPE}");
assertStringsEqual(name, "{COIN_NAME}");
assertStringsEqual(symbol, "{SYMBOL}");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), {DECIMALS});
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchain{BLOCKCHAIN});
Expand Down
1 change: 1 addition & 0 deletions codegen-v2/src/codegen/template_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl TemplateGenerator {
.add_pattern("{TW_CRATE_NAME}", coin.id.to_tw_crate_name())
.add_pattern("{COIN_ID}", coin.id.as_str())
.add_pattern("{COIN_TYPE}", coin.coin_type())
.add_pattern("{COIN_NAME}", &coin.name)
.add_pattern("{SYMBOL}", &coin.symbol)
.add_pattern("{DECIMALS}", coin.decimals)
.add_pattern("{P2PKH_PREFIX}", coin.p2pkh_prefix)
Expand Down
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This list is generated from [./registry.json](../registry.json)
| 148 | Stellar | XLM | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png" width="32" /> | <https://stellar.org> |
| 156 | Bitcoin Gold | BTG | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoingold/info/logo.png" width="32" /> | <https://bitcoingold.org> |
| 165 | Nano | XNO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/nano/info/logo.png" width="32" /> | <https://nano.org> |
| 169 | Manta Pacific | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/manta/info/logo.png" width="32" /> | <https://pacific.manta.network> |
| 175 | Ravencoin | RVN | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ravencoin/info/logo.png" width="32" /> | <https://ravencoin.org> |
| 178 | POA Network | POA | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/poa/info/logo.png" width="32" /> | <https://poa.network> |
| 194 | EOS | EOS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/eos/info/logo.png" width="32" /> | <http://eos.io> |
Expand Down
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ enum TWCoinType {
TWCoinTypeZenEON = 7332,
TWCoinTypeInternetComputer = 223,
TWCoinTypeTia = 21000118,
TWCoinTypeMantaPacific = 169,
// end_of_tw_coin_type_marker_do_not_modify
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CoinAddressDerivationTests {
Ethereum, SmartChain, Polygon, Optimism, Zksync, Arbitrum, ArbitrumNova, ECOChain, AvalancheCChain, XDai,
Fantom, Celo, CronosChain, SmartBitcoinCash, KuCoinCommunityChain, Boba, Metis,
Aurora, Evmos, Moonriver, Moonbeam, KavaEvm, Klaytn, Meter, OKXChain, PolygonzkEVM, Scroll,
ConfluxeSpace, AcalaEVM, OpBNB, Neon, Base, Linea, Greenfield, Mantle, ZenEON,
ConfluxeSpace, AcalaEVM, OpBNB, Neon, Base, Linea, Greenfield, Mantle, ZenEON, MantaPacific,
-> "0x8f348F300873Fd5DA36950B2aC75a26584584feE"

Ronin -> "ronin:8f348F300873Fd5DA36950B2aC75a26584584feE"
Expand Down
30 changes: 30 additions & 0 deletions registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -4508,5 +4508,35 @@
"rpc": "",
"documentation": "https://internetcomputer.org/docs"
}
},
{
"id": "manta",
"name": "Manta Pacific",
"coinId": 169,
"symbol": "ETH",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "169",
"addressHasher": "keccak256",
"explorer": {
"url": "https://pacific-explorer.manta.network",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x2bbd5d85b0ed05d1416e30ce1197a6f0c27d10ce02593a2719e2baf486d2e8c2",
"sampleAccount": "0xF122a1aC569a36a5Cf6d0F828A22254c8A9afF84"
},
"info": {
"url": "https://pacific.manta.network",
"source": "https://github.com/manta-network",
"rpc": "https://pacific-rpc.manta.network/http",
"documentation": "https://docs.manta.network/docs/Introduction"
}
}
]
1 change: 1 addition & 0 deletions rust/tw_any_coin/tests/coin_address_derivation_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn test_coin_address_derivation() {
| CoinType::Greenfield
| CoinType::Mantle
| CoinType::ZenEON
| CoinType::MantaPacific
// end_of_evm_address_derivation_tests_marker_do_not_modify
=> "0xAc1ec44E4f0ca7D172B7803f6836De87Fb72b309",
CoinType::Bitcoin
Expand Down
3 changes: 2 additions & 1 deletion rust/tw_evm/src/message/eip712/eip712_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ fn encode_bytes(value: &Json) -> MessageSigningResult<Data> {
.decode_hex()
.map_err(|_| MessageSigningError::InvalidParameterValue)?;
let hash = keccak256(&bytes);
Ok(encode_tokens(&[Token::Bytes(hash)]))
let checked_bytes = NonEmptyBytes::new(hash).expect("`hash` must not be empty");
Ok(encode_tokens(&[Token::FixedBytes(checked_bytes)]))
}

fn encode_array(
Expand Down
58 changes: 58 additions & 0 deletions rust/tw_evm/tests/data/eip712_different_bytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"BytesTest": [
{
"name": "data_long",
"type": "bytes"
},
{
"name": "data_short",
"type": "bytes"
},
{
"name": "fix_data32",
"type": "bytes32"
},
{
"name": "fix_data32_short",
"type": "bytes32"
},
{
"name": "fix_data16",
"type": "bytes16"
},
{
"name": "fix_data16_short",
"type": "bytes16"
}
]
},
"domain": {
"name": "Test",
"version": "0.0.0",
"verifyingContract": "0xb8d6eb2c8236ba373b40adfad4decb8e05ac9230"
},
"primaryType": "BytesTest",
"message": {
"data_long": "0xcb5a7173d109f8a59c23109189056c862d843808d00bac069e9b76ca7217d845a94d0ad600000000000000000000000000000000000000000000000000000000000000a07c1a7062fbf633885ae02e0919ec07020a96aa20bf9c79554d2ddcd013113c64579837cd54cb5f05c65c46c04fac9abe54f839a74fa3cc1c47fc9048db037a84000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d61414e35575832525851385852374b5158475a6f726931517461597972356e3547537471456a71706a4e71640000000000000000000000",
"data_short": "0xcb5a71",
"fix_data32": "0xcb5a7173d109f8a59c23109189056c862d843808d00bac069e9b76ca7217d845",
"fix_data32_short": "0xcb5a71",
"fix_data16": "0xcb5a7173d109f8a59c23109189056c86",
"fix_data16_short": "0xcb5a71"
}
}
63 changes: 63 additions & 0 deletions rust/tw_evm/tests/data/eip712_long_bytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"ForwardRequest": [
{
"name": "info",
"type": "string"
},
{
"name": "from",
"type": "address"
},
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "gas",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
}
]
},
"domain": {
"name": "MinimalForwarder",
"version": "0.0.2",
"verifyingContract": "0x65CDf66C6FDDCD0a43042F237Aa871414b724f4d"
},
"primaryType": "ForwardRequest",
"message": {
"info": "Please sign this message, so OwnerChip can send this transaction on your behalf.",
"from": "0xff7abfb4ad52ba6ec9af37955365a7691c8167b9",
"to": "0xb8d6eb2c8236ba373b40adfad4decb8e05ac9230",
"value": 0,
"gas": 500000,
"nonce": 228,
"data": "0xcb5a7173d109f8a59c23109189056c862d843808d00bac069e9b76ca7217d845a94d0ad600000000000000000000000000000000000000000000000000000000000000a07c1a7062fbf633885ae02e0919ec07020a96aa20bf9c79554d2ddcd013113c64579837cd54cb5f05c65c46c04fac9abe54f839a74fa3cc1c47fc9048db037a84000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d61414e35575832525851385852374b5158475a6f726931517461597972356e3547537471456a71706a4e71640000000000000000000000"
}
}
24 changes: 24 additions & 0 deletions rust/tw_evm/tests/message_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const EIP712_UNEQUAL_ARRAY_LEN: &str = include_str!("data/eip712_unequal_array_l
const EIP712_WITH_CHAIN_ID_STR: &str = include_str!("data/eip712_with_chain_id_string.json");
const EIP712_GREENFIELD: &str = include_str!("data/eip712_greenfield.json");
const EIP712_FIXED_BYTES: &str = include_str!("data/eip712_fixed_bytes.json");
const EIP712_LONG_BYTES: &str = include_str!("data/eip712_long_bytes.json");
const EIP712_DIFFERENT_BYTES: &str = include_str!("data/eip712_different_bytes.json");

struct SignVerifyTestInput {
private_key: &'static str,
Expand Down Expand Up @@ -277,3 +279,25 @@ fn test_message_signer_sign_verify_eip712_fixed_bytes() {
signature: "7ee9b54fedf355e40fa86bbe23e63b318ef797bd8fdbc5bb714edbace042d4cb60111912218234e856f2cf300b3b47c91383b98e263ecf69c6c10193fef6c9581b",
});
}

#[test]
fn test_message_signer_sign_verify_eip712_long_bytes() {
test_message_signer_sign_verify(SignVerifyTestInput {
private_key: "6f96f3aa7e8052170f1864f72a9a53606ee9c0d185188266cab895512a4bcf84",
msg: EIP712_LONG_BYTES,
msg_type: Proto::MessageType::MessageType_typed,
chain_id: None,
signature: "3f78f5860dc9c38d3bf68fd0759c0e4963f104ba6c7fa44e915ed41a1575dbd50d6fd946919e6cfa7eecb869a5d90658b16b1d7b79ec6380acd1841fc21c77f71c",
});
}

#[test]
fn test_message_signer_sign_verify_eip712_different_bytes() {
test_message_signer_sign_verify(SignVerifyTestInput {
private_key: "6f96f3aa7e8052170f1864f72a9a53606ee9c0d185188266cab895512a4bcf84",
msg: EIP712_DIFFERENT_BYTES,
msg_type: Proto::MessageType::MessageType_typed,
chain_id: None,
signature: "48dc667cd8a53beb58ea6b1745f98c21b12e1a57587ce28bae07689dba3600d40cef2685dc8a68028d38f3e63289891868ecdf05e8affc275fee3001e51d6c581c",
});
}
1 change: 1 addition & 0 deletions rust/tw_misc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// file LICENSE at the root of the source code distribution tree.

pub mod macros;
#[cfg(feature = "serde")]
pub mod serde;
#[cfg(feature = "test-utils")]
pub mod test_utils;
Expand Down
2 changes: 1 addition & 1 deletion samples/kmp/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.trustwallet:wallet-core-kotlin:4.0.10")
implementation("com.trustwallet:wallet-core-kotlin:4.0.13")
}
}
val commonTest by getting {
Expand Down
3 changes: 2 additions & 1 deletion swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class CoinAddressDerivationTests: XCTestCase {
.linea,
.greenfield,
.mantle,
.zenEON:
.zenEON,
.mantaPacific:
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .ronin:
Expand Down
31 changes: 31 additions & 0 deletions tests/chains/MantaPacific/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#include "TestUtilities.h"
#include <TrustWalletCore/TWCoinTypeConfiguration.h>
#include <gtest/gtest.h>

TEST(TWMantaPacificCoinType, TWCoinType) {
const auto coin = TWCoinTypeMantaPacific;
const auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(coin));
const auto id = WRAPS(TWCoinTypeConfigurationGetID(coin));
const auto name = WRAPS(TWCoinTypeConfigurationGetName(coin));
const auto txId = WRAPS(TWStringCreateWithUTF8Bytes("0x2bbd5d85b0ed05d1416e30ce1197a6f0c27d10ce02593a2719e2baf486d2e8c2"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0xF122a1aC569a36a5Cf6d0F828A22254c8A9afF84"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "manta");
assertStringsEqual(name, "Manta Pacific");
assertStringsEqual(symbol, "ETH");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum);
ASSERT_EQ(TWCoinTypeP2pkhPrefix(coin), 0);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0);
assertStringsEqual(txUrl, "https://pacific-explorer.manta.network/tx/0x2bbd5d85b0ed05d1416e30ce1197a6f0c27d10ce02593a2719e2baf486d2e8c2");
assertStringsEqual(accUrl, "https://pacific-explorer.manta.network/address/0xF122a1aC569a36a5Cf6d0F828A22254c8A9afF84");
}
1 change: 1 addition & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeGreenfield:
case TWCoinTypeMantle:
case TWCoinTypeZenEON:
case TWCoinTypeMantaPacific:
// end_of_evm_address_derivation_tests_marker_do_not_modify
EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F");
break;
Expand Down

0 comments on commit b9ef4ab

Please sign in to comment.