import { ArweaveSigner } from 'arbundles' ; import { createData , bundleAndSignData , FileDataItem } from 'arbundles/file' ; import Blockweave from 'blockweave' ; import { AxiosResponse } from 'axios' ; import { JWKInterface } from 'blockweave/dist/faces/lib/wallet' ; import Api from 'arweave/node/lib/api' ; export default class Bundler { private signer : ArweaveSigner ; private blockweave : Blockweave ; constructor ( wallet , blockweave ) { this . signer = new ArweaveSigner ( wallet ) ; this . blockweave = blockweave ; } async createItem ( data , tags = [ ] ) { const item = await createData ( data , this . signer , { tags , } ) ; await item . sign ( this . signer ) ; return item ; } async bundleAndSign ( txs ) { return bundleAndSignData ( txs , this . signer ) ; } async post ( tx , bundler ) { return tx . sendToBundler ( bundler ) ; } static async getAddressBalance ( bundler , address ) { const res = await bundler . get ( `/account/balance?address=${ address }` ) ; return res . data . balance || 0 ; } }