Skip to content

Commit

Permalink
feat(linea): Add support for Linea EVM-compatible chain (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan authored Aug 15, 2023
1 parent aa74755 commit 672f0ab
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CoinAddressDerivationTests {
ETHEREUM, SMARTCHAIN, POLYGON, OPTIMISM, ZKSYNC, ARBITRUM, 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 -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA -> 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 @@ -92,6 +92,7 @@ This list is generated from [./registry.json](../registry.json)
| 18000 | Meter | MTR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/meter/info/logo.png" width="32" /> | <https://meter.io/> |
| 19167 | Flux | FLUX | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zelcash/info/logo.png" width="32" /> | <https://runonflux.io> |
| 52752 | Celo | CELO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/celo/info/logo.png" width="32" /> | <https://celo.org> |
| 59144 | Linea | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/linea/info/logo.png" width="32" /> | <https://linea.build> |
| 105105 | Stratis | STRAX | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stratis/info/logo.png" width="32" /> | <https://www.stratisplatform.com/> |
| 534353 | Scroll | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/scroll/info/logo.png" width="32" /> | <https://scroll.io> |
| 5718350 | Wanchain | WAN | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/wanchain/info/logo.png" width="32" /> | <https://wanchain.org> |
Expand Down
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ enum TWCoinType {
TWCoinTypeNeon = 245022934,
TWCoinTypeBase = 8453,
TWCoinTypeSei = 19000118,
TWCoinTypeLinea = 59144,
};

/// 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 @@ -380,6 +380,36 @@
"documentation": "https://docs.base.org/"
}
},
{
"id": "linea",
"name": "Linea",
"coinId": 59144,
"symbol": "ETH",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "59144",
"addressHasher": "keccak256",
"explorer": {
"url": "https://lineascan.build",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x0c7086f96865f4fcad58d7f3449db7baab9fce2625bcb79e7ea26676aa0d3420",
"sampleAccount": "0xbf71018f716ca6c64b0b12622f87a26b3b86100f"
},
"info": {
"url": "https://linea.build",
"source": "https://github.com/LineaLabs",
"rpc": "https://rpc.linea.build",
"documentation": "https://docs.linea.build"
}
},
{
"id": "ethereum",
"name": "Ethereum",
Expand Down
2 changes: 1 addition & 1 deletion samples/kmp/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.trustwallet:wallet-core-kotlin:3.2.8")
implementation("com.trustwallet:wallet-core-kotlin:3.2.11")
}
}
val commonTest by getting {
Expand Down
3 changes: 2 additions & 1 deletion swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class CoinAddressDerivationTests: XCTestCase {
.opBNB,
.acalaEVM,
.neon,
.base:
.base,
.linea:
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .ronin:
Expand Down
36 changes: 36 additions & 0 deletions tests/chains/Linea/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.
//
// This is a GENERATED FILE, changes made here MAY BE LOST.
// Generated one-time (codegen/bin/cointests)
//

#include "TestUtilities.h"
#include <TrustWalletCore/TWCoinTypeConfiguration.h>
#include <gtest/gtest.h>

TEST(TWLineaCoinType, TWCoinType) {
const auto coin = TWCoinTypeLinea;
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("0x0c7086f96865f4fcad58d7f3449db7baab9fce2625bcb79e7ea26676aa0d3420"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0xbf71018f716ca6c64b0b12622f87a26b3b86100f"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "linea");
assertStringsEqual(name, "Linea");
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, "59144");
assertStringsEqual(txUrl, "https://lineascan.build/tx/0x0c7086f96865f4fcad58d7f3449db7baab9fce2625bcb79e7ea26676aa0d3420");
assertStringsEqual(accUrl, "https://lineascan.build/address/0xbf71018f716ca6c64b0b12622f87a26b3b86100f");
}
1 change: 1 addition & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeOpBNB:
case TWCoinTypeNeon:
case TWCoinTypeBase:
case TWCoinTypeLinea:
EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F");
break;

Expand Down

0 comments on commit 672f0ab

Please sign in to comment.