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

feat(protocol): add rsk protocol #82

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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