@0xsequence/provider 0.42.9 → 0.42.10
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/0xsequence-provider.cjs.dev.js +14 -2
- package/dist/0xsequence-provider.cjs.prod.js +14 -2
- package/dist/0xsequence-provider.esm.js +14 -2
- package/dist/declarations/src/transports/wallet-request-handler.d.ts +5 -1
- package/dist/declarations/src/types.d.ts +1 -1
- package/package.json +8 -8
- package/src/provider.ts +1 -1
- package/src/transports/wallet-request-handler.ts +14 -0
- package/src/types.ts +1 -2
|
@@ -483,12 +483,13 @@ class WalletRequestHandler {
|
|
|
483
483
|
// signer interface of the wallet. A null value means there is no signer (ie. user not signed in). An undefined
|
|
484
484
|
// value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
|
|
485
485
|
// a Signer value is the actually interface to a signed-in account
|
|
486
|
-
constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
|
|
486
|
+
constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
|
|
487
487
|
var _this = this;
|
|
488
488
|
|
|
489
489
|
this.signer = void 0;
|
|
490
490
|
this.signerReadyCallbacks = [];
|
|
491
491
|
this.prompter = void 0;
|
|
492
|
+
this.auxDataProvider = void 0;
|
|
492
493
|
this.mainnetNetworks = void 0;
|
|
493
494
|
this.testnetNetworks = void 0;
|
|
494
495
|
this._openIntent = void 0;
|
|
@@ -962,6 +963,7 @@ class WalletRequestHandler {
|
|
|
962
963
|
|
|
963
964
|
this.signer = _signer;
|
|
964
965
|
this.prompter = prompter;
|
|
966
|
+
this.auxDataProvider = auxDataProvider;
|
|
965
967
|
this.mainnetNetworks = mainnetNetworks;
|
|
966
968
|
this.testnetNetworks = testnetNetworks;
|
|
967
969
|
}
|
|
@@ -1055,6 +1057,16 @@ class WalletRequestHandler {
|
|
|
1055
1057
|
chainId: ethers.ethers.utils.hexlify(await this.getChainId())
|
|
1056
1058
|
};
|
|
1057
1059
|
|
|
1060
|
+
if (options && options.askForEmail) {
|
|
1061
|
+
var _this$auxDataProvider;
|
|
1062
|
+
|
|
1063
|
+
const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
|
|
1064
|
+
|
|
1065
|
+
if (email) {
|
|
1066
|
+
connectDetails.email = email;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1058
1070
|
if (options && options.authorize) {
|
|
1059
1071
|
// Perform ethauth eip712 request and construct the ConnectDetails response
|
|
1060
1072
|
// including the auth proof
|
|
@@ -1339,7 +1351,7 @@ function isSequenceProvider(provider) {
|
|
|
1339
1351
|
}
|
|
1340
1352
|
class LocalWeb3Provider extends Web3Provider {
|
|
1341
1353
|
constructor(signer, networks) {
|
|
1342
|
-
const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
|
|
1354
|
+
const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
|
|
1343
1355
|
super(walletRequestHandler);
|
|
1344
1356
|
}
|
|
1345
1357
|
|
|
@@ -483,12 +483,13 @@ class WalletRequestHandler {
|
|
|
483
483
|
// signer interface of the wallet. A null value means there is no signer (ie. user not signed in). An undefined
|
|
484
484
|
// value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
|
|
485
485
|
// a Signer value is the actually interface to a signed-in account
|
|
486
|
-
constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
|
|
486
|
+
constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
|
|
487
487
|
var _this = this;
|
|
488
488
|
|
|
489
489
|
this.signer = void 0;
|
|
490
490
|
this.signerReadyCallbacks = [];
|
|
491
491
|
this.prompter = void 0;
|
|
492
|
+
this.auxDataProvider = void 0;
|
|
492
493
|
this.mainnetNetworks = void 0;
|
|
493
494
|
this.testnetNetworks = void 0;
|
|
494
495
|
this._openIntent = void 0;
|
|
@@ -962,6 +963,7 @@ class WalletRequestHandler {
|
|
|
962
963
|
|
|
963
964
|
this.signer = _signer;
|
|
964
965
|
this.prompter = prompter;
|
|
966
|
+
this.auxDataProvider = auxDataProvider;
|
|
965
967
|
this.mainnetNetworks = mainnetNetworks;
|
|
966
968
|
this.testnetNetworks = testnetNetworks;
|
|
967
969
|
}
|
|
@@ -1055,6 +1057,16 @@ class WalletRequestHandler {
|
|
|
1055
1057
|
chainId: ethers.ethers.utils.hexlify(await this.getChainId())
|
|
1056
1058
|
};
|
|
1057
1059
|
|
|
1060
|
+
if (options && options.askForEmail) {
|
|
1061
|
+
var _this$auxDataProvider;
|
|
1062
|
+
|
|
1063
|
+
const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
|
|
1064
|
+
|
|
1065
|
+
if (email) {
|
|
1066
|
+
connectDetails.email = email;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1058
1070
|
if (options && options.authorize) {
|
|
1059
1071
|
// Perform ethauth eip712 request and construct the ConnectDetails response
|
|
1060
1072
|
// including the auth proof
|
|
@@ -1339,7 +1351,7 @@ function isSequenceProvider(provider) {
|
|
|
1339
1351
|
}
|
|
1340
1352
|
class LocalWeb3Provider extends Web3Provider {
|
|
1341
1353
|
constructor(signer, networks) {
|
|
1342
|
-
const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
|
|
1354
|
+
const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
|
|
1343
1355
|
super(walletRequestHandler);
|
|
1344
1356
|
}
|
|
1345
1357
|
|
|
@@ -479,12 +479,13 @@ class WalletRequestHandler {
|
|
|
479
479
|
// signer interface of the wallet. A null value means there is no signer (ie. user not signed in). An undefined
|
|
480
480
|
// value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course
|
|
481
481
|
// a Signer value is the actually interface to a signed-in account
|
|
482
|
-
constructor(_signer, prompter, mainnetNetworks, testnetNetworks = []) {
|
|
482
|
+
constructor(_signer, prompter, auxDataProvider, mainnetNetworks, testnetNetworks = []) {
|
|
483
483
|
var _this = this;
|
|
484
484
|
|
|
485
485
|
this.signer = void 0;
|
|
486
486
|
this.signerReadyCallbacks = [];
|
|
487
487
|
this.prompter = void 0;
|
|
488
|
+
this.auxDataProvider = void 0;
|
|
488
489
|
this.mainnetNetworks = void 0;
|
|
489
490
|
this.testnetNetworks = void 0;
|
|
490
491
|
this._openIntent = void 0;
|
|
@@ -958,6 +959,7 @@ class WalletRequestHandler {
|
|
|
958
959
|
|
|
959
960
|
this.signer = _signer;
|
|
960
961
|
this.prompter = prompter;
|
|
962
|
+
this.auxDataProvider = auxDataProvider;
|
|
961
963
|
this.mainnetNetworks = mainnetNetworks;
|
|
962
964
|
this.testnetNetworks = testnetNetworks;
|
|
963
965
|
}
|
|
@@ -1051,6 +1053,16 @@ class WalletRequestHandler {
|
|
|
1051
1053
|
chainId: ethers.utils.hexlify(await this.getChainId())
|
|
1052
1054
|
};
|
|
1053
1055
|
|
|
1056
|
+
if (options && options.askForEmail) {
|
|
1057
|
+
var _this$auxDataProvider;
|
|
1058
|
+
|
|
1059
|
+
const email = await ((_this$auxDataProvider = this.auxDataProvider) == null ? void 0 : _this$auxDataProvider.get('email'));
|
|
1060
|
+
|
|
1061
|
+
if (email) {
|
|
1062
|
+
connectDetails.email = email;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1054
1066
|
if (options && options.authorize) {
|
|
1055
1067
|
// Perform ethauth eip712 request and construct the ConnectDetails response
|
|
1056
1068
|
// including the auth proof
|
|
@@ -1335,7 +1347,7 @@ function isSequenceProvider(provider) {
|
|
|
1335
1347
|
}
|
|
1336
1348
|
class LocalWeb3Provider extends Web3Provider {
|
|
1337
1349
|
constructor(signer, networks) {
|
|
1338
|
-
const walletRequestHandler = new WalletRequestHandler(signer, null, networks || []);
|
|
1350
|
+
const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || []);
|
|
1339
1351
|
super(walletRequestHandler);
|
|
1340
1352
|
}
|
|
1341
1353
|
|
|
@@ -13,6 +13,7 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
|
|
|
13
13
|
private signer;
|
|
14
14
|
private signerReadyCallbacks;
|
|
15
15
|
private prompter;
|
|
16
|
+
private auxDataProvider;
|
|
16
17
|
private mainnetNetworks;
|
|
17
18
|
private testnetNetworks;
|
|
18
19
|
private _openIntent?;
|
|
@@ -20,7 +21,7 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
|
|
|
20
21
|
private _defaultNetworkId?;
|
|
21
22
|
private _chainId?;
|
|
22
23
|
private events;
|
|
23
|
-
constructor(signer: Signer | null | undefined, prompter: WalletUserPrompter | null, mainnetNetworks: NetworkConfig[], testnetNetworks?: NetworkConfig[]);
|
|
24
|
+
constructor(signer: Signer | null | undefined, prompter: WalletUserPrompter | null, auxDataProvider: AuxDataProvider | null, mainnetNetworks: NetworkConfig[], testnetNetworks?: NetworkConfig[]);
|
|
24
25
|
signIn(signer: Signer | null, options?: WalletSignInOptions): Promise<void>;
|
|
25
26
|
signOut(): void;
|
|
26
27
|
signerReset(): void;
|
|
@@ -58,3 +59,6 @@ export interface WalletUserPrompter {
|
|
|
58
59
|
promptSendTransaction(txn: TransactionRequest, chaindId?: number, options?: ConnectOptions): Promise<string>;
|
|
59
60
|
promptConfirmWalletDeploy(chainId: number, options?: ConnectOptions): Promise<boolean>;
|
|
60
61
|
}
|
|
62
|
+
export interface AuxDataProvider {
|
|
63
|
+
get(key: string): Promise<any>;
|
|
64
|
+
}
|
|
@@ -121,7 +121,7 @@ export interface ConnectOptions {
|
|
|
121
121
|
expiry?: number;
|
|
122
122
|
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
123
123
|
authorize?: boolean;
|
|
124
|
-
/**
|
|
124
|
+
/** askForEmail will prompt to give permission to the dapp to access email address */
|
|
125
125
|
askForEmail?: boolean;
|
|
126
126
|
/** refresh flag will force a full re-connect (ie. disconnect then connect again) */
|
|
127
127
|
refresh?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.10",
|
|
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",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@0xsequence/abi": "^0.42.
|
|
18
|
-
"@0xsequence/auth": "^0.42.
|
|
19
|
-
"@0xsequence/config": "^0.42.
|
|
20
|
-
"@0xsequence/network": "^0.42.
|
|
21
|
-
"@0xsequence/transactions": "^0.42.
|
|
22
|
-
"@0xsequence/utils": "^0.42.
|
|
23
|
-
"@0xsequence/wallet": "^0.42.
|
|
17
|
+
"@0xsequence/abi": "^0.42.10",
|
|
18
|
+
"@0xsequence/auth": "^0.42.10",
|
|
19
|
+
"@0xsequence/config": "^0.42.10",
|
|
20
|
+
"@0xsequence/network": "^0.42.10",
|
|
21
|
+
"@0xsequence/transactions": "^0.42.10",
|
|
22
|
+
"@0xsequence/utils": "^0.42.10",
|
|
23
|
+
"@0xsequence/wallet": "^0.42.10",
|
|
24
24
|
"@ethersproject/abstract-signer": "^5.5.0",
|
|
25
25
|
"@ethersproject/hash": "^5.5.0",
|
|
26
26
|
"@ethersproject/providers": "^5.5.1",
|
package/src/provider.ts
CHANGED
|
@@ -94,7 +94,7 @@ export function isSequenceProvider(provider: any): provider is Web3Provider {
|
|
|
94
94
|
|
|
95
95
|
export class LocalWeb3Provider extends Web3Provider {
|
|
96
96
|
constructor(signer: Signer, networks?: NetworkConfig[]) {
|
|
97
|
-
const walletRequestHandler = new WalletRequestHandler(signer, null, networks || [])
|
|
97
|
+
const walletRequestHandler = new WalletRequestHandler(signer, null, null, networks || [])
|
|
98
98
|
super(walletRequestHandler)
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -44,6 +44,7 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
44
44
|
private signerReadyCallbacks: Array<() => void> = []
|
|
45
45
|
|
|
46
46
|
private prompter: WalletUserPrompter | null
|
|
47
|
+
private auxDataProvider: AuxDataProvider | null
|
|
47
48
|
private mainnetNetworks: NetworkConfig[]
|
|
48
49
|
private testnetNetworks: NetworkConfig[]
|
|
49
50
|
|
|
@@ -57,11 +58,13 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
57
58
|
constructor(
|
|
58
59
|
signer: Signer | null | undefined,
|
|
59
60
|
prompter: WalletUserPrompter | null,
|
|
61
|
+
auxDataProvider: AuxDataProvider | null,
|
|
60
62
|
mainnetNetworks: NetworkConfig[],
|
|
61
63
|
testnetNetworks: NetworkConfig[] = []
|
|
62
64
|
) {
|
|
63
65
|
this.signer = signer
|
|
64
66
|
this.prompter = prompter
|
|
67
|
+
this.auxDataProvider = auxDataProvider
|
|
65
68
|
this.mainnetNetworks = mainnetNetworks
|
|
66
69
|
this.testnetNetworks = testnetNetworks
|
|
67
70
|
}
|
|
@@ -152,6 +155,13 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
152
155
|
chainId: ethers.utils.hexlify(await this.getChainId())
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
if (options && options.askForEmail) {
|
|
159
|
+
const email = await this.auxDataProvider?.get('email')
|
|
160
|
+
if (email) {
|
|
161
|
+
connectDetails.email = email
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
155
165
|
if (options && options.authorize) {
|
|
156
166
|
// Perform ethauth eip712 request and construct the ConnectDetails response
|
|
157
167
|
// including the auth proof
|
|
@@ -802,6 +812,10 @@ export interface WalletUserPrompter {
|
|
|
802
812
|
promptConfirmWalletDeploy(chainId: number, options?: ConnectOptions): Promise<boolean>
|
|
803
813
|
}
|
|
804
814
|
|
|
815
|
+
export interface AuxDataProvider {
|
|
816
|
+
get(key: string): Promise<any>
|
|
817
|
+
}
|
|
818
|
+
|
|
805
819
|
const permittedJsonRpcMethods = [
|
|
806
820
|
'net_version',
|
|
807
821
|
'eth_chainId',
|
package/src/types.ts
CHANGED
|
@@ -156,8 +156,7 @@ export interface ConnectOptions {
|
|
|
156
156
|
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
157
157
|
authorize?: boolean
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
// TODO: this feature is currently not used as the wallet does not report emails yet
|
|
159
|
+
/** askForEmail will prompt to give permission to the dapp to access email address */
|
|
161
160
|
askForEmail?: boolean
|
|
162
161
|
|
|
163
162
|
/** refresh flag will force a full re-connect (ie. disconnect then connect again) */
|