Skip to content

Commit

Permalink
feat(rsk): add rsk protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
7alip committed Nov 8, 2021
1 parent 6aea81e commit d449c83
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/app/services/token/TokenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
EthereumERC20ProtocolOptions,
EthereumProtocolNetwork,
GenericERC20,
GenericRskERC20,
RskProtocolNetwork,
RskERC20ProtocolConfig,
RskERC20ProtocolOptions,
IAirGapTransaction,
SignedTransaction,
UnsignedTransaction
Expand Down Expand Up @@ -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!')
Expand Down Expand Up @@ -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!')
Expand Down

0 comments on commit d449c83

Please sign in to comment.