@aptos-labs/wallet-adapter-core 2.0.1 → 2.2.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.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.ts +24 -4
- package/dist/index.js +70 -3
- package/dist/index.mjs +62 -2
- package/package.json +12 -12
- package/src/WalletCore.ts +45 -3
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
- package/src/utils/helpers.ts +26 -0
- package/src/utils/index.ts +1 -0
- package/dist/index.global.js +0 -93
- package/dist/index.global.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-core
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 814939c: Add deeplink support
|
|
8
|
+
|
|
9
|
+
## 2.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 50968c4: Support to submit bcs serialized transactions
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 8dea640: Fix wallet adapter auto reconnect on page refresh
|
|
18
|
+
|
|
3
19
|
## 1.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Types } from 'aptos';
|
|
1
|
+
import { Types, TxnBuilderTypes } from 'aptos';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
3
|
|
|
4
4
|
declare enum WalletReadyState {
|
|
@@ -69,6 +69,9 @@ interface AdapterPluginProps<Name extends string = string> {
|
|
|
69
69
|
icon: `data:image/${"svg+xml" | "webp" | "png" | "gif"};base64,${string}`;
|
|
70
70
|
providerName?: string;
|
|
71
71
|
provider: any;
|
|
72
|
+
deeplinkProvider?: (data: {
|
|
73
|
+
url: string;
|
|
74
|
+
}) => string;
|
|
72
75
|
connect(): Promise<any>;
|
|
73
76
|
disconnect: () => Promise<any>;
|
|
74
77
|
network: () => Promise<any>;
|
|
@@ -166,13 +169,20 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
166
169
|
*/
|
|
167
170
|
disconnect(): Promise<void>;
|
|
168
171
|
/**
|
|
169
|
-
Sign and submit transaction to chain.
|
|
170
|
-
@param transaction
|
|
172
|
+
Sign and submit an entry (not bcs serialized) transaction type to chain.
|
|
173
|
+
@param transaction a non-bcs serialized transaction
|
|
171
174
|
@return response from the wallet's signAndSubmitTransaction function
|
|
172
175
|
@throws WalletSignAndSubmitMessageError
|
|
173
176
|
*/
|
|
174
177
|
signAndSubmitTransaction(transaction: Types.TransactionPayload): Promise<any>;
|
|
175
178
|
/**
|
|
179
|
+
Sign and submit a bsc serialized transaction type to chain.
|
|
180
|
+
@param transaction a bcs serialized transaction
|
|
181
|
+
@return response from the wallet's signAndSubmitBCSTransaction function
|
|
182
|
+
@throws WalletSignAndSubmitMessageError
|
|
183
|
+
*/
|
|
184
|
+
signAndSubmitBCSTransaction(transaction: TxnBuilderTypes.TransactionPayload): Promise<any>;
|
|
185
|
+
/**
|
|
176
186
|
Sign transaction (doesnt submit to chain).
|
|
177
187
|
@param transaction
|
|
178
188
|
@return response from the wallet's signTransaction function
|
|
@@ -201,4 +211,14 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
201
211
|
signMessageAndVerify(message: SignMessagePayload): Promise<boolean>;
|
|
202
212
|
}
|
|
203
213
|
|
|
204
|
-
|
|
214
|
+
declare function scopePollingDetectionStrategy(detect: () => boolean): void;
|
|
215
|
+
|
|
216
|
+
declare function setLocalStorage(walletName: WalletName): void;
|
|
217
|
+
declare function removeLocalStorage(): void;
|
|
218
|
+
declare function getLocalStorage(): void;
|
|
219
|
+
|
|
220
|
+
declare function isMobile(): boolean;
|
|
221
|
+
declare function isInAppBrowser(): boolean;
|
|
222
|
+
declare function isRedirectable(): boolean;
|
|
223
|
+
|
|
224
|
+
export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, NetworkInfo, NetworkName, PluginProvider, SignMessagePayload, SignMessageResponse, Wallet, WalletCore, WalletCoreEvents, WalletInfo, WalletName, WalletReadyState, getLocalStorage, isInAppBrowser, isMobile, isRedirectable, removeLocalStorage, scopePollingDetectionStrategy, setLocalStorage };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,14 @@ var src_exports = {};
|
|
|
28
28
|
__export(src_exports, {
|
|
29
29
|
NetworkName: () => NetworkName,
|
|
30
30
|
WalletCore: () => WalletCore,
|
|
31
|
-
WalletReadyState: () => WalletReadyState
|
|
31
|
+
WalletReadyState: () => WalletReadyState,
|
|
32
|
+
getLocalStorage: () => getLocalStorage,
|
|
33
|
+
isInAppBrowser: () => isInAppBrowser,
|
|
34
|
+
isMobile: () => isMobile,
|
|
35
|
+
isRedirectable: () => isRedirectable,
|
|
36
|
+
removeLocalStorage: () => removeLocalStorage,
|
|
37
|
+
scopePollingDetectionStrategy: () => scopePollingDetectionStrategy,
|
|
38
|
+
setLocalStorage: () => setLocalStorage
|
|
32
39
|
});
|
|
33
40
|
module.exports = __toCommonJS(src_exports);
|
|
34
41
|
|
|
@@ -183,6 +190,30 @@ function setLocalStorage(walletName) {
|
|
|
183
190
|
function removeLocalStorage() {
|
|
184
191
|
localStorage.removeItem(LOCAL_STORAGE_ITEM_KEY);
|
|
185
192
|
}
|
|
193
|
+
function getLocalStorage() {
|
|
194
|
+
localStorage.getItem(LOCAL_STORAGE_ITEM_KEY);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/utils/helpers.ts
|
|
198
|
+
function isMobile() {
|
|
199
|
+
return /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i.test(
|
|
200
|
+
navigator.userAgent
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
function isInAppBrowser() {
|
|
204
|
+
const isIphone = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(
|
|
205
|
+
navigator.userAgent
|
|
206
|
+
);
|
|
207
|
+
const isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(
|
|
208
|
+
navigator.userAgent
|
|
209
|
+
);
|
|
210
|
+
return isIphone || isAndroid;
|
|
211
|
+
}
|
|
212
|
+
function isRedirectable() {
|
|
213
|
+
if (!navigator)
|
|
214
|
+
return false;
|
|
215
|
+
return isMobile() && !isInAppBrowser();
|
|
216
|
+
}
|
|
186
217
|
|
|
187
218
|
// src/ans.ts
|
|
188
219
|
var ChainIdToAnsContractAddressMap = {
|
|
@@ -304,7 +335,7 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
304
335
|
}
|
|
305
336
|
}
|
|
306
337
|
async connect(walletName) {
|
|
307
|
-
var _a;
|
|
338
|
+
var _a, _b;
|
|
308
339
|
try {
|
|
309
340
|
const selectedWallet = (_a = this._wallets) == null ? void 0 : _a.find(
|
|
310
341
|
(wallet) => wallet.name === walletName
|
|
@@ -313,8 +344,19 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
313
344
|
return;
|
|
314
345
|
}
|
|
315
346
|
if (this._connected) {
|
|
347
|
+
if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
|
|
348
|
+
return;
|
|
316
349
|
await this.disconnect();
|
|
317
350
|
}
|
|
351
|
+
if (isRedirectable()) {
|
|
352
|
+
if (selectedWallet.deeplinkProvider) {
|
|
353
|
+
const url = encodeURIComponent(window.location.href);
|
|
354
|
+
const location = selectedWallet.deeplinkProvider({ url });
|
|
355
|
+
window.location.href = location;
|
|
356
|
+
} else {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
318
360
|
this._connecting = true;
|
|
319
361
|
this.setWallet(selectedWallet);
|
|
320
362
|
const account = await selectedWallet.connect();
|
|
@@ -356,6 +398,24 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
356
398
|
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
357
399
|
}
|
|
358
400
|
}
|
|
401
|
+
async signAndSubmitBCSTransaction(transaction) {
|
|
402
|
+
var _a;
|
|
403
|
+
if (this._wallet && !("signAndSubmitBCSTransaction" in this._wallet)) {
|
|
404
|
+
throw new WalletNotSupportedMethod(
|
|
405
|
+
`Submit a BCS Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
|
|
406
|
+
).message;
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
this.doesWalletExist();
|
|
410
|
+
const response = await this._wallet.signAndSubmitBCSTransaction(
|
|
411
|
+
transaction
|
|
412
|
+
);
|
|
413
|
+
return response;
|
|
414
|
+
} catch (error) {
|
|
415
|
+
const errMsg = typeof error == "object" && "message" in error ? error.message : error;
|
|
416
|
+
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
359
419
|
async signTransaction(transaction) {
|
|
360
420
|
var _a;
|
|
361
421
|
if (this._wallet && !("signTransaction" in this._wallet)) {
|
|
@@ -476,5 +536,12 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
476
536
|
0 && (module.exports = {
|
|
477
537
|
NetworkName,
|
|
478
538
|
WalletCore,
|
|
479
|
-
WalletReadyState
|
|
539
|
+
WalletReadyState,
|
|
540
|
+
getLocalStorage,
|
|
541
|
+
isInAppBrowser,
|
|
542
|
+
isMobile,
|
|
543
|
+
isRedirectable,
|
|
544
|
+
removeLocalStorage,
|
|
545
|
+
scopePollingDetectionStrategy,
|
|
546
|
+
setLocalStorage
|
|
480
547
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -149,6 +149,30 @@ function setLocalStorage(walletName) {
|
|
|
149
149
|
function removeLocalStorage() {
|
|
150
150
|
localStorage.removeItem(LOCAL_STORAGE_ITEM_KEY);
|
|
151
151
|
}
|
|
152
|
+
function getLocalStorage() {
|
|
153
|
+
localStorage.getItem(LOCAL_STORAGE_ITEM_KEY);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/utils/helpers.ts
|
|
157
|
+
function isMobile() {
|
|
158
|
+
return /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i.test(
|
|
159
|
+
navigator.userAgent
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function isInAppBrowser() {
|
|
163
|
+
const isIphone = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(
|
|
164
|
+
navigator.userAgent
|
|
165
|
+
);
|
|
166
|
+
const isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(
|
|
167
|
+
navigator.userAgent
|
|
168
|
+
);
|
|
169
|
+
return isIphone || isAndroid;
|
|
170
|
+
}
|
|
171
|
+
function isRedirectable() {
|
|
172
|
+
if (!navigator)
|
|
173
|
+
return false;
|
|
174
|
+
return isMobile() && !isInAppBrowser();
|
|
175
|
+
}
|
|
152
176
|
|
|
153
177
|
// src/ans.ts
|
|
154
178
|
var ChainIdToAnsContractAddressMap = {
|
|
@@ -270,7 +294,7 @@ var WalletCore = class extends EventEmitter {
|
|
|
270
294
|
}
|
|
271
295
|
}
|
|
272
296
|
async connect(walletName) {
|
|
273
|
-
var _a;
|
|
297
|
+
var _a, _b;
|
|
274
298
|
try {
|
|
275
299
|
const selectedWallet = (_a = this._wallets) == null ? void 0 : _a.find(
|
|
276
300
|
(wallet) => wallet.name === walletName
|
|
@@ -279,8 +303,19 @@ var WalletCore = class extends EventEmitter {
|
|
|
279
303
|
return;
|
|
280
304
|
}
|
|
281
305
|
if (this._connected) {
|
|
306
|
+
if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
|
|
307
|
+
return;
|
|
282
308
|
await this.disconnect();
|
|
283
309
|
}
|
|
310
|
+
if (isRedirectable()) {
|
|
311
|
+
if (selectedWallet.deeplinkProvider) {
|
|
312
|
+
const url = encodeURIComponent(window.location.href);
|
|
313
|
+
const location = selectedWallet.deeplinkProvider({ url });
|
|
314
|
+
window.location.href = location;
|
|
315
|
+
} else {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
284
319
|
this._connecting = true;
|
|
285
320
|
this.setWallet(selectedWallet);
|
|
286
321
|
const account = await selectedWallet.connect();
|
|
@@ -322,6 +357,24 @@ var WalletCore = class extends EventEmitter {
|
|
|
322
357
|
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
323
358
|
}
|
|
324
359
|
}
|
|
360
|
+
async signAndSubmitBCSTransaction(transaction) {
|
|
361
|
+
var _a;
|
|
362
|
+
if (this._wallet && !("signAndSubmitBCSTransaction" in this._wallet)) {
|
|
363
|
+
throw new WalletNotSupportedMethod(
|
|
364
|
+
`Submit a BCS Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
|
|
365
|
+
).message;
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
this.doesWalletExist();
|
|
369
|
+
const response = await this._wallet.signAndSubmitBCSTransaction(
|
|
370
|
+
transaction
|
|
371
|
+
);
|
|
372
|
+
return response;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
const errMsg = typeof error == "object" && "message" in error ? error.message : error;
|
|
375
|
+
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
325
378
|
async signTransaction(transaction) {
|
|
326
379
|
var _a;
|
|
327
380
|
if (this._wallet && !("signTransaction" in this._wallet)) {
|
|
@@ -441,5 +494,12 @@ var WalletCore = class extends EventEmitter {
|
|
|
441
494
|
export {
|
|
442
495
|
NetworkName,
|
|
443
496
|
WalletCore,
|
|
444
|
-
WalletReadyState
|
|
497
|
+
WalletReadyState,
|
|
498
|
+
getLocalStorage,
|
|
499
|
+
isInAppBrowser,
|
|
500
|
+
isMobile,
|
|
501
|
+
isRedirectable,
|
|
502
|
+
removeLocalStorage,
|
|
503
|
+
scopePollingDetectionStrategy,
|
|
504
|
+
setLocalStorage
|
|
445
505
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter Core",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -27,27 +27,27 @@
|
|
|
27
27
|
"Wallet Adapter",
|
|
28
28
|
"Aptos Wallet"
|
|
29
29
|
],
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
32
|
-
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
33
|
-
"test": "jest",
|
|
34
|
-
"lint": "TIMING=1 eslint \"src/**/*.ts*\"",
|
|
35
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
36
|
-
},
|
|
37
30
|
"devDependencies": {
|
|
38
|
-
"@aptos-labs/eslint-config-adapter": "workspace:*",
|
|
39
|
-
"@aptos-labs/wallet-adapter-tsconfig": "workspace:*",
|
|
40
31
|
"@types/jest": "^29.2.4",
|
|
41
32
|
"eslint": "^8.15.0",
|
|
42
33
|
"jest": "^29.3.1",
|
|
43
34
|
"ts-jest": "^29.0.3",
|
|
44
35
|
"tsup": "^5.10.1",
|
|
45
|
-
"typescript": "^4.5.3"
|
|
36
|
+
"typescript": "^4.5.3",
|
|
37
|
+
"@aptos-labs/eslint-config-adapter": "0.0.0",
|
|
38
|
+
"@aptos-labs/wallet-adapter-tsconfig": "0.0.0"
|
|
46
39
|
},
|
|
47
40
|
"dependencies": {
|
|
48
41
|
"aptos": "^1.3.17",
|
|
49
42
|
"buffer": "^6.0.3",
|
|
50
43
|
"eventemitter3": "^4.0.7",
|
|
51
44
|
"tweetnacl": "^1.0.3"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
48
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
49
|
+
"test": "jest",
|
|
50
|
+
"lint": "TIMING=1 eslint \"src/**/*.ts*\"",
|
|
51
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|
package/src/WalletCore.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HexString, Types } from "aptos";
|
|
1
|
+
import { HexString, TxnBuilderTypes, Types } from "aptos";
|
|
2
2
|
import EventEmitter from "eventemitter3";
|
|
3
3
|
import nacl from "tweetnacl";
|
|
4
4
|
import { Buffer } from "buffer";
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
removeLocalStorage,
|
|
35
35
|
setLocalStorage,
|
|
36
36
|
scopePollingDetectionStrategy,
|
|
37
|
+
isRedirectable,
|
|
37
38
|
} from "./utils";
|
|
38
39
|
import { getNameByAddress } from "./ans";
|
|
39
40
|
|
|
@@ -195,8 +196,21 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
if (this._connected) {
|
|
199
|
+
// if the selected wallet is already connected, we don't need to connect again
|
|
200
|
+
if (this.wallet?.name === walletName) return;
|
|
201
|
+
|
|
198
202
|
await this.disconnect();
|
|
199
203
|
}
|
|
204
|
+
if (isRedirectable()) {
|
|
205
|
+
// use wallet deep link
|
|
206
|
+
if (selectedWallet.deeplinkProvider) {
|
|
207
|
+
const url = encodeURIComponent(window.location.href);
|
|
208
|
+
const location = selectedWallet.deeplinkProvider({ url });
|
|
209
|
+
window.location.href = location;
|
|
210
|
+
} else {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
200
214
|
this._connecting = true;
|
|
201
215
|
this.setWallet(selectedWallet);
|
|
202
216
|
const account = await selectedWallet.connect();
|
|
@@ -233,8 +247,8 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
/**
|
|
236
|
-
Sign and submit transaction to chain.
|
|
237
|
-
@param transaction
|
|
250
|
+
Sign and submit an entry (not bcs serialized) transaction type to chain.
|
|
251
|
+
@param transaction a non-bcs serialized transaction
|
|
238
252
|
@return response from the wallet's signAndSubmitTransaction function
|
|
239
253
|
@throws WalletSignAndSubmitMessageError
|
|
240
254
|
*/
|
|
@@ -254,6 +268,34 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
254
268
|
}
|
|
255
269
|
}
|
|
256
270
|
|
|
271
|
+
/**
|
|
272
|
+
Sign and submit a bsc serialized transaction type to chain.
|
|
273
|
+
@param transaction a bcs serialized transaction
|
|
274
|
+
@return response from the wallet's signAndSubmitBCSTransaction function
|
|
275
|
+
@throws WalletSignAndSubmitMessageError
|
|
276
|
+
*/
|
|
277
|
+
async signAndSubmitBCSTransaction(
|
|
278
|
+
transaction: TxnBuilderTypes.TransactionPayload
|
|
279
|
+
): Promise<any> {
|
|
280
|
+
if (this._wallet && !("signAndSubmitBCSTransaction" in this._wallet)) {
|
|
281
|
+
throw new WalletNotSupportedMethod(
|
|
282
|
+
`Submit a BCS Transaction is not supported by ${this.wallet?.name}`
|
|
283
|
+
).message;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
this.doesWalletExist();
|
|
288
|
+
const response = await (this._wallet as any).signAndSubmitBCSTransaction(
|
|
289
|
+
transaction
|
|
290
|
+
);
|
|
291
|
+
return response;
|
|
292
|
+
} catch (error: any) {
|
|
293
|
+
const errMsg =
|
|
294
|
+
typeof error == "object" && "message" in error ? error.message : error;
|
|
295
|
+
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
257
299
|
/**
|
|
258
300
|
Sign transaction (doesnt submit to chain).
|
|
259
301
|
@param transaction
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface AdapterPluginProps<Name extends string = string> {
|
|
|
53
53
|
icon: `data:image/${"svg+xml" | "webp" | "png" | "gif"};base64,${string}`;
|
|
54
54
|
providerName?: string;
|
|
55
55
|
provider: any;
|
|
56
|
+
deeplinkProvider?: (data: { url: string }) => string;
|
|
56
57
|
connect(): Promise<any>;
|
|
57
58
|
disconnect: () => Promise<any>;
|
|
58
59
|
network: () => Promise<any>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function isMobile(): boolean {
|
|
2
|
+
return /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i.test(
|
|
3
|
+
navigator.userAgent
|
|
4
|
+
);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isInAppBrowser(): boolean {
|
|
8
|
+
const isIphone = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(
|
|
9
|
+
navigator.userAgent
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(
|
|
13
|
+
navigator.userAgent
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return isIphone || isAndroid;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isRedirectable(): boolean {
|
|
20
|
+
// SSR: return false
|
|
21
|
+
if (!navigator) return false;
|
|
22
|
+
|
|
23
|
+
// if we are on mobile and NOT in a in-app browser we will redirect to a wallet app
|
|
24
|
+
|
|
25
|
+
return isMobile() && !isInAppBrowser();
|
|
26
|
+
}
|
package/src/utils/index.ts
CHANGED