BaseClient.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. import {
  2. APIRequester,
  3. bcs,
  4. Coin,
  5. Coins,
  6. Fee,
  7. Height,
  8. LCDClient,
  9. MnemonicKey,
  10. Msg,
  11. MsgExecute,
  12. MsgInitiateTokenDeposit,
  13. MsgTransfer,
  14. Wallet,
  15. } from '@initia/initia.js'
  16. import { generateRandomString, getAxiosClient } from './utils'
  17. import { HttpsProxyAgent } from 'https-proxy-agent'
  18. const rpcUrl = [
  19. 'https://lcd.initiation-1.initia.xyz/',
  20. 'https://api-initia-testnet.whispernode.com/',
  21. 'https://initia-testnet-lcd.orbitalcommand.io/',
  22. 'https://testnet-initia-api.lavenderfive.com/',
  23. 'https://api.initiation.test.pfc.zone/',
  24. ]
  25. export abstract class BaseClient {
  26. key: MnemonicKey
  27. lcd: LCDClient
  28. tucana: LCDClient
  29. initAi: LCDClient
  30. civi: LCDClient
  31. blackWings: LCDClient
  32. noon: LCDClient
  33. miniMove: LCDClient
  34. wallet: Wallet
  35. tucanaWallet: Wallet
  36. rpcUrlUsing: string
  37. protected constructor(mnemonic: string, useProxy: boolean = true) {
  38. this.key = new MnemonicKey({
  39. mnemonic: mnemonic,
  40. })
  41. const rpc = rpcUrl[Math.floor(Math.random() * rpcUrl.length)]
  42. this.rpcUrlUsing = rpc
  43. const pass = `test1234_session-${generateRandomString(8)}_lifetime-20m`
  44. const proxyAgent = useProxy
  45. ? new HttpsProxyAgent(`http://tuxla:${pass}@geo.iproyal.com:12321`)
  46. : undefined
  47. const username = `u3e4c2852572e05c5-zone-custom-session-${generateRandomString(
  48. 9,
  49. )}-sessTime-20`
  50. const password = 'u3e4c2852572e05c5'
  51. // const proxyAgent = new HttpsProxyAgent(
  52. // `http://${username}:${password}@43.152.113.55:2334`,
  53. // )
  54. const requester = new APIRequester(rpc, {
  55. httpsAgent: proxyAgent,
  56. headers: {
  57. 'User-Agent':
  58. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  59. 'Sec-Ch-Ua':
  60. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  61. 'Sec-Ch-Ua-Mobile': '?0',
  62. 'Sec-Ch-Ua-Platform': '"Windows"',
  63. // Origin: 'https://faucet.testnet.initia.xyz/',
  64. // Referer: 'https://faucet.testnet.initia.xyz/',
  65. 'Sec-Fetch-Dest': 'empty',
  66. 'Sec-Fetch-Mode': 'cors',
  67. 'Sec-Fetch-Site': 'same-site',
  68. },
  69. })
  70. this.lcd = new LCDClient(
  71. rpc,
  72. {
  73. chainId: 'initiation-1',
  74. },
  75. useProxy ? requester : null,
  76. )
  77. const noonRequester = new APIRequester(
  78. 'https://burrito-1-lcd.lunchlunch.xyz/',
  79. {
  80. httpsAgent: proxyAgent,
  81. headers: {
  82. 'User-Agent':
  83. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  84. 'Sec-Ch-Ua':
  85. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  86. 'Sec-Ch-Ua-Mobile': '?0',
  87. 'Sec-Ch-Ua-Platform': '"Windows"',
  88. // Origin: 'https://faucet.testnet.initia.xyz/',
  89. // Referer: 'https://faucet.testnet.initia.xyz/',
  90. 'Sec-Fetch-Dest': 'empty',
  91. 'Sec-Fetch-Mode': 'cors',
  92. 'Sec-Fetch-Site': 'same-site',
  93. },
  94. },
  95. )
  96. this.noon = new LCDClient(
  97. 'https://burrito-1-lcd.lunchlunch.xyz/',
  98. { chainId: 'burrito-1' },
  99. useProxy ? noonRequester : null,
  100. )
  101. const miniMoveRequester = new APIRequester(
  102. 'https://lcd.minimove-1.initia.xyz',
  103. {
  104. httpsAgent: proxyAgent,
  105. headers: {
  106. 'User-Agent':
  107. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  108. 'Sec-Ch-Ua':
  109. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  110. 'Sec-Ch-Ua-Mobile': '?0',
  111. 'Sec-Ch-Ua-Platform': '"Windows"',
  112. // Origin: 'https://faucet.testnet.initia.xyz/',
  113. // Referer: 'https://faucet.testnet.initia.xyz/',
  114. 'Sec-Fetch-Dest': 'empty',
  115. 'Sec-Fetch-Mode': 'cors',
  116. 'Sec-Fetch-Site': 'same-site',
  117. },
  118. },
  119. )
  120. this.miniMove = new LCDClient(
  121. 'https://lcd.minimove-1.initia.xyz',
  122. { chainId: 'minimove-1' },
  123. useProxy ? miniMoveRequester : null,
  124. )
  125. const tucanaMoveRequester = new APIRequester(
  126. 'https://maze-rest-c9796789-107d-49ab-b6de-059724d2a91d.ue1-prod.newmetric.xyz/',
  127. {
  128. httpsAgent: proxyAgent,
  129. headers: {
  130. 'User-Agent':
  131. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  132. 'Sec-Ch-Ua':
  133. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  134. 'Sec-Ch-Ua-Mobile': '?0',
  135. 'Sec-Ch-Ua-Platform': '"Windows"',
  136. // Origin: 'https://faucet.testnet.initia.xyz/',
  137. // Referer: 'https://faucet.testnet.initia.xyz/',
  138. 'Sec-Fetch-Dest': 'empty',
  139. 'Sec-Fetch-Mode': 'cors',
  140. 'Sec-Fetch-Site': 'same-site',
  141. },
  142. },
  143. )
  144. this.tucana = new LCDClient(
  145. 'https://maze-rest-c9796789-107d-49ab-b6de-059724d2a91d.ue1-prod.newmetric.xyz/',
  146. {
  147. chainId: 'birdee-1',
  148. },
  149. useProxy ? tucanaMoveRequester : null,
  150. )
  151. const civiMoveRequester = new APIRequester(
  152. 'https://maze-rest-sequencer-beab9b6f-d96d-435e-9caf-5679296d8172.ue1-prod.newmetric.xyz',
  153. {
  154. httpsAgent: proxyAgent,
  155. headers: {
  156. 'User-Agent':
  157. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  158. 'Sec-Ch-Ua':
  159. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  160. 'Sec-Ch-Ua-Mobile': '?0',
  161. 'Sec-Ch-Ua-Platform': '"Windows"',
  162. // Origin: 'https://faucet.testnet.initia.xyz/',
  163. // Referer: 'https://faucet.testnet.initia.xyz/',
  164. 'Sec-Fetch-Dest': 'empty',
  165. 'Sec-Fetch-Mode': 'cors',
  166. 'Sec-Fetch-Site': 'same-site',
  167. },
  168. },
  169. )
  170. this.civi = new LCDClient(
  171. 'https://maze-rest-sequencer-beab9b6f-d96d-435e-9caf-5679296d8172.ue1-prod.newmetric.xyz',
  172. {
  173. chainId: 'landlord-1',
  174. },
  175. useProxy ? civiMoveRequester : null,
  176. )
  177. const blackWingsMoveRequester = new APIRequester(
  178. 'https://maze-rest-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ue1-prod.newmetric.xyz',
  179. {
  180. httpsAgent: proxyAgent,
  181. headers: {
  182. 'User-Agent':
  183. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  184. 'Sec-Ch-Ua':
  185. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  186. 'Sec-Ch-Ua-Mobile': '?0',
  187. 'Sec-Ch-Ua-Platform': '"Windows"',
  188. // Origin: 'https://faucet.testnet.initia.xyz/',
  189. // Referer: 'https://faucet.testnet.initia.xyz/',
  190. 'Sec-Fetch-Dest': 'empty',
  191. 'Sec-Fetch-Mode': 'cors',
  192. 'Sec-Fetch-Site': 'same-site',
  193. },
  194. },
  195. )
  196. this.blackWings = new LCDClient(
  197. 'https://maze-rest-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ue1-prod.newmetric.xyz',
  198. {
  199. chainId: 'tomcat-1',
  200. },
  201. useProxy ? blackWingsMoveRequester : null,
  202. )
  203. const initAiRequester = new APIRequester(
  204. 'https://maze-rest-617bacff-7d34-4eb8-87f4-ee16fb4e0ac7.ue1-prod.newmetric.xyz',
  205. {
  206. httpsAgent: proxyAgent,
  207. headers: {
  208. 'User-Agent':
  209. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
  210. 'Sec-Ch-Ua':
  211. '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
  212. 'Sec-Ch-Ua-Mobile': '?0',
  213. 'Sec-Ch-Ua-Platform': '"Windows"',
  214. // Origin: 'https://faucet.testnet.initia.xyz/',
  215. // Referer: 'https://faucet.testnet.initia.xyz/',
  216. 'Sec-Fetch-Dest': 'empty',
  217. 'Sec-Fetch-Mode': 'cors',
  218. 'Sec-Fetch-Site': 'same-site',
  219. },
  220. },
  221. )
  222. this.initAi = new LCDClient(
  223. 'https://maze-rest-617bacff-7d34-4eb8-87f4-ee16fb4e0ac7.ue1-prod.newmetric.xyz',
  224. {
  225. chainId: 'init-ai-1',
  226. },
  227. useProxy ? initAiRequester : null,
  228. )
  229. this.wallet = new Wallet(this.lcd, this.key)
  230. }
  231. async broadcast(msg: Msg | Msg[]) {
  232. // const randLimit = 160000 + Math.floor(Math.random() * 10000)
  233. const simulate = await this.lcd.tx.estimateFee(
  234. [{ sequenceNumber: await this.wallet.sequence() }],
  235. {
  236. msgs: Array.isArray(msg) ? msg : [msg],
  237. },
  238. )
  239. // console.log('simulate', simulate)
  240. // console.log('simulate2', simulate.amount.toArray()[0].amount)
  241. const signed = await this.wallet.createAndSignTx({
  242. msgs: Array.isArray(msg) ? msg : [msg],
  243. fee: new Fee(
  244. simulate.gas_limit,
  245. new Coins([
  246. new Coin(
  247. 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
  248. simulate.amount.toArray()[0].amount,
  249. ),
  250. ]),
  251. ),
  252. })
  253. // return `1`
  254. // const signed2 = await this.wallet.createAndSignTx({
  255. // msgs: Array.isArray(msg) ? msg : [msg],
  256. // fee: new Fee(
  257. // Math.floor(Number(simulate) * 1.1),
  258. // new Coins([
  259. // new Coin(
  260. // 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
  261. // Math.floor(Number(simulate) * 1.05),
  262. // ),
  263. // ]),
  264. // ),
  265. // })
  266. const broadcast = await this.lcd.tx.broadcastAsync(signed)
  267. return broadcast.txhash
  268. }
  269. randomAmount(min: number, max: number) {
  270. return Math.floor(Math.random() * (max - min) + min)
  271. }
  272. async checkBalance() {
  273. const balances = await this.lcd.bank.balance(this.key.accAddress)
  274. return balances[0].toArray()
  275. }
  276. async axiosBalance() {
  277. const axios = getAxiosClient(true)
  278. const res = await axios.get(
  279. `https://celatone-api-prod.alleslabs.dev/v1/initia/initiation-1/accounts/${this.key.accAddress}/balances`,
  280. )
  281. return res.data
  282. }
  283. async getGasAmount() {
  284. // const balances = await this.axiosBalance()
  285. // const balances = await this.axiosBalance()
  286. const balances = (await this.lcd.bank.balance(this.key.accAddress))[0]
  287. try {
  288. const usdc = balances.filter(
  289. token =>
  290. token.denom ===
  291. 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
  292. )
  293. return Number(usdc.toArray()[0].amount)
  294. } catch (e) {
  295. throw new Error('..')
  296. }
  297. }
  298. async gasGot() {
  299. const balances = await this.lcd.bank.balanceByDenom(
  300. this.key.accAddress,
  301. 'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
  302. )
  303. return Number(balances.amount) > 3500000
  304. }
  305. async funded() {
  306. const tokens = await this.checkBalance()
  307. const uinit = tokens.filter(token => token.denom === 'uinit')[0]
  308. return Number(uinit.amount) > 0
  309. }
  310. async checkTucanaBalance() {
  311. const balances = await this.tucana.bank.balance(this.key.accAddress)
  312. const tuc = balances[0].toArray().filter(token => token.denom === 'utuc')[0]
  313. return tuc.amount
  314. }
  315. async needBlackWingsInit() {
  316. const balances = await this.blackWings.bank.balance(this.key.accAddress)
  317. const blackWings = balances[0]
  318. .toArray()
  319. .filter(
  320. token =>
  321. token.denom ===
  322. 'l2/aee375e9d0b181f0d9d3a49f9a3d1d6b05d62b0ac81f8c92b9282afa4213d884',
  323. )[0]
  324. return Number(blackWings.amount) < 1000000
  325. }
  326. async checkBlackWingsBalance() {
  327. try {
  328. const balances = await this.blackWings.bank.balance(this.key.accAddress)
  329. return balances[0].toArray()
  330. } catch (e) {
  331. throw new Error('..')
  332. }
  333. }
  334. async checkAiBalance() {
  335. try {
  336. const balances = await this.initAi.bank.balance(this.key.accAddress)
  337. return balances[0].toArray()
  338. } catch (e) {
  339. throw new Error('..')
  340. }
  341. }
  342. async checkUsdcSwaped() {
  343. const tokens = await this.checkBalance()
  344. try {
  345. const usdc = tokens.filter(token => token.denom === 'uusdc')[0]
  346. return Number(usdc.amount) > 2000000
  347. } catch (e) {
  348. console.log(`error`)
  349. throw new Error('..')
  350. }
  351. }
  352. async checkTiaSwaped() {
  353. const tokens = await this.checkBalance()
  354. const usdc = tokens.filter(token => token.denom === 'utia')[0]
  355. return !!usdc
  356. }
  357. async checkEthSwaped() {
  358. const tokens = await this.checkBalance()
  359. try {
  360. const usdc = tokens.filter(token => token.denom === 'ueth')[0]
  361. return !!usdc
  362. } catch (e) {
  363. return false
  364. }
  365. }
  366. async getUsdcAmount() {
  367. const tokens = await this.checkBalance()
  368. const usdc = tokens.filter(token => token.denom === 'uusdc')[0]
  369. return usdc.amount
  370. }
  371. async getTargetAmount(toAddr: string) {
  372. const data = await this.lcd.bank.balance(toAddr)
  373. const tokens = data[0].toArray()
  374. try {
  375. console.log(tokens)
  376. const usdc = tokens.filter(token => token.denom === 'uinit')[0]
  377. return usdc.amount
  378. } catch (e) {
  379. return 0
  380. }
  381. }
  382. async getInitAmount() {
  383. const tokens = await this.checkBalance()
  384. try {
  385. console.log(tokens)
  386. const usdc = tokens.filter(token => token.denom === 'uinit')[0]
  387. return usdc.amount
  388. } catch (e) {
  389. return 0
  390. }
  391. }
  392. async getTiaAmount() {
  393. const tokens = await this.checkBalance()
  394. try {
  395. const usdc = tokens.filter(token => token.denom === 'utia')[0]
  396. return usdc.amount
  397. } catch (e) {
  398. return 0
  399. }
  400. }
  401. async getEthAmount() {
  402. const tokens = await this.checkBalance()
  403. try {
  404. const usdc = tokens.filter(token => token.denom === 'ueth')[0]
  405. return usdc.amount
  406. } catch (e) {
  407. return 0
  408. }
  409. }
  410. async bridge() {
  411. const size = bcs.option(bcs.u64()).serialize(0).toBase64()
  412. const balance = await this.checkTucanaBalance()
  413. console.log('balance', balance)
  414. const randomLimit = 70000 + Math.floor(Math.random() * 1000)
  415. const value = Number(balance) - randomLimit
  416. const size2 = bcs.option(bcs.u64()).serialize(value.toString()).toBase64()
  417. const msgs = [
  418. new MsgTransfer(
  419. 'transfer', // port
  420. 'channel-0', // src channel
  421. new Coin('utuc', value), // amount
  422. this.key.accAddress, // sender
  423. '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a::swap_transfer::mixed_route_swap_to',
  424. // receiver
  425. // you have to provide one of timeout
  426. new Height(0, 0), // timeout height
  427. ((new Date().valueOf() + 3500000) * 1000000).toString(), // timeout timestamp
  428. // timeout timestamp
  429. `{"move":{"message":{"module_address":"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a","module_name":"swap_transfer","function_name":"mixed_route_swap_to","type_args":[],"args":["KxToiwb36zAB/GsetggCNYVVpN+xpO02UHMJotdmzk0=","AQIBACBjlv8aKTjnJqzBAbnFQUuAXZpgXAPI4IMk9cDIgH98vA==",${size2},${size},${bcs
  430. .address()
  431. .serialize(this.key.accAddress)
  432. .toBase64()}]}}}`,
  433. ),
  434. ]
  435. const fee = {
  436. amount: [
  437. {
  438. amount: '62579',
  439. denom: 'utuc',
  440. },
  441. ],
  442. gasLimit: '417192',
  443. granter: '',
  444. payer: '',
  445. }
  446. // 创建 Coins 实例
  447. const coin = new Coin('utuc', '70000')
  448. const coins = new Coins()
  449. coins.add(coin)
  450. // 创建 Fee 实例
  451. const feeInstance = new Fee(
  452. parseInt(fee.gasLimit, 10), // gas_limit
  453. coins, // amount
  454. fee.payer, // payer (optional)
  455. fee.granter, // granter (optional)
  456. )
  457. const signedTx = await this.tucanaWallet.createAndSignTx({
  458. msgs,
  459. fee: feeInstance,
  460. })
  461. await this.tucana.tx.broadcastSync(signedTx).then(res => console.log(res))
  462. }
  463. async bridge2Blackwings(amount: number) {
  464. const size = bcs.option(bcs.u64()).serialize(0).toBase64()
  465. const size2 = bcs
  466. .u64()
  467. .serialize(amount * Math.pow(10, 6))
  468. .toBase64()
  469. const msg = new MsgExecute(
  470. this.key.accAddress,
  471. '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
  472. 'swap_transfer',
  473. 'mixed_route_swap_transfer',
  474. [],
  475. [
  476. 'jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
  477. 'AQIBACDb8GxIrzmE7G2a6KmqfbsLseeEqpuMSlaBr2YM+FWNfQ==',
  478. size2,
  479. size,
  480. bcs.string().serialize(this.key.accAddress).toBase64(),
  481. 'CHRyYW5zZmVy',
  482. 'CmNoYW5uZWwtMTM=',
  483. 'AA==',
  484. ],
  485. )
  486. const signed = await this.wallet.createAndSignTx({
  487. msgs: Array.isArray(msg) ? msg : [msg],
  488. feeDenoms: ['uinit'],
  489. })
  490. await this.lcd.tx.broadcast(signed)
  491. }
  492. async bridge2Ai(amount: number) {
  493. const size = bcs
  494. .option(bcs.u64())
  495. .serialize(amount * Math.pow(10, 6) * 0.995)
  496. .toBase64()
  497. const size2 = bcs
  498. .u64()
  499. .serialize(amount * Math.pow(10, 6))
  500. .toBase64()
  501. const msg = new MsgExecute(
  502. this.key.accAddress,
  503. '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
  504. 'swap_transfer',
  505. 'mixed_route_swap_deposit',
  506. [],
  507. [
  508. 'jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
  509. 'AA==',
  510. size2,
  511. size,
  512. 'BgAAAAAAAAA=',
  513. bcs.address().serialize(this.key.accAddress).toBase64(),
  514. 'AA==',
  515. ],
  516. )
  517. // [
  518. // ('jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
  519. // 'AA==',
  520. // 'QEIPAAAAAAA=',
  521. // 'AbguDwAAAAAA',
  522. // 'BgAAAAAAAAA=',
  523. // 'AAAAAAAAAAAAAAAAdpKzfgzxKB4sBaUJs11Wa9w+emA=',
  524. // 'AA==')
  525. // ][
  526. // ('jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
  527. // 'AA==',
  528. // 'gIQeAAAAAAA=',
  529. // 'AXBdHgAAAAAA',
  530. // 'BgAAAAAAAAA=',
  531. // 'AAAAAAAAAAAAAAAAdpKzfgzxKB4sBaUJs11Wa9w+emA=',
  532. // 'AA==')
  533. // ]
  534. const signed = await this.wallet.createAndSignTx({
  535. msgs: Array.isArray(msg) ? msg : [msg],
  536. feeDenoms: ['uinit'],
  537. })
  538. const broadcast = await this.lcd.tx.broadcastSync(signed)
  539. console.log(broadcast)
  540. }
  541. async newBridgeUsdc2BlackWings() {
  542. const msg = new MsgTransfer(
  543. 'transfer',
  544. 'channel-13',
  545. new Coin('uusdc', 1000000),
  546. this.key.accAddress,
  547. this.key.accAddress,
  548. null, // timeout height
  549. ((new Date().valueOf() + 3500000) * 1000000).toString(),
  550. )
  551. return await this.broadcast(msg)
  552. }
  553. async newBridgeUsdc2Tucana() {
  554. const random = this.randomAmount(1000000, 1500000)
  555. const msg = new MsgTransfer(
  556. 'transfer',
  557. 'channel-25',
  558. new Coin('uusdc', random),
  559. this.key.accAddress,
  560. this.key.accAddress,
  561. null, // timeout height
  562. ((new Date().valueOf() + 3500000) * 1000000).toString(),
  563. )
  564. return await this.broadcast(msg)
  565. }
  566. async newBridgeTia2Noon() {
  567. const random = this.randomAmount(100000, 150000)
  568. const msg = new MsgTransfer(
  569. 'transfer',
  570. 'channel-31',
  571. new Coin('utia', random),
  572. this.key.accAddress,
  573. this.key.accAddress,
  574. null, // timeout height
  575. ((new Date().valueOf() + 3500000) * 1000000).toString(),
  576. )
  577. return await this.broadcast(msg)
  578. }
  579. async newBridgeEth2MiniMove() {
  580. const msg = new MsgTransfer(
  581. 'transfer',
  582. 'channel-0',
  583. new Coin('ueth', 100),
  584. this.key.accAddress,
  585. this.key.accAddress,
  586. null, // timeout height
  587. ((new Date().valueOf() + 3500000) * 1000000).toString(),
  588. )
  589. return await this.broadcast(msg)
  590. }
  591. async newBridge2BlackWings() {
  592. const random = this.randomAmount(1000000, 1500000)
  593. const msg = new MsgInitiateTokenDeposit(
  594. this.key.accAddress,
  595. 8,
  596. this.key.accAddress,
  597. new Coin('uinit', random),
  598. )
  599. return await this.broadcast(msg)
  600. }
  601. async newBridge2Noon() {
  602. const msg = new MsgInitiateTokenDeposit(
  603. this.key.accAddress,
  604. 17,
  605. this.key.accAddress,
  606. new Coin('uinit', 1500000),
  607. )
  608. return await this.broadcast(msg)
  609. }
  610. async newBridge2Ai() {
  611. const random = this.randomAmount(1500000, 2000000)
  612. const msg = new MsgInitiateTokenDeposit(
  613. this.key.accAddress,
  614. 6,
  615. this.key.accAddress,
  616. new Coin('uinit', random),
  617. )
  618. return await this.broadcast(msg)
  619. }
  620. async newBridge2Civi() {
  621. const random = this.randomAmount(1500000, 2000000)
  622. const msg = new MsgInitiateTokenDeposit(
  623. this.key.accAddress,
  624. 24,
  625. this.key.accAddress,
  626. new Coin('uinit', random),
  627. )
  628. return await this.broadcast(msg)
  629. }
  630. async newBridge2Tucana() {
  631. const msg = new MsgInitiateTokenDeposit(
  632. this.key.accAddress,
  633. 14,
  634. this.key.accAddress,
  635. new Coin('uinit', 1000000),
  636. )
  637. return await this.broadcast(msg)
  638. }
  639. async newBridge2Miniwasm() {
  640. const msg = new MsgInitiateTokenDeposit(
  641. this.key.accAddress,
  642. 2,
  643. this.key.accAddress,
  644. new Coin('uinit', 1000000),
  645. )
  646. return await this.broadcast(msg)
  647. }
  648. async newBridge2Minimove() {
  649. const msg = new MsgInitiateTokenDeposit(
  650. this.key.accAddress,
  651. 1,
  652. this.key.accAddress,
  653. new Coin('uinit', 1000000),
  654. )
  655. return await this.broadcast(msg)
  656. }
  657. }