@dynamic-labs/wallet-connector-core 0.16.4 → 0.17.0-RC.1
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/CHANGELOG.md +21 -7
- package/_virtual/_tslib.cjs +30 -0
- package/_virtual/_tslib.js +26 -0
- package/package.json +1 -1
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +1 -1
- package/src/lib/IEmailOTPWalletConnector.d.ts +4 -0
- package/src/lib/IEmailWalletConnector.d.ts +6 -0
- package/src/lib/WalletConnector.cjs +207 -2
- package/src/lib/WalletConnector.d.ts +169 -18
- package/src/lib/WalletConnector.js +206 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
## [0.17.0-RC.1](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.0...v0.17.0-RC.1) (2023-04-20)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add getNameService method to connectors ([#1894](https://github.com/dynamic-labs/DynamicAuth/issues/1894)) ([000b4e9](https://github.com/dynamic-labs/DynamicAuth/commit/000b4e9af89bb69299191c1452984168f30d81b5))
|
|
8
|
+
* add social sign in flow ([#1849](https://github.com/dynamic-labs/DynamicAuth/issues/1849)) ([aa0f201](https://github.com/dynamic-labs/DynamicAuth/commit/aa0f201e6de35b092edc8283fc95e1a9074c7d56))
|
|
9
|
+
* add wallet filter by chain name ([#1878](https://github.com/dynamic-labs/DynamicAuth/issues/1878)) ([8f3f99f](https://github.com/dynamic-labs/DynamicAuth/commit/8f3f99ff4f6d63d5e5ae9193277f35d4c2f99ab6))
|
|
10
|
+
* only set view to wallet list when linking ([#1905](https://github.com/dynamic-labs/DynamicAuth/issues/1905)) ([3413048](https://github.com/dynamic-labs/DynamicAuth/commit/341304832340f2d262e58a59df44691c81572ed6))
|
|
11
|
+
* social sign in ux improvements ([#1898](https://github.com/dynamic-labs/DynamicAuth/issues/1898)) ([cb5a037](https://github.com/dynamic-labs/DynamicAuth/commit/cb5a0376d051a401aadb15c3ad49f0d3301de3e9))
|
|
12
|
+
* **SocialUICard:** adds overlay card with more social options ([#1889](https://github.com/dynamic-labs/DynamicAuth/issues/1889)) ([8ff6920](https://github.com/dynamic-labs/DynamicAuth/commit/8ff6920844b104c4d0679bb23a092eb675297d95))
|
|
3
13
|
|
|
4
14
|
|
|
5
15
|
### Bug Fixes
|
|
6
16
|
|
|
7
|
-
*
|
|
17
|
+
* **DYN-2147:** connectWallet calling createVisit multiple times ([ceba216](https://github.com/dynamic-labs/DynamicAuth/commit/ceba216a82f4073751a210be6e6c8326286e4266))
|
|
18
|
+
* handle undefined or defined cases in new WalletConnector class ([#1914](https://github.com/dynamic-labs/DynamicAuth/issues/1914)) ([869afa6](https://github.com/dynamic-labs/DynamicAuth/commit/869afa67536b26715b4c91a457d8965548f107bd))
|
|
19
|
+
* issue with wallets list being empty after linking new wallet ([#1883](https://github.com/dynamic-labs/DynamicAuth/issues/1883)) ([19bd8cd](https://github.com/dynamic-labs/DynamicAuth/commit/19bd8cd47619b5164fe18235fca02c0a7935780f))
|
|
20
|
+
* make providerResources default to undefined instead of empty array ([#1913](https://github.com/dynamic-labs/DynamicAuth/issues/1913)) ([dbcc5f1](https://github.com/dynamic-labs/DynamicAuth/commit/dbcc5f1874209295464032bdfd3e42d23828e5ab))
|
|
21
|
+
* remove event listeners ([#1910](https://github.com/dynamic-labs/DynamicAuth/issues/1910)) ([b6e1dfd](https://github.com/dynamic-labs/DynamicAuth/commit/b6e1dfd09951e7e97678d5c92648ef2abb548664))
|
|
22
|
+
* use named export from coinbase wallet sdk ([#1903](https://github.com/dynamic-labs/DynamicAuth/issues/1903)) ([cbd106f](https://github.com/dynamic-labs/DynamicAuth/commit/cbd106f065f86a161b082a41023efb2ffd7ab9e0))
|
|
23
|
+
* when linking a new wallet, show sign message if active wallet is not linked ([#1887](https://github.com/dynamic-labs/DynamicAuth/issues/1887)) ([11d86d6](https://github.com/dynamic-labs/DynamicAuth/commit/11d86d6641c8c0b5e48b040d02226585b6d5f1dd))
|
|
8
24
|
|
|
9
|
-
|
|
25
|
+
## [0.17.0-RC.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.1...v0.17.0-RC.0) (2023-04-18)
|
|
10
26
|
|
|
11
27
|
|
|
12
28
|
### Features
|
|
13
29
|
|
|
14
|
-
* add
|
|
15
|
-
|
|
16
|
-
### [0.16.2](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.1...v0.16.2) (2023-04-18)
|
|
30
|
+
* add magic social wallet connector ([#1848](https://github.com/dynamic-labs/DynamicAuth/issues/1848)) ([3f49d22](https://github.com/dynamic-labs/DynamicAuth/commit/3f49d2222ddf90835e3e3d58ac860835f33c9910))
|
|
17
31
|
|
|
18
32
|
|
|
19
33
|
### Bug Fixes
|
|
20
34
|
|
|
21
|
-
* type=module requires dot cjs files for running with node ([#1890](https://github.com/dynamic-labs/DynamicAuth/issues/1890)) ([
|
|
35
|
+
* type=module requires dot cjs files for running with node ([#1890](https://github.com/dynamic-labs/DynamicAuth/issues/1890)) ([5751d6e](https://github.com/dynamic-labs/DynamicAuth/commit/5751d6ebd6df376b241e812c5ae860b3a0cf6c80))
|
|
22
36
|
|
|
23
37
|
### [0.16.1](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.0...v0.16.1) (2023-04-15)
|
|
24
38
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
Copyright (c) Microsoft Corporation.
|
|
7
|
+
|
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
+
purpose with or without fee is hereby granted.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
***************************************************************************** */
|
|
19
|
+
|
|
20
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { __awaiter };
|
package/package.json
CHANGED
package/src/index.cjs
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Chains } from './lib/WalletConnector.js';
|
|
1
|
+
export { Chains, WalletConnectorBase, socialProviders } from './lib/WalletConnector.js';
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
9
|
const Chains = [
|
|
7
10
|
'ETH',
|
|
8
11
|
'FLOW',
|
|
@@ -12,6 +15,208 @@ const Chains = [
|
|
|
12
15
|
'STARK',
|
|
13
16
|
'ATOM',
|
|
14
17
|
'COSMOS',
|
|
15
|
-
];
|
|
18
|
+
];
|
|
19
|
+
const socialProviders = [
|
|
20
|
+
'google',
|
|
21
|
+
'facebook',
|
|
22
|
+
'apple',
|
|
23
|
+
'github',
|
|
24
|
+
'bitbucket',
|
|
25
|
+
'gitlab',
|
|
26
|
+
'linkedin',
|
|
27
|
+
'twitter',
|
|
28
|
+
'discord',
|
|
29
|
+
'twitch',
|
|
30
|
+
'microsoft',
|
|
31
|
+
];
|
|
32
|
+
class WalletConnectorBase {
|
|
33
|
+
constructor() {
|
|
34
|
+
/**
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
this.canConnectViaEmail = false;
|
|
38
|
+
/**
|
|
39
|
+
* IF the wallet needs to be connected via a custodial service
|
|
40
|
+
* such as Blocto, this will be true.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
this.canConnectViaCustodialService = false;
|
|
44
|
+
/**
|
|
45
|
+
* If the wallet is not installed, and can be connected via a QR code,
|
|
46
|
+
* this will be true.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
this.canConnectViaQrCode = false;
|
|
50
|
+
/**
|
|
51
|
+
* Whether this connector can be connected via social login.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
this.canConnectViaSocial = false;
|
|
55
|
+
/**
|
|
56
|
+
* Flag if it is wallet Connect
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
this.isWalletConnect = false;
|
|
61
|
+
/**
|
|
62
|
+
* Additional resources to add to the message to be signed
|
|
63
|
+
*
|
|
64
|
+
* @default undefined
|
|
65
|
+
*/
|
|
66
|
+
this.providerResources = undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Requires switching network in the wallet itself
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
this.switchNetworkOnlyFromWallet = undefined;
|
|
72
|
+
}
|
|
73
|
+
connect() {
|
|
74
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
yield this.fetchPublicAddress();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Generic function to close the wallet connection
|
|
80
|
+
* Originally implemented for WalletConnect, but it is used
|
|
81
|
+
* for anything that needs to be "logged out" or cleaned up
|
|
82
|
+
*
|
|
83
|
+
* @default Promise<undefined>
|
|
84
|
+
*/
|
|
85
|
+
endSession() {
|
|
86
|
+
return Promise.resolve();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets the public address of the wallet
|
|
90
|
+
*
|
|
91
|
+
* @default Promise<undefined>
|
|
92
|
+
*/
|
|
93
|
+
fetchPublicAddress(opts) {
|
|
94
|
+
return Promise.resolve(undefined);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the balance of the wallet
|
|
98
|
+
*
|
|
99
|
+
* @default Promise<undefined>
|
|
100
|
+
*/
|
|
101
|
+
getBalance() {
|
|
102
|
+
return Promise.resolve(undefined);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get the address silently
|
|
106
|
+
*
|
|
107
|
+
* @default Promise<[]>
|
|
108
|
+
*/
|
|
109
|
+
getConnectedAccounts() {
|
|
110
|
+
return Promise.resolve([]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gets the deep link of the wallet
|
|
114
|
+
*
|
|
115
|
+
* @default undefined
|
|
116
|
+
*/
|
|
117
|
+
getDeepLink() {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Gets current network of connected wallet
|
|
122
|
+
*
|
|
123
|
+
* @default Promise<undefined>
|
|
124
|
+
*/
|
|
125
|
+
getNetwork() {
|
|
126
|
+
return Promise.resolve(undefined);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets current network of connected wallet
|
|
130
|
+
*
|
|
131
|
+
* @default Promise<undefined>
|
|
132
|
+
*/
|
|
133
|
+
getNameService() {
|
|
134
|
+
return Promise.resolve(undefined);
|
|
135
|
+
}
|
|
136
|
+
getRpcProvider() {
|
|
137
|
+
return Promise.resolve(undefined);
|
|
138
|
+
}
|
|
139
|
+
getSession() {
|
|
140
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
return Promise.resolve();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
getSigner() {
|
|
145
|
+
return Promise.resolve(undefined);
|
|
146
|
+
}
|
|
147
|
+
getWeb3Provider() {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Initialize the wallet connector with any async operations
|
|
152
|
+
*
|
|
153
|
+
* @default Promise<void>
|
|
154
|
+
*/
|
|
155
|
+
init() {
|
|
156
|
+
return Promise.resolve();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Check if the wallet is installed on the browser
|
|
160
|
+
*
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
163
|
+
isInstalledOnBrowser() {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Normalized wallet name
|
|
168
|
+
*/
|
|
169
|
+
get key() {
|
|
170
|
+
return this.name.replace(/\W/g, '').toLowerCase();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* In most cases this is an alias for `signMessage`
|
|
174
|
+
*
|
|
175
|
+
* @default Promise<undefined>
|
|
176
|
+
*/
|
|
177
|
+
proveOwnership(messageToSign) {
|
|
178
|
+
return this.signMessage(messageToSign);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Set up event listeners for the wallet
|
|
182
|
+
*
|
|
183
|
+
* @default undefined
|
|
184
|
+
*/
|
|
185
|
+
setupEventListeners(listeners) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Sign a message
|
|
190
|
+
*
|
|
191
|
+
* @default Promise<undefined>
|
|
192
|
+
*/
|
|
193
|
+
signMessage(messageToSign) {
|
|
194
|
+
return Promise.resolve(undefined);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Whether the wallet supports network switching
|
|
198
|
+
*
|
|
199
|
+
* @default false
|
|
200
|
+
*/
|
|
201
|
+
supportsNetworkSwitching() {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Switch the network
|
|
206
|
+
* @default Promise<undefined>
|
|
207
|
+
*/
|
|
208
|
+
switchNetwork({ networkName, networkChainId, }) {
|
|
209
|
+
return Promise.resolve(undefined);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Tear down event listeners for the wallet
|
|
213
|
+
* @default void
|
|
214
|
+
*/
|
|
215
|
+
teardownEventListeners() {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
16
219
|
|
|
17
220
|
exports.Chains = Chains;
|
|
221
|
+
exports.WalletConnectorBase = WalletConnectorBase;
|
|
222
|
+
exports.socialProviders = socialProviders;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const Chains: readonly ["ETH", "FLOW", "SOL", "EVM", "ALGO", "STARK", "ATOM", "COSMOS"];
|
|
2
2
|
export type Chain = typeof Chains[number];
|
|
3
|
+
export declare const socialProviders: readonly ["google", "facebook", "apple", "github", "bitbucket", "gitlab", "linkedin", "twitter", "discord", "twitch", "microsoft"];
|
|
4
|
+
export type SocialProvider = typeof socialProviders[number];
|
|
3
5
|
export type PayloadParams = {
|
|
4
6
|
params: {
|
|
5
7
|
accounts: string[];
|
|
@@ -18,46 +20,195 @@ export type WalletEventListeners = {
|
|
|
18
20
|
onChainChange?(chain: string): Promise<void>;
|
|
19
21
|
onDisconnect?(): Promise<void>;
|
|
20
22
|
};
|
|
21
|
-
export
|
|
23
|
+
export type NameServiceData = {
|
|
24
|
+
avatar?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
};
|
|
27
|
+
export interface WalletConnector extends WalletConnectorBase {
|
|
28
|
+
}
|
|
29
|
+
export declare abstract class WalletConnectorBase {
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
canConnectViaEmail: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* IF the wallet needs to be connected via a custodial service
|
|
36
|
+
* such as Blocto, this will be true.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
22
39
|
canConnectViaCustodialService: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* If the wallet is not installed, and can be connected via a QR code,
|
|
42
|
+
* this will be true.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
23
45
|
canConnectViaQrCode: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Whether this connector can be connected via social login.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
canConnectViaSocial: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Connect to the wallet or custodial service
|
|
53
|
+
*
|
|
54
|
+
* Historically, this was used for starting the connect process to be able to fetch
|
|
55
|
+
* public address. But it can be used for different connection initialization.
|
|
56
|
+
*
|
|
57
|
+
* @default string - the public address of the wallet
|
|
58
|
+
*/
|
|
59
|
+
connect(args?: unknown): Promise<void>;
|
|
60
|
+
connect<T = undefined>(args: T): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* The chain this wallet is connected
|
|
63
|
+
*/
|
|
64
|
+
abstract connectedChain?: Chain;
|
|
65
|
+
/**
|
|
66
|
+
* Generic function to close the wallet connection
|
|
67
|
+
* Originally implemented for WalletConnect, but it is used
|
|
68
|
+
* for anything that needs to be "logged out" or cleaned up
|
|
69
|
+
*
|
|
70
|
+
* @default Promise<undefined>
|
|
71
|
+
*/
|
|
72
|
+
endSession(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the public address of the wallet
|
|
75
|
+
*
|
|
76
|
+
* @default Promise<undefined>
|
|
77
|
+
*/
|
|
27
78
|
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the balance of the wallet
|
|
81
|
+
*
|
|
82
|
+
* @default Promise<undefined>
|
|
83
|
+
*/
|
|
28
84
|
getBalance(): Promise<string | undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the address silently
|
|
87
|
+
*
|
|
88
|
+
* @default Promise<[]>
|
|
89
|
+
*/
|
|
29
90
|
getConnectedAccounts(): Promise<string[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the deep link of the wallet
|
|
93
|
+
*
|
|
94
|
+
* @default undefined
|
|
95
|
+
*/
|
|
30
96
|
getDeepLink(): string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Gets current network of connected wallet
|
|
99
|
+
*
|
|
100
|
+
* @default Promise<undefined>
|
|
101
|
+
*/
|
|
31
102
|
getNetwork(): Promise<number | undefined>;
|
|
103
|
+
/**
|
|
104
|
+
* Gets current network of connected wallet
|
|
105
|
+
*
|
|
106
|
+
* @default Promise<undefined>
|
|
107
|
+
*/
|
|
108
|
+
getNameService(): Promise<NameServiceData | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* Get the RPC provider for the wallet
|
|
111
|
+
*
|
|
112
|
+
* @default Promise<undefined>
|
|
113
|
+
*/
|
|
32
114
|
getRpcProvider(): Promise<unknown>;
|
|
33
115
|
getRpcProvider<T>(): Promise<T>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the session for the wallet
|
|
118
|
+
* @default Promise<undefined>
|
|
119
|
+
*/
|
|
120
|
+
getSession(): unknown;
|
|
121
|
+
getSession<T>(): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Get the signer for the wallet
|
|
124
|
+
*
|
|
125
|
+
* @default Promise<undefined>
|
|
126
|
+
*/
|
|
34
127
|
getSigner(): Promise<unknown>;
|
|
35
128
|
getSigner<T>(): Promise<T>;
|
|
129
|
+
/**
|
|
130
|
+
* Get the web3 provider for the wallet
|
|
131
|
+
*
|
|
132
|
+
* @default undefined
|
|
133
|
+
*/
|
|
36
134
|
getWeb3Provider(): unknown;
|
|
37
135
|
getWeb3Provider<T>(): T;
|
|
136
|
+
/**
|
|
137
|
+
* Initialize the wallet connector with any async operations
|
|
138
|
+
*
|
|
139
|
+
* @default Promise<void>
|
|
140
|
+
*/
|
|
141
|
+
init(): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Check if the wallet is installed on the browser
|
|
144
|
+
*
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
38
147
|
isInstalledOnBrowser(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Flag if it is wallet Connect
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
39
153
|
isWalletConnect: boolean;
|
|
40
|
-
|
|
41
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Normalized wallet name
|
|
156
|
+
*/
|
|
157
|
+
get key(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Wallet name
|
|
160
|
+
*/
|
|
161
|
+
abstract name: string;
|
|
162
|
+
/**
|
|
163
|
+
* In most cases this is an alias for `signMessage`
|
|
164
|
+
*
|
|
165
|
+
* @default Promise<undefined>
|
|
166
|
+
*/
|
|
42
167
|
proveOwnership(messageToSign: string): Promise<string | undefined>;
|
|
43
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Additional resources to add to the message to be signed
|
|
170
|
+
*
|
|
171
|
+
* @default undefined
|
|
172
|
+
*/
|
|
173
|
+
providerResources: string[] | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* Set up event listeners for the wallet
|
|
176
|
+
*
|
|
177
|
+
* @default undefined
|
|
178
|
+
*/
|
|
44
179
|
setupEventListeners(listeners: WalletEventListeners): void;
|
|
180
|
+
/**
|
|
181
|
+
* Sign a message
|
|
182
|
+
*
|
|
183
|
+
* @default Promise<undefined>
|
|
184
|
+
*/
|
|
45
185
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
46
|
-
|
|
186
|
+
/**
|
|
187
|
+
* List of supported chains for this wallet
|
|
188
|
+
*/
|
|
189
|
+
abstract readonly supportedChains: Chain[];
|
|
190
|
+
/**
|
|
191
|
+
* Whether the wallet supports network switching
|
|
192
|
+
*
|
|
193
|
+
* @default false
|
|
194
|
+
*/
|
|
47
195
|
supportsNetworkSwitching(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Switch the network
|
|
198
|
+
* @default Promise<undefined>
|
|
199
|
+
*/
|
|
48
200
|
switchNetwork({ networkName, networkChainId, }: {
|
|
49
201
|
networkChainId?: number;
|
|
50
202
|
networkName?: string;
|
|
51
203
|
}): Promise<void>;
|
|
52
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Requires switching network in the wallet itself
|
|
206
|
+
* @default undefined
|
|
207
|
+
*/
|
|
208
|
+
switchNetworkOnlyFromWallet: boolean | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Tear down event listeners for the wallet
|
|
211
|
+
* @default void
|
|
212
|
+
*/
|
|
53
213
|
teardownEventListeners(): void;
|
|
54
214
|
}
|
|
55
|
-
export interface EmailWalletConnector extends WalletConnector {
|
|
56
|
-
canConnectViaEmail: boolean;
|
|
57
|
-
cancelPreviousEmail(): void;
|
|
58
|
-
readonly email: string | undefined;
|
|
59
|
-
setEmail(email: string): void;
|
|
60
|
-
}
|
|
61
|
-
export interface EmailOTPWalletConnector extends EmailWalletConnector {
|
|
62
|
-
verifyOneTimePassword(otp: string): Promise<boolean>;
|
|
63
|
-
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
2
5
|
const Chains = [
|
|
3
6
|
'ETH',
|
|
4
7
|
'FLOW',
|
|
@@ -8,6 +11,206 @@ const Chains = [
|
|
|
8
11
|
'STARK',
|
|
9
12
|
'ATOM',
|
|
10
13
|
'COSMOS',
|
|
11
|
-
];
|
|
14
|
+
];
|
|
15
|
+
const socialProviders = [
|
|
16
|
+
'google',
|
|
17
|
+
'facebook',
|
|
18
|
+
'apple',
|
|
19
|
+
'github',
|
|
20
|
+
'bitbucket',
|
|
21
|
+
'gitlab',
|
|
22
|
+
'linkedin',
|
|
23
|
+
'twitter',
|
|
24
|
+
'discord',
|
|
25
|
+
'twitch',
|
|
26
|
+
'microsoft',
|
|
27
|
+
];
|
|
28
|
+
class WalletConnectorBase {
|
|
29
|
+
constructor() {
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
this.canConnectViaEmail = false;
|
|
34
|
+
/**
|
|
35
|
+
* IF the wallet needs to be connected via a custodial service
|
|
36
|
+
* such as Blocto, this will be true.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
this.canConnectViaCustodialService = false;
|
|
40
|
+
/**
|
|
41
|
+
* If the wallet is not installed, and can be connected via a QR code,
|
|
42
|
+
* this will be true.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
this.canConnectViaQrCode = false;
|
|
46
|
+
/**
|
|
47
|
+
* Whether this connector can be connected via social login.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
this.canConnectViaSocial = false;
|
|
51
|
+
/**
|
|
52
|
+
* Flag if it is wallet Connect
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
this.isWalletConnect = false;
|
|
57
|
+
/**
|
|
58
|
+
* Additional resources to add to the message to be signed
|
|
59
|
+
*
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
62
|
+
this.providerResources = undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Requires switching network in the wallet itself
|
|
65
|
+
* @default undefined
|
|
66
|
+
*/
|
|
67
|
+
this.switchNetworkOnlyFromWallet = undefined;
|
|
68
|
+
}
|
|
69
|
+
connect() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
yield this.fetchPublicAddress();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generic function to close the wallet connection
|
|
76
|
+
* Originally implemented for WalletConnect, but it is used
|
|
77
|
+
* for anything that needs to be "logged out" or cleaned up
|
|
78
|
+
*
|
|
79
|
+
* @default Promise<undefined>
|
|
80
|
+
*/
|
|
81
|
+
endSession() {
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the public address of the wallet
|
|
86
|
+
*
|
|
87
|
+
* @default Promise<undefined>
|
|
88
|
+
*/
|
|
89
|
+
fetchPublicAddress(opts) {
|
|
90
|
+
return Promise.resolve(undefined);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets the balance of the wallet
|
|
94
|
+
*
|
|
95
|
+
* @default Promise<undefined>
|
|
96
|
+
*/
|
|
97
|
+
getBalance() {
|
|
98
|
+
return Promise.resolve(undefined);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the address silently
|
|
102
|
+
*
|
|
103
|
+
* @default Promise<[]>
|
|
104
|
+
*/
|
|
105
|
+
getConnectedAccounts() {
|
|
106
|
+
return Promise.resolve([]);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Gets the deep link of the wallet
|
|
110
|
+
*
|
|
111
|
+
* @default undefined
|
|
112
|
+
*/
|
|
113
|
+
getDeepLink() {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets current network of connected wallet
|
|
118
|
+
*
|
|
119
|
+
* @default Promise<undefined>
|
|
120
|
+
*/
|
|
121
|
+
getNetwork() {
|
|
122
|
+
return Promise.resolve(undefined);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets current network of connected wallet
|
|
126
|
+
*
|
|
127
|
+
* @default Promise<undefined>
|
|
128
|
+
*/
|
|
129
|
+
getNameService() {
|
|
130
|
+
return Promise.resolve(undefined);
|
|
131
|
+
}
|
|
132
|
+
getRpcProvider() {
|
|
133
|
+
return Promise.resolve(undefined);
|
|
134
|
+
}
|
|
135
|
+
getSession() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
return Promise.resolve();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
getSigner() {
|
|
141
|
+
return Promise.resolve(undefined);
|
|
142
|
+
}
|
|
143
|
+
getWeb3Provider() {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Initialize the wallet connector with any async operations
|
|
148
|
+
*
|
|
149
|
+
* @default Promise<void>
|
|
150
|
+
*/
|
|
151
|
+
init() {
|
|
152
|
+
return Promise.resolve();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Check if the wallet is installed on the browser
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
isInstalledOnBrowser() {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Normalized wallet name
|
|
164
|
+
*/
|
|
165
|
+
get key() {
|
|
166
|
+
return this.name.replace(/\W/g, '').toLowerCase();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* In most cases this is an alias for `signMessage`
|
|
170
|
+
*
|
|
171
|
+
* @default Promise<undefined>
|
|
172
|
+
*/
|
|
173
|
+
proveOwnership(messageToSign) {
|
|
174
|
+
return this.signMessage(messageToSign);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Set up event listeners for the wallet
|
|
178
|
+
*
|
|
179
|
+
* @default undefined
|
|
180
|
+
*/
|
|
181
|
+
setupEventListeners(listeners) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Sign a message
|
|
186
|
+
*
|
|
187
|
+
* @default Promise<undefined>
|
|
188
|
+
*/
|
|
189
|
+
signMessage(messageToSign) {
|
|
190
|
+
return Promise.resolve(undefined);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Whether the wallet supports network switching
|
|
194
|
+
*
|
|
195
|
+
* @default false
|
|
196
|
+
*/
|
|
197
|
+
supportsNetworkSwitching() {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Switch the network
|
|
202
|
+
* @default Promise<undefined>
|
|
203
|
+
*/
|
|
204
|
+
switchNetwork({ networkName, networkChainId, }) {
|
|
205
|
+
return Promise.resolve(undefined);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Tear down event listeners for the wallet
|
|
209
|
+
* @default void
|
|
210
|
+
*/
|
|
211
|
+
teardownEventListeners() {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
12
215
|
|
|
13
|
-
export { Chains };
|
|
216
|
+
export { Chains, WalletConnectorBase, socialProviders };
|