@shelby-protocol/sdk 0.0.7 → 0.0.9

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 (49) hide show
  1. package/dist/browser/index.d.ts +3 -3
  2. package/dist/browser/index.mjs +49 -42
  3. package/dist/{chunk-7P3P3D3X.mjs → chunk-5I3MBJGN.mjs} +6 -6
  4. package/dist/chunk-67F5YZ25.mjs +28 -0
  5. package/dist/{chunk-HDYY6NS4.mjs → chunk-7UVMDCCR.mjs} +74 -7
  6. package/dist/{chunk-AUGZMI6U.mjs → chunk-BTHSKDJR.mjs} +57 -15
  7. package/dist/chunk-CPNZAQVY.mjs +29 -0
  8. package/dist/{chunk-FIFKKWXV.mjs → chunk-GY5DCVVL.mjs} +1 -1
  9. package/dist/{chunk-APML3CGJ.mjs → chunk-NLPIHQ7K.mjs} +17 -44
  10. package/dist/{chunk-3ZDXWPYC.mjs → chunk-PZF2VTGP.mjs} +5 -0
  11. package/dist/{chunk-GZJ5IOCG.mjs → chunk-QFWQ7FIC.mjs} +1 -1
  12. package/dist/{chunk-CTGCK3H2.mjs → chunk-WBFEX7OM.mjs} +2 -2
  13. package/dist/chunk-XNEIWM4O.mjs +0 -0
  14. package/dist/{chunk-PCNLFNAT.mjs → chunk-XWAPNLU6.mjs} +39 -13
  15. package/dist/{clay-codes-Ce9EmXfa.d.ts → clay-codes-pdZFxI_B.d.ts} +7 -0
  16. package/dist/core/chunk.mjs +1 -2
  17. package/dist/core/clients/ShelbyBlobClient.d.ts +51 -3
  18. package/dist/core/clients/ShelbyBlobClient.mjs +8 -5
  19. package/dist/core/clients/ShelbyClient.d.ts +23 -4
  20. package/dist/core/clients/ShelbyClient.mjs +12 -9
  21. package/dist/core/clients/ShelbyRPCClient.mjs +5 -6
  22. package/dist/core/clients/index.d.ts +1 -1
  23. package/dist/core/clients/index.mjs +14 -11
  24. package/dist/core/commitments.d.ts +30 -29
  25. package/dist/core/commitments.mjs +6 -5
  26. package/dist/core/erasure/clay-codes.d.ts +1 -1
  27. package/dist/core/erasure/clay-codes.mjs +2 -2
  28. package/dist/core/erasure/default.d.ts +1 -1
  29. package/dist/core/erasure/default.mjs +3 -2
  30. package/dist/core/erasure/index.d.ts +1 -1
  31. package/dist/core/erasure/index.mjs +7 -3
  32. package/dist/core/erasure/provider.d.ts +1 -1
  33. package/dist/core/erasure/reed-solomon.d.ts +1 -1
  34. package/dist/core/erasure/reed-solomon.mjs +1 -1
  35. package/dist/core/erasure/utils.d.ts +1 -1
  36. package/dist/core/index.d.ts +3 -3
  37. package/dist/core/index.mjs +49 -42
  38. package/dist/core/layout.mjs +2 -3
  39. package/dist/core/types/blobs.d.ts +19 -2
  40. package/dist/core/types/encodings.d.ts +1 -1
  41. package/dist/core/types/index.d.ts +2 -2
  42. package/dist/node/clients/ShelbyMetadataClient.mjs +1 -1
  43. package/dist/node/clients/ShelbyNodeClient.d.ts +1 -1
  44. package/dist/node/clients/ShelbyNodeClient.mjs +13 -10
  45. package/dist/node/clients/index.d.ts +1 -1
  46. package/dist/node/clients/index.mjs +16 -13
  47. package/dist/node/index.d.ts +3 -3
  48. package/dist/node/index.mjs +55 -48
  49. package/package.json +2 -2
@@ -5,17 +5,18 @@ import {
5
5
  } from "./chunk-4JZO2D7T.mjs";
6
6
  import {
7
7
  DEFAULT_CHUNKSET_SIZE_BYTES
8
- } from "./chunk-APML3CGJ.mjs";
8
+ } from "./chunk-67F5YZ25.mjs";
9
9
  import {
10
10
  DEFAULT_ERASURE_K,
11
11
  DEFAULT_ERASURE_M
12
12
  } from "./chunk-ZPW742E7.mjs";
13
13
 
14
14
  // src/core/commitments.ts
15
+ import { Hex } from "@aptos-labs/ts-sdk";
15
16
  import { z } from "zod";
16
17
  var ChunksetCommitmentSchema = z.object({
17
18
  // Chunkset root (vector commitment of child chunks)
18
- chunkset_root: z.string().nullable(),
19
+ chunkset_root: z.string(),
19
20
  // the size is known statically from the current configuration
20
21
  chunk_commitments: z.array(z.string())
21
22
  }).refine(
@@ -50,9 +51,34 @@ var BlobCommitmentsSchema = z.object({
50
51
  path: ["chunkset_commitments"]
51
52
  }
52
53
  );
54
+ async function generateMerkleRoot(leafHashes) {
55
+ if (!leafHashes.length) {
56
+ throw new Error(
57
+ "An empty array cannot be used to construct a Merkle tree."
58
+ );
59
+ }
60
+ const zeroArray = new Uint8Array(leafHashes[0].toUint8Array().length);
61
+ const zeroBytes = Hex.fromHexInput(zeroArray);
62
+ let currentLeaves = leafHashes;
63
+ while (currentLeaves.length > 1) {
64
+ if (currentLeaves.length % 2 !== 0) {
65
+ currentLeaves.push(zeroBytes);
66
+ }
67
+ const nextLeaves = [];
68
+ for (let i = 0; i < currentLeaves.length; i += 2) {
69
+ nextLeaves.push(
70
+ await concatHashes([
71
+ currentLeaves[i].toUint8Array(),
72
+ currentLeaves[i + 1].toUint8Array()
73
+ ])
74
+ );
75
+ }
76
+ currentLeaves = nextLeaves;
77
+ }
78
+ return currentLeaves[0];
79
+ }
53
80
  async function generateChunksetCommitments(shouldPad, chunksetIdx, chunksetData, expectedChunksetSize, provider, onChunk) {
54
81
  const { erasure_n } = provider.config;
55
- const chunkCommitments = [];
56
82
  const chunksetPayload = shouldPad ? zeroPadBytes(chunksetData, expectedChunksetSize) : validatePrePaddedChunkset(
57
83
  chunksetData,
58
84
  expectedChunksetSize,
@@ -64,23 +90,24 @@ async function generateChunksetCommitments(shouldPad, chunksetIdx, chunksetData,
64
90
  `Erasure provider produced ${chunks.length} chunks, expected ${erasure_n}.`
65
91
  );
66
92
  }
93
+ const chunkRoots = provider.getChunkMerkleRoots();
67
94
  let chunkIdx = 0;
68
95
  for (const chunkData of chunks) {
69
96
  if (onChunk !== void 0) {
70
97
  await onChunk(chunksetIdx, chunkIdx, chunkData);
71
98
  }
72
- const chunkHash = await concatHashes([chunkData]);
73
- chunkCommitments.push(chunkHash);
74
99
  chunkIdx += 1;
75
100
  }
76
- const h = await concatHashes(
77
- chunkCommitments.map((chunk) => chunk.toUint8Array())
101
+ const a = await generateMerkleRoot(
102
+ chunkRoots.map((a2) => Hex.fromHexInput(a2))
78
103
  );
79
104
  const entry = {
80
- chunkset_root: h.toString(),
81
- chunk_commitments: chunkCommitments.map((chunk) => chunk.toString())
105
+ chunkset_root: a.toString(),
106
+ chunk_commitments: chunkRoots.map(
107
+ (chunk) => Hex.fromHexInput(chunk).toString()
108
+ )
82
109
  };
83
- return { h, entry };
110
+ return { h: a, entry };
84
111
  }
85
112
  async function generateCommitments(provider, fullData, onChunk, options) {
86
113
  const expectedChunksetSize = DEFAULT_CHUNKSET_SIZE_BYTES;
@@ -118,9 +145,7 @@ async function generateCommitments(provider, fullData, onChunk, options) {
118
145
  return {
119
146
  schema_version: "1.3",
120
147
  raw_data_size: rawDataSize,
121
- blob_merkle_root: (await concatHashes(
122
- chunksetCommitmentHashes.map((chunk) => chunk.toUint8Array())
123
- )).toString(),
148
+ blob_merkle_root: (await generateMerkleRoot(chunksetCommitmentHashes)).toString(),
124
149
  chunkset_commitments: chunksetCommitments
125
150
  };
126
151
  }
@@ -137,5 +162,6 @@ export {
137
162
  ChunksetCommitmentSchema,
138
163
  expectedTotalChunksets,
139
164
  BlobCommitmentsSchema,
165
+ generateMerkleRoot,
140
166
  generateCommitments
141
167
  };
@@ -8,6 +8,7 @@ declare class ReedSolomonErasureCodingProvider implements ErasureCodingProvider
8
8
  constructor(options?: ReedSolomonProviderOptions);
9
9
  encode(data: Uint8Array): ChunkCollection;
10
10
  decode(_available: Uint8Array[], _config: DecodeConfig): ChunkCollection;
11
+ getChunkMerkleRoots(): Uint8Array[];
11
12
  }
12
13
 
13
14
  /**
@@ -72,6 +73,10 @@ interface ErasureCodingProvider {
72
73
  * @throws Error if fewer than k chunks are available
73
74
  */
74
75
  decode(available: Uint8Array[], config: DecodeConfig): ChunkCollection;
76
+ /**
77
+ * Get chunk roots.
78
+ */
79
+ getChunkMerkleRoots(): Uint8Array[];
75
80
  }
76
81
 
77
82
  interface ClayConfig extends ErasureCodingConfig, ClayErasureCodeParams {
@@ -107,6 +112,7 @@ declare class ClayErasureCodingProvider implements ErasureCodingProvider {
107
112
  readonly config: ClayConfig;
108
113
  private encoderCache?;
109
114
  private decoderCache?;
115
+ private lastFunction;
110
116
  private constructor();
111
117
  /**
112
118
  * Static factory method to create an initialized ClayErasureCodingProvider
@@ -114,6 +120,7 @@ declare class ClayErasureCodingProvider implements ErasureCodingProvider {
114
120
  static create<T extends ClayProviderOptions>(options?: T): Promise<ClayErasureCodingProvider>;
115
121
  encode(data: Uint8Array): ChunkCollection;
116
122
  decode(available: Uint8Array[], config: ClayDecodeConfig): ChunkCollection;
123
+ getChunkMerkleRoots(): Uint8Array[];
117
124
  /**
118
125
  * Determines if data can be erasure coded as-is or requires padding.
119
126
  *
@@ -4,8 +4,7 @@ import {
4
4
  DEFAULT_CHUNKSET_SIZE_BYTES,
5
5
  DEFAULT_CHUNK_SIZE_BYTES,
6
6
  ERASURE_CODE_AND_CHUNK_MAPPING
7
- } from "../chunk-APML3CGJ.mjs";
8
- import "../chunk-3ZDXWPYC.mjs";
7
+ } from "../chunk-67F5YZ25.mjs";
9
8
  import "../chunk-ZPW742E7.mjs";
10
9
  import "../chunk-7P6ASYW6.mjs";
11
10
  export {
@@ -1,11 +1,11 @@
1
1
  import { Aptos, AccountAddress, AccountAddressInput, Account, InputGenerateTransactionOptions, PendingTransactionResponse, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
2
2
  import { BlobName } from '../layout.js';
3
- import { BlobMetadata, BlobActivity } from '../types/blobs.js';
3
+ import { BlobMetadata, BlobActivity, StorageProviderAck } from '../types/blobs.js';
4
4
  import { ShelbyIndexerClient } from '../operations/index.js';
5
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';
8
+ import '../../clay-codes-pdZFxI_B.js';
9
9
  import '@shelby-protocol/clay-codes';
10
10
  import 'graphql-request';
11
11
  import 'graphql';
@@ -17,6 +17,11 @@ interface WriteBlobCommitmentsOptions {
17
17
  };
18
18
  chunksetSizeBytes?: number;
19
19
  }
20
+ interface AckTransactionOptions {
21
+ build?: {
22
+ options?: InputGenerateTransactionOptions;
23
+ };
24
+ }
20
25
  declare class ShelbyBlobClient {
21
26
  readonly aptos: Aptos;
22
27
  readonly deployer: AccountAddress;
@@ -185,6 +190,42 @@ declare class ShelbyBlobClient {
185
190
  }): Promise<{
186
191
  transaction: PendingTransactionResponse;
187
192
  }>;
193
+ /**
194
+ * Acks the blob chunksets on-chain. If each chunkset meets the necessary threshold, the entire blob will be marked as written.
195
+ *
196
+ * @param params.account - The account that is signing the transaction.
197
+ * @param params.blobOwner - The account that owns the blob.
198
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
199
+ * @param params.creationMicros - The creation time of the blob in microseconds.
200
+ * @param params.chunksetIdx - The index of the chunkset being acknowledged.
201
+ * @param params.storageProviderChunksetAcks - The signatures
202
+ * @param params.options - Additional options for transaction building and encoding.
203
+ *
204
+ * @returns The blob commitments and the pending transaction.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const { transaction } = await client.addChunksetAcknowledgements({
209
+ * account: signer,
210
+ * blobOwner: owner,
211
+ * blobName: "foo/bar.txt",
212
+ * creationMicros, // Taken from the blob metadata at registration time.
213
+ * chunksetIdx,
214
+ * storageProviderAcks: An array of StorageProviderAck types, each having the slot index and signature from the SP.
215
+ * });
216
+ * ```
217
+ */
218
+ addChunksetAcknowledgements(params: {
219
+ account: Account;
220
+ blobOwner: AccountAddress;
221
+ blobName: BlobName;
222
+ creationMicros: number;
223
+ chunksetIdx: number;
224
+ storageProviderAcks: StorageProviderAck[];
225
+ options?: AckTransactionOptions;
226
+ }): Promise<{
227
+ transaction: PendingTransactionResponse;
228
+ }>;
188
229
  /**
189
230
  * Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
190
231
  *
@@ -298,6 +339,13 @@ declare class ShelbyBlobClient {
298
339
  deployer?: AccountAddress;
299
340
  blobNameSuffix: string;
300
341
  }): InputGenerateTransactionPayloadData;
342
+ static createChunksetAcknowledgementsPayload(params: {
343
+ blobOwner: AccountAddress;
344
+ blobName: BlobName;
345
+ creationMicros: number;
346
+ chunksetIdx: number;
347
+ storageProviderAcks: StorageProviderAck[];
348
+ }): InputGenerateTransactionPayloadData;
301
349
  }
302
350
 
303
- export { ShelbyBlobClient, type WriteBlobCommitmentsOptions };
351
+ export { type AckTransactionOptions, ShelbyBlobClient, type WriteBlobCommitmentsOptions };
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  ShelbyBlobClient
3
- } from "../../chunk-HDYY6NS4.mjs";
3
+ } from "../../chunk-7UVMDCCR.mjs";
4
+ import "../../chunk-XNEIWM4O.mjs";
5
+ import "../../chunk-CPNZAQVY.mjs";
6
+ import "../../chunk-NLPIHQ7K.mjs";
7
+ import "../../chunk-PZF2VTGP.mjs";
4
8
  import "../../chunk-HFGEQP5N.mjs";
5
9
  import "../../chunk-WJKSPJSS.mjs";
6
10
  import "../../chunk-RBFWGDMY.mjs";
7
11
  import "../../chunk-OTBLZL2S.mjs";
8
- import "../../chunk-PCNLFNAT.mjs";
12
+ import "../../chunk-XWAPNLU6.mjs";
9
13
  import "../../chunk-4JZO2D7T.mjs";
10
- import "../../chunk-SEXQTDX6.mjs";
11
- import "../../chunk-APML3CGJ.mjs";
12
- import "../../chunk-3ZDXWPYC.mjs";
14
+ import "../../chunk-67F5YZ25.mjs";
13
15
  import "../../chunk-ZPW742E7.mjs";
16
+ import "../../chunk-SEXQTDX6.mjs";
14
17
  import "../../chunk-7P6ASYW6.mjs";
15
18
  export {
16
19
  ShelbyBlobClient
@@ -1,7 +1,7 @@
1
1
  import { WriteBlobCommitmentsOptions, ShelbyBlobClient } from './ShelbyBlobClient.js';
2
2
  import { Aptos, Account, AccountAddressInput } from '@aptos-labs/ts-sdk';
3
3
  import { ShelbyBlob } from '../blobs.js';
4
- import { a as ErasureCodingProvider } from '../../clay-codes-Ce9EmXfa.js';
4
+ import { a as ErasureCodingProvider } from '../../clay-codes-pdZFxI_B.js';
5
5
  import { BlobName } from '../layout.js';
6
6
  import { ShelbyClientConfig } from './ShelbyClientConfig.js';
7
7
  import { ShelbyRPCClient } from './ShelbyRPCClient.js';
@@ -181,16 +181,35 @@ declare class ShelbyClient {
181
181
  *
182
182
  * @example
183
183
  * ```typescript
184
- * const hash = await client.fundAccount({
184
+ * const hash = await client.fundAccountWithShelbyUSD({
185
185
  * address: "0x1",
186
186
  * amount: 100000000,
187
187
  * });
188
188
  * ```
189
189
  */
190
- fundAccount(params: {
190
+ fundAccountWithShelbyUSD(params: {
191
191
  address: AccountAddressInput;
192
192
  amount: number;
193
- }): Promise<any>;
193
+ }): Promise<string>;
194
+ /**
195
+ * Fund an account with APT tokens
196
+ *
197
+ * @param params.address - The address to fund
198
+ * @param params.amount - The amount to fund
199
+ * @returns The transaction hash of the funded account
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const hash = await client.fundAccountWithAPT({
204
+ * address: "0x1",
205
+ * amount: 100000000,
206
+ * });
207
+ * ```
208
+ */
209
+ fundAccountWithAPT(params: {
210
+ address: AccountAddressInput;
211
+ amount: number;
212
+ }): Promise<string>;
194
213
  }
195
214
 
196
215
  export { ShelbyClient, type UploadOptions };
@@ -1,20 +1,23 @@
1
1
  import {
2
2
  ShelbyClient
3
- } from "../../chunk-AUGZMI6U.mjs";
4
- import "../../chunk-7P3P3D3X.mjs";
5
- import "../../chunk-I6NG5GNL.mjs";
6
- import "../../chunk-HDYY6NS4.mjs";
3
+ } from "../../chunk-BTHSKDJR.mjs";
4
+ import "../../chunk-7UVMDCCR.mjs";
5
+ import "../../chunk-XNEIWM4O.mjs";
6
+ import "../../chunk-CPNZAQVY.mjs";
7
+ import "../../chunk-NLPIHQ7K.mjs";
8
+ import "../../chunk-PZF2VTGP.mjs";
9
+ import "../../chunk-5I3MBJGN.mjs";
7
10
  import "../../chunk-HFGEQP5N.mjs";
8
11
  import "../../chunk-WJKSPJSS.mjs";
12
+ import "../../chunk-GY5DCVVL.mjs";
13
+ import "../../chunk-I6NG5GNL.mjs";
9
14
  import "../../chunk-RBFWGDMY.mjs";
10
15
  import "../../chunk-OTBLZL2S.mjs";
11
- import "../../chunk-PCNLFNAT.mjs";
16
+ import "../../chunk-XWAPNLU6.mjs";
12
17
  import "../../chunk-4JZO2D7T.mjs";
13
- import "../../chunk-SEXQTDX6.mjs";
14
- import "../../chunk-FIFKKWXV.mjs";
15
- import "../../chunk-APML3CGJ.mjs";
16
- import "../../chunk-3ZDXWPYC.mjs";
18
+ import "../../chunk-67F5YZ25.mjs";
17
19
  import "../../chunk-ZPW742E7.mjs";
20
+ import "../../chunk-SEXQTDX6.mjs";
18
21
  import "../../chunk-7P6ASYW6.mjs";
19
22
  export {
20
23
  ShelbyClient
@@ -1,16 +1,15 @@
1
1
  import {
2
2
  ShelbyRPCClient
3
- } from "../../chunk-7P3P3D3X.mjs";
4
- import "../../chunk-I6NG5GNL.mjs";
3
+ } from "../../chunk-5I3MBJGN.mjs";
5
4
  import "../../chunk-HFGEQP5N.mjs";
6
5
  import "../../chunk-WJKSPJSS.mjs";
6
+ import "../../chunk-GY5DCVVL.mjs";
7
+ import "../../chunk-I6NG5GNL.mjs";
7
8
  import "../../chunk-RBFWGDMY.mjs";
8
9
  import "../../chunk-4JZO2D7T.mjs";
9
- import "../../chunk-SEXQTDX6.mjs";
10
- import "../../chunk-FIFKKWXV.mjs";
11
- import "../../chunk-APML3CGJ.mjs";
12
- import "../../chunk-3ZDXWPYC.mjs";
10
+ import "../../chunk-67F5YZ25.mjs";
13
11
  import "../../chunk-ZPW742E7.mjs";
12
+ import "../../chunk-SEXQTDX6.mjs";
14
13
  import "../../chunk-7P6ASYW6.mjs";
15
14
  export {
16
15
  ShelbyRPCClient
@@ -6,7 +6,7 @@ import '@aptos-labs/ts-sdk';
6
6
  import '../layout.js';
7
7
  import 'zod';
8
8
  import '../types/blobs.js';
9
- import '../../clay-codes-Ce9EmXfa.js';
9
+ import '../../clay-codes-pdZFxI_B.js';
10
10
  import '@shelby-protocol/clay-codes';
11
11
  import '../operations/index.js';
12
12
  import 'graphql-request';
@@ -1,26 +1,29 @@
1
1
  import "../../chunk-RNXGC54D.mjs";
2
2
  import {
3
3
  ShelbyClient
4
- } from "../../chunk-AUGZMI6U.mjs";
4
+ } from "../../chunk-BTHSKDJR.mjs";
5
+ import {
6
+ ShelbyBlobClient
7
+ } from "../../chunk-7UVMDCCR.mjs";
8
+ import "../../chunk-XNEIWM4O.mjs";
9
+ import "../../chunk-CPNZAQVY.mjs";
10
+ import "../../chunk-NLPIHQ7K.mjs";
11
+ import "../../chunk-PZF2VTGP.mjs";
5
12
  import "../../chunk-Z7RFCADT.mjs";
6
13
  import {
7
14
  ShelbyRPCClient
8
- } from "../../chunk-7P3P3D3X.mjs";
9
- import "../../chunk-I6NG5GNL.mjs";
10
- import {
11
- ShelbyBlobClient
12
- } from "../../chunk-HDYY6NS4.mjs";
15
+ } from "../../chunk-5I3MBJGN.mjs";
13
16
  import "../../chunk-HFGEQP5N.mjs";
14
17
  import "../../chunk-WJKSPJSS.mjs";
18
+ import "../../chunk-GY5DCVVL.mjs";
19
+ import "../../chunk-I6NG5GNL.mjs";
15
20
  import "../../chunk-RBFWGDMY.mjs";
16
21
  import "../../chunk-OTBLZL2S.mjs";
17
- import "../../chunk-PCNLFNAT.mjs";
22
+ import "../../chunk-XWAPNLU6.mjs";
18
23
  import "../../chunk-4JZO2D7T.mjs";
19
- import "../../chunk-SEXQTDX6.mjs";
20
- import "../../chunk-FIFKKWXV.mjs";
21
- import "../../chunk-APML3CGJ.mjs";
22
- import "../../chunk-3ZDXWPYC.mjs";
24
+ import "../../chunk-67F5YZ25.mjs";
23
25
  import "../../chunk-ZPW742E7.mjs";
26
+ import "../../chunk-SEXQTDX6.mjs";
24
27
  import "../../chunk-7P6ASYW6.mjs";
25
28
  export {
26
29
  ShelbyBlobClient,
@@ -1,45 +1,39 @@
1
+ import { Hex } from '@aptos-labs/ts-sdk';
1
2
  import { z } from 'zod';
2
- import { a as ErasureCodingProvider } from '../clay-codes-Ce9EmXfa.js';
3
+ import { a as ErasureCodingProvider } from '../clay-codes-pdZFxI_B.js';
3
4
  import '@shelby-protocol/clay-codes';
4
5
 
5
6
  /**
6
7
  * Defines the schema for the commitment format in commitments.json
7
8
  * This is used for `shelby encode` and oher commands
8
9
  *
9
- * We use a k-ary merkle tree
10
- *
11
- * ```text
12
- * blob_merkle_root
13
- * / \
14
- * chunkset_root_0 chunkset_root_1
15
- * / / | \ \ / / | \ \
16
- * H(c0) ... H(c4) H(c5) ... H(c9)
10
+ * We use a binary merkle tree of the samples of the blob's chunksets.
17
11
  *
18
12
  * Definitions:
19
- * - c0...c9 = chunk_0 ... chunk_9
20
- * - H(c0) = SHA-256(c0) // TODO if this should be SHA3-256 or other hash
21
- * - chunkset_root_0 = H( H(c0) ... H(c4) )
22
- * - blob_merkle_root = H( chunkset_root_0 chunkset_root_1 )
23
- * - indicates binary concatenation
13
+ * - P = H(C0//C1) (concatenate the two children, and use H to form a parent node)
14
+ * H currently SHA256
15
+ * - If the right child doesn't exist, use zeros.
16
+ * - blob_merkle_root = the P of the final two children
17
+ * - // indicates binary concatenation
24
18
  * ```
25
19
  */
26
20
  /**
27
21
  * Represents the (serializable) commitment schema for a single chunkset.
28
22
  */
29
23
  declare const ChunksetCommitmentSchema: z.ZodEffects<z.ZodObject<{
30
- chunkset_root: z.ZodNullable<z.ZodString>;
24
+ chunkset_root: z.ZodString;
31
25
  chunk_commitments: z.ZodArray<z.ZodString, "many">;
32
26
  }, "strip", z.ZodTypeAny, {
33
- chunkset_root: string | null;
27
+ chunkset_root: string;
34
28
  chunk_commitments: string[];
35
29
  }, {
36
- chunkset_root: string | null;
30
+ chunkset_root: string;
37
31
  chunk_commitments: string[];
38
32
  }>, {
39
- chunkset_root: string | null;
33
+ chunkset_root: string;
40
34
  chunk_commitments: string[];
41
35
  }, {
42
- chunkset_root: string | null;
36
+ chunkset_root: string;
43
37
  chunk_commitments: string[];
44
38
  }>;
45
39
  type ChunksetCommitment = z.infer<typeof ChunksetCommitmentSchema>;
@@ -52,19 +46,19 @@ declare const BlobCommitmentsSchema: z.ZodEffects<z.ZodObject<{
52
46
  raw_data_size: z.ZodNumber;
53
47
  blob_merkle_root: z.ZodString;
54
48
  chunkset_commitments: z.ZodArray<z.ZodEffects<z.ZodObject<{
55
- chunkset_root: z.ZodNullable<z.ZodString>;
49
+ chunkset_root: z.ZodString;
56
50
  chunk_commitments: z.ZodArray<z.ZodString, "many">;
57
51
  }, "strip", z.ZodTypeAny, {
58
- chunkset_root: string | null;
52
+ chunkset_root: string;
59
53
  chunk_commitments: string[];
60
54
  }, {
61
- chunkset_root: string | null;
55
+ chunkset_root: string;
62
56
  chunk_commitments: string[];
63
57
  }>, {
64
- chunkset_root: string | null;
58
+ chunkset_root: string;
65
59
  chunk_commitments: string[];
66
60
  }, {
67
- chunkset_root: string | null;
61
+ chunkset_root: string;
68
62
  chunk_commitments: string[];
69
63
  }>, "many">;
70
64
  }, "strip", z.ZodTypeAny, {
@@ -72,7 +66,7 @@ declare const BlobCommitmentsSchema: z.ZodEffects<z.ZodObject<{
72
66
  raw_data_size: number;
73
67
  blob_merkle_root: string;
74
68
  chunkset_commitments: {
75
- chunkset_root: string | null;
69
+ chunkset_root: string;
76
70
  chunk_commitments: string[];
77
71
  }[];
78
72
  }, {
@@ -80,7 +74,7 @@ declare const BlobCommitmentsSchema: z.ZodEffects<z.ZodObject<{
80
74
  raw_data_size: number;
81
75
  blob_merkle_root: string;
82
76
  chunkset_commitments: {
83
- chunkset_root: string | null;
77
+ chunkset_root: string;
84
78
  chunk_commitments: string[];
85
79
  }[];
86
80
  }>, {
@@ -88,7 +82,7 @@ declare const BlobCommitmentsSchema: z.ZodEffects<z.ZodObject<{
88
82
  raw_data_size: number;
89
83
  blob_merkle_root: string;
90
84
  chunkset_commitments: {
91
- chunkset_root: string | null;
85
+ chunkset_root: string;
92
86
  chunk_commitments: string[];
93
87
  }[];
94
88
  }, {
@@ -96,7 +90,7 @@ declare const BlobCommitmentsSchema: z.ZodEffects<z.ZodObject<{
96
90
  raw_data_size: number;
97
91
  blob_merkle_root: string;
98
92
  chunkset_commitments: {
99
- chunkset_root: string | null;
93
+ chunkset_root: string;
100
94
  chunk_commitments: string[];
101
95
  }[];
102
96
  }>;
@@ -109,6 +103,13 @@ interface GenerateCommitmentsOptions {
109
103
  */
110
104
  pad?: boolean;
111
105
  }
106
+ /**
107
+ * Create the merkle root of the tree based on the hashes in the parameter. Non-existent siblings use the zero hash.
108
+ *
109
+ * @param leafHashes The hashes forming the leaves of the merkle tree.
110
+ * @returns The root of the Merkle tree.
111
+ */
112
+ declare function generateMerkleRoot(leafHashes: Hex[]): Promise<Hex>;
112
113
  /**
113
114
  * Generates the blob commitments for a given data stream.
114
115
  *
@@ -128,4 +129,4 @@ interface GenerateCommitmentsOptions {
128
129
  */
129
130
  declare function generateCommitments(provider: ErasureCodingProvider, fullData: ReadableStream<Uint8Array> | Uint8Array, onChunk?: (chunksetIdx: number, chunkIdx: number, chunkData: Uint8Array) => Promise<void> | void, options?: GenerateCommitmentsOptions): Promise<BlobCommitments>;
130
131
 
131
- export { type BlobCommitments, BlobCommitmentsSchema, type ChunksetCommitment, ChunksetCommitmentSchema, type GenerateCommitmentsOptions, expectedTotalChunksets, generateCommitments };
132
+ export { type BlobCommitments, BlobCommitmentsSchema, type ChunksetCommitment, ChunksetCommitmentSchema, type GenerateCommitmentsOptions, expectedTotalChunksets, generateCommitments, generateMerkleRoot };
@@ -2,16 +2,17 @@ import {
2
2
  BlobCommitmentsSchema,
3
3
  ChunksetCommitmentSchema,
4
4
  expectedTotalChunksets,
5
- generateCommitments
6
- } from "../chunk-PCNLFNAT.mjs";
5
+ generateCommitments,
6
+ generateMerkleRoot
7
+ } from "../chunk-XWAPNLU6.mjs";
7
8
  import "../chunk-4JZO2D7T.mjs";
8
- import "../chunk-APML3CGJ.mjs";
9
- import "../chunk-3ZDXWPYC.mjs";
9
+ import "../chunk-67F5YZ25.mjs";
10
10
  import "../chunk-ZPW742E7.mjs";
11
11
  import "../chunk-7P6ASYW6.mjs";
12
12
  export {
13
13
  BlobCommitmentsSchema,
14
14
  ChunksetCommitmentSchema,
15
15
  expectedTotalChunksets,
16
- generateCommitments
16
+ generateCommitments,
17
+ generateMerkleRoot
17
18
  };
@@ -1,2 +1,2 @@
1
1
  import '@shelby-protocol/clay-codes';
2
- export { e as ClayConfig, g as ClayDecodeConfig, f as ClayErasureCodeParams, C as ClayErasureCodingProvider, b as ClayProviderOptions } from '../../clay-codes-Ce9EmXfa.js';
2
+ export { e as ClayConfig, g as ClayDecodeConfig, f as ClayErasureCodeParams, C as ClayErasureCodingProvider, b as ClayProviderOptions } from '../../clay-codes-pdZFxI_B.js';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ClayErasureCodingProvider
3
- } from "../../chunk-APML3CGJ.mjs";
4
- import "../../chunk-3ZDXWPYC.mjs";
3
+ } from "../../chunk-NLPIHQ7K.mjs";
4
+ import "../../chunk-67F5YZ25.mjs";
5
5
  import "../../chunk-ZPW742E7.mjs";
6
6
  import "../../chunk-7P6ASYW6.mjs";
7
7
  export {
@@ -1,4 +1,4 @@
1
- import { C as ClayErasureCodingProvider } from '../../clay-codes-Ce9EmXfa.js';
1
+ import { C as ClayErasureCodingProvider } from '../../clay-codes-pdZFxI_B.js';
2
2
  import '@shelby-protocol/clay-codes';
3
3
 
4
4
  declare function createDefaultErasureCodingProvider(): Promise<ClayErasureCodingProvider>;
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  createDefaultErasureCodingProvider
3
- } from "../../chunk-APML3CGJ.mjs";
4
- import "../../chunk-3ZDXWPYC.mjs";
3
+ } from "../../chunk-CPNZAQVY.mjs";
4
+ import "../../chunk-NLPIHQ7K.mjs";
5
+ import "../../chunk-67F5YZ25.mjs";
5
6
  import "../../chunk-ZPW742E7.mjs";
6
7
  import "../../chunk-7P6ASYW6.mjs";
7
8
  export {
@@ -1,4 +1,4 @@
1
- export { C as ClayErasureCodingProvider, D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, R as ReedSolomonErasureCodingProvider } from '../../clay-codes-Ce9EmXfa.js';
1
+ export { C as ClayErasureCodingProvider, D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, R as ReedSolomonErasureCodingProvider } from '../../clay-codes-pdZFxI_B.js';
2
2
  export { DEFAULT_ERASURE_D, DEFAULT_ERASURE_K, DEFAULT_ERASURE_M, DEFAULT_ERASURE_N, ERASURE_CODE_PARAMS, ErasureCodeParams, ErasureCodingScheme, ErasureSchemeParams } from './constants.js';
3
3
  export { createDefaultErasureCodingProvider } from './default.js';
4
4
  import '@shelby-protocol/clay-codes';
@@ -1,10 +1,14 @@
1
+ import "../../chunk-XNEIWM4O.mjs";
1
2
  import {
2
- ClayErasureCodingProvider,
3
3
  createDefaultErasureCodingProvider
4
- } from "../../chunk-APML3CGJ.mjs";
4
+ } from "../../chunk-CPNZAQVY.mjs";
5
+ import {
6
+ ClayErasureCodingProvider
7
+ } from "../../chunk-NLPIHQ7K.mjs";
5
8
  import {
6
9
  ReedSolomonErasureCodingProvider
7
- } from "../../chunk-3ZDXWPYC.mjs";
10
+ } from "../../chunk-PZF2VTGP.mjs";
11
+ import "../../chunk-67F5YZ25.mjs";
8
12
  import {
9
13
  DEFAULT_ERASURE_D,
10
14
  DEFAULT_ERASURE_K,
@@ -1,2 +1,2 @@
1
1
  import '@shelby-protocol/clay-codes';
2
- export { D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, I as InitConfig } from '../../clay-codes-Ce9EmXfa.js';
2
+ export { D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, I as InitConfig } from '../../clay-codes-pdZFxI_B.js';
@@ -1,2 +1,2 @@
1
1
  import '@shelby-protocol/clay-codes';
2
- export { c as ReedSolomonConfig, R as ReedSolomonErasureCodingProvider, d as ReedSolomonProviderOptions } from '../../clay-codes-Ce9EmXfa.js';
2
+ export { c as ReedSolomonConfig, R as ReedSolomonErasureCodingProvider, d as ReedSolomonProviderOptions } from '../../clay-codes-pdZFxI_B.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ReedSolomonErasureCodingProvider
3
- } from "../../chunk-3ZDXWPYC.mjs";
3
+ } from "../../chunk-PZF2VTGP.mjs";
4
4
  import "../../chunk-7P6ASYW6.mjs";
5
5
  export {
6
6
  ReedSolomonErasureCodingProvider