@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,8 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/core/aptos-explorer.ts
|
|
2
|
+
import { Network } from "@aptos-labs/ts-sdk";
|
|
3
|
+
function getAptosExplorerBaseUrl(network) {
|
|
4
|
+
const normalizedNetwork = network.toLowerCase();
|
|
5
|
+
switch (normalizedNetwork) {
|
|
6
|
+
case Network.MAINNET.toLowerCase():
|
|
7
|
+
return "https://explorer.aptoslabs.com";
|
|
8
|
+
case Network.TESTNET.toLowerCase():
|
|
9
|
+
return "https://explorer.aptoslabs.com";
|
|
10
|
+
case Network.DEVNET.toLowerCase():
|
|
11
|
+
return "https://explorer.aptoslabs.com";
|
|
12
|
+
case Network.LOCAL.toLowerCase():
|
|
13
|
+
return "https://explorer.aptoslabs.com";
|
|
14
|
+
case Network.SHELBYNET.toLowerCase():
|
|
15
|
+
return "https://explorer.aptoslabs.com";
|
|
16
|
+
default:
|
|
17
|
+
return "https://explorer.aptoslabs.com";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getAptosExplorerNetworkParam(network) {
|
|
21
|
+
const normalizedNetwork = network.toLowerCase();
|
|
22
|
+
switch (normalizedNetwork) {
|
|
23
|
+
case Network.MAINNET.toLowerCase():
|
|
24
|
+
return "mainnet";
|
|
25
|
+
case Network.TESTNET.toLowerCase():
|
|
26
|
+
return "testnet";
|
|
27
|
+
case Network.DEVNET.toLowerCase():
|
|
28
|
+
return "devnet";
|
|
29
|
+
case Network.LOCAL.toLowerCase():
|
|
30
|
+
return "local";
|
|
31
|
+
case Network.SHELBYNET.toLowerCase():
|
|
32
|
+
return "shelbynet";
|
|
33
|
+
default:
|
|
34
|
+
return normalizedNetwork;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getAptosTransactionExplorerUrl(network, transactionHash) {
|
|
38
|
+
const baseUrl = getAptosExplorerBaseUrl(network);
|
|
39
|
+
const networkParam = getAptosExplorerNetworkParam(network);
|
|
40
|
+
return `${baseUrl}/txn/${transactionHash}?network=${networkParam}`;
|
|
41
|
+
}
|
|
42
|
+
function getAptosAccountExplorerUrl(network, accountAddress) {
|
|
43
|
+
const baseUrl = getAptosExplorerBaseUrl(network);
|
|
44
|
+
const networkParam = getAptosExplorerNetworkParam(network);
|
|
45
|
+
return `${baseUrl}/account/${accountAddress}?network=${networkParam}`;
|
|
46
|
+
}
|
|
6
47
|
export {
|
|
7
48
|
getAptosAccountExplorerUrl,
|
|
8
49
|
getAptosTransactionExplorerUrl
|
package/dist/core/blobs.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
// src/core/utils.ts
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
AccountAddress,
|
|
4
|
+
Hex
|
|
5
|
+
} from "@aptos-labs/ts-sdk";
|
|
6
|
+
function normalizeAddress(address) {
|
|
7
|
+
return AccountAddress.from(address, { maxMissingChars: 63 });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/core/blobs.ts
|
|
11
|
+
var createBlobKey = (params) => {
|
|
12
|
+
return `@${normalizeAddress(params.account).toStringLongWithoutPrefix()}/${params.blobName}`;
|
|
13
|
+
};
|
|
6
14
|
export {
|
|
7
15
|
createBlobKey
|
|
8
16
|
};
|
package/dist/core/chunk.mjs
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// src/core/erasure/constants.ts
|
|
2
|
+
var ERASURE_CODE_PARAMS = {
|
|
3
|
+
["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
|
|
4
|
+
// total chunks (data + parity)
|
|
5
|
+
erasure_n: 16,
|
|
6
|
+
// data chunks
|
|
7
|
+
erasure_k: 10,
|
|
8
|
+
// helper nodes
|
|
9
|
+
erasure_d: 13,
|
|
10
|
+
// enum index
|
|
11
|
+
enumIndex: 0
|
|
12
|
+
},
|
|
13
|
+
["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
|
|
14
|
+
// total chunks (data + parity)
|
|
15
|
+
erasure_n: 4,
|
|
16
|
+
// data chunks
|
|
17
|
+
erasure_k: 2,
|
|
18
|
+
// helper nodes
|
|
19
|
+
erasure_d: 3,
|
|
20
|
+
// enum index
|
|
21
|
+
enumIndex: 1
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var DEFAULT_ERASURE_N = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_n;
|
|
25
|
+
var DEFAULT_ERASURE_K = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_k;
|
|
26
|
+
var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_d;
|
|
27
|
+
var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
|
|
28
|
+
|
|
29
|
+
// src/core/chunk.ts
|
|
30
|
+
var ChunkSizeScheme = /* @__PURE__ */ ((ChunkSizeScheme2) => {
|
|
31
|
+
ChunkSizeScheme2["ChunkSet10MiB_Chunk1MiB"] = "ChunkSet10MiB_Chunk1MiB";
|
|
32
|
+
ChunkSizeScheme2["ChunkSet2MiB_Chunk1MiB"] = "ChunkSet2MiB_Chunk1MiB";
|
|
33
|
+
return ChunkSizeScheme2;
|
|
34
|
+
})(ChunkSizeScheme || {});
|
|
35
|
+
var CHUNK_SIZE_PARAMS = {
|
|
36
|
+
["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */]: {
|
|
37
|
+
// 1MiB
|
|
38
|
+
chunkSizeBytes: 1 * 1024 * 1024,
|
|
39
|
+
// 10MiB
|
|
40
|
+
chunksetSizeBytes: 10 * 1024 * 1024
|
|
41
|
+
},
|
|
42
|
+
["ChunkSet2MiB_Chunk1MiB" /* ChunkSet2MiB_Chunk1MiB */]: {
|
|
43
|
+
// 1MiB
|
|
44
|
+
chunkSizeBytes: 1 * 1024 * 1024,
|
|
45
|
+
// 2MiB
|
|
46
|
+
chunksetSizeBytes: 2 * 1024 * 1024
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var DEFAULT_CHUNK_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunkSizeBytes;
|
|
50
|
+
var DEFAULT_CHUNKSET_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunksetSizeBytes;
|
|
51
|
+
var ERASURE_CODE_AND_CHUNK_MAPPING = {
|
|
52
|
+
["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
|
|
53
|
+
...CHUNK_SIZE_PARAMS.ChunkSet10MiB_Chunk1MiB
|
|
54
|
+
},
|
|
55
|
+
["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
|
|
56
|
+
...CHUNK_SIZE_PARAMS.ChunkSet2MiB_Chunk1MiB
|
|
57
|
+
}
|
|
58
|
+
};
|
|
10
59
|
export {
|
|
11
60
|
CHUNK_SIZE_PARAMS,
|
|
12
61
|
ChunkSizeScheme,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputGenerateTransactionOptions, Aptos, AccountAddress, InputTransactionPluginData, AccountAddressInput, Account, PendingTransactionResponse, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
|
|
2
2
|
import { BlobName } from '../layout.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FullObjectMetadata, BlobActivity, BlobEncryption, StorageProviderAck } from '../types/blobs.js';
|
|
4
4
|
import { E as ErasureCodingConfig } from '../../clay-codes-DdXABBDx.js';
|
|
5
5
|
import { ShelbyIndexerClient } from '../operations/index.js';
|
|
6
6
|
import { Blobs_Order_By, Blobs_Bool_Exp, Blob_Activities_Bool_Exp, Blob_Activities_Order_By } from '../operations/generated/sdk.js';
|
|
@@ -19,6 +19,22 @@ import '../networks.js';
|
|
|
19
19
|
declare class MissingTransactionSubmitterError extends Error {
|
|
20
20
|
constructor();
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Why `commit_object` rejected a write, mirroring the contract's
|
|
24
|
+
* `CommitRejectionReason` variants (blob_metadata.move).
|
|
25
|
+
*/
|
|
26
|
+
type CommitRejectionReason = "AlreadyExists" | "NoPriorVersion" | "EtagMismatch";
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when `commit_object` rejected a write instead of applying it. The
|
|
29
|
+
* transaction itself succeeded; the contract tore down the pending blob and
|
|
30
|
+
* emitted `ObjectCommitRejectedEvent` rather than aborting.
|
|
31
|
+
*/
|
|
32
|
+
declare class ObjectCommitRejectedError extends Error {
|
|
33
|
+
readonly blobName: BlobName;
|
|
34
|
+
readonly uid: bigint;
|
|
35
|
+
readonly reason: CommitRejectionReason;
|
|
36
|
+
constructor(blobName: BlobName, uid: bigint, reason: CommitRejectionReason);
|
|
37
|
+
}
|
|
22
38
|
interface BuildOptions {
|
|
23
39
|
options?: InputGenerateTransactionOptions;
|
|
24
40
|
withFeePayer?: boolean;
|
|
@@ -51,6 +67,18 @@ interface WriteBlobCommitmentsOptions {
|
|
|
51
67
|
*/
|
|
52
68
|
usdSponsor?: UsdSponsorOptions;
|
|
53
69
|
chunksetSizeBytes?: number;
|
|
70
|
+
/**
|
|
71
|
+
* The location (region) to write the blob to. Authoritative: the write lands there
|
|
72
|
+
* or aborts on chain (e.g. if the account's location preference is locked to a
|
|
73
|
+
* different location).
|
|
74
|
+
*/
|
|
75
|
+
selectedLocation?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Best-effort location hint, typically derived from where the client runs. Honored
|
|
78
|
+
* only for accounts in the default `FollowHint` preference mode, and overridden by
|
|
79
|
+
* `selectedLocation`. Defaults to `ShelbyClientConfig.locationHint`.
|
|
80
|
+
*/
|
|
81
|
+
locationHint?: string;
|
|
54
82
|
}
|
|
55
83
|
interface AckTransactionOptions {
|
|
56
84
|
build?: BuildOptions;
|
|
@@ -128,16 +156,33 @@ declare class ShelbyBlobClient {
|
|
|
128
156
|
*
|
|
129
157
|
* @example
|
|
130
158
|
* ```typescript
|
|
131
|
-
* const metadata = await client.
|
|
159
|
+
* const metadata = await client.getFullObjectMetadata({
|
|
132
160
|
* account: AccountAddress.fromString("0x1"),
|
|
133
161
|
* name: "foo/bar.txt",
|
|
134
162
|
* });
|
|
135
163
|
* ```
|
|
136
164
|
*/
|
|
137
|
-
|
|
165
|
+
getFullObjectMetadata(params: {
|
|
138
166
|
account: AccountAddressInput;
|
|
139
167
|
name: BlobName;
|
|
140
|
-
}): Promise<
|
|
168
|
+
}): Promise<FullObjectMetadata | undefined>;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves blob metadata directly by its on-chain UID, including blobs in
|
|
171
|
+
* the pending (registered-but-not-yet-committed) state that
|
|
172
|
+
* {@link getFullObjectMetadata} cannot resolve by object name. Returns `undefined`
|
|
173
|
+
* if no blob has that UID.
|
|
174
|
+
*
|
|
175
|
+
* The returned `name`/`blobNameSuffix` are empty: the blob layer is keyed by
|
|
176
|
+
* UID and carries no object name (a name binding is established only at
|
|
177
|
+
* commit). `isWritten` reflects whether the blob has been committed.
|
|
178
|
+
*/
|
|
179
|
+
getFullObjectMetadataByUid(uid: bigint): Promise<FullObjectMetadata | undefined>;
|
|
180
|
+
/**
|
|
181
|
+
* Parse the on-chain `BlobMetadata::V1` view shape into the SDK
|
|
182
|
+
* {@link FullObjectMetadata}. `uid` / `name` / `isWritten` are supplied by the
|
|
183
|
+
* caller since they depend on the lookup path (by object name vs by UID).
|
|
184
|
+
*/
|
|
185
|
+
private parseBlobMetadata;
|
|
141
186
|
/**
|
|
142
187
|
* Retrieves all the blobs and their metadata for an account from the
|
|
143
188
|
* blockchain.
|
|
@@ -149,7 +194,7 @@ declare class ShelbyBlobClient {
|
|
|
149
194
|
*
|
|
150
195
|
* @example
|
|
151
196
|
* ```typescript
|
|
152
|
-
* //
|
|
197
|
+
* // FullObjectMetadata[]
|
|
153
198
|
* const blobs = await client.getAccountBlobs({
|
|
154
199
|
* account: AccountAddress.fromString("0x1"),
|
|
155
200
|
* });
|
|
@@ -163,7 +208,19 @@ declare class ShelbyBlobClient {
|
|
|
163
208
|
};
|
|
164
209
|
orderBy?: Blobs_Order_By;
|
|
165
210
|
where?: Omit<Blobs_Bool_Exp, "owner">;
|
|
166
|
-
}): Promise<
|
|
211
|
+
}): Promise<FullObjectMetadata[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Object-facing default filter: only committed, non-deleted, unexpired rows.
|
|
214
|
+
* The blobs table is UID-keyed, so during an atomic overwrite a single
|
|
215
|
+
* object_name transiently has two non-deleted rows — the currently committed
|
|
216
|
+
* blob and the new pending (is_committed = "0") blob. Filtering on
|
|
217
|
+
* is_committed keeps name lookups/listings pinned to the committed object and
|
|
218
|
+
* avoids returning or duplicating the in-flight pending row. Applied to
|
|
219
|
+
* getBlobs *and* the getBlobsCount / getTotalBlobsSize aggregates so counts
|
|
220
|
+
* and sizes agree with the listing mid-overwrite. Callers can override any
|
|
221
|
+
* key (e.g. is_committed) via their own `where`.
|
|
222
|
+
*/
|
|
223
|
+
private activeBlobsWhere;
|
|
167
224
|
/**
|
|
168
225
|
* Retrieves blobs and their metadata from the blockchain.
|
|
169
226
|
*
|
|
@@ -174,7 +231,7 @@ declare class ShelbyBlobClient {
|
|
|
174
231
|
*
|
|
175
232
|
* @example
|
|
176
233
|
* ```typescript
|
|
177
|
-
* //
|
|
234
|
+
* // FullObjectMetadata[]
|
|
178
235
|
* const blobs = await client.getBlobs({
|
|
179
236
|
* where: { owner: { _eq: AccountAddress.fromString("0x1").toString() } },
|
|
180
237
|
* });
|
|
@@ -187,7 +244,7 @@ declare class ShelbyBlobClient {
|
|
|
187
244
|
offset?: number;
|
|
188
245
|
};
|
|
189
246
|
orderBy?: Blobs_Order_By;
|
|
190
|
-
}): Promise<
|
|
247
|
+
}): Promise<FullObjectMetadata[]>;
|
|
191
248
|
getBlobActivities(params: {
|
|
192
249
|
where?: Blob_Activities_Bool_Exp;
|
|
193
250
|
pagination?: {
|
|
@@ -207,7 +264,7 @@ declare class ShelbyBlobClient {
|
|
|
207
264
|
* const count = await client.getBlobsCount();
|
|
208
265
|
* ```
|
|
209
266
|
*/
|
|
210
|
-
getBlobsCount(params
|
|
267
|
+
getBlobsCount(params?: {
|
|
211
268
|
where?: Blobs_Bool_Exp;
|
|
212
269
|
}): Promise<number>;
|
|
213
270
|
/**
|
|
@@ -272,6 +329,7 @@ declare class ShelbyBlobClient {
|
|
|
272
329
|
blobMerkleRoot: string;
|
|
273
330
|
size: number;
|
|
274
331
|
expirationMicros: number;
|
|
332
|
+
encryption?: BlobEncryption;
|
|
275
333
|
config?: ErasureCodingConfig;
|
|
276
334
|
options?: WriteBlobCommitmentsOptions;
|
|
277
335
|
}): Promise<{
|
|
@@ -289,13 +347,13 @@ declare class ShelbyBlobClient {
|
|
|
289
347
|
* @example
|
|
290
348
|
* ```typescript
|
|
291
349
|
*
|
|
292
|
-
* const { transaction } = await client.
|
|
350
|
+
* const { transaction } = await client.deleteObject({
|
|
293
351
|
* account: signer,
|
|
294
352
|
* blobName: "foo/bar.txt",
|
|
295
353
|
* });
|
|
296
354
|
* ```
|
|
297
355
|
*/
|
|
298
|
-
|
|
356
|
+
deleteObject(params: {
|
|
299
357
|
account: Account;
|
|
300
358
|
blobName: BlobName;
|
|
301
359
|
options?: InputGenerateTransactionOptions;
|
|
@@ -305,10 +363,6 @@ declare class ShelbyBlobClient {
|
|
|
305
363
|
/**
|
|
306
364
|
* Deletes multiple blobs on the blockchain in a single atomic transaction.
|
|
307
365
|
*
|
|
308
|
-
* **Note:** This function requires the `delete_multiple_blobs` entry function
|
|
309
|
-
* which will be deployed to the smart contract on 2026-02-04. Using this
|
|
310
|
-
* function before that date will result in a transaction failure.
|
|
311
|
-
*
|
|
312
366
|
* This operation is atomic: if any blob deletion fails (e.g., blob not found),
|
|
313
367
|
* the entire transaction fails and no blobs are deleted.
|
|
314
368
|
*
|
|
@@ -323,55 +377,19 @@ declare class ShelbyBlobClient {
|
|
|
323
377
|
* @example
|
|
324
378
|
* ```typescript
|
|
325
379
|
*
|
|
326
|
-
* const { transaction } = await client.
|
|
380
|
+
* const { transaction } = await client.deleteMultipleObjects({
|
|
327
381
|
* account: signer,
|
|
328
382
|
* blobNames: ["foo/bar.txt", "baz.txt"],
|
|
329
383
|
* });
|
|
330
384
|
* ```
|
|
331
385
|
*/
|
|
332
|
-
|
|
386
|
+
deleteMultipleObjects(params: {
|
|
333
387
|
account: Account;
|
|
334
388
|
blobNames: BlobName[];
|
|
335
389
|
options?: InputGenerateTransactionOptions;
|
|
336
390
|
}): Promise<{
|
|
337
391
|
transaction: PendingTransactionResponse;
|
|
338
392
|
}>;
|
|
339
|
-
/**
|
|
340
|
-
* Acks the blob chunksets on-chain. If each chunkset meets the necessary threshold, the entire blob will be marked as written.
|
|
341
|
-
*
|
|
342
|
-
* @param params.account - The account that is signing the transaction.
|
|
343
|
-
* @param params.blobOwner - The account that owns the blob.
|
|
344
|
-
* @param params.blobName - The name of the blob (e.g. "foo/bar")
|
|
345
|
-
* @param params.creationMicros - The creation time of the blob in microseconds.
|
|
346
|
-
* @param params.chunksetIdx - The index of the chunkset being acknowledged.
|
|
347
|
-
* @param params.storageProviderChunksetAcks - The signatures
|
|
348
|
-
* @param params.options - Additional options for transaction building and encoding.
|
|
349
|
-
*
|
|
350
|
-
* @returns The blob commitments and the pending transaction.
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```typescript
|
|
354
|
-
* const { transaction } = await client.addChunksetAcknowledgements({
|
|
355
|
-
* account: signer,
|
|
356
|
-
* blobOwner: owner,
|
|
357
|
-
* blobName: "foo/bar.txt",
|
|
358
|
-
* creationMicros, // Taken from the blob metadata at registration time.
|
|
359
|
-
* chunksetIdx,
|
|
360
|
-
* storageProviderAcks: An array of StorageProviderAck types, each having the slot index and signature from the SP.
|
|
361
|
-
* });
|
|
362
|
-
* ```
|
|
363
|
-
*/
|
|
364
|
-
addChunksetAcknowledgements(params: {
|
|
365
|
-
account: Account;
|
|
366
|
-
blobOwner: AccountAddress;
|
|
367
|
-
blobName: BlobName;
|
|
368
|
-
creationMicros: number;
|
|
369
|
-
chunksetIdx: number;
|
|
370
|
-
storageProviderAcks: StorageProviderAck[];
|
|
371
|
-
options?: AckTransactionOptions;
|
|
372
|
-
}): Promise<{
|
|
373
|
-
transaction: PendingTransactionResponse;
|
|
374
|
-
}>;
|
|
375
393
|
/**
|
|
376
394
|
* Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
|
|
377
395
|
*
|
|
@@ -413,11 +431,49 @@ declare class ShelbyBlobClient {
|
|
|
413
431
|
blobSize: number;
|
|
414
432
|
blobMerkleRoot: string;
|
|
415
433
|
}[];
|
|
434
|
+
encryption?: BlobEncryption;
|
|
416
435
|
config?: ErasureCodingConfig;
|
|
417
436
|
options?: WriteBlobCommitmentsOptions;
|
|
418
437
|
}): Promise<{
|
|
419
438
|
transaction: PendingTransactionResponse;
|
|
420
439
|
}>;
|
|
440
|
+
/**
|
|
441
|
+
* Extracts the on-chain UIDs assigned at registration from a committed
|
|
442
|
+
* register transaction's events.
|
|
443
|
+
*
|
|
444
|
+
* `register_blob` / `register_multiple_blobs` create *pending* blobs and emit
|
|
445
|
+
* one `BlobRegisteredEvent` per blob. The UID is published only on this event
|
|
446
|
+
* (the blob is not yet in the `objects` map, so it cannot be read back by
|
|
447
|
+
* name), so callers must parse it here before uploading bytes or committing.
|
|
448
|
+
*
|
|
449
|
+
* @param events - The committed transaction's events (from `waitForTransaction`).
|
|
450
|
+
* @param deployer - The contract deployer address.
|
|
451
|
+
* @returns One entry per registered blob, keyed by its full object name
|
|
452
|
+
* (`@<owner>/<suffix>`, matching {@link createBlobKey}).
|
|
453
|
+
*/
|
|
454
|
+
static registeredBlobUids(events: ReadonlyArray<{
|
|
455
|
+
type: string;
|
|
456
|
+
data: unknown;
|
|
457
|
+
}>, deployer: AccountAddress): {
|
|
458
|
+
objectName: string;
|
|
459
|
+
uid: bigint;
|
|
460
|
+
}[];
|
|
461
|
+
/**
|
|
462
|
+
* Detects whether `commit_object` rejected the write for `uid` rather than
|
|
463
|
+
* applying it. A rejected commit is still a *successful* transaction — the
|
|
464
|
+
* contract tears down the pending blob and emits `ObjectCommitRejectedEvent`
|
|
465
|
+
* instead of aborting — so callers must inspect the finalized transaction's
|
|
466
|
+
* events to tell a durable write apart from a silent no-op.
|
|
467
|
+
*
|
|
468
|
+
* @param events - The committed transaction's events (from `waitForTransaction`).
|
|
469
|
+
* @param deployer - The contract deployer address.
|
|
470
|
+
* @param uid - The UID passed to `commit_object`.
|
|
471
|
+
* @returns The rejection reason, or `undefined` if the commit was applied.
|
|
472
|
+
*/
|
|
473
|
+
static findObjectCommitRejection(events: ReadonlyArray<{
|
|
474
|
+
type: string;
|
|
475
|
+
data: unknown;
|
|
476
|
+
}>, deployer: AccountAddress, uid: bigint): CommitRejectionReason | undefined;
|
|
421
477
|
/**
|
|
422
478
|
* Creates a transaction payload to register a blob on the blockchain.
|
|
423
479
|
* This is a static helper method for constructing the Move function call payload.
|
|
@@ -431,19 +487,25 @@ declare class ShelbyBlobClient {
|
|
|
431
487
|
* @param params.numChunksets - The total number of chunksets in the blob.
|
|
432
488
|
*
|
|
433
489
|
* @returns An Aptos transaction payload data object for the register_blob Move function.
|
|
434
|
-
*
|
|
435
|
-
* @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
|
|
436
490
|
*/
|
|
437
491
|
static createRegisterBlobPayload(params: {
|
|
438
492
|
deployer?: AccountAddress;
|
|
439
493
|
account: AccountAddress;
|
|
440
494
|
blobName: BlobName;
|
|
495
|
+
selectedLocation?: string;
|
|
496
|
+
locationHint?: string;
|
|
441
497
|
blobSize: number;
|
|
442
498
|
blobMerkleRoot: string;
|
|
443
499
|
expirationMicros: number;
|
|
444
500
|
numChunksets: number;
|
|
445
501
|
useSponsoredUsdVariant?: boolean;
|
|
446
502
|
encoding: number;
|
|
503
|
+
encryption?: BlobEncryption;
|
|
504
|
+
/**
|
|
505
|
+
* TEMP (#1739): drop the trailing encryption arg to match contracts that
|
|
506
|
+
* predate the encryption upgrade (e.g. shelbynet). Defaults to false.
|
|
507
|
+
*/
|
|
508
|
+
omitEncryptionArg?: boolean;
|
|
447
509
|
}): InputGenerateTransactionPayloadData;
|
|
448
510
|
/**
|
|
449
511
|
* Creates a transaction payload to register multiple blobs on the blockchain.
|
|
@@ -459,12 +521,12 @@ declare class ShelbyBlobClient {
|
|
|
459
521
|
* @param params.blobs.numChunksets - The total number of chunksets in the blob.
|
|
460
522
|
*
|
|
461
523
|
* @returns An Aptos transaction payload data object for the register_multiple_blobs Move function.
|
|
462
|
-
*
|
|
463
|
-
* @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
|
|
464
524
|
*/
|
|
465
525
|
static createBatchRegisterBlobsPayload(params: {
|
|
466
526
|
deployer?: AccountAddress;
|
|
467
527
|
account: AccountAddress;
|
|
528
|
+
selectedLocation?: string;
|
|
529
|
+
locationHint?: string;
|
|
468
530
|
expirationMicros: number;
|
|
469
531
|
blobs: {
|
|
470
532
|
blobName: BlobName;
|
|
@@ -474,6 +536,12 @@ declare class ShelbyBlobClient {
|
|
|
474
536
|
}[];
|
|
475
537
|
useSponsoredUsdVariant?: boolean;
|
|
476
538
|
encoding: number;
|
|
539
|
+
encryption?: BlobEncryption;
|
|
540
|
+
/**
|
|
541
|
+
* TEMP (#1739): drop the trailing encryption arg to match contracts that
|
|
542
|
+
* predate the encryption upgrade (e.g. shelbynet). Defaults to false.
|
|
543
|
+
*/
|
|
544
|
+
omitEncryptionArg?: boolean;
|
|
477
545
|
}): InputGenerateTransactionPayloadData;
|
|
478
546
|
/**
|
|
479
547
|
* Creates a transaction payload to delete a blob on the blockchain.
|
|
@@ -482,11 +550,9 @@ declare class ShelbyBlobClient {
|
|
|
482
550
|
* @param params.deployer - Optional deployer account address. Defaults to SHELBY_DEPLOYER.
|
|
483
551
|
* @param params.blobName - The blob name (e.g. "bar.txt", without the account address prefix).
|
|
484
552
|
*
|
|
485
|
-
* @returns An Aptos transaction payload data object for the
|
|
486
|
-
*
|
|
487
|
-
* @see https://github.com/shelby/shelby/blob/64e9d7b4f0005e586faeb1e4085c79159234b6b6/move/shelby_contract/sources/global_metadata.move#L616
|
|
553
|
+
* @returns An Aptos transaction payload data object for the delete_object Move function.
|
|
488
554
|
*/
|
|
489
|
-
static
|
|
555
|
+
static createDeleteObjectPayload(params: {
|
|
490
556
|
deployer?: AccountAddress;
|
|
491
557
|
blobName: string;
|
|
492
558
|
}): InputGenerateTransactionPayloadData;
|
|
@@ -494,10 +560,6 @@ declare class ShelbyBlobClient {
|
|
|
494
560
|
* Creates a transaction payload to delete multiple blobs on the blockchain.
|
|
495
561
|
* This is a static helper method for constructing the Move function call payload.
|
|
496
562
|
*
|
|
497
|
-
* **Note:** This function requires the `delete_multiple_blobs` entry function
|
|
498
|
-
* which will be deployed to the smart contract on 2026-02-04. Using this
|
|
499
|
-
* function before that date will result in a transaction failure.
|
|
500
|
-
*
|
|
501
563
|
* This operation is atomic: if any blob deletion fails (e.g., blob not found),
|
|
502
564
|
* the entire transaction fails and no blobs are deleted.
|
|
503
565
|
*
|
|
@@ -506,32 +568,42 @@ declare class ShelbyBlobClient {
|
|
|
506
568
|
* (e.g. ["foo/bar.txt", "baz.txt"], NOT ["0x1/foo/bar.txt"]). The account address
|
|
507
569
|
* prefix is automatically derived from the transaction sender.
|
|
508
570
|
*
|
|
509
|
-
* @returns An Aptos transaction payload data object for the
|
|
510
|
-
*
|
|
511
|
-
* @see https://github.com/shelby/shelby/blob/main/move/shelby_contract/sources/blob_metadata.move
|
|
571
|
+
* @returns An Aptos transaction payload data object for the delete_multiple_objects Move function.
|
|
512
572
|
*/
|
|
513
|
-
static
|
|
573
|
+
static createDeleteMultipleObjectsPayload(params: {
|
|
514
574
|
deployer?: AccountAddress;
|
|
515
575
|
blobNames: string[];
|
|
516
576
|
}): InputGenerateTransactionPayloadData;
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
577
|
+
/**
|
|
578
|
+
* Sort acks by slot and reduce to the `(ack_bits, signatures)` pair the
|
|
579
|
+
* contract expects: it walks the set bits low-to-high and consumes the
|
|
580
|
+
* signatures in that same order.
|
|
581
|
+
*/
|
|
582
|
+
private static encodeAcks;
|
|
583
|
+
/**
|
|
584
|
+
* Payload for `commit_object(uid, object_name_suffix, overwrite, if_match_etag,
|
|
585
|
+
* ack_bits, signatures)` — binds a written pending blob under its object name,
|
|
586
|
+
* finalizing the upload. SP acks may be batched in here (the contract applies
|
|
587
|
+
* them before the `is_written` check), so register → upload → commit needs
|
|
588
|
+
* only a single finalize transaction.
|
|
589
|
+
*
|
|
590
|
+
* @param params.uid - The blob UID returned at registration.
|
|
591
|
+
* @param params.blobName - The object name suffix the blob was registered under.
|
|
592
|
+
* @param params.overwrite - Allow replacing an existing binding under this name.
|
|
593
|
+
* @param params.storageProviderAcks - Acks applied atomically with the commit.
|
|
594
|
+
*/
|
|
595
|
+
static createCommitObjectPayload(params: {
|
|
596
|
+
deployer?: AccountAddress;
|
|
597
|
+
uid: bigint;
|
|
526
598
|
blobName: BlobName;
|
|
527
|
-
|
|
599
|
+
overwrite: boolean;
|
|
528
600
|
storageProviderAcks: StorageProviderAck[];
|
|
529
601
|
}): InputGenerateTransactionPayloadData;
|
|
530
|
-
|
|
602
|
+
commitObject(params: {
|
|
531
603
|
account: Account;
|
|
532
|
-
|
|
604
|
+
uid: bigint;
|
|
533
605
|
blobName: BlobName;
|
|
534
|
-
|
|
606
|
+
overwrite: boolean;
|
|
535
607
|
storageProviderAcks: StorageProviderAck[];
|
|
536
608
|
options?: AckTransactionOptions;
|
|
537
609
|
}): Promise<{
|
|
@@ -539,4 +611,4 @@ declare class ShelbyBlobClient {
|
|
|
539
611
|
}>;
|
|
540
612
|
}
|
|
541
613
|
|
|
542
|
-
export { type AckTransactionOptions, type BuildOptions, MissingTransactionSubmitterError, ShelbyBlobClient, type UsdSponsorOptions, type WriteBlobCommitmentsOptions };
|
|
614
|
+
export { type AckTransactionOptions, type BuildOptions, type CommitRejectionReason, MissingTransactionSubmitterError, ObjectCommitRejectedError, ShelbyBlobClient, type UsdSponsorOptions, type WriteBlobCommitmentsOptions };
|