Skip to content

Commit 8656660

Browse files
committed
feat: rsk integration
1 parent 05818df commit 8656660

File tree

21 files changed

+281
-10
lines changed

21 files changed

+281
-10
lines changed

assets/img/currencies/png/RBTC.png

29.8 KB
Loading

assets/img/currencies/png/xusd.png

12.2 KB
Loading

assets/img/currencies/rbtc.svg

+1
Loading

assets/img/currencies/xusd.svg

+1
Loading

src/constants/SupportedCurrencyOptions.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, {ReactElement} from 'react';
22
import BtcIcon from '../../assets/img/currencies/btc.svg';
33
import BchIcon from '../../assets/img/currencies/bch.svg';
44
import EthIcon from '../../assets/img/currencies/eth.svg';
5+
import RbtcIcon from '../../assets/img/currencies/rbtc.svg';
6+
import XUSDIcon from '../../assets/img/currencies/xusd.svg';
57
import DogeIcon from '../../assets/img/currencies/doge.svg';
68
import LtcIcon from '../../assets/img/currencies/ltc.svg';
79
import XrpIcon from '../../assets/img/currencies/xrp.svg';
@@ -32,6 +34,8 @@ export const CurrencyListIcons: {
3234
btc: props => <BtcIcon {...props} />,
3335
bch: props => <BchIcon {...props} />,
3436
eth: props => <EthIcon {...props} />,
37+
rbtc: props => <RbtcIcon {...props} />,
38+
xusd: props => <XUSDIcon {...props} />,
3539
doge: props => <DogeIcon {...props} />,
3640
ltc: props => <LtcIcon {...props} />,
3741
xrp: props => <XrpIcon {...props} />,
@@ -71,6 +75,14 @@ export const SupportedCurrencyOptions: Array<SupportedCurrencyOption> = [
7175
hasMultisig: false, // TODO
7276
imgSrc: require('../../assets/img/currencies/png/ETH.png'),
7377
},
78+
{
79+
id: 'rbtc',
80+
img: CurrencyListIcons.rbtc,
81+
currencyName: 'RSK',
82+
currencyAbbreviation: 'RBTC',
83+
hasMultisig: false, // TODO
84+
imgSrc: require('../../assets/img/currencies/png/RBTC.png'),
85+
},
7486
{
7587
id: 'doge',
7688
img: CurrencyListIcons.doge,
@@ -142,6 +154,14 @@ export const SupportedCurrencyOptions: Array<SupportedCurrencyOption> = [
142154
isToken: true,
143155
imgSrc: require('../../assets/img/currencies/png/BUSD.png'),
144156
},
157+
{
158+
id: 'xusd',
159+
img: CurrencyListIcons.xusd,
160+
currencyName: 'Sovryn XUSD',
161+
currencyAbbreviation: 'XUSD',
162+
isToken: true,
163+
imgSrc: require('../../assets/img/currencies/png/xusd.png'),
164+
},
145165
{
146166
id: 'dai',
147167
img: CurrencyListIcons.dai,

src/constants/config.card.ts

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import BUSDShape from '../navigation/card/assets/currency-shapes/BUSD-shape.svg'
88
import DAIShape from '../navigation/card/assets/currency-shapes/DAI-shape.svg';
99
import DOGEShape from '../navigation/card/assets/currency-shapes/DOGE-shape.svg';
1010
import ETHShape from '../navigation/card/assets/currency-shapes/ETH-shape.svg';
11+
import RBTCShape from '../navigation/card/assets/currency-shapes/RBTC-shape.svg';
1112
import GUSDShape from '../navigation/card/assets/currency-shapes/GUSD-shape.svg';
1213
import USDPShape from '../navigation/card/assets/currency-shapes/USDP-shape.svg';
1314
import USDCShape from '../navigation/card/assets/currency-shapes/USDC-shape.svg';
@@ -192,6 +193,18 @@ export const SUPPORTED_DESIGN_CURRENCIES: SupportedDesignCurrenciesConfig = {
192193
pillCircleBackground: '#FFF',
193194
},
194195
},
196+
RBTC: {
197+
currency: 'RBTC',
198+
enabled: true,
199+
palette: {
200+
BackgroundShape: RBTCShape,
201+
stopColor1: '#9A9FF1',
202+
stopColor2: '#575DC2',
203+
pillColor: '#FFF',
204+
pillBackground: '#595FC6',
205+
pillCircleBackground: '#FFF',
206+
},
207+
},
195208
GUSD: {
196209
currency: 'GUSD',
197210
enabled: true,

src/constants/currencies.ts

+115-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type SupportedCoins = 'btc' | 'bch' | 'ltc' | 'doge' | 'eth';
1+
export type SupportedCoins = 'btc' | 'bch' | 'ltc' | 'doge' | 'eth' | 'rbtc';
22
export type SupportedTokens =
33
| 'usdc'
44
| 'gusd'
@@ -8,7 +8,8 @@ export type SupportedTokens =
88
| 'wbtc'
99
| 'shib'
1010
| 'ape'
11-
| 'euroc';
11+
| 'euroc'
12+
| 'xusd';
1213
export type SupportedCurrencies = SupportedCoins | SupportedTokens;
1314

1415
export interface CurrencyOpts {
@@ -168,6 +169,117 @@ export const Currencies: {[key in string]: CurrencyOpts} = {
168169
gradientBackgroundColor: '#6b71d6',
169170
},
170171
},
172+
rbtc: {
173+
name: 'Smart Bitcoin',
174+
chain: 'RSK',
175+
coin: 'rbtc',
176+
unitInfo: {
177+
unitName: 'RBTC',
178+
unitToSatoshi: 1e18,
179+
unitDecimals: 18,
180+
unitCode: 'rbtc'
181+
},
182+
properties: {
183+
hasMultiSig: false,
184+
hasMultiSend: false,
185+
isUtxo: false,
186+
isERCToken: false,
187+
isStableCoin: false,
188+
singleAddress: true
189+
},
190+
paymentInfo: {
191+
paymentCode: 'EIP681',
192+
protocolPrefix: { livenet: 'rsk', testnet: 'rsk' },
193+
ratesApi: 'https://bws.bitpay.com/bws/api/v3/fiatrates/rbtc',
194+
blockExplorerUrls: 'explorer.rsk.co/',
195+
blockExplorerUrlsTestnet: 'explorer.testet.rsk.co/'
196+
},
197+
feeInfo: {
198+
feeUnit: 'Gwei',
199+
feeUnitAmount: 1e9,
200+
blockTime: 0.53,
201+
maxMerchantFee: 'urgent'
202+
},
203+
theme: {
204+
coinColor: '#41d434',
205+
backgroundColor: '#1e90ff',
206+
gradientBackgroundColor: '#1e90ff'
207+
}
208+
},
209+
rsk: { // This entry is because exchange-rates assumes that chain and coin are the same and asks for theme to 'rsk'
210+
name: 'Smart Bitcoin',
211+
chain: 'RSK',
212+
coin: 'rbtc',
213+
unitInfo: {
214+
unitName: 'RBTC',
215+
unitToSatoshi: 1e18,
216+
unitDecimals: 18,
217+
unitCode: 'rbtc'
218+
},
219+
properties: {
220+
hasMultiSig: false,
221+
hasMultiSend: false,
222+
isUtxo: false,
223+
isERCToken: false,
224+
isStableCoin: false,
225+
singleAddress: true
226+
},
227+
paymentInfo: {
228+
paymentCode: 'EIP681',
229+
protocolPrefix: { livenet: 'rsk', testnet: 'rsk' },
230+
ratesApi: 'https://bws.bitpay.com/bws/api/v3/fiatrates/btc',
231+
blockExplorerUrls: 'explorer.rsk.co/',
232+
blockExplorerUrlsTestnet: 'explorer.testet.rsk.co/'
233+
},
234+
feeInfo: {
235+
feeUnit: 'Gwei',
236+
feeUnitAmount: 1e9,
237+
blockTime: 0.53,
238+
maxMerchantFee: 'urgent'
239+
},
240+
theme: {
241+
coinColor: '#41d434',
242+
backgroundColor: '#1e90ff',
243+
gradientBackgroundColor: '#1e90ff'
244+
},
245+
},
246+
xusd: {
247+
name: 'Sovryn XUSD',
248+
chain: 'RSK',
249+
coin: 'xusd',
250+
unitInfo: {
251+
unitName: 'XUSD',
252+
unitToSatoshi: 1e18,
253+
unitDecimals: 18,
254+
unitCode: 'xusd',
255+
},
256+
properties: {
257+
hasMultiSig: false,
258+
hasMultiSend: false,
259+
isUtxo: false,
260+
isERCToken: true,
261+
isStableCoin: true,
262+
singleAddress: true,
263+
},
264+
paymentInfo: {
265+
paymentCode: 'EIP681',
266+
protocolPrefix: { livenet: 'rsk', testnet: 'rsk' },
267+
ratesApi: 'https://bws.bitpay.com/bws/api/v3/fiatrates/xusd',
268+
blockExplorerUrls: 'explorer.rsk.co/',
269+
blockExplorerUrlsTestnet: 'explorer.testet.rsk.co/'
270+
},
271+
feeInfo: {
272+
feeUnit: 'Gwei',
273+
feeUnitAmount: 1e9,
274+
blockTime: 0.2,
275+
maxMerchantFee: 'urgent',
276+
},
277+
theme: {
278+
coinColor: '#f3ba2d',
279+
backgroundColor: 'rgba(135,206,250,1)',
280+
gradientBackgroundColor: 'rgba(30,144,255, 0.2)',
281+
},
282+
},
171283
xrp: {
172284
name: 'XRP',
173285
chain: 'XRP',
@@ -628,7 +740,7 @@ export const SUPPORTED_TOKENS = [
628740
'ape',
629741
'euroc',
630742
];
631-
export const SUPPORTED_COINS = ['btc', 'bch', 'eth', 'doge', 'ltc', 'xrp'];
743+
export const SUPPORTED_COINS = ['btc', 'bch', 'eth', 'rbtc', 'doge', 'ltc', 'xrp'];
632744
export const SUPPORTED_CURRENCIES = [...SUPPORTED_COINS, ...SUPPORTED_TOKENS];
633745
export const POPULAR_TOKENS = [
634746
'UNI',

src/constants/defaultDerivationPath.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export enum DefaultDerivationPath {
22
defaultBTC = "m/44'/0'/0'",
33
defaultBCH = "m/44'/145'/0'",
44
defaultETH = "m/44'/60'/0'",
5+
defaultRBTC = "m/44'/137'/0'",
56
defaultXRP = "m/44'/144'/0'",
67
defaultDOGE = "m/44'/3'/0'",
78
defaultLTC = "m/44'/2'/0'",

src/constants/tokens.ts

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ export const BitpaySupportedTokenOpts: TokenOptsType = {
3232
decimals: 18,
3333
address: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
3434
},
35+
xusd: {
36+
name: 'Sovryn XUSD',
37+
symbol: 'XUSD',
38+
decimals: 18,
39+
address: '0xb5999795BE0EbB5bAb23144AA5FD6A02D080299F',
40+
},
3541
dai: {
3642
name: 'Dai',
3743
symbol: 'DAI',
@@ -89,6 +95,12 @@ export const BitpaySupportedTokenOptsByAddress: TokenOptsType = {
8995
decimals: 18,
9096
address: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
9197
},
98+
'0xb5999795BE0EbB5bAb23144AA5FD6A02D080299F': {
99+
name: 'Sovryn XUSD',
100+
symbol: 'XUSD',
101+
decimals: 18,
102+
address: '0xb5999795BE0EbB5bAb23144AA5FD6A02D080299F',
103+
},
92104
'0x6b175474e89094c44da98b954eedeac495271d0f': {
93105
name: 'Dai',
94106
symbol: 'DAI',

src/navigation/card/assets/currency-shapes/RBTC-shape.svg

+1
Loading

src/navigation/wallet/screens/CurrencySelection.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const DESCRIPTIONS: Record<string, string> = {
129129

130130
const POPULAR_TOKENS: Record<string, string[]> = {
131131
eth: ['usdc', 'busd', 'ape'],
132+
rsk: ['xusd'],
132133
matic: ['usdc', 'busd', 'gusd'],
133134
};
134135

@@ -256,7 +257,7 @@ const CurrencySelection: React.VFC<CurrencySelectionScreenProps> = ({
256257

257258
const tokenData =
258259
Currencies[k] || appTokenData[k] || appCustomTokenData[k];
259-
const chainData = chainMap[tokenData.chain.toLowerCase()];
260+
const chainData = chainMap[tokenData.chain.toLowerCase() === 'rsk' ? 'rbtc' : tokenData.chain.toLowerCase()];
260261
const imgSrc = SupportedCurrencyOptions.find(c => c.id === k)?.imgSrc;
261262
const isReqSrc = (
262263
src: ImageSourcePropType | undefined,

src/navigation/wallet/screens/WalletDetails.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,12 @@ const WalletDetails: React.FC<WalletDetailsScreenProps> = ({route}) => {
714714
? `https://${Currencies.eth.paymentInfo.blockExplorerUrls}address/${address}`
715715
: `https://${Currencies.eth.paymentInfo.blockExplorerUrlsTestnet}address/${address}`;
716716
}
717+
if (coin === 'rbtc') {
718+
url =
719+
fullWalletObj.network === 'livenet'
720+
? `https://${Currencies.rbtc.paymentInfo.blockExplorerUrls}address/${address}`
721+
: `https://${Currencies.rbtc.paymentInfo.blockExplorerUrlsTestnet}address/${address}`;
722+
}
717723
if (dispatch(IsERCToken(coin))) {
718724
url =
719725
fullWalletObj.network === 'livenet'

src/navigation/wallet/screens/send/SendTo.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ const ValidDataTypes: string[] = [
8787
'BitcoinAddress',
8888
'BitcoinCashAddress',
8989
'EthereumAddress',
90+
'RSKAddress',
9091
'RippleAddress',
9192
'DogecoinAddress',
9293
'LitecoinAddress',
9394
'RippleUri',
9495
'BitcoinUri',
9596
'BitcoinCashUri',
9697
'EthereumUri',
98+
'RSKUri',
9799
'DogecoinUri',
98100
'LitecoinUri',
99101
'BitPayUri',

src/store/card/card.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type SupportedCurrencies =
2828
| 'BTC'
2929
| 'BCH'
3030
| 'ETH'
31+
| 'RBTC'
3132
| 'GUSD'
3233
| 'USDP'
3334
| 'BUSD'

src/store/scan/scan.effects.ts

+41
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
IsValidDogecoinUri,
2020
IsValidEthereumAddress,
2121
IsValidEthereumUri,
22+
IsValidRSKAddress,
23+
IsValidRSKUri,
2224
IsValidImportPrivateKey,
2325
IsValidJoinCode,
2426
IsValidLitecoinAddress,
@@ -98,6 +100,9 @@ export const incomingData =
98100
// Ethereum URI
99101
} else if (IsValidEthereumUri(data)) {
100102
dispatch(handleEthereumUri(data, opts?.wallet));
103+
// RSK URI
104+
} else if (IsValidRSKUri(data)) {
105+
dispatch(handleRSKUri(data, opts?.wallet));
101106
// Ripple URI
102107
} else if (IsValidRippleUri(data)) {
103108
dispatch(handleRippleUri(data, opts?.wallet));
@@ -128,6 +133,9 @@ export const incomingData =
128133
// Address (Ethereum)
129134
} else if (IsValidEthereumAddress(data)) {
130135
dispatch(handlePlainAddress(data, coin || 'eth', opts));
136+
// Address RSK
137+
} else if (IsValidRSKAddress(data)) {
138+
dispatch(handlePlainAddress(data, coin || 'rsk' || 'rbtc', opts));
131139
// Address (Ripple)
132140
} else if (IsValidRippleAddress(data)) {
133141
dispatch(handlePlainAddress(data, coin || 'xrp', opts));
@@ -721,6 +729,39 @@ const handleEthereumUri =
721729
}
722730
};
723731

732+
const handleRSKUri =
733+
(data: string, wallet?: Wallet): Effect<void> =>
734+
dispatch => {
735+
dispatch(LogActions.info('[scan] Incoming-data: RSK URI'));
736+
const coin = 'rbtc';
737+
const value = /[\?\&]value=(\d+([\,\.]\d+)?)/i;
738+
const gasPrice = /[\?\&]gasPrice=(\d+([\,\.]\d+)?)/i;
739+
let feePerKb;
740+
if (gasPrice.exec(data)) {
741+
feePerKb = Number(gasPrice.exec(data)![1]);
742+
}
743+
const address = ExtractBitPayUriAddress(data);
744+
const recipient = {
745+
type: 'address',
746+
currency: coin,
747+
address,
748+
};
749+
if (!value.exec(data)) {
750+
dispatch(goToAmount({coin, recipient, wallet, opts: {feePerKb}}));
751+
} else {
752+
const parsedAmount = value.exec(data)![1];
753+
const amount = Number(dispatch(FormatAmount(coin, Number(parsedAmount))));
754+
dispatch(
755+
goToConfirm({
756+
recipient,
757+
amount,
758+
wallet,
759+
opts: {feePerKb},
760+
}),
761+
);
762+
}
763+
};
764+
724765
const handleRippleUri =
725766
(data: string, wallet?: Wallet): Effect<void> =>
726767
dispatch => {

0 commit comments

Comments
 (0)