@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,16 +5,16 @@ export { ShelbyBlobClient } from '../core/clients/ShelbyBlobClient.js';
5
5
  export { ShelbyClient, UploadOptions } from '../core/clients/ShelbyClient.js';
6
6
  export { ShelbyClientConfig, ShelbyIndexerConfig, ShelbyRPCConfig } from '../core/clients/ShelbyClientConfig.js';
7
7
  export { ShelbyRPCClient } from '../core/clients/ShelbyRPCClient.js';
8
- export { BlobCommitments, BlobCommitmentsSchema, ChunksetCommitment, ChunksetCommitmentSchema, GenerateCommitmentsOptions, expectedTotalChunksets, generateCommitments } from '../core/commitments.js';
8
+ export { BlobCommitments, BlobCommitmentsSchema, ChunksetCommitment, ChunksetCommitmentSchema, GenerateCommitmentsOptions, expectedTotalChunksets, generateCommitments, generateMerkleRoot } from '../core/commitments.js';
9
9
  export { DEFAULT_PROJECT_DESCRIPTION, DEFAULT_PROJECT_NAME, NetworkToShelbyBlobIndexerBaseUrl, NetworkToShelbyRPCBaseUrl, SHELBYUSD_FA_METADATA_ADDRESS, SHELBYUSD_TOKEN_ADDRESS, SHELBYUSD_TOKEN_MODULE, SHELBYUSD_TOKEN_NAME, SHELBY_DEPLOYER, TOKEN_DEPLOYER, TOKEN_OBJECT_ADDRESS } from '../core/constants.js';
10
- export { C as ClayErasureCodingProvider, D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, R as ReedSolomonErasureCodingProvider } from '../clay-codes-Ce9EmXfa.js';
10
+ export { C as ClayErasureCodingProvider, D as DecodeConfig, E as ErasureCodingConfig, a as ErasureCodingProvider, R as ReedSolomonErasureCodingProvider } from '../clay-codes-pdZFxI_B.js';
11
11
  export { DEFAULT_ERASURE_D, DEFAULT_ERASURE_K, DEFAULT_ERASURE_M, DEFAULT_ERASURE_N, ERASURE_CODE_PARAMS, ErasureCodeParams, ErasureCodingScheme, ErasureSchemeParams } from '../core/erasure/constants.js';
12
12
  export { createDefaultErasureCodingProvider } from '../core/erasure/default.js';
13
13
  export { BlobName, BlobNameSchema, ChunkKey, allChunksForBlob, roundSize } from '../core/layout.js';
14
14
  export { ShelbyNetwork, isShelbyNetwork, shelbyNetworks } from '../core/networks.js';
15
15
  export { ShelbyIndexerClient, createShelbyIndexerClient, getShelbyIndexerClient } from '../core/operations/index.js';
16
16
  export { getShelbyAccountBlobsExplorerUrl, getShelbyAccountExplorerUrl, getShelbyBlobExplorerUrl } from '../core/shelby-explorer.js';
17
- export { BlobActivity, BlobActivityType, BlobEncoding, BlobMetadata, ClayEncoding } from '../core/types/blobs.js';
17
+ export { BlobActivity, BlobActivityType, BlobEncoding, BlobMetadata, ClayEncoding, StorageProviderAck } from '../core/types/blobs.js';
18
18
  export { StorageProviderInfo } from '../core/types/storage_providers.js';
19
19
  export { buildRequestUrl, concatHashes, getBlobNameSuffix, readInChunks, zeroPadBytes } from '../core/utils.js';
20
20
  export { Bigint_Comparison_Exp, Blob_Activities, Blob_Activities_Aggregate, Blob_Activities_Aggregate_Fields, Blob_Activities_Aggregate_FieldsCountArgs, Blob_Activities_Avg_Fields, Blob_Activities_Bool_Exp, Blob_Activities_Max_Fields, Blob_Activities_Min_Fields, Blob_Activities_Order_By, Blob_Activities_Select_Column, Blob_Activities_Stddev_Fields, Blob_Activities_Stddev_Pop_Fields, Blob_Activities_Stddev_Samp_Fields, Blob_Activities_Stream_Cursor_Input, Blob_Activities_Stream_Cursor_Value_Input, Blob_Activities_Sum_Fields, Blob_Activities_Var_Pop_Fields, Blob_Activities_Var_Samp_Fields, Blob_Activities_Variance_Fields, Blobs, BlobsPlacement_Group_SlotsArgs, Blobs_Aggregate, Blobs_Aggregate_Fields, Blobs_Aggregate_FieldsCountArgs, Blobs_Avg_Fields, Blobs_Bool_Exp, Blobs_Max_Fields, Blobs_Min_Fields, Blobs_Order_By, Blobs_Select_Column, Blobs_Stddev_Fields, Blobs_Stddev_Pop_Fields, Blobs_Stddev_Samp_Fields, Blobs_Stream_Cursor_Input, Blobs_Stream_Cursor_Value_Input, Blobs_Sum_Fields, Blobs_Var_Pop_Fields, Blobs_Var_Samp_Fields, Blobs_Variance_Fields, Cursor_Ordering, Exact, GetBlobActivitiesCountDocument, GetBlobActivitiesCountQuery, GetBlobActivitiesCountQueryVariables, GetBlobActivitiesDocument, GetBlobActivitiesQuery, GetBlobActivitiesQueryVariables, GetBlobsCountDocument, GetBlobsCountQuery, GetBlobsCountQueryVariables, GetBlobsDocument, GetBlobsQuery, GetBlobsQueryVariables, Incremental, InputMaybe, MakeEmpty, MakeMaybe, MakeOptional, Maybe, Numeric_Comparison_Exp, Order_By, Placement_Group_Slots, Placement_Group_Slots_Aggregate_Order_By, Placement_Group_Slots_Avg_Order_By, Placement_Group_Slots_Bool_Exp, Placement_Group_Slots_Max_Order_By, Placement_Group_Slots_Min_Order_By, Placement_Group_Slots_Order_By, Placement_Group_Slots_Select_Column, Placement_Group_Slots_Stddev_Order_By, Placement_Group_Slots_Stddev_Pop_Order_By, Placement_Group_Slots_Stddev_Samp_Order_By, Placement_Group_Slots_Stream_Cursor_Input, Placement_Group_Slots_Stream_Cursor_Value_Input, Placement_Group_Slots_Sum_Order_By, Placement_Group_Slots_Var_Pop_Order_By, Placement_Group_Slots_Var_Samp_Order_By, Placement_Group_Slots_Variance_Order_By, Processor_Status, Processor_Status_Bool_Exp, Processor_Status_Order_By, Processor_Status_Select_Column, Processor_Status_Stream_Cursor_Input, Processor_Status_Stream_Cursor_Value_Input, Query_Root, Query_RootBlob_ActivitiesArgs, Query_RootBlob_Activities_AggregateArgs, Query_RootBlob_Activities_By_PkArgs, Query_RootBlobsArgs, Query_RootBlobs_AggregateArgs, Query_RootBlobs_By_PkArgs, Query_RootPlacement_Group_SlotsArgs, Query_RootPlacement_Group_Slots_By_PkArgs, Query_RootProcessor_StatusArgs, Scalars, Sdk, SdkFunctionWrapper, String_Comparison_Exp, Subscription_Root, Subscription_RootBlob_ActivitiesArgs, Subscription_RootBlob_Activities_AggregateArgs, Subscription_RootBlob_Activities_By_PkArgs, Subscription_RootBlob_Activities_StreamArgs, Subscription_RootBlobsArgs, Subscription_RootBlobs_AggregateArgs, Subscription_RootBlobs_By_PkArgs, Subscription_RootBlobs_StreamArgs, Subscription_RootPlacement_Group_SlotsArgs, Subscription_RootPlacement_Group_Slots_By_PkArgs, Subscription_RootPlacement_Group_Slots_StreamArgs, Subscription_RootProcessor_StatusArgs, Subscription_RootProcessor_Status_StreamArgs, Timestamp_Comparison_Exp, getSdk } from '../core/operations/generated/sdk.js';
@@ -5,24 +5,24 @@ import "../chunk-ZHXCVRZX.mjs";
5
5
  import "../chunk-RNXGC54D.mjs";
6
6
  import {
7
7
  ShelbyClient
8
- } from "../chunk-AUGZMI6U.mjs";
9
- import "../chunk-Z7RFCADT.mjs";
8
+ } from "../chunk-BTHSKDJR.mjs";
10
9
  import {
11
- ShelbyRPCClient
12
- } from "../chunk-7P3P3D3X.mjs";
10
+ ShelbyBlobClient
11
+ } from "../chunk-7UVMDCCR.mjs";
12
+ import "../chunk-XNEIWM4O.mjs";
13
13
  import {
14
- isShelbyNetwork,
15
- shelbyNetworks
16
- } from "../chunk-VRLIOKWG.mjs";
17
- import "../chunk-I6NG5GNL.mjs";
14
+ createDefaultErasureCodingProvider
15
+ } from "../chunk-CPNZAQVY.mjs";
18
16
  import {
19
- getShelbyAccountBlobsExplorerUrl,
20
- getShelbyAccountExplorerUrl,
21
- getShelbyBlobExplorerUrl
22
- } from "../chunk-BDSW5PHM.mjs";
17
+ ClayErasureCodingProvider
18
+ } from "../chunk-NLPIHQ7K.mjs";
23
19
  import {
24
- ShelbyBlobClient
25
- } from "../chunk-HDYY6NS4.mjs";
20
+ ReedSolomonErasureCodingProvider
21
+ } from "../chunk-PZF2VTGP.mjs";
22
+ import "../chunk-Z7RFCADT.mjs";
23
+ import {
24
+ ShelbyRPCClient
25
+ } from "../chunk-5I3MBJGN.mjs";
26
26
  import {
27
27
  createShelbyIndexerClient,
28
28
  getShelbyIndexerClient
@@ -40,6 +40,22 @@ import {
40
40
  Processor_Status_Select_Column,
41
41
  getSdk
42
42
  } from "../chunk-WJKSPJSS.mjs";
43
+ import {
44
+ BlobNameSchema,
45
+ ChunkKey,
46
+ allChunksForBlob,
47
+ roundSize
48
+ } from "../chunk-GY5DCVVL.mjs";
49
+ import {
50
+ isShelbyNetwork,
51
+ shelbyNetworks
52
+ } from "../chunk-VRLIOKWG.mjs";
53
+ import "../chunk-I6NG5GNL.mjs";
54
+ import {
55
+ getShelbyAccountBlobsExplorerUrl,
56
+ getShelbyAccountExplorerUrl,
57
+ getShelbyBlobExplorerUrl
58
+ } from "../chunk-BDSW5PHM.mjs";
43
59
  import "../chunk-RBFWGDMY.mjs";
44
60
  import {
45
61
  getAptosAccountExplorerUrl,
@@ -52,8 +68,9 @@ import {
52
68
  BlobCommitmentsSchema,
53
69
  ChunksetCommitmentSchema,
54
70
  expectedTotalChunksets,
55
- generateCommitments
56
- } from "../chunk-PCNLFNAT.mjs";
71
+ generateCommitments,
72
+ generateMerkleRoot
73
+ } from "../chunk-XWAPNLU6.mjs";
57
74
  import {
58
75
  buildRequestUrl,
59
76
  concatHashes,
@@ -61,37 +78,13 @@ import {
61
78
  readInChunks,
62
79
  zeroPadBytes
63
80
  } from "../chunk-4JZO2D7T.mjs";
64
- import {
65
- DEFAULT_PROJECT_DESCRIPTION,
66
- DEFAULT_PROJECT_NAME,
67
- NetworkToShelbyBlobIndexerBaseUrl,
68
- NetworkToShelbyRPCBaseUrl,
69
- SHELBYUSD_FA_METADATA_ADDRESS,
70
- SHELBYUSD_TOKEN_ADDRESS,
71
- SHELBYUSD_TOKEN_MODULE,
72
- SHELBYUSD_TOKEN_NAME,
73
- SHELBY_DEPLOYER,
74
- TOKEN_DEPLOYER,
75
- TOKEN_OBJECT_ADDRESS
76
- } from "../chunk-SEXQTDX6.mjs";
77
- import {
78
- BlobNameSchema,
79
- ChunkKey,
80
- allChunksForBlob,
81
- roundSize
82
- } from "../chunk-FIFKKWXV.mjs";
83
81
  import {
84
82
  CHUNK_SIZE_PARAMS,
85
83
  ChunkSizeScheme,
86
- ClayErasureCodingProvider,
87
84
  DEFAULT_CHUNKSET_SIZE_BYTES,
88
85
  DEFAULT_CHUNK_SIZE_BYTES,
89
- ERASURE_CODE_AND_CHUNK_MAPPING,
90
- createDefaultErasureCodingProvider
91
- } from "../chunk-APML3CGJ.mjs";
92
- import {
93
- ReedSolomonErasureCodingProvider
94
- } from "../chunk-3ZDXWPYC.mjs";
86
+ ERASURE_CODE_AND_CHUNK_MAPPING
87
+ } from "../chunk-67F5YZ25.mjs";
95
88
  import {
96
89
  DEFAULT_ERASURE_D,
97
90
  DEFAULT_ERASURE_K,
@@ -100,6 +93,19 @@ import {
100
93
  ERASURE_CODE_PARAMS,
101
94
  ErasureCodingScheme
102
95
  } from "../chunk-ZPW742E7.mjs";
96
+ import {
97
+ DEFAULT_PROJECT_DESCRIPTION,
98
+ DEFAULT_PROJECT_NAME,
99
+ NetworkToShelbyBlobIndexerBaseUrl,
100
+ NetworkToShelbyRPCBaseUrl,
101
+ SHELBYUSD_FA_METADATA_ADDRESS,
102
+ SHELBYUSD_TOKEN_ADDRESS,
103
+ SHELBYUSD_TOKEN_MODULE,
104
+ SHELBYUSD_TOKEN_NAME,
105
+ SHELBY_DEPLOYER,
106
+ TOKEN_DEPLOYER,
107
+ TOKEN_OBJECT_ADDRESS
108
+ } from "../chunk-SEXQTDX6.mjs";
103
109
  import "../chunk-7P6ASYW6.mjs";
104
110
  export {
105
111
  BlobCommitmentsSchema,
@@ -151,6 +157,7 @@ export {
151
157
  createShelbyIndexerClient,
152
158
  expectedTotalChunksets,
153
159
  generateCommitments,
160
+ generateMerkleRoot,
154
161
  getAptosAccountExplorerUrl,
155
162
  getAptosTransactionExplorerUrl,
156
163
  getBlobNameSuffix,
@@ -1,18 +1,18 @@
1
- import {
2
- sleep
3
- } from "./chunk-I6NG5GNL.mjs";
4
1
  import {
5
2
  getShelbyIndexerClient
6
3
  } from "./chunk-HFGEQP5N.mjs";
4
+ import {
5
+ BlobNameSchema
6
+ } from "./chunk-GY5DCVVL.mjs";
7
+ import {
8
+ sleep
9
+ } from "./chunk-I6NG5GNL.mjs";
7
10
  import {
8
11
  buildRequestUrl
9
12
  } from "./chunk-4JZO2D7T.mjs";
10
13
  import {
11
14
  NetworkToShelbyRPCBaseUrl
12
15
  } from "./chunk-SEXQTDX6.mjs";
13
- import {
14
- BlobNameSchema
15
- } from "./chunk-FIFKKWXV.mjs";
16
16
 
17
17
  // src/core/clients/ShelbyRPCClient.ts
18
18
  import { AccountAddress } from "@aptos-labs/ts-sdk";
@@ -0,0 +1,28 @@
1
+ // src/core/chunk.ts
2
+ var ChunkSizeScheme = /* @__PURE__ */ ((ChunkSizeScheme2) => {
3
+ ChunkSizeScheme2["ChunkSet10MiB_Chunk1MiB"] = "ChunkSet10MiB_Chunk1MiB";
4
+ return ChunkSizeScheme2;
5
+ })(ChunkSizeScheme || {});
6
+ var CHUNK_SIZE_PARAMS = {
7
+ ["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */]: {
8
+ // 1MiB
9
+ chunkSizeBytes: 1 * 1024 * 1024,
10
+ // 10MiB
11
+ chunksetSizeBytes: 10 * 1024 * 1024
12
+ }
13
+ };
14
+ var DEFAULT_CHUNK_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunkSizeBytes;
15
+ var DEFAULT_CHUNKSET_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunksetSizeBytes;
16
+ var ERASURE_CODE_AND_CHUNK_MAPPING = {
17
+ ["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
18
+ ...CHUNK_SIZE_PARAMS.ChunkSet10MiB_Chunk1MiB
19
+ }
20
+ };
21
+
22
+ export {
23
+ ChunkSizeScheme,
24
+ CHUNK_SIZE_PARAMS,
25
+ DEFAULT_CHUNK_SIZE_BYTES,
26
+ DEFAULT_CHUNKSET_SIZE_BYTES,
27
+ ERASURE_CODE_AND_CHUNK_MAPPING
28
+ };
@@ -9,20 +9,20 @@ import {
9
9
  } from "./chunk-OTBLZL2S.mjs";
10
10
  import {
11
11
  expectedTotalChunksets
12
- } from "./chunk-PCNLFNAT.mjs";
12
+ } from "./chunk-XWAPNLU6.mjs";
13
13
  import {
14
14
  getBlobNameSuffix
15
15
  } from "./chunk-4JZO2D7T.mjs";
16
- import {
17
- SHELBY_DEPLOYER
18
- } from "./chunk-SEXQTDX6.mjs";
19
16
  import {
20
17
  DEFAULT_CHUNKSET_SIZE_BYTES,
21
18
  ERASURE_CODE_AND_CHUNK_MAPPING
22
- } from "./chunk-APML3CGJ.mjs";
19
+ } from "./chunk-67F5YZ25.mjs";
23
20
  import {
24
21
  ERASURE_CODE_PARAMS
25
22
  } from "./chunk-ZPW742E7.mjs";
23
+ import {
24
+ SHELBY_DEPLOYER
25
+ } from "./chunk-SEXQTDX6.mjs";
26
26
 
27
27
  // src/core/clients/ShelbyBlobClient.ts
28
28
  import {
@@ -30,7 +30,8 @@ import {
30
30
  Aptos,
31
31
  AptosConfig,
32
32
  Hex,
33
- MoveVector
33
+ MoveVector,
34
+ U32
34
35
  } from "@aptos-labs/ts-sdk";
35
36
  var ShelbyBlobClient = class _ShelbyBlobClient {
36
37
  aptos;
@@ -123,7 +124,8 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
123
124
  blobNameSuffix: getBlobNameSuffix(params.name),
124
125
  size: Number(metadata.blob_size),
125
126
  encoding,
126
- expirationMicros: metadata.expiration_micros,
127
+ expirationMicros: Number(metadata.expiration_micros),
128
+ creationMicros: Number(metadata.creation_micros),
127
129
  sliceAddress: AccountAddress.fromString(metadata.slice.inner),
128
130
  isWritten: metadata.is_written
129
131
  };
@@ -208,6 +210,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
208
210
  ...ERASURE_CODE_AND_CHUNK_MAPPING.ClayCode_16Total_10Data_13Helper
209
211
  },
210
212
  expirationMicros: Number(blob.expires_at),
213
+ creationMicros: Number(blob.created_at),
211
214
  sliceAddress: AccountAddress.from(blob.slice_address),
212
215
  isWritten: Boolean(Number(blob.is_written))
213
216
  })
@@ -325,6 +328,50 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
325
328
  })
326
329
  };
327
330
  }
331
+ /**
332
+ * Acks the blob chunksets on-chain. If each chunkset meets the necessary threshold, the entire blob will be marked as written.
333
+ *
334
+ * @param params.account - The account that is signing the transaction.
335
+ * @param params.blobOwner - The account that owns the blob.
336
+ * @param params.blobName - The name of the blob (e.g. "foo/bar")
337
+ * @param params.creationMicros - The creation time of the blob in microseconds.
338
+ * @param params.chunksetIdx - The index of the chunkset being acknowledged.
339
+ * @param params.storageProviderChunksetAcks - The signatures
340
+ * @param params.options - Additional options for transaction building and encoding.
341
+ *
342
+ * @returns The blob commitments and the pending transaction.
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * const { transaction } = await client.addChunksetAcknowledgements({
347
+ * account: signer,
348
+ * blobOwner: owner,
349
+ * blobName: "foo/bar.txt",
350
+ * creationMicros, // Taken from the blob metadata at registration time.
351
+ * chunksetIdx,
352
+ * storageProviderAcks: An array of StorageProviderAck types, each having the slot index and signature from the SP.
353
+ * });
354
+ * ```
355
+ */
356
+ async addChunksetAcknowledgements(params) {
357
+ const transaction = await this.aptos.transaction.build.simple({
358
+ ...params.options?.build,
359
+ data: _ShelbyBlobClient.createChunksetAcknowledgementsPayload({
360
+ blobOwner: params.blobOwner,
361
+ blobName: params.blobName,
362
+ creationMicros: params.creationMicros,
363
+ chunksetIdx: params.chunksetIdx,
364
+ storageProviderAcks: params.storageProviderAcks
365
+ }),
366
+ sender: params.account.accountAddress
367
+ });
368
+ return {
369
+ transaction: await this.aptos.signAndSubmitTransaction({
370
+ signer: params.account,
371
+ transaction
372
+ })
373
+ };
374
+ }
328
375
  /**
329
376
  * Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
330
377
  *
@@ -474,6 +521,26 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
474
521
  functionArguments: [params.blobNameSuffix]
475
522
  };
476
523
  }
524
+ static createChunksetAcknowledgementsPayload(params) {
525
+ const ackBitMask = params.storageProviderAcks.reduce(
526
+ (acc, ack) => acc | 1 << ack.slot,
527
+ 0
528
+ );
529
+ const signatures = new MoveVector(params.storageProviderAcks.map((ack) => MoveVector.U8(ack.signature)));
530
+ return {
531
+ function: `${SHELBY_DEPLOYER}::blob_metadata::add_chunkset_acknowledgements`,
532
+ functionArguments: [
533
+ createBlobKey({
534
+ account: params.blobOwner,
535
+ blobName: params.blobName
536
+ }),
537
+ params.chunksetIdx,
538
+ params.creationMicros,
539
+ new U32(Number(ackBitMask)),
540
+ signatures
541
+ ]
542
+ };
543
+ }
477
544
  };
478
545
 
479
546
  export {
@@ -1,9 +1,12 @@
1
- import {
2
- ShelbyRPCClient
3
- } from "./chunk-7P3P3D3X.mjs";
4
1
  import {
5
2
  ShelbyBlobClient
6
- } from "./chunk-HDYY6NS4.mjs";
3
+ } from "./chunk-7UVMDCCR.mjs";
4
+ import {
5
+ ClayErasureCodingProvider
6
+ } from "./chunk-NLPIHQ7K.mjs";
7
+ import {
8
+ ShelbyRPCClient
9
+ } from "./chunk-5I3MBJGN.mjs";
7
10
  import {
8
11
  getAptosConfig
9
12
  } from "./chunk-RBFWGDMY.mjs";
@@ -12,17 +15,17 @@ import {
12
15
  } from "./chunk-OTBLZL2S.mjs";
13
16
  import {
14
17
  generateCommitments
15
- } from "./chunk-PCNLFNAT.mjs";
18
+ } from "./chunk-XWAPNLU6.mjs";
16
19
  import {
17
20
  NetworkToShelbyRPCBaseUrl
18
21
  } from "./chunk-SEXQTDX6.mjs";
19
- import {
20
- ClayErasureCodingProvider
21
- } from "./chunk-APML3CGJ.mjs";
22
22
 
23
23
  // src/core/clients/ShelbyClient.ts
24
24
  import {
25
- Aptos
25
+ AccountAddress,
26
+ Aptos,
27
+ DEFAULT_TXN_TIMEOUT_SEC,
28
+ TransactionResponseType
26
29
  } from "@aptos-labs/ts-sdk";
27
30
  import pLimit from "p-limit";
28
31
  var ShelbyClient = class {
@@ -142,7 +145,8 @@ var ShelbyClient = class {
142
145
  blobName: params.blobName,
143
146
  blobMerkleRoot: blobCommitments.blob_merkle_root,
144
147
  size: params.blobData.length,
145
- expirationMicros: params.expirationMicros
148
+ expirationMicros: params.expirationMicros,
149
+ options: params.options
146
150
  });
147
151
  await this.coordination.aptos.waitForTransaction({
148
152
  transactionHash: pendingRegisterBlobTransaction.hash
@@ -267,19 +271,22 @@ var ShelbyClient = class {
267
271
  *
268
272
  * @example
269
273
  * ```typescript
270
- * const hash = await client.fundAccount({
274
+ * const hash = await client.fundAccountWithShelbyUSD({
271
275
  * address: "0x1",
272
276
  * amount: 100000000,
273
277
  * });
274
278
  * ```
275
279
  */
276
- async fundAccount(params) {
280
+ async fundAccountWithShelbyUSD(params) {
277
281
  const { address, amount } = params;
278
282
  try {
279
283
  const faucet = this.config.faucet ?? "https://faucet.shelbynet.shelby.xyz/fund?asset=shelbyusd";
280
284
  const response = await fetch(`${faucet}`, {
281
285
  method: "POST",
282
- body: JSON.stringify({ address, amount }),
286
+ body: JSON.stringify({
287
+ address: AccountAddress.from(address).toString(),
288
+ amount
289
+ }),
283
290
  headers: {
284
291
  "Content-Type": "application/json"
285
292
  }
@@ -287,11 +294,46 @@ var ShelbyClient = class {
287
294
  if (!response.ok) {
288
295
  throw new Error("Failed to fund account");
289
296
  }
290
- return response.json();
297
+ const json = await response.json();
298
+ const res = await this.aptos.waitForTransaction({
299
+ transactionHash: json.txn_hashes[0],
300
+ options: {
301
+ timeoutSecs: DEFAULT_TXN_TIMEOUT_SEC,
302
+ checkSuccess: true
303
+ }
304
+ });
305
+ if (res.type === TransactionResponseType.User) {
306
+ return res.hash;
307
+ }
308
+ throw new Error(
309
+ `Unexpected transaction received for fund account: ${res.type}`
310
+ );
291
311
  } catch (error) {
292
- throw new Error("Failed to fund account: " + error);
312
+ throw new Error(`Failed to fund account: ${error}`);
293
313
  }
294
314
  }
315
+ /**
316
+ * Fund an account with APT tokens
317
+ *
318
+ * @param params.address - The address to fund
319
+ * @param params.amount - The amount to fund
320
+ * @returns The transaction hash of the funded account
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const hash = await client.fundAccountWithAPT({
325
+ * address: "0x1",
326
+ * amount: 100000000,
327
+ * });
328
+ * ```
329
+ */
330
+ async fundAccountWithAPT(params) {
331
+ const transaction = await this.aptos.fundAccount({
332
+ accountAddress: params.address,
333
+ amount: params.amount
334
+ });
335
+ return transaction.hash;
336
+ }
295
337
  };
296
338
 
297
339
  export {
@@ -0,0 +1,29 @@
1
+ import {
2
+ ClayErasureCodingProvider
3
+ } from "./chunk-NLPIHQ7K.mjs";
4
+ import {
5
+ DEFAULT_CHUNK_SIZE_BYTES
6
+ } from "./chunk-67F5YZ25.mjs";
7
+ import {
8
+ DEFAULT_ERASURE_D,
9
+ DEFAULT_ERASURE_K,
10
+ DEFAULT_ERASURE_N
11
+ } from "./chunk-ZPW742E7.mjs";
12
+
13
+ // src/core/erasure/default.ts
14
+ var defaultProviderPromise;
15
+ function createDefaultErasureCodingProvider() {
16
+ if (!defaultProviderPromise) {
17
+ defaultProviderPromise = ClayErasureCodingProvider.create({
18
+ erasure_n: DEFAULT_ERASURE_N,
19
+ erasure_k: DEFAULT_ERASURE_K,
20
+ erasure_d: DEFAULT_ERASURE_D,
21
+ chunkSizeBytes: DEFAULT_CHUNK_SIZE_BYTES
22
+ });
23
+ }
24
+ return defaultProviderPromise;
25
+ }
26
+
27
+ export {
28
+ createDefaultErasureCodingProvider
29
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_CHUNKSET_SIZE_BYTES,
3
3
  DEFAULT_CHUNK_SIZE_BYTES
4
- } from "./chunk-APML3CGJ.mjs";
4
+ } from "./chunk-67F5YZ25.mjs";
5
5
  import {
6
6
  DEFAULT_ERASURE_K,
7
7
  DEFAULT_ERASURE_N
@@ -1,3 +1,6 @@
1
+ import {
2
+ DEFAULT_CHUNK_SIZE_BYTES
3
+ } from "./chunk-67F5YZ25.mjs";
1
4
  import {
2
5
  DEFAULT_ERASURE_D,
3
6
  DEFAULT_ERASURE_K,
@@ -9,43 +12,6 @@ import {
9
12
  createDecoder,
10
13
  createEncoder
11
14
  } from "@shelby-protocol/clay-codes";
12
-
13
- // src/core/erasure/default.ts
14
- var defaultProviderPromise;
15
- function createDefaultErasureCodingProvider() {
16
- if (!defaultProviderPromise) {
17
- defaultProviderPromise = ClayErasureCodingProvider.create({
18
- erasure_n: DEFAULT_ERASURE_N,
19
- erasure_k: DEFAULT_ERASURE_K,
20
- erasure_d: DEFAULT_ERASURE_D,
21
- chunkSizeBytes: DEFAULT_CHUNK_SIZE_BYTES
22
- });
23
- }
24
- return defaultProviderPromise;
25
- }
26
-
27
- // src/core/chunk.ts
28
- var ChunkSizeScheme = /* @__PURE__ */ ((ChunkSizeScheme2) => {
29
- ChunkSizeScheme2["ChunkSet10MiB_Chunk1MiB"] = "ChunkSet10MiB_Chunk1MiB";
30
- return ChunkSizeScheme2;
31
- })(ChunkSizeScheme || {});
32
- var CHUNK_SIZE_PARAMS = {
33
- ["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */]: {
34
- // 1MiB
35
- chunkSizeBytes: 1 * 1024 * 1024,
36
- // 10MiB
37
- chunksetSizeBytes: 10 * 1024 * 1024
38
- }
39
- };
40
- var DEFAULT_CHUNK_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunkSizeBytes;
41
- var DEFAULT_CHUNKSET_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunksetSizeBytes;
42
- var ERASURE_CODE_AND_CHUNK_MAPPING = {
43
- ["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
44
- ...CHUNK_SIZE_PARAMS.ChunkSet10MiB_Chunk1MiB
45
- }
46
- };
47
-
48
- // src/core/erasure/clay-codes.ts
49
15
  function getTotalChunks(config) {
50
16
  return config.erasure_n;
51
17
  }
@@ -53,8 +19,10 @@ var ClayErasureCodingProvider = class _ClayErasureCodingProvider {
53
19
  config;
54
20
  encoderCache;
55
21
  decoderCache;
22
+ lastFunction;
56
23
  constructor(config) {
57
24
  this.config = config;
25
+ this.lastFunction = "none" /* NONE */;
58
26
  }
59
27
  /**
60
28
  * Static factory method to create an initialized ClayErasureCodingProvider
@@ -101,6 +69,7 @@ var ClayErasureCodingProvider = class _ClayErasureCodingProvider {
101
69
  `Data size ${data.length} bytes does not match systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}). Provide pre-padded data before encoding.`
102
70
  );
103
71
  }
72
+ this.lastFunction = "encoded" /* ENCODED */;
104
73
  return this.encoderCache.erasureCode(data);
105
74
  }
106
75
  decode(available, config) {
@@ -121,8 +90,18 @@ var ClayErasureCodingProvider = class _ClayErasureCodingProvider {
121
90
  );
122
91
  }
123
92
  }
93
+ this.lastFunction = "decoded" /* DECODED */;
124
94
  return this.decoderCache.decode(available, config);
125
95
  }
96
+ getChunkMerkleRoots() {
97
+ if (this.decoderCache && this.lastFunction === "decoded" /* DECODED */)
98
+ return this.decoderCache.getChunkMerkleRoots();
99
+ if (this.encoderCache && this.lastFunction === "encoded" /* ENCODED */)
100
+ return this.encoderCache.getChunkMerkleRoots();
101
+ throw new Error(
102
+ "You must call encode or decode before calling getChunkMerkleRoots"
103
+ );
104
+ }
126
105
  /**
127
106
  * Determines if data can be erasure coded as-is or requires padding.
128
107
  *
@@ -166,11 +145,5 @@ function buildClayConfig(input) {
166
145
  }
167
146
 
168
147
  export {
169
- ClayErasureCodingProvider,
170
- createDefaultErasureCodingProvider,
171
- ChunkSizeScheme,
172
- CHUNK_SIZE_PARAMS,
173
- DEFAULT_CHUNK_SIZE_BYTES,
174
- DEFAULT_CHUNKSET_SIZE_BYTES,
175
- ERASURE_CODE_AND_CHUNK_MAPPING
148
+ ClayErasureCodingProvider
176
149
  };
@@ -58,6 +58,11 @@ var ReedSolomonErasureCodingProvider = class {
58
58
  "ReedSolomonErasureCodingProvider does not implement decode"
59
59
  );
60
60
  }
61
+ getChunkMerkleRoots() {
62
+ throw new Error(
63
+ "ReedSolomonErasureCodingProvider does not implement getChunkMerkleRoots"
64
+ );
65
+ }
61
66
  };
62
67
 
63
68
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ShelbyClient
3
- } from "./chunk-AUGZMI6U.mjs";
3
+ } from "./chunk-BTHSKDJR.mjs";
4
4
 
5
5
  // src/node/clients/ShelbyNodeClient.ts
6
6
  var ShelbyNodeClient = class extends ShelbyClient {
@@ -114,14 +114,14 @@ var ShelbyMetadataClient = class {
114
114
  try {
115
115
  const sliceSizeMetadata = await this.aptos.view({
116
116
  payload: {
117
- function: `${this.deployer.toString()}::global_metadata::get_number_of_slices`,
117
+ function: `${this.deployer.toString()}::slice_registry::get_number_of_slices`,
118
118
  functionArguments: []
119
119
  }
120
120
  });
121
121
  const finalSliceIndex = sliceSizeMetadata[0] - 1;
122
122
  const addressMetadataArray = await this.aptos.view({
123
123
  payload: {
124
- function: `${this.deployer.toString()}::global_metadata::get_slice_addresses`,
124
+ function: `${this.deployer.toString()}::slice_registry::get_slice_addresses`,
125
125
  functionArguments: [0, finalSliceIndex]
126
126
  }
127
127
  });
File without changes