|
@@ -16,15 +16,15 @@ import {
|
|
|
MsgTransfer,
|
|
|
Wallet,
|
|
|
} from '@initia/initia.js'
|
|
|
-import { generateRandomString, getProxyUrl } from './utils'
|
|
|
+import { generateRandomString, getAxiosClient, getProxyUrl } from './utils'
|
|
|
import { HttpsProxyAgent } from 'https-proxy-agent'
|
|
|
|
|
|
const rpcUrl = [
|
|
|
'https://lcd.initiation-1.initia.xyz/',
|
|
|
'https://api-initia-testnet.whispernode.com/',
|
|
|
- 'https://initia-testnet-lcd.orbitalcommand.io/',
|
|
|
+ // 'https://initia-testnet-lcd.orbitalcommand.io/',
|
|
|
'https://testnet-initia-api.lavenderfive.com/',
|
|
|
- 'https://api.initiation.test.pfc.zone/',
|
|
|
+ // 'https://api.initiation.test.pfc.zone/',
|
|
|
]
|
|
|
|
|
|
export abstract class BaseClient {
|
|
@@ -36,7 +36,7 @@ export abstract class BaseClient {
|
|
|
wallet: Wallet
|
|
|
tucanaWallet: Wallet
|
|
|
rpcUrlUsing: string
|
|
|
- protected constructor(mnemonic: string, useProxy: boolean = false) {
|
|
|
+ protected constructor(mnemonic: string, useProxy: boolean = true) {
|
|
|
this.key = new MnemonicKey({
|
|
|
mnemonic: mnemonic,
|
|
|
})
|
|
@@ -104,12 +104,22 @@ export abstract class BaseClient {
|
|
|
}
|
|
|
|
|
|
async broadcast(msg: Msg | Msg[]) {
|
|
|
+ const randLimit = 160000 + Math.floor(Math.random() * 10000)
|
|
|
const signed = await this.wallet.createAndSignTx({
|
|
|
msgs: Array.isArray(msg) ? msg : [msg],
|
|
|
- feeDenoms: ['uinit'],
|
|
|
+ fee: new Fee(
|
|
|
+ randLimit,
|
|
|
+ new Coins([
|
|
|
+ new Coin(
|
|
|
+ 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
|
|
|
+ randLimit.toString(),
|
|
|
+ ),
|
|
|
+ ]),
|
|
|
+ ),
|
|
|
})
|
|
|
- const broadcast = await this.lcd.tx.broadcast(signed)
|
|
|
- console.log(broadcast)
|
|
|
+ const broadcast = await this.lcd.tx.broadcastAsync(signed)
|
|
|
+ // console.log(broadcast.raw_log)
|
|
|
+ // console.log(this.key.accAddress)
|
|
|
return broadcast.txhash
|
|
|
// console.log(broadcast)
|
|
|
}
|
|
@@ -119,6 +129,24 @@ export abstract class BaseClient {
|
|
|
return balances[0].toArray()
|
|
|
}
|
|
|
|
|
|
+ async axiosBalance() {
|
|
|
+ const axios = getAxiosClient(true)
|
|
|
+ const res = await axios.get(
|
|
|
+ `https://celatone-api-prod.alleslabs.dev/v1/initia/initiation-1/accounts/${this.key.accAddress}/balances`,
|
|
|
+ )
|
|
|
+ return res.data
|
|
|
+ }
|
|
|
+
|
|
|
+ async gasGot() {
|
|
|
+ const balances = await this.axiosBalance()
|
|
|
+ const gas = balances.filter(
|
|
|
+ token =>
|
|
|
+ token.denom ===
|
|
|
+ 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
|
|
|
+ )
|
|
|
+ return gas.length > 0
|
|
|
+ }
|
|
|
+
|
|
|
async funded() {
|
|
|
const tokens = await this.checkBalance()
|
|
|
const uinit = tokens.filter(token => token.denom === 'uinit')[0]
|