@shelby-protocol/sdk 0.3.0 → 0.3.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 (106) hide show
  1. package/dist/browser/index.d.ts +12 -3
  2. package/dist/browser/index.mjs +3717 -142
  3. package/dist/core/aptos-explorer.mjs +46 -5
  4. package/dist/core/blobs.mjs +12 -4
  5. package/dist/core/chunk.mjs +58 -9
  6. package/dist/core/clients/ShelbyBlobClient.d.ts +0 -43
  7. package/dist/core/clients/ShelbyBlobClient.mjs +1084 -17
  8. package/dist/core/clients/ShelbyClient.d.ts +12 -2
  9. package/dist/core/clients/ShelbyClient.mjs +2915 -23
  10. package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
  11. package/dist/core/clients/ShelbyMetadataClient.d.ts +0 -18
  12. package/dist/core/clients/ShelbyMetadataClient.mjs +306 -6
  13. package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -49
  14. package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +839 -13
  15. package/dist/core/clients/ShelbyPlacementGroupClient.mjs +307 -8
  16. package/dist/core/clients/ShelbyRPCClient.d.ts +106 -3
  17. package/dist/core/clients/ShelbyRPCClient.mjs +1261 -12
  18. package/dist/core/clients/index.d.ts +2 -1
  19. package/dist/core/clients/index.mjs +3420 -39
  20. package/dist/core/clients/utils.mjs +65 -6
  21. package/dist/core/commitments.mjs +270 -11
  22. package/dist/core/constants.d.ts +2 -2
  23. package/dist/core/constants.mjs +39 -16
  24. package/dist/core/erasure/clay-codes.mjs +129 -4
  25. package/dist/core/erasure/constants.mjs +33 -10
  26. package/dist/core/erasure/default.mjs +191 -9
  27. package/dist/core/erasure/index.mjs +266 -23
  28. package/dist/core/erasure/reed-solomon.mjs +68 -4
  29. package/dist/core/erasure/utils.mjs +0 -2
  30. package/dist/core/errors.mjs +29 -8
  31. package/dist/core/index.d.ts +1 -1
  32. package/dist/core/index.mjs +3711 -142
  33. package/dist/core/layout.mjs +37 -5
  34. package/dist/core/networks.mjs +10 -5
  35. package/dist/core/operations/generated/sdk.d.ts +9 -0
  36. package/dist/core/operations/generated/sdk.mjs +183 -18
  37. package/dist/core/operations/index.mjs +284 -24
  38. package/dist/core/promises.mjs +4 -4
  39. package/dist/core/rpc-responses.mjs +29 -10
  40. package/dist/core/shelby-explorer.mjs +31 -6
  41. package/dist/core/strings.mjs +0 -2
  42. package/dist/core/types/blobs.mjs +0 -1
  43. package/dist/core/types/index.mjs +230 -9
  44. package/dist/core/types/payments.d.ts +6 -6
  45. package/dist/core/types/payments.mjs +230 -5
  46. package/dist/core/types/placement_groups.mjs +0 -1
  47. package/dist/core/types/storage_providers.mjs +0 -1
  48. package/dist/core/utils.mjs +94 -8
  49. package/dist/node/clients/ShelbyNodeClient.d.ts +1 -0
  50. package/dist/node/clients/ShelbyNodeClient.mjs +2919 -24
  51. package/dist/node/clients/index.d.ts +1 -0
  52. package/dist/node/clients/index.mjs +2920 -26
  53. package/dist/node/index.d.ts +1 -1
  54. package/dist/node/index.mjs +3734 -149
  55. package/dist/node/parallel/commitment_worker.d.ts +9 -0
  56. package/dist/node/parallel/commitment_worker.mjs +298 -0
  57. package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
  58. package/dist/node/parallel/commitment_worker_pool.mjs +286 -0
  59. package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
  60. package/dist/node/parallel/default_commitment_worker_pool.mjs +302 -0
  61. package/dist/node/parallel/index.d.ts +11 -0
  62. package/dist/node/parallel/index.mjs +563 -0
  63. package/dist/node/parallel/parallel_commitments.d.ts +32 -0
  64. package/dist/node/parallel/parallel_commitments.mjs +561 -0
  65. package/dist/node/parallel/worker_pool.d.ts +74 -0
  66. package/dist/node/parallel/worker_pool.mjs +248 -0
  67. package/dist/node/testUtil.mjs +8 -4
  68. package/package.json +6 -2
  69. package/dist/chunk-3NRBHSMQ.mjs +0 -12
  70. package/dist/chunk-5BVSWXQJ.mjs +0 -801
  71. package/dist/chunk-6FJNAUU5.mjs +0 -278
  72. package/dist/chunk-6XSZRDLJ.mjs +0 -375
  73. package/dist/chunk-7P6ASYW6.mjs +0 -9
  74. package/dist/chunk-A4IG6GSE.mjs +0 -21
  75. package/dist/chunk-AD2G3QYD.mjs +0 -0
  76. package/dist/chunk-AUQDI5BS.mjs +0 -43
  77. package/dist/chunk-AY3HBWXA.mjs +0 -51
  78. package/dist/chunk-BDSW5PHM.mjs +0 -37
  79. package/dist/chunk-C6RQ3AEU.mjs +0 -51
  80. package/dist/chunk-CQ6QPIZK.mjs +0 -37
  81. package/dist/chunk-D6GQHO6G.mjs +0 -15
  82. package/dist/chunk-EM67QTMR.mjs +0 -0
  83. package/dist/chunk-I6NG5GNL.mjs +0 -8
  84. package/dist/chunk-JTXYKO3U.mjs +0 -38
  85. package/dist/chunk-KG2TMLEV.mjs +0 -207
  86. package/dist/chunk-M3CP5TFP.mjs +0 -39
  87. package/dist/chunk-M7W43K2Q.mjs +0 -505
  88. package/dist/chunk-MB7C7VQF.mjs +0 -0
  89. package/dist/chunk-MNCQBEMS.mjs +0 -55
  90. package/dist/chunk-MQUVYMNQ.mjs +0 -0
  91. package/dist/chunk-NEO7Z3ZQ.mjs +0 -49
  92. package/dist/chunk-NHWWORCH.mjs +0 -72
  93. package/dist/chunk-OEK24ON7.mjs +0 -135
  94. package/dist/chunk-QQ57OGQ2.mjs +0 -0
  95. package/dist/chunk-RNNJXTX2.mjs +0 -154
  96. package/dist/chunk-S6Q4OG7H.mjs +0 -83
  97. package/dist/chunk-TET3DJEO.mjs +0 -199
  98. package/dist/chunk-UEZNZBJO.mjs +0 -104
  99. package/dist/chunk-V46D5NBW.mjs +0 -11
  100. package/dist/chunk-V4B3GAMQ.mjs +0 -42
  101. package/dist/chunk-WFWRBNTW.mjs +0 -412
  102. package/dist/chunk-WTICJPDB.mjs +0 -0
  103. package/dist/chunk-XNEIWM4O.mjs +0 -0
  104. package/dist/chunk-Z4FZ7W6L.mjs +0 -39
  105. package/dist/chunk-Z7RFCADT.mjs +0 -0
  106. package/dist/chunk-ZHXCVRZX.mjs +0 -0
@@ -1,8 +1,49 @@
1
- import {
2
- getAptosAccountExplorerUrl,
3
- getAptosTransactionExplorerUrl
4
- } from "../chunk-C6RQ3AEU.mjs";
5
- import "../chunk-7P6ASYW6.mjs";
1
+ // src/core/aptos-explorer.ts
2
+ import { Network } from "@aptos-labs/ts-sdk";
3
+ function getAptosExplorerBaseUrl(network) {
4
+ const normalizedNetwork = network.toLowerCase();
5
+ switch (normalizedNetwork) {
6
+ case Network.MAINNET.toLowerCase():
7
+ return "https://explorer.aptoslabs.com";
8
+ case Network.TESTNET.toLowerCase():
9
+ return "https://explorer.aptoslabs.com";
10
+ case Network.DEVNET.toLowerCase():
11
+ return "https://explorer.aptoslabs.com";
12
+ case Network.LOCAL.toLowerCase():
13
+ return "https://explorer.aptoslabs.com";
14
+ case Network.SHELBYNET.toLowerCase():
15
+ return "https://explorer.aptoslabs.com";
16
+ default:
17
+ return "https://explorer.aptoslabs.com";
18
+ }
19
+ }
20
+ function getAptosExplorerNetworkParam(network) {
21
+ const normalizedNetwork = network.toLowerCase();
22
+ switch (normalizedNetwork) {
23
+ case Network.MAINNET.toLowerCase():
24
+ return "mainnet";
25
+ case Network.TESTNET.toLowerCase():
26
+ return "testnet";
27
+ case Network.DEVNET.toLowerCase():
28
+ return "devnet";
29
+ case Network.LOCAL.toLowerCase():
30
+ return "local";
31
+ case Network.SHELBYNET.toLowerCase():
32
+ return "shelbynet";
33
+ default:
34
+ return normalizedNetwork;
35
+ }
36
+ }
37
+ function getAptosTransactionExplorerUrl(network, transactionHash) {
38
+ const baseUrl = getAptosExplorerBaseUrl(network);
39
+ const networkParam = getAptosExplorerNetworkParam(network);
40
+ return `${baseUrl}/txn/${transactionHash}?network=${networkParam}`;
41
+ }
42
+ function getAptosAccountExplorerUrl(network, accountAddress) {
43
+ const baseUrl = getAptosExplorerBaseUrl(network);
44
+ const networkParam = getAptosExplorerNetworkParam(network);
45
+ return `${baseUrl}/account/${accountAddress}?network=${networkParam}`;
46
+ }
6
47
  export {
7
48
  getAptosAccountExplorerUrl,
8
49
  getAptosTransactionExplorerUrl
@@ -1,8 +1,16 @@
1
+ // src/core/utils.ts
1
2
  import {
2
- createBlobKey
3
- } from "../chunk-3NRBHSMQ.mjs";
4
- import "../chunk-UEZNZBJO.mjs";
5
- import "../chunk-7P6ASYW6.mjs";
3
+ AccountAddress,
4
+ Hex
5
+ } from "@aptos-labs/ts-sdk";
6
+ function normalizeAddress(address) {
7
+ return AccountAddress.from(address, { maxMissingChars: 63 });
8
+ }
9
+
10
+ // src/core/blobs.ts
11
+ var createBlobKey = (params) => {
12
+ return `@${normalizeAddress(params.account).toStringLongWithoutPrefix()}/${params.blobName}`;
13
+ };
6
14
  export {
7
15
  createBlobKey
8
16
  };
@@ -1,12 +1,61 @@
1
- import {
2
- CHUNK_SIZE_PARAMS,
3
- ChunkSizeScheme,
4
- DEFAULT_CHUNKSET_SIZE_BYTES,
5
- DEFAULT_CHUNK_SIZE_BYTES,
6
- ERASURE_CODE_AND_CHUNK_MAPPING
7
- } from "../chunk-JTXYKO3U.mjs";
8
- import "../chunk-AUQDI5BS.mjs";
9
- import "../chunk-7P6ASYW6.mjs";
1
+ // src/core/erasure/constants.ts
2
+ var ERASURE_CODE_PARAMS = {
3
+ ["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
4
+ // total chunks (data + parity)
5
+ erasure_n: 16,
6
+ // data chunks
7
+ erasure_k: 10,
8
+ // helper nodes
9
+ erasure_d: 13,
10
+ // enum index
11
+ enumIndex: 0
12
+ },
13
+ ["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
14
+ // total chunks (data + parity)
15
+ erasure_n: 4,
16
+ // data chunks
17
+ erasure_k: 2,
18
+ // helper nodes
19
+ erasure_d: 3,
20
+ // enum index
21
+ enumIndex: 1
22
+ }
23
+ };
24
+ var DEFAULT_ERASURE_N = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_n;
25
+ var DEFAULT_ERASURE_K = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_k;
26
+ var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_d;
27
+ var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
28
+
29
+ // src/core/chunk.ts
30
+ var ChunkSizeScheme = /* @__PURE__ */ ((ChunkSizeScheme2) => {
31
+ ChunkSizeScheme2["ChunkSet10MiB_Chunk1MiB"] = "ChunkSet10MiB_Chunk1MiB";
32
+ ChunkSizeScheme2["ChunkSet2MiB_Chunk1MiB"] = "ChunkSet2MiB_Chunk1MiB";
33
+ return ChunkSizeScheme2;
34
+ })(ChunkSizeScheme || {});
35
+ var CHUNK_SIZE_PARAMS = {
36
+ ["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */]: {
37
+ // 1MiB
38
+ chunkSizeBytes: 1 * 1024 * 1024,
39
+ // 10MiB
40
+ chunksetSizeBytes: 10 * 1024 * 1024
41
+ },
42
+ ["ChunkSet2MiB_Chunk1MiB" /* ChunkSet2MiB_Chunk1MiB */]: {
43
+ // 1MiB
44
+ chunkSizeBytes: 1 * 1024 * 1024,
45
+ // 2MiB
46
+ chunksetSizeBytes: 2 * 1024 * 1024
47
+ }
48
+ };
49
+ var DEFAULT_CHUNK_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunkSizeBytes;
50
+ var DEFAULT_CHUNKSET_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunksetSizeBytes;
51
+ var ERASURE_CODE_AND_CHUNK_MAPPING = {
52
+ ["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
53
+ ...CHUNK_SIZE_PARAMS.ChunkSet10MiB_Chunk1MiB
54
+ },
55
+ ["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
56
+ ...CHUNK_SIZE_PARAMS.ChunkSet2MiB_Chunk1MiB
57
+ }
58
+ };
10
59
  export {
11
60
  CHUNK_SIZE_PARAMS,
12
61
  ChunkSizeScheme,
@@ -336,42 +336,6 @@ declare class ShelbyBlobClient {
336
336
  }): Promise<{
337
337
  transaction: PendingTransactionResponse;
338
338
  }>;
339
- /**
340
- * Acks the blob chunksets on-chain. If each chunkset meets the necessary threshold, the entire blob will be marked as written.
341
- *
342
- * @param params.account - The account that is signing the transaction.
343
- * @param params.blobOwner - The account that owns the blob.
344
- * @param params.blobName - The name of the blob (e.g. "foo/bar")
345
- * @param params.creationMicros - The creation time of the blob in microseconds.
346
- * @param params.chunksetIdx - The index of the chunkset being acknowledged.
347
- * @param params.storageProviderChunksetAcks - The signatures
348
- * @param params.options - Additional options for transaction building and encoding.
349
- *
350
- * @returns The blob commitments and the pending transaction.
351
- *
352
- * @example
353
- * ```typescript
354
- * const { transaction } = await client.addChunksetAcknowledgements({
355
- * account: signer,
356
- * blobOwner: owner,
357
- * blobName: "foo/bar.txt",
358
- * creationMicros, // Taken from the blob metadata at registration time.
359
- * chunksetIdx,
360
- * storageProviderAcks: An array of StorageProviderAck types, each having the slot index and signature from the SP.
361
- * });
362
- * ```
363
- */
364
- addChunksetAcknowledgements(params: {
365
- account: Account;
366
- blobOwner: AccountAddress;
367
- blobName: BlobName;
368
- creationMicros: number;
369
- chunksetIdx: number;
370
- storageProviderAcks: StorageProviderAck[];
371
- options?: AckTransactionOptions;
372
- }): Promise<{
373
- transaction: PendingTransactionResponse;
374
- }>;
375
339
  /**
376
340
  * Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
377
341
  *
@@ -514,13 +478,6 @@ declare class ShelbyBlobClient {
514
478
  deployer?: AccountAddress;
515
479
  blobNames: string[];
516
480
  }): InputGenerateTransactionPayloadData;
517
- static createChunksetAcknowledgementsPayload(params: {
518
- blobOwner: AccountAddress;
519
- blobName: BlobName;
520
- creationMicros: number;
521
- chunksetIdx: number;
522
- storageProviderAcks: StorageProviderAck[];
523
- }): InputGenerateTransactionPayloadData;
524
481
  static createBlobAcknowledgementsPayload(params: {
525
482
  blobOwner: AccountAddress;
526
483
  blobName: BlobName;