import { TransactionRequest, ethers } from "ethers"; import { EvmProjectSigner } from "./signerPlugin"; import { Evm } from "../evm"; import { EvmKeyManagement } from "../types"; /** * Evm signer plugin for those that want to supply their own key. */ export class BringYourOwnKeyPlugin implements EvmProjectSigner { type = EvmKeyManagement.BYOK; private _evm: Evm; privateKey: string; constructor(privateKey: string) { this.privateKey = privateKey; } /** @internal */ init = (evm: Evm) => { this._evm = evm; evm.signTransaction = this.signTransaction; evm.keyManagementType = this.type; }; signTransaction: (txRequest: TransactionRequest) => Promise = async ( txRequest ) => { const wallet = new ethers.Wallet(this.privateKey); return wallet.signTransaction(txRequest); }; }