@0xslots/sdk 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-KRJINGNH.js → chunk-VQ5PSOCE.js} +80 -34
- package/dist/chunk-VQ5PSOCE.js.map +1 -0
- package/dist/{client-BtZNzXuf.d.ts → client-BcIWQW9H.d.ts} +4 -5
- package/dist/index.d.ts +24 -3
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +3 -2
- package/dist/react.js +15 -4
- package/dist/react.js.map +1 -1
- package/package.json +3 -6
- package/dist/chunk-KRJINGNH.js.map +0 -1
|
@@ -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.
|
|
4316
|
+
* chainId: SlotsChain.BASE,
|
|
4318
4317
|
* publicClient,
|
|
4319
4318
|
* walletClient,
|
|
4320
4319
|
* });
|
|
@@ -4551,4 +4550,4 @@ declare class SlotsClient {
|
|
|
4551
4550
|
}
|
|
4552
4551
|
declare function createSlotsClient(config: SlotsClientConfig): SlotsClient;
|
|
4553
4552
|
|
|
4554
|
-
export {
|
|
4553
|
+
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
|
-
|
|
1
|
+
import { S as SlotsChain } from './client-BcIWQW9H.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-BcIWQW9H.js';
|
|
3
|
+
import { Address } from 'viem';
|
|
2
4
|
import 'graphql-request';
|
|
3
5
|
import 'graphql';
|
|
4
|
-
|
|
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-
|
|
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-VQ5PSOCE.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 {
|
|
1
|
+
import { S as SlotsChain, cx as SlotsClient, C as CreateSlotParams, o as CreateSlotsParams, n as BuyParams } from './client-BcIWQW9H.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.
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { SlotsClient } from './chunk-
|
|
1
|
+
import { SlotsClient } from './chunk-VQ5PSOCE.js';
|
|
2
2
|
import { slotFactoryAddress, slotAbi } from '@0xslots/contracts';
|
|
3
3
|
import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
4
4
|
import { usePublicClient, useWalletClient, useWaitForTransactionReceipt, useReadContract, useReadContracts, useBlockNumber } from 'wagmi';
|
|
@@ -24,11 +24,21 @@ function useSlotsClient(chainId, subgraphApiKey) {
|
|
|
24
24
|
}, [chainId, publicClient, walletClient, subgraphApiKey]);
|
|
25
25
|
}
|
|
26
26
|
function extractErrorMessage(error) {
|
|
27
|
-
const message = error instanceof Error ? error.message :
|
|
28
|
-
|
|
27
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
+
if (message.includes("User rejected") || message.includes("User denied"))
|
|
29
|
+
return "Transaction rejected";
|
|
30
|
+
const err = error;
|
|
31
|
+
if (err && typeof err === "object") {
|
|
32
|
+
if (typeof err.shortMessage === "string") return err.shortMessage;
|
|
33
|
+
const cause = err.cause;
|
|
34
|
+
if (cause && typeof cause.shortMessage === "string")
|
|
35
|
+
return cause.shortMessage;
|
|
36
|
+
if (cause && typeof cause.reason === "string") return cause.reason;
|
|
37
|
+
}
|
|
38
|
+
return message.split("\n")[0] || "Transaction failed";
|
|
29
39
|
}
|
|
30
40
|
function useSlotAction(opts) {
|
|
31
|
-
const client = useSlotsClient();
|
|
41
|
+
const client = useSlotsClient(opts?.chainId);
|
|
32
42
|
const [hash, setHash] = useState();
|
|
33
43
|
const [activeAction, setActiveAction] = useState(null);
|
|
34
44
|
const [isPending, setIsPending] = useState(false);
|
|
@@ -68,6 +78,7 @@ function useSlotAction(opts) {
|
|
|
68
78
|
const txHash = await fn();
|
|
69
79
|
setHash(txHash);
|
|
70
80
|
} catch (error) {
|
|
81
|
+
console.error(`[useSlotAction] ${label} failed:`, error);
|
|
71
82
|
setActiveAction(null);
|
|
72
83
|
labelRef.current = "";
|
|
73
84
|
opts?.onError?.(label, extractErrorMessage(error));
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useSlotsClient.ts","../src/hooks/useSlotAction.ts","../src/hooks/useSlotOnChain.ts"],"names":["useEffect"],"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,KA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,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":["useEffect"],"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;AA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AAA,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.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, 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xslots/sdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
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.
|
|
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",
|