Skip to content

Commit

Permalink
[zkevm]: add polygon zkevm (#2966)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius authored Mar 2, 2023
1 parent 366f65c commit 6e0725b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CoinAddressDerivationTests {
DIGIBYTE -> assertEquals("dgb1qtjgmerfqwdffyf8ghcrkgy52cghsqptynmyswu", address)
ETHEREUM, SMARTCHAIN, POLYGON, OPTIMISM, ZKSYNC, ARBITRUM, ECOCHAIN, AVALANCHECCHAIN, XDAI,
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KLAYTN, METER, OKXCHAIN -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KLAYTN, METER, OKXCHAIN, POLYGONZKEVM, -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)
ETHEREUMCLASSIC -> assertEquals("0x078bA3228F3E6C08bEEac9A005de0b7e7089aD1c", address)
GOCHAIN -> assertEquals("0x5940ce4A14210d4Ccd0ac206CE92F21828016aC2", address)
Expand Down
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ This list is generated from [./registry.json](../registry.json)
| 10001088 | Metis | METIS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/metis/info/logo.png" width="32" /> | <https://www.metis.io/> |
| 10001284 | Moonbeam | GLMR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/moonbeam/info/logo.png" width="32" /> | <https://moonbeam.network> |
| 10001285 | Moonriver | MOVR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/moonriver/info/logo.png" width="32" /> | <https://moonbeam.network/networks/moonriver> |
| 10001422 | Polygon zkEVM | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygonzkevm/info/logo.png" width="32" /> | <https://www.polygon.technology/> |
| 10002020 | Ronin | RON | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ronin/info/logo.png" width="32" /> | <https://whitepaper.axieinfinity.com/technology/ronin-ethereum-sidechain> |
| 10002222 | KavaEvm | KAVA | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/kavaevm/info/logo.png" width="32" /> | <https://www.kava.io/> |
| 10008217 | Klaytn | KLAY | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/klaytn/info/logo.png" width="32" /> | <https://klaytn.foundation> |
Expand Down
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ enum TWCoinType {
TWCoinTypeAgoric = 564,
TWCoinTypeTON = 607,
TWCoinTypeSui = 784,
TWCoinTypePolygonzkEVM = 10001422,
};

/// Returns the blockchain for a coin type.
Expand Down
30 changes: 30 additions & 0 deletions registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,36 @@
"documentation": "https://eth.wiki/json-rpc/API"
}
},
{
"id": "polygonzkevm",
"name": "Polygon zkEVM",
"displayName": "Polygon zkEVM",
"coinId": 10001422,
"slip44": 60,
"symbol": "ETH",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "1422",
"addressHasher": "keccak256",
"explorer": {
"url": "https://explorer.public.zkevm-test.net",
"txPath": "/tx/",
"accountPath": "/address/"
},
"info": {
"url": "https://www.polygon.technology/",
"source": "https://github.com/0xpolygonhermez",
"rpc": "https://rpc.public.zkevm-test.net",
"documentation": "https://wiki.polygon.technology/docs/zkEVM/introduction/"
}
},
{
"id": "zksync",
"name": "Zksync",
Expand Down
1 change: 1 addition & 0 deletions swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class CoinAddressDerivationTests: XCTestCase {
.polygon,
.optimism,
.zksync,
.polygonzkEVM,
.arbitrum,
.ecochain,
.avalancheCChain,
Expand Down
36 changes: 36 additions & 0 deletions tests/chains/PolygonZkEvm/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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>

namespace TW::TWPolygonZkEvm::tests {

TEST(TWPolygonZkEVMCoinType, TWCoinType) {
const auto coin = TWCoinTypePolygonzkEVM;
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("0xfbe568183495ad2ec95f0232501e86018bff3e4ca52aaa804983b380dc39d523"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0xC5C39Ec2a271d84d67c0e66a68238102A2ec4b98"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "polygonzkevm");
assertStringsEqual(name, "Polygon zkEVM");
assertStringsEqual(symbol, "ETH");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "1422");
assertStringsEqual(txUrl, "https://explorer.public.zkevm-test.net/tx/0xfbe568183495ad2ec95f0232501e86018bff3e4ca52aaa804983b380dc39d523");
assertStringsEqual(accUrl, "https://explorer.public.zkevm-test.net/address/0xC5C39Ec2a271d84d67c0e66a68238102A2ec4b98");
}

} // namespace TW::TWZksync::tests
1 change: 1 addition & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeMoonriver:
case TWCoinTypeOptimism:
case TWCoinTypeZksync:
case TWCoinTypePolygonzkEVM:
case TWCoinTypeOKXChain:
case TWCoinTypePOANetwork:
case TWCoinTypePolygon:
Expand Down

0 comments on commit 6e0725b

Please sign in to comment.