@getpara/wagmi-v2-connector 2.0.0-alpha.9 → 2.0.0-dev.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.
@@ -9,9 +9,8 @@ interface ParaEIP1193ProviderOpts {
9
9
  disableModal?: boolean;
10
10
  storageOverride?: Pick<Storage, 'setItem' | 'getItem'>;
11
11
  transports?: Record<number, Transport>;
12
- renderModal?: (onClose: () => void) => {
13
- openModal: () => void;
14
- };
12
+ renderModal?: (onClose: () => void) => void;
13
+ openModal?: () => void;
15
14
  }
16
15
  export declare class ParaEIP1193Provider extends EventEmitter implements EIP1193Provider {
17
16
  private currentHexChainId;
package/dist/index.js CHANGED
@@ -1,3 +1,362 @@
1
1
  "use client";
2
- export * from "./paraConnector.js";
3
- export * from "./ParaEIP1193Provider.js";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+
42
+ // src/paraConnector.ts
43
+ import { injected } from "wagmi/connectors";
44
+
45
+ // src/ParaEIP1193Provider.ts
46
+ import {
47
+ ProviderRpcError,
48
+ webSocket,
49
+ publicActions,
50
+ http,
51
+ formatTransaction
52
+ } from "viem";
53
+ import { EventEmitter } from "eventemitter3";
54
+ import { extractRpcUrls } from "@wagmi/core";
55
+ import { getViemChain, createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
56
+ import { decimalToHex, hexToDecimal } from "@getpara/web-sdk";
57
+ var STORAGE_CHAIN_ID_KEY = "@CAPSULE/chainId";
58
+ var TEN_MINUTES_MS = 6e5;
59
+ var serverSessionStorageStub = {
60
+ setItem: () => {
61
+ },
62
+ getItem: () => null
63
+ };
64
+ var ParaEIP1193Provider = class extends EventEmitter {
65
+ constructor(opts) {
66
+ var _a;
67
+ super();
68
+ this.getRpcUrlsFromViemChain = (chain) => {
69
+ return extractRpcUrls({ chain, transports: this.transports });
70
+ };
71
+ this.wagmiChainToAddEthereumChainParameters = (chain) => {
72
+ const hexChainId = decimalToHex(`${chain.id}`);
73
+ return [
74
+ hexChainId,
75
+ {
76
+ chainId: hexChainId,
77
+ chainName: chain.name,
78
+ nativeCurrency: chain.nativeCurrency,
79
+ rpcUrls: this.getRpcUrlsFromViemChain(chain)
80
+ }
81
+ ];
82
+ };
83
+ this.wagmiChainsToAddEthereumChainParameters = (chains) => {
84
+ return Object.fromEntries(chains.map(this.wagmiChainToAddEthereumChainParameters));
85
+ };
86
+ this.accountFromAddress = (address) => {
87
+ return createParaAccount(this.para, address);
88
+ };
89
+ this.setCurrentChain = (chainId) => {
90
+ const chain = this.chains[chainId];
91
+ this.setChainId(chainId);
92
+ const viemChain = this.viemChains[chainId] || getViemChain(hexToDecimal(chainId));
93
+ const rpcUrls = this.getRpcUrlsFromViemChain(viemChain);
94
+ let transport;
95
+ if (this.transports[viemChain.id]) {
96
+ transport = this.transports[viemChain.id];
97
+ } else if (rpcUrls[0].startsWith("ws")) {
98
+ transport = webSocket(chain.rpcUrls[0]);
99
+ } else {
100
+ transport = http(rpcUrls[0]);
101
+ this.chainTransportSubscribe = void 0;
102
+ }
103
+ const chainTransport = transport({
104
+ chain: viemChain
105
+ });
106
+ if (chainTransport.config.type === "ws") {
107
+ this.chainTransportSubscribe = chainTransport.value.subscribe;
108
+ }
109
+ this.walletClient = createParaViemClient(
110
+ this.para,
111
+ {
112
+ chain: viemChain,
113
+ transport
114
+ // @ts-ignore
115
+ },
116
+ { noAccount: true }
117
+ ).extend(publicActions);
118
+ this.emit("chainChanged", this.currentHexChainId);
119
+ };
120
+ this.closeModal = () => {
121
+ this.isModalClosed = true;
122
+ };
123
+ this.request = (args) => __async(this, null, function* () {
124
+ const { method, params } = args;
125
+ switch (method) {
126
+ case "eth_accounts": {
127
+ const accounts = this.accounts;
128
+ return accounts || [];
129
+ }
130
+ case "eth_chainId": {
131
+ return this.currentHexChainId;
132
+ }
133
+ case "eth_requestAccounts": {
134
+ if (yield this.para.isFullyLoggedIn()) {
135
+ const accounts = this.accounts;
136
+ if (accounts && accounts.length > 0) {
137
+ return accounts;
138
+ }
139
+ }
140
+ this.isModalClosed = false;
141
+ this.openModal();
142
+ yield this.waitForLogin();
143
+ try {
144
+ const accounts = yield this.waitForAccounts();
145
+ this.emit("accountsChanged", accounts);
146
+ return accounts;
147
+ } catch (error) {
148
+ throw new ProviderRpcError(new Error("accounts not available after login"), {
149
+ code: 4001,
150
+ shortMessage: "accounts not available after login"
151
+ });
152
+ }
153
+ }
154
+ case "eth_sendTransaction": {
155
+ const fromAddress = params[0].from;
156
+ return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
157
+ chain: void 0,
158
+ // uses the chain from the wallet client
159
+ account: this.accountFromAddress(fromAddress)
160
+ }));
161
+ }
162
+ case "eth_sign":
163
+ case "personal_sign": {
164
+ return this.walletClient.signMessage({
165
+ message: { raw: params[0] },
166
+ account: this.accountFromAddress(params[1])
167
+ });
168
+ }
169
+ case "eth_signTransaction": {
170
+ const fromAddress = params[0].from;
171
+ return this.accountFromAddress(fromAddress).signTransaction(formatTransaction(params[0]));
172
+ }
173
+ case "eth_signTypedData_v4": {
174
+ const fromAddress = params[0];
175
+ let typedMessage = params[1];
176
+ if (typeof typedMessage === "string") {
177
+ typedMessage = JSON.parse(typedMessage);
178
+ }
179
+ return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
180
+ account: this.accountFromAddress(fromAddress)
181
+ }));
182
+ }
183
+ case "eth_subscribe": {
184
+ if (!this.chainTransportSubscribe) {
185
+ throw new ProviderRpcError(new Error("chain does not support subscriptions"), {
186
+ code: 4200,
187
+ shortMessage: "chain does not support subscriptions"
188
+ });
189
+ }
190
+ const res = yield this.chainTransportSubscribe({
191
+ params,
192
+ onData: (data) => {
193
+ this.emit("message", {
194
+ type: "eth_subscription",
195
+ data
196
+ });
197
+ }
198
+ });
199
+ return res.subscriptionId;
200
+ }
201
+ case "wallet_addEthereumChain": {
202
+ if (!this.chains[params[0].chainId]) {
203
+ this.chains[params[0].chainId] = params[0];
204
+ }
205
+ return null;
206
+ }
207
+ case "wallet_getPermissions": {
208
+ return [];
209
+ }
210
+ case "wallet_requestPermissions": {
211
+ return [];
212
+ }
213
+ case "wallet_switchEthereumChain": {
214
+ if (!this.chains[params[0].chainId]) {
215
+ const chain = getViemChain(hexToDecimal(params[0].chainId));
216
+ const [hexChainId, addEthereumChainParameter] = this.wagmiChainToAddEthereumChainParameters(chain);
217
+ this.chains[hexChainId] = addEthereumChainParameter;
218
+ this.setCurrentChain(params[0].chainId);
219
+ }
220
+ if (this.currentHexChainId !== params[0].chainId) {
221
+ this.setCurrentChain(params[0].chainId);
222
+ }
223
+ return null;
224
+ }
225
+ case "wallet_watchAsset": {
226
+ return false;
227
+ }
228
+ default: {
229
+ return this.walletClient.request({
230
+ method,
231
+ params
232
+ });
233
+ }
234
+ }
235
+ });
236
+ this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
237
+ this.isModalClosed = true;
238
+ this.para = opts.para;
239
+ this.disableModal = !!opts.disableModal;
240
+ this.viemChains = opts.chains.reduce((acc, curChain) => {
241
+ acc[decimalToHex(`${curChain.id}`)] = curChain;
242
+ return acc;
243
+ }, {});
244
+ this.chains = this.wagmiChainsToAddEthereumChainParameters(opts.chains);
245
+ this.transports = opts.transports;
246
+ this.openModal = opts.openModal;
247
+ if (!this.disableModal) {
248
+ (_a = opts.renderModal) == null ? void 0 : _a.call(opts, this.closeModal);
249
+ }
250
+ const defaultChainId = this.getStorageChainId() || opts.chainId;
251
+ const currentChainId = this.chains[decimalToHex(defaultChainId)] ? defaultChainId : `${opts.chains[0].id}`;
252
+ this.setCurrentChain(decimalToHex(currentChainId));
253
+ this.emit("connect", { chainId: this.currentHexChainId });
254
+ }
255
+ get accounts() {
256
+ return this.para.getWalletsByType("EVM").map((w) => w.address);
257
+ }
258
+ getStorageChainId() {
259
+ return this.storage.getItem(STORAGE_CHAIN_ID_KEY);
260
+ }
261
+ setChainId(hexChainId) {
262
+ this.currentHexChainId = hexChainId;
263
+ this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
264
+ }
265
+ waitForLogin() {
266
+ return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
267
+ const startTime = Date.now();
268
+ while (Date.now() - startTime < timeoutMs) {
269
+ if (yield this.para.isFullyLoggedIn()) {
270
+ return true;
271
+ }
272
+ if (!this.disableModal && this.isModalClosed) {
273
+ throw new ProviderRpcError(new Error("user closed modal"), {
274
+ code: 4001,
275
+ shortMessage: "user closed modal"
276
+ });
277
+ }
278
+ yield new Promise((resolve) => setTimeout(resolve, 2e3));
279
+ }
280
+ throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
281
+ code: 4900,
282
+ //provider is disconnected code
283
+ shortMessage: "timed out waiting for user to log in"
284
+ });
285
+ });
286
+ }
287
+ waitForAccounts(timeoutMs = 5e3) {
288
+ return __async(this, null, function* () {
289
+ const startTime = Date.now();
290
+ while (Date.now() - startTime < timeoutMs) {
291
+ const accounts = this.accounts;
292
+ if (accounts && accounts.length > 0) {
293
+ return accounts;
294
+ }
295
+ yield new Promise((resolve) => setTimeout(resolve, 500));
296
+ }
297
+ throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
298
+ code: 4900,
299
+ //provider is disconnected code
300
+ shortMessage: "timed out waiting for accounts to load"
301
+ });
302
+ });
303
+ }
304
+ };
305
+
306
+ // src/paraConnector.ts
307
+ import { createConnector } from "wagmi";
308
+ var PARA_ID = "para";
309
+ var PARA_NAME = "Para";
310
+ var PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
311
+ var createParaConnector = ({
312
+ para,
313
+ chains: _chains,
314
+ disableModal,
315
+ storageOverride,
316
+ options,
317
+ iconOverride,
318
+ nameOverride,
319
+ idOverride,
320
+ transports,
321
+ renderModal,
322
+ openModal
323
+ }) => {
324
+ return createConnector((config) => {
325
+ const chains = [...config.chains];
326
+ const eip1193Provider = new ParaEIP1193Provider({
327
+ para,
328
+ chainId: `${chains[0].id}`,
329
+ chains,
330
+ disableModal,
331
+ storageOverride,
332
+ transports: transports || config.transports,
333
+ renderModal,
334
+ openModal
335
+ });
336
+ const injectedObj = injected(__spreadValues({
337
+ target: {
338
+ name: PARA_NAME,
339
+ id: idOverride != null ? idOverride : PARA_ID,
340
+ provider: eip1193Provider
341
+ }
342
+ }, options))(config);
343
+ return __spreadProps(__spreadValues({}, injectedObj), {
344
+ type: idOverride != null ? idOverride : PARA_ID,
345
+ name: nameOverride != null ? nameOverride : PARA_NAME,
346
+ icon: iconOverride != null ? iconOverride : PARA_ICON,
347
+ disconnect: () => __async(void 0, null, function* () {
348
+ eip1193Provider.closeModal();
349
+ yield injectedObj.disconnect();
350
+ para.logout();
351
+ })
352
+ });
353
+ });
354
+ };
355
+ var paraConnector = (opts) => {
356
+ return createParaConnector(opts);
357
+ };
358
+ export {
359
+ ParaEIP1193Provider,
360
+ createParaConnector,
361
+ paraConnector
362
+ };
Binary file
Binary file
@@ -17,27 +17,15 @@ export interface ParaConnectorOpts {
17
17
  nameOverride?: string;
18
18
  transports?: Record<number, Transport>;
19
19
  }
20
- export declare const createParaConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, renderModal, }: ParaConnectorOpts & {
21
- renderModal?: (onClose: () => void) => {
22
- openModal: () => void;
23
- };
24
- }) => (config: {
25
- chains: readonly [Chain, ...Chain[]];
26
- emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
27
- storage?: {
28
- key: string;
29
- getItem: <key extends string, value extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key], defaultValue extends value>(key: key, defaultValue?: defaultValue) => (defaultValue extends null ? value : value) | Promise<defaultValue extends null ? value : value>;
30
- setItem: <key_1 extends string, value_1 extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key_1]>(key: key_1, value: value_1) => void | Promise<void>;
31
- removeItem: (key: string) => void | Promise<void>;
32
- };
33
- transports?: Record<number, import("wagmi").Transport>;
34
- }) => {
20
+ export declare const createParaConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, renderModal, openModal, }: ParaConnectorOpts & {
21
+ renderModal?: (onClose: () => void) => void;
22
+ openModal?: () => void;
23
+ }) => import("wagmi").CreateConnectorFn<unknown, {
35
24
  type: string;
36
25
  name: string;
37
26
  icon: string;
38
27
  disconnect: () => Promise<void>;
39
28
  id: string;
40
- rdns?: string | readonly string[];
41
29
  supportsSimulation?: boolean;
42
30
  setup?: () => Promise<void>;
43
31
  connect: (parameters?: {
@@ -52,8 +40,8 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
52
40
  getProvider: (parameters?: {
53
41
  chainId?: number;
54
42
  }) => Promise<{
55
- on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
56
- removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event_1, listener: import("viem").EIP1193EventMap[event_1]) => void;
43
+ on: <TEvent extends keyof import("viem").EIP1193EventMap>(event: TEvent, listener: import("viem").EIP1193EventMap[TEvent]) => void;
44
+ removeListener: <TEvent_1 extends keyof import("viem").EIP1193EventMap>(event: TEvent_1, listener: import("viem").EIP1193EventMap[TEvent_1]) => void;
57
45
  request: import("viem").EIP1193RequestFn<[{
58
46
  Method: "web3_clientVersion";
59
47
  Parameters?: undefined;
@@ -86,13 +74,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
86
74
  Method: "eth_call";
87
75
  Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier, stateOverrideSet: import("viem").RpcStateOverride];
88
76
  ReturnType: `0x${string}`;
89
- }, {
90
- Method: "eth_createAccessList";
91
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
92
- ReturnType: {
93
- accessList: import("viem").AccessList;
94
- gasUsed: `0x${string}`;
95
- };
96
77
  }, {
97
78
  Method: "eth_chainId";
98
79
  Parameters?: undefined;
@@ -260,40 +241,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
260
241
  Method: "eth_sendRawTransaction";
261
242
  Parameters: [signedTransaction: `0x${string}`];
262
243
  ReturnType: `0x${string}`;
263
- }, {
264
- Method: "eth_simulateV1";
265
- Parameters: [{
266
- blockStateCalls: readonly {
267
- blockOverrides?: import("viem").RpcBlockOverrides;
268
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
269
- stateOverrides?: import("viem").RpcStateOverride;
270
- }[];
271
- returnFullTransactions?: boolean;
272
- traceTransfers?: boolean;
273
- validation?: boolean;
274
- }, `0x${string}` | import("viem").BlockTag];
275
- ReturnType: readonly (import("viem").RpcBlock & {
276
- calls: readonly {
277
- error?: {
278
- data?: `0x${string}`;
279
- code: number;
280
- message: string;
281
- };
282
- logs?: readonly {
283
- address: `0x${string}`;
284
- blockHash: `0x${string}`;
285
- blockNumber: `0x${string}`;
286
- data: `0x${string}`;
287
- logIndex: `0x${string}`;
288
- transactionHash: `0x${string}`;
289
- transactionIndex: `0x${string}`;
290
- removed: boolean;
291
- }[];
292
- gasUsed: `0x${string}`;
293
- returnData: `0x${string}`;
294
- status: `0x${string}`;
295
- }[];
296
- })[];
297
244
  }, {
298
245
  Method: "eth_uninstallFilter";
299
246
  Parameters: [filterId: `0x${string}`];
@@ -398,10 +345,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
398
345
  Method: "wallet_sendCalls";
399
346
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
400
347
  ReturnType: string;
401
- }, {
402
- Method: "wallet_sendTransaction";
403
- Parameters: [transaction: import("viem").RpcTransactionRequest];
404
- ReturnType: `0x${string}`;
405
348
  }, {
406
349
  Method: "wallet_showCallsStatus";
407
350
  Parameters?: [string];
@@ -442,7 +385,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
442
385
  ReturnType: readonly `0x${string}`[];
443
386
  }, {
444
387
  Method: "pm_getPaymasterStubData";
445
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
388
+ Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
446
389
  callData: `0x${string}`;
447
390
  callGasLimit: `0x${string}`;
448
391
  initCode?: `0x${string}`;
@@ -454,7 +397,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
454
397
  sender: `0x${string}`;
455
398
  signature: `0x${string}`;
456
399
  verificationGasLimit: `0x${string}`;
457
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
400
+ }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
458
401
  callData: `0x${string}`;
459
402
  callGasLimit: `0x${string}`;
460
403
  factory?: `0x${string}`;
@@ -524,7 +467,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
524
467
  paymasterVerificationGasLimit: `0x${string}`;
525
468
  paymasterPostOpGasLimit: `0x${string}`;
526
469
  }>;
527
- }], false>;
470
+ }]>;
528
471
  isApexWallet?: true;
529
472
  isAvalanche?: true;
530
473
  isBackpack?: true;
@@ -560,12 +503,11 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
560
503
  isTokenary?: true;
561
504
  isTrust?: true;
562
505
  isTrustWallet?: true;
563
- isUniswapWallet?: true;
564
506
  isXDEFI?: true;
565
507
  isZerion?: true;
566
508
  providers?: {
567
- on: <event_2 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
568
- removeListener: <event_3 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
509
+ on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
510
+ removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
569
511
  request: import("viem").EIP1193RequestFn<[{
570
512
  Method: "web3_clientVersion";
571
513
  Parameters?: undefined;
@@ -598,13 +540,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
598
540
  Method: "eth_call";
599
541
  Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier, stateOverrideSet: import("viem").RpcStateOverride];
600
542
  ReturnType: `0x${string}`;
601
- }, {
602
- Method: "eth_createAccessList";
603
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
604
- ReturnType: {
605
- accessList: import("viem").AccessList;
606
- gasUsed: `0x${string}`;
607
- };
608
543
  }, {
609
544
  Method: "eth_chainId";
610
545
  Parameters?: undefined;
@@ -772,40 +707,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
772
707
  Method: "eth_sendRawTransaction";
773
708
  Parameters: [signedTransaction: `0x${string}`];
774
709
  ReturnType: `0x${string}`;
775
- }, {
776
- Method: "eth_simulateV1";
777
- Parameters: [{
778
- blockStateCalls: readonly {
779
- blockOverrides?: import("viem").RpcBlockOverrides;
780
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
781
- stateOverrides?: import("viem").RpcStateOverride;
782
- }[];
783
- returnFullTransactions?: boolean;
784
- traceTransfers?: boolean;
785
- validation?: boolean;
786
- }, `0x${string}` | import("viem").BlockTag];
787
- ReturnType: readonly (import("viem").RpcBlock & {
788
- calls: readonly {
789
- error?: {
790
- data?: `0x${string}`;
791
- code: number;
792
- message: string;
793
- };
794
- logs?: readonly {
795
- address: `0x${string}`;
796
- blockHash: `0x${string}`;
797
- blockNumber: `0x${string}`;
798
- data: `0x${string}`;
799
- logIndex: `0x${string}`;
800
- transactionHash: `0x${string}`;
801
- transactionIndex: `0x${string}`;
802
- removed: boolean;
803
- }[];
804
- gasUsed: `0x${string}`;
805
- returnData: `0x${string}`;
806
- status: `0x${string}`;
807
- }[];
808
- })[];
809
710
  }, {
810
711
  Method: "eth_uninstallFilter";
811
712
  Parameters: [filterId: `0x${string}`];
@@ -910,10 +811,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
910
811
  Method: "wallet_sendCalls";
911
812
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
912
813
  ReturnType: string;
913
- }, {
914
- Method: "wallet_sendTransaction";
915
- Parameters: [transaction: import("viem").RpcTransactionRequest];
916
- ReturnType: `0x${string}`;
917
814
  }, {
918
815
  Method: "wallet_showCallsStatus";
919
816
  Parameters?: [string];
@@ -954,7 +851,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
954
851
  ReturnType: readonly `0x${string}`[];
955
852
  }, {
956
853
  Method: "pm_getPaymasterStubData";
957
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
854
+ Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
958
855
  callData: `0x${string}`;
959
856
  callGasLimit: `0x${string}`;
960
857
  initCode?: `0x${string}`;
@@ -966,7 +863,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
966
863
  sender: `0x${string}`;
967
864
  signature: `0x${string}`;
968
865
  verificationGasLimit: `0x${string}`;
969
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
866
+ }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
970
867
  callData: `0x${string}`;
971
868
  callGasLimit: `0x${string}`;
972
869
  factory?: `0x${string}`;
@@ -1036,7 +933,7 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
1036
933
  paymasterVerificationGasLimit: `0x${string}`;
1037
934
  paymasterPostOpGasLimit: `0x${string}`;
1038
935
  }>;
1039
- }], false>;
936
+ }]>;
1040
937
  isApexWallet?: true;
1041
938
  isAvalanche?: true;
1042
939
  isBackpack?: true;
@@ -1072,7 +969,6 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
1072
969
  isTokenary?: true;
1073
970
  isTrust?: true;
1074
971
  isTrustWallet?: true;
1075
- isUniswapWallet?: true;
1076
972
  isXDEFI?: true;
1077
973
  isZerion?: true;
1078
974
  providers?: any[];
@@ -1111,24 +1007,13 @@ export declare const createParaConnector: ({ para, chains: _chains, disableModal
1111
1007
  onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
1112
1008
  onDisconnect: (error?: Error) => void;
1113
1009
  onMessage?: (message: import("viem").ProviderMessage) => void;
1114
- };
1115
- export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1116
- chains: readonly [Chain, ...Chain[]];
1117
- emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
1118
- storage?: {
1119
- key: string;
1120
- getItem: <key extends string, value extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key], defaultValue extends value>(key: key, defaultValue?: defaultValue) => (defaultValue extends null ? value : value) | Promise<defaultValue extends null ? value : value>;
1121
- setItem: <key_1 extends string, value_1 extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key_1]>(key: key_1, value: value_1) => void | Promise<void>;
1122
- removeItem: (key: string) => void | Promise<void>;
1123
- };
1124
- transports?: Record<number, import("wagmi").Transport>;
1125
- }) => {
1010
+ }, Record<string, unknown>>;
1011
+ export declare const paraConnector: (opts: ParaConnectorOpts) => import("wagmi").CreateConnectorFn<unknown, {
1126
1012
  type: string;
1127
1013
  name: string;
1128
1014
  icon: string;
1129
1015
  disconnect: () => Promise<void>;
1130
1016
  id: string;
1131
- rdns?: string | readonly string[];
1132
1017
  supportsSimulation?: boolean;
1133
1018
  setup?: () => Promise<void>;
1134
1019
  connect: (parameters?: {
@@ -1143,8 +1028,8 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1143
1028
  getProvider: (parameters?: {
1144
1029
  chainId?: number;
1145
1030
  }) => Promise<{
1146
- on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
1147
- removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event_1, listener: import("viem").EIP1193EventMap[event_1]) => void;
1031
+ on: <TEvent extends keyof import("viem").EIP1193EventMap>(event: TEvent, listener: import("viem").EIP1193EventMap[TEvent]) => void;
1032
+ removeListener: <TEvent_1 extends keyof import("viem").EIP1193EventMap>(event: TEvent_1, listener: import("viem").EIP1193EventMap[TEvent_1]) => void;
1148
1033
  request: import("viem").EIP1193RequestFn<[{
1149
1034
  Method: "web3_clientVersion";
1150
1035
  Parameters?: undefined;
@@ -1177,13 +1062,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1177
1062
  Method: "eth_call";
1178
1063
  Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier, stateOverrideSet: import("viem").RpcStateOverride];
1179
1064
  ReturnType: `0x${string}`;
1180
- }, {
1181
- Method: "eth_createAccessList";
1182
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
1183
- ReturnType: {
1184
- accessList: import("viem").AccessList;
1185
- gasUsed: `0x${string}`;
1186
- };
1187
1065
  }, {
1188
1066
  Method: "eth_chainId";
1189
1067
  Parameters?: undefined;
@@ -1351,40 +1229,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1351
1229
  Method: "eth_sendRawTransaction";
1352
1230
  Parameters: [signedTransaction: `0x${string}`];
1353
1231
  ReturnType: `0x${string}`;
1354
- }, {
1355
- Method: "eth_simulateV1";
1356
- Parameters: [{
1357
- blockStateCalls: readonly {
1358
- blockOverrides?: import("viem").RpcBlockOverrides;
1359
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
1360
- stateOverrides?: import("viem").RpcStateOverride;
1361
- }[];
1362
- returnFullTransactions?: boolean;
1363
- traceTransfers?: boolean;
1364
- validation?: boolean;
1365
- }, `0x${string}` | import("viem").BlockTag];
1366
- ReturnType: readonly (import("viem").RpcBlock & {
1367
- calls: readonly {
1368
- error?: {
1369
- data?: `0x${string}`;
1370
- code: number;
1371
- message: string;
1372
- };
1373
- logs?: readonly {
1374
- address: `0x${string}`;
1375
- blockHash: `0x${string}`;
1376
- blockNumber: `0x${string}`;
1377
- data: `0x${string}`;
1378
- logIndex: `0x${string}`;
1379
- transactionHash: `0x${string}`;
1380
- transactionIndex: `0x${string}`;
1381
- removed: boolean;
1382
- }[];
1383
- gasUsed: `0x${string}`;
1384
- returnData: `0x${string}`;
1385
- status: `0x${string}`;
1386
- }[];
1387
- })[];
1388
1232
  }, {
1389
1233
  Method: "eth_uninstallFilter";
1390
1234
  Parameters: [filterId: `0x${string}`];
@@ -1489,10 +1333,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1489
1333
  Method: "wallet_sendCalls";
1490
1334
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
1491
1335
  ReturnType: string;
1492
- }, {
1493
- Method: "wallet_sendTransaction";
1494
- Parameters: [transaction: import("viem").RpcTransactionRequest];
1495
- ReturnType: `0x${string}`;
1496
1336
  }, {
1497
1337
  Method: "wallet_showCallsStatus";
1498
1338
  Parameters?: [string];
@@ -1533,7 +1373,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1533
1373
  ReturnType: readonly `0x${string}`[];
1534
1374
  }, {
1535
1375
  Method: "pm_getPaymasterStubData";
1536
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
1376
+ Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
1537
1377
  callData: `0x${string}`;
1538
1378
  callGasLimit: `0x${string}`;
1539
1379
  initCode?: `0x${string}`;
@@ -1545,7 +1385,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1545
1385
  sender: `0x${string}`;
1546
1386
  signature: `0x${string}`;
1547
1387
  verificationGasLimit: `0x${string}`;
1548
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
1388
+ }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
1549
1389
  callData: `0x${string}`;
1550
1390
  callGasLimit: `0x${string}`;
1551
1391
  factory?: `0x${string}`;
@@ -1615,7 +1455,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1615
1455
  paymasterVerificationGasLimit: `0x${string}`;
1616
1456
  paymasterPostOpGasLimit: `0x${string}`;
1617
1457
  }>;
1618
- }], false>;
1458
+ }]>;
1619
1459
  isApexWallet?: true;
1620
1460
  isAvalanche?: true;
1621
1461
  isBackpack?: true;
@@ -1651,12 +1491,11 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1651
1491
  isTokenary?: true;
1652
1492
  isTrust?: true;
1653
1493
  isTrustWallet?: true;
1654
- isUniswapWallet?: true;
1655
1494
  isXDEFI?: true;
1656
1495
  isZerion?: true;
1657
1496
  providers?: {
1658
- on: <event_2 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
1659
- removeListener: <event_3 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
1497
+ on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
1498
+ removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
1660
1499
  request: import("viem").EIP1193RequestFn<[{
1661
1500
  Method: "web3_clientVersion";
1662
1501
  Parameters?: undefined;
@@ -1689,13 +1528,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1689
1528
  Method: "eth_call";
1690
1529
  Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier, stateOverrideSet: import("viem").RpcStateOverride];
1691
1530
  ReturnType: `0x${string}`;
1692
- }, {
1693
- Method: "eth_createAccessList";
1694
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
1695
- ReturnType: {
1696
- accessList: import("viem").AccessList;
1697
- gasUsed: `0x${string}`;
1698
- };
1699
1531
  }, {
1700
1532
  Method: "eth_chainId";
1701
1533
  Parameters?: undefined;
@@ -1863,40 +1695,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
1863
1695
  Method: "eth_sendRawTransaction";
1864
1696
  Parameters: [signedTransaction: `0x${string}`];
1865
1697
  ReturnType: `0x${string}`;
1866
- }, {
1867
- Method: "eth_simulateV1";
1868
- Parameters: [{
1869
- blockStateCalls: readonly {
1870
- blockOverrides?: import("viem").RpcBlockOverrides;
1871
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
1872
- stateOverrides?: import("viem").RpcStateOverride;
1873
- }[];
1874
- returnFullTransactions?: boolean;
1875
- traceTransfers?: boolean;
1876
- validation?: boolean;
1877
- }, `0x${string}` | import("viem").BlockTag];
1878
- ReturnType: readonly (import("viem").RpcBlock & {
1879
- calls: readonly {
1880
- error?: {
1881
- data?: `0x${string}`;
1882
- code: number;
1883
- message: string;
1884
- };
1885
- logs?: readonly {
1886
- address: `0x${string}`;
1887
- blockHash: `0x${string}`;
1888
- blockNumber: `0x${string}`;
1889
- data: `0x${string}`;
1890
- logIndex: `0x${string}`;
1891
- transactionHash: `0x${string}`;
1892
- transactionIndex: `0x${string}`;
1893
- removed: boolean;
1894
- }[];
1895
- gasUsed: `0x${string}`;
1896
- returnData: `0x${string}`;
1897
- status: `0x${string}`;
1898
- }[];
1899
- })[];
1900
1698
  }, {
1901
1699
  Method: "eth_uninstallFilter";
1902
1700
  Parameters: [filterId: `0x${string}`];
@@ -2001,10 +1799,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2001
1799
  Method: "wallet_sendCalls";
2002
1800
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
2003
1801
  ReturnType: string;
2004
- }, {
2005
- Method: "wallet_sendTransaction";
2006
- Parameters: [transaction: import("viem").RpcTransactionRequest];
2007
- ReturnType: `0x${string}`;
2008
1802
  }, {
2009
1803
  Method: "wallet_showCallsStatus";
2010
1804
  Parameters?: [string];
@@ -2045,7 +1839,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2045
1839
  ReturnType: readonly `0x${string}`[];
2046
1840
  }, {
2047
1841
  Method: "pm_getPaymasterStubData";
2048
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
1842
+ Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
2049
1843
  callData: `0x${string}`;
2050
1844
  callGasLimit: `0x${string}`;
2051
1845
  initCode?: `0x${string}`;
@@ -2057,7 +1851,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2057
1851
  sender: `0x${string}`;
2058
1852
  signature: `0x${string}`;
2059
1853
  verificationGasLimit: `0x${string}`;
2060
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
1854
+ }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
2061
1855
  callData: `0x${string}`;
2062
1856
  callGasLimit: `0x${string}`;
2063
1857
  factory?: `0x${string}`;
@@ -2127,7 +1921,7 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2127
1921
  paymasterVerificationGasLimit: `0x${string}`;
2128
1922
  paymasterPostOpGasLimit: `0x${string}`;
2129
1923
  }>;
2130
- }], false>;
1924
+ }]>;
2131
1925
  isApexWallet?: true;
2132
1926
  isAvalanche?: true;
2133
1927
  isBackpack?: true;
@@ -2163,7 +1957,6 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2163
1957
  isTokenary?: true;
2164
1958
  isTrust?: true;
2165
1959
  isTrustWallet?: true;
2166
- isUniswapWallet?: true;
2167
1960
  isXDEFI?: true;
2168
1961
  isZerion?: true;
2169
1962
  providers?: any[];
@@ -2202,4 +1995,4 @@ export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
2202
1995
  onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
2203
1996
  onDisconnect: (error?: Error) => void;
2204
1997
  onMessage?: (message: import("viem").ProviderMessage) => void;
2205
- };
1998
+ }, Record<string, unknown>>;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/wagmi-v2-connector",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0-dev.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "dependencies": {
9
- "@getpara/viem-v2-integration": "2.0.0-alpha.9",
10
- "@getpara/web-sdk": "2.0.0-alpha.9"
9
+ "@getpara/viem-v2-integration": "2.0.0-dev.0",
10
+ "@getpara/web-sdk": "2.0.0-dev.0"
11
11
  },
12
12
  "scripts": {
13
13
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
@@ -15,18 +15,18 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "typescript": "5.1.6",
18
- "viem": "^2.24.2",
19
- "wagmi": "^2.14.16"
18
+ "viem": "2.x",
19
+ "wagmi": "2.x"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": "*",
23
23
  "react-dom": "*",
24
- "viem": "^2.24.2",
25
- "wagmi": "^2.14.16"
24
+ "viem": "2.x",
25
+ "wagmi": "2.x"
26
26
  },
27
27
  "files": [
28
28
  "dist",
29
29
  "package.json"
30
30
  ],
31
- "gitHead": "16aae30867cc995bd825cfba04845192502d2b6e"
31
+ "gitHead": "f94ef031ef0e1894f5f0800e55f6ca2904641780"
32
32
  }
@@ -1,268 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "./chunk-IV3L3JVM.js";
7
- import {
8
- ProviderRpcError,
9
- webSocket,
10
- publicActions,
11
- http,
12
- formatTransaction
13
- } from "viem";
14
- import { EventEmitter } from "eventemitter3";
15
- import { extractRpcUrls } from "@wagmi/core";
16
- import { getViemChain, createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
17
- import { decimalToHex, hexToDecimal } from "@getpara/web-sdk";
18
- const STORAGE_CHAIN_ID_KEY = "@CAPSULE/chainId";
19
- const TEN_MINUTES_MS = 6e5;
20
- const serverSessionStorageStub = {
21
- setItem: () => {
22
- },
23
- getItem: () => null
24
- };
25
- class ParaEIP1193Provider extends EventEmitter {
26
- constructor(opts) {
27
- super();
28
- this.getRpcUrlsFromViemChain = (chain) => {
29
- return extractRpcUrls({ chain, transports: this.transports });
30
- };
31
- this.wagmiChainToAddEthereumChainParameters = (chain) => {
32
- const hexChainId = decimalToHex(`${chain.id}`);
33
- return [
34
- hexChainId,
35
- {
36
- chainId: hexChainId,
37
- chainName: chain.name,
38
- nativeCurrency: chain.nativeCurrency,
39
- rpcUrls: this.getRpcUrlsFromViemChain(chain)
40
- }
41
- ];
42
- };
43
- this.wagmiChainsToAddEthereumChainParameters = (chains) => {
44
- return Object.fromEntries(chains.map(this.wagmiChainToAddEthereumChainParameters));
45
- };
46
- this.accountFromAddress = (address) => {
47
- return createParaAccount(this.para, address);
48
- };
49
- this.setCurrentChain = (chainId) => {
50
- const chain = this.chains[chainId];
51
- this.setChainId(chainId);
52
- const viemChain = this.viemChains[chainId] || getViemChain(hexToDecimal(chainId));
53
- const rpcUrls = this.getRpcUrlsFromViemChain(viemChain);
54
- let transport;
55
- if (this.transports[viemChain.id]) {
56
- transport = this.transports[viemChain.id];
57
- } else if (rpcUrls[0].startsWith("ws")) {
58
- transport = webSocket(chain.rpcUrls[0]);
59
- } else {
60
- transport = http(rpcUrls[0]);
61
- this.chainTransportSubscribe = void 0;
62
- }
63
- const chainTransport = transport({
64
- chain: viemChain
65
- });
66
- if (chainTransport.config.type === "ws") {
67
- this.chainTransportSubscribe = chainTransport.value.subscribe;
68
- }
69
- this.walletClient = createParaViemClient(
70
- this.para,
71
- {
72
- chain: viemChain,
73
- transport
74
- // @ts-ignore
75
- },
76
- { noAccount: true }
77
- ).extend(publicActions);
78
- this.emit("chainChanged", this.currentHexChainId);
79
- };
80
- this.closeModal = () => {
81
- this.isModalClosed = true;
82
- };
83
- this.request = (args) => __async(this, null, function* () {
84
- var _a;
85
- const { method, params } = args;
86
- switch (method) {
87
- case "eth_accounts": {
88
- const accounts = this.accounts;
89
- return accounts || [];
90
- }
91
- case "eth_chainId": {
92
- return this.currentHexChainId;
93
- }
94
- case "eth_requestAccounts": {
95
- if (yield this.para.isFullyLoggedIn()) {
96
- const accounts = this.accounts;
97
- if (accounts && accounts.length > 0) {
98
- return accounts;
99
- }
100
- }
101
- this.isModalClosed = false;
102
- (_a = this.openModal) == null ? void 0 : _a.call(this);
103
- yield this.waitForLogin();
104
- try {
105
- const accounts = yield this.waitForAccounts();
106
- this.emit("accountsChanged", accounts);
107
- return accounts;
108
- } catch (error) {
109
- throw new ProviderRpcError(new Error("accounts not available after login"), {
110
- code: 4001,
111
- shortMessage: "accounts not available after login"
112
- });
113
- }
114
- }
115
- case "eth_sendTransaction": {
116
- const fromAddress = params[0].from;
117
- return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
118
- chain: void 0,
119
- // uses the chain from the wallet client
120
- account: this.accountFromAddress(fromAddress)
121
- }));
122
- }
123
- case "eth_sign":
124
- case "personal_sign": {
125
- return this.walletClient.signMessage({
126
- message: { raw: params[0] },
127
- account: this.accountFromAddress(params[1])
128
- });
129
- }
130
- case "eth_signTransaction": {
131
- const fromAddress = params[0].from;
132
- return this.accountFromAddress(fromAddress).signTransaction(formatTransaction(params[0]));
133
- }
134
- case "eth_signTypedData_v4": {
135
- const fromAddress = params[0];
136
- let typedMessage = params[1];
137
- if (typeof typedMessage === "string") {
138
- typedMessage = JSON.parse(typedMessage);
139
- }
140
- return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
141
- account: this.accountFromAddress(fromAddress)
142
- }));
143
- }
144
- case "eth_subscribe": {
145
- if (!this.chainTransportSubscribe) {
146
- throw new ProviderRpcError(new Error("chain does not support subscriptions"), {
147
- code: 4200,
148
- shortMessage: "chain does not support subscriptions"
149
- });
150
- }
151
- const res = yield this.chainTransportSubscribe({
152
- params,
153
- onData: (data) => {
154
- this.emit("message", {
155
- type: "eth_subscription",
156
- data
157
- });
158
- }
159
- });
160
- return res.subscriptionId;
161
- }
162
- case "wallet_addEthereumChain": {
163
- if (!this.chains[params[0].chainId]) {
164
- this.chains[params[0].chainId] = params[0];
165
- }
166
- return null;
167
- }
168
- case "wallet_getPermissions": {
169
- return [];
170
- }
171
- case "wallet_requestPermissions": {
172
- return [];
173
- }
174
- case "wallet_switchEthereumChain": {
175
- if (!this.chains[params[0].chainId]) {
176
- const chain = getViemChain(hexToDecimal(params[0].chainId));
177
- const [hexChainId, addEthereumChainParameter] = this.wagmiChainToAddEthereumChainParameters(chain);
178
- this.chains[hexChainId] = addEthereumChainParameter;
179
- this.setCurrentChain(params[0].chainId);
180
- }
181
- if (this.currentHexChainId !== params[0].chainId) {
182
- this.setCurrentChain(params[0].chainId);
183
- }
184
- return null;
185
- }
186
- case "wallet_watchAsset": {
187
- return false;
188
- }
189
- default: {
190
- return this.walletClient.request({
191
- method,
192
- params
193
- });
194
- }
195
- }
196
- });
197
- this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
198
- this.isModalClosed = true;
199
- this.para = opts.para;
200
- this.disableModal = !!opts.disableModal;
201
- this.viemChains = opts.chains.reduce((acc, curChain) => {
202
- acc[decimalToHex(`${curChain.id}`)] = curChain;
203
- return acc;
204
- }, {});
205
- this.chains = this.wagmiChainsToAddEthereumChainParameters(opts.chains);
206
- this.transports = opts.transports;
207
- if (!this.disableModal && opts.renderModal) {
208
- const { openModal } = opts.renderModal(this.closeModal);
209
- this.openModal = openModal;
210
- }
211
- const defaultChainId = this.getStorageChainId() || opts.chainId;
212
- const currentChainId = this.chains[decimalToHex(defaultChainId)] ? defaultChainId : `${opts.chains[0].id}`;
213
- this.setCurrentChain(decimalToHex(currentChainId));
214
- this.emit("connect", { chainId: this.currentHexChainId });
215
- }
216
- get accounts() {
217
- return this.para.getWalletsByType("EVM").map((w) => w.address);
218
- }
219
- getStorageChainId() {
220
- return this.storage.getItem(STORAGE_CHAIN_ID_KEY);
221
- }
222
- setChainId(hexChainId) {
223
- this.currentHexChainId = hexChainId;
224
- this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
225
- }
226
- waitForLogin() {
227
- return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
228
- const startTime = Date.now();
229
- while (Date.now() - startTime < timeoutMs) {
230
- if (yield this.para.isFullyLoggedIn()) {
231
- return true;
232
- }
233
- if (!this.disableModal && this.isModalClosed) {
234
- throw new ProviderRpcError(new Error("user closed modal"), {
235
- code: 4001,
236
- shortMessage: "user closed modal"
237
- });
238
- }
239
- yield new Promise((resolve) => setTimeout(resolve, 2e3));
240
- }
241
- throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
242
- code: 4900,
243
- //provider is disconnected code
244
- shortMessage: "timed out waiting for user to log in"
245
- });
246
- });
247
- }
248
- waitForAccounts(timeoutMs = 5e3) {
249
- return __async(this, null, function* () {
250
- const startTime = Date.now();
251
- while (Date.now() - startTime < timeoutMs) {
252
- const accounts = this.accounts;
253
- if (accounts && accounts.length > 0) {
254
- return accounts;
255
- }
256
- yield new Promise((resolve) => setTimeout(resolve, 500));
257
- }
258
- throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
259
- code: 4900,
260
- //provider is disconnected code
261
- shortMessage: "timed out waiting for accounts to load"
262
- });
263
- });
264
- }
265
- }
266
- export {
267
- ParaEIP1193Provider
268
- };
@@ -1,46 +0,0 @@
1
- "use client";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __async = (__this, __arguments, generator) => {
22
- return new Promise((resolve, reject) => {
23
- var fulfilled = (value) => {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- };
30
- var rejected = (value) => {
31
- try {
32
- step(generator.throw(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
- step((generator = generator.apply(__this, __arguments)).next());
39
- });
40
- };
41
-
42
- export {
43
- __spreadValues,
44
- __spreadProps,
45
- __async
46
- };
package/dist/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": false
4
- }
@@ -1,61 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "./chunk-IV3L3JVM.js";
7
- import { injected } from "wagmi/connectors";
8
- import { ParaEIP1193Provider } from "./ParaEIP1193Provider.js";
9
- import { createConnector } from "wagmi";
10
- const PARA_ID = "para";
11
- const PARA_NAME = "Para";
12
- const PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
13
- const createParaConnector = ({
14
- para,
15
- chains: _chains,
16
- disableModal,
17
- storageOverride,
18
- options,
19
- iconOverride,
20
- nameOverride,
21
- idOverride,
22
- transports,
23
- renderModal
24
- }) => {
25
- return createConnector((config) => {
26
- const chains = [...config.chains];
27
- const eip1193Provider = new ParaEIP1193Provider({
28
- para,
29
- chainId: `${chains[0].id}`,
30
- chains,
31
- disableModal,
32
- storageOverride,
33
- transports: transports || config.transports,
34
- renderModal
35
- });
36
- const injectedObj = injected(__spreadValues({
37
- target: {
38
- name: PARA_NAME,
39
- id: idOverride != null ? idOverride : PARA_ID,
40
- provider: eip1193Provider
41
- }
42
- }, options))(config);
43
- return __spreadProps(__spreadValues({}, injectedObj), {
44
- type: idOverride != null ? idOverride : PARA_ID,
45
- name: nameOverride != null ? nameOverride : PARA_NAME,
46
- icon: iconOverride != null ? iconOverride : PARA_ICON,
47
- disconnect: () => __async(void 0, null, function* () {
48
- eip1193Provider.closeModal();
49
- yield injectedObj.disconnect();
50
- para.logout();
51
- })
52
- });
53
- });
54
- };
55
- const paraConnector = (opts) => {
56
- return createParaConnector(opts);
57
- };
58
- export {
59
- createParaConnector,
60
- paraConnector
61
- };