@shelby-protocol/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +19 -10
- package/dist/browser/index.mjs +4200 -146
- package/dist/core/aptos-explorer.mjs +46 -5
- package/dist/core/blobs.mjs +12 -4
- package/dist/core/chunk.mjs +58 -9
- package/dist/core/clients/ShelbyBlobClient.d.ts +155 -83
- package/dist/core/clients/ShelbyBlobClient.mjs +1286 -17
- package/dist/core/clients/ShelbyClient.d.ts +39 -6
- package/dist/core/clients/ShelbyClient.mjs +3233 -23
- package/dist/core/clients/ShelbyClientConfig.d.ts +9 -1
- package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
- package/dist/core/clients/ShelbyMetadataClient.d.ts +20 -6
- package/dist/core/clients/ShelbyMetadataClient.mjs +388 -6
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -7
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +894 -13
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +310 -8
- package/dist/core/clients/ShelbyRPCClient.d.ts +117 -25
- package/dist/core/clients/ShelbyRPCClient.mjs +1245 -12
- package/dist/core/clients/index.d.ts +4 -2
- package/dist/core/clients/index.mjs +3802 -39
- package/dist/core/clients/utils.mjs +65 -6
- package/dist/core/commitments.d.ts +12 -1
- package/dist/core/commitments.mjs +277 -11
- package/dist/core/constants.d.ts +3 -3
- package/dist/core/constants.mjs +39 -16
- package/dist/core/erasure/clay-codes.mjs +129 -4
- package/dist/core/erasure/constants.d.ts +16 -1
- package/dist/core/erasure/constants.mjs +48 -11
- package/dist/core/erasure/default.mjs +191 -9
- package/dist/core/erasure/index.d.ts +1 -1
- package/dist/core/erasure/index.mjs +281 -24
- package/dist/core/erasure/reed-solomon.mjs +68 -4
- package/dist/core/erasure/utils.mjs +0 -2
- package/dist/core/errors.d.ts +20 -1
- package/dist/core/errors.mjs +58 -8
- package/dist/core/index.d.ts +9 -9
- package/dist/core/index.mjs +4194 -146
- package/dist/core/layout.mjs +37 -5
- package/dist/core/networks.mjs +10 -5
- package/dist/core/operations/generated/sdk.d.ts +807 -42
- package/dist/core/operations/generated/sdk.mjs +267 -18
- package/dist/core/operations/index.d.ts +1 -1
- package/dist/core/operations/index.mjs +368 -24
- package/dist/core/promises.mjs +4 -4
- package/dist/core/rpc-responses.d.ts +1 -57
- package/dist/core/rpc-responses.mjs +14 -15
- package/dist/core/shelby-explorer.mjs +31 -6
- package/dist/core/sp/chunk_proof.d.ts +23 -0
- package/dist/core/sp/chunk_proof.mjs +113 -0
- package/dist/core/sp/index.d.ts +3 -0
- package/dist/core/sp/index.mjs +402 -0
- package/dist/core/sp/sp_write_client.d.ts +53 -0
- package/dist/core/sp/sp_write_client.mjs +302 -0
- package/dist/core/strings.mjs +0 -2
- package/dist/core/types/blobs.d.ts +24 -5
- package/dist/core/types/blobs.mjs +24 -1
- package/dist/core/types/index.d.ts +2 -2
- package/dist/core/types/index.mjs +275 -10
- package/dist/core/types/payments.d.ts +6 -6
- package/dist/core/types/payments.mjs +230 -5
- package/dist/core/types/placement_groups.mjs +0 -1
- package/dist/core/types/storage_providers.d.ts +32 -6
- package/dist/core/types/storage_providers.mjs +22 -1
- package/dist/core/utils.mjs +94 -8
- package/dist/gen/rpc_server_pb.d.ts +295 -0
- package/dist/gen/rpc_server_pb.mjs +28 -0
- package/dist/node/clients/ShelbyNodeClient.d.ts +2 -0
- package/dist/node/clients/ShelbyNodeClient.mjs +3237 -24
- package/dist/node/clients/index.d.ts +2 -0
- package/dist/node/clients/index.mjs +3236 -26
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.mjs +4217 -153
- package/dist/node/parallel/commitment_worker.d.ts +9 -0
- package/dist/node/parallel/commitment_worker.mjs +85 -0
- package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
- package/dist/node/parallel/commitment_worker_pool.mjs +339 -0
- package/dist/node/parallel/coverage_flush.d.ts +16 -0
- package/dist/node/parallel/coverage_flush.mjs +43 -0
- package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
- package/dist/node/parallel/default_commitment_worker_pool.mjs +355 -0
- package/dist/node/parallel/index.d.ts +12 -0
- package/dist/node/parallel/index.mjs +631 -0
- package/dist/node/parallel/parallel_commitments.d.ts +32 -0
- package/dist/node/parallel/parallel_commitments.mjs +614 -0
- package/dist/node/parallel/worker_pool.d.ts +74 -0
- package/dist/node/parallel/worker_pool.mjs +301 -0
- package/dist/node/testUtil.mjs +8 -4
- package/package.json +16 -5
- package/dist/chunk-3NRBHSMQ.mjs +0 -12
- package/dist/chunk-5BVSWXQJ.mjs +0 -801
- package/dist/chunk-6FJNAUU5.mjs +0 -278
- package/dist/chunk-6XSZRDLJ.mjs +0 -375
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-A4IG6GSE.mjs +0 -21
- package/dist/chunk-AD2G3QYD.mjs +0 -0
- package/dist/chunk-AUQDI5BS.mjs +0 -43
- package/dist/chunk-AY3HBWXA.mjs +0 -51
- package/dist/chunk-BDSW5PHM.mjs +0 -37
- package/dist/chunk-C6RQ3AEU.mjs +0 -51
- package/dist/chunk-CQ6QPIZK.mjs +0 -37
- package/dist/chunk-D6GQHO6G.mjs +0 -15
- package/dist/chunk-EM67QTMR.mjs +0 -0
- package/dist/chunk-I6NG5GNL.mjs +0 -8
- package/dist/chunk-JTXYKO3U.mjs +0 -38
- package/dist/chunk-KG2TMLEV.mjs +0 -207
- package/dist/chunk-M3CP5TFP.mjs +0 -39
- package/dist/chunk-M7W43K2Q.mjs +0 -505
- package/dist/chunk-MB7C7VQF.mjs +0 -0
- package/dist/chunk-MNCQBEMS.mjs +0 -55
- package/dist/chunk-MQUVYMNQ.mjs +0 -0
- package/dist/chunk-NEO7Z3ZQ.mjs +0 -49
- package/dist/chunk-NHWWORCH.mjs +0 -72
- package/dist/chunk-OEK24ON7.mjs +0 -135
- package/dist/chunk-QQ57OGQ2.mjs +0 -0
- package/dist/chunk-RNNJXTX2.mjs +0 -154
- package/dist/chunk-S6Q4OG7H.mjs +0 -83
- package/dist/chunk-TET3DJEO.mjs +0 -199
- package/dist/chunk-UEZNZBJO.mjs +0 -104
- package/dist/chunk-V46D5NBW.mjs +0 -11
- package/dist/chunk-V4B3GAMQ.mjs +0 -42
- package/dist/chunk-WFWRBNTW.mjs +0 -412
- package/dist/chunk-WTICJPDB.mjs +0 -0
- package/dist/chunk-XNEIWM4O.mjs +0 -0
- package/dist/chunk-Z4FZ7W6L.mjs +0 -39
- package/dist/chunk-Z7RFCADT.mjs +0 -0
- package/dist/chunk-ZHXCVRZX.mjs +0 -0
|
@@ -1,11 +1,313 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// src/core/operations/index.ts
|
|
2
|
+
import { Network as Network2 } from "@aptos-labs/ts-sdk";
|
|
3
|
+
import { GraphQLClient } from "graphql-request";
|
|
4
|
+
|
|
5
|
+
// src/core/clients/utils.ts
|
|
6
|
+
import { AptosConfig } from "@aptos-labs/ts-sdk";
|
|
7
|
+
|
|
8
|
+
// src/core/constants.ts
|
|
9
|
+
import { Network } from "@aptos-labs/ts-sdk";
|
|
10
|
+
var NetworkToShelbyRPCBaseUrl = {
|
|
11
|
+
[Network.SHELBYNET]: "https://shelby.shelbynet.shelby.xyz/shelby",
|
|
12
|
+
[Network.NETNA]: void 0,
|
|
13
|
+
[Network.DEVNET]: void 0,
|
|
14
|
+
[Network.TESTNET]: "https://api.testnet.shelby.xyz/shelby",
|
|
15
|
+
[Network.MAINNET]: void 0,
|
|
16
|
+
[Network.LOCAL]: "http://localhost:9090",
|
|
17
|
+
[Network.CUSTOM]: void 0
|
|
18
|
+
};
|
|
19
|
+
var NetworkToShelbyBlobIndexerBaseUrl = {
|
|
20
|
+
[Network.SHELBYNET]: "https://api.shelbynet.aptoslabs.com/nocode/v1/public/alias/shelby/shelbynet/v1/graphql",
|
|
21
|
+
[Network.NETNA]: void 0,
|
|
22
|
+
[Network.DEVNET]: void 0,
|
|
23
|
+
[Network.TESTNET]: "https://api.testnet.aptoslabs.com/nocode/v1/public/alias/shelby/testnet/v1/graphql",
|
|
24
|
+
[Network.MAINNET]: void 0,
|
|
25
|
+
[Network.LOCAL]: "http://localhost:8091/v1/graphql",
|
|
26
|
+
[Network.CUSTOM]: void 0
|
|
27
|
+
};
|
|
28
|
+
var NetworkToGasStationBaseUrl = {
|
|
29
|
+
[Network.SHELBYNET]: "https://api.shelbynet.shelby.xyz/gs/v1",
|
|
30
|
+
[Network.NETNA]: void 0,
|
|
31
|
+
[Network.DEVNET]: void 0,
|
|
32
|
+
[Network.TESTNET]: "https://api.testnet.shelby.xyz/gs/v1",
|
|
33
|
+
[Network.MAINNET]: void 0,
|
|
34
|
+
[Network.LOCAL]: void 0,
|
|
35
|
+
[Network.CUSTOM]: void 0
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/core/clients/utils.ts
|
|
39
|
+
var getAptosConfig = (config) => {
|
|
40
|
+
const baseFaucetConfig = config.faucet?.authToken ? { AUTH_TOKEN: config.faucet.authToken } : void 0;
|
|
41
|
+
if (config.aptos) {
|
|
42
|
+
return new AptosConfig({
|
|
43
|
+
// Spread user's aptos config first
|
|
44
|
+
...config.aptos,
|
|
45
|
+
// Network from top-level is authoritative - cannot be overridden
|
|
46
|
+
network: config.network,
|
|
47
|
+
// Merge clientConfig with API_KEY default
|
|
48
|
+
clientConfig: {
|
|
49
|
+
API_KEY: config.apiKey,
|
|
50
|
+
...config.aptos.clientConfig
|
|
51
|
+
},
|
|
52
|
+
// Merge faucetConfig: aptos config first, then base authToken (authoritative)
|
|
53
|
+
faucetConfig: {
|
|
54
|
+
...config.aptos.faucetConfig,
|
|
55
|
+
...baseFaucetConfig
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return new AptosConfig({
|
|
60
|
+
network: config.network,
|
|
61
|
+
clientConfig: {
|
|
62
|
+
API_KEY: config.apiKey
|
|
63
|
+
},
|
|
64
|
+
faucetConfig: baseFaucetConfig
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/core/operations/generated/sdk.ts
|
|
69
|
+
import gql from "graphql-tag";
|
|
70
|
+
var GetBlobsDocument = gql`
|
|
71
|
+
query getBlobs($where: blobs_bool_exp, $orderBy: [blobs_order_by!], $limit: Int, $offset: Int) {
|
|
72
|
+
blobs(where: $where, order_by: $orderBy, limit: $limit, offset: $offset) {
|
|
73
|
+
uid
|
|
74
|
+
object_name
|
|
75
|
+
owner
|
|
76
|
+
blob_commitment
|
|
77
|
+
created_at
|
|
78
|
+
expires_at
|
|
79
|
+
updated_at
|
|
80
|
+
num_chunksets
|
|
81
|
+
size
|
|
82
|
+
slice_address
|
|
83
|
+
placement_group
|
|
84
|
+
is_persisted
|
|
85
|
+
is_committed
|
|
86
|
+
is_deleted
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
var GetBlobActivitiesDocument = gql`
|
|
91
|
+
query getBlobActivities($where: blob_activities_bool_exp, $orderBy: [blob_activities_order_by!], $limit: Int, $offset: Int) {
|
|
92
|
+
blob_activities(
|
|
93
|
+
where: $where
|
|
94
|
+
order_by: $orderBy
|
|
95
|
+
limit: $limit
|
|
96
|
+
offset: $offset
|
|
97
|
+
) {
|
|
98
|
+
uid
|
|
99
|
+
object_name
|
|
100
|
+
event_index
|
|
101
|
+
event_type
|
|
102
|
+
transaction_hash
|
|
103
|
+
transaction_version
|
|
104
|
+
timestamp
|
|
105
|
+
owner
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
var GetBlobsCountDocument = gql`
|
|
110
|
+
query getBlobsCount($where: blobs_bool_exp) {
|
|
111
|
+
blobs_aggregate(where: $where) {
|
|
112
|
+
aggregate {
|
|
113
|
+
count
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
var GetBlobActivitiesCountDocument = gql`
|
|
119
|
+
query getBlobActivitiesCount($where: blob_activities_bool_exp) {
|
|
120
|
+
blob_activities_aggregate(where: $where) {
|
|
121
|
+
aggregate {
|
|
122
|
+
count
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
var GetTotalBlobsSizeDocument = gql`
|
|
128
|
+
query getTotalBlobsSize($where: blobs_bool_exp) {
|
|
129
|
+
blobs_aggregate(where: $where) {
|
|
130
|
+
aggregate {
|
|
131
|
+
sum {
|
|
132
|
+
size
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
var GetPlacementGroupSlotsDocument = gql`
|
|
139
|
+
query getPlacementGroupSlots($where: placement_group_slots_bool_exp, $orderBy: [placement_group_slots_order_by!], $limit: Int, $offset: Int) {
|
|
140
|
+
placement_group_slots(
|
|
141
|
+
where: $where
|
|
142
|
+
order_by: $orderBy
|
|
143
|
+
limit: $limit
|
|
144
|
+
offset: $offset
|
|
145
|
+
) {
|
|
146
|
+
placement_group
|
|
147
|
+
slot_index
|
|
148
|
+
storage_provider
|
|
149
|
+
status
|
|
150
|
+
updated_at
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
154
|
+
var GetPlacementGroupSlotsCountDocument = gql`
|
|
155
|
+
query getPlacementGroupSlotsCount($where: placement_group_slots_bool_exp) {
|
|
156
|
+
placement_group_slots_aggregate(where: $where) {
|
|
157
|
+
aggregate {
|
|
158
|
+
count
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
var GetProcessorStatusDocument = gql`
|
|
164
|
+
query getProcessorStatus {
|
|
165
|
+
processor_status {
|
|
166
|
+
last_success_version
|
|
167
|
+
last_transaction_timestamp
|
|
168
|
+
last_updated
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
173
|
+
function getSdk(client, withWrapper = defaultWrapper) {
|
|
174
|
+
return {
|
|
175
|
+
getBlobs(variables, requestHeaders, signal) {
|
|
176
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobs", "query", variables);
|
|
177
|
+
},
|
|
178
|
+
getBlobActivities(variables, requestHeaders, signal) {
|
|
179
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivities", "query", variables);
|
|
180
|
+
},
|
|
181
|
+
getBlobsCount(variables, requestHeaders, signal) {
|
|
182
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobsCount", "query", variables);
|
|
183
|
+
},
|
|
184
|
+
getBlobActivitiesCount(variables, requestHeaders, signal) {
|
|
185
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivitiesCount", "query", variables);
|
|
186
|
+
},
|
|
187
|
+
getTotalBlobsSize(variables, requestHeaders, signal) {
|
|
188
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetTotalBlobsSizeDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getTotalBlobsSize", "query", variables);
|
|
189
|
+
},
|
|
190
|
+
getPlacementGroupSlots(variables, requestHeaders, signal) {
|
|
191
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlots", "query", variables);
|
|
192
|
+
},
|
|
193
|
+
getPlacementGroupSlotsCount(variables, requestHeaders, signal) {
|
|
194
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlotsCount", "query", variables);
|
|
195
|
+
},
|
|
196
|
+
getProcessorStatus(variables, requestHeaders, signal) {
|
|
197
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetProcessorStatusDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getProcessorStatus", "query", variables);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/core/operations/index.ts
|
|
203
|
+
function createShelbyIndexerClient(baseUrl, options) {
|
|
204
|
+
const graphqlClient = new GraphQLClient(baseUrl, options);
|
|
205
|
+
return getSdk(graphqlClient);
|
|
206
|
+
}
|
|
207
|
+
function getShelbyIndexerClient(config) {
|
|
208
|
+
const aptosConfig = getAptosConfig(config);
|
|
209
|
+
let { apiKey: indexerApiKey, baseUrl } = config.indexer ?? {};
|
|
210
|
+
if (!baseUrl) {
|
|
211
|
+
switch (aptosConfig?.network) {
|
|
212
|
+
// TODO: Add endpoints for core networks
|
|
213
|
+
case Network2.MAINNET:
|
|
214
|
+
case Network2.TESTNET:
|
|
215
|
+
case Network2.DEVNET:
|
|
216
|
+
case Network2.SHELBYNET:
|
|
217
|
+
case Network2.LOCAL:
|
|
218
|
+
baseUrl = NetworkToShelbyBlobIndexerBaseUrl[aptosConfig.network];
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (baseUrl === void 0) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
"The ShelbyClientConfig does not support the Shelby indexer. Please configure the endpoint in the ShelbyClientConfig.indexer.endpoint or provide a supported Aptos network."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
const apiKey = indexerApiKey ?? config.apiKey;
|
|
228
|
+
return createShelbyIndexerClient(baseUrl, {
|
|
229
|
+
headers: {
|
|
230
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
231
|
+
"x-aptos-client": "shelby-ts-sdk"
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/core/clients/ShelbyPlacementGroupClient.ts
|
|
237
|
+
var ShelbyPlacementGroupClient = class {
|
|
238
|
+
indexer;
|
|
239
|
+
/**
|
|
240
|
+
* Creates a new ShelbyPlacementGroupClient.
|
|
241
|
+
*
|
|
242
|
+
* @param config - The client configuration object.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const pgClient = new ShelbyPlacementGroupClient({
|
|
247
|
+
* network: Network.SHELBYNET,
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
constructor(config) {
|
|
252
|
+
this.indexer = getShelbyIndexerClient(config);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Retrieves placement group slots from the indexer.
|
|
256
|
+
*
|
|
257
|
+
* @param params.where (optional) - The where clause to filter slots by.
|
|
258
|
+
* @param params.pagination (optional) - The pagination options.
|
|
259
|
+
* @param params.orderBy (optional) - The order by clause to sort slots by.
|
|
260
|
+
* @returns The placement group slots that match the filter.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Get all active slots
|
|
265
|
+
* const slots = await client.getPlacementGroupSlots({
|
|
266
|
+
* where: { status: { _eq: "active" } },
|
|
267
|
+
* });
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
async getPlacementGroupSlots(params) {
|
|
271
|
+
const { limit, offset } = params.pagination ?? {};
|
|
272
|
+
const { orderBy, where } = params;
|
|
273
|
+
const { placement_group_slots } = await this.indexer.getPlacementGroupSlots(
|
|
274
|
+
{
|
|
275
|
+
where,
|
|
276
|
+
limit,
|
|
277
|
+
offset,
|
|
278
|
+
orderBy
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
return placement_group_slots.map(
|
|
282
|
+
(slot) => ({
|
|
283
|
+
placementGroup: slot.placement_group,
|
|
284
|
+
slotIndex: Number(slot.slot_index),
|
|
285
|
+
storageProvider: slot.storage_provider,
|
|
286
|
+
status: slot.status,
|
|
287
|
+
updatedAt: Number(slot.updated_at)
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Retrieves the total count of placement group slots from the indexer.
|
|
293
|
+
*
|
|
294
|
+
* @param params.where (optional) - The where clause to filter slots by.
|
|
295
|
+
* @returns The count of placement group slots that match the filter.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Get count of active slots
|
|
300
|
+
* const count = await client.getPlacementGroupSlotsCount({
|
|
301
|
+
* where: { status: { _eq: "active" } },
|
|
302
|
+
* });
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
async getPlacementGroupSlotsCount(params) {
|
|
306
|
+
const { where } = params;
|
|
307
|
+
const { placement_group_slots_aggregate } = await this.indexer.getPlacementGroupSlotsCount({ where });
|
|
308
|
+
return placement_group_slots_aggregate?.aggregate?.count ?? 0;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
9
311
|
export {
|
|
10
312
|
ShelbyPlacementGroupClient
|
|
11
313
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { AccountAddressInput } from '@aptos-labs/ts-sdk';
|
|
1
|
+
import { Account, AccountAddressInput } from '@aptos-labs/ts-sdk';
|
|
2
2
|
import { ShelbyBlob } from '../blobs.js';
|
|
3
|
-
import {
|
|
3
|
+
import { BlobCommitments } from '../commitments.js';
|
|
4
4
|
import { ShelbyIndexerClient } from '../operations/index.js';
|
|
5
|
+
import { ChallengeResponse } from '../rpc-responses.js';
|
|
6
|
+
import { StorageProviderAck } from '../types/blobs.js';
|
|
5
7
|
import { SenderBuiltMicropayment } from '../types/payments.js';
|
|
6
8
|
import { ShelbyRPCConfig, ShelbyClientConfig } from './ShelbyClientConfig.js';
|
|
9
|
+
import '../layout.js';
|
|
7
10
|
import 'zod';
|
|
8
11
|
import '../../clay-codes-DdXABBDx.js';
|
|
9
12
|
import '@shelby-protocol/clay-codes';
|
|
@@ -12,14 +15,57 @@ import '../operations/generated/sdk.js';
|
|
|
12
15
|
import 'graphql';
|
|
13
16
|
import '../networks.js';
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Auth scheme identifier sent in X-Shelby-Auth-Scheme.
|
|
20
|
+
* - "ed25519": standard Ed25519 account (default when header is absent)
|
|
21
|
+
* - "derivable": Derived Abstracted Account (Solana, Ethereum, etc.)
|
|
22
|
+
*/
|
|
23
|
+
type AuthScheme = "ed25519" | "derivable";
|
|
24
|
+
interface BlobOwnerAuthBase {
|
|
25
|
+
challenge: string;
|
|
26
|
+
signature: Uint8Array;
|
|
27
|
+
publicKey: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
interface Ed25519BlobOwnerAuth extends BlobOwnerAuthBase {
|
|
30
|
+
authScheme?: "ed25519";
|
|
31
|
+
}
|
|
32
|
+
interface DerivableBlobOwnerAuth extends BlobOwnerAuthBase {
|
|
33
|
+
authScheme: "derivable";
|
|
34
|
+
/** External identity (e.g. Solana base58 pubkey). */
|
|
35
|
+
identity: string;
|
|
36
|
+
/** dApp domain used during key derivation. */
|
|
37
|
+
domain: string;
|
|
38
|
+
/** On-chain authentication function (e.g. "0x1::solana_derivable_account::authenticate"). */
|
|
39
|
+
authFunction: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Authentication credentials for blob owner operations.
|
|
43
|
+
*
|
|
44
|
+
* Ed25519 (default): only the base fields are needed.
|
|
45
|
+
* Derivable: requires identity, domain, and authFunction.
|
|
46
|
+
*/
|
|
47
|
+
type BlobOwnerAuth = Ed25519BlobOwnerAuth | DerivableBlobOwnerAuth;
|
|
15
48
|
type BlobDataSource = Uint8Array | ReadableStream<Uint8Array>;
|
|
16
|
-
type
|
|
17
|
-
phase: "uploading"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
type PutBlobChunksetsProgress = {
|
|
50
|
+
phase: "uploading";
|
|
51
|
+
chunksetIdx: number;
|
|
52
|
+
totalChunksets: number;
|
|
53
|
+
chunksetBytes: number;
|
|
21
54
|
uploadedBytes: number;
|
|
22
55
|
totalBytes: number;
|
|
56
|
+
acksReceived?: number;
|
|
57
|
+
/** SP blob acknowledgements from this chunkset (if any) */
|
|
58
|
+
spAcks?: StorageProviderAck[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Result of putBlobChunksets operation.
|
|
62
|
+
*/
|
|
63
|
+
type PutBlobChunksetsResult = {
|
|
64
|
+
/**
|
|
65
|
+
* Aggregated SP blob acknowledgements collected across all chunksets.
|
|
66
|
+
* Deduplicated by slot (latest signature wins if an SP acks multiple times).
|
|
67
|
+
*/
|
|
68
|
+
spAcks: StorageProviderAck[];
|
|
23
69
|
};
|
|
24
70
|
declare class ShelbyRPCClient {
|
|
25
71
|
#private;
|
|
@@ -33,6 +79,9 @@ declare class ShelbyRPCClient {
|
|
|
33
79
|
*
|
|
34
80
|
* @param config - The client configuration object.
|
|
35
81
|
* @param config.network - The Shelby network to use.
|
|
82
|
+
* @param options.signChallengeHandler - Optional override for challenge
|
|
83
|
+
* signing. When set, `putBlobChunksets` uses this instead of the built-in
|
|
84
|
+
* `signChallenge`. Intended for kit-level overrides (e.g. Solana DAA).
|
|
36
85
|
*
|
|
37
86
|
* @example
|
|
38
87
|
* ```typescript
|
|
@@ -42,36 +91,79 @@ declare class ShelbyRPCClient {
|
|
|
42
91
|
* });
|
|
43
92
|
* ```
|
|
44
93
|
*/
|
|
45
|
-
constructor(config: ShelbyClientConfig
|
|
94
|
+
constructor(config: ShelbyClientConfig, options?: {
|
|
95
|
+
signChallengeHandler?: (account: Account, challenge: string) => BlobOwnerAuth;
|
|
96
|
+
});
|
|
46
97
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* Uses multipart upload for efficient handling of large files.
|
|
98
|
+
* Request an authentication challenge for the given account.
|
|
99
|
+
* The challenge must be signed and included in subsequent authenticated requests.
|
|
50
100
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @
|
|
101
|
+
* @param account - The Aptos account address to authenticate as.
|
|
102
|
+
* @returns The challenge string and expiration timestamp.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const { challenge, expiresAt } = await client.getChallenge(account.accountAddress);
|
|
107
|
+
* const auth = client.signChallenge(account, challenge);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
getChallenge(account: AccountAddressInput): Promise<ChallengeResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Sign a challenge using the given account and return auth credentials.
|
|
113
|
+
*
|
|
114
|
+
* @param account - The Aptos account to sign with.
|
|
115
|
+
* @param challenge - The hex-encoded challenge string from getChallenge().
|
|
116
|
+
* @returns BlobOwnerAuth credentials for authenticated requests.
|
|
117
|
+
*/
|
|
118
|
+
signChallenge(account: Account, challenge: string): BlobOwnerAuth;
|
|
119
|
+
/**
|
|
120
|
+
* Uploads blob data to the Shelby RPC node using the v2 chunkset API.
|
|
121
|
+
* This method authenticates using challenge-response and uploads chunksets
|
|
122
|
+
* directly to storage providers via the RPC's worker pool.
|
|
123
|
+
*
|
|
124
|
+
* This method:
|
|
125
|
+
* - Sends raw chunkset data directly to the RPC for erasure encoding
|
|
126
|
+
* - Requires pre-computed blob commitments to generate inclusion proofs
|
|
127
|
+
* - Does not support resume (each chunkset is idempotent on the SP side)
|
|
128
|
+
*
|
|
129
|
+
* @param params.account - The Aptos Account (with signing capability) that owns the blob.
|
|
130
|
+
* @param params.uid - The blob's on-chain UID (from `BlobRegisteredEvent` at registration).
|
|
53
131
|
* @param params.blobData - The raw blob data as a Uint8Array or ReadableStream.
|
|
132
|
+
* @param params.commitments - Pre-computed blob commitments (from generateCommitments).
|
|
54
133
|
* @param params.totalBytes - Total byte length. Required for streams; optional for Uint8Array.
|
|
134
|
+
* @param params.chunksetConcurrency - Number of chunksets to upload in parallel. Defaults to 4.
|
|
135
|
+
* @param params.onProgress - Optional callback for upload progress.
|
|
136
|
+
* @param params.signal - Optional AbortSignal for cancellation. When aborted, in-flight
|
|
137
|
+
* HTTP requests are cancelled and an AbortError is thrown.
|
|
55
138
|
*
|
|
56
139
|
* @example
|
|
57
140
|
* ```typescript
|
|
58
|
-
*
|
|
141
|
+
* // First, generate commitments for the blob
|
|
142
|
+
* const commitments = await generateCommitments(provider, fileData);
|
|
59
143
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
144
|
+
* // Register the blob on chain, then read its UID from the register tx's
|
|
145
|
+
* // BlobRegisteredEvent (see ShelbyBlobClient.registeredBlobUids).
|
|
146
|
+
*
|
|
147
|
+
* // Upload using chunkset API
|
|
148
|
+
* await rpcClient.putBlobChunksets({
|
|
149
|
+
* account: myAccount,
|
|
150
|
+
* uid: blobUid,
|
|
151
|
+
* blobData: fileData,
|
|
152
|
+
* commitments,
|
|
153
|
+
* chunksetConcurrency: 8,
|
|
64
154
|
* });
|
|
65
155
|
* ```
|
|
66
156
|
*/
|
|
67
|
-
|
|
68
|
-
account:
|
|
69
|
-
|
|
157
|
+
putBlobChunksets(params: {
|
|
158
|
+
account: Account;
|
|
159
|
+
uid: bigint;
|
|
70
160
|
blobData: BlobDataSource;
|
|
71
|
-
|
|
161
|
+
commitments: BlobCommitments;
|
|
72
162
|
totalBytes?: number;
|
|
73
|
-
|
|
74
|
-
|
|
163
|
+
chunksetConcurrency?: number;
|
|
164
|
+
onProgress?: (progress: PutBlobChunksetsProgress) => void;
|
|
165
|
+
signal?: AbortSignal;
|
|
166
|
+
}): Promise<PutBlobChunksetsResult>;
|
|
75
167
|
/**
|
|
76
168
|
* Downloads a blob from the Shelby RPC node.
|
|
77
169
|
* Returns a streaming response with validation to ensure data integrity.
|
|
@@ -122,4 +214,4 @@ declare class ShelbyRPCClient {
|
|
|
122
214
|
}): Promise<ShelbyBlob>;
|
|
123
215
|
}
|
|
124
216
|
|
|
125
|
-
export { type BlobDataSource, type
|
|
217
|
+
export { type AuthScheme, type BlobDataSource, type BlobOwnerAuth, type DerivableBlobOwnerAuth, type Ed25519BlobOwnerAuth, type PutBlobChunksetsProgress, type PutBlobChunksetsResult, ShelbyRPCClient };
|