@vleap/warps-adapter-evm 0.2.0-alpha.32 → 0.2.0-alpha.34

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
@@ -205,10 +205,12 @@ declare class WarpEvmResults implements AdapterWarpResults {
205
205
  private readonly serializer;
206
206
  private readonly provider;
207
207
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
208
- getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt): Promise<WarpExecution>;
208
+ getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt | null): Promise<WarpExecution>;
209
209
  extractQueryResults(warp: Warp, typedValues: any[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
210
- values: any[];
211
- valuesRaw: any[];
210
+ values: {
211
+ string: string[];
212
+ native: any[];
213
+ };
212
214
  results: WarpExecutionResults;
213
215
  }>;
214
216
  getTransactionStatus(txHash: string): Promise<{
@@ -233,7 +235,6 @@ declare class WarpEvmSerializer implements AdapterWarpSerializer {
233
235
  declare class WarpEvmWallet implements AdapterWarpWallet {
234
236
  private config;
235
237
  private chain;
236
- private wallet;
237
238
  private provider;
238
239
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
239
240
  signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
@@ -250,6 +251,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
250
251
  mnemonic: string;
251
252
  };
252
253
  getAddress(): string | null;
254
+ private getWallet;
253
255
  }
254
256
 
255
257
  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
@@ -205,10 +205,12 @@ declare class WarpEvmResults implements AdapterWarpResults {
205
205
  private readonly serializer;
206
206
  private readonly provider;
207
207
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
208
- getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt): Promise<WarpExecution>;
208
+ getTransactionExecutionResults(warp: Warp, tx: ethers.TransactionReceipt | null): Promise<WarpExecution>;
209
209
  extractQueryResults(warp: Warp, typedValues: any[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
210
- values: any[];
211
- valuesRaw: any[];
210
+ values: {
211
+ string: string[];
212
+ native: any[];
213
+ };
212
214
  results: WarpExecutionResults;
213
215
  }>;
214
216
  getTransactionStatus(txHash: string): Promise<{
@@ -233,7 +235,6 @@ declare class WarpEvmSerializer implements AdapterWarpSerializer {
233
235
  declare class WarpEvmWallet implements AdapterWarpWallet {
234
236
  private config;
235
237
  private chain;
236
- private wallet;
237
238
  private provider;
238
239
  constructor(config: WarpClientConfig, chain: WarpChainInfo);
239
240
  signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
@@ -250,6 +251,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
250
251
  mnemonic: string;
251
252
  };
252
253
  getAddress(): string | null;
254
+ private getWallet;
253
255
  }
254
256
 
255
257
  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
@@ -743,6 +743,20 @@ var WarpEvmResults = class {
743
743
  this.provider = new import_ethers3.ethers.JsonRpcProvider(apiUrl, network);
744
744
  }
745
745
  async getTransactionExecutionResults(warp, tx) {
746
+ if (!tx) {
747
+ return {
748
+ success: false,
749
+ warp,
750
+ action: 0,
751
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
752
+ txHash: "",
753
+ tx: null,
754
+ next: null,
755
+ values: { string: [], native: [] },
756
+ results: {},
757
+ messages: {}
758
+ };
759
+ }
746
760
  const success = tx.status === 1;
747
761
  const gasUsed = tx.gasUsed?.toString() || "0";
748
762
  const gasPrice = tx.gasPrice?.toString() || "0";
@@ -750,35 +764,37 @@ var WarpEvmResults = class {
750
764
  const transactionHash = tx.hash;
751
765
  const logs = tx.logs.map((log) => ({
752
766
  address: log.address,
753
- topics: log.topics,
767
+ topics: [...log.topics],
754
768
  data: log.data,
755
769
  blockNumber: log.blockNumber?.toString() || "0",
756
770
  transactionHash: log.transactionHash,
757
771
  index: log.index?.toString() || "0"
758
772
  }));
773
+ const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
774
+ const stringValues = rawValues.map((v) => String(v));
759
775
  return {
760
776
  success,
761
777
  warp,
762
778
  action: 0,
763
- user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, "evm"),
779
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
764
780
  txHash: transactionHash,
765
781
  tx,
766
782
  next: null,
767
- values: [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []],
768
- valuesRaw: [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []],
783
+ values: { string: stringValues, native: rawValues },
769
784
  results: {},
770
785
  messages: {}
771
786
  };
772
787
  }
773
788
  async extractQueryResults(warp, typedValues, actionIndex, inputs) {
774
- const values = typedValues.map((t) => this.serializer.typedToString(t));
775
- const valuesRaw = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
789
+ const stringValues = typedValues.map((t) => this.serializer.typedToString(t));
790
+ const nativeValues = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
791
+ const values = { string: stringValues, native: nativeValues };
776
792
  let results = {};
777
- if (!warp.results) return { values, valuesRaw, results };
793
+ if (!warp.results) return { values, results };
778
794
  const getNestedValue = (path) => {
779
795
  const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
780
796
  if (indices.length === 0) return void 0;
781
- let value = valuesRaw[indices[0]];
797
+ let value = nativeValues[indices[0]];
782
798
  for (let i = 1; i < indices.length; i++) {
783
799
  if (value === void 0 || value === null) return void 0;
784
800
  value = value[indices[i]];
@@ -798,7 +814,7 @@ var WarpEvmResults = class {
798
814
  results[key] = path;
799
815
  }
800
816
  }
801
- return { values, valuesRaw, results: await (0, import_warps9.evaluateResultsCommon)(warp, results, actionIndex, inputs, this.serializer.coreSerializer) };
817
+ return { values, results: await (0, import_warps9.evaluateResultsCommon)(warp, results, actionIndex, inputs, this.serializer.coreSerializer) };
802
818
  }
803
819
  async getTransactionStatus(txHash) {
804
820
  try {
@@ -953,7 +969,7 @@ var WarpEvmExecutor = class {
953
969
  });
954
970
  const decodedResult = iface.decodeFunctionResult(action.func, result);
955
971
  const isSuccess = true;
956
- const { values, valuesRaw, results } = await this.results.extractQueryResults(
972
+ const { values, results } = await this.results.extractQueryResults(
957
973
  executable.warp,
958
974
  decodedResult,
959
975
  executable.action,
@@ -969,7 +985,6 @@ var WarpEvmExecutor = class {
969
985
  tx: null,
970
986
  next,
971
987
  values,
972
- valuesRaw,
973
988
  results,
974
989
  messages: (0, import_warps10.applyResultsToMessages)(executable.warp, results)
975
990
  };
@@ -982,8 +997,7 @@ var WarpEvmExecutor = class {
982
997
  txHash: null,
983
998
  tx: null,
984
999
  next: null,
985
- values: [],
986
- valuesRaw: [],
1000
+ values: { string: [], native: [] },
987
1001
  results: {},
988
1002
  messages: {}
989
1003
  };
@@ -1189,16 +1203,12 @@ var WarpEvmWallet = class {
1189
1203
  constructor(config, chain) {
1190
1204
  this.config = config;
1191
1205
  this.chain = chain;
1192
- this.wallet = null;
1193
- this.provider = new import_ethers5.ethers.JsonRpcProvider(chain.defaultApiUrl || "https://rpc.sepolia.org");
1206
+ const apiUrl = (0, import_warps11.getProviderUrl)(config, chain.name, config.env, chain.defaultApiUrl);
1207
+ this.provider = new import_ethers5.ethers.JsonRpcProvider(apiUrl);
1194
1208
  }
1195
1209
  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);
1210
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1211
+ const wallet = this.getWallet();
1202
1212
  const txRequest = {
1203
1213
  to: tx.to,
1204
1214
  data: tx.data,
@@ -1213,22 +1223,17 @@ var WarpEvmWallet = class {
1213
1223
  return { ...tx, signature: signedTx };
1214
1224
  }
1215
1225
  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);
1226
+ const wallet = this.getWallet();
1227
+ const signature = await wallet.signMessage(message);
1228
+ return signature;
1220
1229
  }
1221
1230
  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);
1231
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1232
+ if (!tx.signature) throw new Error("Transaction must be signed before sending");
1233
+ const wallet = this.getWallet();
1234
+ if (!wallet) throw new Error("Wallet not initialized - no private key provided");
1235
+ const connectedWallet = wallet.connect(this.provider);
1236
+ const txResponse = await connectedWallet.sendTransaction(tx);
1232
1237
  return txResponse.hash;
1233
1238
  }
1234
1239
  create(mnemonic) {
@@ -1240,11 +1245,16 @@ var WarpEvmWallet = class {
1240
1245
  return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
1241
1246
  }
1242
1247
  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);
1248
+ const wallet = this.getWallet();
1246
1249
  return wallet.address;
1247
1250
  }
1251
+ getWallet() {
1252
+ const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1253
+ if (privateKey) return new import_ethers5.ethers.Wallet(privateKey);
1254
+ const mnemonic = (0, import_warps11.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
1255
+ if (mnemonic) return import_ethers5.ethers.Wallet.fromPhrase(mnemonic);
1256
+ throw new Error("No private key or mnemonic provided");
1257
+ }
1248
1258
  };
1249
1259
 
1250
1260
  // src/chains/common.ts