@b3dotfun/sdk 0.0.32 → 0.0.33-alpha.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.
Files changed (26) hide show
  1. package/dist/cjs/anyspend/types/api.d.ts +26 -7
  2. package/dist/cjs/bondkit/bondkitToken.d.ts +2 -0
  3. package/dist/cjs/bondkit/bondkitToken.js +32 -1
  4. package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -5
  5. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  6. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  7. package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +1 -1
  8. package/dist/cjs/global-account/react/hooks/useFirstEOA.js +1 -1
  9. package/dist/esm/anyspend/types/api.d.ts +26 -7
  10. package/dist/esm/bondkit/bondkitToken.d.ts +2 -0
  11. package/dist/esm/bondkit/bondkitToken.js +32 -1
  12. package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +1 -1
  13. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  14. package/dist/esm/global-account/react/hooks/index.js +1 -0
  15. package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +1 -1
  16. package/dist/esm/global-account/react/hooks/useFirstEOA.js +1 -1
  17. package/dist/types/anyspend/types/api.d.ts +26 -7
  18. package/dist/types/bondkit/bondkitToken.d.ts +2 -0
  19. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  20. package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/anyspend/types/api.ts +26 -7
  23. package/src/bondkit/bondkitToken.ts +36 -1
  24. package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +1 -1
  25. package/src/global-account/react/hooks/index.ts +1 -0
  26. package/src/global-account/react/hooks/useFirstEOA.tsx +1 -1
@@ -50,7 +50,7 @@ export interface paths {
50
50
  decimals: number;
51
51
  metadata: {
52
52
  /** @description Token logo URI */
53
- logoURI: string;
53
+ logoURI?: string;
54
54
  };
55
55
  }[];
56
56
  /** @example 200 */
@@ -874,28 +874,47 @@ export interface components {
874
874
  * @description Country code
875
875
  * @example US
876
876
  */
877
- country?: string;
877
+ country: string;
878
878
  /**
879
879
  * @description Onramp vendor used
880
880
  * @example stripe-web2
881
881
  * @enum {string}
882
882
  */
883
- vendor?: "coinbase" | "stripe" | "stripe-web2";
883
+ vendor: "coinbase" | "stripe" | "stripe-web2";
884
884
  /**
885
885
  * @description Payment method used
886
886
  * @example
887
887
  */
888
- paymentMethod?: string;
888
+ paymentMethod: string;
889
889
  /**
890
890
  * @description Redirect URL after payment
891
891
  * @example https://www.anyspend.com
892
892
  */
893
- redirectUrl?: string;
893
+ redirectUrl: string;
894
894
  /**
895
895
  * @description Stripe payment amount in cents
896
896
  * @example 9900
897
897
  */
898
898
  stripeAmountInCents?: number;
899
+ /**
900
+ * Format: ipv4
901
+ * @description Optional IP address for location detection
902
+ * @example 192.168.1.1
903
+ */
904
+ ipAddress?: string;
905
+ /** @description Optional fingerprint data for fraud detection */
906
+ fingerprint?: {
907
+ /**
908
+ * @description Fingerprint request ID
909
+ * @example fp_req_12345
910
+ */
911
+ requestId: string;
912
+ /**
913
+ * @description Fingerprint visitor ID
914
+ * @example fp_visitor_67890
915
+ */
916
+ visitorId: string;
917
+ };
899
918
  };
900
919
  /** @description Optional onramp configuration */
901
920
  Onramp: {
@@ -1497,10 +1516,10 @@ export interface components {
1497
1516
  */
1498
1517
  chain: number;
1499
1518
  /**
1500
- * @description Sender address
1519
+ * @description Sender address (can be null)
1501
1520
  * @example 0xa7539e73700B1726aBA29526606442A491Ef5747
1502
1521
  */
1503
- from: string;
1522
+ from?: string | null;
1504
1523
  /**
1505
1524
  * @description Transaction hash
1506
1525
  * @example 0x60ece99a645201668d20db6775a6b3d30967433ff0750b356cdad46d3e13f9c8
@@ -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");
@@ -50,7 +50,7 @@ export interface paths {
50
50
  decimals: number;
51
51
  metadata: {
52
52
  /** @description Token logo URI */
53
- logoURI: string;
53
+ logoURI?: string;
54
54
  };
55
55
  }[];
56
56
  /** @example 200 */
@@ -874,28 +874,47 @@ export interface components {
874
874
  * @description Country code
875
875
  * @example US
876
876
  */
877
- country?: string;
877
+ country: string;
878
878
  /**
879
879
  * @description Onramp vendor used
880
880
  * @example stripe-web2
881
881
  * @enum {string}
882
882
  */
883
- vendor?: "coinbase" | "stripe" | "stripe-web2";
883
+ vendor: "coinbase" | "stripe" | "stripe-web2";
884
884
  /**
885
885
  * @description Payment method used
886
886
  * @example
887
887
  */
888
- paymentMethod?: string;
888
+ paymentMethod: string;
889
889
  /**
890
890
  * @description Redirect URL after payment
891
891
  * @example https://www.anyspend.com
892
892
  */
893
- redirectUrl?: string;
893
+ redirectUrl: string;
894
894
  /**
895
895
  * @description Stripe payment amount in cents
896
896
  * @example 9900
897
897
  */
898
898
  stripeAmountInCents?: number;
899
+ /**
900
+ * Format: ipv4
901
+ * @description Optional IP address for location detection
902
+ * @example 192.168.1.1
903
+ */
904
+ ipAddress?: string;
905
+ /** @description Optional fingerprint data for fraud detection */
906
+ fingerprint?: {
907
+ /**
908
+ * @description Fingerprint request ID
909
+ * @example fp_req_12345
910
+ */
911
+ requestId: string;
912
+ /**
913
+ * @description Fingerprint visitor ID
914
+ * @example fp_visitor_67890
915
+ */
916
+ visitorId: string;
917
+ };
899
918
  };
900
919
  /** @description Optional onramp configuration */
901
920
  Onramp: {
@@ -1497,10 +1516,10 @@ export interface components {
1497
1516
  */
1498
1517
  chain: number;
1499
1518
  /**
1500
- * @description Sender address
1519
+ * @description Sender address (can be null)
1501
1520
  * @example 0xa7539e73700B1726aBA29526606442A491Ef5747
1502
1521
  */
1503
- from: string;
1522
+ from?: string | null;
1504
1523
  /**
1505
1524
  * @description Transaction hash
1506
1525
  * @example 0x60ece99a645201668d20db6775a6b3d30967433ff0750b356cdad46d3e13f9c8
@@ -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);
@@ -50,7 +50,7 @@ export interface paths {
50
50
  decimals: number;
51
51
  metadata: {
52
52
  /** @description Token logo URI */
53
- logoURI: string;
53
+ logoURI?: string;
54
54
  };
55
55
  }[];
56
56
  /** @example 200 */
@@ -874,28 +874,47 @@ export interface components {
874
874
  * @description Country code
875
875
  * @example US
876
876
  */
877
- country?: string;
877
+ country: string;
878
878
  /**
879
879
  * @description Onramp vendor used
880
880
  * @example stripe-web2
881
881
  * @enum {string}
882
882
  */
883
- vendor?: "coinbase" | "stripe" | "stripe-web2";
883
+ vendor: "coinbase" | "stripe" | "stripe-web2";
884
884
  /**
885
885
  * @description Payment method used
886
886
  * @example
887
887
  */
888
- paymentMethod?: string;
888
+ paymentMethod: string;
889
889
  /**
890
890
  * @description Redirect URL after payment
891
891
  * @example https://www.anyspend.com
892
892
  */
893
- redirectUrl?: string;
893
+ redirectUrl: string;
894
894
  /**
895
895
  * @description Stripe payment amount in cents
896
896
  * @example 9900
897
897
  */
898
898
  stripeAmountInCents?: number;
899
+ /**
900
+ * Format: ipv4
901
+ * @description Optional IP address for location detection
902
+ * @example 192.168.1.1
903
+ */
904
+ ipAddress?: string;
905
+ /** @description Optional fingerprint data for fraud detection */
906
+ fingerprint?: {
907
+ /**
908
+ * @description Fingerprint request ID
909
+ * @example fp_req_12345
910
+ */
911
+ requestId: string;
912
+ /**
913
+ * @description Fingerprint visitor ID
914
+ * @example fp_visitor_67890
915
+ */
916
+ visitorId: string;
917
+ };
899
918
  };
900
919
  /** @description Optional onramp configuration */
901
920
  Onramp: {
@@ -1497,10 +1516,10 @@ export interface components {
1497
1516
  */
1498
1517
  chain: number;
1499
1518
  /**
1500
- * @description Sender address
1519
+ * @description Sender address (can be null)
1501
1520
  * @example 0xa7539e73700B1726aBA29526606442A491Ef5747
1502
1521
  */
1503
- from: string;
1522
+ from?: string | null;
1504
1523
  /**
1505
1524
  * @description Transaction hash
1506
1525
  * @example 0x60ece99a645201668d20db6775a6b3d30967433ff0750b356cdad46d3e13f9c8
@@ -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",
3
+ "version": "0.0.33-alpha.0",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -51,7 +51,7 @@ export interface paths {
51
51
  decimals: number;
52
52
  metadata: {
53
53
  /** @description Token logo URI */
54
- logoURI: string;
54
+ logoURI?: string;
55
55
  };
56
56
  }[];
57
57
  /** @example 200 */
@@ -880,28 +880,47 @@ export interface components {
880
880
  * @description Country code
881
881
  * @example US
882
882
  */
883
- country?: string;
883
+ country: string;
884
884
  /**
885
885
  * @description Onramp vendor used
886
886
  * @example stripe-web2
887
887
  * @enum {string}
888
888
  */
889
- vendor?: "coinbase" | "stripe" | "stripe-web2";
889
+ vendor: "coinbase" | "stripe" | "stripe-web2";
890
890
  /**
891
891
  * @description Payment method used
892
892
  * @example
893
893
  */
894
- paymentMethod?: string;
894
+ paymentMethod: string;
895
895
  /**
896
896
  * @description Redirect URL after payment
897
897
  * @example https://www.anyspend.com
898
898
  */
899
- redirectUrl?: string;
899
+ redirectUrl: string;
900
900
  /**
901
901
  * @description Stripe payment amount in cents
902
902
  * @example 9900
903
903
  */
904
904
  stripeAmountInCents?: number;
905
+ /**
906
+ * Format: ipv4
907
+ * @description Optional IP address for location detection
908
+ * @example 192.168.1.1
909
+ */
910
+ ipAddress?: string;
911
+ /** @description Optional fingerprint data for fraud detection */
912
+ fingerprint?: {
913
+ /**
914
+ * @description Fingerprint request ID
915
+ * @example fp_req_12345
916
+ */
917
+ requestId: string;
918
+ /**
919
+ * @description Fingerprint visitor ID
920
+ * @example fp_visitor_67890
921
+ */
922
+ visitorId: string;
923
+ };
905
924
  };
906
925
  /** @description Optional onramp configuration */
907
926
  Onramp: {
@@ -1522,10 +1541,10 @@ export interface components {
1522
1541
  */
1523
1542
  chain: number;
1524
1543
  /**
1525
- * @description Sender address
1544
+ * @description Sender address (can be null)
1526
1545
  * @example 0xa7539e73700B1726aBA29526606442A491Ef5747
1527
1546
  */
1528
- from: string;
1547
+ from?: string | null;
1529
1548
  /**
1530
1549
  * @description Transaction hash
1531
1550
  * @example 0x60ece99a645201668d20db6775a6b3d30967433ff0750b356cdad46d3e13f9c8
@@ -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);