@b3dotfun/sdk 0.0.40-alpha.2 → 0.0.40-alpha.4
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/bondkit/bondkitToken.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitToken.js +2 -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/global-account/react/components/B3Provider/B3Provider.d.ts +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +14 -7
- package/dist/esm/bondkit/bondkitToken.d.ts +1 -1
- package/dist/esm/bondkit/bondkitToken.js +2 -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/global-account/react/components/B3Provider/B3Provider.d.ts +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +13 -5
- package/dist/types/bondkit/bondkitToken.d.ts +1 -1
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -2
- package/package.json +1 -1
- package/src/bondkit/bondkitToken.ts +2 -2
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/config.ts +5 -2
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +15 -4
|
@@ -18,7 +18,7 @@ export declare class BondkitToken {
|
|
|
18
18
|
private walletClientInstance;
|
|
19
19
|
private connectedProvider?;
|
|
20
20
|
private tradingToken?;
|
|
21
|
-
constructor(contractAddress: string, walletKey?: string);
|
|
21
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
|
|
22
22
|
connect(provider?: EIP1193Provider): boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -14,8 +14,8 @@ const dexMigrationEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "
|
|
|
14
14
|
const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
|
|
15
15
|
const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
|
|
16
16
|
class BondkitToken {
|
|
17
|
-
constructor(contractAddress, walletKey) {
|
|
18
|
-
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id);
|
|
17
|
+
constructor(contractAddress, walletKey, rpcUrl) {
|
|
18
|
+
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id, rpcUrl);
|
|
19
19
|
this.chain = sdkConfig.chain;
|
|
20
20
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
21
21
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -10,7 +10,7 @@ export declare class BondkitTokenFactory {
|
|
|
10
10
|
private rpcUrl;
|
|
11
11
|
private walletClientInstance;
|
|
12
12
|
private connectedProvider?;
|
|
13
|
-
constructor(chainId: SupportedChainId, walletKey?: string);
|
|
13
|
+
constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string);
|
|
14
14
|
connect(provider?: EIP1193Provider): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -8,14 +8,14 @@ const config_1 = require("./config");
|
|
|
8
8
|
// Define the event ABI snippet for BondkitTokenCreated specifically for decoding
|
|
9
9
|
const bondkitTokenCreatedEventAbi = abis_1.BondkitTokenFactoryABI.find(item => item.type === "event" && item.name === "BondkitTokenCreated");
|
|
10
10
|
class BondkitTokenFactory {
|
|
11
|
-
constructor(chainId, walletKey) {
|
|
11
|
+
constructor(chainId, walletKey, rpcUrl) {
|
|
12
12
|
if (walletKey && !walletKey.startsWith("0x")) {
|
|
13
13
|
this.walletKey = `0x${walletKey}`;
|
|
14
14
|
}
|
|
15
15
|
else if (walletKey) {
|
|
16
16
|
this.walletKey = walletKey;
|
|
17
17
|
}
|
|
18
|
-
const config = (0, config_1.getConfig)(chainId);
|
|
18
|
+
const config = (0, config_1.getConfig)(chainId, rpcUrl);
|
|
19
19
|
this.chain = config.chain;
|
|
20
20
|
this.contractAddress = config.factoryAddress;
|
|
21
21
|
this.rpcUrl = config.rpcUrl;
|
|
@@ -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
|
};
|
|
@@ -3,11 +3,10 @@ import { Account } from "thirdweb/wallets";
|
|
|
3
3
|
import { ClientType } from "../../../client-manager";
|
|
4
4
|
import { B3ContextType } from "./types";
|
|
5
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, }: {
|
|
11
10
|
theme: "light" | "dark";
|
|
12
11
|
children: React.ReactNode;
|
|
13
12
|
accountOverride?: Account;
|
|
@@ -19,6 +18,7 @@ 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
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
/**
|
|
24
24
|
* Inner provider component that provides the actual B3Context
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wagmiConfig = void 0;
|
|
4
3
|
exports.B3Provider = B3Provider;
|
|
5
4
|
exports.InnerProvider = InnerProvider;
|
|
6
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -25,16 +24,24 @@ const DEFAULT_PERMISSIONS = {
|
|
|
25
24
|
startDate: new Date(),
|
|
26
25
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Creates wagmi config with optional custom RPC URLs
|
|
29
|
+
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
30
|
+
*/
|
|
31
|
+
function createWagmiConfig(rpcUrls) {
|
|
32
|
+
return (0, wagmi_1.createConfig)({
|
|
33
|
+
chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
|
|
34
|
+
transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)(rpcUrls?.[chain.id])])),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
32
37
|
// Create queryClient instance
|
|
33
38
|
const queryClient = new react_query_1.QueryClient();
|
|
34
39
|
/**
|
|
35
40
|
* Main B3Provider component
|
|
36
41
|
*/
|
|
37
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
|
|
42
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, }) {
|
|
43
|
+
// Create wagmi config with custom RPC URLs if provided
|
|
44
|
+
const [wagmiConfig] = (0, react_2.useState)(() => createWagmiConfig(rpcUrls));
|
|
38
45
|
// Initialize Google Analytics on mount
|
|
39
46
|
(0, react_2.useEffect)(() => {
|
|
40
47
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -43,7 +50,7 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
43
50
|
(0, react_2.useEffect)(() => {
|
|
44
51
|
(0, client_manager_1.setClientType)(clientType);
|
|
45
52
|
}, [clientType]);
|
|
46
|
-
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config:
|
|
53
|
+
return ((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_3.ThirdwebProvider, { 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 })] }) }) }) }) }) }));
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* Inner provider component that provides the actual B3Context
|
|
@@ -18,7 +18,7 @@ export declare class BondkitToken {
|
|
|
18
18
|
private walletClientInstance;
|
|
19
19
|
private connectedProvider?;
|
|
20
20
|
private tradingToken?;
|
|
21
|
-
constructor(contractAddress: string, walletKey?: string);
|
|
21
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
|
|
22
22
|
connect(provider?: EIP1193Provider): boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -11,8 +11,8 @@ const dexMigrationEventAbi = BondkitTokenABI.find(item => item.type === "event"
|
|
|
11
11
|
const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
|
|
12
12
|
const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
|
|
13
13
|
export class BondkitToken {
|
|
14
|
-
constructor(contractAddress, walletKey) {
|
|
15
|
-
const sdkConfig = getConfig(base.id);
|
|
14
|
+
constructor(contractAddress, walletKey, rpcUrl) {
|
|
15
|
+
const sdkConfig = getConfig(base.id, rpcUrl);
|
|
16
16
|
this.chain = sdkConfig.chain;
|
|
17
17
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
18
18
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -10,7 +10,7 @@ export declare class BondkitTokenFactory {
|
|
|
10
10
|
private rpcUrl;
|
|
11
11
|
private walletClientInstance;
|
|
12
12
|
private connectedProvider?;
|
|
13
|
-
constructor(chainId: SupportedChainId, walletKey?: string);
|
|
13
|
+
constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string);
|
|
14
14
|
connect(provider?: EIP1193Provider): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -5,14 +5,14 @@ import { getConfig } from "./config.js";
|
|
|
5
5
|
// Define the event ABI snippet for BondkitTokenCreated specifically for decoding
|
|
6
6
|
const bondkitTokenCreatedEventAbi = BondkitTokenFactoryABI.find(item => item.type === "event" && item.name === "BondkitTokenCreated");
|
|
7
7
|
export class BondkitTokenFactory {
|
|
8
|
-
constructor(chainId, walletKey) {
|
|
8
|
+
constructor(chainId, walletKey, rpcUrl) {
|
|
9
9
|
if (walletKey && !walletKey.startsWith("0x")) {
|
|
10
10
|
this.walletKey = `0x${walletKey}`;
|
|
11
11
|
}
|
|
12
12
|
else if (walletKey) {
|
|
13
13
|
this.walletKey = walletKey;
|
|
14
14
|
}
|
|
15
|
-
const config = getConfig(chainId);
|
|
15
|
+
const config = getConfig(chainId, rpcUrl);
|
|
16
16
|
this.chain = config.chain;
|
|
17
17
|
this.contractAddress = config.factoryAddress;
|
|
18
18
|
this.rpcUrl = config.rpcUrl;
|
|
@@ -6,9 +6,12 @@ const baseMainnetConfig = {
|
|
|
6
6
|
factoryAddress: BaseBondkitTokenFactoryContractAddress,
|
|
7
7
|
apiEndpoint: "https://api.b3.fun/bondkit-tokens",
|
|
8
8
|
};
|
|
9
|
-
export const getConfig = (chainId) => {
|
|
9
|
+
export const getConfig = (chainId, rpcUrl) => {
|
|
10
10
|
if (chainId === base.id) {
|
|
11
|
-
return
|
|
11
|
+
return {
|
|
12
|
+
...baseMainnetConfig,
|
|
13
|
+
rpcUrl: rpcUrl || BaseMainnetRpcUrl,
|
|
14
|
+
};
|
|
12
15
|
}
|
|
13
16
|
throw new Error(`Unsupported chainId: ${chainId}. This SDK is configured for Base (Chain ID: ${base.id}) only.`);
|
|
14
17
|
};
|
|
@@ -3,11 +3,10 @@ import { Account } from "thirdweb/wallets";
|
|
|
3
3
|
import { ClientType } from "../../../client-manager";
|
|
4
4
|
import { B3ContextType } from "./types";
|
|
5
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, }: {
|
|
11
10
|
theme: "light" | "dark";
|
|
12
11
|
children: React.ReactNode;
|
|
13
12
|
accountOverride?: Account;
|
|
@@ -19,6 +18,7 @@ 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
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
/**
|
|
24
24
|
* Inner provider component that provides the actual B3Context
|
|
@@ -20,16 +20,24 @@ const DEFAULT_PERMISSIONS = {
|
|
|
20
20
|
startDate: new Date(),
|
|
21
21
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Creates wagmi config with optional custom RPC URLs
|
|
25
|
+
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
26
|
+
*/
|
|
27
|
+
function createWagmiConfig(rpcUrls) {
|
|
28
|
+
return createConfig({
|
|
29
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
30
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
// Create queryClient instance
|
|
28
34
|
const queryClient = new QueryClient();
|
|
29
35
|
/**
|
|
30
36
|
* Main B3Provider component
|
|
31
37
|
*/
|
|
32
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
|
|
38
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, }) {
|
|
39
|
+
// Create wagmi config with custom RPC URLs if provided
|
|
40
|
+
const [wagmiConfig] = useState(() => createWagmiConfig(rpcUrls));
|
|
33
41
|
// Initialize Google Analytics on mount
|
|
34
42
|
useEffect(() => {
|
|
35
43
|
loadGA4Script();
|
|
@@ -18,7 +18,7 @@ export declare class BondkitToken {
|
|
|
18
18
|
private walletClientInstance;
|
|
19
19
|
private connectedProvider?;
|
|
20
20
|
private tradingToken?;
|
|
21
|
-
constructor(contractAddress: string, walletKey?: string);
|
|
21
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
|
|
22
22
|
connect(provider?: EIP1193Provider): boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -10,7 +10,7 @@ export declare class BondkitTokenFactory {
|
|
|
10
10
|
private rpcUrl;
|
|
11
11
|
private walletClientInstance;
|
|
12
12
|
private connectedProvider?;
|
|
13
|
-
constructor(chainId: SupportedChainId, walletKey?: string);
|
|
13
|
+
constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string);
|
|
14
14
|
connect(provider?: EIP1193Provider): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -3,11 +3,10 @@ import { Account } from "thirdweb/wallets";
|
|
|
3
3
|
import { ClientType } from "../../../client-manager";
|
|
4
4
|
import { B3ContextType } from "./types";
|
|
5
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, }: {
|
|
11
10
|
theme: "light" | "dark";
|
|
12
11
|
children: React.ReactNode;
|
|
13
12
|
accountOverride?: Account;
|
|
@@ -19,6 +18,7 @@ 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
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
/**
|
|
24
24
|
* Inner provider component that provides the actual B3Context
|
package/package.json
CHANGED
|
@@ -54,8 +54,8 @@ export class BondkitToken {
|
|
|
54
54
|
private connectedProvider?: EIP1193Provider;
|
|
55
55
|
private tradingToken?: Address;
|
|
56
56
|
|
|
57
|
-
constructor(contractAddress: string, walletKey?: string) {
|
|
58
|
-
const sdkConfig = getConfig(base.id);
|
|
57
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string) {
|
|
58
|
+
const sdkConfig = getConfig(base.id, rpcUrl);
|
|
59
59
|
this.chain = sdkConfig.chain;
|
|
60
60
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
61
61
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -30,14 +30,14 @@ export class BondkitTokenFactory {
|
|
|
30
30
|
private walletClientInstance: WalletClient; // Made non-optional, initialized in constructor
|
|
31
31
|
private connectedProvider?: EIP1193Provider;
|
|
32
32
|
|
|
33
|
-
constructor(chainId: SupportedChainId, walletKey?: string) {
|
|
33
|
+
constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string) {
|
|
34
34
|
if (walletKey && !walletKey.startsWith("0x")) {
|
|
35
35
|
this.walletKey = `0x${walletKey}` as Hex;
|
|
36
36
|
} else if (walletKey) {
|
|
37
37
|
this.walletKey = walletKey as Hex;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const config = getConfig(chainId);
|
|
40
|
+
const config = getConfig(chainId, rpcUrl);
|
|
41
41
|
this.chain = config.chain;
|
|
42
42
|
this.contractAddress = config.factoryAddress;
|
|
43
43
|
this.rpcUrl = config.rpcUrl;
|
package/src/bondkit/config.ts
CHANGED
|
@@ -18,9 +18,12 @@ const baseMainnetConfig: Config = {
|
|
|
18
18
|
apiEndpoint: "https://api.b3.fun/bondkit-tokens",
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const getConfig = (chainId: number): Config => {
|
|
21
|
+
export const getConfig = (chainId: number, rpcUrl?: string): Config => {
|
|
22
22
|
if (chainId === base.id) {
|
|
23
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
...baseMainnetConfig,
|
|
25
|
+
rpcUrl: rpcUrl || BaseMainnetRpcUrl,
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
28
|
throw new Error(`Unsupported chainId: ${chainId}. This SDK is configured for Base (Chain ID: ${base.id}) only.`);
|
|
26
29
|
};
|
|
@@ -31,10 +31,16 @@ const DEFAULT_PERMISSIONS = {
|
|
|
31
31
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Creates wagmi config with optional custom RPC URLs
|
|
36
|
+
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
37
|
+
*/
|
|
38
|
+
function createWagmiConfig(rpcUrls?: Record<number, string>) {
|
|
39
|
+
return createConfig({
|
|
40
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
41
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])) as any,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
38
44
|
|
|
39
45
|
// Create queryClient instance
|
|
40
46
|
const queryClient = new QueryClient();
|
|
@@ -51,6 +57,7 @@ export function B3Provider({
|
|
|
51
57
|
simDuneApiKey,
|
|
52
58
|
toaster,
|
|
53
59
|
clientType = "rest",
|
|
60
|
+
rpcUrls,
|
|
54
61
|
}: {
|
|
55
62
|
theme: "light" | "dark";
|
|
56
63
|
children: React.ReactNode;
|
|
@@ -63,7 +70,11 @@ export function B3Provider({
|
|
|
63
70
|
style?: React.CSSProperties;
|
|
64
71
|
};
|
|
65
72
|
clientType?: ClientType;
|
|
73
|
+
rpcUrls?: Record<number, string>;
|
|
66
74
|
}) {
|
|
75
|
+
// Create wagmi config with custom RPC URLs if provided
|
|
76
|
+
const [wagmiConfig] = useState(() => createWagmiConfig(rpcUrls));
|
|
77
|
+
|
|
67
78
|
// Initialize Google Analytics on mount
|
|
68
79
|
useEffect(() => {
|
|
69
80
|
loadGA4Script();
|