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

Add Aurora chain support #2157

Merged
merged 2 commits into from Apr 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,7 +41,8 @@ class CoinAddressDerivationTests {
DASH -> assertEquals("XqHiz8EXYbTAtBEYs4pWTHh7ipEDQcNQeT", address)
DIGIBYTE -> assertEquals("dgb1qtjgmerfqwdffyf8ghcrkgy52cghsqptynmyswu", address)
ETHEREUM, SMARTCHAIN, POLYGON, OPTIMISM, ARBITRUM, ECOCHAIN, AVALANCHECCHAIN, XDAI,
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
RONIN -> assertEquals("ronin:8f348f300873fd5da36950b2ac75a26584584fee", address)
ETHEREUMCLASSIC -> assertEquals("0x078bA3228F3E6C08bEEac9A005de0b7e7089aD1c", address)
GOCHAIN -> assertEquals("0x5940ce4A14210d4Ccd0ac206CE92F21828016aC2", address)
Expand Down
1 change: 1 addition & 0 deletions docs/registry.md
Expand Up @@ -83,3 +83,4 @@ This list is generated from [./registry.json](../registry.json)
| 10009000 | Avalanche C-Chain | AVAX | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png" width="32" /> | <https://www.avalabs.org/> |
| 10042221 | Arbitrum | ARETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png" width="32" /> | <https://arbitrum.io> |
| 20000714 | 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> |
| 1323161554 | Aurora | AURORAETH | <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
Expand Up @@ -103,6 +103,7 @@ enum TWCoinType {
TWCoinTypeKuCoinCommunityChain = 10000321,
TWCoinTypeBoba = 10000288,
TWCoinTypeMetis = 1001088,
TWCoinTypeAurora = 1323161554,
};

/// Returns the blockchain for a coin type.
Expand Down
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWEthereumChainID.h
Expand Up @@ -37,6 +37,7 @@ enum TWEthereumChainID {
TWEthereumChainIDKuCoinCommunityChain = 321,
TWEthereumChainIDBoba = 288,
TWEthereumChainIDMetis = 1088,
TWEthereumChainIDAurora = 1313161554,
};

TW_EXTERN_C_END
24 changes: 24 additions & 0 deletions registry.json
Expand Up @@ -1990,5 +1990,29 @@
"rpc": "https://andromeda.metis.io/?owner=1088",
"documentation": "https://docs.metis.io/"
}
},
{
"id": "aurora",
"name": "Aurora",
"coinId": 1323161554,
"symbol": "AURORAETH",
"decimals": 18,
"blockchain": "Ethereum",
"derivationPath": "m/44'/60'/0'/0/0",
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"explorer": {
"url": "https://explorer.mainnet.aurora.dev",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x99deebdb70f8027037abb3d3d0f3c7523daee857d85e9056d2671593ff2f2f28",
"sampleAccount": "0x8707cdE20dd43E3dB1F74c28fcd509ef38B0bA51"
},
"info": {
"url": "https://aurora.dev/",
"source": "https://github.com/aurora-is-near/aurora-engine",
"rpc": "https://mainnet.aurora.dev/",
"documentation": "https://doc.aurora.dev/"
}
}
]
3 changes: 2 additions & 1 deletion src/AnyAddress.h
Expand Up @@ -130,7 +130,8 @@ class AnyAddress {
case TWCoinTypeSmartBitcoinCash:
case TWCoinTypeKuCoinCommunityChain:
case TWCoinTypeBoba:
case TWCoinTypeMetis: {
case TWCoinTypeMetis:
case TWCoinTypeAurora: {
const auto addr = Ethereum::Address(string);
return {addr.bytes.begin(), addr.bytes.end()};
}
Expand Down
1 change: 1 addition & 0 deletions src/Coin.cpp
Expand Up @@ -185,6 +185,7 @@ CoinEntry* coinDispatcher(TWCoinType coinType) {
case TWCoinTypeKuCoinCommunityChain: entry = &ethereumDP; break;
case TWCoinTypeBoba: entry = &ethereumDP; break;
case TWCoinTypeMetis: entry = &ethereumDP; break;
case TWCoinTypeAurora: entry = &ethereumDP; break;
// end_of_coin_dipatcher_switch_marker_do_not_modify

default: entry = nullptr; break;
Expand Down
3 changes: 2 additions & 1 deletion src/Ethereum/Entry.h
Expand Up @@ -38,7 +38,8 @@ class Entry: public CoinEntry {
TWCoinTypeSmartBitcoinCash,
TWCoinTypeKuCoinCommunityChain,
TWCoinTypeBoba,
TWCoinTypeMetis
TWCoinTypeMetis,
TWCoinTypeAurora,
};
}
virtual bool validateAddress(TWCoinType coin, const std::string& address, TW::byte p2pkh, TW::byte p2sh, const char* hrp) const;
Expand Down
3 changes: 2 additions & 1 deletion swift/Tests/CoinAddressDerivationTests.swift
Expand Up @@ -84,7 +84,8 @@ class CoinAddressDerivationTests: XCTestCase {
.smartBitcoinCash,
.kuCoinCommunityChain,
.boba,
.metis:
.metis,
.aurora:
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .ronin:
Expand Down
34 changes: 34 additions & 0 deletions tests/Aurora/TWCoinTypeTests.cpp
@@ -0,0 +1,34 @@
// Copyright © 2017-2021 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 "../interface/TWTestUtilities.h"
#include <TrustWalletCore/TWCoinTypeConfiguration.h>
#include <gtest/gtest.h>


TEST(TWAuroraCoinType, TWCoinType) {
auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(TWCoinTypeAurora));
auto txId = WRAPS(TWStringCreateWithUTF8Bytes("0x99deebdb70f8027037abb3d3d0f3c7523daee857d85e9056d2671593ff2f2f28"));
auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(TWCoinTypeAurora, txId.get()));
auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x8707cdE20dd43E3dB1F74c28fcd509ef38B0bA51"));
auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(TWCoinTypeAurora, accId.get()));
auto id = WRAPS(TWCoinTypeConfigurationGetID(TWCoinTypeAurora));
auto name = WRAPS(TWCoinTypeConfigurationGetName(TWCoinTypeAurora));

ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(TWCoinTypeAurora), 18);
ASSERT_EQ(TWBlockchainEthereum, TWCoinTypeBlockchain(TWCoinTypeAurora));
ASSERT_EQ(0x0, TWCoinTypeP2shPrefix(TWCoinTypeAurora));
ASSERT_EQ(0x0, TWCoinTypeStaticPrefix(TWCoinTypeAurora));
assertStringsEqual(symbol, "AURORAETH");
assertStringsEqual(txUrl, "https://explorer.mainnet.aurora.dev/tx/0x99deebdb70f8027037abb3d3d0f3c7523daee857d85e9056d2671593ff2f2f28");
assertStringsEqual(accUrl, "https://explorer.mainnet.aurora.dev/address/0x8707cdE20dd43E3dB1F74c28fcd509ef38B0bA51");
assertStringsEqual(id, "aurora");
assertStringsEqual(name, "Aurora");
}