@0xslots/sdk 0.9.2 → 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-VQ5PSOCE.js +1628 -0
- package/dist/chunk-VQ5PSOCE.js.map +1 -0
- package/dist/client-BcIWQW9H.d.ts +4553 -0
- package/dist/index.d.ts +20 -4155
- package/dist/index.js +25 -1572
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +101 -0
- package/dist/react.js +331 -0
- package/dist/react.js.map +1 -0
- package/package.json +23 -4
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { S as SlotsChain, cx as SlotsClient, C as CreateSlotParams, o as CreateSlotsParams, n as BuyParams } from './client-BcIWQW9H.js';
|
|
2
|
+
import { Hash, Address } from 'viem';
|
|
3
|
+
import 'graphql-request';
|
|
4
|
+
import 'graphql';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* React hook that creates a memoized {@link SlotsClient} from wagmi's public/wallet clients.
|
|
8
|
+
*
|
|
9
|
+
* @param chainId - Optional chain ID override. Defaults to the connected chain.
|
|
10
|
+
* @returns A configured SlotsClient instance.
|
|
11
|
+
* @throws If no public client is available or the chain has no factory address.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* function MyComponent() {
|
|
16
|
+
* const client = useSlotsClient(SlotsChain.BASE);
|
|
17
|
+
* // use client.getSlots(), client.buy(), etc.
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function useSlotsClient(chainId?: SlotsChain, subgraphApiKey?: string): SlotsClient;
|
|
22
|
+
|
|
23
|
+
interface SlotActionCallbacks {
|
|
24
|
+
chainId?: SlotsChain;
|
|
25
|
+
onSuccess?: (label: string, hash: Hash) => void;
|
|
26
|
+
onError?: (label: string, error: string) => void;
|
|
27
|
+
}
|
|
28
|
+
declare function useSlotAction(opts?: SlotActionCallbacks): {
|
|
29
|
+
createSlot: (params: CreateSlotParams) => Promise<void>;
|
|
30
|
+
createSlots: (params: CreateSlotsParams) => Promise<void>;
|
|
31
|
+
buy: (params: BuyParams) => Promise<void>;
|
|
32
|
+
selfAssess: (slot: Address, newPrice: bigint) => Promise<void>;
|
|
33
|
+
topUp: (slot: Address, amount: bigint) => Promise<void>;
|
|
34
|
+
withdraw: (slot: Address, amount: bigint) => Promise<void>;
|
|
35
|
+
release: (slot: Address) => Promise<void>;
|
|
36
|
+
collect: (slot: Address) => Promise<void>;
|
|
37
|
+
payTax: (slot: Address) => Promise<void>;
|
|
38
|
+
liquidate: (slot: Address) => Promise<void>;
|
|
39
|
+
proposeTaxUpdate: (slot: Address, newPct: bigint) => Promise<void>;
|
|
40
|
+
proposeModuleUpdate: (slot: Address, newModule: Address) => Promise<void>;
|
|
41
|
+
cancelPendingUpdates: (slot: Address) => Promise<void>;
|
|
42
|
+
setLiquidationBounty: (slot: Address, newBps: bigint) => Promise<void>;
|
|
43
|
+
updateMetadata: (moduleAddress: Address, slot: Address, uri: string) => Promise<void>;
|
|
44
|
+
exec: (label: string, fn: () => Promise<Hash>) => Promise<void>;
|
|
45
|
+
busy: boolean;
|
|
46
|
+
isPending: boolean;
|
|
47
|
+
isConfirming: boolean;
|
|
48
|
+
isSuccess: boolean;
|
|
49
|
+
activeAction: string | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SlotOnChain = {
|
|
53
|
+
id: string;
|
|
54
|
+
recipient: string;
|
|
55
|
+
currency: string;
|
|
56
|
+
manager: string;
|
|
57
|
+
mutableTax: boolean;
|
|
58
|
+
mutableModule: boolean;
|
|
59
|
+
occupant: string | null;
|
|
60
|
+
price: bigint;
|
|
61
|
+
taxPercentage: bigint;
|
|
62
|
+
module: string;
|
|
63
|
+
liquidationBountyBps: bigint;
|
|
64
|
+
minDepositSeconds: bigint;
|
|
65
|
+
deposit: bigint;
|
|
66
|
+
collectedTax: bigint;
|
|
67
|
+
taxOwed: bigint;
|
|
68
|
+
secondsUntilLiquidation: bigint;
|
|
69
|
+
insolvent: boolean;
|
|
70
|
+
hasPendingTax: boolean;
|
|
71
|
+
pendingTaxPercentage: bigint;
|
|
72
|
+
hasPendingModule: boolean;
|
|
73
|
+
pendingModule: string;
|
|
74
|
+
currencyName?: string;
|
|
75
|
+
currencySymbol?: string;
|
|
76
|
+
currencyDecimals?: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Fetch a single slot's complete state from on-chain via getSlotInfo() + currency metadata.
|
|
80
|
+
*
|
|
81
|
+
* @param slotAddress - The slot contract address
|
|
82
|
+
* @param chainId - The chain ID to read from
|
|
83
|
+
*/
|
|
84
|
+
declare function useSlotOnChain(slotAddress: string, chainId: number): {
|
|
85
|
+
data: SlotOnChain | null;
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
refetch: () => void;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Fetch multiple slots' state via multicall getSlotInfo().
|
|
91
|
+
*
|
|
92
|
+
* @param slotAddresses - Array of slot contract addresses
|
|
93
|
+
* @param chainId - The chain ID to read from
|
|
94
|
+
*/
|
|
95
|
+
declare function useSlotsOnChain(slotAddresses: string[], chainId: number): {
|
|
96
|
+
data: SlotOnChain[];
|
|
97
|
+
isLoading: boolean;
|
|
98
|
+
refetch: () => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { type SlotActionCallbacks, type SlotOnChain, useSlotAction, useSlotOnChain, useSlotsClient, useSlotsOnChain };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { SlotsClient } from './chunk-VQ5PSOCE.js';
|
|
2
|
+
import { slotFactoryAddress, slotAbi } from '@0xslots/contracts';
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
4
|
+
import { usePublicClient, useWalletClient, useWaitForTransactionReceipt, useReadContract, useReadContracts, useBlockNumber } from 'wagmi';
|
|
5
|
+
import { erc20Abi } from 'viem';
|
|
6
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
7
|
+
|
|
8
|
+
function useSlotsClient(chainId, subgraphApiKey) {
|
|
9
|
+
const publicClient = usePublicClient({ chainId });
|
|
10
|
+
const { data: walletClient } = useWalletClient({ chainId });
|
|
11
|
+
return useMemo(() => {
|
|
12
|
+
if (!publicClient) throw new Error("No publicClient available");
|
|
13
|
+
const resolvedChainId = chainId ?? publicClient.chain.id;
|
|
14
|
+
const factoryAddress = slotFactoryAddress[resolvedChainId];
|
|
15
|
+
if (!factoryAddress)
|
|
16
|
+
throw new Error(`No factory address for chain ${resolvedChainId}`);
|
|
17
|
+
return new SlotsClient({
|
|
18
|
+
chainId: resolvedChainId,
|
|
19
|
+
factoryAddress,
|
|
20
|
+
publicClient,
|
|
21
|
+
walletClient: walletClient ?? void 0,
|
|
22
|
+
subgraphApiKey
|
|
23
|
+
});
|
|
24
|
+
}, [chainId, publicClient, walletClient, subgraphApiKey]);
|
|
25
|
+
}
|
|
26
|
+
function extractErrorMessage(error) {
|
|
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";
|
|
39
|
+
}
|
|
40
|
+
function useSlotAction(opts) {
|
|
41
|
+
const client = useSlotsClient(opts?.chainId);
|
|
42
|
+
const [hash, setHash] = useState();
|
|
43
|
+
const [activeAction, setActiveAction] = useState(null);
|
|
44
|
+
const [isPending, setIsPending] = useState(false);
|
|
45
|
+
const labelRef = useRef("");
|
|
46
|
+
const {
|
|
47
|
+
isLoading: isConfirming,
|
|
48
|
+
isSuccess,
|
|
49
|
+
isError
|
|
50
|
+
} = useWaitForTransactionReceipt({ hash });
|
|
51
|
+
const busy = isPending || isConfirming;
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (isSuccess && labelRef.current) {
|
|
54
|
+
opts?.onSuccess?.(labelRef.current, hash);
|
|
55
|
+
setActiveAction(null);
|
|
56
|
+
labelRef.current = "";
|
|
57
|
+
}
|
|
58
|
+
}, [isSuccess]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (isError && labelRef.current) {
|
|
61
|
+
opts?.onError?.(labelRef.current, `${labelRef.current} failed on-chain`);
|
|
62
|
+
setActiveAction(null);
|
|
63
|
+
labelRef.current = "";
|
|
64
|
+
}
|
|
65
|
+
}, [isError]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!isPending && !isConfirming && !isSuccess && !isError) {
|
|
68
|
+
setActiveAction(null);
|
|
69
|
+
}
|
|
70
|
+
}, [isPending, isConfirming, isSuccess, isError]);
|
|
71
|
+
const exec = useCallback(
|
|
72
|
+
async (label, fn) => {
|
|
73
|
+
labelRef.current = label;
|
|
74
|
+
setActiveAction(label);
|
|
75
|
+
setIsPending(true);
|
|
76
|
+
setHash(void 0);
|
|
77
|
+
try {
|
|
78
|
+
const txHash = await fn();
|
|
79
|
+
setHash(txHash);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(`[useSlotAction] ${label} failed:`, error);
|
|
82
|
+
setActiveAction(null);
|
|
83
|
+
labelRef.current = "";
|
|
84
|
+
opts?.onError?.(label, extractErrorMessage(error));
|
|
85
|
+
} finally {
|
|
86
|
+
setIsPending(false);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[opts?.onError]
|
|
90
|
+
);
|
|
91
|
+
const createSlot = useCallback(
|
|
92
|
+
(params) => exec("Create slot", () => client.createSlot(params)),
|
|
93
|
+
[exec, client]
|
|
94
|
+
);
|
|
95
|
+
const createSlots = useCallback(
|
|
96
|
+
(params) => exec("Create slots", () => client.createSlots(params)),
|
|
97
|
+
[exec, client]
|
|
98
|
+
);
|
|
99
|
+
const buy = useCallback(
|
|
100
|
+
(params) => exec("Buy slot", () => client.buy(params)),
|
|
101
|
+
[exec, client]
|
|
102
|
+
);
|
|
103
|
+
const selfAssess = useCallback(
|
|
104
|
+
(slot, newPrice) => exec("Set price", () => client.selfAssess(slot, newPrice)),
|
|
105
|
+
[exec, client]
|
|
106
|
+
);
|
|
107
|
+
const topUp = useCallback(
|
|
108
|
+
(slot, amount) => exec("Top up", () => client.topUp(slot, amount)),
|
|
109
|
+
[exec, client]
|
|
110
|
+
);
|
|
111
|
+
const withdraw = useCallback(
|
|
112
|
+
(slot, amount) => exec("Withdraw", () => client.withdraw(slot, amount)),
|
|
113
|
+
[exec, client]
|
|
114
|
+
);
|
|
115
|
+
const release = useCallback(
|
|
116
|
+
(slot) => exec("Release slot", () => client.release(slot)),
|
|
117
|
+
[exec, client]
|
|
118
|
+
);
|
|
119
|
+
const collect = useCallback(
|
|
120
|
+
(slot) => exec("Collect tax", () => client.collect(slot)),
|
|
121
|
+
[exec, client]
|
|
122
|
+
);
|
|
123
|
+
const payTax = useCallback(
|
|
124
|
+
(slot) => exec("Pay tax", () => client.collect(slot)),
|
|
125
|
+
[exec, client]
|
|
126
|
+
);
|
|
127
|
+
const liquidate = useCallback(
|
|
128
|
+
(slot) => exec("Liquidate", () => client.liquidate(slot)),
|
|
129
|
+
[exec, client]
|
|
130
|
+
);
|
|
131
|
+
const proposeTaxUpdate = useCallback(
|
|
132
|
+
(slot, newPct) => exec("Propose tax", () => client.proposeTaxUpdate(slot, newPct)),
|
|
133
|
+
[exec, client]
|
|
134
|
+
);
|
|
135
|
+
const proposeModuleUpdate = useCallback(
|
|
136
|
+
(slot, newModule) => exec(
|
|
137
|
+
"Propose module",
|
|
138
|
+
() => client.proposeModuleUpdate(slot, newModule)
|
|
139
|
+
),
|
|
140
|
+
[exec, client]
|
|
141
|
+
);
|
|
142
|
+
const cancelPendingUpdates = useCallback(
|
|
143
|
+
(slot) => exec("Cancel updates", () => client.cancelPendingUpdates(slot)),
|
|
144
|
+
[exec, client]
|
|
145
|
+
);
|
|
146
|
+
const setLiquidationBounty = useCallback(
|
|
147
|
+
(slot, newBps) => exec("Set bounty", () => client.setLiquidationBounty(slot, newBps)),
|
|
148
|
+
[exec, client]
|
|
149
|
+
);
|
|
150
|
+
const updateMetadata = useCallback(
|
|
151
|
+
(moduleAddress, slot, uri) => exec(
|
|
152
|
+
"Update metadata",
|
|
153
|
+
() => client.modules.metadata.updateMetadata(moduleAddress, slot, uri)
|
|
154
|
+
),
|
|
155
|
+
[exec, client]
|
|
156
|
+
);
|
|
157
|
+
return {
|
|
158
|
+
// Actions
|
|
159
|
+
createSlot,
|
|
160
|
+
createSlots,
|
|
161
|
+
buy,
|
|
162
|
+
selfAssess,
|
|
163
|
+
topUp,
|
|
164
|
+
withdraw,
|
|
165
|
+
release,
|
|
166
|
+
collect,
|
|
167
|
+
payTax,
|
|
168
|
+
liquidate,
|
|
169
|
+
proposeTaxUpdate,
|
|
170
|
+
proposeModuleUpdate,
|
|
171
|
+
cancelPendingUpdates,
|
|
172
|
+
setLiquidationBounty,
|
|
173
|
+
updateMetadata,
|
|
174
|
+
// Executor
|
|
175
|
+
exec,
|
|
176
|
+
// State
|
|
177
|
+
busy,
|
|
178
|
+
isPending,
|
|
179
|
+
isConfirming,
|
|
180
|
+
isSuccess,
|
|
181
|
+
activeAction
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
185
|
+
function parseSlotInfo(slotAddress, info, currencyMeta) {
|
|
186
|
+
return {
|
|
187
|
+
id: slotAddress.toLowerCase(),
|
|
188
|
+
recipient: info.recipient.toLowerCase(),
|
|
189
|
+
currency: info.currency.toLowerCase(),
|
|
190
|
+
manager: info.manager.toLowerCase(),
|
|
191
|
+
mutableTax: info.mutableTax,
|
|
192
|
+
mutableModule: info.mutableModule,
|
|
193
|
+
occupant: info.occupant === ZERO_ADDRESS ? null : info.occupant.toLowerCase(),
|
|
194
|
+
price: info.price,
|
|
195
|
+
taxPercentage: info.taxPercentage,
|
|
196
|
+
module: info.module.toLowerCase(),
|
|
197
|
+
liquidationBountyBps: info.liquidationBountyBps,
|
|
198
|
+
minDepositSeconds: info.minDepositSeconds,
|
|
199
|
+
deposit: info.deposit,
|
|
200
|
+
collectedTax: info.collectedTax,
|
|
201
|
+
taxOwed: info.taxOwed,
|
|
202
|
+
secondsUntilLiquidation: info.secondsUntilLiquidation,
|
|
203
|
+
insolvent: info.insolvent,
|
|
204
|
+
hasPendingTax: info.hasPendingTax,
|
|
205
|
+
pendingTaxPercentage: info.pendingTaxPercentage,
|
|
206
|
+
hasPendingModule: info.hasPendingModule,
|
|
207
|
+
pendingModule: info.pendingModule.toLowerCase(),
|
|
208
|
+
currencyName: currencyMeta?.name,
|
|
209
|
+
currencySymbol: currencyMeta?.symbol,
|
|
210
|
+
currencyDecimals: currencyMeta?.decimals
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function useInvalidateOnBlock(chainId) {
|
|
214
|
+
const queryClient = useQueryClient();
|
|
215
|
+
const { data: blockNumber } = useBlockNumber({ watch: true, chainId });
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (blockNumber) {
|
|
218
|
+
queryClient.invalidateQueries({ queryKey: ["readContract"] });
|
|
219
|
+
queryClient.invalidateQueries({ queryKey: ["readContracts"] });
|
|
220
|
+
}
|
|
221
|
+
}, [blockNumber, queryClient]);
|
|
222
|
+
}
|
|
223
|
+
function useSlotOnChain(slotAddress, chainId) {
|
|
224
|
+
useInvalidateOnBlock(chainId);
|
|
225
|
+
const addr = slotAddress;
|
|
226
|
+
const {
|
|
227
|
+
data: info,
|
|
228
|
+
isLoading: infoLoading,
|
|
229
|
+
refetch
|
|
230
|
+
} = useReadContract({
|
|
231
|
+
address: addr,
|
|
232
|
+
abi: slotAbi,
|
|
233
|
+
functionName: "getSlotInfo",
|
|
234
|
+
chainId,
|
|
235
|
+
query: { gcTime: 0, staleTime: 0, refetchOnMount: "always" }
|
|
236
|
+
});
|
|
237
|
+
const currencyAddr = info ? info.currency : void 0;
|
|
238
|
+
const { data: currencyMeta, isLoading: metaLoading } = useReadContracts({
|
|
239
|
+
contracts: currencyAddr ? [
|
|
240
|
+
{ address: currencyAddr, abi: erc20Abi, functionName: "name", chainId },
|
|
241
|
+
{ address: currencyAddr, abi: erc20Abi, functionName: "symbol", chainId },
|
|
242
|
+
{ address: currencyAddr, abi: erc20Abi, functionName: "decimals", chainId }
|
|
243
|
+
] : [],
|
|
244
|
+
query: { enabled: !!currencyAddr, staleTime: Infinity }
|
|
245
|
+
});
|
|
246
|
+
const isLoading = infoLoading || metaLoading;
|
|
247
|
+
const slot = info ? parseSlotInfo(
|
|
248
|
+
slotAddress,
|
|
249
|
+
info,
|
|
250
|
+
currencyMeta ? {
|
|
251
|
+
name: currencyMeta[0]?.result,
|
|
252
|
+
symbol: currencyMeta[1]?.result,
|
|
253
|
+
decimals: currencyMeta[2]?.result
|
|
254
|
+
} : void 0
|
|
255
|
+
) : null;
|
|
256
|
+
return { data: slot, isLoading, refetch };
|
|
257
|
+
}
|
|
258
|
+
function useSlotsOnChain(slotAddresses, chainId) {
|
|
259
|
+
useInvalidateOnBlock(chainId);
|
|
260
|
+
const contracts = slotAddresses.map((addr) => ({
|
|
261
|
+
address: addr,
|
|
262
|
+
abi: slotAbi,
|
|
263
|
+
functionName: "getSlotInfo",
|
|
264
|
+
chainId
|
|
265
|
+
}));
|
|
266
|
+
const {
|
|
267
|
+
data: infos,
|
|
268
|
+
isLoading: infosLoading,
|
|
269
|
+
refetch
|
|
270
|
+
} = useReadContracts({
|
|
271
|
+
contracts,
|
|
272
|
+
query: {
|
|
273
|
+
enabled: slotAddresses.length > 0,
|
|
274
|
+
gcTime: 0,
|
|
275
|
+
staleTime: 0,
|
|
276
|
+
refetchOnMount: "always"
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const currencies = /* @__PURE__ */ new Set();
|
|
280
|
+
if (infos) {
|
|
281
|
+
for (const r of infos) {
|
|
282
|
+
if (r.result)
|
|
283
|
+
currencies.add(
|
|
284
|
+
r.result.currency.toLowerCase()
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const currencyList = Array.from(currencies);
|
|
289
|
+
const { data: metaResults, isLoading: metaLoading } = useReadContracts({
|
|
290
|
+
contracts: currencyList.flatMap((c) => [
|
|
291
|
+
{ address: c, abi: erc20Abi, functionName: "name", chainId },
|
|
292
|
+
{ address: c, abi: erc20Abi, functionName: "symbol", chainId },
|
|
293
|
+
{
|
|
294
|
+
address: c,
|
|
295
|
+
abi: erc20Abi,
|
|
296
|
+
functionName: "decimals",
|
|
297
|
+
chainId
|
|
298
|
+
}
|
|
299
|
+
]),
|
|
300
|
+
query: { enabled: currencyList.length > 0 }
|
|
301
|
+
});
|
|
302
|
+
const currencyMeta = {};
|
|
303
|
+
if (metaResults) {
|
|
304
|
+
currencyList.forEach((c, i) => {
|
|
305
|
+
currencyMeta[c] = {
|
|
306
|
+
name: metaResults[i * 3]?.result,
|
|
307
|
+
symbol: metaResults[i * 3 + 1]?.result,
|
|
308
|
+
decimals: metaResults[i * 3 + 2]?.result
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const isLoading = infosLoading || metaLoading;
|
|
313
|
+
const slots = [];
|
|
314
|
+
if (infos) {
|
|
315
|
+
for (let i = 0; i < infos.length; i++) {
|
|
316
|
+
const r = infos[i];
|
|
317
|
+
if (r.result) {
|
|
318
|
+
const result = r.result;
|
|
319
|
+
const currency = result.currency.toLowerCase();
|
|
320
|
+
slots.push(
|
|
321
|
+
parseSlotInfo(slotAddresses[i], result, currencyMeta[currency])
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return { data: slots, isLoading, refetch };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export { useSlotAction, useSlotOnChain, useSlotsClient, useSlotsOnChain };
|
|
330
|
+
//# sourceMappingURL=react.js.map
|
|
331
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +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,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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,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.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.
|
|
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",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./react": {
|
|
19
|
+
"types": "./dist/react.d.ts",
|
|
20
|
+
"import": "./dist/react.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"publishConfig": {
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"graphql": "^16.9.0",
|
|
24
28
|
"graphql-request": "^7.2.2",
|
|
25
29
|
"graphql-tag": "^2.12.6",
|
|
26
|
-
"@0xslots/contracts": "0.
|
|
30
|
+
"@0xslots/contracts": "0.7.1"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"@graphql-codegen/cli": "^5.0.4",
|
|
@@ -31,15 +35,30 @@
|
|
|
31
35
|
"@graphql-codegen/typescript-graphql-request": "^6.3.0",
|
|
32
36
|
"@graphql-codegen/typescript-operations": "^4.4.2",
|
|
33
37
|
"@types/node": "^20.10.8",
|
|
38
|
+
"@types/react": "^19",
|
|
34
39
|
"tsup": "^8.0.0",
|
|
35
40
|
"typescript": "^5.4.4"
|
|
36
41
|
},
|
|
37
42
|
"peerDependencies": {
|
|
38
|
-
"
|
|
43
|
+
"@tanstack/react-query": ">=5",
|
|
44
|
+
"react": ">=18",
|
|
45
|
+
"viem": ">=2",
|
|
46
|
+
"wagmi": ">=2"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"react": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"wagmi": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@tanstack/react-query": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
39
58
|
},
|
|
40
59
|
"scripts": {
|
|
41
60
|
"codegen": "graphql-codegen --config codegen.yml",
|
|
42
|
-
"build": "
|
|
61
|
+
"build": "tsup",
|
|
43
62
|
"clean": "rm -rf dist generated",
|
|
44
63
|
"dev": "tsup --watch",
|
|
45
64
|
"typecheck": "tsc --noEmit"
|