@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
|
@@ -3,7 +3,16 @@ import { metadataModuleAbi, getSlotsHubAddress, slotAbi, slotFactoryAbi } from '
|
|
|
3
3
|
import { gql as gql$1, GraphQLClient } from 'graphql-request';
|
|
4
4
|
import { encodeFunctionData, erc20Abi } from 'viem';
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/errors.ts
|
|
7
|
+
var SlotsError = class extends Error {
|
|
8
|
+
constructor(operation, cause) {
|
|
9
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
10
|
+
super(`${operation}: ${msg}`);
|
|
11
|
+
this.operation = operation;
|
|
12
|
+
this.name = "SlotsError";
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
7
16
|
var AccountFieldsFragmentDoc = gql`
|
|
8
17
|
fragment AccountFields on Account {
|
|
9
18
|
id
|
|
@@ -899,17 +908,6 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
899
908
|
}
|
|
900
909
|
};
|
|
901
910
|
}
|
|
902
|
-
|
|
903
|
-
// src/errors.ts
|
|
904
|
-
var SlotsError = class extends Error {
|
|
905
|
-
constructor(operation, cause) {
|
|
906
|
-
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
907
|
-
super(`${operation}: ${msg}`);
|
|
908
|
-
this.operation = operation;
|
|
909
|
-
this.name = "SlotsError";
|
|
910
|
-
this.cause = cause;
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
911
|
var EXPECTED_MODULE_NAME = "MetadataModule";
|
|
914
912
|
var MetadataModuleClient = class {
|
|
915
913
|
constructor(opts) {
|
|
@@ -1052,13 +1050,11 @@ var META_QUERY = gql$1`
|
|
|
1052
1050
|
var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
|
|
1053
1051
|
SlotsChain2[SlotsChain2["BASE"] = 8453] = "BASE";
|
|
1054
1052
|
SlotsChain2[SlotsChain2["BASE_SEPOLIA"] = 84532] = "BASE_SEPOLIA";
|
|
1055
|
-
SlotsChain2[SlotsChain2["ARBITRUM"] = 42161] = "ARBITRUM";
|
|
1056
1053
|
return SlotsChain2;
|
|
1057
1054
|
})(SlotsChain || {});
|
|
1058
1055
|
var SUBGRAPH_URLS = {
|
|
1059
1056
|
[84532 /* BASE_SEPOLIA */]: "https://gateway.thegraph.com/api/subgraphs/id/Z361DLoMdPh9WAopH7shJP8WoXYAB9XeKrLUCTYjdZR",
|
|
1060
|
-
[8453 /* BASE */]: "https://gateway.thegraph.com/api/subgraphs/id/4sZrdv1SFzN4KzE9jiWDRuUyM4CnCrmvQ54Rv1s65qUq"
|
|
1061
|
-
[42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
|
|
1057
|
+
[8453 /* BASE */]: "https://gateway.thegraph.com/api/subgraphs/id/4sZrdv1SFzN4KzE9jiWDRuUyM4CnCrmvQ54Rv1s65qUq"
|
|
1062
1058
|
};
|
|
1063
1059
|
var SlotsClient = class {
|
|
1064
1060
|
constructor(config) {
|
|
@@ -1142,11 +1138,17 @@ var SlotsClient = class {
|
|
|
1142
1138
|
}
|
|
1143
1139
|
/** Fetch all slots owned by a given recipient address. */
|
|
1144
1140
|
getSlotsByRecipient(...args) {
|
|
1145
|
-
return this.query(
|
|
1141
|
+
return this.query(
|
|
1142
|
+
"getSlotsByRecipient",
|
|
1143
|
+
() => this.sdk.GetSlotsByRecipient(...args)
|
|
1144
|
+
);
|
|
1146
1145
|
}
|
|
1147
1146
|
/** Fetch all slots currently occupied by a given address. */
|
|
1148
1147
|
getSlotsByOccupant(...args) {
|
|
1149
|
-
return this.query(
|
|
1148
|
+
return this.query(
|
|
1149
|
+
"getSlotsByOccupant",
|
|
1150
|
+
() => this.sdk.GetSlotsByOccupant(...args)
|
|
1151
|
+
);
|
|
1150
1152
|
}
|
|
1151
1153
|
// Factory queries
|
|
1152
1154
|
/** Fetch factory configuration. */
|
|
@@ -1160,27 +1162,45 @@ var SlotsClient = class {
|
|
|
1160
1162
|
// Event queries
|
|
1161
1163
|
/** Fetch slot deployed events with optional filters. */
|
|
1162
1164
|
getSlotDeployedEvents(...args) {
|
|
1163
|
-
return this.query(
|
|
1165
|
+
return this.query(
|
|
1166
|
+
"getSlotDeployedEvents",
|
|
1167
|
+
() => this.sdk.GetSlotDeployedEvents(...args)
|
|
1168
|
+
);
|
|
1164
1169
|
}
|
|
1165
1170
|
/** Fetch bought events with optional filters. */
|
|
1166
1171
|
getBoughtEvents(...args) {
|
|
1167
|
-
return this.query(
|
|
1172
|
+
return this.query(
|
|
1173
|
+
"getBoughtEvents",
|
|
1174
|
+
() => this.sdk.GetBoughtEvents(...args)
|
|
1175
|
+
);
|
|
1168
1176
|
}
|
|
1169
1177
|
/** Fetch settled events with optional filters. */
|
|
1170
1178
|
getSettledEvents(...args) {
|
|
1171
|
-
return this.query(
|
|
1179
|
+
return this.query(
|
|
1180
|
+
"getSettledEvents",
|
|
1181
|
+
() => this.sdk.GetSettledEvents(...args)
|
|
1182
|
+
);
|
|
1172
1183
|
}
|
|
1173
1184
|
/** Fetch tax-collected events with optional filters. */
|
|
1174
1185
|
getTaxCollectedEvents(...args) {
|
|
1175
|
-
return this.query(
|
|
1186
|
+
return this.query(
|
|
1187
|
+
"getTaxCollectedEvents",
|
|
1188
|
+
() => this.sdk.GetTaxCollectedEvents(...args)
|
|
1189
|
+
);
|
|
1176
1190
|
}
|
|
1177
1191
|
/** Fetch all activity for a specific slot (all event types). */
|
|
1178
1192
|
getSlotActivity(...args) {
|
|
1179
|
-
return this.query(
|
|
1193
|
+
return this.query(
|
|
1194
|
+
"getSlotActivity",
|
|
1195
|
+
() => this.sdk.GetSlotActivity(...args)
|
|
1196
|
+
);
|
|
1180
1197
|
}
|
|
1181
1198
|
/** Fetch the most recent events across all slots. */
|
|
1182
1199
|
getRecentEvents(...args) {
|
|
1183
|
-
return this.query(
|
|
1200
|
+
return this.query(
|
|
1201
|
+
"getRecentEvents",
|
|
1202
|
+
() => this.sdk.GetRecentEvents(...args)
|
|
1203
|
+
);
|
|
1184
1204
|
}
|
|
1185
1205
|
// Account queries
|
|
1186
1206
|
/** Fetch a single account by address. */
|
|
@@ -1194,28 +1214,46 @@ var SlotsClient = class {
|
|
|
1194
1214
|
// Individual event queries
|
|
1195
1215
|
/** Fetch released events with optional filters. */
|
|
1196
1216
|
getReleasedEvents(...args) {
|
|
1197
|
-
return this.query(
|
|
1217
|
+
return this.query(
|
|
1218
|
+
"getReleasedEvents",
|
|
1219
|
+
() => this.sdk.GetReleasedEvents(...args)
|
|
1220
|
+
);
|
|
1198
1221
|
}
|
|
1199
1222
|
/** Fetch liquidated events with optional filters. */
|
|
1200
1223
|
getLiquidatedEvents(...args) {
|
|
1201
|
-
return this.query(
|
|
1224
|
+
return this.query(
|
|
1225
|
+
"getLiquidatedEvents",
|
|
1226
|
+
() => this.sdk.GetLiquidatedEvents(...args)
|
|
1227
|
+
);
|
|
1202
1228
|
}
|
|
1203
1229
|
/** Fetch deposited events with optional filters. */
|
|
1204
1230
|
getDepositedEvents(...args) {
|
|
1205
|
-
return this.query(
|
|
1231
|
+
return this.query(
|
|
1232
|
+
"getDepositedEvents",
|
|
1233
|
+
() => this.sdk.GetDepositedEvents(...args)
|
|
1234
|
+
);
|
|
1206
1235
|
}
|
|
1207
1236
|
/** Fetch withdrawn events with optional filters. */
|
|
1208
1237
|
getWithdrawnEvents(...args) {
|
|
1209
|
-
return this.query(
|
|
1238
|
+
return this.query(
|
|
1239
|
+
"getWithdrawnEvents",
|
|
1240
|
+
() => this.sdk.GetWithdrawnEvents(...args)
|
|
1241
|
+
);
|
|
1210
1242
|
}
|
|
1211
1243
|
/** Fetch price-updated events with optional filters. */
|
|
1212
1244
|
getPriceUpdatedEvents(...args) {
|
|
1213
|
-
return this.query(
|
|
1245
|
+
return this.query(
|
|
1246
|
+
"getPriceUpdatedEvents",
|
|
1247
|
+
() => this.sdk.GetPriceUpdatedEvents(...args)
|
|
1248
|
+
);
|
|
1214
1249
|
}
|
|
1215
1250
|
// Meta
|
|
1216
1251
|
/** Fetch subgraph indexing metadata (latest block, indexing errors). */
|
|
1217
1252
|
getMeta() {
|
|
1218
|
-
return this.query(
|
|
1253
|
+
return this.query(
|
|
1254
|
+
"getMeta",
|
|
1255
|
+
() => this.gqlClient.request(META_QUERY)
|
|
1256
|
+
);
|
|
1219
1257
|
}
|
|
1220
1258
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1221
1259
|
// READ — On-chain (RPC)
|
|
@@ -1264,7 +1302,13 @@ var SlotsClient = class {
|
|
|
1264
1302
|
address: this.factory,
|
|
1265
1303
|
abi: slotFactoryAbi,
|
|
1266
1304
|
functionName: "createSlots",
|
|
1267
|
-
args: [
|
|
1305
|
+
args: [
|
|
1306
|
+
params.recipient,
|
|
1307
|
+
params.currency,
|
|
1308
|
+
params.config,
|
|
1309
|
+
params.initParams,
|
|
1310
|
+
params.count
|
|
1311
|
+
],
|
|
1268
1312
|
account: this.account,
|
|
1269
1313
|
chain: this.chain
|
|
1270
1314
|
});
|
|
@@ -1437,7 +1481,8 @@ var SlotsClient = class {
|
|
|
1437
1481
|
* @throws {SlotsError} If newBps is outside 0-10000, or the transaction fails.
|
|
1438
1482
|
*/
|
|
1439
1483
|
async setLiquidationBounty(slot, newBps) {
|
|
1440
|
-
if (newBps < 0n || newBps > 10000n)
|
|
1484
|
+
if (newBps < 0n || newBps > 10000n)
|
|
1485
|
+
throw new SlotsError("setLiquidationBounty", "newBps must be 0-10000");
|
|
1441
1486
|
return this.wallet.writeContract({
|
|
1442
1487
|
address: slot,
|
|
1443
1488
|
abi: slotAbi,
|
|
@@ -1458,7 +1503,8 @@ var SlotsClient = class {
|
|
|
1458
1503
|
* @throws {SlotsError} If calls array is empty, or the transaction fails.
|
|
1459
1504
|
*/
|
|
1460
1505
|
async multicall(slot, calls) {
|
|
1461
|
-
if (calls.length === 0)
|
|
1506
|
+
if (calls.length === 0)
|
|
1507
|
+
throw new SlotsError("multicall", "calls array must not be empty");
|
|
1462
1508
|
const data = calls.map(
|
|
1463
1509
|
(call) => encodeFunctionData({
|
|
1464
1510
|
abi: slotAbi,
|
|
@@ -1578,5 +1624,5 @@ function createSlotsClient(config) {
|
|
|
1578
1624
|
}
|
|
1579
1625
|
|
|
1580
1626
|
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 };
|
|
1581
|
-
//# sourceMappingURL=chunk-
|
|
1582
|
-
//# sourceMappingURL=chunk-
|
|
1627
|
+
//# sourceMappingURL=chunk-VQ5PSOCE.js.map
|
|
1628
|
+
//# sourceMappingURL=chunk-VQ5PSOCE.js.map
|