viem 0.0.1-alpha.26 → 0.0.1-alpha.27
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/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-YTG4YXMB.js → chunk-2DSFM32P.js} +15 -15
- package/dist/{chunk-YTG4YXMB.js.map → chunk-2DSFM32P.js.map} +1 -1
- package/dist/{chunk-PRG3BBPZ.mjs → chunk-AKGXRZDN.mjs} +214 -55
- package/dist/chunk-AKGXRZDN.mjs.map +1 -0
- package/dist/{chunk-QSIX64VZ.mjs → chunk-BJJH7RYH.mjs} +2 -2
- package/dist/{chunk-QSIX64VZ.mjs.map → chunk-BJJH7RYH.mjs.map} +0 -0
- package/dist/{chunk-LINNE4N4.js → chunk-JY7JGKSA.js} +70 -70
- package/dist/{chunk-LINNE4N4.js.map → chunk-JY7JGKSA.js.map} +0 -0
- package/dist/{chunk-BSAB6UH4.mjs → chunk-LF6P33WQ.mjs} +6 -6
- package/dist/chunk-LF6P33WQ.mjs.map +1 -0
- package/dist/{chunk-DSQO3E4F.js → chunk-W7KWIGWO.js} +210 -51
- package/dist/chunk-W7KWIGWO.js.map +1 -0
- package/dist/contract.js +4 -4
- package/dist/contract.mjs +3 -3
- package/dist/ens.js +21 -21
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +9 -9
- package/dist/ens.mjs.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.mjs +1 -1
- package/dist/public.js +3 -3
- package/dist/public.mjs +2 -2
- package/dist/test.js +13 -13
- package/dist/test.mjs +1 -1
- package/dist/utils/index.d.ts +11 -11
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +13 -13
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/package.json +1 -2
- package/dist/chunk-BSAB6UH4.mjs.map +0 -1
- package/dist/chunk-DSQO3E4F.js.map +0 -1
- package/dist/chunk-PRG3BBPZ.mjs.map +0 -1
package/dist/utils/index.d.ts
CHANGED
@@ -135,7 +135,7 @@ declare function bytesToHex(value: ByteArray): Hex;
|
|
135
135
|
/**
|
136
136
|
* @description Encodes a string, number, bigint, or ByteArray into a hex string
|
137
137
|
*/
|
138
|
-
declare function
|
138
|
+
declare function toHex(value: string | number | bigint | boolean | ByteArray): Hex;
|
139
139
|
type NumberToHexOpts$1 = {
|
140
140
|
signed?: boolean;
|
141
141
|
size: number;
|
@@ -157,7 +157,7 @@ declare function stringToHex(value: string): Hex;
|
|
157
157
|
*/
|
158
158
|
declare function boolToBytes(value: boolean): Uint8Array;
|
159
159
|
/** @description Encodes a UTF-8 string, hex value, bigint, number or boolean to a byte array. */
|
160
|
-
declare function
|
160
|
+
declare function toBytes(value: string | bigint | number | boolean | Hex): ByteArray;
|
161
161
|
/**
|
162
162
|
* @description Encodes a hex string into a byte array.
|
163
163
|
*/
|
@@ -173,14 +173,14 @@ declare function stringToBytes(value: string): ByteArray;
|
|
173
173
|
|
174
174
|
type RecursiveArray<T> = T | Array<RecursiveArray<T>>;
|
175
175
|
type To$1 = 'hex' | 'bytes';
|
176
|
-
type
|
177
|
-
declare function
|
176
|
+
type toRlpResponse<TTo extends To$1> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
|
177
|
+
declare function toRlp<TTo extends To$1 = 'hex'>(hexOrBytes: RecursiveArray<Hex> | RecursiveArray<ByteArray>, to_?: TTo): toRlpResponse<TTo>;
|
178
178
|
|
179
|
-
type
|
179
|
+
type fromBytesResponse<TTo> = TTo extends 'string' ? string : TTo extends 'hex' ? Hex : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'boolean' ? boolean : never;
|
180
180
|
/**
|
181
181
|
* @description Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
|
182
182
|
*/
|
183
|
-
declare function
|
183
|
+
declare function fromBytes<TTo extends 'string' | 'hex' | 'bigint' | 'number' | 'boolean'>(bytes: ByteArray, to: TTo): fromBytesResponse<TTo>;
|
184
184
|
/**
|
185
185
|
* @description Decodes a byte array into a bigint.
|
186
186
|
*/
|
@@ -199,11 +199,11 @@ declare function bytesToNumber(bytes: ByteArray): number;
|
|
199
199
|
*/
|
200
200
|
declare function bytesToString(bytes: ByteArray): string;
|
201
201
|
|
202
|
-
type
|
202
|
+
type fromHexResponse<TTo> = TTo extends 'string' ? string : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'bytes' ? ByteArray : TTo extends 'boolean' ? boolean : never;
|
203
203
|
/**
|
204
204
|
* @description Decodes a hex string into a string, number, bigint, boolean, or bytes32 array.
|
205
205
|
*/
|
206
|
-
declare function
|
206
|
+
declare function fromHex<TTo extends 'string' | 'bigint' | 'number' | 'bytes' | 'boolean'>(hex: Hex, to: TTo): fromHexResponse<TTo>;
|
207
207
|
type HexToBigIntOpts = {
|
208
208
|
signed?: boolean;
|
209
209
|
};
|
@@ -225,8 +225,8 @@ declare function hexToNumber(hex: Hex, opts?: NumberToHexOpts): number;
|
|
225
225
|
*/
|
226
226
|
declare function hexToString(hex: Hex): string;
|
227
227
|
|
228
|
-
type
|
229
|
-
declare function
|
228
|
+
type fromRlpResponse<TTo> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
|
229
|
+
declare function fromRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex, to: TTo): RecursiveArray<fromRlpResponse<TTo>>;
|
230
230
|
|
231
231
|
declare const getEventSignature: (event: EventDefinition) => `0x${string}`;
|
232
232
|
|
@@ -263,4 +263,4 @@ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
|
|
263
263
|
|
264
264
|
declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
|
265
265
|
|
266
|
-
export {
|
266
|
+
export { GetContractAddressOptions, GetCreate2AddressOptions, GetCreateAddressOptions, boolToBytes, boolToHex, buildRequest, bytesToBigint, bytesToBool, bytesToHex, bytesToNumber, bytesToString, etherUnits, extract, extractFunctionName, extractFunctionParams, extractFunctionParts, extractFunctionType, formatEther, formatGwei, formatUnit, fromBytes, fromHex, fromRlp, getAddress, getContractAddress, getContractError, getCreate2Address, getCreateAddress, getEventSignature, getFunctionSignature, gweiUnits, hexToBigInt, hexToBool, hexToBytes, hexToNumber, hexToString, isAddress, isAddressEqual, isBytes, isHex, keccak256, numberToBytes, numberToHex, pad, padBytes, padHex, parseEther, parseGwei, parseUnit, size, slice, sliceBytes, sliceHex, stringToBytes, stringToHex, stringify, toBytes, toHex, toRlp, toRlpResponse, trim, weiUnits };
|
package/dist/utils/index.js
CHANGED
@@ -83,7 +83,7 @@
|
|
83
83
|
|
84
84
|
|
85
85
|
|
86
|
-
var
|
86
|
+
var _chunkW7KWIGWOjs = require('../chunk-W7KWIGWO.js');
|
87
87
|
|
88
88
|
|
89
89
|
|
@@ -169,5 +169,5 @@ var _chunkDSQO3E4Fjs = require('../chunk-DSQO3E4F.js');
|
|
169
169
|
|
170
170
|
|
171
171
|
|
172
|
-
exports.boolToBytes =
|
172
|
+
exports.boolToBytes = _chunkW7KWIGWOjs.boolToBytes; exports.boolToHex = _chunkW7KWIGWOjs.boolToHex; exports.buildRequest = _chunkW7KWIGWOjs.buildRequest; exports.bytesToBigint = _chunkW7KWIGWOjs.bytesToBigint; exports.bytesToBool = _chunkW7KWIGWOjs.bytesToBool; exports.bytesToHex = _chunkW7KWIGWOjs.bytesToHex; exports.bytesToNumber = _chunkW7KWIGWOjs.bytesToNumber; exports.bytesToString = _chunkW7KWIGWOjs.bytesToString; exports.decodeAbi = _chunkW7KWIGWOjs.decodeAbi; exports.decodeErrorResult = _chunkW7KWIGWOjs.decodeErrorResult; exports.decodeEventLog = _chunkW7KWIGWOjs.decodeEventLog; exports.decodeFunctionData = _chunkW7KWIGWOjs.decodeFunctionData; exports.decodeFunctionResult = _chunkW7KWIGWOjs.decodeFunctionResult; exports.defineBlock = _chunkW7KWIGWOjs.defineBlock; exports.defineChain = _chunkW7KWIGWOjs.defineChain; exports.defineFormatter = _chunkW7KWIGWOjs.defineFormatter; exports.defineTransaction = _chunkW7KWIGWOjs.defineTransaction; exports.defineTransactionReceipt = _chunkW7KWIGWOjs.defineTransactionReceipt; exports.defineTransactionRequest = _chunkW7KWIGWOjs.defineTransactionRequest; exports.encodeAbi = _chunkW7KWIGWOjs.encodeAbi; exports.encodeDeployData = _chunkW7KWIGWOjs.encodeDeployData; exports.encodeErrorResult = _chunkW7KWIGWOjs.encodeErrorResult; exports.encodeEventTopics = _chunkW7KWIGWOjs.encodeEventTopics; exports.encodeFunctionData = _chunkW7KWIGWOjs.encodeFunctionData; exports.encodeFunctionResult = _chunkW7KWIGWOjs.encodeFunctionResult; exports.etherUnits = _chunkW7KWIGWOjs.etherUnits; exports.extract = _chunkW7KWIGWOjs.extract; exports.extractFunctionName = _chunkW7KWIGWOjs.extractFunctionName; exports.extractFunctionParams = _chunkW7KWIGWOjs.extractFunctionParams; exports.extractFunctionParts = _chunkW7KWIGWOjs.extractFunctionParts; exports.extractFunctionType = _chunkW7KWIGWOjs.extractFunctionType; exports.format = _chunkW7KWIGWOjs.format; exports.formatAbiItem = _chunkW7KWIGWOjs.formatAbiItem; exports.formatAbiItemWithArgs = _chunkW7KWIGWOjs.formatAbiItemWithArgs; exports.formatBlock = _chunkW7KWIGWOjs.formatBlock; exports.formatEther = _chunkW7KWIGWOjs.formatEther; exports.formatGwei = _chunkW7KWIGWOjs.formatGwei; exports.formatTransaction = _chunkW7KWIGWOjs.formatTransaction; exports.formatTransactionRequest = _chunkW7KWIGWOjs.formatTransactionRequest; exports.formatUnit = _chunkW7KWIGWOjs.formatUnit; exports.fromBytes = _chunkW7KWIGWOjs.fromBytes; exports.fromHex = _chunkW7KWIGWOjs.fromHex; exports.fromRlp = _chunkW7KWIGWOjs.fromRlp; exports.getAbiItem = _chunkW7KWIGWOjs.getAbiItem; exports.getAddress = _chunkW7KWIGWOjs.getAddress; exports.getContractAddress = _chunkW7KWIGWOjs.getContractAddress; exports.getContractError = _chunkW7KWIGWOjs.getContractError; exports.getCreate2Address = _chunkW7KWIGWOjs.getCreate2Address; exports.getCreateAddress = _chunkW7KWIGWOjs.getCreateAddress; exports.getEventSignature = _chunkW7KWIGWOjs.getEventSignature; exports.getFunctionSignature = _chunkW7KWIGWOjs.getFunctionSignature; exports.gweiUnits = _chunkW7KWIGWOjs.gweiUnits; exports.hexToBigInt = _chunkW7KWIGWOjs.hexToBigInt; exports.hexToBool = _chunkW7KWIGWOjs.hexToBool; exports.hexToBytes = _chunkW7KWIGWOjs.hexToBytes; exports.hexToNumber = _chunkW7KWIGWOjs.hexToNumber; exports.hexToString = _chunkW7KWIGWOjs.hexToString; exports.isAddress = _chunkW7KWIGWOjs.isAddress; exports.isAddressEqual = _chunkW7KWIGWOjs.isAddressEqual; exports.isBytes = _chunkW7KWIGWOjs.isBytes; exports.isHex = _chunkW7KWIGWOjs.isHex; exports.keccak256 = _chunkW7KWIGWOjs.keccak256; exports.numberToBytes = _chunkW7KWIGWOjs.numberToBytes; exports.numberToHex = _chunkW7KWIGWOjs.numberToHex; exports.pad = _chunkW7KWIGWOjs.pad; exports.padBytes = _chunkW7KWIGWOjs.padBytes; exports.padHex = _chunkW7KWIGWOjs.padHex; exports.parseEther = _chunkW7KWIGWOjs.parseEther; exports.parseGwei = _chunkW7KWIGWOjs.parseGwei; exports.parseUnit = _chunkW7KWIGWOjs.parseUnit; exports.rpc = _chunkW7KWIGWOjs.rpc; exports.size = _chunkW7KWIGWOjs.size; exports.slice = _chunkW7KWIGWOjs.slice; exports.sliceBytes = _chunkW7KWIGWOjs.sliceBytes; exports.sliceHex = _chunkW7KWIGWOjs.sliceHex; exports.stringToBytes = _chunkW7KWIGWOjs.stringToBytes; exports.stringToHex = _chunkW7KWIGWOjs.stringToHex; exports.stringify = _chunkW7KWIGWOjs.stringify; exports.toBytes = _chunkW7KWIGWOjs.toBytes; exports.toHex = _chunkW7KWIGWOjs.toHex; exports.toRlp = _chunkW7KWIGWOjs.toRlp; exports.transactionType = _chunkW7KWIGWOjs.transactionType; exports.trim = _chunkW7KWIGWOjs.trim; exports.weiUnits = _chunkW7KWIGWOjs.weiUnits;
|
173
173
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.mjs
CHANGED
@@ -8,13 +8,10 @@ import {
|
|
8
8
|
bytesToNumber,
|
9
9
|
bytesToString,
|
10
10
|
decodeAbi,
|
11
|
-
decodeBytes,
|
12
11
|
decodeErrorResult,
|
13
12
|
decodeEventLog,
|
14
13
|
decodeFunctionData,
|
15
14
|
decodeFunctionResult,
|
16
|
-
decodeHex,
|
17
|
-
decodeRlp,
|
18
15
|
defineBlock,
|
19
16
|
defineChain,
|
20
17
|
defineFormatter,
|
@@ -22,14 +19,11 @@ import {
|
|
22
19
|
defineTransactionReceipt,
|
23
20
|
defineTransactionRequest,
|
24
21
|
encodeAbi,
|
25
|
-
encodeBytes,
|
26
22
|
encodeDeployData,
|
27
23
|
encodeErrorResult,
|
28
24
|
encodeEventTopics,
|
29
25
|
encodeFunctionData,
|
30
26
|
encodeFunctionResult,
|
31
|
-
encodeHex,
|
32
|
-
encodeRlp,
|
33
27
|
etherUnits,
|
34
28
|
extract,
|
35
29
|
extractFunctionName,
|
@@ -45,6 +39,9 @@ import {
|
|
45
39
|
formatTransaction,
|
46
40
|
formatTransactionRequest,
|
47
41
|
formatUnit,
|
42
|
+
fromBytes,
|
43
|
+
fromHex,
|
44
|
+
fromRlp,
|
48
45
|
getAbiItem,
|
49
46
|
getAddress,
|
50
47
|
getContractAddress,
|
@@ -80,10 +77,13 @@ import {
|
|
80
77
|
stringToBytes,
|
81
78
|
stringToHex,
|
82
79
|
stringify,
|
80
|
+
toBytes,
|
81
|
+
toHex,
|
82
|
+
toRlp,
|
83
83
|
transactionType,
|
84
84
|
trim,
|
85
85
|
weiUnits
|
86
|
-
} from "../chunk-
|
86
|
+
} from "../chunk-AKGXRZDN.mjs";
|
87
87
|
export {
|
88
88
|
boolToBytes,
|
89
89
|
boolToHex,
|
@@ -94,13 +94,10 @@ export {
|
|
94
94
|
bytesToNumber,
|
95
95
|
bytesToString,
|
96
96
|
decodeAbi,
|
97
|
-
decodeBytes,
|
98
97
|
decodeErrorResult,
|
99
98
|
decodeEventLog,
|
100
99
|
decodeFunctionData,
|
101
100
|
decodeFunctionResult,
|
102
|
-
decodeHex,
|
103
|
-
decodeRlp,
|
104
101
|
defineBlock,
|
105
102
|
defineChain,
|
106
103
|
defineFormatter,
|
@@ -108,14 +105,11 @@ export {
|
|
108
105
|
defineTransactionReceipt,
|
109
106
|
defineTransactionRequest,
|
110
107
|
encodeAbi,
|
111
|
-
encodeBytes,
|
112
108
|
encodeDeployData,
|
113
109
|
encodeErrorResult,
|
114
110
|
encodeEventTopics,
|
115
111
|
encodeFunctionData,
|
116
112
|
encodeFunctionResult,
|
117
|
-
encodeHex,
|
118
|
-
encodeRlp,
|
119
113
|
etherUnits,
|
120
114
|
extract,
|
121
115
|
extractFunctionName,
|
@@ -131,6 +125,9 @@ export {
|
|
131
125
|
formatTransaction,
|
132
126
|
formatTransactionRequest,
|
133
127
|
formatUnit,
|
128
|
+
fromBytes,
|
129
|
+
fromHex,
|
130
|
+
fromRlp,
|
134
131
|
getAbiItem,
|
135
132
|
getAddress,
|
136
133
|
getContractAddress,
|
@@ -166,6 +163,9 @@ export {
|
|
166
163
|
stringToBytes,
|
167
164
|
stringToHex,
|
168
165
|
stringify,
|
166
|
+
toBytes,
|
167
|
+
toHex,
|
168
|
+
toRlp,
|
169
169
|
transactionType,
|
170
170
|
trim,
|
171
171
|
weiUnits
|
package/dist/wallet.js
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
var
|
12
|
-
require('./chunk-
|
11
|
+
var _chunk2DSFM32Pjs = require('./chunk-2DSFM32P.js');
|
12
|
+
require('./chunk-W7KWIGWO.js');
|
13
13
|
|
14
14
|
|
15
15
|
|
@@ -20,5 +20,5 @@ require('./chunk-DSQO3E4F.js');
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
exports.addChain =
|
23
|
+
exports.addChain = _chunk2DSFM32Pjs.addChain; exports.getAccounts = _chunk2DSFM32Pjs.getAccounts; exports.getPermissions = _chunk2DSFM32Pjs.getPermissions; exports.requestAccounts = _chunk2DSFM32Pjs.requestAccounts; exports.requestPermissions = _chunk2DSFM32Pjs.requestPermissions; exports.sendTransaction = _chunk2DSFM32Pjs.sendTransaction; exports.signMessage = _chunk2DSFM32Pjs.signMessage; exports.switchChain = _chunk2DSFM32Pjs.switchChain; exports.watchAsset = _chunk2DSFM32Pjs.watchAsset;
|
24
24
|
//# sourceMappingURL=wallet.js.map
|
package/dist/wallet.mjs
CHANGED
package/package.json
CHANGED
@@ -6,11 +6,10 @@
|
|
6
6
|
"@wagmi/chains": "~0.2.8",
|
7
7
|
"abitype": "~0.3.0",
|
8
8
|
"idna-uts46-hx": "^4.1.2",
|
9
|
-
"isomorphic-unfetch": "^4.0.2",
|
10
9
|
"isomorphic-ws": "^5.0.0",
|
11
10
|
"ws": "^8.12.0"
|
12
11
|
},
|
13
|
-
"version": "0.0.1-alpha.
|
12
|
+
"version": "0.0.1-alpha.27",
|
14
13
|
"files": [
|
15
14
|
"/dist",
|
16
15
|
"/chains",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/actions/wallet/addChain.ts","../src/actions/wallet/getAccounts.ts","../src/actions/wallet/getPermissions.ts","../src/actions/wallet/requestAccounts.ts","../src/actions/wallet/requestPermissions.ts","../src/actions/wallet/sendTransaction.ts","../src/actions/wallet/signMessage.ts","../src/actions/wallet/switchChain.ts","../src/actions/wallet/watchAsset.ts","../src/actions/wallet/writeContract.ts","../src/actions/wallet/deployContract.ts"],"sourcesContent":["import type { WalletClient } from '../../clients'\nimport type { Chain } from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport async function addChain(client: WalletClient, chain: Chain) {\n const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain\n await client.request({\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: numberToHex(id),\n chainName: name,\n nativeCurrency,\n rpcUrls: rpcUrls.default.http,\n blockExplorerUrls: blockExplorers\n ? Object.values(blockExplorers).map(({ url }) => url)\n : undefined,\n },\n ],\n })\n}\n","import type { WalletClient } from '../../clients'\nimport { checksumAddress } from '../../utils/address'\n\nexport async function getAccounts(client: WalletClient) {\n const addresses = await client.request({ method: 'eth_accounts' })\n return addresses.map((address) => checksumAddress(address))\n}\n","import type { WalletClient } from '../../clients'\nimport type { WalletPermission } from '../../types/eip1193'\n\nexport type GetPermissionsResponse = WalletPermission[]\n\nexport async function getPermissions(client: WalletClient) {\n const permissions = await client.request({ method: 'wallet_getPermissions' })\n return permissions\n}\n","import type { WalletClient } from '../../clients'\nimport { getAddress } from '../../utils'\n\nexport async function requestAccounts(client: WalletClient) {\n const addresses = await client.request({ method: 'eth_requestAccounts' })\n return addresses.map((address) => getAddress(address))\n}\n","import type { WalletClient } from '../../clients'\nimport type { WalletPermission } from '../../types/eip1193'\n\nexport type RequestPermissionsArgs = {\n eth_accounts: Record<string, any>\n} & {\n [key: string]: Record<string, any>\n}\nexport type RequestPermissionsResponse = WalletPermission[]\n\nexport async function requestPermissions(\n client: WalletClient,\n permissions: RequestPermissionsArgs,\n) {\n return client.request({\n method: 'wallet_requestPermissions',\n params: [permissions],\n })\n}\n","import type { WalletClient } from '../../clients'\nimport { InvalidGasArgumentsError } from '../../errors'\nimport type {\n Chain,\n Formatter,\n Hash,\n MergeIntersectionProperties,\n TransactionRequest,\n} from '../../types'\nimport type { Formatted, TransactionRequestFormatter } from '../../utils'\nimport { extract, format, formatTransactionRequest } from '../../utils'\n\nexport type FormattedTransactionRequest<\n TFormatter extends Formatter | undefined = Formatter,\n> = MergeIntersectionProperties<\n Formatted<TFormatter, TransactionRequest, true>,\n TransactionRequest\n>\n\nexport type SendTransactionArgs<TChain extends Chain = Chain> =\n FormattedTransactionRequest<TransactionRequestFormatter<TChain>> & {\n chain?: TChain\n }\n\nexport type SendTransactionResponse = Hash\n\nexport async function sendTransaction<TChain extends Chain>(\n client: WalletClient,\n {\n chain,\n from,\n accessList,\n data,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n ...rest\n }: SendTransactionArgs<TChain>,\n): Promise<SendTransactionResponse> {\n if (\n maxFeePerGas !== undefined &&\n maxPriorityFeePerGas !== undefined &&\n maxFeePerGas < maxPriorityFeePerGas\n )\n throw new InvalidGasArgumentsError()\n\n const formatter = chain?.formatters?.transactionRequest\n const request_ = format(\n {\n from,\n accessList,\n data,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n // Pick out extra data that might exist on the chain's transaction request type.\n ...extract(rest, { formatter }),\n } as TransactionRequest,\n {\n formatter: formatter || formatTransactionRequest,\n },\n )\n\n const hash = await client.request({\n method: 'eth_sendTransaction',\n params: [request_],\n })\n return hash\n}\n","import type { WalletClient } from '../../clients'\nimport { BaseError } from '../../errors'\nimport type { Address, ByteArray, Hex } from '../../types'\nimport { encodeHex } from '../../utils'\n\nexport type SignMessageArgs = {\n from: Address\n data: Hex | ByteArray\n}\n\nexport type SignMessageResponse = Hex\n\nexport async function signMessage(\n client: WalletClient,\n { from, data: data_ }: SignMessageArgs,\n): Promise<SignMessageResponse> {\n let data\n if (typeof data_ === 'string') {\n if (!data_.startsWith('0x'))\n throw new BaseError(\n `data (\"${data_}\") must be a hex value. Encode it first to a hex with the \\`encodeHex\\` util.`,\n {\n docsPath: '/TODO',\n },\n )\n data = data_\n } else {\n data = encodeHex(data_)\n }\n const signed = await client.request({\n method: 'personal_sign',\n params: [data, from],\n })\n return signed\n}\n","import type { WalletClient } from '../../clients'\nimport { Chain } from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport type SwitchChainArgs = { id: Chain['id'] }\n\nexport async function switchChain(\n client: WalletClient,\n { id }: SwitchChainArgs,\n) {\n await client.request({\n method: 'wallet_switchEthereumChain',\n params: [\n {\n chainId: numberToHex(id),\n },\n ],\n })\n}\n","import type { WalletClient } from '../../clients'\nimport type { WatchAssetParams } from '../../types/eip1193'\n\nexport type WatchAssetArgs = WatchAssetParams\nexport type WatchAssetResponse = boolean\n\nexport async function watchAsset(\n client: WalletClient,\n params: WatchAssetParams,\n): Promise<WatchAssetResponse> {\n const added = await client.request({\n method: 'wallet_watchAsset',\n params: [params],\n })\n return added\n}\n","import { Abi } from 'abitype'\n\nimport type { WalletClient } from '../../clients'\nimport type { Chain, ContractConfig, GetValue } from '../../types'\nimport { EncodeFunctionDataArgs, encodeFunctionData } from '../../utils'\nimport {\n sendTransaction,\n SendTransactionArgs,\n SendTransactionResponse,\n} from './sendTransaction'\n\nexport type WriteContractArgs<\n TChain extends Chain = Chain,\n TAbi extends Abi | readonly unknown[] = Abi,\n TFunctionName extends string = string,\n> = Omit<SendTransactionArgs<TChain>, 'to' | 'data' | 'value'> & {\n value?: GetValue<TAbi, TFunctionName, SendTransactionArgs<TChain>['value']>\n} & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>\n\nexport type WriteContractResponse = SendTransactionResponse\n\nexport async function writeContract<\n TChain extends Chain,\n TAbi extends Abi | readonly unknown[],\n TFunctionName extends string,\n>(\n client: WalletClient,\n {\n abi,\n address,\n args,\n functionName,\n ...request\n }: WriteContractArgs<TChain, TAbi, TFunctionName>,\n): Promise<WriteContractResponse> {\n const data = encodeFunctionData({\n abi,\n args,\n functionName,\n } as unknown as EncodeFunctionDataArgs<TAbi, TFunctionName>)\n const hash = await sendTransaction(client, {\n data,\n to: address,\n ...request,\n } as unknown as SendTransactionArgs<TChain>)\n return hash\n}\n","import { Abi, Narrow } from 'abitype'\nimport { WalletClient } from '../../clients'\n\nimport { Chain, ExtractConstructorArgsFromAbi, Hex } from '../../types'\nimport { encodeDeployData } from '../../utils'\nimport {\n sendTransaction,\n SendTransactionArgs,\n SendTransactionResponse,\n} from '../wallet'\n\nexport type DeployContractArgs<\n TChain extends Chain = Chain,\n TAbi extends Abi | readonly unknown[] = Abi,\n> = Omit<\n SendTransactionArgs<TChain>,\n 'accessList' | 'to' | 'data' | 'value'\n> & {\n abi: Narrow<TAbi>\n bytecode: Hex\n} & ExtractConstructorArgsFromAbi<TAbi>\n\nexport type DeployContractResponse = SendTransactionResponse\n\nexport function deployContract<TChain extends Chain, TAbi extends Abi>(\n walletClient: WalletClient,\n { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>,\n): Promise<DeployContractResponse> {\n const calldata = encodeDeployData({\n abi,\n args,\n bytecode,\n } as unknown as DeployContractArgs<TChain, TAbi>)\n return sendTransaction(walletClient, {\n ...request,\n data: calldata,\n } as unknown as SendTransactionArgs<TChain>)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA,eAAsB,SAAS,QAAsB,OAAc;AACjE,QAAM,EAAE,IAAI,MAAM,gBAAgB,SAAS,eAAe,IAAI;AAC9D,QAAM,OAAO,QAAQ;AAAA,IACnB,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN;AAAA,QACE,SAAS,YAAY,EAAE;AAAA,QACvB,WAAW;AAAA,QACX;AAAA,QACA,SAAS,QAAQ,QAAQ;AAAA,QACzB,mBAAmB,iBACf,OAAO,OAAO,cAAc,EAAE,IAAI,CAAC,EAAE,IAAI,MAAM,GAAG,IAClD;AAAA,MACN;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ACjBA,eAAsB,YAAY,QAAsB;AACtD,QAAM,YAAY,MAAM,OAAO,QAAQ,EAAE,QAAQ,eAAe,CAAC;AACjE,SAAO,UAAU,IAAI,CAAC,YAAY,gBAAgB,OAAO,CAAC;AAC5D;;;ACDA,eAAsB,eAAe,QAAsB;AACzD,QAAM,cAAc,MAAM,OAAO,QAAQ,EAAE,QAAQ,wBAAwB,CAAC;AAC5E,SAAO;AACT;;;ACLA,eAAsB,gBAAgB,QAAsB;AAC1D,QAAM,YAAY,MAAM,OAAO,QAAQ,EAAE,QAAQ,sBAAsB,CA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