@shelby-protocol/sdk 0.3.0 → 0.4.0
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 +19 -10
- package/dist/browser/index.mjs +4200 -146
- package/dist/core/aptos-explorer.mjs +46 -5
- package/dist/core/blobs.mjs +12 -4
- package/dist/core/chunk.mjs +58 -9
- package/dist/core/clients/ShelbyBlobClient.d.ts +155 -83
- package/dist/core/clients/ShelbyBlobClient.mjs +1286 -17
- package/dist/core/clients/ShelbyClient.d.ts +39 -6
- package/dist/core/clients/ShelbyClient.mjs +3233 -23
- package/dist/core/clients/ShelbyClientConfig.d.ts +9 -1
- package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
- package/dist/core/clients/ShelbyMetadataClient.d.ts +20 -6
- package/dist/core/clients/ShelbyMetadataClient.mjs +388 -6
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -7
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +894 -13
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +310 -8
- package/dist/core/clients/ShelbyRPCClient.d.ts +117 -25
- package/dist/core/clients/ShelbyRPCClient.mjs +1245 -12
- package/dist/core/clients/index.d.ts +4 -2
- package/dist/core/clients/index.mjs +3802 -39
- package/dist/core/clients/utils.mjs +65 -6
- package/dist/core/commitments.d.ts +12 -1
- package/dist/core/commitments.mjs +277 -11
- package/dist/core/constants.d.ts +3 -3
- package/dist/core/constants.mjs +39 -16
- package/dist/core/erasure/clay-codes.mjs +129 -4
- package/dist/core/erasure/constants.d.ts +16 -1
- package/dist/core/erasure/constants.mjs +48 -11
- package/dist/core/erasure/default.mjs +191 -9
- package/dist/core/erasure/index.d.ts +1 -1
- package/dist/core/erasure/index.mjs +281 -24
- package/dist/core/erasure/reed-solomon.mjs +68 -4
- package/dist/core/erasure/utils.mjs +0 -2
- package/dist/core/errors.d.ts +20 -1
- package/dist/core/errors.mjs +58 -8
- package/dist/core/index.d.ts +9 -9
- package/dist/core/index.mjs +4194 -146
- package/dist/core/layout.mjs +37 -5
- package/dist/core/networks.mjs +10 -5
- package/dist/core/operations/generated/sdk.d.ts +807 -42
- package/dist/core/operations/generated/sdk.mjs +267 -18
- package/dist/core/operations/index.d.ts +1 -1
- package/dist/core/operations/index.mjs +368 -24
- package/dist/core/promises.mjs +4 -4
- package/dist/core/rpc-responses.d.ts +1 -57
- package/dist/core/rpc-responses.mjs +14 -15
- package/dist/core/shelby-explorer.mjs +31 -6
- package/dist/core/sp/chunk_proof.d.ts +23 -0
- package/dist/core/sp/chunk_proof.mjs +113 -0
- package/dist/core/sp/index.d.ts +3 -0
- package/dist/core/sp/index.mjs +402 -0
- package/dist/core/sp/sp_write_client.d.ts +53 -0
- package/dist/core/sp/sp_write_client.mjs +302 -0
- package/dist/core/strings.mjs +0 -2
- package/dist/core/types/blobs.d.ts +24 -5
- package/dist/core/types/blobs.mjs +24 -1
- package/dist/core/types/index.d.ts +2 -2
- package/dist/core/types/index.mjs +275 -10
- 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.d.ts +32 -6
- package/dist/core/types/storage_providers.mjs +22 -1
- package/dist/core/utils.mjs +94 -8
- package/dist/gen/rpc_server_pb.d.ts +295 -0
- package/dist/gen/rpc_server_pb.mjs +28 -0
- package/dist/node/clients/ShelbyNodeClient.d.ts +2 -0
- package/dist/node/clients/ShelbyNodeClient.mjs +3237 -24
- package/dist/node/clients/index.d.ts +2 -0
- package/dist/node/clients/index.mjs +3236 -26
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.mjs +4217 -153
- package/dist/node/parallel/commitment_worker.d.ts +9 -0
- package/dist/node/parallel/commitment_worker.mjs +85 -0
- package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
- package/dist/node/parallel/commitment_worker_pool.mjs +339 -0
- package/dist/node/parallel/coverage_flush.d.ts +16 -0
- package/dist/node/parallel/coverage_flush.mjs +43 -0
- package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
- package/dist/node/parallel/default_commitment_worker_pool.mjs +355 -0
- package/dist/node/parallel/index.d.ts +12 -0
- package/dist/node/parallel/index.mjs +631 -0
- package/dist/node/parallel/parallel_commitments.d.ts +32 -0
- package/dist/node/parallel/parallel_commitments.mjs +614 -0
- package/dist/node/parallel/worker_pool.d.ts +74 -0
- package/dist/node/parallel/worker_pool.mjs +301 -0
- package/dist/node/testUtil.mjs +8 -4
- package/package.json +16 -5
- package/dist/chunk-3NRBHSMQ.mjs +0 -12
- package/dist/chunk-5BVSWXQJ.mjs +0 -801
- package/dist/chunk-6FJNAUU5.mjs +0 -278
- package/dist/chunk-6XSZRDLJ.mjs +0 -375
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-A4IG6GSE.mjs +0 -21
- package/dist/chunk-AD2G3QYD.mjs +0 -0
- package/dist/chunk-AUQDI5BS.mjs +0 -43
- package/dist/chunk-AY3HBWXA.mjs +0 -51
- package/dist/chunk-BDSW5PHM.mjs +0 -37
- 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-JTXYKO3U.mjs +0 -38
- package/dist/chunk-KG2TMLEV.mjs +0 -207
- package/dist/chunk-M3CP5TFP.mjs +0 -39
- package/dist/chunk-M7W43K2Q.mjs +0 -505
- package/dist/chunk-MB7C7VQF.mjs +0 -0
- package/dist/chunk-MNCQBEMS.mjs +0 -55
- package/dist/chunk-MQUVYMNQ.mjs +0 -0
- package/dist/chunk-NEO7Z3ZQ.mjs +0 -49
- package/dist/chunk-NHWWORCH.mjs +0 -72
- package/dist/chunk-OEK24ON7.mjs +0 -135
- package/dist/chunk-QQ57OGQ2.mjs +0 -0
- package/dist/chunk-RNNJXTX2.mjs +0 -154
- package/dist/chunk-S6Q4OG7H.mjs +0 -83
- package/dist/chunk-TET3DJEO.mjs +0 -199
- package/dist/chunk-UEZNZBJO.mjs +0 -104
- package/dist/chunk-V46D5NBW.mjs +0 -11
- package/dist/chunk-V4B3GAMQ.mjs +0 -42
- package/dist/chunk-WFWRBNTW.mjs +0 -412
- package/dist/chunk-WTICJPDB.mjs +0 -0
- package/dist/chunk-XNEIWM4O.mjs +0 -0
- package/dist/chunk-Z4FZ7W6L.mjs +0 -39
- package/dist/chunk-Z7RFCADT.mjs +0 -0
- package/dist/chunk-ZHXCVRZX.mjs +0 -0
package/dist/chunk-OEK24ON7.mjs
DELETED
|
@@ -1,135 +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
|
-
erasedChunkIndexes: []
|
|
36
|
-
})
|
|
37
|
-
]);
|
|
38
|
-
return provider;
|
|
39
|
-
}
|
|
40
|
-
encode(data) {
|
|
41
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
42
|
-
if (!this.encoderCache) {
|
|
43
|
-
throw new Error("Encoder cache is missing");
|
|
44
|
-
}
|
|
45
|
-
const systematicCapacity = erasure_k * chunkSizeBytes;
|
|
46
|
-
if (data.byteLength > systematicCapacity) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Data size ${data.byteLength} bytes exceeds systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}).`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
if (this.requiresPadding(data.length)) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`Data size ${data.length} bytes does not match systematic capacity ${systematicCapacity} bytes (erasure_k=${erasure_k} * chunkSizeBytes=${chunkSizeBytes}). Provide pre-padded data before encoding.`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
this.lastFunction = "encoded" /* ENCODED */;
|
|
57
|
-
return this.encoderCache.erasureCode(data);
|
|
58
|
-
}
|
|
59
|
-
decode(available, config) {
|
|
60
|
-
if (!this.decoderCache) {
|
|
61
|
-
throw new Error("Decoder cache is missing");
|
|
62
|
-
}
|
|
63
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
64
|
-
if (available.length < erasure_k) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`Insufficient available chunks: need at least ${erasure_k}, received ${available.length}.`
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
for (let i = 0; i < available.length; i++) {
|
|
70
|
-
const chunk = available[i];
|
|
71
|
-
if (chunk.length !== chunkSizeBytes) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`Chunk ${i} size ${chunk.length} bytes does not match expected chunkSizeBytes ${chunkSizeBytes}.`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
this.lastFunction = "decoded" /* DECODED */;
|
|
78
|
-
return this.decoderCache.decode(available, config);
|
|
79
|
-
}
|
|
80
|
-
getChunkMerkleRoots() {
|
|
81
|
-
if (this.decoderCache && this.lastFunction === "decoded" /* DECODED */)
|
|
82
|
-
return this.decoderCache.getChunkMerkleRoots();
|
|
83
|
-
if (this.encoderCache && this.lastFunction === "encoded" /* ENCODED */)
|
|
84
|
-
return this.encoderCache.getChunkMerkleRoots();
|
|
85
|
-
throw new Error(
|
|
86
|
-
"You must call encode or decode before calling getChunkMerkleRoots"
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Determines if data can be erasure coded as-is or requires padding.
|
|
91
|
-
*
|
|
92
|
-
* Data can be erasure coded without padding if its size exactly matches
|
|
93
|
-
* the total systematic data capacity (k * chunkSizeBytes).
|
|
94
|
-
*
|
|
95
|
-
* @param dataSize - Size of the data in bytes
|
|
96
|
-
* @returns true if data needs padding, false if it can be coded as-is
|
|
97
|
-
*/
|
|
98
|
-
requiresPadding(dataSize) {
|
|
99
|
-
const { erasure_k, chunkSizeBytes } = this.config;
|
|
100
|
-
const systematicCapacity = erasure_k * chunkSizeBytes;
|
|
101
|
-
return dataSize !== systematicCapacity;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
function buildClayConfig(input) {
|
|
105
|
-
const { erasure_n, erasure_k, erasure_d, chunkSizeBytes, enumIndex } = input;
|
|
106
|
-
if (erasure_n <= 0)
|
|
107
|
-
throw new Error("erasure_n (total number of chunks) must be > 0");
|
|
108
|
-
if (erasure_k <= 0)
|
|
109
|
-
throw new Error("erasure_k (number of data chunks) must be > 0");
|
|
110
|
-
if (erasure_k >= erasure_n)
|
|
111
|
-
throw new Error(
|
|
112
|
-
`erasure_k (${erasure_k}) must be < erasure_n (${erasure_n})`
|
|
113
|
-
);
|
|
114
|
-
if (erasure_d <= erasure_k)
|
|
115
|
-
throw new Error(
|
|
116
|
-
`erasure_d (${erasure_d}) must be > erasure_k (${erasure_k})`
|
|
117
|
-
);
|
|
118
|
-
if (erasure_d >= erasure_n)
|
|
119
|
-
throw new Error(
|
|
120
|
-
`erasure_d (${erasure_d}) must be < erasure_n (${erasure_n})`
|
|
121
|
-
);
|
|
122
|
-
if (chunkSizeBytes <= 0) throw new Error("chunkSizeBytes must be > 0");
|
|
123
|
-
return {
|
|
124
|
-
erasure_n,
|
|
125
|
-
erasure_k,
|
|
126
|
-
erasure_d,
|
|
127
|
-
chunkSizeBytes,
|
|
128
|
-
enumIndex
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export {
|
|
133
|
-
ClayErasureCodingProvider,
|
|
134
|
-
buildClayConfig
|
|
135
|
-
};
|
package/dist/chunk-QQ57OGQ2.mjs
DELETED
|
File without changes
|
package/dist/chunk-RNNJXTX2.mjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
concatHashes,
|
|
3
|
-
readInChunks,
|
|
4
|
-
zeroPadBytes
|
|
5
|
-
} from "./chunk-UEZNZBJO.mjs";
|
|
6
|
-
import {
|
|
7
|
-
DEFAULT_CHUNKSET_SIZE_BYTES
|
|
8
|
-
} from "./chunk-JTXYKO3U.mjs";
|
|
9
|
-
import {
|
|
10
|
-
DEFAULT_ERASURE_K,
|
|
11
|
-
DEFAULT_ERASURE_M
|
|
12
|
-
} from "./chunk-AUQDI5BS.mjs";
|
|
13
|
-
|
|
14
|
-
// src/core/commitments.ts
|
|
15
|
-
import { Hex } from "@aptos-labs/ts-sdk";
|
|
16
|
-
import { z } from "zod";
|
|
17
|
-
var COMMITMENT_SCHEMA_VERSION = "1.3";
|
|
18
|
-
var ChunksetCommitmentSchema = z.object({
|
|
19
|
-
// Chunkset root (vector commitment of child chunks)
|
|
20
|
-
chunkset_root: z.string(),
|
|
21
|
-
// the size is known statically from the current configuration
|
|
22
|
-
chunk_commitments: z.array(z.string())
|
|
23
|
-
}).refine(
|
|
24
|
-
(data) => {
|
|
25
|
-
return data.chunk_commitments.length === DEFAULT_ERASURE_K + DEFAULT_ERASURE_M;
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
message: `Chunkset must have exactly ${DEFAULT_ERASURE_K + DEFAULT_ERASURE_M} chunks (ERASURE_K + ERASURE_M = ${DEFAULT_ERASURE_K} + ${DEFAULT_ERASURE_M})`,
|
|
29
|
-
path: ["chunk_commitments"]
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
function expectedTotalChunksets(rawSize, chunksetSize = DEFAULT_CHUNKSET_SIZE_BYTES) {
|
|
33
|
-
if (chunksetSize <= 0) {
|
|
34
|
-
throw new Error("chunksetSize must be positive");
|
|
35
|
-
}
|
|
36
|
-
if (rawSize === 0) return 1;
|
|
37
|
-
return Math.ceil(rawSize / chunksetSize);
|
|
38
|
-
}
|
|
39
|
-
var BlobCommitmentsSchema = z.object({
|
|
40
|
-
schema_version: z.string(),
|
|
41
|
-
raw_data_size: z.number(),
|
|
42
|
-
// FIXME I am not sure about this being here, or if it should be somewhere else
|
|
43
|
-
blob_merkle_root: z.string(),
|
|
44
|
-
chunkset_commitments: z.array(ChunksetCommitmentSchema)
|
|
45
|
-
}).refine(
|
|
46
|
-
(data) => {
|
|
47
|
-
return expectedTotalChunksets(data.raw_data_size) === data.chunkset_commitments.length;
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
message: "Total chunkset count mismatches with raw data size",
|
|
51
|
-
// FIXME put more details in here
|
|
52
|
-
path: ["chunkset_commitments"]
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
async function generateMerkleRoot(leafHashes) {
|
|
56
|
-
if (!leafHashes.length) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
"An empty array cannot be used to construct a Merkle tree."
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const zeroArray = new Uint8Array(leafHashes[0].toUint8Array().length);
|
|
62
|
-
const zeroBytes = Hex.fromHexInput(zeroArray);
|
|
63
|
-
let currentLeaves = leafHashes;
|
|
64
|
-
while (currentLeaves.length > 1) {
|
|
65
|
-
if (currentLeaves.length % 2 !== 0) {
|
|
66
|
-
currentLeaves.push(zeroBytes);
|
|
67
|
-
}
|
|
68
|
-
const nextLeaves = [];
|
|
69
|
-
for (let i = 0; i < currentLeaves.length; i += 2) {
|
|
70
|
-
nextLeaves.push(
|
|
71
|
-
await concatHashes([
|
|
72
|
-
currentLeaves[i].toUint8Array(),
|
|
73
|
-
currentLeaves[i + 1].toUint8Array()
|
|
74
|
-
])
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
currentLeaves = nextLeaves;
|
|
78
|
-
}
|
|
79
|
-
return currentLeaves[0];
|
|
80
|
-
}
|
|
81
|
-
async function generateChunksetCommitments(chunksetIdx, chunksetData, expectedChunksetSize, provider, onChunk) {
|
|
82
|
-
const { erasure_n } = provider.config;
|
|
83
|
-
const chunksetPayload = zeroPadBytes(chunksetData, expectedChunksetSize);
|
|
84
|
-
const { chunks } = provider.encode(chunksetPayload);
|
|
85
|
-
if (chunks.length !== erasure_n) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Erasure provider produced ${chunks.length} chunks, expected ${erasure_n}.`
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const chunkRoots = provider.getChunkMerkleRoots();
|
|
91
|
-
let chunkIdx = 0;
|
|
92
|
-
for (const chunkData of chunks) {
|
|
93
|
-
if (onChunk !== void 0) {
|
|
94
|
-
await onChunk(chunksetIdx, chunkIdx, chunkData);
|
|
95
|
-
}
|
|
96
|
-
chunkIdx += 1;
|
|
97
|
-
}
|
|
98
|
-
const a = await generateMerkleRoot(
|
|
99
|
-
chunkRoots.map((a2) => Hex.fromHexInput(a2))
|
|
100
|
-
);
|
|
101
|
-
const entry = {
|
|
102
|
-
chunkset_root: a.toString(),
|
|
103
|
-
chunk_commitments: chunkRoots.map(
|
|
104
|
-
(chunk) => Hex.fromHexInput(chunk).toString()
|
|
105
|
-
)
|
|
106
|
-
};
|
|
107
|
-
return { h: a, entry };
|
|
108
|
-
}
|
|
109
|
-
async function generateCommitments(provider, fullData, onChunk) {
|
|
110
|
-
const expectedChunksetSize = provider.config.chunkSizeBytes * provider.config.erasure_k;
|
|
111
|
-
const chunksetCommitments = [];
|
|
112
|
-
const chunksetCommitmentHashes = [];
|
|
113
|
-
let rawDataSize = 0;
|
|
114
|
-
const chunksetGen = readInChunks(fullData, expectedChunksetSize);
|
|
115
|
-
for await (const [chunksetIdx, chunksetData] of chunksetGen) {
|
|
116
|
-
rawDataSize += chunksetData.length;
|
|
117
|
-
const { h, entry } = await generateChunksetCommitments(
|
|
118
|
-
chunksetIdx,
|
|
119
|
-
chunksetData,
|
|
120
|
-
expectedChunksetSize,
|
|
121
|
-
provider,
|
|
122
|
-
onChunk
|
|
123
|
-
);
|
|
124
|
-
chunksetCommitments.push(entry);
|
|
125
|
-
chunksetCommitmentHashes.push(h);
|
|
126
|
-
}
|
|
127
|
-
if (rawDataSize === 0) {
|
|
128
|
-
const zeroChunkset = new Uint8Array(expectedChunksetSize);
|
|
129
|
-
const { h, entry } = await generateChunksetCommitments(
|
|
130
|
-
0,
|
|
131
|
-
zeroChunkset,
|
|
132
|
-
expectedChunksetSize,
|
|
133
|
-
provider,
|
|
134
|
-
onChunk
|
|
135
|
-
);
|
|
136
|
-
chunksetCommitments.push(entry);
|
|
137
|
-
chunksetCommitmentHashes.push(h);
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
schema_version: COMMITMENT_SCHEMA_VERSION,
|
|
141
|
-
raw_data_size: rawDataSize,
|
|
142
|
-
blob_merkle_root: (await generateMerkleRoot(chunksetCommitmentHashes)).toString(),
|
|
143
|
-
chunkset_commitments: chunksetCommitments
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export {
|
|
148
|
-
COMMITMENT_SCHEMA_VERSION,
|
|
149
|
-
ChunksetCommitmentSchema,
|
|
150
|
-
expectedTotalChunksets,
|
|
151
|
-
BlobCommitmentsSchema,
|
|
152
|
-
generateMerkleRoot,
|
|
153
|
-
generateCommitments
|
|
154
|
-
};
|
package/dist/chunk-S6Q4OG7H.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getShelbyIndexerClient
|
|
3
|
-
} from "./chunk-NEO7Z3ZQ.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-TET3DJEO.mjs
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// src/core/operations/generated/sdk.ts
|
|
2
|
-
import gql from "graphql-tag";
|
|
3
|
-
var Blob_Activities_Select_Column = /* @__PURE__ */ ((Blob_Activities_Select_Column2) => {
|
|
4
|
-
Blob_Activities_Select_Column2["BlobName"] = "blob_name";
|
|
5
|
-
Blob_Activities_Select_Column2["EventIndex"] = "event_index";
|
|
6
|
-
Blob_Activities_Select_Column2["EventType"] = "event_type";
|
|
7
|
-
Blob_Activities_Select_Column2["Timestamp"] = "timestamp";
|
|
8
|
-
Blob_Activities_Select_Column2["TransactionHash"] = "transaction_hash";
|
|
9
|
-
Blob_Activities_Select_Column2["TransactionVersion"] = "transaction_version";
|
|
10
|
-
return Blob_Activities_Select_Column2;
|
|
11
|
-
})(Blob_Activities_Select_Column || {});
|
|
12
|
-
var Blobs_Select_Column = /* @__PURE__ */ ((Blobs_Select_Column2) => {
|
|
13
|
-
Blobs_Select_Column2["BlobCommitment"] = "blob_commitment";
|
|
14
|
-
Blobs_Select_Column2["BlobName"] = "blob_name";
|
|
15
|
-
Blobs_Select_Column2["CreatedAt"] = "created_at";
|
|
16
|
-
Blobs_Select_Column2["ExpiresAt"] = "expires_at";
|
|
17
|
-
Blobs_Select_Column2["IsDeleted"] = "is_deleted";
|
|
18
|
-
Blobs_Select_Column2["IsWritten"] = "is_written";
|
|
19
|
-
Blobs_Select_Column2["NumChunksets"] = "num_chunksets";
|
|
20
|
-
Blobs_Select_Column2["Owner"] = "owner";
|
|
21
|
-
Blobs_Select_Column2["PlacementGroup"] = "placement_group";
|
|
22
|
-
Blobs_Select_Column2["Size"] = "size";
|
|
23
|
-
Blobs_Select_Column2["SliceAddress"] = "slice_address";
|
|
24
|
-
Blobs_Select_Column2["UpdatedAt"] = "updated_at";
|
|
25
|
-
return Blobs_Select_Column2;
|
|
26
|
-
})(Blobs_Select_Column || {});
|
|
27
|
-
var Cursor_Ordering = /* @__PURE__ */ ((Cursor_Ordering2) => {
|
|
28
|
-
Cursor_Ordering2["Asc"] = "ASC";
|
|
29
|
-
Cursor_Ordering2["Desc"] = "DESC";
|
|
30
|
-
return Cursor_Ordering2;
|
|
31
|
-
})(Cursor_Ordering || {});
|
|
32
|
-
var Order_By = /* @__PURE__ */ ((Order_By2) => {
|
|
33
|
-
Order_By2["Asc"] = "asc";
|
|
34
|
-
Order_By2["AscNullsFirst"] = "asc_nulls_first";
|
|
35
|
-
Order_By2["AscNullsLast"] = "asc_nulls_last";
|
|
36
|
-
Order_By2["Desc"] = "desc";
|
|
37
|
-
Order_By2["DescNullsFirst"] = "desc_nulls_first";
|
|
38
|
-
Order_By2["DescNullsLast"] = "desc_nulls_last";
|
|
39
|
-
return Order_By2;
|
|
40
|
-
})(Order_By || {});
|
|
41
|
-
var Placement_Group_Slots_Select_Column = /* @__PURE__ */ ((Placement_Group_Slots_Select_Column2) => {
|
|
42
|
-
Placement_Group_Slots_Select_Column2["PlacementGroup"] = "placement_group";
|
|
43
|
-
Placement_Group_Slots_Select_Column2["SlotIndex"] = "slot_index";
|
|
44
|
-
Placement_Group_Slots_Select_Column2["Status"] = "status";
|
|
45
|
-
Placement_Group_Slots_Select_Column2["StorageProvider"] = "storage_provider";
|
|
46
|
-
Placement_Group_Slots_Select_Column2["UpdatedAt"] = "updated_at";
|
|
47
|
-
return Placement_Group_Slots_Select_Column2;
|
|
48
|
-
})(Placement_Group_Slots_Select_Column || {});
|
|
49
|
-
var Processor_Status_Select_Column = /* @__PURE__ */ ((Processor_Status_Select_Column2) => {
|
|
50
|
-
Processor_Status_Select_Column2["LastSuccessVersion"] = "last_success_version";
|
|
51
|
-
Processor_Status_Select_Column2["LastTransactionTimestamp"] = "last_transaction_timestamp";
|
|
52
|
-
Processor_Status_Select_Column2["LastUpdated"] = "last_updated";
|
|
53
|
-
return Processor_Status_Select_Column2;
|
|
54
|
-
})(Processor_Status_Select_Column || {});
|
|
55
|
-
var GetBlobsDocument = gql`
|
|
56
|
-
query getBlobs($where: blobs_bool_exp, $orderBy: [blobs_order_by!], $limit: Int, $offset: Int) {
|
|
57
|
-
blobs(where: $where, order_by: $orderBy, limit: $limit, offset: $offset) {
|
|
58
|
-
owner
|
|
59
|
-
blob_commitment
|
|
60
|
-
blob_name
|
|
61
|
-
created_at
|
|
62
|
-
expires_at
|
|
63
|
-
num_chunksets
|
|
64
|
-
is_deleted
|
|
65
|
-
is_written
|
|
66
|
-
placement_group
|
|
67
|
-
size
|
|
68
|
-
updated_at
|
|
69
|
-
slice_address
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
var GetBlobActivitiesDocument = gql`
|
|
74
|
-
query getBlobActivities($where: blob_activities_bool_exp, $orderBy: [blob_activities_order_by!], $limit: Int, $offset: Int) {
|
|
75
|
-
blob_activities(
|
|
76
|
-
where: $where
|
|
77
|
-
order_by: $orderBy
|
|
78
|
-
limit: $limit
|
|
79
|
-
offset: $offset
|
|
80
|
-
) {
|
|
81
|
-
blob_name
|
|
82
|
-
event_index
|
|
83
|
-
event_type
|
|
84
|
-
transaction_hash
|
|
85
|
-
transaction_version
|
|
86
|
-
timestamp
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
var GetBlobsCountDocument = gql`
|
|
91
|
-
query getBlobsCount($where: blobs_bool_exp) {
|
|
92
|
-
blobs_aggregate(where: $where) {
|
|
93
|
-
aggregate {
|
|
94
|
-
count
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
var GetBlobActivitiesCountDocument = gql`
|
|
100
|
-
query getBlobActivitiesCount($where: blob_activities_bool_exp) {
|
|
101
|
-
blob_activities_aggregate(where: $where) {
|
|
102
|
-
aggregate {
|
|
103
|
-
count
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
var GetTotalBlobsSizeDocument = gql`
|
|
109
|
-
query getTotalBlobsSize($where: blobs_bool_exp) {
|
|
110
|
-
blobs_aggregate(where: $where) {
|
|
111
|
-
aggregate {
|
|
112
|
-
sum {
|
|
113
|
-
size
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
var GetPlacementGroupSlotsDocument = gql`
|
|
120
|
-
query getPlacementGroupSlots($where: placement_group_slots_bool_exp, $orderBy: [placement_group_slots_order_by!], $limit: Int, $offset: Int) {
|
|
121
|
-
placement_group_slots(
|
|
122
|
-
where: $where
|
|
123
|
-
order_by: $orderBy
|
|
124
|
-
limit: $limit
|
|
125
|
-
offset: $offset
|
|
126
|
-
) {
|
|
127
|
-
placement_group
|
|
128
|
-
slot_index
|
|
129
|
-
storage_provider
|
|
130
|
-
status
|
|
131
|
-
updated_at
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`;
|
|
135
|
-
var GetPlacementGroupSlotsCountDocument = gql`
|
|
136
|
-
query getPlacementGroupSlotsCount($where: placement_group_slots_bool_exp) {
|
|
137
|
-
placement_group_slots_aggregate(where: $where) {
|
|
138
|
-
aggregate {
|
|
139
|
-
count
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
var GetProcessorStatusDocument = gql`
|
|
145
|
-
query getProcessorStatus {
|
|
146
|
-
processor_status {
|
|
147
|
-
last_success_version
|
|
148
|
-
last_transaction_timestamp
|
|
149
|
-
last_updated
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
`;
|
|
153
|
-
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
154
|
-
function getSdk(client, withWrapper = defaultWrapper) {
|
|
155
|
-
return {
|
|
156
|
-
getBlobs(variables, requestHeaders, signal) {
|
|
157
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobs", "query", variables);
|
|
158
|
-
},
|
|
159
|
-
getBlobActivities(variables, requestHeaders, signal) {
|
|
160
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivities", "query", variables);
|
|
161
|
-
},
|
|
162
|
-
getBlobsCount(variables, requestHeaders, signal) {
|
|
163
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobsCount", "query", variables);
|
|
164
|
-
},
|
|
165
|
-
getBlobActivitiesCount(variables, requestHeaders, signal) {
|
|
166
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivitiesCount", "query", variables);
|
|
167
|
-
},
|
|
168
|
-
getTotalBlobsSize(variables, requestHeaders, signal) {
|
|
169
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetTotalBlobsSizeDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getTotalBlobsSize", "query", variables);
|
|
170
|
-
},
|
|
171
|
-
getPlacementGroupSlots(variables, requestHeaders, signal) {
|
|
172
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlots", "query", variables);
|
|
173
|
-
},
|
|
174
|
-
getPlacementGroupSlotsCount(variables, requestHeaders, signal) {
|
|
175
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlotsCount", "query", variables);
|
|
176
|
-
},
|
|
177
|
-
getProcessorStatus(variables, requestHeaders, signal) {
|
|
178
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetProcessorStatusDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getProcessorStatus", "query", variables);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export {
|
|
184
|
-
Blob_Activities_Select_Column,
|
|
185
|
-
Blobs_Select_Column,
|
|
186
|
-
Cursor_Ordering,
|
|
187
|
-
Order_By,
|
|
188
|
-
Placement_Group_Slots_Select_Column,
|
|
189
|
-
Processor_Status_Select_Column,
|
|
190
|
-
GetBlobsDocument,
|
|
191
|
-
GetBlobActivitiesDocument,
|
|
192
|
-
GetBlobsCountDocument,
|
|
193
|
-
GetBlobActivitiesCountDocument,
|
|
194
|
-
GetTotalBlobsSizeDocument,
|
|
195
|
-
GetPlacementGroupSlotsDocument,
|
|
196
|
-
GetPlacementGroupSlotsCountDocument,
|
|
197
|
-
GetProcessorStatusDocument,
|
|
198
|
-
getSdk
|
|
199
|
-
};
|
package/dist/chunk-UEZNZBJO.mjs
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// src/core/utils.ts
|
|
2
|
-
import {
|
|
3
|
-
AccountAddress,
|
|
4
|
-
Hex
|
|
5
|
-
} from "@aptos-labs/ts-sdk";
|
|
6
|
-
async function* readInChunks(input, chunkSize) {
|
|
7
|
-
let idx = 0;
|
|
8
|
-
if (isReadableStream(input)) {
|
|
9
|
-
const reader = input.getReader();
|
|
10
|
-
let buffer = new Uint8Array(chunkSize);
|
|
11
|
-
let bufferWriteOffset = 0;
|
|
12
|
-
try {
|
|
13
|
-
while (true) {
|
|
14
|
-
const { value, done } = await reader.read();
|
|
15
|
-
if (done) break;
|
|
16
|
-
if (value === void 0) continue;
|
|
17
|
-
let srcOffset = 0;
|
|
18
|
-
while (srcOffset < value.length) {
|
|
19
|
-
const remainingCapacity = chunkSize - bufferWriteOffset;
|
|
20
|
-
const bytesToCopy = Math.min(
|
|
21
|
-
remainingCapacity,
|
|
22
|
-
value.length - srcOffset
|
|
23
|
-
);
|
|
24
|
-
buffer.set(
|
|
25
|
-
value.subarray(srcOffset, srcOffset + bytesToCopy),
|
|
26
|
-
bufferWriteOffset
|
|
27
|
-
);
|
|
28
|
-
bufferWriteOffset += bytesToCopy;
|
|
29
|
-
srcOffset += bytesToCopy;
|
|
30
|
-
if (bufferWriteOffset >= chunkSize) {
|
|
31
|
-
yield [idx++, buffer];
|
|
32
|
-
buffer = new Uint8Array(chunkSize);
|
|
33
|
-
bufferWriteOffset = 0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} finally {
|
|
38
|
-
reader.releaseLock();
|
|
39
|
-
}
|
|
40
|
-
if (bufferWriteOffset > 0) {
|
|
41
|
-
yield [idx++, buffer.subarray(0, bufferWriteOffset)];
|
|
42
|
-
}
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const view = toUint8Array(input);
|
|
46
|
-
for (let offset = 0; offset < view.byteLength; offset += chunkSize) {
|
|
47
|
-
yield [
|
|
48
|
-
idx++,
|
|
49
|
-
view.subarray(offset, Math.min(offset + chunkSize, view.byteLength))
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function zeroPadBytes(buffer, desiredLength) {
|
|
54
|
-
if (buffer.byteLength === desiredLength) {
|
|
55
|
-
return buffer;
|
|
56
|
-
}
|
|
57
|
-
if (buffer.byteLength > desiredLength) {
|
|
58
|
-
return buffer.subarray(0, desiredLength);
|
|
59
|
-
}
|
|
60
|
-
const paddedBuffer = new Uint8Array(desiredLength);
|
|
61
|
-
paddedBuffer.set(buffer);
|
|
62
|
-
return paddedBuffer;
|
|
63
|
-
}
|
|
64
|
-
async function concatHashes(parts) {
|
|
65
|
-
const chunks = parts.map((part) => Hex.fromHexInput(part).toUint8Array());
|
|
66
|
-
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);
|
|
67
|
-
const combined = new Uint8Array(totalLength);
|
|
68
|
-
let offset = 0;
|
|
69
|
-
for (const chunk of chunks) {
|
|
70
|
-
combined.set(chunk, offset);
|
|
71
|
-
offset += chunk.byteLength;
|
|
72
|
-
}
|
|
73
|
-
return Hex.fromHexInput(
|
|
74
|
-
new Uint8Array(await crypto.subtle.digest("SHA-256", combined))
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
function isReadableStream(value) {
|
|
78
|
-
return typeof value === "object" && value !== null && "getReader" in value && typeof value.getReader === "function";
|
|
79
|
-
}
|
|
80
|
-
function toUint8Array(view) {
|
|
81
|
-
return view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
82
|
-
}
|
|
83
|
-
function buildRequestUrl(path, baseUrl) {
|
|
84
|
-
const baseHasSlash = baseUrl.endsWith("/");
|
|
85
|
-
const safeBase = baseHasSlash ? baseUrl : `${baseUrl}/`;
|
|
86
|
-
const safePath = path.replace(/^\/+/, "");
|
|
87
|
-
return new URL(safePath, safeBase);
|
|
88
|
-
}
|
|
89
|
-
function getBlobNameSuffix(blobName) {
|
|
90
|
-
const parts = blobName.split("/");
|
|
91
|
-
return parts.slice(1).join("/") || "";
|
|
92
|
-
}
|
|
93
|
-
function normalizeAddress(address) {
|
|
94
|
-
return AccountAddress.from(address, { maxMissingChars: 63 });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export {
|
|
98
|
-
readInChunks,
|
|
99
|
-
zeroPadBytes,
|
|
100
|
-
concatHashes,
|
|
101
|
-
buildRequestUrl,
|
|
102
|
-
getBlobNameSuffix,
|
|
103
|
-
normalizeAddress
|
|
104
|
-
};
|