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