@getpara/wagmi-v2-integration 1.7.1 → 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.
@@ -1,3 +1,3 @@
1
1
  import ParaWeb from '@getpara/react-sdk';
2
- import { ParaModalPropsForInit } from './ParaEIP1193Provider.js';
2
+ import { ParaModalPropsForInit } from './paraConnector.js';
3
3
  export declare function renderModal(para: ParaWeb, modalProps: Partial<ParaModalPropsForInit>, onCloseArg: () => void): void;
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './paraConnector.js';
2
- export * from './ParaEIP1193Provider.js';
package/dist/index.js CHANGED
@@ -52,24 +52,16 @@ var __async = (__this, __arguments, generator) => {
52
52
  };
53
53
 
54
54
  // src/paraConnector.ts
55
- import { injected } from "wagmi/connectors";
56
-
57
- // src/ParaEIP1193Provider.ts
58
- import {
59
- ProviderRpcError,
60
- webSocket,
61
- publicActions,
62
- http,
63
- formatTransaction
64
- } from "viem";
65
- import { EventEmitter } from "eventemitter3";
66
- import { extractRpcUrls } from "@wagmi/core";
67
- import { getViemChain, createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
68
- import { decimalToHex, hexToDecimal } from "@getpara/react-sdk";
55
+ import { setIsOpen as setIsOpen2 } from "@getpara/react-sdk";
56
+ import { createParaConnector } from "@getpara/wagmi-v2-connector";
69
57
 
70
58
  // src/connectorModal.tsx
71
- import { ParaModal } from "@getpara/react-sdk";
59
+ import { ParaProvider, setIsOpen } from "@getpara/react-sdk";
60
+ import { QueryClient } from "@tanstack/react-query";
61
+ import { QueryClientProvider } from "@tanstack/react-query";
72
62
  import { jsx } from "react/jsx-runtime";
63
+ var queryClient = new QueryClient();
64
+ var Root;
73
65
  function renderModal(para, modalProps, onCloseArg) {
74
66
  const existingContainer = document.getElementById("para-modal");
75
67
  const container = existingContainer != null ? existingContainer : document.createElement("div");
@@ -80,277 +72,33 @@ function renderModal(para, modalProps, onCloseArg) {
80
72
  const onClose = () => {
81
73
  onCloseArg();
82
74
  modalProps.onClose && modalProps.onClose();
83
- render(false);
75
+ setIsOpen(false);
84
76
  };
85
- const render = (isOpen) => __async(this, null, function* () {
86
- const Modal = /* @__PURE__ */ jsx(ParaModal, __spreadProps(__spreadValues({}, modalProps), { onClose, para, isOpen }));
77
+ const render = () => __async(this, null, function* () {
78
+ var _a;
79
+ const Modal = /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
80
+ ParaProvider,
81
+ {
82
+ paraClientConfig: para,
83
+ config: { appName: (_a = modalProps.appName) != null ? _a : "" },
84
+ paraModalConfig: __spreadProps(__spreadValues({}, modalProps), { onClose })
85
+ }
86
+ ) });
87
87
  try {
88
88
  const client = yield import("react-dom/client");
89
- const root = client.createRoot(container);
90
- root.render(Modal);
89
+ if (!Root) {
90
+ Root = client.createRoot(container);
91
+ }
92
+ Root.render(Modal);
91
93
  } catch (e) {
92
94
  const ReactDOM = yield import("react-dom");
93
95
  ReactDOM.render(Modal, container);
94
96
  }
95
97
  });
96
- render(true);
98
+ render();
97
99
  }
98
100
 
99
- // src/ParaEIP1193Provider.ts
100
- var STORAGE_CHAIN_ID_KEY = "@CAPSULE/chainId";
101
- var TEN_MINUTES_MS = 6e5;
102
- var serverSessionStorageStub = {
103
- setItem: () => {
104
- },
105
- getItem: () => null
106
- };
107
- var ParaEIP1193Provider = class extends EventEmitter {
108
- constructor(opts) {
109
- super();
110
- this.getRpcUrlsFromViemChain = (chain) => {
111
- return extractRpcUrls({ chain, transports: this.transports });
112
- };
113
- this.wagmiChainToAddEthereumChainParameters = (chain) => {
114
- const hexChainId = decimalToHex(`${chain.id}`);
115
- return [
116
- hexChainId,
117
- {
118
- chainId: hexChainId,
119
- chainName: chain.name,
120
- nativeCurrency: chain.nativeCurrency,
121
- rpcUrls: this.getRpcUrlsFromViemChain(chain)
122
- }
123
- ];
124
- };
125
- this.wagmiChainsToAddEthereumChainParameters = (chains) => {
126
- return Object.fromEntries(chains.map(this.wagmiChainToAddEthereumChainParameters));
127
- };
128
- this.accountFromAddress = (address) => {
129
- return createParaAccount(this.para, address);
130
- };
131
- this.setCurrentChain = (chainId) => {
132
- const chain = this.chains[chainId];
133
- this.setChainId(chainId);
134
- const viemChain = this.viemChains[chainId] || getViemChain(hexToDecimal(chainId));
135
- const rpcUrls = this.getRpcUrlsFromViemChain(viemChain);
136
- let transport;
137
- if (this.transports[viemChain.id]) {
138
- transport = this.transports[viemChain.id];
139
- } else if (rpcUrls[0].startsWith("ws")) {
140
- transport = webSocket(chain.rpcUrls[0]);
141
- } else {
142
- transport = http(rpcUrls[0]);
143
- this.chainTransportSubscribe = void 0;
144
- }
145
- const chainTransport = transport({
146
- chain: viemChain
147
- });
148
- if (chainTransport.config.type === "ws") {
149
- this.chainTransportSubscribe = chainTransport.value.subscribe;
150
- }
151
- this.walletClient = createParaViemClient(
152
- this.para,
153
- {
154
- chain: viemChain,
155
- transport
156
- // @ts-ignore
157
- },
158
- { noAccount: true }
159
- ).extend(publicActions);
160
- this.emit("chainChanged", this.currentHexChainId);
161
- };
162
- this.closeModal = () => {
163
- this.isModalClosed = true;
164
- };
165
- this.request = (args) => __async(this, null, function* () {
166
- const { method, params } = args;
167
- switch (method) {
168
- case "eth_accounts": {
169
- const accounts = this.accounts;
170
- return accounts || [];
171
- }
172
- case "eth_chainId": {
173
- return this.currentHexChainId;
174
- }
175
- case "eth_requestAccounts": {
176
- if (yield this.para.isFullyLoggedIn()) {
177
- const accounts = this.accounts;
178
- if (accounts && accounts.length > 0) {
179
- return accounts;
180
- }
181
- }
182
- if (!this.disableModal) {
183
- this.isModalClosed = false;
184
- renderModal(this.para, this.modalProps, () => {
185
- this.isModalClosed = true;
186
- });
187
- }
188
- yield this.waitForLogin();
189
- try {
190
- const accounts = yield this.waitForAccounts();
191
- this.emit("accountsChanged", accounts);
192
- return accounts;
193
- } catch (error) {
194
- throw new ProviderRpcError(new Error("accounts not available after login"), {
195
- code: 4001,
196
- shortMessage: "accounts not available after login"
197
- });
198
- }
199
- }
200
- case "eth_sendTransaction": {
201
- const fromAddress = params[0].from;
202
- return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
203
- chain: void 0,
204
- // uses the chain from the wallet client
205
- account: this.accountFromAddress(fromAddress)
206
- }));
207
- }
208
- case "eth_sign":
209
- case "personal_sign": {
210
- return this.walletClient.signMessage({
211
- message: { raw: params[0] },
212
- account: this.accountFromAddress(params[1])
213
- });
214
- }
215
- case "eth_signTransaction": {
216
- const fromAddress = params[0].from;
217
- return this.accountFromAddress(fromAddress).signTransaction(formatTransaction(params[0]));
218
- }
219
- case "eth_signTypedData_v4": {
220
- const fromAddress = params[0];
221
- let typedMessage = params[1];
222
- if (typeof typedMessage === "string") {
223
- typedMessage = JSON.parse(typedMessage);
224
- }
225
- return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
226
- account: this.accountFromAddress(fromAddress)
227
- }));
228
- }
229
- case "eth_subscribe": {
230
- if (!this.chainTransportSubscribe) {
231
- throw new ProviderRpcError(new Error("chain does not support subscriptions"), {
232
- code: 4200,
233
- shortMessage: "chain does not support subscriptions"
234
- });
235
- }
236
- const res = yield this.chainTransportSubscribe({
237
- params,
238
- onData: (data) => {
239
- this.emit("message", {
240
- type: "eth_subscription",
241
- data
242
- });
243
- }
244
- });
245
- return res.subscriptionId;
246
- }
247
- case "wallet_addEthereumChain": {
248
- if (!this.chains[params[0].chainId]) {
249
- this.chains[params[0].chainId] = params[0];
250
- }
251
- return null;
252
- }
253
- case "wallet_getPermissions": {
254
- return [];
255
- }
256
- case "wallet_requestPermissions": {
257
- return [];
258
- }
259
- case "wallet_switchEthereumChain": {
260
- if (!this.chains[params[0].chainId]) {
261
- const chain = getViemChain(hexToDecimal(params[0].chainId));
262
- const [hexChainId, addEthereumChainParameter] = this.wagmiChainToAddEthereumChainParameters(chain);
263
- this.chains[hexChainId] = addEthereumChainParameter;
264
- this.setCurrentChain(params[0].chainId);
265
- }
266
- if (this.currentHexChainId !== params[0].chainId) {
267
- this.setCurrentChain(params[0].chainId);
268
- }
269
- return null;
270
- }
271
- case "wallet_watchAsset": {
272
- return false;
273
- }
274
- default: {
275
- return this.walletClient.request({
276
- method,
277
- params
278
- });
279
- }
280
- }
281
- });
282
- this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
283
- this.isModalClosed = true;
284
- this.para = opts.para;
285
- this.modalProps = __spreadValues({}, opts);
286
- this.disableModal = !!opts.disableModal;
287
- this.viemChains = opts.chains.reduce((acc, curChain) => {
288
- acc[decimalToHex(`${curChain.id}`)] = curChain;
289
- return acc;
290
- }, {});
291
- this.chains = this.wagmiChainsToAddEthereumChainParameters(opts.chains);
292
- this.transports = opts.transports;
293
- const defaultChainId = this.getStorageChainId() || opts.chainId;
294
- const currentChainId = this.chains[decimalToHex(defaultChainId)] ? defaultChainId : `${opts.chains[0].id}`;
295
- this.setCurrentChain(decimalToHex(currentChainId));
296
- this.emit("connect", { chainId: this.currentHexChainId });
297
- }
298
- get accounts() {
299
- return this.para.getWalletsByType("EVM").map((w) => w.address);
300
- }
301
- getStorageChainId() {
302
- return this.storage.getItem(STORAGE_CHAIN_ID_KEY);
303
- }
304
- setChainId(hexChainId) {
305
- this.currentHexChainId = hexChainId;
306
- this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
307
- }
308
- waitForLogin() {
309
- return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
310
- const startTime = Date.now();
311
- while (Date.now() - startTime < timeoutMs) {
312
- if (yield this.para.isFullyLoggedIn()) {
313
- return true;
314
- }
315
- if (!this.disableModal && this.isModalClosed) {
316
- throw new ProviderRpcError(new Error("user closed modal"), {
317
- code: 4001,
318
- shortMessage: "user closed modal"
319
- });
320
- }
321
- yield new Promise((resolve) => setTimeout(resolve, 2e3));
322
- }
323
- throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
324
- code: 4900,
325
- //provider is disconnected code
326
- shortMessage: "timed out waiting for user to log in"
327
- });
328
- });
329
- }
330
- waitForAccounts(timeoutMs = 5e3) {
331
- return __async(this, null, function* () {
332
- const startTime = Date.now();
333
- while (Date.now() - startTime < timeoutMs) {
334
- const accounts = this.accounts;
335
- if (accounts && accounts.length > 0) {
336
- return accounts;
337
- }
338
- yield new Promise((resolve) => setTimeout(resolve, 500));
339
- }
340
- throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
341
- code: 4900,
342
- //provider is disconnected code
343
- shortMessage: "timed out waiting for accounts to load"
344
- });
345
- });
346
- }
347
- };
348
-
349
101
  // src/paraConnector.ts
350
- import { createConnector } from "wagmi";
351
- var PARA_ID = "para";
352
- var PARA_NAME = "Para";
353
- var PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
354
102
  var paraConnector = (_a) => {
355
103
  var _b = _a, {
356
104
  para,
@@ -361,7 +109,8 @@ var paraConnector = (_a) => {
361
109
  iconOverride,
362
110
  nameOverride,
363
111
  idOverride,
364
- transports
112
+ transports,
113
+ appName
365
114
  } = _b, modalProps = __objRest(_b, [
366
115
  "para",
367
116
  "chains",
@@ -371,38 +120,26 @@ var paraConnector = (_a) => {
371
120
  "iconOverride",
372
121
  "nameOverride",
373
122
  "idOverride",
374
- "transports"
123
+ "transports",
124
+ "appName"
375
125
  ]);
376
- return createConnector((config) => {
377
- const chains = [...config.chains];
378
- const eip1193Provider = new ParaEIP1193Provider(__spreadValues({
379
- para,
380
- chainId: `${chains[0].id}`,
381
- chains,
382
- disableModal,
383
- storageOverride,
384
- transports: transports || config.transports
385
- }, modalProps));
386
- const injectedObj = injected(__spreadValues({
387
- target: {
388
- name: PARA_NAME,
389
- id: idOverride != null ? idOverride : PARA_ID,
390
- provider: eip1193Provider
391
- }
392
- }, options))(config);
393
- return __spreadProps(__spreadValues({}, injectedObj), {
394
- type: idOverride != null ? idOverride : PARA_ID,
395
- name: nameOverride != null ? nameOverride : PARA_NAME,
396
- icon: iconOverride != null ? iconOverride : PARA_ICON,
397
- disconnect: () => __async(void 0, null, function* () {
398
- eip1193Provider.closeModal();
399
- yield injectedObj.disconnect();
400
- para.logout();
401
- })
402
- });
126
+ return createParaConnector({
127
+ para,
128
+ chains: _chains,
129
+ disableModal,
130
+ storageOverride,
131
+ options,
132
+ iconOverride,
133
+ nameOverride,
134
+ idOverride,
135
+ transports,
136
+ appName,
137
+ renderModal: (onClose) => renderModal(para, __spreadProps(__spreadValues({}, modalProps), { appName }), onClose),
138
+ openModal: () => {
139
+ setIsOpen2(true);
140
+ }
403
141
  });
404
142
  };
405
143
  export {
406
- ParaEIP1193Provider,
407
144
  paraConnector
408
145
  };
package/dist/index.js.br CHANGED
Binary file
package/dist/index.js.gz CHANGED
Binary file
@@ -1,23 +1,10 @@
1
- import { Chain } from 'wagmi/chains';
2
- import { InjectedParameters } from 'wagmi/connectors';
3
- import ParaWeb, { ParaModalProps } from '@getpara/react-sdk';
4
- import { Transport } from 'viem';
5
- interface ParaConnectorOpts extends Partial<ParaModalProps> {
6
- /**
7
- * @deprecated Use `chains` in the wagmi config instead.
8
- */
9
- chains?: Chain[];
10
- options: InjectedParameters;
11
- para: ParaWeb;
12
- disableModal?: boolean;
1
+ import { ParaModalProps } from '@getpara/react-sdk';
2
+ import { ParaConnectorOpts as ParaConnectorOptsBase } from '@getpara/wagmi-v2-connector';
3
+ export type ParaModalPropsForInit = Omit<ParaModalProps, 'isOpen' | 'para'> & {
13
4
  appName: string;
14
- idOverride?: string;
15
- storageOverride?: Pick<Storage, 'setItem' | 'getItem'>;
16
- iconOverride?: string;
17
- nameOverride?: string;
18
- transports?: Record<number, Transport>;
19
- }
20
- export declare const paraConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, ...modalProps }: ParaConnectorOpts) => import("wagmi").CreateConnectorFn<unknown, {
5
+ };
6
+ type ParaConnectorOpts = Partial<ParaModalPropsForInit> & ParaConnectorOptsBase;
7
+ export declare const paraConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, appName, ...modalProps }: ParaConnectorOpts) => import("wagmi").CreateConnectorFn<unknown, {
21
8
  type: string;
22
9
  name: string;
23
10
  icon: string;
@@ -98,11 +85,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
98
85
  }, {
99
86
  Method: "eth_getBlockByHash";
100
87
  Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
101
- ReturnType: import("viem").RpcBlock;
88
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
102
89
  }, {
103
90
  Method: "eth_getBlockByNumber";
104
91
  Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
105
- ReturnType: import("viem").RpcBlock;
92
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
106
93
  }, {
107
94
  Method: "eth_getBlockTransactionCountByHash";
108
95
  Parameters: [hash: `0x${string}`];
@@ -176,15 +163,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
176
163
  }, {
177
164
  Method: "eth_getTransactionByBlockHashAndIndex";
178
165
  Parameters: [hash: `0x${string}`, index: `0x${string}`];
179
- ReturnType: import("viem").RpcTransaction;
166
+ ReturnType: import("viem").RpcTransaction<boolean>;
180
167
  }, {
181
168
  Method: "eth_getTransactionByBlockNumberAndIndex";
182
169
  Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
183
- ReturnType: import("viem").RpcTransaction;
170
+ ReturnType: import("viem").RpcTransaction<boolean>;
184
171
  }, {
185
172
  Method: "eth_getTransactionByHash";
186
173
  Parameters: [hash: `0x${string}`];
187
- ReturnType: import("viem").RpcTransaction;
174
+ ReturnType: import("viem").RpcTransaction<boolean>;
188
175
  }, {
189
176
  Method: "eth_getTransactionCount";
190
177
  Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
@@ -362,19 +349,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
362
349
  ReturnType: `0x${string}`;
363
350
  }, {
364
351
  Method: "eth_estimateUserOperationGas";
365
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
366
- ReturnType: import("viem").RpcEstimateUserOperationGasReturnType;
352
+ Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
353
+ ReturnType: import("viem").RpcEstimateUserOperationGasReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
367
354
  }, {
368
355
  Method: "eth_getUserOperationByHash";
369
356
  Parameters: [hash: `0x${string}`];
370
- ReturnType: import("viem").RpcGetUserOperationByHashReturnType;
357
+ ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
371
358
  }, {
372
359
  Method: "eth_getUserOperationReceipt";
373
360
  Parameters: [hash: `0x${string}`];
374
- ReturnType: import("viem").RpcUserOperationReceipt;
361
+ ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
375
362
  }, {
376
363
  Method: "eth_sendUserOperation";
377
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`];
364
+ Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`];
378
365
  ReturnType: `0x${string}`;
379
366
  }, {
380
367
  Method: "eth_supportedEntryPoints";
@@ -382,43 +369,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
382
369
  ReturnType: readonly `0x${string}`[];
383
370
  }, {
384
371
  Method: "pm_getPaymasterStubData";
385
- Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
372
+ Parameters?: [userOperation: {
373
+ nonce: `0x${string}`;
386
374
  callData: `0x${string}`;
387
- callGasLimit: `0x${string}`;
375
+ sender: `0x${string}`;
376
+ maxFeePerGas?: `0x${string}`;
377
+ maxPriorityFeePerGas?: `0x${string}`;
378
+ callGasLimit?: `0x${string}`;
379
+ preVerificationGas?: `0x${string}`;
380
+ verificationGasLimit?: `0x${string}`;
388
381
  initCode?: `0x${string}`;
389
- maxFeePerGas: `0x${string}`;
390
- maxPriorityFeePerGas: `0x${string}`;
382
+ factory?: undefined;
383
+ factoryData?: undefined;
384
+ } | {
391
385
  nonce: `0x${string}`;
392
- paymasterAndData?: `0x${string}`;
393
- preVerificationGas: `0x${string}`;
394
- sender: `0x${string}`;
395
- signature: `0x${string}`;
396
- verificationGasLimit: `0x${string}`;
397
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
398
386
  callData: `0x${string}`;
399
- callGasLimit: `0x${string}`;
387
+ sender: `0x${string}`;
388
+ maxFeePerGas?: `0x${string}`;
389
+ maxPriorityFeePerGas?: `0x${string}`;
390
+ callGasLimit?: `0x${string}`;
400
391
  factory?: `0x${string}`;
401
392
  factoryData?: `0x${string}`;
402
- maxFeePerGas: `0x${string}`;
403
- maxPriorityFeePerGas: `0x${string}`;
404
- nonce: `0x${string}`;
405
- paymaster?: `0x${string}`;
406
- paymasterData?: `0x${string}`;
407
- paymasterPostOpGasLimit?: `0x${string}`;
408
- paymasterVerificationGasLimit?: `0x${string}`;
409
- preVerificationGas: `0x${string}`;
410
- sender: `0x${string}`;
411
- signature: `0x${string}`;
412
- verificationGasLimit: `0x${string}`;
413
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "verificationGasLimit">>, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
414
- ReturnType: import("viem").OneOf<{
393
+ preVerificationGas?: `0x${string}`;
394
+ verificationGasLimit?: `0x${string}`;
395
+ initCode?: undefined;
396
+ }, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
397
+ ReturnType: ({
415
398
  paymasterAndData: `0x${string}`;
399
+ paymaster?: undefined;
400
+ paymasterData?: undefined;
401
+ paymasterPostOpGasLimit?: undefined;
402
+ paymasterVerificationGasLimit?: undefined;
416
403
  } | {
417
404
  paymaster: `0x${string}`;
418
405
  paymasterData: `0x${string}`;
419
406
  paymasterVerificationGasLimit: `0x${string}`;
420
407
  paymasterPostOpGasLimit: `0x${string}`;
421
- }> & {
408
+ paymasterAndData?: undefined;
409
+ }) & {
422
410
  sponsor?: {
423
411
  name: string;
424
412
  icon?: string;
@@ -456,14 +444,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
456
444
  signature: `0x${string}`;
457
445
  verificationGasLimit: `0x${string}`;
458
446
  }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
459
- ReturnType: import("viem").OneOf<{
447
+ ReturnType: {
460
448
  paymasterAndData: `0x${string}`;
449
+ paymaster?: undefined;
450
+ paymasterData?: undefined;
451
+ paymasterPostOpGasLimit?: undefined;
452
+ paymasterVerificationGasLimit?: undefined;
461
453
  } | {
462
454
  paymaster: `0x${string}`;
463
455
  paymasterData: `0x${string}`;
464
456
  paymasterVerificationGasLimit: `0x${string}`;
465
457
  paymasterPostOpGasLimit: `0x${string}`;
466
- }>;
458
+ paymasterAndData?: undefined;
459
+ };
467
460
  }]>;
468
461
  isApexWallet?: true;
469
462
  isAvalanche?: true;
@@ -504,7 +497,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
504
497
  isZerion?: true;
505
498
  providers?: {
506
499
  on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
507
- removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
500
+ removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event, listener: event) => void;
508
501
  request: import("viem").EIP1193RequestFn<[{
509
502
  Method: "web3_clientVersion";
510
503
  Parameters?: undefined;
@@ -564,11 +557,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
564
557
  }, {
565
558
  Method: "eth_getBlockByHash";
566
559
  Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
567
- ReturnType: import("viem").RpcBlock;
560
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
568
561
  }, {
569
562
  Method: "eth_getBlockByNumber";
570
563
  Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
571
- ReturnType: import("viem").RpcBlock;
564
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
572
565
  }, {
573
566
  Method: "eth_getBlockTransactionCountByHash";
574
567
  Parameters: [hash: `0x${string}`];
@@ -642,15 +635,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
642
635
  }, {
643
636
  Method: "eth_getTransactionByBlockHashAndIndex";
644
637
  Parameters: [hash: `0x${string}`, index: `0x${string}`];
645
- ReturnType: import("viem").RpcTransaction;
638
+ ReturnType: import("viem").RpcTransaction<boolean>;
646
639
  }, {
647
640
  Method: "eth_getTransactionByBlockNumberAndIndex";
648
641
  Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
649
- ReturnType: import("viem").RpcTransaction;
642
+ ReturnType: import("viem").RpcTransaction<boolean>;
650
643
  }, {
651
644
  Method: "eth_getTransactionByHash";
652
645
  Parameters: [hash: `0x${string}`];
653
- ReturnType: import("viem").RpcTransaction;
646
+ ReturnType: import("viem").RpcTransaction<boolean>;
654
647
  }, {
655
648
  Method: "eth_getTransactionCount";
656
649
  Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
@@ -828,19 +821,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
828
821
  ReturnType: `0x${string}`;
829
822
  }, {
830
823
  Method: "eth_estimateUserOperationGas";
831
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
832
- ReturnType: import("viem").RpcEstimateUserOperationGasReturnType;
824
+ Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
825
+ ReturnType: import("viem").RpcEstimateUserOperationGasReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
833
826
  }, {
834
827
  Method: "eth_getUserOperationByHash";
835
828
  Parameters: [hash: `0x${string}`];
836
- ReturnType: import("viem").RpcGetUserOperationByHashReturnType;
829
+ ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
837
830
  }, {
838
831
  Method: "eth_getUserOperationReceipt";
839
832
  Parameters: [hash: `0x${string}`];
840
- ReturnType: import("viem").RpcUserOperationReceipt;
833
+ ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
841
834
  }, {
842
835
  Method: "eth_sendUserOperation";
843
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`];
836
+ Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`];
844
837
  ReturnType: `0x${string}`;
845
838
  }, {
846
839
  Method: "eth_supportedEntryPoints";
@@ -848,43 +841,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
848
841
  ReturnType: readonly `0x${string}`[];
849
842
  }, {
850
843
  Method: "pm_getPaymasterStubData";
851
- Parameters?: [userOperation: import("viem").OneOf<import("wagmi/chains").PartialBy<Pick<{
844
+ Parameters?: [userOperation: {
845
+ nonce: `0x${string}`;
852
846
  callData: `0x${string}`;
853
- callGasLimit: `0x${string}`;
847
+ sender: `0x${string}`;
848
+ maxFeePerGas?: `0x${string}`;
849
+ maxPriorityFeePerGas?: `0x${string}`;
850
+ callGasLimit?: `0x${string}`;
851
+ preVerificationGas?: `0x${string}`;
852
+ verificationGasLimit?: `0x${string}`;
854
853
  initCode?: `0x${string}`;
855
- maxFeePerGas: `0x${string}`;
856
- maxPriorityFeePerGas: `0x${string}`;
854
+ factory?: undefined;
855
+ factoryData?: undefined;
856
+ } | {
857
857
  nonce: `0x${string}`;
858
- paymasterAndData?: `0x${string}`;
859
- preVerificationGas: `0x${string}`;
860
- sender: `0x${string}`;
861
- signature: `0x${string}`;
862
- verificationGasLimit: `0x${string}`;
863
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("wagmi/chains").PartialBy<Pick<{
864
858
  callData: `0x${string}`;
865
- callGasLimit: `0x${string}`;
859
+ sender: `0x${string}`;
860
+ maxFeePerGas?: `0x${string}`;
861
+ maxPriorityFeePerGas?: `0x${string}`;
862
+ callGasLimit?: `0x${string}`;
866
863
  factory?: `0x${string}`;
867
864
  factoryData?: `0x${string}`;
868
- maxFeePerGas: `0x${string}`;
869
- maxPriorityFeePerGas: `0x${string}`;
870
- nonce: `0x${string}`;
871
- paymaster?: `0x${string}`;
872
- paymasterData?: `0x${string}`;
873
- paymasterPostOpGasLimit?: `0x${string}`;
874
- paymasterVerificationGasLimit?: `0x${string}`;
875
- preVerificationGas: `0x${string}`;
876
- sender: `0x${string}`;
877
- signature: `0x${string}`;
878
- verificationGasLimit: `0x${string}`;
879
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "verificationGasLimit">>, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
880
- ReturnType: import("viem").OneOf<{
865
+ preVerificationGas?: `0x${string}`;
866
+ verificationGasLimit?: `0x${string}`;
867
+ initCode?: undefined;
868
+ }, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
869
+ ReturnType: ({
881
870
  paymasterAndData: `0x${string}`;
871
+ paymaster?: undefined;
872
+ paymasterData?: undefined;
873
+ paymasterPostOpGasLimit?: undefined;
874
+ paymasterVerificationGasLimit?: undefined;
882
875
  } | {
883
876
  paymaster: `0x${string}`;
884
877
  paymasterData: `0x${string}`;
885
878
  paymasterVerificationGasLimit: `0x${string}`;
886
879
  paymasterPostOpGasLimit: `0x${string}`;
887
- }> & {
880
+ paymasterAndData?: undefined;
881
+ }) & {
888
882
  sponsor?: {
889
883
  name: string;
890
884
  icon?: string;
@@ -922,14 +916,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
922
916
  signature: `0x${string}`;
923
917
  verificationGasLimit: `0x${string}`;
924
918
  }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
925
- ReturnType: import("viem").OneOf<{
919
+ ReturnType: {
926
920
  paymasterAndData: `0x${string}`;
921
+ paymaster?: undefined;
922
+ paymasterData?: undefined;
923
+ paymasterPostOpGasLimit?: undefined;
924
+ paymasterVerificationGasLimit?: undefined;
927
925
  } | {
928
926
  paymaster: `0x${string}`;
929
927
  paymasterData: `0x${string}`;
930
928
  paymasterVerificationGasLimit: `0x${string}`;
931
929
  paymasterPostOpGasLimit: `0x${string}`;
932
- }>;
930
+ paymasterAndData?: undefined;
931
+ };
933
932
  }]>;
934
933
  isApexWallet?: true;
935
934
  isAvalanche?: true;
@@ -998,7 +997,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
998
997
  switchChain?: (parameters: {
999
998
  addEthereumChainParameter?: import("@wagmi/core/internal").ExactPartial<import("@wagmi/core/internal").Omit<import("viem").AddEthereumChainParameter, "chainId">>;
1000
999
  chainId: number;
1001
- }) => Promise<Chain>;
1000
+ }) => Promise<import("viem").Chain>;
1002
1001
  onAccountsChanged: (accounts: string[]) => void;
1003
1002
  onChainChanged: (chainId: string) => void;
1004
1003
  onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
package/package.json CHANGED
@@ -1,32 +1,28 @@
1
1
  {
2
2
  "name": "@getpara/wagmi-v2-integration",
3
- "version": "1.7.1",
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/react-sdk": "1.7.1",
10
- "@getpara/viem-v2-integration": "1.7.1"
9
+ "@getpara/react-sdk": "2.0.0-dev.0",
10
+ "@getpara/wagmi-v2-connector": "2.0.0-dev.0"
11
11
  },
12
12
  "scripts": {
13
13
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
14
14
  "typegen": "tsc --emitDeclarationOnly"
15
15
  },
16
16
  "devDependencies": {
17
- "typescript": "5.1.6",
18
- "viem": "2.x",
19
- "wagmi": "2.x"
17
+ "typescript": "5.1.6"
20
18
  },
21
19
  "peerDependencies": {
22
20
  "react": "*",
23
- "react-dom": "*",
24
- "viem": "2.x",
25
- "wagmi": "2.x"
21
+ "react-dom": "*"
26
22
  },
27
23
  "files": [
28
24
  "dist",
29
25
  "package.json"
30
26
  ],
31
- "gitHead": "767395af96d4a724946a092de760e9137a73369a"
27
+ "gitHead": "f94ef031ef0e1894f5f0800e55f6ca2904641780"
32
28
  }
@@ -1,40 +0,0 @@
1
- import { EIP1474Methods, EIP1193Provider, EIP1193RequestFn, Transport } from 'viem';
2
- import { EventEmitter } from 'eventemitter3';
3
- import { Chain } from 'wagmi/chains';
4
- import ParaWeb, { ParaModalProps } from '@getpara/react-sdk';
5
- export type ParaModalPropsForInit = Omit<ParaModalProps, 'isOpen' | 'para'>;
6
- interface ParaEIP1193ProviderOpts extends Partial<ParaModalPropsForInit> {
7
- para: ParaWeb;
8
- chainId: string;
9
- chains: Chain[];
10
- disableModal?: boolean;
11
- storageOverride?: Pick<Storage, 'setItem' | 'getItem'>;
12
- transports?: Record<number, Transport>;
13
- }
14
- export declare class ParaEIP1193Provider extends EventEmitter implements EIP1193Provider {
15
- private currentHexChainId;
16
- private walletClient;
17
- private chainTransportSubscribe?;
18
- private chains;
19
- private viemChains;
20
- private para;
21
- private disableModal;
22
- private storage;
23
- private modalProps;
24
- private isModalClosed;
25
- private transports?;
26
- constructor(opts: ParaEIP1193ProviderOpts);
27
- private get accounts();
28
- private getStorageChainId;
29
- private setChainId;
30
- private getRpcUrlsFromViemChain;
31
- private wagmiChainToAddEthereumChainParameters;
32
- private wagmiChainsToAddEthereumChainParameters;
33
- private accountFromAddress;
34
- private setCurrentChain;
35
- closeModal: () => void;
36
- private waitForLogin;
37
- private waitForAccounts;
38
- request: EIP1193RequestFn<EIP1474Methods>;
39
- }
40
- export {};
package/dist/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": false
4
- }