@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-AUQDI5BS.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/core/erasure/constants.ts
|
|
2
|
-
var ErasureCodingScheme = /* @__PURE__ */ ((ErasureCodingScheme2) => {
|
|
3
|
-
ErasureCodingScheme2["ClayCode_16Total_10Data_13Helper"] = "ClayCode_16Total_10Data_13Helper";
|
|
4
|
-
ErasureCodingScheme2["ClayCode_4Total_2Data_3Helper"] = "ClayCode_4Total_2Data_3Helper";
|
|
5
|
-
return ErasureCodingScheme2;
|
|
6
|
-
})(ErasureCodingScheme || {});
|
|
7
|
-
var ERASURE_CODE_PARAMS = {
|
|
8
|
-
["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */]: {
|
|
9
|
-
// total chunks (data + parity)
|
|
10
|
-
erasure_n: 16,
|
|
11
|
-
// data chunks
|
|
12
|
-
erasure_k: 10,
|
|
13
|
-
// helper nodes
|
|
14
|
-
erasure_d: 13,
|
|
15
|
-
// enum index
|
|
16
|
-
enumIndex: 0
|
|
17
|
-
},
|
|
18
|
-
["ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */]: {
|
|
19
|
-
// total chunks (data + parity)
|
|
20
|
-
erasure_n: 4,
|
|
21
|
-
// data chunks
|
|
22
|
-
erasure_k: 2,
|
|
23
|
-
// helper nodes
|
|
24
|
-
erasure_d: 3,
|
|
25
|
-
// enum index
|
|
26
|
-
enumIndex: 1
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var DEFAULT_ERASURE_N = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_n;
|
|
30
|
-
var DEFAULT_ERASURE_K = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_k;
|
|
31
|
-
var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS["ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */].erasure_d;
|
|
32
|
-
var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
|
|
33
|
-
var DEFAULT_SAMPLE_SIZE = 1024;
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
ErasureCodingScheme,
|
|
37
|
-
ERASURE_CODE_PARAMS,
|
|
38
|
-
DEFAULT_ERASURE_N,
|
|
39
|
-
DEFAULT_ERASURE_K,
|
|
40
|
-
DEFAULT_ERASURE_D,
|
|
41
|
-
DEFAULT_ERASURE_M,
|
|
42
|
-
DEFAULT_SAMPLE_SIZE
|
|
43
|
-
};
|
package/dist/chunk-AY3HBWXA.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClayErasureCodingProvider
|
|
3
|
-
} from "./chunk-OEK24ON7.mjs";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_CHUNK_SIZE_BYTES
|
|
6
|
-
} from "./chunk-JTXYKO3U.mjs";
|
|
7
|
-
import {
|
|
8
|
-
ERASURE_CODE_PARAMS
|
|
9
|
-
} from "./chunk-AUQDI5BS.mjs";
|
|
10
|
-
|
|
11
|
-
// src/core/erasure/default.ts
|
|
12
|
-
var defaultProviderPromise;
|
|
13
|
-
function createDefaultErasureCodingProvider() {
|
|
14
|
-
if (!defaultProviderPromise) {
|
|
15
|
-
defaultProviderPromise = ClayErasureCodingProvider.create(
|
|
16
|
-
defaultErasureCodingConfig()
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return defaultProviderPromise;
|
|
20
|
-
}
|
|
21
|
-
function defaultErasureCodingConfig() {
|
|
22
|
-
const encoding = Number(process.env.SHELBY_ENCODING) || 0;
|
|
23
|
-
if (encoding === 0) {
|
|
24
|
-
return erasureCodingConfig16Total10Data13Helper();
|
|
25
|
-
}
|
|
26
|
-
return erasureCodingConfig4Total2Data3Helper();
|
|
27
|
-
}
|
|
28
|
-
function erasureCodingConfig16Total10Data13Helper() {
|
|
29
|
-
return erasureCodingConfig(
|
|
30
|
-
"ClayCode_16Total_10Data_13Helper" /* ClayCode_16Total_10Data_13Helper */
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function erasureCodingConfig4Total2Data3Helper() {
|
|
34
|
-
return erasureCodingConfig("ClayCode_4Total_2Data_3Helper" /* ClayCode_4Total_2Data_3Helper */);
|
|
35
|
-
}
|
|
36
|
-
function erasureCodingConfig(encodingScheme) {
|
|
37
|
-
return {
|
|
38
|
-
erasure_n: ERASURE_CODE_PARAMS[encodingScheme].erasure_n,
|
|
39
|
-
erasure_k: ERASURE_CODE_PARAMS[encodingScheme].erasure_k,
|
|
40
|
-
erasure_d: ERASURE_CODE_PARAMS[encodingScheme].erasure_d,
|
|
41
|
-
chunkSizeBytes: DEFAULT_CHUNK_SIZE_BYTES,
|
|
42
|
-
enumIndex: ERASURE_CODE_PARAMS[encodingScheme].enumIndex
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
createDefaultErasureCodingProvider,
|
|
48
|
-
defaultErasureCodingConfig,
|
|
49
|
-
erasureCodingConfig16Total10Data13Helper,
|
|
50
|
-
erasureCodingConfig4Total2Data3Helper
|
|
51
|
-
};
|
package/dist/chunk-BDSW5PHM.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/core/shelby-explorer.ts
|
|
2
|
-
import { Network } from "@aptos-labs/ts-sdk";
|
|
3
|
-
function getShelbyExplorerBaseUrl(network) {
|
|
4
|
-
const normalizedNetwork = network.toLowerCase();
|
|
5
|
-
switch (normalizedNetwork) {
|
|
6
|
-
case Network.MAINNET.toLowerCase():
|
|
7
|
-
return "https://explorer.shelby.xyz/mainnet";
|
|
8
|
-
case Network.TESTNET.toLowerCase():
|
|
9
|
-
return "https://explorer.shelby.xyz/testnet";
|
|
10
|
-
case Network.DEVNET.toLowerCase():
|
|
11
|
-
return "https://explorer.shelby.xyz/devnet";
|
|
12
|
-
case Network.LOCAL.toLowerCase():
|
|
13
|
-
return "https://explorer.shelby.xyz/local";
|
|
14
|
-
case Network.SHELBYNET.toLowerCase():
|
|
15
|
-
return "https://explorer.shelby.xyz/shelbynet";
|
|
16
|
-
default:
|
|
17
|
-
return `https://explorer.shelby.xyz/${normalizedNetwork}`;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function getShelbyAccountBlobsExplorerUrl(network, accountAddress) {
|
|
21
|
-
const baseUrl = getShelbyExplorerBaseUrl(network);
|
|
22
|
-
return `${baseUrl}/account/${accountAddress}/blobs`;
|
|
23
|
-
}
|
|
24
|
-
function getShelbyBlobExplorerUrl(network, accountAddress, blobName) {
|
|
25
|
-
const baseUrl = getShelbyExplorerBaseUrl(network);
|
|
26
|
-
return `${baseUrl}/account/${accountAddress}/blob/${encodeURIComponent(blobName)}`;
|
|
27
|
-
}
|
|
28
|
-
function getShelbyAccountExplorerUrl(network, accountAddress) {
|
|
29
|
-
const baseUrl = getShelbyExplorerBaseUrl(network);
|
|
30
|
-
return `${baseUrl}/account/${accountAddress}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
getShelbyAccountBlobsExplorerUrl,
|
|
35
|
-
getShelbyBlobExplorerUrl,
|
|
36
|
-
getShelbyAccountExplorerUrl
|
|
37
|
-
};
|
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-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-KG2TMLEV.mjs
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MICROPAYMENTS_DEPLOYER
|
|
3
|
-
} from "./chunk-MNCQBEMS.mjs";
|
|
4
|
-
|
|
5
|
-
// src/core/types/payments.ts
|
|
6
|
-
import {
|
|
7
|
-
AccountAddress,
|
|
8
|
-
Deserializer,
|
|
9
|
-
Hex,
|
|
10
|
-
Serializer
|
|
11
|
-
} from "@aptos-labs/ts-sdk";
|
|
12
|
-
var MICROPAYMENTS_MODULE_NAME = "micropayments";
|
|
13
|
-
var WITHDRAW_APPROVAL_STRUCT_NAME = "WithdrawApproval";
|
|
14
|
-
function serializeTypeInfo(serializer, moduleAddress, moduleName, structName) {
|
|
15
|
-
moduleAddress.serialize(serializer);
|
|
16
|
-
const moduleNameBytes = new TextEncoder().encode(moduleName);
|
|
17
|
-
serializer.serializeBytes(moduleNameBytes);
|
|
18
|
-
const structNameBytes = new TextEncoder().encode(structName);
|
|
19
|
-
serializer.serializeBytes(structNameBytes);
|
|
20
|
-
}
|
|
21
|
-
var StaleChannelStateError = class _StaleChannelStateError extends Error {
|
|
22
|
-
/**
|
|
23
|
-
* The last valid micropayment stored by the server.
|
|
24
|
-
* Clients can use this to reset their local channel state.
|
|
25
|
-
*/
|
|
26
|
-
storedMicropayment;
|
|
27
|
-
constructor(storedMicropayment, message) {
|
|
28
|
-
super(
|
|
29
|
-
message ?? "Client has stale channel state. Use the returned micropayment to reset local state."
|
|
30
|
-
);
|
|
31
|
-
this.name = "StaleChannelStateError";
|
|
32
|
-
this.storedMicropayment = storedMicropayment;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Returns the stored micropayment as a base64-encoded string.
|
|
36
|
-
*/
|
|
37
|
-
toBase64() {
|
|
38
|
-
const bytes = this.storedMicropayment.bcsToBytes();
|
|
39
|
-
const binaryString = Array.from(
|
|
40
|
-
bytes,
|
|
41
|
-
(byte) => String.fromCharCode(byte)
|
|
42
|
-
).join("");
|
|
43
|
-
return btoa(binaryString);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a StaleChannelStateError from a base64-encoded micropayment string.
|
|
47
|
-
*/
|
|
48
|
-
static fromBase64(base64, message) {
|
|
49
|
-
const binaryString = atob(base64);
|
|
50
|
-
const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
|
|
51
|
-
const micropayment = SenderBuiltMicropayment.deserialize(bytes);
|
|
52
|
-
return new _StaleChannelStateError(micropayment, message);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var SenderBuiltMicropayment = class _SenderBuiltMicropayment {
|
|
56
|
-
/**
|
|
57
|
-
* The sender's address (owner of the payment channel).
|
|
58
|
-
*/
|
|
59
|
-
sender;
|
|
60
|
-
/**
|
|
61
|
-
* The receiver's address (beneficiary of the withdrawal).
|
|
62
|
-
*/
|
|
63
|
-
receiver;
|
|
64
|
-
/**
|
|
65
|
-
* The unique ID of the payment channel.
|
|
66
|
-
*/
|
|
67
|
-
paymentChannelId;
|
|
68
|
-
/**
|
|
69
|
-
* The cumulative amount the receiver is authorized to withdraw.
|
|
70
|
-
*/
|
|
71
|
-
amount;
|
|
72
|
-
/**
|
|
73
|
-
* The fungible asset metadata address.
|
|
74
|
-
*/
|
|
75
|
-
fungibleAssetAddress;
|
|
76
|
-
/**
|
|
77
|
-
* Monotonically increasing sequence number for replay protection.
|
|
78
|
-
*/
|
|
79
|
-
sequenceNumber;
|
|
80
|
-
/**
|
|
81
|
-
* The sender's Ed25519 public key (32 bytes).
|
|
82
|
-
* Used by the receiver to verify the signature before submitting.
|
|
83
|
-
*/
|
|
84
|
-
publicKey;
|
|
85
|
-
/**
|
|
86
|
-
* The Ed25519 signature of the SignedMessage<WithdrawApproval> struct.
|
|
87
|
-
* The SignedMessage includes TypeInfo for domain separation.
|
|
88
|
-
*/
|
|
89
|
-
signature;
|
|
90
|
-
/**
|
|
91
|
-
* The deployer address of the micropayments module.
|
|
92
|
-
* This is needed to reconstruct the TypeInfo for signature verification.
|
|
93
|
-
*/
|
|
94
|
-
deployer;
|
|
95
|
-
constructor(sender, receiver, paymentChannelId, amount, fungibleAssetAddress, sequenceNumber, publicKey, signature, deployer) {
|
|
96
|
-
this.sender = sender;
|
|
97
|
-
this.receiver = receiver;
|
|
98
|
-
this.paymentChannelId = paymentChannelId;
|
|
99
|
-
this.amount = amount;
|
|
100
|
-
this.fungibleAssetAddress = fungibleAssetAddress;
|
|
101
|
-
this.sequenceNumber = sequenceNumber;
|
|
102
|
-
this.publicKey = publicKey;
|
|
103
|
-
this.signature = signature;
|
|
104
|
-
this.deployer = deployer ?? AccountAddress.fromString(MICROPAYMENTS_DEPLOYER);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates the BCS-serialized message that was signed.
|
|
108
|
-
* This is a SignedMessage<WithdrawApproval> which includes:
|
|
109
|
-
* 1. TypeInfo (module_address, module_name, struct_name)
|
|
110
|
-
* 2. WithdrawApproval struct fields
|
|
111
|
-
*
|
|
112
|
-
* This format is used with signature_verify_strict_t for domain separation.
|
|
113
|
-
*/
|
|
114
|
-
getSignedMessage() {
|
|
115
|
-
return _SenderBuiltMicropayment.buildSignedMessage({
|
|
116
|
-
deployer: this.deployer,
|
|
117
|
-
sender: this.sender,
|
|
118
|
-
receiver: this.receiver,
|
|
119
|
-
fungibleAssetAddress: this.fungibleAssetAddress,
|
|
120
|
-
amount: this.amount,
|
|
121
|
-
paymentChannelId: this.paymentChannelId,
|
|
122
|
-
sequenceNumber: this.sequenceNumber
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Static helper to build the SignedMessage<WithdrawApproval> bytes from raw parameters.
|
|
127
|
-
* This can be used to create the message for signing without constructing the full object.
|
|
128
|
-
*
|
|
129
|
-
* @param params - The withdrawal approval parameters.
|
|
130
|
-
* @returns The BCS-serialized SignedMessage<WithdrawApproval> bytes.
|
|
131
|
-
*/
|
|
132
|
-
static buildSignedMessage(params) {
|
|
133
|
-
const serializer = new Serializer();
|
|
134
|
-
serializeTypeInfo(
|
|
135
|
-
serializer,
|
|
136
|
-
params.deployer,
|
|
137
|
-
MICROPAYMENTS_MODULE_NAME,
|
|
138
|
-
WITHDRAW_APPROVAL_STRUCT_NAME
|
|
139
|
-
);
|
|
140
|
-
params.sender.serialize(serializer);
|
|
141
|
-
params.receiver.serialize(serializer);
|
|
142
|
-
params.fungibleAssetAddress.serialize(serializer);
|
|
143
|
-
serializer.serializeU64(params.amount);
|
|
144
|
-
serializer.serializeU64(params.paymentChannelId);
|
|
145
|
-
serializer.serializeU64(params.sequenceNumber);
|
|
146
|
-
return serializer.toUint8Array();
|
|
147
|
-
}
|
|
148
|
-
serialize(serializer) {
|
|
149
|
-
this.sender.serialize(serializer);
|
|
150
|
-
this.receiver.serialize(serializer);
|
|
151
|
-
this.fungibleAssetAddress.serialize(serializer);
|
|
152
|
-
serializer.serializeU64(this.amount);
|
|
153
|
-
serializer.serializeU64(this.paymentChannelId);
|
|
154
|
-
serializer.serializeU64(this.sequenceNumber);
|
|
155
|
-
serializer.serializeBytes(this.publicKey);
|
|
156
|
-
serializer.serializeBytes(this.signature);
|
|
157
|
-
this.deployer.serialize(serializer);
|
|
158
|
-
}
|
|
159
|
-
bcsToBytes() {
|
|
160
|
-
const serializer = new Serializer();
|
|
161
|
-
this.serialize(serializer);
|
|
162
|
-
return serializer.toUint8Array();
|
|
163
|
-
}
|
|
164
|
-
bcsToHex() {
|
|
165
|
-
return Hex.fromHexInput(this.bcsToBytes());
|
|
166
|
-
}
|
|
167
|
-
toStringWithoutPrefix() {
|
|
168
|
-
return this.bcsToHex().toStringWithoutPrefix();
|
|
169
|
-
}
|
|
170
|
-
toString() {
|
|
171
|
-
return this.bcsToHex().toString();
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Deserializes a SenderBuiltMicropayment from BCS bytes.
|
|
175
|
-
* @param bytes - The bytes to deserialize from (Uint8Array or hex string).
|
|
176
|
-
* @returns A new SenderBuiltMicropayment instance.
|
|
177
|
-
*/
|
|
178
|
-
static deserialize(bytes) {
|
|
179
|
-
const bytesArray = typeof bytes === "string" ? Hex.fromHexInput(bytes).toUint8Array() : bytes;
|
|
180
|
-
const deserializer = new Deserializer(bytesArray);
|
|
181
|
-
const sender = AccountAddress.deserialize(deserializer);
|
|
182
|
-
const receiver = AccountAddress.deserialize(deserializer);
|
|
183
|
-
const fungibleAssetAddress = AccountAddress.deserialize(deserializer);
|
|
184
|
-
const amount = deserializer.deserializeU64();
|
|
185
|
-
const paymentChannelId = deserializer.deserializeU64();
|
|
186
|
-
const sequenceNumber = deserializer.deserializeU64();
|
|
187
|
-
const publicKey = deserializer.deserializeBytes();
|
|
188
|
-
const signature = deserializer.deserializeBytes();
|
|
189
|
-
const deployer = AccountAddress.deserialize(deserializer);
|
|
190
|
-
return new _SenderBuiltMicropayment(
|
|
191
|
-
sender,
|
|
192
|
-
receiver,
|
|
193
|
-
paymentChannelId,
|
|
194
|
-
amount,
|
|
195
|
-
fungibleAssetAddress,
|
|
196
|
-
sequenceNumber,
|
|
197
|
-
publicKey,
|
|
198
|
-
signature,
|
|
199
|
-
deployer
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export {
|
|
205
|
-
StaleChannelStateError,
|
|
206
|
-
SenderBuiltMicropayment
|
|
207
|
-
};
|
package/dist/chunk-M3CP5TFP.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// src/core/rpc-responses.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var ChallengeResponseSchema = z.object({
|
|
4
|
-
challenge: z.string(),
|
|
5
|
-
expiresAt: z.number()
|
|
6
|
-
});
|
|
7
|
-
var MultipartUploadStatusResponseSchema = z.object({
|
|
8
|
-
uploadId: z.string(),
|
|
9
|
-
completedParts: z.array(z.number()),
|
|
10
|
-
partSize: z.number(),
|
|
11
|
-
nParts: z.number(),
|
|
12
|
-
uploadedBytes: z.number()
|
|
13
|
-
});
|
|
14
|
-
var StartMultipartUploadResponseSchema = z.object({
|
|
15
|
-
uploadId: z.string()
|
|
16
|
-
});
|
|
17
|
-
var UploadPartResponseSchema = z.object({
|
|
18
|
-
success: z.literal(true)
|
|
19
|
-
});
|
|
20
|
-
var CompleteMultipartUploadResponseSchema = z.object({
|
|
21
|
-
success: z.literal(true)
|
|
22
|
-
});
|
|
23
|
-
var RPCErrorResponseSchema = z.object({
|
|
24
|
-
error: z.string()
|
|
25
|
-
});
|
|
26
|
-
var StaleMicropaymentErrorResponseSchema = z.object({
|
|
27
|
-
error: z.string().optional(),
|
|
28
|
-
storedMicropayment: z.string().optional()
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
ChallengeResponseSchema,
|
|
33
|
-
MultipartUploadStatusResponseSchema,
|
|
34
|
-
StartMultipartUploadResponseSchema,
|
|
35
|
-
UploadPartResponseSchema,
|
|
36
|
-
CompleteMultipartUploadResponseSchema,
|
|
37
|
-
RPCErrorResponseSchema,
|
|
38
|
-
StaleMicropaymentErrorResponseSchema
|
|
39
|
-
};
|