viem 0.0.0 → 0.0.1-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 moxey.eth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../dist/actions/index.js"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../dist/chains.js"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../dist/clients/index.js"
4
+ }
@@ -0,0 +1,18 @@
1
+ type BaseErrorArgs = {
2
+ docsPath?: string;
3
+ } & ({
4
+ cause?: never;
5
+ details?: string;
6
+ } | {
7
+ cause: BaseError | Error;
8
+ details?: never;
9
+ });
10
+ declare class BaseError extends Error {
11
+ humanMessage: string;
12
+ details: string;
13
+ docsPath?: string;
14
+ name: string;
15
+ constructor(humanMessage: string, args?: BaseErrorArgs);
16
+ }
17
+
18
+ export { BaseError as B };
@@ -0,0 +1,12 @@
1
+ export { C as CallArgs, a as CallResponse, b as CreateBlockFilterResponse, c as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, d as EstimateGasResponse, bb as FormattedTransactionRequest, G as GetBalanceArgs, e as GetBalanceResponse, f as GetBlockArgs, g as GetBlockNumberArgs, h as GetBlockNumberResponse, i as GetBlockResponse, j as GetBlockTransactionCountArgs, k as GetBlockTransactionCountResponse, l as GetFeeHistoryArgs, m as GetFeeHistoryResponse, n as GetFilterChangesArgs, o as GetFilterChangesResponse, p as GetGasPriceResponse, q as GetPermissionsResponse, r as GetTransactionArgs, s as GetTransactionConfirmationsArgs, t as GetTransactionConfirmationsResponse, u as GetTransactionCountArgs, v as GetTransactionCountResponse, x as GetTransactionReceiptArgs, y as GetTransactionReceiptResponse, w as GetTransactionResponse, I as ImpersonateAccountArgs, z as IncreaseTimeArgs, bc as InvalidGasArgumentsError, M as MineArgs, O as OnBlock, A as OnBlockNumber, B as OnBlockNumberResponse, F as OnBlockResponse, H as OnTransactions, J as OnTransactionsResponse, b8 as ReplacementReason, b9 as ReplacementResponse, K as RequestPermissionsResponse, R as ResetArgs, L as RevertArgs, S as SendTransactionArgs, N as SendTransactionResponse, P as SendUnsignedTransactionArgs, Q as SendUnsignedTransactionResponse, T as SetBalanceArgs, U as SetBlockGasLimitArgs, Z as SetBlockTimestampIntervalArgs, V as SetCodeArgs, W as SetCoinbaseArgs, X as SetIntervalMiningArgs, Y as SetMinGasPriceArgs, $ as SetNextBlockBaseFeePerGasArgs, _ as SetNextBlockTimestampArgs, a0 as SetNonceArgs, a1 as SetStorageAtArgs, a2 as SignMessageArgs, a3 as SignMessageResponse, a4 as StopImpersonatingAccountArgs, a5 as SwitchChainArgs, a6 as UninstallFilterArgs, a7 as UninstallFilterResponse, a8 as WaitForTransactionReceiptArgs, a9 as WaitForTransactionReceiptResponse, ba as WaitForTransactionReceiptTimeoutError, aa as WatchAssetArgs, ab as WatchAssetResponse, ac as WatchBlockNumberArgs, ad as WatchBlocksArgs, ae as WatchPendingTransactionsArgs, af as addChain, ag as call, ah as createBlockFilter, ai as createPendingTransactionFilter, ak as dropTransaction, aj as estimateGas, al as getAutomine, am as getBalance, an as getBlock, ao as getBlockNumber, b6 as getBlockNumberCache, ap as getBlockTransactionCount, aq as getChainId, ar as getFeeHistory, b7 as getFilterChanges, as as getGasPrice, at as getPermissions, au as getTransaction, av as getTransactionConfirmations, aw as getTransactionCount, ax as getTransactionReceipt, ay as getTxpoolContent, az as getTxpoolStatus, aA as impersonateAccount, aB as increaseTime, aC as inspectTxpool, aD as mine, aE as removeBlockTimestampInterval, aG as requestAccounts, aH as requestPermissions, aF as reset, aI as revert, aJ as sendTransaction, aK as sendUnsignedTransaction, aL as setAutomine, aM as setBalance, aN as setBlockGasLimit, aO as setBlockTimestampInterval, aP as setCode, aQ as setCoinbase, aR as setIntervalMining, aS as setLoggingEnabled, aT as setMinGasPrice, aU as setNextBlockBaseFeePerGas, aV as setNextBlockTimestamp, aW as setNonce, aX as setStorageAt, aY as signMessage, aZ as snapshot, a_ as stopImpersonatingAccount, a$ as switchChain, b0 as uninstallFilter, b1 as waitForTransactionReceipt, b2 as watchAsset, b3 as watchBlockNumber, b4 as watchBlocks, b5 as watchPendingTransactions } from '../watchAsset-bb30848d.js';
2
+ import { W as WalletClient } from '../createWalletClient-c40fef16.js';
3
+ import '../chains.js';
4
+ import '../rpc-655c0ba4.js';
5
+ import '@wagmi/chains';
6
+ import '../transactionRequest-ade896ac.js';
7
+ import '../BaseError-7688f84e.js';
8
+ import '../eip1193-8f7c22ce.js';
9
+
10
+ declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
11
+
12
+ export { getAccounts };
@@ -0,0 +1,121 @@
1
+ import {
2
+ addChain,
3
+ call,
4
+ createBlockFilter,
5
+ createPendingTransactionFilter,
6
+ dropTransaction,
7
+ estimateGas,
8
+ getAccounts,
9
+ getAutomine,
10
+ getBalance,
11
+ getBlock,
12
+ getBlockNumber,
13
+ getBlockNumberCache,
14
+ getBlockTransactionCount,
15
+ getChainId,
16
+ getFeeHistory,
17
+ getFilterChanges,
18
+ getGasPrice,
19
+ getPermissions,
20
+ getTransaction,
21
+ getTransactionConfirmations,
22
+ getTransactionCount,
23
+ getTransactionReceipt,
24
+ getTxpoolContent,
25
+ getTxpoolStatus,
26
+ impersonateAccount,
27
+ increaseTime,
28
+ inspectTxpool,
29
+ mine,
30
+ removeBlockTimestampInterval,
31
+ requestAccounts,
32
+ requestPermissions,
33
+ reset,
34
+ revert,
35
+ sendTransaction,
36
+ sendUnsignedTransaction,
37
+ setAutomine,
38
+ setBalance,
39
+ setBlockGasLimit,
40
+ setBlockTimestampInterval,
41
+ setCode,
42
+ setCoinbase,
43
+ setIntervalMining,
44
+ setLoggingEnabled,
45
+ setMinGasPrice,
46
+ setNextBlockBaseFeePerGas,
47
+ setNextBlockTimestamp,
48
+ setNonce,
49
+ setStorageAt,
50
+ signMessage,
51
+ snapshot,
52
+ stopImpersonatingAccount,
53
+ switchChain,
54
+ uninstallFilter,
55
+ waitForTransactionReceipt,
56
+ watchAsset,
57
+ watchBlockNumber,
58
+ watchBlocks,
59
+ watchPendingTransactions
60
+ } from "../chunk-JSYJDK4W.js";
61
+ import "../chunk-GI67STNV.js";
62
+ export {
63
+ addChain,
64
+ call,
65
+ createBlockFilter,
66
+ createPendingTransactionFilter,
67
+ dropTransaction,
68
+ estimateGas,
69
+ getAccounts,
70
+ getAutomine,
71
+ getBalance,
72
+ getBlock,
73
+ getBlockNumber,
74
+ getBlockNumberCache,
75
+ getBlockTransactionCount,
76
+ getChainId,
77
+ getFeeHistory,
78
+ getFilterChanges,
79
+ getGasPrice,
80
+ getPermissions,
81
+ getTransaction,
82
+ getTransactionConfirmations,
83
+ getTransactionCount,
84
+ getTransactionReceipt,
85
+ getTxpoolContent,
86
+ getTxpoolStatus,
87
+ impersonateAccount,
88
+ increaseTime,
89
+ inspectTxpool,
90
+ mine,
91
+ removeBlockTimestampInterval,
92
+ requestAccounts,
93
+ requestPermissions,
94
+ reset,
95
+ revert,
96
+ sendTransaction,
97
+ sendUnsignedTransaction,
98
+ setAutomine,
99
+ setBalance,
100
+ setBlockGasLimit,
101
+ setBlockTimestampInterval,
102
+ setCode,
103
+ setCoinbase,
104
+ setIntervalMining,
105
+ setLoggingEnabled,
106
+ setMinGasPrice,
107
+ setNextBlockBaseFeePerGas,
108
+ setNextBlockTimestamp,
109
+ setNonce,
110
+ setStorageAt,
111
+ signMessage,
112
+ snapshot,
113
+ stopImpersonatingAccount,
114
+ switchChain,
115
+ uninstallFilter,
116
+ waitForTransactionReceipt,
117
+ watchAsset,
118
+ watchBlockNumber,
119
+ watchBlocks,
120
+ watchPendingTransactions
121
+ };
@@ -0,0 +1,113 @@
1
+ import { R as RpcBlock, B as Block, q as RpcTransaction, D as Transaction, r as RpcTransactionReceipt, T as TransactionReceipt, v as TransactionRequest, s as RpcTransactionRequest, N as TransactionType, H as Hex } from './rpc-655c0ba4.js';
2
+ import { Chain as Chain$1 } from '@wagmi/chains';
3
+
4
+ type Formatter<TSource = any, TTarget = any> = (value: TSource & {
5
+ [key: string]: unknown;
6
+ }) => TTarget;
7
+ type Formatters = {
8
+ block?: Formatter<RpcBlock, Block>;
9
+ transaction?: Formatter<RpcTransaction, Transaction>;
10
+ transactionReceipt?: Formatter<RpcTransactionReceipt, TransactionReceipt>;
11
+ transactionRequest?: Formatter<TransactionRequest, RpcTransactionRequest>;
12
+ };
13
+ type Chain<TFormatters extends Formatters = Formatters> = Chain$1 & {
14
+ formatters?: TFormatters;
15
+ };
16
+ declare function defineChain<TFormatters extends Formatters = Formatters, TChain extends Chain<TFormatters> = Chain<TFormatters>>(chain: TChain): TChain;
17
+ declare const defineBlock: <TFormat extends Formatter<Partial<RpcBlock>, Partial<Block<bigint, Transaction<bigint, number>>> & {
18
+ [key: string]: unknown;
19
+ }>, TExclude extends (keyof RpcBlock)[] = []>({ exclude, format: formatOverride, }: {
20
+ exclude?: TExclude | undefined;
21
+ format?: TFormat | undefined;
22
+ }) => (data: Partial<RpcBlock> & {
23
+ [key: string]: unknown;
24
+ }) => Block<bigint, Transaction<bigint, number>> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
25
+ declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
26
+ [key: string]: unknown;
27
+ }>, TExclude extends ("type" | "blockHash" | "blockNumber" | "from" | "gas" | "hash" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "value" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
28
+ exclude?: TExclude | undefined;
29
+ format?: TFormat | undefined;
30
+ }) => (data: Partial<RpcTransaction> & {
31
+ [key: string]: unknown;
32
+ }) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
33
+ declare const defineTransactionRequest: <TFormat extends Formatter<Partial<TransactionRequest<bigint, number>>, Partial<RpcTransactionRequest> & {
34
+ [key: string]: unknown;
35
+ }>, TExclude extends ("data" | "from" | "gas" | "nonce" | "to" | "value" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
36
+ exclude?: TExclude | undefined;
37
+ format?: TFormat | undefined;
38
+ }) => (data: Partial<TransactionRequest<bigint, number>> & {
39
+ [key: string]: unknown;
40
+ }) => RpcTransactionRequest & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
41
+ declare const defineTransactionReceipt: <TFormat extends Formatter<Partial<RpcTransactionReceipt>, Partial<TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>> & {
42
+ [key: string]: unknown;
43
+ }>, TExclude extends (keyof RpcTransactionReceipt)[] = []>({ exclude, format: formatOverride, }: {
44
+ exclude?: TExclude | undefined;
45
+ format?: TFormat | undefined;
46
+ }) => (data: Partial<RpcTransactionReceipt> & {
47
+ [key: string]: unknown;
48
+ }) => TransactionReceipt<bigint, number, "success" | "reverted", TransactionType> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
49
+ declare const arbitrumGoerli: Chain$1;
50
+ declare const arbitrum: Chain$1;
51
+ declare const avalancheFuji: Chain$1;
52
+ declare const avalanche: Chain$1;
53
+ declare const bscTestnet: Chain$1;
54
+ declare const bsc: Chain$1;
55
+ declare const celo: {
56
+ id: number;
57
+ name: string;
58
+ network: string;
59
+ nativeCurrency: {
60
+ name: string;
61
+ symbol: string;
62
+ decimals: number;
63
+ };
64
+ rpcUrls: {
65
+ default: {
66
+ http: string[];
67
+ };
68
+ };
69
+ formatters: {
70
+ block: (data: Partial<RpcBlock> & {
71
+ [key: string]: unknown;
72
+ }) => Block<bigint, Transaction<bigint, number>> & {
73
+ randomness: {
74
+ committed: Hex;
75
+ revealed: Hex;
76
+ };
77
+ } & {
78
+ nonce: never;
79
+ difficulty: never;
80
+ gasLimit: never;
81
+ mixHash: never;
82
+ uncles: never;
83
+ };
84
+ transaction: (data: Partial<RpcTransaction> & {
85
+ [key: string]: unknown;
86
+ }) => Transaction<bigint, number> & {
87
+ feeCurrency: `0x${string}` | null;
88
+ gatewayFee: bigint | null;
89
+ gatewayFeeRecipient: `0x${string}` | null;
90
+ } & {};
91
+ transactionRequest: (data: Partial<TransactionRequest<bigint, number>> & {
92
+ [key: string]: unknown;
93
+ }) => RpcTransactionRequest & {
94
+ feeCurrency: `0x${string}` | undefined;
95
+ gatewayFee: `0x${string}` | undefined;
96
+ gatewayFeeRecipient: `0x${string}` | undefined;
97
+ } & {};
98
+ };
99
+ };
100
+ declare const fantomTestnet: Chain$1;
101
+ declare const fantom: Chain$1;
102
+ declare const foundry: Chain$1;
103
+ declare const goerli: Chain$1;
104
+ declare const hardhat: Chain$1;
105
+ declare const localhost: Chain$1;
106
+ declare const mainnet: Chain$1;
107
+ declare const optimismGoerli: Chain$1;
108
+ declare const optimism: Chain$1;
109
+ declare const polygonMumbai: Chain$1;
110
+ declare const polygon: Chain$1;
111
+ declare const sepolia: Chain$1;
112
+
113
+ export { Chain, Formatter, Formatters, arbitrum, arbitrumGoerli, avalanche, avalancheFuji, bsc, bscTestnet, celo, defineBlock, defineChain, defineTransaction, defineTransactionReceipt, defineTransactionRequest, fantom, fantomTestnet, foundry, goerli, hardhat, localhost, mainnet, optimism, optimismGoerli, polygon, polygonMumbai, sepolia };
package/dist/chains.js ADDED
@@ -0,0 +1,133 @@
1
+ import {
2
+ formatBlock,
3
+ formatTransaction,
4
+ formatTransactionReceipt,
5
+ formatTransactionRequest
6
+ } from "./chunk-GI67STNV.js";
7
+
8
+ // src/chains.ts
9
+ import {
10
+ arbitrumGoerli as arbitrumGoerli_,
11
+ arbitrum as arbitrum_,
12
+ avalancheFuji as avalancheFuji_,
13
+ avalanche as avalanche_,
14
+ bscTestnet as bscTestnet_,
15
+ bsc as bsc_,
16
+ fantomTestnet as fantomTestnet_,
17
+ fantom as fantom_,
18
+ foundry as foundry_,
19
+ goerli as goerli_,
20
+ hardhat as hardhat_,
21
+ localhost as localhost_,
22
+ mainnet as mainnet_,
23
+ optimismGoerli as optimismGoerli_,
24
+ optimism as optimism_,
25
+ polygonMumbai as polygonMumbai_,
26
+ polygon as polygon_,
27
+ sepolia as sepolia_
28
+ } from "@wagmi/chains";
29
+ function defineChain(chain) {
30
+ return chain;
31
+ }
32
+ function defineFormatter({
33
+ format
34
+ }) {
35
+ return ({
36
+ exclude,
37
+ format: formatOverride
38
+ }) => (data) => {
39
+ const formatted = format(data);
40
+ if (exclude) {
41
+ for (const key of exclude) {
42
+ delete formatted[key];
43
+ }
44
+ }
45
+ return {
46
+ ...formatted,
47
+ ...formatOverride?.(data)
48
+ };
49
+ };
50
+ }
51
+ var defineBlock = defineFormatter({ format: formatBlock });
52
+ var defineTransaction = defineFormatter({ format: formatTransaction });
53
+ var defineTransactionRequest = defineFormatter({
54
+ format: formatTransactionRequest
55
+ });
56
+ var defineTransactionReceipt = defineFormatter({
57
+ format: formatTransactionReceipt
58
+ });
59
+ var arbitrumGoerli = defineChain(arbitrumGoerli_);
60
+ var arbitrum = defineChain(arbitrum_);
61
+ var avalancheFuji = defineChain(avalancheFuji_);
62
+ var avalanche = defineChain(avalanche_);
63
+ var bscTestnet = defineChain(bscTestnet_);
64
+ var bsc = defineChain(bsc_);
65
+ var celo = defineChain({
66
+ id: 42220,
67
+ name: "Celo",
68
+ network: "celo",
69
+ nativeCurrency: { name: "Celo", symbol: "CELO", decimals: 18 },
70
+ rpcUrls: {
71
+ default: { http: ["https://rpc.ankr.com/celo"] }
72
+ },
73
+ formatters: {
74
+ block: defineBlock({
75
+ exclude: ["difficulty", "gasLimit", "mixHash", "nonce", "uncles"],
76
+ format: (block) => ({
77
+ randomness: block.randomness
78
+ })
79
+ }),
80
+ transaction: defineTransaction({
81
+ format: (transaction) => ({
82
+ feeCurrency: transaction.feeCurrency,
83
+ gatewayFee: transaction.gatewayFee ? BigInt(transaction.gatewayFee) : null,
84
+ gatewayFeeRecipient: transaction.gatewayFeeRecipient
85
+ })
86
+ }),
87
+ transactionRequest: defineTransactionRequest({
88
+ format: (transactionRequest) => ({
89
+ feeCurrency: transactionRequest.feeCurrency,
90
+ gatewayFee: transactionRequest.gatewayFee,
91
+ gatewayFeeRecipient: transactionRequest.gatewayFeeRecipient
92
+ })
93
+ })
94
+ }
95
+ });
96
+ var fantomTestnet = defineChain(fantomTestnet_);
97
+ var fantom = defineChain(fantom_);
98
+ var foundry = defineChain(foundry_);
99
+ var goerli = defineChain(goerli_);
100
+ var hardhat = defineChain(hardhat_);
101
+ var localhost = defineChain(localhost_);
102
+ var mainnet = defineChain(mainnet_);
103
+ var optimismGoerli = defineChain(optimismGoerli_);
104
+ var optimism = defineChain(optimism_);
105
+ var polygonMumbai = defineChain(polygonMumbai_);
106
+ var polygon = defineChain(polygon_);
107
+ var sepolia = defineChain(sepolia_);
108
+ export {
109
+ arbitrum,
110
+ arbitrumGoerli,
111
+ avalanche,
112
+ avalancheFuji,
113
+ bsc,
114
+ bscTestnet,
115
+ celo,
116
+ defineBlock,
117
+ defineChain,
118
+ defineTransaction,
119
+ defineTransactionReceipt,
120
+ defineTransactionRequest,
121
+ fantom,
122
+ fantomTestnet,
123
+ foundry,
124
+ goerli,
125
+ hardhat,
126
+ localhost,
127
+ mainnet,
128
+ optimism,
129
+ optimismGoerli,
130
+ polygon,
131
+ polygonMumbai,
132
+ sepolia
133
+ };