viem 0.0.1-alpha.2 → 0.0.1-alpha.4
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/actions/index.d.ts +5 -6
- package/dist/actions/index.js +3 -2
- package/dist/chains.d.ts +2 -2
- package/dist/chains.js +2 -1
- package/dist/{chunk-4HNVS7AM.js → chunk-43X52QQL.js} +149 -200
- package/dist/chunk-COHLCIQM.js +1012 -0
- package/dist/{chunk-3EOU525X.js → chunk-ROF2KQ2X.js} +78 -893
- package/dist/{chunk-YQRTXQ2G.js → chunk-ZGVHEFCJ.js} +2 -15
- package/dist/clients/index.d.ts +5 -6
- package/dist/clients/index.js +2 -4
- package/dist/{createWalletClient-915223f3.d.ts → createWalletClient-15ad1601.d.ts} +1 -1
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-8b4d90ce.d.ts} +1 -1
- package/dist/index.d.ts +281 -9
- package/dist/index.js +77 -23
- package/dist/{parseGwei-fd7a0f7d.d.ts → parseGwei-a952d720.d.ts} +18 -112
- package/dist/{rpc-655c0ba4.d.ts → rpc-15b85963.d.ts} +1 -1
- package/dist/{rpc-3c0e3985.d.ts → rpc-26932bae.d.ts} +1 -38
- package/dist/{transactionRequest-ade896ac.d.ts → transactionRequest-f538ea86.d.ts} +1 -1
- package/dist/utils/index.d.ts +7 -6
- package/dist/utils/index.js +11 -39
- package/dist/{watchAsset-04ab8db5.d.ts → watchAsset-0c9d01e2.d.ts} +5 -16
- package/dist/{webSocket-c6e0d26f.d.ts → webSocket-b55b0951.d.ts} +4 -9
- package/dist/window.d.ts +2 -2
- package/package.json +1 -1
- package/dist/BaseError-7688f84e.d.ts +0 -18
package/dist/actions/index.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
export { C as CallArgs, a as CallResponse, b as CreateBlockFilterResponse, c as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, d as EstimateGasResponse,
|
1
|
+
export { C as CallArgs, a as CallResponse, b as CreateBlockFilterResponse, c as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, d as EstimateGasResponse, be 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 GetFilterLogsArgs, q as GetFilterLogsResponse, r as GetGasPriceResponse, s as GetPermissionsResponse, t as GetTransactionArgs, u as GetTransactionConfirmationsArgs, v as GetTransactionConfirmationsResponse, w as GetTransactionCountArgs, x as GetTransactionCountResponse, z as GetTransactionReceiptArgs, A as GetTransactionReceiptResponse, y as GetTransactionResponse, I as ImpersonateAccountArgs, B as IncreaseTimeArgs, M as MineArgs, O as OnBlock, F as OnBlockNumber, H as OnBlockNumberResponse, J as OnBlockResponse, K as OnTransactions, L as OnTransactionsResponse, bc as ReplacementReason, bd as ReplacementResponse, N as RequestPermissionsResponse, R as ResetArgs, P as RevertArgs, S as SendTransactionArgs, Q as SendTransactionResponse, T as SendUnsignedTransactionArgs, U as SendUnsignedTransactionResponse, V as SetBalanceArgs, W as SetBlockGasLimitArgs, $ as SetBlockTimestampIntervalArgs, X as SetCodeArgs, Y as SetCoinbaseArgs, Z as SetIntervalMiningArgs, _ as SetMinGasPriceArgs, a1 as SetNextBlockBaseFeePerGasArgs, a0 as SetNextBlockTimestampArgs, a2 as SetNonceArgs, a3 as SetStorageAtArgs, a4 as SignMessageArgs, a5 as SignMessageResponse, a6 as StopImpersonatingAccountArgs, a7 as SwitchChainArgs, a8 as UninstallFilterArgs, a9 as UninstallFilterResponse, aa as WaitForTransactionReceiptArgs, ab as WaitForTransactionReceiptResponse, ac as WatchAssetArgs, ad as WatchAssetResponse, ae as WatchBlockNumberArgs, af as WatchBlocksArgs, ag as WatchPendingTransactionsArgs, ah as addChain, ai as call, aj as createBlockFilter, ak as createPendingTransactionFilter, am as dropTransaction, al as estimateGas, an as getAccounts, ao as getAutomine, ap as getBalance, aq as getBlock, ar as getBlockNumber, bb as getBlockNumberCache, as as getBlockTransactionCount, at as getChainId, au as getFeeHistory, av as getFilterChanges, aw as getFilterLogs, ax as getGasPrice, ay as getPermissions, az as getTransaction, aA as getTransactionConfirmations, aB as getTransactionCount, aC as getTransactionReceipt, aD as getTxpoolContent, aE as getTxpoolStatus, aF as impersonateAccount, aG as increaseTime, aH as inspectTxpool, aI as mine, aJ as removeBlockTimestampInterval, aL as requestAccounts, aM as requestPermissions, aK as reset, aN as revert, aO as sendTransaction, aP as sendUnsignedTransaction, aQ as setAutomine, aR as setBalance, aS as setBlockGasLimit, aT as setBlockTimestampInterval, aU as setCode, aV as setCoinbase, aW as setIntervalMining, aX as setLoggingEnabled, aY as setMinGasPrice, aZ as setNextBlockBaseFeePerGas, a_ as setNextBlockTimestamp, a$ as setNonce, b0 as setStorageAt, b1 as signMessage, b2 as snapshot, b3 as stopImpersonatingAccount, b4 as switchChain, b5 as uninstallFilter, b6 as waitForTransactionReceipt, b7 as watchAsset, b8 as watchBlockNumber, b9 as watchBlocks, ba as watchPendingTransactions } from '../watchAsset-0c9d01e2.js';
|
2
2
|
import '../chains.js';
|
3
|
-
import '../rpc-
|
3
|
+
import '../rpc-15b85963.js';
|
4
4
|
import '@wagmi/chains';
|
5
|
-
import '../
|
6
|
-
import '../
|
7
|
-
import '../
|
8
|
-
import '../BaseError-7688f84e.js';
|
5
|
+
import '../createWalletClient-15ad1601.js';
|
6
|
+
import '../eip1193-8b4d90ce.js';
|
7
|
+
import '../transactionRequest-f538ea86.js';
|
package/dist/actions/index.js
CHANGED
@@ -58,8 +58,9 @@ import {
|
|
58
58
|
watchBlockNumber,
|
59
59
|
watchBlocks,
|
60
60
|
watchPendingTransactions
|
61
|
-
} from "../chunk-
|
62
|
-
import "../chunk-
|
61
|
+
} from "../chunk-43X52QQL.js";
|
62
|
+
import "../chunk-ROF2KQ2X.js";
|
63
|
+
import "../chunk-COHLCIQM.js";
|
63
64
|
export {
|
64
65
|
addChain,
|
65
66
|
call,
|
package/dist/chains.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { R as RpcBlock,
|
1
|
+
import { R as RpcBlock, d as Block, q as RpcTransaction, D as Transaction, r as RpcTransactionReceipt, T as TransactionReceipt, v as TransactionRequest, s as RpcTransactionRequest, N as TransactionType, a as Hex } from './rpc-15b85963.js';
|
2
2
|
import { Chain as Chain$1 } from '@wagmi/chains';
|
3
3
|
|
4
4
|
type Formatter<TSource = any, TTarget = any> = (value: TSource & {
|
@@ -24,7 +24,7 @@ declare const defineBlock: <TFormat extends Formatter<Partial<RpcBlock>, Partial
|
|
24
24
|
}) => Block<bigint, Transaction<bigint, number>> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
25
25
|
declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
|
26
26
|
[key: string]: unknown;
|
27
|
-
}>, TExclude extends ("gas" | "type" | "
|
27
|
+
}>, TExclude extends ("gas" | "type" | "blockHash" | "blockNumber" | "hash" | "value" | "from" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
|
28
28
|
exclude?: TExclude | undefined;
|
29
29
|
format?: TFormat | undefined;
|
30
30
|
}) => (data: Partial<RpcTransaction> & {
|
package/dist/chains.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
import {
|
2
|
-
BaseError,
|
3
|
-
__publicField,
|
4
2
|
checksumAddress,
|
5
3
|
encodeHex,
|
6
4
|
format,
|
@@ -11,146 +9,20 @@ import {
|
|
11
9
|
formatTransactionReceipt,
|
12
10
|
formatTransactionRequest,
|
13
11
|
getAddress,
|
14
|
-
getCache,
|
15
12
|
hexToNumber,
|
16
|
-
numberToHex
|
13
|
+
numberToHex
|
14
|
+
} from "./chunk-ROF2KQ2X.js";
|
15
|
+
import {
|
16
|
+
BaseError,
|
17
|
+
BlockNotFoundError,
|
18
|
+
InvalidGasArgumentsError,
|
19
|
+
TransactionNotFoundError,
|
20
|
+
TransactionReceiptNotFoundError,
|
21
|
+
WaitForTransactionReceiptTimeoutError,
|
22
|
+
getCache,
|
17
23
|
wait,
|
18
24
|
withCache
|
19
|
-
} from "./chunk-
|
20
|
-
|
21
|
-
// src/actions/wallet/addChain.ts
|
22
|
-
async function addChain(client, chain) {
|
23
|
-
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
24
|
-
await client.request({
|
25
|
-
method: "wallet_addEthereumChain",
|
26
|
-
params: [
|
27
|
-
{
|
28
|
-
chainId: numberToHex(id),
|
29
|
-
chainName: name,
|
30
|
-
nativeCurrency,
|
31
|
-
rpcUrls: rpcUrls.default.http,
|
32
|
-
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
33
|
-
}
|
34
|
-
]
|
35
|
-
});
|
36
|
-
}
|
37
|
-
|
38
|
-
// src/actions/wallet/getAccounts.ts
|
39
|
-
async function getAccounts(client) {
|
40
|
-
const addresses = await client.request({ method: "eth_accounts" });
|
41
|
-
return addresses.map((address) => checksumAddress(address));
|
42
|
-
}
|
43
|
-
|
44
|
-
// src/actions/wallet/getPermissions.ts
|
45
|
-
async function getPermissions(client) {
|
46
|
-
const permissions = await client.request({ method: "wallet_getPermissions" });
|
47
|
-
return permissions;
|
48
|
-
}
|
49
|
-
|
50
|
-
// src/actions/wallet/requestAccounts.ts
|
51
|
-
async function requestAccounts(client) {
|
52
|
-
const addresses = await client.request({ method: "eth_requestAccounts" });
|
53
|
-
return addresses.map((address) => getAddress(address));
|
54
|
-
}
|
55
|
-
|
56
|
-
// src/actions/wallet/requestPermissions.ts
|
57
|
-
async function requestPermissions(client, permissions) {
|
58
|
-
return client.request({
|
59
|
-
method: "wallet_requestPermissions",
|
60
|
-
params: [permissions]
|
61
|
-
});
|
62
|
-
}
|
63
|
-
|
64
|
-
// src/actions/wallet/sendTransaction.ts
|
65
|
-
async function sendTransaction(client, {
|
66
|
-
chain,
|
67
|
-
from,
|
68
|
-
accessList,
|
69
|
-
data,
|
70
|
-
gas,
|
71
|
-
gasPrice,
|
72
|
-
maxFeePerGas,
|
73
|
-
maxPriorityFeePerGas,
|
74
|
-
nonce,
|
75
|
-
to,
|
76
|
-
value,
|
77
|
-
...rest
|
78
|
-
}) {
|
79
|
-
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
80
|
-
throw new InvalidGasArgumentsError();
|
81
|
-
const request_ = format(
|
82
|
-
{
|
83
|
-
from,
|
84
|
-
accessList,
|
85
|
-
data,
|
86
|
-
gas,
|
87
|
-
gasPrice,
|
88
|
-
maxFeePerGas,
|
89
|
-
maxPriorityFeePerGas,
|
90
|
-
nonce,
|
91
|
-
to,
|
92
|
-
value,
|
93
|
-
...rest
|
94
|
-
},
|
95
|
-
{
|
96
|
-
formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
|
97
|
-
}
|
98
|
-
);
|
99
|
-
const hash = await client.request({
|
100
|
-
method: "eth_sendTransaction",
|
101
|
-
params: [request_]
|
102
|
-
});
|
103
|
-
return hash;
|
104
|
-
}
|
105
|
-
var InvalidGasArgumentsError = class extends BaseError {
|
106
|
-
constructor() {
|
107
|
-
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
108
|
-
__publicField(this, "name", "InvalidGasArgumentsError");
|
109
|
-
}
|
110
|
-
};
|
111
|
-
|
112
|
-
// src/actions/wallet/signMessage.ts
|
113
|
-
async function signMessage(client, { from, data: data_ }) {
|
114
|
-
let data;
|
115
|
-
if (typeof data_ === "string") {
|
116
|
-
if (!data_.startsWith("0x"))
|
117
|
-
throw new BaseError(
|
118
|
-
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
119
|
-
{
|
120
|
-
docsPath: "/TODO"
|
121
|
-
}
|
122
|
-
);
|
123
|
-
data = data_;
|
124
|
-
} else {
|
125
|
-
data = encodeHex(data_);
|
126
|
-
}
|
127
|
-
const signed = await client.request({
|
128
|
-
method: "personal_sign",
|
129
|
-
params: [data, from]
|
130
|
-
});
|
131
|
-
return signed;
|
132
|
-
}
|
133
|
-
|
134
|
-
// src/actions/wallet/switchChain.ts
|
135
|
-
async function switchChain(client, { id }) {
|
136
|
-
await client.request({
|
137
|
-
method: "wallet_switchEthereumChain",
|
138
|
-
params: [
|
139
|
-
{
|
140
|
-
chainId: numberToHex(id)
|
141
|
-
}
|
142
|
-
]
|
143
|
-
});
|
144
|
-
}
|
145
|
-
|
146
|
-
// src/actions/wallet/watchAsset.ts
|
147
|
-
async function watchAsset(client, params) {
|
148
|
-
const added = await client.request({
|
149
|
-
method: "wallet_watchAsset",
|
150
|
-
params: [params]
|
151
|
-
});
|
152
|
-
return added;
|
153
|
-
}
|
25
|
+
} from "./chunk-COHLCIQM.js";
|
154
26
|
|
155
27
|
// src/actions/public/call.ts
|
156
28
|
async function call(client, {
|
@@ -282,20 +154,6 @@ async function getBlock(client, {
|
|
282
154
|
formatter: client.chain?.formatters?.block || formatBlock
|
283
155
|
});
|
284
156
|
}
|
285
|
-
var BlockNotFoundError = class extends BaseError {
|
286
|
-
constructor({
|
287
|
-
blockHash,
|
288
|
-
blockNumber
|
289
|
-
}) {
|
290
|
-
let identifier = "Block";
|
291
|
-
if (blockHash)
|
292
|
-
identifier = `Block at hash "${blockHash}"`;
|
293
|
-
if (blockNumber)
|
294
|
-
identifier = `Block at number "${blockNumber}"`;
|
295
|
-
super(`${identifier} could not be found.`);
|
296
|
-
__publicField(this, "name", "BlockNotFoundError");
|
297
|
-
}
|
298
|
-
};
|
299
157
|
|
300
158
|
// src/actions/public/getBlockNumber.ts
|
301
159
|
var cacheKey = (id) => `blockNumber.${id}`;
|
@@ -425,27 +283,6 @@ async function getTransaction(client, {
|
|
425
283
|
formatter: client.chain?.formatters?.transaction || formatTransaction
|
426
284
|
});
|
427
285
|
}
|
428
|
-
var TransactionNotFoundError = class extends BaseError {
|
429
|
-
constructor({
|
430
|
-
blockHash,
|
431
|
-
blockNumber,
|
432
|
-
blockTag,
|
433
|
-
hash,
|
434
|
-
index
|
435
|
-
}) {
|
436
|
-
let identifier = "Transaction";
|
437
|
-
if (blockTag && index !== void 0)
|
438
|
-
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
439
|
-
if (blockHash && index !== void 0)
|
440
|
-
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
441
|
-
if (blockNumber && index !== void 0)
|
442
|
-
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
443
|
-
if (hash)
|
444
|
-
identifier = `Transaction with hash "${hash}"`;
|
445
|
-
super(`${identifier} could not be found.`);
|
446
|
-
__publicField(this, "name", "TransactionNotFoundError");
|
447
|
-
}
|
448
|
-
};
|
449
286
|
|
450
287
|
// src/actions/public/getTransactionConfirmations.ts
|
451
288
|
async function getTransactionConfirmations(client, { hash, transactionReceipt }) {
|
@@ -480,14 +317,6 @@ async function getTransactionReceipt(client, { hash }) {
|
|
480
317
|
formatter: client.chain?.formatters?.transactionReceipt || formatTransactionReceipt
|
481
318
|
});
|
482
319
|
}
|
483
|
-
var TransactionReceiptNotFoundError = class extends BaseError {
|
484
|
-
constructor({ hash }) {
|
485
|
-
super(
|
486
|
-
`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`
|
487
|
-
);
|
488
|
-
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
489
|
-
}
|
490
|
-
};
|
491
320
|
|
492
321
|
// src/actions/public/uninstallFilter.ts
|
493
322
|
async function uninstallFilter(client, { filter }) {
|
@@ -630,14 +459,6 @@ async function waitForTransactionReceipt(client, {
|
|
630
459
|
);
|
631
460
|
});
|
632
461
|
}
|
633
|
-
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
634
|
-
constructor({ hash }) {
|
635
|
-
super(
|
636
|
-
`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`
|
637
|
-
);
|
638
|
-
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
639
|
-
}
|
640
|
-
};
|
641
462
|
|
642
463
|
// src/utils/poll.ts
|
643
464
|
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
@@ -1035,16 +856,135 @@ async function stopImpersonatingAccount(client, { address }) {
|
|
1035
856
|
});
|
1036
857
|
}
|
1037
858
|
|
859
|
+
// src/actions/wallet/addChain.ts
|
860
|
+
async function addChain(client, chain) {
|
861
|
+
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
862
|
+
await client.request({
|
863
|
+
method: "wallet_addEthereumChain",
|
864
|
+
params: [
|
865
|
+
{
|
866
|
+
chainId: numberToHex(id),
|
867
|
+
chainName: name,
|
868
|
+
nativeCurrency,
|
869
|
+
rpcUrls: rpcUrls.default.http,
|
870
|
+
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
871
|
+
}
|
872
|
+
]
|
873
|
+
});
|
874
|
+
}
|
875
|
+
|
876
|
+
// src/actions/wallet/getAccounts.ts
|
877
|
+
async function getAccounts(client) {
|
878
|
+
const addresses = await client.request({ method: "eth_accounts" });
|
879
|
+
return addresses.map((address) => checksumAddress(address));
|
880
|
+
}
|
881
|
+
|
882
|
+
// src/actions/wallet/getPermissions.ts
|
883
|
+
async function getPermissions(client) {
|
884
|
+
const permissions = await client.request({ method: "wallet_getPermissions" });
|
885
|
+
return permissions;
|
886
|
+
}
|
887
|
+
|
888
|
+
// src/actions/wallet/requestAccounts.ts
|
889
|
+
async function requestAccounts(client) {
|
890
|
+
const addresses = await client.request({ method: "eth_requestAccounts" });
|
891
|
+
return addresses.map((address) => getAddress(address));
|
892
|
+
}
|
893
|
+
|
894
|
+
// src/actions/wallet/requestPermissions.ts
|
895
|
+
async function requestPermissions(client, permissions) {
|
896
|
+
return client.request({
|
897
|
+
method: "wallet_requestPermissions",
|
898
|
+
params: [permissions]
|
899
|
+
});
|
900
|
+
}
|
901
|
+
|
902
|
+
// src/actions/wallet/sendTransaction.ts
|
903
|
+
async function sendTransaction(client, {
|
904
|
+
chain,
|
905
|
+
from,
|
906
|
+
accessList,
|
907
|
+
data,
|
908
|
+
gas,
|
909
|
+
gasPrice,
|
910
|
+
maxFeePerGas,
|
911
|
+
maxPriorityFeePerGas,
|
912
|
+
nonce,
|
913
|
+
to,
|
914
|
+
value,
|
915
|
+
...rest
|
916
|
+
}) {
|
917
|
+
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
918
|
+
throw new InvalidGasArgumentsError();
|
919
|
+
const request_ = format(
|
920
|
+
{
|
921
|
+
from,
|
922
|
+
accessList,
|
923
|
+
data,
|
924
|
+
gas,
|
925
|
+
gasPrice,
|
926
|
+
maxFeePerGas,
|
927
|
+
maxPriorityFeePerGas,
|
928
|
+
nonce,
|
929
|
+
to,
|
930
|
+
value,
|
931
|
+
...rest
|
932
|
+
},
|
933
|
+
{
|
934
|
+
formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
|
935
|
+
}
|
936
|
+
);
|
937
|
+
const hash = await client.request({
|
938
|
+
method: "eth_sendTransaction",
|
939
|
+
params: [request_]
|
940
|
+
});
|
941
|
+
return hash;
|
942
|
+
}
|
943
|
+
|
944
|
+
// src/actions/wallet/signMessage.ts
|
945
|
+
async function signMessage(client, { from, data: data_ }) {
|
946
|
+
let data;
|
947
|
+
if (typeof data_ === "string") {
|
948
|
+
if (!data_.startsWith("0x"))
|
949
|
+
throw new BaseError(
|
950
|
+
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
951
|
+
{
|
952
|
+
docsPath: "/TODO"
|
953
|
+
}
|
954
|
+
);
|
955
|
+
data = data_;
|
956
|
+
} else {
|
957
|
+
data = encodeHex(data_);
|
958
|
+
}
|
959
|
+
const signed = await client.request({
|
960
|
+
method: "personal_sign",
|
961
|
+
params: [data, from]
|
962
|
+
});
|
963
|
+
return signed;
|
964
|
+
}
|
965
|
+
|
966
|
+
// src/actions/wallet/switchChain.ts
|
967
|
+
async function switchChain(client, { id }) {
|
968
|
+
await client.request({
|
969
|
+
method: "wallet_switchEthereumChain",
|
970
|
+
params: [
|
971
|
+
{
|
972
|
+
chainId: numberToHex(id)
|
973
|
+
}
|
974
|
+
]
|
975
|
+
});
|
976
|
+
}
|
977
|
+
|
978
|
+
// src/actions/wallet/watchAsset.ts
|
979
|
+
async function watchAsset(client, params) {
|
980
|
+
const added = await client.request({
|
981
|
+
method: "wallet_watchAsset",
|
982
|
+
params: [params]
|
983
|
+
});
|
984
|
+
return added;
|
985
|
+
}
|
986
|
+
|
1038
987
|
export {
|
1039
|
-
addChain,
|
1040
|
-
getAccounts,
|
1041
|
-
getPermissions,
|
1042
|
-
requestAccounts,
|
1043
|
-
requestPermissions,
|
1044
|
-
sendTransaction,
|
1045
|
-
signMessage,
|
1046
|
-
switchChain,
|
1047
|
-
watchAsset,
|
1048
988
|
call,
|
1049
989
|
createPendingTransactionFilter,
|
1050
990
|
createBlockFilter,
|
@@ -1094,5 +1034,14 @@ export {
|
|
1094
1034
|
setNonce,
|
1095
1035
|
setStorageAt,
|
1096
1036
|
snapshot,
|
1097
|
-
stopImpersonatingAccount
|
1037
|
+
stopImpersonatingAccount,
|
1038
|
+
addChain,
|
1039
|
+
getAccounts,
|
1040
|
+
getPermissions,
|
1041
|
+
requestAccounts,
|
1042
|
+
requestPermissions,
|
1043
|
+
sendTransaction,
|
1044
|
+
signMessage,
|
1045
|
+
switchChain,
|
1046
|
+
watchAsset
|
1098
1047
|
};
|