@farcaster/miniapp-wagmi-connector 1.1.1 → 2.0.0

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.
@@ -20,7 +20,7 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
20
20
  } | {
21
21
  Request: {
22
22
  method: "eth_call";
23
- params: [transaction: import("ox/TransactionRequest").Rpc] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier, stateOverride: unknown];
23
+ params: [transaction: import("ox/TransactionRequest").Rpc] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier, stateOverrides: import("ox/StateOverrides").Rpc];
24
24
  };
25
25
  ReturnType: import("ox/Hex").Hex;
26
26
  } | {
@@ -38,7 +38,7 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
38
38
  } | {
39
39
  Request: {
40
40
  method: "eth_estimateGas";
41
- params: [transaction: import("ox/TransactionRequest").Rpc] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier, stateOverride: unknown];
41
+ params: [transaction: import("ox/TransactionRequest").Rpc] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier] | [transaction: import("ox/TransactionRequest").Rpc, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier, stateOverrides: import("ox/StateOverrides").Rpc];
42
42
  };
43
43
  ReturnType: import("ox/Hex").Hex;
44
44
  } | {
@@ -203,12 +203,45 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
203
203
  params: [serializedTransaction: import("ox/Hex").Hex];
204
204
  };
205
205
  ReturnType: import("ox/Hex").Hex;
206
+ } | {
207
+ Request: {
208
+ method: "eth_sendRawTransactionSync";
209
+ params: [serializedTransaction: import("ox/Hex").Hex] | [serializedTransaction: import("ox/Hex").Hex, timeout: number];
210
+ };
211
+ ReturnType: import("ox/TransactionReceipt").Rpc;
206
212
  } | {
207
213
  Request: {
208
214
  method: "eth_sendTransaction";
209
215
  params: [transaction: import("ox/TransactionRequest").Rpc];
210
216
  };
211
217
  ReturnType: import("ox/Hex").Hex;
218
+ } | {
219
+ Request: {
220
+ method: "eth_simulateV1";
221
+ params: [{
222
+ blockStateCalls: readonly {
223
+ blockOverrides?: import("ox/BlockOverrides").Rpc | undefined;
224
+ calls?: readonly import("ox/TransactionRequest").Rpc[] | undefined;
225
+ stateOverrides?: import("ox/StateOverrides").Rpc | undefined;
226
+ }[];
227
+ returnFullTransactions?: boolean | undefined;
228
+ traceTransfers?: boolean | undefined;
229
+ validation?: boolean | undefined;
230
+ }, block: import("ox/Block").Number<import("ox/Hex").Hex> | import("ox/Block").Tag | import("ox/Block").Hash | import("ox/Block").Identifier];
231
+ };
232
+ ReturnType: readonly (import("ox/Block").Rpc & {
233
+ calls?: readonly {
234
+ error?: {
235
+ data?: import("ox/Hex").Hex | undefined;
236
+ code: number;
237
+ message: string;
238
+ } | undefined;
239
+ logs?: readonly import("ox/Log").Rpc[] | undefined;
240
+ gasUsed: import("ox/Hex").Hex;
241
+ returnData: import("ox/Hex").Hex;
242
+ status: import("ox/Hex").Hex;
243
+ }[] | undefined;
244
+ })[];
212
245
  } | {
213
246
  Request: {
214
247
  method: "eth_signTransaction";
@@ -239,6 +272,12 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
239
272
  params: [serializedTransaction: import("ox/Hex").Hex];
240
273
  };
241
274
  ReturnType: import("ox/Hex").Hex;
275
+ } | {
276
+ Request: {
277
+ method: "eth_sendRawTransactionSync";
278
+ params: [serializedTransaction: import("ox/Hex").Hex] | [serializedTransaction: import("ox/Hex").Hex, timeout: number];
279
+ };
280
+ ReturnType: import("ox/TransactionReceipt").Rpc;
242
281
  } | {
243
282
  Request: {
244
283
  method: "eth_sendTransaction";
@@ -286,7 +325,12 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
286
325
  params?: [string];
287
326
  };
288
327
  ReturnType: {
289
- status: "PENDING" | "CONFIRMED";
328
+ atomic: boolean;
329
+ capabilities?: {
330
+ [capability: string]: any;
331
+ } | undefined;
332
+ chainId: import("ox/Hex").Hex;
333
+ id: string;
290
334
  receipts?: readonly {
291
335
  logs: {
292
336
  address: import("ox/Hex").Hex;
@@ -299,11 +343,13 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
299
343
  gasUsed: import("ox/Hex").Hex;
300
344
  transactionHash: import("ox/Hex").Hex;
301
345
  }[] | undefined;
346
+ status: number;
347
+ version: string;
302
348
  };
303
349
  } | {
304
350
  Request: {
305
351
  method: "wallet_getCapabilities";
306
- params?: [import("ox/Address").Address];
352
+ params?: readonly [] | readonly [import("ox/Address").Address | undefined] | readonly [import("ox/Address").Address | undefined, readonly import("ox/Hex").Hex[] | undefined] | undefined;
307
353
  };
308
354
  ReturnType: {
309
355
  [x: `0x${string}`]: {
@@ -393,7 +439,11 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
393
439
  Request: {
394
440
  method: "wallet_sendCalls";
395
441
  params: [{
442
+ atomicRequired: boolean;
396
443
  calls: readonly {
444
+ capabilities?: {
445
+ [capability: string]: any;
446
+ } | undefined;
397
447
  to?: import("ox/Address").Address | undefined;
398
448
  data?: import("ox/Hex").Hex | undefined;
399
449
  value?: import("ox/Hex").Hex | undefined;
@@ -402,11 +452,17 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
402
452
  [capability: string]: any;
403
453
  } | undefined;
404
454
  chainId?: import("ox/Hex").Hex | undefined;
405
- from: import("ox/Address").Address;
455
+ id?: string | undefined;
456
+ from?: import("ox/Address").Address | undefined;
406
457
  version: string;
407
458
  }];
408
459
  };
409
- ReturnType: string;
460
+ ReturnType: {
461
+ capabilities?: {
462
+ [capability: string]: any;
463
+ } | undefined;
464
+ id: string;
465
+ };
410
466
  } | {
411
467
  Request: {
412
468
  method: "wallet_showCallsStatus";
@@ -436,8 +492,94 @@ export declare function farcasterMiniApp(): import("@wagmi/core").CreateConnecto
436
492
  };
437
493
  ReturnType: boolean;
438
494
  }>;
439
- on: import("ox/Provider").EventListenerFn;
440
- removeListener: import("ox/Provider").EventListenerFn;
495
+ eventNames?: (() => ("connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message")[]) | undefined;
496
+ listeners?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T) => ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
497
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
498
+ chainChanged: (chainId: string) => void;
499
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
500
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
501
+ message: (message: import("ox/Provider").Message) => void;
502
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void)[]) | undefined;
503
+ listenerCount?: ((event: "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message") => number) | undefined;
504
+ emit?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, ...args: import("eventemitter3").EventEmitter.ArgumentMap<{
505
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
506
+ chainChanged: (chainId: string) => void;
507
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
508
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
509
+ message: (message: import("ox/Provider").Message) => void;
510
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => boolean) | undefined;
511
+ on?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
512
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
513
+ chainChanged: (chainId: string) => void;
514
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
515
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
516
+ message: (message: import("ox/Provider").Message) => void;
517
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
518
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
519
+ chainChanged: (chainId: string) => void;
520
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
521
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
522
+ message: (message: import("ox/Provider").Message) => void;
523
+ }, any>) | undefined;
524
+ addListener?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
525
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
526
+ chainChanged: (chainId: string) => void;
527
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
528
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
529
+ message: (message: import("ox/Provider").Message) => void;
530
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
531
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
532
+ chainChanged: (chainId: string) => void;
533
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
534
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
535
+ message: (message: import("ox/Provider").Message) => void;
536
+ }, any>) | undefined;
537
+ once?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
538
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
539
+ chainChanged: (chainId: string) => void;
540
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
541
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
542
+ message: (message: import("ox/Provider").Message) => void;
543
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
544
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
545
+ chainChanged: (chainId: string) => void;
546
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
547
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
548
+ message: (message: import("ox/Provider").Message) => void;
549
+ }, any>) | undefined;
550
+ removeListener?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
551
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
552
+ chainChanged: (chainId: string) => void;
553
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
554
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
555
+ message: (message: import("ox/Provider").Message) => void;
556
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void) | undefined, context?: any, once?: boolean) => import("eventemitter3").EventEmitter<{
557
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
558
+ chainChanged: (chainId: string) => void;
559
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
560
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
561
+ message: (message: import("ox/Provider").Message) => void;
562
+ }, any>) | undefined;
563
+ off?: (<T extends "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
564
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
565
+ chainChanged: (chainId: string) => void;
566
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
567
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
568
+ message: (message: import("ox/Provider").Message) => void;
569
+ }>[Extract<T, "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message">]) => void) | undefined, context?: any, once?: boolean) => import("eventemitter3").EventEmitter<{
570
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
571
+ chainChanged: (chainId: string) => void;
572
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
573
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
574
+ message: (message: import("ox/Provider").Message) => void;
575
+ }, any>) | undefined;
576
+ removeAllListeners?: ((event?: "connect" | "disconnect" | "accountsChanged" | "chainChanged" | "message" | undefined) => import("eventemitter3").EventEmitter<{
577
+ accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
578
+ chainChanged: (chainId: string) => void;
579
+ connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
580
+ disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
581
+ message: (message: import("ox/Provider").Message) => void;
582
+ }, any>) | undefined;
441
583
  }, Record<string, unknown>, Record<string, unknown>>;
442
584
  export declare namespace farcasterMiniApp {
443
585
  var type: string;
package/dist/connector.js CHANGED
@@ -5,6 +5,14 @@ farcasterMiniApp.type = 'farcasterMiniApp';
5
5
  let accountsChanged;
6
6
  let chainChanged;
7
7
  let disconnect;
8
+ function assertProviderHasEventEmitterMethods(provider) {
9
+ if (typeof provider.on !== 'function') {
10
+ throw new Error('MiniApp provider does not support event listeners.');
11
+ }
12
+ if (typeof provider.removeListener !== 'function') {
13
+ throw new Error('MiniApp provider does not support removing listeners.');
14
+ }
15
+ }
8
16
  export function farcasterMiniApp() {
9
17
  return createConnector((config) => ({
10
18
  id: 'farcaster',
@@ -14,6 +22,7 @@ export function farcasterMiniApp() {
14
22
  type: farcasterMiniApp.type,
15
23
  async connect({ chainId } = {}) {
16
24
  const provider = await this.getProvider();
25
+ assertProviderHasEventEmitterMethods(provider);
17
26
  const accounts = await provider.request({
18
27
  method: 'eth_requestAccounts',
19
28
  });
@@ -29,8 +38,8 @@ export function farcasterMiniApp() {
29
38
  if (!targetChainId)
30
39
  throw new Error('No chains found on connector.');
31
40
  if (!accountsChanged) {
32
- accountsChanged = this.onAccountsChanged.bind(this);
33
- // @ts-expect-error - provider type is stricter
41
+ const onAccountsChanged = this.onAccountsChanged.bind(this);
42
+ accountsChanged = (accounts) => onAccountsChanged([...accounts]);
34
43
  provider.on('accountsChanged', accountsChanged);
35
44
  }
36
45
  if (!chainChanged) {
@@ -53,8 +62,8 @@ export function farcasterMiniApp() {
53
62
  },
54
63
  async disconnect() {
55
64
  const provider = await this.getProvider();
65
+ assertProviderHasEventEmitterMethods(provider);
56
66
  if (accountsChanged) {
57
- // @ts-expect-error - provider type is stricter
58
67
  provider.removeListener('accountsChanged', accountsChanged);
59
68
  accountsChanged = undefined;
60
69
  }