@b3dotfun/sdk 0.0.32-alpha.1 → 0.0.32-alpha.2

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.
@@ -55,6 +55,8 @@ export declare class BondkitToken {
55
55
  } | undefined>;
56
56
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
57
57
  private executeWrite;
58
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
59
+ waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
58
60
  initialize(config: BondkitTokenInitializationConfig, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
59
61
  transfer(to: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
60
62
  approve(spender: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
@@ -10,6 +10,9 @@ const config_1 = require("./config");
10
10
  const boughtEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
11
11
  const soldEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
12
12
  const dexMigrationEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondkitTokenMigrated");
13
+ // OKX wallet polling constants
14
+ const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
15
+ const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
13
16
  class BondkitToken {
14
17
  constructor(contractAddress, walletKey) {
15
18
  const sdkConfig = (0, config_1.getConfig)(chains_1.base.id);
@@ -453,6 +456,34 @@ class BondkitToken {
453
456
  return this.handleError(error, functionName);
454
457
  }
455
458
  }
459
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
460
+ async waitForTransaction(hash) {
461
+ const isOKX = (typeof window !== "undefined" && window.ethereum?.isOKXWallet) || window.okxwallet;
462
+ if (isOKX) {
463
+ // Fallback to polling for OKX wallet
464
+ let retries = 0;
465
+ while (retries < OKX_POLLING_MAX_RETRIES) {
466
+ try {
467
+ const receipt = await this.publicClient.getTransactionReceipt({ hash });
468
+ if (receipt) {
469
+ return receipt;
470
+ }
471
+ }
472
+ catch (error) {
473
+ if (error.name !== "TransactionReceiptNotFoundError") {
474
+ throw error;
475
+ }
476
+ }
477
+ await new Promise(resolve => setTimeout(resolve, OKX_POLLING_INTERVAL_MS));
478
+ retries++;
479
+ }
480
+ throw new Error("Transaction confirmation timeout");
481
+ }
482
+ else {
483
+ // Use normal waitForTransactionReceipt for other wallets
484
+ return await this.publicClient.waitForTransactionReceipt({ hash });
485
+ }
486
+ }
456
487
  async initialize(config, options) {
457
488
  return this.executeWrite("initialize", [config], options);
458
489
  }
@@ -503,7 +534,7 @@ class BondkitToken {
503
534
  if (options?.maxPriorityFeePerGas !== undefined)
504
535
  approveOptions.maxPriorityFeePerGas = options.maxPriorityFeePerGas;
505
536
  const approveTx = await tradingTokenContract.write.approve([this.contractAddress, amountBigInt], approveOptions);
506
- await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
537
+ await this.waitForTransaction(approveTx);
507
538
  }
508
539
  // Now call the buy function with the trading token amount
509
540
  return this.executeWrite("buy", [amountBigInt, minTokensOut], options);
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.BalanceContent = BalanceContent;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -13,7 +10,7 @@ const utils_1 = require("../../../../shared/utils");
13
10
  const lucide_react_1 = require("lucide-react");
14
11
  const react_2 = require("react");
15
12
  const react_3 = require("thirdweb/react");
16
- const useFirstEOA_1 = __importDefault(require("../../hooks/useFirstEOA"));
13
+ const useFirstEOA_1 = require("../../hooks/useFirstEOA");
17
14
  const TokenIcon_1 = require("../TokenIcon");
18
15
  const accordion_1 = require("../ui/accordion");
19
16
  const TokenBalanceRow_1 = require("./TokenBalanceRow");
@@ -24,7 +21,7 @@ function centerTruncate(str, length = 4) {
24
21
  }
25
22
  function BalanceContent({ onLogout, partnerId }) {
26
23
  const account = (0, react_3.useActiveAccount)();
27
- const { address: eoaAddress, info: eoaInfo } = (0, useFirstEOA_1.default)();
24
+ const { address: eoaAddress, info: eoaInfo } = (0, useFirstEOA_1.useFirstEOA)();
28
25
  const { data: profile } = (0, react_1.useProfile)({
29
26
  address: eoaAddress || account?.address,
30
27
  fresh: true,
@@ -10,6 +10,7 @@ export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
10
  export * from "./useClaim";
11
11
  export { useConnect } from "./useConnect";
12
12
  export { useExchangeRate } from "./useExchangeRate";
13
+ export { useFirstEOA } from "./useFirstEOA";
13
14
  export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
14
15
  export { useGetGeo } from "./useGetGeo";
15
16
  export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
17
+ exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
18
18
  var useAccountAssets_1 = require("./useAccountAssets");
19
19
  Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
20
20
  var useAccountWallet_1 = require("./useAccountWallet");
@@ -38,6 +38,8 @@ var useConnect_1 = require("./useConnect");
38
38
  Object.defineProperty(exports, "useConnect", { enumerable: true, get: function () { return useConnect_1.useConnect; } });
39
39
  var useExchangeRate_1 = require("./useExchangeRate");
40
40
  Object.defineProperty(exports, "useExchangeRate", { enumerable: true, get: function () { return useExchangeRate_1.useExchangeRate; } });
41
+ var useFirstEOA_1 = require("./useFirstEOA");
42
+ Object.defineProperty(exports, "useFirstEOA", { enumerable: true, get: function () { return useFirstEOA_1.useFirstEOA; } });
41
43
  var useGetAllTWSigners_1 = require("./useGetAllTWSigners");
42
44
  Object.defineProperty(exports, "useGetAllTWSigners", { enumerable: true, get: function () { return useGetAllTWSigners_1.useGetAllTWSigners; } });
43
45
  var useGetGeo_1 = require("./useGetGeo");
@@ -1,5 +1,5 @@
1
1
  import { Wallet } from "thirdweb/wallets";
2
- export default function useFirstEOA(): {
2
+ export declare function useFirstEOA(): {
3
3
  account: Wallet | undefined;
4
4
  address: string | undefined;
5
5
  info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = useFirstEOA;
3
+ exports.useFirstEOA = useFirstEOA;
4
4
  const react_1 = require("../../../global-account/react");
5
5
  const debug_1 = require("../../../shared/utils/debug");
6
6
  const react_2 = require("react");
@@ -55,6 +55,8 @@ export declare class BondkitToken {
55
55
  } | undefined>;
56
56
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
57
57
  private executeWrite;
58
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
59
+ waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
58
60
  initialize(config: BondkitTokenInitializationConfig, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
59
61
  transfer(to: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
60
62
  approve(spender: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
@@ -7,6 +7,9 @@ import { getConfig } from "./config.js";
7
7
  const boughtEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
8
8
  const soldEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
9
9
  const dexMigrationEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondkitTokenMigrated");
10
+ // OKX wallet polling constants
11
+ const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
12
+ const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
10
13
  export class BondkitToken {
11
14
  constructor(contractAddress, walletKey) {
12
15
  const sdkConfig = getConfig(base.id);
@@ -450,6 +453,34 @@ export class BondkitToken {
450
453
  return this.handleError(error, functionName);
451
454
  }
452
455
  }
456
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
457
+ async waitForTransaction(hash) {
458
+ const isOKX = (typeof window !== "undefined" && window.ethereum?.isOKXWallet) || window.okxwallet;
459
+ if (isOKX) {
460
+ // Fallback to polling for OKX wallet
461
+ let retries = 0;
462
+ while (retries < OKX_POLLING_MAX_RETRIES) {
463
+ try {
464
+ const receipt = await this.publicClient.getTransactionReceipt({ hash });
465
+ if (receipt) {
466
+ return receipt;
467
+ }
468
+ }
469
+ catch (error) {
470
+ if (error.name !== "TransactionReceiptNotFoundError") {
471
+ throw error;
472
+ }
473
+ }
474
+ await new Promise(resolve => setTimeout(resolve, OKX_POLLING_INTERVAL_MS));
475
+ retries++;
476
+ }
477
+ throw new Error("Transaction confirmation timeout");
478
+ }
479
+ else {
480
+ // Use normal waitForTransactionReceipt for other wallets
481
+ return await this.publicClient.waitForTransactionReceipt({ hash });
482
+ }
483
+ }
453
484
  async initialize(config, options) {
454
485
  return this.executeWrite("initialize", [config], options);
455
486
  }
@@ -500,7 +531,7 @@ export class BondkitToken {
500
531
  if (options?.maxPriorityFeePerGas !== undefined)
501
532
  approveOptions.maxPriorityFeePerGas = options.maxPriorityFeePerGas;
502
533
  const approveTx = await tradingTokenContract.write.approve([this.contractAddress, amountBigInt], approveOptions);
503
- await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
534
+ await this.waitForTransaction(approveTx);
504
535
  }
505
536
  // Now call the buy function with the trading token amount
506
537
  return this.executeWrite("buy", [amountBigInt, minTokensOut], options);
@@ -7,7 +7,7 @@ import { formatUsername } from "../../../../shared/utils/index.js";
7
7
  import { Loader2, Pencil } from "lucide-react";
8
8
  import { useEffect, useRef, useState } from "react";
9
9
  import { useActiveAccount } from "thirdweb/react";
10
- import useFirstEOA from "../../hooks/useFirstEOA.js";
10
+ import { useFirstEOA } from "../../hooks/useFirstEOA.js";
11
11
  import { B3TokenIcon, EthereumTokenIcon } from "../TokenIcon.js";
12
12
  import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion.js";
13
13
  import { TokenBalanceRow } from "./TokenBalanceRow.js";
@@ -10,6 +10,7 @@ export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
10
  export * from "./useClaim";
11
11
  export { useConnect } from "./useConnect";
12
12
  export { useExchangeRate } from "./useExchangeRate";
13
+ export { useFirstEOA } from "./useFirstEOA";
13
14
  export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
14
15
  export { useGetGeo } from "./useGetGeo";
15
16
  export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
@@ -10,6 +10,7 @@ export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
10
10
  export * from "./useClaim.js";
11
11
  export { useConnect } from "./useConnect.js";
12
12
  export { useExchangeRate } from "./useExchangeRate.js";
13
+ export { useFirstEOA } from "./useFirstEOA.js";
13
14
  export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
14
15
  export { useGetGeo } from "./useGetGeo.js";
15
16
  export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
@@ -1,5 +1,5 @@
1
1
  import { Wallet } from "thirdweb/wallets";
2
- export default function useFirstEOA(): {
2
+ export declare function useFirstEOA(): {
3
3
  account: Wallet | undefined;
4
4
  address: string | undefined;
5
5
  info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
@@ -3,7 +3,7 @@ import { debugB3React } from "../../../shared/utils/debug.js";
3
3
  import { useEffect, useState } from "react";
4
4
  import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
5
5
  const debug = debugB3React("useFirstEOA");
6
- export default function useFirstEOA() {
6
+ export function useFirstEOA() {
7
7
  const wallets = useConnectedWallets();
8
8
  const isConnected = useAuthStore(state => state.isConnected);
9
9
  const [firstEOA, setFirstEOA] = useState(undefined);
@@ -55,6 +55,8 @@ export declare class BondkitToken {
55
55
  } | undefined>;
56
56
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
57
57
  private executeWrite;
58
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
59
+ waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
58
60
  initialize(config: BondkitTokenInitializationConfig, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
59
61
  transfer(to: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
60
62
  approve(spender: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
@@ -10,6 +10,7 @@ export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
10
  export * from "./useClaim";
11
11
  export { useConnect } from "./useConnect";
12
12
  export { useExchangeRate } from "./useExchangeRate";
13
+ export { useFirstEOA } from "./useFirstEOA";
13
14
  export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
14
15
  export { useGetGeo } from "./useGetGeo";
15
16
  export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
@@ -1,5 +1,5 @@
1
1
  import { Wallet } from "thirdweb/wallets";
2
- export default function useFirstEOA(): {
2
+ export declare function useFirstEOA(): {
3
3
  account: Wallet | undefined;
4
4
  address: string | undefined;
5
5
  info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.32-alpha.1",
3
+ "version": "0.0.32-alpha.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -38,6 +38,10 @@ type ExecuteWriteOptions = {
38
38
  // Potentially add nonce or other parameters if needed
39
39
  };
40
40
 
41
+ // OKX wallet polling constants
42
+ const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
43
+ const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
44
+
41
45
  export class BondkitToken {
42
46
  public contract: GetContractReturnType<typeof BondkitTokenABI, WalletClient>;
43
47
  public publicClient: PublicClient;
@@ -522,6 +526,37 @@ export class BondkitToken {
522
526
  }
523
527
  }
524
528
 
529
+ /** Helper method to wait for transaction confirmation with OKX wallet fallback */
530
+ public async waitForTransaction(hash: Hex) {
531
+ const isOKX = (typeof window !== "undefined" && (window as any).ethereum?.isOKXWallet) || (window as any).okxwallet;
532
+
533
+ if (isOKX) {
534
+ // Fallback to polling for OKX wallet
535
+ let retries = 0;
536
+
537
+ while (retries < OKX_POLLING_MAX_RETRIES) {
538
+ try {
539
+ const receipt = await this.publicClient.getTransactionReceipt({ hash });
540
+ if (receipt) {
541
+ return receipt;
542
+ }
543
+ } catch (error: any) {
544
+ if (error.name !== "TransactionReceiptNotFoundError") {
545
+ throw error;
546
+ }
547
+ }
548
+
549
+ await new Promise(resolve => setTimeout(resolve, OKX_POLLING_INTERVAL_MS));
550
+ retries++;
551
+ }
552
+
553
+ throw new Error("Transaction confirmation timeout");
554
+ } else {
555
+ // Use normal waitForTransactionReceipt for other wallets
556
+ return await this.publicClient.waitForTransactionReceipt({ hash });
557
+ }
558
+ }
559
+
525
560
  public async initialize(
526
561
  config: BondkitTokenInitializationConfig,
527
562
  options?: ExecuteWriteOptions,
@@ -594,7 +629,7 @@ export class BondkitToken {
594
629
  approveOptions,
595
630
  );
596
631
 
597
- await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
632
+ await this.waitForTransaction(approveTx);
598
633
  }
599
634
 
600
635
  // Now call the buy function with the trading token amount
@@ -14,7 +14,7 @@ import { formatUsername } from "@b3dotfun/sdk/shared/utils";
14
14
  import { Loader2, Pencil } from "lucide-react";
15
15
  import { useEffect, useRef, useState } from "react";
16
16
  import { useActiveAccount } from "thirdweb/react";
17
- import useFirstEOA from "../../hooks/useFirstEOA";
17
+ import { useFirstEOA } from "../../hooks/useFirstEOA";
18
18
  import { B3TokenIcon, EthereumTokenIcon } from "../TokenIcon";
19
19
  import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion";
20
20
  import { TokenBalanceRow } from "./TokenBalanceRow";
@@ -10,6 +10,7 @@ export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
10
  export * from "./useClaim";
11
11
  export { useConnect } from "./useConnect";
12
12
  export { useExchangeRate } from "./useExchangeRate";
13
+ export { useFirstEOA } from "./useFirstEOA";
13
14
  export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
14
15
  export { useGetGeo } from "./useGetGeo";
15
16
  export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
@@ -6,7 +6,7 @@ import { Wallet } from "thirdweb/wallets";
6
6
 
7
7
  const debug = debugB3React("useFirstEOA");
8
8
 
9
- export default function useFirstEOA() {
9
+ export function useFirstEOA() {
10
10
  const wallets = useConnectedWallets();
11
11
  const isConnected = useAuthStore(state => state.isConnected);
12
12
  const [firstEOA, setFirstEOA] = useState<Wallet | undefined>(undefined);