-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f958498
commit 1094ede
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { AVAX_PUBLIC_URL } from '../constants/public-urls'; | ||
import { Api } from '../vms/common/baseApi'; | ||
import type { | ||
GetBlockchainIDResponse, | ||
GetNetworkIdResponse, | ||
GetNetworkNameResponse, | ||
GetNodeIdResponse, | ||
GetNodeIpResponse, | ||
GetNodeVersionReply, | ||
GetPeersResponse, | ||
GetTxFeeResponse, | ||
isBootstrapped, | ||
UptimeResponse, | ||
GetUpgradesInfoResponse, | ||
} from './model'; | ||
|
||
export class InfoApi extends Api { | ||
constructor(private readonly baseURL: string = AVAX_PUBLIC_URL) { | ||
super(baseURL, '/ext/info', 'info'); | ||
} | ||
|
||
getNodeVersion(): Promise<GetNodeVersionReply> { | ||
return this.callRpc<GetNodeVersionReply>('getNodeVersion'); | ||
} | ||
|
||
async getNodeId(): Promise<GetNodeIdResponse> { | ||
return this.callRpc<GetNodeIdResponse>('getNodeID'); | ||
} | ||
|
||
getNodeIp(): Promise<GetNodeIpResponse> { | ||
return this.callRpc<GetNodeIpResponse>('getNodeIP'); | ||
} | ||
|
||
getNetworkId(): Promise<GetNetworkIdResponse> { | ||
return this.callRpc<GetNetworkIdResponse>('getNetworkID'); | ||
} | ||
|
||
getNetworkName(): Promise<GetNetworkNameResponse> { | ||
return this.callRpc<GetNetworkNameResponse>('getNetworkName'); | ||
} | ||
|
||
getBlockchainId(alias: string): Promise<GetBlockchainIDResponse> { | ||
return this.callRpc<GetBlockchainIDResponse>('getBlockchainID', { alias }); | ||
} | ||
|
||
peers(nodeIDs?: string[]): Promise<GetPeersResponse> { | ||
return this.callRpc<GetPeersResponse>('peers', { nodeIDs }); | ||
} | ||
|
||
isBootstrapped(chain: string): Promise<isBootstrapped> { | ||
return this.callRpc<isBootstrapped>('peers', { chain }); | ||
} | ||
/** | ||
* @link https://docs.avax.network/apis/avalanchego/apis/info#infogettxfee | ||
*/ | ||
async getTxFee(): Promise<GetTxFeeResponse> { | ||
const resp = await this.callRpc<GetTxFeeResponse>('getTxFee'); | ||
|
||
return { | ||
txFee: BigInt(resp.txFee), | ||
createAssetTxFee: BigInt(resp.createAssetTxFee), | ||
createSubnetTxFee: BigInt(resp.createSubnetTxFee), | ||
transformSubnetTxFee: BigInt(resp.transformSubnetTxFee), | ||
createBlockchainTxFee: BigInt(resp.createBlockchainTxFee), | ||
addPrimaryNetworkValidatorFee: BigInt(resp.addPrimaryNetworkValidatorFee), | ||
addPrimaryNetworkDelegatorFee: BigInt(resp.addPrimaryNetworkDelegatorFee), | ||
addSubnetValidatorFee: BigInt(resp.addSubnetValidatorFee), | ||
addSubnetDelegatorFee: BigInt(resp.addSubnetDelegatorFee), | ||
}; | ||
} | ||
|
||
uptime(): Promise<UptimeResponse> { | ||
return this.callRpc<UptimeResponse>('uptime'); | ||
} | ||
|
||
getVMs(): Promise<Map<string, string[]>> { | ||
return this.callRpc<Map<string, string[]>>('getVMs'); | ||
} | ||
|
||
// Post-Etna API | ||
|
||
// get upgrades info | ||
getUpgradesInfo(): Promise<GetUpgradesInfoResponse> { | ||
return this.callRpc<GetUpgradesInfoResponse>('upgrades'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './api'; | ||
export * from './model'; |