import { Injectable } from '@angular/core' ; import { BlockchainsBridgeProvider } from 'src/app/features/bridge/services/bridge-service/blockchains-bridge-provider/common/blockchains-bridge-provider' ; import { first } from 'rxjs/operators' ; import { BridgeTokenPair } from '@features/bridge/models/bridge-token-pair' ; import { BRIDGE_PROVIDER } from '@shared/models/bridge/bridge-provider' ; import { BLOCKCHAIN_NAME } from '@shared/models/blockchain/blockchain-name' ; import { Observable } from 'rxjs' ; import { BridgeTrade } from '@features/bridge/models/bridge-trade' ; import { TransactionReceipt } from 'web3-eth' ; import { UnknownError } from '@core/errors/models/unknown.error' ; import { BinancePolygonRubicBridgeProviderService } from '@features/bridge/services/bridge-service/blockchains-bridge-provider/binance-polygon-bridge-provider/binance-polygon-rubic-bridge-provider/binance-polygon-rubic-bridge-provider.service' ; @ Injectable ( ) export class BinancePolygonBridgeProviderService extends BlockchainsBridgeProvider { constructor ( private readonly rubicBridgeProvider ) { super ( ) ; this . rubicBridgeProvider . tokenPairs$ . pipe ( first ( ) ) . subscribe ( rubicToken => this . _tokenPairs$ . next ( rubicToken ) ) ; } public getProviderType ( token ? ) { if ( this . isRBCToken ( token ?. symbol ) ) { return BRIDGE_PROVIDER . SWAP_RBC ; } throw new UnknownError ( ) ; } public getFee ( tokenPair , toBlockchain ) { if ( this . isRBCToken ( tokenPair . symbol ) ) { return this . rubicBridgeProvider . getFee ( tokenPair , toBlockchain ) ; } throw new UnknownError ( ) ; } public createTrade ( bridgeTrade ) { if ( this . isRBCToken ( bridgeTrade . token . symbol ) ) { return this . rubicBridgeProvider . createTrade ( bridgeTrade ) ; } throw new UnknownError ( ) ; } public approve ( bridgeTrade ) { if ( this . isRBCToken ( bridgeTrade . token . symbol ) ) { return this . rubicBridgeProvider . approve ( bridgeTrade ) ; } throw new UnknownError ( ) ; } public needApprove ( bridgeTrade ) { if ( this . isRBCToken ( bridgeTrade . token . symbol ) ) { return this . rubicBridgeProvider . needApprove ( bridgeTrade ) ; } throw new UnknownError ( ) ; } private isRBCToken ( symbol ) { return symbol === 'RBC' ; } }