@shelby-protocol/sdk 0.2.0 → 0.2.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 +1 -1
- package/dist/browser/index.mjs +31 -29
- package/dist/{chunk-ZEDD2MPU.mjs → chunk-33BZ7KYA.mjs} +1 -1
- package/dist/chunk-3NRBHSMQ.mjs +12 -0
- package/dist/{chunk-7PN65RDX.mjs → chunk-5CES6RPZ.mjs} +11 -9
- package/dist/{chunk-MV6FNYAU.mjs → chunk-7O77OM4T.mjs} +98 -19
- package/dist/{chunk-2WEX3K7C.mjs → chunk-BXEVML7N.mjs} +1 -1
- package/dist/{chunk-PJVWGMVI.mjs → chunk-EFR6H3RT.mjs} +7 -7
- package/dist/{chunk-SRV4YWFH.mjs → chunk-IBAUPQOF.mjs} +11 -12
- package/dist/chunk-KTVNKLBT.mjs +207 -0
- package/dist/{chunk-E5QCRTBU.mjs → chunk-OQNP5QXH.mjs} +85 -73
- package/dist/{chunk-4JZO2D7T.mjs → chunk-UEZNZBJO.mjs} +9 -2
- package/dist/core/blobs.mjs +2 -1
- package/dist/core/clients/ShelbyBlobClient.mjs +5 -5
- package/dist/core/clients/ShelbyClient.d.ts +1 -1
- package/dist/core/clients/ShelbyClient.mjs +10 -10
- package/dist/core/clients/ShelbyMetadataClient.d.ts +56 -5
- package/dist/core/clients/ShelbyMetadataClient.mjs +2 -1
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +39 -34
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +4 -3
- package/dist/core/clients/ShelbyRPCClient.mjs +4 -4
- package/dist/core/clients/index.mjs +17 -17
- package/dist/core/commitments.mjs +2 -2
- package/dist/core/erasure/index.mjs +3 -3
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +31 -29
- package/dist/core/types/index.mjs +3 -2
- 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 +11 -11
- package/dist/node/clients/index.mjs +11 -11
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.mjs +35 -33
- 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
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import "../chunk-EM67QTMR.mjs";
|
|
2
2
|
import "../chunk-WTICJPDB.mjs";
|
|
3
|
+
import {
|
|
4
|
+
ShelbyPlacementGroupClient
|
|
5
|
+
} from "../chunk-W37FZSMA.mjs";
|
|
3
6
|
import {
|
|
4
7
|
ShelbyClient
|
|
5
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-5CES6RPZ.mjs";
|
|
9
|
+
import {
|
|
10
|
+
ShelbyRPCClient
|
|
11
|
+
} from "../chunk-EFR6H3RT.mjs";
|
|
6
12
|
import {
|
|
7
13
|
MissingTransactionSubmitterError,
|
|
8
14
|
ShelbyBlobClient
|
|
9
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-IBAUPQOF.mjs";
|
|
10
16
|
import "../chunk-XNEIWM4O.mjs";
|
|
17
|
+
import {
|
|
18
|
+
ReedSolomonErasureCodingProvider
|
|
19
|
+
} from "../chunk-NHWWORCH.mjs";
|
|
11
20
|
import {
|
|
12
21
|
createDefaultErasureCodingProvider,
|
|
13
22
|
defaultErasureCodingConfig,
|
|
@@ -17,30 +26,21 @@ import {
|
|
|
17
26
|
import {
|
|
18
27
|
ClayErasureCodingProvider
|
|
19
28
|
} from "../chunk-OGKZ575S.mjs";
|
|
20
|
-
import {
|
|
21
|
-
ReedSolomonErasureCodingProvider
|
|
22
|
-
} from "../chunk-NHWWORCH.mjs";
|
|
23
29
|
import "../chunk-Z7RFCADT.mjs";
|
|
24
30
|
import {
|
|
25
31
|
ShelbyMetadataClient
|
|
26
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-7O77OM4T.mjs";
|
|
27
33
|
import {
|
|
28
34
|
ShelbyMicropaymentChannelClient
|
|
29
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-OQNP5QXH.mjs";
|
|
30
36
|
import "../chunk-QQ57OGQ2.mjs";
|
|
37
|
+
import "../chunk-MQUVYMNQ.mjs";
|
|
31
38
|
import "../chunk-ZHXCVRZX.mjs";
|
|
32
39
|
import "../chunk-AD2G3QYD.mjs";
|
|
33
|
-
import "../chunk-MQUVYMNQ.mjs";
|
|
34
|
-
import {
|
|
35
|
-
ShelbyPlacementGroupClient
|
|
36
|
-
} from "../chunk-W37FZSMA.mjs";
|
|
37
|
-
import {
|
|
38
|
-
ShelbyRPCClient
|
|
39
|
-
} from "../chunk-PJVWGMVI.mjs";
|
|
40
40
|
import {
|
|
41
41
|
SenderBuiltMicropayment,
|
|
42
42
|
StaleChannelStateError
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-KTVNKLBT.mjs";
|
|
44
44
|
import {
|
|
45
45
|
createShelbyIndexerClient,
|
|
46
46
|
getShelbyIndexerClient
|
|
@@ -62,6 +62,17 @@ import {
|
|
|
62
62
|
getSdk
|
|
63
63
|
} from "../chunk-KJ24NKPH.mjs";
|
|
64
64
|
import "../chunk-AABBONAF.mjs";
|
|
65
|
+
import {
|
|
66
|
+
ShelbyErrorCodes,
|
|
67
|
+
isAccessDeniedError,
|
|
68
|
+
isBlobAlreadyExistsError,
|
|
69
|
+
isBlobExpiredError,
|
|
70
|
+
isBlobNotFoundError
|
|
71
|
+
} from "../chunk-CQ6QPIZK.mjs";
|
|
72
|
+
import {
|
|
73
|
+
BlobNameSchema,
|
|
74
|
+
ChunkKey
|
|
75
|
+
} from "../chunk-Z4FZ7W6L.mjs";
|
|
65
76
|
import {
|
|
66
77
|
isShelbyNetwork,
|
|
67
78
|
shelbyNetworks
|
|
@@ -85,7 +96,7 @@ import {
|
|
|
85
96
|
} from "../chunk-C6RQ3AEU.mjs";
|
|
86
97
|
import {
|
|
87
98
|
createBlobKey
|
|
88
|
-
} from "../chunk-
|
|
99
|
+
} from "../chunk-3NRBHSMQ.mjs";
|
|
89
100
|
import {
|
|
90
101
|
BlobCommitmentsSchema,
|
|
91
102
|
COMMITMENT_SCHEMA_VERSION,
|
|
@@ -93,14 +104,15 @@ import {
|
|
|
93
104
|
expectedTotalChunksets,
|
|
94
105
|
generateCommitments,
|
|
95
106
|
generateMerkleRoot
|
|
96
|
-
} from "../chunk-
|
|
107
|
+
} from "../chunk-BXEVML7N.mjs";
|
|
97
108
|
import {
|
|
98
109
|
buildRequestUrl,
|
|
99
110
|
concatHashes,
|
|
100
111
|
getBlobNameSuffix,
|
|
112
|
+
normalizeAddress,
|
|
101
113
|
readInChunks,
|
|
102
114
|
zeroPadBytes
|
|
103
|
-
} from "../chunk-
|
|
115
|
+
} from "../chunk-UEZNZBJO.mjs";
|
|
104
116
|
import {
|
|
105
117
|
CHUNK_SIZE_PARAMS,
|
|
106
118
|
ChunkSizeScheme,
|
|
@@ -132,17 +144,6 @@ import {
|
|
|
132
144
|
TOKEN_DEPLOYER,
|
|
133
145
|
TOKEN_OBJECT_ADDRESS
|
|
134
146
|
} from "../chunk-4ZOFT75Q.mjs";
|
|
135
|
-
import {
|
|
136
|
-
ShelbyErrorCodes,
|
|
137
|
-
isAccessDeniedError,
|
|
138
|
-
isBlobAlreadyExistsError,
|
|
139
|
-
isBlobExpiredError,
|
|
140
|
-
isBlobNotFoundError
|
|
141
|
-
} 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
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShelbyRPCClient
|
|
3
|
+
} from "./chunk-EFR6H3RT.mjs";
|
|
1
4
|
import {
|
|
2
5
|
ShelbyBlobClient
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IBAUPQOF.mjs";
|
|
4
7
|
import {
|
|
5
8
|
defaultErasureCodingConfig
|
|
6
9
|
} from "./chunk-HPPMI7DC.mjs";
|
|
@@ -9,26 +12,25 @@ import {
|
|
|
9
12
|
} from "./chunk-OGKZ575S.mjs";
|
|
10
13
|
import {
|
|
11
14
|
ShelbyMetadataClient
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
ShelbyRPCClient
|
|
15
|
-
} from "./chunk-PJVWGMVI.mjs";
|
|
15
|
+
} from "./chunk-7O77OM4T.mjs";
|
|
16
16
|
import {
|
|
17
17
|
getAptosConfig
|
|
18
18
|
} from "./chunk-AABBONAF.mjs";
|
|
19
19
|
import {
|
|
20
20
|
createBlobKey
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3NRBHSMQ.mjs";
|
|
22
22
|
import {
|
|
23
23
|
generateCommitments
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-BXEVML7N.mjs";
|
|
25
|
+
import {
|
|
26
|
+
normalizeAddress
|
|
27
|
+
} from "./chunk-UEZNZBJO.mjs";
|
|
25
28
|
import {
|
|
26
29
|
NetworkToShelbyRPCBaseUrl
|
|
27
30
|
} from "./chunk-4ZOFT75Q.mjs";
|
|
28
31
|
|
|
29
32
|
// src/core/clients/ShelbyClient.ts
|
|
30
33
|
import {
|
|
31
|
-
AccountAddress,
|
|
32
34
|
Aptos,
|
|
33
35
|
DEFAULT_TXN_TIMEOUT_SEC,
|
|
34
36
|
Network,
|
|
@@ -316,7 +318,7 @@ var ShelbyClient = class {
|
|
|
316
318
|
const response = await fetch(`${faucet}`, {
|
|
317
319
|
method: "POST",
|
|
318
320
|
body: JSON.stringify({
|
|
319
|
-
address:
|
|
321
|
+
address: normalizeAddress(address).toString(),
|
|
320
322
|
amount
|
|
321
323
|
}),
|
|
322
324
|
headers: {
|
|
@@ -1,6 +1,9 @@
|
|
|
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
9
|
} from "./chunk-4ZOFT75Q.mjs";
|
|
@@ -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
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StaleChannelStateError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KTVNKLBT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getShelbyIndexerClient
|
|
6
6
|
} from "./chunk-CGYJLKBU.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
24
|
} from "./chunk-4ZOFT75Q.mjs";
|
|
21
|
-
import {
|
|
22
|
-
BlobNameSchema
|
|
23
|
-
} from "./chunk-Z4FZ7W6L.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
|
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
} from "./chunk-AABBONAF.mjs";
|
|
10
10
|
import {
|
|
11
11
|
createBlobKey
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3NRBHSMQ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
expectedTotalChunksets
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BXEVML7N.mjs";
|
|
16
16
|
import {
|
|
17
|
-
getBlobNameSuffix
|
|
18
|
-
|
|
17
|
+
getBlobNameSuffix,
|
|
18
|
+
normalizeAddress
|
|
19
|
+
} from "./chunk-UEZNZBJO.mjs";
|
|
19
20
|
import {
|
|
20
21
|
ERASURE_CODE_AND_CHUNK_MAPPING
|
|
21
22
|
} from "./chunk-JTXYKO3U.mjs";
|
|
@@ -174,14 +175,14 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
174
175
|
blobMerkleRoot: Hex.fromHexInput(
|
|
175
176
|
metadata.blob_commitment
|
|
176
177
|
).toUint8Array(),
|
|
177
|
-
owner:
|
|
178
|
+
owner: normalizeAddress(metadata.owner),
|
|
178
179
|
name: params.name,
|
|
179
180
|
blobNameSuffix: getBlobNameSuffix(params.name),
|
|
180
181
|
size: Number(metadata.blob_size),
|
|
181
182
|
encoding,
|
|
182
183
|
expirationMicros: Number(metadata.expiration_micros),
|
|
183
184
|
creationMicros: Number(metadata.creation_micros),
|
|
184
|
-
sliceAddress:
|
|
185
|
+
sliceAddress: normalizeAddress(metadata.slice.inner),
|
|
185
186
|
isWritten: metadata.is_written
|
|
186
187
|
};
|
|
187
188
|
} catch (error) {
|
|
@@ -214,7 +215,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
214
215
|
return this.getBlobs({
|
|
215
216
|
where: {
|
|
216
217
|
...where,
|
|
217
|
-
owner: { _eq:
|
|
218
|
+
owner: { _eq: normalizeAddress(params.account).toString() }
|
|
218
219
|
},
|
|
219
220
|
pagination: rest.pagination,
|
|
220
221
|
orderBy: rest.orderBy
|
|
@@ -253,7 +254,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
253
254
|
});
|
|
254
255
|
return blobs.map(
|
|
255
256
|
(blob) => ({
|
|
256
|
-
owner:
|
|
257
|
+
owner: normalizeAddress(blob.owner),
|
|
257
258
|
name: blob.blob_name,
|
|
258
259
|
blobNameSuffix: getBlobNameSuffix(blob.blob_name),
|
|
259
260
|
blobMerkleRoot: Hex.fromHexInput(blob.blob_commitment).toUint8Array(),
|
|
@@ -266,7 +267,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
266
267
|
},
|
|
267
268
|
expirationMicros: Number(blob.expires_at),
|
|
268
269
|
creationMicros: Number(blob.created_at),
|
|
269
|
-
sliceAddress:
|
|
270
|
+
sliceAddress: normalizeAddress(blob.slice_address),
|
|
270
271
|
isWritten: Boolean(Number(blob.is_written)),
|
|
271
272
|
isDeleted: Boolean(Number(blob.is_deleted))
|
|
272
273
|
})
|
|
@@ -290,9 +291,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
290
291
|
return blob_activities.map(
|
|
291
292
|
(activity) => ({
|
|
292
293
|
blobName: activity.blob_name,
|
|
293
|
-
accountAddress:
|
|
294
|
-
activity.blob_name.substring(1, 65)
|
|
295
|
-
),
|
|
294
|
+
accountAddress: normalizeAddress(activity.blob_name.substring(1, 65)),
|
|
296
295
|
type: activityTypeMapping[activity.event_type] ?? "unknown",
|
|
297
296
|
eventType: activity.event_type,
|
|
298
297
|
eventIndex: Number(activity.event_index),
|