Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sonic): Add support for Sonic EVM chain #4239

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CoinAddressDerivationTests {
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KAIA, METER, OKXCHAIN, POLYGONZKEVM, SCROLL,
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA, GREENFIELD, MANTLE, ZENEON, MANTAPACIFIC,
ZETAEVM, MERLIN, LIGHTLINK, BLAST, BOUNCEBIT, ZKLINKNOVA,
ZETAEVM, MERLIN, LIGHTLINK, BLAST, BOUNCEBIT, ZKLINKNOVA, SONIC,
-> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)

RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)
Expand Down
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ This list is generated from [./registry.json](../registry.json)
| 10000100 | Gnosis Chain | xDAI | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/xdai/info/logo.png" width="32" /> | <https://www.xdaichain.com> |
| 10000118 | Osmosis | OSMO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/osmosis/info/logo.png" width="32" /> | <https://osmosis.zone/> |
| 10000145 | Smart Bitcoin Cash | BCH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartbch/info/logo.png" width="32" /> | <https://smartbch.org/> |
| 10000146 | Sonic | S | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sonic/info/logo.png" width="32" /> | <https://www.soniclabs.com> |
| 10000250 | Fantom | FTM | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/fantom/info/logo.png" width="32" /> | <https://fantom.foundation> |
| 10000288 | Boba | BOBAETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/boba/info/logo.png" width="32" /> | <https://boba.network/> |
| 10000321 | KuCoin Community Chain | KCS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/kcc/info/logo.png" width="32" /> | <https://www.kcc.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 @@ -187,6 +187,7 @@ enum TWCoinType {
TWCoinTypeBounceBit = 6001,
TWCoinTypeZkLinkNova = 810180,
TWCoinTypePactus = 21888,
TWCoinTypeSonic = 10000146,
// end_of_tw_coin_type_marker_do_not_modify
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CoinAddressDerivationTests {
Fantom, Celo, CronosChain, SmartBitcoinCash, KuCoinCommunityChain, Boba, Metis,
Aurora, Evmos, Moonriver, Moonbeam, KavaEvm, Kaia, Meter, OKXChain, PolygonzkEVM, Scroll,
ConfluxeSpace, AcalaEVM, OpBNB, Neon, Base, Linea, Greenfield, Mantle, ZenEON, MantaPacific,
ZetaEVM, Merlin, Lightlink, Blast, BounceBit, ZkLinkNova,
ZetaEVM, Merlin, Lightlink, Blast, BounceBit, ZkLinkNova, Sonic,
-> "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 @@ -4788,6 +4788,36 @@
"documentation": "https://docs.zklink.io"
}
},
{
"id": "sonic",
"name": "Sonic",
"coinId": 10000146,
"symbol": "S",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "146",
"addressHasher": "keccak256",
"explorer": {
"url": "https://sonicscan.org",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x886c34de9e054c741b2bcb15c3a3e0382e3ed7a48f2c6f2a489f6d82abdd4a7c",
"sampleAccount": "0x9c174f0e2d11559447e5fe2815d930475be19016"
},
"info": {
"url": "https://www.soniclabs.com",
"source": "https://github.com/Fantom-foundation/Sonic",
"rpc": "https://rpc.soniclabs.com",
"documentation": "https://docs.soniclabs.com"
}
},
{
"id": "pactus",
"name": "Pactus",
Expand Down
1 change: 1 addition & 0 deletions rust/tw_tests/tests/coin_address_derivation_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn test_coin_address_derivation() {
| CoinType::Blast
| CoinType::BounceBit
| CoinType::ZkLinkNova
| CoinType::Sonic
// end_of_evm_address_derivation_tests_marker_do_not_modify
=> "0xAc1ec44E4f0ca7D172B7803f6836De87Fb72b309",
CoinType::Bitcoin => "bc1qten42eesehw0ktddcp0fws7d3ycsqez3f7d5yt",
Expand Down
3 changes: 2 additions & 1 deletion swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class CoinAddressDerivationTests: XCTestCase {
.lightlink,
.blast,
.bounceBit,
.zkLinkNova:
.zkLinkNova,
.sonic:
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .ronin:
Expand Down
29 changes: 29 additions & 0 deletions tests/chains/Sonic/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
//
// Copyright © 2017 Trust Wallet.

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

TEST(TWSonicCoinType, TWCoinType) {
const auto coin = TWCoinTypeSonic;
const auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(coin));
const auto id = WRAPS(TWCoinTypeConfigurationGetID(coin));
const auto name = WRAPS(TWCoinTypeConfigurationGetName(coin));
const auto txId = WRAPS(TWStringCreateWithUTF8Bytes("0x886c34de9e054c741b2bcb15c3a3e0382e3ed7a48f2c6f2a489f6d82abdd4a7c"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x9c174f0e2d11559447e5fe2815d930475be19016"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "sonic");
assertStringsEqual(name, "Sonic");
assertStringsEqual(symbol, "S");
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://sonicscan.org/tx/0x886c34de9e054c741b2bcb15c3a3e0382e3ed7a48f2c6f2a489f6d82abdd4a7c");
assertStringsEqual(accUrl, "https://sonicscan.org/address/0x9c174f0e2d11559447e5fe2815d930475be19016");
}
1 change: 1 addition & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeBlast:
case TWCoinTypeBounceBit:
case TWCoinTypeZkLinkNova:
case TWCoinTypeSonic:
// end_of_evm_address_derivation_tests_marker_do_not_modify
EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F");
break;
Expand Down
Loading