Skip to content

Commit

Permalink
[Cosmos]: Add support for Kujira (#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Apr 11, 2023
1 parent 1e3dc17 commit 4b3258c
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ class CoinAddressDerivationTests {
STRIDE -> assertEquals("stride142j9u5eaduzd7faumygud6ruhdwme98qn029zl", address)
AXELAR -> assertEquals("axelar142j9u5eaduzd7faumygud6ruhdwme98q52u3aj", address)
CRESCENT -> assertEquals("cre142j9u5eaduzd7faumygud6ruhdwme98q5veur7", address)
KUJIRA -> assertEquals("kujira142j9u5eaduzd7faumygud6ruhdwme98qpvgpme", address)
}
}
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ This list is generated from [./registry.json](../registry.json)
| 40000118 | Stride | STRD | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stride/info/logo.png" width="32" /> | <https://stride.zone/> |
| 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/> |
| 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 @@ -137,6 +137,7 @@ enum TWCoinType {
TWCoinTypeStride = 40000118,
TWCoinTypeAxelar = 50000118,
TWCoinTypeCrescent = 60000118,
TWCoinTypeKujira = 70000118,
};

/// 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 @@ -637,6 +637,36 @@
"documentation": "https://docs.crescent.network/introduction/what-is-crescent"
}
},
{
"id": "kujira",
"name": "Kujira",
"displayName": "Kujira",
"coinId": 70000118,
"symbol": "KUJI",
"decimals": 6,
"chainId": "kaiyo-1",
"blockchain": "Cosmos",
"derivation": [
{
"path": "m/44'/118'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1",
"hrp": "kujira",
"addressHasher": "sha256ripemd",
"explorer": {
"url": "https://www.mintscan.io/kujira",
"txPath": "/txs/",
"accountPath": "/account/"
},
"info": {
"url": "https://kujira.app/",
"source": "https://github.com/Team-Kujira/core",
"rpc": "https://kujira-rpc.polkachu.com",
"documentation": "https://docs.kujira.app/introduction/readme"
}
},
{
"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 @@ -290,6 +290,9 @@ class CoinAddressDerivationTests: XCTestCase {
case .crescent:
let expectedResult = "cre142j9u5eaduzd7faumygud6ruhdwme98q5veur7"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .kujira:
let expectedResult = "kujira142j9u5eaduzd7faumygud6ruhdwme98qpvgpme"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
@unknown default:
fatalError()
}
Expand Down
19 changes: 19 additions & 0 deletions tests/chains/Cosmos/Kujira/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 gKujiraAddr = "kujira1mry47pkga5tdswtluy0m8teslpalkdq00fjk3l";
static const std::string gKujiraHrp = "kujira";

TEST(TWKujiraAnyAddress, AllKujiraAddressTests) {
CosmosAddressParameters parameters{.hrp = gKujiraHrp, .coinType = TWCoinTypeKujira, .address = gKujiraAddr};
TestCosmosAddressParameters(parameters);
}

}
37 changes: 37 additions & 0 deletions tests/chains/Cosmos/Kujira/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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(TWKujiraCoinType, TWCoinType) {
const auto coin = TWCoinTypeKujira;
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("2F5D1B1E0041A86B0590AAD2ED028693E93137A3EA1E614D59FE9B02261BC235"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("kujira13c90ger64wc26s8399rvazceqy273u3n84kgyp"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "kujira");
assertStringsEqual(name, "Kujira");
assertStringsEqual(symbol, "KUJI");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 6);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainCosmos);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "kaiyo-1");
assertStringsEqual(txUrl, "https://www.mintscan.io/kujira/txs/2F5D1B1E0041A86B0590AAD2ED028693E93137A3EA1E614D59FE9B02261BC235");
assertStringsEqual(accUrl, "https://www.mintscan.io/kujira/account/kujira13c90ger64wc26s8399rvazceqy273u3n84kgyp");
}
6 changes: 6 additions & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeAxelar:
EXPECT_EQ(address, "axelar1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z0a4ft8q");
break;
case TWCoinTypeCrescent:
EXPECT_EQ(address, "cre1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z0anvxev");
break;
case TWCoinTypeKujira:
EXPECT_EQ(address, "kujira1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z0gnampt");
break;
// no default branch here, intentionally, to better notice any missing coins
}
}
Expand Down

0 comments on commit 4b3258c

Please sign in to comment.