From ca1a2d2b5ac6a9ccdcefbe8f04d5187318212fd7 Mon Sep 17 00:00:00 2001 From: satoshiotomakan <127754187+satoshiotomakan@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:26:59 +0700 Subject: [PATCH] feat(ZetaChain) Add support for ZetaEVM mainnet (#3670) * feat(ZetaChain): Add `new-cosmos-chain` command * feat(ZetaChain): Add `NativeZetaChain` mainnet * feat(ZetaChain): Add support for custom Cosmos chain * feat(ZetaChain): Add `SignerInfo` to the Cosmos.proto protocol * feat(ZetaChain): Fix zetachain params in registry.json * feat(ZetaChain): Add mobile tests * [CI] Trigger CI * feat(ZetaChain): Update JSON Public Key Type * feat(ZetaChain): Fix `accountPath` in `registry.json` * feat(ZetaChain): Fix rustfmt * feat(ZetaChain): Add ZetaEVM chain * feat(ZetaChain): Add mobile tests * feat(ZetaChain): Fix Swift test * feat(ZetaChain): Slightly refactor NativeEvmos and NativeInjective public key types * feat(ZetaChain): Fix C++ test --- .../blockchains/CoinAddressDerivationTests.kt | 1 + docs/registry.md | 1 + include/TrustWalletCore/TWCoinType.h | 1 + .../core/test/CoinAddressDerivationTests.kt | 1 + registry.json | 28 +++++++++++++++ .../tests/coin_address_derivation_test.rs | 1 + swift/Tests/CoinAddressDerivationTests.swift | 3 +- tests/chains/ZetaEVM/TWCoinTypeTests.cpp | 35 +++++++++++++++++++ tests/common/CoinAddressDerivationTests.cpp | 1 + 9 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/chains/ZetaEVM/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 ed19bae335c..05d20a89744 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 @@ -47,6 +47,7 @@ class CoinAddressDerivationTests { 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, MANTAPACIFIC, + ZETAEVM, -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address) RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address) diff --git a/docs/registry.md b/docs/registry.md index 558ee6febf3..4fd54a26c0c 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -141,6 +141,7 @@ This list is generated from [./registry.json](../registry.json) | 19000118 | Sei | SEI | | | | 20000118 | Stargaze | STARS | | | | 20000714 | BNB Smart Chain | BNB | | | +| 20007000 | Zeta EVM | ZETA | | | | 20009001 | Native Evmos | EVMOS | | | | 21000118 | Celestia | TIA | | | | 30000118 | Juno | JUNO | | | diff --git a/include/TrustWalletCore/TWCoinType.h b/include/TrustWalletCore/TWCoinType.h index 64e5b5f9225..289ff480a82 100644 --- a/include/TrustWalletCore/TWCoinType.h +++ b/include/TrustWalletCore/TWCoinType.h @@ -179,6 +179,7 @@ enum TWCoinType { TWCoinTypeTia = 21000118, TWCoinTypeMantaPacific = 169, TWCoinTypeNativeZetaChain = 10007000, + TWCoinTypeZetaEVM = 20007000, // 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 6a2a7f54b05..444e9ea9767 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 @@ -40,6 +40,7 @@ class CoinAddressDerivationTests { 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, MantaPacific, + ZetaEVM, -> "0x8f348F300873Fd5DA36950B2aC75a26584584feE" Ronin -> "ronin:8f348F300873Fd5DA36950B2aC75a26584584feE" diff --git a/registry.json b/registry.json index 2df0f2c23c6..e034c34bede 100644 --- a/registry.json +++ b/registry.json @@ -4451,6 +4451,34 @@ "documentation": "https://www.zetachain.com/docs/" } }, + { + "id": "zetaevm", + "name": "Zeta EVM", + "coinId": 20007000, + "symbol": "ZETA", + "decimals": 18, + "blockchain": "Ethereum", + "derivation": [ + { + "path": "m/44'/60'/0'/0/0" + } + ], + "curve": "secp256k1", + "publicKeyType": "secp256k1Extended", + "chainId": "7000", + "addressHasher": "keccak256", + "explorer": { + "url": "https://explorer.zetachain.com", + "txPath": "/evm/tx/", + "accountPath": "/address/", + "sampleTx": "0x04cb1201857de29af97b755e51c888454fb96c1f3bb3c1329bb94d5353d5c19e", + "sampleAccount": "0x85539A58F9c88DdDccBaBBfc660968323Fd1e167" + }, + "info": { + "url": "https://www.zetachain.com/", + "documentation": "https://www.zetachain.com/docs/" + } + }, { "id": "ton", "name": "TON", 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 09bd78cd283..12ce7f772fc 100644 --- a/rust/tw_any_coin/tests/coin_address_derivation_test.rs +++ b/rust/tw_any_coin/tests/coin_address_derivation_test.rs @@ -85,6 +85,7 @@ fn test_coin_address_derivation() { | CoinType::Mantle | CoinType::ZenEON | CoinType::MantaPacific + | CoinType::ZetaEVM // 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 2e4ce928ecd..4d18de7ae96 100644 --- a/swift/Tests/CoinAddressDerivationTests.swift +++ b/swift/Tests/CoinAddressDerivationTests.swift @@ -113,7 +113,8 @@ class CoinAddressDerivationTests: XCTestCase { .greenfield, .mantle, .zenEON, - .mantaPacific: + .mantaPacific, + .zetaEVM: let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE" assertCoinDerivation(coin, expectedResult, derivedAddress, address) case .ronin: diff --git a/tests/chains/ZetaEVM/TWCoinTypeTests.cpp b/tests/chains/ZetaEVM/TWCoinTypeTests.cpp new file mode 100644 index 00000000000..b8e9eaf9ef9 --- /dev/null +++ b/tests/chains/ZetaEVM/TWCoinTypeTests.cpp @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright © 2017 Trust Wallet. +// +// This is a GENERATED FILE, changes made here MAY BE LOST. +// Generated one-time (codegen/bin/cointests) +// + +#include "TestUtilities.h" +#include +#include + + +TEST(TWZetaEVMCoinType, TWCoinType) { + const auto coin = TWCoinTypeZetaEVM; + const auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(coin)); + const auto id = WRAPS(TWCoinTypeConfigurationGetID(coin)); + const auto name = WRAPS(TWCoinTypeConfigurationGetName(coin)); + const auto chainId = WRAPS(TWCoinTypeChainId(coin)); + const auto txId = WRAPS(TWStringCreateWithUTF8Bytes("0x04cb1201857de29af97b755e51c888454fb96c1f3bb3c1329bb94d5353d5c19e")); + const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get())); + const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x85539A58F9c88DdDccBaBBfc660968323Fd1e167")); + const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get())); + + assertStringsEqual(id, "zetaevm"); + assertStringsEqual(name, "Zeta EVM"); + assertStringsEqual(symbol, "ZETA"); + ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18); + ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum); + ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0); + ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0); + assertStringsEqual(chainId, "7000"); + assertStringsEqual(txUrl, "https://explorer.zetachain.com/evm/tx/0x04cb1201857de29af97b755e51c888454fb96c1f3bb3c1329bb94d5353d5c19e"); + assertStringsEqual(accUrl, "https://explorer.zetachain.com/address/0x85539A58F9c88DdDccBaBBfc660968323Fd1e167"); +} diff --git a/tests/common/CoinAddressDerivationTests.cpp b/tests/common/CoinAddressDerivationTests.cpp index 6aa4c4604b8..f052b41322b 100644 --- a/tests/common/CoinAddressDerivationTests.cpp +++ b/tests/common/CoinAddressDerivationTests.cpp @@ -83,6 +83,7 @@ TEST(Coin, DeriveAddress) { case TWCoinTypeMantle: case TWCoinTypeZenEON: case TWCoinTypeMantaPacific: + case TWCoinTypeZetaEVM: // end_of_evm_address_derivation_tests_marker_do_not_modify EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F"); break;