From bcf88c199c5db10e93d4e8b6a48bc927b8b30d9c Mon Sep 17 00:00:00 2001 From: 7alip Date: Mon, 28 Jun 2021 10:22:34 +0200 Subject: [PATCH] feat(rsk): add rsk protocol --- src/app/services/token/TokenService.ts | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/app/services/token/TokenService.ts b/src/app/services/token/TokenService.ts index 0a7f17ff..96de4dc7 100644 --- a/src/app/services/token/TokenService.ts +++ b/src/app/services/token/TokenService.ts @@ -5,6 +5,10 @@ import { EthereumERC20ProtocolOptions, EthereumProtocolNetwork, GenericERC20, + GenericRskERC20, + RskProtocolNetwork, + RskERC20ProtocolConfig, + RskERC20ProtocolOptions, IAirGapTransaction, SignedTransaction, UnsignedTransaction @@ -35,7 +39,23 @@ export class TokenService { ) ) - const transactions: IAirGapTransaction[] = await genericErc20.getTransactionDetailsFromSigned(signedTransaction) + const genericRskERC20: GenericRskERC20 = new GenericRskERC20( + new RskERC20ProtocolOptions( + new RskProtocolNetwork(), + new RskERC20ProtocolConfig( + token.symbol, + token.name, + token.marketSymbol, + token.identifier as SubProtocolSymbols, + token.contractAddress, + token.decimals + ) + ) + ) + + const ethTransactions: IAirGapTransaction[] = await genericErc20.getTransactionDetailsFromSigned(signedTransaction) + const rskTransactions: IAirGapTransaction[] = await genericRskERC20.getTransactionDetailsFromSigned(signedTransaction) + const transactions: IAirGapTransaction[] = ethTransactions.concat(rskTransactions) if (transactions.length !== 1) { throw Error('TokenTransferDetails returned more than 1 transaction!') @@ -64,7 +84,23 @@ export class TokenService { ) ) - const transactions: IAirGapTransaction[] = await genericErc20.getTransactionDetails(unsignedTransaction) + const genericRskERC20: GenericRskERC20 = new GenericRskERC20( + new RskERC20ProtocolOptions( + new RskProtocolNetwork(), + new RskERC20ProtocolConfig( + token.symbol, + token.name, + token.marketSymbol, + token.identifier as SubProtocolSymbols, + token.contractAddress, + token.decimals + ) + ) + ) + + const ethTransactions: IAirGapTransaction[] = await genericErc20.getTransactionDetails(unsignedTransaction) + const rskTransactions: IAirGapTransaction[] = await genericRskERC20.getTransactionDetails(unsignedTransaction) + const transactions: IAirGapTransaction[] = ethTransactions.concat(rskTransactions) if (transactions.length !== 1) { throw Error('TokenTransferDetails returned more than 1 transaction!')