@shelby-protocol/sdk 0.2.4 → 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 +13 -4
- package/dist/browser/index.mjs +3719 -140
- package/dist/{clay-codes-DHP-bYcP.d.ts → clay-codes-DdXABBDx.d.ts} +0 -7
- package/dist/core/aptos-explorer.mjs +46 -5
- package/dist/core/blobs.d.ts +1 -1
- package/dist/core/blobs.mjs +12 -4
- package/dist/core/chunk.mjs +58 -9
- package/dist/core/clients/ShelbyBlobClient.d.ts +9 -44
- 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.d.ts +8 -0
- 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 +107 -4
- package/dist/core/clients/ShelbyRPCClient.mjs +1261 -12
- package/dist/core/clients/index.d.ts +3 -2
- package/dist/core/clients/index.mjs +3421 -40
- package/dist/core/clients/utils.mjs +65 -6
- package/dist/core/commitments.d.ts +3 -12
- package/dist/core/commitments.mjs +270 -11
- package/dist/core/constants.d.ts +4 -4
- package/dist/core/constants.mjs +39 -16
- package/dist/core/erasure/clay-codes.d.ts +1 -1
- package/dist/core/erasure/clay-codes.mjs +129 -4
- package/dist/core/erasure/constants.mjs +33 -10
- package/dist/core/erasure/default.d.ts +1 -1
- package/dist/core/erasure/default.mjs +191 -9
- package/dist/core/erasure/index.d.ts +1 -1
- package/dist/core/erasure/index.mjs +266 -23
- package/dist/core/erasure/provider.d.ts +1 -1
- package/dist/core/erasure/reed-solomon.d.ts +1 -1
- package/dist/core/erasure/reed-solomon.mjs +68 -4
- package/dist/core/erasure/utils.d.ts +1 -1
- package/dist/core/erasure/utils.mjs +0 -2
- package/dist/core/errors.mjs +29 -8
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.mjs +3713 -140
- package/dist/core/layout.d.ts +1 -1
- 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.d.ts +38 -1
- package/dist/core/rpc-responses.mjs +31 -8
- package/dist/core/shelby-explorer.mjs +31 -6
- package/dist/core/strings.mjs +0 -2
- package/dist/core/types/blobs.d.ts +1 -1
- package/dist/core/types/blobs.mjs +0 -1
- package/dist/core/types/index.d.ts +1 -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 +2 -1
- package/dist/node/clients/ShelbyNodeClient.mjs +2919 -24
- package/dist/node/clients/index.d.ts +2 -1
- package/dist/node/clients/index.mjs +2920 -26
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.mjs +3736 -147
- 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 +9 -6
- package/dist/chunk-3NRBHSMQ.mjs +0 -12
- package/dist/chunk-3PCG7PNP.mjs +0 -375
- package/dist/chunk-7OV5ZYW6.mjs +0 -55
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-A4IG6GSE.mjs +0 -21
- package/dist/chunk-AD2G3QYD.mjs +0 -0
- package/dist/chunk-AEDVYYGD.mjs +0 -11
- package/dist/chunk-AUQDI5BS.mjs +0 -43
- package/dist/chunk-BDSW5PHM.mjs +0 -37
- package/dist/chunk-BKL7NCUB.mjs +0 -412
- package/dist/chunk-BUWAD67L.mjs +0 -505
- package/dist/chunk-BXEVML7N.mjs +0 -169
- 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-IE6LYVIA.mjs +0 -26
- package/dist/chunk-IKRWBDG5.mjs +0 -42
- package/dist/chunk-JTXYKO3U.mjs +0 -38
- package/dist/chunk-KYQRWJ3U.mjs +0 -49
- package/dist/chunk-MB7C7VQF.mjs +0 -0
- package/dist/chunk-MQUVYMNQ.mjs +0 -0
- package/dist/chunk-NHWWORCH.mjs +0 -72
- package/dist/chunk-NI6XBZLI.mjs +0 -83
- package/dist/chunk-OGKZ575S.mjs +0 -136
- package/dist/chunk-QQ57OGQ2.mjs +0 -0
- package/dist/chunk-SSE4MFNN.mjs +0 -278
- package/dist/chunk-TET3DJEO.mjs +0 -199
- package/dist/chunk-TVLV7C74.mjs +0 -207
- package/dist/chunk-UEZNZBJO.mjs +0 -104
- package/dist/chunk-WJTVYLKW.mjs +0 -782
- package/dist/chunk-WTICJPDB.mjs +0 -0
- package/dist/chunk-XNEIWM4O.mjs +0 -0
- package/dist/chunk-XRLHLAOW.mjs +0 -51
- package/dist/chunk-Z4FZ7W6L.mjs +0 -39
- package/dist/chunk-Z7RFCADT.mjs +0 -0
- package/dist/chunk-ZHXCVRZX.mjs +0 -0
- package/dist/core/operations/generated/types.d.ts +0 -908
- package/dist/core/operations/generated/types.mjs +0 -63
- package/dist/core/types/encodings.d.ts +0 -11
- package/dist/core/types/encodings.mjs +0 -0
package/dist/chunk-SSE4MFNN.mjs
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAptosConfig
|
|
3
|
-
} from "./chunk-IKRWBDG5.mjs";
|
|
4
|
-
import {
|
|
5
|
-
normalizeAddress
|
|
6
|
-
} from "./chunk-UEZNZBJO.mjs";
|
|
7
|
-
import {
|
|
8
|
-
SHELBY_DEPLOYER
|
|
9
|
-
} from "./chunk-7OV5ZYW6.mjs";
|
|
10
|
-
|
|
11
|
-
// src/core/clients/ShelbyMetadataClient.ts
|
|
12
|
-
import {
|
|
13
|
-
AccountAddress,
|
|
14
|
-
Aptos,
|
|
15
|
-
Hex
|
|
16
|
-
} from "@aptos-labs/ts-sdk";
|
|
17
|
-
function parseStorageProviderState(raw) {
|
|
18
|
-
switch (raw.__variant__) {
|
|
19
|
-
case "Active":
|
|
20
|
-
return {
|
|
21
|
-
variant: "Active",
|
|
22
|
-
quota: raw.quota.value,
|
|
23
|
-
stakeAtStartOfStakingEpoch: raw.stake_at_start_of_staking_epoch,
|
|
24
|
-
faulty: raw.faulty,
|
|
25
|
-
leaving: raw.leaving
|
|
26
|
-
};
|
|
27
|
-
case "Waitlisted":
|
|
28
|
-
return {
|
|
29
|
-
variant: "Waitlisted"
|
|
30
|
-
};
|
|
31
|
-
case "Frozen":
|
|
32
|
-
return {
|
|
33
|
-
variant: "Frozen",
|
|
34
|
-
frozenReason: raw.frozen_reason,
|
|
35
|
-
frozenFrom: raw.frozen_from,
|
|
36
|
-
frozenTill: raw.frozen_till
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
var ShelbyMetadataClient = class {
|
|
41
|
-
aptos;
|
|
42
|
-
deployer;
|
|
43
|
-
/**
|
|
44
|
-
* The ShelbyMetadataClient is used to interact with the Shelby contract on the Aptos blockchain. This
|
|
45
|
-
* includes functions like gathering basic details about the Shelby system, including storage provider information.
|
|
46
|
-
*
|
|
47
|
-
* @param config.aptos.config - The Aptos config.
|
|
48
|
-
* @param config.shelbyDeployer - The deployer account address of the Shelby contract. If not provided, the default deployer address will be used.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));
|
|
53
|
-
* const metadataClient = new ShelbyMetadataClient({ aptos });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
constructor(config) {
|
|
57
|
-
this.aptos = new Aptos(getAptosConfig(config));
|
|
58
|
-
this.deployer = config.deployer ?? AccountAddress.fromString(SHELBY_DEPLOYER);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves storage provider list from the blockchain.
|
|
62
|
-
*
|
|
63
|
-
* @returns A list of storage providers, or empty array if none exist.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const spList = await client.getStorageProviders();
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
async getStorageProviders() {
|
|
71
|
-
try {
|
|
72
|
-
const rawMetadata = await this.aptos.view({
|
|
73
|
-
payload: {
|
|
74
|
-
function: `${this.deployer.toString()}::storage_provider_registry::get_all_storage_providers`,
|
|
75
|
-
functionArguments: []
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const metadata = rawMetadata[0];
|
|
79
|
-
return metadata.map((provider) => ({
|
|
80
|
-
address: normalizeAddress(provider.address),
|
|
81
|
-
ipAddress: provider.ip_address,
|
|
82
|
-
port: provider.port,
|
|
83
|
-
blsPublicKey: Hex.fromHexInput(provider.bls_public_key).toUint8Array(),
|
|
84
|
-
availabilityZone: provider.availability_zone,
|
|
85
|
-
state: parseStorageProviderState(provider.state)
|
|
86
|
-
}));
|
|
87
|
-
} catch (error) {
|
|
88
|
-
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
89
|
-
error.message?.includes("sub_status: Some(404)")) {
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Retrieves the list of placement group addresses.
|
|
97
|
-
*
|
|
98
|
-
* @returns The placement group address list, or an empty array if none exist.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* const pgList = await client.getPlacementGroupAddresses();
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
async getPlacementGroupAddresses() {
|
|
106
|
-
try {
|
|
107
|
-
const pgSizeMetadata = await this.aptos.view({
|
|
108
|
-
payload: {
|
|
109
|
-
function: `${this.deployer.toString()}::placement_group_registry::get_number_of_placement_groups`,
|
|
110
|
-
functionArguments: []
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
const finalPlacementGroupIndex = pgSizeMetadata[0] - 1;
|
|
114
|
-
const addressMetadataArray = await this.aptos.view({
|
|
115
|
-
payload: {
|
|
116
|
-
function: `${this.deployer.toString()}::placement_group_registry::get_placement_group_addresses`,
|
|
117
|
-
functionArguments: [0, finalPlacementGroupIndex]
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
const metadata = addressMetadataArray[0];
|
|
121
|
-
return metadata.map((pg) => normalizeAddress(pg));
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
124
|
-
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_PLACEMENT_GROUP_NOT_FOUND"))) {
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Retrieves the list of slice addresses.
|
|
132
|
-
*
|
|
133
|
-
* @returns The slice group list, or an empty array if none exist.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```typescript
|
|
137
|
-
* const pgList = await client.getSliceAddresses();
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
async getSliceAddresses() {
|
|
141
|
-
try {
|
|
142
|
-
const sliceSizeMetadata = await this.aptos.view({
|
|
143
|
-
payload: {
|
|
144
|
-
function: `${this.deployer.toString()}::slice_registry::get_number_of_slices`,
|
|
145
|
-
functionArguments: []
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
const finalSliceIndex = sliceSizeMetadata[0] - 1;
|
|
149
|
-
const addressMetadataArray = await this.aptos.view({
|
|
150
|
-
payload: {
|
|
151
|
-
function: `${this.deployer.toString()}::slice_registry::get_slice_addresses`,
|
|
152
|
-
functionArguments: [0, finalSliceIndex]
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
const metadata = addressMetadataArray[0];
|
|
156
|
-
return metadata.map((slice) => normalizeAddress(slice));
|
|
157
|
-
} catch (error) {
|
|
158
|
-
if (error instanceof Error && // Depending on the network, the error message may show up differently.
|
|
159
|
-
(error.message?.includes("sub_status: Some(404)") || error.message?.includes("E_SLICE_NOT_FOUND"))) {
|
|
160
|
-
return [];
|
|
161
|
-
}
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
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
|
|
188
|
-
*
|
|
189
|
-
* @param params.account - The address of the slice account.
|
|
190
|
-
* @returns An array where result[i] is the designated SP for slot i, or null if no SP is designated.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```typescript
|
|
194
|
-
* const providers = await client.getDesignatedStorageProvidersForSlice({ account: sliceAddress });
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
async getDesignatedStorageProvidersForSlice(params) {
|
|
198
|
-
const placementGroupAddress = await this.getPlacementGroupAddressForSlice(
|
|
199
|
-
params.account
|
|
200
|
-
);
|
|
201
|
-
const rawMetadata = await this.aptos.view({
|
|
202
|
-
payload: {
|
|
203
|
-
function: `${this.deployer.toString()}::placement_group::get_designated_storage_providers`,
|
|
204
|
-
functionArguments: [placementGroupAddress]
|
|
205
|
-
}
|
|
206
|
-
});
|
|
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
|
-
);
|
|
231
|
-
const rawMetadata = await this.aptos.view({
|
|
232
|
-
payload: {
|
|
233
|
-
function: `${this.deployer.toString()}::placement_group::get_active_storage_providers`,
|
|
234
|
-
functionArguments: [placementGroupAddress]
|
|
235
|
-
}
|
|
236
|
-
});
|
|
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
|
-
}
|
|
268
|
-
});
|
|
269
|
-
const providers = rawMetadata[0];
|
|
270
|
-
return providers.map(
|
|
271
|
-
(slotProviders) => slotProviders.map((addr) => normalizeAddress(addr))
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export {
|
|
277
|
-
ShelbyMetadataClient
|
|
278
|
-
};
|
package/dist/chunk-TET3DJEO.mjs
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// src/core/operations/generated/sdk.ts
|
|
2
|
-
import gql from "graphql-tag";
|
|
3
|
-
var Blob_Activities_Select_Column = /* @__PURE__ */ ((Blob_Activities_Select_Column2) => {
|
|
4
|
-
Blob_Activities_Select_Column2["BlobName"] = "blob_name";
|
|
5
|
-
Blob_Activities_Select_Column2["EventIndex"] = "event_index";
|
|
6
|
-
Blob_Activities_Select_Column2["EventType"] = "event_type";
|
|
7
|
-
Blob_Activities_Select_Column2["Timestamp"] = "timestamp";
|
|
8
|
-
Blob_Activities_Select_Column2["TransactionHash"] = "transaction_hash";
|
|
9
|
-
Blob_Activities_Select_Column2["TransactionVersion"] = "transaction_version";
|
|
10
|
-
return Blob_Activities_Select_Column2;
|
|
11
|
-
})(Blob_Activities_Select_Column || {});
|
|
12
|
-
var Blobs_Select_Column = /* @__PURE__ */ ((Blobs_Select_Column2) => {
|
|
13
|
-
Blobs_Select_Column2["BlobCommitment"] = "blob_commitment";
|
|
14
|
-
Blobs_Select_Column2["BlobName"] = "blob_name";
|
|
15
|
-
Blobs_Select_Column2["CreatedAt"] = "created_at";
|
|
16
|
-
Blobs_Select_Column2["ExpiresAt"] = "expires_at";
|
|
17
|
-
Blobs_Select_Column2["IsDeleted"] = "is_deleted";
|
|
18
|
-
Blobs_Select_Column2["IsWritten"] = "is_written";
|
|
19
|
-
Blobs_Select_Column2["NumChunksets"] = "num_chunksets";
|
|
20
|
-
Blobs_Select_Column2["Owner"] = "owner";
|
|
21
|
-
Blobs_Select_Column2["PlacementGroup"] = "placement_group";
|
|
22
|
-
Blobs_Select_Column2["Size"] = "size";
|
|
23
|
-
Blobs_Select_Column2["SliceAddress"] = "slice_address";
|
|
24
|
-
Blobs_Select_Column2["UpdatedAt"] = "updated_at";
|
|
25
|
-
return Blobs_Select_Column2;
|
|
26
|
-
})(Blobs_Select_Column || {});
|
|
27
|
-
var Cursor_Ordering = /* @__PURE__ */ ((Cursor_Ordering2) => {
|
|
28
|
-
Cursor_Ordering2["Asc"] = "ASC";
|
|
29
|
-
Cursor_Ordering2["Desc"] = "DESC";
|
|
30
|
-
return Cursor_Ordering2;
|
|
31
|
-
})(Cursor_Ordering || {});
|
|
32
|
-
var Order_By = /* @__PURE__ */ ((Order_By2) => {
|
|
33
|
-
Order_By2["Asc"] = "asc";
|
|
34
|
-
Order_By2["AscNullsFirst"] = "asc_nulls_first";
|
|
35
|
-
Order_By2["AscNullsLast"] = "asc_nulls_last";
|
|
36
|
-
Order_By2["Desc"] = "desc";
|
|
37
|
-
Order_By2["DescNullsFirst"] = "desc_nulls_first";
|
|
38
|
-
Order_By2["DescNullsLast"] = "desc_nulls_last";
|
|
39
|
-
return Order_By2;
|
|
40
|
-
})(Order_By || {});
|
|
41
|
-
var Placement_Group_Slots_Select_Column = /* @__PURE__ */ ((Placement_Group_Slots_Select_Column2) => {
|
|
42
|
-
Placement_Group_Slots_Select_Column2["PlacementGroup"] = "placement_group";
|
|
43
|
-
Placement_Group_Slots_Select_Column2["SlotIndex"] = "slot_index";
|
|
44
|
-
Placement_Group_Slots_Select_Column2["Status"] = "status";
|
|
45
|
-
Placement_Group_Slots_Select_Column2["StorageProvider"] = "storage_provider";
|
|
46
|
-
Placement_Group_Slots_Select_Column2["UpdatedAt"] = "updated_at";
|
|
47
|
-
return Placement_Group_Slots_Select_Column2;
|
|
48
|
-
})(Placement_Group_Slots_Select_Column || {});
|
|
49
|
-
var Processor_Status_Select_Column = /* @__PURE__ */ ((Processor_Status_Select_Column2) => {
|
|
50
|
-
Processor_Status_Select_Column2["LastSuccessVersion"] = "last_success_version";
|
|
51
|
-
Processor_Status_Select_Column2["LastTransactionTimestamp"] = "last_transaction_timestamp";
|
|
52
|
-
Processor_Status_Select_Column2["LastUpdated"] = "last_updated";
|
|
53
|
-
return Processor_Status_Select_Column2;
|
|
54
|
-
})(Processor_Status_Select_Column || {});
|
|
55
|
-
var GetBlobsDocument = gql`
|
|
56
|
-
query getBlobs($where: blobs_bool_exp, $orderBy: [blobs_order_by!], $limit: Int, $offset: Int) {
|
|
57
|
-
blobs(where: $where, order_by: $orderBy, limit: $limit, offset: $offset) {
|
|
58
|
-
owner
|
|
59
|
-
blob_commitment
|
|
60
|
-
blob_name
|
|
61
|
-
created_at
|
|
62
|
-
expires_at
|
|
63
|
-
num_chunksets
|
|
64
|
-
is_deleted
|
|
65
|
-
is_written
|
|
66
|
-
placement_group
|
|
67
|
-
size
|
|
68
|
-
updated_at
|
|
69
|
-
slice_address
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
var GetBlobActivitiesDocument = gql`
|
|
74
|
-
query getBlobActivities($where: blob_activities_bool_exp, $orderBy: [blob_activities_order_by!], $limit: Int, $offset: Int) {
|
|
75
|
-
blob_activities(
|
|
76
|
-
where: $where
|
|
77
|
-
order_by: $orderBy
|
|
78
|
-
limit: $limit
|
|
79
|
-
offset: $offset
|
|
80
|
-
) {
|
|
81
|
-
blob_name
|
|
82
|
-
event_index
|
|
83
|
-
event_type
|
|
84
|
-
transaction_hash
|
|
85
|
-
transaction_version
|
|
86
|
-
timestamp
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
var GetBlobsCountDocument = gql`
|
|
91
|
-
query getBlobsCount($where: blobs_bool_exp) {
|
|
92
|
-
blobs_aggregate(where: $where) {
|
|
93
|
-
aggregate {
|
|
94
|
-
count
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
var GetBlobActivitiesCountDocument = gql`
|
|
100
|
-
query getBlobActivitiesCount($where: blob_activities_bool_exp) {
|
|
101
|
-
blob_activities_aggregate(where: $where) {
|
|
102
|
-
aggregate {
|
|
103
|
-
count
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
var GetTotalBlobsSizeDocument = gql`
|
|
109
|
-
query getTotalBlobsSize($where: blobs_bool_exp) {
|
|
110
|
-
blobs_aggregate(where: $where) {
|
|
111
|
-
aggregate {
|
|
112
|
-
sum {
|
|
113
|
-
size
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
var GetPlacementGroupSlotsDocument = gql`
|
|
120
|
-
query getPlacementGroupSlots($where: placement_group_slots_bool_exp, $orderBy: [placement_group_slots_order_by!], $limit: Int, $offset: Int) {
|
|
121
|
-
placement_group_slots(
|
|
122
|
-
where: $where
|
|
123
|
-
order_by: $orderBy
|
|
124
|
-
limit: $limit
|
|
125
|
-
offset: $offset
|
|
126
|
-
) {
|
|
127
|
-
placement_group
|
|
128
|
-
slot_index
|
|
129
|
-
storage_provider
|
|
130
|
-
status
|
|
131
|
-
updated_at
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`;
|
|
135
|
-
var GetPlacementGroupSlotsCountDocument = gql`
|
|
136
|
-
query getPlacementGroupSlotsCount($where: placement_group_slots_bool_exp) {
|
|
137
|
-
placement_group_slots_aggregate(where: $where) {
|
|
138
|
-
aggregate {
|
|
139
|
-
count
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
var GetProcessorStatusDocument = gql`
|
|
145
|
-
query getProcessorStatus {
|
|
146
|
-
processor_status {
|
|
147
|
-
last_success_version
|
|
148
|
-
last_transaction_timestamp
|
|
149
|
-
last_updated
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
`;
|
|
153
|
-
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
154
|
-
function getSdk(client, withWrapper = defaultWrapper) {
|
|
155
|
-
return {
|
|
156
|
-
getBlobs(variables, requestHeaders, signal) {
|
|
157
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobs", "query", variables);
|
|
158
|
-
},
|
|
159
|
-
getBlobActivities(variables, requestHeaders, signal) {
|
|
160
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivities", "query", variables);
|
|
161
|
-
},
|
|
162
|
-
getBlobsCount(variables, requestHeaders, signal) {
|
|
163
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobsCount", "query", variables);
|
|
164
|
-
},
|
|
165
|
-
getBlobActivitiesCount(variables, requestHeaders, signal) {
|
|
166
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBlobActivitiesCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getBlobActivitiesCount", "query", variables);
|
|
167
|
-
},
|
|
168
|
-
getTotalBlobsSize(variables, requestHeaders, signal) {
|
|
169
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetTotalBlobsSizeDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getTotalBlobsSize", "query", variables);
|
|
170
|
-
},
|
|
171
|
-
getPlacementGroupSlots(variables, requestHeaders, signal) {
|
|
172
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlots", "query", variables);
|
|
173
|
-
},
|
|
174
|
-
getPlacementGroupSlotsCount(variables, requestHeaders, signal) {
|
|
175
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPlacementGroupSlotsCountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getPlacementGroupSlotsCount", "query", variables);
|
|
176
|
-
},
|
|
177
|
-
getProcessorStatus(variables, requestHeaders, signal) {
|
|
178
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetProcessorStatusDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "getProcessorStatus", "query", variables);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export {
|
|
184
|
-
Blob_Activities_Select_Column,
|
|
185
|
-
Blobs_Select_Column,
|
|
186
|
-
Cursor_Ordering,
|
|
187
|
-
Order_By,
|
|
188
|
-
Placement_Group_Slots_Select_Column,
|
|
189
|
-
Processor_Status_Select_Column,
|
|
190
|
-
GetBlobsDocument,
|
|
191
|
-
GetBlobActivitiesDocument,
|
|
192
|
-
GetBlobsCountDocument,
|
|
193
|
-
GetBlobActivitiesCountDocument,
|
|
194
|
-
GetTotalBlobsSizeDocument,
|
|
195
|
-
GetPlacementGroupSlotsDocument,
|
|
196
|
-
GetPlacementGroupSlotsCountDocument,
|
|
197
|
-
GetProcessorStatusDocument,
|
|
198
|
-
getSdk
|
|
199
|
-
};
|
package/dist/chunk-TVLV7C74.mjs
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MICROPAYMENTS_DEPLOYER
|
|
3
|
-
} from "./chunk-7OV5ZYW6.mjs";
|
|
4
|
-
|
|
5
|
-
// src/core/types/payments.ts
|
|
6
|
-
import {
|
|
7
|
-
AccountAddress,
|
|
8
|
-
Deserializer,
|
|
9
|
-
Hex,
|
|
10
|
-
Serializer
|
|
11
|
-
} from "@aptos-labs/ts-sdk";
|
|
12
|
-
var MICROPAYMENTS_MODULE_NAME = "micropayments";
|
|
13
|
-
var WITHDRAW_APPROVAL_STRUCT_NAME = "WithdrawApproval";
|
|
14
|
-
function serializeTypeInfo(serializer, moduleAddress, moduleName, structName) {
|
|
15
|
-
moduleAddress.serialize(serializer);
|
|
16
|
-
const moduleNameBytes = new TextEncoder().encode(moduleName);
|
|
17
|
-
serializer.serializeBytes(moduleNameBytes);
|
|
18
|
-
const structNameBytes = new TextEncoder().encode(structName);
|
|
19
|
-
serializer.serializeBytes(structNameBytes);
|
|
20
|
-
}
|
|
21
|
-
var StaleChannelStateError = class _StaleChannelStateError extends Error {
|
|
22
|
-
/**
|
|
23
|
-
* The last valid micropayment stored by the server.
|
|
24
|
-
* Clients can use this to reset their local channel state.
|
|
25
|
-
*/
|
|
26
|
-
storedMicropayment;
|
|
27
|
-
constructor(storedMicropayment, message) {
|
|
28
|
-
super(
|
|
29
|
-
message ?? "Client has stale channel state. Use the returned micropayment to reset local state."
|
|
30
|
-
);
|
|
31
|
-
this.name = "StaleChannelStateError";
|
|
32
|
-
this.storedMicropayment = storedMicropayment;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Returns the stored micropayment as a base64-encoded string.
|
|
36
|
-
*/
|
|
37
|
-
toBase64() {
|
|
38
|
-
const bytes = this.storedMicropayment.bcsToBytes();
|
|
39
|
-
const binaryString = Array.from(
|
|
40
|
-
bytes,
|
|
41
|
-
(byte) => String.fromCharCode(byte)
|
|
42
|
-
).join("");
|
|
43
|
-
return btoa(binaryString);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a StaleChannelStateError from a base64-encoded micropayment string.
|
|
47
|
-
*/
|
|
48
|
-
static fromBase64(base64, message) {
|
|
49
|
-
const binaryString = atob(base64);
|
|
50
|
-
const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
|
|
51
|
-
const micropayment = SenderBuiltMicropayment.deserialize(bytes);
|
|
52
|
-
return new _StaleChannelStateError(micropayment, message);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var SenderBuiltMicropayment = class _SenderBuiltMicropayment {
|
|
56
|
-
/**
|
|
57
|
-
* The sender's address (owner of the payment channel).
|
|
58
|
-
*/
|
|
59
|
-
sender;
|
|
60
|
-
/**
|
|
61
|
-
* The receiver's address (beneficiary of the withdrawal).
|
|
62
|
-
*/
|
|
63
|
-
receiver;
|
|
64
|
-
/**
|
|
65
|
-
* The unique ID of the payment channel.
|
|
66
|
-
*/
|
|
67
|
-
paymentChannelId;
|
|
68
|
-
/**
|
|
69
|
-
* The cumulative amount the receiver is authorized to withdraw.
|
|
70
|
-
*/
|
|
71
|
-
amount;
|
|
72
|
-
/**
|
|
73
|
-
* The fungible asset metadata address.
|
|
74
|
-
*/
|
|
75
|
-
fungibleAssetAddress;
|
|
76
|
-
/**
|
|
77
|
-
* Monotonically increasing sequence number for replay protection.
|
|
78
|
-
*/
|
|
79
|
-
sequenceNumber;
|
|
80
|
-
/**
|
|
81
|
-
* The sender's Ed25519 public key (32 bytes).
|
|
82
|
-
* Used by the receiver to verify the signature before submitting.
|
|
83
|
-
*/
|
|
84
|
-
publicKey;
|
|
85
|
-
/**
|
|
86
|
-
* The Ed25519 signature of the SignedMessage<WithdrawApproval> struct.
|
|
87
|
-
* The SignedMessage includes TypeInfo for domain separation.
|
|
88
|
-
*/
|
|
89
|
-
signature;
|
|
90
|
-
/**
|
|
91
|
-
* The deployer address of the micropayments module.
|
|
92
|
-
* This is needed to reconstruct the TypeInfo for signature verification.
|
|
93
|
-
*/
|
|
94
|
-
deployer;
|
|
95
|
-
constructor(sender, receiver, paymentChannelId, amount, fungibleAssetAddress, sequenceNumber, publicKey, signature, deployer) {
|
|
96
|
-
this.sender = sender;
|
|
97
|
-
this.receiver = receiver;
|
|
98
|
-
this.paymentChannelId = paymentChannelId;
|
|
99
|
-
this.amount = amount;
|
|
100
|
-
this.fungibleAssetAddress = fungibleAssetAddress;
|
|
101
|
-
this.sequenceNumber = sequenceNumber;
|
|
102
|
-
this.publicKey = publicKey;
|
|
103
|
-
this.signature = signature;
|
|
104
|
-
this.deployer = deployer ?? AccountAddress.fromString(MICROPAYMENTS_DEPLOYER);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates the BCS-serialized message that was signed.
|
|
108
|
-
* This is a SignedMessage<WithdrawApproval> which includes:
|
|
109
|
-
* 1. TypeInfo (module_address, module_name, struct_name)
|
|
110
|
-
* 2. WithdrawApproval struct fields
|
|
111
|
-
*
|
|
112
|
-
* This format is used with signature_verify_strict_t for domain separation.
|
|
113
|
-
*/
|
|
114
|
-
getSignedMessage() {
|
|
115
|
-
return _SenderBuiltMicropayment.buildSignedMessage({
|
|
116
|
-
deployer: this.deployer,
|
|
117
|
-
sender: this.sender,
|
|
118
|
-
receiver: this.receiver,
|
|
119
|
-
fungibleAssetAddress: this.fungibleAssetAddress,
|
|
120
|
-
amount: this.amount,
|
|
121
|
-
paymentChannelId: this.paymentChannelId,
|
|
122
|
-
sequenceNumber: this.sequenceNumber
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Static helper to build the SignedMessage<WithdrawApproval> bytes from raw parameters.
|
|
127
|
-
* This can be used to create the message for signing without constructing the full object.
|
|
128
|
-
*
|
|
129
|
-
* @param params - The withdrawal approval parameters.
|
|
130
|
-
* @returns The BCS-serialized SignedMessage<WithdrawApproval> bytes.
|
|
131
|
-
*/
|
|
132
|
-
static buildSignedMessage(params) {
|
|
133
|
-
const serializer = new Serializer();
|
|
134
|
-
serializeTypeInfo(
|
|
135
|
-
serializer,
|
|
136
|
-
params.deployer,
|
|
137
|
-
MICROPAYMENTS_MODULE_NAME,
|
|
138
|
-
WITHDRAW_APPROVAL_STRUCT_NAME
|
|
139
|
-
);
|
|
140
|
-
params.sender.serialize(serializer);
|
|
141
|
-
params.receiver.serialize(serializer);
|
|
142
|
-
params.fungibleAssetAddress.serialize(serializer);
|
|
143
|
-
serializer.serializeU64(params.amount);
|
|
144
|
-
serializer.serializeU64(params.paymentChannelId);
|
|
145
|
-
serializer.serializeU64(params.sequenceNumber);
|
|
146
|
-
return serializer.toUint8Array();
|
|
147
|
-
}
|
|
148
|
-
serialize(serializer) {
|
|
149
|
-
this.sender.serialize(serializer);
|
|
150
|
-
this.receiver.serialize(serializer);
|
|
151
|
-
this.fungibleAssetAddress.serialize(serializer);
|
|
152
|
-
serializer.serializeU64(this.amount);
|
|
153
|
-
serializer.serializeU64(this.paymentChannelId);
|
|
154
|
-
serializer.serializeU64(this.sequenceNumber);
|
|
155
|
-
serializer.serializeBytes(this.publicKey);
|
|
156
|
-
serializer.serializeBytes(this.signature);
|
|
157
|
-
this.deployer.serialize(serializer);
|
|
158
|
-
}
|
|
159
|
-
bcsToBytes() {
|
|
160
|
-
const serializer = new Serializer();
|
|
161
|
-
this.serialize(serializer);
|
|
162
|
-
return serializer.toUint8Array();
|
|
163
|
-
}
|
|
164
|
-
bcsToHex() {
|
|
165
|
-
return Hex.fromHexInput(this.bcsToBytes());
|
|
166
|
-
}
|
|
167
|
-
toStringWithoutPrefix() {
|
|
168
|
-
return this.bcsToHex().toStringWithoutPrefix();
|
|
169
|
-
}
|
|
170
|
-
toString() {
|
|
171
|
-
return this.bcsToHex().toString();
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Deserializes a SenderBuiltMicropayment from BCS bytes.
|
|
175
|
-
* @param bytes - The bytes to deserialize from (Uint8Array or hex string).
|
|
176
|
-
* @returns A new SenderBuiltMicropayment instance.
|
|
177
|
-
*/
|
|
178
|
-
static deserialize(bytes) {
|
|
179
|
-
const bytesArray = typeof bytes === "string" ? Hex.fromHexInput(bytes).toUint8Array() : bytes;
|
|
180
|
-
const deserializer = new Deserializer(bytesArray);
|
|
181
|
-
const sender = AccountAddress.deserialize(deserializer);
|
|
182
|
-
const receiver = AccountAddress.deserialize(deserializer);
|
|
183
|
-
const fungibleAssetAddress = AccountAddress.deserialize(deserializer);
|
|
184
|
-
const amount = deserializer.deserializeU64();
|
|
185
|
-
const paymentChannelId = deserializer.deserializeU64();
|
|
186
|
-
const sequenceNumber = deserializer.deserializeU64();
|
|
187
|
-
const publicKey = deserializer.deserializeBytes();
|
|
188
|
-
const signature = deserializer.deserializeBytes();
|
|
189
|
-
const deployer = AccountAddress.deserialize(deserializer);
|
|
190
|
-
return new _SenderBuiltMicropayment(
|
|
191
|
-
sender,
|
|
192
|
-
receiver,
|
|
193
|
-
paymentChannelId,
|
|
194
|
-
amount,
|
|
195
|
-
fungibleAssetAddress,
|
|
196
|
-
sequenceNumber,
|
|
197
|
-
publicKey,
|
|
198
|
-
signature,
|
|
199
|
-
deployer
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export {
|
|
205
|
-
StaleChannelStateError,
|
|
206
|
-
SenderBuiltMicropayment
|
|
207
|
-
};
|