@shelby-protocol/sdk 0.2.4 → 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.
- package/dist/browser/index.d.ts +13 -4
- package/dist/browser/index.mjs +3719 -140
- package/dist/{clay-codes-DHP-bYcP.d.ts → clay-codes-DdXABBDx.d.ts} +0 -7
- package/dist/core/aptos-explorer.mjs +46 -5
- package/dist/core/blobs.d.ts +1 -1
- package/dist/core/blobs.mjs +12 -4
- package/dist/core/chunk.mjs +58 -9
- package/dist/core/clients/ShelbyBlobClient.d.ts +9 -44
- package/dist/core/clients/ShelbyBlobClient.mjs +1084 -17
- package/dist/core/clients/ShelbyClient.d.ts +12 -2
- package/dist/core/clients/ShelbyClient.mjs +2915 -23
- package/dist/core/clients/ShelbyClientConfig.d.ts +8 -0
- package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
- package/dist/core/clients/ShelbyMetadataClient.d.ts +0 -18
- package/dist/core/clients/ShelbyMetadataClient.mjs +306 -6
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -49
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +839 -13
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +307 -8
- package/dist/core/clients/ShelbyRPCClient.d.ts +107 -4
- package/dist/core/clients/ShelbyRPCClient.mjs +1261 -12
- package/dist/core/clients/index.d.ts +3 -2
- package/dist/core/clients/index.mjs +3421 -40
- package/dist/core/clients/utils.mjs +65 -6
- package/dist/core/commitments.d.ts +3 -12
- package/dist/core/commitments.mjs +270 -11
- package/dist/core/constants.d.ts +4 -4
- package/dist/core/constants.mjs +39 -16
- package/dist/core/erasure/clay-codes.d.ts +1 -1
- package/dist/core/erasure/clay-codes.mjs +129 -4
- package/dist/core/erasure/constants.mjs +33 -10
- package/dist/core/erasure/default.d.ts +1 -1
- package/dist/core/erasure/default.mjs +191 -9
- package/dist/core/erasure/index.d.ts +1 -1
- package/dist/core/erasure/index.mjs +266 -23
- package/dist/core/erasure/provider.d.ts +1 -1
- package/dist/core/erasure/reed-solomon.d.ts +1 -1
- package/dist/core/erasure/reed-solomon.mjs +68 -4
- package/dist/core/erasure/utils.d.ts +1 -1
- package/dist/core/erasure/utils.mjs +0 -2
- package/dist/core/errors.mjs +29 -8
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.mjs +3713 -140
- package/dist/core/layout.d.ts +1 -1
- package/dist/core/layout.mjs +37 -5
- package/dist/core/networks.mjs +10 -5
- package/dist/core/operations/generated/sdk.d.ts +9 -0
- package/dist/core/operations/generated/sdk.mjs +183 -18
- package/dist/core/operations/index.mjs +284 -24
- package/dist/core/promises.mjs +4 -4
- package/dist/core/rpc-responses.d.ts +38 -1
- package/dist/core/rpc-responses.mjs +31 -8
- package/dist/core/shelby-explorer.mjs +31 -6
- package/dist/core/strings.mjs +0 -2
- package/dist/core/types/blobs.d.ts +1 -1
- package/dist/core/types/blobs.mjs +0 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/index.mjs +230 -9
- package/dist/core/types/payments.d.ts +6 -6
- package/dist/core/types/payments.mjs +230 -5
- package/dist/core/types/placement_groups.mjs +0 -1
- package/dist/core/types/storage_providers.mjs +0 -1
- package/dist/core/utils.mjs +94 -8
- package/dist/node/clients/ShelbyNodeClient.d.ts +2 -1
- package/dist/node/clients/ShelbyNodeClient.mjs +2919 -24
- package/dist/node/clients/index.d.ts +2 -1
- package/dist/node/clients/index.mjs +2920 -26
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.mjs +3736 -147
- package/dist/node/parallel/commitment_worker.d.ts +9 -0
- package/dist/node/parallel/commitment_worker.mjs +298 -0
- package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
- package/dist/node/parallel/commitment_worker_pool.mjs +286 -0
- package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
- package/dist/node/parallel/default_commitment_worker_pool.mjs +302 -0
- package/dist/node/parallel/index.d.ts +11 -0
- package/dist/node/parallel/index.mjs +563 -0
- package/dist/node/parallel/parallel_commitments.d.ts +32 -0
- package/dist/node/parallel/parallel_commitments.mjs +561 -0
- package/dist/node/parallel/worker_pool.d.ts +74 -0
- package/dist/node/parallel/worker_pool.mjs +248 -0
- package/dist/node/testUtil.mjs +8 -4
- package/package.json +9 -6
- package/dist/chunk-3NRBHSMQ.mjs +0 -12
- package/dist/chunk-3PCG7PNP.mjs +0 -375
- package/dist/chunk-7OV5ZYW6.mjs +0 -55
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-A4IG6GSE.mjs +0 -21
- package/dist/chunk-AD2G3QYD.mjs +0 -0
- package/dist/chunk-AEDVYYGD.mjs +0 -11
- package/dist/chunk-AUQDI5BS.mjs +0 -43
- package/dist/chunk-BDSW5PHM.mjs +0 -37
- package/dist/chunk-BKL7NCUB.mjs +0 -412
- package/dist/chunk-BUWAD67L.mjs +0 -505
- package/dist/chunk-BXEVML7N.mjs +0 -169
- package/dist/chunk-C6RQ3AEU.mjs +0 -51
- package/dist/chunk-CQ6QPIZK.mjs +0 -37
- package/dist/chunk-D6GQHO6G.mjs +0 -15
- package/dist/chunk-EM67QTMR.mjs +0 -0
- package/dist/chunk-I6NG5GNL.mjs +0 -8
- package/dist/chunk-IE6LYVIA.mjs +0 -26
- package/dist/chunk-IKRWBDG5.mjs +0 -42
- package/dist/chunk-JTXYKO3U.mjs +0 -38
- package/dist/chunk-KYQRWJ3U.mjs +0 -49
- package/dist/chunk-MB7C7VQF.mjs +0 -0
- package/dist/chunk-MQUVYMNQ.mjs +0 -0
- package/dist/chunk-NHWWORCH.mjs +0 -72
- package/dist/chunk-NI6XBZLI.mjs +0 -83
- package/dist/chunk-OGKZ575S.mjs +0 -136
- package/dist/chunk-QQ57OGQ2.mjs +0 -0
- package/dist/chunk-SSE4MFNN.mjs +0 -278
- package/dist/chunk-TET3DJEO.mjs +0 -199
- package/dist/chunk-TVLV7C74.mjs +0 -207
- package/dist/chunk-UEZNZBJO.mjs +0 -104
- package/dist/chunk-WJTVYLKW.mjs +0 -782
- package/dist/chunk-WTICJPDB.mjs +0 -0
- package/dist/chunk-XNEIWM4O.mjs +0 -0
- package/dist/chunk-XRLHLAOW.mjs +0 -51
- package/dist/chunk-Z4FZ7W6L.mjs +0 -39
- package/dist/chunk-Z7RFCADT.mjs +0 -0
- package/dist/chunk-ZHXCVRZX.mjs +0 -0
- package/dist/core/operations/generated/types.d.ts +0 -908
- package/dist/core/operations/generated/types.mjs +0 -63
- package/dist/core/types/encodings.d.ts +0 -11
- package/dist/core/types/encodings.mjs +0 -0
|
@@ -101,13 +101,6 @@ interface ClayErasureCodeParams {
|
|
|
101
101
|
type ClayProviderOptions = Partial<ClayErasureCodeParams & ErasureCodingConfig>;
|
|
102
102
|
/**
|
|
103
103
|
* Clay-specific decode configuration.
|
|
104
|
-
*
|
|
105
|
-
* Supports flexible erasure pattern specification in any of three formats:
|
|
106
|
-
* - availableChunkIndexes: Array of available chunk positions
|
|
107
|
-
* - erasedChunkIndexes: Array of missing chunk positions
|
|
108
|
-
* - erasedChunksMask: Bitmask where bit i=1 means chunk i is missing
|
|
109
|
-
*
|
|
110
|
-
* Exactly one of these three options must be provided.
|
|
111
104
|
*/
|
|
112
105
|
type ClayDecodeConfig = DecoderReconfigureOptions;
|
|
113
106
|
declare class ClayErasureCodingProvider implements ErasureCodingProvider {
|
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
package/dist/core/blobs.d.ts
CHANGED
package/dist/core/blobs.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
// src/core/utils.ts
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
};
|
package/dist/core/chunk.mjs
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputGenerateTransactionOptions, Aptos, AccountAddress, InputTransactionPluginData, AccountAddressInput, Account, PendingTransactionResponse, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
|
|
2
2
|
import { BlobName } from '../layout.js';
|
|
3
3
|
import { BlobMetadata, BlobActivity, StorageProviderAck } from '../types/blobs.js';
|
|
4
|
-
import { E as ErasureCodingConfig } from '../../clay-codes-
|
|
4
|
+
import { E as ErasureCodingConfig } from '../../clay-codes-DdXABBDx.js';
|
|
5
5
|
import { ShelbyIndexerClient } from '../operations/index.js';
|
|
6
6
|
import { Blobs_Order_By, Blobs_Bool_Exp, Blob_Activities_Bool_Exp, Blob_Activities_Order_By } from '../operations/generated/sdk.js';
|
|
7
7
|
import { ShelbyClientConfig } from './ShelbyClientConfig.js';
|
|
@@ -60,6 +60,7 @@ declare class ShelbyBlobClient {
|
|
|
60
60
|
readonly deployer: AccountAddress;
|
|
61
61
|
readonly indexer: ShelbyIndexerClient;
|
|
62
62
|
readonly defaultOptions: WriteBlobCommitmentsOptions;
|
|
63
|
+
private readonly orderless;
|
|
63
64
|
/**
|
|
64
65
|
* The ShelbyBlobClient is used to interact with the Shelby contract on the Aptos blockchain. This
|
|
65
66
|
* includes functions for registering blob commitments and retrieving blob metadata.
|
|
@@ -110,6 +111,13 @@ declare class ShelbyBlobClient {
|
|
|
110
111
|
* provided without a transaction submitter.
|
|
111
112
|
*/
|
|
112
113
|
private validateUsdSponsorConfig;
|
|
114
|
+
/**
|
|
115
|
+
* Merges orderless replay protection into transaction options when
|
|
116
|
+
* `config.orderless` is enabled. If the caller already supplies options
|
|
117
|
+
* (e.g. custom gas limits), those are preserved and the nonce is injected
|
|
118
|
+
* alongside them. When orderless mode is off, user options are returned as-is.
|
|
119
|
+
*/
|
|
120
|
+
private orderlessTxOptions;
|
|
113
121
|
/**
|
|
114
122
|
* Retrieves the blob metadata from the blockchain. If it does not exist,
|
|
115
123
|
* returns `undefined`.
|
|
@@ -328,42 +336,6 @@ declare class ShelbyBlobClient {
|
|
|
328
336
|
}): Promise<{
|
|
329
337
|
transaction: PendingTransactionResponse;
|
|
330
338
|
}>;
|
|
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
|
-
addChunksetAcknowledgements(params: {
|
|
357
|
-
account: Account;
|
|
358
|
-
blobOwner: AccountAddress;
|
|
359
|
-
blobName: BlobName;
|
|
360
|
-
creationMicros: number;
|
|
361
|
-
chunksetIdx: number;
|
|
362
|
-
storageProviderAcks: StorageProviderAck[];
|
|
363
|
-
options?: AckTransactionOptions;
|
|
364
|
-
}): Promise<{
|
|
365
|
-
transaction: PendingTransactionResponse;
|
|
366
|
-
}>;
|
|
367
339
|
/**
|
|
368
340
|
* Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
|
|
369
341
|
*
|
|
@@ -506,13 +478,6 @@ declare class ShelbyBlobClient {
|
|
|
506
478
|
deployer?: AccountAddress;
|
|
507
479
|
blobNames: string[];
|
|
508
480
|
}): InputGenerateTransactionPayloadData;
|
|
509
|
-
static createChunksetAcknowledgementsPayload(params: {
|
|
510
|
-
blobOwner: AccountAddress;
|
|
511
|
-
blobName: BlobName;
|
|
512
|
-
creationMicros: number;
|
|
513
|
-
chunksetIdx: number;
|
|
514
|
-
storageProviderAcks: StorageProviderAck[];
|
|
515
|
-
}): InputGenerateTransactionPayloadData;
|
|
516
481
|
static createBlobAcknowledgementsPayload(params: {
|
|
517
482
|
blobOwner: AccountAddress;
|
|
518
483
|
blobName: BlobName;
|