@b3dotfun/sdk 0.0.23 → 0.0.24
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 +5 -8
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +35 -28
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +35 -28
- package/dist/cjs/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/Accordion.js +53 -0
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +3 -22
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +76 -83
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +1 -5
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +2 -2
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +2 -4
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +0 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +1332 -0
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +514 -0
- package/dist/cjs/bondkit/abis/index.d.ts +2 -0
- package/dist/cjs/bondkit/abis/index.js +18 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +68 -0
- package/dist/cjs/bondkit/bondkitToken.js +456 -0
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/cjs/bondkit/bondkitTokenFactory.js +274 -0
- package/dist/cjs/bondkit/components/TradingView.d.ts +3 -0
- package/dist/cjs/bondkit/components/TradingView.js +296 -0
- package/dist/cjs/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/cjs/bondkit/components/config/cdn.js +63 -0
- package/dist/cjs/bondkit/components/index.d.ts +5 -0
- package/dist/cjs/bondkit/components/index.js +25 -0
- package/dist/cjs/bondkit/components/types.d.ts +8 -0
- package/dist/cjs/bondkit/components/types.js +5 -0
- package/dist/cjs/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/cjs/bondkit/components/utils/cdn-loader.js +73 -0
- package/dist/cjs/bondkit/components/utils/format.d.ts +4 -0
- package/dist/cjs/bondkit/components/utils/format.js +31 -0
- package/dist/cjs/bondkit/config.d.ts +10 -0
- package/dist/cjs/bondkit/config.js +18 -0
- package/dist/cjs/bondkit/constants.d.ts +3 -0
- package/dist/cjs/bondkit/constants.js +5 -0
- package/dist/cjs/bondkit/index.d.ts +7 -0
- package/dist/cjs/bondkit/index.js +33 -0
- package/dist/cjs/bondkit/json_abis/BondkitABI.json +1329 -0
- package/dist/cjs/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/dist/cjs/bondkit/json_abis/index.d.ts +3 -0
- package/dist/cjs/bondkit/json_abis/index.js +10 -0
- package/dist/cjs/bondkit/json_abis/index.ts +4 -0
- package/dist/cjs/bondkit/types.d.ts +77 -0
- package/dist/cjs/bondkit/types.js +11 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/MintButton/MintButton.js +0 -1
- package/dist/cjs/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/cjs/global-account/react/components/SendERC20Button/SendERC20Button.js +33 -0
- package/dist/cjs/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/cjs/global-account/react/components/SendETHButton/SendETHButton.js +23 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +4 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +8 -2
- package/dist/cjs/global-account/react/components/ui/scroll-area.js +1 -1
- package/dist/cjs/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +18 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +8 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -4
- package/dist/cjs/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/cjs/global-account/react/hooks/useChainSwitchWithAction.js +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.js +9 -7
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +160 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -0
- package/dist/cjs/shared/constants/chains/supported.js +11 -0
- package/dist/cjs/shared/generated/chain-networks.json +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +5 -8
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +37 -30
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +37 -30
- package/dist/esm/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/Accordion.js +14 -0
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +3 -22
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +79 -86
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +5 -4
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -5
- package/dist/esm/anyspend/react/components/common/StepProgress.js +2 -2
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +2 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +0 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +1329 -0
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +511 -0
- package/dist/esm/bondkit/abis/index.d.ts +2 -0
- package/dist/esm/bondkit/abis/index.js +2 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +68 -0
- package/dist/esm/bondkit/bondkitToken.js +452 -0
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/esm/bondkit/bondkitTokenFactory.js +270 -0
- package/dist/esm/bondkit/components/TradingView.d.ts +3 -0
- package/dist/esm/bondkit/components/TradingView.js +294 -0
- package/dist/esm/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/esm/bondkit/components/config/cdn.js +55 -0
- package/dist/esm/bondkit/components/index.d.ts +5 -0
- package/dist/esm/bondkit/components/index.js +4 -0
- package/dist/esm/bondkit/components/types.d.ts +8 -0
- package/dist/esm/bondkit/components/types.js +4 -0
- package/dist/esm/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/esm/bondkit/components/utils/cdn-loader.js +66 -0
- package/dist/esm/bondkit/components/utils/format.d.ts +4 -0
- package/dist/esm/bondkit/components/utils/format.js +28 -0
- package/dist/esm/bondkit/config.d.ts +10 -0
- package/dist/esm/bondkit/config.js +14 -0
- package/dist/esm/bondkit/constants.d.ts +3 -0
- package/dist/esm/bondkit/constants.js +2 -0
- package/dist/esm/bondkit/index.d.ts +7 -0
- package/dist/esm/bondkit/index.js +12 -0
- package/dist/esm/bondkit/json_abis/BondkitABI.json +1329 -0
- package/dist/esm/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/dist/esm/bondkit/json_abis/index.d.ts +3 -0
- package/dist/esm/bondkit/json_abis/index.js +3 -0
- package/dist/esm/bondkit/json_abis/index.ts +4 -0
- package/dist/esm/bondkit/types.d.ts +77 -0
- package/dist/esm/bondkit/types.js +8 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/MintButton/MintButton.js +0 -1
- package/dist/esm/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/esm/global-account/react/components/SendERC20Button/SendERC20Button.js +30 -0
- package/dist/esm/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/esm/global-account/react/components/SendETHButton/SendETHButton.js +20 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +4 -0
- package/dist/esm/global-account/react/components/ui/scroll-area.js +1 -1
- package/dist/esm/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +8 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -4
- package/dist/esm/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/esm/global-account/react/hooks/useChainSwitchWithAction.js +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.js +9 -7
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +154 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -0
- package/dist/esm/shared/constants/chains/supported.js +10 -0
- package/dist/esm/shared/generated/chain-networks.json +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/types/bondkit/abis/index.d.ts +2 -0
- package/dist/types/bondkit/bondkitToken.d.ts +68 -0
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/types/bondkit/components/TradingView.d.ts +3 -0
- package/dist/types/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/types/bondkit/components/index.d.ts +5 -0
- package/dist/types/bondkit/components/types.d.ts +8 -0
- package/dist/types/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/types/bondkit/components/utils/format.d.ts +4 -0
- package/dist/types/bondkit/config.d.ts +10 -0
- package/dist/types/bondkit/constants.d.ts +3 -0
- package/dist/types/bondkit/index.d.ts +7 -0
- package/dist/types/bondkit/json_abis/index.d.ts +3 -0
- package/dist/types/bondkit/types.d.ts +77 -0
- package/dist/types/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/types/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/types/shared/constants/chains/supported.d.ts +4 -0
- package/package.json +42 -7
- package/src/anyspend/react/components/AnySpend.tsx +5 -23
- package/src/anyspend/react/components/AnySpendBondKit.tsx +2 -2
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +42 -32
- package/src/anyspend/react/components/AnySpendCustom.tsx +7 -13
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +44 -34
- package/src/anyspend/react/components/common/Accordion.tsx +56 -0
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +0 -25
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +1 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +292 -260
- package/src/anyspend/react/components/common/OrderStatus.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +7 -7
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +0 -6
- package/src/anyspend/react/components/common/StepProgress.tsx +2 -2
- package/src/anyspend/react/components/common/TokenBalance.tsx +3 -3
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +2 -4
- package/src/anyspend/react/hooks/useStripeSupport.ts +0 -1
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/bondkit/abis/BondkitTokenABI.ts +1329 -0
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +511 -0
- package/src/bondkit/abis/index.ts +2 -0
- package/src/bondkit/bondkitToken.ts +539 -0
- package/src/bondkit/bondkitTokenFactory.ts +336 -0
- package/src/bondkit/components/TradingView.tsx +341 -0
- package/src/bondkit/components/config/cdn.ts +63 -0
- package/src/bondkit/components/index.ts +5 -0
- package/src/bondkit/components/types.ts +9 -0
- package/src/bondkit/components/utils/cdn-loader.ts +77 -0
- package/src/bondkit/components/utils/format.ts +36 -0
- package/src/bondkit/config.ts +26 -0
- package/src/bondkit/constants.ts +5 -0
- package/src/bondkit/index.ts +16 -0
- package/src/bondkit/json_abis/BondkitABI.json +1329 -0
- package/src/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/src/bondkit/json_abis/index.ts +4 -0
- package/src/bondkit/types.ts +98 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +2 -1
- package/src/global-account/react/components/MintButton/MintButton.tsx +0 -1
- package/src/global-account/react/components/SendERC20Button/SendERC20Button.tsx +57 -0
- package/src/global-account/react/components/SendETHButton/SendETHButton.tsx +37 -0
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +21 -22
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/index.ts +6 -0
- package/src/global-account/react/components/ui/scroll-area.tsx +2 -2
- package/src/global-account/react/components/ui/tooltip.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAccountWallet.tsx +10 -1
- package/src/global-account/react/hooks/useAuthentication.ts +4 -4
- package/src/global-account/react/hooks/useChainSwitchWithAction.ts +3 -4
- package/src/global-account/react/hooks/useFirstEOA.tsx +10 -7
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +186 -0
- package/src/shared/constants/chains/supported.ts +11 -0
- package/src/shared/generated/chain-networks.json +1 -1
- package/src/styles/index.css +27 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
export type TokenDetails = {
|
|
3
|
+
name: string;
|
|
4
|
+
symbol: string;
|
|
5
|
+
decimals: number;
|
|
6
|
+
totalSupply: bigint;
|
|
7
|
+
owner: Address;
|
|
8
|
+
};
|
|
9
|
+
export type BondkitTokenConfig = {
|
|
10
|
+
name: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
feeRecipient: Address;
|
|
13
|
+
finalTokenSupply: bigint;
|
|
14
|
+
aggressivenessFactor: number;
|
|
15
|
+
lpSplitRatioFeeRecipientBps: bigint;
|
|
16
|
+
targetEth: bigint;
|
|
17
|
+
uniswapV2RouterAddress: Address;
|
|
18
|
+
migrationAdminAddress: Address;
|
|
19
|
+
};
|
|
20
|
+
export type BondkitTokenCreatedEventArgs = {
|
|
21
|
+
tokenAddress: Address;
|
|
22
|
+
implementationAddress: Address;
|
|
23
|
+
name: string;
|
|
24
|
+
symbol: string;
|
|
25
|
+
feeRecipient: Address;
|
|
26
|
+
migrationAdmin: Address;
|
|
27
|
+
};
|
|
28
|
+
export type BondkitTokenInitializationConfig = BondkitTokenConfig;
|
|
29
|
+
export type BoughtEventArgs = {
|
|
30
|
+
buyer: Address;
|
|
31
|
+
ethIn: bigint;
|
|
32
|
+
tokensOut: bigint;
|
|
33
|
+
feeRecipientFee: bigint;
|
|
34
|
+
};
|
|
35
|
+
export type SoldEventArgs = {
|
|
36
|
+
seller: Address;
|
|
37
|
+
tokensIn: bigint;
|
|
38
|
+
ethOut: bigint;
|
|
39
|
+
feeRecipientFee: bigint;
|
|
40
|
+
};
|
|
41
|
+
export type DexMigrationEventArgs = {
|
|
42
|
+
ethForLp: bigint;
|
|
43
|
+
tokensForLp: bigint;
|
|
44
|
+
ethForFeeRecipient: bigint;
|
|
45
|
+
};
|
|
46
|
+
export declare enum TokenStatus {
|
|
47
|
+
Inactive = 0,// Assuming mapping from ABI, verify actual enum values if specified elsewhere
|
|
48
|
+
BondingPhase = 1,
|
|
49
|
+
DexPhase = 2,
|
|
50
|
+
Migrated = 3
|
|
51
|
+
}
|
|
52
|
+
export interface GetTransactionHistoryOptions {
|
|
53
|
+
userAddress?: Address;
|
|
54
|
+
type?: "buy" | "sell";
|
|
55
|
+
from?: number;
|
|
56
|
+
to?: number;
|
|
57
|
+
limit?: number;
|
|
58
|
+
offset?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface Transaction {
|
|
61
|
+
timestamp: number;
|
|
62
|
+
price: number;
|
|
63
|
+
amount: string;
|
|
64
|
+
type: "buy" | "sell";
|
|
65
|
+
userAddress: Address;
|
|
66
|
+
txHash: Hex;
|
|
67
|
+
chainId: number;
|
|
68
|
+
blockNumber?: number;
|
|
69
|
+
totalEthRaisedBonding?: string;
|
|
70
|
+
value?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface TransactionResponse {
|
|
73
|
+
total: number;
|
|
74
|
+
limit: number;
|
|
75
|
+
skip: number;
|
|
76
|
+
data: Transaction[];
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
interface SendERC20ButtonProps {
|
|
3
|
+
chainId: number;
|
|
4
|
+
to: `0x${string}`;
|
|
5
|
+
tokenAddress: `0x${string}`;
|
|
6
|
+
amount: bigint;
|
|
7
|
+
className?: string;
|
|
8
|
+
children?: string | JSX.Element;
|
|
9
|
+
onSuccess?: (tx: `0x${string}`) => void;
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function SendERC20Button({ chainId, to, tokenAddress, amount, className, children, onSuccess, onError, }: SendERC20ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
interface SendETHButtonProps {
|
|
3
|
+
chainId: number;
|
|
4
|
+
to: `0x${string}`;
|
|
5
|
+
value: bigint;
|
|
6
|
+
className?: string;
|
|
7
|
+
children?: string | JSX.Element;
|
|
8
|
+
onSuccess?: (tx: `0x${string}`) => void;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function SendETHButton({ chainId, to, value, className, children, onSuccess, onError }: SendETHButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -17,6 +17,8 @@ export { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
|
17
17
|
export { RequestPermissionsButton } from "./RequestPermissions/RequestPermissionsButton";
|
|
18
18
|
export { AccountAssets } from "./AccountAssets/AccountAssets";
|
|
19
19
|
export { MintButton } from "./MintButton/MintButton";
|
|
20
|
+
export { SendETHButton } from "./SendETHButton/SendETHButton";
|
|
21
|
+
export { SendERC20Button } from "./SendERC20Button/SendERC20Button";
|
|
20
22
|
export { TransakModal } from "./Transak/TransakModal";
|
|
21
23
|
export { Button as CustomButton, buttonVariants as customButtonVariants } from "./custom/Button";
|
|
22
24
|
export { ClientOnly } from "./custom/ClientOnly";
|
|
@@ -3,5 +3,5 @@ import * as React from "react";
|
|
|
3
3
|
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
4
4
|
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
5
5
|
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
-
declare const TooltipContent: React.ForwardRefExoticComponent<
|
|
6
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
7
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -6,7 +6,7 @@ export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
|
6
6
|
export { useB3EnsName } from "./useB3EnsName";
|
|
7
7
|
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
8
8
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
9
|
-
export
|
|
9
|
+
export * from "./useClaim";
|
|
10
10
|
export { useConnect } from "./useConnect";
|
|
11
11
|
export { useExchangeRate } from "./useExchangeRate";
|
|
12
12
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
@@ -32,4 +32,5 @@ export { useTokenFromUrl } from "./useTokenFromUrl";
|
|
|
32
32
|
export { useTokenPrice } from "./useTokenPrice";
|
|
33
33
|
export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback";
|
|
34
34
|
export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
35
|
+
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
35
36
|
export { useURLParams } from "./useURLParams";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WalletClient } from "viem";
|
|
2
1
|
export declare function useChainSwitchWithAction(): {
|
|
3
|
-
switchChainAndExecute: (targetChainId: number, action: (
|
|
2
|
+
switchChainAndExecute: (targetChainId: number, action: () => Promise<void>) => Promise<void>;
|
|
4
3
|
isSwitchingOrExecuting: boolean;
|
|
5
4
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface UnifiedTransactionParams {
|
|
2
|
+
to: string;
|
|
3
|
+
data?: string;
|
|
4
|
+
value: bigint;
|
|
5
|
+
}
|
|
6
|
+
export declare function useUnifiedChainSwitchAndExecute(): {
|
|
7
|
+
switchChainAndExecute: (targetChainId: number, params: UnifiedTransactionParams) => Promise<string | undefined>;
|
|
8
|
+
isSwitchingOrExecuting: boolean;
|
|
9
|
+
isActiveSmartWallet: boolean | undefined;
|
|
10
|
+
isActiveEOAWallet: boolean | undefined;
|
|
11
|
+
};
|
|
@@ -62,3 +62,7 @@ export declare const b3TestnetThirdWeb: Readonly<import("thirdweb/dist/types/cha
|
|
|
62
62
|
export declare const b3Mainnet: import("viem").Chain;
|
|
63
63
|
export declare const b3Testnet: import("viem").Chain;
|
|
64
64
|
export declare const baseMainnet: import("viem").Chain;
|
|
65
|
+
/**
|
|
66
|
+
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
67
|
+
*/
|
|
68
|
+
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -65,6 +65,36 @@
|
|
|
65
65
|
"import": "./dist/esm/anyspend/abis/*.js",
|
|
66
66
|
"require": "./dist/cjs/anyspend/abis/*.js"
|
|
67
67
|
},
|
|
68
|
+
"./bondkit": {
|
|
69
|
+
"types": "./dist/types/bondkit/index.d.ts",
|
|
70
|
+
"import": "./dist/esm/bondkit/index.js",
|
|
71
|
+
"require": "./dist/cjs/bondkit/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./bondkit/types": {
|
|
74
|
+
"types": "./dist/types/bondkit/types.d.ts",
|
|
75
|
+
"import": "./dist/esm/bondkit/types.js",
|
|
76
|
+
"require": "./dist/cjs/bondkit/types.js"
|
|
77
|
+
},
|
|
78
|
+
"./bondkit/constants": {
|
|
79
|
+
"types": "./dist/types/bondkit/constants.d.ts",
|
|
80
|
+
"import": "./dist/esm/bondkit/constants.js",
|
|
81
|
+
"require": "./dist/cjs/bondkit/constants.js"
|
|
82
|
+
},
|
|
83
|
+
"./bondkit/config": {
|
|
84
|
+
"types": "./dist/types/bondkit/config.d.ts",
|
|
85
|
+
"import": "./dist/esm/bondkit/config.js",
|
|
86
|
+
"require": "./dist/cjs/bondkit/config.js"
|
|
87
|
+
},
|
|
88
|
+
"./bondkit/abis": {
|
|
89
|
+
"types": "./dist/types/bondkit/abis/index.d.ts",
|
|
90
|
+
"import": "./dist/esm/bondkit/abis/index.js",
|
|
91
|
+
"require": "./dist/cjs/bondkit/abis/index.js"
|
|
92
|
+
},
|
|
93
|
+
"./bondkit/abis/*": {
|
|
94
|
+
"types": "./dist/types/bondkit/abis/*.d.ts",
|
|
95
|
+
"import": "./dist/esm/bondkit/abis/*.js",
|
|
96
|
+
"require": "./dist/cjs/bondkit/abis/*.js"
|
|
97
|
+
},
|
|
68
98
|
"./global-account": {
|
|
69
99
|
"react-native": {
|
|
70
100
|
"types": "./dist/types/global-account/index.native.d.ts",
|
|
@@ -179,6 +209,11 @@
|
|
|
179
209
|
"types": "./dist/types/generated/chain-networks.d.ts",
|
|
180
210
|
"import": "./dist/esm/generated/chain-networks.js",
|
|
181
211
|
"require": "./dist/cjs/generated/chain-networks.js"
|
|
212
|
+
},
|
|
213
|
+
"./bondkit/components/TradingView/TradingView": {
|
|
214
|
+
"types": "./dist/types/bondkit/components/TradingView/TradingView.d.ts",
|
|
215
|
+
"import": "./dist/esm/bondkit/components/TradingView/TradingView.js",
|
|
216
|
+
"require": "./dist/cjs/bondkit/components/TradingView/TradingView.js"
|
|
182
217
|
}
|
|
183
218
|
},
|
|
184
219
|
"files": [
|
|
@@ -191,9 +226,8 @@
|
|
|
191
226
|
],
|
|
192
227
|
"dependencies": {
|
|
193
228
|
"@amplitude/analytics-browser": "2.14.0",
|
|
194
|
-
"@b3dotfun/b3-api": "0.0.
|
|
229
|
+
"@b3dotfun/b3-api": "0.0.41",
|
|
195
230
|
"@b3dotfun/basement-api": "0.0.11",
|
|
196
|
-
"@b3dotfun/bondkit": "^0.1.17",
|
|
197
231
|
"@chakra-ui/react": "2.10.7",
|
|
198
232
|
"@feathersjs/authentication-client": "5.0.33",
|
|
199
233
|
"@feathersjs/feathers": "5.0.33",
|
|
@@ -203,13 +237,14 @@
|
|
|
203
237
|
"@hey-api/client-fetch": "0.8.3",
|
|
204
238
|
"@hey-api/openapi-ts": "0.64.13",
|
|
205
239
|
"@lottiefiles/dotlottie-react": "0.7.2",
|
|
240
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
206
241
|
"@radix-ui/react-dialog": "1.1.7",
|
|
207
242
|
"@radix-ui/react-popover": "1.1.7",
|
|
208
243
|
"@radix-ui/react-scroll-area": "1.1.0",
|
|
209
244
|
"@radix-ui/react-slot": "1.1.2",
|
|
210
245
|
"@radix-ui/react-tabs": "1.1.3",
|
|
211
246
|
"@radix-ui/react-tooltip": "1.1.8",
|
|
212
|
-
"@reservoir0x/relay-kit-ui": "2.15.
|
|
247
|
+
"@reservoir0x/relay-kit-ui": "2.15.11",
|
|
213
248
|
"@reservoir0x/relay-sdk": "2.3.1",
|
|
214
249
|
"@reservoir0x/reservoir-kit-ui": "2.8.7",
|
|
215
250
|
"@solana/spl-token": "^0.4.13",
|
|
@@ -240,7 +275,7 @@
|
|
|
240
275
|
"thirdweb": "5.105.20",
|
|
241
276
|
"typescript": "5.8.2",
|
|
242
277
|
"vaul": "^1.1.2",
|
|
243
|
-
"viem": "2.
|
|
278
|
+
"viem": "2.28.1",
|
|
244
279
|
"wagmi": "2.14.15",
|
|
245
280
|
"zod": "3.25.51",
|
|
246
281
|
"zustand": "4.5.6"
|
|
@@ -314,8 +349,8 @@
|
|
|
314
349
|
"fix-dist": "[ -d ./dist/react/src ] && cp -r ./dist/react/src/* ./dist/ && rm -rf ./dist/react || echo \"No react directory found\"",
|
|
315
350
|
"build": "pnpm clean && pnpm lint && pnpm build:types && pnpm build:cjs && pnpm build:esm && pnpm build:css",
|
|
316
351
|
"build:types": "tsc -p tsconfig.cjs.json --emitDeclarationOnly --declarationDir dist/types",
|
|
317
|
-
"build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/",
|
|
318
|
-
"build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && node scripts/fix-esm-imports.js",
|
|
352
|
+
"build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/ && ([ -d src/bondkit/json_abis ] && mkdir -p dist/cjs/bondkit/json_abis && cp -r src/bondkit/json_abis/* dist/cjs/bondkit/json_abis/ || echo \"No bondkit json_abis\")",
|
|
353
|
+
"build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && ([ -d src/bondkit/json_abis ] && mkdir -p dist/esm/bondkit/json_abis && cp -r src/bondkit/json_abis/* dist/esm/bondkit/json_abis/ || echo \"No bondkit json_abis\") && node scripts/fix-esm-imports.js",
|
|
319
354
|
"build:css": "postcss src/styles/index.css -o dist/styles/index.css",
|
|
320
355
|
"dev:cjs": "tsc-watch -p tsconfig.cjs.json --onSuccess \"tsc-alias -p tsconfig.cjs.json --outDir dist/cjs\"",
|
|
321
356
|
"dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
|
|
@@ -415,7 +415,7 @@ function AnySpendInner({
|
|
|
415
415
|
}, [recipientAddressFromProps, globalAddress]);
|
|
416
416
|
|
|
417
417
|
// Get geo-based onramp options for fiat payments
|
|
418
|
-
const { geoData, coinbaseAvailablePaymentMethods,
|
|
418
|
+
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
419
419
|
isMainnet,
|
|
420
420
|
srcAmountOnRamp,
|
|
421
421
|
);
|
|
@@ -427,9 +427,7 @@ function AnySpendInner({
|
|
|
427
427
|
return "coinbase";
|
|
428
428
|
case FiatPaymentMethod.STRIPE:
|
|
429
429
|
// Determine if it's stripe onramp or stripe-web2 based on support
|
|
430
|
-
if (
|
|
431
|
-
return "stripe";
|
|
432
|
-
} else if (stripeWeb2Support?.isSupport) {
|
|
430
|
+
if (stripeWeb2Support?.isSupport) {
|
|
433
431
|
return "stripe-web2";
|
|
434
432
|
}
|
|
435
433
|
return undefined;
|
|
@@ -844,7 +842,7 @@ function AnySpendInner({
|
|
|
844
842
|
vendor = "coinbase";
|
|
845
843
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || ""; // Use first available payment method ID
|
|
846
844
|
} else if (paymentMethod === FiatPaymentMethod.STRIPE) {
|
|
847
|
-
if (!
|
|
845
|
+
if (!stripeWeb2Support || !stripeWeb2Support.isSupport) {
|
|
848
846
|
toast.error("Stripe not available");
|
|
849
847
|
return;
|
|
850
848
|
}
|
|
@@ -1078,16 +1076,8 @@ function AnySpendInner({
|
|
|
1078
1076
|
<>
|
|
1079
1077
|
{connectedAddress ? (
|
|
1080
1078
|
<>
|
|
1081
|
-
{globalWallet?.meta?.icon && (
|
|
1082
|
-
<img
|
|
1083
|
-
src={globalWallet.meta.icon || ""}
|
|
1084
|
-
alt={globalWallet.ensName || ""}
|
|
1085
|
-
className="bg-b3-react-foreground size-6 rounded-full object-cover opacity-100"
|
|
1086
|
-
/>
|
|
1087
|
-
)}
|
|
1088
1079
|
<div className="flex items-center gap-1">
|
|
1089
|
-
{connectedName
|
|
1090
|
-
<span>{shortenAddress(connectedAddress || "")}</span>
|
|
1080
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
1091
1081
|
</div>
|
|
1092
1082
|
</>
|
|
1093
1083
|
) : (
|
|
@@ -1211,16 +1201,8 @@ function AnySpendInner({
|
|
|
1211
1201
|
<>
|
|
1212
1202
|
{recipientAddress ? (
|
|
1213
1203
|
<>
|
|
1214
|
-
{recipientProfile?.data?.avatar && (
|
|
1215
|
-
<img
|
|
1216
|
-
src={recipientProfile.data?.avatar || ""}
|
|
1217
|
-
alt="Connected Wallet"
|
|
1218
|
-
className="bg-as-primary h-6 w-6 rounded-full"
|
|
1219
|
-
/>
|
|
1220
|
-
)}
|
|
1221
1204
|
<span className="text-as-tertiarry flex items-center gap-1 text-sm">
|
|
1222
|
-
{recipientName
|
|
1223
|
-
<span>{shortenAddress(recipientAddress || "")}</span>
|
|
1205
|
+
{recipientName ? formatUsername(recipientName) : shortenAddress(recipientAddress || "")}
|
|
1224
1206
|
</span>
|
|
1225
1207
|
</>
|
|
1226
1208
|
) : (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BondkitToken } from "
|
|
1
|
+
import { BondkitToken } from "../../../bondkit";
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
4
|
GlareCardRounded,
|
|
@@ -202,7 +202,7 @@ export function AnySpendBondKit({
|
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
const header = () => (
|
|
205
|
-
<div className="w-full px-6 py-4">
|
|
205
|
+
<div className="bg-as-surface-primary w-full px-6 py-4">
|
|
206
206
|
<div className="flex w-full flex-col items-center space-y-6">
|
|
207
207
|
<h2 className="text-[28px] font-bold">
|
|
208
208
|
Buy {tokenName} ({tokenSymbol})
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
Input,
|
|
6
6
|
StyleRoot,
|
|
7
7
|
TextLoop,
|
|
8
|
-
useChainSwitchWithAction,
|
|
9
8
|
useHasMounted,
|
|
10
9
|
useModalStore,
|
|
11
10
|
useTokenBalance,
|
|
11
|
+
useUnifiedChainSwitchAndExecute,
|
|
12
12
|
} from "@b3dotfun/sdk/global-account/react";
|
|
13
13
|
import { baseMainnet } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
14
14
|
import invariant from "invariant";
|
|
@@ -17,7 +17,7 @@ import { motion } from "motion/react";
|
|
|
17
17
|
import { useCallback, useEffect, useState } from "react";
|
|
18
18
|
import { toast } from "sonner";
|
|
19
19
|
import { createPublicClient, encodeFunctionData, erc20Abi, formatUnits, http } from "viem";
|
|
20
|
-
import { useAccount, useWaitForTransactionReceipt
|
|
20
|
+
import { useAccount, useWaitForTransactionReceipt } from "wagmi";
|
|
21
21
|
import { AnySpendCustom } from "./AnySpendCustom";
|
|
22
22
|
import { EthIcon } from "./icons/EthIcon";
|
|
23
23
|
import { SolIcon } from "./icons/SolIcon";
|
|
@@ -159,8 +159,7 @@ export function AnySpendBuySpin({
|
|
|
159
159
|
|
|
160
160
|
// Wagmi hooks
|
|
161
161
|
const { address } = useAccount();
|
|
162
|
-
const {
|
|
163
|
-
const { switchChainAndExecute } = useChainSwitchWithAction();
|
|
162
|
+
const { switchChainAndExecute, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
164
163
|
|
|
165
164
|
// State for direct buying flow (when user has B3 tokens)
|
|
166
165
|
const [isBuying, setIsBuying] = useState(false);
|
|
@@ -348,41 +347,52 @@ export function AnySpendBuySpin({
|
|
|
348
347
|
try {
|
|
349
348
|
setIsBuying(true);
|
|
350
349
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
// Check current allowance for B3 token to entryModule
|
|
351
|
+
const allowance = await basePublicClient.readContract({
|
|
352
|
+
address: B3_TOKEN.address as `0x${string}`,
|
|
353
|
+
abi: erc20Abi,
|
|
354
|
+
functionName: "allowance",
|
|
355
|
+
args: [address, paymentConfig.entryModule as `0x${string}`],
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// If allowance is insufficient, request approval first
|
|
359
|
+
if (allowance < totalCost) {
|
|
360
|
+
toast.info("Approving B3 spending...");
|
|
361
|
+
|
|
362
|
+
const approvalData = encodeFunctionData({
|
|
355
363
|
abi: erc20Abi,
|
|
356
|
-
functionName: "
|
|
357
|
-
args: [
|
|
364
|
+
functionName: "approve",
|
|
365
|
+
args: [paymentConfig.entryModule as `0x${string}`, totalCost],
|
|
358
366
|
});
|
|
359
367
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
368
|
+
await switchChainAndExecute(chainId, {
|
|
369
|
+
to: B3_TOKEN.address as `0x${string}`,
|
|
370
|
+
data: approvalData,
|
|
371
|
+
value: BigInt(0),
|
|
372
|
+
});
|
|
363
373
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
abi: erc20Abi,
|
|
367
|
-
functionName: "approve",
|
|
368
|
-
args: [paymentConfig.entryModule as `0x${string}`, totalCost],
|
|
369
|
-
});
|
|
374
|
+
toast.info("Approval confirmed. Proceeding with spin purchase...");
|
|
375
|
+
}
|
|
370
376
|
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
// Execute the buy entries and spin
|
|
378
|
+
toast.info("Buying spins...");
|
|
373
379
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
functionName: "buyEntriesAndSpin",
|
|
380
|
-
args: [address, BigInt(userSpinQuantity)],
|
|
381
|
-
});
|
|
380
|
+
const buyData = encodeFunctionData({
|
|
381
|
+
abi: SPIN_WHEEL_ABI,
|
|
382
|
+
functionName: "buyEntriesAndSpin",
|
|
383
|
+
args: [address, BigInt(userSpinQuantity)],
|
|
384
|
+
});
|
|
382
385
|
|
|
386
|
+
const buyHash = await switchChainAndExecute(chainId, {
|
|
387
|
+
to: spinwheelContractAddress as `0x${string}`,
|
|
388
|
+
data: buyData,
|
|
389
|
+
value: BigInt(0),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (buyHash) {
|
|
383
393
|
setBuyingTxHash(buyHash);
|
|
384
394
|
toast.success("Spin purchase transaction submitted!");
|
|
385
|
-
}
|
|
395
|
+
}
|
|
386
396
|
} catch (error) {
|
|
387
397
|
console.error("@@anyspend-buy-spin:error:", error);
|
|
388
398
|
toast.error("Spin purchase failed. Please try again.");
|
|
@@ -637,10 +647,10 @@ export function AnySpendBuySpin({
|
|
|
637
647
|
|
|
638
648
|
<Button
|
|
639
649
|
onClick={confirmQuantity}
|
|
640
|
-
disabled={!isQuantityValid || !displayQuantity || isBuying || isTxPending}
|
|
650
|
+
disabled={!isQuantityValid || !displayQuantity || isBuying || isTxPending || isSwitchingOrExecuting}
|
|
641
651
|
className="bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium"
|
|
642
652
|
>
|
|
643
|
-
{isBuying ? "Buying..." : isTxPending ? "Confirming..." : "Continue"}
|
|
653
|
+
{isBuying || isSwitchingOrExecuting ? "Buying..." : isTxPending ? "Confirming..." : "Continue"}
|
|
644
654
|
</Button>
|
|
645
655
|
</div>
|
|
646
656
|
) : null}
|
|
@@ -371,8 +371,10 @@ function AnySpendCustomInner({
|
|
|
371
371
|
);
|
|
372
372
|
|
|
373
373
|
// Get geo data and onramp options (after quote is available)
|
|
374
|
-
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods,
|
|
375
|
-
|
|
374
|
+
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
375
|
+
isMainnet,
|
|
376
|
+
srcFiatAmount,
|
|
377
|
+
);
|
|
376
378
|
|
|
377
379
|
useEffect(() => {
|
|
378
380
|
if (oat?.data?.order.status === "executed") {
|
|
@@ -404,7 +406,7 @@ function AnySpendCustomInner({
|
|
|
404
406
|
|
|
405
407
|
const isCreatingOrder = isCreatingRegularOrder || isCreatingOnrampOrder;
|
|
406
408
|
|
|
407
|
-
const { address: connectedAddress, name: connectedName
|
|
409
|
+
const { address: connectedAddress, name: connectedName } = useConnectedUserProfile();
|
|
408
410
|
const recipientProfile = useProfile({ address: recipientAddress });
|
|
409
411
|
const recipientName = recipientProfile.data?.name;
|
|
410
412
|
|
|
@@ -556,7 +558,7 @@ function AnySpendCustomInner({
|
|
|
556
558
|
vendor = "coinbase";
|
|
557
559
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || "";
|
|
558
560
|
} else if (paymentMethod === FiatPaymentMethod.STRIPE) {
|
|
559
|
-
if (!
|
|
561
|
+
if (!stripeWeb2Support || !stripeWeb2Support.isSupport) {
|
|
560
562
|
toast.error("Stripe not available");
|
|
561
563
|
return;
|
|
562
564
|
}
|
|
@@ -861,16 +863,8 @@ function AnySpendCustomInner({
|
|
|
861
863
|
<>
|
|
862
864
|
{connectedAddress ? (
|
|
863
865
|
<>
|
|
864
|
-
{connectedProfile?.data?.avatar && (
|
|
865
|
-
<img
|
|
866
|
-
src={connectedProfile.data?.avatar || ""}
|
|
867
|
-
alt="Connected Wallet"
|
|
868
|
-
className="bg-as-primary h-6 w-6 rounded-full"
|
|
869
|
-
/>
|
|
870
|
-
)}
|
|
871
866
|
<span className="text-as-tertiarry flex items-center gap-1">
|
|
872
|
-
{connectedName
|
|
873
|
-
<span>{shortenAddress(connectedAddress || "")}</span>
|
|
867
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
874
868
|
</span>
|
|
875
869
|
</>
|
|
876
870
|
) : (
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
Input,
|
|
6
6
|
StyleRoot,
|
|
7
7
|
TextLoop,
|
|
8
|
-
useChainSwitchWithAction,
|
|
9
8
|
useHasMounted,
|
|
10
9
|
useModalStore,
|
|
11
10
|
useTokenBalance,
|
|
11
|
+
useUnifiedChainSwitchAndExecute,
|
|
12
12
|
} from "@b3dotfun/sdk/global-account/react";
|
|
13
13
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
14
14
|
import invariant from "invariant";
|
|
@@ -18,7 +18,7 @@ import { useEffect, useState } from "react";
|
|
|
18
18
|
import { toast } from "sonner";
|
|
19
19
|
import { createPublicClient, encodeFunctionData, erc20Abi, http } from "viem";
|
|
20
20
|
import { base } from "viem/chains";
|
|
21
|
-
import { useAccount, useWaitForTransactionReceipt
|
|
21
|
+
import { useAccount, useWaitForTransactionReceipt } from "wagmi";
|
|
22
22
|
import { AnySpendCustom } from "./AnySpendCustom";
|
|
23
23
|
import { EthIcon } from "./icons/EthIcon";
|
|
24
24
|
import { SolIcon } from "./icons/SolIcon";
|
|
@@ -70,8 +70,7 @@ export function AnySpendStakeB3({
|
|
|
70
70
|
|
|
71
71
|
// Wagmi hooks for direct staking
|
|
72
72
|
const { address } = useAccount();
|
|
73
|
-
const {
|
|
74
|
-
const { switchChainAndExecute } = useChainSwitchWithAction();
|
|
73
|
+
const { switchChainAndExecute, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
75
74
|
|
|
76
75
|
// State for direct staking flow
|
|
77
76
|
const [isStaking, setIsStaking] = useState(false);
|
|
@@ -191,41 +190,52 @@ export function AnySpendStakeB3({
|
|
|
191
190
|
try {
|
|
192
191
|
setIsStaking(true);
|
|
193
192
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
// Check current allowance
|
|
194
|
+
const allowance = await basePublicClient.readContract({
|
|
195
|
+
address: B3_TOKEN.address as `0x${string}`,
|
|
196
|
+
abi: erc20Abi,
|
|
197
|
+
functionName: "allowance",
|
|
198
|
+
args: [address, ERC20Staking as `0x${string}`],
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// If allowance is insufficient, request approval first
|
|
202
|
+
if (allowance < BigInt(userStakeAmount)) {
|
|
203
|
+
toast.info("Approving B3 spending...");
|
|
204
|
+
|
|
205
|
+
const approvalData = encodeFunctionData({
|
|
198
206
|
abi: erc20Abi,
|
|
199
|
-
functionName: "
|
|
200
|
-
args: [
|
|
207
|
+
functionName: "approve",
|
|
208
|
+
args: [ERC20Staking as `0x${string}`, BigInt(userStakeAmount)],
|
|
201
209
|
});
|
|
202
210
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
await writeContractAsync({
|
|
208
|
-
address: B3_TOKEN.address as `0x${string}`,
|
|
209
|
-
abi: erc20Abi,
|
|
210
|
-
functionName: "approve",
|
|
211
|
-
args: [ERC20Staking as `0x${string}`, BigInt(userStakeAmount)],
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
toast.info("Approval confirmed. Proceeding with stake...");
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Execute the stake
|
|
218
|
-
toast.info("Staking B3...");
|
|
219
|
-
const stakeHash = await writeContractAsync({
|
|
220
|
-
address: ERC20Staking as `0x${string}`,
|
|
221
|
-
abi: ABI_ERC20_STAKING,
|
|
222
|
-
functionName: "stake",
|
|
223
|
-
args: [BigInt(userStakeAmount), recipientAddress as `0x${string}`],
|
|
211
|
+
await switchChainAndExecute(base.id, {
|
|
212
|
+
to: B3_TOKEN.address as `0x${string}`,
|
|
213
|
+
data: approvalData,
|
|
214
|
+
value: BigInt(0),
|
|
224
215
|
});
|
|
225
216
|
|
|
217
|
+
toast.info("Approval confirmed. Proceeding with stake...");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Execute the stake
|
|
221
|
+
toast.info("Staking B3...");
|
|
222
|
+
|
|
223
|
+
const stakeData = encodeFunctionData({
|
|
224
|
+
abi: ABI_ERC20_STAKING,
|
|
225
|
+
functionName: "stake",
|
|
226
|
+
args: [BigInt(userStakeAmount), recipientAddress as `0x${string}`],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const stakeHash = await switchChainAndExecute(base.id, {
|
|
230
|
+
to: ERC20Staking as `0x${string}`,
|
|
231
|
+
data: stakeData,
|
|
232
|
+
value: BigInt(0),
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (stakeHash) {
|
|
226
236
|
setStakingTxHash(stakeHash);
|
|
227
237
|
toast.success("Staking transaction submitted!");
|
|
228
|
-
}
|
|
238
|
+
}
|
|
229
239
|
} catch (error) {
|
|
230
240
|
console.error("@@b3-stake:error:", error);
|
|
231
241
|
toast.error("Staking failed. Please try again.");
|
|
@@ -375,10 +385,10 @@ export function AnySpendStakeB3({
|
|
|
375
385
|
|
|
376
386
|
<Button
|
|
377
387
|
onClick={confirmAmount}
|
|
378
|
-
disabled={!isAmountValid || !displayAmount || isStaking || isTxPending}
|
|
388
|
+
disabled={!isAmountValid || !displayAmount || isStaking || isTxPending || isSwitchingOrExecuting}
|
|
379
389
|
className="bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium"
|
|
380
390
|
>
|
|
381
|
-
{isStaking ? "Staking..." : isTxPending ? "Confirming..." : "Continue"}
|
|
391
|
+
{isStaking || isSwitchingOrExecuting ? "Staking..." : isTxPending ? "Confirming..." : "Continue"}
|
|
382
392
|
</Button>
|
|
383
393
|
</motion.div>
|
|
384
394
|
</div>
|