@etherplay/connect 0.0.6 → 0.0.8
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.d.ts +2 -1
- package/dist/index.js +35 -16
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -73,8 +73,9 @@ export declare function createConnection(settings: {
|
|
|
73
73
|
}): {
|
|
74
74
|
subscribe: (this: void, run: import("svelte/store").Subscriber<Connection>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
75
75
|
connect: (mechanism?: Mechanism, options?: {
|
|
76
|
-
|
|
76
|
+
requireUserConfirmationBeforeSIgnatureRequest?: boolean;
|
|
77
77
|
doNotStoreLocally?: boolean;
|
|
78
|
+
requestSignatureRightAway?: boolean;
|
|
78
79
|
}) => Promise<void>;
|
|
79
80
|
cancel: () => void;
|
|
80
81
|
back: (step: "MechanismToChoose" | "Idle" | "WalletToChoose") => void;
|
package/dist/index.js
CHANGED
|
@@ -215,6 +215,7 @@ export function createConnection(settings) {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
function onAccountChanged(accounts) {
|
|
218
|
+
const accountsFormated = accounts.map((a) => a.toLowerCase());
|
|
218
219
|
if ($connection.step === 'SignedIn' && $connection.mechanism.type === 'wallet') {
|
|
219
220
|
// TODO if auto-connect and saved-signature ?
|
|
220
221
|
// connect(
|
|
@@ -223,13 +224,12 @@ export function createConnection(settings) {
|
|
|
223
224
|
// address: accounts[0],
|
|
224
225
|
// name: $connection.mechanism.name
|
|
225
226
|
// },
|
|
226
|
-
// {
|
|
227
|
+
// { requireUserConfirmationBeforeSIgnatureRequest: true }
|
|
227
228
|
// );
|
|
228
|
-
if (
|
|
229
|
-
accounts[0].toLowerCase() != $connection.account.address.toLowerCase()) {
|
|
229
|
+
if (accountsFormated.length > 0 && accountsFormated[0] != $connection.account.address) {
|
|
230
230
|
set({
|
|
231
231
|
...$connection,
|
|
232
|
-
walletAccountChanged:
|
|
232
|
+
walletAccountChanged: accountsFormated[0]
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
else if ($connection.walletAccountChanged) {
|
|
@@ -271,6 +271,7 @@ export function createConnection(settings) {
|
|
|
271
271
|
});
|
|
272
272
|
const provider = wallet.provider;
|
|
273
273
|
let accounts = await provider.request({ method: 'eth_accounts' });
|
|
274
|
+
accounts = accounts.map((v) => v.toLowerCase());
|
|
274
275
|
if (accounts.length === 0) {
|
|
275
276
|
set({
|
|
276
277
|
step: 'WaitingForWalletConnection',
|
|
@@ -278,16 +279,31 @@ export function createConnection(settings) {
|
|
|
278
279
|
wallets: $connection.wallets
|
|
279
280
|
});
|
|
280
281
|
accounts = await provider.request({ method: 'eth_requestAccounts' });
|
|
282
|
+
accounts = accounts.map((v) => v.toLowerCase());
|
|
281
283
|
if (accounts.length > 0) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
if (options?.requestSignatureRightAway) {
|
|
285
|
+
watchForAccountChange(walletProvider);
|
|
286
|
+
set({
|
|
287
|
+
step: 'NeedWalletSignature',
|
|
288
|
+
mechanism: {
|
|
289
|
+
...mechanism,
|
|
290
|
+
address: accounts[0]
|
|
291
|
+
},
|
|
292
|
+
wallets: $connection.wallets
|
|
293
|
+
});
|
|
294
|
+
await requestSignature();
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
set({
|
|
298
|
+
step: 'NeedWalletSignature',
|
|
299
|
+
mechanism: {
|
|
300
|
+
...mechanism,
|
|
301
|
+
address: accounts[0]
|
|
302
|
+
},
|
|
303
|
+
wallets: $connection.wallets
|
|
304
|
+
});
|
|
305
|
+
watchForAccountChange(walletProvider);
|
|
306
|
+
}
|
|
291
307
|
}
|
|
292
308
|
else {
|
|
293
309
|
set({
|
|
@@ -298,7 +314,7 @@ export function createConnection(settings) {
|
|
|
298
314
|
}
|
|
299
315
|
}
|
|
300
316
|
else {
|
|
301
|
-
if (options?.
|
|
317
|
+
if (options?.requireUserConfirmationBeforeSIgnatureRequest) {
|
|
302
318
|
set({
|
|
303
319
|
step: 'NeedWalletSignature',
|
|
304
320
|
mechanism: {
|
|
@@ -464,8 +480,11 @@ export function createConnection(settings) {
|
|
|
464
480
|
entriesToAdd.push([entry[0].slice(`renraku_`.length), entry[1]]);
|
|
465
481
|
}
|
|
466
482
|
}
|
|
467
|
-
if (currentURL.searchParams.has('
|
|
468
|
-
entriesToAdd.push(['
|
|
483
|
+
if (currentURL.searchParams.has('eruda')) {
|
|
484
|
+
entriesToAdd.push(['eruda', currentURL.searchParams.get('eruda') || '']);
|
|
485
|
+
}
|
|
486
|
+
if (currentURL.searchParams.has('eruda')) {
|
|
487
|
+
entriesToAdd.push(['eruda', currentURL.searchParams.get('eruda') || '']);
|
|
469
488
|
}
|
|
470
489
|
for (const entryToAdd of entriesToAdd) {
|
|
471
490
|
popupURL.searchParams.append(entryToAdd[0], entryToAdd[1]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etherplay/connect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@scure/bip32": "^1.6.2",
|
|
53
53
|
"@scure/bip39": "^1.5.4",
|
|
54
54
|
"zustand": "^5.0.3",
|
|
55
|
-
"@etherplay/alchemy": "0.0.
|
|
55
|
+
"@etherplay/alchemy": "0.0.6"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"dev": "vite dev --host --port 60002",
|