@aptos-labs/wallet-adapter-core 5.3.0 → 5.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/dist/WalletCore.d.ts +4 -0
- package/dist/WalletCore.d.ts.map +1 -1
- package/dist/index.js +2215 -980
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2075 -956
- package/dist/index.mjs.map +1 -1
- package/dist/sdkWallets.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/types.d.ts +2 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +7 -5
- package/src/WalletCore.ts +9 -2
- package/src/sdkWallets.ts +10 -0
- package/src/utils/types.ts +8 -5
- package/src/version.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,1025 +1,2144 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function _assert_this_initialized(self) {
|
|
3
|
+
if (self === void 0) {
|
|
4
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
5
|
+
}
|
|
6
|
+
return self;
|
|
7
|
+
}
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9
|
+
try {
|
|
10
|
+
var info = gen[key](arg);
|
|
11
|
+
var value = info.value;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
reject(error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (info.done) {
|
|
17
|
+
resolve(value);
|
|
18
|
+
} else {
|
|
19
|
+
Promise.resolve(value).then(_next, _throw);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _async_to_generator(fn) {
|
|
23
|
+
return function() {
|
|
24
|
+
var self = this, args = arguments;
|
|
25
|
+
return new Promise(function(resolve, reject) {
|
|
26
|
+
var gen = fn.apply(self, args);
|
|
27
|
+
function _next(value) {
|
|
28
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
29
|
+
}
|
|
30
|
+
function _throw(err) {
|
|
31
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
32
|
+
}
|
|
33
|
+
_next(undefined);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function _call_super(_this, derived, args) {
|
|
38
|
+
derived = _get_prototype_of(derived);
|
|
39
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
40
|
+
}
|
|
41
|
+
function _class_call_check(instance, Constructor) {
|
|
42
|
+
if (!(instance instanceof Constructor)) {
|
|
43
|
+
throw new TypeError("Cannot call a class as a function");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function _construct(Parent, args, Class) {
|
|
47
|
+
if (_is_native_reflect_construct()) {
|
|
48
|
+
_construct = Reflect.construct;
|
|
49
|
+
} else {
|
|
50
|
+
_construct = function construct(Parent, args, Class) {
|
|
51
|
+
var a = [
|
|
52
|
+
null
|
|
53
|
+
];
|
|
54
|
+
a.push.apply(a, args);
|
|
55
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
56
|
+
var instance = new Constructor();
|
|
57
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
58
|
+
return instance;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return _construct.apply(null, arguments);
|
|
62
|
+
}
|
|
63
|
+
function _defineProperties(target, props) {
|
|
64
|
+
for(var i = 0; i < props.length; i++){
|
|
65
|
+
var descriptor = props[i];
|
|
66
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
67
|
+
descriptor.configurable = true;
|
|
68
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
69
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
73
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
74
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
75
|
+
return Constructor;
|
|
76
|
+
}
|
|
77
|
+
function _define_property(obj, key, value) {
|
|
78
|
+
if (key in obj) {
|
|
79
|
+
Object.defineProperty(obj, key, {
|
|
80
|
+
value: value,
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
obj[key] = value;
|
|
87
|
+
}
|
|
88
|
+
return obj;
|
|
89
|
+
}
|
|
90
|
+
function _get_prototype_of(o) {
|
|
91
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
92
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
93
|
+
};
|
|
94
|
+
return _get_prototype_of(o);
|
|
95
|
+
}
|
|
96
|
+
function _inherits(subClass, superClass) {
|
|
97
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
98
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
99
|
+
}
|
|
100
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
101
|
+
constructor: {
|
|
102
|
+
value: subClass,
|
|
103
|
+
writable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
108
|
+
}
|
|
109
|
+
function _is_native_function(fn) {
|
|
110
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
111
|
+
}
|
|
112
|
+
function _object_spread(target) {
|
|
113
|
+
for(var i = 1; i < arguments.length; i++){
|
|
114
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
115
|
+
var ownKeys = Object.keys(source);
|
|
116
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
117
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
118
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
ownKeys.forEach(function(key) {
|
|
122
|
+
_define_property(target, key, source[key]);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return target;
|
|
126
|
+
}
|
|
127
|
+
function ownKeys(object, enumerableOnly) {
|
|
128
|
+
var keys = Object.keys(object);
|
|
129
|
+
if (Object.getOwnPropertySymbols) {
|
|
130
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
131
|
+
if (enumerableOnly) {
|
|
132
|
+
symbols = symbols.filter(function(sym) {
|
|
133
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
keys.push.apply(keys, symbols);
|
|
137
|
+
}
|
|
138
|
+
return keys;
|
|
139
|
+
}
|
|
140
|
+
function _object_spread_props(target, source) {
|
|
141
|
+
source = source != null ? source : {};
|
|
142
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
143
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
144
|
+
} else {
|
|
145
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
146
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return target;
|
|
150
|
+
}
|
|
151
|
+
function _possible_constructor_return(self, call) {
|
|
152
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
153
|
+
return call;
|
|
154
|
+
}
|
|
155
|
+
return _assert_this_initialized(self);
|
|
156
|
+
}
|
|
157
|
+
function _set_prototype_of(o, p) {
|
|
158
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
159
|
+
o.__proto__ = p;
|
|
160
|
+
return o;
|
|
161
|
+
};
|
|
162
|
+
return _set_prototype_of(o, p);
|
|
163
|
+
}
|
|
164
|
+
function _type_of(obj) {
|
|
165
|
+
"@swc/helpers - typeof";
|
|
166
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
167
|
+
}
|
|
168
|
+
function _wrap_native_super(Class) {
|
|
169
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
170
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
171
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
172
|
+
if (typeof Class !== "function") {
|
|
173
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
174
|
+
}
|
|
175
|
+
if (typeof _cache !== "undefined") {
|
|
176
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
177
|
+
_cache.set(Class, Wrapper);
|
|
178
|
+
}
|
|
179
|
+
function Wrapper() {
|
|
180
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
181
|
+
}
|
|
182
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
183
|
+
constructor: {
|
|
184
|
+
value: Wrapper,
|
|
185
|
+
enumerable: false,
|
|
186
|
+
writable: true,
|
|
187
|
+
configurable: true
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return _set_prototype_of(Wrapper, Class);
|
|
191
|
+
};
|
|
192
|
+
return _wrap_native_super(Class);
|
|
193
|
+
}
|
|
194
|
+
function _is_native_reflect_construct() {
|
|
195
|
+
try {
|
|
196
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
197
|
+
} catch (_) {}
|
|
198
|
+
return (_is_native_reflect_construct = function() {
|
|
199
|
+
return !!result;
|
|
200
|
+
})();
|
|
201
|
+
}
|
|
202
|
+
function _ts_generator(thisArg, body) {
|
|
203
|
+
var f, y, t, g, _ = {
|
|
204
|
+
label: 0,
|
|
205
|
+
sent: function() {
|
|
206
|
+
if (t[0] & 1) throw t[1];
|
|
207
|
+
return t[1];
|
|
208
|
+
},
|
|
209
|
+
trys: [],
|
|
210
|
+
ops: []
|
|
211
|
+
};
|
|
212
|
+
return g = {
|
|
213
|
+
next: verb(0),
|
|
214
|
+
"throw": verb(1),
|
|
215
|
+
"return": verb(2)
|
|
216
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
217
|
+
return this;
|
|
218
|
+
}), g;
|
|
219
|
+
function verb(n) {
|
|
220
|
+
return function(v) {
|
|
221
|
+
return step([
|
|
222
|
+
n,
|
|
223
|
+
v
|
|
224
|
+
]);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function step(op) {
|
|
228
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
229
|
+
while(_)try {
|
|
230
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
231
|
+
if (y = 0, t) op = [
|
|
232
|
+
op[0] & 2,
|
|
233
|
+
t.value
|
|
234
|
+
];
|
|
235
|
+
switch(op[0]){
|
|
236
|
+
case 0:
|
|
237
|
+
case 1:
|
|
238
|
+
t = op;
|
|
239
|
+
break;
|
|
240
|
+
case 4:
|
|
241
|
+
_.label++;
|
|
242
|
+
return {
|
|
243
|
+
value: op[1],
|
|
244
|
+
done: false
|
|
245
|
+
};
|
|
246
|
+
case 5:
|
|
247
|
+
_.label++;
|
|
248
|
+
y = op[1];
|
|
249
|
+
op = [
|
|
250
|
+
0
|
|
251
|
+
];
|
|
252
|
+
continue;
|
|
253
|
+
case 7:
|
|
254
|
+
op = _.ops.pop();
|
|
255
|
+
_.trys.pop();
|
|
256
|
+
continue;
|
|
257
|
+
default:
|
|
258
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
259
|
+
_ = 0;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
263
|
+
_.label = op[1];
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
267
|
+
_.label = t[1];
|
|
268
|
+
t = op;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
if (t && _.label < t[2]) {
|
|
272
|
+
_.label = t[2];
|
|
273
|
+
_.ops.push(op);
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (t[2]) _.ops.pop();
|
|
277
|
+
_.trys.pop();
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
op = body.call(thisArg, _);
|
|
281
|
+
} catch (e) {
|
|
282
|
+
op = [
|
|
283
|
+
6,
|
|
284
|
+
e
|
|
285
|
+
];
|
|
286
|
+
y = 0;
|
|
287
|
+
} finally{
|
|
288
|
+
f = t = 0;
|
|
289
|
+
}
|
|
290
|
+
if (op[0] & 5) throw op[1];
|
|
291
|
+
return {
|
|
292
|
+
value: op[0] ? op[1] : void 0,
|
|
293
|
+
done: true
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
var WALLET_ADAPTER_CORE_VERSION = "5.4.1";
|
|
4
298
|
// src/WalletCore.ts
|
|
5
299
|
import EventEmitter from "eventemitter3";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
Aptos as Aptos2,
|
|
9
|
-
Network as Network3,
|
|
10
|
-
NetworkToChainId
|
|
11
|
-
} from "@aptos-labs/ts-sdk";
|
|
12
|
-
import {
|
|
13
|
-
getAptosWallets,
|
|
14
|
-
isWalletWithRequiredFeatureSet,
|
|
15
|
-
UserResponseStatus
|
|
16
|
-
} from "@aptos-labs/wallet-standard";
|
|
17
|
-
|
|
300
|
+
import { AccountAddress, Aptos as Aptos2, Network as Network3, NetworkToChainId } from "@aptos-labs/ts-sdk";
|
|
301
|
+
import { getAptosWallets, isWalletWithRequiredFeatureSet, UserResponseStatus } from "@aptos-labs/wallet-standard";
|
|
18
302
|
// src/ga/index.ts
|
|
19
|
-
var GA4 =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
|
|
303
|
+
var GA4 = /*#__PURE__*/ function() {
|
|
304
|
+
"use strict";
|
|
305
|
+
function GA4() {
|
|
306
|
+
_class_call_check(this, GA4);
|
|
307
|
+
this.aptosGAID = "G-GNVVWBL3J9";
|
|
308
|
+
this.injectGA(this.aptosGAID);
|
|
309
|
+
}
|
|
310
|
+
_create_class(GA4, [
|
|
311
|
+
{
|
|
312
|
+
key: "gtag",
|
|
313
|
+
value: function gtag(a, b, c) {
|
|
314
|
+
var dataLayer = window.dataLayer || [];
|
|
315
|
+
dataLayer.push(arguments);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
key: "injectGA",
|
|
320
|
+
value: function injectGA(gaID) {
|
|
321
|
+
if (typeof window === "undefined") return;
|
|
322
|
+
if (!gaID) return;
|
|
323
|
+
var head = document.getElementsByTagName("head")[0];
|
|
324
|
+
var myScript = document.createElement("script");
|
|
325
|
+
myScript.setAttribute("src", "https://www.googletagmanager.com/gtag/js?id=".concat(gaID));
|
|
326
|
+
var that = this;
|
|
327
|
+
myScript.onload = function() {
|
|
328
|
+
that.gtag("js", /* @__PURE__ */ new Date());
|
|
329
|
+
that.gtag("config", "".concat(gaID), {
|
|
330
|
+
send_page_view: false
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
head.insertBefore(myScript, head.children[1]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
]);
|
|
337
|
+
return GA4;
|
|
338
|
+
}();
|
|
50
339
|
// src/error/index.ts
|
|
51
|
-
var WalletError =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
340
|
+
var WalletError = /*#__PURE__*/ function(Error1) {
|
|
341
|
+
"use strict";
|
|
342
|
+
_inherits(WalletError, Error1);
|
|
343
|
+
function WalletError(message, error) {
|
|
344
|
+
_class_call_check(this, WalletError);
|
|
345
|
+
var _this;
|
|
346
|
+
_this = _call_super(this, WalletError, [
|
|
347
|
+
message
|
|
348
|
+
]);
|
|
349
|
+
_this.error = error;
|
|
350
|
+
return _this;
|
|
351
|
+
}
|
|
352
|
+
return WalletError;
|
|
353
|
+
}(_wrap_native_super(Error));
|
|
354
|
+
var WalletNotSelectedError = /*#__PURE__*/ function(WalletError) {
|
|
355
|
+
"use strict";
|
|
356
|
+
_inherits(WalletNotSelectedError, WalletError);
|
|
357
|
+
function WalletNotSelectedError() {
|
|
358
|
+
_class_call_check(this, WalletNotSelectedError);
|
|
359
|
+
var _this;
|
|
360
|
+
_this = _call_super(this, WalletNotSelectedError, arguments);
|
|
361
|
+
_this.name = "WalletNotSelectedError";
|
|
362
|
+
return _this;
|
|
363
|
+
}
|
|
364
|
+
return WalletNotSelectedError;
|
|
365
|
+
}(WalletError);
|
|
366
|
+
var WalletNotReadyError = /*#__PURE__*/ function(WalletError) {
|
|
367
|
+
"use strict";
|
|
368
|
+
_inherits(WalletNotReadyError, WalletError);
|
|
369
|
+
function WalletNotReadyError() {
|
|
370
|
+
_class_call_check(this, WalletNotReadyError);
|
|
371
|
+
var _this;
|
|
372
|
+
_this = _call_super(this, WalletNotReadyError, arguments);
|
|
373
|
+
_this.name = "WalletNotReadyError";
|
|
374
|
+
return _this;
|
|
375
|
+
}
|
|
376
|
+
return WalletNotReadyError;
|
|
377
|
+
}(WalletError);
|
|
378
|
+
var WalletConnectionError = /*#__PURE__*/ function(WalletError) {
|
|
379
|
+
"use strict";
|
|
380
|
+
_inherits(WalletConnectionError, WalletError);
|
|
381
|
+
function WalletConnectionError() {
|
|
382
|
+
_class_call_check(this, WalletConnectionError);
|
|
383
|
+
var _this;
|
|
384
|
+
_this = _call_super(this, WalletConnectionError, arguments);
|
|
385
|
+
_this.name = "WalletConnectionError";
|
|
386
|
+
return _this;
|
|
387
|
+
}
|
|
388
|
+
return WalletConnectionError;
|
|
389
|
+
}(WalletError);
|
|
390
|
+
var WalletDisconnectionError = /*#__PURE__*/ function(WalletError) {
|
|
391
|
+
"use strict";
|
|
392
|
+
_inherits(WalletDisconnectionError, WalletError);
|
|
393
|
+
function WalletDisconnectionError() {
|
|
394
|
+
_class_call_check(this, WalletDisconnectionError);
|
|
395
|
+
var _this;
|
|
396
|
+
_this = _call_super(this, WalletDisconnectionError, arguments);
|
|
397
|
+
_this.name = "WalletDisconnectionError";
|
|
398
|
+
return _this;
|
|
399
|
+
}
|
|
400
|
+
return WalletDisconnectionError;
|
|
401
|
+
}(WalletError);
|
|
402
|
+
var WalletAccountError = /*#__PURE__*/ function(WalletError) {
|
|
403
|
+
"use strict";
|
|
404
|
+
_inherits(WalletAccountError, WalletError);
|
|
405
|
+
function WalletAccountError() {
|
|
406
|
+
_class_call_check(this, WalletAccountError);
|
|
407
|
+
var _this;
|
|
408
|
+
_this = _call_super(this, WalletAccountError, arguments);
|
|
409
|
+
_this.name = "WalletAccountError";
|
|
410
|
+
return _this;
|
|
411
|
+
}
|
|
412
|
+
return WalletAccountError;
|
|
413
|
+
}(WalletError);
|
|
414
|
+
var WalletGetNetworkError = /*#__PURE__*/ function(WalletError) {
|
|
415
|
+
"use strict";
|
|
416
|
+
_inherits(WalletGetNetworkError, WalletError);
|
|
417
|
+
function WalletGetNetworkError() {
|
|
418
|
+
_class_call_check(this, WalletGetNetworkError);
|
|
419
|
+
var _this;
|
|
420
|
+
_this = _call_super(this, WalletGetNetworkError, arguments);
|
|
421
|
+
_this.name = "WalletGetNetworkError";
|
|
422
|
+
return _this;
|
|
423
|
+
}
|
|
424
|
+
return WalletGetNetworkError;
|
|
425
|
+
}(WalletError);
|
|
426
|
+
var WalletAccountChangeError = /*#__PURE__*/ function(WalletError) {
|
|
427
|
+
"use strict";
|
|
428
|
+
_inherits(WalletAccountChangeError, WalletError);
|
|
429
|
+
function WalletAccountChangeError() {
|
|
430
|
+
_class_call_check(this, WalletAccountChangeError);
|
|
431
|
+
var _this;
|
|
432
|
+
_this = _call_super(this, WalletAccountChangeError, arguments);
|
|
433
|
+
_this.name = "WalletAccountChangeError";
|
|
434
|
+
return _this;
|
|
435
|
+
}
|
|
436
|
+
return WalletAccountChangeError;
|
|
437
|
+
}(WalletError);
|
|
438
|
+
var WalletNetworkChangeError = /*#__PURE__*/ function(WalletError) {
|
|
439
|
+
"use strict";
|
|
440
|
+
_inherits(WalletNetworkChangeError, WalletError);
|
|
441
|
+
function WalletNetworkChangeError() {
|
|
442
|
+
_class_call_check(this, WalletNetworkChangeError);
|
|
443
|
+
var _this;
|
|
444
|
+
_this = _call_super(this, WalletNetworkChangeError, arguments);
|
|
445
|
+
_this.name = "WalletNetworkChangeError";
|
|
446
|
+
return _this;
|
|
447
|
+
}
|
|
448
|
+
return WalletNetworkChangeError;
|
|
449
|
+
}(WalletError);
|
|
450
|
+
var WalletNotConnectedError = /*#__PURE__*/ function(WalletError) {
|
|
451
|
+
"use strict";
|
|
452
|
+
_inherits(WalletNotConnectedError, WalletError);
|
|
453
|
+
function WalletNotConnectedError() {
|
|
454
|
+
_class_call_check(this, WalletNotConnectedError);
|
|
455
|
+
var _this;
|
|
456
|
+
_this = _call_super(this, WalletNotConnectedError, arguments);
|
|
457
|
+
_this.name = "WalletNotConnectedError";
|
|
458
|
+
return _this;
|
|
459
|
+
}
|
|
460
|
+
return WalletNotConnectedError;
|
|
461
|
+
}(WalletError);
|
|
462
|
+
var WalletSignMessageError = /*#__PURE__*/ function(WalletError) {
|
|
463
|
+
"use strict";
|
|
464
|
+
_inherits(WalletSignMessageError, WalletError);
|
|
465
|
+
function WalletSignMessageError() {
|
|
466
|
+
_class_call_check(this, WalletSignMessageError);
|
|
467
|
+
var _this;
|
|
468
|
+
_this = _call_super(this, WalletSignMessageError, arguments);
|
|
469
|
+
_this.name = "WalletSignMessageError";
|
|
470
|
+
return _this;
|
|
471
|
+
}
|
|
472
|
+
return WalletSignMessageError;
|
|
473
|
+
}(WalletError);
|
|
474
|
+
var WalletSignMessageAndVerifyError = /*#__PURE__*/ function(WalletError) {
|
|
475
|
+
"use strict";
|
|
476
|
+
_inherits(WalletSignMessageAndVerifyError, WalletError);
|
|
477
|
+
function WalletSignMessageAndVerifyError() {
|
|
478
|
+
_class_call_check(this, WalletSignMessageAndVerifyError);
|
|
479
|
+
var _this;
|
|
480
|
+
_this = _call_super(this, WalletSignMessageAndVerifyError, arguments);
|
|
481
|
+
_this.name = "WalletSignMessageAndVerifyError";
|
|
482
|
+
return _this;
|
|
483
|
+
}
|
|
484
|
+
return WalletSignMessageAndVerifyError;
|
|
485
|
+
}(WalletError);
|
|
486
|
+
var WalletSignAndSubmitMessageError = /*#__PURE__*/ function(WalletError) {
|
|
487
|
+
"use strict";
|
|
488
|
+
_inherits(WalletSignAndSubmitMessageError, WalletError);
|
|
489
|
+
function WalletSignAndSubmitMessageError() {
|
|
490
|
+
_class_call_check(this, WalletSignAndSubmitMessageError);
|
|
491
|
+
var _this;
|
|
492
|
+
_this = _call_super(this, WalletSignAndSubmitMessageError, arguments);
|
|
493
|
+
_this.name = "WalletSignAndSubmitMessageError";
|
|
494
|
+
return _this;
|
|
495
|
+
}
|
|
496
|
+
return WalletSignAndSubmitMessageError;
|
|
497
|
+
}(WalletError);
|
|
498
|
+
var WalletSignTransactionError = /*#__PURE__*/ function(WalletError) {
|
|
499
|
+
"use strict";
|
|
500
|
+
_inherits(WalletSignTransactionError, WalletError);
|
|
501
|
+
function WalletSignTransactionError() {
|
|
502
|
+
_class_call_check(this, WalletSignTransactionError);
|
|
503
|
+
var _this;
|
|
504
|
+
_this = _call_super(this, WalletSignTransactionError, arguments);
|
|
505
|
+
_this.name = "WalletSignTransactionError";
|
|
506
|
+
return _this;
|
|
507
|
+
}
|
|
508
|
+
return WalletSignTransactionError;
|
|
509
|
+
}(WalletError);
|
|
510
|
+
var WalletNotSupportedMethod = /*#__PURE__*/ function(WalletError) {
|
|
511
|
+
"use strict";
|
|
512
|
+
_inherits(WalletNotSupportedMethod, WalletError);
|
|
513
|
+
function WalletNotSupportedMethod() {
|
|
514
|
+
_class_call_check(this, WalletNotSupportedMethod);
|
|
515
|
+
var _this;
|
|
516
|
+
_this = _call_super(this, WalletNotSupportedMethod, arguments);
|
|
517
|
+
_this.name = "WalletNotSupportedMethod";
|
|
518
|
+
return _this;
|
|
519
|
+
}
|
|
520
|
+
return WalletNotSupportedMethod;
|
|
521
|
+
}(WalletError);
|
|
522
|
+
var WalletChangeNetworkError = /*#__PURE__*/ function(WalletError) {
|
|
523
|
+
"use strict";
|
|
524
|
+
_inherits(WalletChangeNetworkError, WalletError);
|
|
525
|
+
function WalletChangeNetworkError() {
|
|
526
|
+
_class_call_check(this, WalletChangeNetworkError);
|
|
527
|
+
var _this;
|
|
528
|
+
_this = _call_super(this, WalletChangeNetworkError, arguments);
|
|
529
|
+
_this.name = "WalletChangeNetworkError";
|
|
530
|
+
return _this;
|
|
531
|
+
}
|
|
532
|
+
return WalletChangeNetworkError;
|
|
533
|
+
}(WalletError);
|
|
534
|
+
var WalletSubmitTransactionError = /*#__PURE__*/ function(WalletError) {
|
|
535
|
+
"use strict";
|
|
536
|
+
_inherits(WalletSubmitTransactionError, WalletError);
|
|
537
|
+
function WalletSubmitTransactionError() {
|
|
538
|
+
_class_call_check(this, WalletSubmitTransactionError);
|
|
539
|
+
var _this;
|
|
540
|
+
_this = _call_super(this, WalletSubmitTransactionError, arguments);
|
|
541
|
+
_this.name = "WalletSubmitTransactionError";
|
|
542
|
+
return _this;
|
|
543
|
+
}
|
|
544
|
+
return WalletSubmitTransactionError;
|
|
545
|
+
}(WalletError);
|
|
546
|
+
var WalletNotFoundError = /*#__PURE__*/ function(WalletError) {
|
|
547
|
+
"use strict";
|
|
548
|
+
_inherits(WalletNotFoundError, WalletError);
|
|
549
|
+
function WalletNotFoundError() {
|
|
550
|
+
_class_call_check(this, WalletNotFoundError);
|
|
551
|
+
var _this;
|
|
552
|
+
_this = _call_super(this, WalletNotFoundError, arguments);
|
|
553
|
+
_this.name = "WalletNotFoundError";
|
|
554
|
+
return _this;
|
|
555
|
+
}
|
|
556
|
+
return WalletNotFoundError;
|
|
557
|
+
}(WalletError);
|
|
160
558
|
// src/constants.ts
|
|
161
|
-
var WalletReadyState = /* @__PURE__ */ (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
var NetworkName = /* @__PURE__ */ (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
559
|
+
var WalletReadyState = /* @__PURE__ */ function(WalletReadyState2) {
|
|
560
|
+
WalletReadyState2["Installed"] = "Installed";
|
|
561
|
+
WalletReadyState2["NotDetected"] = "NotDetected";
|
|
562
|
+
return WalletReadyState2;
|
|
563
|
+
}(WalletReadyState || {});
|
|
564
|
+
var NetworkName = /* @__PURE__ */ function(NetworkName2) {
|
|
565
|
+
NetworkName2["Mainnet"] = "mainnet";
|
|
566
|
+
NetworkName2["Testnet"] = "testnet";
|
|
567
|
+
NetworkName2["Devnet"] = "devnet";
|
|
568
|
+
return NetworkName2;
|
|
569
|
+
}(NetworkName || {});
|
|
172
570
|
var ChainIdToAnsSupportedNetworkMap = {
|
|
173
|
-
|
|
174
|
-
|
|
571
|
+
"1": "mainnet",
|
|
572
|
+
// mainnet
|
|
573
|
+
"2": "testnet"
|
|
175
574
|
};
|
|
176
575
|
var APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
177
576
|
var APTOS_CONNECT_ACCOUNT_URL = "https://aptosconnect.app/dashboard/main-account";
|
|
178
|
-
|
|
179
577
|
// src/utils/helpers.ts
|
|
180
|
-
import {
|
|
181
|
-
Aptos,
|
|
182
|
-
AptosConfig,
|
|
183
|
-
Hex,
|
|
184
|
-
Network,
|
|
185
|
-
NetworkToNodeAPI
|
|
186
|
-
} from "@aptos-labs/ts-sdk";
|
|
578
|
+
import { Aptos, AptosConfig, Hex, Network, NetworkToNodeAPI } from "@aptos-labs/ts-sdk";
|
|
187
579
|
function isMobile() {
|
|
188
|
-
|
|
189
|
-
navigator.userAgent
|
|
190
|
-
);
|
|
580
|
+
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(navigator.userAgent);
|
|
191
581
|
}
|
|
192
582
|
function isInAppBrowser() {
|
|
193
|
-
|
|
194
|
-
navigator.userAgent
|
|
195
|
-
|
|
196
|
-
const isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(
|
|
197
|
-
navigator.userAgent
|
|
198
|
-
);
|
|
199
|
-
return isIphone || isAndroid;
|
|
583
|
+
var isIphone = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
|
|
584
|
+
var isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(navigator.userAgent);
|
|
585
|
+
return isIphone || isAndroid;
|
|
200
586
|
}
|
|
201
587
|
function isRedirectable() {
|
|
202
|
-
|
|
203
|
-
return
|
|
204
|
-
return isMobile() && !isInAppBrowser();
|
|
588
|
+
if (typeof navigator === "undefined" || !navigator) return false;
|
|
589
|
+
return isMobile() && !isInAppBrowser();
|
|
205
590
|
}
|
|
206
591
|
function generalizedErrorMessage(error) {
|
|
207
|
-
|
|
592
|
+
return (typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && "message" in error ? error.message : error;
|
|
208
593
|
}
|
|
209
|
-
var getAptosConfig = (networkInfo, dappConfig)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
if (isAptosNetwork(networkInfo)) {
|
|
214
|
-
const currentNetwork = convertNetwork(networkInfo);
|
|
215
|
-
if (isAptosLiveNetwork(currentNetwork)) {
|
|
216
|
-
const apiKey = dappConfig == null ? void 0 : dappConfig.aptosApiKeys;
|
|
217
|
-
return new AptosConfig({
|
|
218
|
-
network: currentNetwork,
|
|
219
|
-
clientConfig: { API_KEY: apiKey ? apiKey[currentNetwork] : void 0 }
|
|
220
|
-
});
|
|
594
|
+
var getAptosConfig = function(networkInfo, dappConfig) {
|
|
595
|
+
if (!networkInfo) {
|
|
596
|
+
throw new Error("Undefined network");
|
|
221
597
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
fullnode: networkInfo.url
|
|
237
|
-
});
|
|
598
|
+
if (isAptosNetwork(networkInfo)) {
|
|
599
|
+
var currentNetwork = convertNetwork(networkInfo);
|
|
600
|
+
if (isAptosLiveNetwork(currentNetwork)) {
|
|
601
|
+
var apiKey = dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosApiKeys;
|
|
602
|
+
return new AptosConfig({
|
|
603
|
+
network: currentNetwork,
|
|
604
|
+
clientConfig: {
|
|
605
|
+
API_KEY: apiKey ? apiKey[currentNetwork] : void 0
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
return new AptosConfig({
|
|
610
|
+
network: currentNetwork
|
|
611
|
+
});
|
|
238
612
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
613
|
+
var knownNetworks = {
|
|
614
|
+
okx: "https://wallet.okx.com/fullnode/aptos/discover/rpc"
|
|
615
|
+
};
|
|
616
|
+
if (networkInfo.url) {
|
|
617
|
+
var isKnownNetwork = Object.values(knownNetworks).includes(networkInfo.url);
|
|
618
|
+
if (isKnownNetwork) {
|
|
619
|
+
return new AptosConfig({
|
|
620
|
+
network: Network.CUSTOM,
|
|
621
|
+
fullnode: networkInfo.url
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
throw new Error("Invalid network, network ".concat(networkInfo.name, " not supported with Aptos wallet adapter to prevent user from using an unexpected network."));
|
|
249
626
|
};
|
|
250
|
-
var
|
|
251
|
-
|
|
627
|
+
var isAptosNetwork = function(networkInfo) {
|
|
628
|
+
if (!networkInfo) {
|
|
629
|
+
throw new Error("Undefined network");
|
|
630
|
+
}
|
|
631
|
+
return NetworkToNodeAPI[networkInfo.name] !== void 0;
|
|
252
632
|
};
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
return await aptos.getChainId();
|
|
633
|
+
var isAptosLiveNetwork = function(networkInfo) {
|
|
634
|
+
return networkInfo === "devnet" || networkInfo === "testnet" || networkInfo === "mainnet";
|
|
256
635
|
};
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
636
|
+
var fetchDevnetChainId = /*#__PURE__*/ function() {
|
|
637
|
+
var _ref = _async_to_generator(function() {
|
|
638
|
+
var aptos;
|
|
639
|
+
return _ts_generator(this, function(_state) {
|
|
640
|
+
switch(_state.label){
|
|
641
|
+
case 0:
|
|
642
|
+
aptos = new Aptos();
|
|
643
|
+
return [
|
|
644
|
+
4,
|
|
645
|
+
aptos.getChainId()
|
|
646
|
+
];
|
|
647
|
+
case 1:
|
|
648
|
+
return [
|
|
649
|
+
2,
|
|
650
|
+
_state.sent()
|
|
651
|
+
];
|
|
652
|
+
}
|
|
653
|
+
});
|
|
269
654
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
655
|
+
return function fetchDevnetChainId() {
|
|
656
|
+
return _ref.apply(this, arguments);
|
|
657
|
+
};
|
|
658
|
+
}();
|
|
659
|
+
var handlePublishPackageTransaction = function(transactionInput) {
|
|
660
|
+
var metadataBytes = transactionInput.data.functionArguments[0];
|
|
661
|
+
if (typeof metadataBytes === "string") {
|
|
662
|
+
metadataBytes = Hex.fromHexInput(metadataBytes).toUint8Array();
|
|
663
|
+
}
|
|
664
|
+
var byteCode = transactionInput.data.functionArguments[1];
|
|
665
|
+
if (Array.isArray(byteCode)) {
|
|
666
|
+
byteCode = byteCode.map(function(byte) {
|
|
667
|
+
if (typeof byte === "string") {
|
|
668
|
+
return Hex.fromHexInput(byte).toUint8Array();
|
|
669
|
+
}
|
|
670
|
+
return byte;
|
|
671
|
+
});
|
|
672
|
+
} else {
|
|
673
|
+
throw new WalletSignAndSubmitMessageError("The bytecode argument must be an array.").message;
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
metadataBytes: metadataBytes,
|
|
677
|
+
byteCode: byteCode
|
|
678
|
+
};
|
|
276
679
|
};
|
|
277
680
|
function convertNetwork(networkInfo) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
681
|
+
switch(networkInfo === null || networkInfo === void 0 ? void 0 : networkInfo.name){
|
|
682
|
+
case "mainnet":
|
|
683
|
+
return Network.MAINNET;
|
|
684
|
+
case "testnet":
|
|
685
|
+
return Network.TESTNET;
|
|
686
|
+
case "devnet":
|
|
687
|
+
return Network.DEVNET;
|
|
688
|
+
case "local":
|
|
689
|
+
return Network.LOCAL;
|
|
690
|
+
default:
|
|
691
|
+
throw new Error("Invalid Aptos network name");
|
|
692
|
+
}
|
|
290
693
|
}
|
|
291
|
-
|
|
292
694
|
// src/utils/localStorage.ts
|
|
293
695
|
var LOCAL_STORAGE_ITEM_KEY = "AptosWalletName";
|
|
294
696
|
function setLocalStorage(walletName) {
|
|
295
|
-
|
|
697
|
+
localStorage.setItem(LOCAL_STORAGE_ITEM_KEY, walletName);
|
|
296
698
|
}
|
|
297
699
|
function removeLocalStorage() {
|
|
298
|
-
|
|
700
|
+
localStorage.removeItem(LOCAL_STORAGE_ITEM_KEY);
|
|
299
701
|
}
|
|
300
702
|
function getLocalStorage() {
|
|
301
|
-
|
|
703
|
+
localStorage.getItem(LOCAL_STORAGE_ITEM_KEY);
|
|
302
704
|
}
|
|
303
|
-
|
|
304
705
|
// src/utils/walletSelector.ts
|
|
305
|
-
function partitionWallets(wallets
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
706
|
+
function partitionWallets(wallets) {
|
|
707
|
+
var partitionFunction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : isInstalledOrLoadable;
|
|
708
|
+
var defaultWallets = [];
|
|
709
|
+
var moreWallets = [];
|
|
710
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
711
|
+
try {
|
|
712
|
+
for(var _iterator = wallets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
713
|
+
var wallet = _step.value;
|
|
714
|
+
if (partitionFunction(wallet)) defaultWallets.push(wallet);
|
|
715
|
+
else moreWallets.push(wallet);
|
|
716
|
+
}
|
|
717
|
+
} catch (err) {
|
|
718
|
+
_didIteratorError = true;
|
|
719
|
+
_iteratorError = err;
|
|
720
|
+
} finally{
|
|
721
|
+
try {
|
|
722
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
723
|
+
_iterator.return();
|
|
724
|
+
}
|
|
725
|
+
} finally{
|
|
726
|
+
if (_didIteratorError) {
|
|
727
|
+
throw _iteratorError;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return {
|
|
732
|
+
defaultWallets: defaultWallets,
|
|
733
|
+
moreWallets: moreWallets
|
|
734
|
+
};
|
|
315
735
|
}
|
|
316
736
|
function isInstalledOrLoadable(wallet) {
|
|
317
|
-
|
|
737
|
+
return wallet.readyState === "Installed" /* Installed */ ;
|
|
318
738
|
}
|
|
319
739
|
function isInstallRequired(wallet) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
740
|
+
var isWalletReady = isInstalledOrLoadable(wallet);
|
|
741
|
+
var isMobile2 = !isWalletReady && isRedirectable();
|
|
742
|
+
return !isMobile2 && !isWalletReady;
|
|
323
743
|
}
|
|
324
744
|
function truncateAddress(address) {
|
|
325
|
-
|
|
326
|
-
return;
|
|
327
|
-
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
745
|
+
if (!address) return;
|
|
746
|
+
return "".concat(address.slice(0, 6), "...").concat(address.slice(-5));
|
|
328
747
|
}
|
|
329
748
|
function isAptosConnectWallet(wallet) {
|
|
330
|
-
|
|
331
|
-
return
|
|
332
|
-
return wallet.url.startsWith(APTOS_CONNECT_BASE_URL);
|
|
749
|
+
if (!wallet.url) return false;
|
|
750
|
+
return wallet.url.startsWith(APTOS_CONNECT_BASE_URL);
|
|
333
751
|
}
|
|
334
752
|
function getAptosConnectWallets(wallets) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
753
|
+
var _partitionWallets = partitionWallets(wallets, isAptosConnectWallet), defaultWallets = _partitionWallets.defaultWallets, moreWallets = _partitionWallets.moreWallets;
|
|
754
|
+
return {
|
|
755
|
+
aptosConnectWallets: defaultWallets,
|
|
756
|
+
otherWallets: moreWallets
|
|
757
|
+
};
|
|
340
758
|
}
|
|
341
759
|
function groupAndSortWallets(wallets, options) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
760
|
+
var _getAptosConnectWallets = getAptosConnectWallets(wallets), aptosConnectWallets = _getAptosConnectWallets.aptosConnectWallets, otherWallets = _getAptosConnectWallets.otherWallets;
|
|
761
|
+
var _partitionWallets = partitionWallets(otherWallets), defaultWallets = _partitionWallets.defaultWallets, moreWallets = _partitionWallets.moreWallets;
|
|
762
|
+
if (options === null || options === void 0 ? void 0 : options.sortAptosConnectWallets) {
|
|
763
|
+
aptosConnectWallets.sort(options.sortAptosConnectWallets);
|
|
764
|
+
}
|
|
765
|
+
if (options === null || options === void 0 ? void 0 : options.sortAvailableWallets) {
|
|
766
|
+
defaultWallets.sort(options.sortAvailableWallets);
|
|
767
|
+
}
|
|
768
|
+
if (options === null || options === void 0 ? void 0 : options.sortInstallableWallets) {
|
|
769
|
+
moreWallets.sort(options.sortInstallableWallets);
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
/** Wallets that use social login to create an account on the blockchain */ aptosConnectWallets: aptosConnectWallets,
|
|
773
|
+
/** Wallets that are currently installed or loadable. */ availableWallets: defaultWallets,
|
|
774
|
+
/** Wallets that are NOT currently installed or loadable. */ installableWallets: moreWallets
|
|
775
|
+
};
|
|
358
776
|
}
|
|
359
|
-
|
|
360
777
|
// src/registry.ts
|
|
361
778
|
var aptosStandardSupportedWalletList = [
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
779
|
+
{
|
|
780
|
+
name: "Nightly",
|
|
781
|
+
url: "https://nightly.app/",
|
|
782
|
+
icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyOC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iV2Fyc3R3YV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDg1MS41IDg1MS41IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA4NTEuNSA4NTEuNTsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCgkuc3Qwe2ZpbGw6IzYwNjdGOTt9DQoJLnN0MXtmaWxsOiNGN0Y3Rjc7fQ0KPC9zdHlsZT4NCjxnPg0KCTxnIGlkPSJXYXJzdHdhXzJfMDAwMDAwMTQ2MDk2NTQyNTMxODA5NDY0NjAwMDAwMDg2NDc4NTIwMDIxMTY5MTg2ODhfIj4NCgkJPHBhdGggY2xhc3M9InN0MCIgZD0iTTEyNCwwaDYwMy42YzY4LjUsMCwxMjQsNTUuNSwxMjQsMTI0djYwMy42YzAsNjguNS01NS41LDEyNC0xMjQsMTI0SDEyNGMtNjguNSwwLTEyNC01NS41LTEyNC0xMjRWMTI0DQoJCQlDMCw1NS41LDU1LjUsMCwxMjQsMHoiLz4NCgk8L2c+DQoJPGcgaWQ9IldhcnN0d2FfMyI+DQoJCTxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik02MjMuNSwxNzAuM2MtMzcuNCw1Mi4yLTg0LjIsODguNC0xMzkuNSwxMTIuNmMtMTkuMi01LjMtMzguOS04LTU4LjMtNy44Yy0xOS40LTAuMi0zOS4xLDIuNi01OC4zLDcuOA0KCQkJYy01NS4zLTI0LjMtMTAyLjEtNjAuMy0xMzkuNS0xMTIuNmMtMTEuMywyOC40LTU0LjgsMTI2LjQtMi42LDI2My40YzAsMC0xNi43LDcxLjUsMTQsMTMyLjljMCwwLDQ0LjQtMjAuMSw3OS43LDguMg0KCQkJYzM2LjksMjkuOSwyNS4xLDU4LjcsNTEuMSw4My41YzIyLjQsMjIuOSw1NS43LDIyLjksNTUuNywyMi45czMzLjMsMCw1NS43LTIyLjhjMjYtMjQuNywxNC4zLTUzLjUsNTEuMS04My41DQoJCQljMzUuMi0yOC4zLDc5LjctOC4yLDc5LjctOC4yYzMwLjYtNjEuNCwxNC0xMzIuOSwxNC0xMzIuOUM2NzguMywyOTYuNyw2MzQuOSwxOTguNyw2MjMuNSwxNzAuM3ogTTI1My4xLDQxNC44DQoJCQljLTI4LjQtNTguMy0zNi4yLTEzOC4zLTE4LjMtMjAxLjVjMjMuNyw2MCw1NS45LDg2LjksOTQuMiwxMTUuM0MzMTIuOCwzNjIuMywyODIuMywzOTQuMSwyNTMuMSw0MTQuOHogTTMzNC44LDUxNy41DQoJCQljLTIyLjQtOS45LTI3LjEtMjkuNC0yNy4xLTI5LjRjMzAuNS0xOS4yLDc1LjQtNC41LDc2LjgsNDAuOUMzNjAuOSw1MTQuNywzNTMsNTI1LjQsMzM0LjgsNTE3LjV6IE00MjUuNyw2NzguNw0KCQkJYy0xNiwwLTI5LTExLjUtMjktMjUuNnMxMy0yNS42LDI5LTI1LjZzMjksMTEuNSwyOSwyNS42QzQ1NC43LDY2Ny4zLDQ0MS43LDY3OC43LDQyNS43LDY3OC43eiBNNTE2LjcsNTE3LjUNCgkJCWMtMTguMiw4LTI2LTIuOC00OS43LDExLjVjMS41LTQ1LjQsNDYuMi02MC4xLDc2LjgtNDAuOUM1NDMuOCw0ODgsNTM5LDUwNy42LDUxNi43LDUxNy41eiBNNTk4LjMsNDE0LjgNCgkJCWMtMjkuMS0yMC43LTU5LjctNTIuNC03Ni04Ni4yYzM4LjMtMjguNCw3MC42LTU1LjQsOTQuMi0xMTUuM0M2MzQuNiwyNzYuNSw2MjYuOCwzNTYuNiw1OTguMyw0MTQuOHoiLz4NCgk8L2c+DQo8L2c+DQo8L3N2Zz4NCg==",
|
|
783
|
+
readyState: "NotDetected" /* NotDetected */ ,
|
|
784
|
+
isAIP62Standard: true,
|
|
785
|
+
deeplinkProvider: "nightly://v1?network=aptos&url="
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: "Petra",
|
|
789
|
+
url: "https://chromewebstore.google.com/detail/petra-aptos-wallet/ejjladinnckdgjemekebdpeokbikhfci?hl=en",
|
|
790
|
+
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWbSURBVHgB7Z09c9NYFIaPlFSpUqQNK6rQhbSkWJghLZP9BesxfwAqytg1xe7+AY+3go5ACzObBkpwSqrVQkuRCiqkva8UZW1je22wpHPveZ8ZRU6wwwznueee+6FLJCuSdzrb7nZTNjaOJc9/ctdNiaJESPPkeeq+phLH5/L162k0HJ7JikTLvtEFPnFBf+D+0l/dt9tCNJK6xnjmZOg7GdJlPvC/AhQtPo5P3MsHQvwhiobLiLBQABf82y74z4Qt3ldSybKHToLTeW+I5/1B3u2euOD/JQy+zyRowEUs5zAzA1x+oCckJHrRYNCf/uE3AjD4QfONBBMC5PfvY2j3TEi4ZNmd8eHilQDFMK/s8xMhIXPhJLjuJLjAN/8VgRsbPWHwLbAtm5tXRWGRAS5b/99C7FBmgbTMAGXrJ5aIomJir8wA3S5afyLEEkUtEBezfQy+RYpFvdilgmMhNnGxRw2wL8QqScy1fMNE0T4yQCLEKkksxDQUwDj2BNjbK69pdndn/zxwNsUCCOyNGyJ374psbYkMBiLv30++59o1kW5X5NMnkdFI5OXL8nXghCsAAn10NL/Fz2NnpxQFFyR5/bq8BypDWAIg6AcHIoeH60nn4/K8e1deECIgwhAAQULQEXxIUAf43bju3ZvMDJ7jrwDT/XpToIvABeECqBf8EuB7+/W6CKBe0C/Auvv1uvC0XtArQBP9el14VC/oEqCtfr0uPKgX2hdAW79eF0rrhfYFQPCRKi1RyY4ZyZYF4GKQcSiAcSiAcSiAcSiAcSiAcSiAcSiAcSiAcSiAcSiAcSiAcSiAcShAm3z+LG1DAdqEAhjn40dpGwrQFtgIwgxgGAWtH1CAtsC2cQVQgLZQsk2cArSBoqeHKEAbKHpiiAI0DVq+kv4fUICmQetXMPyroABNgtb/5o1oggI0icJzBChAUyDwr16JNihAUzx+LBqhAE3w5InaU0MoQN08f64y9VdQgDrBkO/FC9EMBagLBB/P/yvHxlGxTYPh3tOn4gMUYN2g4FPc509DAdYFqvxZh1ArhwKsg6rSVzTHvywU4EeoqnyPTxKnAKuCVo4iD4s6ARwhTwGWoTrk8e3bIE4IH4cCVCDI1U6dL1/K73Eh4B727ctCASoQ6MBa9zJwJtA4FMA4FMA4FMA4FMA4FMA4FMA4FMA47Qtg4P/n1Uz7AgQ8zeoD7Qug5KQMq+joApgFWkNHEWhwEUYLFMA4OgRQdGCCNXQIUG28II2jZyKIWaAV9Aig7OgUK+gRAMH36ImaUNC1FoDt1swCjaJLAAQfT9mQxtC3GohugCOCxtC5HIyHLNkVNIJOATAv4Mnz9b6jd0MIhoWsB2pH944gPHmLkQGpDf1bwtAVUILa8GNPICRgd1AL/mwKRXfA0cHa8WtXMArDfp8bSdeIf9vCEfxHj8psQBF+GH/PB0A2wIzhrVsih4ciOztCVsfvAyKQAVAbYPr44EDk6Ehkd1fI8oRxQggKQ2QEXMgEe3ulELhvbQmZT3hHxFRn+1Tn/UAAZAWIUXUTHz4IKQn/jCBkB6Pn/ywDHw41DgUwDgRIhVgljSWKzoXYJM+dAFmWCrHKeewsOBViExd71AAjd10IsUYaDYdnsfty4Uz4U4g1zvClHAbm+e9CbJFlfdwKAVwWSJ0EfwixwrCIuYxPBOV5T1gLWCCtWj+4EqCoBbLsFyFhk2UPq9YPJqaCURW6W19IqPRdjCeG/dGsd+Xdbs/dToSERD8aDHrTP4zmvZsSBMXM4INo0afyTudY4vg39zIR4iNFXXfZtc9k4XJw0V9k2R1OFHkIhvVZdn1R8MHCDDDx+zqdxK0c9tz1szAjaKWc1XUTe+OV/iKWFmAcJ8NtJ8Kxe7kvkCGKEiHN45Zz3b/9yN3/uVzUGxXD+RX4F56985hsqA6SAAAAAElFTkSuQmCC",
|
|
791
|
+
readyState: "NotDetected" /* NotDetected */ ,
|
|
792
|
+
isAIP62Standard: true,
|
|
793
|
+
deeplinkProvider: "https://petra.app/explore?link="
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
name: "Pontem Wallet",
|
|
797
|
+
url: "https://pontem.network/pontem-wallet",
|
|
798
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE4IDBDOC4wNzMwNCAwIDAgOC4wNzEzOSAwIDE3Ljk5NjNDMCAyNS4xMjk4IDQuMTczMTYgMzEuMzEwOCAxMC4yMDc2IDM0LjIyMDNWMzQuMjM1MUgxMC4yMzcyQzEyLjU4NiAzNS4zNjQ5IDE1LjIyMjggMzYgMTggMzZDMjcuOTI3IDM2IDM2IDI3LjkyODYgMzYgMTguMDAzN0MzNiA4LjA3MTM4IDI3LjkyNyAwIDE4IDBaTTE4IDEuNDc2OTJDMjcuMTA3MSAxLjQ3NjkyIDM0LjUyMjggOC44OTEwOCAzNC41MjI4IDE3Ljk5NjNDMzQuNTIyOCAyMC42MTA1IDMzLjkwOTcgMjMuMDkxNyAzMi44MjQgMjUuMjkyM0MzMC40NDU2IDI0LjE0MDMgMjguMDMwNCAyMy4yODM3IDI1LjU5MjkgMjIuNzAwM1Y4LjkyMDYyQzI1LjU5MjkgOC40NDA2MiAyNS4yMTYyIDguMDU2NjIgMjQuNzQzNSA4LjA1NjYySDIxLjcxNTJIMTQuMDg1NEgxMS4wNTdDMTAuNTkxNyA4LjA1NjYyIDEwLjIwNzYgOC40NDA2MiAxMC4yMDc2IDguOTIwNjJWMjIuNzY2OEM3Ljg0NDA3IDIzLjM1MDIgNS40OTUyOCAyNC4xOTIgMy4xODM0MiAyNS4yOTk3QzIuMDkwMjcgMjMuMDkxNyAxLjQ3NzIzIDIwLjYxNzggMS40NzcyMyAxNy45OTYzQzEuNDc3MjMgOC44OTEwOCA4Ljg5MjkgMS40NzY5MiAxOCAxLjQ3NjkyWk00LjEzNjIzIDI2Ljk2MTJDNi4wOTM1NiAyNS45OTM4IDguMTI0NzQgMjUuMjQ4IDEwLjIxNSAyNC43MzExVjMyLjU1ODhDNy43NDA2NiAzMS4yMzY5IDUuNjUwMzkgMjkuMzAyMiA0LjEzNjIzIDI2Ljk2MTJaTTE0LjA4NTQgMzQuMDQzMVYxNS42MDM3QzE0LjA4NTQgMTMuNDY5NSAxNS44MzU5IDExLjcwNDYgMTcuOTI2MSAxMS43MDQ2QzIwLjAxNjQgMTEuNzA0NiAyMS43MTUyIDEzLjQzMjYgMjEuNzE1MiAxNS41NTk0QzIxLjcxNTIgMTUuNTc0MiAyMS43MDc4IDE1LjU4ODkgMjEuNzA3OCAxNS42MDM3SDIxLjcxNTJWMjIuMDIwOUMxOS45MzUyIDIxLjgxNDIgMTguMTQ3NyAyMS43NDc3IDE2LjM2MDMgMjEuODQzN0wxNC44OTA0IDIzLjk3NzhDMTcuMTgwMSAyMy43ODU4IDE5LjQxMDcgMjMuODAwNiAyMS42MTE4IDI0LjA1MTdDMjEuNjM0IDI0LjA1MTcgMjEuNjQ4NyAyNC4wNTE3IDIxLjY3MDkgMjQuMDU5MUMyMS42ODU3IDI0LjA1OTEgMjEuNzAwNSAyNC4wNTkxIDIxLjcyMjYgMjQuMDY2NUMyMi4xMDY3IDI0LjExMDggMjMuNTAyNyAyNC4yODggMjQuNzgwNSAyNC42MDU1TDIxLjcyMjYgMjUuNjQ2OFYzNC4xMDIyQzIwLjUyNjEgMzQuMzc1NCAxOS4yODUyIDM0LjUzMDUgMTguMDE0OCAzNC41MzA1QzE2LjY0ODMgMzQuNTE1NyAxNS4zNDEgMzQuMzQ1OCAxNC4wODU0IDM0LjA0MzFaTTI1LjU4NTYgMzIuNjYyMlYyNC43NjhDMjcuNjY4NCAyNS4yOTIzIDI5LjcyOTIgMjYuMDYwMyAzMS43OTczIDI3LjA2NDZDMzAuMjQ2MiAyOS40MjAzIDI4LjEwNDIgMzEuMzU1MSAyNS41ODU2IDMyLjY2MjJaIiBmaWxsPSJ1cmwoI3BhaW50MF9saW5lYXJfMjIyXzE2NzApIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMjIyXzE2NzAiIHgxPSIxNy45OTk3IiB5MT0iMzYuNzc4OSIgeDI9IjE3Ljk5OTciIHkyPSItNS41MTk3OCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBvZmZzZXQ9IjAuMDg1OCIgc3RvcC1jb2xvcj0iIzhEMjlDMSIvPgo8c3RvcCBvZmZzZXQ9IjAuMjM4MyIgc3RvcC1jb2xvcj0iIzk0MkJCQiIvPgo8c3RvcCBvZmZzZXQ9IjAuNDY2NyIgc3RvcC1jb2xvcj0iI0E5MkZBQyIvPgo8c3RvcCBvZmZzZXQ9IjAuNzQxMyIgc3RvcC1jb2xvcj0iI0NBMzc5MyIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGMDNGNzciLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K",
|
|
799
|
+
readyState: "NotDetected" /* NotDetected */ ,
|
|
800
|
+
isAIP62Standard: true
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
name: "Rimosafe",
|
|
804
|
+
url: "https://chromewebstore.google.com/detail/rimo-safe-wallet/kiicddjcakdmobjkcpppkgcjbpakcagp",
|
|
805
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIGZpbGw9Im5vbmUiLz4KICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgzLCAzKSBzY2FsZSgwLjgpIj4KICAgIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMjkuNTMxMSA5Ljg0MzY5VjBIMTkuNjg3NEwxOS42ODc3IDAuMDAwMzQwNTU1TDAgMC4wMDAzNDE0MTVMNC4zMjEzNGUtMDcgOS44NDQwM0g5Ljg0MzY5QzQuNDA3MTcgOS44NDQwMyAwIDE0LjI1MTIgMCAxOS42ODc3VjMwLjAwMDFIOS44NDM2OVYxOS42ODc5TDE5LjY4NzEgMzAuMDAwMUwxOS42ODcxIDE5LjY4NzdMMjkuNTMwOCA5Ljg0NDAzTDI5LjUzMTEgOS44NDQwM1Y5Ljg0MzY1TDI5LjUzMTEgOS44NDM2OVpNMTkuNjg3MSAxOS42ODc2TDE5LjY4NzEgOS44NDQwM0g5Ljg0MzY5VjE5LjY4NzZIMTkuNjg3MVpNMjkuNTMxMSA5Ljg0MzY1TDE5LjY4NzcgMC4wMDAzNDA1NTVMMjkuNTMxMSAwLjAwMDM0MDEyNVY5Ljg0MzY1Wk0xOS42ODc0IDE5LjY4NzZIMjkuNTMxMVYzMC4wMDAxSDE5LjY4NzRWMTkuNjg3NloiIGZpbGw9IiNGRjVDMjgiLz4KICA8L2c+Cjwvc3ZnPgo=",
|
|
806
|
+
readyState: "NotDetected" /* NotDetected */ ,
|
|
807
|
+
isAIP62Standard: true
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: "OKX Wallet",
|
|
811
|
+
url: "https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",
|
|
812
|
+
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJDSURBVHgB7Zq9jtpAEMfHlhEgQLiioXEkoAGECwoKxMcTRHmC5E3IoyRPkPAEkI7unJYmTgEFTYwA8a3NTKScLnCHN6c9r1e3P2llWQy7M/s1Gv1twCP0ej37dDq9x+Zut1t3t9vZjDEHIiSRSPg4ZpDL5fxkMvn1cDh8m0wmfugfO53OoFQq/crn8wxfY9EymQyrVCqMfHvScZx1p9ls3pFxXBy/bKlUipGPrVbLuQqAfsCliq3zl0H84zwtjQrOw4Mt1W63P5LvBm2d+Xz+YzqdgkqUy+WgWCy+Mc/nc282m4FqLBYL+3g8fjDxenq72WxANZbLJeA13zDX67UDioL5ybXwafMYu64Ltn3bdDweQ5R97fd7GyhBQMipx4POeEDHIu2LfDdBIGGz+hJ9CQ1ABjoA2egAZPM6AgiCAEQhsi/C4jHyPA/6/f5NG3Ks2+3CYDC4aTccDrn6ojG54MnEvG00GoVmWLIRNZ7wTCwDHYBsdACy0QHIhiuRETxlICWpMMhGZHmqS8qH6JLyGegAZKMDkI0uKf8X4SWlaZo+Pp1bRrwlJU8ZKLIvUjKh0WiQ3sRUbNVq9c5Ebew7KEo2m/1p4jJ4qAmDaqDQBzj5XyiAT4VCQezJigAU+IDU+z8vJFnGWeC+bKQV/5VZ71FV6L7PA3gg3tXrdQ+DgLhC+75Wq3no69P3MC0NFQpx2lL04Ql9gHK1bRDjsSBIvScBnDTk1WrlGIZBorIDEYJj+rhdgnQ67VmWRe0zlplXl81vcyEt0rSoYDUAAAAASUVORK5CYII=",
|
|
813
|
+
readyState: "NotDetected" /* NotDetected */ ,
|
|
814
|
+
isAIP62Standard: true
|
|
815
|
+
}
|
|
399
816
|
];
|
|
400
|
-
|
|
401
817
|
// src/sdkWallets.ts
|
|
402
|
-
import {
|
|
403
|
-
AptosConnectAppleWallet,
|
|
404
|
-
AptosConnectGoogleWallet
|
|
405
|
-
} from "@aptos-connect/wallet-adapter-plugin";
|
|
818
|
+
import { AptosConnectAppleWallet, AptosConnectGoogleWallet } from "@aptos-connect/wallet-adapter-plugin";
|
|
406
819
|
import { Network as Network2 } from "@aptos-labs/ts-sdk";
|
|
407
820
|
import { DevTWallet, TWallet } from "@atomrigslab/aptos-wallet-adapter";
|
|
408
821
|
import { MizuWallet } from "@mizuwallet-sdk/aptos-wallet-adapter";
|
|
822
|
+
import { MSafeWallet } from "@msafe/aptos-aip62-wallet";
|
|
409
823
|
function getSDKWallets(dappConfig) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
appId: dappConfig.mizuwallet.appId
|
|
430
|
-
})
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
if ((dappConfig == null ? void 0 : dappConfig.network) === Network2.MAINNET) {
|
|
435
|
-
sdkWallets.push(new TWallet());
|
|
436
|
-
} else {
|
|
437
|
-
sdkWallets.push(new DevTWallet());
|
|
438
|
-
}
|
|
439
|
-
return sdkWallets;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// src/WalletCore.ts
|
|
443
|
-
var WalletCore = class extends EventEmitter {
|
|
444
|
-
constructor(optInWallets, dappConfig, disableTelemetry) {
|
|
445
|
-
super();
|
|
446
|
-
this._wallet = null;
|
|
447
|
-
this._sdkWallets = [];
|
|
448
|
-
this._standard_wallets = [];
|
|
449
|
-
this._standard_not_detected_wallets = [];
|
|
450
|
-
this._network = null;
|
|
451
|
-
this._connected = false;
|
|
452
|
-
this._connecting = false;
|
|
453
|
-
this._account = null;
|
|
454
|
-
this._optInWallets = [];
|
|
455
|
-
this._disableTelemetry = false;
|
|
456
|
-
this.ga4 = null;
|
|
457
|
-
this._optInWallets = optInWallets || [];
|
|
458
|
-
this._dappConfig = dappConfig;
|
|
459
|
-
this._disableTelemetry = disableTelemetry != null ? disableTelemetry : false;
|
|
460
|
-
this._sdkWallets = getSDKWallets(this._dappConfig);
|
|
461
|
-
if (!this._disableTelemetry) {
|
|
462
|
-
this.ga4 = new GA4();
|
|
463
|
-
}
|
|
464
|
-
this.fetchExtensionAIP62AptosWallets();
|
|
465
|
-
this.fetchSDKAIP62AptosWallets();
|
|
466
|
-
this.appendNotDetectedStandardSupportedWallets();
|
|
467
|
-
}
|
|
468
|
-
fetchExtensionAIP62AptosWallets() {
|
|
469
|
-
let { aptosWallets, on } = getAptosWallets();
|
|
470
|
-
this.setExtensionAIP62Wallets(aptosWallets);
|
|
471
|
-
if (typeof window === "undefined")
|
|
472
|
-
return;
|
|
473
|
-
const that = this;
|
|
474
|
-
const removeRegisterListener = on("register", function() {
|
|
475
|
-
let { aptosWallets: aptosWallets2 } = getAptosWallets();
|
|
476
|
-
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
477
|
-
});
|
|
478
|
-
const removeUnregisterListener = on("unregister", function() {
|
|
479
|
-
let { aptosWallets: aptosWallets2 } = getAptosWallets();
|
|
480
|
-
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
setExtensionAIP62Wallets(extensionwWallets) {
|
|
484
|
-
extensionwWallets.map((wallet) => {
|
|
485
|
-
if (this.excludeWallet(wallet)) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
this._standard_wallets = this._standard_wallets.filter(
|
|
489
|
-
(item) => item.name !== wallet.name
|
|
490
|
-
);
|
|
491
|
-
const isValid = isWalletWithRequiredFeatureSet(wallet);
|
|
492
|
-
if (isValid) {
|
|
493
|
-
const index = this._standard_not_detected_wallets.findIndex(
|
|
494
|
-
(notDetctedWallet) => notDetctedWallet.name == wallet.name
|
|
495
|
-
);
|
|
496
|
-
if (index !== -1) {
|
|
497
|
-
this._standard_not_detected_wallets.splice(index, 1);
|
|
498
|
-
}
|
|
499
|
-
wallet.readyState = "Installed" /* Installed */;
|
|
500
|
-
this._standard_wallets.push(wallet);
|
|
501
|
-
this.emit("standardWalletsAdded", wallet);
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
fetchSDKAIP62AptosWallets() {
|
|
506
|
-
this._sdkWallets.map((wallet) => {
|
|
507
|
-
if (this.excludeWallet(wallet)) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
const isValid = isWalletWithRequiredFeatureSet(wallet);
|
|
511
|
-
if (isValid) {
|
|
512
|
-
wallet.readyState = "Installed" /* Installed */;
|
|
513
|
-
this._standard_wallets.push(wallet);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
appendNotDetectedStandardSupportedWallets() {
|
|
518
|
-
aptosStandardSupportedWalletList.map((supportedWallet) => {
|
|
519
|
-
const existingStandardWallet = this._standard_wallets.find(
|
|
520
|
-
(wallet) => wallet.name == supportedWallet.name
|
|
521
|
-
);
|
|
522
|
-
if (existingStandardWallet) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
if (this.excludeWallet(supportedWallet)) {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
if (!existingStandardWallet) {
|
|
529
|
-
this._standard_not_detected_wallets.push(supportedWallet);
|
|
530
|
-
this.emit("standardNotDetectedWalletAdded", supportedWallet);
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
excludeWallet(wallet) {
|
|
535
|
-
if (this._optInWallets.length > 0 && !this._optInWallets.includes(wallet.name)) {
|
|
536
|
-
return true;
|
|
537
|
-
}
|
|
538
|
-
return false;
|
|
539
|
-
}
|
|
540
|
-
recordEvent(eventName, additionalInfo) {
|
|
541
|
-
var _a, _b, _c, _d;
|
|
542
|
-
(_d = this.ga4) == null ? void 0 : _d.gtag("event", `wallet_adapter_${eventName}`, {
|
|
543
|
-
wallet: (_a = this._wallet) == null ? void 0 : _a.name,
|
|
544
|
-
network: (_b = this._network) == null ? void 0 : _b.name,
|
|
545
|
-
network_url: (_c = this._network) == null ? void 0 : _c.url,
|
|
546
|
-
adapter_core_version: WALLET_ADAPTER_CORE_VERSION,
|
|
547
|
-
send_to: "G-GNVVWBL3J9",
|
|
548
|
-
...additionalInfo
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
ensureWalletExists(wallet) {
|
|
552
|
-
if (!wallet) {
|
|
553
|
-
throw new WalletNotConnectedError().name;
|
|
554
|
-
}
|
|
555
|
-
if (!(wallet.readyState === "Installed" /* Installed */))
|
|
556
|
-
throw new WalletNotReadyError("Wallet is not set").name;
|
|
557
|
-
}
|
|
558
|
-
ensureAccountExists(account) {
|
|
559
|
-
if (!account) {
|
|
560
|
-
throw new WalletAccountError("Account is not set").name;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
async setAnsName() {
|
|
564
|
-
var _a;
|
|
565
|
-
if (((_a = this._network) == null ? void 0 : _a.chainId) && this._account) {
|
|
566
|
-
if (this._account.ansName)
|
|
567
|
-
return;
|
|
568
|
-
if (!ChainIdToAnsSupportedNetworkMap[this._network.chainId] || !isAptosNetwork(this._network)) {
|
|
569
|
-
this._account.ansName = void 0;
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
573
|
-
const aptos = new Aptos2(aptosConfig);
|
|
574
|
-
try {
|
|
575
|
-
const name = await aptos.ans.getPrimaryName({
|
|
576
|
-
address: this._account.address.toString()
|
|
577
|
-
});
|
|
578
|
-
this._account.ansName = name;
|
|
579
|
-
} catch (error) {
|
|
580
|
-
console.log(`Error setting ANS name ${error}`);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
clearData() {
|
|
585
|
-
this._connected = false;
|
|
586
|
-
this.setWallet(null);
|
|
587
|
-
this.setAccount(null);
|
|
588
|
-
this.setNetwork(null);
|
|
589
|
-
removeLocalStorage();
|
|
590
|
-
}
|
|
591
|
-
setWallet(wallet) {
|
|
592
|
-
this._wallet = wallet;
|
|
593
|
-
}
|
|
594
|
-
setAccount(account) {
|
|
595
|
-
this._account = account;
|
|
596
|
-
}
|
|
597
|
-
setNetwork(network) {
|
|
598
|
-
this._network = network;
|
|
599
|
-
}
|
|
600
|
-
isConnected() {
|
|
601
|
-
return this._connected;
|
|
602
|
-
}
|
|
603
|
-
get wallets() {
|
|
604
|
-
return this._standard_wallets;
|
|
605
|
-
}
|
|
606
|
-
get notDetectedWallets() {
|
|
607
|
-
return this._standard_not_detected_wallets;
|
|
608
|
-
}
|
|
609
|
-
get wallet() {
|
|
610
|
-
try {
|
|
611
|
-
if (!this._wallet)
|
|
612
|
-
return null;
|
|
613
|
-
return this._wallet;
|
|
614
|
-
} catch (error) {
|
|
615
|
-
throw new WalletNotSelectedError(error).message;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
get account() {
|
|
619
|
-
try {
|
|
620
|
-
return this._account;
|
|
621
|
-
} catch (error) {
|
|
622
|
-
throw new WalletAccountError(error).message;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
get network() {
|
|
626
|
-
try {
|
|
627
|
-
return this._network;
|
|
628
|
-
} catch (error) {
|
|
629
|
-
throw new WalletGetNetworkError(error).message;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
async connect(walletName) {
|
|
633
|
-
var _a;
|
|
634
|
-
if (isRedirectable()) {
|
|
635
|
-
const selectedWallet2 = this._standard_not_detected_wallets.find(
|
|
636
|
-
(wallet) => wallet.name === walletName
|
|
637
|
-
);
|
|
638
|
-
if (selectedWallet2) {
|
|
639
|
-
const uninstalledWallet = selectedWallet2;
|
|
640
|
-
if (uninstalledWallet.deeplinkProvider) {
|
|
641
|
-
const url = encodeURIComponent(window.location.href);
|
|
642
|
-
const location = uninstalledWallet.deeplinkProvider.concat(url);
|
|
643
|
-
window.location.href = location;
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
const allDetectedWallets = this._standard_wallets;
|
|
649
|
-
const selectedWallet = allDetectedWallets.find(
|
|
650
|
-
(wallet) => wallet.name === walletName
|
|
651
|
-
);
|
|
652
|
-
if (!selectedWallet)
|
|
653
|
-
return;
|
|
654
|
-
if (this._connected && this._account) {
|
|
655
|
-
if (((_a = this._wallet) == null ? void 0 : _a.name) === walletName)
|
|
656
|
-
throw new WalletConnectionError(
|
|
657
|
-
`${walletName} wallet is already connected`
|
|
658
|
-
).message;
|
|
659
|
-
}
|
|
660
|
-
await this.connectWallet(selectedWallet, async () => {
|
|
661
|
-
const response = await selectedWallet.features["aptos:connect"].connect();
|
|
662
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
663
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
664
|
-
}
|
|
665
|
-
return { account: response.args, output: void 0 };
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
async signIn(args) {
|
|
669
|
-
const { input, walletName } = args;
|
|
670
|
-
const allDetectedWallets = this._standard_wallets;
|
|
671
|
-
const selectedWallet = allDetectedWallets.find(
|
|
672
|
-
(wallet) => wallet.name === walletName
|
|
673
|
-
);
|
|
674
|
-
if (!selectedWallet) {
|
|
675
|
-
throw new WalletNotFoundError(`Wallet ${walletName} not found`).message;
|
|
676
|
-
}
|
|
677
|
-
if (!selectedWallet.features["aptos:signIn"]) {
|
|
678
|
-
throw new WalletNotSupportedMethod(
|
|
679
|
-
`aptos:signIn is not supported by ${walletName}`
|
|
680
|
-
).message;
|
|
681
|
-
}
|
|
682
|
-
return await this.connectWallet(selectedWallet, async () => {
|
|
683
|
-
if (!selectedWallet.features["aptos:signIn"]) {
|
|
684
|
-
throw new WalletNotSupportedMethod(
|
|
685
|
-
`aptos:signIn is not supported by ${selectedWallet.name}`
|
|
686
|
-
).message;
|
|
687
|
-
}
|
|
688
|
-
const response = await selectedWallet.features["aptos:signIn"].signIn(input);
|
|
689
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
690
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
691
|
-
}
|
|
692
|
-
return { account: response.args.account, output: response.args };
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
async connectWallet(selectedWallet, onConnect) {
|
|
696
|
-
try {
|
|
697
|
-
this._connecting = true;
|
|
698
|
-
this.setWallet(selectedWallet);
|
|
699
|
-
const { account, output } = await onConnect();
|
|
700
|
-
this.setAccount(account);
|
|
701
|
-
const network = await selectedWallet.features["aptos:network"].network();
|
|
702
|
-
this.setNetwork(network);
|
|
703
|
-
await this.setAnsName();
|
|
704
|
-
setLocalStorage(selectedWallet.name);
|
|
705
|
-
this._connected = true;
|
|
706
|
-
this.recordEvent("wallet_connect");
|
|
707
|
-
this.emit("connect", account);
|
|
708
|
-
return output;
|
|
709
|
-
} catch (error) {
|
|
710
|
-
this.clearData();
|
|
711
|
-
const errMsg = generalizedErrorMessage(error);
|
|
712
|
-
throw new WalletConnectionError(errMsg).message;
|
|
713
|
-
} finally {
|
|
714
|
-
this._connecting = false;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
async disconnect() {
|
|
718
|
-
try {
|
|
719
|
-
this.ensureWalletExists(this._wallet);
|
|
720
|
-
await this._wallet.features["aptos:disconnect"].disconnect();
|
|
721
|
-
this.clearData();
|
|
722
|
-
this.recordEvent("wallet_disconnect");
|
|
723
|
-
this.emit("disconnect");
|
|
724
|
-
} catch (error) {
|
|
725
|
-
const errMsg = generalizedErrorMessage(error);
|
|
726
|
-
throw new WalletDisconnectionError(errMsg).message;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
async signAndSubmitTransaction(transactionInput) {
|
|
730
|
-
var _a, _b;
|
|
731
|
-
try {
|
|
732
|
-
if ("function" in transactionInput.data) {
|
|
733
|
-
if (transactionInput.data.function === "0x1::account::rotate_authentication_key_call") {
|
|
734
|
-
throw new WalletSignAndSubmitMessageError("SCAM SITE DETECTED").message;
|
|
735
|
-
}
|
|
736
|
-
if (transactionInput.data.function === "0x1::code::publish_package_txn") {
|
|
737
|
-
({
|
|
738
|
-
metadataBytes: transactionInput.data.functionArguments[0],
|
|
739
|
-
byteCode: transactionInput.data.functionArguments[1]
|
|
740
|
-
} = handlePublishPackageTransaction(transactionInput));
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
this.ensureWalletExists(this._wallet);
|
|
744
|
-
this.ensureAccountExists(this._account);
|
|
745
|
-
this.recordEvent("sign_and_submit_transaction");
|
|
746
|
-
if (this._wallet.features["aptos:signAndSubmitTransaction"]) {
|
|
747
|
-
if (this._wallet.features["aptos:signAndSubmitTransaction"].version !== "1.1.0") {
|
|
748
|
-
const aptosConfig2 = getAptosConfig(this._network, this._dappConfig);
|
|
749
|
-
const aptos2 = new Aptos2(aptosConfig2);
|
|
750
|
-
const transaction2 = await aptos2.transaction.build.simple({
|
|
751
|
-
sender: this._account.address.toString(),
|
|
752
|
-
data: transactionInput.data,
|
|
753
|
-
options: transactionInput.options
|
|
754
|
-
});
|
|
755
|
-
const signAndSubmitTransactionMethod = this._wallet.features["aptos:signAndSubmitTransaction"].signAndSubmitTransaction;
|
|
756
|
-
const response3 = await signAndSubmitTransactionMethod(
|
|
757
|
-
transaction2
|
|
758
|
-
);
|
|
759
|
-
if (response3.status === UserResponseStatus.REJECTED) {
|
|
760
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
761
|
-
}
|
|
762
|
-
return response3.args;
|
|
824
|
+
var sdkWallets = [];
|
|
825
|
+
if (typeof window !== "undefined") {
|
|
826
|
+
sdkWallets.push(new AptosConnectGoogleWallet(_object_spread({
|
|
827
|
+
network: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network,
|
|
828
|
+
dappId: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnectDappId
|
|
829
|
+
}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnect)), new AptosConnectAppleWallet(_object_spread({
|
|
830
|
+
network: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network,
|
|
831
|
+
dappId: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnectDappId
|
|
832
|
+
}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnect)));
|
|
833
|
+
if ((dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.mizuwallet) && (dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network) && [
|
|
834
|
+
Network2.MAINNET,
|
|
835
|
+
Network2.TESTNET
|
|
836
|
+
].includes(dappConfig.network)) {
|
|
837
|
+
sdkWallets.push(new MizuWallet({
|
|
838
|
+
// mizo supports only TESTNET and MAINNET and holds a custom type for network
|
|
839
|
+
network: dappConfig.network,
|
|
840
|
+
manifestURL: dappConfig.mizuwallet.manifestURL,
|
|
841
|
+
appId: dappConfig.mizuwallet.appId
|
|
842
|
+
}));
|
|
763
843
|
}
|
|
764
|
-
const response2 = await this._wallet.features["aptos:signAndSubmitTransaction"].signAndSubmitTransaction({
|
|
765
|
-
payload: transactionInput.data,
|
|
766
|
-
gasUnitPrice: (_a = transactionInput.options) == null ? void 0 : _a.gasUnitPrice,
|
|
767
|
-
maxGasAmount: (_b = transactionInput.options) == null ? void 0 : _b.maxGasAmount
|
|
768
|
-
});
|
|
769
|
-
if (response2.status === UserResponseStatus.REJECTED) {
|
|
770
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
771
|
-
}
|
|
772
|
-
return response2.args;
|
|
773
|
-
}
|
|
774
|
-
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
775
|
-
const aptos = new Aptos2(aptosConfig);
|
|
776
|
-
const transaction = await aptos.transaction.build.simple({
|
|
777
|
-
sender: this._account.address,
|
|
778
|
-
data: transactionInput.data,
|
|
779
|
-
options: transactionInput.options
|
|
780
|
-
});
|
|
781
|
-
const signTransactionResponse = await this.signTransaction({
|
|
782
|
-
transactionOrPayload: transaction
|
|
783
|
-
});
|
|
784
|
-
const response = await this.submitTransaction({
|
|
785
|
-
transaction,
|
|
786
|
-
senderAuthenticator: signTransactionResponse.authenticator
|
|
787
|
-
});
|
|
788
|
-
return { hash: response.hash };
|
|
789
|
-
} catch (error) {
|
|
790
|
-
const errMsg = generalizedErrorMessage(error);
|
|
791
|
-
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
792
844
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
try {
|
|
798
|
-
this.ensureWalletExists(this._wallet);
|
|
799
|
-
this.ensureAccountExists(this._account);
|
|
800
|
-
this.recordEvent("sign_transaction");
|
|
801
|
-
if ("rawTransaction" in transactionOrPayload) {
|
|
802
|
-
const response = await ((_a = this._wallet) == null ? void 0 : _a.features["aptos:signTransaction"].signTransaction(
|
|
803
|
-
transactionOrPayload,
|
|
804
|
-
asFeePayer
|
|
805
|
-
));
|
|
806
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
807
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
808
|
-
}
|
|
809
|
-
return {
|
|
810
|
-
authenticator: response.args,
|
|
811
|
-
rawTransaction: transactionOrPayload.rawTransaction.bcsToBytes()
|
|
812
|
-
};
|
|
813
|
-
} else if (((_b = this._wallet.features["aptos:signTransaction"]) == null ? void 0 : _b.version) === "1.1") {
|
|
814
|
-
const signTransactionV1_1StandardInput = {
|
|
815
|
-
payload: transactionOrPayload.data,
|
|
816
|
-
expirationTimestamp: (_c = transactionOrPayload.options) == null ? void 0 : _c.expirationTimestamp,
|
|
817
|
-
expirationSecondsFromNow: (_d = transactionOrPayload.options) == null ? void 0 : _d.expirationSecondsFromNow,
|
|
818
|
-
gasUnitPrice: (_e = transactionOrPayload.options) == null ? void 0 : _e.gasUnitPrice,
|
|
819
|
-
maxGasAmount: (_f = transactionOrPayload.options) == null ? void 0 : _f.maxGasAmount,
|
|
820
|
-
sequenceNumber: (_g = transactionOrPayload.options) == null ? void 0 : _g.accountSequenceNumber,
|
|
821
|
-
sender: transactionOrPayload.sender ? { address: AccountAddress.from(transactionOrPayload.sender) } : void 0
|
|
822
|
-
};
|
|
823
|
-
const walletSignTransactionMethod = (_h = this._wallet) == null ? void 0 : _h.features["aptos:signTransaction"].signTransaction;
|
|
824
|
-
const response = await walletSignTransactionMethod(
|
|
825
|
-
signTransactionV1_1StandardInput
|
|
826
|
-
);
|
|
827
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
828
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
829
|
-
}
|
|
830
|
-
return {
|
|
831
|
-
authenticator: response.args.authenticator,
|
|
832
|
-
rawTransaction: response.args.rawTransaction.bcsToBytes()
|
|
833
|
-
};
|
|
834
|
-
} else {
|
|
835
|
-
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
836
|
-
const aptos = new Aptos2(aptosConfig);
|
|
837
|
-
const transaction = await aptos.transaction.build.simple({
|
|
838
|
-
sender: this._account.address,
|
|
839
|
-
data: transactionOrPayload.data,
|
|
840
|
-
options: transactionOrPayload.options
|
|
841
|
-
});
|
|
842
|
-
const response = await ((_i = this._wallet) == null ? void 0 : _i.features["aptos:signTransaction"].signTransaction(
|
|
843
|
-
transaction,
|
|
844
|
-
asFeePayer
|
|
845
|
-
));
|
|
846
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
847
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
848
|
-
}
|
|
849
|
-
return {
|
|
850
|
-
authenticator: response.args,
|
|
851
|
-
rawTransaction: transaction.bcsToBytes()
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
} catch (error) {
|
|
855
|
-
const errMsg = generalizedErrorMessage(error);
|
|
856
|
-
throw new WalletSignTransactionError(errMsg).message;
|
|
845
|
+
if ((dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network) === Network2.MAINNET) {
|
|
846
|
+
sdkWallets.push(new TWallet());
|
|
847
|
+
} else {
|
|
848
|
+
sdkWallets.push(new DevTWallet());
|
|
857
849
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.ensureWalletExists(this._wallet);
|
|
863
|
-
this.recordEvent("sign_message");
|
|
864
|
-
const response = await ((_b = (_a = this._wallet) == null ? void 0 : _a.features["aptos:signMessage"]) == null ? void 0 : _b.signMessage(message));
|
|
865
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
866
|
-
throw new WalletConnectionError("User has rejected the request").message;
|
|
867
|
-
}
|
|
868
|
-
return response.args;
|
|
869
|
-
} catch (error) {
|
|
870
|
-
const errMsg = generalizedErrorMessage(error);
|
|
871
|
-
throw new WalletSignMessageError(errMsg).message;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
async submitTransaction(transaction) {
|
|
875
|
-
try {
|
|
876
|
-
this.ensureWalletExists(this._wallet);
|
|
877
|
-
const { additionalSignersAuthenticators } = transaction;
|
|
878
|
-
const transactionType = additionalSignersAuthenticators !== void 0 ? "multi-agent" : "simple";
|
|
879
|
-
this.recordEvent("submit_transaction", {
|
|
880
|
-
transaction_type: transactionType
|
|
881
|
-
});
|
|
882
|
-
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
883
|
-
const aptos = new Aptos2(aptosConfig);
|
|
884
|
-
if (additionalSignersAuthenticators !== void 0) {
|
|
885
|
-
const multiAgentTxn = {
|
|
886
|
-
...transaction,
|
|
887
|
-
additionalSignersAuthenticators
|
|
888
|
-
};
|
|
889
|
-
return aptos.transaction.submit.multiAgent(multiAgentTxn);
|
|
890
|
-
} else {
|
|
891
|
-
return aptos.transaction.submit.simple(transaction);
|
|
892
|
-
}
|
|
893
|
-
} catch (error) {
|
|
894
|
-
const errMsg = generalizedErrorMessage(error);
|
|
895
|
-
throw new WalletSubmitTransactionError(errMsg).message;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
async onAccountChange() {
|
|
899
|
-
var _a;
|
|
900
|
-
try {
|
|
901
|
-
this.ensureWalletExists(this._wallet);
|
|
902
|
-
await ((_a = this._wallet.features["aptos:onAccountChange"]) == null ? void 0 : _a.onAccountChange(
|
|
903
|
-
async (data) => {
|
|
904
|
-
this.setAccount(data);
|
|
905
|
-
await this.setAnsName();
|
|
906
|
-
this.recordEvent("account_change");
|
|
907
|
-
this.emit("accountChange", this._account);
|
|
908
|
-
}
|
|
909
|
-
));
|
|
910
|
-
} catch (error) {
|
|
911
|
-
const errMsg = generalizedErrorMessage(error);
|
|
912
|
-
throw new WalletAccountChangeError(errMsg).message;
|
|
850
|
+
if (dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network) {
|
|
851
|
+
sdkWallets.push(new MSafeWallet(_object_spread_props(_object_spread({}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.msafeWalletConfig), {
|
|
852
|
+
network: dappConfig.network
|
|
853
|
+
})));
|
|
913
854
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
855
|
+
return sdkWallets;
|
|
856
|
+
}
|
|
857
|
+
// src/WalletCore.ts
|
|
858
|
+
var WalletCore = /*#__PURE__*/ function(EventEmitter) {
|
|
859
|
+
"use strict";
|
|
860
|
+
_inherits(WalletCore, EventEmitter);
|
|
861
|
+
function WalletCore(optInWallets, dappConfig, disableTelemetry) {
|
|
862
|
+
_class_call_check(this, WalletCore);
|
|
863
|
+
var _this;
|
|
864
|
+
_this = _call_super(this, WalletCore);
|
|
865
|
+
// Local private variable to hold the wallet that is currently connected
|
|
866
|
+
_this._wallet = null;
|
|
867
|
+
// Local private variable to hold SDK wallets in the adapter
|
|
868
|
+
_this._sdkWallets = [];
|
|
869
|
+
// Local array that holds all the wallets that are AIP-62 standard compatible
|
|
870
|
+
_this._standard_wallets = [];
|
|
871
|
+
// Local array that holds all the wallets that are AIP-62 standard compatible but are not installed on the user machine
|
|
872
|
+
_this._standard_not_detected_wallets = [];
|
|
873
|
+
// Local private variable to hold the network that is currently connected
|
|
874
|
+
_this._network = null;
|
|
875
|
+
// Local private variable to hold the wallet connected state
|
|
876
|
+
_this._connected = false;
|
|
877
|
+
// Local private variable to hold the connecting state
|
|
878
|
+
_this._connecting = false;
|
|
879
|
+
// Local private variable to hold the account that is currently connected
|
|
880
|
+
_this._account = null;
|
|
881
|
+
// Private array that holds all the Wallets a dapp decided to opt-in to
|
|
882
|
+
_this._optInWallets = [];
|
|
883
|
+
// Local flag to disable the adapter telemetry tool
|
|
884
|
+
_this._disableTelemetry = false;
|
|
885
|
+
// Google Analytics 4 module
|
|
886
|
+
_this.ga4 = null;
|
|
887
|
+
_this._optInWallets = optInWallets || [];
|
|
888
|
+
_this._dappConfig = dappConfig;
|
|
889
|
+
_this._disableTelemetry = disableTelemetry !== null && disableTelemetry !== void 0 ? disableTelemetry : false;
|
|
890
|
+
_this._sdkWallets = getSDKWallets(_this._dappConfig);
|
|
891
|
+
if (!_this._disableTelemetry) {
|
|
892
|
+
_this.ga4 = new GA4();
|
|
924
893
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
894
|
+
_this.fetchExtensionAIP62AptosWallets();
|
|
895
|
+
_this.fetchSDKAIP62AptosWallets();
|
|
896
|
+
_this.appendNotDetectedStandardSupportedWallets();
|
|
897
|
+
return _this;
|
|
929
898
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
899
|
+
_create_class(WalletCore, [
|
|
900
|
+
{
|
|
901
|
+
key: "fetchExtensionAIP62AptosWallets",
|
|
902
|
+
value: function fetchExtensionAIP62AptosWallets() {
|
|
903
|
+
var _getAptosWallets = getAptosWallets(), aptosWallets = _getAptosWallets.aptosWallets, on = _getAptosWallets.on;
|
|
904
|
+
this.setExtensionAIP62Wallets(aptosWallets);
|
|
905
|
+
if (typeof window === "undefined") return;
|
|
906
|
+
var that = this;
|
|
907
|
+
var removeRegisterListener = on("register", function() {
|
|
908
|
+
var _getAptosWallets = getAptosWallets(), aptosWallets2 = _getAptosWallets.aptosWallets;
|
|
909
|
+
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
910
|
+
});
|
|
911
|
+
var removeUnregisterListener = on("unregister", function() {
|
|
912
|
+
var _getAptosWallets = getAptosWallets(), aptosWallets2 = _getAptosWallets.aptosWallets;
|
|
913
|
+
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
/**
|
|
919
|
+
* Set AIP-62 extension wallets
|
|
920
|
+
*
|
|
921
|
+
* @param extensionwWallets
|
|
922
|
+
*/ key: "setExtensionAIP62Wallets",
|
|
923
|
+
value: function setExtensionAIP62Wallets(extensionwWallets) {
|
|
924
|
+
var _this = this;
|
|
925
|
+
extensionwWallets.map(function(wallet) {
|
|
926
|
+
if (_this.excludeWallet(wallet)) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
_this._standard_wallets = _this._standard_wallets.filter(function(item) {
|
|
930
|
+
return item.name !== wallet.name;
|
|
931
|
+
});
|
|
932
|
+
var isValid = isWalletWithRequiredFeatureSet(wallet);
|
|
933
|
+
if (isValid) {
|
|
934
|
+
var index = _this._standard_not_detected_wallets.findIndex(function(notDetctedWallet) {
|
|
935
|
+
return notDetctedWallet.name == wallet.name;
|
|
936
|
+
});
|
|
937
|
+
if (index !== -1) {
|
|
938
|
+
_this._standard_not_detected_wallets.splice(index, 1);
|
|
939
|
+
}
|
|
940
|
+
wallet.readyState = "Installed" /* Installed */ ;
|
|
941
|
+
_this._standard_wallets.push(wallet);
|
|
942
|
+
_this.emit("standardWalletsAdded", wallet);
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
/**
|
|
949
|
+
* Set AIP-62 SDK wallets
|
|
950
|
+
*/ key: "fetchSDKAIP62AptosWallets",
|
|
951
|
+
value: function fetchSDKAIP62AptosWallets() {
|
|
952
|
+
var _this = this;
|
|
953
|
+
this._sdkWallets.map(function(wallet) {
|
|
954
|
+
if (_this.excludeWallet(wallet)) {
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
var isValid = isWalletWithRequiredFeatureSet(wallet);
|
|
958
|
+
if (isValid) {
|
|
959
|
+
wallet.readyState = "Installed" /* Installed */ ;
|
|
960
|
+
_this._standard_wallets.push(wallet);
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
// Since we can't discover AIP-62 wallets that are not installed on the user machine,
|
|
967
|
+
// we hold a AIP-62 wallets registry to show on the wallet selector modal for the users.
|
|
968
|
+
// Append wallets from wallet standard support registry to the `_standard_not_detected_wallets` array
|
|
969
|
+
// when wallet is not installed on the user machine
|
|
970
|
+
key: "appendNotDetectedStandardSupportedWallets",
|
|
971
|
+
value: function appendNotDetectedStandardSupportedWallets() {
|
|
972
|
+
var _this = this;
|
|
973
|
+
aptosStandardSupportedWalletList.map(function(supportedWallet) {
|
|
974
|
+
var existingStandardWallet = _this._standard_wallets.find(function(wallet) {
|
|
975
|
+
return wallet.name == supportedWallet.name;
|
|
976
|
+
});
|
|
977
|
+
if (existingStandardWallet) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (_this.excludeWallet(supportedWallet)) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (!existingStandardWallet) {
|
|
984
|
+
_this._standard_not_detected_wallets.push(supportedWallet);
|
|
985
|
+
_this.emit("standardNotDetectedWalletAdded", supportedWallet);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
/**
|
|
992
|
+
* A function that excludes an AIP-62 compatible wallet the dapp doesnt want to include
|
|
993
|
+
*
|
|
994
|
+
* @param wallet AdapterWallet | AdapterNotDetectedWallet
|
|
995
|
+
* @returns boolean
|
|
996
|
+
*/ key: "excludeWallet",
|
|
997
|
+
value: function excludeWallet(wallet) {
|
|
998
|
+
if (this._optInWallets.length > 0 && !this._optInWallets.includes(wallet.name)) {
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
key: "recordEvent",
|
|
1006
|
+
value: function recordEvent(eventName, additionalInfo) {
|
|
1007
|
+
var _this__wallet, _this__network, _this__network1, _this_ga4;
|
|
1008
|
+
(_this_ga4 = this.ga4) === null || _this_ga4 === void 0 ? void 0 : _this_ga4.gtag("event", "wallet_adapter_".concat(eventName), _object_spread({
|
|
1009
|
+
wallet: (_this__wallet = this._wallet) === null || _this__wallet === void 0 ? void 0 : _this__wallet.name,
|
|
1010
|
+
network: (_this__network = this._network) === null || _this__network === void 0 ? void 0 : _this__network.name,
|
|
1011
|
+
network_url: (_this__network1 = this._network) === null || _this__network1 === void 0 ? void 0 : _this__network1.url,
|
|
1012
|
+
adapter_core_version: WALLET_ADAPTER_CORE_VERSION,
|
|
1013
|
+
send_to: "G-GNVVWBL3J9"
|
|
1014
|
+
}, additionalInfo));
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
/**
|
|
1019
|
+
* Helper function to ensure wallet exists
|
|
1020
|
+
*
|
|
1021
|
+
* @param wallet A wallet
|
|
1022
|
+
*/ key: "ensureWalletExists",
|
|
1023
|
+
value: function ensureWalletExists(wallet) {
|
|
1024
|
+
if (!wallet) {
|
|
1025
|
+
throw new WalletNotConnectedError().name;
|
|
1026
|
+
}
|
|
1027
|
+
if (!(wallet.readyState === "Installed" /* Installed */ )) throw new WalletNotReadyError("Wallet is not set").name;
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
/**
|
|
1032
|
+
* Helper function to ensure account exists
|
|
1033
|
+
*
|
|
1034
|
+
* @param account An account
|
|
1035
|
+
*/ key: "ensureAccountExists",
|
|
1036
|
+
value: function ensureAccountExists(account) {
|
|
1037
|
+
if (!account) {
|
|
1038
|
+
throw new WalletAccountError("Account is not set").name;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
key: "setAnsName",
|
|
1044
|
+
value: /**
|
|
1045
|
+
* Queries and sets ANS name for the current connected wallet account
|
|
1046
|
+
*/ function setAnsName() {
|
|
1047
|
+
var _this = this;
|
|
1048
|
+
return _async_to_generator(function() {
|
|
1049
|
+
var _this__network, aptosConfig, aptos, name, error;
|
|
1050
|
+
return _ts_generator(this, function(_state) {
|
|
1051
|
+
switch(_state.label){
|
|
1052
|
+
case 0:
|
|
1053
|
+
if (!(((_this__network = _this._network) === null || _this__network === void 0 ? void 0 : _this__network.chainId) && _this._account)) return [
|
|
1054
|
+
3,
|
|
1055
|
+
4
|
|
1056
|
+
];
|
|
1057
|
+
if (_this._account.ansName) return [
|
|
1058
|
+
2
|
|
1059
|
+
];
|
|
1060
|
+
if (!ChainIdToAnsSupportedNetworkMap[_this._network.chainId] || !isAptosNetwork(_this._network)) {
|
|
1061
|
+
_this._account.ansName = void 0;
|
|
1062
|
+
return [
|
|
1063
|
+
2
|
|
1064
|
+
];
|
|
1065
|
+
}
|
|
1066
|
+
aptosConfig = getAptosConfig(_this._network, _this._dappConfig);
|
|
1067
|
+
aptos = new Aptos2(aptosConfig);
|
|
1068
|
+
_state.label = 1;
|
|
1069
|
+
case 1:
|
|
1070
|
+
_state.trys.push([
|
|
1071
|
+
1,
|
|
1072
|
+
3,
|
|
1073
|
+
,
|
|
1074
|
+
4
|
|
1075
|
+
]);
|
|
1076
|
+
return [
|
|
1077
|
+
4,
|
|
1078
|
+
aptos.ans.getPrimaryName({
|
|
1079
|
+
address: _this._account.address.toString()
|
|
1080
|
+
})
|
|
1081
|
+
];
|
|
1082
|
+
case 2:
|
|
1083
|
+
name = _state.sent();
|
|
1084
|
+
_this._account.ansName = name;
|
|
1085
|
+
return [
|
|
1086
|
+
3,
|
|
1087
|
+
4
|
|
1088
|
+
];
|
|
1089
|
+
case 3:
|
|
1090
|
+
error = _state.sent();
|
|
1091
|
+
console.log("Error setting ANS name ".concat(error));
|
|
1092
|
+
return [
|
|
1093
|
+
3,
|
|
1094
|
+
4
|
|
1095
|
+
];
|
|
1096
|
+
case 4:
|
|
1097
|
+
return [
|
|
1098
|
+
2
|
|
1099
|
+
];
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
})();
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
/**
|
|
1107
|
+
* Function to cleat wallet adapter data.
|
|
1108
|
+
*
|
|
1109
|
+
* - Removes current connected wallet state
|
|
1110
|
+
* - Removes current connected account state
|
|
1111
|
+
* - Removes current connected network state
|
|
1112
|
+
* - Removes autoconnect local storage value
|
|
1113
|
+
*/ key: "clearData",
|
|
1114
|
+
value: function clearData() {
|
|
1115
|
+
this._connected = false;
|
|
1116
|
+
this.setWallet(null);
|
|
1117
|
+
this.setAccount(null);
|
|
1118
|
+
this.setNetwork(null);
|
|
1119
|
+
removeLocalStorage();
|
|
1120
|
+
}
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
/**
|
|
1124
|
+
* Sets the connected wallet
|
|
1125
|
+
*
|
|
1126
|
+
* @param wallet A wallet
|
|
1127
|
+
*/ key: "setWallet",
|
|
1128
|
+
value: function setWallet(wallet) {
|
|
1129
|
+
this._wallet = wallet;
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
/**
|
|
1134
|
+
* Sets the connected account
|
|
1135
|
+
*
|
|
1136
|
+
* @param account An account
|
|
1137
|
+
*/ key: "setAccount",
|
|
1138
|
+
value: function setAccount(account) {
|
|
1139
|
+
this._account = account;
|
|
1140
|
+
}
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
/**
|
|
1144
|
+
* Sets the connected network
|
|
1145
|
+
*
|
|
1146
|
+
* @param network A network
|
|
1147
|
+
*/ key: "setNetwork",
|
|
1148
|
+
value: function setNetwork(network) {
|
|
1149
|
+
this._network = network;
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
/**
|
|
1154
|
+
* Helper function to detect whether a wallet is connected
|
|
1155
|
+
*
|
|
1156
|
+
* @returns boolean
|
|
1157
|
+
*/ key: "isConnected",
|
|
1158
|
+
value: function isConnected() {
|
|
1159
|
+
return this._connected;
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
key: "wallets",
|
|
1164
|
+
get: /**
|
|
1165
|
+
* Getter to fetch all detected wallets
|
|
1166
|
+
*/ function get() {
|
|
1167
|
+
return this._standard_wallets;
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
key: "notDetectedWallets",
|
|
1172
|
+
get: function get() {
|
|
1173
|
+
return this._standard_not_detected_wallets;
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
{
|
|
1177
|
+
key: "wallet",
|
|
1178
|
+
get: /**
|
|
1179
|
+
* Getter for the current connected wallet
|
|
1180
|
+
*
|
|
1181
|
+
* @return wallet info
|
|
1182
|
+
* @throws WalletNotSelectedError
|
|
1183
|
+
*/ function get() {
|
|
1184
|
+
try {
|
|
1185
|
+
if (!this._wallet) return null;
|
|
1186
|
+
return this._wallet;
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
throw new WalletNotSelectedError(error).message;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
key: "account",
|
|
1194
|
+
get: /**
|
|
1195
|
+
* Getter for the current connected account
|
|
1196
|
+
*
|
|
1197
|
+
* @return account info
|
|
1198
|
+
* @throws WalletAccountError
|
|
1199
|
+
*/ function get() {
|
|
1200
|
+
try {
|
|
1201
|
+
return this._account;
|
|
1202
|
+
} catch (error) {
|
|
1203
|
+
throw new WalletAccountError(error).message;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
key: "network",
|
|
1209
|
+
get: /**
|
|
1210
|
+
* Getter for the current wallet network
|
|
1211
|
+
*
|
|
1212
|
+
* @return network info
|
|
1213
|
+
* @throws WalletGetNetworkError
|
|
1214
|
+
*/ function get() {
|
|
1215
|
+
try {
|
|
1216
|
+
return this._network;
|
|
1217
|
+
} catch (error) {
|
|
1218
|
+
throw new WalletGetNetworkError(error).message;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
key: "connect",
|
|
1224
|
+
value: /**
|
|
1225
|
+
* Helper function to run some checks before we connect with a wallet.
|
|
1226
|
+
*
|
|
1227
|
+
* @param walletName. The wallet name we want to connect with.
|
|
1228
|
+
*/ function connect(walletName) {
|
|
1229
|
+
var _this = this;
|
|
1230
|
+
return _async_to_generator(function() {
|
|
1231
|
+
var selectedWallet2, uninstalledWallet, url, location, allDetectedWallets, selectedWallet, _this__wallet;
|
|
1232
|
+
return _ts_generator(this, function(_state) {
|
|
1233
|
+
switch(_state.label){
|
|
1234
|
+
case 0:
|
|
1235
|
+
if (isRedirectable()) {
|
|
1236
|
+
selectedWallet2 = _this._standard_not_detected_wallets.find(function(wallet) {
|
|
1237
|
+
return wallet.name === walletName;
|
|
1238
|
+
});
|
|
1239
|
+
if (selectedWallet2) {
|
|
1240
|
+
uninstalledWallet = selectedWallet2;
|
|
1241
|
+
if (uninstalledWallet.deeplinkProvider) {
|
|
1242
|
+
url = encodeURIComponent(window.location.href);
|
|
1243
|
+
location = uninstalledWallet.deeplinkProvider.concat(url);
|
|
1244
|
+
window.location.href = location;
|
|
1245
|
+
return [
|
|
1246
|
+
2
|
|
1247
|
+
];
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
allDetectedWallets = _this._standard_wallets;
|
|
1252
|
+
selectedWallet = allDetectedWallets.find(function(wallet) {
|
|
1253
|
+
return wallet.name === walletName;
|
|
1254
|
+
});
|
|
1255
|
+
if (!selectedWallet) return [
|
|
1256
|
+
2
|
|
1257
|
+
];
|
|
1258
|
+
if (_this._connected && _this._account) {
|
|
1259
|
+
;
|
|
1260
|
+
if (((_this__wallet = _this._wallet) === null || _this__wallet === void 0 ? void 0 : _this__wallet.name) === walletName) throw new WalletConnectionError("".concat(walletName, " wallet is already connected")).message;
|
|
1261
|
+
}
|
|
1262
|
+
return [
|
|
1263
|
+
4,
|
|
1264
|
+
_this.connectWallet(selectedWallet, /*#__PURE__*/ _async_to_generator(function() {
|
|
1265
|
+
var response;
|
|
1266
|
+
return _ts_generator(this, function(_state) {
|
|
1267
|
+
switch(_state.label){
|
|
1268
|
+
case 0:
|
|
1269
|
+
return [
|
|
1270
|
+
4,
|
|
1271
|
+
selectedWallet.features["aptos:connect"].connect()
|
|
1272
|
+
];
|
|
1273
|
+
case 1:
|
|
1274
|
+
response = _state.sent();
|
|
1275
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
1276
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1277
|
+
}
|
|
1278
|
+
return [
|
|
1279
|
+
2,
|
|
1280
|
+
{
|
|
1281
|
+
account: response.args,
|
|
1282
|
+
output: void 0
|
|
1283
|
+
}
|
|
1284
|
+
];
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}))
|
|
1288
|
+
];
|
|
1289
|
+
case 1:
|
|
1290
|
+
_state.sent();
|
|
1291
|
+
return [
|
|
1292
|
+
2
|
|
1293
|
+
];
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
})();
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
key: "signIn",
|
|
1301
|
+
value: /**
|
|
1302
|
+
* Signs into the wallet by connecting and signing an authentication messages.
|
|
1303
|
+
*
|
|
1304
|
+
* For more information, visit: https://siwa.aptos.dev
|
|
1305
|
+
*
|
|
1306
|
+
* @param args
|
|
1307
|
+
* @param args.input The AptosSignInInput which defines how the SIWA Message should be constructed
|
|
1308
|
+
* @param args.walletName The name of the wallet to sign into
|
|
1309
|
+
* @returns The AptosSignInOutput which contains the account and signature information
|
|
1310
|
+
*/ function signIn(args) {
|
|
1311
|
+
var _this = this;
|
|
1312
|
+
return _async_to_generator(function() {
|
|
1313
|
+
var input, walletName, allDetectedWallets, selectedWallet;
|
|
1314
|
+
return _ts_generator(this, function(_state) {
|
|
1315
|
+
switch(_state.label){
|
|
1316
|
+
case 0:
|
|
1317
|
+
input = args.input, walletName = args.walletName;
|
|
1318
|
+
allDetectedWallets = _this._standard_wallets;
|
|
1319
|
+
selectedWallet = allDetectedWallets.find(function(wallet) {
|
|
1320
|
+
return wallet.name === walletName;
|
|
1321
|
+
});
|
|
1322
|
+
if (!selectedWallet) {
|
|
1323
|
+
throw new WalletNotFoundError("Wallet ".concat(walletName, " not found")).message;
|
|
1324
|
+
}
|
|
1325
|
+
if (!selectedWallet.features["aptos:signIn"]) {
|
|
1326
|
+
throw new WalletNotSupportedMethod("aptos:signIn is not supported by ".concat(walletName)).message;
|
|
1327
|
+
}
|
|
1328
|
+
return [
|
|
1329
|
+
4,
|
|
1330
|
+
_this.connectWallet(selectedWallet, /*#__PURE__*/ _async_to_generator(function() {
|
|
1331
|
+
var response;
|
|
1332
|
+
return _ts_generator(this, function(_state) {
|
|
1333
|
+
switch(_state.label){
|
|
1334
|
+
case 0:
|
|
1335
|
+
if (!selectedWallet.features["aptos:signIn"]) {
|
|
1336
|
+
throw new WalletNotSupportedMethod("aptos:signIn is not supported by ".concat(selectedWallet.name)).message;
|
|
1337
|
+
}
|
|
1338
|
+
return [
|
|
1339
|
+
4,
|
|
1340
|
+
selectedWallet.features["aptos:signIn"].signIn(input)
|
|
1341
|
+
];
|
|
1342
|
+
case 1:
|
|
1343
|
+
response = _state.sent();
|
|
1344
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
1345
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1346
|
+
}
|
|
1347
|
+
return [
|
|
1348
|
+
2,
|
|
1349
|
+
{
|
|
1350
|
+
account: response.args.account,
|
|
1351
|
+
output: response.args
|
|
1352
|
+
}
|
|
1353
|
+
];
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
}))
|
|
1357
|
+
];
|
|
1358
|
+
case 1:
|
|
1359
|
+
return [
|
|
1360
|
+
2,
|
|
1361
|
+
_state.sent()
|
|
1362
|
+
];
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
})();
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
key: "connectWallet",
|
|
1370
|
+
value: /**
|
|
1371
|
+
* Connects a wallet to the dapp.
|
|
1372
|
+
* On connect success, we set the current account and the network, and keeping the selected wallet
|
|
1373
|
+
* name in LocalStorage to support autoConnect function.
|
|
1374
|
+
*
|
|
1375
|
+
* @param selectedWallet. The wallet we want to connect.
|
|
1376
|
+
* @emit emits "connect" event
|
|
1377
|
+
* @throws WalletConnectionError
|
|
1378
|
+
*/ function connectWallet(selectedWallet, onConnect) {
|
|
1379
|
+
var _this = this;
|
|
1380
|
+
return _async_to_generator(function() {
|
|
1381
|
+
var _ref, account, output, network, error, errMsg;
|
|
1382
|
+
return _ts_generator(this, function(_state) {
|
|
1383
|
+
switch(_state.label){
|
|
1384
|
+
case 0:
|
|
1385
|
+
_state.trys.push([
|
|
1386
|
+
0,
|
|
1387
|
+
4,
|
|
1388
|
+
5,
|
|
1389
|
+
6
|
|
1390
|
+
]);
|
|
1391
|
+
_this._connecting = true;
|
|
1392
|
+
_this.setWallet(selectedWallet);
|
|
1393
|
+
return [
|
|
1394
|
+
4,
|
|
1395
|
+
onConnect()
|
|
1396
|
+
];
|
|
1397
|
+
case 1:
|
|
1398
|
+
_ref = _state.sent(), account = _ref.account, output = _ref.output;
|
|
1399
|
+
_this.setAccount(account);
|
|
1400
|
+
return [
|
|
1401
|
+
4,
|
|
1402
|
+
selectedWallet.features["aptos:network"].network()
|
|
1403
|
+
];
|
|
1404
|
+
case 2:
|
|
1405
|
+
network = _state.sent();
|
|
1406
|
+
_this.setNetwork(network);
|
|
1407
|
+
return [
|
|
1408
|
+
4,
|
|
1409
|
+
_this.setAnsName()
|
|
1410
|
+
];
|
|
1411
|
+
case 3:
|
|
1412
|
+
_state.sent();
|
|
1413
|
+
setLocalStorage(selectedWallet.name);
|
|
1414
|
+
_this._connected = true;
|
|
1415
|
+
_this.recordEvent("wallet_connect");
|
|
1416
|
+
_this.emit("connect", account);
|
|
1417
|
+
return [
|
|
1418
|
+
2,
|
|
1419
|
+
output
|
|
1420
|
+
];
|
|
1421
|
+
case 4:
|
|
1422
|
+
error = _state.sent();
|
|
1423
|
+
_this.clearData();
|
|
1424
|
+
errMsg = generalizedErrorMessage(error);
|
|
1425
|
+
throw new WalletConnectionError(errMsg).message;
|
|
1426
|
+
case 5:
|
|
1427
|
+
_this._connecting = false;
|
|
1428
|
+
return [
|
|
1429
|
+
7
|
|
1430
|
+
];
|
|
1431
|
+
case 6:
|
|
1432
|
+
return [
|
|
1433
|
+
2
|
|
1434
|
+
];
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
})();
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
key: "disconnect",
|
|
1442
|
+
value: /**
|
|
1443
|
+
* Disconnect the current connected wallet. On success, we clear the
|
|
1444
|
+
* current account, current network and LocalStorage data.
|
|
1445
|
+
*
|
|
1446
|
+
* @emit emits "disconnect" event
|
|
1447
|
+
* @throws WalletDisconnectionError
|
|
1448
|
+
*/ function disconnect() {
|
|
1449
|
+
var _this = this;
|
|
1450
|
+
return _async_to_generator(function() {
|
|
1451
|
+
var error, errMsg;
|
|
1452
|
+
return _ts_generator(this, function(_state) {
|
|
1453
|
+
switch(_state.label){
|
|
1454
|
+
case 0:
|
|
1455
|
+
_state.trys.push([
|
|
1456
|
+
0,
|
|
1457
|
+
2,
|
|
1458
|
+
,
|
|
1459
|
+
3
|
|
1460
|
+
]);
|
|
1461
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1462
|
+
return [
|
|
1463
|
+
4,
|
|
1464
|
+
_this._wallet.features["aptos:disconnect"].disconnect()
|
|
1465
|
+
];
|
|
1466
|
+
case 1:
|
|
1467
|
+
_state.sent();
|
|
1468
|
+
_this.clearData();
|
|
1469
|
+
_this.recordEvent("wallet_disconnect");
|
|
1470
|
+
_this.emit("disconnect");
|
|
1471
|
+
return [
|
|
1472
|
+
3,
|
|
1473
|
+
3
|
|
1474
|
+
];
|
|
1475
|
+
case 2:
|
|
1476
|
+
error = _state.sent();
|
|
1477
|
+
errMsg = generalizedErrorMessage(error);
|
|
1478
|
+
throw new WalletDisconnectionError(errMsg).message;
|
|
1479
|
+
case 3:
|
|
1480
|
+
return [
|
|
1481
|
+
2
|
|
1482
|
+
];
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
})();
|
|
1486
|
+
}
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
key: "signAndSubmitTransaction",
|
|
1490
|
+
value: /**
|
|
1491
|
+
* Signs and submits a transaction to chain
|
|
1492
|
+
*
|
|
1493
|
+
* @param transactionInput InputTransactionData
|
|
1494
|
+
* @returns AptosSignAndSubmitTransactionOutput
|
|
1495
|
+
*/ function signAndSubmitTransaction(transactionInput) {
|
|
1496
|
+
var _this = this;
|
|
1497
|
+
return _async_to_generator(function() {
|
|
1498
|
+
var ref, _transactionInput_options, _transactionInput_options1, aptosConfig2, aptos2, transaction2, signAndSubmitTransactionMethod, response3, response2, aptosConfig, aptos, transaction, signTransactionResponse, response, error, errMsg;
|
|
1499
|
+
return _ts_generator(this, function(_state) {
|
|
1500
|
+
switch(_state.label){
|
|
1501
|
+
case 0:
|
|
1502
|
+
_state.trys.push([
|
|
1503
|
+
0,
|
|
1504
|
+
9,
|
|
1505
|
+
,
|
|
1506
|
+
10
|
|
1507
|
+
]);
|
|
1508
|
+
if ("function" in transactionInput.data) {
|
|
1509
|
+
if (transactionInput.data.function === "0x1::account::rotate_authentication_key_call") {
|
|
1510
|
+
throw new WalletSignAndSubmitMessageError("SCAM SITE DETECTED").message;
|
|
1511
|
+
}
|
|
1512
|
+
if (transactionInput.data.function === "0x1::code::publish_package_txn") {
|
|
1513
|
+
;
|
|
1514
|
+
ref = handlePublishPackageTransaction(transactionInput), transactionInput.data.functionArguments[0] = ref.metadataBytes, transactionInput.data.functionArguments[1] = ref.byteCode, ref;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1518
|
+
_this.ensureAccountExists(_this._account);
|
|
1519
|
+
_this.recordEvent("sign_and_submit_transaction");
|
|
1520
|
+
if (!_this._wallet.features["aptos:signAndSubmitTransaction"]) return [
|
|
1521
|
+
3,
|
|
1522
|
+
5
|
|
1523
|
+
];
|
|
1524
|
+
if (!(_this._wallet.features["aptos:signAndSubmitTransaction"].version !== "1.1.0")) return [
|
|
1525
|
+
3,
|
|
1526
|
+
3
|
|
1527
|
+
];
|
|
1528
|
+
aptosConfig2 = getAptosConfig(_this._network, _this._dappConfig);
|
|
1529
|
+
aptos2 = new Aptos2(aptosConfig2);
|
|
1530
|
+
return [
|
|
1531
|
+
4,
|
|
1532
|
+
aptos2.transaction.build.simple({
|
|
1533
|
+
sender: _this._account.address.toString(),
|
|
1534
|
+
data: transactionInput.data,
|
|
1535
|
+
options: transactionInput.options
|
|
1536
|
+
})
|
|
1537
|
+
];
|
|
1538
|
+
case 1:
|
|
1539
|
+
transaction2 = _state.sent();
|
|
1540
|
+
signAndSubmitTransactionMethod = _this._wallet.features["aptos:signAndSubmitTransaction"].signAndSubmitTransaction;
|
|
1541
|
+
return [
|
|
1542
|
+
4,
|
|
1543
|
+
signAndSubmitTransactionMethod(transaction2)
|
|
1544
|
+
];
|
|
1545
|
+
case 2:
|
|
1546
|
+
response3 = _state.sent();
|
|
1547
|
+
if (response3.status === UserResponseStatus.REJECTED) {
|
|
1548
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1549
|
+
}
|
|
1550
|
+
return [
|
|
1551
|
+
2,
|
|
1552
|
+
response3.args
|
|
1553
|
+
];
|
|
1554
|
+
case 3:
|
|
1555
|
+
return [
|
|
1556
|
+
4,
|
|
1557
|
+
_this._wallet.features["aptos:signAndSubmitTransaction"].signAndSubmitTransaction({
|
|
1558
|
+
payload: transactionInput.data,
|
|
1559
|
+
gasUnitPrice: (_transactionInput_options = transactionInput.options) === null || _transactionInput_options === void 0 ? void 0 : _transactionInput_options.gasUnitPrice,
|
|
1560
|
+
maxGasAmount: (_transactionInput_options1 = transactionInput.options) === null || _transactionInput_options1 === void 0 ? void 0 : _transactionInput_options1.maxGasAmount
|
|
1561
|
+
})
|
|
1562
|
+
];
|
|
1563
|
+
case 4:
|
|
1564
|
+
response2 = _state.sent();
|
|
1565
|
+
if (response2.status === UserResponseStatus.REJECTED) {
|
|
1566
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1567
|
+
}
|
|
1568
|
+
return [
|
|
1569
|
+
2,
|
|
1570
|
+
response2.args
|
|
1571
|
+
];
|
|
1572
|
+
case 5:
|
|
1573
|
+
aptosConfig = getAptosConfig(_this._network, _this._dappConfig);
|
|
1574
|
+
aptos = new Aptos2(aptosConfig);
|
|
1575
|
+
return [
|
|
1576
|
+
4,
|
|
1577
|
+
aptos.transaction.build.simple({
|
|
1578
|
+
sender: _this._account.address,
|
|
1579
|
+
data: transactionInput.data,
|
|
1580
|
+
options: transactionInput.options
|
|
1581
|
+
})
|
|
1582
|
+
];
|
|
1583
|
+
case 6:
|
|
1584
|
+
transaction = _state.sent();
|
|
1585
|
+
return [
|
|
1586
|
+
4,
|
|
1587
|
+
_this.signTransaction({
|
|
1588
|
+
transactionOrPayload: transaction
|
|
1589
|
+
})
|
|
1590
|
+
];
|
|
1591
|
+
case 7:
|
|
1592
|
+
signTransactionResponse = _state.sent();
|
|
1593
|
+
return [
|
|
1594
|
+
4,
|
|
1595
|
+
_this.submitTransaction({
|
|
1596
|
+
transaction: transaction,
|
|
1597
|
+
senderAuthenticator: signTransactionResponse.authenticator
|
|
1598
|
+
})
|
|
1599
|
+
];
|
|
1600
|
+
case 8:
|
|
1601
|
+
response = _state.sent();
|
|
1602
|
+
return [
|
|
1603
|
+
2,
|
|
1604
|
+
{
|
|
1605
|
+
hash: response.hash
|
|
1606
|
+
}
|
|
1607
|
+
];
|
|
1608
|
+
case 9:
|
|
1609
|
+
error = _state.sent();
|
|
1610
|
+
errMsg = generalizedErrorMessage(error);
|
|
1611
|
+
throw new WalletSignAndSubmitMessageError(errMsg).message;
|
|
1612
|
+
case 10:
|
|
1613
|
+
return [
|
|
1614
|
+
2
|
|
1615
|
+
];
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
})();
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
key: "signTransaction",
|
|
1623
|
+
value: /**
|
|
1624
|
+
* Signs a transaction
|
|
1625
|
+
*
|
|
1626
|
+
* This method supports 2 input types -
|
|
1627
|
+
* 1. A raw transaction that was already built by the dapp,
|
|
1628
|
+
* 2. A transaction data input as JSON. This is for the wallet to be able to simulate before signing
|
|
1629
|
+
*
|
|
1630
|
+
* @param transactionOrPayload AnyRawTransaction | InputTransactionData
|
|
1631
|
+
* @param asFeePayer optional. A flag indicates to sign the transaction as the fee payer
|
|
1632
|
+
* @param options optional. Transaction options
|
|
1633
|
+
*
|
|
1634
|
+
* @returns AccountAuthenticator
|
|
1635
|
+
*/ function signTransaction(args) {
|
|
1636
|
+
var _this = this;
|
|
1637
|
+
return _async_to_generator(function() {
|
|
1638
|
+
var transactionOrPayload, asFeePayer, _this__wallet_features_aptossignTransaction, _this__wallet, response, _transactionOrPayload_options, _transactionOrPayload_options1, _transactionOrPayload_options2, _transactionOrPayload_options3, _transactionOrPayload_options4, _this__wallet1, signTransactionV1_1StandardInput, walletSignTransactionMethod, response1, _this__wallet2, aptosConfig, aptos, transaction, response2, error, errMsg;
|
|
1639
|
+
return _ts_generator(this, function(_state) {
|
|
1640
|
+
switch(_state.label){
|
|
1641
|
+
case 0:
|
|
1642
|
+
transactionOrPayload = args.transactionOrPayload, asFeePayer = args.asFeePayer;
|
|
1643
|
+
_state.label = 1;
|
|
1644
|
+
case 1:
|
|
1645
|
+
_state.trys.push([
|
|
1646
|
+
1,
|
|
1647
|
+
9,
|
|
1648
|
+
,
|
|
1649
|
+
10
|
|
1650
|
+
]);
|
|
1651
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1652
|
+
_this.ensureAccountExists(_this._account);
|
|
1653
|
+
_this.recordEvent("sign_transaction");
|
|
1654
|
+
if (!("rawTransaction" in transactionOrPayload)) return [
|
|
1655
|
+
3,
|
|
1656
|
+
3
|
|
1657
|
+
];
|
|
1658
|
+
return [
|
|
1659
|
+
4,
|
|
1660
|
+
(_this__wallet = _this._wallet) === null || _this__wallet === void 0 ? void 0 : _this__wallet.features["aptos:signTransaction"].signTransaction(transactionOrPayload, asFeePayer)
|
|
1661
|
+
];
|
|
1662
|
+
case 2:
|
|
1663
|
+
response = _state.sent();
|
|
1664
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
1665
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1666
|
+
}
|
|
1667
|
+
return [
|
|
1668
|
+
2,
|
|
1669
|
+
{
|
|
1670
|
+
authenticator: response.args,
|
|
1671
|
+
rawTransaction: transactionOrPayload.rawTransaction.bcsToBytes()
|
|
1672
|
+
}
|
|
1673
|
+
];
|
|
1674
|
+
case 3:
|
|
1675
|
+
if (!(((_this__wallet_features_aptossignTransaction = _this._wallet.features["aptos:signTransaction"]) === null || _this__wallet_features_aptossignTransaction === void 0 ? void 0 : _this__wallet_features_aptossignTransaction.version) === "1.1")) return [
|
|
1676
|
+
3,
|
|
1677
|
+
5
|
|
1678
|
+
];
|
|
1679
|
+
signTransactionV1_1StandardInput = {
|
|
1680
|
+
payload: transactionOrPayload.data,
|
|
1681
|
+
expirationTimestamp: (_transactionOrPayload_options = transactionOrPayload.options) === null || _transactionOrPayload_options === void 0 ? void 0 : _transactionOrPayload_options.expirationTimestamp,
|
|
1682
|
+
expirationSecondsFromNow: (_transactionOrPayload_options1 = transactionOrPayload.options) === null || _transactionOrPayload_options1 === void 0 ? void 0 : _transactionOrPayload_options1.expirationSecondsFromNow,
|
|
1683
|
+
gasUnitPrice: (_transactionOrPayload_options2 = transactionOrPayload.options) === null || _transactionOrPayload_options2 === void 0 ? void 0 : _transactionOrPayload_options2.gasUnitPrice,
|
|
1684
|
+
maxGasAmount: (_transactionOrPayload_options3 = transactionOrPayload.options) === null || _transactionOrPayload_options3 === void 0 ? void 0 : _transactionOrPayload_options3.maxGasAmount,
|
|
1685
|
+
sequenceNumber: (_transactionOrPayload_options4 = transactionOrPayload.options) === null || _transactionOrPayload_options4 === void 0 ? void 0 : _transactionOrPayload_options4.accountSequenceNumber,
|
|
1686
|
+
sender: transactionOrPayload.sender ? {
|
|
1687
|
+
address: AccountAddress.from(transactionOrPayload.sender)
|
|
1688
|
+
} : void 0
|
|
1689
|
+
};
|
|
1690
|
+
walletSignTransactionMethod = (_this__wallet1 = _this._wallet) === null || _this__wallet1 === void 0 ? void 0 : _this__wallet1.features["aptos:signTransaction"].signTransaction;
|
|
1691
|
+
return [
|
|
1692
|
+
4,
|
|
1693
|
+
walletSignTransactionMethod(signTransactionV1_1StandardInput)
|
|
1694
|
+
];
|
|
1695
|
+
case 4:
|
|
1696
|
+
response1 = _state.sent();
|
|
1697
|
+
if (response1.status === UserResponseStatus.REJECTED) {
|
|
1698
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1699
|
+
}
|
|
1700
|
+
return [
|
|
1701
|
+
2,
|
|
1702
|
+
{
|
|
1703
|
+
authenticator: response1.args.authenticator,
|
|
1704
|
+
rawTransaction: response1.args.rawTransaction.bcsToBytes()
|
|
1705
|
+
}
|
|
1706
|
+
];
|
|
1707
|
+
case 5:
|
|
1708
|
+
aptosConfig = getAptosConfig(_this._network, _this._dappConfig);
|
|
1709
|
+
aptos = new Aptos2(aptosConfig);
|
|
1710
|
+
return [
|
|
1711
|
+
4,
|
|
1712
|
+
aptos.transaction.build.simple({
|
|
1713
|
+
sender: _this._account.address,
|
|
1714
|
+
data: transactionOrPayload.data,
|
|
1715
|
+
options: transactionOrPayload.options,
|
|
1716
|
+
withFeePayer: transactionOrPayload.withFeePayer
|
|
1717
|
+
})
|
|
1718
|
+
];
|
|
1719
|
+
case 6:
|
|
1720
|
+
transaction = _state.sent();
|
|
1721
|
+
return [
|
|
1722
|
+
4,
|
|
1723
|
+
(_this__wallet2 = _this._wallet) === null || _this__wallet2 === void 0 ? void 0 : _this__wallet2.features["aptos:signTransaction"].signTransaction(transaction, asFeePayer)
|
|
1724
|
+
];
|
|
1725
|
+
case 7:
|
|
1726
|
+
response2 = _state.sent();
|
|
1727
|
+
if (response2.status === UserResponseStatus.REJECTED) {
|
|
1728
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1729
|
+
}
|
|
1730
|
+
return [
|
|
1731
|
+
2,
|
|
1732
|
+
{
|
|
1733
|
+
authenticator: response2.args,
|
|
1734
|
+
rawTransaction: transaction.bcsToBytes()
|
|
1735
|
+
}
|
|
1736
|
+
];
|
|
1737
|
+
case 8:
|
|
1738
|
+
return [
|
|
1739
|
+
3,
|
|
1740
|
+
10
|
|
1741
|
+
];
|
|
1742
|
+
case 9:
|
|
1743
|
+
error = _state.sent();
|
|
1744
|
+
errMsg = generalizedErrorMessage(error);
|
|
1745
|
+
throw new WalletSignTransactionError(errMsg).message;
|
|
1746
|
+
case 10:
|
|
1747
|
+
return [
|
|
1748
|
+
2
|
|
1749
|
+
];
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
})();
|
|
1753
|
+
}
|
|
1754
|
+
},
|
|
1755
|
+
{
|
|
1756
|
+
key: "signMessage",
|
|
1757
|
+
value: /**
|
|
1758
|
+
* Sign a message (doesnt submit to chain).
|
|
1759
|
+
*
|
|
1760
|
+
* @param message - AptosSignMessageInput
|
|
1761
|
+
*
|
|
1762
|
+
* @return response from the wallet's signMessage function
|
|
1763
|
+
* @throws WalletSignMessageError
|
|
1764
|
+
*/ function signMessage(message) {
|
|
1765
|
+
var _this = this;
|
|
1766
|
+
return _async_to_generator(function() {
|
|
1767
|
+
var _this__wallet_features_aptossignMessage, _this__wallet, response, error, errMsg;
|
|
1768
|
+
return _ts_generator(this, function(_state) {
|
|
1769
|
+
switch(_state.label){
|
|
1770
|
+
case 0:
|
|
1771
|
+
_state.trys.push([
|
|
1772
|
+
0,
|
|
1773
|
+
2,
|
|
1774
|
+
,
|
|
1775
|
+
3
|
|
1776
|
+
]);
|
|
1777
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1778
|
+
_this.recordEvent("sign_message");
|
|
1779
|
+
return [
|
|
1780
|
+
4,
|
|
1781
|
+
(_this__wallet = _this._wallet) === null || _this__wallet === void 0 ? void 0 : (_this__wallet_features_aptossignMessage = _this__wallet.features["aptos:signMessage"]) === null || _this__wallet_features_aptossignMessage === void 0 ? void 0 : _this__wallet_features_aptossignMessage.signMessage(message)
|
|
1782
|
+
];
|
|
1783
|
+
case 1:
|
|
1784
|
+
response = _state.sent();
|
|
1785
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
1786
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
1787
|
+
}
|
|
1788
|
+
return [
|
|
1789
|
+
2,
|
|
1790
|
+
response.args
|
|
1791
|
+
];
|
|
1792
|
+
case 2:
|
|
1793
|
+
error = _state.sent();
|
|
1794
|
+
errMsg = generalizedErrorMessage(error);
|
|
1795
|
+
throw new WalletSignMessageError(errMsg).message;
|
|
1796
|
+
case 3:
|
|
1797
|
+
return [
|
|
1798
|
+
2
|
|
1799
|
+
];
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
})();
|
|
1803
|
+
}
|
|
1804
|
+
},
|
|
1805
|
+
{
|
|
1806
|
+
key: "submitTransaction",
|
|
1807
|
+
value: /**
|
|
1808
|
+
* Submits transaction to chain
|
|
1809
|
+
*
|
|
1810
|
+
* @param transaction - InputSubmitTransactionData
|
|
1811
|
+
* @returns PendingTransactionResponse
|
|
1812
|
+
*/ function submitTransaction(transaction) {
|
|
1813
|
+
var _this = this;
|
|
1814
|
+
return _async_to_generator(function() {
|
|
1815
|
+
var additionalSignersAuthenticators, transactionType, aptosConfig, aptos, multiAgentTxn, errMsg;
|
|
1816
|
+
return _ts_generator(this, function(_state) {
|
|
1817
|
+
try {
|
|
1818
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1819
|
+
additionalSignersAuthenticators = transaction.additionalSignersAuthenticators;
|
|
1820
|
+
transactionType = additionalSignersAuthenticators !== void 0 ? "multi-agent" : "simple";
|
|
1821
|
+
_this.recordEvent("submit_transaction", {
|
|
1822
|
+
transaction_type: transactionType
|
|
1823
|
+
});
|
|
1824
|
+
aptosConfig = getAptosConfig(_this._network, _this._dappConfig);
|
|
1825
|
+
aptos = new Aptos2(aptosConfig);
|
|
1826
|
+
if (additionalSignersAuthenticators !== void 0) {
|
|
1827
|
+
multiAgentTxn = _object_spread_props(_object_spread({}, transaction), {
|
|
1828
|
+
additionalSignersAuthenticators: additionalSignersAuthenticators
|
|
1829
|
+
});
|
|
1830
|
+
return [
|
|
1831
|
+
2,
|
|
1832
|
+
aptos.transaction.submit.multiAgent(multiAgentTxn)
|
|
1833
|
+
];
|
|
1834
|
+
} else {
|
|
1835
|
+
return [
|
|
1836
|
+
2,
|
|
1837
|
+
aptos.transaction.submit.simple(transaction)
|
|
1838
|
+
];
|
|
1839
|
+
}
|
|
1840
|
+
} catch (error) {
|
|
1841
|
+
errMsg = generalizedErrorMessage(error);
|
|
1842
|
+
throw new WalletSubmitTransactionError(errMsg).message;
|
|
1843
|
+
}
|
|
1844
|
+
return [
|
|
1845
|
+
2
|
|
1846
|
+
];
|
|
1847
|
+
});
|
|
1848
|
+
})();
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
key: "onAccountChange",
|
|
1853
|
+
value: /**
|
|
1854
|
+
Event for when account has changed on the wallet
|
|
1855
|
+
@return the new account info
|
|
1856
|
+
@throws WalletAccountChangeError
|
|
1857
|
+
*/ function onAccountChange() {
|
|
1858
|
+
var _this = this;
|
|
1859
|
+
return _async_to_generator(function() {
|
|
1860
|
+
var _this__wallet_features_aptosonAccountChange, error, errMsg;
|
|
1861
|
+
return _ts_generator(this, function(_state) {
|
|
1862
|
+
switch(_state.label){
|
|
1863
|
+
case 0:
|
|
1864
|
+
_state.trys.push([
|
|
1865
|
+
0,
|
|
1866
|
+
2,
|
|
1867
|
+
,
|
|
1868
|
+
3
|
|
1869
|
+
]);
|
|
1870
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1871
|
+
return [
|
|
1872
|
+
4,
|
|
1873
|
+
(_this__wallet_features_aptosonAccountChange = _this._wallet.features["aptos:onAccountChange"]) === null || _this__wallet_features_aptosonAccountChange === void 0 ? void 0 : _this__wallet_features_aptosonAccountChange.onAccountChange(/*#__PURE__*/ function() {
|
|
1874
|
+
var _ref = _async_to_generator(function(data) {
|
|
1875
|
+
return _ts_generator(this, function(_state) {
|
|
1876
|
+
switch(_state.label){
|
|
1877
|
+
case 0:
|
|
1878
|
+
_this.setAccount(data);
|
|
1879
|
+
return [
|
|
1880
|
+
4,
|
|
1881
|
+
_this.setAnsName()
|
|
1882
|
+
];
|
|
1883
|
+
case 1:
|
|
1884
|
+
_state.sent();
|
|
1885
|
+
_this.recordEvent("account_change");
|
|
1886
|
+
_this.emit("accountChange", _this._account);
|
|
1887
|
+
return [
|
|
1888
|
+
2
|
|
1889
|
+
];
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
});
|
|
1893
|
+
return function(data) {
|
|
1894
|
+
return _ref.apply(this, arguments);
|
|
1895
|
+
};
|
|
1896
|
+
}())
|
|
1897
|
+
];
|
|
1898
|
+
case 1:
|
|
1899
|
+
_state.sent();
|
|
1900
|
+
return [
|
|
1901
|
+
3,
|
|
1902
|
+
3
|
|
1903
|
+
];
|
|
1904
|
+
case 2:
|
|
1905
|
+
error = _state.sent();
|
|
1906
|
+
errMsg = generalizedErrorMessage(error);
|
|
1907
|
+
throw new WalletAccountChangeError(errMsg).message;
|
|
1908
|
+
case 3:
|
|
1909
|
+
return [
|
|
1910
|
+
2
|
|
1911
|
+
];
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
})();
|
|
1915
|
+
}
|
|
1916
|
+
},
|
|
1917
|
+
{
|
|
1918
|
+
key: "onNetworkChange",
|
|
1919
|
+
value: /**
|
|
1920
|
+
Event for when network has changed on the wallet
|
|
1921
|
+
@return the new network info
|
|
1922
|
+
@throws WalletNetworkChangeError
|
|
1923
|
+
*/ function onNetworkChange() {
|
|
1924
|
+
var _this = this;
|
|
1925
|
+
return _async_to_generator(function() {
|
|
1926
|
+
var _this__wallet_features_aptosonNetworkChange, error, errMsg;
|
|
1927
|
+
return _ts_generator(this, function(_state) {
|
|
1928
|
+
switch(_state.label){
|
|
1929
|
+
case 0:
|
|
1930
|
+
_state.trys.push([
|
|
1931
|
+
0,
|
|
1932
|
+
2,
|
|
1933
|
+
,
|
|
1934
|
+
3
|
|
1935
|
+
]);
|
|
1936
|
+
_this.ensureWalletExists(_this._wallet);
|
|
1937
|
+
return [
|
|
1938
|
+
4,
|
|
1939
|
+
(_this__wallet_features_aptosonNetworkChange = _this._wallet.features["aptos:onNetworkChange"]) === null || _this__wallet_features_aptosonNetworkChange === void 0 ? void 0 : _this__wallet_features_aptosonNetworkChange.onNetworkChange(/*#__PURE__*/ function() {
|
|
1940
|
+
var _ref = _async_to_generator(function(data) {
|
|
1941
|
+
return _ts_generator(this, function(_state) {
|
|
1942
|
+
switch(_state.label){
|
|
1943
|
+
case 0:
|
|
1944
|
+
_this.setNetwork(data);
|
|
1945
|
+
return [
|
|
1946
|
+
4,
|
|
1947
|
+
_this.setAnsName()
|
|
1948
|
+
];
|
|
1949
|
+
case 1:
|
|
1950
|
+
_state.sent();
|
|
1951
|
+
_this.emit("networkChange", _this._network);
|
|
1952
|
+
return [
|
|
1953
|
+
2
|
|
1954
|
+
];
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
});
|
|
1958
|
+
return function(data) {
|
|
1959
|
+
return _ref.apply(this, arguments);
|
|
1960
|
+
};
|
|
1961
|
+
}())
|
|
1962
|
+
];
|
|
1963
|
+
case 1:
|
|
1964
|
+
_state.sent();
|
|
1965
|
+
return [
|
|
1966
|
+
3,
|
|
1967
|
+
3
|
|
1968
|
+
];
|
|
1969
|
+
case 2:
|
|
1970
|
+
error = _state.sent();
|
|
1971
|
+
errMsg = generalizedErrorMessage(error);
|
|
1972
|
+
throw new WalletNetworkChangeError(errMsg).message;
|
|
1973
|
+
case 3:
|
|
1974
|
+
return [
|
|
1975
|
+
2
|
|
1976
|
+
];
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
})();
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
{
|
|
1983
|
+
key: "changeNetwork",
|
|
1984
|
+
value: /**
|
|
1985
|
+
* Sends a change network request to the wallet to change the connected network
|
|
1986
|
+
*
|
|
1987
|
+
* @param network - Network
|
|
1988
|
+
* @returns AptosChangeNetworkOutput
|
|
1989
|
+
*/ function changeNetwork(network) {
|
|
1990
|
+
var _this = this;
|
|
1991
|
+
return _async_to_generator(function() {
|
|
1992
|
+
var _this__network, chainId, _tmp, networkInfo, response, error, errMsg;
|
|
1993
|
+
return _ts_generator(this, function(_state) {
|
|
1994
|
+
switch(_state.label){
|
|
1995
|
+
case 0:
|
|
1996
|
+
_state.trys.push([
|
|
1997
|
+
0,
|
|
1998
|
+
6,
|
|
1999
|
+
,
|
|
2000
|
+
7
|
|
2001
|
+
]);
|
|
2002
|
+
_this.ensureWalletExists(_this._wallet);
|
|
2003
|
+
_this.recordEvent("change_network_request", {
|
|
2004
|
+
from: (_this__network = _this._network) === null || _this__network === void 0 ? void 0 : _this__network.name,
|
|
2005
|
+
to: network
|
|
2006
|
+
});
|
|
2007
|
+
if (!(network === Network3.DEVNET)) return [
|
|
2008
|
+
3,
|
|
2009
|
+
2
|
|
2010
|
+
];
|
|
2011
|
+
return [
|
|
2012
|
+
4,
|
|
2013
|
+
fetchDevnetChainId()
|
|
2014
|
+
];
|
|
2015
|
+
case 1:
|
|
2016
|
+
_tmp = _state.sent();
|
|
2017
|
+
return [
|
|
2018
|
+
3,
|
|
2019
|
+
3
|
|
2020
|
+
];
|
|
2021
|
+
case 2:
|
|
2022
|
+
_tmp = NetworkToChainId[network];
|
|
2023
|
+
_state.label = 3;
|
|
2024
|
+
case 3:
|
|
2025
|
+
chainId = _tmp;
|
|
2026
|
+
networkInfo = {
|
|
2027
|
+
name: network,
|
|
2028
|
+
chainId: chainId
|
|
2029
|
+
};
|
|
2030
|
+
if (!_this._wallet.features["aptos:changeNetwork"]) return [
|
|
2031
|
+
3,
|
|
2032
|
+
5
|
|
2033
|
+
];
|
|
2034
|
+
return [
|
|
2035
|
+
4,
|
|
2036
|
+
_this._wallet.features["aptos:changeNetwork"].changeNetwork(networkInfo)
|
|
2037
|
+
];
|
|
2038
|
+
case 4:
|
|
2039
|
+
response = _state.sent();
|
|
2040
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
2041
|
+
throw new WalletConnectionError("User has rejected the request").message;
|
|
2042
|
+
}
|
|
2043
|
+
return [
|
|
2044
|
+
2,
|
|
2045
|
+
response.args
|
|
2046
|
+
];
|
|
2047
|
+
case 5:
|
|
2048
|
+
throw new WalletChangeNetworkError("".concat(_this._wallet.name, " does not support changing network request")).message;
|
|
2049
|
+
case 6:
|
|
2050
|
+
error = _state.sent();
|
|
2051
|
+
errMsg = generalizedErrorMessage(error);
|
|
2052
|
+
throw new WalletChangeNetworkError(errMsg).message;
|
|
2053
|
+
case 7:
|
|
2054
|
+
return [
|
|
2055
|
+
2
|
|
2056
|
+
];
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
})();
|
|
2060
|
+
}
|
|
2061
|
+
},
|
|
2062
|
+
{
|
|
2063
|
+
key: "signMessageAndVerify",
|
|
2064
|
+
value: /**
|
|
2065
|
+
* Signs a message and verifies the signer
|
|
2066
|
+
* @param message - AptosSignMessageInput
|
|
2067
|
+
* @returns boolean
|
|
2068
|
+
*/ function signMessageAndVerify(message) {
|
|
2069
|
+
var _this = this;
|
|
2070
|
+
return _async_to_generator(function() {
|
|
2071
|
+
var response, aptosConfig, signingMessage, error, errMsg;
|
|
2072
|
+
return _ts_generator(this, function(_state) {
|
|
2073
|
+
switch(_state.label){
|
|
2074
|
+
case 0:
|
|
2075
|
+
_state.trys.push([
|
|
2076
|
+
0,
|
|
2077
|
+
4,
|
|
2078
|
+
,
|
|
2079
|
+
5
|
|
2080
|
+
]);
|
|
2081
|
+
_this.ensureWalletExists(_this._wallet);
|
|
2082
|
+
_this.ensureAccountExists(_this._account);
|
|
2083
|
+
_this.recordEvent("sign_message_and_verify");
|
|
2084
|
+
return [
|
|
2085
|
+
4,
|
|
2086
|
+
_this._wallet.features["aptos:signMessage"].signMessage(message)
|
|
2087
|
+
];
|
|
2088
|
+
case 1:
|
|
2089
|
+
response = _state.sent();
|
|
2090
|
+
if (response.status === UserResponseStatus.REJECTED) {
|
|
2091
|
+
throw new WalletConnectionError("Failed to sign a message").message;
|
|
2092
|
+
}
|
|
2093
|
+
aptosConfig = getAptosConfig(_this._network, _this._dappConfig);
|
|
2094
|
+
signingMessage = new TextEncoder().encode(response.args.fullMessage);
|
|
2095
|
+
if (!("verifySignatureAsync" in _this._account.publicKey)) return [
|
|
2096
|
+
3,
|
|
2097
|
+
3
|
|
2098
|
+
];
|
|
2099
|
+
return [
|
|
2100
|
+
4,
|
|
2101
|
+
_this._account.publicKey.verifySignatureAsync({
|
|
2102
|
+
aptosConfig: aptosConfig,
|
|
2103
|
+
message: signingMessage,
|
|
2104
|
+
signature: response.args.signature,
|
|
2105
|
+
options: {
|
|
2106
|
+
throwErrorWithReason: true
|
|
2107
|
+
}
|
|
2108
|
+
})
|
|
2109
|
+
];
|
|
2110
|
+
case 2:
|
|
2111
|
+
return [
|
|
2112
|
+
2,
|
|
2113
|
+
_state.sent()
|
|
2114
|
+
];
|
|
2115
|
+
case 3:
|
|
2116
|
+
return [
|
|
2117
|
+
2,
|
|
2118
|
+
_this._account.publicKey.verifySignature({
|
|
2119
|
+
message: signingMessage,
|
|
2120
|
+
signature: response.args.signature
|
|
2121
|
+
})
|
|
2122
|
+
];
|
|
2123
|
+
case 4:
|
|
2124
|
+
error = _state.sent();
|
|
2125
|
+
errMsg = generalizedErrorMessage(error);
|
|
2126
|
+
throw new WalletSignMessageAndVerifyError(errMsg).message;
|
|
2127
|
+
case 5:
|
|
2128
|
+
return [
|
|
2129
|
+
2
|
|
2130
|
+
];
|
|
2131
|
+
}
|
|
2132
|
+
});
|
|
2133
|
+
})();
|
|
2134
|
+
}
|
|
950
2135
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
`${this._wallet.name} does not support changing network request`
|
|
955
|
-
).message;
|
|
956
|
-
} catch (error) {
|
|
957
|
-
const errMsg = generalizedErrorMessage(error);
|
|
958
|
-
throw new WalletChangeNetworkError(errMsg).message;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
async signMessageAndVerify(message) {
|
|
962
|
-
try {
|
|
963
|
-
this.ensureWalletExists(this._wallet);
|
|
964
|
-
this.ensureAccountExists(this._account);
|
|
965
|
-
this.recordEvent("sign_message_and_verify");
|
|
966
|
-
const response = await this._wallet.features["aptos:signMessage"].signMessage(message);
|
|
967
|
-
if (response.status === UserResponseStatus.REJECTED) {
|
|
968
|
-
throw new WalletConnectionError("Failed to sign a message").message;
|
|
969
|
-
}
|
|
970
|
-
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
971
|
-
const signingMessage = new TextEncoder().encode(response.args.fullMessage);
|
|
972
|
-
if ("verifySignatureAsync" in this._account.publicKey) {
|
|
973
|
-
return await this._account.publicKey.verifySignatureAsync({
|
|
974
|
-
aptosConfig,
|
|
975
|
-
message: signingMessage,
|
|
976
|
-
signature: response.args.signature,
|
|
977
|
-
options: { throwErrorWithReason: true }
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
return this._account.publicKey.verifySignature({
|
|
981
|
-
message: signingMessage,
|
|
982
|
-
signature: response.args.signature
|
|
983
|
-
});
|
|
984
|
-
} catch (error) {
|
|
985
|
-
const errMsg = generalizedErrorMessage(error);
|
|
986
|
-
throw new WalletSignMessageAndVerifyError(errMsg).message;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
|
|
2136
|
+
]);
|
|
2137
|
+
return WalletCore;
|
|
2138
|
+
}(EventEmitter);
|
|
991
2139
|
// src/index.ts
|
|
992
2140
|
if (typeof window !== "undefined") {
|
|
993
|
-
|
|
2141
|
+
window.WALLET_ADAPTER_CORE_VERSION = WALLET_ADAPTER_CORE_VERSION;
|
|
994
2142
|
}
|
|
995
|
-
export {
|
|
996
|
-
APTOS_CONNECT_ACCOUNT_URL,
|
|
997
|
-
APTOS_CONNECT_BASE_URL,
|
|
998
|
-
ChainIdToAnsSupportedNetworkMap,
|
|
999
|
-
NetworkName,
|
|
1000
|
-
WalletCore,
|
|
1001
|
-
WalletReadyState,
|
|
1002
|
-
aptosStandardSupportedWalletList,
|
|
1003
|
-
convertNetwork,
|
|
1004
|
-
fetchDevnetChainId,
|
|
1005
|
-
generalizedErrorMessage,
|
|
1006
|
-
getAptosConfig,
|
|
1007
|
-
getAptosConnectWallets,
|
|
1008
|
-
getLocalStorage,
|
|
1009
|
-
getSDKWallets,
|
|
1010
|
-
groupAndSortWallets,
|
|
1011
|
-
handlePublishPackageTransaction,
|
|
1012
|
-
isAptosConnectWallet,
|
|
1013
|
-
isAptosLiveNetwork,
|
|
1014
|
-
isAptosNetwork,
|
|
1015
|
-
isInAppBrowser,
|
|
1016
|
-
isInstallRequired,
|
|
1017
|
-
isInstalledOrLoadable,
|
|
1018
|
-
isMobile,
|
|
1019
|
-
isRedirectable,
|
|
1020
|
-
partitionWallets,
|
|
1021
|
-
removeLocalStorage,
|
|
1022
|
-
setLocalStorage,
|
|
1023
|
-
truncateAddress
|
|
1024
|
-
};
|
|
2143
|
+
export { APTOS_CONNECT_ACCOUNT_URL, APTOS_CONNECT_BASE_URL, ChainIdToAnsSupportedNetworkMap, NetworkName, WalletCore, WalletReadyState, aptosStandardSupportedWalletList, convertNetwork, fetchDevnetChainId, generalizedErrorMessage, getAptosConfig, getAptosConnectWallets, getLocalStorage, getSDKWallets, groupAndSortWallets, handlePublishPackageTransaction, isAptosConnectWallet, isAptosLiveNetwork, isAptosNetwork, isInAppBrowser, isInstallRequired, isInstalledOrLoadable, isMobile, isRedirectable, partitionWallets, removeLocalStorage, setLocalStorage, truncateAddress };
|
|
1025
2144
|
//# sourceMappingURL=index.mjs.map
|