@0xsequence/provider 0.0.0-20230726163002 → 0.0.0-20230726172246

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.
@@ -79,6 +79,8 @@ const ErrSignedInRequired = new ProviderError('Wallet is not signed in. Connect
79
79
 
80
80
  // TODO: lets build some nice error handling tools, prob in /utils ...
81
81
 
82
+ // This is required by viem, it expects a provider to have an EIP-1193 compliant `request` attribute.
83
+
82
84
  const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
83
85
 
84
86
  let _messageIdx = 0;
@@ -3264,6 +3266,9 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
3264
3266
  send(method, params) {
3265
3267
  return this.perform(method, params);
3266
3268
  }
3269
+ request(request) {
3270
+ return this.perform(request.method, request.params);
3271
+ }
3267
3272
  async detectNetwork() {
3268
3273
  const chainId = this.client.getChainId();
3269
3274
  const network$1 = network.findNetworkConfig(this.networks, chainId);
@@ -79,6 +79,8 @@ const ErrSignedInRequired = new ProviderError('Wallet is not signed in. Connect
79
79
 
80
80
  // TODO: lets build some nice error handling tools, prob in /utils ...
81
81
 
82
+ // This is required by viem, it expects a provider to have an EIP-1193 compliant `request` attribute.
83
+
82
84
  const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
83
85
 
84
86
  let _messageIdx = 0;
@@ -3264,6 +3266,9 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
3264
3266
  send(method, params) {
3265
3267
  return this.perform(method, params);
3266
3268
  }
3269
+ request(request) {
3270
+ return this.perform(request.method, request.params);
3271
+ }
3267
3272
  async detectNetwork() {
3268
3273
  const chainId = this.client.getChainId();
3269
3274
  const network$1 = network.findNetworkConfig(this.networks, chainId);
@@ -75,6 +75,8 @@ const ErrSignedInRequired = new ProviderError('Wallet is not signed in. Connect
75
75
 
76
76
  // TODO: lets build some nice error handling tools, prob in /utils ...
77
77
 
78
+ // This is required by viem, it expects a provider to have an EIP-1193 compliant `request` attribute.
79
+
78
80
  const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
79
81
 
80
82
  let _messageIdx = 0;
@@ -3260,6 +3262,9 @@ class SequenceProvider extends ethers.providers.BaseProvider {
3260
3262
  send(method, params) {
3261
3263
  return this.perform(method, params);
3262
3264
  }
3265
+ request(request) {
3266
+ return this.perform(request.method, request.params);
3267
+ }
3263
3268
  async detectNetwork() {
3264
3269
  const chainId = this.client.getChainId();
3265
3270
  const network = findNetworkConfig(this.networks, chainId);
@@ -1,7 +1,7 @@
1
1
  import { ethers } from "ethers";
2
2
  import { SequenceClient } from "./client.js";
3
3
  import { ChainIdLike, NetworkConfig } from "@0xsequence/network";
4
- import { ConnectDetails, ConnectOptions, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types.js";
4
+ import { ConnectDetails, ConnectOptions, EIP1193Provider, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types.js";
5
5
  import { commons } from "@0xsequence/core";
6
6
  import { WalletUtils } from "./utils/index.js";
7
7
  import { SequenceSigner, SingleNetworkSequenceSigner } from "./signer.js";
@@ -29,7 +29,7 @@ export interface ISequenceProvider {
29
29
  getWalletConfig(chainId?: ChainIdLike): Promise<commons.config.Config>;
30
30
  utils: WalletUtils;
31
31
  }
32
- export declare class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider {
32
+ export declare class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider, EIP1193Provider {
33
33
  readonly client: SequenceClient;
34
34
  private readonly providerFor;
35
35
  readonly networks: NetworkConfig[];
@@ -79,6 +79,10 @@ export declare class SequenceProvider extends ethers.providers.BaseProvider impl
79
79
  _getSubprovider(chainId?: ChainIdLike): Promise<ethers.providers.JsonRpcProvider>;
80
80
  perform(method: string, params: any): Promise<any>;
81
81
  send(method: string, params: any): Promise<any>;
82
+ request(request: {
83
+ method: string;
84
+ params?: any[] | undefined;
85
+ }): Promise<any>;
82
86
  detectNetwork(): Promise<ethers.providers.Network>;
83
87
  waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number, optionals?: OptionalChainIdLike): Promise<ethers.providers.TransactionReceipt>;
84
88
  getBlockNumber(optionals?: OptionalChainIdLike): Promise<number>;
@@ -244,4 +244,10 @@ export type OptionalChainId = {
244
244
  export type OptionalEIP6492 = {
245
245
  eip6492?: boolean;
246
246
  } | undefined;
247
+ export interface EIP1193Provider {
248
+ request: (request: {
249
+ method: string;
250
+ params?: Array<any>;
251
+ }) => Promise<any>;
252
+ }
247
253
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.0.0-20230726163002",
3
+ "version": "0.0.0-20230726172246",
4
4
  "description": "provider sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
6
6
  "source": "src/index.ts",
@@ -11,15 +11,15 @@
11
11
  "dependencies": {
12
12
  "eventemitter2": "^6.4.5",
13
13
  "webextension-polyfill": "^0.10.0",
14
- "@0xsequence/abi": "0.0.0-20230726163002",
15
- "@0xsequence/account": "0.0.0-20230726163002",
16
- "@0xsequence/migration": "0.0.0-20230726163002",
17
- "@0xsequence/core": "0.0.0-20230726163002",
18
- "@0xsequence/network": "0.0.0-20230726163002",
19
- "@0xsequence/wallet": "0.0.0-20230726163002",
20
- "@0xsequence/auth": "0.0.0-20230726163002",
21
- "@0xsequence/relayer": "0.0.0-20230726163002",
22
- "@0xsequence/utils": "0.0.0-20230726163002"
14
+ "@0xsequence/abi": "0.0.0-20230726172246",
15
+ "@0xsequence/core": "0.0.0-20230726172246",
16
+ "@0xsequence/auth": "0.0.0-20230726172246",
17
+ "@0xsequence/migration": "0.0.0-20230726172246",
18
+ "@0xsequence/account": "0.0.0-20230726172246",
19
+ "@0xsequence/network": "0.0.0-20230726172246",
20
+ "@0xsequence/utils": "0.0.0-20230726172246",
21
+ "@0xsequence/wallet": "0.0.0-20230726172246",
22
+ "@0xsequence/relayer": "0.0.0-20230726172246"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "ethers": ">=5.5 < 6"
package/src/provider.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { ethers } from "ethers"
3
3
  import { SequenceClient } from "./client"
4
4
  import { ChainIdLike, NetworkConfig, allNetworks, findNetworkConfig } from "@0xsequence/network"
5
- import { ConnectDetails, ConnectOptions, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types"
5
+ import { ConnectDetails, ConnectOptions, EIP1193Provider, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types"
6
6
  import { commons } from "@0xsequence/core"
7
7
  import { WalletUtils } from "./utils/index"
8
8
  import { SequenceSigner, SingleNetworkSequenceSigner } from "./signer"
@@ -47,7 +47,7 @@ export interface ISequenceProvider {
47
47
  utils: WalletUtils
48
48
  }
49
49
 
50
- export class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider {
50
+ export class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider, EIP1193Provider {
51
51
  private readonly singleNetworkProviders: { [chainId: number]: SingleNetworkSequenceProvider } = {}
52
52
 
53
53
  readonly _isSequenceProvider = true
@@ -269,6 +269,10 @@ export class SequenceProvider extends ethers.providers.BaseProvider implements I
269
269
  return this.perform(method, params)
270
270
  }
271
271
 
272
+ request (request: { method: string; params?: any[] | undefined }) {
273
+ return this.perform(request.method, request.params)
274
+ }
275
+
272
276
  async detectNetwork(): Promise<ethers.providers.Network> {
273
277
  const chainId = this.client.getChainId()
274
278
  const network = findNetworkConfig(this.networks, chainId)
package/src/types.ts CHANGED
@@ -340,3 +340,8 @@ export type OptionalChainId = {
340
340
  export type OptionalEIP6492 = {
341
341
  eip6492?: boolean
342
342
  } | undefined
343
+
344
+ // This is required by viem, it expects a provider to have an EIP-1193 compliant `request` attribute.
345
+ export interface EIP1193Provider {
346
+ request: (request: { method: string, params?: Array<any> }) => Promise<any>
347
+ }