@autonomys/auto-consensus 1.5.2 → 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 +56 -0
- package/dist/domain.d.ts.map +1 -1
- package/dist/domain.js +91 -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 +36 -1
- package/dist/position/index.d.ts.map +1 -1
- package/dist/position/index.js +117 -70
- package/dist/position/price.d.ts +60 -3
- package/dist/position/price.d.ts.map +1 -1
- package/dist/position/price.js +60 -3
- package/dist/position/utils.d.ts +53 -2
- package/dist/position/utils.d.ts.map +1 -1
- package/dist/position/utils.js +53 -2
- 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 +305 -0
- package/dist/transfer.d.ts +59 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +59 -0
- package/dist/types/position.d.ts +1 -1
- package/dist/types/position.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/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/account.d.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import type { Api } from '@autonomys/auto-utils';
|
|
2
2
|
import type { AccountData } from './types/account';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves detailed account information including nonce and balance data.
|
|
5
|
+
*
|
|
6
|
+
* This function queries the system account storage to get comprehensive account information
|
|
7
|
+
* including the account nonce (transaction counter) and balance details (free, reserved, frozen, flags).
|
|
8
|
+
*
|
|
9
|
+
* @param api - The connected API instance to query the blockchain
|
|
10
|
+
* @param address - The account address to query information for
|
|
11
|
+
* @returns Promise that resolves to AccountData containing nonce and balance information
|
|
12
|
+
* @throws Error if the account query fails or if there's an issue parsing the data
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { account } from '@autonomys/auto-consensus'
|
|
17
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
18
|
+
*
|
|
19
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
20
|
+
* const accountData = await account(api, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
|
21
|
+
*
|
|
22
|
+
* console.log(`Nonce: ${accountData.nonce}`)
|
|
23
|
+
* console.log(`Free Balance: ${accountData.data.free}`)
|
|
24
|
+
* console.log(`Reserved Balance: ${accountData.data.reserved}`)
|
|
25
|
+
*
|
|
26
|
+
* await api.disconnect()
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
3
29
|
export declare const account: (api: Api, address: string) => Promise<AccountData>;
|
|
4
30
|
//# sourceMappingURL=account.d.ts.map
|
package/dist/account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAA;AAGlE,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,WAAW,CAc5E,CAAA"}
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAA;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,WAAW,CAc5E,CAAA"}
|
package/dist/account.js
CHANGED
|
@@ -12,6 +12,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.account = void 0;
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves detailed account information including nonce and balance data.
|
|
17
|
+
*
|
|
18
|
+
* This function queries the system account storage to get comprehensive account information
|
|
19
|
+
* including the account nonce (transaction counter) and balance details (free, reserved, frozen, flags).
|
|
20
|
+
*
|
|
21
|
+
* @param api - The connected API instance to query the blockchain
|
|
22
|
+
* @param address - The account address to query information for
|
|
23
|
+
* @returns Promise that resolves to AccountData containing nonce and balance information
|
|
24
|
+
* @throws Error if the account query fails or if there's an issue parsing the data
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { account } from '@autonomys/auto-consensus'
|
|
29
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
30
|
+
*
|
|
31
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
32
|
+
* const accountData = await account(api, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
|
33
|
+
*
|
|
34
|
+
* console.log(`Nonce: ${accountData.nonce}`)
|
|
35
|
+
* console.log(`Free Balance: ${accountData.data.free}`)
|
|
36
|
+
* console.log(`Reserved Balance: ${accountData.data.reserved}`)
|
|
37
|
+
*
|
|
38
|
+
* await api.disconnect()
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
15
41
|
const account = (api, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
42
|
try {
|
|
17
43
|
const rawAccount = yield api.query.system.account(address);
|
package/dist/balances.d.ts
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
import { Api } from '@autonomys/auto-utils';
|
|
2
2
|
import type { BalanceData } from './types/balance';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the total token issuance of the network.
|
|
5
|
+
*
|
|
6
|
+
* This function queries the blockchain to get the total amount of tokens that have been issued
|
|
7
|
+
* across the entire network. This includes all tokens in circulation, staked, reserved, and frozen.
|
|
8
|
+
*
|
|
9
|
+
* @param networkId - Optional network identifier. If not provided, uses the default network
|
|
10
|
+
* @returns Promise that resolves to a Codec containing the total issuance value as a hex string
|
|
11
|
+
* @throws Error if the network connection fails or the query is unsuccessful
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { totalIssuance } from '@autonomys/auto-consensus'
|
|
16
|
+
*
|
|
17
|
+
* // Query total issuance for default network
|
|
18
|
+
* const issuance = await totalIssuance()
|
|
19
|
+
* const totalTokens = BigInt(issuance.toString())
|
|
20
|
+
* console.log(`Total tokens issued: ${totalTokens}`)
|
|
21
|
+
*
|
|
22
|
+
* // Query for specific network
|
|
23
|
+
* const taurusIssuance = await totalIssuance('taurus')
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
3
26
|
export declare const totalIssuance: (networkId?: string) => Promise<import("@autonomys/auto-utils").Codec>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the balance information for a specific account.
|
|
29
|
+
*
|
|
30
|
+
* This function queries the balance data for a given account address, returning information
|
|
31
|
+
* about free, reserved, frozen, and flag balances. It uses the account function internally
|
|
32
|
+
* to get comprehensive account data and extracts the balance portion.
|
|
33
|
+
*
|
|
34
|
+
* @param api - The connected API instance to query the blockchain
|
|
35
|
+
* @param address - The account address to query balance information for
|
|
36
|
+
* @returns Promise that resolves to BalanceData containing balance details
|
|
37
|
+
* @throws Error if the account query fails or balance data cannot be retrieved
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { balance } from '@autonomys/auto-consensus'
|
|
42
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
43
|
+
*
|
|
44
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
45
|
+
* const balanceData = await balance(api, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
|
46
|
+
*
|
|
47
|
+
* console.log(`Free Balance: ${balanceData.free}`)
|
|
48
|
+
* console.log(`Reserved Balance: ${balanceData.reserved}`)
|
|
49
|
+
* console.log(`Frozen Balance: ${balanceData.frozen}`)
|
|
50
|
+
*
|
|
51
|
+
* await api.disconnect()
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
4
54
|
export declare const balance: (api: Api, address: string) => Promise<BalanceData>;
|
|
5
55
|
//# sourceMappingURL=balances.d.ts.map
|
package/dist/balances.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../src/balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,eAAO,MAAM,aAAa,GAAU,YAAY,MAAM,mDAQrD,CAAA;AAED,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,WAAW,CAY5E,CAAA"}
|
|
1
|
+
{"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../src/balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,aAAa,GAAU,YAAY,MAAM,mDAQrD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,WAAW,CAY5E,CAAA"}
|
package/dist/balances.js
CHANGED
|
@@ -12,6 +12,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.balance = exports.totalIssuance = void 0;
|
|
13
13
|
const auto_utils_1 = require("@autonomys/auto-utils");
|
|
14
14
|
const account_1 = require("./account");
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the total token issuance of the network.
|
|
17
|
+
*
|
|
18
|
+
* This function queries the blockchain to get the total amount of tokens that have been issued
|
|
19
|
+
* across the entire network. This includes all tokens in circulation, staked, reserved, and frozen.
|
|
20
|
+
*
|
|
21
|
+
* @param networkId - Optional network identifier. If not provided, uses the default network
|
|
22
|
+
* @returns Promise that resolves to a Codec containing the total issuance value as a hex string
|
|
23
|
+
* @throws Error if the network connection fails or the query is unsuccessful
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { totalIssuance } from '@autonomys/auto-consensus'
|
|
28
|
+
*
|
|
29
|
+
* // Query total issuance for default network
|
|
30
|
+
* const issuance = await totalIssuance()
|
|
31
|
+
* const totalTokens = BigInt(issuance.toString())
|
|
32
|
+
* console.log(`Total tokens issued: ${totalTokens}`)
|
|
33
|
+
*
|
|
34
|
+
* // Query for specific network
|
|
35
|
+
* const taurusIssuance = await totalIssuance('taurus')
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
15
38
|
const totalIssuance = (networkId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
39
|
// Get the api instance for the network
|
|
17
40
|
const api = yield (0, auto_utils_1.activate)({ networkId });
|
|
@@ -20,6 +43,33 @@ const totalIssuance = (networkId) => __awaiter(void 0, void 0, void 0, function*
|
|
|
20
43
|
return totalIssuance;
|
|
21
44
|
});
|
|
22
45
|
exports.totalIssuance = totalIssuance;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the balance information for a specific account.
|
|
48
|
+
*
|
|
49
|
+
* This function queries the balance data for a given account address, returning information
|
|
50
|
+
* about free, reserved, frozen, and flag balances. It uses the account function internally
|
|
51
|
+
* to get comprehensive account data and extracts the balance portion.
|
|
52
|
+
*
|
|
53
|
+
* @param api - The connected API instance to query the blockchain
|
|
54
|
+
* @param address - The account address to query balance information for
|
|
55
|
+
* @returns Promise that resolves to BalanceData containing balance details
|
|
56
|
+
* @throws Error if the account query fails or balance data cannot be retrieved
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { balance } from '@autonomys/auto-consensus'
|
|
61
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
62
|
+
*
|
|
63
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
64
|
+
* const balanceData = await balance(api, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
|
65
|
+
*
|
|
66
|
+
* console.log(`Free Balance: ${balanceData.free}`)
|
|
67
|
+
* console.log(`Reserved Balance: ${balanceData.reserved}`)
|
|
68
|
+
* console.log(`Frozen Balance: ${balanceData.frozen}`)
|
|
69
|
+
*
|
|
70
|
+
* await api.disconnect()
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
23
73
|
const balance = (api, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
74
|
// Query the balance of the address and parse the data
|
|
25
75
|
try {
|
package/dist/batch.d.ts
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
1
|
import type { ApiPromise } from '@autonomys/auto-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a batch transaction that executes multiple transactions atomically.
|
|
4
|
+
*
|
|
5
|
+
* This function creates a utility batch transaction that allows multiple operations to be
|
|
6
|
+
* executed together in a single transaction. All operations in the batch will either
|
|
7
|
+
* succeed together or fail together, ensuring atomicity.
|
|
8
|
+
*
|
|
9
|
+
* @param api - The connected API promise instance
|
|
10
|
+
* @param txs - Array of transaction objects to be batched together
|
|
11
|
+
* @returns A batch transaction that can be signed and submitted
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { batch, transfer } from '@autonomys/auto-consensus'
|
|
16
|
+
* import { activate, signAndSendTx } from '@autonomys/auto-utils'
|
|
17
|
+
*
|
|
18
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
19
|
+
*
|
|
20
|
+
* // Create multiple transfer transactions
|
|
21
|
+
* const tx1 = transfer(api, 'recipient1', '1000000000000')
|
|
22
|
+
* const tx2 = transfer(api, 'recipient2', '2000000000000')
|
|
23
|
+
*
|
|
24
|
+
* // Batch them together
|
|
25
|
+
* const batchTx = batch(api, [tx1, tx2])
|
|
26
|
+
*
|
|
27
|
+
* // Sign and send the batch transaction
|
|
28
|
+
* await signAndSendTx(sender, batchTx)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
2
31
|
export declare const batch: (api: ApiPromise, txs: any[]) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
3
32
|
//# sourceMappingURL=batch.d.ts.map
|
package/dist/batch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,GAAI,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,wHAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,wHAA8B,CAAA"}
|
package/dist/batch.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.batch = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a batch transaction that executes multiple transactions atomically.
|
|
6
|
+
*
|
|
7
|
+
* This function creates a utility batch transaction that allows multiple operations to be
|
|
8
|
+
* executed together in a single transaction. All operations in the batch will either
|
|
9
|
+
* succeed together or fail together, ensuring atomicity.
|
|
10
|
+
*
|
|
11
|
+
* @param api - The connected API promise instance
|
|
12
|
+
* @param txs - Array of transaction objects to be batched together
|
|
13
|
+
* @returns A batch transaction that can be signed and submitted
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { batch, transfer } from '@autonomys/auto-consensus'
|
|
18
|
+
* import { activate, signAndSendTx } from '@autonomys/auto-utils'
|
|
19
|
+
*
|
|
20
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
21
|
+
*
|
|
22
|
+
* // Create multiple transfer transactions
|
|
23
|
+
* const tx1 = transfer(api, 'recipient1', '1000000000000')
|
|
24
|
+
* const tx2 = transfer(api, 'recipient2', '2000000000000')
|
|
25
|
+
*
|
|
26
|
+
* // Batch them together
|
|
27
|
+
* const batchTx = batch(api, [tx1, tx2])
|
|
28
|
+
*
|
|
29
|
+
* // Sign and send the batch transaction
|
|
30
|
+
* await signAndSendTx(sender, batchTx)
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
4
33
|
const batch = (api, txs) => api.tx.utility.batch(txs);
|
|
5
34
|
exports.batch = batch;
|
package/dist/domain.d.ts
CHANGED
|
@@ -1,7 +1,63 @@
|
|
|
1
1
|
import type { Api } from '@autonomys/auto-utils';
|
|
2
2
|
import { ConfirmedDomainBlock, DomainRegistry, DomainStakingSummary } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves all registered domains on the network.
|
|
5
|
+
*
|
|
6
|
+
* This function queries the domain registry to get information about all domains
|
|
7
|
+
* registered on the Autonomys network, including their configuration, ownership,
|
|
8
|
+
* and creation details.
|
|
9
|
+
*
|
|
10
|
+
* @param api - The connected API instance to query the blockchain
|
|
11
|
+
* @returns Promise that resolves to an array of DomainRegistry objects
|
|
12
|
+
* @throws Error if the domain registry query fails
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { domains } from '@autonomys/auto-consensus'
|
|
17
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
18
|
+
*
|
|
19
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
20
|
+
* const domainList = await domains(api)
|
|
21
|
+
*
|
|
22
|
+
* domainList.forEach(domain => {
|
|
23
|
+
* console.log(`Domain ID: ${domain.domainId}`)
|
|
24
|
+
* console.log(`Owner: ${domain.ownerAccountId}`)
|
|
25
|
+
* console.log(`Name: ${domain.domainConfig.domainName}`)
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* await api.disconnect()
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
3
31
|
export declare const domains: (api: Api) => Promise<DomainRegistry[]>;
|
|
4
32
|
export declare function domainStakingSummary(api: Api): Promise<DomainStakingSummary[]>;
|
|
5
33
|
export declare function domainStakingSummary(api: Api, domainId: string | number | bigint): Promise<DomainStakingSummary | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the latest confirmed domain blocks for all domains.
|
|
36
|
+
*
|
|
37
|
+
* This function queries the latest confirmed block information for each domain,
|
|
38
|
+
* providing details about the most recent blocks that have been confirmed
|
|
39
|
+
* on each domain chain.
|
|
40
|
+
*
|
|
41
|
+
* @param api - The connected API instance to query the blockchain
|
|
42
|
+
* @returns Promise that resolves to an array of ConfirmedDomainBlock objects
|
|
43
|
+
* @throws Error if the confirmed domain block query fails
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { latestConfirmedDomainBlock } from '@autonomys/auto-consensus'
|
|
48
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
49
|
+
*
|
|
50
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
51
|
+
* const confirmedBlocks = await latestConfirmedDomainBlock(api)
|
|
52
|
+
*
|
|
53
|
+
* confirmedBlocks.forEach(block => {
|
|
54
|
+
* console.log(`Domain ${block.id}: Block #${block.blockNumber}`)
|
|
55
|
+
* console.log(`Block Hash: ${block.blockHash}`)
|
|
56
|
+
* console.log(`State Root: ${block.stateRoot}`)
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* await api.disconnect()
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
6
62
|
export declare const latestConfirmedDomainBlock: (api: Api) => Promise<ConfirmedDomainBlock[]>;
|
|
7
63
|
//# sourceMappingURL=domain.d.ts.map
|
package/dist/domain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGpF,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,cAAc,EAAE,CAQhE,CAAA;AAGD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAA;AACrF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,cAAc,EAAE,CAQhE,CAAA;AAGD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAA;AACrF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;AAuE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,0BAA0B,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,oBAAoB,EAAE,CAWzF,CAAA"}
|
package/dist/domain.js
CHANGED
|
@@ -13,6 +13,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.latestConfirmedDomainBlock = exports.domains = void 0;
|
|
14
14
|
exports.domainStakingSummary = domainStakingSummary;
|
|
15
15
|
const parse_1 = require("./utils/parse");
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves all registered domains on the network.
|
|
18
|
+
*
|
|
19
|
+
* This function queries the domain registry to get information about all domains
|
|
20
|
+
* registered on the Autonomys network, including their configuration, ownership,
|
|
21
|
+
* and creation details.
|
|
22
|
+
*
|
|
23
|
+
* @param api - The connected API instance to query the blockchain
|
|
24
|
+
* @returns Promise that resolves to an array of DomainRegistry objects
|
|
25
|
+
* @throws Error if the domain registry query fails
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { domains } from '@autonomys/auto-consensus'
|
|
30
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
31
|
+
*
|
|
32
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
33
|
+
* const domainList = await domains(api)
|
|
34
|
+
*
|
|
35
|
+
* domainList.forEach(domain => {
|
|
36
|
+
* console.log(`Domain ID: ${domain.domainId}`)
|
|
37
|
+
* console.log(`Owner: ${domain.ownerAccountId}`)
|
|
38
|
+
* console.log(`Name: ${domain.domainConfig.domainName}`)
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* await api.disconnect()
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
16
44
|
const domains = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
45
|
try {
|
|
18
46
|
const _domains = yield api.query.domains.domainRegistry.entries();
|
|
@@ -24,6 +52,41 @@ const domains = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
24
52
|
}
|
|
25
53
|
});
|
|
26
54
|
exports.domains = domains;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves staking summary information for domains.
|
|
57
|
+
*
|
|
58
|
+
* This function can be used in two ways:
|
|
59
|
+
* 1. Without domainId: Returns staking summaries for all domains
|
|
60
|
+
* 2. With domainId: Returns staking summary for a specific domain
|
|
61
|
+
*
|
|
62
|
+
* The staking summary includes information about current epoch, total stake,
|
|
63
|
+
* operators, and epoch rewards for each domain.
|
|
64
|
+
*
|
|
65
|
+
* @param api - The connected API instance to query the blockchain
|
|
66
|
+
* @param domainId - Optional domain ID to query specific domain summary
|
|
67
|
+
* @returns Promise that resolves to array of summaries (all domains) or single summary (specific domain)
|
|
68
|
+
* @throws Error if the staking summary query fails
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { domainStakingSummary } from '@autonomys/auto-consensus'
|
|
73
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
74
|
+
*
|
|
75
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
76
|
+
*
|
|
77
|
+
* // Get all domain staking summaries
|
|
78
|
+
* const allSummaries = await domainStakingSummary(api)
|
|
79
|
+
* console.log(`Found ${allSummaries.length} domains`)
|
|
80
|
+
*
|
|
81
|
+
* // Get specific domain summary
|
|
82
|
+
* const specificSummary = await domainStakingSummary(api, '0')
|
|
83
|
+
* if (specificSummary) {
|
|
84
|
+
* console.log(`Domain 0 total stake: ${specificSummary.currentTotalStake}`)
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* await api.disconnect()
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
27
90
|
// Implementation function
|
|
28
91
|
function domainStakingSummary(api, domainId) {
|
|
29
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -47,6 +110,34 @@ function domainStakingSummary(api, domainId) {
|
|
|
47
110
|
}
|
|
48
111
|
});
|
|
49
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Retrieves the latest confirmed domain blocks for all domains.
|
|
115
|
+
*
|
|
116
|
+
* This function queries the latest confirmed block information for each domain,
|
|
117
|
+
* providing details about the most recent blocks that have been confirmed
|
|
118
|
+
* on each domain chain.
|
|
119
|
+
*
|
|
120
|
+
* @param api - The connected API instance to query the blockchain
|
|
121
|
+
* @returns Promise that resolves to an array of ConfirmedDomainBlock objects
|
|
122
|
+
* @throws Error if the confirmed domain block query fails
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { latestConfirmedDomainBlock } from '@autonomys/auto-consensus'
|
|
127
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
128
|
+
*
|
|
129
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
130
|
+
* const confirmedBlocks = await latestConfirmedDomainBlock(api)
|
|
131
|
+
*
|
|
132
|
+
* confirmedBlocks.forEach(block => {
|
|
133
|
+
* console.log(`Domain ${block.id}: Block #${block.blockNumber}`)
|
|
134
|
+
* console.log(`Block Hash: ${block.blockHash}`)
|
|
135
|
+
* console.log(`State Root: ${block.stateRoot}`)
|
|
136
|
+
* })
|
|
137
|
+
*
|
|
138
|
+
* await api.disconnect()
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
50
141
|
const latestConfirmedDomainBlock = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
142
|
try {
|
|
52
143
|
const _latestConfirmedDomainBlock = yield api.query.domains.latestConfirmedDomainBlock.entries();
|