@0xsequence/provider 0.43.30 → 0.43.31

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.
@@ -439,12 +439,11 @@ class WalletRequestHandler {
439
439
  // value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
440
440
  // a Signer value is the actually interface to a signed-in account
441
441
 
442
- constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
442
+ constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
443
443
  var _this = this;
444
444
  this.signer = void 0;
445
445
  this.signerReadyCallbacks = [];
446
446
  this.prompter = void 0;
447
- this.auxDataProvider = void 0;
448
447
  this.mainnetNetworks = void 0;
449
448
  this.testnetNetworks = void 0;
450
449
  this._openIntent = void 0;
@@ -862,7 +861,6 @@ class WalletRequestHandler {
862
861
  };
863
862
  this.signer = _signer;
864
863
  this.prompter = prompter;
865
- this.auxDataProvider = auxDataProvider;
866
864
  this.mainnetNetworks = mainnetNetworks;
867
865
  this.testnetNetworks = testnetNetworks;
868
866
  }
@@ -895,12 +893,19 @@ class WalletRequestHandler {
895
893
  //
896
894
  // NOTE: if a user is signing into a dapp from a fresh state, and and auth request is made
897
895
  // we don't trigger the promptConnect flow, as we consider the user just authenticated
898
- // for this dapp, so its safe to authorize in the connect() method without the prompt.
896
+ // for this dapp, so its safe to authorize in the promptSignInConnect() which will directly
897
+ // connect after signing in.
899
898
  //
900
899
  // NOTE: signIn can optionally connect and notify dapp at this time for new signIn flows
901
900
  if (connect) {
902
901
  const connectOptions = this._connectOptions;
903
- const connectDetails = await this.connect(connectOptions);
902
+ let connectDetails;
903
+ if (this.prompter !== null) {
904
+ var _this$prompter;
905
+ connectDetails = await ((_this$prompter = this.prompter) == null ? void 0 : _this$prompter.promptSignInConnect(connectOptions));
906
+ } else {
907
+ connectDetails = await this.connect(connectOptions);
908
+ }
904
909
  this.notifyConnect(connectDetails);
905
910
  if (!connectOptions || connectOptions.keepWalletOpened !== true) {
906
911
  this.notifyClose();
@@ -943,13 +948,6 @@ class WalletRequestHandler {
943
948
  connected: true,
944
949
  chainId: ethers.ethers.utils.hexlify(await this.getChainId())
945
950
  };
946
- if (options && options.askForEmail) {
947
- var _this$auxDataProvider;
948
- const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
949
- if (email) {
950
- connectDetails.email = email;
951
- }
952
- }
953
951
  if (options && options.authorize) {
954
952
  // Perform ethauth eip712 request and construct the ConnectDetails response
955
953
  // including the auth proof
@@ -1188,7 +1186,7 @@ function isSequenceProvider(provider) {
1188
1186
  }
1189
1187
  class LocalWeb3Provider extends Web3Provider {
1190
1188
  constructor(signer, networks) {
1191
- const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
1189
+ const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
1192
1190
  super(walletRequestHandler);
1193
1191
  }
1194
1192
  }
@@ -439,12 +439,11 @@ class WalletRequestHandler {
439
439
  // value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
440
440
  // a Signer value is the actually interface to a signed-in account
441
441
 
442
- constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
442
+ constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
443
443
  var _this = this;
444
444
  this.signer = void 0;
445
445
  this.signerReadyCallbacks = [];
446
446
  this.prompter = void 0;
447
- this.auxDataProvider = void 0;
448
447
  this.mainnetNetworks = void 0;
449
448
  this.testnetNetworks = void 0;
450
449
  this._openIntent = void 0;
@@ -862,7 +861,6 @@ class WalletRequestHandler {
862
861
  };
863
862
  this.signer = _signer;
864
863
  this.prompter = prompter;
865
- this.auxDataProvider = auxDataProvider;
866
864
  this.mainnetNetworks = mainnetNetworks;
867
865
  this.testnetNetworks = testnetNetworks;
868
866
  }
@@ -895,12 +893,19 @@ class WalletRequestHandler {
895
893
  //
896
894
  // NOTE: if a user is signing into a dapp from a fresh state, and and auth request is made
897
895
  // we don't trigger the promptConnect flow, as we consider the user just authenticated
898
- // for this dapp, so its safe to authorize in the connect() method without the prompt.
896
+ // for this dapp, so its safe to authorize in the promptSignInConnect() which will directly
897
+ // connect after signing in.
899
898
  //
900
899
  // NOTE: signIn can optionally connect and notify dapp at this time for new signIn flows
901
900
  if (connect) {
902
901
  const connectOptions = this._connectOptions;
903
- const connectDetails = await this.connect(connectOptions);
902
+ let connectDetails;
903
+ if (this.prompter !== null) {
904
+ var _this$prompter;
905
+ connectDetails = await ((_this$prompter = this.prompter) == null ? void 0 : _this$prompter.promptSignInConnect(connectOptions));
906
+ } else {
907
+ connectDetails = await this.connect(connectOptions);
908
+ }
904
909
  this.notifyConnect(connectDetails);
905
910
  if (!connectOptions || connectOptions.keepWalletOpened !== true) {
906
911
  this.notifyClose();
@@ -943,13 +948,6 @@ class WalletRequestHandler {
943
948
  connected: true,
944
949
  chainId: ethers.ethers.utils.hexlify(await this.getChainId())
945
950
  };
946
- if (options && options.askForEmail) {
947
- var _this$auxDataProvider;
948
- const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
949
- if (email) {
950
- connectDetails.email = email;
951
- }
952
- }
953
951
  if (options && options.authorize) {
954
952
  // Perform ethauth eip712 request and construct the ConnectDetails response
955
953
  // including the auth proof
@@ -1188,7 +1186,7 @@ function isSequenceProvider(provider) {
1188
1186
  }
1189
1187
  class LocalWeb3Provider extends Web3Provider {
1190
1188
  constructor(signer, networks) {
1191
- const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
1189
+ const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
1192
1190
  super(walletRequestHandler);
1193
1191
  }
1194
1192
  }
@@ -435,12 +435,11 @@ class WalletRequestHandler {
435
435
  // value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
436
436
  // a Signer value is the actually interface to a signed-in account
437
437
 
438
- constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
438
+ constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
439
439
  var _this = this;
440
440
  this.signer = void 0;
441
441
  this.signerReadyCallbacks = [];
442
442
  this.prompter = void 0;
443
- this.auxDataProvider = void 0;
444
443
  this.mainnetNetworks = void 0;
445
444
  this.testnetNetworks = void 0;
446
445
  this._openIntent = void 0;
@@ -858,7 +857,6 @@ class WalletRequestHandler {
858
857
  };
859
858
  this.signer = _signer;
860
859
  this.prompter = prompter;
861
- this.auxDataProvider = auxDataProvider;
862
860
  this.mainnetNetworks = mainnetNetworks;
863
861
  this.testnetNetworks = testnetNetworks;
864
862
  }
@@ -891,12 +889,19 @@ class WalletRequestHandler {
891
889
  //
892
890
  // NOTE: if a user is signing into a dapp from a fresh state, and and auth request is made
893
891
  // we don't trigger the promptConnect flow, as we consider the user just authenticated
894
- // for this dapp, so its safe to authorize in the connect() method without the prompt.
892
+ // for this dapp, so its safe to authorize in the promptSignInConnect() which will directly
893
+ // connect after signing in.
895
894
  //
896
895
  // NOTE: signIn can optionally connect and notify dapp at this time for new signIn flows
897
896
  if (connect) {
898
897
  const connectOptions = this._connectOptions;
899
- const connectDetails = await this.connect(connectOptions);
898
+ let connectDetails;
899
+ if (this.prompter !== null) {
900
+ var _this$prompter;
901
+ connectDetails = await ((_this$prompter = this.prompter) == null ? void 0 : _this$prompter.promptSignInConnect(connectOptions));
902
+ } else {
903
+ connectDetails = await this.connect(connectOptions);
904
+ }
900
905
  this.notifyConnect(connectDetails);
901
906
  if (!connectOptions || connectOptions.keepWalletOpened !== true) {
902
907
  this.notifyClose();
@@ -939,13 +944,6 @@ class WalletRequestHandler {
939
944
  connected: true,
940
945
  chainId: ethers.utils.hexlify(await this.getChainId())
941
946
  };
942
- if (options && options.askForEmail) {
943
- var _this$auxDataProvider;
944
- const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
945
- if (email) {
946
- connectDetails.email = email;
947
- }
948
- }
949
947
  if (options && options.authorize) {
950
948
  // Perform ethauth eip712 request and construct the ConnectDetails response
951
949
  // including the auth proof
@@ -1184,7 +1182,7 @@ function isSequenceProvider(provider) {
1184
1182
  }
1185
1183
  class LocalWeb3Provider extends Web3Provider {
1186
1184
  constructor(signer, networks) {
1187
- const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
1185
+ const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
1188
1186
  super(walletRequestHandler);
1189
1187
  }
1190
1188
  }
@@ -14,7 +14,6 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
14
14
  private signer;
15
15
  private signerReadyCallbacks;
16
16
  private prompter;
17
- private auxDataProvider;
18
17
  private mainnetNetworks;
19
18
  private testnetNetworks;
20
19
  private _openIntent?;
@@ -22,7 +21,7 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
22
21
  private _defaultNetworkId?;
23
22
  private _chainId?;
24
23
  private events;
25
- constructor(signer: Signer | null | undefined, prompter: WalletUserPrompter | null, auxDataProvider: AuxDataProvider | null, mainnetNetworks: NetworkConfig[], testnetNetworks?: NetworkConfig[]);
24
+ constructor(signer: Signer | null | undefined, prompter: WalletUserPrompter | null, mainnetNetworks: NetworkConfig[], testnetNetworks?: NetworkConfig[]);
26
25
  signIn(signer: Signer | null, options?: WalletSignInOptions): Promise<void>;
27
26
  signOut(): void;
28
27
  signerReset(): void;
@@ -55,12 +54,10 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
55
54
  }
56
55
  export interface WalletUserPrompter {
57
56
  promptConnect(options?: ConnectOptions): Promise<PromptConnectDetails>;
57
+ promptSignInConnect(options?: ConnectOptions): Promise<PromptConnectDetails>;
58
58
  promptSignMessage(message: MessageToSign, options?: ConnectOptions): Promise<string>;
59
59
  promptSignTransaction(txn: TransactionRequest, chaindId?: number, options?: ConnectOptions): Promise<string>;
60
60
  promptSendTransaction(txn: TransactionRequest, chaindId?: number, options?: ConnectOptions): Promise<string>;
61
61
  promptConfirmWalletDeploy(chainId: number, options?: ConnectOptions): Promise<boolean>;
62
62
  }
63
- export interface AuxDataProvider {
64
- get(key: string): Promise<any>;
65
- }
66
63
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.43.30",
3
+ "version": "0.43.31",
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",
@@ -9,14 +9,14 @@
9
9
  "author": "Horizon Blockchain Games",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "@0xsequence/abi": "^0.43.30",
13
- "@0xsequence/auth": "^0.43.30",
14
- "@0xsequence/config": "^0.43.30",
15
- "@0xsequence/network": "^0.43.30",
16
- "@0xsequence/relayer": "^0.43.30",
17
- "@0xsequence/transactions": "^0.43.30",
18
- "@0xsequence/utils": "^0.43.30",
19
- "@0xsequence/wallet": "^0.43.30",
12
+ "@0xsequence/abi": "^0.43.31",
13
+ "@0xsequence/auth": "^0.43.31",
14
+ "@0xsequence/config": "^0.43.31",
15
+ "@0xsequence/network": "^0.43.31",
16
+ "@0xsequence/relayer": "^0.43.31",
17
+ "@0xsequence/transactions": "^0.43.31",
18
+ "@0xsequence/utils": "^0.43.31",
19
+ "@0xsequence/wallet": "^0.43.31",
20
20
  "eventemitter2": "^6.4.5",
21
21
  "webextension-polyfill": "^0.10.0"
22
22
  },
package/src/provider.ts CHANGED
@@ -81,7 +81,7 @@ export function isSequenceProvider(provider: any): provider is Web3Provider {
81
81
 
82
82
  export class LocalWeb3Provider extends Web3Provider {
83
83
  constructor(signer: Signer, networks?: NetworkConfig[]) {
84
- const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || [])
84
+ const walletRequestHandler = new WalletRequestHandler(signer, null, networks || [])
85
85
  super(walletRequestHandler)
86
86
  }
87
87
  }
@@ -45,7 +45,6 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
45
45
  private signerReadyCallbacks: Array<() => void> = []
46
46
 
47
47
  private prompter: WalletUserPrompter | null
48
- private auxDataProvider: AuxDataProvider | null
49
48
  private mainnetNetworks: NetworkConfig[]
50
49
  private testnetNetworks: NetworkConfig[]
51
50
 
@@ -59,13 +58,11 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
59
58
  constructor(
60
59
  signer: Signer | null | undefined,
61
60
  prompter: WalletUserPrompter | null,
62
- auxDataProvider: AuxDataProvider | null,
63
61
  mainnetNetworks: NetworkConfig[],
64
62
  testnetNetworks: NetworkConfig[] = []
65
63
  ) {
66
64
  this.signer = signer
67
65
  this.prompter = prompter
68
- this.auxDataProvider = auxDataProvider
69
66
  this.mainnetNetworks = mainnetNetworks
70
67
  this.testnetNetworks = testnetNetworks
71
68
  }
@@ -100,13 +97,21 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
100
97
  //
101
98
  // NOTE: if a user is signing into a dapp from a fresh state, and and auth request is made
102
99
  // we don't trigger the promptConnect flow, as we consider the user just authenticated
103
- // for this dapp, so its safe to authorize in the connect() method without the prompt.
100
+ // for this dapp, so its safe to authorize in the promptSignInConnect() which will directly
101
+ // connect after signing in.
104
102
  //
105
103
  // NOTE: signIn can optionally connect and notify dapp at this time for new signIn flows
106
104
  if (connect) {
107
105
  const connectOptions = this._connectOptions
108
106
 
109
- const connectDetails = await this.connect(connectOptions)
107
+ let connectDetails: ConnectDetails | PromptConnectDetails
108
+
109
+ if (this.prompter !== null) {
110
+ connectDetails = await this.prompter?.promptSignInConnect(connectOptions)
111
+ } else {
112
+ connectDetails = await this.connect(connectOptions)
113
+ }
114
+
110
115
  this.notifyConnect(connectDetails)
111
116
 
112
117
  if (!connectOptions || connectOptions.keepWalletOpened !== true) {
@@ -156,13 +161,6 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
156
161
  chainId: ethers.utils.hexlify(await this.getChainId())
157
162
  }
158
163
 
159
- if (options && options.askForEmail) {
160
- const email = await this.auxDataProvider?.get('email')
161
- if (email) {
162
- connectDetails.email = email
163
- }
164
- }
165
-
166
164
  if (options && options.authorize) {
167
165
  // Perform ethauth eip712 request and construct the ConnectDetails response
168
166
  // including the auth proof
@@ -812,16 +810,14 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
812
810
 
813
811
  export interface WalletUserPrompter {
814
812
  promptConnect(options?: ConnectOptions): Promise<PromptConnectDetails>
813
+ promptSignInConnect(options?: ConnectOptions): Promise<PromptConnectDetails>
814
+
815
815
  promptSignMessage(message: MessageToSign, options?: ConnectOptions): Promise<string>
816
816
  promptSignTransaction(txn: TransactionRequest, chaindId?: number, options?: ConnectOptions): Promise<string>
817
817
  promptSendTransaction(txn: TransactionRequest, chaindId?: number, options?: ConnectOptions): Promise<string>
818
818
  promptConfirmWalletDeploy(chainId: number, options?: ConnectOptions): Promise<boolean>
819
819
  }
820
820
 
821
- export interface AuxDataProvider {
822
- get(key: string): Promise<any>
823
- }
824
-
825
821
  const permittedJsonRpcMethods = [
826
822
  'net_version',
827
823
  'eth_chainId',