@joai/warps-adapter-evm 1.0.1 → 1.1.0

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
@@ -281,6 +281,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
281
281
  importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
282
282
  export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
283
283
  generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
284
+ delete(provider: WarpWalletProvider, externalId: string): Promise<void>;
284
285
  getAddress(): string | null;
285
286
  getPublicKey(): string | null;
286
287
  registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
package/dist/index.d.ts CHANGED
@@ -281,6 +281,7 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
281
281
  importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
282
282
  export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
283
283
  generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
284
+ delete(provider: WarpWalletProvider, externalId: string): Promise<void>;
284
285
  getAddress(): string | null;
285
286
  getPublicKey(): string | null;
286
287
  registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ var _UniswapService = class _UniswapService {
92
92
  async findToken(address) {
93
93
  const normalizedAddress = address.toLowerCase();
94
94
  const cacheKey = `uniswap:token:${this.chainId}:${normalizedAddress}`;
95
- const cachedToken = this.cache.get(cacheKey);
95
+ const cachedToken = await this.cache.get(cacheKey);
96
96
  if (cachedToken) {
97
97
  return cachedToken;
98
98
  }
@@ -103,9 +103,9 @@ var _UniswapService = class _UniswapService {
103
103
  return null;
104
104
  }
105
105
  if (token) {
106
- this.cache.set(cacheKey, token, import_warps.CacheTtl.OneHour);
106
+ await this.cache.set(cacheKey, token, import_warps.CacheTtl.OneHour);
107
107
  } else {
108
- this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
108
+ await this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
109
109
  }
110
110
  return token;
111
111
  } catch (error) {
@@ -115,13 +115,13 @@ var _UniswapService = class _UniswapService {
115
115
  async getTokenMetadata(address) {
116
116
  const normalizedAddress = address.toLowerCase();
117
117
  const cacheKey = `uniswap:metadata:${this.chainId}:${normalizedAddress}`;
118
- const cachedMetadata = this.cache.get(cacheKey);
118
+ const cachedMetadata = await this.cache.get(cacheKey);
119
119
  if (cachedMetadata !== null) {
120
120
  return cachedMetadata;
121
121
  }
122
122
  const token = await this.findToken(address);
123
123
  if (!token) {
124
- this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
124
+ await this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
125
125
  return null;
126
126
  }
127
127
  const metadata = {
@@ -130,26 +130,26 @@ var _UniswapService = class _UniswapService {
130
130
  decimals: token.decimals,
131
131
  logoUrl: token.logoURI
132
132
  };
133
- this.cache.set(cacheKey, metadata, import_warps.CacheTtl.OneHour);
133
+ await this.cache.set(cacheKey, metadata, import_warps.CacheTtl.OneHour);
134
134
  return metadata;
135
135
  }
136
136
  async getBridgeInfo(address) {
137
137
  const normalizedAddress = address.toLowerCase();
138
138
  const cacheKey = `uniswap:bridge:${this.chainId}:${normalizedAddress}`;
139
- const cachedBridgeInfo = this.cache.get(cacheKey);
139
+ const cachedBridgeInfo = await this.cache.get(cacheKey);
140
140
  if (cachedBridgeInfo !== null) {
141
141
  return cachedBridgeInfo;
142
142
  }
143
143
  const token = await this.findToken(address);
144
144
  if (!token?.extensions?.bridgeInfo) {
145
- this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
145
+ await this.cache.set(cacheKey, null, import_warps.CacheTtl.OneMinute * 5);
146
146
  return null;
147
147
  }
148
148
  const bridgeInfo = {};
149
149
  for (const [chainId, info] of Object.entries(token.extensions.bridgeInfo)) {
150
150
  bridgeInfo[chainId] = info.tokenAddress;
151
151
  }
152
- this.cache.set(cacheKey, bridgeInfo, import_warps.CacheTtl.OneHour);
152
+ await this.cache.set(cacheKey, bridgeInfo, import_warps.CacheTtl.OneHour);
153
153
  return bridgeInfo;
154
154
  }
155
155
  };
@@ -245,6 +245,9 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
245
245
  mnemonic: null
246
246
  };
247
247
  }
248
+ async delete(externalId) {
249
+ (0, import_warps2.removeWarpWalletFromConfig)(this.config, this.chain.name);
250
+ }
248
251
  getWallet() {
249
252
  if (this.wallet) return this.wallet;
250
253
  const privateKey = (0, import_warps2.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
@@ -352,6 +355,9 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
352
355
  mnemonic
353
356
  };
354
357
  }
358
+ async delete(externalId) {
359
+ (0, import_warps3.removeWarpWalletFromConfig)(this.config, this.chain.name);
360
+ }
355
361
  getWallet() {
356
362
  if (this.wallet) return this.wallet;
357
363
  const mnemonic = (0, import_warps3.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
@@ -400,6 +406,9 @@ var ReadOnlyWalletProvider = class {
400
406
  const address = (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
401
407
  throw new Error(`Wallet can not be used for signing: ${address}`);
402
408
  }
409
+ async delete(externalId) {
410
+ (0, import_warps4.removeWarpWalletFromConfig)(this.config, this.chain.name);
411
+ }
403
412
  };
404
413
 
405
414
  // src/tokens.ts
@@ -822,7 +831,7 @@ var WarpEvmDataLoader = class {
822
831
  return this.chain.nativeToken;
823
832
  }
824
833
  const cacheKey = import_warps14.WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
825
- const cachedAsset = this.cache.get(cacheKey);
834
+ const cachedAsset = await this.cache.get(cacheKey);
826
835
  if (cachedAsset) {
827
836
  return cachedAsset;
828
837
  }
@@ -849,7 +858,7 @@ var WarpEvmDataLoader = class {
849
858
  decimals: metadata.decimals,
850
859
  logoUrl: metadata.logoUrl
851
860
  };
852
- this.cache.set(cacheKey, asset, import_warps14.CacheTtl.OneHour);
861
+ await this.cache.set(cacheKey, asset, import_warps14.CacheTtl.OneHour);
853
862
  return asset;
854
863
  } catch (error) {
855
864
  return null;
@@ -1260,7 +1269,7 @@ var WarpEvmOutput = class {
1260
1269
  this.cache = new import_warps16.WarpCache(config.env, config.cache);
1261
1270
  }
1262
1271
  async getActionExecution(warp, actionIndex, tx) {
1263
- const inputs = this.cache.get(import_warps16.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
1272
+ const inputs = await this.cache.get(import_warps16.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
1264
1273
  const resolvedInputs = (0, import_warps16.extractResolvedInputValues)(inputs);
1265
1274
  if (!tx) {
1266
1275
  return this.createFailedExecution(warp, actionIndex, resolvedInputs);
@@ -1800,8 +1809,10 @@ var WarpEvmExplorer = class {
1800
1809
 
1801
1810
  // src/WarpEvmWallet.ts
1802
1811
  var import_warps18 = require("@joai/warps");
1812
+ var import_evm = require("@x402/evm");
1803
1813
  var import_client = require("@x402/evm/exact/client");
1804
1814
  var import_ethers7 = require("ethers");
1815
+ var import_viem = require("viem");
1805
1816
  var import_accounts = require("viem/accounts");
1806
1817
  var WarpEvmWallet = class {
1807
1818
  constructor(config, chain) {
@@ -1898,6 +1909,10 @@ var WarpEvmWallet = class {
1898
1909
  const walletProvider = this.createProviderForOperation(provider);
1899
1910
  return await walletProvider.generate();
1900
1911
  }
1912
+ async delete(provider, externalId) {
1913
+ const walletProvider = this.createProviderForOperation(provider);
1914
+ await walletProvider.delete(externalId);
1915
+ }
1901
1916
  getAddress() {
1902
1917
  return this.cachedAddress;
1903
1918
  }
@@ -1911,7 +1926,12 @@ var WarpEvmWallet = class {
1911
1926
  if (typeof getInstance !== "function") throw new Error("Wallet provider does not have getWalletInstance method");
1912
1927
  const wallet = getInstance();
1913
1928
  if (!wallet || !wallet.privateKey) throw new Error("Wallet instance does not have private key");
1914
- const signer = (0, import_accounts.privateKeyToAccount)(wallet.privateKey);
1929
+ const signer = (0, import_evm.toClientEvmSigner)(
1930
+ (0, import_accounts.privateKeyToAccount)(wallet.privateKey),
1931
+ (0, import_viem.createPublicClient)({
1932
+ transport: (0, import_viem.http)((0, import_warps18.getProviderConfig)(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl).url)
1933
+ })
1934
+ );
1915
1935
  const handlers = {};
1916
1936
  for (const chainId of SupportedEvmChainIds) {
1917
1937
  handlers[`eip155:${chainId}`] = () => {