From 949b0c3357f2465fd4ecd608d14f5dc1841c8305 Mon Sep 17 00:00:00 2001 From: satoshiotomakan <127754187+satoshiotomakan@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:37:18 +0100 Subject: [PATCH] feat(Manta): Add support for Manta Pacific Mainnet (#3617) * feat(manta): Add support for Manta Pacific Mainnet * feat(manta): Fix iOS, Android, Kotlin tests * feat(manta): Fix some tests, codegen-v2 --- .../blockchains/CoinAddressDerivationTests.kt | 5 ++- .../codegen/cpp/templates/TWCoinTypeTests.cpp | 2 +- codegen-v2/src/codegen/template_generator.rs | 1 + docs/registry.md | 1 + include/TrustWalletCore/TWCoinType.h | 1 + .../core/test/CoinAddressDerivationTests.kt | 2 +- registry.json | 30 ++++++++++++++++++ .../tests/coin_address_derivation_test.rs | 1 + swift/Tests/CoinAddressDerivationTests.swift | 3 +- tests/chains/MantaPacific/TWCoinTypeTests.cpp | 31 +++++++++++++++++++ tests/common/CoinAddressDerivationTests.cpp | 1 + 11 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 tests/chains/MantaPacific/TWCoinTypeTests.cpp diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/CoinAddressDerivationTests.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/CoinAddressDerivationTests.kt index 7e44af34e2e..1436bb783cf 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/CoinAddressDerivationTests.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/CoinAddressDerivationTests.kt @@ -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) diff --git a/codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp b/codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp index 83124519c83..59a9d1a2e3f 100644 --- a/codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp +++ b/codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp @@ -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}); diff --git a/codegen-v2/src/codegen/template_generator.rs b/codegen-v2/src/codegen/template_generator.rs index 39f1780f1f1..add3da7fcb7 100644 --- a/codegen-v2/src/codegen/template_generator.rs +++ b/codegen-v2/src/codegen/template_generator.rs @@ -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) diff --git a/docs/registry.md b/docs/registry.md index b49763ff960..490965bc8b1 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -31,6 +31,7 @@ This list is generated from [./registry.json](../registry.json) | 148 | Stellar | XLM | | | | 156 | Bitcoin Gold | BTG | | | | 165 | Nano | XNO | | | +| 169 | Manta Pacific | ETH | | | | 175 | Ravencoin | RVN | | | | 178 | POA Network | POA | | | | 194 | EOS | EOS | | | diff --git a/include/TrustWalletCore/TWCoinType.h b/include/TrustWalletCore/TWCoinType.h index 6a09ac2f74f..9aeca0a9953 100644 --- a/include/TrustWalletCore/TWCoinType.h +++ b/include/TrustWalletCore/TWCoinType.h @@ -179,6 +179,7 @@ enum TWCoinType { TWCoinTypeZenEON = 7332, TWCoinTypeInternetComputer = 223, TWCoinTypeTia = 21000118, + TWCoinTypeMantaPacific = 169, // end_of_tw_coin_type_marker_do_not_modify }; diff --git a/kotlin/wallet-core-kotlin/src/commonTest/kotlin/com/trustwallet/core/test/CoinAddressDerivationTests.kt b/kotlin/wallet-core-kotlin/src/commonTest/kotlin/com/trustwallet/core/test/CoinAddressDerivationTests.kt index cec9314a3be..db177dc1b16 100644 --- a/kotlin/wallet-core-kotlin/src/commonTest/kotlin/com/trustwallet/core/test/CoinAddressDerivationTests.kt +++ b/kotlin/wallet-core-kotlin/src/commonTest/kotlin/com/trustwallet/core/test/CoinAddressDerivationTests.kt @@ -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" diff --git a/registry.json b/registry.json index d78c60aae73..ce1fc2fbba5 100644 --- a/registry.json +++ b/registry.json @@ -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" + } } ] diff --git a/rust/tw_any_coin/tests/coin_address_derivation_test.rs b/rust/tw_any_coin/tests/coin_address_derivation_test.rs index 260243fa0ea..58f522939c9 100644 --- a/rust/tw_any_coin/tests/coin_address_derivation_test.rs +++ b/rust/tw_any_coin/tests/coin_address_derivation_test.rs @@ -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 diff --git a/swift/Tests/CoinAddressDerivationTests.swift b/swift/Tests/CoinAddressDerivationTests.swift index fdc68d10b43..00e6aecd5f0 100644 --- a/swift/Tests/CoinAddressDerivationTests.swift +++ b/swift/Tests/CoinAddressDerivationTests.swift @@ -114,7 +114,8 @@ class CoinAddressDerivationTests: XCTestCase { .linea, .greenfield, .mantle, - .zenEON: + .zenEON, + .mantaPacific: let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE" assertCoinDerivation(coin, expectedResult, derivedAddress, address) case .ronin: diff --git a/tests/chains/MantaPacific/TWCoinTypeTests.cpp b/tests/chains/MantaPacific/TWCoinTypeTests.cpp new file mode 100644 index 00000000000..4f053c7fc01 --- /dev/null +++ b/tests/chains/MantaPacific/TWCoinTypeTests.cpp @@ -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 +#include + +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"); +} diff --git a/tests/common/CoinAddressDerivationTests.cpp b/tests/common/CoinAddressDerivationTests.cpp index da1bd05e983..059290d6c46 100644 --- a/tests/common/CoinAddressDerivationTests.cpp +++ b/tests/common/CoinAddressDerivationTests.cpp @@ -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;