@dynamic-labs/ethereum-core 3.0.0-alpha.49
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/CHANGELOG.md +3894 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/_virtual/_tslib.cjs +49 -0
- package/_virtual/_tslib.js +44 -0
- package/package.json +37 -0
- package/src/index.cjs +34 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +13 -0
- package/src/lib/utils/index.d.ts +2 -0
- package/src/lib/utils/logger.cjs +10 -0
- package/src/lib/utils/logger.d.ts +2 -0
- package/src/lib/utils/logger.js +6 -0
- package/src/lib/utils/validateAddressFormat.cjs +8 -0
- package/src/lib/utils/validateAddressFormat.d.ts +1 -0
- package/src/lib/utils/validateAddressFormat.js +4 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.cjs +51 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.d.ts +20 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.js +47 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs +98 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.d.ts +37 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js +94 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.cjs +121 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.d.ts +56 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.js +117 -0
- package/src/lib/utils/viem/ViemUiTransaction/index.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.cjs +31 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.js +7 -0
- package/src/lib/utils/viem/chainsMap/index.d.ts +1 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.cjs +39 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.d.ts +11 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.js +35 -0
- package/src/lib/utils/viem/confirmationTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.cjs +41 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.d.ts +12 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.js +37 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.cjs +33 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.d.ts +25 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.js +29 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.cjs +40 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.d.ts +9 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.js +36 -0
- package/src/lib/utils/viem/createViemUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.cjs +70 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.d.ts +19 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.js +46 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.cjs +73 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.d.ts +29 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.js +69 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/erc20/abi.cjs +230 -0
- package/src/lib/utils/viem/erc20/abi.d.ts +38 -0
- package/src/lib/utils/viem/erc20/abi.js +226 -0
- package/src/lib/utils/viem/erc20/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.cjs +31 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.d.ts +10 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.js +26 -0
- package/src/lib/utils/viem/estimateL1Fee/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.cjs +23 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.d.ts +20 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.js +18 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs +30 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.d.ts +3 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.js +25 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/index.d.ts +1 -0
- package/src/lib/utils/viem/formatEther/formatEther.cjs +11 -0
- package/src/lib/utils/viem/formatEther/formatEther.d.ts +2 -0
- package/src/lib/utils/viem/formatEther/formatEther.js +7 -0
- package/src/lib/utils/viem/formatEther/index.d.ts +1 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.cjs +77 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.d.ts +11 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.js +51 -0
- package/src/lib/utils/viem/getOrMapViemChain/index.d.ts +1 -0
- package/src/lib/utils/viem/index.d.ts +11 -0
- package/src/lib/utils/viem/interceptTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.cjs +35 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.d.ts +29 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.js +31 -0
- package/src/lib/utils/viem/parseEther/index.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.cjs +10 -0
- package/src/lib/utils/viem/parseEther/parseEther.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.js +6 -0
- package/src/lib/utils/viem/unFormatTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.cjs +30 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.d.ts +8 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.js +26 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Address, CustomTransport, Hex, RpcTransactionRequest, Transport } from 'viem';
|
|
2
|
+
type Provider = Pick<ReturnType<CustomTransport>, 'request'>;
|
|
3
|
+
export type InterceptTransportProps = {
|
|
4
|
+
transport: Transport;
|
|
5
|
+
getAccounts?: (props: {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
}) => Promise<Address[]>;
|
|
8
|
+
onPersonalSign?: (props: {
|
|
9
|
+
message: Hex;
|
|
10
|
+
args: Args;
|
|
11
|
+
provider: Provider;
|
|
12
|
+
}) => Promise<string>;
|
|
13
|
+
onSendTransaction?: (props: {
|
|
14
|
+
transaction: RpcTransactionRequest;
|
|
15
|
+
args: Args;
|
|
16
|
+
provider: Provider;
|
|
17
|
+
}) => Promise<Hex>;
|
|
18
|
+
onSignTypedData?: (props: {
|
|
19
|
+
message: string;
|
|
20
|
+
args: Args;
|
|
21
|
+
provider: Provider;
|
|
22
|
+
}) => Promise<string>;
|
|
23
|
+
};
|
|
24
|
+
type Args = {
|
|
25
|
+
method: string;
|
|
26
|
+
params: unknown[];
|
|
27
|
+
};
|
|
28
|
+
export declare const interceptTransport: ({ getAccounts, onPersonalSign, onSendTransaction, onSignTypedData, transport, }: InterceptTransportProps) => CustomTransport;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { custom } from 'viem';
|
|
4
|
+
|
|
5
|
+
const interceptTransport = ({ getAccounts, onPersonalSign, onSendTransaction, onSignTypedData, transport, }) => (props) => {
|
|
6
|
+
const provider = transport(props);
|
|
7
|
+
return custom({
|
|
8
|
+
request: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
var _a;
|
|
10
|
+
const { method, params } = args;
|
|
11
|
+
if (getAccounts && method === 'eth_accounts') {
|
|
12
|
+
return getAccounts({ provider });
|
|
13
|
+
}
|
|
14
|
+
if (onPersonalSign && method === 'personal_sign') {
|
|
15
|
+
const [message] = params;
|
|
16
|
+
return onPersonalSign({ args, message, provider });
|
|
17
|
+
}
|
|
18
|
+
if (onSendTransaction && method === 'eth_sendTransaction') {
|
|
19
|
+
const [transaction] = params;
|
|
20
|
+
return onSendTransaction({ args, provider, transaction });
|
|
21
|
+
}
|
|
22
|
+
if (onSignTypedData && method === 'eth_signTypedData_v4') {
|
|
23
|
+
const [, message] = (_a = params) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
return onSignTypedData({ args, message, provider });
|
|
25
|
+
}
|
|
26
|
+
return provider.request(args);
|
|
27
|
+
}),
|
|
28
|
+
})(props);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { interceptTransport };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseEther } from './parseEther';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseEther: (input: string) => bigint;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { unFormatTransaction } from './unFormatTransaction';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var viem = require('viem');
|
|
7
|
+
|
|
8
|
+
/* eslint-disable max-len */
|
|
9
|
+
/**
|
|
10
|
+
* Unformat a transaction request
|
|
11
|
+
* This is used to convert the transaction the RPC transporter receives from
|
|
12
|
+
* an eth_sendTransaction call to a format that viem account accepts.
|
|
13
|
+
* This reverts what viem is doing internally with the format function.
|
|
14
|
+
* https://github.com/wagmi-dev/viem/blob/0977829160effbe7dac5a69f43d263605544fa19/src/actions/wallet/sendTransaction.ts#L206
|
|
15
|
+
*/
|
|
16
|
+
const unFormatTransaction = (transactionRequest) => (Object.assign(Object.assign({}, transactionRequest), { gas: typeof transactionRequest.gas !== 'undefined'
|
|
17
|
+
? viem.hexToBigInt(transactionRequest.gas)
|
|
18
|
+
: undefined, gasPrice: typeof transactionRequest.gasPrice !== 'undefined'
|
|
19
|
+
? viem.hexToBigInt(transactionRequest.gasPrice)
|
|
20
|
+
: undefined, maxFeePerGas: typeof transactionRequest.maxFeePerGas !== 'undefined'
|
|
21
|
+
? viem.hexToBigInt(transactionRequest.maxFeePerGas)
|
|
22
|
+
: undefined, maxPriorityFeePerGas: typeof transactionRequest.maxPriorityFeePerGas !== 'undefined'
|
|
23
|
+
? viem.hexToBigInt(transactionRequest.maxPriorityFeePerGas)
|
|
24
|
+
: undefined, nonce: typeof transactionRequest.nonce !== 'undefined'
|
|
25
|
+
? viem.hexToBigInt(transactionRequest.nonce)
|
|
26
|
+
: undefined, value: typeof transactionRequest.value !== 'undefined'
|
|
27
|
+
? viem.hexToBigInt(transactionRequest.value)
|
|
28
|
+
: undefined }));
|
|
29
|
+
|
|
30
|
+
exports.unFormatTransaction = unFormatTransaction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unformat a transaction request
|
|
3
|
+
* This is used to convert the transaction the RPC transporter receives from
|
|
4
|
+
* an eth_sendTransaction call to a format that viem account accepts.
|
|
5
|
+
* This reverts what viem is doing internally with the format function.
|
|
6
|
+
* https://github.com/wagmi-dev/viem/blob/0977829160effbe7dac5a69f43d263605544fa19/src/actions/wallet/sendTransaction.ts#L206
|
|
7
|
+
*/
|
|
8
|
+
export declare const unFormatTransaction: (transactionRequest: any) => any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { hexToBigInt } from 'viem';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable max-len */
|
|
5
|
+
/**
|
|
6
|
+
* Unformat a transaction request
|
|
7
|
+
* This is used to convert the transaction the RPC transporter receives from
|
|
8
|
+
* an eth_sendTransaction call to a format that viem account accepts.
|
|
9
|
+
* This reverts what viem is doing internally with the format function.
|
|
10
|
+
* https://github.com/wagmi-dev/viem/blob/0977829160effbe7dac5a69f43d263605544fa19/src/actions/wallet/sendTransaction.ts#L206
|
|
11
|
+
*/
|
|
12
|
+
const unFormatTransaction = (transactionRequest) => (Object.assign(Object.assign({}, transactionRequest), { gas: typeof transactionRequest.gas !== 'undefined'
|
|
13
|
+
? hexToBigInt(transactionRequest.gas)
|
|
14
|
+
: undefined, gasPrice: typeof transactionRequest.gasPrice !== 'undefined'
|
|
15
|
+
? hexToBigInt(transactionRequest.gasPrice)
|
|
16
|
+
: undefined, maxFeePerGas: typeof transactionRequest.maxFeePerGas !== 'undefined'
|
|
17
|
+
? hexToBigInt(transactionRequest.maxFeePerGas)
|
|
18
|
+
: undefined, maxPriorityFeePerGas: typeof transactionRequest.maxPriorityFeePerGas !== 'undefined'
|
|
19
|
+
? hexToBigInt(transactionRequest.maxPriorityFeePerGas)
|
|
20
|
+
: undefined, nonce: typeof transactionRequest.nonce !== 'undefined'
|
|
21
|
+
? hexToBigInt(transactionRequest.nonce)
|
|
22
|
+
: undefined, value: typeof transactionRequest.value !== 'undefined'
|
|
23
|
+
? hexToBigInt(transactionRequest.value)
|
|
24
|
+
: undefined }));
|
|
25
|
+
|
|
26
|
+
export { unFormatTransaction };
|