Skip to content

Commit

Permalink
[Cosmos]: Add Comdex (#3068)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Apr 12, 2023
1 parent 73d0675 commit c9a9188
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ class CoinAddressDerivationTests {
CRESCENT -> assertEquals("cre142j9u5eaduzd7faumygud6ruhdwme98q5veur7", address)
KUJIRA -> assertEquals("kujira142j9u5eaduzd7faumygud6ruhdwme98qpvgpme", address)
NATIVECANTO -> assertEquals("canto13u6g7vqgw074mgmf2ze2cadzvkz9snlwqua5pd", address)
COMDEX -> assertEquals("comdex142j9u5eaduzd7faumygud6ruhdwme98qhtgm0y", address)
}
}
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ This list is generated from [./registry.json](../registry.json)
| 50000118 | Axelar | AXL | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/axelar/info/logo.png" width="32" /> | <https://axelar.network/> |
| 60000118 | Crescent | CRE | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/crescent/info/logo.png" width="32" /> | <https://crescent.network/> |
| 70000118 | Kujira | KUJI | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/kujira/info/logo.png" width="32" /> | <https://kujira.app/> |
| 80000118 | Comdex | CMDX | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/comdex/info/logo.png" width="32" /> | <https://comdex.one/> |
| 1323161554 | Aurora | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aurora/info/logo.png" width="32" /> | <https://aurora.dev/> |
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ enum TWCoinType {
TWCoinTypeCrescent = 60000118,
TWCoinTypeKujira = 70000118,
TWCoinTypeNativeCanto = 10007700,
TWCoinTypeComdex = 80000118,
};

/// 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 @@ -667,6 +667,36 @@
"documentation": "https://docs.kujira.app/introduction/readme"
}
},
{
"id": "comdex",
"name": "Comdex",
"displayName": "Comdex",
"coinId": 80000118,
"symbol": "CMDX",
"decimals": 6,
"chainId": "comdex-1",
"blockchain": "Cosmos",
"derivation": [
{
"path": "m/44'/118'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1",
"hrp": "comdex",
"addressHasher": "sha256ripemd",
"explorer": {
"url": "https://www.mintscan.io/comdex",
"txPath": "/txs/",
"accountPath": "/account/",
"sampleTx": "04C790D09A40EE958DBDD385B679B5EB60C10F9BC1389CC8F896DC9193A5ED6C",
"sampleAccount": "comdex1jz7av7cq45gh5hhrugtak7lkps2ga5v0u64nz6"
},
"info": {
"url": "https://comdex.one/",
"documentation": "https://docs.comdex.one/"
}
},
{
"id": "zcash",
"name": "Zcash",
Expand Down
3 changes: 3 additions & 0 deletions swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ class CoinAddressDerivationTests: XCTestCase {
case .nativeCanto:
let expectedResult = "canto13u6g7vqgw074mgmf2ze2cadzvkz9snlwqua5pd"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .comdex:
let expectedResult = "comdex142j9u5eaduzd7faumygud6ruhdwme98qhtgm0y"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
@unknown default:
fatalError()
}
Expand Down
19 changes: 19 additions & 0 deletions tests/chains/Cosmos/Comdex/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 gComdexAddr = "comdex1mry47pkga5tdswtluy0m8teslpalkdq0ewjv9z";
static const std::string gComdexHrp = "comdex";

TEST(TWComdexAnyAddress, AllComdexAddressTests) {
CosmosAddressParameters parameters{.hrp = gComdexHrp, .coinType = TWCoinTypeComdex, .address = gComdexAddr};
TestCosmosAddressParameters(parameters);
}

}
38 changes: 38 additions & 0 deletions tests/chains/Cosmos/Comdex/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(TWComdexCoinType, TWCoinType) {
const auto coin = TWCoinTypeComdex;
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("04C790D09A40EE958DBDD385B679B5EB60C10F9BC1389CC8F896DC9193A5ED6C"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("comdex1jz7av7cq45gh5hhrugtak7lkps2ga5v0u64nz6"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "comdex");
assertStringsEqual(name, "Comdex");
assertStringsEqual(symbol, "CMDX");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 6);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainCosmos);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "comdex-1");
assertStringsEqual(txUrl, "https://www.mintscan.io/comdex/txs/04C790D09A40EE958DBDD385B679B5EB60C10F9BC1389CC8F896DC9193A5ED6C");
assertStringsEqual(accUrl, "https://www.mintscan.io/comdex/account/comdex1jz7av7cq45gh5hhrugtak7lkps2ga5v0u64nz6");
}
}
3 changes: 3 additions & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeNativeCanto:
EXPECT_EQ(address, "canto1nk9x9ajk4rgkzhqjjn7hr6w0k0jg2kj0wvfqju");
break;
case TWCoinTypeComdex:
EXPECT_EQ(address, "comdex1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z075ap4k");
break;
// no default branch here, intentionally, to better notice any missing coins
}
}
Expand Down

0 comments on commit c9a9188

Please sign in to comment.