@b3dotfun/sdk 0.0.40-alpha.2 → 0.0.40-alpha.21
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.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +8 -4
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/types/api.d.ts +11 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +1 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +373 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -9
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +8 -4
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/types/api.d.ts +11 -1
- package/dist/esm/anyspend/utils/orderPayload.js +1 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +369 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -9
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/types/api.d.ts +11 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +24 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +55 -13
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -9
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +1 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api.ts +11 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/orderPayload.ts +1 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +461 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +51 -15
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/useAuthentication.ts +1 -2
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +23 -21
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
export declare const BaseBondkitTokenFactoryContractAddress: Address;
|
|
3
3
|
export declare const BaseMainnetRpcUrl = "https://base-rpc.publicnode.com";
|
|
4
|
+
export declare const UniversalRouterAddress: Address;
|
|
5
|
+
export declare const QuoterAddress: Address;
|
|
6
|
+
export declare const Permit2Address: Address;
|
|
7
|
+
export declare const B3TokenAddress: Address;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export const BaseBondkitTokenFactoryContractAddress = "0x5d641bbB206d4B5585eCCd919F36270200A9A2Ad";
|
|
2
2
|
export const BaseMainnetRpcUrl = "https://base-rpc.publicnode.com";
|
|
3
|
+
// Uniswap V4 addresses on Base
|
|
4
|
+
export const UniversalRouterAddress = "0x6ff5693b99212da76ad316178a184ab56d299b43";
|
|
5
|
+
export const QuoterAddress = "0x0d5e0f971ed27fbff6c2837bf31316121532048d";
|
|
6
|
+
export const Permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
7
|
+
export const B3TokenAddress = "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3";
|
|
@@ -8,5 +8,7 @@ export * from "./constants.js";
|
|
|
8
8
|
export * from "./types.js";
|
|
9
9
|
// ABIs
|
|
10
10
|
export * from "./abis/index.js";
|
|
11
|
+
// Swap functionality
|
|
12
|
+
export { BondkitSwapService } from "./swapService.js";
|
|
11
13
|
// Components
|
|
12
14
|
export { default as TradingView } from "./components/TradingView.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Address, WalletClient } from "viem";
|
|
2
|
+
import type { SwapQuote } from "./types";
|
|
3
|
+
interface SwapParams {
|
|
4
|
+
tokenIn: Address;
|
|
5
|
+
tokenOut: Address;
|
|
6
|
+
amountIn: string;
|
|
7
|
+
tokenInDecimals: number;
|
|
8
|
+
tokenOutDecimals: number;
|
|
9
|
+
slippageTolerance: number;
|
|
10
|
+
recipient: Address;
|
|
11
|
+
deadline?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Internal swap service for handling Uniswap V4 swaps between trading token and bondkit token
|
|
15
|
+
*/
|
|
16
|
+
export declare class BondkitSwapService {
|
|
17
|
+
private v4Config;
|
|
18
|
+
private configInitialized;
|
|
19
|
+
private readonly bondkitTokenAddress;
|
|
20
|
+
private readonly publicClient;
|
|
21
|
+
constructor(bondkitTokenAddress: Address);
|
|
22
|
+
/**
|
|
23
|
+
* Initialize V4 pool configuration from bondkit token contract
|
|
24
|
+
*/
|
|
25
|
+
private initializeV4Config;
|
|
26
|
+
/**
|
|
27
|
+
* Get V4 pool configuration
|
|
28
|
+
*/
|
|
29
|
+
private getV4Config;
|
|
30
|
+
/**
|
|
31
|
+
* Handle token approvals for swap
|
|
32
|
+
*/
|
|
33
|
+
private handleTokenApprovals;
|
|
34
|
+
/**
|
|
35
|
+
* Get swap quote
|
|
36
|
+
*/
|
|
37
|
+
getSwapQuote(params: SwapParams): Promise<SwapQuote | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Execute swap transaction
|
|
40
|
+
*/
|
|
41
|
+
executeSwap(params: SwapParams, walletClient: WalletClient): Promise<string | null>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { parseUnits, formatUnits, encodeAbiParameters, parseAbiParameters, getContract, createPublicClient, http, } from "viem";
|
|
2
|
+
import { base } from "viem/chains";
|
|
3
|
+
import { UniversalRouterAddress, QuoterAddress, Permit2Address, BaseMainnetRpcUrl } from "./constants.js";
|
|
4
|
+
// Minimal ABIs needed for swap functionality
|
|
5
|
+
const UNIVERSAL_ROUTER_ABI = [
|
|
6
|
+
{
|
|
7
|
+
inputs: [
|
|
8
|
+
{ name: "commands", type: "bytes" },
|
|
9
|
+
{ name: "inputs", type: "bytes[]" },
|
|
10
|
+
{ name: "deadline", type: "uint256" },
|
|
11
|
+
],
|
|
12
|
+
name: "execute",
|
|
13
|
+
outputs: [],
|
|
14
|
+
stateMutability: "payable",
|
|
15
|
+
type: "function",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
const QUOTER_ABI = [
|
|
19
|
+
{
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
components: [
|
|
23
|
+
{
|
|
24
|
+
components: [
|
|
25
|
+
{ internalType: "Currency", name: "currency0", type: "address" },
|
|
26
|
+
{ internalType: "Currency", name: "currency1", type: "address" },
|
|
27
|
+
{ internalType: "uint24", name: "fee", type: "uint24" },
|
|
28
|
+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
|
|
29
|
+
{ internalType: "contract IHooks", name: "hooks", type: "address" },
|
|
30
|
+
],
|
|
31
|
+
internalType: "struct PoolKey",
|
|
32
|
+
name: "poolKey",
|
|
33
|
+
type: "tuple",
|
|
34
|
+
},
|
|
35
|
+
{ internalType: "bool", name: "zeroForOne", type: "bool" },
|
|
36
|
+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
|
|
37
|
+
{ internalType: "bytes", name: "hookData", type: "bytes" },
|
|
38
|
+
],
|
|
39
|
+
internalType: "struct IV4Quoter.QuoteExactSingleParams",
|
|
40
|
+
name: "params",
|
|
41
|
+
type: "tuple",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
name: "quoteExactInputSingle",
|
|
45
|
+
outputs: [
|
|
46
|
+
{ internalType: "uint256", name: "amountOut", type: "uint256" },
|
|
47
|
+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
|
|
48
|
+
],
|
|
49
|
+
stateMutability: "nonpayable",
|
|
50
|
+
type: "function",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const ERC20_ABI = [
|
|
54
|
+
{
|
|
55
|
+
inputs: [
|
|
56
|
+
{ name: "spender", type: "address" },
|
|
57
|
+
{ name: "amount", type: "uint256" },
|
|
58
|
+
],
|
|
59
|
+
name: "approve",
|
|
60
|
+
outputs: [{ name: "", type: "bool" }],
|
|
61
|
+
stateMutability: "nonpayable",
|
|
62
|
+
type: "function",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
inputs: [
|
|
66
|
+
{ name: "owner", type: "address" },
|
|
67
|
+
{ name: "spender", type: "address" },
|
|
68
|
+
],
|
|
69
|
+
name: "allowance",
|
|
70
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
71
|
+
stateMutability: "view",
|
|
72
|
+
type: "function",
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
const PERMIT2_ABI = [
|
|
76
|
+
{
|
|
77
|
+
inputs: [
|
|
78
|
+
{ name: "token", type: "address" },
|
|
79
|
+
{ name: "spender", type: "address" },
|
|
80
|
+
{ name: "amount", type: "uint160" },
|
|
81
|
+
{ name: "expiration", type: "uint48" },
|
|
82
|
+
],
|
|
83
|
+
name: "approve",
|
|
84
|
+
outputs: [],
|
|
85
|
+
stateMutability: "nonpayable",
|
|
86
|
+
type: "function",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
inputs: [
|
|
90
|
+
{ name: "owner", type: "address" },
|
|
91
|
+
{ name: "token", type: "address" },
|
|
92
|
+
{ name: "spender", type: "address" },
|
|
93
|
+
],
|
|
94
|
+
name: "allowance",
|
|
95
|
+
outputs: [
|
|
96
|
+
{ name: "amount", type: "uint160" },
|
|
97
|
+
{ name: "expiration", type: "uint48" },
|
|
98
|
+
{ name: "nonce", type: "uint48" },
|
|
99
|
+
],
|
|
100
|
+
stateMutability: "view",
|
|
101
|
+
type: "function",
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
const TOKEN_V4_CONFIG_ABI = [
|
|
105
|
+
{
|
|
106
|
+
inputs: [],
|
|
107
|
+
name: "v4Hook",
|
|
108
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
109
|
+
stateMutability: "view",
|
|
110
|
+
type: "function",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
inputs: [],
|
|
114
|
+
name: "v4PoolFee",
|
|
115
|
+
outputs: [{ internalType: "uint24", name: "", type: "uint24" }],
|
|
116
|
+
stateMutability: "view",
|
|
117
|
+
type: "function",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
inputs: [],
|
|
121
|
+
name: "v4TickSpacing",
|
|
122
|
+
outputs: [{ internalType: "int24", name: "", type: "int24" }],
|
|
123
|
+
stateMutability: "view",
|
|
124
|
+
type: "function",
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
// Command and action constants
|
|
128
|
+
const COMMANDS = {
|
|
129
|
+
V4_SWAP: "0x10",
|
|
130
|
+
};
|
|
131
|
+
const V4_ACTIONS = {
|
|
132
|
+
SWAP_EXACT_IN_SINGLE: 6,
|
|
133
|
+
TAKE_ALL: 15,
|
|
134
|
+
SETTLE_ALL: 12,
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Internal swap service for handling Uniswap V4 swaps between trading token and bondkit token
|
|
138
|
+
*/
|
|
139
|
+
export class BondkitSwapService {
|
|
140
|
+
constructor(bondkitTokenAddress) {
|
|
141
|
+
this.v4Config = null;
|
|
142
|
+
this.configInitialized = false;
|
|
143
|
+
this.bondkitTokenAddress = bondkitTokenAddress;
|
|
144
|
+
this.publicClient = createPublicClient({
|
|
145
|
+
chain: base,
|
|
146
|
+
transport: http(BaseMainnetRpcUrl),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Initialize V4 pool configuration from bondkit token contract
|
|
151
|
+
*/
|
|
152
|
+
async initializeV4Config() {
|
|
153
|
+
if (this.configInitialized) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const tokenContract = getContract({
|
|
158
|
+
address: this.bondkitTokenAddress,
|
|
159
|
+
abi: TOKEN_V4_CONFIG_ABI,
|
|
160
|
+
client: this.publicClient,
|
|
161
|
+
});
|
|
162
|
+
const [hook, fee, tickSpacing] = await Promise.all([
|
|
163
|
+
tokenContract.read.v4Hook(),
|
|
164
|
+
tokenContract.read.v4PoolFee(),
|
|
165
|
+
tokenContract.read.v4TickSpacing(),
|
|
166
|
+
]);
|
|
167
|
+
this.v4Config = {
|
|
168
|
+
hook: hook,
|
|
169
|
+
fee: Number(fee),
|
|
170
|
+
tickSpacing: Number(tickSpacing),
|
|
171
|
+
};
|
|
172
|
+
this.configInitialized = true;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.warn("Failed to initialize V4 configuration:", error);
|
|
176
|
+
// Use fallback configuration
|
|
177
|
+
this.v4Config = {
|
|
178
|
+
hook: "0xB36f4A2FB18b745ef8eD31452781a463d2B3f0cC",
|
|
179
|
+
fee: 30000,
|
|
180
|
+
tickSpacing: 60,
|
|
181
|
+
};
|
|
182
|
+
this.configInitialized = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get V4 pool configuration
|
|
187
|
+
*/
|
|
188
|
+
async getV4Config() {
|
|
189
|
+
await this.initializeV4Config();
|
|
190
|
+
return this.v4Config;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Handle token approvals for swap
|
|
194
|
+
*/
|
|
195
|
+
async handleTokenApprovals(tokenAddress, amountIn, walletClient, deadline) {
|
|
196
|
+
// Skip approvals for ETH
|
|
197
|
+
if (tokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const userAddress = walletClient.account?.address;
|
|
201
|
+
if (!userAddress) {
|
|
202
|
+
throw new Error("No user address found");
|
|
203
|
+
}
|
|
204
|
+
const erc20Contract = getContract({
|
|
205
|
+
address: tokenAddress,
|
|
206
|
+
abi: ERC20_ABI,
|
|
207
|
+
client: walletClient,
|
|
208
|
+
});
|
|
209
|
+
const permit2Contract = getContract({
|
|
210
|
+
address: Permit2Address,
|
|
211
|
+
abi: PERMIT2_ABI,
|
|
212
|
+
client: walletClient,
|
|
213
|
+
});
|
|
214
|
+
// Check ERC20 allowance to Permit2
|
|
215
|
+
const currentAllowance = (await erc20Contract.read.allowance([userAddress, Permit2Address]));
|
|
216
|
+
const requiredAmount = BigInt(amountIn);
|
|
217
|
+
if (currentAllowance < requiredAmount) {
|
|
218
|
+
await erc20Contract.write.approve([Permit2Address, BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")], {
|
|
219
|
+
account: userAddress,
|
|
220
|
+
chain: base,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// Check Permit2 allowance for Universal Router
|
|
224
|
+
const permit2Allowance = (await permit2Contract.read.allowance([
|
|
225
|
+
userAddress,
|
|
226
|
+
tokenAddress,
|
|
227
|
+
UniversalRouterAddress,
|
|
228
|
+
]));
|
|
229
|
+
const [currentPermit2Amount, expiration] = permit2Allowance;
|
|
230
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
231
|
+
const isExpired = expiration <= currentTime;
|
|
232
|
+
if (currentPermit2Amount < requiredAmount || isExpired) {
|
|
233
|
+
await permit2Contract.write.approve([tokenAddress, UniversalRouterAddress, BigInt("0xffffffffffffffffffffffffffffffffffffff"), Number(deadline)], {
|
|
234
|
+
account: userAddress,
|
|
235
|
+
chain: base,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get swap quote
|
|
241
|
+
*/
|
|
242
|
+
async getSwapQuote(params) {
|
|
243
|
+
try {
|
|
244
|
+
const { tokenIn, tokenOut, amountIn, tokenInDecimals, tokenOutDecimals, slippageTolerance } = params;
|
|
245
|
+
const v4Config = await this.getV4Config();
|
|
246
|
+
const amountInWei = parseUnits(amountIn, tokenInDecimals);
|
|
247
|
+
// Determine token order for pool
|
|
248
|
+
const currency0 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenIn : tokenOut;
|
|
249
|
+
const currency1 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenOut : tokenIn;
|
|
250
|
+
const zeroForOne = tokenIn.toLowerCase() === currency0.toLowerCase();
|
|
251
|
+
const poolKey = {
|
|
252
|
+
currency0: currency0,
|
|
253
|
+
currency1: currency1,
|
|
254
|
+
fee: v4Config.fee,
|
|
255
|
+
tickSpacing: v4Config.tickSpacing,
|
|
256
|
+
hooks: v4Config.hook,
|
|
257
|
+
};
|
|
258
|
+
const quoteParams = {
|
|
259
|
+
poolKey,
|
|
260
|
+
zeroForOne,
|
|
261
|
+
exactAmount: BigInt(amountInWei.toString()),
|
|
262
|
+
hookData: "0x",
|
|
263
|
+
};
|
|
264
|
+
const { result } = await this.publicClient.simulateContract({
|
|
265
|
+
address: QuoterAddress,
|
|
266
|
+
abi: QUOTER_ABI,
|
|
267
|
+
functionName: "quoteExactInputSingle",
|
|
268
|
+
args: [quoteParams],
|
|
269
|
+
});
|
|
270
|
+
const [amountOut] = result;
|
|
271
|
+
const amountOutRaw = formatUnits(amountOut, tokenOutDecimals);
|
|
272
|
+
const amountOutFormatted = parseFloat(amountOutRaw).toFixed(Math.min(6, tokenOutDecimals));
|
|
273
|
+
// Calculate minimum amount out with slippage
|
|
274
|
+
const slippageMultiplier = (100 - slippageTolerance) / 100;
|
|
275
|
+
const amountOutMinRaw = parseFloat(amountOutFormatted) * slippageMultiplier;
|
|
276
|
+
const amountOutMin = amountOutMinRaw.toFixed(tokenOutDecimals);
|
|
277
|
+
// Simple execution price calculation
|
|
278
|
+
const rate = parseFloat(amountOutFormatted) / parseFloat(amountIn);
|
|
279
|
+
const executionPrice = `1 = ${rate.toFixed(6)}`;
|
|
280
|
+
return {
|
|
281
|
+
amountOut: amountOutFormatted,
|
|
282
|
+
amountOutMin,
|
|
283
|
+
priceImpact: "0.0", // Simplified
|
|
284
|
+
executionPrice,
|
|
285
|
+
fee: (v4Config.fee / 10000).toString(),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
console.warn("Error getting swap quote:", error);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Execute swap transaction
|
|
295
|
+
*/
|
|
296
|
+
async executeSwap(params, walletClient) {
|
|
297
|
+
try {
|
|
298
|
+
const { tokenIn, tokenOut, amountIn, tokenInDecimals, tokenOutDecimals, deadline } = params;
|
|
299
|
+
const swapDeadline = deadline || Math.floor(Date.now() / 1000) + 3600;
|
|
300
|
+
if (!walletClient.account) {
|
|
301
|
+
throw new Error("Wallet client must have an account");
|
|
302
|
+
}
|
|
303
|
+
const amountInWei = parseUnits(amountIn, tokenInDecimals);
|
|
304
|
+
// Handle token approvals
|
|
305
|
+
await this.handleTokenApprovals(tokenIn, amountInWei.toString(), walletClient, swapDeadline);
|
|
306
|
+
// Get quote for minimum amount out
|
|
307
|
+
const quote = await this.getSwapQuote(params);
|
|
308
|
+
if (!quote) {
|
|
309
|
+
throw new Error("Unable to get swap quote");
|
|
310
|
+
}
|
|
311
|
+
const amountOutMinimum = parseUnits(quote.amountOutMin, tokenOutDecimals);
|
|
312
|
+
const v4Config = await this.getV4Config();
|
|
313
|
+
// Determine token order
|
|
314
|
+
const currency0 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenIn : tokenOut;
|
|
315
|
+
const currency1 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenOut : tokenIn;
|
|
316
|
+
const zeroForOne = tokenIn.toLowerCase() === currency0.toLowerCase();
|
|
317
|
+
const poolKey = [currency0, currency1, v4Config.fee, v4Config.tickSpacing, v4Config.hook];
|
|
318
|
+
// Encode V4 actions
|
|
319
|
+
const actions = [
|
|
320
|
+
{
|
|
321
|
+
type: V4_ACTIONS.SWAP_EXACT_IN_SINGLE,
|
|
322
|
+
params: [poolKey, zeroForOne, amountInWei, amountOutMinimum, "0x"],
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
type: V4_ACTIONS.TAKE_ALL,
|
|
326
|
+
params: [(zeroForOne ? currency1 : currency0), BigInt(0)],
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
type: V4_ACTIONS.SETTLE_ALL,
|
|
330
|
+
params: [(zeroForOne ? currency0 : currency1), amountInWei],
|
|
331
|
+
},
|
|
332
|
+
];
|
|
333
|
+
// Encode actions
|
|
334
|
+
const actionTypes = actions.map(action => action.type);
|
|
335
|
+
const actionsBytes = ("0x" + actionTypes.map(type => type.toString(16).padStart(2, "0")).join(""));
|
|
336
|
+
const actionParams = actions.map(action => {
|
|
337
|
+
switch (action.type) {
|
|
338
|
+
case V4_ACTIONS.SWAP_EXACT_IN_SINGLE:
|
|
339
|
+
return encodeAbiParameters(parseAbiParameters("((address,address,uint24,int24,address),bool,uint128,uint128,bytes)"), [action.params]);
|
|
340
|
+
case V4_ACTIONS.TAKE_ALL:
|
|
341
|
+
return encodeAbiParameters(parseAbiParameters("address,uint256"), action.params);
|
|
342
|
+
case V4_ACTIONS.SETTLE_ALL:
|
|
343
|
+
return encodeAbiParameters(parseAbiParameters("address,uint256"), action.params);
|
|
344
|
+
default:
|
|
345
|
+
return "0x00";
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
const v4SwapInput = encodeAbiParameters(parseAbiParameters("bytes,bytes[]"), [actionsBytes, actionParams]);
|
|
349
|
+
const commands = COMMANDS.V4_SWAP;
|
|
350
|
+
const inputs = [v4SwapInput];
|
|
351
|
+
// Execute swap
|
|
352
|
+
const universalRouter = getContract({
|
|
353
|
+
address: UniversalRouterAddress,
|
|
354
|
+
abi: UNIVERSAL_ROUTER_ABI,
|
|
355
|
+
client: walletClient,
|
|
356
|
+
});
|
|
357
|
+
const txHash = await universalRouter.write.execute([commands, inputs, BigInt(swapDeadline)], {
|
|
358
|
+
account: walletClient.account,
|
|
359
|
+
chain: base,
|
|
360
|
+
value: tokenIn === "0x0000000000000000000000000000000000000000" ? amountInWei : BigInt(0),
|
|
361
|
+
});
|
|
362
|
+
return txHash;
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
console.warn("Error executing swap:", error);
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -49,10 +49,9 @@ export type DexMigrationEventArgs = {
|
|
|
49
49
|
ethForFeeRecipient: bigint;
|
|
50
50
|
};
|
|
51
51
|
export declare enum TokenStatus {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Migrated = 3
|
|
52
|
+
Uninitialized = 0,
|
|
53
|
+
Bonding = 1,
|
|
54
|
+
Dex = 2
|
|
56
55
|
}
|
|
57
56
|
export interface GetTransactionHistoryOptions {
|
|
58
57
|
userAddress?: Address;
|
|
@@ -80,3 +79,10 @@ export interface TransactionResponse {
|
|
|
80
79
|
skip: number;
|
|
81
80
|
data: Transaction[];
|
|
82
81
|
}
|
|
82
|
+
export interface SwapQuote {
|
|
83
|
+
amountOut: string;
|
|
84
|
+
amountOutMin: string;
|
|
85
|
+
priceImpact: string;
|
|
86
|
+
executionPrice: string;
|
|
87
|
+
fee: string;
|
|
88
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// Enum for Status (
|
|
1
|
+
// Enum for Status (matches contract Status enum exactly)
|
|
2
2
|
export var TokenStatus;
|
|
3
3
|
(function (TokenStatus) {
|
|
4
|
-
TokenStatus[TokenStatus["
|
|
5
|
-
TokenStatus[TokenStatus["
|
|
6
|
-
TokenStatus[TokenStatus["
|
|
7
|
-
TokenStatus[TokenStatus["Migrated"] = 3] = "Migrated";
|
|
4
|
+
TokenStatus[TokenStatus["Uninitialized"] = 0] = "Uninitialized";
|
|
5
|
+
TokenStatus[TokenStatus["Bonding"] = 1] = "Bonding";
|
|
6
|
+
TokenStatus[TokenStatus["Dex"] = 2] = "Dex";
|
|
8
7
|
})(TokenStatus || (TokenStatus = {}));
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
2
|
+
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
2
3
|
import { Account } from "thirdweb/wallets";
|
|
3
4
|
import { ClientType } from "../../../client-manager";
|
|
4
5
|
import { B3ContextType } from "./types";
|
|
5
|
-
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
6
|
-
export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly import("wagmi").CreateConnectorFn[]>;
|
|
7
6
|
/**
|
|
8
7
|
* Main B3Provider component
|
|
9
8
|
*/
|
|
10
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
|
|
9
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, }: {
|
|
11
10
|
theme: "light" | "dark";
|
|
12
11
|
children: React.ReactNode;
|
|
13
12
|
accountOverride?: Account;
|
|
@@ -19,6 +18,8 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
19
18
|
style?: React.CSSProperties;
|
|
20
19
|
};
|
|
21
20
|
clientType?: ClientType;
|
|
21
|
+
rpcUrls?: Record<number, string>;
|
|
22
|
+
partnerId?: string;
|
|
22
23
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
/**
|
|
24
25
|
* Inner provider component that provides the actual B3Context
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { RelayKitProviderWrapper, TooltipProvider, useAuthStore } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
4
|
+
import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
4
5
|
import { supportedChains } from "../../../../shared/constants/chains/supported.js";
|
|
6
|
+
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
7
|
+
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
8
|
+
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
5
9
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
-
import {
|
|
10
|
+
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
11
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
12
|
import { Toaster } from "sonner";
|
|
8
13
|
import { getLastAuthProvider, ThirdwebProvider, useActiveAccount, useConnectedWallets, useSetActiveWallet, } from "thirdweb/react";
|
|
9
14
|
import { createConfig, http, WagmiProvider } from "wagmi";
|
|
10
15
|
import { setClientType } from "../../../client-manager.js";
|
|
11
16
|
import { StyleRoot } from "../StyleRoot.js";
|
|
12
17
|
import { B3Context } from "./types.js";
|
|
13
|
-
|
|
18
|
+
const debug = debugB3React("B3Provider");
|
|
14
19
|
/**
|
|
15
20
|
* Default permissions configuration for B3 provider
|
|
16
21
|
*/
|
|
@@ -20,16 +25,12 @@ const DEFAULT_PERMISSIONS = {
|
|
|
20
25
|
startDate: new Date(),
|
|
21
26
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
22
27
|
};
|
|
23
|
-
export const wagmiConfig = createConfig({
|
|
24
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
25
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])),
|
|
26
|
-
});
|
|
27
28
|
// Create queryClient instance
|
|
28
29
|
const queryClient = new QueryClient();
|
|
29
30
|
/**
|
|
30
31
|
* Main B3Provider component
|
|
31
32
|
*/
|
|
32
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
|
|
33
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, }) {
|
|
33
34
|
// Initialize Google Analytics on mount
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
loadGA4Script();
|
|
@@ -38,7 +39,32 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
setClientType(clientType);
|
|
40
41
|
}, [clientType]);
|
|
41
|
-
|
|
42
|
+
const ecocystemConfig = useMemo(() => {
|
|
43
|
+
if (!partnerId)
|
|
44
|
+
return undefined;
|
|
45
|
+
return {
|
|
46
|
+
ecosystemId: ecosystemWalletId,
|
|
47
|
+
partnerId: partnerId,
|
|
48
|
+
client,
|
|
49
|
+
};
|
|
50
|
+
}, [partnerId]);
|
|
51
|
+
/**
|
|
52
|
+
* Creates wagmi config with optional custom RPC URLs
|
|
53
|
+
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
54
|
+
*/
|
|
55
|
+
const wagmiConfig = useMemo(() => createConfig({
|
|
56
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
57
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
|
|
58
|
+
connectors: [
|
|
59
|
+
inAppWalletConnector({
|
|
60
|
+
...(ecocystemConfig || {}),
|
|
61
|
+
client,
|
|
62
|
+
}),
|
|
63
|
+
// injected(),
|
|
64
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
65
|
+
],
|
|
66
|
+
}), [partnerId]);
|
|
67
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
42
68
|
}
|
|
43
69
|
/**
|
|
44
70
|
* Inner provider component that provides the actual B3Context
|
|
@@ -49,6 +75,7 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
49
75
|
const wallets = useConnectedWallets();
|
|
50
76
|
const setActiveWallet = useSetActiveWallet();
|
|
51
77
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
78
|
+
debug("@@wallets", wallets);
|
|
52
79
|
const [user, setUser] = useState(() => {
|
|
53
80
|
// Try to restore user from localStorage on initialization
|
|
54
81
|
if (typeof window !== "undefined") {
|
|
@@ -79,7 +106,7 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
79
106
|
const setWallet = useCallback((wallet) => {
|
|
80
107
|
setManuallySelectedWallet(wallet);
|
|
81
108
|
const account = wallet.getAccount();
|
|
82
|
-
|
|
109
|
+
debug("@@setWallet", wallet.id, account?.address);
|
|
83
110
|
setActiveWallet(wallet);
|
|
84
111
|
}, [setManuallySelectedWallet, setActiveWallet]);
|
|
85
112
|
useEffect(() => {
|