@vleap/warps-adapter-evm 0.2.0-alpha.27 → 0.2.0-alpha.29

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.mjs CHANGED
@@ -457,7 +457,8 @@ import {
457
457
  applyResultsToMessages,
458
458
  getNextInfo,
459
459
  getProviderUrl as getProviderUrl3,
460
- getWarpActionByIndex
460
+ getWarpActionByIndex,
461
+ getWarpWalletAddressFromConfig as getWarpWalletAddressFromConfig2
461
462
  } from "@vleap/warps";
462
463
  import { ethers as ethers4 } from "ethers";
463
464
 
@@ -540,6 +541,7 @@ var ExplorerUrls = {
540
541
  import {
541
542
  evaluateResultsCommon,
542
543
  getProviderUrl as getProviderUrl2,
544
+ getWarpWalletAddressFromConfig,
543
545
  parseResultsOutIndex,
544
546
  WarpConstants as WarpConstants2
545
547
  } from "@vleap/warps";
@@ -734,7 +736,7 @@ var WarpEvmResults = class {
734
736
  success,
735
737
  warp,
736
738
  action: 0,
737
- user: this.config.user?.wallets?.evm || null,
739
+ user: getWarpWalletAddressFromConfig(this.config, "evm"),
738
740
  txHash: transactionHash,
739
741
  tx,
740
742
  next: null,
@@ -825,7 +827,7 @@ var WarpEvmExecutor = class {
825
827
  return tx;
826
828
  }
827
829
  async createTransferTransaction(executable) {
828
- const userWallet = this.config.user?.wallets?.[executable.chain.name];
830
+ const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
829
831
  if (!userWallet) throw new Error("WarpEvmExecutor: createTransfer - user address not set");
830
832
  if (!ethers4.isAddress(executable.destination)) {
831
833
  throw new Error(`WarpEvmExecutor: Invalid destination address: ${executable.destination}`);
@@ -841,7 +843,7 @@ var WarpEvmExecutor = class {
841
843
  return this.estimateGasAndSetDefaults(tx, userWallet);
842
844
  }
843
845
  async createContractCallTransaction(executable) {
844
- const userWallet = this.config.user?.wallets?.[executable.chain.name];
846
+ const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
845
847
  if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
846
848
  const action = getWarpActionByIndex(executable.warp, executable.action);
847
849
  if (!action || !("func" in action) || !action.func) {
@@ -938,7 +940,7 @@ var WarpEvmExecutor = class {
938
940
  success: isSuccess,
939
941
  warp: executable.warp,
940
942
  action: executable.action,
941
- user: this.config.user?.wallets?.[executable.chain.name] || null,
943
+ user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
942
944
  txHash: null,
943
945
  tx: null,
944
946
  next,
@@ -952,7 +954,7 @@ var WarpEvmExecutor = class {
952
954
  success: false,
953
955
  warp: executable.warp,
954
956
  action: executable.action,
955
- user: this.config.user?.wallets?.[executable.chain.name] || null,
957
+ user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
956
958
  txHash: null,
957
959
  tx: null,
958
960
  next: null,
@@ -1156,6 +1158,68 @@ var WarpEvmExplorer = class {
1156
1158
  }
1157
1159
  };
1158
1160
 
1161
+ // src/WarpEvmWallet.ts
1162
+ import { ethers as ethers5 } from "ethers";
1163
+ var WarpEvmWallet = class {
1164
+ constructor(config, chain) {
1165
+ this.config = config;
1166
+ this.chain = chain;
1167
+ this.wallet = null;
1168
+ this.provider = new ethers5.JsonRpcProvider(chain.defaultApiUrl || "https://rpc.sepolia.org");
1169
+ }
1170
+ async signTransaction(tx) {
1171
+ if (!this.wallet) {
1172
+ throw new Error("Wallet not initialized - no private key provided");
1173
+ }
1174
+ if (!tx || typeof tx !== "object") {
1175
+ throw new Error("Invalid transaction object");
1176
+ }
1177
+ const txRequest = {
1178
+ to: tx.to,
1179
+ data: tx.data,
1180
+ value: tx.value || 0,
1181
+ gasLimit: tx.gasLimit,
1182
+ maxFeePerGas: tx.maxFeePerGas,
1183
+ maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1184
+ nonce: tx.nonce,
1185
+ chainId: tx.chainId
1186
+ };
1187
+ const signedTx = await this.wallet.signTransaction(txRequest);
1188
+ return { ...tx, signature: signedTx };
1189
+ }
1190
+ async signMessage(message) {
1191
+ if (!this.wallet) {
1192
+ throw new Error("Wallet not initialized - no private key provided");
1193
+ }
1194
+ return await this.wallet.signMessage(message);
1195
+ }
1196
+ async sendTransaction(tx) {
1197
+ if (!tx || typeof tx !== "object") {
1198
+ throw new Error("Invalid transaction object");
1199
+ }
1200
+ if (!tx.signature) {
1201
+ throw new Error("Transaction must be signed before sending");
1202
+ }
1203
+ if (!this.wallet) {
1204
+ throw new Error("Wallet not initialized - no private key provided");
1205
+ }
1206
+ const connectedWallet = this.wallet.connect(this.provider);
1207
+ const txResponse = await connectedWallet.sendTransaction(tx);
1208
+ return txResponse.hash;
1209
+ }
1210
+ create(mnemonic) {
1211
+ const wallet = ethers5.Wallet.fromPhrase(mnemonic);
1212
+ return { address: wallet.address, privateKey: wallet.privateKey, mnemonic };
1213
+ }
1214
+ generate() {
1215
+ const wallet = ethers5.Wallet.createRandom();
1216
+ return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
1217
+ }
1218
+ getAddress() {
1219
+ return this.wallet?.address || null;
1220
+ }
1221
+ };
1222
+
1159
1223
  // src/chains/common.ts
1160
1224
  var createEvmAdapter = (chainName, chainPrefix, chainInfos) => {
1161
1225
  return (config, fallback) => {
@@ -1172,7 +1236,8 @@ var createEvmAdapter = (chainName, chainPrefix, chainInfos) => {
1172
1236
  explorer: new WarpEvmExplorer(chainInfos[config.env], config),
1173
1237
  abiBuilder: () => fallback.abiBuilder(),
1174
1238
  brandBuilder: () => fallback.brandBuilder(),
1175
- dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env])
1239
+ dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env]),
1240
+ wallet: new WarpEvmWallet(config, chainInfos[config.env])
1176
1241
  };
1177
1242
  };
1178
1243
  };
@@ -1194,6 +1259,7 @@ var getArbitrumAdapter = createEvmAdapter(WarpChainName6.Arbitrum, "arb", {
1194
1259
  blockTime: 1e3,
1195
1260
  addressHrp: "0x",
1196
1261
  defaultApiUrl: "https://arb1.arbitrum.io/rpc",
1262
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1197
1263
  nativeToken: NativeTokenArb
1198
1264
  },
1199
1265
  testnet: {
@@ -1203,6 +1269,7 @@ var getArbitrumAdapter = createEvmAdapter(WarpChainName6.Arbitrum, "arb", {
1203
1269
  blockTime: 1e3,
1204
1270
  addressHrp: "0x",
1205
1271
  defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
1272
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1206
1273
  nativeToken: NativeTokenArb
1207
1274
  },
1208
1275
  devnet: {
@@ -1212,6 +1279,7 @@ var getArbitrumAdapter = createEvmAdapter(WarpChainName6.Arbitrum, "arb", {
1212
1279
  blockTime: 1e3,
1213
1280
  addressHrp: "0x",
1214
1281
  defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
1282
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1215
1283
  nativeToken: NativeTokenArb
1216
1284
  }
1217
1285
  });
@@ -1234,6 +1302,7 @@ var getBaseAdapter = createEvmAdapter(WarpChainName7.Base, "base", {
1234
1302
  blockTime: 2e3,
1235
1303
  addressHrp: "0x",
1236
1304
  defaultApiUrl: "https://mainnet.base.org",
1305
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1237
1306
  nativeToken: NativeTokenBase
1238
1307
  },
1239
1308
  testnet: {
@@ -1243,6 +1312,7 @@ var getBaseAdapter = createEvmAdapter(WarpChainName7.Base, "base", {
1243
1312
  blockTime: 2e3,
1244
1313
  addressHrp: "0x",
1245
1314
  defaultApiUrl: "https://sepolia.base.org",
1315
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1246
1316
  nativeToken: NativeTokenBase
1247
1317
  },
1248
1318
  devnet: {
@@ -1252,6 +1322,7 @@ var getBaseAdapter = createEvmAdapter(WarpChainName7.Base, "base", {
1252
1322
  blockTime: 2e3,
1253
1323
  addressHrp: "0x",
1254
1324
  defaultApiUrl: "https://sepolia.base.org",
1325
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1255
1326
  nativeToken: NativeTokenBase
1256
1327
  }
1257
1328
  });
@@ -1277,6 +1348,7 @@ var getEthereumAdapter = createEvmAdapter(WarpChainName8.Ethereum, "eth", {
1277
1348
  blockTime: 12e3,
1278
1349
  addressHrp: "0x",
1279
1350
  defaultApiUrl: "https://ethereum-rpc.publicnode.com",
1351
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1280
1352
  nativeToken: NativeTokenEth
1281
1353
  },
1282
1354
  testnet: {
@@ -1286,6 +1358,7 @@ var getEthereumAdapter = createEvmAdapter(WarpChainName8.Ethereum, "eth", {
1286
1358
  blockTime: 12e3,
1287
1359
  addressHrp: "0x",
1288
1360
  defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
1361
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1289
1362
  nativeToken: NativeTokenEth
1290
1363
  },
1291
1364
  devnet: {
@@ -1295,6 +1368,7 @@ var getEthereumAdapter = createEvmAdapter(WarpChainName8.Ethereum, "eth", {
1295
1368
  blockTime: 12e3,
1296
1369
  addressHrp: "0x",
1297
1370
  defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
1371
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1298
1372
  nativeToken: NativeTokenEth
1299
1373
  }
1300
1374
  });
@@ -1325,6 +1399,7 @@ var getSomniaAdapter = createEvmAdapter(WarpChainName9.Somnia, "eth", {
1325
1399
  blockTime: 100,
1326
1400
  addressHrp: "0x",
1327
1401
  defaultApiUrl: "https://api.infra.mainnet.somnia.network/",
1402
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1328
1403
  nativeToken: NativeTokenSomi
1329
1404
  },
1330
1405
  testnet: {
@@ -1334,6 +1409,7 @@ var getSomniaAdapter = createEvmAdapter(WarpChainName9.Somnia, "eth", {
1334
1409
  blockTime: 100,
1335
1410
  addressHrp: "0x",
1336
1411
  defaultApiUrl: "https://dream-rpc.somnia.network/",
1412
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1337
1413
  nativeToken: NativeTokenStt
1338
1414
  },
1339
1415
  devnet: {
@@ -1343,6 +1419,7 @@ var getSomniaAdapter = createEvmAdapter(WarpChainName9.Somnia, "eth", {
1343
1419
  blockTime: 100,
1344
1420
  addressHrp: "0x",
1345
1421
  defaultApiUrl: "https://dream-rpc.somnia.network",
1422
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1346
1423
  nativeToken: NativeTokenStt
1347
1424
  }
1348
1425
  });
@@ -1377,6 +1454,7 @@ export {
1377
1454
  WarpEvmExplorer,
1378
1455
  WarpEvmResults,
1379
1456
  WarpEvmSerializer,
1457
+ WarpEvmWallet,
1380
1458
  createEvmAdapter,
1381
1459
  findKnownTokenById,
1382
1460
  getAllEvmAdapters,