@getpara/wagmi-v2-connector 2.0.0-alpha.60 → 2.0.0-alpha.61
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/ParaEIP1193Provider.d.ts +42 -0
- package/dist/ParaEIP1193Provider.js +268 -0
- package/dist/chunk-IV3L3JVM.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/package.json +4 -0
- package/dist/paraConnector.d.ts +325 -0
- package/dist/paraConnector.js +60 -0
- package/package.json +4 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EIP1474Methods, EIP1193Provider, EIP1193RequestFn, Transport } from 'viem';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { Chain } from 'wagmi/chains';
|
|
4
|
+
import ParaWeb from '@getpara/web-sdk';
|
|
5
|
+
interface ParaEIP1193ProviderOpts {
|
|
6
|
+
para: ParaWeb;
|
|
7
|
+
chainId: string;
|
|
8
|
+
chains: Chain[];
|
|
9
|
+
disableModal?: boolean;
|
|
10
|
+
storageOverride?: Pick<Storage, 'setItem' | 'getItem'>;
|
|
11
|
+
transports?: Record<number, Transport>;
|
|
12
|
+
renderModal?: (onClose: () => void) => {
|
|
13
|
+
openModal: () => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare class ParaEIP1193Provider extends EventEmitter implements EIP1193Provider {
|
|
17
|
+
private currentHexChainId;
|
|
18
|
+
private walletClient;
|
|
19
|
+
private chainTransportSubscribe?;
|
|
20
|
+
private chains;
|
|
21
|
+
private viemChains;
|
|
22
|
+
private para;
|
|
23
|
+
private disableModal;
|
|
24
|
+
private storage;
|
|
25
|
+
private isModalClosed;
|
|
26
|
+
private transports?;
|
|
27
|
+
private openModal?;
|
|
28
|
+
constructor(opts: ParaEIP1193ProviderOpts);
|
|
29
|
+
private get accounts();
|
|
30
|
+
private getStorageChainId;
|
|
31
|
+
private setChainId;
|
|
32
|
+
private getRpcUrlsFromViemChain;
|
|
33
|
+
private wagmiChainToAddEthereumChainParameters;
|
|
34
|
+
private wagmiChainsToAddEthereumChainParameters;
|
|
35
|
+
private accountFromAddress;
|
|
36
|
+
private setCurrentChain;
|
|
37
|
+
closeModal: () => void;
|
|
38
|
+
private waitForLogin;
|
|
39
|
+
private waitForAccounts;
|
|
40
|
+
request: EIP1193RequestFn<EIP1474Methods>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-IV3L3JVM.js";
|
|
7
|
+
import {
|
|
8
|
+
ProviderRpcError,
|
|
9
|
+
webSocket,
|
|
10
|
+
publicActions,
|
|
11
|
+
http,
|
|
12
|
+
formatTransaction
|
|
13
|
+
} from "viem";
|
|
14
|
+
import { EventEmitter } from "eventemitter3";
|
|
15
|
+
import { extractRpcUrls } from "@wagmi/core";
|
|
16
|
+
import { getViemChain, createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
|
|
17
|
+
import { decimalToHex, hexToDecimal } from "@getpara/web-sdk";
|
|
18
|
+
const STORAGE_CHAIN_ID_KEY = "@CAPSULE/chainId";
|
|
19
|
+
const TEN_MINUTES_MS = 6e5;
|
|
20
|
+
const serverSessionStorageStub = {
|
|
21
|
+
setItem: () => {
|
|
22
|
+
},
|
|
23
|
+
getItem: () => null
|
|
24
|
+
};
|
|
25
|
+
class ParaEIP1193Provider extends EventEmitter {
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
super();
|
|
28
|
+
this.getRpcUrlsFromViemChain = (chain) => {
|
|
29
|
+
return extractRpcUrls({ chain, transports: this.transports });
|
|
30
|
+
};
|
|
31
|
+
this.wagmiChainToAddEthereumChainParameters = (chain) => {
|
|
32
|
+
const hexChainId = decimalToHex(`${chain.id}`);
|
|
33
|
+
return [
|
|
34
|
+
hexChainId,
|
|
35
|
+
{
|
|
36
|
+
chainId: hexChainId,
|
|
37
|
+
chainName: chain.name,
|
|
38
|
+
nativeCurrency: chain.nativeCurrency,
|
|
39
|
+
rpcUrls: this.getRpcUrlsFromViemChain(chain)
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
};
|
|
43
|
+
this.wagmiChainsToAddEthereumChainParameters = (chains) => {
|
|
44
|
+
return Object.fromEntries(chains.map(this.wagmiChainToAddEthereumChainParameters));
|
|
45
|
+
};
|
|
46
|
+
this.accountFromAddress = (address) => {
|
|
47
|
+
return createParaAccount(this.para, address);
|
|
48
|
+
};
|
|
49
|
+
this.setCurrentChain = (chainId) => {
|
|
50
|
+
const chain = this.chains[chainId];
|
|
51
|
+
this.setChainId(chainId);
|
|
52
|
+
const viemChain = this.viemChains[chainId] || getViemChain(hexToDecimal(chainId));
|
|
53
|
+
const rpcUrls = this.getRpcUrlsFromViemChain(viemChain);
|
|
54
|
+
let transport;
|
|
55
|
+
if (this.transports[viemChain.id]) {
|
|
56
|
+
transport = this.transports[viemChain.id];
|
|
57
|
+
} else if (rpcUrls[0].startsWith("ws")) {
|
|
58
|
+
transport = webSocket(chain.rpcUrls[0]);
|
|
59
|
+
} else {
|
|
60
|
+
transport = http(rpcUrls[0]);
|
|
61
|
+
this.chainTransportSubscribe = void 0;
|
|
62
|
+
}
|
|
63
|
+
const chainTransport = transport({
|
|
64
|
+
chain: viemChain
|
|
65
|
+
});
|
|
66
|
+
if (chainTransport.config.type === "ws") {
|
|
67
|
+
this.chainTransportSubscribe = chainTransport.value.subscribe;
|
|
68
|
+
}
|
|
69
|
+
this.walletClient = createParaViemClient(
|
|
70
|
+
this.para,
|
|
71
|
+
{
|
|
72
|
+
chain: viemChain,
|
|
73
|
+
transport
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
},
|
|
76
|
+
{ noAccount: true }
|
|
77
|
+
).extend(publicActions);
|
|
78
|
+
this.emit("chainChanged", this.currentHexChainId);
|
|
79
|
+
};
|
|
80
|
+
this.closeModal = () => {
|
|
81
|
+
this.isModalClosed = true;
|
|
82
|
+
};
|
|
83
|
+
this.request = (args) => __async(this, null, function* () {
|
|
84
|
+
var _a;
|
|
85
|
+
const { method, params } = args;
|
|
86
|
+
switch (method) {
|
|
87
|
+
case "eth_accounts": {
|
|
88
|
+
const accounts = this.accounts;
|
|
89
|
+
return accounts || [];
|
|
90
|
+
}
|
|
91
|
+
case "eth_chainId": {
|
|
92
|
+
return this.currentHexChainId;
|
|
93
|
+
}
|
|
94
|
+
case "eth_requestAccounts": {
|
|
95
|
+
if (yield this.para.isFullyLoggedIn()) {
|
|
96
|
+
const accounts = this.accounts;
|
|
97
|
+
if (accounts && accounts.length > 0) {
|
|
98
|
+
return accounts;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.isModalClosed = false;
|
|
102
|
+
(_a = this.openModal) == null ? void 0 : _a.call(this);
|
|
103
|
+
yield this.waitForLogin();
|
|
104
|
+
try {
|
|
105
|
+
const accounts = yield this.waitForAccounts();
|
|
106
|
+
this.emit("accountsChanged", accounts);
|
|
107
|
+
return accounts;
|
|
108
|
+
} catch (error) {
|
|
109
|
+
throw new ProviderRpcError(new Error("accounts not available after login"), {
|
|
110
|
+
code: 4001,
|
|
111
|
+
shortMessage: "accounts not available after login"
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
case "eth_sendTransaction": {
|
|
116
|
+
const fromAddress = params[0].from;
|
|
117
|
+
return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
|
|
118
|
+
chain: void 0,
|
|
119
|
+
// uses the chain from the wallet client
|
|
120
|
+
account: this.accountFromAddress(fromAddress)
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
case "eth_sign":
|
|
124
|
+
case "personal_sign": {
|
|
125
|
+
return this.walletClient.signMessage({
|
|
126
|
+
message: { raw: params[0] },
|
|
127
|
+
account: this.accountFromAddress(params[1])
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
case "eth_signTransaction": {
|
|
131
|
+
const fromAddress = params[0].from;
|
|
132
|
+
return this.accountFromAddress(fromAddress).signTransaction(formatTransaction(params[0]));
|
|
133
|
+
}
|
|
134
|
+
case "eth_signTypedData_v4": {
|
|
135
|
+
const fromAddress = params[0];
|
|
136
|
+
let typedMessage = params[1];
|
|
137
|
+
if (typeof typedMessage === "string") {
|
|
138
|
+
typedMessage = JSON.parse(typedMessage);
|
|
139
|
+
}
|
|
140
|
+
return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
|
|
141
|
+
account: this.accountFromAddress(fromAddress)
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
case "eth_subscribe": {
|
|
145
|
+
if (!this.chainTransportSubscribe) {
|
|
146
|
+
throw new ProviderRpcError(new Error("chain does not support subscriptions"), {
|
|
147
|
+
code: 4200,
|
|
148
|
+
shortMessage: "chain does not support subscriptions"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const res = yield this.chainTransportSubscribe({
|
|
152
|
+
params,
|
|
153
|
+
onData: (data) => {
|
|
154
|
+
this.emit("message", {
|
|
155
|
+
type: "eth_subscription",
|
|
156
|
+
data
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return res.subscriptionId;
|
|
161
|
+
}
|
|
162
|
+
case "wallet_addEthereumChain": {
|
|
163
|
+
if (!this.chains[params[0].chainId]) {
|
|
164
|
+
this.chains[params[0].chainId] = params[0];
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
case "wallet_getPermissions": {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
case "wallet_requestPermissions": {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
case "wallet_switchEthereumChain": {
|
|
175
|
+
if (!this.chains[params[0].chainId]) {
|
|
176
|
+
const chain = getViemChain(hexToDecimal(params[0].chainId));
|
|
177
|
+
const [hexChainId, addEthereumChainParameter] = this.wagmiChainToAddEthereumChainParameters(chain);
|
|
178
|
+
this.chains[hexChainId] = addEthereumChainParameter;
|
|
179
|
+
this.setCurrentChain(params[0].chainId);
|
|
180
|
+
}
|
|
181
|
+
if (this.currentHexChainId !== params[0].chainId) {
|
|
182
|
+
this.setCurrentChain(params[0].chainId);
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
case "wallet_watchAsset": {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
default: {
|
|
190
|
+
return this.walletClient.request({
|
|
191
|
+
method,
|
|
192
|
+
params
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
|
|
198
|
+
this.isModalClosed = true;
|
|
199
|
+
this.para = opts.para;
|
|
200
|
+
this.disableModal = !!opts.disableModal;
|
|
201
|
+
this.viemChains = opts.chains.reduce((acc, curChain) => {
|
|
202
|
+
acc[decimalToHex(`${curChain.id}`)] = curChain;
|
|
203
|
+
return acc;
|
|
204
|
+
}, {});
|
|
205
|
+
this.chains = this.wagmiChainsToAddEthereumChainParameters(opts.chains);
|
|
206
|
+
this.transports = opts.transports;
|
|
207
|
+
if (!this.disableModal && opts.renderModal) {
|
|
208
|
+
const { openModal } = opts.renderModal(this.closeModal);
|
|
209
|
+
this.openModal = openModal;
|
|
210
|
+
}
|
|
211
|
+
const defaultChainId = this.getStorageChainId() || opts.chainId;
|
|
212
|
+
const currentChainId = this.chains[decimalToHex(defaultChainId)] ? defaultChainId : `${opts.chains[0].id}`;
|
|
213
|
+
this.setCurrentChain(decimalToHex(currentChainId));
|
|
214
|
+
this.emit("connect", { chainId: this.currentHexChainId });
|
|
215
|
+
}
|
|
216
|
+
get accounts() {
|
|
217
|
+
return this.para.getWalletsByType("EVM").map((w) => w.address);
|
|
218
|
+
}
|
|
219
|
+
getStorageChainId() {
|
|
220
|
+
return this.storage.getItem(STORAGE_CHAIN_ID_KEY);
|
|
221
|
+
}
|
|
222
|
+
setChainId(hexChainId) {
|
|
223
|
+
this.currentHexChainId = hexChainId;
|
|
224
|
+
this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
|
|
225
|
+
}
|
|
226
|
+
waitForLogin() {
|
|
227
|
+
return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
|
|
228
|
+
const startTime = Date.now();
|
|
229
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
230
|
+
if (yield this.para.isFullyLoggedIn()) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
if (!this.disableModal && this.isModalClosed) {
|
|
234
|
+
throw new ProviderRpcError(new Error("user closed modal"), {
|
|
235
|
+
code: 4001,
|
|
236
|
+
shortMessage: "user closed modal"
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
yield new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
240
|
+
}
|
|
241
|
+
throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
|
|
242
|
+
code: 4900,
|
|
243
|
+
//provider is disconnected code
|
|
244
|
+
shortMessage: "timed out waiting for user to log in"
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
waitForAccounts(timeoutMs = 5e3) {
|
|
249
|
+
return __async(this, null, function* () {
|
|
250
|
+
const startTime = Date.now();
|
|
251
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
252
|
+
const accounts = this.accounts;
|
|
253
|
+
if (accounts && accounts.length > 0) {
|
|
254
|
+
return accounts;
|
|
255
|
+
}
|
|
256
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
257
|
+
}
|
|
258
|
+
throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
|
|
259
|
+
code: 4900,
|
|
260
|
+
//provider is disconnected code
|
|
261
|
+
shortMessage: "timed out waiting for accounts to load"
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export {
|
|
267
|
+
ParaEIP1193Provider
|
|
268
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __async = (__this, __arguments, generator) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
var fulfilled = (value) => {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var rejected = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.throw(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
__spreadValues,
|
|
44
|
+
__spreadProps,
|
|
45
|
+
__async
|
|
46
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { Chain } from 'wagmi/chains';
|
|
2
|
+
import { InjectedParameters } from 'wagmi/connectors';
|
|
3
|
+
import ParaWeb from '@getpara/web-sdk';
|
|
4
|
+
import { Transport } from 'viem';
|
|
5
|
+
export interface ParaConnectorOpts {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `chains` in the wagmi config instead.
|
|
8
|
+
*/
|
|
9
|
+
chains?: Chain[];
|
|
10
|
+
options: InjectedParameters;
|
|
11
|
+
para: ParaWeb;
|
|
12
|
+
disableModal?: boolean;
|
|
13
|
+
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 createParaConnector: ({ para, chains: _chains, disableModal, storageOverride, options, iconOverride, nameOverride, idOverride, transports, renderModal, }: ParaConnectorOpts & {
|
|
21
|
+
renderModal?: (onClose: () => void) => {
|
|
22
|
+
openModal: () => void;
|
|
23
|
+
};
|
|
24
|
+
}) => (config: {
|
|
25
|
+
chains: readonly [Chain, ...Chain[]];
|
|
26
|
+
emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
|
|
27
|
+
storage?: {
|
|
28
|
+
key: string;
|
|
29
|
+
getItem: <key_1 extends string, value extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key_1], defaultValue_1 extends value>(key: key_1, defaultValue?: defaultValue_1) => (defaultValue_1 extends null ? value : value) | Promise<defaultValue_1 extends null ? value : value>;
|
|
30
|
+
setItem: <key_1 extends string, value_1 extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key_1]>(key: key_1, value: value_1) => void | Promise<void>;
|
|
31
|
+
removeItem: (key: string) => void | Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
transports?: Record<number, import("wagmi").Transport> | undefined;
|
|
34
|
+
}) => {
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
icon: string;
|
|
38
|
+
disconnect: () => Promise<void>;
|
|
39
|
+
id: string;
|
|
40
|
+
rdns?: string | readonly string[] | undefined;
|
|
41
|
+
supportsSimulation?: boolean | undefined;
|
|
42
|
+
setup?: () => Promise<void>;
|
|
43
|
+
connect: (parameters?: {
|
|
44
|
+
chainId?: number | undefined;
|
|
45
|
+
isReconnecting?: boolean | undefined;
|
|
46
|
+
} | undefined) => Promise<{
|
|
47
|
+
accounts: readonly import("viem").Address[];
|
|
48
|
+
chainId: number;
|
|
49
|
+
}>;
|
|
50
|
+
getAccounts: () => Promise<readonly import("viem").Address[]>;
|
|
51
|
+
getChainId: () => Promise<number>;
|
|
52
|
+
getProvider: (parameters?: {
|
|
53
|
+
chainId?: number | undefined;
|
|
54
|
+
} | undefined) => Promise<{
|
|
55
|
+
on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
56
|
+
removeListener: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
57
|
+
request: import("viem").EIP1193RequestFn<import("viem").EIP1474Methods>;
|
|
58
|
+
isApexWallet?: true | undefined;
|
|
59
|
+
isAvalanche?: true | undefined;
|
|
60
|
+
isBackpack?: true | undefined;
|
|
61
|
+
isBifrost?: true | undefined;
|
|
62
|
+
isBitKeep?: true | undefined;
|
|
63
|
+
isBitski?: true | undefined;
|
|
64
|
+
isBlockWallet?: true | undefined;
|
|
65
|
+
isBraveWallet?: true | undefined;
|
|
66
|
+
isCoinbaseWallet?: true | undefined;
|
|
67
|
+
isDawn?: true | undefined;
|
|
68
|
+
isEnkrypt?: true | undefined;
|
|
69
|
+
isExodus?: true | undefined;
|
|
70
|
+
isFrame?: true | undefined;
|
|
71
|
+
isFrontier?: true | undefined;
|
|
72
|
+
isGamestop?: true | undefined;
|
|
73
|
+
isHyperPay?: true | undefined;
|
|
74
|
+
isImToken?: true | undefined;
|
|
75
|
+
isKuCoinWallet?: true | undefined;
|
|
76
|
+
isMathWallet?: true | undefined;
|
|
77
|
+
isMetaMask?: true | undefined;
|
|
78
|
+
isOkxWallet?: true | undefined;
|
|
79
|
+
isOKExWallet?: true | undefined;
|
|
80
|
+
isOneInchAndroidWallet?: true | undefined;
|
|
81
|
+
isOneInchIOSWallet?: true | undefined;
|
|
82
|
+
isOpera?: true | undefined;
|
|
83
|
+
isPhantom?: true | undefined;
|
|
84
|
+
isPortal?: true | undefined;
|
|
85
|
+
isRabby?: true | undefined;
|
|
86
|
+
isRainbow?: true | undefined;
|
|
87
|
+
isStatus?: true | undefined;
|
|
88
|
+
isTally?: true | undefined;
|
|
89
|
+
isTokenPocket?: true | undefined;
|
|
90
|
+
isTokenary?: true | undefined;
|
|
91
|
+
isTrust?: true | undefined;
|
|
92
|
+
isTrustWallet?: true | undefined;
|
|
93
|
+
isUniswapWallet?: true | undefined;
|
|
94
|
+
isXDEFI?: true | undefined;
|
|
95
|
+
isZerion?: true | undefined;
|
|
96
|
+
providers?: {
|
|
97
|
+
on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
98
|
+
removeListener: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
99
|
+
request: import("viem").EIP1193RequestFn<import("viem").EIP1474Methods>;
|
|
100
|
+
isApexWallet?: true;
|
|
101
|
+
isAvalanche?: true;
|
|
102
|
+
isBackpack?: true;
|
|
103
|
+
isBifrost?: true;
|
|
104
|
+
isBitKeep?: true;
|
|
105
|
+
isBitski?: true;
|
|
106
|
+
isBlockWallet?: true;
|
|
107
|
+
isBraveWallet?: true;
|
|
108
|
+
isCoinbaseWallet?: true;
|
|
109
|
+
isDawn?: true;
|
|
110
|
+
isEnkrypt?: true;
|
|
111
|
+
isExodus?: true;
|
|
112
|
+
isFrame?: true;
|
|
113
|
+
isFrontier?: true;
|
|
114
|
+
isGamestop?: true;
|
|
115
|
+
isHyperPay?: true;
|
|
116
|
+
isImToken?: true;
|
|
117
|
+
isKuCoinWallet?: true;
|
|
118
|
+
isMathWallet?: true;
|
|
119
|
+
isMetaMask?: true;
|
|
120
|
+
isOkxWallet?: true;
|
|
121
|
+
isOKExWallet?: true;
|
|
122
|
+
isOneInchAndroidWallet?: true;
|
|
123
|
+
isOneInchIOSWallet?: true;
|
|
124
|
+
isOpera?: true;
|
|
125
|
+
isPhantom?: true;
|
|
126
|
+
isPortal?: true;
|
|
127
|
+
isRabby?: true;
|
|
128
|
+
isRainbow?: true;
|
|
129
|
+
isStatus?: true;
|
|
130
|
+
isTally?: true;
|
|
131
|
+
isTokenPocket?: true;
|
|
132
|
+
isTokenary?: true;
|
|
133
|
+
isTrust?: true;
|
|
134
|
+
isTrustWallet?: true;
|
|
135
|
+
isUniswapWallet?: true;
|
|
136
|
+
isXDEFI?: true;
|
|
137
|
+
isZerion?: true;
|
|
138
|
+
providers?: /*elided*/ any[];
|
|
139
|
+
_events?: {
|
|
140
|
+
connect?: (() => void) | undefined;
|
|
141
|
+
} | undefined;
|
|
142
|
+
_state?: {
|
|
143
|
+
accounts?: string[];
|
|
144
|
+
initialized?: boolean;
|
|
145
|
+
isConnected?: boolean;
|
|
146
|
+
isPermanentlyDisconnected?: boolean;
|
|
147
|
+
isUnlocked?: boolean;
|
|
148
|
+
} | undefined;
|
|
149
|
+
}[];
|
|
150
|
+
_events?: {
|
|
151
|
+
connect?: (() => void) | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
_state?: {
|
|
154
|
+
accounts?: string[];
|
|
155
|
+
initialized?: boolean;
|
|
156
|
+
isConnected?: boolean;
|
|
157
|
+
isPermanentlyDisconnected?: boolean;
|
|
158
|
+
isUnlocked?: boolean;
|
|
159
|
+
} | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
getClient?: (parameters?: {
|
|
162
|
+
chainId?: number | undefined;
|
|
163
|
+
} | undefined) => Promise<import("viem").Client>;
|
|
164
|
+
isAuthorized: () => Promise<boolean>;
|
|
165
|
+
switchChain?: (parameters: import("@wagmi/core/internal").Compute<{
|
|
166
|
+
addEthereumChainParameter?: import("@wagmi/core/internal").ExactPartial<import("@wagmi/core/internal").Omit<import("viem").AddEthereumChainParameter, "chainId">> | undefined;
|
|
167
|
+
chainId: number;
|
|
168
|
+
}>) => Promise<Chain>;
|
|
169
|
+
onAccountsChanged: (accounts: string[]) => void;
|
|
170
|
+
onChainChanged: (chainId: string) => void;
|
|
171
|
+
onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
|
|
172
|
+
onDisconnect: (error?: Error | undefined) => void;
|
|
173
|
+
onMessage?: (message: import("viem").ProviderMessage) => void;
|
|
174
|
+
};
|
|
175
|
+
export declare const paraConnector: (opts: ParaConnectorOpts) => (config: {
|
|
176
|
+
chains: readonly [Chain, ...Chain[]];
|
|
177
|
+
emitter: import("@wagmi/core/internal").Emitter<import("wagmi").ConnectorEventMap>;
|
|
178
|
+
storage?: {
|
|
179
|
+
key: string;
|
|
180
|
+
getItem: <key_1 extends string, value extends (import("@wagmi/core").StorageItemMap & Record<string, unknown>)[key_1], defaultValue_1 extends value>(key: key_1, defaultValue?: defaultValue_1) => (defaultValue_1 extends null ? value : value) | Promise<defaultValue_1 extends null ? value : value>;
|
|
181
|
+
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>;
|
|
182
|
+
removeItem: (key: string) => void | Promise<void>;
|
|
183
|
+
};
|
|
184
|
+
transports?: Record<number, import("wagmi").Transport> | undefined;
|
|
185
|
+
}) => {
|
|
186
|
+
type: string;
|
|
187
|
+
name: string;
|
|
188
|
+
icon: string;
|
|
189
|
+
disconnect: () => Promise<void>;
|
|
190
|
+
id: string;
|
|
191
|
+
rdns?: string | readonly string[] | undefined;
|
|
192
|
+
supportsSimulation?: boolean | undefined;
|
|
193
|
+
setup?: () => Promise<void>;
|
|
194
|
+
connect: (parameters?: {
|
|
195
|
+
chainId?: number | undefined;
|
|
196
|
+
isReconnecting?: boolean | undefined;
|
|
197
|
+
} | undefined) => Promise<{
|
|
198
|
+
accounts: readonly import("viem").Address[];
|
|
199
|
+
chainId: number;
|
|
200
|
+
}>;
|
|
201
|
+
getAccounts: () => Promise<readonly import("viem").Address[]>;
|
|
202
|
+
getChainId: () => Promise<number>;
|
|
203
|
+
getProvider: (parameters?: {
|
|
204
|
+
chainId?: number | undefined;
|
|
205
|
+
} | undefined) => Promise<{
|
|
206
|
+
on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
207
|
+
removeListener: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
208
|
+
request: import("viem").EIP1193RequestFn<import("viem").EIP1474Methods>;
|
|
209
|
+
isApexWallet?: true | undefined;
|
|
210
|
+
isAvalanche?: true | undefined;
|
|
211
|
+
isBackpack?: true | undefined;
|
|
212
|
+
isBifrost?: true | undefined;
|
|
213
|
+
isBitKeep?: true | undefined;
|
|
214
|
+
isBitski?: true | undefined;
|
|
215
|
+
isBlockWallet?: true | undefined;
|
|
216
|
+
isBraveWallet?: true | undefined;
|
|
217
|
+
isCoinbaseWallet?: true | undefined;
|
|
218
|
+
isDawn?: true | undefined;
|
|
219
|
+
isEnkrypt?: true | undefined;
|
|
220
|
+
isExodus?: true | undefined;
|
|
221
|
+
isFrame?: true | undefined;
|
|
222
|
+
isFrontier?: true | undefined;
|
|
223
|
+
isGamestop?: true | undefined;
|
|
224
|
+
isHyperPay?: true | undefined;
|
|
225
|
+
isImToken?: true | undefined;
|
|
226
|
+
isKuCoinWallet?: true | undefined;
|
|
227
|
+
isMathWallet?: true | undefined;
|
|
228
|
+
isMetaMask?: true | undefined;
|
|
229
|
+
isOkxWallet?: true | undefined;
|
|
230
|
+
isOKExWallet?: true | undefined;
|
|
231
|
+
isOneInchAndroidWallet?: true | undefined;
|
|
232
|
+
isOneInchIOSWallet?: true | undefined;
|
|
233
|
+
isOpera?: true | undefined;
|
|
234
|
+
isPhantom?: true | undefined;
|
|
235
|
+
isPortal?: true | undefined;
|
|
236
|
+
isRabby?: true | undefined;
|
|
237
|
+
isRainbow?: true | undefined;
|
|
238
|
+
isStatus?: true | undefined;
|
|
239
|
+
isTally?: true | undefined;
|
|
240
|
+
isTokenPocket?: true | undefined;
|
|
241
|
+
isTokenary?: true | undefined;
|
|
242
|
+
isTrust?: true | undefined;
|
|
243
|
+
isTrustWallet?: true | undefined;
|
|
244
|
+
isUniswapWallet?: true | undefined;
|
|
245
|
+
isXDEFI?: true | undefined;
|
|
246
|
+
isZerion?: true | undefined;
|
|
247
|
+
providers?: {
|
|
248
|
+
on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
249
|
+
removeListener: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
250
|
+
request: import("viem").EIP1193RequestFn<import("viem").EIP1474Methods>;
|
|
251
|
+
isApexWallet?: true;
|
|
252
|
+
isAvalanche?: true;
|
|
253
|
+
isBackpack?: true;
|
|
254
|
+
isBifrost?: true;
|
|
255
|
+
isBitKeep?: true;
|
|
256
|
+
isBitski?: true;
|
|
257
|
+
isBlockWallet?: true;
|
|
258
|
+
isBraveWallet?: true;
|
|
259
|
+
isCoinbaseWallet?: true;
|
|
260
|
+
isDawn?: true;
|
|
261
|
+
isEnkrypt?: true;
|
|
262
|
+
isExodus?: true;
|
|
263
|
+
isFrame?: true;
|
|
264
|
+
isFrontier?: true;
|
|
265
|
+
isGamestop?: true;
|
|
266
|
+
isHyperPay?: true;
|
|
267
|
+
isImToken?: true;
|
|
268
|
+
isKuCoinWallet?: true;
|
|
269
|
+
isMathWallet?: true;
|
|
270
|
+
isMetaMask?: true;
|
|
271
|
+
isOkxWallet?: true;
|
|
272
|
+
isOKExWallet?: true;
|
|
273
|
+
isOneInchAndroidWallet?: true;
|
|
274
|
+
isOneInchIOSWallet?: true;
|
|
275
|
+
isOpera?: true;
|
|
276
|
+
isPhantom?: true;
|
|
277
|
+
isPortal?: true;
|
|
278
|
+
isRabby?: true;
|
|
279
|
+
isRainbow?: true;
|
|
280
|
+
isStatus?: true;
|
|
281
|
+
isTally?: true;
|
|
282
|
+
isTokenPocket?: true;
|
|
283
|
+
isTokenary?: true;
|
|
284
|
+
isTrust?: true;
|
|
285
|
+
isTrustWallet?: true;
|
|
286
|
+
isUniswapWallet?: true;
|
|
287
|
+
isXDEFI?: true;
|
|
288
|
+
isZerion?: true;
|
|
289
|
+
providers?: /*elided*/ any[];
|
|
290
|
+
_events?: {
|
|
291
|
+
connect?: (() => void) | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
_state?: {
|
|
294
|
+
accounts?: string[];
|
|
295
|
+
initialized?: boolean;
|
|
296
|
+
isConnected?: boolean;
|
|
297
|
+
isPermanentlyDisconnected?: boolean;
|
|
298
|
+
isUnlocked?: boolean;
|
|
299
|
+
} | undefined;
|
|
300
|
+
}[];
|
|
301
|
+
_events?: {
|
|
302
|
+
connect?: (() => void) | undefined;
|
|
303
|
+
} | undefined;
|
|
304
|
+
_state?: {
|
|
305
|
+
accounts?: string[];
|
|
306
|
+
initialized?: boolean;
|
|
307
|
+
isConnected?: boolean;
|
|
308
|
+
isPermanentlyDisconnected?: boolean;
|
|
309
|
+
isUnlocked?: boolean;
|
|
310
|
+
} | undefined;
|
|
311
|
+
}>;
|
|
312
|
+
getClient?: (parameters?: {
|
|
313
|
+
chainId?: number | undefined;
|
|
314
|
+
} | undefined) => Promise<import("viem").Client>;
|
|
315
|
+
isAuthorized: () => Promise<boolean>;
|
|
316
|
+
switchChain?: (parameters: import("@wagmi/core/internal").Compute<{
|
|
317
|
+
addEthereumChainParameter?: import("@wagmi/core/internal").ExactPartial<import("@wagmi/core/internal").Omit<import("viem").AddEthereumChainParameter, "chainId">> | undefined;
|
|
318
|
+
chainId: number;
|
|
319
|
+
}>) => Promise<Chain>;
|
|
320
|
+
onAccountsChanged: (accounts: string[]) => void;
|
|
321
|
+
onChainChanged: (chainId: string) => void;
|
|
322
|
+
onConnect: ((connectInfo: import("viem").ProviderConnectInfo) => void) & ((connectInfo: import("viem").ProviderConnectInfo) => void);
|
|
323
|
+
onDisconnect: (error?: Error | undefined) => void;
|
|
324
|
+
onMessage?: (message: import("viem").ProviderMessage) => void;
|
|
325
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-IV3L3JVM.js";
|
|
7
|
+
import { injected } from "wagmi/connectors";
|
|
8
|
+
import { ParaEIP1193Provider } from "./ParaEIP1193Provider.js";
|
|
9
|
+
import { createConnector } from "wagmi";
|
|
10
|
+
const PARA_ID = "para";
|
|
11
|
+
const PARA_NAME = "Para";
|
|
12
|
+
const PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
|
|
13
|
+
const createParaConnector = ({
|
|
14
|
+
para,
|
|
15
|
+
chains: _chains,
|
|
16
|
+
disableModal,
|
|
17
|
+
storageOverride,
|
|
18
|
+
options,
|
|
19
|
+
iconOverride,
|
|
20
|
+
nameOverride,
|
|
21
|
+
idOverride,
|
|
22
|
+
transports,
|
|
23
|
+
renderModal
|
|
24
|
+
}) => {
|
|
25
|
+
return createConnector((config) => {
|
|
26
|
+
const chains = [...config.chains];
|
|
27
|
+
const eip1193Provider = new ParaEIP1193Provider({
|
|
28
|
+
para,
|
|
29
|
+
chainId: `${chains[0].id}`,
|
|
30
|
+
chains,
|
|
31
|
+
disableModal,
|
|
32
|
+
storageOverride,
|
|
33
|
+
transports: transports || config.transports,
|
|
34
|
+
renderModal
|
|
35
|
+
});
|
|
36
|
+
const injectedObj = injected(__spreadValues({
|
|
37
|
+
target: {
|
|
38
|
+
name: PARA_NAME,
|
|
39
|
+
id: idOverride != null ? idOverride : PARA_ID,
|
|
40
|
+
provider: eip1193Provider
|
|
41
|
+
}
|
|
42
|
+
}, options))(config);
|
|
43
|
+
return __spreadProps(__spreadValues({}, injectedObj), {
|
|
44
|
+
type: idOverride != null ? idOverride : PARA_ID,
|
|
45
|
+
name: nameOverride != null ? nameOverride : PARA_NAME,
|
|
46
|
+
icon: iconOverride != null ? iconOverride : PARA_ICON,
|
|
47
|
+
disconnect: () => __async(void 0, null, function* () {
|
|
48
|
+
eip1193Provider.closeModal();
|
|
49
|
+
yield injectedObj.disconnect();
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const paraConnector = (opts) => {
|
|
55
|
+
return createParaConnector(opts);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
createParaConnector,
|
|
59
|
+
paraConnector
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/wagmi-v2-connector",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.61",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/viem-v2-integration": "2.0.0-alpha.
|
|
6
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
5
|
+
"@getpara/viem-v2-integration": "2.0.0-alpha.61",
|
|
6
|
+
"@getpara/web-sdk": "2.0.0-alpha.61"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"typescript": "^5.8.3",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist",
|
|
15
15
|
"package.json"
|
|
16
16
|
],
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "3a84954ff65c95d95fa96794bf0b0d4dc646c624",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": "*",
|