@vleap/warps-adapter-evm 0.2.0-beta.59 → 0.2.0-beta.61
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 +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +45 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory, WarpChain, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails } from '@vleap/warps';
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChain, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
|
|
4
4
|
declare const NativeTokenArb: WarpChainAsset;
|
|
@@ -257,18 +257,19 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
|
257
257
|
private cachedAddress;
|
|
258
258
|
private cachedPublicKey;
|
|
259
259
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
260
|
-
private createProvider;
|
|
261
|
-
private initializeCache;
|
|
262
260
|
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
263
261
|
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
264
262
|
signMessage(message: string): Promise<string>;
|
|
265
263
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
266
264
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
267
|
-
create(mnemonic: string): WarpWalletDetails;
|
|
268
|
-
generate(): WarpWalletDetails;
|
|
265
|
+
create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
|
|
266
|
+
generate(provider: WarpWalletProvider): WarpWalletDetails;
|
|
269
267
|
getAddress(): string | null;
|
|
270
268
|
getPublicKey(): string | null;
|
|
271
269
|
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
|
270
|
+
private createProvider;
|
|
271
|
+
private initializeCache;
|
|
272
|
+
private createProviderForOperation;
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
export { ArbitrumAdapter, ArbitrumExplorers, BaseAdapter, BaseExplorers, EthereumAdapter, EthereumExplorers, EvmChainIdMap, EvmChainIds, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, SupportedEvmChainIds, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmOutput, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getKnownTokensForChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory, WarpChain, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails } from '@vleap/warps';
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChain, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
|
|
4
4
|
declare const NativeTokenArb: WarpChainAsset;
|
|
@@ -257,18 +257,19 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
|
257
257
|
private cachedAddress;
|
|
258
258
|
private cachedPublicKey;
|
|
259
259
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
260
|
-
private createProvider;
|
|
261
|
-
private initializeCache;
|
|
262
260
|
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
263
261
|
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
264
262
|
signMessage(message: string): Promise<string>;
|
|
265
263
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
266
264
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
267
|
-
create(mnemonic: string): WarpWalletDetails;
|
|
268
|
-
generate(): WarpWalletDetails;
|
|
265
|
+
create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
|
|
266
|
+
generate(provider: WarpWalletProvider): WarpWalletDetails;
|
|
269
267
|
getAddress(): string | null;
|
|
270
268
|
getPublicKey(): string | null;
|
|
271
269
|
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
|
270
|
+
private createProvider;
|
|
271
|
+
private initializeCache;
|
|
272
|
+
private createProviderForOperation;
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
export { ArbitrumAdapter, ArbitrumExplorers, BaseAdapter, BaseExplorers, EthereumAdapter, EthereumExplorers, EvmChainIdMap, EvmChainIds, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, SupportedEvmChainIds, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmOutput, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getKnownTokensForChain };
|
package/dist/index.js
CHANGED
|
@@ -146,11 +146,10 @@ var UniswapService = _UniswapService;
|
|
|
146
146
|
// src/providers/PrivateKeyWalletProvider.ts
|
|
147
147
|
var import_ethers = require("ethers");
|
|
148
148
|
var import_warps2 = require("@vleap/warps");
|
|
149
|
-
var
|
|
150
|
-
constructor(config, chain
|
|
149
|
+
var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
150
|
+
constructor(config, chain) {
|
|
151
151
|
this.config = config;
|
|
152
152
|
this.chain = chain;
|
|
153
|
-
this.rpcProvider = rpcProvider;
|
|
154
153
|
this.wallet = null;
|
|
155
154
|
}
|
|
156
155
|
async getAddress() {
|
|
@@ -193,21 +192,15 @@ var PrivateKeyWalletProvider = class {
|
|
|
193
192
|
return this.getWallet();
|
|
194
193
|
}
|
|
195
194
|
create(mnemonic) {
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
provider: "privateKey",
|
|
199
|
-
address: wallet.address,
|
|
200
|
-
privateKey: wallet.privateKey,
|
|
201
|
-
mnemonic
|
|
202
|
-
};
|
|
195
|
+
throw new Error("PrivateKeyWalletProvider does not support creating wallets from mnemonics. Use MnemonicWalletProvider instead.");
|
|
203
196
|
}
|
|
204
197
|
generate() {
|
|
205
198
|
const wallet = import_ethers.ethers.Wallet.createRandom();
|
|
206
199
|
return {
|
|
207
|
-
provider:
|
|
200
|
+
provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
|
|
208
201
|
address: wallet.address,
|
|
209
202
|
privateKey: wallet.privateKey,
|
|
210
|
-
mnemonic:
|
|
203
|
+
mnemonic: null
|
|
211
204
|
};
|
|
212
205
|
}
|
|
213
206
|
getWallet() {
|
|
@@ -218,15 +211,16 @@ var PrivateKeyWalletProvider = class {
|
|
|
218
211
|
return this.wallet;
|
|
219
212
|
}
|
|
220
213
|
};
|
|
214
|
+
_PrivateKeyWalletProvider.PROVIDER_NAME = "privateKey";
|
|
215
|
+
var PrivateKeyWalletProvider = _PrivateKeyWalletProvider;
|
|
221
216
|
|
|
222
217
|
// src/providers/MnemonicWalletProvider.ts
|
|
223
218
|
var import_ethers2 = require("ethers");
|
|
224
219
|
var import_warps3 = require("@vleap/warps");
|
|
225
|
-
var
|
|
226
|
-
constructor(config, chain
|
|
220
|
+
var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
221
|
+
constructor(config, chain) {
|
|
227
222
|
this.config = config;
|
|
228
223
|
this.chain = chain;
|
|
229
|
-
this.rpcProvider = rpcProvider;
|
|
230
224
|
this.wallet = null;
|
|
231
225
|
}
|
|
232
226
|
async getAddress() {
|
|
@@ -271,18 +265,18 @@ var MnemonicWalletProvider = class {
|
|
|
271
265
|
create(mnemonic) {
|
|
272
266
|
const wallet = import_ethers2.ethers.Wallet.fromPhrase(mnemonic);
|
|
273
267
|
return {
|
|
274
|
-
provider:
|
|
268
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
275
269
|
address: wallet.address,
|
|
276
|
-
privateKey:
|
|
270
|
+
privateKey: null,
|
|
277
271
|
mnemonic
|
|
278
272
|
};
|
|
279
273
|
}
|
|
280
274
|
generate() {
|
|
281
275
|
const wallet = import_ethers2.ethers.Wallet.createRandom();
|
|
282
276
|
return {
|
|
283
|
-
provider:
|
|
277
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
284
278
|
address: wallet.address,
|
|
285
|
-
privateKey:
|
|
279
|
+
privateKey: null,
|
|
286
280
|
mnemonic: wallet.mnemonic?.phrase || null
|
|
287
281
|
};
|
|
288
282
|
}
|
|
@@ -294,6 +288,8 @@ var MnemonicWalletProvider = class {
|
|
|
294
288
|
return this.wallet;
|
|
295
289
|
}
|
|
296
290
|
};
|
|
291
|
+
_MnemonicWalletProvider.PROVIDER_NAME = "mnemonic";
|
|
292
|
+
var MnemonicWalletProvider = _MnemonicWalletProvider;
|
|
297
293
|
|
|
298
294
|
// src/providers/ReadOnlyWalletProvider.ts
|
|
299
295
|
var import_warps4 = require("@vleap/warps");
|
|
@@ -1615,23 +1611,6 @@ var WarpEvmWallet = class {
|
|
|
1615
1611
|
this.walletProvider = this.createProvider();
|
|
1616
1612
|
this.initializeCache();
|
|
1617
1613
|
}
|
|
1618
|
-
createProvider() {
|
|
1619
|
-
const wallet = this.config.user?.wallets?.[this.chain.name];
|
|
1620
|
-
if (!wallet) return null;
|
|
1621
|
-
if (typeof wallet === "string") return new ReadOnlyWalletProvider(this.config, this.chain);
|
|
1622
|
-
const customWalletProviders = this.config.walletProviders?.[this.chain.name];
|
|
1623
|
-
const providerFactory = customWalletProviders?.[wallet.provider];
|
|
1624
|
-
if (providerFactory) return providerFactory(this.config, this.chain);
|
|
1625
|
-
if (wallet.provider === "privateKey") return new PrivateKeyWalletProvider(this.config, this.chain, this.provider);
|
|
1626
|
-
if (wallet.provider === "mnemonic") return new MnemonicWalletProvider(this.config, this.chain, this.provider);
|
|
1627
|
-
throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${wallet.provider}`);
|
|
1628
|
-
}
|
|
1629
|
-
initializeCache() {
|
|
1630
|
-
(0, import_warps15.initializeWalletCache)(this.walletProvider).then((cache) => {
|
|
1631
|
-
this.cachedAddress = cache.address;
|
|
1632
|
-
this.cachedPublicKey = cache.publicKey;
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
1614
|
async signTransaction(tx) {
|
|
1636
1615
|
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
1637
1616
|
if (!this.walletProvider) throw new Error("No wallet provider available");
|
|
@@ -1694,15 +1673,13 @@ var WarpEvmWallet = class {
|
|
|
1694
1673
|
async sendTransactions(txs) {
|
|
1695
1674
|
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
1696
1675
|
}
|
|
1697
|
-
create(mnemonic) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
return this.walletProvider.create(mnemonic);
|
|
1676
|
+
create(provider, mnemonic) {
|
|
1677
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
1678
|
+
return walletProvider.create(mnemonic);
|
|
1701
1679
|
}
|
|
1702
|
-
generate() {
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
return this.walletProvider.generate();
|
|
1680
|
+
generate(provider) {
|
|
1681
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
1682
|
+
return walletProvider.generate();
|
|
1706
1683
|
}
|
|
1707
1684
|
getAddress() {
|
|
1708
1685
|
return this.cachedAddress;
|
|
@@ -1726,6 +1703,30 @@ var WarpEvmWallet = class {
|
|
|
1726
1703
|
}
|
|
1727
1704
|
return handlers;
|
|
1728
1705
|
}
|
|
1706
|
+
createProvider() {
|
|
1707
|
+
const wallet = this.config.user?.wallets?.[this.chain.name];
|
|
1708
|
+
if (!wallet) return null;
|
|
1709
|
+
if (typeof wallet === "string") return new ReadOnlyWalletProvider(this.config, this.chain);
|
|
1710
|
+
return this.createProviderForOperation(wallet.provider);
|
|
1711
|
+
}
|
|
1712
|
+
initializeCache() {
|
|
1713
|
+
(0, import_warps15.initializeWalletCache)(this.walletProvider).then((cache) => {
|
|
1714
|
+
this.cachedAddress = cache.address;
|
|
1715
|
+
this.cachedPublicKey = cache.publicKey;
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
createProviderForOperation(provider) {
|
|
1719
|
+
const customWalletProviders = this.config.walletProviders?.[this.chain.name];
|
|
1720
|
+
const providerFactory = customWalletProviders?.[provider];
|
|
1721
|
+
if (providerFactory) {
|
|
1722
|
+
const walletProvider = providerFactory(this.config, this.chain);
|
|
1723
|
+
if (!walletProvider) throw new Error(`Custom wallet provider factory returned null for ${provider}`);
|
|
1724
|
+
return walletProvider;
|
|
1725
|
+
}
|
|
1726
|
+
if (provider === "privateKey") return new PrivateKeyWalletProvider(this.config, this.chain);
|
|
1727
|
+
if (provider === "mnemonic") return new MnemonicWalletProvider(this.config, this.chain);
|
|
1728
|
+
throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${provider}`);
|
|
1729
|
+
}
|
|
1729
1730
|
};
|
|
1730
1731
|
|
|
1731
1732
|
// src/chains/common.ts
|