Skip to content

Commit

Permalink
Adds Support for Moonbeam, and Moonriver (trustwallet#2280)
Browse files Browse the repository at this point in the history
* Add Moonriver chain
* Add Moonbeam chain
* Add test for Moonriver and Moonbeam
  • Loading branch information
AyushBherwani1998 authored Jun 4, 2022
1 parent 785cee6 commit 246ee50
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CoinAddressDerivationTests {
DIGIBYTE -> assertEquals("dgb1qtjgmerfqwdffyf8ghcrkgy52cghsqptynmyswu", address)
ETHEREUM, SMARTCHAIN, POLYGON, OPTIMISM, ARBITRUM, ECOCHAIN, AVALANCHECCHAIN, XDAI,
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA, EVMOS -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
AURORA, EVMOS, MOONRIVER, MOONBEAM -> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)
RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)
ETHEREUMCLASSIC -> assertEquals("0x078bA3228F3E6C08bEEac9A005de0b7e7089aD1c", address)
GOCHAIN -> assertEquals("0x5940ce4A14210d4Ccd0ac206CE92F21828016aC2", address)
Expand Down
2 changes: 2 additions & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ This list is generated from [./registry.json](../registry.json)
| 10000321 | KuCoin Community Chain | KCS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/kcc/info/logo.png" width="32" /> | <https://www.kcc.io/> |
| 10000553 | Huobi ECO Chain | HT | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/heco/info/logo.png" width="32" /> | <https://www.hecochain.com/en-us> |
| 10001088 | Metis | METIS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/metis/info/logo.png" width="32" /> | <https://www.metis.io/> |
| 10001284 | Moonbeam | GLMR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/moonbeam/info/logo.png" width="32" /> | <https://moonbeam.network> |
| 10001285 | Moonriver | MOVR | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/moonriver/info/logo.png" width="32" /> | <https://moonbeam.network/networks/moonriver> |
| 10002020 | Ronin | RON | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ronin/info/logo.png" width="32" /> | <https://whitepaper.axieinfinity.com/technology/ronin-ethereum-sidechain> |
| 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/> |
| 10009001 | Evmos | EVMOS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/evmos/info/logo.png" width="32" /> | <https://evmos.org/> |
Expand Down
2 changes: 2 additions & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ enum TWCoinType {
TWCoinTypeAurora = 1323161554,
TWCoinTypeEvmos = 10009001,
TWCoinTypeNativeEvmos = 20009001,
TWCoinTypeMoonriver = 10001285,
TWCoinTypeMoonbeam = 10001284,
};

/// Returns the blockchain for a coin type.
Expand Down
57 changes: 56 additions & 1 deletion registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@
"documentation": "https://docs.evmos.org/"
}
},
{
{
"id": "nativeevmos",
"name": "NativeEvmos",
"displayName": "Native Evmos",
Expand Down Expand Up @@ -2487,5 +2487,60 @@
"clientPublic": "https://rest.bd.evmos.org:1317",
"clientDocs": ""
}
},
{
"id": "moonriver",
"name": "Moonriver",
"coinId": 10001285,
"symbol": "MOVR",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "1285",
"explorer": {
"url": "https://moonriver.moonscan.io",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x2e2daa3943ba65d9bbb910a4f6765aa6a466a0ef8935090547ca9d30e201e032",
"sampleAccount": "0x899831D937937d011305E73EE782cce0455DF15a"
},
"info": {
"url": "https://moonbeam.network/networks/moonriver",
"rpc": "https://moonriver.public.blastapi.io"
}
},
{
"id": "moonbeam",
"name": "Moonbeam",
"coinId": 10001284,
"symbol": "GLMR",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "1284",
"explorer": {
"url": "https://moonscan.io",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0xb22a146c933e6e51affbfa5f712a266b5f5e92ae453cd2f252bcc3c36ff035a6",
"sampleAccount": "0x201bb4f276C765dF7225e5A4153E17edD23a67eC"
},
"info": {
"url": "https://moonbeam.network",
"rpc": "https://rpc.api.moonbeam.network",
"documentation": "https://docs.moonbeam.network"
}
}
]
4 changes: 3 additions & 1 deletion swift/Tests/CoinAddressDerivationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class CoinAddressDerivationTests: XCTestCase {
.boba,
.metis,
.aurora,
.evmos:
.evmos,
.moonriver,
.moonbeam:
let expectedResult = "0x8f348F300873Fd5DA36950B2aC75a26584584feE"
assertCoinDerivation(coin, expectedResult, derivedAddress, address)
case .ronin:
Expand Down
37 changes: 37 additions & 0 deletions tests/Moonbeam/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright © 2017-2022 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(TWMoonbeamCoinType, TWCoinType) {
const auto coin = TWCoinTypeMoonbeam;
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("0xb22a146c933e6e51affbfa5f712a266b5f5e92ae453cd2f252bcc3c36ff035a6"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x201bb4f276C765dF7225e5A4153E17edD23a67eC"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "moonbeam");
assertStringsEqual(name, "Moonbeam");
assertStringsEqual(symbol, "GLMR");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "1284");
assertStringsEqual(txUrl, "https://moonscan.io/tx/0xb22a146c933e6e51affbfa5f712a266b5f5e92ae453cd2f252bcc3c36ff035a6");
assertStringsEqual(accUrl, "https://moonscan.io/address/0x201bb4f276C765dF7225e5A4153E17edD23a67eC");
}
37 changes: 37 additions & 0 deletions tests/Moonriver/TWCoinTypeTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright © 2017-2022 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(TWMoonriverCoinType, TWCoinType) {
const auto coin = TWCoinTypeMoonriver;
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("0x2e2daa3943ba65d9bbb910a4f6765aa6a466a0ef8935090547ca9d30e201e032"));
const auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(coin, txId.get()));
const auto accId = WRAPS(TWStringCreateWithUTF8Bytes("0x899831D937937d011305E73EE782cce0455DF15a"));
const auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(coin, accId.get()));

assertStringsEqual(id, "moonriver");
assertStringsEqual(name, "Moonriver");
assertStringsEqual(symbol, "MOVR");
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(coin), 18);
ASSERT_EQ(TWCoinTypeBlockchain(coin), TWBlockchainEthereum);
ASSERT_EQ(TWCoinTypeP2shPrefix(coin), 0x0);
ASSERT_EQ(TWCoinTypeStaticPrefix(coin), 0x0);
assertStringsEqual(chainId, "1285");
assertStringsEqual(txUrl, "https://moonriver.moonscan.io/tx/0x2e2daa3943ba65d9bbb910a4f6765aa6a466a0ef8935090547ca9d30e201e032");
assertStringsEqual(accUrl, "https://moonriver.moonscan.io/address/0x899831D937937d011305E73EE782cce0455DF15a");
}

0 comments on commit 246ee50

Please sign in to comment.