@autonomys/auto-consensus 1.5.2 → 1.5.4

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.
Files changed (45) hide show
  1. package/dist/account.d.ts +26 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/account.js +26 -0
  4. package/dist/balances.d.ts +50 -0
  5. package/dist/balances.d.ts.map +1 -1
  6. package/dist/balances.js +50 -0
  7. package/dist/batch.d.ts +29 -0
  8. package/dist/batch.d.ts.map +1 -1
  9. package/dist/batch.js +29 -0
  10. package/dist/domain.d.ts +56 -0
  11. package/dist/domain.d.ts.map +1 -1
  12. package/dist/domain.js +91 -0
  13. package/dist/info.d.ts +406 -0
  14. package/dist/info.d.ts.map +1 -1
  15. package/dist/info.js +406 -0
  16. package/dist/position/index.d.ts +36 -1
  17. package/dist/position/index.d.ts.map +1 -1
  18. package/dist/position/index.js +117 -70
  19. package/dist/position/price.d.ts +60 -3
  20. package/dist/position/price.d.ts.map +1 -1
  21. package/dist/position/price.js +60 -3
  22. package/dist/position/utils.d.ts +53 -2
  23. package/dist/position/utils.d.ts.map +1 -1
  24. package/dist/position/utils.js +53 -2
  25. package/dist/remark.d.ts +29 -0
  26. package/dist/remark.d.ts.map +1 -1
  27. package/dist/remark.js +29 -0
  28. package/dist/staking.d.ts +305 -0
  29. package/dist/staking.d.ts.map +1 -1
  30. package/dist/staking.js +305 -0
  31. package/dist/transfer.d.ts +59 -0
  32. package/dist/transfer.d.ts.map +1 -1
  33. package/dist/transfer.js +59 -0
  34. package/dist/types/position.d.ts +1 -1
  35. package/dist/types/position.d.ts.map +1 -1
  36. package/dist/utils/format.d.ts +86 -0
  37. package/dist/utils/format.d.ts.map +1 -1
  38. package/dist/utils/format.js +86 -0
  39. package/dist/utils/query.d.ts +31 -0
  40. package/dist/utils/query.d.ts.map +1 -1
  41. package/dist/utils/query.js +31 -0
  42. package/dist/utils/sudo.d.ts +36 -0
  43. package/dist/utils/sudo.d.ts.map +1 -1
  44. package/dist/utils/sudo.js +36 -0
  45. package/package.json +3 -3
package/dist/staking.d.ts CHANGED
@@ -1,13 +1,318 @@
1
1
  import { Api } from '@autonomys/auto-utils';
2
2
  import type { NominateOperatorParams, RegisterOperatorParams, StakingParams, StringNumberOrBigInt, WithdrawStakeParams } from './types/staking';
3
+ /**
4
+ * Retrieves all registered operators on the network.
5
+ *
6
+ * This function queries the blockchain to get information about all operators
7
+ * that have been registered across all domains. Operators are entities that
8
+ * process transactions and maintain domain chains.
9
+ *
10
+ * @param api - The connected API instance
11
+ * @returns Promise that resolves to an array of Operator objects
12
+ * @throws Error if the operators query fails
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { operators } from '@autonomys/auto-consensus'
17
+ * import { activate } from '@autonomys/auto-utils'
18
+ *
19
+ * const api = await activate({ networkId: 'gemini-3h' })
20
+ * const allOperators = await operators(api)
21
+ *
22
+ * allOperators.forEach(op => {
23
+ * console.log(`Operator ${op.operatorId}: Domain ${op.operatorDetails.currentDomainId}`)
24
+ * console.log(`Total Stake: ${op.operatorDetails.currentTotalStake}`)
25
+ * })
26
+ * ```
27
+ */
3
28
  export declare const operators: (api: Api) => Promise<import("./types/staking").Operator[]>;
29
+ /**
30
+ * Retrieves detailed information about a specific operator.
31
+ *
32
+ * This function queries information about a single operator including their
33
+ * signing key, domain assignment, stake amounts, and operational status.
34
+ *
35
+ * @param api - The connected API instance
36
+ * @param operatorId - The ID of the operator to query
37
+ * @returns Promise that resolves to OperatorDetails object
38
+ * @throws Error if the operator query fails or operator doesn't exist
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { operator } from '@autonomys/auto-consensus'
43
+ * import { activate } from '@autonomys/auto-utils'
44
+ *
45
+ * const api = await activate({ networkId: 'gemini-3h' })
46
+ * const operatorInfo = await operator(api, '1')
47
+ *
48
+ * console.log(`Domain: ${operatorInfo.currentDomainId}`)
49
+ * console.log(`Total Stake: ${operatorInfo.currentTotalStake}`)
50
+ * console.log(`Minimum Nominator Stake: ${operatorInfo.minimumNominatorStake}`)
51
+ * console.log(`Nomination Tax: ${operatorInfo.nominationTax}%`)
52
+ * ```
53
+ */
4
54
  export declare const operator: (api: Api, operatorId: StringNumberOrBigInt) => Promise<import("./types/staking").OperatorDetails>;
55
+ /**
56
+ * Retrieves deposit information for an operator.
57
+ *
58
+ * This function queries all deposits (stakes) made to a specific operator.
59
+ * It can optionally filter deposits by a specific account address.
60
+ *
61
+ * @param api - The connected API instance
62
+ * @param operatorId - The ID of the operator to query deposits for
63
+ * @param account - Optional account address to filter deposits by
64
+ * @returns Promise that resolves to an array of Deposit objects
65
+ * @throws Error if the deposits query fails
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import { deposits } from '@autonomys/auto-consensus'
70
+ * import { activate } from '@autonomys/auto-utils'
71
+ *
72
+ * const api = await activate({ networkId: 'gemini-3h' })
73
+ *
74
+ * // Get all deposits for operator
75
+ * const allDeposits = await deposits(api, '1')
76
+ *
77
+ * // Get deposits for specific account
78
+ * const accountDeposits = await deposits(api, '1', 'account_address')
79
+ *
80
+ * allDeposits.forEach(deposit => {
81
+ * console.log(`Account: ${deposit.account}, Shares: ${deposit.shares}`)
82
+ * })
83
+ * ```
84
+ */
5
85
  export declare const deposits: (api: Api, operatorId: StringNumberOrBigInt, account?: string | undefined) => Promise<import("./types/staking").Deposit[]>;
86
+ /**
87
+ * Retrieves withdrawal information for an operator.
88
+ *
89
+ * This function queries all pending withdrawals for a specific operator.
90
+ * Withdrawals are stakes that have been requested to be unstaked but are
91
+ * still in the withdrawal period. Can optionally filter by account.
92
+ *
93
+ * @param api - The connected API instance
94
+ * @param operatorId - The ID of the operator to query withdrawals for
95
+ * @param account - Optional account address to filter withdrawals by
96
+ * @returns Promise that resolves to an array of Withdrawal objects
97
+ * @throws Error if the withdrawals query fails
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * import { withdrawals } from '@autonomys/auto-consensus'
102
+ * import { activate } from '@autonomys/auto-utils'
103
+ *
104
+ * const api = await activate({ networkId: 'gemini-3h' })
105
+ *
106
+ * // Get all withdrawals for operator
107
+ * const allWithdrawals = await withdrawals(api, '1')
108
+ *
109
+ * // Get withdrawals for specific account
110
+ * const accountWithdrawals = await withdrawals(api, '1', 'account_address')
111
+ *
112
+ * allWithdrawals.forEach(withdrawal => {
113
+ * console.log(`Account: ${withdrawal.account}`)
114
+ * console.log(`Total Withdrawal: ${withdrawal.totalWithdrawalAmount}`)
115
+ * })
116
+ * ```
117
+ */
6
118
  export declare const withdrawals: (api: Api, operatorId: StringNumberOrBigInt, account?: string | undefined) => Promise<import("./types/staking").Withdrawal[]>;
119
+ /**
120
+ * Creates a transaction to register a new operator.
121
+ *
122
+ * This function creates a transaction to register a new operator on a specific domain.
123
+ * The operator will be able to process transactions and earn rewards. Requires
124
+ * initial stake, minimum nominator stake, and nomination tax settings.
125
+ *
126
+ * @param params - RegisterOperatorParams containing all registration parameters
127
+ * @param params.api - The connected API promise instance
128
+ * @param params.domainId - The domain ID where the operator will be registered
129
+ * @param params.amountToStake - Initial amount to stake (in smallest token units)
130
+ * @param params.minimumNominatorStake - Minimum stake required from nominators
131
+ * @param params.nominationTax - Percentage fee charged to nominators
132
+ * @param params.signingKey - Optional signing key (derived from publicKey if not provided)
133
+ * @param params.publicKey - Optional public key (used to derive signingKey if needed)
134
+ * @returns A submittable operator registration transaction
135
+ * @throws Error if signing key/public key not provided or transaction creation fails
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * import { registerOperator } from '@autonomys/auto-consensus'
140
+ * import { activate, activateWallet, signAndSendTx } from '@autonomys/auto-utils'
141
+ *
142
+ * const api = await activate({ networkId: 'gemini-3h' })
143
+ * const { accounts } = await activateWallet({ networkId: 'gemini-3h', mnemonic })
144
+ *
145
+ * const registerTx = registerOperator({
146
+ * api,
147
+ * domainId: '0',
148
+ * amountToStake: '100000000000000000000', // 100 AI3
149
+ * minimumNominatorStake: '1000000000000000000', // 1 AI3
150
+ * nominationTax: '10', // 10%
151
+ * publicKey: accounts[0].publicKey
152
+ * })
153
+ *
154
+ * await signAndSendTx(accounts[0], registerTx)
155
+ * ```
156
+ */
7
157
  export declare const registerOperator: (params: RegisterOperatorParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
158
+ /**
159
+ * Creates a transaction to nominate (stake to) an existing operator.
160
+ *
161
+ * This function creates a transaction to stake tokens to an existing operator.
162
+ * Nominators earn rewards proportional to their stake, minus the operator's
163
+ * nomination tax. The stake helps secure the network and the specific domain.
164
+ *
165
+ * @param params - NominateOperatorParams containing nomination parameters
166
+ * @param params.api - The connected API promise instance
167
+ * @param params.operatorId - The ID of the operator to nominate
168
+ * @param params.amountToStake - Amount to stake (in smallest token units)
169
+ * @returns A submittable operator nomination transaction
170
+ * @throws Error if transaction creation fails
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * import { nominateOperator } from '@autonomys/auto-consensus'
175
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
176
+ *
177
+ * const api = await activate({ networkId: 'gemini-3h' })
178
+ *
179
+ * const nominateTx = nominateOperator({
180
+ * api,
181
+ * operatorId: '1',
182
+ * amountToStake: '50000000000000000000' // 50 AI3
183
+ * })
184
+ *
185
+ * await signAndSendTx(nominator, nominateTx)
186
+ * ```
187
+ */
8
188
  export declare const nominateOperator: (params: NominateOperatorParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
189
+ /**
190
+ * Creates a transaction to withdraw stake from an operator.
191
+ *
192
+ * This function creates a transaction to withdraw staked tokens from an operator.
193
+ * Supports different withdrawal modes: all stake, by percentage, by specific amount,
194
+ * or by number of shares. Withdrawn stake enters a withdrawal period before being available.
195
+ *
196
+ * @param params - WithdrawStakeParams containing withdrawal parameters
197
+ * @param params.api - The connected API promise instance
198
+ * @param params.operatorId - The ID of the operator to withdraw stake from
199
+ * @param params.all - Optional: withdraw all stake (boolean)
200
+ * @param params.percent - Optional: withdraw by percentage (string/number)
201
+ * @param params.stake - Optional: withdraw specific stake amount
202
+ * @param params.shares - Optional: withdraw specific number of shares
203
+ * @returns A submittable stake withdrawal transaction
204
+ * @throws Error if no withdrawal method specified or transaction creation fails
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * import { withdrawStake } from '@autonomys/auto-consensus'
209
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
210
+ *
211
+ * const api = await activate({ networkId: 'gemini-3h' })
212
+ *
213
+ * // Withdraw all stake
214
+ * const withdrawAllTx = withdrawStake({ api, operatorId: '1', all: true })
215
+ *
216
+ * // Withdraw 50% of stake
217
+ * const withdrawPercentTx = withdrawStake({ api, operatorId: '1', percent: '50' })
218
+ *
219
+ * // Withdraw specific amount
220
+ * const withdrawAmountTx = withdrawStake({
221
+ * api,
222
+ * operatorId: '1',
223
+ * stake: '25000000000000000000'
224
+ * })
225
+ *
226
+ * await signAndSendTx(staker, withdrawAllTx)
227
+ * ```
228
+ */
9
229
  export declare const withdrawStake: (params: WithdrawStakeParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
230
+ /**
231
+ * Creates a transaction to deregister an operator.
232
+ *
233
+ * This function creates a transaction to deregister an operator, removing them
234
+ * from active service. The operator will no longer process transactions or earn
235
+ * rewards. All stakes will enter the withdrawal period.
236
+ *
237
+ * @param params - StakingParams containing the operator information
238
+ * @param params.api - The connected API promise instance
239
+ * @param params.operatorId - The ID of the operator to deregister
240
+ * @returns A submittable operator deregistration transaction
241
+ * @throws Error if transaction creation fails
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * import { deregisterOperator } from '@autonomys/auto-consensus'
246
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
247
+ *
248
+ * const api = await activate({ networkId: 'gemini-3h' })
249
+ *
250
+ * const deregisterTx = deregisterOperator({
251
+ * api,
252
+ * operatorId: '1'
253
+ * })
254
+ *
255
+ * await signAndSendTx(operatorOwner, deregisterTx)
256
+ * ```
257
+ */
10
258
  export declare const deregisterOperator: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
259
+ /**
260
+ * Creates a transaction to unlock funds from an operator.
261
+ *
262
+ * This function creates a transaction to unlock funds that have completed
263
+ * their withdrawal period. These are funds that were previously withdrawn
264
+ * and have now passed the required waiting period.
265
+ *
266
+ * @param params - StakingParams containing the operator information
267
+ * @param params.api - The connected API promise instance
268
+ * @param params.operatorId - The ID of the operator to unlock funds from
269
+ * @returns A submittable unlock funds transaction
270
+ * @throws Error if transaction creation fails
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * import { unlockFunds } from '@autonomys/auto-consensus'
275
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
276
+ *
277
+ * const api = await activate({ networkId: 'gemini-3h' })
278
+ *
279
+ * const unlockTx = unlockFunds({
280
+ * api,
281
+ * operatorId: '1'
282
+ * })
283
+ *
284
+ * await signAndSendTx(account, unlockTx)
285
+ * ```
286
+ */
11
287
  export declare const unlockFunds: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
288
+ /**
289
+ * Creates a transaction to unlock a nominator from an operator.
290
+ *
291
+ * This function creates a transaction to unlock a nominator's position,
292
+ * allowing them to withdraw their stake after the withdrawal period.
293
+ * This is typically used when a nominator wants to completely exit their
294
+ * position with an operator.
295
+ *
296
+ * @param params - StakingParams containing the operator information
297
+ * @param params.api - The connected API promise instance
298
+ * @param params.operatorId - The ID of the operator to unlock nominator from
299
+ * @returns A submittable unlock nominator transaction
300
+ * @throws Error if transaction creation fails
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * import { unlockNominator } from '@autonomys/auto-consensus'
305
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
306
+ *
307
+ * const api = await activate({ networkId: 'gemini-3h' })
308
+ *
309
+ * const unlockNominatorTx = unlockNominator({
310
+ * api,
311
+ * operatorId: '1'
312
+ * })
313
+ *
314
+ * await signAndSendTx(nominator, unlockNominatorTx)
315
+ * ```
316
+ */
12
317
  export declare const unlockNominator: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
13
318
  //# sourceMappingURL=staking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EAOJ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AASxB,eAAO,MAAM,SAAS,GAAU,KAAK,GAAG,kDAQvC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAU,KAAK,GAAG,EAAE,YAAY,oBAAoB,uDAQxE,CAAA;AAED,eAAO,MAAM,QAAQ,GACnB,KAAK,GAAG,EACR,YAAY,oBAAoB,EAChC,UAAS,MAAM,GAAG,SAAqB,iDAgBxC,CAAA;AAED,eAAO,MAAM,WAAW,GACtB,KAAK,GAAG,EACR,YAAY,oBAAoB,EAChC,UAAS,MAAM,GAAG,SAAqB,oDAkBxC,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAmB9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAS9D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,QAAQ,mBAAmB,wHAmBxD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,aAAa,wHASvD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAQ,aAAa,wHAShD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,wHASpD,CAAA"}
1
+ {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EAOJ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AASxB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,SAAS,GAAU,KAAK,GAAG,kDAQvC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,QAAQ,GAAU,KAAK,GAAG,EAAE,YAAY,oBAAoB,uDAQxE,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,QAAQ,GACnB,KAAK,GAAG,EACR,YAAY,oBAAoB,EAChC,UAAS,MAAM,GAAG,SAAqB,iDAgBxC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,GAAG,EACR,YAAY,oBAAoB,EAChC,UAAS,MAAM,GAAG,SAAqB,oDAkBxC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAmB9D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAS9D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,mBAAmB,wHAmBxD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,aAAa,wHASvD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,aAAa,wHAShD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,wHASpD,CAAA"}
package/dist/staking.js CHANGED
@@ -13,6 +13,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.unlockNominator = exports.unlockFunds = exports.deregisterOperator = exports.withdrawStake = exports.nominateOperator = exports.registerOperator = exports.withdrawals = exports.deposits = exports.operator = exports.operators = void 0;
14
14
  const auto_utils_1 = require("@autonomys/auto-utils");
15
15
  const parse_1 = require("./utils/parse");
16
+ /**
17
+ * Retrieves all registered operators on the network.
18
+ *
19
+ * This function queries the blockchain to get information about all operators
20
+ * that have been registered across all domains. Operators are entities that
21
+ * process transactions and maintain domain chains.
22
+ *
23
+ * @param api - The connected API instance
24
+ * @returns Promise that resolves to an array of Operator objects
25
+ * @throws Error if the operators query fails
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { operators } from '@autonomys/auto-consensus'
30
+ * import { activate } from '@autonomys/auto-utils'
31
+ *
32
+ * const api = await activate({ networkId: 'gemini-3h' })
33
+ * const allOperators = await operators(api)
34
+ *
35
+ * allOperators.forEach(op => {
36
+ * console.log(`Operator ${op.operatorId}: Domain ${op.operatorDetails.currentDomainId}`)
37
+ * console.log(`Total Stake: ${op.operatorDetails.currentTotalStake}`)
38
+ * })
39
+ * ```
40
+ */
16
41
  const operators = (api) => __awaiter(void 0, void 0, void 0, function* () {
17
42
  try {
18
43
  const _operators = yield api.query.domains.operators.entries();
@@ -24,6 +49,31 @@ const operators = (api) => __awaiter(void 0, void 0, void 0, function* () {
24
49
  }
25
50
  });
26
51
  exports.operators = operators;
52
+ /**
53
+ * Retrieves detailed information about a specific operator.
54
+ *
55
+ * This function queries information about a single operator including their
56
+ * signing key, domain assignment, stake amounts, and operational status.
57
+ *
58
+ * @param api - The connected API instance
59
+ * @param operatorId - The ID of the operator to query
60
+ * @returns Promise that resolves to OperatorDetails object
61
+ * @throws Error if the operator query fails or operator doesn't exist
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * import { operator } from '@autonomys/auto-consensus'
66
+ * import { activate } from '@autonomys/auto-utils'
67
+ *
68
+ * const api = await activate({ networkId: 'gemini-3h' })
69
+ * const operatorInfo = await operator(api, '1')
70
+ *
71
+ * console.log(`Domain: ${operatorInfo.currentDomainId}`)
72
+ * console.log(`Total Stake: ${operatorInfo.currentTotalStake}`)
73
+ * console.log(`Minimum Nominator Stake: ${operatorInfo.minimumNominatorStake}`)
74
+ * console.log(`Nomination Tax: ${operatorInfo.nominationTax}%`)
75
+ * ```
76
+ */
27
77
  const operator = (api, operatorId) => __awaiter(void 0, void 0, void 0, function* () {
28
78
  try {
29
79
  const _operator = yield api.query.domains.operators((0, parse_1.parseString)(operatorId));
@@ -35,6 +85,36 @@ const operator = (api, operatorId) => __awaiter(void 0, void 0, void 0, function
35
85
  }
36
86
  });
37
87
  exports.operator = operator;
88
+ /**
89
+ * Retrieves deposit information for an operator.
90
+ *
91
+ * This function queries all deposits (stakes) made to a specific operator.
92
+ * It can optionally filter deposits by a specific account address.
93
+ *
94
+ * @param api - The connected API instance
95
+ * @param operatorId - The ID of the operator to query deposits for
96
+ * @param account - Optional account address to filter deposits by
97
+ * @returns Promise that resolves to an array of Deposit objects
98
+ * @throws Error if the deposits query fails
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * import { deposits } from '@autonomys/auto-consensus'
103
+ * import { activate } from '@autonomys/auto-utils'
104
+ *
105
+ * const api = await activate({ networkId: 'gemini-3h' })
106
+ *
107
+ * // Get all deposits for operator
108
+ * const allDeposits = await deposits(api, '1')
109
+ *
110
+ * // Get deposits for specific account
111
+ * const accountDeposits = await deposits(api, '1', 'account_address')
112
+ *
113
+ * allDeposits.forEach(deposit => {
114
+ * console.log(`Account: ${deposit.account}, Shares: ${deposit.shares}`)
115
+ * })
116
+ * ```
117
+ */
38
118
  const deposits = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, operatorId_1, ...args_1], void 0, function* (api, operatorId, account = undefined) {
39
119
  try {
40
120
  if (account) {
@@ -54,6 +134,38 @@ const deposits = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, o
54
134
  }
55
135
  });
56
136
  exports.deposits = deposits;
137
+ /**
138
+ * Retrieves withdrawal information for an operator.
139
+ *
140
+ * This function queries all pending withdrawals for a specific operator.
141
+ * Withdrawals are stakes that have been requested to be unstaked but are
142
+ * still in the withdrawal period. Can optionally filter by account.
143
+ *
144
+ * @param api - The connected API instance
145
+ * @param operatorId - The ID of the operator to query withdrawals for
146
+ * @param account - Optional account address to filter withdrawals by
147
+ * @returns Promise that resolves to an array of Withdrawal objects
148
+ * @throws Error if the withdrawals query fails
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * import { withdrawals } from '@autonomys/auto-consensus'
153
+ * import { activate } from '@autonomys/auto-utils'
154
+ *
155
+ * const api = await activate({ networkId: 'gemini-3h' })
156
+ *
157
+ * // Get all withdrawals for operator
158
+ * const allWithdrawals = await withdrawals(api, '1')
159
+ *
160
+ * // Get withdrawals for specific account
161
+ * const accountWithdrawals = await withdrawals(api, '1', 'account_address')
162
+ *
163
+ * allWithdrawals.forEach(withdrawal => {
164
+ * console.log(`Account: ${withdrawal.account}`)
165
+ * console.log(`Total Withdrawal: ${withdrawal.totalWithdrawalAmount}`)
166
+ * })
167
+ * ```
168
+ */
57
169
  const withdrawals = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, operatorId_1, ...args_1], void 0, function* (api, operatorId, account = undefined) {
58
170
  try {
59
171
  if (account) {
@@ -75,6 +187,44 @@ const withdrawals = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1
75
187
  }
76
188
  });
77
189
  exports.withdrawals = withdrawals;
190
+ /**
191
+ * Creates a transaction to register a new operator.
192
+ *
193
+ * This function creates a transaction to register a new operator on a specific domain.
194
+ * The operator will be able to process transactions and earn rewards. Requires
195
+ * initial stake, minimum nominator stake, and nomination tax settings.
196
+ *
197
+ * @param params - RegisterOperatorParams containing all registration parameters
198
+ * @param params.api - The connected API promise instance
199
+ * @param params.domainId - The domain ID where the operator will be registered
200
+ * @param params.amountToStake - Initial amount to stake (in smallest token units)
201
+ * @param params.minimumNominatorStake - Minimum stake required from nominators
202
+ * @param params.nominationTax - Percentage fee charged to nominators
203
+ * @param params.signingKey - Optional signing key (derived from publicKey if not provided)
204
+ * @param params.publicKey - Optional public key (used to derive signingKey if needed)
205
+ * @returns A submittable operator registration transaction
206
+ * @throws Error if signing key/public key not provided or transaction creation fails
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * import { registerOperator } from '@autonomys/auto-consensus'
211
+ * import { activate, activateWallet, signAndSendTx } from '@autonomys/auto-utils'
212
+ *
213
+ * const api = await activate({ networkId: 'gemini-3h' })
214
+ * const { accounts } = await activateWallet({ networkId: 'gemini-3h', mnemonic })
215
+ *
216
+ * const registerTx = registerOperator({
217
+ * api,
218
+ * domainId: '0',
219
+ * amountToStake: '100000000000000000000', // 100 AI3
220
+ * minimumNominatorStake: '1000000000000000000', // 1 AI3
221
+ * nominationTax: '10', // 10%
222
+ * publicKey: accounts[0].publicKey
223
+ * })
224
+ *
225
+ * await signAndSendTx(accounts[0], registerTx)
226
+ * ```
227
+ */
78
228
  const registerOperator = (params) => {
79
229
  try {
80
230
  const { api, domainId, amountToStake, minimumNominatorStake, nominationTax, publicKey } = params;
@@ -97,6 +247,36 @@ const registerOperator = (params) => {
97
247
  }
98
248
  };
99
249
  exports.registerOperator = registerOperator;
250
+ /**
251
+ * Creates a transaction to nominate (stake to) an existing operator.
252
+ *
253
+ * This function creates a transaction to stake tokens to an existing operator.
254
+ * Nominators earn rewards proportional to their stake, minus the operator's
255
+ * nomination tax. The stake helps secure the network and the specific domain.
256
+ *
257
+ * @param params - NominateOperatorParams containing nomination parameters
258
+ * @param params.api - The connected API promise instance
259
+ * @param params.operatorId - The ID of the operator to nominate
260
+ * @param params.amountToStake - Amount to stake (in smallest token units)
261
+ * @returns A submittable operator nomination transaction
262
+ * @throws Error if transaction creation fails
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * import { nominateOperator } from '@autonomys/auto-consensus'
267
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
268
+ *
269
+ * const api = await activate({ networkId: 'gemini-3h' })
270
+ *
271
+ * const nominateTx = nominateOperator({
272
+ * api,
273
+ * operatorId: '1',
274
+ * amountToStake: '50000000000000000000' // 50 AI3
275
+ * })
276
+ *
277
+ * await signAndSendTx(nominator, nominateTx)
278
+ * ```
279
+ */
100
280
  const nominateOperator = (params) => {
101
281
  try {
102
282
  const { api, operatorId, amountToStake } = params;
@@ -108,6 +288,46 @@ const nominateOperator = (params) => {
108
288
  }
109
289
  };
110
290
  exports.nominateOperator = nominateOperator;
291
+ /**
292
+ * Creates a transaction to withdraw stake from an operator.
293
+ *
294
+ * This function creates a transaction to withdraw staked tokens from an operator.
295
+ * Supports different withdrawal modes: all stake, by percentage, by specific amount,
296
+ * or by number of shares. Withdrawn stake enters a withdrawal period before being available.
297
+ *
298
+ * @param params - WithdrawStakeParams containing withdrawal parameters
299
+ * @param params.api - The connected API promise instance
300
+ * @param params.operatorId - The ID of the operator to withdraw stake from
301
+ * @param params.all - Optional: withdraw all stake (boolean)
302
+ * @param params.percent - Optional: withdraw by percentage (string/number)
303
+ * @param params.stake - Optional: withdraw specific stake amount
304
+ * @param params.shares - Optional: withdraw specific number of shares
305
+ * @returns A submittable stake withdrawal transaction
306
+ * @throws Error if no withdrawal method specified or transaction creation fails
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * import { withdrawStake } from '@autonomys/auto-consensus'
311
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
312
+ *
313
+ * const api = await activate({ networkId: 'gemini-3h' })
314
+ *
315
+ * // Withdraw all stake
316
+ * const withdrawAllTx = withdrawStake({ api, operatorId: '1', all: true })
317
+ *
318
+ * // Withdraw 50% of stake
319
+ * const withdrawPercentTx = withdrawStake({ api, operatorId: '1', percent: '50' })
320
+ *
321
+ * // Withdraw specific amount
322
+ * const withdrawAmountTx = withdrawStake({
323
+ * api,
324
+ * operatorId: '1',
325
+ * stake: '25000000000000000000'
326
+ * })
327
+ *
328
+ * await signAndSendTx(staker, withdrawAllTx)
329
+ * ```
330
+ */
111
331
  const withdrawStake = (params) => {
112
332
  try {
113
333
  const { api, operatorId } = params;
@@ -130,6 +350,34 @@ const withdrawStake = (params) => {
130
350
  }
131
351
  };
132
352
  exports.withdrawStake = withdrawStake;
353
+ /**
354
+ * Creates a transaction to deregister an operator.
355
+ *
356
+ * This function creates a transaction to deregister an operator, removing them
357
+ * from active service. The operator will no longer process transactions or earn
358
+ * rewards. All stakes will enter the withdrawal period.
359
+ *
360
+ * @param params - StakingParams containing the operator information
361
+ * @param params.api - The connected API promise instance
362
+ * @param params.operatorId - The ID of the operator to deregister
363
+ * @returns A submittable operator deregistration transaction
364
+ * @throws Error if transaction creation fails
365
+ *
366
+ * @example
367
+ * ```typescript
368
+ * import { deregisterOperator } from '@autonomys/auto-consensus'
369
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
370
+ *
371
+ * const api = await activate({ networkId: 'gemini-3h' })
372
+ *
373
+ * const deregisterTx = deregisterOperator({
374
+ * api,
375
+ * operatorId: '1'
376
+ * })
377
+ *
378
+ * await signAndSendTx(operatorOwner, deregisterTx)
379
+ * ```
380
+ */
133
381
  const deregisterOperator = (params) => {
134
382
  try {
135
383
  const { api, operatorId } = params;
@@ -141,6 +389,34 @@ const deregisterOperator = (params) => {
141
389
  }
142
390
  };
143
391
  exports.deregisterOperator = deregisterOperator;
392
+ /**
393
+ * Creates a transaction to unlock funds from an operator.
394
+ *
395
+ * This function creates a transaction to unlock funds that have completed
396
+ * their withdrawal period. These are funds that were previously withdrawn
397
+ * and have now passed the required waiting period.
398
+ *
399
+ * @param params - StakingParams containing the operator information
400
+ * @param params.api - The connected API promise instance
401
+ * @param params.operatorId - The ID of the operator to unlock funds from
402
+ * @returns A submittable unlock funds transaction
403
+ * @throws Error if transaction creation fails
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * import { unlockFunds } from '@autonomys/auto-consensus'
408
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
409
+ *
410
+ * const api = await activate({ networkId: 'gemini-3h' })
411
+ *
412
+ * const unlockTx = unlockFunds({
413
+ * api,
414
+ * operatorId: '1'
415
+ * })
416
+ *
417
+ * await signAndSendTx(account, unlockTx)
418
+ * ```
419
+ */
144
420
  const unlockFunds = (params) => {
145
421
  try {
146
422
  const { api, operatorId } = params;
@@ -152,6 +428,35 @@ const unlockFunds = (params) => {
152
428
  }
153
429
  };
154
430
  exports.unlockFunds = unlockFunds;
431
+ /**
432
+ * Creates a transaction to unlock a nominator from an operator.
433
+ *
434
+ * This function creates a transaction to unlock a nominator's position,
435
+ * allowing them to withdraw their stake after the withdrawal period.
436
+ * This is typically used when a nominator wants to completely exit their
437
+ * position with an operator.
438
+ *
439
+ * @param params - StakingParams containing the operator information
440
+ * @param params.api - The connected API promise instance
441
+ * @param params.operatorId - The ID of the operator to unlock nominator from
442
+ * @returns A submittable unlock nominator transaction
443
+ * @throws Error if transaction creation fails
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * import { unlockNominator } from '@autonomys/auto-consensus'
448
+ * import { activate, signAndSendTx } from '@autonomys/auto-utils'
449
+ *
450
+ * const api = await activate({ networkId: 'gemini-3h' })
451
+ *
452
+ * const unlockNominatorTx = unlockNominator({
453
+ * api,
454
+ * operatorId: '1'
455
+ * })
456
+ *
457
+ * await signAndSendTx(nominator, unlockNominatorTx)
458
+ * ```
459
+ */
155
460
  const unlockNominator = (params) => {
156
461
  try {
157
462
  const { api, operatorId } = params;