@joai/warps-adapter-evm 1.0.0 → 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ var _UniswapService = class _UniswapService {
|
|
|
33
33
|
async findToken(address) {
|
|
34
34
|
const normalizedAddress = address.toLowerCase();
|
|
35
35
|
const cacheKey = `uniswap:token:${this.chainId}:${normalizedAddress}`;
|
|
36
|
-
const cachedToken = this.cache.get(cacheKey);
|
|
36
|
+
const cachedToken = await this.cache.get(cacheKey);
|
|
37
37
|
if (cachedToken) {
|
|
38
38
|
return cachedToken;
|
|
39
39
|
}
|
|
@@ -44,9 +44,9 @@ var _UniswapService = class _UniswapService {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
if (token) {
|
|
47
|
-
this.cache.set(cacheKey, token, CacheTtl.OneHour);
|
|
47
|
+
await this.cache.set(cacheKey, token, CacheTtl.OneHour);
|
|
48
48
|
} else {
|
|
49
|
-
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
49
|
+
await this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
50
50
|
}
|
|
51
51
|
return token;
|
|
52
52
|
} catch (error) {
|
|
@@ -56,13 +56,13 @@ var _UniswapService = class _UniswapService {
|
|
|
56
56
|
async getTokenMetadata(address) {
|
|
57
57
|
const normalizedAddress = address.toLowerCase();
|
|
58
58
|
const cacheKey = `uniswap:metadata:${this.chainId}:${normalizedAddress}`;
|
|
59
|
-
const cachedMetadata = this.cache.get(cacheKey);
|
|
59
|
+
const cachedMetadata = await this.cache.get(cacheKey);
|
|
60
60
|
if (cachedMetadata !== null) {
|
|
61
61
|
return cachedMetadata;
|
|
62
62
|
}
|
|
63
63
|
const token = await this.findToken(address);
|
|
64
64
|
if (!token) {
|
|
65
|
-
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
65
|
+
await this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
const metadata = {
|
|
@@ -71,26 +71,26 @@ var _UniswapService = class _UniswapService {
|
|
|
71
71
|
decimals: token.decimals,
|
|
72
72
|
logoUrl: token.logoURI
|
|
73
73
|
};
|
|
74
|
-
this.cache.set(cacheKey, metadata, CacheTtl.OneHour);
|
|
74
|
+
await this.cache.set(cacheKey, metadata, CacheTtl.OneHour);
|
|
75
75
|
return metadata;
|
|
76
76
|
}
|
|
77
77
|
async getBridgeInfo(address) {
|
|
78
78
|
const normalizedAddress = address.toLowerCase();
|
|
79
79
|
const cacheKey = `uniswap:bridge:${this.chainId}:${normalizedAddress}`;
|
|
80
|
-
const cachedBridgeInfo = this.cache.get(cacheKey);
|
|
80
|
+
const cachedBridgeInfo = await this.cache.get(cacheKey);
|
|
81
81
|
if (cachedBridgeInfo !== null) {
|
|
82
82
|
return cachedBridgeInfo;
|
|
83
83
|
}
|
|
84
84
|
const token = await this.findToken(address);
|
|
85
85
|
if (!token?.extensions?.bridgeInfo) {
|
|
86
|
-
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
86
|
+
await this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
89
|
const bridgeInfo = {};
|
|
90
90
|
for (const [chainId, info] of Object.entries(token.extensions.bridgeInfo)) {
|
|
91
91
|
bridgeInfo[chainId] = info.tokenAddress;
|
|
92
92
|
}
|
|
93
|
-
this.cache.set(cacheKey, bridgeInfo, CacheTtl.OneHour);
|
|
93
|
+
await this.cache.set(cacheKey, bridgeInfo, CacheTtl.OneHour);
|
|
94
94
|
return bridgeInfo;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
@@ -102,6 +102,7 @@ import { ethers } from "ethers";
|
|
|
102
102
|
import {
|
|
103
103
|
getWarpWalletMnemonicFromConfig,
|
|
104
104
|
getWarpWalletPrivateKeyFromConfig,
|
|
105
|
+
removeWarpWalletFromConfig,
|
|
105
106
|
setWarpWalletInConfig
|
|
106
107
|
} from "@joai/warps";
|
|
107
108
|
var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
@@ -190,6 +191,9 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
190
191
|
mnemonic: null
|
|
191
192
|
};
|
|
192
193
|
}
|
|
194
|
+
async delete(externalId) {
|
|
195
|
+
removeWarpWalletFromConfig(this.config, this.chain.name);
|
|
196
|
+
}
|
|
193
197
|
getWallet() {
|
|
194
198
|
if (this.wallet) return this.wallet;
|
|
195
199
|
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
@@ -210,6 +214,7 @@ import {
|
|
|
210
214
|
getWarpWalletPrivateKeyFromConfig as getWarpWalletPrivateKeyFromConfig2,
|
|
211
215
|
normalizeAndValidateMnemonic,
|
|
212
216
|
normalizeMnemonic,
|
|
217
|
+
removeWarpWalletFromConfig as removeWarpWalletFromConfig2,
|
|
213
218
|
setWarpWalletInConfig as setWarpWalletInConfig2,
|
|
214
219
|
validateMnemonicLength
|
|
215
220
|
} from "@joai/warps";
|
|
@@ -304,6 +309,9 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
304
309
|
mnemonic
|
|
305
310
|
};
|
|
306
311
|
}
|
|
312
|
+
async delete(externalId) {
|
|
313
|
+
removeWarpWalletFromConfig2(this.config, this.chain.name);
|
|
314
|
+
}
|
|
307
315
|
getWallet() {
|
|
308
316
|
if (this.wallet) return this.wallet;
|
|
309
317
|
const mnemonic = getWarpWalletMnemonicFromConfig2(this.config, this.chain.name);
|
|
@@ -316,7 +324,7 @@ _MnemonicWalletProvider.PROVIDER_NAME = "mnemonic";
|
|
|
316
324
|
var MnemonicWalletProvider = _MnemonicWalletProvider;
|
|
317
325
|
|
|
318
326
|
// src/providers/ReadOnlyWalletProvider.ts
|
|
319
|
-
import { getWarpWalletAddressFromConfig } from "@joai/warps";
|
|
327
|
+
import { getWarpWalletAddressFromConfig, removeWarpWalletFromConfig as removeWarpWalletFromConfig3 } from "@joai/warps";
|
|
320
328
|
var ReadOnlyWalletProvider = class {
|
|
321
329
|
constructor(config, chain) {
|
|
322
330
|
this.config = config;
|
|
@@ -352,6 +360,9 @@ var ReadOnlyWalletProvider = class {
|
|
|
352
360
|
const address = getWarpWalletAddressFromConfig(this.config, this.chain.name);
|
|
353
361
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
354
362
|
}
|
|
363
|
+
async delete(externalId) {
|
|
364
|
+
removeWarpWalletFromConfig3(this.config, this.chain.name);
|
|
365
|
+
}
|
|
355
366
|
};
|
|
356
367
|
|
|
357
368
|
// src/tokens.ts
|
|
@@ -774,7 +785,7 @@ var WarpEvmDataLoader = class {
|
|
|
774
785
|
return this.chain.nativeToken;
|
|
775
786
|
}
|
|
776
787
|
const cacheKey = WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
|
|
777
|
-
const cachedAsset = this.cache.get(cacheKey);
|
|
788
|
+
const cachedAsset = await this.cache.get(cacheKey);
|
|
778
789
|
if (cachedAsset) {
|
|
779
790
|
return cachedAsset;
|
|
780
791
|
}
|
|
@@ -801,7 +812,7 @@ var WarpEvmDataLoader = class {
|
|
|
801
812
|
decimals: metadata.decimals,
|
|
802
813
|
logoUrl: metadata.logoUrl
|
|
803
814
|
};
|
|
804
|
-
this.cache.set(cacheKey, asset, CacheTtl2.OneHour);
|
|
815
|
+
await this.cache.set(cacheKey, asset, CacheTtl2.OneHour);
|
|
805
816
|
return asset;
|
|
806
817
|
} catch (error) {
|
|
807
818
|
return null;
|
|
@@ -1231,7 +1242,7 @@ var WarpEvmOutput = class {
|
|
|
1231
1242
|
this.cache = new WarpCache3(config.env, config.cache);
|
|
1232
1243
|
}
|
|
1233
1244
|
async getActionExecution(warp, actionIndex, tx) {
|
|
1234
|
-
const inputs = this.cache.get(WarpCacheKey2.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
1245
|
+
const inputs = await this.cache.get(WarpCacheKey2.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
1235
1246
|
const resolvedInputs = extractResolvedInputValues(inputs);
|
|
1236
1247
|
if (!tx) {
|
|
1237
1248
|
return this.createFailedExecution(warp, actionIndex, resolvedInputs);
|
|
@@ -1343,7 +1354,7 @@ var WarpEvmOutput = class {
|
|
|
1343
1354
|
output[key] = path;
|
|
1344
1355
|
}
|
|
1345
1356
|
}
|
|
1346
|
-
return { values, output: await evaluateOutputCommon(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
1357
|
+
return { values, output: await evaluateOutputCommon(warp, output, nativeValues, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
1347
1358
|
}
|
|
1348
1359
|
async getTransactionStatus(txHash) {
|
|
1349
1360
|
try {
|
|
@@ -1773,8 +1784,10 @@ var WarpEvmExplorer = class {
|
|
|
1773
1784
|
import {
|
|
1774
1785
|
getProviderConfig as getProviderConfig4
|
|
1775
1786
|
} from "@joai/warps";
|
|
1787
|
+
import { toClientEvmSigner } from "@x402/evm";
|
|
1776
1788
|
import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
1777
1789
|
import { ethers as ethers7 } from "ethers";
|
|
1790
|
+
import { createPublicClient, http } from "viem";
|
|
1778
1791
|
import { privateKeyToAccount } from "viem/accounts";
|
|
1779
1792
|
var WarpEvmWallet = class {
|
|
1780
1793
|
constructor(config, chain) {
|
|
@@ -1871,6 +1884,10 @@ var WarpEvmWallet = class {
|
|
|
1871
1884
|
const walletProvider = this.createProviderForOperation(provider);
|
|
1872
1885
|
return await walletProvider.generate();
|
|
1873
1886
|
}
|
|
1887
|
+
async delete(provider, externalId) {
|
|
1888
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
1889
|
+
await walletProvider.delete(externalId);
|
|
1890
|
+
}
|
|
1874
1891
|
getAddress() {
|
|
1875
1892
|
return this.cachedAddress;
|
|
1876
1893
|
}
|
|
@@ -1884,7 +1901,12 @@ var WarpEvmWallet = class {
|
|
|
1884
1901
|
if (typeof getInstance !== "function") throw new Error("Wallet provider does not have getWalletInstance method");
|
|
1885
1902
|
const wallet = getInstance();
|
|
1886
1903
|
if (!wallet || !wallet.privateKey) throw new Error("Wallet instance does not have private key");
|
|
1887
|
-
const signer =
|
|
1904
|
+
const signer = toClientEvmSigner(
|
|
1905
|
+
privateKeyToAccount(wallet.privateKey),
|
|
1906
|
+
createPublicClient({
|
|
1907
|
+
transport: http(getProviderConfig4(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl).url)
|
|
1908
|
+
})
|
|
1909
|
+
);
|
|
1888
1910
|
const handlers = {};
|
|
1889
1911
|
for (const chainId of SupportedEvmChainIds) {
|
|
1890
1912
|
handlers[`eip155:${chainId}`] = () => {
|