@shelby-protocol/sdk 0.0.1-experimental.4 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +41 -0
  2. package/dist/browser/index.d.ts +17 -8
  3. package/dist/browser/index.mjs +83 -34
  4. package/dist/chunk-3ZDXWPYC.mjs +65 -0
  5. package/dist/chunk-6MDQI7PW.mjs +177 -0
  6. package/dist/chunk-75VHXY5P.mjs +48 -0
  7. package/dist/chunk-APML3CGJ.mjs +176 -0
  8. package/dist/chunk-DLMDDEWF.mjs +112 -0
  9. package/dist/{chunk-C33H3C3N.mjs → chunk-EAPAG4L7.mjs} +1 -1
  10. package/dist/{chunk-GGYTHP5F.mjs → chunk-FIFKKWXV.mjs} +19 -17
  11. package/dist/chunk-HPVCKAN2.mjs +41 -0
  12. package/dist/{chunk-2FF5FICZ.mjs → chunk-JSR44EDC.mjs} +96 -42
  13. package/dist/chunk-KBUWZXFA.mjs +92 -0
  14. package/dist/chunk-LTV26KU4.mjs +141 -0
  15. package/dist/chunk-NTJSNNA7.mjs +175 -0
  16. package/dist/{chunk-QEMIORTL.mjs → chunk-OTBLZL2S.mjs} +1 -1
  17. package/dist/chunk-RBFWGDMY.mjs +30 -0
  18. package/dist/chunk-VRLIOKWG.mjs +11 -0
  19. package/dist/chunk-XGMJ4CG4.mjs +384 -0
  20. package/dist/chunk-Z7RFCADT.mjs +0 -0
  21. package/dist/chunk-ZPW742E7.mjs +28 -0
  22. package/dist/clay-codes-Ce9EmXfa.d.ts +129 -0
  23. package/dist/core/blobs.mjs +1 -1
  24. package/dist/core/chunk.d.ts +34 -0
  25. package/dist/core/chunk.mjs +17 -0
  26. package/dist/core/clients/ShelbyBlobClient.d.ts +121 -89
  27. package/dist/core/clients/ShelbyBlobClient.mjs +11 -3
  28. package/dist/core/clients/ShelbyClient.d.ts +71 -30
  29. package/dist/core/clients/ShelbyClient.mjs +14 -9
  30. package/dist/core/clients/ShelbyClientConfig.d.ts +43 -9
  31. package/dist/core/clients/ShelbyClientConfig.mjs +1 -0
  32. package/dist/core/clients/ShelbyRPCClient.d.ts +47 -20
  33. package/dist/core/clients/ShelbyRPCClient.mjs +10 -3
  34. package/dist/core/clients/index.d.ts +10 -5
  35. package/dist/core/clients/index.mjs +16 -10
  36. package/dist/core/clients/utils.d.ts +7 -0
  37. package/dist/core/clients/utils.mjs +7 -0
  38. package/dist/core/commitments.d.ts +18 -18
  39. package/dist/core/commitments.mjs +7 -5
  40. package/dist/core/constants.d.ts +24 -19
  41. package/dist/core/constants.mjs +15 -15
  42. package/dist/core/erasure/clay-codes.d.ts +2 -0
  43. package/dist/core/erasure/clay-codes.mjs +9 -0
  44. package/dist/core/erasure/constants.d.ts +48 -0
  45. package/dist/core/erasure/constants.mjs +17 -0
  46. package/dist/core/erasure/default.d.ts +6 -0
  47. package/dist/core/erasure/default.mjs +9 -0
  48. package/dist/core/erasure/index.d.ts +4 -0
  49. package/dist/core/erasure/index.mjs +27 -0
  50. package/dist/core/erasure/provider.d.ts +2 -0
  51. package/dist/core/erasure/provider.mjs +0 -0
  52. package/dist/core/erasure/reed-solomon.d.ts +2 -0
  53. package/dist/core/erasure/reed-solomon.mjs +7 -0
  54. package/dist/core/erasure/utils.d.ts +12 -0
  55. package/dist/core/erasure/utils.mjs +33 -0
  56. package/dist/core/index.d.ts +17 -8
  57. package/dist/core/index.mjs +83 -34
  58. package/dist/core/layout.mjs +4 -2
  59. package/dist/core/networks.d.ts +7 -0
  60. package/dist/core/networks.mjs +9 -0
  61. package/dist/core/operations/generated/sdk.d.ts +686 -0
  62. package/dist/core/operations/generated/sdk.mjs +23 -0
  63. package/dist/core/operations/index.d.ts +31 -0
  64. package/dist/core/operations/index.mjs +12 -0
  65. package/dist/core/strings.d.ts +6 -0
  66. package/dist/core/strings.mjs +9 -0
  67. package/dist/core/types/blobs.d.ts +49 -79
  68. package/dist/core/types/encodings.d.ts +5 -13
  69. package/dist/core/types/encodings.mjs +0 -1
  70. package/dist/core/types/index.d.ts +4 -2
  71. package/dist/core/types/index.mjs +1 -1
  72. package/dist/core/types/placement_groups.d.ts +15 -0
  73. package/dist/core/types/placement_groups.mjs +0 -0
  74. package/dist/core/types/storage_providers.d.ts +31 -0
  75. package/dist/core/types/storage_providers.mjs +1 -0
  76. package/dist/core/utils.d.ts +15 -3
  77. package/dist/core/utils.mjs +5 -3
  78. package/dist/node/clients/ShelbyMetadataClient.d.ts +72 -0
  79. package/dist/node/clients/ShelbyMetadataClient.mjs +9 -0
  80. package/dist/node/clients/ShelbyNodeClient.d.ts +8 -3
  81. package/dist/node/clients/ShelbyNodeClient.mjs +15 -10
  82. package/dist/node/clients/index.d.ts +12 -5
  83. package/dist/node/clients/index.mjs +20 -11
  84. package/dist/node/index.d.ts +18 -8
  85. package/dist/node/index.mjs +89 -36
  86. package/package.json +25 -12
  87. package/dist/chunk-5Z3RVWU3.mjs +0 -67
  88. package/dist/chunk-B3CB2YEO.mjs +0 -318
  89. package/dist/chunk-D2FERD4A.mjs +0 -39
  90. package/dist/chunk-G263DBCY.mjs +0 -105
  91. package/dist/chunk-P7BVGLTV.mjs +0 -32
  92. package/dist/chunk-QM5BVKLD.mjs +0 -109
  93. package/dist/core/erasure.d.ts +0 -6
  94. package/dist/core/erasure.mjs +0 -7
  95. /package/dist/{chunk-7S6RVKYB.mjs → chunk-MB7C7VQF.mjs} +0 -0
  96. /package/dist/{chunk-IHTPXUYI.mjs → chunk-MQUVYMNQ.mjs} +0 -0
  97. /package/dist/{chunk-PLUDE5C3.mjs → chunk-RNXGC54D.mjs} +0 -0
  98. /package/dist/{chunk-QKT5R735.mjs → chunk-TUANYVZQ.mjs} +0 -0
@@ -1,37 +1,43 @@
1
1
  import { Aptos, AccountAddress, AccountAddressInput, Account, InputGenerateTransactionOptions, PendingTransactionResponse, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
2
- import { BlobCommitments } from '../commitments.js';
3
2
  import { BlobName } from '../layout.js';
4
- import { BlobMetadata, BlobChunk, SignedChunkCommitment } from '../types/blobs.js';
5
- import { EncodingOptions } from '../types/encodings.js';
3
+ import { BlobMetadata, BlobActivity } from '../types/blobs.js';
4
+ import { ShelbyIndexerClient } from '../operations/index.js';
5
+ import { Blobs_Order_By, Blobs_Bool_Exp, Blob_Activities_Bool_Exp, Blob_Activities_Order_By } from '../operations/generated/sdk.js';
6
6
  import { ShelbyClientConfig } from './ShelbyClientConfig.js';
7
7
  import 'zod';
8
+ import '../../clay-codes-Ce9EmXfa.js';
9
+ import '@shelby-protocol/clay-codes';
10
+ import 'graphql-request';
11
+ import 'graphql';
12
+ import '../networks.js';
8
13
 
9
14
  interface WriteBlobCommitmentsOptions {
10
15
  build?: {
11
16
  options?: InputGenerateTransactionOptions;
12
17
  };
13
- encoding?: EncodingOptions;
14
- }
15
- interface ConfirmBlobChunksOptions {
16
- build?: {
17
- options?: InputGenerateTransactionOptions;
18
- };
19
- encoding?: EncodingOptions;
18
+ chunksetSizeBytes?: number;
20
19
  }
21
20
  declare class ShelbyBlobClient {
22
21
  readonly aptos: Aptos;
23
22
  readonly deployer: AccountAddress;
23
+ readonly indexer: ShelbyIndexerClient;
24
24
  /**
25
25
  * The ShelbyBlobClient is used to interact with the Shelby contract on the Aptos blockchain. This
26
- * includes functions like writing blob commitments, confirming chunks, and retrieving blob metadata.
26
+ * includes functions for registering blob commitments and retrieving blob metadata.
27
27
  *
28
- * @param config.aptos.config - The Aptos config.
29
- * @param config.shelbyDeployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
28
+ * @param config - The client configuration object.
29
+ * @param config.network - The Shelby network to use.
30
30
  *
31
31
  * @example
32
32
  * ```typescript
33
- * const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
34
- * const blobClient = new ShelbyBlobClient({ aptos });
33
+ * const blobClient = new ShelbyBlobClient({
34
+ * aptos: {
35
+ * network: Network.SHELBYNET,
36
+ * clientConfig: {
37
+ * API_KEY: "AG-***",
38
+ * },
39
+ * },
40
+ * });
35
41
  * ```
36
42
  */
37
43
  constructor(config: ShelbyClientConfig);
@@ -60,6 +66,8 @@ declare class ShelbyBlobClient {
60
66
  * blockchain.
61
67
  *
62
68
  * @param params.account - The account namespace the blobs are stored in (e.g. "0x1")
69
+ * @param params.pagination (optional) - The pagination options.
70
+ * @param params.orderBy (optional) - The order by clause to sort the blobs by.
63
71
  * @returns The blob metadata for all the blobs for the account.
64
72
  *
65
73
  * @example
@@ -72,11 +80,50 @@ declare class ShelbyBlobClient {
72
80
  */
73
81
  getAccountBlobs(params: {
74
82
  account: AccountAddressInput;
83
+ pagination?: {
84
+ limit?: number;
85
+ offset?: number;
86
+ };
87
+ orderBy?: Blobs_Order_By;
88
+ }): Promise<BlobMetadata[]>;
89
+ /**
90
+ * Retrieves blobs and their metadata from the blockchain.
91
+ *
92
+ * @param params.where (optional) - The where clause to filter the blobs by.
93
+ * @param params.pagination (optional) - The pagination options.
94
+ * @param params.orderBy (optional) - The order by clause to sort the blobs by.
95
+ * @returns The blob metadata for all the blobs that match the where clause.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * // BlobMetadata[]
100
+ * const blobs = await client.getBlobs({
101
+ * where: { owner: { _eq: AccountAddress.fromString("0x1").toString() } },
102
+ * });
103
+ * ```
104
+ */
105
+ getBlobs(params?: {
106
+ where?: Blobs_Bool_Exp;
107
+ pagination?: {
108
+ limit?: number;
109
+ offset?: number;
110
+ };
111
+ orderBy?: Blobs_Order_By;
75
112
  }): Promise<BlobMetadata[]>;
113
+ getBlobActivities(params: {
114
+ where?: Blob_Activities_Bool_Exp;
115
+ pagination?: {
116
+ limit?: number;
117
+ offset?: number;
118
+ };
119
+ orderBy?: Blob_Activities_Order_By;
120
+ }): Promise<BlobActivity[]>;
76
121
  /**
77
122
  * Retrieves the blob chunks for a given blob from the blockchain. The blob chunk will contain
78
123
  * the commitment, the storage provider location, and the status of the chunk (stored or pending).
79
124
  *
125
+ * @deprecated Will need to get reworked when we are acking blobs from storage providers.
126
+ *
80
127
  * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
81
128
  * @param params.name - The name of the blob (e.g. "foo/bar")
82
129
  * @returns The chunks that make up the blob.
@@ -92,116 +139,101 @@ declare class ShelbyBlobClient {
92
139
  * const isStored = chunks.every((c) => c.location.variant === "stored");
93
140
  * ```
94
141
  */
95
- getBlobChunks(params: {
142
+ getBlobChunks(_params: {
96
143
  account: AccountAddressInput;
97
144
  name: BlobName;
98
- }): Promise<BlobChunk[]>;
145
+ }): Promise<string[]>;
99
146
  /**
100
- * Writes the blob commitments to the blockchain.
101
- *
102
- * If `data` is provided instead of `blobCommitments`, the data will be encoded into commitments before being written
103
- * to the blockchain.
147
+ * Registers a blob on the blockchain by writing its merkle root and metadata.
104
148
  *
105
- * @param params.signer - The account that is signing the transaction.
106
- * @param params.blobName - The name of the blob (e.g. "foo/bar")
149
+ * @param params.account - The account that is signing and paying for the transaction.
150
+ * @param params.blobName - The name/path of the blob (e.g. "foo/bar.txt").
151
+ * @param params.blobMerkleRoot - The merkle root of the blob commitments.
152
+ * @param params.size - The size of the blob in bytes.
107
153
  * @param params.expirationMicros - The expiration time of the blob in microseconds.
108
- * @param params.options - Additional options for transaction building and encoding.
109
- * @param params.blobCommitments - The blob commitments to write to the blockchain (required if `data` is not provided).
110
- * @param params.data - The data to encode into commitments before writing to the blockchain (required if `blobCommitments` is not provided).
154
+ * @param params.options - Optional transaction building options.
155
+ * @param params.options.chunksetSizeBytes - Custom chunkset size (defaults to DEFAULT_CHUNKSET_SIZE_BYTES).
156
+ * @param params.options.build - Additional Aptos transaction building options.
111
157
  *
112
- * @returns The blob commitments and the pending transaction.
158
+ * @returns An object containing the pending transaction.
113
159
  *
114
160
  * @example
115
161
  * ```typescript
116
- * const blobCommitments = await generateCommitments(data);
162
+ * const provider = await ClayErasureCodingProvider.create();
163
+ * const blobCommitments = await generateCommitments(provider, data);
117
164
  *
118
- * const { blobCommitments, transaction } = await client.writeBlobCommitments({
119
- * signer,
165
+ * const { transaction } = await client.registerBlob({
166
+ * account: signer,
120
167
  * blobName: "foo/bar.txt",
121
- * blobCommitments,
168
+ * blobMerkleRoot: blobCommitments.blob_merkle_root,
169
+ * size: data.length,
122
170
  * expirationMicros: Date.now() * 1000 + 3600_000_000, // 1 hour from now in microseconds
123
171
  * });
124
172
  * ```
125
173
  */
126
- writeBlobCommitments(params: {
127
- blobCommitments: BlobCommitments;
128
- signer: Account;
174
+ registerBlob(params: {
175
+ account: Account;
129
176
  blobName: BlobName;
177
+ blobMerkleRoot: string;
178
+ size: number;
130
179
  expirationMicros: number;
131
180
  options?: WriteBlobCommitmentsOptions;
132
- }): Promise<{
133
- blobCommitments: BlobCommitments;
134
- transaction: PendingTransactionResponse;
135
- }>;
136
- /**
137
- * Confirms an array of signed chunk commitments for a blob. Once all chunks for a blob are confirmed, the blob is
138
- * considered "stored" and can be retrieved by RPC nodes.
139
- *
140
- * @param params.signer - The account that is signing the transaction.
141
- * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
142
- * @param params.blobName - The name of the blob (e.g. "foo/bar")
143
- * @param params.signedChunksetChunkCommitments - The signed chunk commitments, signed by their storage provider.
144
- * @param params.options - Additional options for transaction building and encoding.
145
- *
146
- * @returns The pending transaction response.
147
- *
148
- * @example
149
- * ```typescript
150
- * const { transaction } = await client.confirmBlobChunks({
151
- * signer,
152
- * account: AccountAddress.fromString("0x1"),
153
- * blobName: "foo/bar.txt",
154
- * signedChunksetChunkCommitments,
155
- * });
156
- * ```
157
- */
158
- confirmBlobChunks(params: {
159
- signer: Account;
160
- account: AccountAddressInput;
161
- blobName: BlobName;
162
- signedChunksetChunkCommitments: SignedChunkCommitment[][];
163
- options?: ConfirmBlobChunksOptions;
164
181
  }): Promise<{
165
182
  transaction: PendingTransactionResponse;
166
183
  }>;
167
184
  /**
168
- * Creates a transaction payload to write blob commitments to the blockchain.
169
- *
170
- * @param params.deployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
171
- * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
172
- * @param params.blobName - The name of the blob (e.g. "foo/bar")
173
- * @param params.blobMerkleRoot - The blob merkle root.
174
- * @param params.chunksetChunkCommitments - The chunk commitments for each chunkset.
185
+ * Creates a transaction payload to register a blob on the blockchain.
186
+ * This is a static helper method for constructing the Move function call payload.
187
+ *
188
+ * @param params.deployer - Optional deployer account address. Defaults to SHELBY_DEPLOYER.
189
+ * @param params.account - The account that will own the blob.
190
+ * @param params.blobName - The name/path of the blob (e.g. "foo/bar.txt").
191
+ * @param params.blobSize - The size of the blob in bytes.
192
+ * @param params.blobMerkleRoot - The merkle root of the blob commitments as a hex string.
175
193
  * @param params.expirationMicros - The expiration time of the blob in microseconds.
176
- * @param params.size - The size of the blob in bytes.
194
+ * @param params.numChunksets - The total number of chunksets in the blob.
195
+ *
196
+ * @returns An Aptos transaction payload data object for the register_blob Move function.
177
197
  *
178
- * @see https://github.com/JumpCrypto/shelby/blob/e009607aad330ccddb08d80bf9addfaadae7972b/move/prototype/move/sources/prototype_interface.move#L211-L220
198
+ * @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
179
199
  */
180
- static createWriteBlobCommitmentsPayload(params: {
200
+ static createRegisterBlobPayload(params: {
181
201
  deployer?: AccountAddress;
182
202
  account: AccountAddress;
183
203
  blobName: BlobName;
204
+ blobSize: number;
184
205
  blobMerkleRoot: string;
185
- chunksetChunkCommitments: string[][];
186
206
  expirationMicros: number;
187
- size: number;
207
+ numChunksets: number;
188
208
  }): InputGenerateTransactionPayloadData;
189
209
  /**
190
- * Creates a transaction payload to confirm the chunks of a blob.
210
+ * Creates a transaction payload to register multiple blobs on the blockchain.
211
+ * This is a static helper method for constructing the Move function call payload.
191
212
  *
192
- * @param params.deployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
193
- * @param params.account - The account namespace the blob is stored in (e.g. "0x1")
194
- * @param params.blobName - The name of the blob (e.g. "foo/bar")
195
- * @param params.signedChunksetChunkCommitments - The signed chunk commitments, signed by their storage provider.
213
+ * @param params.deployer - Optional deployer account address. Defaults to SHELBY_DEPLOYER.
214
+ * @param params.account - The account that will own the blobs.
215
+ * @param params.expirationMicros - The expiration time of the blobs in microseconds.
216
+ * @param params.blobs - The blobs to register.
217
+ * @param params.blobs.blobName - The name/path of the blob (e.g. "foo/bar.txt").
218
+ * @param params.blobs.blobSize - The size of the blob in bytes.
219
+ * @param params.blobs.blobMerkleRoot - The merkle root of the blob commitments as a hex string.
220
+ * @param params.blobs.numChunksets - The total number of chunksets in the blob.
221
+ *
222
+ * @returns An Aptos transaction payload data object for the register_multiple_blobs Move function.
196
223
  *
197
- * @see https://github.com/JumpCrypto/shelby/blob/e009607aad330ccddb08d80bf9addfaadae7972b/move/prototype/move/sources/prototype_interface.move#L343-L349
224
+ * @see https://github.com/shelby/shelby/blob/e08e84742cf2b80ad8bb7227deb3013398076d53/move/shelby_contract/sources/global_metadata.move#L357
198
225
  */
199
- static createConfirmBlobChunksPayload(params: {
226
+ static createBatchRegisterBlobsPayload(params: {
200
227
  deployer?: AccountAddress;
201
- account: AccountAddressInput;
202
- blobName: BlobName;
203
- signedChunksetChunkCommitments: SignedChunkCommitment[][];
228
+ account: AccountAddress;
229
+ expirationMicros: number;
230
+ blobs: {
231
+ blobName: BlobName;
232
+ blobSize: number;
233
+ blobMerkleRoot: string;
234
+ numChunksets: number;
235
+ }[];
204
236
  }): InputGenerateTransactionPayloadData;
205
237
  }
206
238
 
207
- export { type ConfirmBlobChunksOptions, ShelbyBlobClient, type WriteBlobCommitmentsOptions };
239
+ export { ShelbyBlobClient, type WriteBlobCommitmentsOptions };
@@ -1,8 +1,16 @@
1
1
  import {
2
2
  ShelbyBlobClient
3
- } from "../../chunk-B3CB2YEO.mjs";
4
- import "../../chunk-QEMIORTL.mjs";
5
- import "../../chunk-D2FERD4A.mjs";
3
+ } from "../../chunk-XGMJ4CG4.mjs";
4
+ import "../../chunk-75VHXY5P.mjs";
5
+ import "../../chunk-DLMDDEWF.mjs";
6
+ import "../../chunk-RBFWGDMY.mjs";
7
+ import "../../chunk-OTBLZL2S.mjs";
8
+ import "../../chunk-LTV26KU4.mjs";
9
+ import "../../chunk-KBUWZXFA.mjs";
10
+ import "../../chunk-HPVCKAN2.mjs";
11
+ import "../../chunk-APML3CGJ.mjs";
12
+ import "../../chunk-3ZDXWPYC.mjs";
13
+ import "../../chunk-ZPW742E7.mjs";
6
14
  import "../../chunk-7P6ASYW6.mjs";
7
15
  export {
8
16
  ShelbyBlobClient
@@ -1,15 +1,20 @@
1
- import { ShelbyBlobClient, WriteBlobCommitmentsOptions } from './ShelbyBlobClient.js';
2
- import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
1
+ import { WriteBlobCommitmentsOptions, ShelbyBlobClient } from './ShelbyBlobClient.js';
3
2
  import { Aptos, Account, AccountAddressInput } from '@aptos-labs/ts-sdk';
4
3
  import { ShelbyBlob } from '../blobs.js';
4
+ import { a as ErasureCodingProvider } from '../../clay-codes-Ce9EmXfa.js';
5
5
  import { BlobName } from '../layout.js';
6
6
  import { ShelbyClientConfig } from './ShelbyClientConfig.js';
7
7
  import { ShelbyRPCClient } from './ShelbyRPCClient.js';
8
- import '../commitments.js';
9
- import 'zod';
10
- import '../types/encodings.js';
11
8
  import '../types/blobs.js';
9
+ import '@shelby-protocol/clay-codes';
10
+ import 'zod';
11
+ import '../operations/index.js';
12
+ import '../operations/generated/sdk.js';
13
+ import 'graphql';
14
+ import 'graphql-request';
15
+ import '../networks.js';
12
16
 
17
+ type UploadOptions = WriteBlobCommitmentsOptions;
13
18
  declare class ShelbyClient {
14
19
  /**
15
20
  * The coordination client is used to interact with the Aptos blockchain which handles the commitments
@@ -19,6 +24,8 @@ declare class ShelbyClient {
19
24
  /**
20
25
  * The RPC client is used to interact with the Shelby RPC node which can be responsible for storing,
21
26
  * confirming, and retrieving blobs from the storage layer.
27
+ *
28
+ * If not provided, the default RPC client will be created.
22
29
  */
23
30
  readonly rpc: ShelbyRPCClient;
24
31
  /**
@@ -27,48 +34,82 @@ declare class ShelbyClient {
27
34
  readonly config: ShelbyClientConfig;
28
35
  /**
29
36
  * The Aptos client.
37
+ *
38
+ * If not provided, a default Aptos client will be created.
30
39
  */
31
40
  readonly aptos: Aptos;
32
41
  /**
33
- * The base class for Shelby clients
42
+ * The erasure coding provider used for encoding/decoding operations.
43
+ * Lazily initialized on first use if not provided.
44
+ */
45
+ private _provider?;
46
+ /**
47
+ * Creates a new ShelbyClient instance for interacting with the Shelby Protocol.
48
+ * This client combines blockchain operations (via coordination) and storage operations (via RPC).
49
+ *
50
+ * @param config - The client configuration object.
51
+ * @param config.aptos.config - The Aptos network configuration.
52
+ * @param config.shelby.rpc.baseUrl - The base URL of the Shelby RPC node (optional, defaults to devnet).
53
+ * @param config.shelby.indexer - The indexer configuration for GraphQL queries.
54
+ * @param provider - Optional erasure coding provider for encoding/decoding operations.
55
+ * If not provided, a ClayErasureCodingProvider will be created on first use.
56
+ * Pass a shared provider to reuse across multiple clients.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Basic usage (provider created automatically)
61
+ * const client = new ShelbyClient({
62
+ * network: Network.SHELBYNET,
63
+ * });
34
64
  *
35
- * @param config.aptos.config - The Aptos config.
36
- * @param config.shelby.baseUrl - The base URL of the Shelby RPC node. If not provided, the default base URL will be used.
65
+ * // Advanced: Share provider across multiple clients
66
+ * const provider = await ClayErasureCodingProvider.create();
67
+ * const mainnetClient = new ShelbyClient(mainnetConfig, provider);
68
+ * const devnetClient = new ShelbyClient(devnetConfig, provider);
69
+ * ```
37
70
  */
38
- constructor(config: ShelbyClientConfig);
71
+ constructor(config: ShelbyClientConfig, provider?: ErasureCodingProvider);
72
+ /**
73
+ * Get the erasure coding provider, creating it if necessary.
74
+ * This allows lazy initialization for users who don't provide a provider.
75
+ */
76
+ private getProvider;
39
77
  /**
40
78
  * The base URL for the Shelby RPC node.
41
79
  */
42
80
  get baseUrl(): string;
43
81
  /**
44
82
  * Uploads a blob to the Shelby network.
83
+ * This method handles the complete upload flow including commitment generation,
84
+ * blockchain registration, and storage upload.
85
+ *
86
+ * @param params.blobData - The raw data to upload as a Uint8Array.
87
+ * @param params.signer - The account that signs and pays for the transaction.
88
+ * @param params.blobName - The name/path of the blob (e.g. "folder/file.txt").
89
+ * @param params.expirationMicros - The expiration time in microseconds since Unix epoch.
90
+ * @param params.options - Optional upload configuration.
91
+ * @param params.options.chunksetSizeBytes - Custom chunkset size.
92
+ * @param params.options.build - Additional Aptos transaction options.
45
93
  *
46
- * @param params.blobData - The data to upload.
47
- * @param params.signer - The signer of the transaction.
48
- * @param params.blobName - The name of the blob.
49
- * @param params.expirationMicros - The expiration time of the blob in microseconds.
50
- * @param params.options - The options for the upload.
94
+ * @returns The transaction and generated blob commitments (when implemented).
51
95
  *
52
- * @returns The transaction and generated blob commitments.
96
+ * @example
97
+ * ```typescript
98
+ * await client.upload({
99
+ * blobData: Buffer.from("Hello, World!"),
100
+ * signer: account,
101
+ * blobName: "hello.txt",
102
+ * expirationMicros: Date.now() * 1000 + 86400_000_000 // 24 hours from now
103
+ * });
104
+ * ```
53
105
  */
54
106
  upload(params: {
55
- blobData: Buffer;
107
+ blobData: Uint8Array;
56
108
  signer: Account;
57
109
  blobName: BlobName;
58
110
  expirationMicros: number;
59
- options?: WriteBlobCommitmentsOptions;
60
- }): Promise<{
61
- transaction: _aptos_labs_ts_sdk.CommittedTransactionResponse;
62
- blobCommitments: {
63
- schema_version: string;
64
- raw_data_size: number;
65
- blob_merkle_root: string;
66
- chunkset_commitments: {
67
- chunkset_root: string | null;
68
- chunk_commitments: string[];
69
- }[];
70
- };
71
- }>;
111
+ options?: UploadOptions;
112
+ }): Promise<void>;
72
113
  /**
73
114
  * Downloads a blob from the Shelby RPC node.
74
115
  *
@@ -96,4 +137,4 @@ declare class ShelbyClient {
96
137
  }): Promise<ShelbyBlob>;
97
138
  }
98
139
 
99
- export { ShelbyClient };
140
+ export { ShelbyClient, type UploadOptions };
@@ -1,15 +1,20 @@
1
1
  import {
2
2
  ShelbyClient
3
- } from "../../chunk-QM5BVKLD.mjs";
4
- import "../../chunk-B3CB2YEO.mjs";
5
- import "../../chunk-2FF5FICZ.mjs";
6
- import "../../chunk-QEMIORTL.mjs";
7
- import "../../chunk-G263DBCY.mjs";
8
- import "../../chunk-5Z3RVWU3.mjs";
9
- import "../../chunk-P7BVGLTV.mjs";
10
- import "../../chunk-GGYTHP5F.mjs";
11
- import "../../chunk-D2FERD4A.mjs";
3
+ } from "../../chunk-6MDQI7PW.mjs";
4
+ import "../../chunk-XGMJ4CG4.mjs";
5
+ import "../../chunk-JSR44EDC.mjs";
6
+ import "../../chunk-75VHXY5P.mjs";
7
+ import "../../chunk-DLMDDEWF.mjs";
8
+ import "../../chunk-RBFWGDMY.mjs";
12
9
  import "../../chunk-I6NG5GNL.mjs";
10
+ import "../../chunk-OTBLZL2S.mjs";
11
+ import "../../chunk-LTV26KU4.mjs";
12
+ import "../../chunk-KBUWZXFA.mjs";
13
+ import "../../chunk-HPVCKAN2.mjs";
14
+ import "../../chunk-FIFKKWXV.mjs";
15
+ import "../../chunk-APML3CGJ.mjs";
16
+ import "../../chunk-3ZDXWPYC.mjs";
17
+ import "../../chunk-ZPW742E7.mjs";
13
18
  import "../../chunk-7P6ASYW6.mjs";
14
19
  export {
15
20
  ShelbyClient
@@ -1,13 +1,47 @@
1
- import { AptosConfig, AccountAddress } from '@aptos-labs/ts-sdk';
1
+ import { AptosSettings, AccountAddress } from '@aptos-labs/ts-sdk';
2
+ import { ShelbyNetwork } from '../networks.js';
2
3
 
4
+ /**
5
+ * Configuration for the Shelby RPC connection.
6
+ */
7
+ type ShelbyRPCConfig = {
8
+ /** Base URL of the Shelby RPC node (e.g., "https://api.shelbynet.shelby.xyz/shelby"). */
9
+ baseUrl?: string;
10
+ /** API key for authenticating with the RPC node. */
11
+ apiKey?: string;
12
+ };
13
+ /**
14
+ * Configuration for the Shelby indexer (GraphQL) connection.
15
+ */
16
+ interface ShelbyIndexerConfig {
17
+ /** Base URL of the indexer GraphQL endpoint. */
18
+ baseUrl?: string;
19
+ /** API key for authenticating with the indexer. */
20
+ apiKey?: string;
21
+ }
22
+ /**
23
+ * Complete configuration object for Shelby SDK clients.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const config: ShelbyClientConfig = {
28
+ * network: Network.SHELBYNET
29
+ * };
30
+ * ```
31
+ */
3
32
  interface ShelbyClientConfig {
4
- aptos: {
5
- config: AptosConfig;
6
- };
7
- shelby?: {
8
- baseUrl?: string;
9
- deployer?: AccountAddress;
10
- };
33
+ /** The Shelby network to use. */
34
+ network: ShelbyNetwork;
35
+ /** API key for authenticating with the Shelby services. */
36
+ apiKey?: string;
37
+ /** An optional Aptos blockchain configuration. If not provided, the default Aptos client will be used. */
38
+ aptos?: AptosSettings;
39
+ /** Custom deployer address for the Shelby smart contract (optional, defaults to SHELBY_DEPLOYER). */
40
+ deployer?: AccountAddress;
41
+ /** An optional RPC node configuration for blob storage operations. If not provided, the default RPC node will be used. */
42
+ rpc?: ShelbyRPCConfig;
43
+ /** An optional indexer configuration for GraphQL queries. If not provided, the default indexer will be used. */
44
+ indexer?: ShelbyIndexerConfig;
11
45
  }
12
46
 
13
- export type { ShelbyClientConfig };
47
+ export type { ShelbyClientConfig, ShelbyIndexerConfig, ShelbyRPCConfig };
@@ -0,0 +1 @@
1
+ import "../../chunk-Z7RFCADT.mjs";
@@ -1,40 +1,54 @@
1
1
  import { AccountAddressInput } from '@aptos-labs/ts-sdk';
2
2
  import { ShelbyBlob } from '../blobs.js';
3
3
  import { BlobName } from '../layout.js';
4
- import { ShelbyClientConfig } from './ShelbyClientConfig.js';
4
+ import { ShelbyIndexerClient } from '../operations/index.js';
5
+ import { ShelbyRPCConfig, ShelbyClientConfig } from './ShelbyClientConfig.js';
5
6
  import 'zod';
7
+ import '../operations/generated/sdk.js';
8
+ import 'graphql';
9
+ import 'graphql-request';
10
+ import '../networks.js';
6
11
 
7
12
  declare class ShelbyRPCClient {
8
13
  #private;
9
14
  readonly baseUrl: string;
15
+ readonly apiKey: string | undefined;
16
+ readonly rpcConfig: ShelbyRPCConfig;
17
+ readonly indexer: ShelbyIndexerClient;
10
18
  /**
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.
19
+ * Creates a new ShelbyRPCClient for interacting with Shelby RPC nodes.
20
+ * This client handles blob storage operations including upload and download.
14
21
  *
15
- * @param config.aptos.config - The Aptos config.
16
- * @param config.shelby.baseUrl - The base URL of the Shelby RPC node.
22
+ * @param config - The client configuration object.
23
+ * @param config.network - The Shelby network to use.
17
24
  *
18
25
  * @example
19
26
  * ```typescript
20
- * const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
21
- * const client = new ShelbyRPCClient({ aptos, shelby: { baseUrl: "https://api.shelby.dev" } });
27
+ * const client = new ShelbyRPCClient({
28
+ * network: Network.SHELBYNET,
29
+ * apiKey: "AG-***",
30
+ * });
22
31
  * ```
23
32
  */
24
33
  constructor(config: ShelbyClientConfig);
25
34
  /**
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.
35
+ * Uploads blob data to the Shelby RPC node for storage by storage providers.
36
+ * This method should be called after blob commitments have been registered on the blockchain.
37
+ * Uses multipart upload for efficient handling of large files.
28
38
  *
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.
39
+ * @param params.account - The account that owns the blob.
40
+ * @param params.blobName - The name/path of the blob (e.g. "folder/file.txt").
41
+ * @param params.blobData - The raw blob data as a Uint8Array.
32
42
  *
33
43
  * @example
34
44
  * ```typescript
35
45
  * const blobData = new TextEncoder().encode("Hello, world!");
36
46
  *
37
- * await client.putBlob({ account, blobName: "foo/bar.txt", blobData });
47
+ * await client.putBlob({
48
+ * account: AccountAddress.from("0x1"),
49
+ * blobName: "greetings/hello.txt",
50
+ * blobData
51
+ * });
38
52
  * ```
39
53
  */
40
54
  putBlob(params: {
@@ -44,18 +58,31 @@ declare class ShelbyRPCClient {
44
58
  }): Promise<void>;
45
59
  /**
46
60
  * Downloads a blob from the Shelby RPC node.
61
+ * Returns a streaming response with validation to ensure data integrity.
62
+ *
63
+ * @param params.account - The account that owns the blob.
64
+ * @param params.blobName - The name/path of the blob (e.g. "folder/file.txt").
65
+ * @param params.range - Optional byte range for partial downloads.
66
+ * @param params.range.start - Starting byte position (inclusive).
67
+ * @param params.range.end - Ending byte position (inclusive, optional).
47
68
  *
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.
69
+ * @returns A ShelbyBlob object containing the account, name, readable stream, and content length.
51
70
  *
52
- * @returns A `ShelbyBlob` object containing the blob data.
71
+ * @throws Error if the download fails or content length doesn't match.
53
72
  *
54
73
  * @example
55
74
  * ```typescript
75
+ * // Download entire blob
56
76
  * const blob = await client.getBlob({
57
- * account,
58
- * blobName: "foo/bar.txt",
77
+ * account: AccountAddress.from("0x1"),
78
+ * blobName: "documents/report.pdf"
79
+ * });
80
+ *
81
+ * // Download partial content (bytes 100-199)
82
+ * const partial = await client.getBlob({
83
+ * account: AccountAddress.from("0x1"),
84
+ * blobName: "large-file.bin",
85
+ * range: { start: 100, end: 199 }
59
86
  * });
60
87
  * ```
61
88
  */