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