@getpara/wagmi-v2-integration 1.4.4 → 1.5.1
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/index.js +138 -78
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
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
|
+
};
|
|
2
53
|
|
|
3
54
|
// src/paraConnector.ts
|
|
4
55
|
import { injected } from "wagmi/connectors";
|
|
@@ -21,7 +72,7 @@ import { ParaModal } from "@getpara/react-sdk";
|
|
|
21
72
|
import { jsx } from "react/jsx-runtime";
|
|
22
73
|
function renderModal(para, modalProps, onCloseArg) {
|
|
23
74
|
const existingContainer = document.getElementById("para-modal");
|
|
24
|
-
const container = existingContainer
|
|
75
|
+
const container = existingContainer != null ? existingContainer : document.createElement("div");
|
|
25
76
|
container.id = "para-modal";
|
|
26
77
|
if (!existingContainer) {
|
|
27
78
|
document.body.appendChild(container);
|
|
@@ -31,17 +82,17 @@ function renderModal(para, modalProps, onCloseArg) {
|
|
|
31
82
|
modalProps.onClose && modalProps.onClose();
|
|
32
83
|
render(false);
|
|
33
84
|
};
|
|
34
|
-
const render =
|
|
35
|
-
const Modal = /* @__PURE__ */ jsx(ParaModal, {
|
|
85
|
+
const render = (isOpen) => __async(this, null, function* () {
|
|
86
|
+
const Modal = /* @__PURE__ */ jsx(ParaModal, __spreadProps(__spreadValues({}, modalProps), { onClose, para, isOpen }));
|
|
36
87
|
try {
|
|
37
|
-
const client =
|
|
88
|
+
const client = yield import("react-dom/client");
|
|
38
89
|
const root = client.createRoot(container);
|
|
39
90
|
root.render(Modal);
|
|
40
91
|
} catch (e) {
|
|
41
|
-
const ReactDOM =
|
|
92
|
+
const ReactDOM = yield import("react-dom");
|
|
42
93
|
ReactDOM.render(Modal, container);
|
|
43
94
|
}
|
|
44
|
-
};
|
|
95
|
+
});
|
|
45
96
|
render(true);
|
|
46
97
|
}
|
|
47
98
|
|
|
@@ -111,7 +162,7 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
111
162
|
this.closeModal = () => {
|
|
112
163
|
this.isModalClosed = true;
|
|
113
164
|
};
|
|
114
|
-
this.request =
|
|
165
|
+
this.request = (args) => __async(this, null, function* () {
|
|
115
166
|
const { method, params } = args;
|
|
116
167
|
switch (method) {
|
|
117
168
|
case "eth_accounts": {
|
|
@@ -122,7 +173,7 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
122
173
|
return this.currentHexChainId;
|
|
123
174
|
}
|
|
124
175
|
case "eth_requestAccounts": {
|
|
125
|
-
if (
|
|
176
|
+
if (yield this.para.isFullyLoggedIn()) {
|
|
126
177
|
const accounts = this.accounts;
|
|
127
178
|
if (accounts && accounts.length > 0) {
|
|
128
179
|
return accounts;
|
|
@@ -134,9 +185,9 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
134
185
|
this.isModalClosed = true;
|
|
135
186
|
});
|
|
136
187
|
}
|
|
137
|
-
|
|
188
|
+
yield this.waitForLogin();
|
|
138
189
|
try {
|
|
139
|
-
const accounts =
|
|
190
|
+
const accounts = yield this.waitForAccounts();
|
|
140
191
|
this.emit("accountsChanged", accounts);
|
|
141
192
|
return accounts;
|
|
142
193
|
} catch (error) {
|
|
@@ -148,12 +199,11 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
148
199
|
}
|
|
149
200
|
case "eth_sendTransaction": {
|
|
150
201
|
const fromAddress = params[0].from;
|
|
151
|
-
return this.walletClient.sendTransaction({
|
|
152
|
-
...formatTransaction(params[0]),
|
|
202
|
+
return this.walletClient.sendTransaction(__spreadProps(__spreadValues({}, formatTransaction(params[0])), {
|
|
153
203
|
chain: void 0,
|
|
154
204
|
// uses the chain from the wallet client
|
|
155
205
|
account: this.accountFromAddress(fromAddress)
|
|
156
|
-
});
|
|
206
|
+
}));
|
|
157
207
|
}
|
|
158
208
|
case "eth_sign":
|
|
159
209
|
case "personal_sign": {
|
|
@@ -172,10 +222,9 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
172
222
|
if (typeof typedMessage === "string") {
|
|
173
223
|
typedMessage = JSON.parse(typedMessage);
|
|
174
224
|
}
|
|
175
|
-
return this.walletClient.signTypedData({
|
|
176
|
-
...typedMessage,
|
|
225
|
+
return this.walletClient.signTypedData(__spreadProps(__spreadValues({}, typedMessage), {
|
|
177
226
|
account: this.accountFromAddress(fromAddress)
|
|
178
|
-
});
|
|
227
|
+
}));
|
|
179
228
|
}
|
|
180
229
|
case "eth_subscribe": {
|
|
181
230
|
if (!this.chainTransportSubscribe) {
|
|
@@ -184,7 +233,7 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
184
233
|
shortMessage: "chain does not support subscriptions"
|
|
185
234
|
});
|
|
186
235
|
}
|
|
187
|
-
const res =
|
|
236
|
+
const res = yield this.chainTransportSubscribe({
|
|
188
237
|
params,
|
|
189
238
|
onData: (data) => {
|
|
190
239
|
this.emit("message", {
|
|
@@ -229,11 +278,11 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
229
278
|
});
|
|
230
279
|
}
|
|
231
280
|
}
|
|
232
|
-
};
|
|
281
|
+
});
|
|
233
282
|
this.storage = opts.storageOverride || typeof window === "undefined" ? serverSessionStorageStub : sessionStorage;
|
|
234
283
|
this.isModalClosed = true;
|
|
235
284
|
this.para = opts.para;
|
|
236
|
-
this.modalProps = {
|
|
285
|
+
this.modalProps = __spreadValues({}, opts);
|
|
237
286
|
this.disableModal = !!opts.disableModal;
|
|
238
287
|
this.viemChains = opts.chains.reduce((acc, curChain) => {
|
|
239
288
|
acc[decimalToHex(`${curChain.id}`)] = curChain;
|
|
@@ -256,39 +305,43 @@ var ParaEIP1193Provider = class extends EventEmitter {
|
|
|
256
305
|
this.currentHexChainId = hexChainId;
|
|
257
306
|
this.storage.setItem(STORAGE_CHAIN_ID_KEY, hexToDecimal(hexChainId));
|
|
258
307
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
308
|
+
waitForLogin() {
|
|
309
|
+
return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
|
|
310
|
+
const startTime = Date.now();
|
|
311
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
312
|
+
if (yield this.para.isFullyLoggedIn()) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
if (!this.disableModal && this.isModalClosed) {
|
|
316
|
+
throw new ProviderRpcError(new Error("user closed modal"), {
|
|
317
|
+
code: 4001,
|
|
318
|
+
shortMessage: "user closed modal"
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
yield new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
270
322
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
shortMessage: "timed out waiting for user to log in"
|
|
323
|
+
throw new ProviderRpcError(new Error("timed out waiting for user to log in"), {
|
|
324
|
+
code: 4900,
|
|
325
|
+
//provider is disconnected code
|
|
326
|
+
shortMessage: "timed out waiting for user to log in"
|
|
327
|
+
});
|
|
277
328
|
});
|
|
278
329
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
330
|
+
waitForAccounts(timeoutMs = 5e3) {
|
|
331
|
+
return __async(this, null, function* () {
|
|
332
|
+
const startTime = Date.now();
|
|
333
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
334
|
+
const accounts = this.accounts;
|
|
335
|
+
if (accounts && accounts.length > 0) {
|
|
336
|
+
return accounts;
|
|
337
|
+
}
|
|
338
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
285
339
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
shortMessage: "timed out waiting for accounts to load"
|
|
340
|
+
throw new ProviderRpcError(new Error("timed out waiting for accounts to load"), {
|
|
341
|
+
code: 4900,
|
|
342
|
+
//provider is disconnected code
|
|
343
|
+
shortMessage: "timed out waiting for accounts to load"
|
|
344
|
+
});
|
|
292
345
|
});
|
|
293
346
|
}
|
|
294
347
|
};
|
|
@@ -298,48 +351,55 @@ import { createConnector } from "wagmi";
|
|
|
298
351
|
var PARA_ID = "para";
|
|
299
352
|
var PARA_NAME = "Para";
|
|
300
353
|
var PARA_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjE2IiBoZWlnaHQ9IjIwNCIgdmlld0JveD0iMCAwIDIxNiAyMDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02MCAwSDE0NEMxODMuNzY0IDAgMjE2IDMyLjIzNTUgMjE2IDcyQzIxNiAxMTEuNzY1IDE4My43NjQgMTQ0IDE0NCAxNDRIOTZDODIuNzQ1MiAxNDQgNzIgMTU0Ljc0NSA3MiAxNjhWMjA0SDBWMTMySDM2QzQ5LjI1NDggMTMyIDYwIDEyMS4yNTUgNjAgMTA4TDYwIDBaIiBmaWxsPSJibGFjayIvPgo8L3N2Zz4K";
|
|
301
|
-
var paraConnector = ({
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
354
|
+
var paraConnector = (_a) => {
|
|
355
|
+
var _b = _a, {
|
|
356
|
+
para,
|
|
357
|
+
chains: _chains,
|
|
358
|
+
disableModal,
|
|
359
|
+
storageOverride,
|
|
360
|
+
options,
|
|
361
|
+
iconOverride,
|
|
362
|
+
nameOverride,
|
|
363
|
+
idOverride,
|
|
364
|
+
transports
|
|
365
|
+
} = _b, modalProps = __objRest(_b, [
|
|
366
|
+
"para",
|
|
367
|
+
"chains",
|
|
368
|
+
"disableModal",
|
|
369
|
+
"storageOverride",
|
|
370
|
+
"options",
|
|
371
|
+
"iconOverride",
|
|
372
|
+
"nameOverride",
|
|
373
|
+
"idOverride",
|
|
374
|
+
"transports"
|
|
375
|
+
]);
|
|
313
376
|
return createConnector((config) => {
|
|
314
377
|
const chains = [...config.chains];
|
|
315
|
-
const eip1193Provider = new ParaEIP1193Provider({
|
|
378
|
+
const eip1193Provider = new ParaEIP1193Provider(__spreadValues({
|
|
316
379
|
para,
|
|
317
380
|
chainId: `${chains[0].id}`,
|
|
318
381
|
chains,
|
|
319
382
|
disableModal,
|
|
320
383
|
storageOverride,
|
|
321
|
-
transports: transports || config.transports
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const injectedObj = injected({
|
|
384
|
+
transports: transports || config.transports
|
|
385
|
+
}, modalProps));
|
|
386
|
+
const injectedObj = injected(__spreadValues({
|
|
325
387
|
target: {
|
|
326
388
|
name: PARA_NAME,
|
|
327
|
-
id: idOverride
|
|
389
|
+
id: idOverride != null ? idOverride : PARA_ID,
|
|
328
390
|
provider: eip1193Provider
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
icon: iconOverride ?? PARA_ICON,
|
|
337
|
-
disconnect: async () => {
|
|
391
|
+
}
|
|
392
|
+
}, options))(config);
|
|
393
|
+
return __spreadProps(__spreadValues({}, injectedObj), {
|
|
394
|
+
type: idOverride != null ? idOverride : PARA_ID,
|
|
395
|
+
name: nameOverride != null ? nameOverride : PARA_NAME,
|
|
396
|
+
icon: iconOverride != null ? iconOverride : PARA_ICON,
|
|
397
|
+
disconnect: () => __async(void 0, null, function* () {
|
|
338
398
|
eip1193Provider.closeModal();
|
|
339
|
-
|
|
399
|
+
yield injectedObj.disconnect();
|
|
340
400
|
para.logout();
|
|
341
|
-
}
|
|
342
|
-
};
|
|
401
|
+
})
|
|
402
|
+
});
|
|
343
403
|
});
|
|
344
404
|
};
|
|
345
405
|
export {
|
package/dist/index.js.br
CHANGED
|
Binary file
|
package/dist/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/wagmi-v2-integration",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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.
|
|
10
|
-
"@getpara/viem-v2-integration": "1.
|
|
9
|
+
"@getpara/react-sdk": "1.5.1",
|
|
10
|
+
"@getpara/viem-v2-integration": "1.5.1"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"dist",
|
|
29
29
|
"package.json"
|
|
30
30
|
],
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
|
|
32
32
|
}
|