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

[Sei]: Add support for Sei cosmos chain #3362

Merged
merged 1 commit into from
Aug 11, 2023
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 @@ -145,5 +145,6 @@ class CoinAddressDerivationTests {
AKASH -> assertEquals("akash142j9u5eaduzd7faumygud6ruhdwme98qal870f", address)
NOBLE -> assertEquals("noble142j9u5eaduzd7faumygud6ruhdwme98qc8l3wa", address)
ROOTSTOCK -> assertEquals("0xA2D7065F94F838a3aB9C04D67B312056846424Df", address)
SEI -> assertEquals("sei142j9u5eaduzd7faumygud6ruhdwme98qagm0sj", address)
}
}
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ This list is generated from [./registry.json](../registry.json)
| 16000118 | Persistence | XPRT | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/persistence/info/logo.png" width="32" /> | <https://persistence.one/> |
| 17000118 | Akash | AKT | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/akash/info/logo.png" width="32" /> | <https://akash.network/> |
| 18000118 | Noble | USDC | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/noble/info/logo.png" width="32" /> | <https://nobleassets.xyz/> |
| 19000118 | Sei | SEI | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sei/info/logo.png" width="32" /> | <https://sei.io/> |
| 20000118 | Stargaze | STARS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stargaze/info/logo.png" width="32" /> | <https://www.stargaze.zone/> |
| 20000714 | BNB Smart Chain | BNB | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain/info/logo.png" width="32" /> | <https://www.binance.org/en/smartChain> |
| 20009001 | Native Evmos | EVMOS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/nativeevmos/info/logo.png" width="32" /> | <https://evmos.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 @@ -171,6 +171,7 @@ enum TWCoinType {
TWCoinTypeOpBNB = 204,
TWCoinTypeNeon = 245022934,
TWCoinTypeBase = 8453,
TWCoinTypeSei = 19000118,
};

/// 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 @@ -1046,6 +1046,36 @@
"url": "https://nobleassets.xyz/"
}
},
{
"id": "sei",
"name": "Sei",
"displayName": "Sei",
"coinId": 19000118,
"symbol": "SEI",
"decimals": 6,
"blockchain": "Cosmos",
"chainId": "pacific-1",
"derivation": [
{
"path": "m/44'/118'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1",
"hrp": "sei",
"addressHasher": "sha256ripemd",
"explorer": {
"url": "https://www.mintscan.io/sei",
"txPath": "/txs/",
"accountPath": "/account/",
"sampleTx": "4A2114EE45317439690F3BEA9C8B6CFA11D42CF978F9487754902D372EEB488C",
"sampleAccount": "sei155hqv2rsypqzq0zpjn72frsxx4l6tcmplw63m2"
},
"info": {
"url": "https://sei.io/",
"documentation": "https://docs.sei.io/"
}
},
{
"id": "coreum",
"name": "Coreum",
Expand Down
3 changes: 3 additions & 0 deletions swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ class CoinAddressDerivationTests: XCTestCase {
case .noble:
let expectedResult = "noble142j9u5eaduzd7faumygud6ruhdwme98qc8l3wa"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .sei:
let expectedResult = "sei142j9u5eaduzd7faumygud6ruhdwme98qagm0sj"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
@unknown default:
fatalError()
}
Expand Down
19 changes: 19 additions & 0 deletions tests/chains/Cosmos/Sei/TWAnyAddressTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 "../CosmosTestHelpers.h"

namespace TW::Cosmos::tests {

static const std::string gSeiAddr = "sei1mry47pkga5tdswtluy0m8teslpalkdq0ndpc65";
static const std::string gSeiHrp = "sei";

TEST(TWSeiAnyAddress, AllSeiAddressTests) {
CosmosAddressParameters parameters{.hrp = gSeiHrp, .coinType = TWCoinTypeSei, .address = gSeiAddr};
TestCosmosAddressParameters(parameters);
}

}
38 changes: 38 additions & 0 deletions tests/chains/Cosmos/Sei/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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>

namespace TW::Cosmos::tests {
TEST(TWSeiCoinType, TWCoinType) {
const auto coin = TWCoinTypeSei;
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("4A2114EE45317439690F3BEA9C8B6CFA11D42CF978F9487754902D372EEB488C"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("sei155hqv2rsypqzq0zpjn72frsxx4l6tcmplw63m2"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "sei");
assertStringsEqual(name, "Sei");
assertStringsEqual(symbol, "SEI");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 6);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainCosmos);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "pacific-1");
assertStringsEqual(txUrl, "https://www.mintscan.io/sei/txs/4A2114EE45317439690F3BEA9C8B6CFA11D42CF978F9487754902D372EEB488C");
assertStringsEqual(accUrl, "https://www.mintscan.io/sei/account/sei155hqv2rsypqzq0zpjn72frsxx4l6tcmplw63m2");
}
}
5 changes: 4 additions & 1 deletion tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ TEST(Coin, DeriveAddress) {
break;
case TWCoinTypeRootstock:
EXPECT_EQ(address, "0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F");
break;
break;
case TWCoinTypeSei:
EXPECT_EQ(address, "sei1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z05hw42q");
break;
// no default branch here, intentionally, to better notice any missing coins
}
}
Expand Down