@autonomys/auto-consensus 1.5.3 → 1.5.5
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/domain.d.ts +29 -0
- package/dist/domain.d.ts.map +1 -1
- package/dist/domain.js +44 -1
- package/dist/position/index.d.ts.map +1 -1
- package/dist/position/index.js +4 -2
- package/dist/types/position.d.ts +2 -1
- package/dist/types/position.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/domain.d.ts
CHANGED
|
@@ -60,4 +60,33 @@ export declare function domainStakingSummary(api: Api, domainId: string | number
|
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
export declare const latestConfirmedDomainBlock: (api: Api) => Promise<ConfirmedDomainBlock[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the latest block number for a specific domain.
|
|
65
|
+
*
|
|
66
|
+
* This function queries the domain's current latest block number, which represents
|
|
67
|
+
* the highest block number that has been processed for the specified domain.
|
|
68
|
+
*
|
|
69
|
+
* @param api - The connected API instance to query the blockchain
|
|
70
|
+
* @param domainId - The ID of the domain to query (can be string, number, or bigint)
|
|
71
|
+
* @returns Promise that resolves to the best block number, or undefined if not found
|
|
72
|
+
* @throws Error if the domain best number query fails
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { headDomainNumber } from '@autonomys/auto-consensus'
|
|
77
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
78
|
+
*
|
|
79
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
80
|
+
* const headNumber = await headDomainNumber(api, '0')
|
|
81
|
+
*
|
|
82
|
+
* if (headNumber !== undefined) {
|
|
83
|
+
* console.log(`Domain 0 head block number: ${headNumber}`)
|
|
84
|
+
* } else {
|
|
85
|
+
* console.log('Domain not found or no blocks processed')
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* await api.disconnect()
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare const headDomainNumber: (api: Api, domainId: string | number | bigint) => Promise<number | undefined>;
|
|
63
92
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,GAAG,EACR,UAAU,MAAM,GAAG,MAAM,GAAG,MAAM,KACjC,OAAO,CAAC,MAAM,GAAG,SAAS,CAY5B,CAAA"}
|
package/dist/domain.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.latestConfirmedDomainBlock = exports.domains = void 0;
|
|
13
|
+
exports.headDomainNumber = exports.latestConfirmedDomainBlock = exports.domains = void 0;
|
|
14
14
|
exports.domainStakingSummary = domainStakingSummary;
|
|
15
15
|
const parse_1 = require("./utils/parse");
|
|
16
16
|
/**
|
|
@@ -149,3 +149,46 @@ const latestConfirmedDomainBlock = (api) => __awaiter(void 0, void 0, void 0, fu
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
exports.latestConfirmedDomainBlock = latestConfirmedDomainBlock;
|
|
152
|
+
/**
|
|
153
|
+
* Retrieves the latest block number for a specific domain.
|
|
154
|
+
*
|
|
155
|
+
* This function queries the domain's current latest block number, which represents
|
|
156
|
+
* the highest block number that has been processed for the specified domain.
|
|
157
|
+
*
|
|
158
|
+
* @param api - The connected API instance to query the blockchain
|
|
159
|
+
* @param domainId - The ID of the domain to query (can be string, number, or bigint)
|
|
160
|
+
* @returns Promise that resolves to the best block number, or undefined if not found
|
|
161
|
+
* @throws Error if the domain best number query fails
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { headDomainNumber } from '@autonomys/auto-consensus'
|
|
166
|
+
* import { activate } from '@autonomys/auto-utils'
|
|
167
|
+
*
|
|
168
|
+
* const api = await activate({ networkId: 'gemini-3h' })
|
|
169
|
+
* const headNumber = await headDomainNumber(api, '0')
|
|
170
|
+
*
|
|
171
|
+
* if (headNumber !== undefined) {
|
|
172
|
+
* console.log(`Domain 0 head block number: ${headNumber}`)
|
|
173
|
+
* } else {
|
|
174
|
+
* console.log('Domain not found or no blocks processed')
|
|
175
|
+
* }
|
|
176
|
+
*
|
|
177
|
+
* await api.disconnect()
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
const headDomainNumber = (api, domainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
+
try {
|
|
182
|
+
const blockHeight = yield api.query.domains.headDomainNumber(domainId.toString());
|
|
183
|
+
if (blockHeight.isEmpty) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const result = blockHeight.toJSON();
|
|
187
|
+
return result !== null ? Number(result) : undefined;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error('error', error);
|
|
191
|
+
throw new Error('Error querying domain head number.' + error);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
exports.headDomainNumber = headDomainNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/position/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/position/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAoH1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,GAAG,EACR,YAAY,MAAM,GAAG,MAAM,GAAG,MAAM,EACpC,oBAAoB,MAAM,KACzB,OAAO,CAAC,iBAAiB,CAkE3B,CAAA"}
|
package/dist/position/index.js
CHANGED
|
@@ -64,8 +64,9 @@ const processPendingWithdrawals = (api, operatorId, withdrawalsData, currentEpoc
|
|
|
64
64
|
// Process regular withdrawals
|
|
65
65
|
for (const w of withdrawal.withdrawals) {
|
|
66
66
|
pendingWithdrawals.push({
|
|
67
|
-
|
|
67
|
+
stakeWithdrawalAmount: w.amountToUnlock,
|
|
68
68
|
unlockAtDomainBlock: w.unlockAtConfirmedDomainBlockNumber,
|
|
69
|
+
storageFeeRefund: w.storageFeeRefund,
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
const sharePrice =
|
|
@@ -76,8 +77,9 @@ const processPendingWithdrawals = (api, operatorId, withdrawalsData, currentEpoc
|
|
|
76
77
|
: yield (0, price_1.instantSharePrice)(api, operatorId);
|
|
77
78
|
const withdrawalAmount = sharePrice ? (0, utils_1.shareToStake)(shares, sharePrice) : BigInt(0); // fallback to 0 if no price available
|
|
78
79
|
pendingWithdrawals.push({
|
|
79
|
-
|
|
80
|
+
stakeWithdrawalAmount: withdrawalAmount,
|
|
80
81
|
unlockAtDomainBlock: unlockAtConfirmedDomainBlockNumber,
|
|
82
|
+
storageFeeRefund: withdrawalInShares.storageFeeRefund,
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
return pendingWithdrawals;
|
package/dist/types/position.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/types/position.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,EAAE,MAAM,CAAA;KACvB,EAAE,CAAA;IACH,kBAAkB,EAAE;QAClB,
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/types/position.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,EAAE,MAAM,CAAA;KACvB,EAAE,CAAA;IACH,kBAAkB,EAAE;QAClB,qBAAqB,EAAE,MAAM,CAAA;QAC7B,mBAAmB,EAAE,MAAM,CAAA;QAC3B,gBAAgB,EAAE,MAAM,CAAA;KACzB,EAAE,CAAA;IACH,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-consensus",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@autonomys/auto-utils": "^1.5.
|
|
28
|
+
"@autonomys/auto-utils": "^1.5.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/jest": "^29.5.14",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"ts-jest": "^29.3.1",
|
|
36
36
|
"typescript": "^5.8.3"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "17dbdd2bf2d56d13d6893361b74b719539f2d854"
|
|
39
39
|
}
|