@b3dotfun/sdk 0.0.18-alpha.2 → 0.0.18-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +21 -2
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpend.js +21 -2
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +25 -6
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
|
@@ -298,6 +298,26 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
298
298
|
(0, react_4.useEffect)(() => {
|
|
299
299
|
setRecipientAddress(recipientAddressFromProps || globalAddress);
|
|
300
300
|
}, [recipientAddressFromProps, globalAddress]);
|
|
301
|
+
// Get geo-based onramp options for fiat payments
|
|
302
|
+
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(isMainnet, srcAmountOnRamp);
|
|
303
|
+
// Helper function to map payment method to onramp vendor
|
|
304
|
+
const getOnrampVendor = (paymentMethod) => {
|
|
305
|
+
switch (paymentMethod) {
|
|
306
|
+
case FiatPaymentMethod_1.FiatPaymentMethod.COINBASE_PAY:
|
|
307
|
+
return "coinbase";
|
|
308
|
+
case FiatPaymentMethod_1.FiatPaymentMethod.STRIPE:
|
|
309
|
+
// Determine if it's stripe onramp or stripe-web2 based on support
|
|
310
|
+
if (isStripeOnrampSupported) {
|
|
311
|
+
return "stripe";
|
|
312
|
+
}
|
|
313
|
+
else if (stripeWeb2Support?.isSupport) {
|
|
314
|
+
return "stripe-web2";
|
|
315
|
+
}
|
|
316
|
+
return undefined;
|
|
317
|
+
default:
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
301
321
|
// Get anyspend price
|
|
302
322
|
const activeInputAmountInWei = isSrcInputDirty
|
|
303
323
|
? (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals).toString()
|
|
@@ -321,6 +341,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
321
341
|
type: "swap",
|
|
322
342
|
tradeType: "EXACT_INPUT",
|
|
323
343
|
amount: srcAmountOnrampInWei,
|
|
344
|
+
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
324
345
|
});
|
|
325
346
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
326
347
|
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
@@ -525,8 +546,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
525
546
|
sonner_1.toast.error("Failed to create order: " + error.message);
|
|
526
547
|
},
|
|
527
548
|
});
|
|
528
|
-
// Get geo-based onramp options for fiat payments
|
|
529
|
-
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(isMainnet, srcAmountOnRamp);
|
|
530
549
|
// Determine button state and text
|
|
531
550
|
const btnInfo = (0, react_4.useMemo)(() => {
|
|
532
551
|
if (activeInputAmountInWei === "0")
|
|
@@ -18,8 +18,8 @@ function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
18
18
|
const getFeeFromApi = (paymentMethod) => {
|
|
19
19
|
switch (paymentMethod) {
|
|
20
20
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
21
|
-
// Coinbase doesn't provide fee info in API,
|
|
22
|
-
return
|
|
21
|
+
// Coinbase doesn't provide fee info in API, return null
|
|
22
|
+
return null;
|
|
23
23
|
case FiatPaymentMethod.STRIPE:
|
|
24
24
|
// Get fee from Stripe API response
|
|
25
25
|
if (stripeWeb2Support && "formattedFeeUsd" in stripeWeb2Support) {
|
|
@@ -291,6 +291,26 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
291
291
|
useEffect(() => {
|
|
292
292
|
setRecipientAddress(recipientAddressFromProps || globalAddress);
|
|
293
293
|
}, [recipientAddressFromProps, globalAddress]);
|
|
294
|
+
// Get geo-based onramp options for fiat payments
|
|
295
|
+
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = useGeoOnrampOptions(isMainnet, srcAmountOnRamp);
|
|
296
|
+
// Helper function to map payment method to onramp vendor
|
|
297
|
+
const getOnrampVendor = (paymentMethod) => {
|
|
298
|
+
switch (paymentMethod) {
|
|
299
|
+
case FiatPaymentMethod.COINBASE_PAY:
|
|
300
|
+
return "coinbase";
|
|
301
|
+
case FiatPaymentMethod.STRIPE:
|
|
302
|
+
// Determine if it's stripe onramp or stripe-web2 based on support
|
|
303
|
+
if (isStripeOnrampSupported) {
|
|
304
|
+
return "stripe";
|
|
305
|
+
}
|
|
306
|
+
else if (stripeWeb2Support?.isSupport) {
|
|
307
|
+
return "stripe-web2";
|
|
308
|
+
}
|
|
309
|
+
return undefined;
|
|
310
|
+
default:
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
294
314
|
// Get anyspend price
|
|
295
315
|
const activeInputAmountInWei = isSrcInputDirty
|
|
296
316
|
? parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals).toString()
|
|
@@ -314,6 +334,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
314
334
|
type: "swap",
|
|
315
335
|
tradeType: "EXACT_INPUT",
|
|
316
336
|
amount: srcAmountOnrampInWei,
|
|
337
|
+
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
317
338
|
});
|
|
318
339
|
const recipientProfile = useProfile({ address: recipientAddress });
|
|
319
340
|
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
@@ -518,8 +539,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
518
539
|
toast.error("Failed to create order: " + error.message);
|
|
519
540
|
},
|
|
520
541
|
});
|
|
521
|
-
// Get geo-based onramp options for fiat payments
|
|
522
|
-
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = useGeoOnrampOptions(isMainnet, srcAmountOnRamp);
|
|
523
542
|
// Determine button state and text
|
|
524
543
|
const btnInfo = useMemo(() => {
|
|
525
544
|
if (activeInputAmountInWei === "0")
|
|
@@ -14,8 +14,8 @@ export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedP
|
|
|
14
14
|
const getFeeFromApi = (paymentMethod) => {
|
|
15
15
|
switch (paymentMethod) {
|
|
16
16
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
17
|
-
// Coinbase doesn't provide fee info in API,
|
|
18
|
-
return
|
|
17
|
+
// Coinbase doesn't provide fee info in API, return null
|
|
18
|
+
return null;
|
|
19
19
|
case FiatPaymentMethod.STRIPE:
|
|
20
20
|
// Get fee from Stripe API response
|
|
21
21
|
if (stripeWeb2Support && "formattedFeeUsd" in stripeWeb2Support) {
|
package/package.json
CHANGED
|
@@ -411,6 +411,30 @@ function AnySpendInner({
|
|
|
411
411
|
setRecipientAddress(recipientAddressFromProps || globalAddress);
|
|
412
412
|
}, [recipientAddressFromProps, globalAddress]);
|
|
413
413
|
|
|
414
|
+
// Get geo-based onramp options for fiat payments
|
|
415
|
+
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = useGeoOnrampOptions(
|
|
416
|
+
isMainnet,
|
|
417
|
+
srcAmountOnRamp,
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
// Helper function to map payment method to onramp vendor
|
|
421
|
+
const getOnrampVendor = (paymentMethod: FiatPaymentMethod): "coinbase" | "stripe" | "stripe-web2" | undefined => {
|
|
422
|
+
switch (paymentMethod) {
|
|
423
|
+
case FiatPaymentMethod.COINBASE_PAY:
|
|
424
|
+
return "coinbase";
|
|
425
|
+
case FiatPaymentMethod.STRIPE:
|
|
426
|
+
// Determine if it's stripe onramp or stripe-web2 based on support
|
|
427
|
+
if (isStripeOnrampSupported) {
|
|
428
|
+
return "stripe";
|
|
429
|
+
} else if (stripeWeb2Support?.isSupport) {
|
|
430
|
+
return "stripe-web2";
|
|
431
|
+
}
|
|
432
|
+
return undefined;
|
|
433
|
+
default:
|
|
434
|
+
return undefined;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
|
|
414
438
|
// Get anyspend price
|
|
415
439
|
const activeInputAmountInWei = isSrcInputDirty
|
|
416
440
|
? parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals).toString()
|
|
@@ -436,6 +460,7 @@ function AnySpendInner({
|
|
|
436
460
|
type: "swap",
|
|
437
461
|
tradeType: "EXACT_INPUT",
|
|
438
462
|
amount: srcAmountOnrampInWei,
|
|
463
|
+
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
439
464
|
},
|
|
440
465
|
);
|
|
441
466
|
|
|
@@ -662,12 +687,6 @@ function AnySpendInner({
|
|
|
662
687
|
},
|
|
663
688
|
});
|
|
664
689
|
|
|
665
|
-
// Get geo-based onramp options for fiat payments
|
|
666
|
-
const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = useGeoOnrampOptions(
|
|
667
|
-
isMainnet,
|
|
668
|
-
srcAmountOnRamp,
|
|
669
|
-
);
|
|
670
|
-
|
|
671
690
|
// Determine button state and text
|
|
672
691
|
const btnInfo: { text: string; disable: boolean; error: boolean } = useMemo(() => {
|
|
673
692
|
if (activeInputAmountInWei === "0") return { text: "Enter an amount", disable: true, error: false };
|
|
@@ -31,8 +31,8 @@ export function FiatPaymentMethodComponent({
|
|
|
31
31
|
const getFeeFromApi = (paymentMethod: FiatPaymentMethod): string | null => {
|
|
32
32
|
switch (paymentMethod) {
|
|
33
33
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
34
|
-
// Coinbase doesn't provide fee info in API,
|
|
35
|
-
return
|
|
34
|
+
// Coinbase doesn't provide fee info in API, return null
|
|
35
|
+
return null;
|
|
36
36
|
case FiatPaymentMethod.STRIPE:
|
|
37
37
|
// Get fee from Stripe API response
|
|
38
38
|
if (stripeWeb2Support && "formattedFeeUsd" in stripeWeb2Support) {
|