@getpara/wagmi-v2-integration 1.12.0 → 2.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connectorModal.d.ts +5 -2
- package/dist/connectorModal.js +31 -13
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/paraConnector.d.ts +104 -102
- package/dist/paraConnector.js +20 -36
- package/package.json +7 -10
- package/dist/ParaEIP1193Provider.d.ts +0 -40
- package/dist/ParaEIP1193Provider.js +0 -269
package/dist/connectorModal.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import ParaWeb from '@getpara/react-sdk';
|
|
2
|
-
import { ParaModalPropsForInit } from './
|
|
3
|
-
|
|
2
|
+
import { type ParaModalPropsForInit } from './paraConnector.js';
|
|
3
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
4
|
+
export declare function renderModal(para: ParaWeb, modalProps: Partial<ParaModalPropsForInit>, onCloseArg: () => void, queryClient: QueryClient): {
|
|
5
|
+
openModal: () => void;
|
|
6
|
+
};
|
package/dist/connectorModal.js
CHANGED
|
@@ -5,31 +5,49 @@ import {
|
|
|
5
5
|
__spreadValues
|
|
6
6
|
} from "./chunk-MMUBH76A.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
document.body.appendChild(container);
|
|
8
|
+
import { setIsOpen } from "@getpara/react-sdk";
|
|
9
|
+
let Root;
|
|
10
|
+
function renderModal(para, modalProps, onCloseArg, queryClient) {
|
|
11
|
+
if (typeof window === "undefined") {
|
|
12
|
+
return { openModal: () => {
|
|
13
|
+
} };
|
|
15
14
|
}
|
|
16
15
|
const onClose = () => {
|
|
17
16
|
onCloseArg();
|
|
18
17
|
modalProps.onClose && modalProps.onClose();
|
|
19
|
-
|
|
18
|
+
setIsOpen(false);
|
|
20
19
|
};
|
|
21
|
-
const render = (
|
|
22
|
-
|
|
20
|
+
const render = () => __async(this, null, function* () {
|
|
21
|
+
var _a;
|
|
22
|
+
const { ParaProvider } = yield import("@getpara/react-sdk");
|
|
23
|
+
const { QueryClientProvider } = yield import("@tanstack/react-query");
|
|
24
|
+
const existingContainer = document.getElementById("para-modal");
|
|
25
|
+
const container = existingContainer != null ? existingContainer : document.createElement("div");
|
|
26
|
+
container.id = "para-modal";
|
|
27
|
+
if (!existingContainer) {
|
|
28
|
+
document.body.insertAdjacentElement("beforeend", container);
|
|
29
|
+
}
|
|
30
|
+
const Modal = /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
|
|
31
|
+
ParaProvider,
|
|
32
|
+
{
|
|
33
|
+
paraClientConfig: para,
|
|
34
|
+
config: { appName: (_a = modalProps.appName) != null ? _a : "" },
|
|
35
|
+
paraModalConfig: __spreadProps(__spreadValues({}, modalProps), { onClose })
|
|
36
|
+
}
|
|
37
|
+
) });
|
|
23
38
|
try {
|
|
24
39
|
const client = yield import("react-dom/client");
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
if (!Root) {
|
|
41
|
+
Root = client.createRoot(container);
|
|
42
|
+
}
|
|
43
|
+
Root.render(Modal);
|
|
27
44
|
} catch (e) {
|
|
28
45
|
const ReactDOM = yield import("react-dom");
|
|
29
46
|
ReactDOM.render(Modal, container);
|
|
30
47
|
}
|
|
31
48
|
});
|
|
32
|
-
render(
|
|
49
|
+
render();
|
|
50
|
+
return { openModal: () => setIsOpen(true) };
|
|
33
51
|
}
|
|
34
52
|
export {
|
|
35
53
|
renderModal
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/paraConnector.d.ts
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
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
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
+
export type ParaModalPropsForInit = Omit<ParaModalProps, 'isOpen' | 'para'> & {
|
|
13
5
|
appName: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare const paraConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, ...modalProps }: ParaConnectorOpts) => (config: {
|
|
21
|
-
chains: readonly [Chain, ...Chain[]];
|
|
6
|
+
};
|
|
7
|
+
type ParaConnectorOpts = Partial<ParaModalPropsForInit> & ParaConnectorOptsBase & {
|
|
8
|
+
queryClient: QueryClient;
|
|
9
|
+
};
|
|
10
|
+
export declare const paraConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, appName, queryClient, ...modalProps }: ParaConnectorOpts) => (config: {
|
|
11
|
+
chains: readonly [import("viem").Chain, ...import("viem").Chain[]];
|
|
22
12
|
emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
|
|
23
13
|
storage?: {
|
|
24
14
|
key: string;
|
|
@@ -26,7 +16,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
26
16
|
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
17
|
removeItem: (key: string) => void | Promise<void>;
|
|
28
18
|
};
|
|
29
|
-
transports?: Record<number, import("wagmi").Transport
|
|
19
|
+
transports?: Record<number, import("wagmi").Transport<string, Record<string, any>, import("viem").EIP1193RequestFn>>;
|
|
30
20
|
}) => {
|
|
31
21
|
type: string;
|
|
32
22
|
name: string;
|
|
@@ -116,11 +106,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
116
106
|
}, {
|
|
117
107
|
Method: "eth_getBlockByHash";
|
|
118
108
|
Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
|
|
119
|
-
ReturnType: import("viem").RpcBlock
|
|
109
|
+
ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
|
|
120
110
|
}, {
|
|
121
111
|
Method: "eth_getBlockByNumber";
|
|
122
112
|
Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
|
|
123
|
-
ReturnType: import("viem").RpcBlock
|
|
113
|
+
ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
|
|
124
114
|
}, {
|
|
125
115
|
Method: "eth_getBlockTransactionCountByHash";
|
|
126
116
|
Parameters: [hash: `0x${string}`];
|
|
@@ -194,15 +184,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
194
184
|
}, {
|
|
195
185
|
Method: "eth_getTransactionByBlockHashAndIndex";
|
|
196
186
|
Parameters: [hash: `0x${string}`, index: `0x${string}`];
|
|
197
|
-
ReturnType: import("viem").RpcTransaction
|
|
187
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
198
188
|
}, {
|
|
199
189
|
Method: "eth_getTransactionByBlockNumberAndIndex";
|
|
200
190
|
Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
|
|
201
|
-
ReturnType: import("viem").RpcTransaction
|
|
191
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
202
192
|
}, {
|
|
203
193
|
Method: "eth_getTransactionByHash";
|
|
204
194
|
Parameters: [hash: `0x${string}`];
|
|
205
|
-
ReturnType: import("viem").RpcTransaction
|
|
195
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
206
196
|
}, {
|
|
207
197
|
Method: "eth_getTransactionCount";
|
|
208
198
|
Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
|
|
@@ -268,7 +258,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
268
258
|
traceTransfers?: boolean;
|
|
269
259
|
validation?: boolean;
|
|
270
260
|
}, `0x${string}` | import("viem").BlockTag];
|
|
271
|
-
ReturnType: readonly (import("viem").RpcBlock & {
|
|
261
|
+
ReturnType: readonly (import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>> & {
|
|
272
262
|
calls: readonly {
|
|
273
263
|
error?: {
|
|
274
264
|
data?: `0x${string}`;
|
|
@@ -418,19 +408,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
418
408
|
ReturnType: `0x${string}`;
|
|
419
409
|
}, {
|
|
420
410
|
Method: "eth_estimateUserOperationGas";
|
|
421
|
-
Parameters: [userOperation: import("viem").RpcUserOperation
|
|
422
|
-
ReturnType: import("viem").RpcEstimateUserOperationGasReturnType
|
|
411
|
+
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];
|
|
412
|
+
ReturnType: import("viem").RpcEstimateUserOperationGasReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
423
413
|
}, {
|
|
424
414
|
Method: "eth_getUserOperationByHash";
|
|
425
415
|
Parameters: [hash: `0x${string}`];
|
|
426
|
-
ReturnType: import("viem").RpcGetUserOperationByHashReturnType
|
|
416
|
+
ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
427
417
|
}, {
|
|
428
418
|
Method: "eth_getUserOperationReceipt";
|
|
429
419
|
Parameters: [hash: `0x${string}`];
|
|
430
|
-
ReturnType: import("viem").RpcUserOperationReceipt
|
|
420
|
+
ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
431
421
|
}, {
|
|
432
422
|
Method: "eth_sendUserOperation";
|
|
433
|
-
Parameters: [userOperation: import("viem").RpcUserOperation
|
|
423
|
+
Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`];
|
|
434
424
|
ReturnType: `0x${string}`;
|
|
435
425
|
}, {
|
|
436
426
|
Method: "eth_supportedEntryPoints";
|
|
@@ -438,43 +428,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
438
428
|
ReturnType: readonly `0x${string}`[];
|
|
439
429
|
}, {
|
|
440
430
|
Method: "pm_getPaymasterStubData";
|
|
441
|
-
Parameters?: [userOperation:
|
|
431
|
+
Parameters?: [userOperation: {
|
|
432
|
+
nonce: `0x${string}`;
|
|
442
433
|
callData: `0x${string}`;
|
|
443
|
-
|
|
434
|
+
sender: `0x${string}`;
|
|
435
|
+
maxFeePerGas?: `0x${string}`;
|
|
436
|
+
maxPriorityFeePerGas?: `0x${string}`;
|
|
437
|
+
callGasLimit?: `0x${string}`;
|
|
438
|
+
preVerificationGas?: `0x${string}`;
|
|
439
|
+
verificationGasLimit?: `0x${string}`;
|
|
444
440
|
initCode?: `0x${string}`;
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
factory?: undefined;
|
|
442
|
+
factoryData?: undefined;
|
|
443
|
+
} | {
|
|
447
444
|
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
445
|
callData: `0x${string}`;
|
|
455
|
-
|
|
446
|
+
sender: `0x${string}`;
|
|
447
|
+
maxFeePerGas?: `0x${string}`;
|
|
448
|
+
maxPriorityFeePerGas?: `0x${string}`;
|
|
449
|
+
callGasLimit?: `0x${string}`;
|
|
456
450
|
factory?: `0x${string}`;
|
|
457
451
|
factoryData?: `0x${string}`;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
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<{
|
|
452
|
+
preVerificationGas?: `0x${string}`;
|
|
453
|
+
verificationGasLimit?: `0x${string}`;
|
|
454
|
+
initCode?: undefined;
|
|
455
|
+
}, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
|
|
456
|
+
ReturnType: ({
|
|
471
457
|
paymasterAndData: `0x${string}`;
|
|
458
|
+
paymaster?: undefined;
|
|
459
|
+
paymasterData?: undefined;
|
|
460
|
+
paymasterPostOpGasLimit?: undefined;
|
|
461
|
+
paymasterVerificationGasLimit?: undefined;
|
|
472
462
|
} | {
|
|
473
463
|
paymaster: `0x${string}`;
|
|
474
464
|
paymasterData: `0x${string}`;
|
|
475
465
|
paymasterVerificationGasLimit: `0x${string}`;
|
|
476
466
|
paymasterPostOpGasLimit: `0x${string}`;
|
|
477
|
-
|
|
467
|
+
paymasterAndData?: undefined;
|
|
468
|
+
}) & {
|
|
478
469
|
sponsor?: {
|
|
479
470
|
name: string;
|
|
480
471
|
icon?: string;
|
|
@@ -512,15 +503,20 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
512
503
|
signature: `0x${string}`;
|
|
513
504
|
verificationGasLimit: `0x${string}`;
|
|
514
505
|
}, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
|
|
515
|
-
ReturnType:
|
|
506
|
+
ReturnType: {
|
|
516
507
|
paymasterAndData: `0x${string}`;
|
|
508
|
+
paymaster?: undefined;
|
|
509
|
+
paymasterData?: undefined;
|
|
510
|
+
paymasterPostOpGasLimit?: undefined;
|
|
511
|
+
paymasterVerificationGasLimit?: undefined;
|
|
517
512
|
} | {
|
|
518
513
|
paymaster: `0x${string}`;
|
|
519
514
|
paymasterData: `0x${string}`;
|
|
520
515
|
paymasterVerificationGasLimit: `0x${string}`;
|
|
521
516
|
paymasterPostOpGasLimit: `0x${string}`;
|
|
522
|
-
|
|
523
|
-
|
|
517
|
+
paymasterAndData?: undefined;
|
|
518
|
+
};
|
|
519
|
+
}], false>;
|
|
524
520
|
isApexWallet?: true;
|
|
525
521
|
isAvalanche?: true;
|
|
526
522
|
isBackpack?: true;
|
|
@@ -560,8 +556,8 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
560
556
|
isXDEFI?: true;
|
|
561
557
|
isZerion?: true;
|
|
562
558
|
providers?: {
|
|
563
|
-
on: <event_2 extends keyof import("viem").EIP1193EventMap>(event: event, listener:
|
|
564
|
-
removeListener: <event_3 extends keyof import("viem").EIP1193EventMap>(event: event, listener:
|
|
559
|
+
on: <event_2 extends keyof import("viem").EIP1193EventMap>(event: event, listener: event) => void;
|
|
560
|
+
removeListener: <event_3 extends keyof import("viem").EIP1193EventMap>(event: event, listener: event) => void;
|
|
565
561
|
request: import("viem").EIP1193RequestFn<[{
|
|
566
562
|
Method: "web3_clientVersion";
|
|
567
563
|
Parameters?: undefined;
|
|
@@ -628,11 +624,11 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
628
624
|
}, {
|
|
629
625
|
Method: "eth_getBlockByHash";
|
|
630
626
|
Parameters: [hash: `0x${string}`, includeTransactionObjects: boolean];
|
|
631
|
-
ReturnType: import("viem").RpcBlock
|
|
627
|
+
ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
|
|
632
628
|
}, {
|
|
633
629
|
Method: "eth_getBlockByNumber";
|
|
634
630
|
Parameters: [block: `0x${string}` | import("viem").BlockTag, includeTransactionObjects: boolean];
|
|
635
|
-
ReturnType: import("viem").RpcBlock
|
|
631
|
+
ReturnType: import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>>;
|
|
636
632
|
}, {
|
|
637
633
|
Method: "eth_getBlockTransactionCountByHash";
|
|
638
634
|
Parameters: [hash: `0x${string}`];
|
|
@@ -706,15 +702,15 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
706
702
|
}, {
|
|
707
703
|
Method: "eth_getTransactionByBlockHashAndIndex";
|
|
708
704
|
Parameters: [hash: `0x${string}`, index: `0x${string}`];
|
|
709
|
-
ReturnType: import("viem").RpcTransaction
|
|
705
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
710
706
|
}, {
|
|
711
707
|
Method: "eth_getTransactionByBlockNumberAndIndex";
|
|
712
708
|
Parameters: [block: `0x${string}` | import("viem").BlockTag, index: `0x${string}`];
|
|
713
|
-
ReturnType: import("viem").RpcTransaction
|
|
709
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
714
710
|
}, {
|
|
715
711
|
Method: "eth_getTransactionByHash";
|
|
716
712
|
Parameters: [hash: `0x${string}`];
|
|
717
|
-
ReturnType: import("viem").RpcTransaction
|
|
713
|
+
ReturnType: import("viem").RpcTransaction<boolean>;
|
|
718
714
|
}, {
|
|
719
715
|
Method: "eth_getTransactionCount";
|
|
720
716
|
Parameters: [address: `0x${string}`, block: `0x${string}` | import("viem").BlockTag | import("viem").RpcBlockIdentifier];
|
|
@@ -780,7 +776,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
780
776
|
traceTransfers?: boolean;
|
|
781
777
|
validation?: boolean;
|
|
782
778
|
}, `0x${string}` | import("viem").BlockTag];
|
|
783
|
-
ReturnType: readonly (import("viem").RpcBlock & {
|
|
779
|
+
ReturnType: readonly (import("viem").RpcBlock<import("viem").BlockTag, boolean, import("viem").RpcTransaction<boolean>> & {
|
|
784
780
|
calls: readonly {
|
|
785
781
|
error?: {
|
|
786
782
|
data?: `0x${string}`;
|
|
@@ -930,19 +926,19 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
930
926
|
ReturnType: `0x${string}`;
|
|
931
927
|
}, {
|
|
932
928
|
Method: "eth_estimateUserOperationGas";
|
|
933
|
-
Parameters: [userOperation: import("viem").RpcUserOperation
|
|
934
|
-
ReturnType: import("viem").RpcEstimateUserOperationGasReturnType
|
|
929
|
+
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];
|
|
930
|
+
ReturnType: import("viem").RpcEstimateUserOperationGasReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
935
931
|
}, {
|
|
936
932
|
Method: "eth_getUserOperationByHash";
|
|
937
933
|
Parameters: [hash: `0x${string}`];
|
|
938
|
-
ReturnType: import("viem").RpcGetUserOperationByHashReturnType
|
|
934
|
+
ReturnType: import("viem").RpcGetUserOperationByHashReturnType<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
939
935
|
}, {
|
|
940
936
|
Method: "eth_getUserOperationReceipt";
|
|
941
937
|
Parameters: [hash: `0x${string}`];
|
|
942
|
-
ReturnType: import("viem").RpcUserOperationReceipt
|
|
938
|
+
ReturnType: import("viem").RpcUserOperationReceipt<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>;
|
|
943
939
|
}, {
|
|
944
940
|
Method: "eth_sendUserOperation";
|
|
945
|
-
Parameters: [userOperation: import("viem").RpcUserOperation
|
|
941
|
+
Parameters: [userOperation: import("viem").RpcUserOperation<import("viem/_types/account-abstraction/types/entryPointVersion.js").EntryPointVersion>, entrypoint: `0x${string}`];
|
|
946
942
|
ReturnType: `0x${string}`;
|
|
947
943
|
}, {
|
|
948
944
|
Method: "eth_supportedEntryPoints";
|
|
@@ -950,43 +946,44 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
950
946
|
ReturnType: readonly `0x${string}`[];
|
|
951
947
|
}, {
|
|
952
948
|
Method: "pm_getPaymasterStubData";
|
|
953
|
-
Parameters?: [userOperation:
|
|
949
|
+
Parameters?: [userOperation: {
|
|
950
|
+
nonce: `0x${string}`;
|
|
954
951
|
callData: `0x${string}`;
|
|
955
|
-
|
|
952
|
+
sender: `0x${string}`;
|
|
953
|
+
maxFeePerGas?: `0x${string}`;
|
|
954
|
+
maxPriorityFeePerGas?: `0x${string}`;
|
|
955
|
+
callGasLimit?: `0x${string}`;
|
|
956
|
+
preVerificationGas?: `0x${string}`;
|
|
957
|
+
verificationGasLimit?: `0x${string}`;
|
|
956
958
|
initCode?: `0x${string}`;
|
|
957
|
-
|
|
958
|
-
|
|
959
|
+
factory?: undefined;
|
|
960
|
+
factoryData?: undefined;
|
|
961
|
+
} | {
|
|
959
962
|
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
963
|
callData: `0x${string}`;
|
|
967
|
-
|
|
964
|
+
sender: `0x${string}`;
|
|
965
|
+
maxFeePerGas?: `0x${string}`;
|
|
966
|
+
maxPriorityFeePerGas?: `0x${string}`;
|
|
967
|
+
callGasLimit?: `0x${string}`;
|
|
968
968
|
factory?: `0x${string}`;
|
|
969
969
|
factoryData?: `0x${string}`;
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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<{
|
|
970
|
+
preVerificationGas?: `0x${string}`;
|
|
971
|
+
verificationGasLimit?: `0x${string}`;
|
|
972
|
+
initCode?: undefined;
|
|
973
|
+
}, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
|
|
974
|
+
ReturnType: ({
|
|
983
975
|
paymasterAndData: `0x${string}`;
|
|
976
|
+
paymaster?: undefined;
|
|
977
|
+
paymasterData?: undefined;
|
|
978
|
+
paymasterPostOpGasLimit?: undefined;
|
|
979
|
+
paymasterVerificationGasLimit?: undefined;
|
|
984
980
|
} | {
|
|
985
981
|
paymaster: `0x${string}`;
|
|
986
982
|
paymasterData: `0x${string}`;
|
|
987
983
|
paymasterVerificationGasLimit: `0x${string}`;
|
|
988
984
|
paymasterPostOpGasLimit: `0x${string}`;
|
|
989
|
-
|
|
985
|
+
paymasterAndData?: undefined;
|
|
986
|
+
}) & {
|
|
990
987
|
sponsor?: {
|
|
991
988
|
name: string;
|
|
992
989
|
icon?: string;
|
|
@@ -1024,15 +1021,20 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
1024
1021
|
signature: `0x${string}`;
|
|
1025
1022
|
verificationGasLimit: `0x${string}`;
|
|
1026
1023
|
}, "nonce" | "maxFeePerGas" | "maxPriorityFeePerGas" | "callData" | "callGasLimit" | "factory" | "factoryData" | "preVerificationGas" | "sender" | "verificationGasLimit">, entrypoint: `0x${string}`, chainId: `0x${string}`, context: unknown];
|
|
1027
|
-
ReturnType:
|
|
1024
|
+
ReturnType: {
|
|
1028
1025
|
paymasterAndData: `0x${string}`;
|
|
1026
|
+
paymaster?: undefined;
|
|
1027
|
+
paymasterData?: undefined;
|
|
1028
|
+
paymasterPostOpGasLimit?: undefined;
|
|
1029
|
+
paymasterVerificationGasLimit?: undefined;
|
|
1029
1030
|
} | {
|
|
1030
1031
|
paymaster: `0x${string}`;
|
|
1031
1032
|
paymasterData: `0x${string}`;
|
|
1032
1033
|
paymasterVerificationGasLimit: `0x${string}`;
|
|
1033
1034
|
paymasterPostOpGasLimit: `0x${string}`;
|
|
1034
|
-
|
|
1035
|
-
|
|
1035
|
+
paymasterAndData?: undefined;
|
|
1036
|
+
};
|
|
1037
|
+
}], false>;
|
|
1036
1038
|
isApexWallet?: true;
|
|
1037
1039
|
isAvalanche?: true;
|
|
1038
1040
|
isBackpack?: true;
|
|
@@ -1101,7 +1103,7 @@ export declare const paraConnector: ({ para, chains: _chains, disableModal, stor
|
|
|
1101
1103
|
switchChain?: (parameters: {
|
|
1102
1104
|
addEthereumChainParameter?: import("@wagmi/core/internal").ExactPartial<import("@wagmi/core/internal").Omit<import("viem").AddEthereumChainParameter, "chainId">>;
|
|
1103
1105
|
chainId: number;
|
|
1104
|
-
}) => Promise<Chain>;
|
|
1106
|
+
}) => Promise<import("viem").Chain>;
|
|
1105
1107
|
onAccountsChanged: (accounts: string[]) => void;
|
|
1106
1108
|
onChainChanged: (chainId: string) => void;
|
|
1107
1109
|
onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
|
package/dist/paraConnector.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__async,
|
|
4
3
|
__objRest,
|
|
5
4
|
__spreadProps,
|
|
6
5
|
__spreadValues
|
|
7
6
|
} from "./chunk-MMUBH76A.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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";
|
|
7
|
+
import { createParaConnector } from "@getpara/wagmi-v2-connector";
|
|
8
|
+
import { renderModal } from "./connectorModal.js";
|
|
14
9
|
const paraConnector = (_a) => {
|
|
15
10
|
var _b = _a, {
|
|
16
11
|
para,
|
|
@@ -21,7 +16,9 @@ const paraConnector = (_a) => {
|
|
|
21
16
|
iconOverride,
|
|
22
17
|
nameOverride,
|
|
23
18
|
idOverride,
|
|
24
|
-
transports
|
|
19
|
+
transports,
|
|
20
|
+
appName,
|
|
21
|
+
queryClient
|
|
25
22
|
} = _b, modalProps = __objRest(_b, [
|
|
26
23
|
"para",
|
|
27
24
|
"chains",
|
|
@@ -31,35 +28,22 @@ const paraConnector = (_a) => {
|
|
|
31
28
|
"iconOverride",
|
|
32
29
|
"nameOverride",
|
|
33
30
|
"idOverride",
|
|
34
|
-
"transports"
|
|
31
|
+
"transports",
|
|
32
|
+
"appName",
|
|
33
|
+
"queryClient"
|
|
35
34
|
]);
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
});
|
|
35
|
+
return createParaConnector({
|
|
36
|
+
para,
|
|
37
|
+
chains: _chains,
|
|
38
|
+
disableModal,
|
|
39
|
+
storageOverride,
|
|
40
|
+
options,
|
|
41
|
+
iconOverride,
|
|
42
|
+
nameOverride,
|
|
43
|
+
idOverride,
|
|
44
|
+
transports,
|
|
45
|
+
appName,
|
|
46
|
+
renderModal: (onClose) => renderModal(para, __spreadProps(__spreadValues({}, modalProps), { appName }), onClose, queryClient)
|
|
63
47
|
});
|
|
64
48
|
};
|
|
65
49
|
export {
|
package/package.json
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/wagmi-v2-integration",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
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": "
|
|
10
|
-
"@getpara/
|
|
9
|
+
"@getpara/react-sdk": "2.0.0-alpha.11",
|
|
10
|
+
"@getpara/wagmi-v2-connector": "2.0.0-alpha.11"
|
|
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.16"
|
|
17
|
+
"typescript": "5.1.6"
|
|
20
18
|
},
|
|
21
19
|
"peerDependencies": {
|
|
20
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
22
21
|
"react": "*",
|
|
23
|
-
"react-dom": "*"
|
|
24
|
-
"viem": "2.x",
|
|
25
|
-
"wagmi": "2.x"
|
|
22
|
+
"react-dom": "*"
|
|
26
23
|
},
|
|
27
24
|
"files": [
|
|
28
25
|
"dist",
|
|
29
26
|
"package.json"
|
|
30
27
|
],
|
|
31
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "e877dc4237cc4cc3a233f3d4166cc8f5a1942900"
|
|
32
29
|
}
|
|
@@ -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
|
-
};
|