Skip to content

Commit

Permalink
feat(Manta): Add support for Manta Pacific Mainnet (#3617)
Browse files Browse the repository at this point in the history
* feat(manta): Add support for Manta Pacific Mainnet

* feat(manta): Fix iOS, Android, Kotlin tests

* feat(manta): Fix some tests, codegen-v2
  • Loading branch information
satoshiotomakan authored Dec 20, 2023
1 parent 374da80 commit 949b0c3
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 4 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 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 949b0c3

Please sign in to comment.