@vleap/warps-adapter-evm 0.2.0-alpha.33 → 0.2.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { WarpChainAsset, AdapterFactory, WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, WarpCache, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpResults, Warp, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction } from '@vleap/warps';
1
+ import { WarpChainAsset, AdapterFactory, WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, WarpCache, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecution, AdapterWarpExplorer, AdapterWarpResults, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction } from '@vleap/warps';
2
2
  import { ethers } from 'ethers';
3
3
 
4
4
  declare const NativeTokenArb: WarpChainAsset;
@@ -172,9 +172,8 @@ declare class WarpEvmExecutor implements AdapterWarpExecutor {
172
172
  createContractCallTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
173
173
  private createTokenTransferTransaction;
174
174
  private createSingleTokenTransfer;
175
- executeQuery(executable: WarpExecutable): Promise<WarpExecution>;
175
+ executeQuery(executable: WarpExecutable): Promise<WarpActionExecution>;
176
176
  private estimateGasAndSetDefaults;
177
- signMessage(message: string, privateKey: string): Promise<string>;
178
177
  verifyMessage(message: string, signature: string): Promise<string>;
179
178
  }
180
179
 
@@ -205,11 +204,14 @@ declare class WarpEvmResults implements AdapterWarpResults {
205
204
  private readonly serializer;
206
205
  private readonly provider;
207
206
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
208
- getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt): Promise<WarpExecution>;
209
- extractQueryResults(warp: Warp, typedValues: any[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
207
+ getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecution>;
208
+ private createFailedExecution;
209
+ private handleWarpChainAction;
210
+ private handleTransactionReceipt;
211
+ extractQueryResults(warp: Warp, typedValues: unknown[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
210
212
  values: {
211
213
  string: string[];
212
- native: any[];
214
+ native: WarpNativeValue[];
213
215
  };
214
216
  results: WarpExecutionResults;
215
217
  }>;
@@ -235,12 +237,13 @@ declare class WarpEvmSerializer implements AdapterWarpSerializer {
235
237
  declare class WarpEvmWallet implements AdapterWarpWallet {
236
238
  private config;
237
239
  private chain;
238
- private wallet;
239
240
  private provider;
240
241
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
241
242
  signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
243
+ signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
242
244
  signMessage(message: string): Promise<string>;
243
245
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
246
+ sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
244
247
  create(mnemonic: string): {
245
248
  address: string;
246
249
  privateKey: string;
@@ -252,6 +255,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
252
255
  mnemonic: string;
253
256
  };
254
257
  getAddress(): string | null;
258
+ private getWallet;
255
259
  }
256
260
 
257
261
  export { ArbitrumExplorers, BaseExplorers, EthereumExplorers, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, UniswapService, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmResults, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getArbitrumAdapter, getBaseAdapter, getEthereumAdapter, getKnownTokensForChain };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WarpChainAsset, AdapterFactory, WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, WarpCache, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpResults, Warp, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction } from '@vleap/warps';
1
+ import { WarpChainAsset, AdapterFactory, WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, WarpCache, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecution, AdapterWarpExplorer, AdapterWarpResults, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction } from '@vleap/warps';
2
2
  import { ethers } from 'ethers';
3
3
 
4
4
  declare const NativeTokenArb: WarpChainAsset;
@@ -172,9 +172,8 @@ declare class WarpEvmExecutor implements AdapterWarpExecutor {
172
172
  createContractCallTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
173
173
  private createTokenTransferTransaction;
174
174
  private createSingleTokenTransfer;
175
- executeQuery(executable: WarpExecutable): Promise<WarpExecution>;
175
+ executeQuery(executable: WarpExecutable): Promise<WarpActionExecution>;
176
176
  private estimateGasAndSetDefaults;
177
- signMessage(message: string, privateKey: string): Promise<string>;
178
177
  verifyMessage(message: string, signature: string): Promise<string>;
179
178
  }
180
179
 
@@ -205,11 +204,14 @@ declare class WarpEvmResults implements AdapterWarpResults {
205
204
  private readonly serializer;
206
205
  private readonly provider;
207
206
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
208
- getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt): Promise<WarpExecution>;
209
- extractQueryResults(warp: Warp, typedValues: any[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
207
+ getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecution>;
208
+ private createFailedExecution;
209
+ private handleWarpChainAction;
210
+ private handleTransactionReceipt;
211
+ extractQueryResults(warp: Warp, typedValues: unknown[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
210
212
  values: {
211
213
  string: string[];
212
- native: any[];
214
+ native: WarpNativeValue[];
213
215
  };
214
216
  results: WarpExecutionResults;
215
217
  }>;
@@ -235,12 +237,13 @@ declare class WarpEvmSerializer implements AdapterWarpSerializer {
235
237
  declare class WarpEvmWallet implements AdapterWarpWallet {
236
238
  private config;
237
239
  private chain;
238
- private wallet;
239
240
  private provider;
240
241
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
241
242
  signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
243
+ signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
242
244
  signMessage(message: string): Promise<string>;
243
245
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
246
+ sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
244
247
  create(mnemonic: string): {
245
248
  address: string;
246
249
  privateKey: string;
@@ -252,6 +255,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
252
255
  mnemonic: string;
253
256
  };
254
257
  getAddress(): string | null;
258
+ private getWallet;
255
259
  }
256
260
 
257
261
  export { ArbitrumExplorers, BaseExplorers, EthereumExplorers, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, UniswapService, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmResults, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getArbitrumAdapter, getBaseAdapter, getEthereumAdapter, getKnownTokensForChain };
package/dist/index.js CHANGED
@@ -426,7 +426,10 @@ var WarpEvmDataLoader = class {
426
426
  try {
427
427
  const tx = await this.provider.getTransaction(identifier);
428
428
  if (!tx) return null;
429
- const receipt = await this.provider.getTransactionReceipt(identifier);
429
+ let receipt = await this.provider.getTransactionReceipt(identifier);
430
+ if (awaitCompleted && !receipt) {
431
+ receipt = await tx.wait();
432
+ }
430
433
  const block = await this.provider.getBlock(tx.blockNumber || "latest");
431
434
  return {
432
435
  chain: this.chain.name,
@@ -742,7 +745,51 @@ var WarpEvmResults = class {
742
745
  const network = new import_ethers3.ethers.Network(this.chain.name, parseInt(this.chain.chainId));
743
746
  this.provider = new import_ethers3.ethers.JsonRpcProvider(apiUrl, network);
744
747
  }
745
- async getTransactionExecutionResults(warp, tx) {
748
+ async getActionExecution(warp, actionIndex, tx) {
749
+ if (!tx) {
750
+ return this.createFailedExecution(warp, actionIndex);
751
+ }
752
+ if ("status" in tx && typeof tx.status === "string") {
753
+ return this.handleWarpChainAction(warp, actionIndex, tx);
754
+ }
755
+ return this.handleTransactionReceipt(warp, actionIndex, tx);
756
+ }
757
+ createFailedExecution(warp, actionIndex) {
758
+ return {
759
+ success: false,
760
+ warp,
761
+ action: actionIndex,
762
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
763
+ txHash: "",
764
+ tx: null,
765
+ next: null,
766
+ values: { string: [], native: [] },
767
+ results: {},
768
+ messages: {}
769
+ };
770
+ }
771
+ handleWarpChainAction(warp, actionIndex, tx) {
772
+ const success = tx.status === "success";
773
+ const transactionHash = tx.id || tx.tx?.hash || "";
774
+ const gasUsed = tx.tx?.gasLimit || "0";
775
+ const gasPrice = tx.tx?.gasPrice || "0";
776
+ const blockNumber = tx.tx?.blockNumber || "0";
777
+ const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice];
778
+ const stringValues = rawValues.map(String);
779
+ return {
780
+ success,
781
+ warp,
782
+ action: actionIndex,
783
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
784
+ txHash: transactionHash,
785
+ tx,
786
+ next: null,
787
+ values: { string: stringValues, native: rawValues },
788
+ results: {},
789
+ messages: {}
790
+ };
791
+ }
792
+ handleTransactionReceipt(warp, actionIndex, tx) {
746
793
  const success = tx.status === 1;
747
794
  const gasUsed = tx.gasUsed?.toString() || "0";
748
795
  const gasPrice = tx.gasPrice?.toString() || "0";
@@ -757,12 +804,12 @@ var WarpEvmResults = class {
757
804
  index: log.index?.toString() || "0"
758
805
  }));
759
806
  const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
760
- const stringValues = rawValues.map((v) => String(v));
807
+ const stringValues = rawValues.map(String);
761
808
  return {
762
809
  success,
763
810
  warp,
764
- action: 0,
765
- user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, "evm"),
811
+ action: actionIndex,
812
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
766
813
  txHash: transactionHash,
767
814
  tx,
768
815
  next: null,
@@ -872,15 +919,17 @@ var WarpEvmExecutor = class {
872
919
  const userWallet = (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
873
920
  if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
874
921
  const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
875
- if (!action || !("func" in action) || !action.func) {
876
- throw new Error("WarpEvmExecutor: Contract action must have a function name");
877
- }
878
- if (!import_ethers4.ethers.isAddress(executable.destination)) {
879
- throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
880
- }
922
+ if (!action || !("func" in action) || !action.func) throw new Error("WarpEvmExecutor: Contract action must have a function name");
923
+ if (!import_ethers4.ethers.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
881
924
  try {
882
- const iface = new import_ethers4.ethers.Interface([`function ${action.func}`]);
883
- const encodedData = iface.encodeFunctionData(action.func, executable.args);
925
+ let iface;
926
+ try {
927
+ iface = new import_ethers4.ethers.Interface(JSON.parse(action.abi));
928
+ } catch {
929
+ iface = new import_ethers4.ethers.Interface([action.abi]);
930
+ }
931
+ const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
932
+ const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
884
933
  const tx = {
885
934
  to: executable.destination,
886
935
  value: executable.value,
@@ -892,19 +941,13 @@ var WarpEvmExecutor = class {
892
941
  }
893
942
  }
894
943
  async createTokenTransferTransaction(executable, userWallet) {
895
- if (executable.transfers.length === 0) {
896
- throw new Error("WarpEvmExecutor: No transfers provided");
897
- }
898
- if (!this.chain.nativeToken?.identifier) {
899
- throw new Error("WarpEvmExecutor: No native token defined for this chain");
900
- }
944
+ if (executable.transfers.length === 0) throw new Error("WarpEvmExecutor: No transfers provided");
945
+ if (!this.chain.nativeToken?.identifier) throw new Error("WarpEvmExecutor: No native token defined for this chain");
901
946
  const nativeTokenTransfers = executable.transfers.filter((transfer) => transfer.identifier === this.chain.nativeToken.identifier);
902
947
  const erc20Transfers = executable.transfers.filter((transfer) => transfer.identifier !== this.chain.nativeToken.identifier);
903
948
  if (nativeTokenTransfers.length === 1 && erc20Transfers.length === 0) {
904
949
  const transfer = nativeTokenTransfers[0];
905
- if (transfer.amount <= 0n) {
906
- throw new Error("WarpEvmExecutor: Native token transfer amount must be positive");
907
- }
950
+ if (transfer.amount <= 0n) throw new Error("WarpEvmExecutor: Native token transfer amount must be positive");
908
951
  const tx = {
909
952
  to: executable.destination,
910
953
  value: transfer.amount,
@@ -915,9 +958,7 @@ var WarpEvmExecutor = class {
915
958
  if (nativeTokenTransfers.length === 0 && erc20Transfers.length === 1) {
916
959
  return this.createSingleTokenTransfer(executable, erc20Transfers[0], userWallet);
917
960
  }
918
- if (executable.transfers.length > 1) {
919
- throw new Error("WarpEvmExecutor: Multiple token transfers not yet supported");
920
- }
961
+ if (executable.transfers.length > 1) throw new Error("WarpEvmExecutor: Multiple token transfers not yet supported");
921
962
  throw new Error("WarpEvmExecutor: Invalid transfer configuration");
922
963
  }
923
964
  async createSingleTokenTransfer(executable, transfer, userWallet) {
@@ -928,27 +969,25 @@ var WarpEvmExecutor = class {
928
969
  const encodedData = transferInterface.encodeFunctionData("transfer", [executable.destination, transfer.amount]);
929
970
  const tx = {
930
971
  to: transfer.identifier,
931
- // Token contract address
932
972
  value: 0n,
933
- // No native token value for ERC-20 transfers
934
973
  data: encodedData
935
974
  };
936
975
  return this.estimateGasAndSetDefaults(tx, userWallet);
937
976
  }
938
977
  async executeQuery(executable) {
939
978
  const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
940
- if (action.type !== "query") {
941
- throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
942
- }
943
- if (!action.func) {
944
- throw new Error("WarpEvmExecutor: Query action must have a function name");
945
- }
946
- if (!import_ethers4.ethers.isAddress(executable.destination)) {
947
- throw new Error(`WarpEvmExecutor: Invalid contract address for query: ${executable.destination}`);
948
- }
979
+ if (action.type !== "query") throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
980
+ if (!action.func) throw new Error("WarpEvmExecutor: Query action must have a function name");
981
+ if (!import_ethers4.ethers.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid address for query: ${executable.destination}`);
949
982
  try {
950
- const iface = new import_ethers4.ethers.Interface([`function ${action.func}`]);
951
- const encodedData = iface.encodeFunctionData(action.func, executable.args);
983
+ let iface;
984
+ try {
985
+ iface = new import_ethers4.ethers.Interface(JSON.parse(action.abi));
986
+ } catch {
987
+ iface = new import_ethers4.ethers.Interface([action.abi]);
988
+ }
989
+ const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
990
+ const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
952
991
  const result = await this.provider.call({
953
992
  to: executable.destination,
954
993
  data: encodedData
@@ -995,12 +1034,8 @@ var WarpEvmExecutor = class {
995
1034
  ...tx,
996
1035
  from
997
1036
  });
998
- if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) {
999
- throw new Error(`Gas estimate too low: ${gasEstimate}`);
1000
- }
1001
- if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) {
1002
- throw new Error(`Gas estimate too high: ${gasEstimate}`);
1003
- }
1037
+ if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) throw new Error(`Gas estimate too low: ${gasEstimate}`);
1038
+ if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) throw new Error(`Gas estimate too high: ${gasEstimate}`);
1004
1039
  const feeData = await this.provider.getFeeData();
1005
1040
  if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
1006
1041
  return {
@@ -1044,15 +1079,6 @@ var WarpEvmExecutor = class {
1044
1079
  };
1045
1080
  }
1046
1081
  }
1047
- async signMessage(message, privateKey) {
1048
- try {
1049
- const wallet = new import_ethers4.ethers.Wallet(privateKey);
1050
- const signature = await wallet.signMessage(message);
1051
- return signature;
1052
- } catch (error) {
1053
- throw new Error(`Failed to sign message: ${error}`);
1054
- }
1055
- }
1056
1082
  async verifyMessage(message, signature) {
1057
1083
  try {
1058
1084
  const recoveredAddress = import_ethers4.ethers.verifyMessage(message, signature);
@@ -1189,16 +1215,12 @@ var WarpEvmWallet = class {
1189
1215
  constructor(config, chain) {
1190
1216
  this.config = config;
1191
1217
  this.chain = chain;
1192
- this.wallet = null;
1193
- this.provider = new import_ethers5.ethers.JsonRpcProvider(chain.defaultApiUrl || "https://rpc.sepolia.org");
1218
+ const apiUrl = (0, import_warps11.getProviderUrl)(config, chain.name, config.env, chain.defaultApiUrl);
1219
+ this.provider = new import_ethers5.ethers.JsonRpcProvider(apiUrl);
1194
1220
  }
1195
1221
  async signTransaction(tx) {
1196
- if (!tx || typeof tx !== "object") {
1197
- throw new Error("Invalid transaction object");
1198
- }
1199
- const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1200
- if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
1201
- const wallet = new import_ethers5.ethers.Wallet(privateKey);
1222
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1223
+ const wallet = this.getWallet();
1202
1224
  const txRequest = {
1203
1225
  to: tx.to,
1204
1226
  data: tx.data,
@@ -1212,25 +1234,53 @@ var WarpEvmWallet = class {
1212
1234
  const signedTx = await wallet.signTransaction(txRequest);
1213
1235
  return { ...tx, signature: signedTx };
1214
1236
  }
1237
+ async signTransactions(txs) {
1238
+ if (txs.length === 0) return [];
1239
+ if (txs.length > 1) {
1240
+ const wallet = this.getWallet();
1241
+ const address = wallet.address;
1242
+ const currentNonce = await this.provider.getTransactionCount(address, "pending");
1243
+ const signedTxs = [];
1244
+ for (let i = 0; i < txs.length; i++) {
1245
+ const tx = { ...txs[i] };
1246
+ tx.nonce = currentNonce + i;
1247
+ if (i > 0) {
1248
+ const priorityReduction = BigInt(i * 1e9);
1249
+ const minGasPrice = BigInt(1e9);
1250
+ if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
1251
+ tx.maxFeePerGas = tx.maxFeePerGas > priorityReduction ? tx.maxFeePerGas - priorityReduction : minGasPrice;
1252
+ tx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas > priorityReduction ? tx.maxPriorityFeePerGas - priorityReduction : minGasPrice;
1253
+ delete tx.gasPrice;
1254
+ } else if (tx.gasPrice) {
1255
+ tx.gasPrice = tx.gasPrice > priorityReduction ? tx.gasPrice - priorityReduction : minGasPrice;
1256
+ delete tx.maxFeePerGas;
1257
+ delete tx.maxPriorityFeePerGas;
1258
+ }
1259
+ }
1260
+ const signedTx = await this.signTransaction(tx);
1261
+ signedTxs.push(signedTx);
1262
+ }
1263
+ return signedTxs;
1264
+ }
1265
+ return Promise.all(txs.map(async (tx) => this.signTransaction(tx)));
1266
+ }
1215
1267
  async signMessage(message) {
1216
- const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1217
- if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
1218
- const wallet = new import_ethers5.ethers.Wallet(privateKey);
1219
- return await wallet.signMessage(message);
1268
+ const wallet = this.getWallet();
1269
+ const signature = await wallet.signMessage(message);
1270
+ return signature;
1220
1271
  }
1221
1272
  async sendTransaction(tx) {
1222
- if (!tx || typeof tx !== "object") {
1223
- throw new Error("Invalid transaction object");
1224
- }
1225
- if (!tx.signature) {
1226
- throw new Error("Transaction must be signed before sending");
1227
- }
1228
- const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1229
- if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
1230
- const wallet = new import_ethers5.ethers.Wallet(privateKey).connect(this.provider);
1231
- const txResponse = await wallet.sendTransaction(tx);
1273
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1274
+ if (!tx.signature) throw new Error("Transaction must be signed before sending");
1275
+ const wallet = this.getWallet();
1276
+ if (!wallet) throw new Error("Wallet not initialized - no private key provided");
1277
+ const connectedWallet = wallet.connect(this.provider);
1278
+ const txResponse = await connectedWallet.sendTransaction(tx);
1232
1279
  return txResponse.hash;
1233
1280
  }
1281
+ async sendTransactions(txs) {
1282
+ return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
1283
+ }
1234
1284
  create(mnemonic) {
1235
1285
  const wallet = import_ethers5.ethers.Wallet.fromPhrase(mnemonic);
1236
1286
  return { address: wallet.address, privateKey: wallet.privateKey, mnemonic };
@@ -1240,11 +1290,16 @@ var WarpEvmWallet = class {
1240
1290
  return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
1241
1291
  }
1242
1292
  getAddress() {
1243
- const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1244
- if (!privateKey) return null;
1245
- const wallet = new import_ethers5.ethers.Wallet(privateKey);
1293
+ const wallet = this.getWallet();
1246
1294
  return wallet.address;
1247
1295
  }
1296
+ getWallet() {
1297
+ const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1298
+ if (privateKey) return new import_ethers5.ethers.Wallet(privateKey);
1299
+ const mnemonic = (0, import_warps11.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
1300
+ if (mnemonic) return import_ethers5.ethers.Wallet.fromPhrase(mnemonic);
1301
+ throw new Error("No private key or mnemonic provided");
1302
+ }
1248
1303
  };
1249
1304
 
1250
1305
  // src/chains/common.ts