Skip to content

Commit 793ae1c

Browse files
feat(Plasma): Add Plasma Mainnet (trustwallet#4499)
* feat(plasma): Add Plasma Mainnet * feat(plasma): Add mobile tests
1 parent 3c1f86c commit 793ae1c

File tree

9 files changed

+67
-3
lines changed

9 files changed

+67
-3
lines changed

android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/CoinAddressDerivationTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CoinAddressDerivationTests {
4747
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
4848
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KAIA, METER, OKXCHAIN, POLYGONZKEVM, SCROLL,
4949
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA, GREENFIELD, MANTLE, ZENEON, MANTAPACIFIC,
50-
ZETAEVM, MERLIN, LIGHTLINK, BLAST, BOUNCEBIT, ZKLINKNOVA, SONIC,
50+
ZETAEVM, MERLIN, LIGHTLINK, BLAST, BOUNCEBIT, ZKLINKNOVA, SONIC, PLASMA,
5151
-> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
5252

5353
RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)

docs/registry.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ This list is generated from [./registry.json](../registry.json)
9797
| 7332 | Zen EON | ZEN | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zeneon/info/logo.png" width="32" /> | <https://eon.horizen.io> |
9898
| 8453 | Base | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png" width="32" /> | <https://base.mirror.xyz/> |
9999
| 8964 | NULS | NULS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/nuls/info/logo.png" width="32" /> | <https://nuls.io> |
100+
| 9745 | Plasma Mainnet | XPL | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/plasma/info/logo.png" width="32" /> | <https://plasma.to> |
100101
| 14001 | WAX | WAXP | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/wax/info/logo.png" width="32" /> | <http://wax.io> |
101102
| 18000 | Meter | MTR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/meter/info/logo.png" width="32" /> | <https://meter.io/> |
102103
| 19167 | Flux | FLUX | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zelcash/info/logo.png" width="32" /> | <https://runonflux.io> |

include/TrustWalletCore/TWCoinType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ enum TWCoinType {
189189
TWCoinTypePactus = 21888,
190190
TWCoinTypeSonic = 10000146,
191191
TWCoinTypePolymesh = 595,
192+
TWCoinTypePlasma = 9745,
192193
// end_of_tw_coin_type_marker_do_not_modify
193194
};
194195

kotlin/wallet-core-kotlin/src/commonTest/kotlin/com/trustwallet/core/test/CoinAddressDerivationTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CoinAddressDerivationTests {
4040
Fantom, Celo, CronosChain, SmartBitcoinCash, KuCoinCommunityChain, Boba, Metis,
4141
Aurora, Evmos, Moonriver, Moonbeam, KavaEvm, Kaia, Meter, OKXChain, PolygonzkEVM, Scroll,
4242
ConfluxeSpace, AcalaEVM, OpBNB, Neon, Base, Linea, Greenfield, Mantle, ZenEON, MantaPacific,
43-
ZetaEVM, Merlin, Lightlink, Blast, BounceBit, ZkLinkNova, Sonic,
43+
ZetaEVM, Merlin, Lightlink, Blast, BounceBit, ZkLinkNova, Sonic, Plasma,
4444
-> "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
4545

4646
Ronin -> "ronin:8f348F300873Fd5DA36950B2aC75a26584584feE"

registry.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,5 +4879,35 @@
48794879
"rpc": "wss://rpc.polymesh.network/",
48804880
"documentation": "https://developers.polymesh.network/"
48814881
}
4882+
},
4883+
{
4884+
"id": "plasma",
4885+
"name": "Plasma",
4886+
"displayName": "Plasma Mainnet",
4887+
"coinId": 9745,
4888+
"symbol": "XPL",
4889+
"decimals": 18,
4890+
"blockchain": "Ethereum",
4891+
"derivation": [
4892+
{
4893+
"path": "m/44'/60'/0'/0/0"
4894+
}
4895+
],
4896+
"curve": "secp256k1",
4897+
"publicKeyType": "secp256k1Extended",
4898+
"chainId": "9745",
4899+
"addressHasher": "keccak256",
4900+
"explorer": {
4901+
"url": "https://plasmascan.to",
4902+
"txPath": "/tx/",
4903+
"accountPath": "/address/",
4904+
"sampleTx": "0x3700212ec535b4c804363be87ba8a5f5668de6314ed41978f6ad71c5340d4d77",
4905+
"sampleAccount": "0x30A3E1F27B60c095E2c87bce1e2ffB24f381C8cd"
4906+
},
4907+
"info": {
4908+
"url": "https://plasma.to",
4909+
"rpc": "https://rpc.plasma.to",
4910+
"documentation": "https://plasmascan.to/documentation"
4911+
}
48824912
}
48834913
]

rust/tw_tests/tests/coin_address_derivation_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fn test_coin_address_derivation() {
9292
| CoinType::BounceBit
9393
| CoinType::ZkLinkNova
9494
| CoinType::Sonic
95+
| CoinType::Plasma
9596
// end_of_evm_address_derivation_tests_marker_do_not_modify
9697
=> "0xAc1ec44E4f0ca7D172B7803f6836De87Fb72b309",
9798
CoinType::Bitcoin => "bc1qten42eesehw0ktddcp0fws7d3ycsqez3f7d5yt",

swift/Tests/CoinAddressDerivationTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ class CoinAddressDerivationTests: XCTestCase {
120120
.blast,
121121
.bounceBit,
122122
.zkLinkNova,
123-
.sonic:
123+
.sonic,
124+
.plasma:
124125
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
125126
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
126127
case .ronin:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// Copyright © 2017 Trust Wallet.
4+
5+
#include "TestUtilities.h"
6+
#include <TrustWalletCore/TWCoinTypeConfiguration.h>
7+
#include <gtest/gtest.h>
8+
9+
TEST(TWPlasmaCoinType, TWCoinType) {
10+
const auto coin = TWCoinTypePlasma;
11+
const auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(coin));
12+
const auto id = WRAPS(TWCoinTypeConfigurationGetID(coin));
13+
const auto name = WRAPS(TWCoinTypeConfigurationGetName(coin));
14+
const auto txId = WRAPS(TWStringCreateWithUTF8Bytes("0x3700212ec535b4c804363be87ba8a5f5668de6314ed41978f6ad71c5340d4d77"));
15+
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
16+
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x30A3E1F27B60c095E2c87bce1e2ffB24f381C8cd"));
17+
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));
18+
19+
assertStringsEqual(id, "plasma");
20+
assertStringsEqual(name, "Plasma Mainnet");
21+
assertStringsEqual(symbol, "XPL");
22+
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18);
23+
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum);
24+
ASSERT_EQ(TWCoinTypeP2pkhPrefix(coin), 0);
25+
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0);
26+
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0);
27+
assertStringsEqual(txUrl, "https://plasmascan.to/tx/0x3700212ec535b4c804363be87ba8a5f5668de6314ed41978f6ad71c5340d4d77");
28+
assertStringsEqual(accUrl, "https://plasmascan.to/address/0x30A3E1F27B60c095E2c87bce1e2ffB24f381C8cd");
29+
}

tests/common/CoinAddressDerivationTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ TEST(Coin, DeriveAddress) {
9090
case TWCoinTypeBounceBit:
9191
case TWCoinTypeZkLinkNova:
9292
case TWCoinTypeSonic:
93+
case TWCoinTypePlasma:
9394
// end_of_evm_address_derivation_tests_marker_do_not_modify
9495
EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F");
9596
break;

0 commit comments

Comments
 (0)