@getpara/wagmi-v2-integration 1.8.0 → 2.0.0-alpha.3

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
@@ -1,3 +1,145 @@
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 __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
53
+
54
+ // src/paraConnector.ts
55
+ import { setIsOpen as setIsOpen2 } from "@getpara/react-sdk";
56
+ import { createParaConnector } from "@getpara/wagmi-v2-connector";
57
+
58
+ // src/connectorModal.tsx
59
+ import { ParaProvider, setIsOpen } from "@getpara/react-sdk";
60
+ import { QueryClient } from "@tanstack/react-query";
61
+ import { QueryClientProvider } from "@tanstack/react-query";
62
+ import { jsx } from "react/jsx-runtime";
63
+ var queryClient = new QueryClient();
64
+ var Root;
65
+ function renderModal(para, modalProps, onCloseArg) {
66
+ const existingContainer = document.getElementById("para-modal");
67
+ const container = existingContainer != null ? existingContainer : document.createElement("div");
68
+ container.id = "para-modal";
69
+ if (!existingContainer) {
70
+ document.body.appendChild(container);
71
+ }
72
+ const onClose = () => {
73
+ onCloseArg();
74
+ modalProps.onClose && modalProps.onClose();
75
+ setIsOpen(false);
76
+ };
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
+ try {
88
+ const client = yield import("react-dom/client");
89
+ if (!Root) {
90
+ Root = client.createRoot(container);
91
+ }
92
+ Root.render(Modal);
93
+ } catch (e) {
94
+ const ReactDOM = yield import("react-dom");
95
+ ReactDOM.render(Modal, container);
96
+ }
97
+ });
98
+ render();
99
+ }
100
+
101
+ // src/paraConnector.ts
102
+ var paraConnector = (_a) => {
103
+ var _b = _a, {
104
+ para,
105
+ chains: _chains,
106
+ disableModal,
107
+ storageOverride,
108
+ options,
109
+ iconOverride,
110
+ nameOverride,
111
+ idOverride,
112
+ transports,
113
+ appName
114
+ } = _b, modalProps = __objRest(_b, [
115
+ "para",
116
+ "chains",
117
+ "disableModal",
118
+ "storageOverride",
119
+ "options",
120
+ "iconOverride",
121
+ "nameOverride",
122
+ "idOverride",
123
+ "transports",
124
+ "appName"
125
+ ]);
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
+ }
141
+ });
142
+ };
143
+ export {
144
+ paraConnector
145
+ };
Binary file
Binary file
@@ -1,39 +1,15 @@
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) => (config: {
21
- chains: readonly [Chain, ...Chain[]];
22
- emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
23
- storage?: {
24
- key: string;
25
- 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>;
26
- 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>;
27
- removeItem: (key: string) => void | Promise<void>;
28
- };
29
- transports?: Record<number, import("wagmi").Transport>;
30
- }) => {
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, {
31
8
  type: string;
32
9
  name: string;
33
10
  icon: string;
34
11
  disconnect: () => Promise<void>;
35
12
  id: string;
36
- rdns?: string | readonly string[];
37
13
  supportsSimulation?: boolean;
38
14
  setup?: () => Promise<void>;
39
15
  connect: (parameters?: {
@@ -48,8 +24,8 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
48
24
  getProvider: (parameters?: {
49
25
  chainId?: number;
50
26
  }) => Promise<{
51
- on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
52
- removeListener: <event_1 extends keyof import("viem").EIP1193EventMap>(event: event_1, listener: import("viem").EIP1193EventMap[event_1]) => void;
27
+ on: <TEvent extends keyof import("viem").EIP1193EventMap>(event: TEvent, listener: import("viem").EIP1193EventMap[TEvent]) => void;
28
+ removeListener: <TEvent_1 extends keyof import("viem").EIP1193EventMap>(event: TEvent_1, listener: import("viem").EIP1193EventMap[TEvent_1]) => void;
53
29
  request: import("viem").EIP1193RequestFn<[{
54
30
  Method: "web3_clientVersion";
55
31
  Parameters?: undefined;
@@ -82,13 +58,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
82
58
  Method: "eth_call";
83
59
  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];
84
60
  ReturnType: `0x${string}`;
85
- }, {
86
- Method: "eth_createAccessList";
87
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
88
- ReturnType: {
89
- accessList: import("viem").AccessList;
90
- gasUsed: `0x${string}`;
91
- };
92
61
  }, {
93
62
  Method: "eth_chainId";
94
63
  Parameters?: undefined;
@@ -116,11 +85,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
116
85
  }, {
117
86
  Method: "eth_getBlockByHash";
118
87
  Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
119
- ReturnType: import("viem").RpcBlock;
88
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
120
89
  }, {
121
90
  Method: "eth_getBlockByNumber";
122
91
  Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
123
- ReturnType: import("viem").RpcBlock;
92
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
124
93
  }, {
125
94
  Method: "eth_getBlockTransactionCountByHash";
126
95
  Parameters: [hash: `0x${string}`];
@@ -194,15 +163,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
194
163
  }, {
195
164
  Method: "eth_getTransactionByBlockHashAndIndex";
196
165
  Parameters: [hash: `0x${string}`, index: `0x${string}`];
197
- ReturnType: import("viem").RpcTransaction;
166
+ ReturnType: import("viem").RpcTransaction<boolean>;
198
167
  }, {
199
168
  Method: "eth_getTransactionByBlockNumberAndIndex";
200
169
  Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
201
- ReturnType: import("viem").RpcTransaction;
170
+ ReturnType: import("viem").RpcTransaction<boolean>;
202
171
  }, {
203
172
  Method: "eth_getTransactionByHash";
204
173
  Parameters: [hash: `0x${string}`];
205
- ReturnType: import("viem").RpcTransaction;
174
+ ReturnType: import("viem").RpcTransaction<boolean>;
206
175
  }, {
207
176
  Method: "eth_getTransactionCount";
208
177
  Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
@@ -256,40 +225,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
256
225
  Method: "eth_sendRawTransaction";
257
226
  Parameters: [signedTransaction: `0x${string}`];
258
227
  ReturnType: `0x${string}`;
259
- }, {
260
- Method: "eth_simulateV1";
261
- Parameters: [{
262
- blockStateCalls: readonly {
263
- blockOverrides?: import("viem").RpcBlockOverrides;
264
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
265
- stateOverrides?: import("viem").RpcStateOverride;
266
- }[];
267
- returnFullTransactions?: boolean;
268
- traceTransfers?: boolean;
269
- validation?: boolean;
270
- }, `0x${string}` | import("viem").BlockTag];
271
- ReturnType: readonly (import("viem").RpcBlock & {
272
- calls: readonly {
273
- error?: {
274
- data?: `0x${string}`;
275
- code: number;
276
- message: string;
277
- };
278
- logs?: readonly {
279
- address: `0x${string}`;
280
- blockHash: `0x${string}`;
281
- blockNumber: `0x${string}`;
282
- data: `0x${string}`;
283
- logIndex: `0x${string}`;
284
- transactionHash: `0x${string}`;
285
- transactionIndex: `0x${string}`;
286
- removed: boolean;
287
- }[];
288
- gasUsed: `0x${string}`;
289
- returnData: `0x${string}`;
290
- status: `0x${string}`;
291
- }[];
292
- })[];
293
228
  }, {
294
229
  Method: "eth_uninstallFilter";
295
230
  Parameters: [filterId: `0x${string}`];
@@ -394,10 +329,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
394
329
  Method: "wallet_sendCalls";
395
330
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
396
331
  ReturnType: string;
397
- }, {
398
- Method: "wallet_sendTransaction";
399
- Parameters: [transaction: import("viem").RpcTransactionRequest];
400
- ReturnType: `0x${string}`;
401
332
  }, {
402
333
  Method: "wallet_showCallsStatus";
403
334
  Parameters?: [string];
@@ -418,19 +349,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
418
349
  ReturnType: `0x${string}`;
419
350
  }, {
420
351
  Method: "eth_estimateUserOperationGas";
421
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
422
- 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>;
423
354
  }, {
424
355
  Method: "eth_getUserOperationByHash";
425
356
  Parameters: [hash: `0x${string}`];
426
- ReturnType: import("viem").RpcGetUserOperationByHashReturnType;
357
+ ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
427
358
  }, {
428
359
  Method: "eth_getUserOperationReceipt";
429
360
  Parameters: [hash: `0x${string}`];
430
- ReturnType: import("viem").RpcUserOperationReceipt;
361
+ ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
431
362
  }, {
432
363
  Method: "eth_sendUserOperation";
433
- 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}`];
434
365
  ReturnType: `0x${string}`;
435
366
  }, {
436
367
  Method: "eth_supportedEntryPoints";
@@ -438,43 +369,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
438
369
  ReturnType: readonly `0x${string}`[];
439
370
  }, {
440
371
  Method: "pm_getPaymasterStubData";
441
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
372
+ Parameters?: [userOperation: {
373
+ nonce: `0x${string}`;
442
374
  callData: `0x${string}`;
443
- 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}`;
444
381
  initCode?: `0x${string}`;
445
- maxFeePerGas: `0x${string}`;
446
- maxPriorityFeePerGas: `0x${string}`;
382
+ factory?: undefined;
383
+ factoryData?: undefined;
384
+ } | {
447
385
  nonce: `0x${string}`;
448
- paymasterAndData?: `0x${string}`;
449
- preVerificationGas: `0x${string}`;
450
- sender: `0x${string}`;
451
- signature: `0x${string}`;
452
- verificationGasLimit: `0x${string}`;
453
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
454
386
  callData: `0x${string}`;
455
- callGasLimit: `0x${string}`;
387
+ sender: `0x${string}`;
388
+ maxFeePerGas?: `0x${string}`;
389
+ maxPriorityFeePerGas?: `0x${string}`;
390
+ callGasLimit?: `0x${string}`;
456
391
  factory?: `0x${string}`;
457
392
  factoryData?: `0x${string}`;
458
- maxFeePerGas: `0x${string}`;
459
- maxPriorityFeePerGas: `0x${string}`;
460
- nonce: `0x${string}`;
461
- paymaster?: `0x${string}`;
462
- paymasterData?: `0x${string}`;
463
- paymasterPostOpGasLimit?: `0x${string}`;
464
- paymasterVerificationGasLimit?: `0x${string}`;
465
- preVerificationGas: `0x${string}`;
466
- sender: `0x${string}`;
467
- signature: `0x${string}`;
468
- verificationGasLimit: `0x${string}`;
469
- }, "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];
470
- 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: ({
471
398
  paymasterAndData: `0x${string}`;
399
+ paymaster?: undefined;
400
+ paymasterData?: undefined;
401
+ paymasterPostOpGasLimit?: undefined;
402
+ paymasterVerificationGasLimit?: undefined;
472
403
  } | {
473
404
  paymaster: `0x${string}`;
474
405
  paymasterData: `0x${string}`;
475
406
  paymasterVerificationGasLimit: `0x${string}`;
476
407
  paymasterPostOpGasLimit: `0x${string}`;
477
- }> & {
408
+ paymasterAndData?: undefined;
409
+ }) & {
478
410
  sponsor?: {
479
411
  name: string;
480
412
  icon?: string;
@@ -512,14 +444,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
512
444
  signature: `0x${string}`;
513
445
  verificationGasLimit: `0x${string}`;
514
446
  }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
515
- ReturnType: import("viem").OneOf<{
447
+ ReturnType: {
516
448
  paymasterAndData: `0x${string}`;
449
+ paymaster?: undefined;
450
+ paymasterData?: undefined;
451
+ paymasterPostOpGasLimit?: undefined;
452
+ paymasterVerificationGasLimit?: undefined;
517
453
  } | {
518
454
  paymaster: `0x${string}`;
519
455
  paymasterData: `0x${string}`;
520
456
  paymasterVerificationGasLimit: `0x${string}`;
521
457
  paymasterPostOpGasLimit: `0x${string}`;
522
- }>;
458
+ paymasterAndData?: undefined;
459
+ };
523
460
  }]>;
524
461
  isApexWallet?: true;
525
462
  isAvalanche?: true;
@@ -556,12 +493,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
556
493
  isTokenary?: true;
557
494
  isTrust?: true;
558
495
  isTrustWallet?: true;
559
- isUniswapWallet?: true;
560
496
  isXDEFI?: true;
561
497
  isZerion?: true;
562
498
  providers?: {
563
- on: <event_2 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
564
- removeListener: <event_3 extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
499
+ on: <event 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;
565
501
  request: import("viem").EIP1193RequestFn<[{
566
502
  Method: "web3_clientVersion";
567
503
  Parameters?: undefined;
@@ -594,13 +530,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
594
530
  Method: "eth_call";
595
531
  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];
596
532
  ReturnType: `0x${string}`;
597
- }, {
598
- Method: "eth_createAccessList";
599
- Parameters: [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>] | [transaction: import("viem").ExactPartial<import("viem").RpcTransactionRequest>, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
600
- ReturnType: {
601
- accessList: import("viem").AccessList;
602
- gasUsed: `0x${string}`;
603
- };
604
533
  }, {
605
534
  Method: "eth_chainId";
606
535
  Parameters?: undefined;
@@ -628,11 +557,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
628
557
  }, {
629
558
  Method: "eth_getBlockByHash";
630
559
  Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
631
- ReturnType: import("viem").RpcBlock;
560
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
632
561
  }, {
633
562
  Method: "eth_getBlockByNumber";
634
563
  Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
635
- ReturnType: import("viem").RpcBlock;
564
+ ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
636
565
  }, {
637
566
  Method: "eth_getBlockTransactionCountByHash";
638
567
  Parameters: [hash: `0x${string}`];
@@ -706,15 +635,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
706
635
  }, {
707
636
  Method: "eth_getTransactionByBlockHashAndIndex";
708
637
  Parameters: [hash: `0x${string}`, index: `0x${string}`];
709
- ReturnType: import("viem").RpcTransaction;
638
+ ReturnType: import("viem").RpcTransaction<boolean>;
710
639
  }, {
711
640
  Method: "eth_getTransactionByBlockNumberAndIndex";
712
641
  Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
713
- ReturnType: import("viem").RpcTransaction;
642
+ ReturnType: import("viem").RpcTransaction<boolean>;
714
643
  }, {
715
644
  Method: "eth_getTransactionByHash";
716
645
  Parameters: [hash: `0x${string}`];
717
- ReturnType: import("viem").RpcTransaction;
646
+ ReturnType: import("viem").RpcTransaction<boolean>;
718
647
  }, {
719
648
  Method: "eth_getTransactionCount";
720
649
  Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
@@ -768,40 +697,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
768
697
  Method: "eth_sendRawTransaction";
769
698
  Parameters: [signedTransaction: `0x${string}`];
770
699
  ReturnType: `0x${string}`;
771
- }, {
772
- Method: "eth_simulateV1";
773
- Parameters: [{
774
- blockStateCalls: readonly {
775
- blockOverrides?: import("viem").RpcBlockOverrides;
776
- calls?: readonly import("viem").ExactPartial<import("viem").RpcTransactionRequest>[];
777
- stateOverrides?: import("viem").RpcStateOverride;
778
- }[];
779
- returnFullTransactions?: boolean;
780
- traceTransfers?: boolean;
781
- validation?: boolean;
782
- }, `0x${string}` | import("viem").BlockTag];
783
- ReturnType: readonly (import("viem").RpcBlock & {
784
- calls: readonly {
785
- error?: {
786
- data?: `0x${string}`;
787
- code: number;
788
- message: string;
789
- };
790
- logs?: readonly {
791
- address: `0x${string}`;
792
- blockHash: `0x${string}`;
793
- blockNumber: `0x${string}`;
794
- data: `0x${string}`;
795
- logIndex: `0x${string}`;
796
- transactionHash: `0x${string}`;
797
- transactionIndex: `0x${string}`;
798
- removed: boolean;
799
- }[];
800
- gasUsed: `0x${string}`;
801
- returnData: `0x${string}`;
802
- status: `0x${string}`;
803
- }[];
804
- })[];
805
700
  }, {
806
701
  Method: "eth_uninstallFilter";
807
702
  Parameters: [filterId: `0x${string}`];
@@ -906,10 +801,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
906
801
  Method: "wallet_sendCalls";
907
802
  Parameters?: import("viem").WalletSendCallsParameters<import("viem").WalletCapabilities, `0x${string}`, `0x${string}`>;
908
803
  ReturnType: string;
909
- }, {
910
- Method: "wallet_sendTransaction";
911
- Parameters: [transaction: import("viem").RpcTransactionRequest];
912
- ReturnType: `0x${string}`;
913
804
  }, {
914
805
  Method: "wallet_showCallsStatus";
915
806
  Parameters?: [string];
@@ -930,19 +821,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
930
821
  ReturnType: `0x${string}`;
931
822
  }, {
932
823
  Method: "eth_estimateUserOperationGas";
933
- Parameters: [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`] | [userOperation: import("viem").RpcUserOperation, entrypoint: `0x${string}`, stateOverrideSet: import("viem").RpcStateOverride];
934
- 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>;
935
826
  }, {
936
827
  Method: "eth_getUserOperationByHash";
937
828
  Parameters: [hash: `0x${string}`];
938
- ReturnType: import("viem").RpcGetUserOperationByHashReturnType;
829
+ ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
939
830
  }, {
940
831
  Method: "eth_getUserOperationReceipt";
941
832
  Parameters: [hash: `0x${string}`];
942
- ReturnType: import("viem").RpcUserOperationReceipt;
833
+ ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
943
834
  }, {
944
835
  Method: "eth_sendUserOperation";
945
- 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}`];
946
837
  ReturnType: `0x${string}`;
947
838
  }, {
948
839
  Method: "eth_supportedEntryPoints";
@@ -950,43 +841,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
950
841
  ReturnType: readonly `0x${string}`[];
951
842
  }, {
952
843
  Method: "pm_getPaymasterStubData";
953
- Parameters?: [userOperation: import("viem").OneOf<import("viem").PartialBy<Pick<{
844
+ Parameters?: [userOperation: {
845
+ nonce: `0x${string}`;
954
846
  callData: `0x${string}`;
955
- 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}`;
956
853
  initCode?: `0x${string}`;
957
- maxFeePerGas: `0x${string}`;
958
- maxPriorityFeePerGas: `0x${string}`;
854
+ factory?: undefined;
855
+ factoryData?: undefined;
856
+ } | {
959
857
  nonce: `0x${string}`;
960
- paymasterAndData?: `0x${string}`;
961
- preVerificationGas: `0x${string}`;
962
- sender: `0x${string}`;
963
- signature: `0x${string}`;
964
- verificationGasLimit: `0x${string}`;
965
- }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "preVerificationGas" | "sender" | "verificationGasLimit" | "initCode">, "maxFeePerGas" | "maxPriorityFeePerGas" | "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "initCode"> | import("viem").PartialBy<Pick<{
966
858
  callData: `0x${string}`;
967
- callGasLimit: `0x${string}`;
859
+ sender: `0x${string}`;
860
+ maxFeePerGas?: `0x${string}`;
861
+ maxPriorityFeePerGas?: `0x${string}`;
862
+ callGasLimit?: `0x${string}`;
968
863
  factory?: `0x${string}`;
969
864
  factoryData?: `0x${string}`;
970
- maxFeePerGas: `0x${string}`;
971
- maxPriorityFeePerGas: `0x${string}`;
972
- nonce: `0x${string}`;
973
- paymaster?: `0x${string}`;
974
- paymasterData?: `0x${string}`;
975
- paymasterPostOpGasLimit?: `0x${string}`;
976
- paymasterVerificationGasLimit?: `0x${string}`;
977
- preVerificationGas: `0x${string}`;
978
- sender: `0x${string}`;
979
- signature: `0x${string}`;
980
- verificationGasLimit: `0x${string}`;
981
- }, "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];
982
- 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: ({
983
870
  paymasterAndData: `0x${string}`;
871
+ paymaster?: undefined;
872
+ paymasterData?: undefined;
873
+ paymasterPostOpGasLimit?: undefined;
874
+ paymasterVerificationGasLimit?: undefined;
984
875
  } | {
985
876
  paymaster: `0x${string}`;
986
877
  paymasterData: `0x${string}`;
987
878
  paymasterVerificationGasLimit: `0x${string}`;
988
879
  paymasterPostOpGasLimit: `0x${string}`;
989
- }> & {
880
+ paymasterAndData?: undefined;
881
+ }) & {
990
882
  sponsor?: {
991
883
  name: string;
992
884
  icon?: string;
@@ -1024,14 +916,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
1024
916
  signature: `0x${string}`;
1025
917
  verificationGasLimit: `0x${string}`;
1026
918
  }, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
1027
- ReturnType: import("viem").OneOf<{
919
+ ReturnType: {
1028
920
  paymasterAndData: `0x${string}`;
921
+ paymaster?: undefined;
922
+ paymasterData?: undefined;
923
+ paymasterPostOpGasLimit?: undefined;
924
+ paymasterVerificationGasLimit?: undefined;
1029
925
  } | {
1030
926
  paymaster: `0x${string}`;
1031
927
  paymasterData: `0x${string}`;
1032
928
  paymasterVerificationGasLimit: `0x${string}`;
1033
929
  paymasterPostOpGasLimit: `0x${string}`;
1034
- }>;
930
+ paymasterAndData?: undefined;
931
+ };
1035
932
  }]>;
1036
933
  isApexWallet?: true;
1037
934
  isAvalanche?: true;
@@ -1068,7 +965,6 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
1068
965
  isTokenary?: true;
1069
966
  isTrust?: true;
1070
967
  isTrustWallet?: true;
1071
- isUniswapWallet?: true;
1072
968
  isXDEFI?: true;
1073
969
  isZerion?: true;
1074
970
  providers?: any[];
@@ -1101,11 +997,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
1101
997
  switchChain?: (parameters: {
1102
998
  addEthereumChainParameter?: import("@wagmi/core/internal").ExactPartial<import("@wagmi/core/internal").Omit<import("viem").AddEthereumChainParameter, "chainId">>;
1103
999
  chainId: number;
1104
- }) => Promise<Chain>;
1000
+ }) => Promise<import("viem").Chain>;
1105
1001
  onAccountsChanged: (accounts: string[]) => void;
1106
1002
  onChainChanged: (chainId: string) => void;
1107
1003
  onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
1108
1004
  onDisconnect: (error?: Error) => void;
1109
1005
  onMessage?: (message: import("viem").ProviderMessage) => void;
1110
- };
1006
+ }, Record<string, unknown>>;
1111
1007
  export {};
package/package.json CHANGED
@@ -1,32 +1,28 @@
1
1
  {
2
2
  "name": "@getpara/wagmi-v2-integration",
3
- "version": "1.8.0",
3
+ "version": "2.0.0-alpha.3",
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.8.0",
10
- "@getpara/viem-v2-integration": "1.8.0"
9
+ "@getpara/react-sdk": "2.0.0-alpha.3",
10
+ "@getpara/wagmi-v2-connector": "2.0.0-alpha.3"
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.23.5",
19
- "wagmi": "^2.14.12"
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": "ef96e79558695ccbe148d25a8e3611c4596d1954"
27
+ "gitHead": "77a1e04b06258842ca9c81e3db2a2b0092517659"
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 {};
@@ -1,269 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "./chunk-MMUBH76A.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/react-sdk";
18
- import { renderModal } from "./connectorModal.js";
19
- const STORAGE_CHAIN_ID_KEY = "@CAPSULE/chainId";
20
- const TEN_MINUTES_MS = 6e5;
21
- const serverSessionStorageStub = {
22
- setItem: () => {
23
- },
24
- getItem: () => null
25
- };
26
- class ParaEIP1193Provider extends EventEmitter {
27
- constructor(opts) {
28
- super();
29
- this.getRpcUrlsFromViemChain = (chain) => {
30
- return extractRpcUrls({ chain, transports: this.transports });
31
- };
32
- this.wagmiChainToAddEthereumChainParameters = (chain) => {
33
- const hexChainId = decimalToHex(`${chain.id}`);
34
- return [
35
- hexChainId,
36
- {
37
- chainId: hexChainId,
38
- chainName: chain.name,
39
- nativeCurrency: chain.nativeCurrency,
40
- rpcUrls: this.getRpcUrlsFromViemChain(chain)
41
- }
42
- ];
43
- };
44
- this.wagmiChainsToAddEthereumChainParameters = (chains) => {
45
- return Object.fromEntries(chains.map(this.wagmiChainToAddEthereumChainParameters));
46
- };
47
- this.accountFromAddress = (address) => {
48
- return createParaAccount(this.para, address);
49
- };
50
- this.setCurrentChain = (chainId) => {
51
- const chain = this.chains[chainId];
52
- this.setChainId(chainId);
53
- const viemChain = this.viemChains[chainId] || getViemChain(hexToDecimal(chainId));
54
- const rpcUrls = this.getRpcUrlsFromViemChain(viemChain);
55
- let transport;
56
- if (this.transports[viemChain.id]) {
57
- transport = this.transports[viemChain.id];
58
- } else if (rpcUrls[0].startsWith("ws")) {
59
- transport = webSocket(chain.rpcUrls[0]);
60
- } else {
61
- transport = http(rpcUrls[0]);
62
- this.chainTransportSubscribe = void 0;
63
- }
64
- const chainTransport = transport({
65
- chain: viemChain
66
- });
67
- if (chainTransport.config.type === "ws") {
68
- this.chainTransportSubscribe = chainTransport.value.subscribe;
69
- }
70
- this.walletClient = createParaViemClient(
71
- this.para,
72
- {
73
- chain: viemChain,
74
- transport
75
- // @ts-ignore
76
- },
77
- { noAccount: true }
78
- ).extend(publicActions);
79
- this.emit("chainChanged", this.currentHexChainId);
80
- };
81
- this.closeModal = () => {
82
- this.isModalClosed = true;
83
- };
84
- this.request = (args) => __async(this, null, function* () {
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
- if (!this.disableModal) {
102
- this.isModalClosed = false;
103
- renderModal(this.para, this.modalProps, () => {
104
- this.isModalClosed = true;
105
- });
106
- }
107
- yield this.waitForLogin();
108
- try {
109
- const accounts = yield this.waitForAccounts();
110
- this.emit("accountsChanged", accounts);
111
- return accounts;
112
- } catch (error) {
113
- throw new ProviderRpcError(new Error("accounts not available after login"), {
114
- code: 4001,
115
- shortMessage: "accounts not available after login"
116
- });
117
- }
118
- }
119
- case "eth_sendTransaction": {
120
- const fromAddress = params[0].from;
121
- return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
122
- chain: void 0,
123
- // uses the chain from the wallet client
124
- account: this.accountFromAddress(fromAddress)
125
- }));
126
- }
127
- case "eth_sign":
128
- case "personal_sign": {
129
- return this.walletClient.signMessage({
130
- message: { raw: params[0] },
131
- account: this.accountFromAddress(params[1])
132
- });
133
- }
134
- case "eth_signTransaction": {
135
- const fromAddress = params[0].from;
136
- return this.accountFromAddress(fromAddress).signTransaction(formatTransaction(params[0]));
137
- }
138
- case "eth_signTypedData_v4": {
139
- const fromAddress = params[0];
140
- let typedMessage = params[1];
141
- if (typeof typedMessage === "string") {
142
- typedMessage = JSON.parse(typedMessage);
143
- }
144
- return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
145
- account: this.accountFromAddress(fromAddress)
146
- }));
147
- }
148
- case "eth_subscribe": {
149
- if (!this.chainTransportSubscribe) {
150
- throw new ProviderRpcError(new Error("chain does not support subscriptions"), {
151
- code: 4200,
152
- shortMessage: "chain does not support subscriptions"
153
- });
154
- }
155
- const res = yield this.chainTransportSubscribe({
156
- params,
157
- onData: (data) => {
158
- this.emit("message", {
159
- type: "eth_subscription",
160
- data
161
- });
162
- }
163
- });
164
- return res.subscriptionId;
165
- }
166
- case "wallet_addEthereumChain": {
167
- if (!this.chains[params[0].chainId]) {
168
- this.chains[params[0].chainId] = params[0];
169
- }
170
- return null;
171
- }
172
- case "wallet_getPermissions": {
173
- return [];
174
- }
175
- case "wallet_requestPermissions": {
176
- return [];
177
- }
178
- case "wallet_switchEthereumChain": {
179
- if (!this.chains[params[0].chainId]) {
180
- const chain = getViemChain(hexToDecimal(params[0].chainId));
181
- const [hexChainId, addEthereumChainParameter] = this.wagmiChainToAddEthereumChainParameters(chain);
182
- this.chains[hexChainId] = addEthereumChainParameter;
183
- this.setCurrentChain(params[0].chainId);
184
- }
185
- if (this.currentHexChainId !== params[0].chainId) {
186
- this.setCurrentChain(params[0].chainId);
187
- }
188
- return null;
189
- }
190
- case "wallet_watchAsset": {
191
- return false;
192
- }
193
- default: {
194
- return this.walletClient.request({
195
- method,
196
- params
197
- });
198
- }
199
- }
200
- });
201
- this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
202
- this.isModalClosed = true;
203
- this.para = opts.para;
204
- this.modalProps = __spreadValues({}, opts);
205
- this.disableModal = !!opts.disableModal;
206
- this.viemChains = opts.chains.reduce((acc, curChain) => {
207
- acc[decimalToHex(`${curChain.id}`)] = curChain;
208
- return acc;
209
- }, {});
210
- this.chains = this.wagmiChainsToAddEthereumChainParameters(opts.chains);
211
- this.transports = opts.transports;
212
- const defaultChainId = this.getStorageChainId() || opts.chainId;
213
- const currentChainId = this.chains[decimalToHex(defaultChainId)] ? defaultChainId : `${opts.chains[0].id}`;
214
- this.setCurrentChain(decimalToHex(currentChainId));
215
- this.emit("connect", { chainId: this.currentHexChainId });
216
- }
217
- get accounts() {
218
- return this.para.getWalletsByType("EVM").map((w) => w.address);
219
- }
220
- getStorageChainId() {
221
- return this.storage.getItem(STORAGE_CHAIN_ID_KEY);
222
- }
223
- setChainId(hexChainId) {
224
- this.currentHexChainId = hexChainId;
225
- this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
226
- }
227
- waitForLogin() {
228
- return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
229
- const startTime = Date.now();
230
- while (Date.now() - startTime < timeoutMs) {
231
- if (yield this.para.isFullyLoggedIn()) {
232
- return true;
233
- }
234
- if (!this.disableModal && this.isModalClosed) {
235
- throw new ProviderRpcError(new Error("user closed modal"), {
236
- code: 4001,
237
- shortMessage: "user closed modal"
238
- });
239
- }
240
- yield new Promise((resolve) => setTimeout(resolve, 2e3));
241
- }
242
- throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
243
- code: 4900,
244
- //provider is disconnected code
245
- shortMessage: "timed out waiting for user to log in"
246
- });
247
- });
248
- }
249
- waitForAccounts(timeoutMs = 5e3) {
250
- return __async(this, null, function* () {
251
- const startTime = Date.now();
252
- while (Date.now() - startTime < timeoutMs) {
253
- const accounts = this.accounts;
254
- if (accounts && accounts.length > 0) {
255
- return accounts;
256
- }
257
- yield new Promise((resolve) => setTimeout(resolve, 500));
258
- }
259
- throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
260
- code: 4900,
261
- //provider is disconnected code
262
- shortMessage: "timed out waiting for accounts to load"
263
- });
264
- });
265
- }
266
- }
267
- export {
268
- ParaEIP1193Provider
269
- };
@@ -1,59 +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 __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var __async = (__this, __arguments, generator) => {
34
- return new Promise((resolve, reject) => {
35
- var fulfilled = (value) => {
36
- try {
37
- step(generator.next(value));
38
- } catch (e) {
39
- reject(e);
40
- }
41
- };
42
- var rejected = (value) => {
43
- try {
44
- step(generator.throw(value));
45
- } catch (e) {
46
- reject(e);
47
- }
48
- };
49
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
- step((generator = generator.apply(__this, __arguments)).next());
51
- });
52
- };
53
-
54
- export {
55
- __spreadValues,
56
- __spreadProps,
57
- __objRest,
58
- __async
59
- };
@@ -1,36 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "./chunk-MMUBH76A.js";
7
- import { jsx } from "react/jsx-runtime";
8
- import { ParaModal } from "@getpara/react-sdk";
9
- function renderModal(para, modalProps, onCloseArg) {
10
- const existingContainer = document.getElementById("para-modal");
11
- const container = existingContainer != null ? existingContainer : document.createElement("div");
12
- container.id = "para-modal";
13
- if (!existingContainer) {
14
- document.body.appendChild(container);
15
- }
16
- const onClose = () => {
17
- onCloseArg();
18
- modalProps.onClose && modalProps.onClose();
19
- render(false);
20
- };
21
- const render = (isOpen) => __async(this, null, function* () {
22
- const Modal = /* @__PURE__ */ jsx(ParaModal, __spreadProps(__spreadValues({}, modalProps), { onClose, para, isOpen }));
23
- try {
24
- const client = yield import("react-dom/client");
25
- const root = client.createRoot(container);
26
- root.render(Modal);
27
- } catch (e) {
28
- const ReactDOM = yield import("react-dom");
29
- ReactDOM.render(Modal, container);
30
- }
31
- });
32
- render(true);
33
- }
34
- export {
35
- renderModal
36
- };
package/dist/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": false
4
- }
@@ -1,67 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __objRest,
5
- __spreadProps,
6
- __spreadValues
7
- } from "./chunk-MMUBH76A.js";
8
- import { injected } from "wagmi/connectors";
9
- import { ParaEIP1193Provider } from "./ParaEIP1193Provider.js";
10
- import { createConnector } from "wagmi";
11
- const PARA_ID = "para";
12
- const PARA_NAME = "Para";
13
- const PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
14
- const paraConnector = (_a) => {
15
- var _b = _a, {
16
- para,
17
- chains: _chains,
18
- disableModal,
19
- storageOverride,
20
- options,
21
- iconOverride,
22
- nameOverride,
23
- idOverride,
24
- transports
25
- } = _b, modalProps = __objRest(_b, [
26
- "para",
27
- "chains",
28
- "disableModal",
29
- "storageOverride",
30
- "options",
31
- "iconOverride",
32
- "nameOverride",
33
- "idOverride",
34
- "transports"
35
- ]);
36
- return createConnector((config) => {
37
- const chains = [...config.chains];
38
- const eip1193Provider = new ParaEIP1193Provider(__spreadValues({
39
- para,
40
- chainId: `${chains[0].id}`,
41
- chains,
42
- disableModal,
43
- storageOverride,
44
- transports: transports || config.transports
45
- }, modalProps));
46
- const injectedObj = injected(__spreadValues({
47
- target: {
48
- name: PARA_NAME,
49
- id: idOverride != null ? idOverride : PARA_ID,
50
- provider: eip1193Provider
51
- }
52
- }, options))(config);
53
- return __spreadProps(__spreadValues({}, injectedObj), {
54
- type: idOverride != null ? idOverride : PARA_ID,
55
- name: nameOverride != null ? nameOverride : PARA_NAME,
56
- icon: iconOverride != null ? iconOverride : PARA_ICON,
57
- disconnect: () => __async(void 0, null, function* () {
58
- eip1193Provider.closeModal();
59
- yield injectedObj.disconnect();
60
- para.logout();
61
- })
62
- });
63
- });
64
- };
65
- export {
66
- paraConnector
67
- };