File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ import yargs from "yargs" ;
2
+ import { hideBin } from "yargs/helpers" ;
3
+ import {
4
+ AptosContract ,
5
+ CosmWasmContract ,
6
+ DefaultStore ,
7
+ EvmContract ,
8
+ } from "../src" ;
9
+ import { PriceServiceConnection } from "@pythnetwork/price-service-client" ;
10
+
11
+ const parser = yargs ( hideBin ( process . argv ) )
12
+ . usage ( "Usage: $0" )
13
+ . options ( {
14
+ testnet : {
15
+ type : "boolean" ,
16
+ default : false ,
17
+ desc : "Fetch testnet contract fees instead of mainnet" ,
18
+ } ,
19
+ } ) ;
20
+
21
+ async function main ( ) {
22
+ const argv = await parser . argv ;
23
+ for ( const contract of Object . values ( DefaultStore . contracts ) ) {
24
+ if ( contract . getChain ( ) . isMainnet ( ) === argv . testnet ) continue ;
25
+ if (
26
+ contract instanceof AptosContract ||
27
+ contract instanceof EvmContract ||
28
+ contract instanceof CosmWasmContract
29
+ ) {
30
+ console . log ( `${ contract . getId ( ) } ${ await contract . getTotalFee ( ) } ` ) ;
31
+ }
32
+ }
33
+ }
34
+
35
+ main ( ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Contract, PriceFeed } from "../base";
2
2
import { AptosAccount , BCS , TxnBuilderTypes } from "aptos" ;
3
3
import { AptosChain , Chain } from "../chains" ;
4
4
import { DataSource } from "xc_admin_common" ;
5
+ import { CoinClient } from "aptos" ;
5
6
6
7
export class AptosContract extends Contract {
7
8
static type : string = "AptosContract" ;
@@ -174,6 +175,11 @@ export class AptosContract extends Contract {
174
175
return AptosContract . type ;
175
176
}
176
177
178
+ async getTotalFee ( ) : Promise < bigint > {
179
+ const client = new CoinClient ( this . chain . getClient ( ) ) ;
180
+ return await client . checkBalance ( this . stateId ) ;
181
+ }
182
+
177
183
async getValidTimePeriod ( ) {
178
184
const data = ( await this . findResource ( "StalePriceThreshold" ) ) as any ;
179
185
return Number ( data . threshold_secs ) ;
Original file line number Diff line number Diff line change @@ -368,6 +368,15 @@ export class CosmWasmContract extends Contract {
368
368
return this . chain ;
369
369
}
370
370
371
+ async getTotalFee ( ) : Promise < bigint > {
372
+ const client = await CosmWasmClient . connect ( this . chain . endpoint ) ;
373
+ const coin = await client . getBalance (
374
+ this . address ,
375
+ this . getChain ( ) . feeDenom
376
+ ) ;
377
+ return BigInt ( coin . amount ) ;
378
+ }
379
+
371
380
async getValidTimePeriod ( ) {
372
381
let client = await CosmWasmClient . connect ( this . chain . endpoint ) ;
373
382
let result = await client . queryContractSmart (
Original file line number Diff line number Diff line change @@ -346,6 +346,11 @@ export class EvmContract extends Contract {
346
346
return Web3 . utils . keccak256 ( strippedCode ) ;
347
347
}
348
348
349
+ async getTotalFee ( ) : Promise < bigint > {
350
+ const web3 = new Web3 ( this . chain . getRpcUrl ( ) ) ;
351
+ return BigInt ( await web3 . eth . getBalance ( this . address ) ) ;
352
+ }
353
+
349
354
async getLastExecutedGovernanceSequence ( ) {
350
355
const pythContract = await this . getContract ( ) ;
351
356
return Number (
Original file line number Diff line number Diff line change 3
3
wormholeChainName : injective
4
4
mainnet : true
5
5
type : CosmWasmChain
6
+ feeDenom : inj
6
7
- endpoint : https://rpc.atlantic-2.seinetwork.io/
7
8
id : sei_testnet_atlantic_2
8
9
wormholeChainName : sei_testnet_atlantic_2
23
24
id : injective_testnet
24
25
wormholeChainName : injective_testnet
25
26
mainnet : false
27
+ feeDenom : inj
26
28
type : CosmWasmChain
27
29
- endpoint : https://rpc-palvus.pion-1.ntrn.tech/
28
30
id : neutron_testnet_pion_1
You can’t perform that action at this time.
0 commit comments