@autonomys/auto-consensus 1.5.1 → 1.5.3
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/account.d.ts +26 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/account.js +26 -0
- package/dist/balances.d.ts +50 -0
- package/dist/balances.d.ts.map +1 -1
- package/dist/balances.js +50 -0
- package/dist/batch.d.ts +29 -0
- package/dist/batch.d.ts.map +1 -1
- package/dist/batch.js +29 -0
- package/dist/domain.d.ts +58 -1
- package/dist/domain.d.ts.map +1 -1
- package/dist/domain.js +116 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/info.d.ts +406 -0
- package/dist/info.d.ts.map +1 -1
- package/dist/info.js +406 -0
- package/dist/position/index.d.ts +42 -0
- package/dist/position/index.d.ts.map +1 -0
- package/dist/position/index.js +170 -0
- package/dist/position/price.d.ts +69 -0
- package/dist/position/price.d.ts.map +1 -0
- package/dist/position/price.js +137 -0
- package/dist/position/utils.d.ts +62 -0
- package/dist/position/utils.d.ts.map +1 -0
- package/dist/position/utils.js +73 -0
- package/dist/position.d.ts +4 -0
- package/dist/position.d.ts.map +1 -0
- package/dist/position.js +20 -0
- package/dist/remark.d.ts +29 -0
- package/dist/remark.d.ts.map +1 -1
- package/dist/remark.js +29 -0
- package/dist/staking.d.ts +305 -0
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +327 -4
- package/dist/transfer.d.ts +59 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +59 -0
- package/dist/types/domain.d.ts +1 -0
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/position.d.ts +13 -0
- package/dist/types/position.d.ts.map +1 -0
- package/dist/types/position.js +2 -0
- package/dist/types/staking.d.ts +2 -2
- package/dist/types/staking.d.ts.map +1 -1
- package/dist/utils/format.d.ts +86 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +86 -0
- package/dist/utils/parse.d.ts +1 -1
- package/dist/utils/parse.d.ts.map +1 -1
- package/dist/utils/parse.js +5 -3
- package/dist/utils/query.d.ts +31 -0
- package/dist/utils/query.d.ts.map +1 -1
- package/dist/utils/query.js +31 -0
- package/dist/utils/sudo.d.ts +36 -0
- package/dist/utils/sudo.d.ts.map +1 -1
- package/dist/utils/sudo.js +36 -0
- package/package.json +3 -3
package/dist/info.d.ts
CHANGED
|
@@ -1,26 +1,432 @@
|
|
|
1
1
|
import type { AnyTuple, Api, BlockHash, Codec, Header, SignedBlock, StorageKey } from '@autonomys/auto-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Executes an RPC call on the blockchain API.
|
|
4
|
+
*
|
|
5
|
+
* This is a generic function that allows calling any RPC method available on the blockchain API.
|
|
6
|
+
* RPC calls are remote procedure calls that interact with the blockchain node.
|
|
7
|
+
*
|
|
8
|
+
* @param api - The connected API instance
|
|
9
|
+
* @param methodPath - The RPC method path (e.g., 'chain.getHeader', 'system.health')
|
|
10
|
+
* @param params - Array of parameters to pass to the RPC method
|
|
11
|
+
* @returns Promise that resolves to the RPC call result
|
|
12
|
+
* @throws Error if the RPC call fails or method path is invalid
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { rpc } from '@autonomys/auto-consensus'
|
|
17
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
18
|
+
*
|
|
19
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
20
|
+
* const header = await rpc(api, 'chain.getHeader', [])
|
|
21
|
+
* const health = await rpc(api, 'system.health', [])
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
2
24
|
export declare const rpc: <T>(api: Api, methodPath: string, params?: any[]) => Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Executes a storage query on the blockchain API.
|
|
27
|
+
*
|
|
28
|
+
* This is a generic function that allows querying any storage item available on the blockchain.
|
|
29
|
+
* Storage queries retrieve data that is stored on-chain in the blockchain's state.
|
|
30
|
+
*
|
|
31
|
+
* @param api - The connected API instance
|
|
32
|
+
* @param methodPath - The storage query path (e.g., 'system.account', 'balances.totalIssuance')
|
|
33
|
+
* @param params - Array of parameters to pass to the storage query
|
|
34
|
+
* @returns Promise that resolves to the storage query result
|
|
35
|
+
* @throws Error if the storage query fails or method path is invalid
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { query } from '@autonomys/auto-consensus'
|
|
40
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
41
|
+
*
|
|
42
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
43
|
+
* const totalIssuance = await query(api, 'balances.totalIssuance', [])
|
|
44
|
+
* const accountData = await query(api, 'system.account', ['5GrwvaEF5z...'])
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
3
47
|
export declare const query: <T>(api: Api, methodPath: string, params?: any[]) => Promise<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves the header information of the latest block.
|
|
50
|
+
*
|
|
51
|
+
* The block header contains metadata about a block including its number, parent hash,
|
|
52
|
+
* state root, and extrinsics root. This function gets the header of the current latest block.
|
|
53
|
+
*
|
|
54
|
+
* @param api - The connected API instance
|
|
55
|
+
* @returns Promise that resolves to the block Header
|
|
56
|
+
* @throws Error if the header query fails
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { header } from '@autonomys/auto-consensus'
|
|
61
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
62
|
+
*
|
|
63
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
64
|
+
* const blockHeader = await header(api)
|
|
65
|
+
* console.log(`Block number: ${blockHeader.number}`)
|
|
66
|
+
* console.log(`Parent hash: ${blockHeader.parentHash}`)
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
4
69
|
export declare const header: (api: Api) => Promise<Header>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves a complete block including its extrinsics.
|
|
72
|
+
*
|
|
73
|
+
* This function fetches a full block with all its transaction data (extrinsics).
|
|
74
|
+
* If no block hash is provided, it returns the latest block.
|
|
75
|
+
*
|
|
76
|
+
* @param api - The connected API instance
|
|
77
|
+
* @param blockHash - Optional block hash to fetch a specific block
|
|
78
|
+
* @returns Promise that resolves to a SignedBlock containing all block data
|
|
79
|
+
* @throws Error if the block query fails
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { block } from '@autonomys/auto-consensus'
|
|
84
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
85
|
+
*
|
|
86
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
87
|
+
*
|
|
88
|
+
* // Get latest block
|
|
89
|
+
* const latestBlock = await block(api)
|
|
90
|
+
*
|
|
91
|
+
* // Get specific block by hash
|
|
92
|
+
* const specificBlock = await block(api, '0x1234...')
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
5
95
|
export declare const block: (api: Api, blockHash?: string) => Promise<SignedBlock>;
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves and parses all extrinsics from a block.
|
|
98
|
+
*
|
|
99
|
+
* Extrinsics are transactions or operations that modify the blockchain state.
|
|
100
|
+
* This function fetches a block and extracts all extrinsics in a parsed format
|
|
101
|
+
* for easier consumption.
|
|
102
|
+
*
|
|
103
|
+
* @param api - The connected API instance
|
|
104
|
+
* @param blockHash - Optional block hash to fetch extrinsics from a specific block
|
|
105
|
+
* @returns Promise that resolves to an array of parsed Extrinsic objects
|
|
106
|
+
* @throws Error if the block query or parsing fails
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* import { blockExtrinsics } from '@autonomys/auto-consensus'
|
|
111
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
112
|
+
*
|
|
113
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
114
|
+
* const extrinsics = await blockExtrinsics(api)
|
|
115
|
+
*
|
|
116
|
+
* extrinsics.forEach(ext => {
|
|
117
|
+
* console.log(`${ext.section}.${ext.method} by ${ext.signer}`)
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
6
121
|
export declare const blockExtrinsics: (api: Api, blockHash?: string) => Promise<import("./types").Extrinsic[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Retrieves and parses all transfer-related extrinsics from a block.
|
|
124
|
+
*
|
|
125
|
+
* This function filters extrinsics to only include those related to token transfers,
|
|
126
|
+
* such as balance transfers and cross-chain transfers. It's useful for tracking
|
|
127
|
+
* token movement within a specific block.
|
|
128
|
+
*
|
|
129
|
+
* @param api - The connected API instance
|
|
130
|
+
* @param blockHash - Optional block hash to fetch transfers from a specific block
|
|
131
|
+
* @returns Promise that resolves to an array of transfer Extrinsic objects
|
|
132
|
+
* @throws Error if the block query or parsing fails
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import { blockTransfers } from '@autonomys/auto-consensus'
|
|
137
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
138
|
+
*
|
|
139
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
140
|
+
* const transfers = await blockTransfers(api)
|
|
141
|
+
*
|
|
142
|
+
* console.log(`Found ${transfers.length} transfers in latest block`)
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
7
145
|
export declare const blockTransfers: (api: Api, blockHash?: string) => Promise<import("./types").Extrinsic[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves the current block number.
|
|
148
|
+
*
|
|
149
|
+
* This function gets the block number of the latest block on the blockchain.
|
|
150
|
+
* Block numbers increment sequentially as new blocks are produced.
|
|
151
|
+
*
|
|
152
|
+
* @param api - The connected API instance
|
|
153
|
+
* @returns Promise that resolves to the current block number as a number
|
|
154
|
+
* @throws Error if the block query fails
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* import { blockNumber } from '@autonomys/auto-consensus'
|
|
159
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
160
|
+
*
|
|
161
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
162
|
+
* const currentBlock = await blockNumber(api)
|
|
163
|
+
* console.log(`Current block: ${currentBlock}`)
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
8
166
|
export declare const blockNumber: (api: Api) => Promise<number>;
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the hash of a block.
|
|
169
|
+
*
|
|
170
|
+
* This function gets the hash of a specific block by its number, or the latest
|
|
171
|
+
* block hash if no block number is provided. Block hashes are unique identifiers
|
|
172
|
+
* for each block.
|
|
173
|
+
*
|
|
174
|
+
* @param api - The connected API instance
|
|
175
|
+
* @param blockNumber - Optional block number to get hash for specific block
|
|
176
|
+
* @returns Promise that resolves to the block hash as a hex string
|
|
177
|
+
* @throws Error if the block hash query fails
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* import { blockHash } from '@autonomys/auto-consensus'
|
|
182
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
183
|
+
*
|
|
184
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
185
|
+
*
|
|
186
|
+
* // Get latest block hash
|
|
187
|
+
* const latestHash = await blockHash(api)
|
|
188
|
+
*
|
|
189
|
+
* // Get hash of specific block
|
|
190
|
+
* const specificHash = await blockHash(api, 1000)
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
9
193
|
export declare const blockHash: (api: Api, blockNumber?: number) => Promise<string>;
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves the hash of the finalized head block.
|
|
196
|
+
*
|
|
197
|
+
* The finalized head is the latest block that has been finalized by the consensus
|
|
198
|
+
* mechanism and is considered irreversible. This provides the hash of that block.
|
|
199
|
+
*
|
|
200
|
+
* @param api - The connected API instance
|
|
201
|
+
* @returns Promise that resolves to the finalized head block hash
|
|
202
|
+
* @throws Error if the finalized head query fails
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* import { finalizedHead } from '@autonomys/auto-consensus'
|
|
207
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
208
|
+
*
|
|
209
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
210
|
+
* const finalizedHash = await finalizedHead(api)
|
|
211
|
+
* console.log(`Finalized block hash: ${finalizedHash}`)
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
10
214
|
export declare const finalizedHead: (api: Api) => Promise<BlockHash>;
|
|
215
|
+
/**
|
|
216
|
+
* Retrieves the current network timestamp.
|
|
217
|
+
*
|
|
218
|
+
* This function gets the timestamp of the current block, which represents
|
|
219
|
+
* the time when the block was produced. The timestamp is set by block producers
|
|
220
|
+
* and represents network time.
|
|
221
|
+
*
|
|
222
|
+
* @param api - The connected API instance
|
|
223
|
+
* @returns Promise that resolves to the network timestamp as a Codec
|
|
224
|
+
* @throws Error if the timestamp query fails
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* import { networkTimestamp } from '@autonomys/auto-consensus'
|
|
229
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
230
|
+
*
|
|
231
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
232
|
+
* const timestamp = await networkTimestamp(api)
|
|
233
|
+
* const networkTime = new Date(Number(timestamp.toString()))
|
|
234
|
+
* console.log(`Network time: ${networkTime}`)
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
11
237
|
export declare const networkTimestamp: (api: Api) => Promise<Codec>;
|
|
238
|
+
/**
|
|
239
|
+
* Retrieves the current solution ranges for the consensus mechanism.
|
|
240
|
+
*
|
|
241
|
+
* Solution ranges are used in the Proof of Archival Storage consensus to determine
|
|
242
|
+
* the difficulty of finding valid solutions. This includes current and next solution
|
|
243
|
+
* ranges for both regular consensus and voting.
|
|
244
|
+
*
|
|
245
|
+
* @param api - The connected API instance
|
|
246
|
+
* @returns Promise that resolves to solution ranges object with current/next values
|
|
247
|
+
* @throws Error if the solution ranges query fails
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* import { solutionRanges } from '@autonomys/auto-consensus'
|
|
252
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
253
|
+
*
|
|
254
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
255
|
+
* const ranges = await solutionRanges(api)
|
|
256
|
+
* console.log(`Current solution range: ${ranges.current}`)
|
|
257
|
+
* console.log(`Next solution range: ${ranges.next}`)
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
12
260
|
export declare const solutionRanges: (api: Api) => Promise<{
|
|
13
261
|
current: bigint | null;
|
|
14
262
|
next: bigint | null;
|
|
15
263
|
votingCurrent: bigint | null;
|
|
16
264
|
votingNext: bigint | null;
|
|
17
265
|
}>;
|
|
266
|
+
/**
|
|
267
|
+
* Checks if the solution range should be adjusted.
|
|
268
|
+
*
|
|
269
|
+
* This function queries whether the consensus mechanism has determined that
|
|
270
|
+
* the solution range needs to be adjusted based on network conditions.
|
|
271
|
+
*
|
|
272
|
+
* @param api - The connected API instance
|
|
273
|
+
* @returns Promise that resolves to boolean indicating if adjustment is needed
|
|
274
|
+
* @throws Error if the query fails
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* import { shouldAdjustSolutionRange } from '@autonomys/auto-consensus'
|
|
279
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
280
|
+
*
|
|
281
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
282
|
+
* const shouldAdjust = await shouldAdjustSolutionRange(api)
|
|
283
|
+
* console.log(`Solution range adjustment needed: ${shouldAdjust}`)
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
18
286
|
export declare const shouldAdjustSolutionRange: (api: Api) => Promise<boolean>;
|
|
287
|
+
/**
|
|
288
|
+
* Retrieves segment commitment information.
|
|
289
|
+
*
|
|
290
|
+
* Segment commitments are cryptographic commitments to data segments in the
|
|
291
|
+
* Autonomys network's decentralized storage system. This function retrieves
|
|
292
|
+
* all current segment commitments.
|
|
293
|
+
*
|
|
294
|
+
* @param api - The connected API instance
|
|
295
|
+
* @returns Promise that resolves to array of segment commitment entries
|
|
296
|
+
* @throws Error if the segment commitment query fails
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* import { segmentCommitment } from '@autonomys/auto-consensus'
|
|
301
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
302
|
+
*
|
|
303
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
304
|
+
* const commitments = await segmentCommitment(api)
|
|
305
|
+
* console.log(`Found ${commitments.length} segment commitments`)
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
19
308
|
export declare const segmentCommitment: (api: Api) => Promise<[StorageKey<AnyTuple>, Codec][]>;
|
|
309
|
+
/**
|
|
310
|
+
* Retrieves the slot probability configuration.
|
|
311
|
+
*
|
|
312
|
+
* Slot probability defines the likelihood that a farmer will be able to produce
|
|
313
|
+
* a block in any given slot. It's returned as a fraction [numerator, denominator].
|
|
314
|
+
*
|
|
315
|
+
* @param api - The connected API instance
|
|
316
|
+
* @returns Tuple representing slot probability as [numerator, denominator]
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* import { slotProbability } from '@autonomys/auto-consensus'
|
|
321
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
322
|
+
*
|
|
323
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
324
|
+
* const [num, den] = slotProbability(api)
|
|
325
|
+
* console.log(`Slot probability: ${num}/${den} = ${num/den}`)
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
20
328
|
export declare const slotProbability: (api: Api) => [number, number];
|
|
329
|
+
/**
|
|
330
|
+
* Retrieves the maximum number of pieces that can fit in a sector.
|
|
331
|
+
*
|
|
332
|
+
* In the Autonomys storage system, data is organized into pieces and sectors.
|
|
333
|
+
* This function returns the maximum number of pieces that can be stored in
|
|
334
|
+
* a single sector.
|
|
335
|
+
*
|
|
336
|
+
* @param api - The connected API instance
|
|
337
|
+
* @returns Maximum pieces per sector as a bigint
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* import { maxPiecesInSector } from '@autonomys/auto-consensus'
|
|
342
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
343
|
+
*
|
|
344
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
345
|
+
* const maxPieces = maxPiecesInSector(api)
|
|
346
|
+
* console.log(`Max pieces per sector: ${maxPieces}`)
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
21
349
|
export declare const maxPiecesInSector: (api: Api) => bigint;
|
|
350
|
+
/**
|
|
351
|
+
* Converts solution range to the equivalent number of pieces.
|
|
352
|
+
*
|
|
353
|
+
* This utility function converts a solution range value to the equivalent
|
|
354
|
+
* number of pieces that would need to be stored to achieve that solution range,
|
|
355
|
+
* taking into account the slot probability.
|
|
356
|
+
*
|
|
357
|
+
* @param solutionRange - The solution range value to convert
|
|
358
|
+
* @param slotProbability - Slot probability as [numerator, denominator] tuple
|
|
359
|
+
* @returns Number of pieces equivalent to the solution range
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* import { solutionRangeToPieces, solutionRanges, slotProbability } from '@autonomys/auto-consensus'
|
|
364
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
365
|
+
*
|
|
366
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
367
|
+
* const ranges = await solutionRanges(api)
|
|
368
|
+
* const slotProb = slotProbability(api)
|
|
369
|
+
*
|
|
370
|
+
* if (ranges.current) {
|
|
371
|
+
* const pieces = solutionRangeToPieces(ranges.current, [BigInt(slotProb[0]), BigInt(slotProb[1])])
|
|
372
|
+
* console.log(`Current solution range equals ${pieces} pieces`)
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
22
376
|
export declare function solutionRangeToPieces(solutionRange: bigint, slotProbability: [bigint, bigint]): bigint;
|
|
377
|
+
/**
|
|
378
|
+
* Calculates the total space pledged to the network.
|
|
379
|
+
*
|
|
380
|
+
* This function calculates the total amount of storage space that has been
|
|
381
|
+
* pledged to the Autonomys network by farmers, based on the current solution
|
|
382
|
+
* range and slot probability.
|
|
383
|
+
*
|
|
384
|
+
* @param api - The connected API instance
|
|
385
|
+
* @returns Promise that resolves to total pledged space in bytes as bigint
|
|
386
|
+
* @throws Error if unable to retrieve solution ranges or calculate space
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```typescript
|
|
390
|
+
* import { spacePledged } from '@autonomys/auto-consensus'
|
|
391
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
392
|
+
*
|
|
393
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
394
|
+
* const pledgedSpace = await spacePledged(api)
|
|
395
|
+
* const pledgedGB = Number(pledgedSpace) / (1024 ** 3)
|
|
396
|
+
* console.log(`Total pledged space: ${pledgedGB.toFixed(2)} GB`)
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
23
399
|
export declare const spacePledged: (api: Api) => Promise<bigint>;
|
|
400
|
+
/**
|
|
401
|
+
* @deprecated Use spacePledged instead. This function will be removed in a future major release.
|
|
402
|
+
*
|
|
403
|
+
* Calculates the total space pledged to the network.
|
|
404
|
+
*
|
|
405
|
+
* @param api - The connected API instance
|
|
406
|
+
* @returns Promise that resolves to total pledged space in bytes as bigint
|
|
407
|
+
*/
|
|
24
408
|
export declare const spacePledge: (api: Api) => Promise<bigint>;
|
|
409
|
+
/**
|
|
410
|
+
* Calculates the total blockchain size.
|
|
411
|
+
*
|
|
412
|
+
* This function calculates the total size of the blockchain by counting
|
|
413
|
+
* the number of segment commitments and multiplying by the size per segment.
|
|
414
|
+
* This represents the total amount of data stored in the blockchain.
|
|
415
|
+
*
|
|
416
|
+
* @param api - The connected API instance
|
|
417
|
+
* @returns Promise that resolves to total blockchain size in bytes as bigint
|
|
418
|
+
* @throws Error if unable to retrieve segment commitments
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* import { blockchainSize } from '@autonomys/auto-consensus'
|
|
423
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
424
|
+
*
|
|
425
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
426
|
+
* const totalSize = await blockchainSize(api)
|
|
427
|
+
* const sizeGB = Number(totalSize) / (1024 ** 3)
|
|
428
|
+
* console.log(`Blockchain size: ${sizeGB.toFixed(2)} GB`)
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
25
431
|
export declare const blockchainSize: (api: Api) => Promise<bigint>;
|
|
26
432
|
//# sourceMappingURL=info.d.ts.map
|
package/dist/info.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,GAAG,EAEH,SAAS,EACT,KAAK,EACL,MAAM,EACN,WAAW,EACX,UAAU,EACX,MAAM,uBAAuB,CAAA;AAM9B,eAAO,MAAM,GAAG,GAAU,CAAC,EAAE,KAAK,GAAG,EAAE,YAAY,MAAM,EAAE,SAAQ,GAAG,EAAO,KAAG,OAAO,CAAC,CAAC,CAC7B,CAAA;AAE5D,eAAO,MAAM,KAAK,GAAU,CAAC,EAAE,KAAK,GAAG,EAAE,YAAY,MAAM,EAAE,SAAQ,GAAG,EAAO,KAAG,OAAO,CAAC,CAAC,CAC7B,CAAA;AAE9D,eAAO,MAAM,MAAM,GAAU,KAAK,GAAG,oBAAkD,CAAA;AAE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