@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 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
- alwaysRequestSignatureOnlyAfterUserConfirmation?: boolean;
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
- // { alwaysRequestSignatureOnlyAfterUserConfirmation: true }
227
+ // { requireUserConfirmationBeforeSIgnatureRequest: true }
227
228
  // );
228
- if (accounts.length > 0 &&
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: accounts[0]
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
- set({
283
- step: 'NeedWalletSignature',
284
- mechanism: {
285
- ...mechanism,
286
- address: accounts[0]
287
- },
288
- wallets: $connection.wallets
289
- });
290
- watchForAccountChange(walletProvider);
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?.alwaysRequestSignatureOnlyAfterUserConfirmation) {
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('_d_eruda')) {
468
- entriesToAdd.push(['_d_eruda', currentURL.searchParams.get('_d_eruda') || '']);
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.6",
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.5"
55
+ "@etherplay/alchemy": "0.0.6"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "vite dev --host --port 60002",