@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.
Files changed (126) hide show
  1. package/dist/browser/index.d.ts +19 -10
  2. package/dist/browser/index.mjs +4200 -146
  3. package/dist/core/aptos-explorer.mjs +46 -5
  4. package/dist/core/blobs.mjs +12 -4
  5. package/dist/core/chunk.mjs +58 -9
  6. package/dist/core/clients/ShelbyBlobClient.d.ts +155 -83
  7. package/dist/core/clients/ShelbyBlobClient.mjs +1286 -17
  8. package/dist/core/clients/ShelbyClient.d.ts +39 -6
  9. package/dist/core/clients/ShelbyClient.mjs +3233 -23
  10. package/dist/core/clients/ShelbyClientConfig.d.ts +9 -1
  11. package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
  12. package/dist/core/clients/ShelbyMetadataClient.d.ts +20 -6
  13. package/dist/core/clients/ShelbyMetadataClient.mjs +388 -6
  14. package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -7
  15. package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +894 -13
  16. package/dist/core/clients/ShelbyPlacementGroupClient.mjs +310 -8
  17. package/dist/core/clients/ShelbyRPCClient.d.ts +117 -25
  18. package/dist/core/clients/ShelbyRPCClient.mjs +1245 -12
  19. package/dist/core/clients/index.d.ts +4 -2
  20. package/dist/core/clients/index.mjs +3802 -39
  21. package/dist/core/clients/utils.mjs +65 -6
  22. package/dist/core/commitments.d.ts +12 -1
  23. package/dist/core/commitments.mjs +277 -11
  24. package/dist/core/constants.d.ts +3 -3
  25. package/dist/core/constants.mjs +39 -16
  26. package/dist/core/erasure/clay-codes.mjs +129 -4
  27. package/dist/core/erasure/constants.d.ts +16 -1
  28. package/dist/core/erasure/constants.mjs +48 -11
  29. package/dist/core/erasure/default.mjs +191 -9
  30. package/dist/core/erasure/index.d.ts +1 -1
  31. package/dist/core/erasure/index.mjs +281 -24
  32. package/dist/core/erasure/reed-solomon.mjs +68 -4
  33. package/dist/core/erasure/utils.mjs +0 -2
  34. package/dist/core/errors.d.ts +20 -1
  35. package/dist/core/errors.mjs +58 -8
  36. package/dist/core/index.d.ts +9 -9
  37. package/dist/core/index.mjs +4194 -146
  38. package/dist/core/layout.mjs +37 -5
  39. package/dist/core/networks.mjs +10 -5
  40. package/dist/core/operations/generated/sdk.d.ts +807 -42
  41. package/dist/core/operations/generated/sdk.mjs +267 -18
  42. package/dist/core/operations/index.d.ts +1 -1
  43. package/dist/core/operations/index.mjs +368 -24
  44. package/dist/core/promises.mjs +4 -4
  45. package/dist/core/rpc-responses.d.ts +1 -57
  46. package/dist/core/rpc-responses.mjs +14 -15
  47. package/dist/core/shelby-explorer.mjs +31 -6
  48. package/dist/core/sp/chunk_proof.d.ts +23 -0
  49. package/dist/core/sp/chunk_proof.mjs +113 -0
  50. package/dist/core/sp/index.d.ts +3 -0
  51. package/dist/core/sp/index.mjs +402 -0
  52. package/dist/core/sp/sp_write_client.d.ts +53 -0
  53. package/dist/core/sp/sp_write_client.mjs +302 -0
  54. package/dist/core/strings.mjs +0 -2
  55. package/dist/core/types/blobs.d.ts +24 -5
  56. package/dist/core/types/blobs.mjs +24 -1
  57. package/dist/core/types/index.d.ts +2 -2
  58. package/dist/core/types/index.mjs +275 -10
  59. package/dist/core/types/payments.d.ts +6 -6
  60. package/dist/core/types/payments.mjs +230 -5
  61. package/dist/core/types/placement_groups.mjs +0 -1
  62. package/dist/core/types/storage_providers.d.ts +32 -6
  63. package/dist/core/types/storage_providers.mjs +22 -1
  64. package/dist/core/utils.mjs +94 -8
  65. package/dist/gen/rpc_server_pb.d.ts +295 -0
  66. package/dist/gen/rpc_server_pb.mjs +28 -0
  67. package/dist/node/clients/ShelbyNodeClient.d.ts +2 -0
  68. package/dist/node/clients/ShelbyNodeClient.mjs +3237 -24
  69. package/dist/node/clients/index.d.ts +2 -0
  70. package/dist/node/clients/index.mjs +3236 -26
  71. package/dist/node/index.d.ts +9 -9
  72. package/dist/node/index.mjs +4217 -153
  73. package/dist/node/parallel/commitment_worker.d.ts +9 -0
  74. package/dist/node/parallel/commitment_worker.mjs +85 -0
  75. package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
  76. package/dist/node/parallel/commitment_worker_pool.mjs +339 -0
  77. package/dist/node/parallel/coverage_flush.d.ts +16 -0
  78. package/dist/node/parallel/coverage_flush.mjs +43 -0
  79. package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
  80. package/dist/node/parallel/default_commitment_worker_pool.mjs +355 -0
  81. package/dist/node/parallel/index.d.ts +12 -0
  82. package/dist/node/parallel/index.mjs +631 -0
  83. package/dist/node/parallel/parallel_commitments.d.ts +32 -0
  84. package/dist/node/parallel/parallel_commitments.mjs +614 -0
  85. package/dist/node/parallel/worker_pool.d.ts +74 -0
  86. package/dist/node/parallel/worker_pool.mjs +301 -0
  87. package/dist/node/testUtil.mjs +8 -4
  88. package/package.json +16 -5
  89. package/dist/chunk-3NRBHSMQ.mjs +0 -12
  90. package/dist/chunk-5BVSWXQJ.mjs +0 -801
  91. package/dist/chunk-6FJNAUU5.mjs +0 -278
  92. package/dist/chunk-6XSZRDLJ.mjs +0 -375
  93. package/dist/chunk-7P6ASYW6.mjs +0 -9
  94. package/dist/chunk-A4IG6GSE.mjs +0 -21
  95. package/dist/chunk-AD2G3QYD.mjs +0 -0
  96. package/dist/chunk-AUQDI5BS.mjs +0 -43
  97. package/dist/chunk-AY3HBWXA.mjs +0 -51
  98. package/dist/chunk-BDSW5PHM.mjs +0 -37
  99. package/dist/chunk-C6RQ3AEU.mjs +0 -51
  100. package/dist/chunk-CQ6QPIZK.mjs +0 -37
  101. package/dist/chunk-D6GQHO6G.mjs +0 -15
  102. package/dist/chunk-EM67QTMR.mjs +0 -0
  103. package/dist/chunk-I6NG5GNL.mjs +0 -8
  104. package/dist/chunk-JTXYKO3U.mjs +0 -38
  105. package/dist/chunk-KG2TMLEV.mjs +0 -207
  106. package/dist/chunk-M3CP5TFP.mjs +0 -39
  107. package/dist/chunk-M7W43K2Q.mjs +0 -505
  108. package/dist/chunk-MB7C7VQF.mjs +0 -0
  109. package/dist/chunk-MNCQBEMS.mjs +0 -55
  110. package/dist/chunk-MQUVYMNQ.mjs +0 -0
  111. package/dist/chunk-NEO7Z3ZQ.mjs +0 -49
  112. package/dist/chunk-NHWWORCH.mjs +0 -72
  113. package/dist/chunk-OEK24ON7.mjs +0 -135
  114. package/dist/chunk-QQ57OGQ2.mjs +0 -0
  115. package/dist/chunk-RNNJXTX2.mjs +0 -154
  116. package/dist/chunk-S6Q4OG7H.mjs +0 -83
  117. package/dist/chunk-TET3DJEO.mjs +0 -199
  118. package/dist/chunk-UEZNZBJO.mjs +0 -104
  119. package/dist/chunk-V46D5NBW.mjs +0 -11
  120. package/dist/chunk-V4B3GAMQ.mjs +0 -42
  121. package/dist/chunk-WFWRBNTW.mjs +0 -412
  122. package/dist/chunk-WTICJPDB.mjs +0 -0
  123. package/dist/chunk-XNEIWM4O.mjs +0 -0
  124. package/dist/chunk-Z4FZ7W6L.mjs +0 -39
  125. package/dist/chunk-Z7RFCADT.mjs +0 -0
  126. package/dist/chunk-ZHXCVRZX.mjs +0 -0
@@ -5,7 +5,7 @@ import { ShelbyNetwork } from '../networks.js';
5
5
  * Configuration for the Shelby RPC connection.
6
6
  */
7
7
  type ShelbyRPCConfig = {
8
- /** Base URL of the Shelby RPC node (e.g., "https://api.shelbynet.shelby.xyz/shelby"). */
8
+ /** Base URL of the Shelby RPC node (e.g., "https://shelby.shelbynet.shelby.xyz/shelby"). */
9
9
  baseUrl?: string;
10
10
  /** API key for authenticating with the RPC node. */
11
11
  apiKey?: string;
@@ -57,6 +57,14 @@ interface ShelbyClientConfig {
57
57
  * generated automatically for each transaction.
58
58
  */
59
59
  orderless?: boolean;
60
+ /**
61
+ * Best-effort location (region) hint sent with every blob registration from this client,
62
+ * typically the location closest to where the client runs. Honored only for accounts in
63
+ * the default `FollowHint` location-preference mode, and overridden by a per-write
64
+ * `selectedLocation`. Without a resolvable location (no preference, no selection, no
65
+ * hint), writes abort on chain.
66
+ */
67
+ locationHint?: string;
60
68
  }
61
69
 
62
70
  export type { ShelbyClientConfig, ShelbyIndexerConfig, ShelbyRPCConfig };
@@ -1 +0,0 @@
1
- import "../../chunk-Z7RFCADT.mjs";
@@ -32,27 +32,41 @@ declare class ShelbyMetadataClient {
32
32
  */
33
33
  getStorageProviders(): Promise<StorageProviderInfo[]>;
34
34
  /**
35
- * Retrieves the list of placement group addresses.
35
+ * Retrieves the names of every activated location (region). Locations that are
36
+ * registered but not yet brought online are admin-internal and not listed.
36
37
  *
38
+ * @returns The location name list.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const locations = await client.getLocationNames();
43
+ * ```
44
+ */
45
+ getLocationNames(): Promise<string[]>;
46
+ /**
47
+ * Retrieves the list of placement group addresses in a location.
48
+ *
49
+ * @param locationName - The location whose placement groups to list.
37
50
  * @returns The placement group address list, or an empty array if none exist.
38
51
  *
39
52
  * @example
40
53
  * ```typescript
41
- * const pgList = await client.getPlacementGroupAddresses();
54
+ * const pgList = await client.getPlacementGroupAddresses("us-east-1");
42
55
  * ```
43
56
  */
44
- getPlacementGroupAddresses(): Promise<AccountAddress[]>;
57
+ getPlacementGroupAddresses(locationName: string): Promise<AccountAddress[]>;
45
58
  /**
46
- * Retrieves the list of slice addresses.
59
+ * Retrieves the list of slice addresses in a location.
47
60
  *
61
+ * @param locationName - The location whose slices to list.
48
62
  * @returns The slice group list, or an empty array if none exist.
49
63
  *
50
64
  * @example
51
65
  * ```typescript
52
- * const pgList = await client.getSliceAddresses();
66
+ * const pgList = await client.getSliceAddresses("us-east-1");
53
67
  * ```
54
68
  */
55
- getSliceAddresses(): Promise<AccountAddress[]>;
69
+ getSliceAddresses(locationName: string): Promise<AccountAddress[]>;
56
70
  /**
57
71
  * Gets the placement group address for a slice.
58
72
  *
@@ -1,10 +1,392 @@
1
+ // src/core/clients/ShelbyMetadataClient.ts
1
2
  import {
2
- ShelbyMetadataClient
3
- } from "../../chunk-6FJNAUU5.mjs";
4
- import "../../chunk-V4B3GAMQ.mjs";
5
- import "../../chunk-UEZNZBJO.mjs";
6
- import "../../chunk-MNCQBEMS.mjs";
7
- import "../../chunk-7P6ASYW6.mjs";
3
+ AccountAddress as AccountAddress2,
4
+ Aptos,
5
+ Hex as Hex2
6
+ } from "@aptos-labs/ts-sdk";
7
+
8
+ // src/core/constants.ts
9
+ import { Network } from "@aptos-labs/ts-sdk";
10
+ var NetworkToShelbyRPCBaseUrl = {
11
+ [Network.SHELBYNET]: "https://shelby.shelbynet.shelby.xyz/shelby",
12
+ [Network.NETNA]: void 0,
13
+ [Network.DEVNET]: void 0,
14
+ [Network.TESTNET]: "https://api.testnet.shelby.xyz/shelby",
15
+ [Network.MAINNET]: void 0,
16
+ [Network.LOCAL]: "http://localhost:9090",
17
+ [Network.CUSTOM]: void 0
18
+ };
19
+ var NetworkToShelbyBlobIndexerBaseUrl = {
20
+ [Network.SHELBYNET]: "https://api.shelbynet.aptoslabs.com/nocode/v1/public/alias/shelby/shelbynet/v1/graphql",
21
+ [Network.NETNA]: void 0,
22
+ [Network.DEVNET]: void 0,
23
+ [Network.TESTNET]: "https://api.testnet.aptoslabs.com/nocode/v1/public/alias/shelby/testnet/v1/graphql",
24
+ [Network.MAINNET]: void 0,
25
+ [Network.LOCAL]: "http://localhost:8091/v1/graphql",
26
+ [Network.CUSTOM]: void 0
27
+ };
28
+ var NetworkToGasStationBaseUrl = {
29
+ [Network.SHELBYNET]: "https://api.shelbynet.shelby.xyz/gs/v1",
30
+ [Network.NETNA]: void 0,
31
+ [Network.DEVNET]: void 0,
32
+ [Network.TESTNET]: "https://api.testnet.shelby.xyz/gs/v1",
33
+ [Network.MAINNET]: void 0,
34
+ [Network.LOCAL]: void 0,
35
+ [Network.CUSTOM]: void 0
36
+ };
37
+ var SHELBY_DEPLOYER = "0x85fdb9a176ab8ef1d9d9c1b60d60b3924f0800ac1de1cc2085fb0b8bb4988e6a";
38
+
39
+ // src/core/types/storage_providers.ts
40
+ var ACTIVE_PROVIDER_CONDITIONS = [
41
+ "Normal",
42
+ "Faulty",
43
+ "Leaving",
44
+ "Evicted",
45
+ "PendingLeaving"
46
+ ];
47
+ function isActiveProviderCondition(value) {
48
+ return typeof value === "string" && ACTIVE_PROVIDER_CONDITIONS.includes(value);
49
+ }
50
+
51
+ // src/core/utils.ts
52
+ import {
53
+ AccountAddress,
54
+ Hex
55
+ } from "@aptos-labs/ts-sdk";
56
+ function normalizeAddress(address) {
57
+ return AccountAddress.from(address, { maxMissingChars: 63 });
58
+ }
59
+
60
+ // src/core/clients/utils.ts
61
+ import { AptosConfig } from "@aptos-labs/ts-sdk";
62
+ var getAptosConfig = (config) => {
63
+ const baseFaucetConfig = config.faucet?.authToken ? { AUTH_TOKEN: config.faucet.authToken } : void 0;
64
+ if (config.aptos) {
65
+ return new AptosConfig({
66
+ // Spread user's aptos config first
67
+ ...config.aptos,
68
+ // Network from top-level is authoritative - cannot be overridden
69
+ network: config.network,
70
+ // Merge clientConfig with API_KEY default
71
+ clientConfig: {
72
+ API_KEY: config.apiKey,
73
+ ...config.aptos.clientConfig
74
+ },
75
+ // Merge faucetConfig: aptos config first, then base authToken (authoritative)
76
+ faucetConfig: {
77
+ ...config.aptos.faucetConfig,
78
+ ...baseFaucetConfig
79
+ }
80
+ });
81
+ }
82
+ return new AptosConfig({
83
+ network: config.network,
84
+ clientConfig: {
85
+ API_KEY: config.apiKey
86
+ },
87
+ faucetConfig: baseFaucetConfig
88
+ });
89
+ };
90
+
91
+ // src/core/clients/ShelbyMetadataClient.ts
92
+ function parseActiveProviderCondition(raw) {
93
+ const variant = raw?.__variant__;
94
+ if (!isActiveProviderCondition(variant)) {
95
+ throw new Error(
96
+ `Unknown ActiveProviderCondition variant: ${JSON.stringify(raw)}`
97
+ );
98
+ }
99
+ return variant;
100
+ }
101
+ function parseStorageProviderState(raw) {
102
+ switch (raw.__variant__) {
103
+ case "Active":
104
+ return {
105
+ variant: "Active",
106
+ quota: raw.quota.value,
107
+ stakeAtStartOfStakingEpoch: raw.stake_at_start_of_staking_epoch,
108
+ condition: parseActiveProviderCondition(raw.condition)
109
+ };
110
+ case "Waitlisted":
111
+ return {
112
+ variant: "Waitlisted"
113
+ };
114
+ case "Frozen":
115
+ return {
116
+ variant: "Frozen",
117
+ frozenReason: raw.frozen_reason,
118
+ frozenFrom: raw.frozen_from,
119
+ frozenTill: raw.frozen_till
120
+ };
121
+ default:
122
+ throw new Error(
123
+ `Unknown StorageProviderStateDetails variant: ${JSON.stringify(raw)}`
124
+ );
125
+ }
126
+ }
127
+ var ShelbyMetadataClient = class {
128
+ aptos;
129
+ deployer;
130
+ /**
131
+ * The ShelbyMetadataClient is used to interact with the Shelby contract on the Aptos blockchain. This
132
+ * includes functions like gathering basic details about the Shelby system, including storage provider information.
133
+ *
134
+ * @param config.aptos.config - The Aptos config.
135
+ * @param config.shelbyDeployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
140
+ * const metadataClient = new ShelbyMetadataClient({ aptos });
141
+ * ```
142
+ */
143
+ constructor(config) {
144
+ this.aptos = new Aptos(getAptosConfig(config));
145
+ this.deployer = config.deployer ?? AccountAddress2.fromString(SHELBY_DEPLOYER);
146
+ }
147
+ /**
148
+ * Retrieves storage provider list from the blockchain.
149
+ *
150
+ * @returns A list of storage providers, or empty array if none exist.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const spList = await client.getStorageProviders();
155
+ * ```
156
+ */
157
+ async getStorageProviders() {
158
+ try {
159
+ const rawMetadata = await this.aptos.view({
160
+ payload: {
161
+ function: `${this.deployer.toString()}::storage_provider_registry::get_all_storage_providers`,
162
+ functionArguments: []
163
+ }
164
+ });
165
+ const metadata = rawMetadata[0];
166
+ return metadata.map((provider) => ({
167
+ address: normalizeAddress(provider.address),
168
+ ipAddress: provider.ip_address,
169
+ port: provider.port,
170
+ blsPublicKey: Hex2.fromHexInput(provider.bls_public_key).toUint8Array(),
171
+ availabilityZone: provider.availability_zone,
172
+ state: parseStorageProviderState(provider.state)
173
+ }));
174
+ } catch (error) {
175
+ if (error instanceof Error && // Depending on the network, the error message may show up differently.
176
+ error.message?.includes("sub_status: Some(404)")) {
177
+ return [];
178
+ }
179
+ throw error;
180
+ }
181
+ }
182
+ /**
183
+ * Retrieves the names of every activated location (region). Locations that are
184
+ * registered but not yet brought online are admin-internal and not listed.
185
+ *
186
+ * @returns The location name list.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const locations = await client.getLocationNames();
191
+ * ```
192
+ */
193
+ async getLocationNames() {
194
+ const names = await this.aptos.view({
195
+ payload: {
196
+ function: `${this.deployer.toString()}::location::activated_location_names`,
197
+ functionArguments: []
198
+ }
199
+ });
200
+ return names[0];
201
+ }
202
+ /**
203
+ * Retrieves the list of placement group addresses in a location.
204
+ *
205
+ * @param locationName - The location whose placement groups to list.
206
+ * @returns The placement group address list, or an empty array if none exist.
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const pgList = await client.getPlacementGroupAddresses("us-east-1");
211
+ * ```
212
+ */
213
+ async getPlacementGroupAddresses(locationName) {
214
+ try {
215
+ const pgSizeMetadata = await this.aptos.view({
216
+ payload: {
217
+ function: `${this.deployer.toString()}::placement_group_registry::get_number_of_placement_groups`,
218
+ functionArguments: [locationName]
219
+ }
220
+ });
221
+ if (Number(pgSizeMetadata[0]) === 0) {
222
+ return [];
223
+ }
224
+ const finalPlacementGroupIndex = pgSizeMetadata[0] - 1;
225
+ const addressMetadataArray = await this.aptos.view({
226
+ payload: {
227
+ function: `${this.deployer.toString()}::placement_group_registry::get_placement_group_addresses`,
228
+ functionArguments: [locationName, 0, finalPlacementGroupIndex]
229
+ }
230
+ });
231
+ const metadata = addressMetadataArray[0];
232
+ return metadata.map((pg) => normalizeAddress(pg));
233
+ } catch (error) {
234
+ if (error instanceof Error && // Depending on the network, the error message may show up differently.
235
+ (error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_PLACEMENT_GROUP_NOT_FOUND"))) {
236
+ return [];
237
+ }
238
+ throw error;
239
+ }
240
+ }
241
+ /**
242
+ * Retrieves the list of slice addresses in a location.
243
+ *
244
+ * @param locationName - The location whose slices to list.
245
+ * @returns The slice group list, or an empty array if none exist.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const pgList = await client.getSliceAddresses("us-east-1");
250
+ * ```
251
+ */
252
+ async getSliceAddresses(locationName) {
253
+ try {
254
+ const sliceSizeMetadata = await this.aptos.view({
255
+ payload: {
256
+ function: `${this.deployer.toString()}::slice_registry::get_number_of_slices`,
257
+ functionArguments: [locationName]
258
+ }
259
+ });
260
+ if (Number(sliceSizeMetadata[0]) === 0) {
261
+ return [];
262
+ }
263
+ const finalSliceIndex = sliceSizeMetadata[0] - 1;
264
+ const addressMetadataArray = await this.aptos.view({
265
+ payload: {
266
+ function: `${this.deployer.toString()}::slice_registry::get_slice_addresses`,
267
+ functionArguments: [locationName, 0, finalSliceIndex]
268
+ }
269
+ });
270
+ const metadata = addressMetadataArray[0];
271
+ return metadata.map((slice) => normalizeAddress(slice));
272
+ } catch (error) {
273
+ if (error instanceof Error && // Depending on the network, the error message may show up differently.
274
+ (error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_SLICE_NOT_FOUND"))) {
275
+ return [];
276
+ }
277
+ throw error;
278
+ }
279
+ }
280
+ /**
281
+ * Gets the placement group address for a slice.
282
+ *
283
+ * @param sliceAddress - The address of the slice account.
284
+ * @returns The placement group address as a string.
285
+ */
286
+ async getPlacementGroupAddressForSlice(sliceAddress) {
287
+ const sliceMetadata = await this.aptos.view({
288
+ payload: {
289
+ function: `${this.deployer.toString()}::slice::get_slice_info`,
290
+ functionArguments: [sliceAddress.toString()]
291
+ }
292
+ });
293
+ return sliceMetadata[0].placement_group_assignments[0].placement_group_address;
294
+ }
295
+ /**
296
+ * Retrieves the designated storage providers for a slice.
297
+ *
298
+ * Designated SPs are those appointed to store data for their slots:
299
+ * - Active: Currently serving data
300
+ * - Receiving: Receiving data during slot transfer
301
+ * - Repairing: Repairing data after crash or failed transfer
302
+ * - Reconstructing: Reconstructing data if the repair fails
303
+ *
304
+ * @param params.account - The address of the slice account.
305
+ * @returns An array where result[i] is the designated SP for slot i, or null if no SP is designated.
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * const providers = await client.getDesignatedStorageProvidersForSlice({ account: sliceAddress });
310
+ * ```
311
+ */
312
+ async getDesignatedStorageProvidersForSlice(params) {
313
+ const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
314
+ params.account
315
+ );
316
+ const rawMetadata = await this.aptos.view({
317
+ payload: {
318
+ function: `${this.deployer.toString()}::placement_group::get_designated_storage_providers`,
319
+ functionArguments: [placementGroupAddress]
320
+ }
321
+ });
322
+ const providers = rawMetadata[0];
323
+ return providers.map(
324
+ (opt) => opt.vec.length > 0 ? normalizeAddress(opt.vec[0]) : null
325
+ );
326
+ }
327
+ /**
328
+ * Retrieves the active storage providers for a slice.
329
+ *
330
+ * Active SPs have a complete copy of the data for the slot, and are not in any data transfer/repair/reconstruction phase.
331
+ * Active SP can be audited for the data it contains.
332
+ * Each slot has at most one active SP.
333
+ *
334
+ * @param params.account - The address of the slice account.
335
+ * @returns An array where result[i] is the active SP for slot i, or null if no SP is active.
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const providers = await client.getActiveStorageProvidersForSlice({ account: sliceAddress });
340
+ * ```
341
+ */
342
+ async getActiveStorageProvidersForSlice(params) {
343
+ const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
344
+ params.account
345
+ );
346
+ const rawMetadata = await this.aptos.view({
347
+ payload: {
348
+ function: `${this.deployer.toString()}::placement_group::get_active_storage_providers`,
349
+ functionArguments: [placementGroupAddress]
350
+ }
351
+ });
352
+ const providers = rawMetadata[0];
353
+ return providers.map(
354
+ (opt) => opt.vec.length > 0 ? normalizeAddress(opt.vec[0]) : null
355
+ );
356
+ }
357
+ /**
358
+ * Retrieves the serving storage providers for a slice.
359
+ *
360
+ * Serving SPs are those that can respond to read requests. The serving logic is:
361
+ * - If an Active SP exists for a slot: Only the Active SP is serving
362
+ * - If no Active SP (transition in progress): Both Designated and Vacating SPs serve
363
+ *
364
+ * Each slot may have multiple serving SPs during transitions.
365
+ *
366
+ * @param params.account - The address of the slice account.
367
+ * @returns An array where result[i] contains the serving SPs for slot i.
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * const providers = await client.getServingStorageProvidersForSlice({ account: sliceAddress });
372
+ * ```
373
+ */
374
+ async getServingStorageProvidersForSlice(params) {
375
+ const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
376
+ params.account
377
+ );
378
+ const rawMetadata = await this.aptos.view({
379
+ payload: {
380
+ function: `${this.deployer.toString()}::placement_group::get_serving_storage_providers`,
381
+ functionArguments: [placementGroupAddress]
382
+ }
383
+ });
384
+ const providers = rawMetadata[0];
385
+ return providers.map(
386
+ (slotProviders) => slotProviders.map((addr) => normalizeAddress(addr))
387
+ );
388
+ }
389
+ };
8
390
  export {
9
391
  ShelbyMetadataClient
10
392
  };
@@ -81,7 +81,7 @@ declare class ShelbyMicropaymentChannelClient {
81
81
  createChannel(params: {
82
82
  sender: Account;
83
83
  receiver: AccountAddress;
84
- expirationMicros: number;
84
+ expirationMicros: number | bigint;
85
85
  depositAmount: number;
86
86
  fungibleAssetAddress: AccountAddress;
87
87
  publicKey?: Uint8Array;
@@ -106,7 +106,7 @@ declare class ShelbyMicropaymentChannelClient {
106
106
  static makeCreateMicropaymentChannelPayload(params: {
107
107
  deployer?: AccountAddress;
108
108
  receiver: AccountAddress;
109
- expirationMicros: number;
109
+ expirationMicros: number | bigint;
110
110
  depositAmount: number;
111
111
  fungibleAssetAddress: AccountAddress;
112
112
  publicKey: Uint8Array;
@@ -183,9 +183,9 @@ declare class ShelbyMicropaymentChannelClient {
183
183
  sender: Account;
184
184
  receiver: AccountAddress;
185
185
  fungibleAssetAddress: AccountAddress;
186
- amount: number;
187
- paymentChannelId: number;
188
- sequenceNumber: number;
186
+ amount: number | bigint;
187
+ paymentChannelId: number | bigint;
188
+ sequenceNumber: number | bigint;
189
189
  }): SenderBuiltMicropayment;
190
190
  /**
191
191
  * Creates a static payload for the receiver_withdraw Move function.
@@ -260,7 +260,7 @@ declare class ShelbyMicropaymentChannelClient {
260
260
  sender: Account;
261
261
  receiver: AccountAddress;
262
262
  fungibleAssetAddress: AccountAddress;
263
- newExpirationMicros: number;
263
+ newExpirationMicros: number | bigint;
264
264
  options?: InputGenerateTransactionOptions;
265
265
  }): Promise<{
266
266
  transaction: PendingTransactionResponse;
@@ -280,7 +280,7 @@ declare class ShelbyMicropaymentChannelClient {
280
280
  deployer?: AccountAddress;
281
281
  receiver: AccountAddress;
282
282
  fungibleAssetAddress: AccountAddress;
283
- newExpirationMicros: number;
283
+ newExpirationMicros: number | bigint;
284
284
  }): InputGenerateTransactionPayloadData;
285
285
  /**
286
286
  * Increases the deposit amount locked in a micropayment channel.