@@ -39,6 +39,7 @@ import type { EdgeAsset, StringMap } from '../../../types/types'
39
39
import { sha512HashAndSign } from '../../../util/crypto'
40
40
import { CryptoAmount } from '../../../util/CryptoAmount'
41
41
import { getCurrencyCodeMultiplier } from '../../../util/CurrencyInfoHelpers'
42
+ import { makeUuid } from '../../../util/rnUtils'
42
43
import { removeIsoPrefix } from '../../../util/utils'
43
44
import {
44
45
SendErrorBackPressed ,
@@ -47,7 +48,6 @@ import {
47
48
import type {
48
49
FiatDirection ,
49
50
FiatPaymentType ,
50
- FiatPluginRegionCode ,
51
51
SaveTxActionParams
52
52
} from '../../gui/fiatPluginTypes'
53
53
import type {
@@ -593,19 +593,12 @@ export const paybisRampPlugin: RampPluginFactory = (
593
593
partnerUserId = await pluginConfig . store
594
594
. getItem ( 'partnerUserId' )
595
595
. catch ( ( ) => '' )
596
- if ( partnerUserId === '' && pluginConfig . makeUuid != null ) {
597
- partnerUserId = await pluginConfig . makeUuid ( )
598
- await pluginConfig . store . setItem ( 'partnerUserId' , partnerUserId )
599
- } else if ( partnerUserId === '' ) {
600
- partnerUserId = `edge-user-${ Date . now ( ) } -${ Math . random ( )
601
- . toString ( 36 )
602
- . substring ( 7 ) } `
596
+ if ( partnerUserId === '' ) {
597
+ partnerUserId = await makeUuid ( )
603
598
await pluginConfig . store . setItem ( 'partnerUserId' , partnerUserId )
604
599
}
605
600
} else {
606
- partnerUserId = `edge-user-${ Date . now ( ) } -${ Math . random ( )
607
- . toString ( 36 )
608
- . substring ( 7 ) } `
601
+ partnerUserId = await makeUuid ( )
609
602
}
610
603
611
604
state = {
@@ -629,37 +622,15 @@ export const paybisRampPlugin: RampPluginFactory = (
629
622
}
630
623
}
631
624
632
- const validateSupportRequest = (
633
- regionCode ?: FiatPluginRegionCode ,
634
- countryCode ?: string
635
- ) : { supported : false } | undefined => {
636
- // Check region restrictions
637
- if ( regionCode != null ) {
638
- try {
639
- validateRegion ( pluginId , regionCode , SUPPORTED_REGIONS )
640
- } catch ( error ) {
641
- return { supported : false }
642
- }
643
- }
644
-
645
- // Check country-specific restrictions
646
- if ( countryCode === 'GB' ) {
647
- return { supported : false }
648
- }
649
-
650
- return undefined
651
- }
652
-
653
625
const checkAssetSupport = (
654
626
direction : FiatDirection ,
655
627
fiatCurrencyCode : string ,
656
- cryptoPluginId : string ,
657
- tokenId ?: string | null
628
+ asset : EdgeAsset
658
629
) : { supported : false } | undefined => {
659
630
// Check if crypto is supported
660
631
const paybisCc =
661
- EDGE_TO_PAYBIS_CURRENCY_MAP [ `${ cryptoPluginId } _${ tokenId ?? '' } ` ]
662
- if ( ! paybisCc ) {
632
+ EDGE_TO_PAYBIS_CURRENCY_MAP [ `${ asset . pluginId } _${ asset . tokenId ?? '' } ` ]
633
+ if ( paybisCc == null ) {
663
634
return { supported : false }
664
635
}
665
636
@@ -720,21 +691,20 @@ export const paybisRampPlugin: RampPluginFactory = (
720
691
// Ensure assets are initialized for the direction
721
692
await ensureAssetsInitialized ( direction )
722
693
723
- // Validate region and country restrictions
724
- const regionResult = validateSupportRequest (
725
- regionCode ,
726
- regionCode . countryCode
727
- )
728
- if ( regionResult != null ) {
729
- return regionResult
694
+ // Validate region restrictions
695
+ if ( regionCode != null ) {
696
+ try {
697
+ validateRegion ( pluginId , regionCode , SUPPORTED_REGIONS )
698
+ } catch ( error ) {
699
+ return { supported : false }
700
+ }
730
701
}
731
702
732
703
// Check asset support
733
704
const assetResult = checkAssetSupport (
734
705
direction ,
735
706
`iso:${ fiatAsset . currencyCode } ` ,
736
- cryptoAsset . pluginId ,
737
- cryptoAsset . tokenId
707
+ cryptoAsset
738
708
)
739
709
if ( assetResult != null ) {
740
710
return assetResult
@@ -754,7 +724,7 @@ export const paybisRampPlugin: RampPluginFactory = (
754
724
request : RampQuoteRequest
755
725
) : Promise < RampQuoteResult [ ] > => {
756
726
await ensureStateInitialized ( )
757
- if ( ! state ) throw new Error ( 'Plugin state not initialized' )
727
+ if ( state == null ) throw new Error ( 'Plugin state not initialized' )
758
728
759
729
const {
760
730
amountType,
@@ -769,14 +739,14 @@ export const paybisRampPlugin: RampPluginFactory = (
769
739
tokenId
770
740
} = request
771
741
772
- // Validate region and country restrictions using helper
773
- const regionResult = validateSupportRequest (
774
- regionCode ,
775
- regionCode . countryCode
776
- )
777
- if ( regionResult != null ) {
778
- // Return empty array for unsupported regions
779
- return [ ]
742
+ // Validate region restrictions
743
+ if ( regionCode != null ) {
744
+ try {
745
+ validateRegion ( pluginId , regionCode , SUPPORTED_REGIONS )
746
+ } catch ( error ) {
747
+ // Return empty array for unsupported regions
748
+ return [ ]
749
+ }
780
750
}
781
751
782
752
// Initialize assets for the direction
@@ -820,11 +790,14 @@ export const paybisRampPlugin: RampPluginFactory = (
820
790
const fiat = removeIsoPrefix ( fiatCurrencyCode )
821
791
822
792
// Check asset support using helper
793
+ const cryptoAsset : EdgeAsset = {
794
+ pluginId : currencyPluginId ,
795
+ tokenId : tokenId ?? null
796
+ }
823
797
const assetResult = checkAssetSupport (
824
798
direction ,
825
799
fiatCurrencyCode ,
826
- currencyPluginId ,
827
- tokenId
800
+ cryptoAsset
828
801
)
829
802
if ( assetResult != null ) {
830
803
// Return empty array for unsupported asset pairs
0 commit comments