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