@vleap/warps-adapter-evm 0.2.0-beta.68 → 0.2.0-beta.69
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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +63 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -272,6 +272,11 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
|
272
272
|
private createProvider;
|
|
273
273
|
private initializeCache;
|
|
274
274
|
private createProviderForOperation;
|
|
275
|
+
private formatTransaction;
|
|
276
|
+
private formatBigInt;
|
|
277
|
+
private parseBigInt;
|
|
278
|
+
private normalizePriorityFee;
|
|
279
|
+
private needsFormatting;
|
|
275
280
|
}
|
|
276
281
|
|
|
277
282
|
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
|
@@ -272,6 +272,11 @@ declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
|
272
272
|
private createProvider;
|
|
273
273
|
private initializeCache;
|
|
274
274
|
private createProviderForOperation;
|
|
275
|
+
private formatTransaction;
|
|
276
|
+
private formatBigInt;
|
|
277
|
+
private parseBigInt;
|
|
278
|
+
private normalizePriorityFee;
|
|
279
|
+
private needsFormatting;
|
|
275
280
|
}
|
|
276
281
|
|
|
277
282
|
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
|
@@ -304,7 +304,7 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
304
304
|
return this.getWallet();
|
|
305
305
|
}
|
|
306
306
|
async importFromMnemonic(mnemonic) {
|
|
307
|
-
const wallet = import_ethers2.
|
|
307
|
+
const wallet = import_ethers2.HDNodeWallet.fromPhrase(mnemonic.trim());
|
|
308
308
|
const walletDetails = {
|
|
309
309
|
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
310
310
|
address: wallet.address,
|
|
@@ -337,8 +337,12 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
337
337
|
};
|
|
338
338
|
}
|
|
339
339
|
async generate() {
|
|
340
|
-
const
|
|
341
|
-
const
|
|
340
|
+
const mnemonicRaw = bip39.generateMnemonic(import_english.wordlist, 256);
|
|
341
|
+
const mnemonic = typeof mnemonicRaw === "string" ? mnemonicRaw.trim() : String(mnemonicRaw).trim();
|
|
342
|
+
const words = mnemonic.split(/\s+/).filter((w) => w.length > 0);
|
|
343
|
+
if (words.length !== 24) throw new Error(`Failed to generate valid 24-word mnemonic. Got ${words.length} words`);
|
|
344
|
+
const mnemonicForEthers = words.join(" ");
|
|
345
|
+
const wallet = import_ethers2.HDNodeWallet.fromPhrase(mnemonicForEthers);
|
|
342
346
|
return {
|
|
343
347
|
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
344
348
|
address: wallet.address,
|
|
@@ -350,7 +354,7 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
350
354
|
if (this.wallet) return this.wallet;
|
|
351
355
|
const mnemonic = (0, import_warps3.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
352
356
|
if (!mnemonic) throw new Error("No mnemonic provided");
|
|
353
|
-
this.wallet = import_ethers2.
|
|
357
|
+
this.wallet = import_ethers2.HDNodeWallet.fromPhrase(mnemonic.trim());
|
|
354
358
|
return this.wallet;
|
|
355
359
|
}
|
|
356
360
|
};
|
|
@@ -1698,7 +1702,8 @@ var WarpEvmWallet = class {
|
|
|
1698
1702
|
tx.nonce = await this.provider.getTransactionCount(address, "pending");
|
|
1699
1703
|
}
|
|
1700
1704
|
}
|
|
1701
|
-
|
|
1705
|
+
const formattedTx = this.needsFormatting() ? this.formatTransaction(tx) : tx;
|
|
1706
|
+
return await this.walletProvider.signTransaction(formattedTx);
|
|
1702
1707
|
}
|
|
1703
1708
|
async signTransactions(txs) {
|
|
1704
1709
|
if (txs.length === 0) return [];
|
|
@@ -1825,6 +1830,59 @@ var WarpEvmWallet = class {
|
|
|
1825
1830
|
if (provider === "mnemonic") return new MnemonicWalletProvider(this.config, this.chain);
|
|
1826
1831
|
throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${provider}`);
|
|
1827
1832
|
}
|
|
1833
|
+
formatTransaction(tx) {
|
|
1834
|
+
const formatted = {
|
|
1835
|
+
...tx,
|
|
1836
|
+
value: this.formatBigInt(tx.value) || "0x0",
|
|
1837
|
+
data: tx.data || "0x",
|
|
1838
|
+
chainId: typeof tx.chainId === "number" ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId))
|
|
1839
|
+
};
|
|
1840
|
+
if (tx.gasLimit) formatted.gas = this.formatBigInt(tx.gasLimit);
|
|
1841
|
+
if (tx.nonce !== void 0)
|
|
1842
|
+
formatted.nonce = typeof tx.nonce === "number" ? `0x${tx.nonce.toString(16)}` : this.formatBigInt(tx.nonce);
|
|
1843
|
+
const hasEip1559Fields = tx.maxFeePerGas !== void 0 && tx.maxPriorityFeePerGas !== void 0;
|
|
1844
|
+
const hasLegacyFields = tx.gasPrice !== void 0 && !hasEip1559Fields;
|
|
1845
|
+
if (hasEip1559Fields) {
|
|
1846
|
+
const maxFee = this.parseBigInt(tx.maxFeePerGas);
|
|
1847
|
+
const maxPriorityFee = this.parseBigInt(tx.maxPriorityFeePerGas);
|
|
1848
|
+
const safePriorityFee = this.normalizePriorityFee(maxFee, maxPriorityFee);
|
|
1849
|
+
formatted.maxFeePerGas = this.formatBigInt(maxFee);
|
|
1850
|
+
formatted.maxPriorityFeePerGas = this.formatBigInt(safePriorityFee);
|
|
1851
|
+
} else if (hasLegacyFields) {
|
|
1852
|
+
const gasPrice = this.parseBigInt(tx.gasPrice);
|
|
1853
|
+
formatted.maxFeePerGas = this.formatBigInt(gasPrice);
|
|
1854
|
+
const priorityFee = gasPrice * 9n / 10n;
|
|
1855
|
+
formatted.maxPriorityFeePerGas = this.formatBigInt(priorityFee > 0n ? priorityFee : 1n);
|
|
1856
|
+
} else {
|
|
1857
|
+
const defaultMaxFee = 1000000000n;
|
|
1858
|
+
formatted.maxFeePerGas = this.formatBigInt(defaultMaxFee);
|
|
1859
|
+
formatted.maxPriorityFeePerGas = this.formatBigInt(defaultMaxFee / 10n);
|
|
1860
|
+
}
|
|
1861
|
+
return formatted;
|
|
1862
|
+
}
|
|
1863
|
+
formatBigInt(value) {
|
|
1864
|
+
if (value === void 0 || value === null) return void 0;
|
|
1865
|
+
if (typeof value === "bigint") return `0x${value.toString(16)}`;
|
|
1866
|
+
if (typeof value === "string" && value.startsWith("0x")) return value;
|
|
1867
|
+
return `0x${BigInt(value).toString(16)}`;
|
|
1868
|
+
}
|
|
1869
|
+
parseBigInt(value) {
|
|
1870
|
+
if (value === void 0 || value === null) return void 0;
|
|
1871
|
+
if (typeof value === "bigint") return value;
|
|
1872
|
+
return BigInt(value);
|
|
1873
|
+
}
|
|
1874
|
+
normalizePriorityFee(maxFee, maxPriorityFee) {
|
|
1875
|
+
if (maxPriorityFee <= maxFee) return maxPriorityFee;
|
|
1876
|
+
const safeFee = maxFee / 10n;
|
|
1877
|
+
if (safeFee < 1n) return 1n;
|
|
1878
|
+
if (safeFee > maxFee) return maxFee;
|
|
1879
|
+
return safeFee;
|
|
1880
|
+
}
|
|
1881
|
+
needsFormatting() {
|
|
1882
|
+
if (!this.walletProvider) return false;
|
|
1883
|
+
const providerName = this.walletProvider.constructor?.PROVIDER_NAME;
|
|
1884
|
+
return providerName === "coinbase";
|
|
1885
|
+
}
|
|
1828
1886
|
};
|
|
1829
1887
|
|
|
1830
1888
|
// src/chains/common.ts
|