@manahippo/aptos-wallet-adapter 0.3.8 → 0.4.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/README.md +18 -6
- package/dist/WalletAdapters/BaseAdapter.d.ts +19 -2
- package/dist/WalletAdapters/BaseAdapter.d.ts.map +1 -1
- package/dist/WalletAdapters/BaseAdapter.js +6 -14
- package/dist/WalletAdapters/BaseAdapter.js.map +1 -1
- package/dist/WalletAdapters/FewchaWallet.d.ts +2 -2
- package/dist/WalletAdapters/FewchaWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/FewchaWallet.js +127 -152
- package/dist/WalletAdapters/FewchaWallet.js.map +1 -1
- package/dist/WalletAdapters/HippoExtensionWallet.d.ts +1 -1
- package/dist/WalletAdapters/HippoExtensionWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/HippoExtensionWallet.js +97 -119
- package/dist/WalletAdapters/HippoExtensionWallet.js.map +1 -1
- package/dist/WalletAdapters/HippoWallet.js +105 -131
- package/dist/WalletAdapters/HippoWallet.js.map +1 -1
- package/dist/WalletAdapters/MartianWallet.d.ts +3 -5
- package/dist/WalletAdapters/MartianWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/MartianWallet.js +110 -130
- package/dist/WalletAdapters/MartianWallet.js.map +1 -1
- package/dist/WalletAdapters/NightlyWallet.js +1 -5
- package/dist/WalletAdapters/NightlyWallet.js.map +1 -1
- package/dist/WalletAdapters/{AptosWallet.d.ts → PetraWallet.d.ts} +4 -6
- package/dist/WalletAdapters/PetraWallet.d.ts.map +1 -0
- package/dist/WalletAdapters/PetraWallet.js +151 -0
- package/dist/WalletAdapters/PetraWallet.js.map +1 -0
- package/dist/WalletAdapters/PontemWallet.js +102 -128
- package/dist/WalletAdapters/PontemWallet.js.map +1 -1
- package/dist/WalletAdapters/SpikaWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/SpikaWallet.js +112 -137
- package/dist/WalletAdapters/SpikaWallet.js.map +1 -1
- package/dist/WalletAdapters/index.d.ts +1 -1
- package/dist/WalletAdapters/index.js +8 -24
- package/dist/WalletAdapters/index.js.map +1 -1
- package/dist/WalletProviders/WalletProvider.d.ts.map +1 -1
- package/dist/WalletProviders/WalletProvider.js +91 -102
- package/dist/WalletProviders/WalletProvider.js.map +1 -1
- package/dist/WalletProviders/errors.js +19 -41
- package/dist/WalletProviders/errors.js.map +1 -1
- package/dist/WalletProviders/index.js +3 -19
- package/dist/WalletProviders/index.js.map +1 -1
- package/dist/WalletProviders/useWallet.d.ts +3 -3
- package/dist/WalletProviders/useWallet.d.ts.map +1 -1
- package/dist/WalletProviders/useWallet.js +4 -8
- package/dist/WalletProviders/useWallet.js.map +1 -1
- package/dist/config/aptosConstants.js +10 -13
- package/dist/config/aptosConstants.js.map +1 -1
- package/dist/hooks/useLocalStorage.js +5 -9
- package/dist/hooks/useLocalStorage.js.map +1 -1
- package/dist/hooks/useSSR.js +4 -8
- package/dist/hooks/useSSR.js.map +1 -1
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/utilities/util.js +1 -5
- package/dist/utilities/util.js.map +1 -1
- package/package.json +3 -3
- package/src/WalletAdapters/BaseAdapter.ts +25 -2
- package/src/WalletAdapters/FewchaWallet.ts +4 -2
- package/src/WalletAdapters/HippoExtensionWallet.ts +1 -1
- package/src/WalletAdapters/MartianWallet.ts +10 -5
- package/src/WalletAdapters/{AptosWallet.ts → PetraWallet.ts} +10 -5
- package/src/WalletAdapters/SpikaWallet.ts +1 -1
- package/src/WalletAdapters/index.ts +1 -1
- package/src/WalletProviders/WalletProvider.tsx +40 -42
- package/src/WalletProviders/useWallet.ts +6 -2
- package/dist/WalletAdapters/AptosWallet.d.ts.map +0 -1
- package/dist/WalletAdapters/AptosWallet.js +0 -174
- package/dist/WalletAdapters/AptosWallet.js.map +0 -1
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PontemWalletAdapter = exports.PontemWalletName = void 0;
|
|
13
|
-
const errors_1 = require("../WalletProviders/errors");
|
|
14
|
-
const BaseAdapter_1 = require("./BaseAdapter");
|
|
15
|
-
exports.PontemWalletName = 'Pontem';
|
|
16
|
-
class PontemWalletAdapter extends BaseAdapter_1.BaseWalletAdapter {
|
|
1
|
+
import { WalletDisconnectionError, WalletNotConnectedError, WalletNotReadyError, WalletSignAndSubmitMessageError, WalletSignMessageError, WalletSignTransactionError } from '../WalletProviders/errors';
|
|
2
|
+
import { BaseWalletAdapter, scopePollingDetectionStrategy, WalletReadyState } from './BaseAdapter';
|
|
3
|
+
export const PontemWalletName = 'Pontem';
|
|
4
|
+
export class PontemWalletAdapter extends BaseWalletAdapter {
|
|
17
5
|
constructor({
|
|
18
6
|
// provider,
|
|
19
7
|
// network = WalletAdapterNetwork.Mainnet,
|
|
20
8
|
timeout = 10000 } = {}) {
|
|
21
9
|
super();
|
|
22
|
-
this.name =
|
|
10
|
+
this.name = PontemWalletName;
|
|
23
11
|
this.url = 'https://chrome.google.com/webstore/detail/pontem-wallet/phkbamefinggmakgklpkljjmgibohnba';
|
|
24
12
|
this.icon = 'https://www.gitbook.com/cdn-cgi/image/width=20,height=20,fit=contain,dpr=2,format=auto/https%3A%2F%2F736486047-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fspaces%252F-MVVJKmKQGx983dZy_jr%252Favatar-1619180126965.png%3Fgeneration%3D1619180127194239%26alt%3Dmedia';
|
|
25
13
|
this._readyState = typeof window === 'undefined' || typeof document === 'undefined'
|
|
26
|
-
?
|
|
27
|
-
:
|
|
14
|
+
? WalletReadyState.Unsupported
|
|
15
|
+
: WalletReadyState.NotDetected;
|
|
28
16
|
this._provider = typeof window !== 'undefined' ? window.pontem : undefined;
|
|
29
17
|
// this._network = network;
|
|
30
18
|
this._timeout = timeout;
|
|
31
19
|
this._connecting = false;
|
|
32
20
|
this._wallet = null;
|
|
33
|
-
if (typeof window !== 'undefined' && this._readyState !==
|
|
34
|
-
|
|
21
|
+
if (typeof window !== 'undefined' && this._readyState !== WalletReadyState.Unsupported) {
|
|
22
|
+
scopePollingDetectionStrategy(() => {
|
|
35
23
|
if (window.pontem) {
|
|
36
|
-
this._readyState =
|
|
24
|
+
this._readyState = WalletReadyState.Installed;
|
|
37
25
|
this.emit('readyStateChange', this._readyState);
|
|
38
26
|
return true;
|
|
39
27
|
}
|
|
@@ -42,136 +30,122 @@ class PontemWalletAdapter extends BaseAdapter_1.BaseWalletAdapter {
|
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
32
|
get publicAccount() {
|
|
45
|
-
var _a, _b, _c;
|
|
46
33
|
return {
|
|
47
|
-
publicKey:
|
|
48
|
-
address:
|
|
49
|
-
authKey:
|
|
34
|
+
publicKey: this._wallet?.publicKey || null,
|
|
35
|
+
address: this._wallet?.address || null,
|
|
36
|
+
authKey: this._wallet?.authKey || null
|
|
50
37
|
};
|
|
51
38
|
}
|
|
52
39
|
get connecting() {
|
|
53
40
|
return this._connecting;
|
|
54
41
|
}
|
|
55
42
|
get connected() {
|
|
56
|
-
|
|
57
|
-
return !!((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.isConnected);
|
|
43
|
+
return !!this._wallet?.isConnected;
|
|
58
44
|
}
|
|
59
45
|
get readyState() {
|
|
60
46
|
return this._readyState;
|
|
61
47
|
}
|
|
62
|
-
connect() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (isConnected) {
|
|
75
|
-
yield (provider === null || provider === void 0 ? void 0 : provider.disconnect());
|
|
76
|
-
}
|
|
77
|
-
const response = yield (provider === null || provider === void 0 ? void 0 : provider.connect());
|
|
78
|
-
if (!response) {
|
|
79
|
-
throw new errors_1.WalletNotConnectedError('No connect response');
|
|
80
|
-
}
|
|
81
|
-
const walletAccount = yield (provider === null || provider === void 0 ? void 0 : provider.account());
|
|
82
|
-
const publicKey = yield (provider === null || provider === void 0 ? void 0 : provider.publicKey());
|
|
83
|
-
if (walletAccount) {
|
|
84
|
-
this._wallet = {
|
|
85
|
-
address: walletAccount,
|
|
86
|
-
publicKey,
|
|
87
|
-
isConnected: true
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
this.emit('connect', ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.address) || '');
|
|
48
|
+
async connect() {
|
|
49
|
+
try {
|
|
50
|
+
if (this.connected || this.connecting)
|
|
51
|
+
return;
|
|
52
|
+
if (!(this._readyState === WalletReadyState.Loadable ||
|
|
53
|
+
this._readyState === WalletReadyState.Installed))
|
|
54
|
+
throw new WalletNotReadyError();
|
|
55
|
+
this._connecting = true;
|
|
56
|
+
const provider = this._provider || window.pontem;
|
|
57
|
+
const isConnected = await provider?.isConnected();
|
|
58
|
+
if (isConnected) {
|
|
59
|
+
await provider?.disconnect();
|
|
91
60
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
throw
|
|
61
|
+
const response = await provider?.connect();
|
|
62
|
+
if (!response) {
|
|
63
|
+
throw new WalletNotConnectedError('No connect response');
|
|
95
64
|
}
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
const walletAccount = await provider?.account();
|
|
66
|
+
const publicKey = await provider?.publicKey();
|
|
67
|
+
if (walletAccount) {
|
|
68
|
+
this._wallet = {
|
|
69
|
+
address: walletAccount,
|
|
70
|
+
publicKey,
|
|
71
|
+
isConnected: true
|
|
72
|
+
};
|
|
98
73
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
yield (provider === null || provider === void 0 ? void 0 : provider.disconnect());
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
this.emit('error', new errors_1.WalletDisconnectionError(error === null || error === void 0 ? void 0 : error.message, error));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
this.emit('disconnect');
|
|
115
|
-
});
|
|
74
|
+
this.emit('connect', this._wallet?.address || '');
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.emit('error', new Error('User has rejected the connection'));
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
this._connecting = false;
|
|
82
|
+
}
|
|
116
83
|
}
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
async disconnect() {
|
|
85
|
+
const wallet = this._wallet;
|
|
86
|
+
const provider = this._provider || window.pontem;
|
|
87
|
+
if (wallet) {
|
|
88
|
+
this._wallet = null;
|
|
119
89
|
try {
|
|
120
|
-
|
|
121
|
-
const provider = this._provider || window.pontem;
|
|
122
|
-
if (!wallet || !provider)
|
|
123
|
-
throw new errors_1.WalletNotConnectedError();
|
|
124
|
-
const response = yield (provider === null || provider === void 0 ? void 0 : provider.signTransaction(transactionPyld, options));
|
|
125
|
-
return response;
|
|
90
|
+
await provider?.disconnect();
|
|
126
91
|
}
|
|
127
92
|
catch (error) {
|
|
128
|
-
this.emit('error', new
|
|
129
|
-
throw error;
|
|
93
|
+
this.emit('error', new WalletDisconnectionError(error?.message, error));
|
|
130
94
|
}
|
|
131
|
-
}
|
|
95
|
+
}
|
|
96
|
+
this.emit('disconnect');
|
|
132
97
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
98
|
+
async signTransaction(transactionPyld, options) {
|
|
99
|
+
try {
|
|
100
|
+
const wallet = this._wallet;
|
|
101
|
+
const provider = this._provider || window.pontem;
|
|
102
|
+
if (!wallet || !provider)
|
|
103
|
+
throw new WalletNotConnectedError();
|
|
104
|
+
const response = await provider?.signTransaction(transactionPyld, options);
|
|
105
|
+
return response;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.emit('error', new WalletSignTransactionError(error));
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async signAndSubmitTransaction(transactionPyld, options) {
|
|
113
|
+
try {
|
|
114
|
+
const wallet = this._wallet;
|
|
115
|
+
const provider = this._provider || window.pontem;
|
|
116
|
+
if (!wallet || !provider)
|
|
117
|
+
throw new WalletNotConnectedError();
|
|
118
|
+
const response = await provider?.signAndSubmit(transactionPyld, options);
|
|
119
|
+
if (!response || !response.success) {
|
|
120
|
+
throw new Error('No response');
|
|
149
121
|
}
|
|
150
|
-
|
|
122
|
+
return { hash: response.result.hash };
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
this.emit('error', new WalletSignAndSubmitMessageError(error.error.message));
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
151
128
|
}
|
|
152
|
-
signMessage(message) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return response.result.hexString;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
throw new Error('Sign Message failed');
|
|
166
|
-
}
|
|
129
|
+
async signMessage(message) {
|
|
130
|
+
try {
|
|
131
|
+
const wallet = this._wallet;
|
|
132
|
+
const provider = this._provider || window.pontem;
|
|
133
|
+
if (!wallet || !provider)
|
|
134
|
+
throw new WalletNotConnectedError();
|
|
135
|
+
const response = await provider?.signMessage(message);
|
|
136
|
+
console.log('MEMEM>>>', response);
|
|
137
|
+
if (response.success) {
|
|
138
|
+
return response.result.hexString;
|
|
167
139
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.emit('error', new errors_1.WalletSignMessageError(errMsg));
|
|
171
|
-
throw error;
|
|
140
|
+
else {
|
|
141
|
+
throw new Error('Sign Message failed');
|
|
172
142
|
}
|
|
173
|
-
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const errMsg = error.message;
|
|
146
|
+
this.emit('error', new WalletSignMessageError(errMsg));
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
174
149
|
}
|
|
175
150
|
}
|
|
176
|
-
exports.PontemWalletAdapter = PontemWalletAdapter;
|
|
177
151
|
//# sourceMappingURL=PontemWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PontemWallet.js","sourceRoot":"","sources":["../../src/WalletAdapters/PontemWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PontemWallet.js","sourceRoot":"","sources":["../../src/WalletAdapters/PontemWallet.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,+BAA+B,EAC/B,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,iBAAiB,EACjB,6BAA6B,EAE7B,gBAAgB,EACjB,MAAM,eAAe,CAAC;AA8CvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAgC,CAAC;AAQjE,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAsBxD,YAAY;IACV,YAAY;IACZ,0CAA0C;IAC1C,OAAO,GAAG,KAAK,KACc,EAAE;QAC/B,KAAK,EAAE,C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SAA8C;IAElD,SAAS,CAAC,SAAS,EAAE,YAAY,GAAG,SAAS,CAAC;IAG9C,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE3B,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAGJ;IAEnC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IAE/B,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;gBAElB,EAGV,OAAe,EAChB,GAAE,wBAA6B;IAqBhC,IAAI,aAAa,IAAI,WAAW,CAM/B;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,UAAU,IAAI,gBAAgB,CAEjC;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA6CxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,eAAe,CAAC,WAAW,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAmBpF,wBAAwB,CAC5B,WAAW,EAAE,kBAAkB,EAC/B,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAmB/B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBpD"}
|
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SpikaWalletAdapter = exports.SpikaWalletName = void 0;
|
|
13
|
-
const errors_1 = require("../WalletProviders/errors");
|
|
14
|
-
const BaseAdapter_1 = require("./BaseAdapter");
|
|
15
|
-
exports.SpikaWalletName = 'Spika';
|
|
16
|
-
class SpikaWalletAdapter extends BaseAdapter_1.BaseWalletAdapter {
|
|
1
|
+
import { WalletDisconnectionError, WalletNotConnectedError, WalletNotReadyError, WalletSignAndSubmitMessageError, WalletSignMessageError, WalletSignTransactionError } from '../WalletProviders/errors';
|
|
2
|
+
import { BaseWalletAdapter, scopePollingDetectionStrategy, WalletReadyState } from './BaseAdapter';
|
|
3
|
+
export const SpikaWalletName = 'Spika';
|
|
4
|
+
export class SpikaWalletAdapter extends BaseWalletAdapter {
|
|
17
5
|
constructor({
|
|
18
6
|
// provider,
|
|
19
7
|
// network = WalletAdapterNetwork.Mainnet,
|
|
20
8
|
timeout = 10000 } = {}) {
|
|
21
9
|
super();
|
|
22
|
-
this.name =
|
|
10
|
+
this.name = SpikaWalletName;
|
|
23
11
|
this.url = 'https://chrome.google.com/webstore/detail/spika/fadkojdgchhfkdkklllhcphknohbmjmb';
|
|
24
|
-
this.icon = 'https://
|
|
12
|
+
this.icon = 'https://spika.app/assets/logo_400_nb.png';
|
|
25
13
|
this._readyState = typeof window === 'undefined' || typeof document === 'undefined'
|
|
26
|
-
?
|
|
27
|
-
:
|
|
14
|
+
? WalletReadyState.Unsupported
|
|
15
|
+
: WalletReadyState.NotDetected;
|
|
28
16
|
this._provider = typeof window !== 'undefined' ? window.spika : undefined;
|
|
29
17
|
// this._network = network;
|
|
30
18
|
this._timeout = timeout;
|
|
31
19
|
this._connecting = false;
|
|
32
20
|
this._wallet = null;
|
|
33
|
-
if (typeof window !== 'undefined' && this._readyState !==
|
|
34
|
-
|
|
21
|
+
if (typeof window !== 'undefined' && this._readyState !== WalletReadyState.Unsupported) {
|
|
22
|
+
scopePollingDetectionStrategy(() => {
|
|
35
23
|
if (window.spika) {
|
|
36
|
-
this._readyState =
|
|
24
|
+
this._readyState = WalletReadyState.Installed;
|
|
37
25
|
this.emit('readyStateChange', this._readyState);
|
|
38
26
|
return true;
|
|
39
27
|
}
|
|
@@ -42,146 +30,133 @@ class SpikaWalletAdapter extends BaseAdapter_1.BaseWalletAdapter {
|
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
32
|
get publicAccount() {
|
|
45
|
-
var _a, _b, _c;
|
|
46
33
|
return {
|
|
47
|
-
publicKey:
|
|
48
|
-
address:
|
|
49
|
-
authKey:
|
|
34
|
+
publicKey: this._wallet?.publicKey || null,
|
|
35
|
+
address: this._wallet?.address || null,
|
|
36
|
+
authKey: this._wallet?.authKey || null
|
|
50
37
|
};
|
|
51
38
|
}
|
|
52
39
|
get connecting() {
|
|
53
40
|
return this._connecting;
|
|
54
41
|
}
|
|
55
42
|
get connected() {
|
|
56
|
-
|
|
57
|
-
return !!((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.isConnected);
|
|
43
|
+
return !!this._wallet?.isConnected;
|
|
58
44
|
}
|
|
59
45
|
get readyState() {
|
|
60
46
|
return this._readyState;
|
|
61
47
|
}
|
|
62
|
-
connect() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (!(this._readyState === BaseAdapter_1.WalletReadyState.Loadable ||
|
|
69
|
-
this._readyState === BaseAdapter_1.WalletReadyState.Installed))
|
|
70
|
-
throw new errors_1.WalletNotReadyError();
|
|
71
|
-
this._connecting = true;
|
|
72
|
-
const provider = this._provider || window.spika;
|
|
73
|
-
yield (provider === null || provider === void 0 ? void 0 : provider.isConnected());
|
|
74
|
-
// const isConnected = await provider?.isConnected();
|
|
75
|
-
// if (isConnected === true) {
|
|
76
|
-
// await provider?.disconnect();
|
|
77
|
-
// }
|
|
78
|
-
const response = yield (provider === null || provider === void 0 ? void 0 : provider.connect());
|
|
79
|
-
if ((response === null || response === void 0 ? void 0 : response.publicKey) !== undefined) {
|
|
80
|
-
this._wallet = {
|
|
81
|
-
publicKey: response === null || response === void 0 ? void 0 : response.publicKey,
|
|
82
|
-
address: response === null || response === void 0 ? void 0 : response.account,
|
|
83
|
-
authKey: response === null || response === void 0 ? void 0 : response.authKey,
|
|
84
|
-
isConnected: true
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this._wallet = {
|
|
89
|
-
isConnected: false
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
this.emit('connect', this._wallet.publicKey);
|
|
48
|
+
async connect() {
|
|
49
|
+
try {
|
|
50
|
+
if (this.connected || this.connecting) {
|
|
51
|
+
return;
|
|
93
52
|
}
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
throw
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
53
|
+
if (!(this._readyState === WalletReadyState.Loadable ||
|
|
54
|
+
this._readyState === WalletReadyState.Installed))
|
|
55
|
+
throw new WalletNotReadyError();
|
|
56
|
+
this._connecting = true;
|
|
57
|
+
const provider = this._provider || window.spika;
|
|
58
|
+
await provider?.isConnected();
|
|
59
|
+
// const isConnected = await provider?.isConnected();
|
|
60
|
+
// if (isConnected === true) {
|
|
61
|
+
// await provider?.disconnect();
|
|
62
|
+
// }
|
|
63
|
+
const response = await provider?.connect();
|
|
64
|
+
if (response?.publicKey !== undefined) {
|
|
65
|
+
this._wallet = {
|
|
66
|
+
publicKey: response?.publicKey,
|
|
67
|
+
address: response?.account,
|
|
68
|
+
authKey: response?.authKey,
|
|
69
|
+
isConnected: true
|
|
70
|
+
};
|
|
100
71
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const wallet = this._wallet;
|
|
106
|
-
if (wallet) {
|
|
107
|
-
this._wallet = null;
|
|
108
|
-
try {
|
|
109
|
-
const provider = this._provider || window.spika;
|
|
110
|
-
yield (provider === null || provider === void 0 ? void 0 : provider.disconnect());
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
this.emit('error', new errors_1.WalletDisconnectionError(error === null || error === void 0 ? void 0 : error.message, error));
|
|
114
|
-
}
|
|
72
|
+
else {
|
|
73
|
+
this._wallet = {
|
|
74
|
+
isConnected: false
|
|
75
|
+
};
|
|
115
76
|
}
|
|
116
|
-
this.emit('
|
|
117
|
-
}
|
|
77
|
+
this.emit('connect', this._wallet.publicKey);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
this.emit('error', error);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
this._connecting = false;
|
|
85
|
+
}
|
|
118
86
|
}
|
|
119
|
-
|
|
120
|
-
|
|
87
|
+
async disconnect() {
|
|
88
|
+
const wallet = this._wallet;
|
|
89
|
+
if (wallet) {
|
|
90
|
+
this._wallet = null;
|
|
121
91
|
try {
|
|
122
|
-
const wallet = this._wallet;
|
|
123
92
|
const provider = this._provider || window.spika;
|
|
124
|
-
|
|
125
|
-
throw new errors_1.WalletNotConnectedError();
|
|
126
|
-
const response = yield (provider === null || provider === void 0 ? void 0 : provider.signTransaction(transaction, options));
|
|
127
|
-
if (response) {
|
|
128
|
-
return response;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
throw new Error('Sign Transaction failed');
|
|
132
|
-
}
|
|
93
|
+
await provider?.disconnect();
|
|
133
94
|
}
|
|
134
95
|
catch (error) {
|
|
135
|
-
|
|
136
|
-
this.emit('error', new errors_1.WalletSignTransactionError(errMsg));
|
|
137
|
-
throw error;
|
|
96
|
+
this.emit('error', new WalletDisconnectionError(error?.message, error));
|
|
138
97
|
}
|
|
139
|
-
}
|
|
98
|
+
}
|
|
99
|
+
this.emit('disconnect');
|
|
140
100
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return response;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
throw new Error('Transaction failed');
|
|
154
|
-
}
|
|
101
|
+
async signTransaction(transaction, options) {
|
|
102
|
+
try {
|
|
103
|
+
const wallet = this._wallet;
|
|
104
|
+
const provider = this._provider || window.spika;
|
|
105
|
+
if (!wallet || !provider)
|
|
106
|
+
throw new WalletNotConnectedError();
|
|
107
|
+
const response = await provider?.signTransaction(transaction, options);
|
|
108
|
+
if (response) {
|
|
109
|
+
return response;
|
|
155
110
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.emit('error', new errors_1.WalletSignAndSubmitMessageError(errMsg));
|
|
159
|
-
throw error;
|
|
111
|
+
else {
|
|
112
|
+
throw new Error('Sign Transaction failed');
|
|
160
113
|
}
|
|
161
|
-
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const errMsg = error.message;
|
|
117
|
+
this.emit('error', new WalletSignTransactionError(errMsg));
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
162
120
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return response;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
throw new Error('Sign Message failed');
|
|
176
|
-
}
|
|
121
|
+
async signAndSubmitTransaction(transaction, options) {
|
|
122
|
+
try {
|
|
123
|
+
const wallet = this._wallet;
|
|
124
|
+
const provider = this._provider || window.spika;
|
|
125
|
+
if (!wallet || !provider)
|
|
126
|
+
throw new WalletNotConnectedError();
|
|
127
|
+
const response = await provider?.signAndSubmitTransaction(transaction, options);
|
|
128
|
+
if (response) {
|
|
129
|
+
return response;
|
|
177
130
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
this.emit('error', new errors_1.WalletSignMessageError(errMsg));
|
|
181
|
-
throw error;
|
|
131
|
+
else {
|
|
132
|
+
throw new Error('Transaction failed');
|
|
182
133
|
}
|
|
183
|
-
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const errMsg = error.message;
|
|
137
|
+
this.emit('error', new WalletSignAndSubmitMessageError(errMsg));
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async signMessage(message) {
|
|
142
|
+
try {
|
|
143
|
+
const wallet = this._wallet;
|
|
144
|
+
const provider = this._provider || window.spika;
|
|
145
|
+
if (!wallet || !provider)
|
|
146
|
+
throw new WalletNotConnectedError();
|
|
147
|
+
const response = await provider?.signMessage(message);
|
|
148
|
+
if (response) {
|
|
149
|
+
return response;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new Error('Sign Message failed');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const errMsg = error.message;
|
|
157
|
+
this.emit('error', new WalletSignMessageError(errMsg));
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
184
160
|
}
|
|
185
161
|
}
|
|
186
|
-
exports.SpikaWalletAdapter = SpikaWalletAdapter;
|
|
187
162
|
//# sourceMappingURL=SpikaWallet.js.map
|