@shelby-protocol/sdk 0.0.1-experimental.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.
Files changed (63) hide show
  1. package/README.md +60 -0
  2. package/dist/browser/index.d.ts +10 -0
  3. package/dist/browser/index.mjs +55 -0
  4. package/dist/chunk-7P6ASYW6.mjs +9 -0
  5. package/dist/chunk-A4IG6GSE.mjs +21 -0
  6. package/dist/chunk-D2FERD4A.mjs +39 -0
  7. package/dist/chunk-DBTBUKCW.mjs +235 -0
  8. package/dist/chunk-E3QOKRQ4.mjs +50 -0
  9. package/dist/chunk-EFE5Y7IE.mjs +331 -0
  10. package/dist/chunk-GGYTHP5F.mjs +84 -0
  11. package/dist/chunk-I6NG5GNL.mjs +8 -0
  12. package/dist/chunk-IHTPXUYI.mjs +0 -0
  13. package/dist/chunk-MWDW4ROU.mjs +0 -0
  14. package/dist/chunk-NPM7WXK3.mjs +49 -0
  15. package/dist/chunk-OWIIKLFI.mjs +43 -0
  16. package/dist/chunk-PZPMURE4.mjs +0 -0
  17. package/dist/chunk-QEMIORTL.mjs +9 -0
  18. package/dist/chunk-VLLCOFH7.mjs +73 -0
  19. package/dist/chunk-WVWL2OPB.mjs +0 -0
  20. package/dist/chunk-XZMYTH4K.mjs +90 -0
  21. package/dist/chunk-YV67F5NY.mjs +38 -0
  22. package/dist/chunk-ZHXCVRZX.mjs +0 -0
  23. package/dist/core/ShelbyClient.d.ts +34 -0
  24. package/dist/core/ShelbyClient.mjs +8 -0
  25. package/dist/core/blobs.d.ts +52 -0
  26. package/dist/core/blobs.mjs +7 -0
  27. package/dist/core/commitments.d.ts +102 -0
  28. package/dist/core/commitments.mjs +11 -0
  29. package/dist/core/constants.d.ts +26 -0
  30. package/dist/core/constants.mjs +27 -0
  31. package/dist/core/index.d.ts +10 -0
  32. package/dist/core/index.mjs +55 -0
  33. package/dist/core/layout.d.ts +41 -0
  34. package/dist/core/layout.mjs +14 -0
  35. package/dist/core/promises.d.ts +10 -0
  36. package/dist/core/promises.mjs +7 -0
  37. package/dist/core/types/blobs.d.ts +132 -0
  38. package/dist/core/types/blobs.mjs +1 -0
  39. package/dist/core/types/encodings.d.ts +19 -0
  40. package/dist/core/types/encodings.mjs +1 -0
  41. package/dist/core/types/index.d.ts +5 -0
  42. package/dist/core/types/index.mjs +3 -0
  43. package/dist/node/clients/ShelbyBlobClient.d.ts +215 -0
  44. package/dist/node/clients/ShelbyBlobClient.mjs +19 -0
  45. package/dist/node/clients/ShelbyNodeClient.d.ts +95 -0
  46. package/dist/node/clients/ShelbyNodeClient.mjs +22 -0
  47. package/dist/node/clients/ShelbyRPCClient.d.ts +72 -0
  48. package/dist/node/clients/ShelbyRPCClient.mjs +17 -0
  49. package/dist/node/clients/index.d.ts +12 -0
  50. package/dist/node/clients/index.mjs +29 -0
  51. package/dist/node/commitments.d.ts +35 -0
  52. package/dist/node/commitments.mjs +18 -0
  53. package/dist/node/erasure.d.ts +12 -0
  54. package/dist/node/erasure.mjs +7 -0
  55. package/dist/node/index.d.ts +18 -0
  56. package/dist/node/index.mjs +85 -0
  57. package/dist/node/readableUtil.d.ts +2 -0
  58. package/dist/node/readableUtil.mjs +9 -0
  59. package/dist/node/testUtil.d.ts +1 -0
  60. package/dist/node/testUtil.mjs +7 -0
  61. package/dist/readableUtil-BW_7enT-.d.ts +12 -0
  62. package/dist/testUtil-BnxAchIN.d.ts +8 -0
  63. package/package.json +60 -0
@@ -0,0 +1,215 @@
1
+ import { AptosConfig, AccountAddress, InputGenerateTransactionOptions, Aptos, AccountAddressInput, Account, PendingTransactionResponse, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
2
+ import { BlobCommitments } from '../../core/commitments.js';
3
+ import { BlobName } from '../../core/layout.js';
4
+ import { BlobMetadata, BlobChunk, SignedChunkCommitment } from '../../core/types/blobs.js';
5
+ import { EncodingOptions } from '../../core/types/encodings.js';
6
+ import 'zod';
7
+
8
+ interface ShelbyBlobClientConfig {
9
+ aptos: {
10
+ config: AptosConfig;
11
+ };
12
+ shelbyDeployer?: AccountAddress;
13
+ }
14
+ interface WriteBlobCommitmentsOptions {
15
+ build?: {
16
+ options?: InputGenerateTransactionOptions;
17
+ };
18
+ encoding?: EncodingOptions;
19
+ }
20
+ interface ConfirmBlobChunksOptions {
21
+ build?: {
22
+ options?: InputGenerateTransactionOptions;
23
+ };
24
+ encoding?: EncodingOptions;
25
+ }
26
+ declare class ShelbyBlobClient {
27
+ readonly aptos: Aptos;
28
+ readonly deployer: AccountAddress;
29
+ /**
30
+ * The ShelbyBlobClient is used to interact with the Shelby contract on the Aptos blockchain. This
31
+ * includes functions like writing blob commitments, confirming chunks, and retrieving blob metadata.
32
+ *
33
+ * @param config.aptos.config - The Aptos config.
34
+ * @param config.shelbyDeployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
39
+ * const blobClient = new ShelbyBlobClient({ aptos });
40
+ * ```
41
+ */
42
+ constructor(config: ShelbyBlobClientConfig);
43
+ /**
44
+ * Retrieves the blob metadata from the blockchain. If it does not exist,
45
+ * returns `undefined`.
46
+ *
47
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
48
+ * @param params.name - The name of the blob (e.g. "foo/bar")
49
+ * @returns The blob metadata.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const metadata = await client.getBlobMetadata({
54
+ * account: AccountAddress.fromString("0x1"),
55
+ * name: "foo/bar.txt",
56
+ * });
57
+ * ```
58
+ */
59
+ getBlobMetadata(params: {
60
+ account: AccountAddressInput;
61
+ name: BlobName;
62
+ }): Promise<BlobMetadata | undefined>;
63
+ /**
64
+ * Retrieves all the blobs and their metadata for an account from the
65
+ * blockchain.
66
+ *
67
+ * @param params.account - The account namespace the blobs are stored in (e.g. "0x1")
68
+ * @returns The blob metadata for all the blobs for the account.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * // BlobMetadata[]
73
+ * const blobs = await client.getAccountBlobs({
74
+ * account: AccountAddress.fromString("0x1"),
75
+ * });
76
+ * ```
77
+ */
78
+ getAccountBlobs(params: {
79
+ account: AccountAddressInput;
80
+ }): Promise<BlobMetadata[]>;
81
+ /**
82
+ * Retrieves the blob chunks for a given blob from the blockchain. The blob chunk will contain
83
+ * the commitment, the storage provider location, and the status of the chunk (stored or pending).
84
+ *
85
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
86
+ * @param params.name - The name of the blob (e.g. "foo/bar")
87
+ * @returns The chunks that make up the blob.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // BlobChunk[]
92
+ * const chunks = await client.getBlobChunks({
93
+ * account: AccountAddress.fromString("0x1"),
94
+ * name: "foo/bar.txt",
95
+ * });
96
+ *
97
+ * const isStored = chunks.every((c) => c.location.variant === "stored");
98
+ * ```
99
+ */
100
+ getBlobChunks(params: {
101
+ account: AccountAddressInput;
102
+ name: BlobName;
103
+ }): Promise<BlobChunk[]>;
104
+ /**
105
+ * Writes the blob commitments to the blockchain.
106
+ *
107
+ * If `data` is provided instead of `blobCommitments`, the data will be encoded into commitments before being written
108
+ * to the blockchain.
109
+ *
110
+ * @param params.signer - The account that is signing the transaction.
111
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
112
+ * @param params.expirationMicros - The expiration time of the blob in microseconds.
113
+ * @param params.options - Additional options for transaction building and encoding.
114
+ * @param params.blobCommitments - The blob commitments to write to the blockchain (required if `data` is not provided).
115
+ * @param params.data - The data to encode into commitments before writing to the blockchain (required if `blobCommitments` is not provided).
116
+ *
117
+ * @returns The blob commitments and the pending transaction.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const blobCommitments = await generateCommitments(Readable.from(data));
122
+ *
123
+ * const { blobCommitments, transaction } = await client.writeBlobCommitments({
124
+ * signer,
125
+ * blobName: "foo/bar.txt",
126
+ * blobCommitments,
127
+ * expirationMicros: Date.now() * 1000 + 3600_000_000, // 1 hour from now in microseconds
128
+ * });
129
+ * ```
130
+ */
131
+ writeBlobCommitments(params: ({
132
+ blobCommitments: BlobCommitments;
133
+ } | {
134
+ blobData: Buffer;
135
+ }) & {
136
+ signer: Account;
137
+ blobName: BlobName;
138
+ expirationMicros: number;
139
+ options?: WriteBlobCommitmentsOptions;
140
+ }): Promise<{
141
+ blobCommitments: BlobCommitments;
142
+ transaction: PendingTransactionResponse;
143
+ }>;
144
+ /**
145
+ * Confirms an array of signed chunk commitments for a blob. Once all chunks for a blob are confirmed, the blob is
146
+ * considered "stored" and can be retrieved by RPC nodes.
147
+ *
148
+ * @param params.signer - The account that is signing the transaction.
149
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
150
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
151
+ * @param params.signedChunksetChunkCommitments - The signed chunk commitments, signed by their storage provider.
152
+ * @param params.options - Additional options for transaction building and encoding.
153
+ *
154
+ * @returns The pending transaction response.
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const { transaction } = await client.confirmBlobChunks({
159
+ * signer,
160
+ * account: AccountAddress.fromString("0x1"),
161
+ * blobName: "foo/bar.txt",
162
+ * signedChunksetChunkCommitments,
163
+ * });
164
+ * ```
165
+ */
166
+ confirmBlobChunks(params: {
167
+ signer: Account;
168
+ account: AccountAddressInput;
169
+ blobName: BlobName;
170
+ signedChunksetChunkCommitments: SignedChunkCommitment[][];
171
+ options?: ConfirmBlobChunksOptions;
172
+ }): Promise<{
173
+ transaction: PendingTransactionResponse;
174
+ }>;
175
+ /**
176
+ * Creates a transaction payload to write blob commitments to the blockchain.
177
+ *
178
+ * @param params.deployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
179
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
180
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
181
+ * @param params.blobMerkleRoot - The blob merkle root.
182
+ * @param params.chunksetChunkCommitments - The chunk commitments for each chunkset.
183
+ * @param params.expirationMicros - The expiration time of the blob in microseconds.
184
+ * @param params.size - The size of the blob in bytes.
185
+ *
186
+ * @see https://github.com/JumpCrypto/shelby/blob/e009607aad330ccddb08d80bf9addfaadae7972b/move/prototype/move/sources/prototype_interface.move#L211-L220
187
+ */
188
+ static createWriteBlobCommitmentsPayload(params: {
189
+ deployer?: AccountAddress;
190
+ account: AccountAddress;
191
+ blobName: BlobName;
192
+ blobMerkleRoot: string;
193
+ chunksetChunkCommitments: string[][];
194
+ expirationMicros: number;
195
+ size: number;
196
+ }): InputGenerateTransactionPayloadData;
197
+ /**
198
+ * Creates a transaction payload to confirm the chunks of a blob.
199
+ *
200
+ * @param params.deployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
201
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
202
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
203
+ * @param params.signedChunksetChunkCommitments - The signed chunk commitments, signed by their storage provider.
204
+ *
205
+ * @see https://github.com/JumpCrypto/shelby/blob/e009607aad330ccddb08d80bf9addfaadae7972b/move/prototype/move/sources/prototype_interface.move#L343-L349
206
+ */
207
+ static createConfirmBlobChunksPayload(params: {
208
+ deployer?: AccountAddress;
209
+ account: AccountAddressInput;
210
+ blobName: BlobName;
211
+ signedChunksetChunkCommitments: SignedChunkCommitment[][];
212
+ }): InputGenerateTransactionPayloadData;
213
+ }
214
+
215
+ export { type ConfirmBlobChunksOptions, ShelbyBlobClient, type ShelbyBlobClientConfig, type WriteBlobCommitmentsOptions };
@@ -0,0 +1,19 @@
1
+ import {
2
+ ShelbyBlobClient
3
+ } from "../../chunk-EFE5Y7IE.mjs";
4
+ import "../../chunk-VLLCOFH7.mjs";
5
+ import "../../chunk-OWIIKLFI.mjs";
6
+ import "../../chunk-E3QOKRQ4.mjs";
7
+ import "../../chunk-PZPMURE4.mjs";
8
+ import "../../chunk-MWDW4ROU.mjs";
9
+ import "../../chunk-ZHXCVRZX.mjs";
10
+ import "../../chunk-IHTPXUYI.mjs";
11
+ import "../../chunk-YV67F5NY.mjs";
12
+ import "../../chunk-QEMIORTL.mjs";
13
+ import "../../chunk-NPM7WXK3.mjs";
14
+ import "../../chunk-GGYTHP5F.mjs";
15
+ import "../../chunk-D2FERD4A.mjs";
16
+ import "../../chunk-7P6ASYW6.mjs";
17
+ export {
18
+ ShelbyBlobClient
19
+ };
@@ -0,0 +1,95 @@
1
+ import { ShelbyBlobClient, WriteBlobCommitmentsOptions } from './ShelbyBlobClient.js';
2
+ import { ShelbyRPCClient } from './ShelbyRPCClient.js';
3
+ import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
4
+ import { Account, AccountAddressInput } from '@aptos-labs/ts-sdk';
5
+ import { BlobName } from '../../core/layout.js';
6
+ import { ShelbyBlob } from '../../core/blobs.js';
7
+ import { ShelbyClient, ShelbyClientConfig } from '../../core/ShelbyClient.js';
8
+ import '../../core/commitments.js';
9
+ import 'zod';
10
+ import '../../core/types/blobs.js';
11
+ import '../../core/types/encodings.js';
12
+ import 'node:stream';
13
+
14
+ declare class ShelbyNodeClient extends ShelbyClient {
15
+ /**
16
+ * The coordination client is used to interact with the Aptos blockchain which handles the commitments
17
+ * and metadata for blobs.
18
+ */
19
+ readonly coordination: ShelbyBlobClient;
20
+ /**
21
+ * The RPC client is used to interact with the Shelby RPC node which can be responsible for storing,
22
+ * confirming, and retrieving blobs from the storage layer.
23
+ */
24
+ readonly rpc: ShelbyRPCClient;
25
+ /**
26
+ * The ShelbyNodeClient is used to interact with the Shelby network.
27
+ *
28
+ * @param config.aptos.config - The Aptos config.
29
+ * @param config.shelby.baseUrl - The base URL of the Shelby RPC node. If not provided, the default base URL will be used.
30
+ * @param config.shelby.deployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const aptos = new Aptos(new AptosConfig({ network: Network.DEVNET }));
35
+ * const client = new ShelbyNodeClient({ aptos, shelby: { baseUrl: "https://api.shelby.dev" } });
36
+ * ```
37
+ */
38
+ constructor(config: ShelbyClientConfig);
39
+ /**
40
+ * Uploads a blob to the Shelby network.
41
+ *
42
+ * @param params.blobData - The data to upload.
43
+ * @param params.signer - The signer of the transaction.
44
+ * @param params.blobName - The name of the blob.
45
+ * @param params.expirationMicros - The expiration time of the blob in microseconds.
46
+ * @param params.options - The options for the upload.
47
+ *
48
+ * @returns The transaction and generated blob commitments.
49
+ */
50
+ upload(params: {
51
+ blobData: Buffer;
52
+ signer: Account;
53
+ blobName: BlobName;
54
+ expirationMicros: number;
55
+ options?: WriteBlobCommitmentsOptions;
56
+ }): Promise<{
57
+ transaction: _aptos_labs_ts_sdk.CommittedTransactionResponse;
58
+ blobCommitments: {
59
+ schema_version: string;
60
+ raw_data_size: number;
61
+ blob_merkle_root: string;
62
+ chunkset_commitments: {
63
+ chunkset_root: string | null;
64
+ chunk_commitments: string[];
65
+ }[];
66
+ };
67
+ }>;
68
+ /**
69
+ * Downloads a blob from the Shelby RPC node.
70
+ *
71
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
72
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
73
+ * @param params.range - The range of the blob to download.
74
+ *
75
+ * @returns A `ShelbyBlob` object containing the blob data.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const blob = await client.download({
80
+ * account,
81
+ * blobName: "foo/bar.txt",
82
+ * });
83
+ * ```
84
+ */
85
+ download(params: {
86
+ account: AccountAddressInput;
87
+ blobName: string;
88
+ range?: {
89
+ start: number;
90
+ end?: number;
91
+ };
92
+ }): Promise<ShelbyBlob>;
93
+ }
94
+
95
+ export { ShelbyNodeClient };
@@ -0,0 +1,22 @@
1
+ import {
2
+ ShelbyNodeClient
3
+ } from "../../chunk-XZMYTH4K.mjs";
4
+ import "../../chunk-EFE5Y7IE.mjs";
5
+ import "../../chunk-DBTBUKCW.mjs";
6
+ import "../../chunk-VLLCOFH7.mjs";
7
+ import "../../chunk-OWIIKLFI.mjs";
8
+ import "../../chunk-E3QOKRQ4.mjs";
9
+ import "../../chunk-PZPMURE4.mjs";
10
+ import "../../chunk-MWDW4ROU.mjs";
11
+ import "../../chunk-ZHXCVRZX.mjs";
12
+ import "../../chunk-IHTPXUYI.mjs";
13
+ import "../../chunk-YV67F5NY.mjs";
14
+ import "../../chunk-QEMIORTL.mjs";
15
+ import "../../chunk-NPM7WXK3.mjs";
16
+ import "../../chunk-GGYTHP5F.mjs";
17
+ import "../../chunk-D2FERD4A.mjs";
18
+ import "../../chunk-I6NG5GNL.mjs";
19
+ import "../../chunk-7P6ASYW6.mjs";
20
+ export {
21
+ ShelbyNodeClient
22
+ };
@@ -0,0 +1,72 @@
1
+ import { AccountAddressInput } from '@aptos-labs/ts-sdk';
2
+ import { BlobName } from '../../core/layout.js';
3
+ import { ShelbyBlob } from '../../core/blobs.js';
4
+ import { ShelbyClient, ShelbyClientConfig } from '../../core/ShelbyClient.js';
5
+ import 'zod';
6
+ import 'node:stream';
7
+
8
+ declare class ShelbyRPCClient extends ShelbyClient {
9
+ #private;
10
+ /**
11
+ * The ShelbyRPCClient is used to interact with the Shelby RPC node. This
12
+ * includes functions like uploading blobs after they have been committed to the
13
+ * blockchain and downloading blobs.
14
+ *
15
+ * @param config.aptos.config - The Aptos config.
16
+ * @param config.shelby.baseUrl - The base URL of the Shelby RPC node.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const aptos = new Aptos(new AptosConfig({ network: Network.DEVNET }));
21
+ * const client = new ShelbyRPCClient({ aptos, shelby: { baseUrl: "https://api.shelby.dev" } });
22
+ * ```
23
+ */
24
+ constructor(config: ShelbyClientConfig);
25
+ /**
26
+ * Uploads blob data to the Shelby RPC node to be stored and confirmed by storage providers. This should be performed after the blob
27
+ * commitments have been written to the blockchain.
28
+ *
29
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
30
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
31
+ * @param params.blobData - The data to upload.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const blobData = Buffer.from("Hello, world!");
36
+ *
37
+ * await client.putBlob({ account, blobName: "foo/bar.txt", blobData });
38
+ * ```
39
+ */
40
+ putBlob(params: {
41
+ account: AccountAddressInput;
42
+ blobName: BlobName;
43
+ blobData: Buffer;
44
+ }): Promise<void>;
45
+ /**
46
+ * Downloads a blob from the Shelby RPC node.
47
+ *
48
+ * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
49
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
50
+ * @param params.range - The range of the blob to download.
51
+ *
52
+ * @returns A `ShelbyBlob` object containing the blob data.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const blob = await client.getBlob({
57
+ * account,
58
+ * blobName: "foo/bar.txt",
59
+ * });
60
+ * ```
61
+ */
62
+ getBlob(params: {
63
+ account: AccountAddressInput;
64
+ blobName: string;
65
+ range?: {
66
+ start: number;
67
+ end?: number;
68
+ };
69
+ }): Promise<ShelbyBlob>;
70
+ }
71
+
72
+ export { ShelbyRPCClient };
@@ -0,0 +1,17 @@
1
+ import {
2
+ ShelbyRPCClient
3
+ } from "../../chunk-DBTBUKCW.mjs";
4
+ import "../../chunk-PZPMURE4.mjs";
5
+ import "../../chunk-MWDW4ROU.mjs";
6
+ import "../../chunk-ZHXCVRZX.mjs";
7
+ import "../../chunk-IHTPXUYI.mjs";
8
+ import "../../chunk-YV67F5NY.mjs";
9
+ import "../../chunk-QEMIORTL.mjs";
10
+ import "../../chunk-NPM7WXK3.mjs";
11
+ import "../../chunk-GGYTHP5F.mjs";
12
+ import "../../chunk-D2FERD4A.mjs";
13
+ import "../../chunk-I6NG5GNL.mjs";
14
+ import "../../chunk-7P6ASYW6.mjs";
15
+ export {
16
+ ShelbyRPCClient
17
+ };
@@ -0,0 +1,12 @@
1
+ export { ConfirmBlobChunksOptions, ShelbyBlobClient, ShelbyBlobClientConfig, WriteBlobCommitmentsOptions } from './ShelbyBlobClient.js';
2
+ export { ShelbyRPCClient } from './ShelbyRPCClient.js';
3
+ export { ShelbyNodeClient } from './ShelbyNodeClient.js';
4
+ import '@aptos-labs/ts-sdk';
5
+ import '../../core/commitments.js';
6
+ import 'zod';
7
+ import '../../core/layout.js';
8
+ import '../../core/types/blobs.js';
9
+ import '../../core/types/encodings.js';
10
+ import '../../core/blobs.js';
11
+ import 'node:stream';
12
+ import '../../core/ShelbyClient.js';
@@ -0,0 +1,29 @@
1
+ import "../../chunk-WVWL2OPB.mjs";
2
+ import {
3
+ ShelbyNodeClient
4
+ } from "../../chunk-XZMYTH4K.mjs";
5
+ import {
6
+ ShelbyBlobClient
7
+ } from "../../chunk-EFE5Y7IE.mjs";
8
+ import {
9
+ ShelbyRPCClient
10
+ } from "../../chunk-DBTBUKCW.mjs";
11
+ import "../../chunk-VLLCOFH7.mjs";
12
+ import "../../chunk-OWIIKLFI.mjs";
13
+ import "../../chunk-E3QOKRQ4.mjs";
14
+ import "../../chunk-PZPMURE4.mjs";
15
+ import "../../chunk-MWDW4ROU.mjs";
16
+ import "../../chunk-ZHXCVRZX.mjs";
17
+ import "../../chunk-IHTPXUYI.mjs";
18
+ import "../../chunk-YV67F5NY.mjs";
19
+ import "../../chunk-QEMIORTL.mjs";
20
+ import "../../chunk-NPM7WXK3.mjs";
21
+ import "../../chunk-GGYTHP5F.mjs";
22
+ import "../../chunk-D2FERD4A.mjs";
23
+ import "../../chunk-I6NG5GNL.mjs";
24
+ import "../../chunk-7P6ASYW6.mjs";
25
+ export {
26
+ ShelbyBlobClient,
27
+ ShelbyNodeClient,
28
+ ShelbyRPCClient
29
+ };
@@ -0,0 +1,35 @@
1
+ import { Readable } from 'node:stream';
2
+ import { BlobCommitments } from '../core/commitments.js';
3
+ import { EncodingOptions } from '../core/types/encodings.js';
4
+ import 'zod';
5
+
6
+ /**
7
+ * When full dataset is available (as a stream), stream over it, producing
8
+ * chunks of data as we go, and the full BlobCommitment once we've consumed the
9
+ * entire data.
10
+ *
11
+ * FIXME optimization needed around partial commitments, need to return them
12
+ * from the cb so the outer layers can check against what they already have?
13
+ *
14
+ * Callback is also a werid interface into this; I'm not entirely happy with it,
15
+ * but I want this logic to be centralized into a single helper then the rest of
16
+ * the code can be completely agnostic to coding scheme and layout of a chunkset.
17
+ */
18
+ /**
19
+ * Generates the blob commitments for a given data stream.
20
+ *
21
+ * @param fullData - The data stream to generate commitments for.
22
+ * @param onChunk - A callback that is called for each chunk of data.
23
+ * @param options - The encoding options to use.
24
+ *
25
+ * @returns The blob commitments.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const buffer = Buffer.from("Hello, world!");
30
+ * const commitments = await generateCommitments(Readable.from(buffer));
31
+ * ```
32
+ */
33
+ declare function generateCommitments(fullData: Readable, onChunk?: (chunksetIdx: number, chunkIdx: number, chunkData: Buffer) => Promise<void> | void, options?: EncodingOptions): Promise<BlobCommitments>;
34
+
35
+ export { generateCommitments };
@@ -0,0 +1,18 @@
1
+ import {
2
+ generateCommitments
3
+ } from "../chunk-VLLCOFH7.mjs";
4
+ import "../chunk-OWIIKLFI.mjs";
5
+ import "../chunk-E3QOKRQ4.mjs";
6
+ import "../chunk-PZPMURE4.mjs";
7
+ import "../chunk-MWDW4ROU.mjs";
8
+ import "../chunk-ZHXCVRZX.mjs";
9
+ import "../chunk-IHTPXUYI.mjs";
10
+ import "../chunk-YV67F5NY.mjs";
11
+ import "../chunk-QEMIORTL.mjs";
12
+ import "../chunk-NPM7WXK3.mjs";
13
+ import "../chunk-GGYTHP5F.mjs";
14
+ import "../chunk-D2FERD4A.mjs";
15
+ import "../chunk-7P6ASYW6.mjs";
16
+ export {
17
+ generateCommitments
18
+ };
@@ -0,0 +1,12 @@
1
+ import { Buffer } from 'node:buffer';
2
+
3
+ /**
4
+ * Split `data` into `k` data shards + `m` parity shards (Reed-Solomon).
5
+ *
6
+ * Note: This calls `@ronomon/reed-solomon` which has a node-gyp C to Node binding
7
+ * for reed-solomon implementation. It requires Node bindings for Buffer
8
+ * and unfortunately we cannot use Uint8Array here.
9
+ */
10
+ declare function erasureEncode(data: Buffer, k: number, m: number): Promise<Buffer[]>;
11
+
12
+ export { erasureEncode };
@@ -0,0 +1,7 @@
1
+ import {
2
+ erasureEncode
3
+ } from "../chunk-OWIIKLFI.mjs";
4
+ import "../chunk-7P6ASYW6.mjs";
5
+ export {
6
+ erasureEncode
7
+ };
@@ -0,0 +1,18 @@
1
+ export { BlobCommitments, BlobCommitmentsSchema, ChunksetCommitment, ChunksetCommitmentSchema } from '../core/commitments.js';
2
+ export { BlobName, BlobNameSchema, ChunkKey, allChunksForBlob, roundSize } from '../core/layout.js';
3
+ export { CHUNKSET_SIZE_BYTES, DEFAULT_PROJECT_DESCRIPTION, DEFAULT_PROJECT_NAME, DEFAULT_SHELBY_BASE_URL, ERASURE_K, ERASURE_M, SHELBY_DEPLOYER, TOKEN_DEPLOYER, TOKEN_OBJECT_ADDRESS, getChunkSizeBytes, getChunksetSizeBytes } from '../core/constants.js';
4
+ export { BlobChunk, BlobEncoding, BlobMetadata, ChunkLocation, ClayEncoding, PendingChunkLocation, SignedChunkCommitment, StoredChunkLocation } from '../core/types/blobs.js';
5
+ export { EncodingOptions } from '../core/types/encodings.js';
6
+ export { ShelbyBlob, createBlobKey } from '../core/blobs.js';
7
+ export { ShelbyClient, ShelbyClientConfig } from '../core/ShelbyClient.js';
8
+ export { ConfirmBlobChunksOptions, ShelbyBlobClient, ShelbyBlobClientConfig, WriteBlobCommitmentsOptions } from './clients/ShelbyBlobClient.js';
9
+ export { ShelbyRPCClient } from './clients/ShelbyRPCClient.js';
10
+ export { ShelbyNodeClient } from './clients/ShelbyNodeClient.js';
11
+ export { erasureEncode } from './erasure.js';
12
+ export { generateCommitments } from './commitments.js';
13
+ export { t as testUtil } from '../testUtil-BnxAchIN.js';
14
+ export { r as readableUtil } from '../readableUtil-BW_7enT-.js';
15
+ import 'zod';
16
+ import '@aptos-labs/ts-sdk';
17
+ import 'node:stream';
18
+ import 'node:buffer';
@@ -0,0 +1,85 @@
1
+ import "../chunk-WVWL2OPB.mjs";
2
+ import {
3
+ ShelbyNodeClient
4
+ } from "../chunk-XZMYTH4K.mjs";
5
+ import {
6
+ ShelbyBlobClient
7
+ } from "../chunk-EFE5Y7IE.mjs";
8
+ import {
9
+ ShelbyRPCClient
10
+ } from "../chunk-DBTBUKCW.mjs";
11
+ import {
12
+ generateCommitments
13
+ } from "../chunk-VLLCOFH7.mjs";
14
+ import {
15
+ erasureEncode
16
+ } from "../chunk-OWIIKLFI.mjs";
17
+ import {
18
+ readableUtil_exports
19
+ } from "../chunk-E3QOKRQ4.mjs";
20
+ import {
21
+ testUtil_exports
22
+ } from "../chunk-A4IG6GSE.mjs";
23
+ import "../chunk-PZPMURE4.mjs";
24
+ import "../chunk-MWDW4ROU.mjs";
25
+ import "../chunk-ZHXCVRZX.mjs";
26
+ import "../chunk-IHTPXUYI.mjs";
27
+ import {
28
+ ShelbyClient
29
+ } from "../chunk-YV67F5NY.mjs";
30
+ import {
31
+ createBlobKey
32
+ } from "../chunk-QEMIORTL.mjs";
33
+ import {
34
+ BlobCommitmentsSchema,
35
+ ChunksetCommitmentSchema
36
+ } from "../chunk-NPM7WXK3.mjs";
37
+ import {
38
+ BlobNameSchema,
39
+ ChunkKey,
40
+ allChunksForBlob,
41
+ roundSize
42
+ } from "../chunk-GGYTHP5F.mjs";
43
+ import {
44
+ CHUNKSET_SIZE_BYTES,
45
+ DEFAULT_PROJECT_DESCRIPTION,
46
+ DEFAULT_PROJECT_NAME,
47
+ DEFAULT_SHELBY_BASE_URL,
48
+ ERASURE_K,
49
+ ERASURE_M,
50
+ SHELBY_DEPLOYER,
51
+ TOKEN_DEPLOYER,
52
+ TOKEN_OBJECT_ADDRESS,
53
+ getChunkSizeBytes,
54
+ getChunksetSizeBytes
55
+ } from "../chunk-D2FERD4A.mjs";
56
+ import "../chunk-I6NG5GNL.mjs";
57
+ import "../chunk-7P6ASYW6.mjs";
58
+ export {
59
+ BlobCommitmentsSchema,
60
+ BlobNameSchema,
61
+ CHUNKSET_SIZE_BYTES,
62
+ ChunkKey,
63
+ ChunksetCommitmentSchema,
64
+ DEFAULT_PROJECT_DESCRIPTION,
65
+ DEFAULT_PROJECT_NAME,
66
+ DEFAULT_SHELBY_BASE_URL,
67
+ ERASURE_K,
68
+ ERASURE_M,
69
+ SHELBY_DEPLOYER,
70
+ ShelbyBlobClient,
71
+ ShelbyClient,
72
+ ShelbyNodeClient,
73
+ ShelbyRPCClient,
74
+ TOKEN_DEPLOYER,
75
+ TOKEN_OBJECT_ADDRESS,
76
+ allChunksForBlob,
77
+ createBlobKey,
78
+ erasureEncode,
79
+ generateCommitments,
80
+ getChunkSizeBytes,
81
+ getChunksetSizeBytes,
82
+ readableUtil_exports as readableUtil,
83
+ roundSize,
84
+ testUtil_exports as testUtil
85
+ };
@@ -0,0 +1,2 @@
1
+ import 'node:stream';
2
+ export { a as readInChunks, z as zeroPadBuffer } from '../readableUtil-BW_7enT-.js';