@shelby-protocol/sdk 0.3.0 → 0.3.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 +12 -3
- package/dist/browser/index.mjs +3717 -142
- 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 +0 -43
- package/dist/core/clients/ShelbyBlobClient.mjs +1084 -17
- package/dist/core/clients/ShelbyClient.d.ts +12 -2
- package/dist/core/clients/ShelbyClient.mjs +2915 -23
- package/dist/core/clients/ShelbyClientConfig.mjs +0 -1
- package/dist/core/clients/ShelbyMetadataClient.d.ts +0 -18
- package/dist/core/clients/ShelbyMetadataClient.mjs +306 -6
- package/dist/core/clients/ShelbyMicropaymentChannelClient.d.ts +7 -49
- package/dist/core/clients/ShelbyMicropaymentChannelClient.mjs +839 -13
- package/dist/core/clients/ShelbyPlacementGroupClient.mjs +307 -8
- package/dist/core/clients/ShelbyRPCClient.d.ts +106 -3
- package/dist/core/clients/ShelbyRPCClient.mjs +1261 -12
- package/dist/core/clients/index.d.ts +2 -1
- package/dist/core/clients/index.mjs +3420 -39
- package/dist/core/clients/utils.mjs +65 -6
- package/dist/core/commitments.mjs +270 -11
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.mjs +39 -16
- package/dist/core/erasure/clay-codes.mjs +129 -4
- package/dist/core/erasure/constants.mjs +33 -10
- package/dist/core/erasure/default.mjs +191 -9
- package/dist/core/erasure/index.mjs +266 -23
- package/dist/core/erasure/reed-solomon.mjs +68 -4
- package/dist/core/erasure/utils.mjs +0 -2
- package/dist/core/errors.mjs +29 -8
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +3711 -142
- package/dist/core/layout.mjs +37 -5
- package/dist/core/networks.mjs +10 -5
- package/dist/core/operations/generated/sdk.d.ts +9 -0
- package/dist/core/operations/generated/sdk.mjs +183 -18
- package/dist/core/operations/index.mjs +284 -24
- package/dist/core/promises.mjs +4 -4
- package/dist/core/rpc-responses.mjs +29 -10
- package/dist/core/shelby-explorer.mjs +31 -6
- package/dist/core/strings.mjs +0 -2
- package/dist/core/types/blobs.mjs +0 -1
- package/dist/core/types/index.mjs +230 -9
- 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.mjs +0 -1
- package/dist/core/utils.mjs +94 -8
- package/dist/node/clients/ShelbyNodeClient.d.ts +1 -0
- package/dist/node/clients/ShelbyNodeClient.mjs +2919 -24
- package/dist/node/clients/index.d.ts +1 -0
- package/dist/node/clients/index.mjs +2920 -26
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.mjs +3734 -149
- package/dist/node/parallel/commitment_worker.d.ts +9 -0
- package/dist/node/parallel/commitment_worker.mjs +298 -0
- package/dist/node/parallel/commitment_worker_pool.d.ts +35 -0
- package/dist/node/parallel/commitment_worker_pool.mjs +286 -0
- package/dist/node/parallel/default_commitment_worker_pool.d.ts +24 -0
- package/dist/node/parallel/default_commitment_worker_pool.mjs +302 -0
- package/dist/node/parallel/index.d.ts +11 -0
- package/dist/node/parallel/index.mjs +563 -0
- package/dist/node/parallel/parallel_commitments.d.ts +32 -0
- package/dist/node/parallel/parallel_commitments.mjs +561 -0
- package/dist/node/parallel/worker_pool.d.ts +74 -0
- package/dist/node/parallel/worker_pool.mjs +248 -0
- package/dist/node/testUtil.mjs +8 -4
- package/package.json +6 -2
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../../chunk-Z7RFCADT.mjs";
|
|
@@ -80,24 +80,6 @@ declare class ShelbyMetadataClient {
|
|
|
80
80
|
getDesignatedStorageProvidersForSlice(params: {
|
|
81
81
|
account: AccountAddressInput;
|
|
82
82
|
}): Promise<(AccountAddress | null)[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves the active storage providers for a slice.
|
|
85
|
-
*
|
|
86
|
-
* Active SPs have a complete copy of the data for the slot, and are not in any data transfer/repair/reconstruction phase.
|
|
87
|
-
* Active SP can be audited for the data it contains.
|
|
88
|
-
* Each slot has at most one active SP.
|
|
89
|
-
*
|
|
90
|
-
* @param params.account - The address of the slice account.
|
|
91
|
-
* @returns An array where result[i] is the active SP for slot i, or null if no SP is active.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const providers = await client.getActiveStorageProvidersForSlice({ account: sliceAddress });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
getActiveStorageProvidersForSlice(params: {
|
|
99
|
-
account: AccountAddressInput;
|
|
100
|
-
}): Promise<(AccountAddress | null)[]>;
|
|
101
83
|
/**
|
|
102
84
|
* Retrieves the serving storage providers for a slice.
|
|
103
85
|
*
|
|
@@ -1,10 +1,310 @@
|
|
|
1
|
+
// src/core/clients/ShelbyMetadataClient.ts
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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://api.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/utils.ts
|
|
40
|
+
import {
|
|
41
|
+
AccountAddress,
|
|
42
|
+
Hex
|
|
43
|
+
} from "@aptos-labs/ts-sdk";
|
|
44
|
+
function normalizeAddress(address) {
|
|
45
|
+
return AccountAddress.from(address, { maxMissingChars: 63 });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/core/clients/utils.ts
|
|
49
|
+
import { AptosConfig } from "@aptos-labs/ts-sdk";
|
|
50
|
+
var getAptosConfig = (config) => {
|
|
51
|
+
const baseFaucetConfig = config.faucet?.authToken ? { AUTH_TOKEN: config.faucet.authToken } : void 0;
|
|
52
|
+
if (config.aptos) {
|
|
53
|
+
return new AptosConfig({
|
|
54
|
+
// Spread user's aptos config first
|
|
55
|
+
...config.aptos,
|
|
56
|
+
// Network from top-level is authoritative - cannot be overridden
|
|
57
|
+
network: config.network,
|
|
58
|
+
// Merge clientConfig with API_KEY default
|
|
59
|
+
clientConfig: {
|
|
60
|
+
API_KEY: config.apiKey,
|
|
61
|
+
...config.aptos.clientConfig
|
|
62
|
+
},
|
|
63
|
+
// Merge faucetConfig: aptos config first, then base authToken (authoritative)
|
|
64
|
+
faucetConfig: {
|
|
65
|
+
...config.aptos.faucetConfig,
|
|
66
|
+
...baseFaucetConfig
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return new AptosConfig({
|
|
71
|
+
network: config.network,
|
|
72
|
+
clientConfig: {
|
|
73
|
+
API_KEY: config.apiKey
|
|
74
|
+
},
|
|
75
|
+
faucetConfig: baseFaucetConfig
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/core/clients/ShelbyMetadataClient.ts
|
|
80
|
+
function parseStorageProviderState(raw) {
|
|
81
|
+
switch (raw.__variant__) {
|
|
82
|
+
case "Active":
|
|
83
|
+
return {
|
|
84
|
+
variant: "Active",
|
|
85
|
+
quota: raw.quota.value,
|
|
86
|
+
stakeAtStartOfStakingEpoch: raw.stake_at_start_of_staking_epoch,
|
|
87
|
+
faulty: raw.faulty,
|
|
88
|
+
leaving: raw.leaving
|
|
89
|
+
};
|
|
90
|
+
case "Waitlisted":
|
|
91
|
+
return {
|
|
92
|
+
variant: "Waitlisted"
|
|
93
|
+
};
|
|
94
|
+
case "Frozen":
|
|
95
|
+
return {
|
|
96
|
+
variant: "Frozen",
|
|
97
|
+
frozenReason: raw.frozen_reason,
|
|
98
|
+
frozenFrom: raw.frozen_from,
|
|
99
|
+
frozenTill: raw.frozen_till
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var ShelbyMetadataClient = class {
|
|
104
|
+
aptos;
|
|
105
|
+
deployer;
|
|
106
|
+
/**
|
|
107
|
+
* The ShelbyMetadataClient is used to interact with the Shelby contract on the Aptos blockchain. This
|
|
108
|
+
* includes functions like gathering basic details about the Shelby system, including storage provider information.
|
|
109
|
+
*
|
|
110
|
+
* @param config.aptos.config - The Aptos config.
|
|
111
|
+
* @param config.shelbyDeployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
|
|
116
|
+
* const metadataClient = new ShelbyMetadataClient({ aptos });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
constructor(config) {
|
|
120
|
+
this.aptos = new Aptos(getAptosConfig(config));
|
|
121
|
+
this.deployer = config.deployer ?? AccountAddress2.fromString(SHELBY_DEPLOYER);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves storage provider list from the blockchain.
|
|
125
|
+
*
|
|
126
|
+
* @returns A list of storage providers, or empty array if none exist.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const spList = await client.getStorageProviders();
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
async getStorageProviders() {
|
|
134
|
+
try {
|
|
135
|
+
const rawMetadata = await this.aptos.view({
|
|
136
|
+
payload: {
|
|
137
|
+
function: `${this.deployer.toString()}::storage_provider_registry::get_all_storage_providers`,
|
|
138
|
+
functionArguments: []
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const metadata = rawMetadata[0];
|
|
142
|
+
return metadata.map((provider) => ({
|
|
143
|
+
address: normalizeAddress(provider.address),
|
|
144
|
+
ipAddress: provider.ip_address,
|
|
145
|
+
port: provider.port,
|
|
146
|
+
blsPublicKey: Hex2.fromHexInput(provider.bls_public_key).toUint8Array(),
|
|
147
|
+
availabilityZone: provider.availability_zone,
|
|
148
|
+
state: parseStorageProviderState(provider.state)
|
|
149
|
+
}));
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
152
|
+
error.message?.includes("sub_status: Some(404)")) {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the list of placement group addresses.
|
|
160
|
+
*
|
|
161
|
+
* @returns The placement group address list, or an empty array if none exist.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const pgList = await client.getPlacementGroupAddresses();
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
async getPlacementGroupAddresses() {
|
|
169
|
+
try {
|
|
170
|
+
const pgSizeMetadata = await this.aptos.view({
|
|
171
|
+
payload: {
|
|
172
|
+
function: `${this.deployer.toString()}::placement_group_registry::get_number_of_placement_groups`,
|
|
173
|
+
functionArguments: []
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const finalPlacementGroupIndex = pgSizeMetadata[0] - 1;
|
|
177
|
+
const addressMetadataArray = await this.aptos.view({
|
|
178
|
+
payload: {
|
|
179
|
+
function: `${this.deployer.toString()}::placement_group_registry::get_placement_group_addresses`,
|
|
180
|
+
functionArguments: [0, finalPlacementGroupIndex]
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
const metadata = addressMetadataArray[0];
|
|
184
|
+
return metadata.map((pg) => normalizeAddress(pg));
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
187
|
+
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_PLACEMENT_GROUP_NOT_FOUND"))) {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves the list of slice addresses.
|
|
195
|
+
*
|
|
196
|
+
* @returns The slice group list, or an empty array if none exist.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const pgList = await client.getSliceAddresses();
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
async getSliceAddresses() {
|
|
204
|
+
try {
|
|
205
|
+
const sliceSizeMetadata = await this.aptos.view({
|
|
206
|
+
payload: {
|
|
207
|
+
function: `${this.deployer.toString()}::slice_registry::get_number_of_slices`,
|
|
208
|
+
functionArguments: []
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
const finalSliceIndex = sliceSizeMetadata[0] - 1;
|
|
212
|
+
const addressMetadataArray = await this.aptos.view({
|
|
213
|
+
payload: {
|
|
214
|
+
function: `${this.deployer.toString()}::slice_registry::get_slice_addresses`,
|
|
215
|
+
functionArguments: [0, finalSliceIndex]
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const metadata = addressMetadataArray[0];
|
|
219
|
+
return metadata.map((slice) => normalizeAddress(slice));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
222
|
+
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_SLICE_NOT_FOUND"))) {
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Gets the placement group address for a slice.
|
|
230
|
+
*
|
|
231
|
+
* @param sliceAddress - The address of the slice account.
|
|
232
|
+
* @returns The placement group address as a string.
|
|
233
|
+
*/
|
|
234
|
+
async getPlacementGroupAddressForSlice(sliceAddress) {
|
|
235
|
+
const sliceMetadata = await this.aptos.view({
|
|
236
|
+
payload: {
|
|
237
|
+
function: `${this.deployer.toString()}::slice::get_slice_info`,
|
|
238
|
+
functionArguments: [sliceAddress.toString()]
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return sliceMetadata[0].placement_group_assignments[0].placement_group_address;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Retrieves the designated storage providers for a slice.
|
|
245
|
+
*
|
|
246
|
+
* Designated SPs are those appointed to store data for their slots:
|
|
247
|
+
* - Active: Currently serving data
|
|
248
|
+
* - Receiving: Receiving data during slot transfer
|
|
249
|
+
* - Repairing: Repairing data after crash or failed transfer
|
|
250
|
+
* - Reconstructing: Reconstructing data if the repair fails
|
|
251
|
+
*
|
|
252
|
+
* @param params.account - The address of the slice account.
|
|
253
|
+
* @returns An array where result[i] is the designated SP for slot i, or null if no SP is designated.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const providers = await client.getDesignatedStorageProvidersForSlice({ account: sliceAddress });
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
async getDesignatedStorageProvidersForSlice(params) {
|
|
261
|
+
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
262
|
+
params.account
|
|
263
|
+
);
|
|
264
|
+
const rawMetadata = await this.aptos.view({
|
|
265
|
+
payload: {
|
|
266
|
+
function: `${this.deployer.toString()}::placement_group::get_designated_storage_providers`,
|
|
267
|
+
functionArguments: [placementGroupAddress]
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
const providers = rawMetadata[0];
|
|
271
|
+
return providers.map(
|
|
272
|
+
(opt) => opt.vec.length > 0 ? normalizeAddress(opt.vec[0]) : null
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Retrieves the serving storage providers for a slice.
|
|
277
|
+
*
|
|
278
|
+
* Serving SPs are those that can respond to read requests. The serving logic is:
|
|
279
|
+
* - If an Active SP exists for a slot: Only the Active SP is serving
|
|
280
|
+
* - If no Active SP (transition in progress): Both Designated and Vacating SPs serve
|
|
281
|
+
*
|
|
282
|
+
* Each slot may have multiple serving SPs during transitions.
|
|
283
|
+
*
|
|
284
|
+
* @param params.account - The address of the slice account.
|
|
285
|
+
* @returns An array where result[i] contains the serving SPs for slot i.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* const providers = await client.getServingStorageProvidersForSlice({ account: sliceAddress });
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
async getServingStorageProvidersForSlice(params) {
|
|
293
|
+
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
294
|
+
params.account
|
|
295
|
+
);
|
|
296
|
+
const rawMetadata = await this.aptos.view({
|
|
297
|
+
payload: {
|
|
298
|
+
function: `${this.deployer.toString()}::placement_group::get_serving_storage_providers`,
|
|
299
|
+
functionArguments: [placementGroupAddress]
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
const providers = rawMetadata[0];
|
|
303
|
+
return providers.map(
|
|
304
|
+
(slotProviders) => slotProviders.map((addr) => normalizeAddress(addr))
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
8
308
|
export {
|
|
9
309
|
ShelbyMetadataClient
|
|
10
310
|
};
|
|
@@ -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,53 +106,11 @@ 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;
|
|
113
113
|
}): InputGenerateTransactionPayloadData;
|
|
114
|
-
/**
|
|
115
|
-
* Withdraws funds from a micropayment channel as the sender.
|
|
116
|
-
*
|
|
117
|
-
* @param params.sender - The account that is withdrawing funds.
|
|
118
|
-
* @param params.receiver - The account the channel is configured to send funds to.
|
|
119
|
-
* @param params.fungibleAssetAddress - The account address of the fungible asset.
|
|
120
|
-
* @param params.options - Optional transaction generation options.
|
|
121
|
-
*
|
|
122
|
-
* @returns An object containing the pending transaction.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* const { transaction } = await client.senderWithdraw({
|
|
127
|
-
* sender: sender,
|
|
128
|
-
* receiver: receiver,
|
|
129
|
-
* fungibleAssetAddress: fungibleAssetAddress,
|
|
130
|
-
* });
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
senderWithdraw(params: {
|
|
134
|
-
sender: Account;
|
|
135
|
-
receiver: AccountAddress;
|
|
136
|
-
fungibleAssetAddress: AccountAddress;
|
|
137
|
-
options?: InputGenerateTransactionOptions;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
transaction: PendingTransactionResponse;
|
|
140
|
-
}>;
|
|
141
|
-
/**
|
|
142
|
-
* Creates a static payload for the sender_withdraw Move function.
|
|
143
|
-
* This is a helper method for constructing the transaction payload without signing.
|
|
144
|
-
*
|
|
145
|
-
* @param params.deployer - Optional deployer account address. Defaults to MICROPAYMENTS_DEPLOYER.
|
|
146
|
-
* @param params.receiver - The account address of the receiver.
|
|
147
|
-
* @param params.fungibleAssetAddress - The account address of the fungible asset.
|
|
148
|
-
*
|
|
149
|
-
* @returns An Aptos transaction payload data object for the sender_withdraw Move function.
|
|
150
|
-
*/
|
|
151
|
-
static createSenderWithdrawPayload(params: {
|
|
152
|
-
deployer?: AccountAddress;
|
|
153
|
-
receiver: AccountAddress;
|
|
154
|
-
fungibleAssetAddress: AccountAddress;
|
|
155
|
-
}): InputGenerateTransactionPayloadData;
|
|
156
114
|
/**
|
|
157
115
|
* Creates a micropayment that can be sent to a receiver.
|
|
158
116
|
* The sender signs a WithdrawApproval message that authorizes the receiver
|
|
@@ -183,9 +141,9 @@ declare class ShelbyMicropaymentChannelClient {
|
|
|
183
141
|
sender: Account;
|
|
184
142
|
receiver: AccountAddress;
|
|
185
143
|
fungibleAssetAddress: AccountAddress;
|
|
186
|
-
amount: number;
|
|
187
|
-
paymentChannelId: number;
|
|
188
|
-
sequenceNumber: number;
|
|
144
|
+
amount: number | bigint;
|
|
145
|
+
paymentChannelId: number | bigint;
|
|
146
|
+
sequenceNumber: number | bigint;
|
|
189
147
|
}): SenderBuiltMicropayment;
|
|
190
148
|
/**
|
|
191
149
|
* Creates a static payload for the receiver_withdraw Move function.
|
|
@@ -260,7 +218,7 @@ declare class ShelbyMicropaymentChannelClient {
|
|
|
260
218
|
sender: Account;
|
|
261
219
|
receiver: AccountAddress;
|
|
262
220
|
fungibleAssetAddress: AccountAddress;
|
|
263
|
-
newExpirationMicros: number;
|
|
221
|
+
newExpirationMicros: number | bigint;
|
|
264
222
|
options?: InputGenerateTransactionOptions;
|
|
265
223
|
}): Promise<{
|
|
266
224
|
transaction: PendingTransactionResponse;
|
|
@@ -280,7 +238,7 @@ declare class ShelbyMicropaymentChannelClient {
|
|
|
280
238
|
deployer?: AccountAddress;
|
|
281
239
|
receiver: AccountAddress;
|
|
282
240
|
fungibleAssetAddress: AccountAddress;
|
|
283
|
-
newExpirationMicros: number;
|
|
241
|
+
newExpirationMicros: number | bigint;
|
|
284
242
|
}): InputGenerateTransactionPayloadData;
|
|
285
243
|
/**
|
|
286
244
|
* Increases the deposit amount locked in a micropayment channel.
|