@shelby-protocol/sdk 0.2.0 → 0.2.2
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 +1 -1
- package/dist/browser/index.mjs +31 -29
- package/dist/chunk-3NRBHSMQ.mjs +12 -0
- package/dist/{chunk-W37FZSMA.mjs → chunk-57RQAVKL.mjs} +1 -1
- package/dist/{chunk-4ZOFT75Q.mjs → chunk-7OV5ZYW6.mjs} +2 -2
- package/dist/{chunk-2WEX3K7C.mjs → chunk-BXEVML7N.mjs} +1 -1
- package/dist/{chunk-PJVWGMVI.mjs → chunk-E5PP7BZJ.mjs} +9 -9
- package/dist/{chunk-CGYJLKBU.mjs → chunk-EZPZAUIV.mjs} +1 -1
- package/dist/{chunk-ZEDD2MPU.mjs → chunk-FMPOGFDW.mjs} +1 -1
- package/dist/{chunk-MV6FNYAU.mjs → chunk-H53O23I7.mjs} +99 -20
- package/dist/{chunk-E5QCRTBU.mjs → chunk-H5YZHUSJ.mjs} +87 -75
- package/dist/{chunk-7PN65RDX.mjs → chunk-ONOOCOQ5.mjs} +16 -14
- package/dist/{chunk-SRV4YWFH.mjs → chunk-PESSW3FK.mjs} +52 -17
- package/dist/chunk-TVLV7C74.mjs +207 -0
- package/dist/{chunk-4JZO2D7T.mjs → chunk-UEZNZBJO.mjs} +9 -2
- package/dist/core/blobs.mjs +2 -1
- package/dist/core/clients/ShelbyBlobClient.d.ts +16 -0
- package/dist/core/clients/ShelbyBlobClient.mjs +8 -8
- package/dist/core/clients/ShelbyClient.mjs +13 -13
- package/dist/core/clients/ShelbyMetadataClient.d.ts +56 -5
- package/dist/core/clients/ShelbyMetadataClient.mjs +3 -2
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +39 -34
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +5 -4
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +3 -3
- package/dist/core/clients/ShelbyRPCClient.mjs +6 -6
- package/dist/core/clients/index.mjs +17 -17
- package/dist/core/commitments.mjs +2 -2
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.mjs +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +31 -29
- package/dist/core/operations/generated/types.d.ts +908 -0
- package/dist/core/operations/generated/types.mjs +63 -0
- package/dist/core/operations/index.mjs +2 -2
- package/dist/core/types/index.mjs +2 -1
- package/dist/core/types/payments.d.ts +82 -9
- package/dist/core/types/payments.mjs +2 -1
- package/dist/core/types/placement_groups.d.ts +2 -2
- package/dist/core/types/storage_providers.d.ts +2 -2
- package/dist/core/utils.d.ts +3 -2
- package/dist/core/utils.mjs +3 -1
- package/dist/node/clients/ShelbyNodeClient.mjs +14 -14
- package/dist/node/clients/index.mjs +16 -16
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.mjs +32 -30
- package/package.json +1 -1
- package/dist/chunk-4MG4XGY4.mjs +0 -91
- package/dist/chunk-OTBLZL2S.mjs +0 -9
package/dist/browser/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { BlobActivity, BlobActivityType, BlobEncoding, BlobMetadata, ClayEncodin
|
|
|
23
23
|
export { ChannelInfo, SenderBuiltMicropayment, StaleChannelStateError } from '../core/types/payments.js';
|
|
24
24
|
export { PlacementGroupInfo, PlacementGroupSlot, PlacementGroupSlotStatus } from '../core/types/placement_groups.js';
|
|
25
25
|
export { ActiveStateDetails, FrozenStateDetails, StorageProviderInfo, StorageProviderStateDetails, WaitlistedStateDetails } from '../core/types/storage_providers.js';
|
|
26
|
-
export { buildRequestUrl, concatHashes, getBlobNameSuffix, readInChunks, zeroPadBytes } from '../core/utils.js';
|
|
26
|
+
export { buildRequestUrl, concatHashes, getBlobNameSuffix, normalizeAddress, readInChunks, zeroPadBytes } from '../core/utils.js';
|
|
27
27
|
export { Bigint_Comparison_Exp, Blob_Activities, Blob_Activities_Aggregate, Blob_Activities_Aggregate_Fields, Blob_Activities_Aggregate_FieldsCountArgs, Blob_Activities_Avg_Fields, Blob_Activities_Bool_Exp, Blob_Activities_Max_Fields, Blob_Activities_Min_Fields, Blob_Activities_Order_By, Blob_Activities_Select_Column, Blob_Activities_Stddev_Fields, Blob_Activities_Stddev_Pop_Fields, Blob_Activities_Stddev_Samp_Fields, Blob_Activities_Stream_Cursor_Input, Blob_Activities_Stream_Cursor_Value_Input, Blob_Activities_Sum_Fields, Blob_Activities_Var_Pop_Fields, Blob_Activities_Var_Samp_Fields, Blob_Activities_Variance_Fields, Blobs, BlobsPlacement_Group_SlotsArgs, BlobsPlacement_Group_Slots_AggregateArgs, Blobs_Aggregate, Blobs_Aggregate_Fields, Blobs_Aggregate_FieldsCountArgs, Blobs_Avg_Fields, Blobs_Bool_Exp, Blobs_Max_Fields, Blobs_Min_Fields, Blobs_Order_By, Blobs_Select_Column, Blobs_Stddev_Fields, Blobs_Stddev_Pop_Fields, Blobs_Stddev_Samp_Fields, Blobs_Stream_Cursor_Input, Blobs_Stream_Cursor_Value_Input, Blobs_Sum_Fields, Blobs_Var_Pop_Fields, Blobs_Var_Samp_Fields, Blobs_Variance_Fields, Cursor_Ordering, Exact, GetBlobActivitiesCountDocument, GetBlobActivitiesCountQuery, GetBlobActivitiesCountQueryVariables, GetBlobActivitiesDocument, GetBlobActivitiesQuery, GetBlobActivitiesQueryVariables, GetBlobsCountDocument, GetBlobsCountQuery, GetBlobsCountQueryVariables, GetBlobsDocument, GetBlobsQuery, GetBlobsQueryVariables, GetPlacementGroupSlotsCountDocument, GetPlacementGroupSlotsCountQuery, GetPlacementGroupSlotsCountQueryVariables, GetPlacementGroupSlotsDocument, GetPlacementGroupSlotsQuery, GetPlacementGroupSlotsQueryVariables, GetProcessorStatusDocument, GetProcessorStatusQuery, GetProcessorStatusQueryVariables, Incremental, InputMaybe, Int_Comparison_Exp, MakeEmpty, MakeMaybe, MakeOptional, Maybe, Numeric_Comparison_Exp, Order_By, Placement_Group_Slots, Placement_Group_Slots_Aggregate, Placement_Group_Slots_Aggregate_Bool_Exp, Placement_Group_Slots_Aggregate_Bool_Exp_Count, Placement_Group_Slots_Aggregate_Fields, Placement_Group_Slots_Aggregate_FieldsCountArgs, Placement_Group_Slots_Aggregate_Order_By, Placement_Group_Slots_Avg_Fields, Placement_Group_Slots_Avg_Order_By, Placement_Group_Slots_Bool_Exp, Placement_Group_Slots_Max_Fields, Placement_Group_Slots_Max_Order_By, Placement_Group_Slots_Min_Fields, Placement_Group_Slots_Min_Order_By, Placement_Group_Slots_Order_By, Placement_Group_Slots_Select_Column, Placement_Group_Slots_Stddev_Fields, Placement_Group_Slots_Stddev_Order_By, Placement_Group_Slots_Stddev_Pop_Fields, Placement_Group_Slots_Stddev_Pop_Order_By, Placement_Group_Slots_Stddev_Samp_Fields, Placement_Group_Slots_Stddev_Samp_Order_By, Placement_Group_Slots_Stream_Cursor_Input, Placement_Group_Slots_Stream_Cursor_Value_Input, Placement_Group_Slots_Sum_Fields, Placement_Group_Slots_Sum_Order_By, Placement_Group_Slots_Var_Pop_Fields, Placement_Group_Slots_Var_Pop_Order_By, Placement_Group_Slots_Var_Samp_Fields, Placement_Group_Slots_Var_Samp_Order_By, Placement_Group_Slots_Variance_Fields, Placement_Group_Slots_Variance_Order_By, Processor_Status, Processor_Status_Bool_Exp, Processor_Status_Order_By, Processor_Status_Select_Column, Processor_Status_Stream_Cursor_Input, Processor_Status_Stream_Cursor_Value_Input, Query_Root, Query_RootBlob_ActivitiesArgs, Query_RootBlob_Activities_AggregateArgs, Query_RootBlob_Activities_By_PkArgs, Query_RootBlobsArgs, Query_RootBlobs_AggregateArgs, Query_RootBlobs_By_PkArgs, Query_RootPlacement_Group_SlotsArgs, Query_RootPlacement_Group_Slots_AggregateArgs, Query_RootPlacement_Group_Slots_By_PkArgs, Query_RootProcessor_StatusArgs, Scalars, Sdk, SdkFunctionWrapper, String_Comparison_Exp, Subscription_Root, Subscription_RootBlob_ActivitiesArgs, Subscription_RootBlob_Activities_AggregateArgs, Subscription_RootBlob_Activities_By_PkArgs, Subscription_RootBlob_Activities_StreamArgs, Subscription_RootBlobsArgs, Subscription_RootBlobs_AggregateArgs, Subscription_RootBlobs_By_PkArgs, Subscription_RootBlobs_StreamArgs, Subscription_RootPlacement_Group_SlotsArgs, Subscription_RootPlacement_Group_Slots_AggregateArgs, Subscription_RootPlacement_Group_Slots_By_PkArgs, Subscription_RootPlacement_Group_Slots_StreamArgs, Subscription_RootProcessor_StatusArgs, Subscription_RootProcessor_Status_StreamArgs, Timestamp_Comparison_Exp, getSdk } from '../core/operations/generated/sdk.js';
|
|
28
28
|
import '@aptos-labs/ts-sdk';
|
|
29
29
|
import 'zod';
|
package/dist/browser/index.mjs
CHANGED
|
@@ -2,49 +2,36 @@ import "../chunk-EM67QTMR.mjs";
|
|
|
2
2
|
import "../chunk-WTICJPDB.mjs";
|
|
3
3
|
import {
|
|
4
4
|
ShelbyClient
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-ONOOCOQ5.mjs";
|
|
6
6
|
import {
|
|
7
7
|
MissingTransactionSubmitterError,
|
|
8
8
|
ShelbyBlobClient
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-XNEIWM4O.mjs";
|
|
11
|
-
import {
|
|
12
|
-
createDefaultErasureCodingProvider,
|
|
13
|
-
defaultErasureCodingConfig,
|
|
14
|
-
erasureCodingConfig16Total10Data13Helper,
|
|
15
|
-
erasureCodingConfig4Total2Data3Helper
|
|
16
|
-
} from "../chunk-HPPMI7DC.mjs";
|
|
17
|
-
import {
|
|
18
|
-
ClayErasureCodingProvider
|
|
19
|
-
} from "../chunk-OGKZ575S.mjs";
|
|
20
|
-
import {
|
|
21
|
-
ReedSolomonErasureCodingProvider
|
|
22
|
-
} from "../chunk-NHWWORCH.mjs";
|
|
9
|
+
} from "../chunk-PESSW3FK.mjs";
|
|
23
10
|
import "../chunk-Z7RFCADT.mjs";
|
|
24
11
|
import {
|
|
25
12
|
ShelbyMetadataClient
|
|
26
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-H53O23I7.mjs";
|
|
27
14
|
import {
|
|
28
15
|
ShelbyMicropaymentChannelClient
|
|
29
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-H5YZHUSJ.mjs";
|
|
30
17
|
import "../chunk-QQ57OGQ2.mjs";
|
|
31
18
|
import "../chunk-ZHXCVRZX.mjs";
|
|
32
19
|
import "../chunk-AD2G3QYD.mjs";
|
|
33
20
|
import "../chunk-MQUVYMNQ.mjs";
|
|
34
21
|
import {
|
|
35
22
|
ShelbyPlacementGroupClient
|
|
36
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-57RQAVKL.mjs";
|
|
37
24
|
import {
|
|
38
25
|
ShelbyRPCClient
|
|
39
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-E5PP7BZJ.mjs";
|
|
40
27
|
import {
|
|
41
28
|
SenderBuiltMicropayment,
|
|
42
29
|
StaleChannelStateError
|
|
43
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-TVLV7C74.mjs";
|
|
44
31
|
import {
|
|
45
32
|
createShelbyIndexerClient,
|
|
46
33
|
getShelbyIndexerClient
|
|
47
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-EZPZAUIV.mjs";
|
|
48
35
|
import {
|
|
49
36
|
Blob_Activities_Select_Column,
|
|
50
37
|
Blobs_Select_Column,
|
|
@@ -62,6 +49,23 @@ import {
|
|
|
62
49
|
getSdk
|
|
63
50
|
} from "../chunk-KJ24NKPH.mjs";
|
|
64
51
|
import "../chunk-AABBONAF.mjs";
|
|
52
|
+
import "../chunk-XNEIWM4O.mjs";
|
|
53
|
+
import {
|
|
54
|
+
createDefaultErasureCodingProvider,
|
|
55
|
+
defaultErasureCodingConfig,
|
|
56
|
+
erasureCodingConfig16Total10Data13Helper,
|
|
57
|
+
erasureCodingConfig4Total2Data3Helper
|
|
58
|
+
} from "../chunk-HPPMI7DC.mjs";
|
|
59
|
+
import {
|
|
60
|
+
ClayErasureCodingProvider
|
|
61
|
+
} from "../chunk-OGKZ575S.mjs";
|
|
62
|
+
import {
|
|
63
|
+
ReedSolomonErasureCodingProvider
|
|
64
|
+
} from "../chunk-NHWWORCH.mjs";
|
|
65
|
+
import {
|
|
66
|
+
BlobNameSchema,
|
|
67
|
+
ChunkKey
|
|
68
|
+
} from "../chunk-Z4FZ7W6L.mjs";
|
|
65
69
|
import {
|
|
66
70
|
isShelbyNetwork,
|
|
67
71
|
shelbyNetworks
|
|
@@ -85,7 +89,7 @@ import {
|
|
|
85
89
|
} from "../chunk-C6RQ3AEU.mjs";
|
|
86
90
|
import {
|
|
87
91
|
createBlobKey
|
|
88
|
-
} from "../chunk-
|
|
92
|
+
} from "../chunk-3NRBHSMQ.mjs";
|
|
89
93
|
import {
|
|
90
94
|
BlobCommitmentsSchema,
|
|
91
95
|
COMMITMENT_SCHEMA_VERSION,
|
|
@@ -93,14 +97,15 @@ import {
|
|
|
93
97
|
expectedTotalChunksets,
|
|
94
98
|
generateCommitments,
|
|
95
99
|
generateMerkleRoot
|
|
96
|
-
} from "../chunk-
|
|
100
|
+
} from "../chunk-BXEVML7N.mjs";
|
|
97
101
|
import {
|
|
98
102
|
buildRequestUrl,
|
|
99
103
|
concatHashes,
|
|
100
104
|
getBlobNameSuffix,
|
|
105
|
+
normalizeAddress,
|
|
101
106
|
readInChunks,
|
|
102
107
|
zeroPadBytes
|
|
103
|
-
} from "../chunk-
|
|
108
|
+
} from "../chunk-UEZNZBJO.mjs";
|
|
104
109
|
import {
|
|
105
110
|
CHUNK_SIZE_PARAMS,
|
|
106
111
|
ChunkSizeScheme,
|
|
@@ -131,7 +136,7 @@ import {
|
|
|
131
136
|
SHELBY_DEPLOYER,
|
|
132
137
|
TOKEN_DEPLOYER,
|
|
133
138
|
TOKEN_OBJECT_ADDRESS
|
|
134
|
-
} from "../chunk-
|
|
139
|
+
} from "../chunk-7OV5ZYW6.mjs";
|
|
135
140
|
import {
|
|
136
141
|
ShelbyErrorCodes,
|
|
137
142
|
isAccessDeniedError,
|
|
@@ -139,10 +144,6 @@ import {
|
|
|
139
144
|
isBlobExpiredError,
|
|
140
145
|
isBlobNotFoundError
|
|
141
146
|
} from "../chunk-CQ6QPIZK.mjs";
|
|
142
|
-
import {
|
|
143
|
-
BlobNameSchema,
|
|
144
|
-
ChunkKey
|
|
145
|
-
} from "../chunk-Z4FZ7W6L.mjs";
|
|
146
147
|
import "../chunk-7P6ASYW6.mjs";
|
|
147
148
|
export {
|
|
148
149
|
BlobCommitmentsSchema,
|
|
@@ -229,6 +230,7 @@ export {
|
|
|
229
230
|
isBlobExpiredError,
|
|
230
231
|
isBlobNotFoundError,
|
|
231
232
|
isShelbyNetwork,
|
|
233
|
+
normalizeAddress,
|
|
232
234
|
readInChunks,
|
|
233
235
|
shelbyNetworks,
|
|
234
236
|
zeroPadBytes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeAddress
|
|
3
|
+
} from "./chunk-UEZNZBJO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/core/blobs.ts
|
|
6
|
+
var createBlobKey = (params) => {
|
|
7
|
+
return `@${normalizeAddress(params.account).toStringLongWithoutPrefix()}/${params.blobName}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
createBlobKey
|
|
12
|
+
};
|
|
@@ -29,8 +29,8 @@ var NetworkToGasStationBaseUrl = {
|
|
|
29
29
|
[Network.LOCAL]: void 0,
|
|
30
30
|
[Network.CUSTOM]: void 0
|
|
31
31
|
};
|
|
32
|
-
var SHELBY_DEPLOYER = "
|
|
33
|
-
var MICROPAYMENTS_DEPLOYER = "
|
|
32
|
+
var SHELBY_DEPLOYER = "0x85fdb9a176ab8ef1d9d9c1b60d60b3924f0800ac1de1cc2085fb0b8bb4988e6a";
|
|
33
|
+
var MICROPAYMENTS_DEPLOYER = "0x1ae7275148bf6ef742b658fd9cbcc2e094201606f4a7bc707bab0201da8043ee";
|
|
34
34
|
var TOKEN_DEPLOYER = "0x33009e852be7f93762dd0bf303383c2cb2c5cab7a30d8238ca5f9f177ae75124";
|
|
35
35
|
var TOKEN_OBJECT_ADDRESS = "0x249f5c642a63885ff88a5113b3ba0079840af5a1357706f8c7f3bfc5dd12511f";
|
|
36
36
|
var SHELBYUSD_TOKEN_ADDRESS = TOKEN_OBJECT_ADDRESS;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StaleChannelStateError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TVLV7C74.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getShelbyIndexerClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EZPZAUIV.mjs";
|
|
7
|
+
import {
|
|
8
|
+
BlobNameSchema
|
|
9
|
+
} from "./chunk-Z4FZ7W6L.mjs";
|
|
7
10
|
import {
|
|
8
11
|
sleep
|
|
9
12
|
} from "./chunk-I6NG5GNL.mjs";
|
|
@@ -13,17 +16,14 @@ import {
|
|
|
13
16
|
} from "./chunk-IE6LYVIA.mjs";
|
|
14
17
|
import {
|
|
15
18
|
buildRequestUrl,
|
|
19
|
+
normalizeAddress,
|
|
16
20
|
readInChunks
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UEZNZBJO.mjs";
|
|
18
22
|
import {
|
|
19
23
|
NetworkToShelbyRPCBaseUrl
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import {
|
|
22
|
-
BlobNameSchema
|
|
23
|
-
} from "./chunk-Z4FZ7W6L.mjs";
|
|
24
|
+
} from "./chunk-7OV5ZYW6.mjs";
|
|
24
25
|
|
|
25
26
|
// src/core/clients/ShelbyRPCClient.ts
|
|
26
|
-
import { AccountAddress } from "@aptos-labs/ts-sdk";
|
|
27
27
|
var MICROPAYMENT_HEADER = "X-Shelby-Micropayment";
|
|
28
28
|
function encodeURIComponentKeepSlashes(str) {
|
|
29
29
|
return encodeURIComponent(str).replace(/%2F/g, "/");
|
|
@@ -399,7 +399,7 @@ var ShelbyRPCClient = class {
|
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
401
|
return {
|
|
402
|
-
account:
|
|
402
|
+
account: normalizeAddress(params.account),
|
|
403
403
|
name: params.blobName,
|
|
404
404
|
readable: validatingStream,
|
|
405
405
|
contentLength: expectedContentLength
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAptosConfig
|
|
3
3
|
} from "./chunk-AABBONAF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
normalizeAddress
|
|
6
|
+
} from "./chunk-UEZNZBJO.mjs";
|
|
4
7
|
import {
|
|
5
8
|
SHELBY_DEPLOYER
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7OV5ZYW6.mjs";
|
|
7
10
|
|
|
8
11
|
// src/core/clients/ShelbyMetadataClient.ts
|
|
9
12
|
import {
|
|
@@ -74,11 +77,11 @@ var ShelbyMetadataClient = class {
|
|
|
74
77
|
});
|
|
75
78
|
const metadata = rawMetadata[0];
|
|
76
79
|
return metadata.map((provider) => ({
|
|
77
|
-
address:
|
|
80
|
+
address: normalizeAddress(provider.address),
|
|
78
81
|
ipAddress: provider.ip_address,
|
|
79
82
|
port: provider.port,
|
|
80
83
|
blsPublicKey: Hex.fromHexInput(provider.bls_public_key).toUint8Array(),
|
|
81
|
-
|
|
84
|
+
availabilityZone: provider.availability_zone,
|
|
82
85
|
state: parseStorageProviderState(provider.state)
|
|
83
86
|
}));
|
|
84
87
|
} catch (error) {
|
|
@@ -115,7 +118,7 @@ var ShelbyMetadataClient = class {
|
|
|
115
118
|
}
|
|
116
119
|
});
|
|
117
120
|
const metadata = addressMetadataArray[0];
|
|
118
|
-
return metadata.map((pg) =>
|
|
121
|
+
return metadata.map((pg) => normalizeAddress(pg));
|
|
119
122
|
} catch (error) {
|
|
120
123
|
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
121
124
|
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_PLACEMENT_GROUP_NOT_FOUND"))) {
|
|
@@ -150,7 +153,7 @@ var ShelbyMetadataClient = class {
|
|
|
150
153
|
}
|
|
151
154
|
});
|
|
152
155
|
const metadata = addressMetadataArray[0];
|
|
153
|
-
return metadata.map((slice) =>
|
|
156
|
+
return metadata.map((slice) => normalizeAddress(slice));
|
|
154
157
|
} catch (error) {
|
|
155
158
|
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
156
159
|
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_SLICE_NOT_FOUND"))) {
|
|
@@ -160,37 +163,113 @@ var ShelbyMetadataClient = class {
|
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
/**
|
|
163
|
-
*
|
|
166
|
+
* Gets the placement group address for a slice.
|
|
167
|
+
*
|
|
168
|
+
* @param sliceAddress - The address of the slice account.
|
|
169
|
+
* @returns The placement group address as a string.
|
|
170
|
+
*/
|
|
171
|
+
async getPlacementGroupAddressForSlice(sliceAddress) {
|
|
172
|
+
const sliceMetadata = await this.aptos.view({
|
|
173
|
+
payload: {
|
|
174
|
+
function: `${this.deployer.toString()}::slice::get_slice_info`,
|
|
175
|
+
functionArguments: [sliceAddress.toString()]
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return sliceMetadata[0].placement_group_assignments[0].placement_group_address;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves the designated storage providers for a slice.
|
|
182
|
+
*
|
|
183
|
+
* Designated SPs are those appointed to store data for their slots:
|
|
184
|
+
* - Active: Currently serving data
|
|
185
|
+
* - Receiving: Receiving data during slot transfer
|
|
186
|
+
* - Repairing: Repairing data after crash or failed transfer
|
|
187
|
+
* - Reconstructing: Reconstructing data if the repair fails
|
|
164
188
|
*
|
|
165
189
|
* @param params.account - The address of the slice account.
|
|
166
|
-
* @returns
|
|
190
|
+
* @returns An array where result[i] is the designated SP for slot i, or null if no SP is designated.
|
|
167
191
|
*
|
|
168
192
|
* @example
|
|
169
193
|
* ```typescript
|
|
170
|
-
* const
|
|
194
|
+
* const providers = await client.getDesignatedStorageProvidersForSlice({ account: sliceAddress });
|
|
171
195
|
* ```
|
|
172
196
|
*/
|
|
173
|
-
async
|
|
174
|
-
const
|
|
197
|
+
async getDesignatedStorageProvidersForSlice(params) {
|
|
198
|
+
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
199
|
+
params.account
|
|
200
|
+
);
|
|
201
|
+
const rawMetadata = await this.aptos.view({
|
|
175
202
|
payload: {
|
|
176
|
-
function: `${this.deployer.toString()}::
|
|
177
|
-
functionArguments: [
|
|
203
|
+
function: `${this.deployer.toString()}::placement_group::get_designated_storage_providers`,
|
|
204
|
+
functionArguments: [placementGroupAddress]
|
|
178
205
|
}
|
|
179
206
|
});
|
|
180
|
-
const
|
|
207
|
+
const providers = rawMetadata[0];
|
|
208
|
+
return providers.map(
|
|
209
|
+
(opt) => opt.vec.length > 0 ? normalizeAddress(opt.vec[0]) : null
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Retrieves the active storage providers for a slice.
|
|
214
|
+
*
|
|
215
|
+
* Active SPs have a complete copy of the data for the slot, and are not in any data transfer/repair/reconstruction phase.
|
|
216
|
+
* Active SP can be audited for the data it contains.
|
|
217
|
+
* Each slot has at most one active SP.
|
|
218
|
+
*
|
|
219
|
+
* @param params.account - The address of the slice account.
|
|
220
|
+
* @returns An array where result[i] is the active SP for slot i, or null if no SP is active.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const providers = await client.getActiveStorageProvidersForSlice({ account: sliceAddress });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
async getActiveStorageProvidersForSlice(params) {
|
|
228
|
+
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
229
|
+
params.account
|
|
230
|
+
);
|
|
181
231
|
const rawMetadata = await this.aptos.view({
|
|
182
232
|
payload: {
|
|
183
|
-
function: `${this.deployer.toString()}::placement_group::
|
|
233
|
+
function: `${this.deployer.toString()}::placement_group::get_active_storage_providers`,
|
|
184
234
|
functionArguments: [placementGroupAddress]
|
|
185
235
|
}
|
|
186
236
|
});
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
237
|
+
const providers = rawMetadata[0];
|
|
238
|
+
return providers.map(
|
|
239
|
+
(opt) => opt.vec.length > 0 ? normalizeAddress(opt.vec[0]) : null
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Retrieves the serving storage providers for a slice.
|
|
244
|
+
*
|
|
245
|
+
* Serving SPs are those that can respond to read requests. The serving logic is:
|
|
246
|
+
* - If an Active SP exists for a slot: Only the Active SP is serving
|
|
247
|
+
* - If no Active SP (transition in progress): Both Designated and Vacating SPs serve
|
|
248
|
+
*
|
|
249
|
+
* Each slot may have multiple serving SPs during transitions.
|
|
250
|
+
*
|
|
251
|
+
* @param params.account - The address of the slice account.
|
|
252
|
+
* @returns An array where result[i] contains the serving SPs for slot i.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const providers = await client.getServingStorageProvidersForSlice({ account: sliceAddress });
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
async getServingStorageProvidersForSlice(params) {
|
|
260
|
+
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
261
|
+
params.account
|
|
262
|
+
);
|
|
263
|
+
const rawMetadata = await this.aptos.view({
|
|
264
|
+
payload: {
|
|
265
|
+
function: `${this.deployer.toString()}::placement_group::get_serving_storage_providers`,
|
|
266
|
+
functionArguments: [placementGroupAddress]
|
|
267
|
+
}
|
|
192
268
|
});
|
|
193
|
-
|
|
269
|
+
const providers = rawMetadata[0];
|
|
270
|
+
return providers.map(
|
|
271
|
+
(slotProviders) => slotProviders.map((addr) => normalizeAddress(addr))
|
|
272
|
+
);
|
|
194
273
|
}
|
|
195
274
|
};
|
|
196
275
|
|