|
| 1 | +import { PChainOwner } from '../../serializable'; |
1 | 2 | import { TransferableOutput } from '../../serializable/avax';
|
2 | 3 | import { Utxo } from '../../serializable/avax/utxo';
|
3 | 4 | import { getPVMManager } from '../../serializable/pvm/codec';
|
4 |
| -import { hexToBuffer } from '../../utils'; |
| 5 | +import { hexToBuffer, parse } from '../../utils'; |
5 | 6 | import type { GetAssetDescriptionResponse } from '../common/apiModels';
|
6 | 7 | import { AvaxApi } from '../common/avaxApi';
|
7 | 8 | import { createDimensions } from '../common/fees/dimensions';
|
8 | 9 | import type {
|
| 10 | + GetL1ValidatorResponse, |
| 11 | + L1ValidatorDetails, |
9 | 12 | FeeConfig,
|
10 | 13 | FeeConfigResponse,
|
11 | 14 | FeeState,
|
@@ -266,4 +269,29 @@ export class PVMApi extends AvaxApi {
|
266 | 269 | timestamp: resp.timestamp,
|
267 | 270 | };
|
268 | 271 | }
|
| 272 | + |
| 273 | + async getL1Validator(validationID: string): Promise<L1ValidatorDetails> { |
| 274 | + const resp = await this.callRpc<GetL1ValidatorResponse>('getL1Validator', { |
| 275 | + validationID, |
| 276 | + }); |
| 277 | + |
| 278 | + const deactivationOwner = PChainOwner.fromNative( |
| 279 | + resp.deactivationOwner.addresses.map((a) => parse(a)[2]), |
| 280 | + Number(resp.deactivationOwner.threshold), |
| 281 | + ); |
| 282 | + const remainingBalanceOwner = PChainOwner.fromNative( |
| 283 | + resp.remainingBalanceOwner.addresses.map((a) => parse(a)[2]), |
| 284 | + Number(resp.remainingBalanceOwner.threshold), |
| 285 | + ); |
| 286 | + |
| 287 | + return { |
| 288 | + balance: BigInt(resp.balance), |
| 289 | + nodeID: resp.nodeID, |
| 290 | + publicKey: resp.publicKey, |
| 291 | + subnetID: resp.subnetID, |
| 292 | + weight: BigInt(resp.weight), |
| 293 | + deactivationOwner, |
| 294 | + remainingBalanceOwner, |
| 295 | + }; |
| 296 | + } |
269 | 297 | }
|
0 commit comments