UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

34 lines 1.49 kB
import { ethers } from 'ethers'; import { Account as StarknetAccount } from 'starknet'; import { assert } from '@hyperlane-xyz/utils'; export class StarknetMultiProtocolSignerAdapter { chainName; signer; constructor(chainName, privateKey, address, multiProtocolProvider) { this.chainName = chainName; const provider = multiProtocolProvider.getStarknetProvider(this.chainName); assert(ethers.utils.isHexString(address), 'Starknet address must be a hex string'); assert(ethers.utils.isHexString(privateKey), 'Starknet private key must be a hex string'); this.signer = new StarknetAccount(provider, address, privateKey); } async address() { return this.signer.address; } async sendAndConfirmTransaction(tx, _options) { const { entrypoint, calldata, contractAddress } = tx.transaction; assert(entrypoint, 'entrypoint is required for starknet transactions'); const transaction = await this.signer.execute([ { contractAddress, entrypoint, calldata, }, ]); const transactionReceipt = await this.signer.waitForTransaction(transaction.transaction_hash); if (transactionReceipt.isReverted()) { throw new Error(`Transaction ${transaction.transaction_hash} failed on chain ${this.chainName}`); } return transaction.transaction_hash; } } //# sourceMappingURL=starknetjs.js.map