@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
package/dist/chunk-C6RQ3AEU.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
getAptosTransactionExplorerUrl,
|
|
50
|
-
getAptosAccountExplorerUrl
|
|
51
|
-
};
|
package/dist/chunk-CQ6QPIZK.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/core/errors.ts
|
|
2
|
-
var ShelbyErrorCodes = {
|
|
3
|
-
// blob_metadata.move errors
|
|
4
|
-
E_BLOB_NOT_FOUND: "E_BLOB_NOT_FOUND",
|
|
5
|
-
E_INVALID_EXPIRATION_TIME: "E_INVALID_EXPIRATION_TIME",
|
|
6
|
-
E_TEST_ENCODING_NOT_ALLOWED: "E_TEST_ENCODING_NOT_ALLOWED",
|
|
7
|
-
E_BLOB_NOT_EXPIRED: "E_BLOB_NOT_EXPIRED",
|
|
8
|
-
E_INVALID_CHUNKSET_COUNT: "E_INVALID_CHUNKSET_COUNT",
|
|
9
|
-
E_NOT_BLOB_OWNER: "E_NOT_BLOB_OWNER",
|
|
10
|
-
E_NOT_ADMIN: "E_NOT_ADMIN",
|
|
11
|
-
E_BLOB_EXPIRED: "E_BLOB_EXPIRED",
|
|
12
|
-
E_BLOB_NAME_TOO_LONG: "E_BLOB_NAME_TOO_LONG",
|
|
13
|
-
E_INVALID_PAYMENT_EPOCHS: "E_INVALID_PAYMENT_EPOCHS",
|
|
14
|
-
E_NO_SLICES_AVAILABLE: "E_NO_SLICES_AVAILABLE",
|
|
15
|
-
// Common Aptos/Move errors
|
|
16
|
-
EALREADY_EXISTS: "EALREADY_EXISTS"
|
|
17
|
-
};
|
|
18
|
-
function isBlobAlreadyExistsError(errorMessage) {
|
|
19
|
-
return errorMessage.includes(ShelbyErrorCodes.EALREADY_EXISTS) || errorMessage.includes("already exists");
|
|
20
|
-
}
|
|
21
|
-
function isAccessDeniedError(errorMessage) {
|
|
22
|
-
return errorMessage.includes(ShelbyErrorCodes.E_NOT_BLOB_OWNER) || errorMessage.includes(ShelbyErrorCodes.E_NOT_ADMIN) || errorMessage.includes("ENOT_AUTHORIZED") || errorMessage.includes("not authorized") || errorMessage.includes("permission denied");
|
|
23
|
-
}
|
|
24
|
-
function isBlobNotFoundError(errorMessage) {
|
|
25
|
-
return errorMessage.includes(ShelbyErrorCodes.E_BLOB_NOT_FOUND);
|
|
26
|
-
}
|
|
27
|
-
function isBlobExpiredError(errorMessage) {
|
|
28
|
-
return errorMessage.includes(ShelbyErrorCodes.E_BLOB_EXPIRED);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
ShelbyErrorCodes,
|
|
33
|
-
isBlobAlreadyExistsError,
|
|
34
|
-
isAccessDeniedError,
|
|
35
|
-
isBlobNotFoundError,
|
|
36
|
-
isBlobExpiredError
|
|
37
|
-
};
|
package/dist/chunk-D6GQHO6G.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/core/networks.ts
|
|
2
|
-
import { Network } from "@aptos-labs/ts-sdk";
|
|
3
|
-
var shelbyNetworks = [
|
|
4
|
-
Network.LOCAL,
|
|
5
|
-
Network.TESTNET,
|
|
6
|
-
Network.SHELBYNET
|
|
7
|
-
];
|
|
8
|
-
var isShelbyNetwork = (network) => {
|
|
9
|
-
return shelbyNetworks.includes(network.toLowerCase());
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
shelbyNetworks,
|
|
14
|
-
isShelbyNetwork
|
|
15
|
-
};
|
package/dist/chunk-EM67QTMR.mjs
DELETED
|
File without changes
|
package/dist/chunk-I6NG5GNL.mjs
DELETED
package/dist/chunk-IE6LYVIA.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/core/rpc-responses.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var StartMultipartUploadResponseSchema = z.object({
|
|
4
|
-
uploadId: z.string()
|
|
5
|
-
});
|
|
6
|
-
var UploadPartResponseSchema = z.object({
|
|
7
|
-
success: z.literal(true)
|
|
8
|
-
});
|
|
9
|
-
var CompleteMultipartUploadResponseSchema = z.object({
|
|
10
|
-
success: z.literal(true)
|
|
11
|
-
});
|
|
12
|
-
var RPCErrorResponseSchema = z.object({
|
|
13
|
-
error: z.string()
|
|
14
|
-
});
|
|
15
|
-
var StaleMicropaymentErrorResponseSchema = z.object({
|
|
16
|
-
error: z.string().optional(),
|
|
17
|
-
storedMicropayment: z.string().optional()
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
StartMultipartUploadResponseSchema,
|
|
22
|
-
UploadPartResponseSchema,
|
|
23
|
-
CompleteMultipartUploadResponseSchema,
|
|
24
|
-
RPCErrorResponseSchema,
|
|
25
|
-
StaleMicropaymentErrorResponseSchema
|
|
26
|
-
};
|
package/dist/chunk-IKRWBDG5.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NetworkToShelbyRPCBaseUrl
|
|
3
|
-
} from "./chunk-7OV5ZYW6.mjs";
|
|
4
|
-
|
|
5
|
-
// src/core/clients/utils.ts
|
|
6
|
-
import { AptosConfig } from "@aptos-labs/ts-sdk";
|
|
7
|
-
var getAptosConfig = (config) => {
|
|
8
|
-
const baseFaucetConfig = config.faucet?.authToken ? { AUTH_TOKEN: config.faucet.authToken } : void 0;
|
|
9
|
-
if (config.aptos) {
|
|
10
|
-
return new AptosConfig({
|
|
11
|
-
// Spread user's aptos config first
|
|
12
|
-
...config.aptos,
|
|
13
|
-
// Network from top-level is authoritative - cannot be overridden
|
|
14
|
-
network: config.network,
|
|
15
|
-
// Merge clientConfig with API_KEY default
|
|
16
|
-
clientConfig: {
|
|
17
|
-
API_KEY: config.apiKey,
|
|
18
|
-
...config.aptos.clientConfig
|
|
19
|
-
},
|
|
20
|
-
// Merge faucetConfig: aptos config first, then base authToken (authoritative)
|
|
21
|
-
faucetConfig: {
|
|
22
|
-
...config.aptos.faucetConfig,
|
|
23
|
-
...baseFaucetConfig
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return new AptosConfig({
|
|
28
|
-
network: config.network,
|
|
29
|
-
clientConfig: {
|
|
30
|
-
API_KEY: config.apiKey
|
|
31
|
-
},
|
|
32
|
-
faucetConfig: baseFaucetConfig
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var getShelbyRPCBaseUrl = (config) => {
|
|
36
|
-
return config.rpc?.baseUrl ?? NetworkToShelbyRPCBaseUrl[config.network] ?? NetworkToShelbyRPCBaseUrl.testnet;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
getAptosConfig,
|
|
41
|
-
getShelbyRPCBaseUrl
|
|
42
|
-
};
|
package/dist/chunk-JTXYKO3U.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// src/core/chunk.ts
|
|
2
|
-
var ChunkSizeScheme = /* @__PURE__ */ ((ChunkSizeScheme2) => {
|
|
3
|
-
ChunkSizeScheme2["ChunkSet10MiB_Chunk1MiB"] = "ChunkSet10MiB_Chunk1MiB";
|
|
4
|
-
ChunkSizeScheme2["ChunkSet2MiB_Chunk1MiB"] = "ChunkSet2MiB_Chunk1MiB";
|
|
5
|
-
return ChunkSizeScheme2;
|
|
6
|
-
})(ChunkSizeScheme || {});
|
|
7
|
-
var CHUNK_SIZE_PARAMS = {
|
|
8
|
-
["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */]: {
|
|
9
|
-
// 1MiB
|
|
10
|
-
chunkSizeBytes: 1 * 1024 * 1024,
|
|
11
|
-
// 10MiB
|
|
12
|
-
chunksetSizeBytes: 10 * 1024 * 1024
|
|
13
|
-
},
|
|
14
|
-
["ChunkSet2MiB_Chunk1MiB" /* ChunkSet2MiB_Chunk1MiB */]: {
|
|
15
|
-
// 1MiB
|
|
16
|
-
chunkSizeBytes: 1 * 1024 * 1024,
|
|
17
|
-
// 2MiB
|
|
18
|
-
chunksetSizeBytes: 2 * 1024 * 1024
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var DEFAULT_CHUNK_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunkSizeBytes;
|
|
22
|
-
var DEFAULT_CHUNKSET_SIZE_BYTES = CHUNK_SIZE_PARAMS["ChunkSet10MiB_Chunk1MiB" /* ChunkSet10MiB_Chunk1MiB */].chunksetSizeBytes;
|
|
23
|
-
var ERASURE_CODE_AND_CHUNK_MAPPING = {
|
|
24
|
-
["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
|
|
25
|
-
...CHUNK_SIZE_PARAMS.ChunkSet10MiB_Chunk1MiB
|
|
26
|
-
},
|
|
27
|
-
["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
|
|
28
|
-
...CHUNK_SIZE_PARAMS.ChunkSet2MiB_Chunk1MiB
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
ChunkSizeScheme,
|
|
34
|
-
CHUNK_SIZE_PARAMS,
|
|
35
|
-
DEFAULT_CHUNK_SIZE_BYTES,
|
|
36
|
-
DEFAULT_CHUNKSET_SIZE_BYTES,
|
|
37
|
-
ERASURE_CODE_AND_CHUNK_MAPPING
|
|
38
|
-
};
|
package/dist/chunk-KYQRWJ3U.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSdk
|
|
3
|
-
} from "./chunk-TET3DJEO.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getAptosConfig
|
|
6
|
-
} from "./chunk-IKRWBDG5.mjs";
|
|
7
|
-
import {
|
|
8
|
-
NetworkToShelbyBlobIndexerBaseUrl
|
|
9
|
-
} from "./chunk-7OV5ZYW6.mjs";
|
|
10
|
-
|
|
11
|
-
// src/core/operations/index.ts
|
|
12
|
-
import { Network } from "@aptos-labs/ts-sdk";
|
|
13
|
-
import { GraphQLClient } from "graphql-request";
|
|
14
|
-
function createShelbyIndexerClient(baseUrl, options) {
|
|
15
|
-
const graphqlClient = new GraphQLClient(baseUrl, options);
|
|
16
|
-
return getSdk(graphqlClient);
|
|
17
|
-
}
|
|
18
|
-
function getShelbyIndexerClient(config) {
|
|
19
|
-
const aptosConfig = getAptosConfig(config);
|
|
20
|
-
let { apiKey: indexerApiKey, baseUrl } = config.indexer ?? {};
|
|
21
|
-
if (!baseUrl) {
|
|
22
|
-
switch (aptosConfig?.network) {
|
|
23
|
-
// TODO: Add endpoints for core networks
|
|
24
|
-
case Network.MAINNET:
|
|
25
|
-
case Network.TESTNET:
|
|
26
|
-
case Network.DEVNET:
|
|
27
|
-
case Network.SHELBYNET:
|
|
28
|
-
baseUrl = NetworkToShelbyBlobIndexerBaseUrl[aptosConfig.network];
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (baseUrl === void 0) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
"The ShelbyClientConfig does not support the Shelby indexer. Please configure the endpoint in the ShelbyClientConfig.indexer.endpoint or provide a supported Aptos network."
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
const apiKey = indexerApiKey ?? config.apiKey;
|
|
38
|
-
return createShelbyIndexerClient(baseUrl, {
|
|
39
|
-
headers: {
|
|
40
|
-
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
41
|
-
"x-aptos-client": "shelby-ts-sdk"
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
createShelbyIndexerClient,
|
|
48
|
-
getShelbyIndexerClient
|
|
49
|
-
};
|
package/dist/chunk-MB7C7VQF.mjs
DELETED
|
File without changes
|
package/dist/chunk-MQUVYMNQ.mjs
DELETED
|
File without changes
|
package/dist/chunk-NHWWORCH.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// src/core/erasure/reed-solomon.ts
|
|
2
|
-
import { createWasmReedSolomonBinding } from "@shelby-protocol/reed-solomon";
|
|
3
|
-
var DEFAULT_ERASURE_K = 10;
|
|
4
|
-
var DEFAULT_ERASURE_N = 16;
|
|
5
|
-
var DEFAULT_CHUNK_SIZE_BYTES = 2 * 1024 * 1024;
|
|
6
|
-
var ReedSolomonErasureCodingProvider = class {
|
|
7
|
-
config;
|
|
8
|
-
constructor(options) {
|
|
9
|
-
const erasure_k = options?.erasure_k ?? DEFAULT_ERASURE_K;
|
|
10
|
-
const erasure_n = options?.erasure_n ?? DEFAULT_ERASURE_N;
|
|
11
|
-
const chunkSizeBytes = options?.chunkSizeBytes ?? DEFAULT_CHUNK_SIZE_BYTES;
|
|
12
|
-
const enumIndex = -1;
|
|
13
|
-
if (erasure_k <= 0)
|
|
14
|
-
throw new Error("erasure_k (number of data chunks) must be > 0");
|
|
15
|
-
if (erasure_n <= erasure_k)
|
|
16
|
-
throw new Error(
|
|
17
|
-
`erasure_n (${erasure_n}) must be > erasure_k (${erasure_k})`
|
|
18
|
-
);
|
|
19
|
-
if (chunkSizeBytes <= 0) throw new Error("chunkSizeBytes must be > 0");
|
|
20
|
-
this.config = {
|
|
21
|
-
erasure_n,
|
|
22
|
-
erasure_k,
|
|
23
|
-
chunkSizeBytes,
|
|
24
|
-
enumIndex
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
encode(data) {
|
|
28
|
-
const { erasure_k, erasure_n, chunkSizeBytes } = this.config;
|
|
29
|
-
const erasure_m = erasure_n - erasure_k;
|
|
30
|
-
const systematicCapacity = erasure_k * chunkSizeBytes;
|
|
31
|
-
if (data.byteLength > systematicCapacity) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Data size ${data.byteLength} bytes exceeds systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}).`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (data.byteLength !== systematicCapacity) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Data size ${data.byteLength} bytes does not match systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}). Provide pre-padded data before encoding.`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
const reedSolomon = createWasmReedSolomonBinding();
|
|
42
|
-
const shards = new Uint8Array(
|
|
43
|
-
systematicCapacity + erasure_m * chunkSizeBytes
|
|
44
|
-
);
|
|
45
|
-
shards.set(data, 0);
|
|
46
|
-
reedSolomon.encode(shards, erasure_k, erasure_m);
|
|
47
|
-
const chunks = new Array(erasure_n);
|
|
48
|
-
for (let idx = 0; idx < erasure_n; idx++) {
|
|
49
|
-
const start = idx * chunkSizeBytes;
|
|
50
|
-
chunks[idx] = shards.slice(start, start + chunkSizeBytes);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
chunks,
|
|
54
|
-
systematic: chunks.slice(0, erasure_k),
|
|
55
|
-
parity: chunks.slice(erasure_k)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
decode(_available, _config) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
"ReedSolomonErasureCodingProvider does not implement decode"
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
getChunkMerkleRoots() {
|
|
64
|
-
throw new Error(
|
|
65
|
-
"ReedSolomonErasureCodingProvider does not implement getChunkMerkleRoots"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
ReedSolomonErasureCodingProvider
|
|
72
|
-
};
|
package/dist/chunk-NI6XBZLI.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getShelbyIndexerClient
|
|
3
|
-
} from "./chunk-KYQRWJ3U.mjs";
|
|
4
|
-
|
|
5
|
-
// src/core/clients/ShelbyPlacementGroupClient.ts
|
|
6
|
-
var ShelbyPlacementGroupClient = class {
|
|
7
|
-
indexer;
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new ShelbyPlacementGroupClient.
|
|
10
|
-
*
|
|
11
|
-
* @param config - The client configuration object.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const pgClient = new ShelbyPlacementGroupClient({
|
|
16
|
-
* network: Network.SHELBYNET,
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.indexer = getShelbyIndexerClient(config);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieves placement group slots from the indexer.
|
|
25
|
-
*
|
|
26
|
-
* @param params.where (optional) - The where clause to filter slots by.
|
|
27
|
-
* @param params.pagination (optional) - The pagination options.
|
|
28
|
-
* @param params.orderBy (optional) - The order by clause to sort slots by.
|
|
29
|
-
* @returns The placement group slots that match the filter.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* // Get all active slots
|
|
34
|
-
* const slots = await client.getPlacementGroupSlots({
|
|
35
|
-
* where: { status: { _eq: "active" } },
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
async getPlacementGroupSlots(params) {
|
|
40
|
-
const { limit, offset } = params.pagination ?? {};
|
|
41
|
-
const { orderBy, where } = params;
|
|
42
|
-
const { placement_group_slots } = await this.indexer.getPlacementGroupSlots(
|
|
43
|
-
{
|
|
44
|
-
where,
|
|
45
|
-
limit,
|
|
46
|
-
offset,
|
|
47
|
-
orderBy
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
return placement_group_slots.map(
|
|
51
|
-
(slot) => ({
|
|
52
|
-
placementGroup: slot.placement_group,
|
|
53
|
-
slotIndex: Number(slot.slot_index),
|
|
54
|
-
storageProvider: slot.storage_provider,
|
|
55
|
-
status: slot.status,
|
|
56
|
-
updatedAt: Number(slot.updated_at)
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves the total count of placement group slots from the indexer.
|
|
62
|
-
*
|
|
63
|
-
* @param params.where (optional) - The where clause to filter slots by.
|
|
64
|
-
* @returns The count of placement group slots that match the filter.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // Get count of active slots
|
|
69
|
-
* const count = await client.getPlacementGroupSlotsCount({
|
|
70
|
-
* where: { status: { _eq: "active" } },
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
async getPlacementGroupSlotsCount(params) {
|
|
75
|
-
const { where } = params;
|
|
76
|
-
const { placement_group_slots_aggregate } = await this.indexer.getPlacementGroupSlotsCount({ where });
|
|
77
|
-
return placement_group_slots_aggregate?.aggregate?.count ?? 0;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
ShelbyPlacementGroupClient
|
|
83
|
-
};
|
package/dist/chunk-OGKZ575S.mjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// src/core/erasure/clay-codes.ts
|
|
2
|
-
import {
|
|
3
|
-
createDecoder,
|
|
4
|
-
createEncoder
|
|
5
|
-
} from "@shelby-protocol/clay-codes";
|
|
6
|
-
function getTotalChunks(config) {
|
|
7
|
-
return config.erasure_n;
|
|
8
|
-
}
|
|
9
|
-
var ClayErasureCodingProvider = class _ClayErasureCodingProvider {
|
|
10
|
-
config;
|
|
11
|
-
encoderCache;
|
|
12
|
-
decoderCache;
|
|
13
|
-
lastFunction;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
this.lastFunction = "none" /* NONE */;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Static factory method to create an initialized ClayErasureCodingProvider
|
|
20
|
-
*/
|
|
21
|
-
static async create(config) {
|
|
22
|
-
const provider = new _ClayErasureCodingProvider(config);
|
|
23
|
-
[provider.encoderCache, provider.decoderCache] = await Promise.all([
|
|
24
|
-
createEncoder({
|
|
25
|
-
n: getTotalChunks(config),
|
|
26
|
-
k: config.erasure_k,
|
|
27
|
-
d: config.erasure_d,
|
|
28
|
-
chunkSizeBytes: config.chunkSizeBytes
|
|
29
|
-
}),
|
|
30
|
-
createDecoder({
|
|
31
|
-
n: getTotalChunks(config),
|
|
32
|
-
k: config.erasure_k,
|
|
33
|
-
d: config.erasure_d,
|
|
34
|
-
chunkSizeBytes: config.chunkSizeBytes,
|
|
35
|
-
erasedChunksMask: 0
|
|
36
|
-
// No chunks erased initially; will be reconfigured on decode
|
|
37
|
-
})
|
|
38
|
-
]);
|
|
39
|
-
return provider;
|
|
40
|
-
}
|
|
41
|
-
encode(data) {
|
|
42
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
43
|
-
if (!this.encoderCache) {
|
|
44
|
-
throw new Error("Encoder cache is missing");
|
|
45
|
-
}
|
|
46
|
-
const systematicCapacity = erasure_k * chunkSizeBytes;
|
|
47
|
-
if (data.byteLength > systematicCapacity) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Data size ${data.byteLength} bytes exceeds systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}).`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (this.requiresPadding(data.length)) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Data size ${data.length} bytes does not match systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}). Provide pre-padded data before encoding.`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
this.lastFunction = "encoded" /* ENCODED */;
|
|
58
|
-
return this.encoderCache.erasureCode(data);
|
|
59
|
-
}
|
|
60
|
-
decode(available, config) {
|
|
61
|
-
if (!this.decoderCache) {
|
|
62
|
-
throw new Error("Decoder cache is missing");
|
|
63
|
-
}
|
|
64
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
65
|
-
if (available.length < erasure_k) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`Insufficient available chunks: need at least ${erasure_k}, received ${available.length}.`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
for (let i = 0; i < available.length; i++) {
|
|
71
|
-
const chunk = available[i];
|
|
72
|
-
if (chunk.length !== chunkSizeBytes) {
|
|
73
|
-
throw new Error(
|
|
74
|
-
`Chunk ${i} size ${chunk.length} bytes does not match expected chunkSizeBytes ${chunkSizeBytes}.`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
this.lastFunction = "decoded" /* DECODED */;
|
|
79
|
-
return this.decoderCache.decode(available, config);
|
|
80
|
-
}
|
|
81
|
-
getChunkMerkleRoots() {
|
|
82
|
-
if (this.decoderCache && this.lastFunction === "decoded" /* DECODED */)
|
|
83
|
-
return this.decoderCache.getChunkMerkleRoots();
|
|
84
|
-
if (this.encoderCache && this.lastFunction === "encoded" /* ENCODED */)
|
|
85
|
-
return this.encoderCache.getChunkMerkleRoots();
|
|
86
|
-
throw new Error(
|
|
87
|
-
"You must call encode or decode before calling getChunkMerkleRoots"
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Determines if data can be erasure coded as-is or requires padding.
|
|
92
|
-
*
|
|
93
|
-
* Data can be erasure coded without padding if its size exactly matches
|
|
94
|
-
* the total systematic data capacity (k * chunkSizeBytes).
|
|
95
|
-
*
|
|
96
|
-
* @param dataSize - Size of the data in bytes
|
|
97
|
-
* @returns true if data needs padding, false if it can be coded as-is
|
|
98
|
-
*/
|
|
99
|
-
requiresPadding(dataSize) {
|
|
100
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
101
|
-
const systematicCapacity = erasure_k * chunkSizeBytes;
|
|
102
|
-
return dataSize !== systematicCapacity;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
function buildClayConfig(input) {
|
|
106
|
-
const { erasure_n, erasure_k, erasure_d, chunkSizeBytes, enumIndex } = input;
|
|
107
|
-
if (erasure_n <= 0)
|
|
108
|
-
throw new Error("erasure_n (total number of chunks) must be > 0");
|
|
109
|
-
if (erasure_k <= 0)
|
|
110
|
-
throw new Error("erasure_k (number of data chunks) must be > 0");
|
|
111
|
-
if (erasure_k >= erasure_n)
|
|
112
|
-
throw new Error(
|
|
113
|
-
`erasure_k (${erasure_k}) must be < erasure_n (${erasure_n})`
|
|
114
|
-
);
|
|
115
|
-
if (erasure_d <= erasure_k)
|
|
116
|
-
throw new Error(
|
|
117
|
-
`erasure_d (${erasure_d}) must be > erasure_k (${erasure_k})`
|
|
118
|
-
);
|
|
119
|
-
if (erasure_d >= erasure_n)
|
|
120
|
-
throw new Error(
|
|
121
|
-
`erasure_d (${erasure_d}) must be < erasure_n (${erasure_n})`
|
|
122
|
-
);
|
|
123
|
-
if (chunkSizeBytes <= 0) throw new Error("chunkSizeBytes must be > 0");
|
|
124
|
-
return {
|
|
125
|
-
erasure_n,
|
|
126
|
-
erasure_k,
|
|
127
|
-
erasure_d,
|
|
128
|
-
chunkSizeBytes,
|
|
129
|
-
enumIndex
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
ClayErasureCodingProvider,
|
|
135
|
-
buildClayConfig
|
|
136
|
-
};
|
package/dist/chunk-QQ57OGQ2.mjs
DELETED
|
File without changes
|