@shelby-protocol/sdk 0.0.9 → 0.1.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 +13 -7
- package/dist/browser/index.mjs +70 -17
- package/dist/{chunk-HFGEQP5N.mjs → chunk-3ZL3FSNA.mjs} +4 -4
- package/dist/chunk-4MG4XGY4.mjs +91 -0
- package/dist/chunk-66GI734H.mjs +493 -0
- package/dist/chunk-AABBONAF.mjs +34 -0
- package/dist/{chunk-7UVMDCCR.mjs → chunk-AGRRYZWV.mjs} +213 -42
- package/dist/chunk-CQ6QPIZK.mjs +37 -0
- package/dist/{chunk-QFWQ7FIC.mjs → chunk-DI2K6OUG.mjs} +1 -1
- package/dist/{chunk-SEXQTDX6.mjs → chunk-FLLOQZVD.mjs} +4 -0
- package/dist/chunk-IE6LYVIA.mjs +26 -0
- package/dist/{chunk-WJKSPJSS.mjs → chunk-KJ24NKPH.mjs} +46 -0
- package/dist/{chunk-ZPW742E7.mjs → chunk-LZSIZJYR.mjs} +3 -1
- package/dist/chunk-MSCUDBMH.mjs +83 -0
- package/dist/{chunk-CPNZAQVY.mjs → chunk-OMZOR2ZF.mjs} +2 -2
- package/dist/chunk-QQ57OGQ2.mjs +0 -0
- package/dist/{chunk-XWAPNLU6.mjs → chunk-RLRI2533.mjs} +4 -2
- package/dist/{chunk-NLPIHQ7K.mjs → chunk-UCDAABAS.mjs} +1 -1
- package/dist/{chunk-GY5DCVVL.mjs → chunk-W5NRGZEP.mjs} +1 -1
- package/dist/{chunk-BTHSKDJR.mjs → chunk-W6YL46DT.mjs} +22 -9
- package/dist/{chunk-WBFEX7OM.mjs → chunk-YZXIPUVQ.mjs} +30 -6
- package/dist/{chunk-5I3MBJGN.mjs → chunk-ZAM2EUVN.mjs} +162 -33
- package/dist/core/chunk.mjs +1 -1
- package/dist/core/clients/ShelbyBlobClient.d.ts +160 -11
- package/dist/core/clients/ShelbyBlobClient.mjs +11 -9
- package/dist/core/clients/ShelbyClient.d.ts +14 -3
- package/dist/core/clients/ShelbyClient.mjs +14 -12
- package/dist/core/clients/ShelbyClientConfig.d.ts +7 -2
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +349 -0
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +16 -0
- package/dist/core/clients/ShelbyPlacementGroupClient.d.ts +73 -0
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +11 -0
- package/dist/core/clients/ShelbyRPCClient.d.ts +28 -4
- package/dist/core/clients/ShelbyRPCClient.mjs +9 -7
- package/dist/core/clients/index.d.ts +7 -3
- package/dist/core/clients/index.mjs +29 -13
- package/dist/core/clients/utils.d.ts +54 -0
- package/dist/core/clients/utils.mjs +1 -1
- package/dist/core/commitments.d.ts +5 -1
- package/dist/core/commitments.mjs +4 -2
- package/dist/core/constants.d.ts +4 -1
- package/dist/core/constants.mjs +3 -1
- package/dist/core/erasure/clay-codes.mjs +2 -2
- package/dist/core/erasure/constants.d.ts +5 -1
- package/dist/core/erasure/constants.mjs +3 -1
- package/dist/core/erasure/default.mjs +3 -3
- package/dist/core/erasure/index.d.ts +1 -1
- package/dist/core/erasure/index.mjs +5 -3
- package/dist/core/errors.d.ts +58 -0
- package/dist/core/errors.mjs +15 -0
- package/dist/core/index.d.ts +13 -7
- package/dist/core/index.mjs +70 -17
- package/dist/core/layout.mjs +2 -2
- package/dist/core/operations/generated/sdk.d.ts +207 -17
- package/dist/core/operations/generated/sdk.mjs +7 -1
- package/dist/core/operations/generated/types.d.ts +908 -0
- package/dist/core/operations/generated/types.mjs +63 -0
- package/dist/core/operations/index.d.ts +9 -3
- package/dist/core/operations/index.mjs +10 -4
- package/dist/core/rpc-responses.d.ts +69 -0
- package/dist/core/rpc-responses.mjs +15 -0
- package/dist/core/types/blobs.d.ts +7 -3
- package/dist/core/types/index.d.ts +3 -1
- package/dist/core/types/index.mjs +12 -2
- package/dist/core/types/payments.d.ts +94 -0
- package/dist/core/types/payments.mjs +9 -0
- package/dist/core/types/placement_groups.d.ts +30 -1
- package/dist/core/types/placement_groups.mjs +1 -0
- package/dist/core/types/storage_providers.d.ts +32 -2
- package/dist/node/clients/ShelbyMetadataClient.mjs +3 -3
- package/dist/node/clients/ShelbyNodeClient.d.ts +4 -3
- package/dist/node/clients/ShelbyNodeClient.mjs +15 -13
- package/dist/node/clients/index.d.ts +4 -3
- package/dist/node/clients/index.mjs +16 -14
- package/dist/node/index.d.ts +13 -7
- package/dist/node/index.mjs +75 -22
- package/package.json +3 -2
- package/dist/chunk-RBFWGDMY.mjs +0 -30
- /package/dist/{chunk-DJJD2AXO.mjs → chunk-AD2G3QYD.mjs} +0 -0
- /package/dist/{chunk-MWDW4ROU.mjs → chunk-EM67QTMR.mjs} +0 -0
- /package/dist/{chunk-RNXGC54D.mjs → chunk-FGUK6IBA.mjs} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getShelbyIndexerClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3ZL3FSNA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getAptosConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AABBONAF.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createBlobKey
|
|
9
9
|
} from "./chunk-OTBLZL2S.mjs";
|
|
10
10
|
import {
|
|
11
11
|
expectedTotalChunksets
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RLRI2533.mjs";
|
|
13
13
|
import {
|
|
14
14
|
getBlobNameSuffix
|
|
15
15
|
} from "./chunk-4JZO2D7T.mjs";
|
|
@@ -19,30 +19,38 @@ import {
|
|
|
19
19
|
} from "./chunk-67F5YZ25.mjs";
|
|
20
20
|
import {
|
|
21
21
|
ERASURE_CODE_PARAMS
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LZSIZJYR.mjs";
|
|
23
23
|
import {
|
|
24
24
|
SHELBY_DEPLOYER
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FLLOQZVD.mjs";
|
|
26
26
|
|
|
27
27
|
// src/core/clients/ShelbyBlobClient.ts
|
|
28
28
|
import {
|
|
29
29
|
AccountAddress,
|
|
30
30
|
Aptos,
|
|
31
|
-
AptosConfig,
|
|
32
31
|
Hex,
|
|
33
|
-
MoveVector,
|
|
34
32
|
U32
|
|
35
33
|
} from "@aptos-labs/ts-sdk";
|
|
34
|
+
var MissingTransactionSubmitterError = class extends Error {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(
|
|
37
|
+
"USD sponsorship (usdSponsor) requires a transaction submitter to be configured. The sponsored transaction is a multi-agent transaction that must be co-signed by the sponsor. Configure a transaction submitter via aptos.pluginSettings.TRANSACTION_SUBMITTER that routes transactions to a service (like a gas station) capable of providing the sponsor's signature."
|
|
38
|
+
);
|
|
39
|
+
this.name = "MissingTransactionSubmitterError";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
37
43
|
aptos;
|
|
38
44
|
deployer;
|
|
39
45
|
indexer;
|
|
46
|
+
defaultOptions;
|
|
40
47
|
/**
|
|
41
48
|
* The ShelbyBlobClient is used to interact with the Shelby contract on the Aptos blockchain. This
|
|
42
49
|
* includes functions for registering blob commitments and retrieving blob metadata.
|
|
43
50
|
*
|
|
44
51
|
* @param config - The client configuration object.
|
|
45
52
|
* @param config.network - The Shelby network to use.
|
|
53
|
+
* @param defaultOptions - Optional default options for blob operations.
|
|
46
54
|
*
|
|
47
55
|
* @example
|
|
48
56
|
* ```typescript
|
|
@@ -55,20 +63,57 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
55
63
|
* },
|
|
56
64
|
* });
|
|
57
65
|
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // With default options for USD sponsorship
|
|
70
|
+
* const blobClient = new ShelbyBlobClient(
|
|
71
|
+
* {
|
|
72
|
+
* network: Network.SHELBYNET,
|
|
73
|
+
* aptos: {
|
|
74
|
+
* pluginSettings: {
|
|
75
|
+
* TRANSACTION_SUBMITTER: myGasStationSubmitter,
|
|
76
|
+
* },
|
|
77
|
+
* },
|
|
78
|
+
* },
|
|
79
|
+
* {
|
|
80
|
+
* usdSponsor: { feePayerAddress: sponsorAddress },
|
|
81
|
+
* }
|
|
82
|
+
* );
|
|
83
|
+
* ```
|
|
58
84
|
*/
|
|
59
|
-
constructor(config) {
|
|
60
|
-
|
|
61
|
-
const aptosConfig = new AptosConfig({
|
|
62
|
-
...baseAptosConfig,
|
|
63
|
-
clientConfig: {
|
|
64
|
-
...baseAptosConfig.clientConfig,
|
|
65
|
-
// Only use top-level apiKey if no API_KEY is already provided in Aptos settings
|
|
66
|
-
API_KEY: baseAptosConfig.clientConfig?.API_KEY ?? config.apiKey
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
this.aptos = new Aptos(aptosConfig);
|
|
85
|
+
constructor(config, defaultOptions) {
|
|
86
|
+
this.aptos = new Aptos(getAptosConfig(config));
|
|
70
87
|
this.deployer = config.deployer ?? AccountAddress.fromString(SHELBY_DEPLOYER);
|
|
71
88
|
this.indexer = getShelbyIndexerClient(config);
|
|
89
|
+
this.defaultOptions = defaultOptions ?? {};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Merges method-level options with default options, giving precedence to method-level values.
|
|
93
|
+
*/
|
|
94
|
+
mergeOptions(options) {
|
|
95
|
+
return {
|
|
96
|
+
build: options?.build ?? this.defaultOptions.build,
|
|
97
|
+
submit: options?.submit ?? this.defaultOptions.submit,
|
|
98
|
+
usdSponsor: options?.usdSponsor ?? this.defaultOptions.usdSponsor,
|
|
99
|
+
chunksetSizeBytes: options?.chunksetSizeBytes ?? this.defaultOptions.chunksetSizeBytes
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validates that if USD sponsorship is requested, a transaction submitter is
|
|
104
|
+
* configured as well. Checks both the client-level and method-level transaction
|
|
105
|
+
* submitter configurations. Throws MissingTransactionSubmitterError if usdSponsor is
|
|
106
|
+
* provided without a transaction submitter.
|
|
107
|
+
*/
|
|
108
|
+
validateUsdSponsorConfig(usdSponsor, submit) {
|
|
109
|
+
if (!usdSponsor) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const hasClientSubmitter = this.aptos.config.getTransactionSubmitter();
|
|
113
|
+
const hasMethodSubmitter = submit?.transactionSubmitter !== void 0 && submit?.transactionSubmitter !== null;
|
|
114
|
+
if (!hasClientSubmitter && !hasMethodSubmitter) {
|
|
115
|
+
throw new MissingTransactionSubmitterError();
|
|
116
|
+
}
|
|
72
117
|
}
|
|
73
118
|
/**
|
|
74
119
|
* Retrieves the blob metadata from the blockchain. If it does not exist,
|
|
@@ -158,7 +203,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
158
203
|
const { where, ...rest } = params;
|
|
159
204
|
return this.getBlobs({
|
|
160
205
|
where: {
|
|
161
|
-
...where
|
|
206
|
+
...where,
|
|
162
207
|
owner: { _eq: AccountAddress.from(params.account).toString() }
|
|
163
208
|
},
|
|
164
209
|
pagination: rest.pagination,
|
|
@@ -184,7 +229,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
184
229
|
async getBlobs(params = {}) {
|
|
185
230
|
const { limit, offset } = params.pagination ?? {};
|
|
186
231
|
const { orderBy, where } = params;
|
|
187
|
-
const currentMicros = Date.now() * 1e3;
|
|
232
|
+
const currentMicros = String(Date.now() * 1e3);
|
|
188
233
|
const defaultActiveFilter = {
|
|
189
234
|
expires_at: { _gte: currentMicros },
|
|
190
235
|
is_deleted: { _eq: "0" }
|
|
@@ -212,7 +257,8 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
212
257
|
expirationMicros: Number(blob.expires_at),
|
|
213
258
|
creationMicros: Number(blob.created_at),
|
|
214
259
|
sliceAddress: AccountAddress.from(blob.slice_address),
|
|
215
|
-
isWritten: Boolean(Number(blob.is_written))
|
|
260
|
+
isWritten: Boolean(Number(blob.is_written)),
|
|
261
|
+
isDeleted: Boolean(Number(blob.is_deleted))
|
|
216
262
|
})
|
|
217
263
|
);
|
|
218
264
|
}
|
|
@@ -239,10 +285,12 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
239
285
|
),
|
|
240
286
|
type: activityTypeMapping[activity.event_type] ?? "unknown",
|
|
241
287
|
eventType: activity.event_type,
|
|
242
|
-
eventIndex: activity.event_index,
|
|
288
|
+
eventIndex: Number(activity.event_index),
|
|
243
289
|
transactionHash: activity.transaction_hash,
|
|
244
|
-
|
|
245
|
-
|
|
290
|
+
// Using Number here in JS is technically not okay because txn version can be
|
|
291
|
+
// as large as u64::MAX, but it should be fine for a long while.
|
|
292
|
+
transactionVersion: Number(activity.transaction_version),
|
|
293
|
+
timestamp: `${activity.timestamp}Z`
|
|
246
294
|
})
|
|
247
295
|
);
|
|
248
296
|
}
|
|
@@ -307,9 +355,11 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
307
355
|
* ```
|
|
308
356
|
*/
|
|
309
357
|
async registerBlob(params) {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
358
|
+
const options = this.mergeOptions(params.options);
|
|
359
|
+
this.validateUsdSponsorConfig(options.usdSponsor, options.submit);
|
|
360
|
+
const chunksetSize = options.chunksetSizeBytes ?? DEFAULT_CHUNKSET_SIZE_BYTES;
|
|
361
|
+
const buildArgs = {
|
|
362
|
+
...options.build,
|
|
313
363
|
data: _ShelbyBlobClient.createRegisterBlobPayload({
|
|
314
364
|
deployer: this.deployer,
|
|
315
365
|
account: params.account.accountAddress,
|
|
@@ -317,7 +367,90 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
317
367
|
blobSize: params.size,
|
|
318
368
|
blobMerkleRoot: params.blobMerkleRoot,
|
|
319
369
|
numChunksets: expectedTotalChunksets(params.size, chunksetSize),
|
|
320
|
-
expirationMicros: params.expirationMicros
|
|
370
|
+
expirationMicros: params.expirationMicros,
|
|
371
|
+
useSponsoredUsdVariant: options.usdSponsor !== void 0
|
|
372
|
+
}),
|
|
373
|
+
sender: params.account.accountAddress
|
|
374
|
+
};
|
|
375
|
+
const transaction = options.usdSponsor ? await this.aptos.transaction.build.multiAgent({
|
|
376
|
+
...buildArgs,
|
|
377
|
+
secondarySignerAddresses: [options.usdSponsor.feePayerAddress]
|
|
378
|
+
}) : await this.aptos.transaction.build.simple(buildArgs);
|
|
379
|
+
return {
|
|
380
|
+
transaction: await this.aptos.signAndSubmitTransaction({
|
|
381
|
+
signer: params.account,
|
|
382
|
+
transaction,
|
|
383
|
+
...options.submit
|
|
384
|
+
})
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Deletes a blob on the blockchain.
|
|
389
|
+
*
|
|
390
|
+
* @param params.account - The account that is signing and paying for the transaction.
|
|
391
|
+
* @param params.blobName - The name/path of the blob (e.g. "foo/bar.txt").
|
|
392
|
+
* @param params.options - Optional transaction building options.
|
|
393
|
+
*
|
|
394
|
+
* @returns An object containing the pending transaction.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
*
|
|
399
|
+
* const { transaction } = await client.deleteBlob({
|
|
400
|
+
* account: signer,
|
|
401
|
+
* blobName: "foo/bar.txt",
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
async deleteBlob(params) {
|
|
406
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
407
|
+
...params.options,
|
|
408
|
+
data: _ShelbyBlobClient.createDeleteBlobPayload({
|
|
409
|
+
deployer: this.deployer,
|
|
410
|
+
blobName: params.blobName
|
|
411
|
+
}),
|
|
412
|
+
sender: params.account.accountAddress
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
transaction: await this.aptos.signAndSubmitTransaction({
|
|
416
|
+
signer: params.account,
|
|
417
|
+
transaction
|
|
418
|
+
})
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Deletes multiple blobs on the blockchain in a single atomic transaction.
|
|
423
|
+
*
|
|
424
|
+
* **Note:** This function requires the `delete_multiple_blobs` entry function
|
|
425
|
+
* which will be deployed to the smart contract on 2026-02-04. Using this
|
|
426
|
+
* function before that date will result in a transaction failure.
|
|
427
|
+
*
|
|
428
|
+
* This operation is atomic: if any blob deletion fails (e.g., blob not found),
|
|
429
|
+
* the entire transaction fails and no blobs are deleted.
|
|
430
|
+
*
|
|
431
|
+
* @param params.account - The account that is signing and paying for the transaction.
|
|
432
|
+
* @param params.blobNames - Array of blob name suffixes without the account address prefix
|
|
433
|
+
* (e.g. ["foo/bar.txt", "baz.txt"], NOT ["0x1/foo/bar.txt"]). The account address
|
|
434
|
+
* prefix is automatically derived from the signer.
|
|
435
|
+
* @param params.options - Optional transaction building options.
|
|
436
|
+
*
|
|
437
|
+
* @returns An object containing the pending transaction.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
*
|
|
442
|
+
* const { transaction } = await client.deleteMultipleBlobs({
|
|
443
|
+
* account: signer,
|
|
444
|
+
* blobNames: ["foo/bar.txt", "baz.txt"],
|
|
445
|
+
* });
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
async deleteMultipleBlobs(params) {
|
|
449
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
450
|
+
...params.options,
|
|
451
|
+
data: _ShelbyBlobClient.createDeleteMultipleBlobsPayload({
|
|
452
|
+
deployer: this.deployer,
|
|
453
|
+
blobNames: params.blobNames
|
|
321
454
|
}),
|
|
322
455
|
sender: params.account.accountAddress
|
|
323
456
|
});
|
|
@@ -406,9 +539,11 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
406
539
|
* ```
|
|
407
540
|
*/
|
|
408
541
|
async batchRegisterBlobs(params) {
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
542
|
+
const options = this.mergeOptions(params.options);
|
|
543
|
+
this.validateUsdSponsorConfig(options.usdSponsor, options.submit);
|
|
544
|
+
const chunksetSize = options.chunksetSizeBytes ?? DEFAULT_CHUNKSET_SIZE_BYTES;
|
|
545
|
+
const buildArgs = {
|
|
546
|
+
...options.build,
|
|
412
547
|
sender: params.account.accountAddress,
|
|
413
548
|
data: _ShelbyBlobClient.createBatchRegisterBlobsPayload({
|
|
414
549
|
deployer: this.deployer,
|
|
@@ -419,13 +554,19 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
419
554
|
blobSize: blob.blobSize,
|
|
420
555
|
blobMerkleRoot: blob.blobMerkleRoot,
|
|
421
556
|
numChunksets: expectedTotalChunksets(blob.blobSize, chunksetSize)
|
|
422
|
-
}))
|
|
557
|
+
})),
|
|
558
|
+
useSponsoredUsdVariant: options.usdSponsor !== void 0
|
|
423
559
|
})
|
|
424
|
-
}
|
|
560
|
+
};
|
|
561
|
+
const transaction = options.usdSponsor ? await this.aptos.transaction.build.multiAgent({
|
|
562
|
+
...buildArgs,
|
|
563
|
+
secondarySignerAddresses: [options.usdSponsor.feePayerAddress]
|
|
564
|
+
}) : await this.aptos.transaction.build.simple(buildArgs);
|
|
425
565
|
return {
|
|
426
566
|
transaction: await this.aptos.signAndSubmitTransaction({
|
|
427
567
|
signer: params.account,
|
|
428
|
-
transaction
|
|
568
|
+
transaction,
|
|
569
|
+
...options.submit
|
|
429
570
|
})
|
|
430
571
|
};
|
|
431
572
|
}
|
|
@@ -446,12 +587,13 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
446
587
|
* @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
|
|
447
588
|
*/
|
|
448
589
|
static createRegisterBlobPayload(params) {
|
|
590
|
+
const functionName = params.useSponsoredUsdVariant ? "register_blob_with_sponsor" : "register_blob";
|
|
449
591
|
return {
|
|
450
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata
|
|
592
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::${functionName}`,
|
|
451
593
|
functionArguments: [
|
|
452
594
|
params.blobName,
|
|
453
595
|
params.expirationMicros,
|
|
454
|
-
|
|
596
|
+
Hex.fromHexString(params.blobMerkleRoot).toUint8Array(),
|
|
455
597
|
params.numChunksets,
|
|
456
598
|
params.blobSize,
|
|
457
599
|
// TODO
|
|
@@ -480,18 +622,21 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
480
622
|
* @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
|
|
481
623
|
*/
|
|
482
624
|
static createBatchRegisterBlobsPayload(params) {
|
|
625
|
+
const functionName = params.useSponsoredUsdVariant ? "register_multiple_blobs_with_sponsor" : "register_multiple_blobs";
|
|
483
626
|
const blobNames = [];
|
|
484
627
|
const blobMerkleRoots = [];
|
|
485
628
|
const blobNumChunksets = [];
|
|
486
629
|
const blobSizes = [];
|
|
487
630
|
params.blobs.forEach((blob) => {
|
|
488
631
|
blobNames.push(blob.blobName);
|
|
489
|
-
blobMerkleRoots.push(
|
|
632
|
+
blobMerkleRoots.push(
|
|
633
|
+
Hex.fromHexString(blob.blobMerkleRoot).toUint8Array()
|
|
634
|
+
);
|
|
490
635
|
blobNumChunksets.push(blob.numChunksets);
|
|
491
636
|
blobSizes.push(blob.blobSize);
|
|
492
637
|
});
|
|
493
638
|
return {
|
|
494
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata
|
|
639
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::${functionName}`,
|
|
495
640
|
functionArguments: [
|
|
496
641
|
blobNames,
|
|
497
642
|
params.expirationMicros,
|
|
@@ -509,7 +654,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
509
654
|
* This is a static helper method for constructing the Move function call payload.
|
|
510
655
|
*
|
|
511
656
|
* @param params.deployer - Optional deployer account address. Defaults to SHELBY_DEPLOYER.
|
|
512
|
-
* @param params.
|
|
657
|
+
* @param params.blobName - The blob name (e.g. "bar.txt", without the account address prefix).
|
|
513
658
|
*
|
|
514
659
|
* @returns An Aptos transaction payload data object for the delete_blob Move function.
|
|
515
660
|
*
|
|
@@ -518,7 +663,33 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
518
663
|
static createDeleteBlobPayload(params) {
|
|
519
664
|
return {
|
|
520
665
|
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::delete_blob`,
|
|
521
|
-
functionArguments: [params.
|
|
666
|
+
functionArguments: [params.blobName]
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Creates a transaction payload to delete multiple blobs on the blockchain.
|
|
671
|
+
* This is a static helper method for constructing the Move function call payload.
|
|
672
|
+
*
|
|
673
|
+
* **Note:** This function requires the `delete_multiple_blobs` entry function
|
|
674
|
+
* which will be deployed to the smart contract on 2026-02-04. Using this
|
|
675
|
+
* function before that date will result in a transaction failure.
|
|
676
|
+
*
|
|
677
|
+
* This operation is atomic: if any blob deletion fails (e.g., blob not found),
|
|
678
|
+
* the entire transaction fails and no blobs are deleted.
|
|
679
|
+
*
|
|
680
|
+
* @param params.deployer - Optional deployer account address. Defaults to SHELBY_DEPLOYER.
|
|
681
|
+
* @param params.blobNames - Array of blob name suffixes without the account address prefix
|
|
682
|
+
* (e.g. ["foo/bar.txt", "baz.txt"], NOT ["0x1/foo/bar.txt"]). The account address
|
|
683
|
+
* prefix is automatically derived from the transaction sender.
|
|
684
|
+
*
|
|
685
|
+
* @returns An Aptos transaction payload data object for the delete_multiple_blobs Move function.
|
|
686
|
+
*
|
|
687
|
+
* @see https://github.com/shelby/shelby/blob/main/move/shelby_contract/sources/blob_metadata.move
|
|
688
|
+
*/
|
|
689
|
+
static createDeleteMultipleBlobsPayload(params) {
|
|
690
|
+
return {
|
|
691
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::delete_multiple_blobs`,
|
|
692
|
+
functionArguments: [params.blobNames]
|
|
522
693
|
};
|
|
523
694
|
}
|
|
524
695
|
static createChunksetAcknowledgementsPayload(params) {
|
|
@@ -526,7 +697,6 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
526
697
|
(acc, ack) => acc | 1 << ack.slot,
|
|
527
698
|
0
|
|
528
699
|
);
|
|
529
|
-
const signatures = new MoveVector(params.storageProviderAcks.map((ack) => MoveVector.U8(ack.signature)));
|
|
530
700
|
return {
|
|
531
701
|
function: `${SHELBY_DEPLOYER}::blob_metadata::add_chunkset_acknowledgements`,
|
|
532
702
|
functionArguments: [
|
|
@@ -537,12 +707,13 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
537
707
|
params.chunksetIdx,
|
|
538
708
|
params.creationMicros,
|
|
539
709
|
new U32(Number(ackBitMask)),
|
|
540
|
-
|
|
710
|
+
params.storageProviderAcks.map((ack) => ack.signature)
|
|
541
711
|
]
|
|
542
712
|
};
|
|
543
713
|
}
|
|
544
714
|
};
|
|
545
715
|
|
|
546
716
|
export {
|
|
717
|
+
MissingTransactionSubmitterError,
|
|
547
718
|
ShelbyBlobClient
|
|
548
719
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/core/errors.ts
|
|
2
|
+
var ShelbyErrorCodes = {
|
|
3
|
+
// blob_metadata.move errors
|
|
4
|
+
E_BLOB_NOT_FOUND: "E_BLOB_NOT_FOUND",
|
|
5
|
+
E_INVALID_EXPIRATION_TIME: "E_INVALID_EXPIRATION_TIME",
|
|
6
|
+
E_TEST_ENCODING_NOT_ALLOWED: "E_TEST_ENCODING_NOT_ALLOWED",
|
|
7
|
+
E_BLOB_NOT_EXPIRED: "E_BLOB_NOT_EXPIRED",
|
|
8
|
+
E_INVALID_CHUNKSET_COUNT: "E_INVALID_CHUNKSET_COUNT",
|
|
9
|
+
E_NOT_BLOB_OWNER: "E_NOT_BLOB_OWNER",
|
|
10
|
+
E_NOT_ADMIN: "E_NOT_ADMIN",
|
|
11
|
+
E_BLOB_EXPIRED: "E_BLOB_EXPIRED",
|
|
12
|
+
E_BLOB_NAME_TOO_LONG: "E_BLOB_NAME_TOO_LONG",
|
|
13
|
+
E_INVALID_PAYMENT_EPOCHS: "E_INVALID_PAYMENT_EPOCHS",
|
|
14
|
+
E_NO_SLICES_AVAILABLE: "E_NO_SLICES_AVAILABLE",
|
|
15
|
+
// Common Aptos/Move errors
|
|
16
|
+
EALREADY_EXISTS: "EALREADY_EXISTS"
|
|
17
|
+
};
|
|
18
|
+
function isBlobAlreadyExistsError(errorMessage) {
|
|
19
|
+
return errorMessage.includes(ShelbyErrorCodes.EALREADY_EXISTS) || errorMessage.includes("already exists");
|
|
20
|
+
}
|
|
21
|
+
function isAccessDeniedError(errorMessage) {
|
|
22
|
+
return errorMessage.includes(ShelbyErrorCodes.E_NOT_BLOB_OWNER) || errorMessage.includes(ShelbyErrorCodes.E_NOT_ADMIN) || errorMessage.includes("ENOT_AUTHORIZED") || errorMessage.includes("not authorized") || errorMessage.includes("permission denied");
|
|
23
|
+
}
|
|
24
|
+
function isBlobNotFoundError(errorMessage) {
|
|
25
|
+
return errorMessage.includes(ShelbyErrorCodes.E_BLOB_NOT_FOUND);
|
|
26
|
+
}
|
|
27
|
+
function isBlobExpiredError(errorMessage) {
|
|
28
|
+
return errorMessage.includes(ShelbyErrorCodes.E_BLOB_EXPIRED);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
ShelbyErrorCodes,
|
|
33
|
+
isBlobAlreadyExistsError,
|
|
34
|
+
isAccessDeniedError,
|
|
35
|
+
isBlobNotFoundError,
|
|
36
|
+
isBlobExpiredError
|
|
37
|
+
};
|
|
@@ -4,6 +4,7 @@ var DEFAULT_PROJECT_NAME = "shelby";
|
|
|
4
4
|
var DEFAULT_PROJECT_DESCRIPTION = "High performance, decentralized storage";
|
|
5
5
|
var NetworkToShelbyRPCBaseUrl = {
|
|
6
6
|
[Network.SHELBYNET]: "https://api.shelbynet.shelby.xyz/shelby",
|
|
7
|
+
[Network.NETNA]: void 0,
|
|
7
8
|
[Network.DEVNET]: void 0,
|
|
8
9
|
[Network.TESTNET]: void 0,
|
|
9
10
|
[Network.MAINNET]: void 0,
|
|
@@ -12,6 +13,7 @@ var NetworkToShelbyRPCBaseUrl = {
|
|
|
12
13
|
};
|
|
13
14
|
var NetworkToShelbyBlobIndexerBaseUrl = {
|
|
14
15
|
[Network.SHELBYNET]: "https://api.shelbynet.aptoslabs.com/nocode/v1/public/cmforrguw0042s601fn71f9l2/v1/graphql",
|
|
16
|
+
[Network.NETNA]: void 0,
|
|
15
17
|
[Network.DEVNET]: void 0,
|
|
16
18
|
[Network.TESTNET]: void 0,
|
|
17
19
|
[Network.MAINNET]: void 0,
|
|
@@ -19,6 +21,7 @@ var NetworkToShelbyBlobIndexerBaseUrl = {
|
|
|
19
21
|
[Network.CUSTOM]: void 0
|
|
20
22
|
};
|
|
21
23
|
var SHELBY_DEPLOYER = "0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5";
|
|
24
|
+
var MICROPAYMENTS_DEPLOYER = "0xb42ac038b6dae86f6171e28e297aab9555ce09909445ec579e4ffe6b8d4d63bf";
|
|
22
25
|
var TOKEN_DEPLOYER = "0x33009e852be7f93762dd0bf303383c2cb2c5cab7a30d8238ca5f9f177ae75124";
|
|
23
26
|
var TOKEN_OBJECT_ADDRESS = "0x249f5c642a63885ff88a5113b3ba0079840af5a1357706f8c7f3bfc5dd12511f";
|
|
24
27
|
var SHELBYUSD_TOKEN_ADDRESS = TOKEN_OBJECT_ADDRESS;
|
|
@@ -32,6 +35,7 @@ export {
|
|
|
32
35
|
NetworkToShelbyRPCBaseUrl,
|
|
33
36
|
NetworkToShelbyBlobIndexerBaseUrl,
|
|
34
37
|
SHELBY_DEPLOYER,
|
|
38
|
+
MICROPAYMENTS_DEPLOYER,
|
|
35
39
|
TOKEN_DEPLOYER,
|
|
36
40
|
TOKEN_OBJECT_ADDRESS,
|
|
37
41
|
SHELBYUSD_TOKEN_ADDRESS,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/core/rpc-responses.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var StartMultipartUploadResponseSchema = z.object({
|
|
4
|
+
uploadId: z.string()
|
|
5
|
+
});
|
|
6
|
+
var UploadPartResponseSchema = z.object({
|
|
7
|
+
success: z.literal(true)
|
|
8
|
+
});
|
|
9
|
+
var CompleteMultipartUploadResponseSchema = z.object({
|
|
10
|
+
success: z.literal(true)
|
|
11
|
+
});
|
|
12
|
+
var RPCErrorResponseSchema = z.object({
|
|
13
|
+
error: z.string()
|
|
14
|
+
});
|
|
15
|
+
var StaleMicropaymentErrorResponseSchema = z.object({
|
|
16
|
+
error: z.string().optional(),
|
|
17
|
+
storedMicropayment: z.string().optional()
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
StartMultipartUploadResponseSchema,
|
|
22
|
+
UploadPartResponseSchema,
|
|
23
|
+
CompleteMultipartUploadResponseSchema,
|
|
24
|
+
RPCErrorResponseSchema,
|
|
25
|
+
StaleMicropaymentErrorResponseSchema
|
|
26
|
+
};
|
|
@@ -105,6 +105,40 @@ var GetBlobActivitiesCountDocument = gql`
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
`;
|
|
108
|
+
var GetPlacementGroupSlotsDocument = gql`
|
|
109
|
+
query getPlacementGroupSlots($where: placement_group_slots_bool_exp, $orderBy: [placement_group_slots_order_by!], $limit: Int, $offset: Int) {
|
|
110
|
+
placement_group_slots(
|
|
111
|
+
where: $where
|
|
112
|
+
order_by: $orderBy
|
|
113
|
+
limit: $limit
|
|
114
|
+
offset: $offset
|
|
115
|
+
) {
|
|
116
|
+
placement_group
|
|
117
|
+
slot_index
|
|
118
|
+
storage_provider
|
|
119
|
+
status
|
|
120
|
+
updated_at
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
var GetPlacementGroupSlotsCountDocument = gql`
|
|
125
|
+
query getPlacementGroupSlotsCount($where: placement_group_slots_bool_exp) {
|
|
126
|
+
placement_group_slots_aggregate(where: $where) {
|
|
127
|
+
aggregate {
|
|
128
|
+
count
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
var GetProcessorStatusDocument = gql`
|
|
134
|
+
query getProcessorStatus {
|
|
135
|
+
processor_status {
|
|
136
|
+
last_success_version
|
|
137
|
+
last_transaction_timestamp
|
|
138
|
+
last_updated
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
108
142
|
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
109
143
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
110
144
|
return {
|
|
@@ -119,6 +153,15 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
119
153
|
},
|
|
120
154
|
getBlobActivitiesCount(variables, requestHeaders, signal) {
|
|
121
155
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivitiesCount", "query", variables);
|
|
156
|
+
},
|
|
157
|
+
getPlacementGroupSlots(variables, requestHeaders, signal) {
|
|
158
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlots", "query", variables);
|
|
159
|
+
},
|
|
160
|
+
getPlacementGroupSlotsCount(variables, requestHeaders, signal) {
|
|
161
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlotsCount", "query", variables);
|
|
162
|
+
},
|
|
163
|
+
getProcessorStatus(variables, requestHeaders, signal) {
|
|
164
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetProcessorStatusDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getProcessorStatus", "query", variables);
|
|
122
165
|
}
|
|
123
166
|
};
|
|
124
167
|
}
|
|
@@ -134,5 +177,8 @@ export {
|
|
|
134
177
|
GetBlobActivitiesDocument,
|
|
135
178
|
GetBlobsCountDocument,
|
|
136
179
|
GetBlobActivitiesCountDocument,
|
|
180
|
+
GetPlacementGroupSlotsDocument,
|
|
181
|
+
GetPlacementGroupSlotsCountDocument,
|
|
182
|
+
GetProcessorStatusDocument,
|
|
137
183
|
getSdk
|
|
138
184
|
};
|
|
@@ -17,6 +17,7 @@ var DEFAULT_ERASURE_N = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /
|
|
|
17
17
|
var DEFAULT_ERASURE_K = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_k;
|
|
18
18
|
var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_d;
|
|
19
19
|
var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
|
|
20
|
+
var DEFAULT_SAMPLE_SIZE = 1024;
|
|
20
21
|
|
|
21
22
|
export {
|
|
22
23
|
ErasureCodingScheme,
|
|
@@ -24,5 +25,6 @@ export {
|
|
|
24
25
|
DEFAULT_ERASURE_N,
|
|
25
26
|
DEFAULT_ERASURE_K,
|
|
26
27
|
DEFAULT_ERASURE_D,
|
|
27
|
-
DEFAULT_ERASURE_M
|
|
28
|
+
DEFAULT_ERASURE_M,
|
|
29
|
+
DEFAULT_SAMPLE_SIZE
|
|
28
30
|
};
|