UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

43 lines 1.84 kB
import { TxSubmitterType } from '../TxSubmitterTypes.js'; import { EV5GnosisSafeTxSubmitter } from './EV5GnosisSafeTxSubmitter.js'; /** * This class is used to create a Safe Transaction Builder compatible object. * It is not a true Submitter because it does not submits any transactions. */ export class EV5GnosisSafeTxBuilder extends EV5GnosisSafeTxSubmitter { multiProvider; props; txSubmitterType = TxSubmitterType.GNOSIS_TX_BUILDER; constructor(multiProvider, props, safe, safeService) { super(multiProvider, props, safe, safeService); this.multiProvider = multiProvider; this.props = props; } static async create(multiProvider, props) { const { chain, safeAddress } = props; const { safe, safeService } = await EV5GnosisSafeTxSubmitter.initSafeAndService(chain, multiProvider, safeAddress); return new EV5GnosisSafeTxBuilder(multiProvider, props, safe, safeService); } // No requirement to get the next nonce from the Safe service. // When proposing the JSON file, the Safe UI will automatically update the nonce. // So we just return 0 and save ourselves from the unreliability of Safe APIs. async getNextNonce() { return 0; } /** * Creates a Gnosis Safe transaction builder object using the PopulatedTransactions * * @param txs - An array of populated transactions */ async submit(...txs) { const chainId = this.multiProvider.getChainId(this.props.chain); const transactions = await Promise.all(txs.map(async (tx) => (await this.createSafeTransaction(tx)).data)); return { version: this.props.version, chainId: chainId.toString(), meta: {}, transactions, }; } } //# sourceMappingURL=EV5GnosisSafeTxBuilder.js.map