Skip to content

Commit

Permalink
[Cosmos]: adding fetch.ai (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Apr 14, 2023
1 parent 6e4dde4 commit 0e0e351
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 @@ -124,5 +124,6 @@ class CoinAddressDerivationTests {
COMDEX -> assertEquals("comdex142j9u5eaduzd7faumygud6ruhdwme98qhtgm0y", address)
NEUTRON -> assertEquals("neutron142j9u5eaduzd7faumygud6ruhdwme98q5mrmv5", address)
SOMMELIER -> assertEquals("somm142j9u5eaduzd7faumygud6ruhdwme98quc948e", address)
FETCHAI -> assertEquals("fetch142j9u5eaduzd7faumygud6ruhdwme98qrera5y", address)
}
}
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ This list is generated from [./registry.json](../registry.json)
| 10009001 | Evmos | EVMOS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/evmos/info/logo.png" width="32" /> | <https://evmos.org/> |
| 10042221 | Arbitrum | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png" width="32" /> | <https://arbitrum.io> |
| 11000118 | Sommelier | SOMM | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sommelier/info/logo.png" width="32" /> | <https://www.sommelier.finance/> |
| 12000118 | Fetch AI | FET | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/fetchai/info/logo.png" width="32" /> | <https://fetch.ai/> |
| 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 @@ -143,6 +143,7 @@ enum TWCoinType {
TWCoinTypeComdex = 80000118,
TWCoinTypeNeutron = 90000118,
TWCoinTypeSommelier = 11000118,
TWCoinTypeFetchAI = 12000118,
};

/// 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 @@ -756,6 +756,36 @@
"url": "https://www.sommelier.finance/"
}
},
{
"id": "fetchai",
"name": "FetchAI",
"displayName": "Fetch AI",
"coinId": 12000118,
"symbol": "FET",
"decimals": 6,
"chainId": "fetchhub-4",
"blockchain": "Cosmos",
"derivation": [
{
"path": "m/44'/118'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1",
"hrp": "fetch",
"addressHasher": "sha256ripemd",
"explorer": {
"url": "https://www.mintscan.io/fetchai",
"txPath": "/txs/",
"accountPath": "/account/",
"sampleTx": "7EB4F6C26809BA047F81CEFD0889775AC8522B7B8AF559B436083BE7039C5EA6",
"sampleAccount": "fetch1t3qet68dr0qkmrjtq89lrx837qa2t05265qy6s"
},
"info": {
"url": "https://fetch.ai/",
"documentation": "https://docs.fetch.ai/"
}
},
{
"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 @@ -308,6 +308,9 @@ class CoinAddressDerivationTests: XCTestCase {
case .sommelier:
let expectedResult = "somm142j9u5eaduzd7faumygud6ruhdwme98quc948e"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .fetchAI:
let expectedResult = "fetch142j9u5eaduzd7faumygud6ruhdwme98qrera5y"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
@unknown default:
fatalError()
}
Expand Down
19 changes: 19 additions & 0 deletions tests/chains/Cosmos/FetchAI/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 gFetchAIAddr = "fetch1mry47pkga5tdswtluy0m8teslpalkdq0due27z";
static const std::string gFetchAIHrp = "fetch";

TEST(TWFetchAIAnyAddress, AllFetchAIAddressTests) {
CosmosAddressParameters parameters{.hrp = gFetchAIHrp, .coinType = TWCoinTypeFetchAI, .address = gFetchAIAddr};
TestCosmosAddressParameters(parameters);
}

}
38 changes: 38 additions & 0 deletions tests/chains/Cosmos/FetchAI/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(TWFetchAICoinType, TWCoinType) {
const auto coin = TWCoinTypeFetchAI;
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("7EB4F6C26809BA047F81CEFD0889775AC8522B7B8AF559B436083BE7039C5EA6"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("fetch1t3qet68dr0qkmrjtq89lrx837qa2t05265qy6s"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "fetchai");
assertStringsEqual(name, "Fetch AI");
assertStringsEqual(symbol, "FET");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 6);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainCosmos);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "fetchhub-4");
assertStringsEqual(txUrl, "https://www.mintscan.io/fetchai/txs/7EB4F6C26809BA047F81CEFD0889775AC8522B7B8AF559B436083BE7039C5EA6");
assertStringsEqual(accUrl, "https://www.mintscan.io/fetchai/account/fetch1t3qet68dr0qkmrjtq89lrx837qa2t05265qy6s");
}
}
3 changes: 3 additions & 0 deletions tests/common/CoinAddressDerivationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ TEST(Coin, DeriveAddress) {
case TWCoinTypeSommelier:
EXPECT_EQ(address, "somm1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z048s0at");
break;
case TWCoinTypeFetchAI:
EXPECT_EQ(address, "fetch1hkfq3zahaqkkzx5mjnamwjsfpq2jk7z02xk8wk");
break;
// no default branch here, intentionally, to better notice any missing coins
}
}
Expand Down

0 comments on commit 0e0e351

Please sign in to comment.