@0xslots/sdk 0.10.0 → 0.10.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.
@@ -1,6 +1,6 @@
1
1
  import { GraphQLClient, RequestOptions } from 'graphql-request';
2
- import * as graphql from 'graphql';
3
2
  import { PublicClient, WalletClient, Address, Hash } from 'viem';
3
+ import * as graphql from 'graphql';
4
4
 
5
5
  type Maybe<T> = T | null;
6
6
  type InputMaybe<T> = T | null;
@@ -4267,8 +4267,7 @@ interface SubgraphMeta {
4267
4267
  }
4268
4268
  declare enum SlotsChain {
4269
4269
  BASE = 8453,
4270
- BASE_SEPOLIA = 84532,
4271
- ARBITRUM = 42161
4270
+ BASE_SEPOLIA = 84532
4272
4271
  }
4273
4272
  declare const SUBGRAPH_URLS: Record<SlotsChain, string>;
4274
4273
  interface SlotConfig {
@@ -4314,7 +4313,7 @@ interface SlotsClientConfig {
4314
4313
  * @example
4315
4314
  * ```ts
4316
4315
  * const client = new SlotsClient({
4317
- * chainId: SlotsChain.ARBITRUM,
4316
+ * chainId: SlotsChain.BASE,
4318
4317
  * publicClient,
4319
4318
  * walletClient,
4320
4319
  * });
@@ -4328,7 +4327,6 @@ declare class SlotsClient {
4328
4327
  private readonly _publicClient?;
4329
4328
  private readonly walletClient?;
4330
4329
  private readonly _factory?;
4331
- private _atomicSupport;
4332
4330
  /** Module namespaces for protocol extensions. */
4333
4331
  readonly modules: {
4334
4332
  metadata: MetadataModuleClient;
@@ -4538,17 +4536,14 @@ declare class SlotsClient {
4538
4536
  functionName: string;
4539
4537
  args?: any[];
4540
4538
  }[]): Promise<Hash>;
4541
- /** Check if wallet supports atomic batch calls (EIP-5792). */
4542
- private supportsAtomicBatch;
4543
- /** Poll EIP-5792 getCallsStatus until the batch settles, then return a tx hash. */
4544
- private pollBatchReceipt;
4545
4539
  /**
4546
- * Execute a contract call that needs ERC-20 allowance.
4547
- * If wallet supports atomic batch (EIP-5792): sends approve + action as one atomic call.
4548
- * Otherwise: chains approve tx (if needed) then action tx.
4540
+ * Approve confirm on-chain execute call sequentially.
4541
+ * Skips approval if the existing allowance already covers the amount.
4549
4542
  */
4550
4543
  private withAllowance;
4544
+ /** Poll `check` every `delayMs` until it returns a truthy value or `maxAttempts` is exhausted. */
4545
+ private pollUntil;
4551
4546
  }
4552
4547
  declare function createSlotsClient(config: SlotsClientConfig): SlotsClient;
4553
4548
 
4554
- export { type GetMetadataSlotsByRecipientQuery as $, type Account as A, type BlockChangedFilter as B, type CreateSlotParams as C, type DepositedEvent as D, type Exact as E, type Factory as F, GetAccountDocument as G, type GetAccountQueryVariables as H, GetAccountsDocument as I, type GetAccountsQuery as J, type GetAccountsQueryVariables as K, GetBoughtEventsDocument as L, type GetBoughtEventsQuery as M, type GetBoughtEventsQueryVariables as N, GetDepositedEventsDocument as O, type GetDepositedEventsQuery as P, type GetDepositedEventsQueryVariables as Q, GetFactoryDocument as R, type GetFactoryQuery as S, type GetFactoryQueryVariables as T, GetLiquidatedEventsDocument as U, type GetLiquidatedEventsQuery as V, type GetLiquidatedEventsQueryVariables as W, GetMetadataSlotDocument as X, type GetMetadataSlotQuery as Y, type GetMetadataSlotQueryVariables as Z, GetMetadataSlotsByRecipientDocument as _, type AccountFieldsFragment as a, type MetadataUpdatedEvent_OrderBy as a$, type GetMetadataSlotsByRecipientQueryVariables as a0, GetMetadataSlotsDocument as a1, type GetMetadataSlotsQuery as a2, type GetMetadataSlotsQueryVariables as a3, GetMetadataUpdatedEventsDocument as a4, type GetMetadataUpdatedEventsQuery as a5, type GetMetadataUpdatedEventsQueryVariables as a6, GetModulesDocument as a7, type GetModulesQuery as a8, type GetModulesQueryVariables as a9, type GetSlotsByRecipientQueryVariables as aA, GetSlotsDocument as aB, type GetSlotsQuery as aC, type GetSlotsQueryVariables as aD, GetTaxCollectedEventsDocument as aE, type GetTaxCollectedEventsQuery as aF, type GetTaxCollectedEventsQueryVariables as aG, GetWithdrawnEventsDocument as aH, type GetWithdrawnEventsQuery as aI, type GetWithdrawnEventsQueryVariables as aJ, type Incremental as aK, type InputMaybe as aL, type LiquidatedEvent as aM, type LiquidatedEvent_Filter as aN, type LiquidatedEvent_OrderBy as aO, type MakeEmpty as aP, type MakeMaybe as aQ, type MakeOptional as aR, type Maybe as aS, MetadataModuleClient as aT, type MetadataSlot as aU, type MetadataSlotFieldsFragment as aV, MetadataSlotFieldsFragmentDoc as aW, type MetadataSlot_Filter as aX, type MetadataSlot_OrderBy as aY, type MetadataUpdatedEvent as aZ, type MetadataUpdatedEvent_Filter as a_, GetPriceUpdatedEventsDocument as aa, type GetPriceUpdatedEventsQuery as ab, type GetPriceUpdatedEventsQueryVariables as ac, GetRecentEventsDocument as ad, type GetRecentEventsQuery as ae, type GetRecentEventsQueryVariables as af, GetReleasedEventsDocument as ag, type GetReleasedEventsQuery as ah, type GetReleasedEventsQueryVariables as ai, GetSettledEventsDocument as aj, type GetSettledEventsQuery as ak, type GetSettledEventsQueryVariables as al, GetSlotActivityDocument as am, type GetSlotActivityQuery as an, type GetSlotActivityQueryVariables as ao, GetSlotDeployedEventsDocument as ap, type GetSlotDeployedEventsQuery as aq, type GetSlotDeployedEventsQueryVariables as ar, GetSlotDocument as as, type GetSlotQuery as at, type GetSlotQueryVariables as au, GetSlotsByOccupantDocument as av, type GetSlotsByOccupantQuery as aw, type GetSlotsByOccupantQueryVariables as ax, GetSlotsByRecipientDocument as ay, type GetSlotsByRecipientQuery as az, AccountFieldsFragmentDoc as b, type Query_MetaArgs as b$, type Module as b0, type ModuleUpdateProposedEvent as b1, type ModuleUpdateProposedEvent_Filter as b2, type ModuleUpdateProposedEvent_OrderBy as b3, type Module_Filter as b4, type Module_OrderBy as b5, type NftCollection as b6, type NftCollectionTokensArgs as b7, type NftCollection_Filter as b8, type NftCollection_OrderBy as b9, type QueryMetadataUpdatedEventsArgs as bA, type QueryModuleArgs as bB, type QueryModuleUpdateProposedEventArgs as bC, type QueryModuleUpdateProposedEventsArgs as bD, type QueryModulesArgs as bE, type QueryNftcollectionArgs as bF, type QueryNftcollectionsArgs as bG, type QueryNfttokenArgs as bH, type QueryNfttokensArgs as bI, type QueryPendingUpdateCancelledEventArgs as bJ, type QueryPendingUpdateCancelledEventsArgs as bK, type QueryPriceUpdatedEventArgs as bL, type QueryPriceUpdatedEventsArgs as bM, type QueryReleasedEventArgs as bN, type QueryReleasedEventsArgs as bO, type QuerySettledEventArgs as bP, type QuerySettledEventsArgs as bQ, type QuerySlotArgs as bR, type QuerySlotDeployedEventArgs as bS, type QuerySlotDeployedEventsArgs as bT, type QuerySlotsArgs as bU, type QueryTaxCollectedEventArgs as bV, type QueryTaxCollectedEventsArgs as bW, type QueryTaxUpdateProposedEventArgs as bX, type QueryTaxUpdateProposedEventsArgs as bY, type QueryWithdrawnEventArgs as bZ, type QueryWithdrawnEventsArgs as b_, type NftToken as ba, type NftToken_Filter as bb, type NftToken_OrderBy as bc, type OrderDirection as bd, type PendingUpdateCancelledEvent as be, type PendingUpdateCancelledEvent_Filter as bf, type PendingUpdateCancelledEvent_OrderBy as bg, type PriceUpdatedEvent as bh, type PriceUpdatedEvent_Filter as bi, type PriceUpdatedEvent_OrderBy as bj, type Query as bk, type QueryAccountArgs as bl, type QueryAccountsArgs as bm, type QueryBoughtEventArgs as bn, type QueryBoughtEventsArgs as bo, type QueryCurrenciesArgs as bp, type QueryCurrencyArgs as bq, type QueryDepositedEventArgs as br, type QueryDepositedEventsArgs as bs, type QueryFactoriesArgs as bt, type QueryFactoryArgs as bu, type QueryLiquidatedEventArgs as bv, type QueryLiquidatedEventsArgs as bw, type QueryMetadataSlotArgs as bx, type QueryMetadataSlotsArgs as by, type QueryMetadataUpdatedEventArgs as bz, type AccountSlotsAsOccupantArgs as c, type ReleasedEvent as c0, type ReleasedEvent_Filter as c1, type ReleasedEvent_OrderBy as c2, SUBGRAPH_URLS as c3, type Scalars as c4, type Sdk as c5, type SdkFunctionWrapper as c6, type SettledEvent as c7, type SettledEvent_Filter as c8, type SettledEvent_OrderBy as c9, type TaxCollectedEvent as cA, type TaxCollectedEvent_Filter as cB, type TaxCollectedEvent_OrderBy as cC, type TaxUpdateProposedEvent as cD, type TaxUpdateProposedEvent_Filter as cE, type TaxUpdateProposedEvent_OrderBy as cF, type WithdrawnEvent as cG, type WithdrawnEvent_Filter as cH, type WithdrawnEvent_OrderBy as cI, type _Block_ as cJ, type _Meta_ as cK, type _SubgraphErrorPolicy_ as cL, createSlotsClient as cM, getSdk as cN, type Slot as ca, type SlotConfig as cb, type SlotDeployedEvent as cc, type SlotDeployedEvent_Filter as cd, type SlotDeployedEvent_OrderBy as ce, type SlotDepositsArgs as cf, type SlotFieldsFragment as cg, SlotFieldsFragmentDoc as ch, type SlotInitParams as ci, type SlotLiquidationsArgs as cj, type SlotMetadataUpdatesArgs as ck, type SlotModuleUpdateProposalsArgs as cl, type SlotPendingUpdateCancellationsArgs as cm, type SlotPriceUpdatesArgs as cn, type SlotPurchasesArgs as co, type SlotReleasesArgs as cp, type SlotSettlementsArgs as cq, type SlotTaxCollectionsArgs as cr, type SlotTaxUpdateProposalsArgs as cs, type SlotWithdrawalsArgs as ct, type Slot_Filter as cu, type Slot_OrderBy as cv, SlotsChain as cw, SlotsClient as cx, type SlotsClientConfig as cy, type SubgraphMeta as cz, type AccountSlotsAsRecipientArgs as d, type AccountType as e, type Account_Filter as f, type Account_OrderBy as g, type Aggregation_Current as h, type Aggregation_Interval as i, type Block_Height as j, type BoughtEvent as k, type BoughtEvent_Filter as l, type BoughtEvent_OrderBy as m, type BuyParams as n, type CreateSlotsParams as o, type Currency as p, type CurrencyFieldsFragment as q, CurrencyFieldsFragmentDoc as r, type Currency_Filter as s, type Currency_OrderBy as t, type DepositedEvent_Filter as u, type DepositedEvent_OrderBy as v, type FactoryModulesArgs as w, type Factory_Filter as x, type Factory_OrderBy as y, type GetAccountQuery as z };
4549
+ export { GetMetadataSlotsByRecipientDocument as $, type Account as A, type BlockChangedFilter as B, type CreateSlotParams as C, type DepositedEvent as D, type Exact as E, type Factory as F, GetAccountDocument as G, type GetAccountQueryVariables as H, GetAccountsDocument as I, type GetAccountsQuery as J, type GetAccountsQueryVariables as K, GetBoughtEventsDocument as L, type GetBoughtEventsQuery as M, type GetBoughtEventsQueryVariables as N, GetDepositedEventsDocument as O, type GetDepositedEventsQuery as P, type GetDepositedEventsQueryVariables as Q, GetFactoryDocument as R, SlotsChain as S, type GetFactoryQuery as T, type GetFactoryQueryVariables as U, GetLiquidatedEventsDocument as V, type GetLiquidatedEventsQuery as W, type GetLiquidatedEventsQueryVariables as X, GetMetadataSlotDocument as Y, type GetMetadataSlotQuery as Z, type GetMetadataSlotQueryVariables as _, type AccountFieldsFragment as a, type MetadataUpdatedEvent_Filter as a$, type GetMetadataSlotsByRecipientQuery as a0, type GetMetadataSlotsByRecipientQueryVariables as a1, GetMetadataSlotsDocument as a2, type GetMetadataSlotsQuery as a3, type GetMetadataSlotsQueryVariables as a4, GetMetadataUpdatedEventsDocument as a5, type GetMetadataUpdatedEventsQuery as a6, type GetMetadataUpdatedEventsQueryVariables as a7, GetModulesDocument as a8, type GetModulesQuery as a9, type GetSlotsByRecipientQuery as aA, type GetSlotsByRecipientQueryVariables as aB, GetSlotsDocument as aC, type GetSlotsQuery as aD, type GetSlotsQueryVariables as aE, GetTaxCollectedEventsDocument as aF, type GetTaxCollectedEventsQuery as aG, type GetTaxCollectedEventsQueryVariables as aH, GetWithdrawnEventsDocument as aI, type GetWithdrawnEventsQuery as aJ, type GetWithdrawnEventsQueryVariables as aK, type Incremental as aL, type InputMaybe as aM, type LiquidatedEvent as aN, type LiquidatedEvent_Filter as aO, type LiquidatedEvent_OrderBy as aP, type MakeEmpty as aQ, type MakeMaybe as aR, type MakeOptional as aS, type Maybe as aT, MetadataModuleClient as aU, type MetadataSlot as aV, type MetadataSlotFieldsFragment as aW, MetadataSlotFieldsFragmentDoc as aX, type MetadataSlot_Filter as aY, type MetadataSlot_OrderBy as aZ, type MetadataUpdatedEvent as a_, type GetModulesQueryVariables as aa, GetPriceUpdatedEventsDocument as ab, type GetPriceUpdatedEventsQuery as ac, type GetPriceUpdatedEventsQueryVariables as ad, GetRecentEventsDocument as ae, type GetRecentEventsQuery as af, type GetRecentEventsQueryVariables as ag, GetReleasedEventsDocument as ah, type GetReleasedEventsQuery as ai, type GetReleasedEventsQueryVariables as aj, GetSettledEventsDocument as ak, type GetSettledEventsQuery as al, type GetSettledEventsQueryVariables as am, GetSlotActivityDocument as an, type GetSlotActivityQuery as ao, type GetSlotActivityQueryVariables as ap, GetSlotDeployedEventsDocument as aq, type GetSlotDeployedEventsQuery as ar, type GetSlotDeployedEventsQueryVariables as as, GetSlotDocument as at, type GetSlotQuery as au, type GetSlotQueryVariables as av, GetSlotsByOccupantDocument as aw, type GetSlotsByOccupantQuery as ax, type GetSlotsByOccupantQueryVariables as ay, GetSlotsByRecipientDocument as az, AccountFieldsFragmentDoc as b, type QueryWithdrawnEventsArgs as b$, type MetadataUpdatedEvent_OrderBy as b0, type Module as b1, type ModuleUpdateProposedEvent as b2, type ModuleUpdateProposedEvent_Filter as b3, type ModuleUpdateProposedEvent_OrderBy as b4, type Module_Filter as b5, type Module_OrderBy as b6, type NftCollection as b7, type NftCollectionTokensArgs as b8, type NftCollection_Filter as b9, type QueryMetadataUpdatedEventArgs as bA, type QueryMetadataUpdatedEventsArgs as bB, type QueryModuleArgs as bC, type QueryModuleUpdateProposedEventArgs as bD, type QueryModuleUpdateProposedEventsArgs as bE, type QueryModulesArgs as bF, type QueryNftcollectionArgs as bG, type QueryNftcollectionsArgs as bH, type QueryNfttokenArgs as bI, type QueryNfttokensArgs as bJ, type QueryPendingUpdateCancelledEventArgs as bK, type QueryPendingUpdateCancelledEventsArgs as bL, type QueryPriceUpdatedEventArgs as bM, type QueryPriceUpdatedEventsArgs as bN, type QueryReleasedEventArgs as bO, type QueryReleasedEventsArgs as bP, type QuerySettledEventArgs as bQ, type QuerySettledEventsArgs as bR, type QuerySlotArgs as bS, type QuerySlotDeployedEventArgs as bT, type QuerySlotDeployedEventsArgs as bU, type QuerySlotsArgs as bV, type QueryTaxCollectedEventArgs as bW, type QueryTaxCollectedEventsArgs as bX, type QueryTaxUpdateProposedEventArgs as bY, type QueryTaxUpdateProposedEventsArgs as bZ, type QueryWithdrawnEventArgs as b_, type NftCollection_OrderBy as ba, type NftToken as bb, type NftToken_Filter as bc, type NftToken_OrderBy as bd, type OrderDirection as be, type PendingUpdateCancelledEvent as bf, type PendingUpdateCancelledEvent_Filter as bg, type PendingUpdateCancelledEvent_OrderBy as bh, type PriceUpdatedEvent as bi, type PriceUpdatedEvent_Filter as bj, type PriceUpdatedEvent_OrderBy as bk, type Query as bl, type QueryAccountArgs as bm, type QueryAccountsArgs as bn, type QueryBoughtEventArgs as bo, type QueryBoughtEventsArgs as bp, type QueryCurrenciesArgs as bq, type QueryCurrencyArgs as br, type QueryDepositedEventArgs as bs, type QueryDepositedEventsArgs as bt, type QueryFactoriesArgs as bu, type QueryFactoryArgs as bv, type QueryLiquidatedEventArgs as bw, type QueryLiquidatedEventsArgs as bx, type QueryMetadataSlotArgs as by, type QueryMetadataSlotsArgs as bz, type AccountSlotsAsOccupantArgs as c, type Query_MetaArgs as c0, type ReleasedEvent as c1, type ReleasedEvent_Filter as c2, type ReleasedEvent_OrderBy as c3, SUBGRAPH_URLS as c4, type Scalars as c5, type Sdk as c6, type SdkFunctionWrapper as c7, type SettledEvent as c8, type SettledEvent_Filter as c9, type TaxCollectedEvent as cA, type TaxCollectedEvent_Filter as cB, type TaxCollectedEvent_OrderBy as cC, type TaxUpdateProposedEvent as cD, type TaxUpdateProposedEvent_Filter as cE, type TaxUpdateProposedEvent_OrderBy as cF, type WithdrawnEvent as cG, type WithdrawnEvent_Filter as cH, type WithdrawnEvent_OrderBy as cI, type _Block_ as cJ, type _Meta_ as cK, type _SubgraphErrorPolicy_ as cL, createSlotsClient as cM, getSdk as cN, type SettledEvent_OrderBy as ca, type Slot as cb, type SlotConfig as cc, type SlotDeployedEvent as cd, type SlotDeployedEvent_Filter as ce, type SlotDeployedEvent_OrderBy as cf, type SlotDepositsArgs as cg, type SlotFieldsFragment as ch, SlotFieldsFragmentDoc as ci, type SlotInitParams as cj, type SlotLiquidationsArgs as ck, type SlotMetadataUpdatesArgs as cl, type SlotModuleUpdateProposalsArgs as cm, type SlotPendingUpdateCancellationsArgs as cn, type SlotPriceUpdatesArgs as co, type SlotPurchasesArgs as cp, type SlotReleasesArgs as cq, type SlotSettlementsArgs as cr, type SlotTaxCollectionsArgs as cs, type SlotTaxUpdateProposalsArgs as ct, type SlotWithdrawalsArgs as cu, type Slot_Filter as cv, type Slot_OrderBy as cw, SlotsClient as cx, type SlotsClientConfig as cy, type SubgraphMeta as cz, type AccountSlotsAsRecipientArgs as d, type AccountType as e, type Account_Filter as f, type Account_OrderBy as g, type Aggregation_Current as h, type Aggregation_Interval as i, type Block_Height as j, type BoughtEvent as k, type BoughtEvent_Filter as l, type BoughtEvent_OrderBy as m, type BuyParams as n, type CreateSlotsParams as o, type Currency as p, type CurrencyFieldsFragment as q, CurrencyFieldsFragmentDoc as r, type Currency_Filter as s, type Currency_OrderBy as t, type DepositedEvent_Filter as u, type DepositedEvent_OrderBy as v, type FactoryModulesArgs as w, type Factory_Filter as x, type Factory_OrderBy as y, type GetAccountQuery as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,28 @@
1
- export { A as Account, a as AccountFieldsFragment, b as AccountFieldsFragmentDoc, c as AccountSlotsAsOccupantArgs, d as AccountSlotsAsRecipientArgs, e as AccountType, f as Account_Filter, g as Account_OrderBy, h as Aggregation_Current, i as Aggregation_Interval, B as BlockChangedFilter, j as Block_Height, k as BoughtEvent, l as BoughtEvent_Filter, m as BoughtEvent_OrderBy, n as BuyParams, C as CreateSlotParams, o as CreateSlotsParams, p as Currency, q as CurrencyFieldsFragment, r as CurrencyFieldsFragmentDoc, s as Currency_Filter, t as Currency_OrderBy, D as DepositedEvent, u as DepositedEvent_Filter, v as DepositedEvent_OrderBy, E as Exact, F as Factory, w as FactoryModulesArgs, x as Factory_Filter, y as Factory_OrderBy, G as GetAccountDocument, z as GetAccountQuery, H as GetAccountQueryVariables, I as GetAccountsDocument, J as GetAccountsQuery, K as GetAccountsQueryVariables, L as GetBoughtEventsDocument, M as GetBoughtEventsQuery, N as GetBoughtEventsQueryVariables, O as GetDepositedEventsDocument, P as GetDepositedEventsQuery, Q as GetDepositedEventsQueryVariables, R as GetFactoryDocument, S as GetFactoryQuery, T as GetFactoryQueryVariables, U as GetLiquidatedEventsDocument, V as GetLiquidatedEventsQuery, W as GetLiquidatedEventsQueryVariables, X as GetMetadataSlotDocument, Y as GetMetadataSlotQuery, Z as GetMetadataSlotQueryVariables, _ as GetMetadataSlotsByRecipientDocument, $ as GetMetadataSlotsByRecipientQuery, a0 as GetMetadataSlotsByRecipientQueryVariables, a1 as GetMetadataSlotsDocument, a2 as GetMetadataSlotsQuery, a3 as GetMetadataSlotsQueryVariables, a4 as GetMetadataUpdatedEventsDocument, a5 as GetMetadataUpdatedEventsQuery, a6 as GetMetadataUpdatedEventsQueryVariables, a7 as GetModulesDocument, a8 as GetModulesQuery, a9 as GetModulesQueryVariables, aa as GetPriceUpdatedEventsDocument, ab as GetPriceUpdatedEventsQuery, ac as GetPriceUpdatedEventsQueryVariables, ad as GetRecentEventsDocument, ae as GetRecentEventsQuery, af as GetRecentEventsQueryVariables, ag as GetReleasedEventsDocument, ah as GetReleasedEventsQuery, ai as GetReleasedEventsQueryVariables, aj as GetSettledEventsDocument, ak as GetSettledEventsQuery, al as GetSettledEventsQueryVariables, am as GetSlotActivityDocument, an as GetSlotActivityQuery, ao as GetSlotActivityQueryVariables, ap as GetSlotDeployedEventsDocument, aq as GetSlotDeployedEventsQuery, ar as GetSlotDeployedEventsQueryVariables, as as GetSlotDocument, at as GetSlotQuery, au as GetSlotQueryVariables, av as GetSlotsByOccupantDocument, aw as GetSlotsByOccupantQuery, ax as GetSlotsByOccupantQueryVariables, ay as GetSlotsByRecipientDocument, az as GetSlotsByRecipientQuery, aA as GetSlotsByRecipientQueryVariables, aB as GetSlotsDocument, aC as GetSlotsQuery, aD as GetSlotsQueryVariables, aE as GetTaxCollectedEventsDocument, aF as GetTaxCollectedEventsQuery, aG as GetTaxCollectedEventsQueryVariables, aH as GetWithdrawnEventsDocument, aI as GetWithdrawnEventsQuery, aJ as GetWithdrawnEventsQueryVariables, aK as Incremental, aL as InputMaybe, aM as LiquidatedEvent, aN as LiquidatedEvent_Filter, aO as LiquidatedEvent_OrderBy, aP as MakeEmpty, aQ as MakeMaybe, aR as MakeOptional, aS as Maybe, aT as MetadataModuleClient, aU as MetadataSlot, aV as MetadataSlotFieldsFragment, aW as MetadataSlotFieldsFragmentDoc, aX as MetadataSlot_Filter, aY as MetadataSlot_OrderBy, aZ as MetadataUpdatedEvent, a_ as MetadataUpdatedEvent_Filter, a$ as MetadataUpdatedEvent_OrderBy, b0 as Module, b1 as ModuleUpdateProposedEvent, b2 as ModuleUpdateProposedEvent_Filter, b3 as ModuleUpdateProposedEvent_OrderBy, b4 as Module_Filter, b5 as Module_OrderBy, b6 as NftCollection, b7 as NftCollectionTokensArgs, b8 as NftCollection_Filter, b9 as NftCollection_OrderBy, ba as NftToken, bb as NftToken_Filter, bc as NftToken_OrderBy, bd as OrderDirection, be as PendingUpdateCancelledEvent, bf as PendingUpdateCancelledEvent_Filter, bg as PendingUpdateCancelledEvent_OrderBy, bh as PriceUpdatedEvent, bi as PriceUpdatedEvent_Filter, bj as PriceUpdatedEvent_OrderBy, bk as Query, bl as QueryAccountArgs, bm as QueryAccountsArgs, bn as QueryBoughtEventArgs, bo as QueryBoughtEventsArgs, bp as QueryCurrenciesArgs, bq as QueryCurrencyArgs, br as QueryDepositedEventArgs, bs as QueryDepositedEventsArgs, bt as QueryFactoriesArgs, bu as QueryFactoryArgs, bv as QueryLiquidatedEventArgs, bw as QueryLiquidatedEventsArgs, bx as QueryMetadataSlotArgs, by as QueryMetadataSlotsArgs, bz as QueryMetadataUpdatedEventArgs, bA as QueryMetadataUpdatedEventsArgs, bB as QueryModuleArgs, bC as QueryModuleUpdateProposedEventArgs, bD as QueryModuleUpdateProposedEventsArgs, bE as QueryModulesArgs, bF as QueryNftcollectionArgs, bG as QueryNftcollectionsArgs, bH as QueryNfttokenArgs, bI as QueryNfttokensArgs, bJ as QueryPendingUpdateCancelledEventArgs, bK as QueryPendingUpdateCancelledEventsArgs, bL as QueryPriceUpdatedEventArgs, bM as QueryPriceUpdatedEventsArgs, bN as QueryReleasedEventArgs, bO as QueryReleasedEventsArgs, bP as QuerySettledEventArgs, bQ as QuerySettledEventsArgs, bR as QuerySlotArgs, bS as QuerySlotDeployedEventArgs, bT as QuerySlotDeployedEventsArgs, bU as QuerySlotsArgs, bV as QueryTaxCollectedEventArgs, bW as QueryTaxCollectedEventsArgs, bX as QueryTaxUpdateProposedEventArgs, bY as QueryTaxUpdateProposedEventsArgs, bZ as QueryWithdrawnEventArgs, b_ as QueryWithdrawnEventsArgs, b$ as Query_MetaArgs, c0 as ReleasedEvent, c1 as ReleasedEvent_Filter, c2 as ReleasedEvent_OrderBy, c3 as SUBGRAPH_URLS, c4 as Scalars, c5 as Sdk, c6 as SdkFunctionWrapper, c7 as SettledEvent, c8 as SettledEvent_Filter, c9 as SettledEvent_OrderBy, ca as Slot, cb as SlotConfig, cc as SlotDeployedEvent, cd as SlotDeployedEvent_Filter, ce as SlotDeployedEvent_OrderBy, cf as SlotDepositsArgs, cg as SlotFieldsFragment, ch as SlotFieldsFragmentDoc, ci as SlotInitParams, cj as SlotLiquidationsArgs, ck as SlotMetadataUpdatesArgs, cl as SlotModuleUpdateProposalsArgs, cm as SlotPendingUpdateCancellationsArgs, cn as SlotPriceUpdatesArgs, co as SlotPurchasesArgs, cp as SlotReleasesArgs, cq as SlotSettlementsArgs, cr as SlotTaxCollectionsArgs, cs as SlotTaxUpdateProposalsArgs, ct as SlotWithdrawalsArgs, cu as Slot_Filter, cv as Slot_OrderBy, cw as SlotsChain, cx as SlotsClient, cy as SlotsClientConfig, cz as SubgraphMeta, cA as TaxCollectedEvent, cB as TaxCollectedEvent_Filter, cC as TaxCollectedEvent_OrderBy, cD as TaxUpdateProposedEvent, cE as TaxUpdateProposedEvent_Filter, cF as TaxUpdateProposedEvent_OrderBy, cG as WithdrawnEvent, cH as WithdrawnEvent_Filter, cI as WithdrawnEvent_OrderBy, cJ as _Block_, cK as _Meta_, cL as _SubgraphErrorPolicy_, cM as createSlotsClient, cN as getSdk } from './client-BtZNzXuf.js';
1
+ import { S as SlotsChain } from './client-pupk2FMg.js';
2
+ export { A as Account, a as AccountFieldsFragment, b as AccountFieldsFragmentDoc, c as AccountSlotsAsOccupantArgs, d as AccountSlotsAsRecipientArgs, e as AccountType, f as Account_Filter, g as Account_OrderBy, h as Aggregation_Current, i as Aggregation_Interval, B as BlockChangedFilter, j as Block_Height, k as BoughtEvent, l as BoughtEvent_Filter, m as BoughtEvent_OrderBy, n as BuyParams, C as CreateSlotParams, o as CreateSlotsParams, p as Currency, q as CurrencyFieldsFragment, r as CurrencyFieldsFragmentDoc, s as Currency_Filter, t as Currency_OrderBy, D as DepositedEvent, u as DepositedEvent_Filter, v as DepositedEvent_OrderBy, E as Exact, F as Factory, w as FactoryModulesArgs, x as Factory_Filter, y as Factory_OrderBy, G as GetAccountDocument, z as GetAccountQuery, H as GetAccountQueryVariables, I as GetAccountsDocument, J as GetAccountsQuery, K as GetAccountsQueryVariables, L as GetBoughtEventsDocument, M as GetBoughtEventsQuery, N as GetBoughtEventsQueryVariables, O as GetDepositedEventsDocument, P as GetDepositedEventsQuery, Q as GetDepositedEventsQueryVariables, R as GetFactoryDocument, T as GetFactoryQuery, U as GetFactoryQueryVariables, V as GetLiquidatedEventsDocument, W as GetLiquidatedEventsQuery, X as GetLiquidatedEventsQueryVariables, Y as GetMetadataSlotDocument, Z as GetMetadataSlotQuery, _ as GetMetadataSlotQueryVariables, $ as GetMetadataSlotsByRecipientDocument, a0 as GetMetadataSlotsByRecipientQuery, a1 as GetMetadataSlotsByRecipientQueryVariables, a2 as GetMetadataSlotsDocument, a3 as GetMetadataSlotsQuery, a4 as GetMetadataSlotsQueryVariables, a5 as GetMetadataUpdatedEventsDocument, a6 as GetMetadataUpdatedEventsQuery, a7 as GetMetadataUpdatedEventsQueryVariables, a8 as GetModulesDocument, a9 as GetModulesQuery, aa as GetModulesQueryVariables, ab as GetPriceUpdatedEventsDocument, ac as GetPriceUpdatedEventsQuery, ad as GetPriceUpdatedEventsQueryVariables, ae as GetRecentEventsDocument, af as GetRecentEventsQuery, ag as GetRecentEventsQueryVariables, ah as GetReleasedEventsDocument, ai as GetReleasedEventsQuery, aj as GetReleasedEventsQueryVariables, ak as GetSettledEventsDocument, al as GetSettledEventsQuery, am as GetSettledEventsQueryVariables, an as GetSlotActivityDocument, ao as GetSlotActivityQuery, ap as GetSlotActivityQueryVariables, aq as GetSlotDeployedEventsDocument, ar as GetSlotDeployedEventsQuery, as as GetSlotDeployedEventsQueryVariables, at as GetSlotDocument, au as GetSlotQuery, av as GetSlotQueryVariables, aw as GetSlotsByOccupantDocument, ax as GetSlotsByOccupantQuery, ay as GetSlotsByOccupantQueryVariables, az as GetSlotsByRecipientDocument, aA as GetSlotsByRecipientQuery, aB as GetSlotsByRecipientQueryVariables, aC as GetSlotsDocument, aD as GetSlotsQuery, aE as GetSlotsQueryVariables, aF as GetTaxCollectedEventsDocument, aG as GetTaxCollectedEventsQuery, aH as GetTaxCollectedEventsQueryVariables, aI as GetWithdrawnEventsDocument, aJ as GetWithdrawnEventsQuery, aK as GetWithdrawnEventsQueryVariables, aL as Incremental, aM as InputMaybe, aN as LiquidatedEvent, aO as LiquidatedEvent_Filter, aP as LiquidatedEvent_OrderBy, aQ as MakeEmpty, aR as MakeMaybe, aS as MakeOptional, aT as Maybe, aU as MetadataModuleClient, aV as MetadataSlot, aW as MetadataSlotFieldsFragment, aX as MetadataSlotFieldsFragmentDoc, aY as MetadataSlot_Filter, aZ as MetadataSlot_OrderBy, a_ as MetadataUpdatedEvent, a$ as MetadataUpdatedEvent_Filter, b0 as MetadataUpdatedEvent_OrderBy, b1 as Module, b2 as ModuleUpdateProposedEvent, b3 as ModuleUpdateProposedEvent_Filter, b4 as ModuleUpdateProposedEvent_OrderBy, b5 as Module_Filter, b6 as Module_OrderBy, b7 as NftCollection, b8 as NftCollectionTokensArgs, b9 as NftCollection_Filter, ba as NftCollection_OrderBy, bb as NftToken, bc as NftToken_Filter, bd as NftToken_OrderBy, be as OrderDirection, bf as PendingUpdateCancelledEvent, bg as PendingUpdateCancelledEvent_Filter, bh as PendingUpdateCancelledEvent_OrderBy, bi as PriceUpdatedEvent, bj as PriceUpdatedEvent_Filter, bk as PriceUpdatedEvent_OrderBy, bl as Query, bm as QueryAccountArgs, bn as QueryAccountsArgs, bo as QueryBoughtEventArgs, bp as QueryBoughtEventsArgs, bq as QueryCurrenciesArgs, br as QueryCurrencyArgs, bs as QueryDepositedEventArgs, bt as QueryDepositedEventsArgs, bu as QueryFactoriesArgs, bv as QueryFactoryArgs, bw as QueryLiquidatedEventArgs, bx as QueryLiquidatedEventsArgs, by as QueryMetadataSlotArgs, bz as QueryMetadataSlotsArgs, bA as QueryMetadataUpdatedEventArgs, bB as QueryMetadataUpdatedEventsArgs, bC as QueryModuleArgs, bD as QueryModuleUpdateProposedEventArgs, bE as QueryModuleUpdateProposedEventsArgs, bF as QueryModulesArgs, bG as QueryNftcollectionArgs, bH as QueryNftcollectionsArgs, bI as QueryNfttokenArgs, bJ as QueryNfttokensArgs, bK as QueryPendingUpdateCancelledEventArgs, bL as QueryPendingUpdateCancelledEventsArgs, bM as QueryPriceUpdatedEventArgs, bN as QueryPriceUpdatedEventsArgs, bO as QueryReleasedEventArgs, bP as QueryReleasedEventsArgs, bQ as QuerySettledEventArgs, bR as QuerySettledEventsArgs, bS as QuerySlotArgs, bT as QuerySlotDeployedEventArgs, bU as QuerySlotDeployedEventsArgs, bV as QuerySlotsArgs, bW as QueryTaxCollectedEventArgs, bX as QueryTaxCollectedEventsArgs, bY as QueryTaxUpdateProposedEventArgs, bZ as QueryTaxUpdateProposedEventsArgs, b_ as QueryWithdrawnEventArgs, b$ as QueryWithdrawnEventsArgs, c0 as Query_MetaArgs, c1 as ReleasedEvent, c2 as ReleasedEvent_Filter, c3 as ReleasedEvent_OrderBy, c4 as SUBGRAPH_URLS, c5 as Scalars, c6 as Sdk, c7 as SdkFunctionWrapper, c8 as SettledEvent, c9 as SettledEvent_Filter, ca as SettledEvent_OrderBy, cb as Slot, cc as SlotConfig, cd as SlotDeployedEvent, ce as SlotDeployedEvent_Filter, cf as SlotDeployedEvent_OrderBy, cg as SlotDepositsArgs, ch as SlotFieldsFragment, ci as SlotFieldsFragmentDoc, cj as SlotInitParams, ck as SlotLiquidationsArgs, cl as SlotMetadataUpdatesArgs, cm as SlotModuleUpdateProposalsArgs, cn as SlotPendingUpdateCancellationsArgs, co as SlotPriceUpdatesArgs, cp as SlotPurchasesArgs, cq as SlotReleasesArgs, cr as SlotSettlementsArgs, cs as SlotTaxCollectionsArgs, ct as SlotTaxUpdateProposalsArgs, cu as SlotWithdrawalsArgs, cv as Slot_Filter, cw as Slot_OrderBy, cx as SlotsClient, cy as SlotsClientConfig, cz as SubgraphMeta, cA as TaxCollectedEvent, cB as TaxCollectedEvent_Filter, cC as TaxCollectedEvent_OrderBy, cD as TaxUpdateProposedEvent, cE as TaxUpdateProposedEvent_Filter, cF as TaxUpdateProposedEvent_OrderBy, cG as WithdrawnEvent, cH as WithdrawnEvent_Filter, cI as WithdrawnEvent_OrderBy, cJ as _Block_, cK as _Meta_, cL as _SubgraphErrorPolicy_, cM as createSlotsClient, cN as getSdk } from './client-pupk2FMg.js';
3
+ import { Address } from 'viem';
2
4
  import 'graphql-request';
3
5
  import 'graphql';
4
- import 'viem';
6
+
7
+ interface TokenInfo {
8
+ address: Address;
9
+ name: string;
10
+ symbol: string;
11
+ decimals: number;
12
+ }
13
+ /**
14
+ * Predetermined tokens available per chain for slot creation.
15
+ * The first token in each array is the default.
16
+ */
17
+ declare const CHAIN_TOKENS: Record<SlotsChain, TokenInfo[]>;
18
+ /**
19
+ * Get the list of predetermined tokens for a given chain.
20
+ */
21
+ declare function getChainTokens(chainId: number): TokenInfo[];
22
+ /**
23
+ * Get the default token for a given chain (first in the list).
24
+ */
25
+ declare function getDefaultToken(chainId: number): TokenInfo | undefined;
5
26
 
6
27
  /** Error thrown by SlotsClient operations, wrapping the original cause with operation context. */
7
28
  declare class SlotsError extends Error {
@@ -10,4 +31,4 @@ declare class SlotsError extends Error {
10
31
  constructor(operation: string, cause: unknown);
11
32
  }
12
33
 
13
- export { SlotsError };
34
+ export { CHAIN_TOKENS, SlotsChain, SlotsError, type TokenInfo, getChainTokens, getDefaultToken };
package/dist/index.js CHANGED
@@ -1,3 +1,31 @@
1
- export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetMetadataSlotDocument, GetMetadataSlotsByRecipientDocument, GetMetadataSlotsDocument, GetMetadataUpdatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDeployedEventsDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, MetadataModuleClient, MetadataSlotFieldsFragmentDoc, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk } from './chunk-KRJINGNH.js';
1
+ export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetMetadataSlotDocument, GetMetadataSlotsByRecipientDocument, GetMetadataSlotsDocument, GetMetadataUpdatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDeployedEventsDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, MetadataModuleClient, MetadataSlotFieldsFragmentDoc, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk } from './chunk-PZ2PG636.js';
2
+
3
+ // src/tokens.ts
4
+ var CHAIN_TOKENS = {
5
+ [84532 /* BASE_SEPOLIA */]: [
6
+ {
7
+ address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
8
+ name: "USD Coin",
9
+ symbol: "USDC",
10
+ decimals: 6
11
+ }
12
+ ],
13
+ [8453 /* BASE */]: [
14
+ {
15
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
16
+ name: "USD Coin",
17
+ symbol: "USDC",
18
+ decimals: 6
19
+ }
20
+ ]
21
+ };
22
+ function getChainTokens(chainId) {
23
+ return CHAIN_TOKENS[chainId] ?? [];
24
+ }
25
+ function getDefaultToken(chainId) {
26
+ return getChainTokens(chainId)[0];
27
+ }
28
+
29
+ export { CHAIN_TOKENS, getChainTokens, getDefaultToken };
2
30
  //# sourceMappingURL=index.js.map
3
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../src/tokens.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAgD;AAAA,EAC3D,4BAA2B;AAAA,IACzB;AAAA,MACE,OAAA,EAAS,4CAAA;AAAA,MACT,IAAA,EAAM,UAAA;AAAA,MACN,MAAA,EAAQ,MAAA;AAAA,MACR,QAAA,EAAU;AAAA;AACZ,GACF;AAAA,EACA,mBAAmB;AAAA,IACjB;AAAA,MACE,OAAA,EAAS,4CAAA;AAAA,MACT,IAAA,EAAM,UAAA;AAAA,MACN,MAAA,EAAQ,MAAA;AAAA,MACR,QAAA,EAAU;AAAA;AACZ;AAEJ;AAKO,SAAS,eAAe,OAAA,EAA8B;AAC3D,EAAA,OAAO,YAAA,CAAa,OAAqB,CAAA,IAAK,EAAC;AACjD;AAKO,SAAS,gBAAgB,OAAA,EAAwC;AACtE,EAAA,OAAO,cAAA,CAAe,OAAO,CAAA,CAAE,CAAC,CAAA;AAClC","file":"index.js","sourcesContent":["import type { Address } from \"viem\";\nimport { SlotsChain } from \"./client\";\n\nexport interface TokenInfo {\n address: Address;\n name: string;\n symbol: string;\n decimals: number;\n}\n\n/**\n * Predetermined tokens available per chain for slot creation.\n * The first token in each array is the default.\n */\nexport const CHAIN_TOKENS: Record<SlotsChain, TokenInfo[]> = {\n [SlotsChain.BASE_SEPOLIA]: [\n {\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n name: \"USD Coin\",\n symbol: \"USDC\",\n decimals: 6,\n },\n ],\n [SlotsChain.BASE]: [\n {\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n name: \"USD Coin\",\n symbol: \"USDC\",\n decimals: 6,\n },\n ],\n};\n\n/**\n * Get the list of predetermined tokens for a given chain.\n */\nexport function getChainTokens(chainId: number): TokenInfo[] {\n return CHAIN_TOKENS[chainId as SlotsChain] ?? [];\n}\n\n/**\n * Get the default token for a given chain (first in the list).\n */\nexport function getDefaultToken(chainId: number): TokenInfo | undefined {\n return getChainTokens(chainId)[0];\n}\n"]}
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { cw as SlotsChain, cx as SlotsClient, C as CreateSlotParams, o as CreateSlotsParams, n as BuyParams } from './client-BtZNzXuf.js';
1
+ import { S as SlotsChain, cx as SlotsClient, C as CreateSlotParams, o as CreateSlotsParams, n as BuyParams } from './client-pupk2FMg.js';
2
2
  import { Hash, Address } from 'viem';
3
3
  import 'graphql-request';
4
4
  import 'graphql';
@@ -13,7 +13,7 @@ import 'graphql';
13
13
  * @example
14
14
  * ```tsx
15
15
  * function MyComponent() {
16
- * const client = useSlotsClient(SlotsChain.ARBITRUM);
16
+ * const client = useSlotsClient(SlotsChain.BASE);
17
17
  * // use client.getSlots(), client.buy(), etc.
18
18
  * }
19
19
  * ```
@@ -21,6 +21,7 @@ import 'graphql';
21
21
  declare function useSlotsClient(chainId?: SlotsChain, subgraphApiKey?: string): SlotsClient;
22
22
 
23
23
  interface SlotActionCallbacks {
24
+ chainId?: SlotsChain;
24
25
  onSuccess?: (label: string, hash: Hash) => void;
25
26
  onError?: (label: string, error: string) => void;
26
27
  }
package/dist/react.js CHANGED
@@ -1,9 +1,8 @@
1
- import { SlotsClient } from './chunk-KRJINGNH.js';
1
+ import { SlotsClient } from './chunk-PZ2PG636.js';
2
2
  import { slotFactoryAddress, slotAbi } from '@0xslots/contracts';
3
3
  import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
4
- import { usePublicClient, useWalletClient, useWaitForTransactionReceipt, useReadContract, useReadContracts, useBlockNumber } from 'wagmi';
4
+ import { usePublicClient, useWalletClient, useWaitForTransactionReceipt, useReadContract, useReadContracts } from 'wagmi';
5
5
  import { erc20Abi } from 'viem';
6
- import { useQueryClient } from '@tanstack/react-query';
7
6
 
8
7
  function useSlotsClient(chainId, subgraphApiKey) {
9
8
  const publicClient = usePublicClient({ chainId });
@@ -24,11 +23,21 @@ function useSlotsClient(chainId, subgraphApiKey) {
24
23
  }, [chainId, publicClient, walletClient, subgraphApiKey]);
25
24
  }
26
25
  function extractErrorMessage(error) {
27
- const message = error instanceof Error ? error.message : "";
28
- return message.includes("User rejected") || message.includes("User denied") ? "Transaction rejected" : message.split("\n")[0] || "Transaction failed";
26
+ const message = error instanceof Error ? error.message : String(error);
27
+ if (message.includes("User rejected") || message.includes("User denied"))
28
+ return "Transaction rejected";
29
+ const err = error;
30
+ if (err && typeof err === "object") {
31
+ if (typeof err.shortMessage === "string") return err.shortMessage;
32
+ const cause = err.cause;
33
+ if (cause && typeof cause.shortMessage === "string")
34
+ return cause.shortMessage;
35
+ if (cause && typeof cause.reason === "string") return cause.reason;
36
+ }
37
+ return message.split("\n")[0] || "Transaction failed";
29
38
  }
30
39
  function useSlotAction(opts) {
31
- const client = useSlotsClient();
40
+ const client = useSlotsClient(opts?.chainId);
32
41
  const [hash, setHash] = useState();
33
42
  const [activeAction, setActiveAction] = useState(null);
34
43
  const [isPending, setIsPending] = useState(false);
@@ -68,6 +77,7 @@ function useSlotAction(opts) {
68
77
  const txHash = await fn();
69
78
  setHash(txHash);
70
79
  } catch (error) {
80
+ console.error(`[useSlotAction] ${label} failed:`, error);
71
81
  setActiveAction(null);
72
82
  labelRef.current = "";
73
83
  opts?.onError?.(label, extractErrorMessage(error));
@@ -199,18 +209,7 @@ function parseSlotInfo(slotAddress, info, currencyMeta) {
199
209
  currencyDecimals: currencyMeta?.decimals
200
210
  };
201
211
  }
202
- function useInvalidateOnBlock(chainId) {
203
- const queryClient = useQueryClient();
204
- const { data: blockNumber } = useBlockNumber({ watch: true, chainId });
205
- useEffect(() => {
206
- if (blockNumber) {
207
- queryClient.invalidateQueries({ queryKey: ["readContract"] });
208
- queryClient.invalidateQueries({ queryKey: ["readContracts"] });
209
- }
210
- }, [blockNumber, queryClient]);
211
- }
212
212
  function useSlotOnChain(slotAddress, chainId) {
213
- useInvalidateOnBlock(chainId);
214
213
  const addr = slotAddress;
215
214
  const {
216
215
  data: info,
@@ -245,7 +244,6 @@ function useSlotOnChain(slotAddress, chainId) {
245
244
  return { data: slot, isLoading, refetch };
246
245
  }
247
246
  function useSlotsOnChain(slotAddresses, chainId) {
248
- useInvalidateOnBlock(chainId);
249
247
  const contracts = slotAddresses.map((addr) => ({
250
248
  address: addr,
251
249
  abi: slotAbi,
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useSlotsClient.ts","../src/hooks/useSlotAction.ts","../src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AA,CAAQ,CAAC,CAAA,EAAG,CAAA,KAAM;AAC7B,MAAA,YAAA,CAAa,CAAC,CAAA,GAAI;AAAA,QAChB,IAAA,EAAM,WAAA,CAAY,CAAA,GAAI,CAAC,CAAA,EAAG,MAAA;AAAA,QAC1B,MAAA,EAAQ,WAAA,CAAY,CAAA,GAAI,CAAA,GAAI,CAAC,CAAA,EAAG,MAAA;AAAA,QAChC,QAAA,EAAU,WAAA,CAAY,CAAA,GAAI,CAAA,GAAI,CAAC,CAAA,EAAG;AAAA,OACpC;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,YAAY,YAAA,IAAgB,WAAA;AAElC,EAAA,MAAM,QAAuB,EAAC;AAC9B,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,QAAQ,CAAA,EAAA,EAAK;AACrC,MAAA,MAAM,CAAA,GAAI,MAAM,CAAC,CAAA;AACjB,MAAA,IAAI,EAAE,MAAA,EAAQ;AACZ,QAAA,MAAM,SAAS,CAAA,CAAE,MAAA;AACjB,QAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,WAAA,EAAY;AAC7C,QAAA,KAAA,CAAM,IAAA;AAAA,UACJ,cAAc,aAAA,CAAc,CAAC,GAAG,MAAA,EAAQ,YAAA,CAAa,QAAQ,CAAC;AAAA,SAChE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,SAAA,EAAW,OAAA,EAAQ;AAC3C","file":"react.js","sourcesContent":["\"use client\";\n\nimport { type SupportedChainId, slotFactoryAddress } from \"@0xslots/contracts\";\nimport { useMemo } from \"react\";\nimport { usePublicClient, useWalletClient } from \"wagmi\";\nimport { type SlotsChain, SlotsClient } from \"../client\";\n\n/**\n * React hook that creates a memoized {@link SlotsClient} from wagmi's public/wallet clients.\n *\n * @param chainId - Optional chain ID override. Defaults to the connected chain.\n * @returns A configured SlotsClient instance.\n * @throws If no public client is available or the chain has no factory address.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const client = useSlotsClient(SlotsChain.ARBITRUM);\n * // use client.getSlots(), client.buy(), etc.\n * }\n * ```\n */\nexport function useSlotsClient(chainId?: SlotsChain, subgraphApiKey?: string): SlotsClient {\n const publicClient = usePublicClient({ chainId });\n const { data: walletClient } = useWalletClient({ chainId });\n\n return useMemo(() => {\n if (!publicClient) throw new Error(\"No publicClient available\");\n const resolvedChainId = (chainId ?? publicClient.chain.id) as SlotsChain;\n const factoryAddress =\n slotFactoryAddress[resolvedChainId as SupportedChainId];\n if (!factoryAddress)\n throw new Error(`No factory address for chain ${resolvedChainId}`);\n\n return new SlotsClient({\n chainId: resolvedChainId,\n factoryAddress,\n publicClient,\n walletClient: walletClient ?? undefined,\n subgraphApiKey,\n });\n }, [chainId, publicClient, walletClient, subgraphApiKey]);\n}\n","\"use client\";\n\nimport type {\n BuyParams,\n CreateSlotParams,\n CreateSlotsParams,\n} from \"../client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Address, Hash } from \"viem\";\nimport { useWaitForTransactionReceipt } from \"wagmi\";\nimport { useSlotsClient } from \"./useSlotsClient\";\n\nfunction extractErrorMessage(error: unknown): string {\n const message = error instanceof Error ? error.message : \"\";\n return message.includes(\"User rejected\") || message.includes(\"User denied\")\n ? \"Transaction rejected\"\n : message.split(\"\\n\")[0] || \"Transaction failed\";\n}\n\nexport interface SlotActionCallbacks {\n onSuccess?: (label: string, hash: Hash) => void;\n onError?: (label: string, error: string) => void;\n}\n\nexport function useSlotAction(opts?: SlotActionCallbacks) {\n const client = useSlotsClient();\n\n // --- state ---\n const [hash, setHash] = useState<Hash | undefined>();\n const [activeAction, setActiveAction] = useState<string | null>(null);\n const [isPending, setIsPending] = useState(false);\n const labelRef = useRef<string>(\"\");\n\n // --- receipt tracking ---\n const {\n isLoading: isConfirming,\n isSuccess,\n isError,\n } = useWaitForTransactionReceipt({ hash });\n\n const busy = isPending || isConfirming;\n\n // --- callback on success ---\n useEffect(() => {\n if (isSuccess && labelRef.current) {\n opts?.onSuccess?.(labelRef.current, hash!);\n setActiveAction(null);\n labelRef.current = \"\";\n }\n }, [isSuccess]);\n\n // --- callback on on-chain error ---\n useEffect(() => {\n if (isError && labelRef.current) {\n opts?.onError?.(labelRef.current, `${labelRef.current} failed on-chain`);\n setActiveAction(null);\n labelRef.current = \"\";\n }\n }, [isError]);\n\n // --- reset if everything settles with no result ---\n useEffect(() => {\n if (!isPending && !isConfirming && !isSuccess && !isError) {\n setActiveAction(null);\n }\n }, [isPending, isConfirming, isSuccess, isError]);\n\n /**\n * Execute an SDK method with shared pending/receipt tracking.\n */\n const exec = useCallback(\n async (label: string, fn: () => Promise<Hash>) => {\n labelRef.current = label;\n setActiveAction(label);\n setIsPending(true);\n setHash(undefined);\n try {\n const txHash = await fn();\n setHash(txHash);\n } catch (error) {\n setActiveAction(null);\n labelRef.current = \"\";\n opts?.onError?.(label, extractErrorMessage(error));\n } finally {\n setIsPending(false);\n }\n },\n [opts?.onError],\n );\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Named actions — each calls one SDK method\n // ═══════════════════════════════════════════════════════════════════════════\n\n // Factory\n const createSlot = useCallback(\n (params: CreateSlotParams) =>\n exec(\"Create slot\", () => client.createSlot(params)),\n [exec, client],\n );\n const createSlots = useCallback(\n (params: CreateSlotsParams) =>\n exec(\"Create slots\", () => client.createSlots(params)),\n [exec, client],\n );\n\n // Slot interactions\n const buy = useCallback(\n (params: BuyParams) => exec(\"Buy slot\", () => client.buy(params)),\n [exec, client],\n );\n const selfAssess = useCallback(\n (slot: Address, newPrice: bigint) =>\n exec(\"Set price\", () => client.selfAssess(slot, newPrice)),\n [exec, client],\n );\n const topUp = useCallback(\n (slot: Address, amount: bigint) =>\n exec(\"Top up\", () => client.topUp(slot, amount)),\n [exec, client],\n );\n const withdraw = useCallback(\n (slot: Address, amount: bigint) =>\n exec(\"Withdraw\", () => client.withdraw(slot, amount)),\n [exec, client],\n );\n const release = useCallback(\n (slot: Address) => exec(\"Release slot\", () => client.release(slot)),\n [exec, client],\n );\n const collect = useCallback(\n (slot: Address) => exec(\"Collect tax\", () => client.collect(slot)),\n [exec, client],\n );\n const payTax = useCallback(\n (slot: Address) => exec(\"Pay tax\", () => client.collect(slot)),\n [exec, client],\n );\n const liquidate = useCallback(\n (slot: Address) => exec(\"Liquidate\", () => client.liquidate(slot)),\n [exec, client],\n );\n\n // Manager\n const proposeTaxUpdate = useCallback(\n (slot: Address, newPct: bigint) =>\n exec(\"Propose tax\", () => client.proposeTaxUpdate(slot, newPct)),\n [exec, client],\n );\n const proposeModuleUpdate = useCallback(\n (slot: Address, newModule: Address) =>\n exec(\"Propose module\", () =>\n client.proposeModuleUpdate(slot, newModule),\n ),\n [exec, client],\n );\n const cancelPendingUpdates = useCallback(\n (slot: Address) =>\n exec(\"Cancel updates\", () => client.cancelPendingUpdates(slot)),\n [exec, client],\n );\n const setLiquidationBounty = useCallback(\n (slot: Address, newBps: bigint) =>\n exec(\"Set bounty\", () => client.setLiquidationBounty(slot, newBps)),\n [exec, client],\n );\n\n // Metadata module\n const updateMetadata = useCallback(\n (moduleAddress: Address, slot: Address, uri: string) =>\n exec(\"Update metadata\", () =>\n client.modules.metadata.updateMetadata(moduleAddress, slot, uri),\n ),\n [exec, client],\n );\n\n return {\n // Actions\n createSlot,\n createSlots,\n buy,\n selfAssess,\n topUp,\n withdraw,\n release,\n collect,\n payTax,\n liquidate,\n proposeTaxUpdate,\n proposeModuleUpdate,\n cancelPendingUpdates,\n setLiquidationBounty,\n updateMetadata,\n // Executor\n exec,\n // State\n busy,\n isPending,\n isConfirming,\n isSuccess,\n activeAction,\n };\n}\n","\"use client\";\n\nimport { slotAbi } from \"@0xslots/contracts\";\nimport { type Address, erc20Abi } from \"viem\";\nimport { useReadContract, useReadContracts, useBlockNumber } from \"wagmi\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useEffect } from \"react\";\n\nexport type SlotOnChain = {\n // Identity\n id: string;\n recipient: string;\n currency: string;\n manager: string;\n mutableTax: boolean;\n mutableModule: boolean;\n // State\n occupant: string | null;\n price: bigint;\n taxPercentage: bigint;\n module: string;\n liquidationBountyBps: bigint;\n minDepositSeconds: bigint;\n // Financials\n deposit: bigint;\n collectedTax: bigint;\n taxOwed: bigint;\n secondsUntilLiquidation: bigint;\n insolvent: boolean;\n // Pending\n hasPendingTax: boolean;\n pendingTaxPercentage: bigint;\n hasPendingModule: boolean;\n pendingModule: string;\n // Currency metadata\n currencyName?: string;\n currencySymbol?: string;\n currencyDecimals?: number;\n};\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\ntype SlotInfoResult = {\n recipient: string;\n currency: string;\n manager: string;\n mutableTax: boolean;\n mutableModule: boolean;\n occupant: string;\n price: bigint;\n taxPercentage: bigint;\n module: string;\n liquidationBountyBps: bigint;\n minDepositSeconds: bigint;\n deposit: bigint;\n collectedTax: bigint;\n taxOwed: bigint;\n secondsUntilLiquidation: bigint;\n insolvent: boolean;\n hasPendingTax: boolean;\n pendingTaxPercentage: bigint;\n hasPendingModule: boolean;\n pendingModule: string;\n};\n\nfunction parseSlotInfo(\n slotAddress: string,\n info: SlotInfoResult,\n currencyMeta?: { name?: string; symbol?: string; decimals?: number },\n): SlotOnChain {\n return {\n id: slotAddress.toLowerCase(),\n recipient: info.recipient.toLowerCase(),\n currency: info.currency.toLowerCase(),\n manager: info.manager.toLowerCase(),\n mutableTax: info.mutableTax,\n mutableModule: info.mutableModule,\n occupant:\n info.occupant === ZERO_ADDRESS ? null : info.occupant.toLowerCase(),\n price: info.price,\n taxPercentage: info.taxPercentage,\n module: info.module.toLowerCase(),\n liquidationBountyBps: info.liquidationBountyBps,\n minDepositSeconds: info.minDepositSeconds,\n deposit: info.deposit,\n collectedTax: info.collectedTax,\n taxOwed: info.taxOwed,\n secondsUntilLiquidation: info.secondsUntilLiquidation,\n insolvent: info.insolvent,\n hasPendingTax: info.hasPendingTax,\n pendingTaxPercentage: info.pendingTaxPercentage,\n hasPendingModule: info.hasPendingModule,\n pendingModule: info.pendingModule.toLowerCase(),\n currencyName: currencyMeta?.name,\n currencySymbol: currencyMeta?.symbol,\n currencyDecimals: currencyMeta?.decimals,\n };\n}\n\n/**\n * Invalidate all contract reads on every new block — ensures fresh data after txs\n */\nfunction useInvalidateOnBlock(chainId: number) {\n const queryClient = useQueryClient();\n const { data: blockNumber } = useBlockNumber({ watch: true, chainId });\n useEffect(() => {\n if (blockNumber) {\n queryClient.invalidateQueries({ queryKey: [\"readContract\"] });\n queryClient.invalidateQueries({ queryKey: [\"readContracts\"] });\n }\n }, [blockNumber, queryClient]);\n}\n\n/**\n * Fetch a single slot's complete state from on-chain via getSlotInfo() + currency metadata.\n *\n * @param slotAddress - The slot contract address\n * @param chainId - The chain ID to read from\n */\nexport function useSlotOnChain(slotAddress: string, chainId: number): {\n data: SlotOnChain | null;\n isLoading: boolean;\n refetch: () => void;\n} {\n useInvalidateOnBlock(chainId);\n const addr = slotAddress as Address;\n\n const {\n data: info,\n isLoading: infoLoading,\n refetch,\n } = useReadContract({\n address: addr,\n abi: slotAbi,\n functionName: \"getSlotInfo\",\n chainId,\n query: { gcTime: 0, staleTime: 0, refetchOnMount: \"always\" },\n });\n\n // Currency metadata — only fetch when we have info (static, can cache)\n const currencyAddr = info\n ? ((info as SlotInfoResult).currency as Address)\n : undefined;\n const { data: currencyMeta, isLoading: metaLoading } = useReadContracts({\n contracts: currencyAddr\n ? [\n { address: currencyAddr, abi: erc20Abi, functionName: \"name\", chainId },\n { address: currencyAddr, abi: erc20Abi, functionName: \"symbol\", chainId },\n { address: currencyAddr, abi: erc20Abi, functionName: \"decimals\", chainId },\n ]\n : [],\n query: { enabled: !!currencyAddr, staleTime: Infinity },\n });\n\n const isLoading = infoLoading || metaLoading;\n\n const slot = info\n ? parseSlotInfo(\n slotAddress,\n info as SlotInfoResult,\n currencyMeta\n ? {\n name: currencyMeta[0]?.result as string | undefined,\n symbol: currencyMeta[1]?.result as string | undefined,\n decimals: currencyMeta[2]?.result as number | undefined,\n }\n : undefined,\n )\n : null;\n\n return { data: slot, isLoading, refetch };\n}\n\n/**\n * Fetch multiple slots' state via multicall getSlotInfo().\n *\n * @param slotAddresses - Array of slot contract addresses\n * @param chainId - The chain ID to read from\n */\nexport function useSlotsOnChain(slotAddresses: string[], chainId: number): {\n data: SlotOnChain[];\n isLoading: boolean;\n refetch: () => void;\n} {\n useInvalidateOnBlock(chainId);\n const contracts = slotAddresses.map((addr) => ({\n address: addr as Address,\n abi: slotAbi,\n functionName: \"getSlotInfo\" as const,\n chainId,\n }));\n\n const {\n data: infos,\n isLoading: infosLoading,\n refetch,\n } = useReadContracts({\n contracts,\n query: {\n enabled: slotAddresses.length > 0,\n gcTime: 0,\n staleTime: 0,\n refetchOnMount: \"always\",\n },\n });\n\n // Get unique currencies to fetch metadata\n const currencies = new Set<string>();\n if (infos) {\n for (const r of infos) {\n if (r.result)\n currencies.add(\n (r.result as SlotInfoResult).currency.toLowerCase(),\n );\n }\n }\n const currencyList = Array.from(currencies);\n\n const { data: metaResults, isLoading: metaLoading } = useReadContracts({\n contracts: currencyList.flatMap((c) => [\n { address: c as Address, abi: erc20Abi, functionName: \"name\" as const, chainId },\n { address: c as Address, abi: erc20Abi, functionName: \"symbol\" as const, chainId },\n {\n address: c as Address,\n abi: erc20Abi,\n functionName: \"decimals\" as const,\n chainId,\n },\n ]),\n query: { enabled: currencyList.length > 0 },\n });\n\n // Build currency metadata map\n const currencyMeta: Record<\n string,\n { name?: string; symbol?: string; decimals?: number }\n > = {};\n if (metaResults) {\n currencyList.forEach((c, i) => {\n currencyMeta[c] = {\n name: metaResults[i * 3]?.result as string | undefined,\n symbol: metaResults[i * 3 + 1]?.result as string | undefined,\n decimals: metaResults[i * 3 + 2]?.result as number | undefined,\n };\n });\n }\n\n const isLoading = infosLoading || metaLoading;\n\n const slots: SlotOnChain[] = [];\n if (infos) {\n for (let i = 0; i < infos.length; i++) {\n const r = infos[i];\n if (r.result) {\n const result = r.result as SlotInfoResult;\n const currency = result.currency.toLowerCase();\n slots.push(\n parseSlotInfo(slotAddresses[i], result, currencyMeta[currency]),\n );\n }\n }\n }\n\n return { data: slots, isLoading, refetch };\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useSlotsClient.ts","../src/hooks/useSlotAction.ts","../src/hooks/useSlotOnChain.ts"],"names":[],"mappings":";;;;;;AAsBO,SAAS,cAAA,CAAe,SAAsB,cAAA,EAAsC;AACzF,EAAA,MAAM,YAAA,GAAe,eAAA,CAAgB,EAAE,OAAA,EAAS,CAAA;AAChD,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,KAAiB,eAAA,CAAgB,EAAE,SAAS,CAAA;AAE1D,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,IAAI,CAAC,YAAA,EAAc,MAAM,IAAI,MAAM,2BAA2B,CAAA;AAC9D,IAAA,MAAM,eAAA,GAAmB,OAAA,IAAW,YAAA,CAAa,KAAA,CAAM,EAAA;AACvD,IAAA,MAAM,cAAA,GACJ,mBAAmB,eAAmC,CAAA;AACxD,IAAA,IAAI,CAAC,cAAA;AACH,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6BAAA,EAAgC,eAAe,CAAA,CAAE,CAAA;AAEnE,IAAA,OAAO,IAAI,WAAA,CAAY;AAAA,MACrB,OAAA,EAAS,eAAA;AAAA,MACT,cAAA;AAAA,MACA,YAAA;AAAA,MACA,cAAc,YAAA,IAAgB,MAAA;AAAA,MAC9B;AAAA,KACD,CAAA;AAAA,EACH,GAAG,CAAC,OAAA,EAAS,YAAA,EAAc,YAAA,EAAc,cAAc,CAAC,CAAA;AAC1D;AC7BA,SAAS,oBAAoB,KAAA,EAAwB;AACnD,EAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,EA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EA,EAAA,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,SAAA,EAAW,OAAA,EAAQ;AAC3C","file":"react.js","sourcesContent":["\"use client\";\n\nimport { type SupportedChainId, slotFactoryAddress } from \"@0xslots/contracts\";\nimport { useMemo } from \"react\";\nimport { usePublicClient, useWalletClient } from \"wagmi\";\nimport { type SlotsChain, SlotsClient } from \"../client\";\n\n/**\n * React hook that creates a memoized {@link SlotsClient} from wagmi's public/wallet clients.\n *\n * @param chainId - Optional chain ID override. Defaults to the connected chain.\n * @returns A configured SlotsClient instance.\n * @throws If no public client is available or the chain has no factory address.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const client = useSlotsClient(SlotsChain.BASE);\n * // use client.getSlots(), client.buy(), etc.\n * }\n * ```\n */\nexport function useSlotsClient(chainId?: SlotsChain, subgraphApiKey?: string): SlotsClient {\n const publicClient = usePublicClient({ chainId });\n const { data: walletClient } = useWalletClient({ chainId });\n\n return useMemo(() => {\n if (!publicClient) throw new Error(\"No publicClient available\");\n const resolvedChainId = (chainId ?? publicClient.chain.id) as SlotsChain;\n const factoryAddress =\n slotFactoryAddress[resolvedChainId as SupportedChainId];\n if (!factoryAddress)\n throw new Error(`No factory address for chain ${resolvedChainId}`);\n\n return new SlotsClient({\n chainId: resolvedChainId,\n factoryAddress,\n publicClient,\n walletClient: walletClient ?? undefined,\n subgraphApiKey,\n });\n }, [chainId, publicClient, walletClient, subgraphApiKey]);\n}\n","\"use client\";\n\nimport type {\n BuyParams,\n CreateSlotParams,\n CreateSlotsParams,\n SlotsChain,\n} from \"../client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Address, Hash } from \"viem\";\nimport { useWaitForTransactionReceipt } from \"wagmi\";\nimport { useSlotsClient } from \"./useSlotsClient\";\n\nfunction extractErrorMessage(error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"User rejected\") || message.includes(\"User denied\"))\n return \"Transaction rejected\";\n\n // viem ContractFunctionExecutionError: extract the shortMessage or reason\n const err = error as Record<string, unknown> | undefined;\n if (err && typeof err === \"object\") {\n if (typeof err.shortMessage === \"string\") return err.shortMessage;\n const cause = err.cause as Record<string, unknown> | undefined;\n if (cause && typeof cause.shortMessage === \"string\")\n return cause.shortMessage;\n if (cause && typeof cause.reason === \"string\") return cause.reason;\n }\n\n return message.split(\"\\n\")[0] || \"Transaction failed\";\n}\n\nexport interface SlotActionCallbacks {\n chainId?: SlotsChain;\n onSuccess?: (label: string, hash: Hash) => void;\n onError?: (label: string, error: string) => void;\n}\n\nexport function useSlotAction(opts?: SlotActionCallbacks) {\n const client = useSlotsClient(opts?.chainId);\n\n // --- state ---\n const [hash, setHash] = useState<Hash | undefined>();\n const [activeAction, setActiveAction] = useState<string | null>(null);\n const [isPending, setIsPending] = useState(false);\n const labelRef = useRef<string>(\"\");\n\n // --- receipt tracking ---\n const {\n isLoading: isConfirming,\n isSuccess,\n isError,\n } = useWaitForTransactionReceipt({ hash });\n\n const busy = isPending || isConfirming;\n\n // --- callback on success ---\n useEffect(() => {\n if (isSuccess && labelRef.current) {\n opts?.onSuccess?.(labelRef.current, hash!);\n setActiveAction(null);\n labelRef.current = \"\";\n }\n }, [isSuccess]);\n\n // --- callback on on-chain error ---\n useEffect(() => {\n if (isError && labelRef.current) {\n opts?.onError?.(labelRef.current, `${labelRef.current} failed on-chain`);\n setActiveAction(null);\n labelRef.current = \"\";\n }\n }, [isError]);\n\n // --- reset if everything settles with no result ---\n useEffect(() => {\n if (!isPending && !isConfirming && !isSuccess && !isError) {\n setActiveAction(null);\n }\n }, [isPending, isConfirming, isSuccess, isError]);\n\n /**\n * Execute an SDK method with shared pending/receipt tracking.\n */\n const exec = useCallback(\n async (label: string, fn: () => Promise<Hash>) => {\n labelRef.current = label;\n setActiveAction(label);\n setIsPending(true);\n setHash(undefined);\n try {\n const txHash = await fn();\n setHash(txHash);\n } catch (error) {\n console.error(`[useSlotAction] ${label} failed:`, error);\n setActiveAction(null);\n labelRef.current = \"\";\n opts?.onError?.(label, extractErrorMessage(error));\n } finally {\n setIsPending(false);\n }\n },\n [opts?.onError],\n );\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Named actions — each calls one SDK method\n // ═══════════════════════════════════════════════════════════════════════════\n\n // Factory\n const createSlot = useCallback(\n (params: CreateSlotParams) =>\n exec(\"Create slot\", () => client.createSlot(params)),\n [exec, client],\n );\n const createSlots = useCallback(\n (params: CreateSlotsParams) =>\n exec(\"Create slots\", () => client.createSlots(params)),\n [exec, client],\n );\n\n // Slot interactions\n const buy = useCallback(\n (params: BuyParams) => exec(\"Buy slot\", () => client.buy(params)),\n [exec, client],\n );\n const selfAssess = useCallback(\n (slot: Address, newPrice: bigint) =>\n exec(\"Set price\", () => client.selfAssess(slot, newPrice)),\n [exec, client],\n );\n const topUp = useCallback(\n (slot: Address, amount: bigint) =>\n exec(\"Top up\", () => client.topUp(slot, amount)),\n [exec, client],\n );\n const withdraw = useCallback(\n (slot: Address, amount: bigint) =>\n exec(\"Withdraw\", () => client.withdraw(slot, amount)),\n [exec, client],\n );\n const release = useCallback(\n (slot: Address) => exec(\"Release slot\", () => client.release(slot)),\n [exec, client],\n );\n const collect = useCallback(\n (slot: Address) => exec(\"Collect tax\", () => client.collect(slot)),\n [exec, client],\n );\n const payTax = useCallback(\n (slot: Address) => exec(\"Pay tax\", () => client.collect(slot)),\n [exec, client],\n );\n const liquidate = useCallback(\n (slot: Address) => exec(\"Liquidate\", () => client.liquidate(slot)),\n [exec, client],\n );\n\n // Manager\n const proposeTaxUpdate = useCallback(\n (slot: Address, newPct: bigint) =>\n exec(\"Propose tax\", () => client.proposeTaxUpdate(slot, newPct)),\n [exec, client],\n );\n const proposeModuleUpdate = useCallback(\n (slot: Address, newModule: Address) =>\n exec(\"Propose module\", () =>\n client.proposeModuleUpdate(slot, newModule),\n ),\n [exec, client],\n );\n const cancelPendingUpdates = useCallback(\n (slot: Address) =>\n exec(\"Cancel updates\", () => client.cancelPendingUpdates(slot)),\n [exec, client],\n );\n const setLiquidationBounty = useCallback(\n (slot: Address, newBps: bigint) =>\n exec(\"Set bounty\", () => client.setLiquidationBounty(slot, newBps)),\n [exec, client],\n );\n\n // Metadata module\n const updateMetadata = useCallback(\n (moduleAddress: Address, slot: Address, uri: string) =>\n exec(\"Update metadata\", () =>\n client.modules.metadata.updateMetadata(moduleAddress, slot, uri),\n ),\n [exec, client],\n );\n\n return {\n // Actions\n createSlot,\n createSlots,\n buy,\n selfAssess,\n topUp,\n withdraw,\n release,\n collect,\n payTax,\n liquidate,\n proposeTaxUpdate,\n proposeModuleUpdate,\n cancelPendingUpdates,\n setLiquidationBounty,\n updateMetadata,\n // Executor\n exec,\n // State\n busy,\n isPending,\n isConfirming,\n isSuccess,\n activeAction,\n };\n}\n","\"use client\";\n\nimport { slotAbi } from \"@0xslots/contracts\";\nimport { type Address, erc20Abi } from \"viem\";\nimport { useReadContract, useReadContracts } from \"wagmi\";\n\nexport type SlotOnChain = {\n // Identity\n id: string;\n recipient: string;\n currency: string;\n manager: string;\n mutableTax: boolean;\n mutableModule: boolean;\n // State\n occupant: string | null;\n price: bigint;\n taxPercentage: bigint;\n module: string;\n liquidationBountyBps: bigint;\n minDepositSeconds: bigint;\n // Financials\n deposit: bigint;\n collectedTax: bigint;\n taxOwed: bigint;\n secondsUntilLiquidation: bigint;\n insolvent: boolean;\n // Pending\n hasPendingTax: boolean;\n pendingTaxPercentage: bigint;\n hasPendingModule: boolean;\n pendingModule: string;\n // Currency metadata\n currencyName?: string;\n currencySymbol?: string;\n currencyDecimals?: number;\n};\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\ntype SlotInfoResult = {\n recipient: string;\n currency: string;\n manager: string;\n mutableTax: boolean;\n mutableModule: boolean;\n occupant: string;\n price: bigint;\n taxPercentage: bigint;\n module: string;\n liquidationBountyBps: bigint;\n minDepositSeconds: bigint;\n deposit: bigint;\n collectedTax: bigint;\n taxOwed: bigint;\n secondsUntilLiquidation: bigint;\n insolvent: boolean;\n hasPendingTax: boolean;\n pendingTaxPercentage: bigint;\n hasPendingModule: boolean;\n pendingModule: string;\n};\n\nfunction parseSlotInfo(\n slotAddress: string,\n info: SlotInfoResult,\n currencyMeta?: { name?: string; symbol?: string; decimals?: number },\n): SlotOnChain {\n return {\n id: slotAddress.toLowerCase(),\n recipient: info.recipient.toLowerCase(),\n currency: info.currency.toLowerCase(),\n manager: info.manager.toLowerCase(),\n mutableTax: info.mutableTax,\n mutableModule: info.mutableModule,\n occupant:\n info.occupant === ZERO_ADDRESS ? null : info.occupant.toLowerCase(),\n price: info.price,\n taxPercentage: info.taxPercentage,\n module: info.module.toLowerCase(),\n liquidationBountyBps: info.liquidationBountyBps,\n minDepositSeconds: info.minDepositSeconds,\n deposit: info.deposit,\n collectedTax: info.collectedTax,\n taxOwed: info.taxOwed,\n secondsUntilLiquidation: info.secondsUntilLiquidation,\n insolvent: info.insolvent,\n hasPendingTax: info.hasPendingTax,\n pendingTaxPercentage: info.pendingTaxPercentage,\n hasPendingModule: info.hasPendingModule,\n pendingModule: info.pendingModule.toLowerCase(),\n currencyName: currencyMeta?.name,\n currencySymbol: currencyMeta?.symbol,\n currencyDecimals: currencyMeta?.decimals,\n };\n}\n\n// Block-watching removed — use refetch() for manual refresh to save RPC calls\n\n/**\n * Fetch a single slot's complete state from on-chain via getSlotInfo() + currency metadata.\n *\n * @param slotAddress - The slot contract address\n * @param chainId - The chain ID to read from\n */\nexport function useSlotOnChain(slotAddress: string, chainId: number): {\n data: SlotOnChain | null;\n isLoading: boolean;\n refetch: () => void;\n} {\n // Manual refetch only — no block watching\n const addr = slotAddress as Address;\n\n const {\n data: info,\n isLoading: infoLoading,\n refetch,\n } = useReadContract({\n address: addr,\n abi: slotAbi,\n functionName: \"getSlotInfo\",\n chainId,\n query: { gcTime: 0, staleTime: 0, refetchOnMount: \"always\" },\n });\n\n // Currency metadata — only fetch when we have info (static, can cache)\n const currencyAddr = info\n ? ((info as SlotInfoResult).currency as Address)\n : undefined;\n const { data: currencyMeta, isLoading: metaLoading } = useReadContracts({\n contracts: currencyAddr\n ? [\n { address: currencyAddr, abi: erc20Abi, functionName: \"name\", chainId },\n { address: currencyAddr, abi: erc20Abi, functionName: \"symbol\", chainId },\n { address: currencyAddr, abi: erc20Abi, functionName: \"decimals\", chainId },\n ]\n : [],\n query: { enabled: !!currencyAddr, staleTime: Infinity },\n });\n\n const isLoading = infoLoading || metaLoading;\n\n const slot = info\n ? parseSlotInfo(\n slotAddress,\n info as SlotInfoResult,\n currencyMeta\n ? {\n name: currencyMeta[0]?.result as string | undefined,\n symbol: currencyMeta[1]?.result as string | undefined,\n decimals: currencyMeta[2]?.result as number | undefined,\n }\n : undefined,\n )\n : null;\n\n return { data: slot, isLoading, refetch };\n}\n\n/**\n * Fetch multiple slots' state via multicall getSlotInfo().\n *\n * @param slotAddresses - Array of slot contract addresses\n * @param chainId - The chain ID to read from\n */\nexport function useSlotsOnChain(slotAddresses: string[], chainId: number): {\n data: SlotOnChain[];\n isLoading: boolean;\n refetch: () => void;\n} {\n // Manual refetch only — no block watching\n const contracts = slotAddresses.map((addr) => ({\n address: addr as Address,\n abi: slotAbi,\n functionName: \"getSlotInfo\" as const,\n chainId,\n }));\n\n const {\n data: infos,\n isLoading: infosLoading,\n refetch,\n } = useReadContracts({\n contracts,\n query: {\n enabled: slotAddresses.length > 0,\n gcTime: 0,\n staleTime: 0,\n refetchOnMount: \"always\",\n },\n });\n\n // Get unique currencies to fetch metadata\n const currencies = new Set<string>();\n if (infos) {\n for (const r of infos) {\n if (r.result)\n currencies.add(\n (r.result as SlotInfoResult).currency.toLowerCase(),\n );\n }\n }\n const currencyList = Array.from(currencies);\n\n const { data: metaResults, isLoading: metaLoading } = useReadContracts({\n contracts: currencyList.flatMap((c) => [\n { address: c as Address, abi: erc20Abi, functionName: \"name\" as const, chainId },\n { address: c as Address, abi: erc20Abi, functionName: \"symbol\" as const, chainId },\n {\n address: c as Address,\n abi: erc20Abi,\n functionName: \"decimals\" as const,\n chainId,\n },\n ]),\n query: { enabled: currencyList.length > 0 },\n });\n\n // Build currency metadata map\n const currencyMeta: Record<\n string,\n { name?: string; symbol?: string; decimals?: number }\n > = {};\n if (metaResults) {\n currencyList.forEach((c, i) => {\n currencyMeta[c] = {\n name: metaResults[i * 3]?.result as string | undefined,\n symbol: metaResults[i * 3 + 1]?.result as string | undefined,\n decimals: metaResults[i * 3 + 2]?.result as number | undefined,\n };\n });\n }\n\n const isLoading = infosLoading || metaLoading;\n\n const slots: SlotOnChain[] = [];\n if (infos) {\n for (let i = 0; i < infos.length; i++) {\n const r = infos[i];\n if (r.result) {\n const result = r.result as SlotInfoResult;\n const currency = result.currency.toLowerCase();\n slots.push(\n parseSlotInfo(slotAddresses[i], result, currencyMeta[currency]),\n );\n }\n }\n }\n\n return { data: slots, isLoading, refetch };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xslots/sdk",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Type-safe SDK for the 0xSlots protocol — reads (subgraph) + writes (viem)",
5
5
  "author": "Nezz",
6
6
  "license": "MIT",
@@ -27,20 +27,17 @@
27
27
  "graphql": "^16.9.0",
28
28
  "graphql-request": "^7.2.2",
29
29
  "graphql-tag": "^2.12.6",
30
- "@0xslots/contracts": "0.7.0"
30
+ "@0xslots/contracts": "0.7.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@graphql-codegen/cli": "^5.0.4",
34
34
  "@graphql-codegen/typescript": "^4.1.3",
35
35
  "@graphql-codegen/typescript-graphql-request": "^6.3.0",
36
36
  "@graphql-codegen/typescript-operations": "^4.4.2",
37
- "@tanstack/react-query": "^5.90.21",
38
37
  "@types/node": "^20.10.8",
39
38
  "@types/react": "^19",
40
- "react": "^19.0.0",
41
39
  "tsup": "^8.0.0",
42
- "typescript": "^5.4.4",
43
- "wagmi": "^3.5.0"
40
+ "typescript": "^5.4.4"
44
41
  },
45
42
  "peerDependencies": {
46
43
  "@tanstack/react-query": ">=5",