@rango-dev/provider-safepal 0.1.11-next.69

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Network, ProviderConnectResult } from '@rango-dev/wallets-shared';
2
+ declare type Provider = Map<Network, any>;
3
+ export declare function safepal(): Map<any, any> | null;
4
+ export declare function getNonEvmAccounts(instances: Provider): Promise<ProviderConnectResult[]>;
5
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Network, WalletType, CanSwitchNetwork, Connect, Subscribe, SwitchNetwork, WalletSigners, BlockchainMeta, WalletInfo } from '@rango-dev/wallets-shared';
2
+ import { safepal as safepal_instance } from './helpers';
3
+ export declare const config: {
4
+ type: WalletType;
5
+ defaultNetwork: Network;
6
+ };
7
+ export declare const getInstance: typeof safepal_instance;
8
+ export declare const connect: Connect;
9
+ export declare const subscribe: Subscribe;
10
+ export declare const switchNetwork: SwitchNetwork;
11
+ export declare const canSwitchNetworkTo: CanSwitchNetwork;
12
+ export declare const getSigners: (provider: any) => WalletSigners;
13
+ export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./provider-safepal.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./provider-safepal.cjs.development.js')
8
+ }
@@ -0,0 +1,486 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var walletsShared = require('@rango-dev/wallets-shared');
6
+
7
+ function _regeneratorRuntime() {
8
+ _regeneratorRuntime = function () {
9
+ return exports;
10
+ };
11
+ var exports = {},
12
+ Op = Object.prototype,
13
+ hasOwn = Op.hasOwnProperty,
14
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
15
+ obj[key] = desc.value;
16
+ },
17
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
18
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
19
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
20
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
21
+ function define(obj, key, value) {
22
+ return Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: !0,
25
+ configurable: !0,
26
+ writable: !0
27
+ }), obj[key];
28
+ }
29
+ try {
30
+ define({}, "");
31
+ } catch (err) {
32
+ define = function (obj, key, value) {
33
+ return obj[key] = value;
34
+ };
35
+ }
36
+ function wrap(innerFn, outerFn, self, tryLocsList) {
37
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
38
+ generator = Object.create(protoGenerator.prototype),
39
+ context = new Context(tryLocsList || []);
40
+ return defineProperty(generator, "_invoke", {
41
+ value: makeInvokeMethod(innerFn, self, context)
42
+ }), generator;
43
+ }
44
+ function tryCatch(fn, obj, arg) {
45
+ try {
46
+ return {
47
+ type: "normal",
48
+ arg: fn.call(obj, arg)
49
+ };
50
+ } catch (err) {
51
+ return {
52
+ type: "throw",
53
+ arg: err
54
+ };
55
+ }
56
+ }
57
+ exports.wrap = wrap;
58
+ var ContinueSentinel = {};
59
+ function Generator() {}
60
+ function GeneratorFunction() {}
61
+ function GeneratorFunctionPrototype() {}
62
+ var IteratorPrototype = {};
63
+ define(IteratorPrototype, iteratorSymbol, function () {
64
+ return this;
65
+ });
66
+ var getProto = Object.getPrototypeOf,
67
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
68
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
69
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
70
+ function defineIteratorMethods(prototype) {
71
+ ["next", "throw", "return"].forEach(function (method) {
72
+ define(prototype, method, function (arg) {
73
+ return this._invoke(method, arg);
74
+ });
75
+ });
76
+ }
77
+ function AsyncIterator(generator, PromiseImpl) {
78
+ function invoke(method, arg, resolve, reject) {
79
+ var record = tryCatch(generator[method], generator, arg);
80
+ if ("throw" !== record.type) {
81
+ var result = record.arg,
82
+ value = result.value;
83
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
84
+ invoke("next", value, resolve, reject);
85
+ }, function (err) {
86
+ invoke("throw", err, resolve, reject);
87
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
88
+ result.value = unwrapped, resolve(result);
89
+ }, function (error) {
90
+ return invoke("throw", error, resolve, reject);
91
+ });
92
+ }
93
+ reject(record.arg);
94
+ }
95
+ var previousPromise;
96
+ defineProperty(this, "_invoke", {
97
+ value: function (method, arg) {
98
+ function callInvokeWithMethodAndArg() {
99
+ return new PromiseImpl(function (resolve, reject) {
100
+ invoke(method, arg, resolve, reject);
101
+ });
102
+ }
103
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
104
+ }
105
+ });
106
+ }
107
+ function makeInvokeMethod(innerFn, self, context) {
108
+ var state = "suspendedStart";
109
+ return function (method, arg) {
110
+ if ("executing" === state) throw new Error("Generator is already running");
111
+ if ("completed" === state) {
112
+ if ("throw" === method) throw arg;
113
+ return doneResult();
114
+ }
115
+ for (context.method = method, context.arg = arg;;) {
116
+ var delegate = context.delegate;
117
+ if (delegate) {
118
+ var delegateResult = maybeInvokeDelegate(delegate, context);
119
+ if (delegateResult) {
120
+ if (delegateResult === ContinueSentinel) continue;
121
+ return delegateResult;
122
+ }
123
+ }
124
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
125
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
126
+ context.dispatchException(context.arg);
127
+ } else "return" === context.method && context.abrupt("return", context.arg);
128
+ state = "executing";
129
+ var record = tryCatch(innerFn, self, context);
130
+ if ("normal" === record.type) {
131
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
132
+ return {
133
+ value: record.arg,
134
+ done: context.done
135
+ };
136
+ }
137
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
138
+ }
139
+ };
140
+ }
141
+ function maybeInvokeDelegate(delegate, context) {
142
+ var methodName = context.method,
143
+ method = delegate.iterator[methodName];
144
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
145
+ var record = tryCatch(method, delegate.iterator, context.arg);
146
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
147
+ var info = record.arg;
148
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
149
+ }
150
+ function pushTryEntry(locs) {
151
+ var entry = {
152
+ tryLoc: locs[0]
153
+ };
154
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
155
+ }
156
+ function resetTryEntry(entry) {
157
+ var record = entry.completion || {};
158
+ record.type = "normal", delete record.arg, entry.completion = record;
159
+ }
160
+ function Context(tryLocsList) {
161
+ this.tryEntries = [{
162
+ tryLoc: "root"
163
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
164
+ }
165
+ function values(iterable) {
166
+ if (iterable) {
167
+ var iteratorMethod = iterable[iteratorSymbol];
168
+ if (iteratorMethod) return iteratorMethod.call(iterable);
169
+ if ("function" == typeof iterable.next) return iterable;
170
+ if (!isNaN(iterable.length)) {
171
+ var i = -1,
172
+ next = function next() {
173
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
174
+ return next.value = undefined, next.done = !0, next;
175
+ };
176
+ return next.next = next;
177
+ }
178
+ }
179
+ return {
180
+ next: doneResult
181
+ };
182
+ }
183
+ function doneResult() {
184
+ return {
185
+ value: undefined,
186
+ done: !0
187
+ };
188
+ }
189
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
190
+ value: GeneratorFunctionPrototype,
191
+ configurable: !0
192
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
193
+ value: GeneratorFunction,
194
+ configurable: !0
195
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
196
+ var ctor = "function" == typeof genFun && genFun.constructor;
197
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
198
+ }, exports.mark = function (genFun) {
199
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
200
+ }, exports.awrap = function (arg) {
201
+ return {
202
+ __await: arg
203
+ };
204
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
205
+ return this;
206
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
207
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
208
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
209
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
210
+ return result.done ? result.value : iter.next();
211
+ });
212
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
213
+ return this;
214
+ }), define(Gp, "toString", function () {
215
+ return "[object Generator]";
216
+ }), exports.keys = function (val) {
217
+ var object = Object(val),
218
+ keys = [];
219
+ for (var key in object) keys.push(key);
220
+ return keys.reverse(), function next() {
221
+ for (; keys.length;) {
222
+ var key = keys.pop();
223
+ if (key in object) return next.value = key, next.done = !1, next;
224
+ }
225
+ return next.done = !0, next;
226
+ };
227
+ }, exports.values = values, Context.prototype = {
228
+ constructor: Context,
229
+ reset: function (skipTempReset) {
230
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
231
+ },
232
+ stop: function () {
233
+ this.done = !0;
234
+ var rootRecord = this.tryEntries[0].completion;
235
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
236
+ return this.rval;
237
+ },
238
+ dispatchException: function (exception) {
239
+ if (this.done) throw exception;
240
+ var context = this;
241
+ function handle(loc, caught) {
242
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
243
+ }
244
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
245
+ var entry = this.tryEntries[i],
246
+ record = entry.completion;
247
+ if ("root" === entry.tryLoc) return handle("end");
248
+ if (entry.tryLoc <= this.prev) {
249
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
250
+ hasFinally = hasOwn.call(entry, "finallyLoc");
251
+ if (hasCatch && hasFinally) {
252
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
253
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
254
+ } else if (hasCatch) {
255
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
256
+ } else {
257
+ if (!hasFinally) throw new Error("try statement without catch or finally");
258
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
259
+ }
260
+ }
261
+ }
262
+ },
263
+ abrupt: function (type, arg) {
264
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
265
+ var entry = this.tryEntries[i];
266
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
267
+ var finallyEntry = entry;
268
+ break;
269
+ }
270
+ }
271
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
272
+ var record = finallyEntry ? finallyEntry.completion : {};
273
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
274
+ },
275
+ complete: function (record, afterLoc) {
276
+ if ("throw" === record.type) throw record.arg;
277
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
278
+ },
279
+ finish: function (finallyLoc) {
280
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
281
+ var entry = this.tryEntries[i];
282
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
283
+ }
284
+ },
285
+ catch: function (tryLoc) {
286
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
287
+ var entry = this.tryEntries[i];
288
+ if (entry.tryLoc === tryLoc) {
289
+ var record = entry.completion;
290
+ if ("throw" === record.type) {
291
+ var thrown = record.arg;
292
+ resetTryEntry(entry);
293
+ }
294
+ return thrown;
295
+ }
296
+ }
297
+ throw new Error("illegal catch attempt");
298
+ },
299
+ delegateYield: function (iterable, resultName, nextLoc) {
300
+ return this.delegate = {
301
+ iterator: values(iterable),
302
+ resultName: resultName,
303
+ nextLoc: nextLoc
304
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
305
+ }
306
+ }, exports;
307
+ }
308
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
309
+ try {
310
+ var info = gen[key](arg);
311
+ var value = info.value;
312
+ } catch (error) {
313
+ reject(error);
314
+ return;
315
+ }
316
+ if (info.done) {
317
+ resolve(value);
318
+ } else {
319
+ Promise.resolve(value).then(_next, _throw);
320
+ }
321
+ }
322
+ function _asyncToGenerator(fn) {
323
+ return function () {
324
+ var self = this,
325
+ args = arguments;
326
+ return new Promise(function (resolve, reject) {
327
+ var gen = fn.apply(self, args);
328
+ function _next(value) {
329
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
330
+ }
331
+ function _throw(err) {
332
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
333
+ }
334
+ _next(undefined);
335
+ });
336
+ };
337
+ }
338
+ function _extends() {
339
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
340
+ for (var i = 1; i < arguments.length; i++) {
341
+ var source = arguments[i];
342
+ for (var key in source) {
343
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
344
+ target[key] = source[key];
345
+ }
346
+ }
347
+ }
348
+ return target;
349
+ };
350
+ return _extends.apply(this, arguments);
351
+ }
352
+
353
+ function safepal() {
354
+ var instances = new Map();
355
+ var _window = window,
356
+ isSafePal = _window.isSafePal,
357
+ safepal = _window.safepal,
358
+ safepalProvider = _window.safepalProvider;
359
+ if (!isSafePal) return null;
360
+ if (!!safepal && safepal.isSafePalWallet) instances.set(walletsShared.Network.SOLANA, safepal);
361
+ if (safepalProvider && safepalProvider) instances.set(walletsShared.Network.ETHEREUM, safepalProvider);
362
+ if (instances.size === 0) return null;
363
+ return instances;
364
+ }
365
+ function getNonEvmAccounts(_x) {
366
+ return _getNonEvmAccounts.apply(this, arguments);
367
+ }
368
+ function _getNonEvmAccounts() {
369
+ _getNonEvmAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(instances) {
370
+ var solanaInstance, results, solanaResponse, solanaAccounts;
371
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
372
+ while (1) switch (_context.prev = _context.next) {
373
+ case 0:
374
+ solanaInstance = instances.get(walletsShared.Network.SOLANA);
375
+ results = [];
376
+ if (!solanaInstance) {
377
+ _context.next = 8;
378
+ break;
379
+ }
380
+ _context.next = 5;
381
+ return solanaInstance.connect();
382
+ case 5:
383
+ solanaResponse = _context.sent;
384
+ solanaAccounts = solanaResponse.publicKey.toString();
385
+ results.push({
386
+ accounts: [solanaAccounts],
387
+ chainId: walletsShared.Network.SOLANA
388
+ });
389
+ case 8:
390
+ return _context.abrupt("return", results);
391
+ case 9:
392
+ case "end":
393
+ return _context.stop();
394
+ }
395
+ }, _callee);
396
+ }));
397
+ return _getNonEvmAccounts.apply(this, arguments);
398
+ }
399
+
400
+ function getSigners(provider) {
401
+ return walletsShared.defaultSigners({
402
+ provider: provider,
403
+ walletType: walletsShared.WalletType.SAFEPAL,
404
+ supportEvm: true,
405
+ supportSolana: true
406
+ });
407
+ }
408
+
409
+ var WALLET = walletsShared.WalletType.SAFEPAL;
410
+ var config = {
411
+ type: WALLET,
412
+ defaultNetwork: walletsShared.Network.ETHEREUM
413
+ };
414
+ var getInstance = safepal;
415
+ var connect = /*#__PURE__*/function () {
416
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
417
+ var instance, meta, ethInstance, results, evmResult, nonEvmResults;
418
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
419
+ while (1) switch (_context.prev = _context.next) {
420
+ case 0:
421
+ instance = _ref.instance, meta = _ref.meta;
422
+ ethInstance = walletsShared.chooseInstance(instance, meta, walletsShared.Network.ETHEREUM);
423
+ results = [];
424
+ if (!ethInstance) {
425
+ _context.next = 8;
426
+ break;
427
+ }
428
+ _context.next = 6;
429
+ return walletsShared.getEvmAccounts(ethInstance);
430
+ case 6:
431
+ evmResult = _context.sent;
432
+ results.push(evmResult);
433
+ case 8:
434
+ _context.next = 10;
435
+ return getNonEvmAccounts(instance);
436
+ case 10:
437
+ nonEvmResults = _context.sent;
438
+ results = [].concat(results, nonEvmResults);
439
+ return _context.abrupt("return", results);
440
+ case 13:
441
+ case "end":
442
+ return _context.stop();
443
+ }
444
+ }, _callee);
445
+ }));
446
+ return function connect(_x) {
447
+ return _ref2.apply(this, arguments);
448
+ };
449
+ }();
450
+ var subscribe = function subscribe(options) {
451
+ var ethInstance = walletsShared.chooseInstance(options.instance, options.meta, walletsShared.Network.ETHEREUM);
452
+ if (ethInstance) {
453
+ walletsShared.subscribeToEvm(_extends({}, options, {
454
+ instance: ethInstance
455
+ }));
456
+ }
457
+ };
458
+ var switchNetwork = walletsShared.switchNetworkForEvm;
459
+ var canSwitchNetworkTo = walletsShared.canSwitchNetworkToEvm;
460
+ var getSigners$1 = getSigners;
461
+ var getWalletInfo = function getWalletInfo(allBlockChains) {
462
+ var evms = walletsShared.evmBlockchains(allBlockChains);
463
+ var solana = walletsShared.solanaBlockchain(allBlockChains);
464
+ return {
465
+ name: 'SafePal',
466
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',
467
+ installLink: {
468
+ CHROME: 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
469
+ BRAVE: 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
470
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',
471
+ DEFAULT: 'https://www.safepal.com/download'
472
+ },
473
+ color: '#4A21EF',
474
+ supportedChains: [].concat(evms, solana)
475
+ };
476
+ };
477
+
478
+ exports.canSwitchNetworkTo = canSwitchNetworkTo;
479
+ exports.config = config;
480
+ exports.connect = connect;
481
+ exports.getInstance = getInstance;
482
+ exports.getSigners = getSigners$1;
483
+ exports.getWalletInfo = getWalletInfo;
484
+ exports.subscribe = subscribe;
485
+ exports.switchNetwork = switchNetwork;
486
+ //# sourceMappingURL=provider-safepal.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-safepal.cjs.development.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["import { Network, ProviderConnectResult } from '@rango-dev/wallets-shared';\n\ntype Provider = Map<Network, any>;\n\nexport function safepal() {\n const instances = new Map();\n const { isSafePal, safepal, safepalProvider } = window;\n\n if (!isSafePal) return null;\n\n if (!!safepal && safepal.isSafePalWallet)\n instances.set(Network.SOLANA, safepal);\n\n if (safepalProvider && safepalProvider)\n instances.set(Network.ETHEREUM, safepalProvider);\n\n if (instances.size === 0) return null;\n\n return instances;\n}\n\nexport async function getNonEvmAccounts(\n instances: Provider\n): Promise<ProviderConnectResult[]> {\n const solanaInstance = instances.get(Network.SOLANA);\n const results: ProviderConnectResult[] = [];\n\n if (!!solanaInstance) {\n const solanaResponse = await solanaInstance.connect();\n\n const solanaAccounts: string = solanaResponse.publicKey.toString();\n\n results.push({\n accounts: [solanaAccounts],\n chainId: Network.SOLANA,\n });\n }\n\n return results;\n}\n","import {\n WalletType,\n WalletSigners,\n defaultSigners,\n} from '@rango-dev/wallets-shared';\n\nexport default function getSigners(provider: any): WalletSigners {\n return defaultSigners({\n provider,\n walletType: WalletType.SAFEPAL,\n supportEvm: true,\n supportSolana: true,\n });\n}\n","import {\n Network,\n WalletType,\n CanSwitchNetwork,\n Connect,\n ProviderConnectResult,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n chooseInstance,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n BlockchainMeta,\n WalletInfo,\n evmBlockchains,\n solanaBlockchain,\n} from '@rango-dev/wallets-shared';\nimport { getNonEvmAccounts, safepal as safepal_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.SAFEPAL;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.ETHEREUM,\n};\n\nexport const getInstance = safepal_instance;\nexport const connect: Connect = async ({ instance, meta }) => {\n const ethInstance = chooseInstance(instance, meta, Network.ETHEREUM);\n\n let results: ProviderConnectResult[] = [];\n\n if (ethInstance) {\n const evmResult = await getEvmAccounts(ethInstance);\n results.push(evmResult);\n }\n\n const nonEvmResults = await getNonEvmAccounts(instance);\n results = [...results, ...nonEvmResults];\n\n return results;\n};\n\nexport const subscribe: Subscribe = (options) => {\n const ethInstance = chooseInstance(\n options.instance,\n options.meta,\n Network.ETHEREUM\n );\n\n if (ethInstance) {\n subscribeToEvm({ ...options, instance: ethInstance });\n }\n};\n\nexport const switchNetwork: SwitchNetwork = switchNetworkForEvm;\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm;\n\nexport const getSigners: (provider: any) => WalletSigners = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const evms = evmBlockchains(allBlockChains);\n const solana = solanaBlockchain(allBlockChains);\n return {\n name: 'SafePal',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n FIREFOX:\n 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',\n DEFAULT: 'https://www.safepal.com/download',\n },\n color: '#4A21EF',\n supportedChains: [...evms, ...solana],\n };\n};\n"],"names":["safepal","instances","Map","window","isSafePal","safepalProvider","isSafePalWallet","set","Network","SOLANA","ETHEREUM","size","getNonEvmAccounts","solanaInstance","get","results","connect","solanaResponse","solanaAccounts","publicKey","toString","push","accounts","chainId","getSigners","provider","defaultSigners","walletType","WalletType","SAFEPAL","supportEvm","supportSolana","WALLET","config","type","defaultNetwork","getInstance","safepal_instance","instance","meta","ethInstance","chooseInstance","getEvmAccounts","evmResult","nonEvmResults","subscribe","options","subscribeToEvm","switchNetwork","switchNetworkForEvm","canSwitchNetworkTo","canSwitchNetworkToEvm","signer","getWalletInfo","allBlockChains","evms","evmBlockchains","solana","solanaBlockchain","name","img","installLink","CHROME","BRAVE","FIREFOX","DEFAULT","color","supportedChains"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@rango-dev/wallets-shared");function e(){e=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new N(n||[]);return o(a,"_invoke",{value:b(t,r,i)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function v(){}function d(){}var y={};s(y,i,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(S([])));w&&w!==r&&n.call(w,i)&&(y=w);var m=d.prototype=p.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){var r;o(this,"_invoke",{value:function(o,a){function i(){return new e((function(r,i){!function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}(o,a,r,i)}))}return r=r?r.then(i,i):i()}})}function b(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=L(i,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function L(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return v.prototype=d,o(m,"constructor",{value:d,configurable:!0}),o(d,"constructor",{value:v,configurable:!0}),v.displayName=s(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,u,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},x(E.prototype),s(E.prototype,c,(function(){return this})),t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(l(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},x(m),s(m,u,"Generator"),s(m,i,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=S,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function r(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,a){var i=t.apply(e,n);function c(t){r(i,o,a,c,u,"next",t)}function u(t){r(i,o,a,c,u,"throw",t)}c(void 0)}))}}function o(){return(o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function a(t){return i.apply(this,arguments)}function i(){return(i=n(e().mark((function r(n){var o,a,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.get(t.Network.SOLANA),a=[],!o){e.next=8;break}return e.next=5,o.connect();case 5:i=e.sent.publicKey.toString(),a.push({accounts:[i],chainId:t.Network.SOLANA});case 8:return e.abrupt("return",a);case 9:case"end":return e.stop()}}),r)})))).apply(this,arguments)}var c={type:t.WalletType.SAFEPAL,defaultNetwork:t.Network.ETHEREUM},u=function(){var r=n(e().mark((function r(n){var o,i,c;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.chooseInstance(o=n.instance,n.meta,t.Network.ETHEREUM),c=[],!i){e.next=8;break}return e.next=6,t.getEvmAccounts(i);case 6:c.push(e.sent);case 8:return e.next=10,a(o);case 10:return c=[].concat(c,e.sent),e.abrupt("return",c);case 13:case"end":return e.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}(),s=t.switchNetworkForEvm;exports.canSwitchNetworkTo=t.canSwitchNetworkToEvm,exports.config=c,exports.connect=u,exports.getInstance=function(){var e=new Map,r=window,n=r.safepal,o=r.safepalProvider;return r.isSafePal?(n&&n.isSafePalWallet&&e.set(t.Network.SOLANA,n),o&&o&&e.set(t.Network.ETHEREUM,o),0===e.size?null:e):null},exports.getSigners=function(e){return t.defaultSigners({provider:e,walletType:t.WalletType.SAFEPAL,supportEvm:!0,supportSolana:!0})},exports.getWalletInfo=function(e){var r=t.evmBlockchains(e),n=t.solanaBlockchain(e);return{name:"SafePal",img:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png",installLink:{CHROME:"https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa",BRAVE:"https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa",FIREFOX:"https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet",DEFAULT:"https://www.safepal.com/download"},color:"#4A21EF",supportedChains:[].concat(r,n)}},exports.subscribe=function(e){var r=t.chooseInstance(e.instance,e.meta,t.Network.ETHEREUM);r&&t.subscribeToEvm(o({},e,{instance:r}))},exports.switchNetwork=s;
2
+ //# sourceMappingURL=provider-safepal.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-safepal.cjs.production.min.js","sources":["../src/helpers.ts","../src/index.ts","../src/signer.ts"],"sourcesContent":["import { Network, ProviderConnectResult } from '@rango-dev/wallets-shared';\n\ntype Provider = Map<Network, any>;\n\nexport function safepal() {\n const instances = new Map();\n const { isSafePal, safepal, safepalProvider } = window;\n\n if (!isSafePal) return null;\n\n if (!!safepal && safepal.isSafePalWallet)\n instances.set(Network.SOLANA, safepal);\n\n if (safepalProvider && safepalProvider)\n instances.set(Network.ETHEREUM, safepalProvider);\n\n if (instances.size === 0) return null;\n\n return instances;\n}\n\nexport async function getNonEvmAccounts(\n instances: Provider\n): Promise<ProviderConnectResult[]> {\n const solanaInstance = instances.get(Network.SOLANA);\n const results: ProviderConnectResult[] = [];\n\n if (!!solanaInstance) {\n const solanaResponse = await solanaInstance.connect();\n\n const solanaAccounts: string = solanaResponse.publicKey.toString();\n\n results.push({\n accounts: [solanaAccounts],\n chainId: Network.SOLANA,\n });\n }\n\n return results;\n}\n","import {\n Network,\n WalletType,\n CanSwitchNetwork,\n Connect,\n ProviderConnectResult,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n chooseInstance,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n BlockchainMeta,\n WalletInfo,\n evmBlockchains,\n solanaBlockchain,\n} from '@rango-dev/wallets-shared';\nimport { getNonEvmAccounts, safepal as safepal_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.SAFEPAL;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.ETHEREUM,\n};\n\nexport const getInstance = safepal_instance;\nexport const connect: Connect = async ({ instance, meta }) => {\n const ethInstance = chooseInstance(instance, meta, Network.ETHEREUM);\n\n let results: ProviderConnectResult[] = [];\n\n if (ethInstance) {\n const evmResult = await getEvmAccounts(ethInstance);\n results.push(evmResult);\n }\n\n const nonEvmResults = await getNonEvmAccounts(instance);\n results = [...results, ...nonEvmResults];\n\n return results;\n};\n\nexport const subscribe: Subscribe = (options) => {\n const ethInstance = chooseInstance(\n options.instance,\n options.meta,\n Network.ETHEREUM\n );\n\n if (ethInstance) {\n subscribeToEvm({ ...options, instance: ethInstance });\n }\n};\n\nexport const switchNetwork: SwitchNetwork = switchNetworkForEvm;\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm;\n\nexport const getSigners: (provider: any) => WalletSigners = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const evms = evmBlockchains(allBlockChains);\n const solana = solanaBlockchain(allBlockChains);\n return {\n name: 'SafePal',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n FIREFOX:\n 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',\n DEFAULT: 'https://www.safepal.com/download',\n },\n color: '#4A21EF',\n supportedChains: [...evms, ...solana],\n };\n};\n","import {\n WalletType,\n WalletSigners,\n defaultSigners,\n} from '@rango-dev/wallets-shared';\n\nexport default function getSigners(provider: any): WalletSigners {\n return defaultSigners({\n provider,\n walletType: WalletType.SAFEPAL,\n supportEvm: true,\n supportSolana: true,\n });\n}\n"],"names":["getNonEvmAccounts","_getNonEvmAccounts","instances","solanaInstance","get","Network","SOLANA","results","_context","connect","solanaAccounts","publicKey","toString","push","accounts","chainId","config","type","WalletType","SAFEPAL","defaultNetwork","ETHEREUM","ethInstance","chooseInstance","instance","meta","getEvmAccounts","switchNetwork","switchNetworkForEvm","canSwitchNetworkToEvm","Map","window","safepal","safepalProvider","isSafePal","isSafePalWallet","set","size","provider","defaultSigners","walletType","supportEvm","supportSolana","allBlockChains","evms","evmBlockchains","solana","solanaBlockchain","name","img","installLink","CHROME","BRAVE","FIREFOX","DEFAULT","color","supportedChains","options","subscribeToEvm"],"mappings":"8lOAqBsBA,KAAiB,+BAkBtC,aAAA,OAAAC,cAlBM,WACLC,GAAmB,UAAA,6BAAA,6BAAA,OAGwB,GADrCC,EAAiBD,EAAUE,IAAIC,UAAQC,QACvCC,EAAmC,IAEnCJ,GAAcK,SAAA,MAAA,OAAAA,SACWL,EAAeM,UAAS,OAE/CC,SAAwCC,UAAUC,WAExDL,EAAQM,KAAK,CACXC,SAAU,CAACJ,GACXK,QAASV,UAAQC,SAChB,OAAA,yBAGEC,GAAO,OAAA,UAAA,iDChBhB,IAEaS,EAAS,CACpBC,KAHaC,aAAWC,QAIxBC,eAAgBf,UAAQgB,UAIbZ,aAAO,kBAAY,cAAA,UAAA,6BAAA,6BAAA,OAGW,GAFnCa,EAAcC,iBADmBC,IAAAA,WAAUC,KACEpB,UAAQgB,UAEvDd,EAAmC,IAEnCe,GAAWd,SAAA,MAAA,OAAAA,SACWkB,iBAAeJ,GAAY,OACnDf,EAAQM,aAAgB,OAAA,OAAAL,UAGER,EAAkBwB,GAAS,QACd,OAAzCjB,YAAcA,4BAEPA,GAAO,QAAA,UAAA,0BACf,mBAdmB,mCA4BPoB,EAA+BC,iDAEQC,0FDvDlD,IAAM3B,EAAY,IAAI4B,MAC0BC,OAA7BC,IAAAA,QAASC,IAAAA,gBAE5B,SAFQC,WAIFF,GAAWA,EAAQG,iBACvBjC,EAAUkC,IAAI/B,UAAQC,OAAQ0B,GAE5BC,GAAmBA,GACrB/B,EAAUkC,IAAI/B,UAAQgB,SAAUY,GAEX,IAAnB/B,EAAUmC,KAAmB,KAE1BnC,GAVgB,kCEFUoC,GACjC,OAAOC,iBAAe,CACpBD,SAAAA,EACAE,WAAYtB,aAAWC,QACvBsB,YAAY,EACZC,eAAe,2BDqD4D,SAC7EC,GAEA,IAAMC,EAAOC,iBAAeF,GACtBG,EAASC,mBAAiBJ,GAChC,MAAO,CACLK,KAAM,UACNC,IAAK,qGACLC,YAAa,CACXC,OACE,sGACFC,MACE,sGACFC,QACE,0EACFC,QAAS,oCAEXC,MAAO,UACPC,0BAAqBZ,EAASE,uBApCE,SAACW,GACnC,IAAMnC,EAAcC,iBAClBkC,EAAQjC,SACRiC,EAAQhC,KACRpB,UAAQgB,UAGNC,GACFoC,sBAAoBD,GAASjC,SAAUF"}
@@ -0,0 +1,475 @@
1
+ import { Network, defaultSigners, WalletType, chooseInstance, subscribeToEvm, switchNetworkForEvm, canSwitchNetworkToEvm, evmBlockchains, solanaBlockchain, getEvmAccounts } from '@rango-dev/wallets-shared';
2
+
3
+ function _regeneratorRuntime() {
4
+ _regeneratorRuntime = function () {
5
+ return exports;
6
+ };
7
+ var exports = {},
8
+ Op = Object.prototype,
9
+ hasOwn = Op.hasOwnProperty,
10
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
11
+ obj[key] = desc.value;
12
+ },
13
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
14
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
15
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
16
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
17
+ function define(obj, key, value) {
18
+ return Object.defineProperty(obj, key, {
19
+ value: value,
20
+ enumerable: !0,
21
+ configurable: !0,
22
+ writable: !0
23
+ }), obj[key];
24
+ }
25
+ try {
26
+ define({}, "");
27
+ } catch (err) {
28
+ define = function (obj, key, value) {
29
+ return obj[key] = value;
30
+ };
31
+ }
32
+ function wrap(innerFn, outerFn, self, tryLocsList) {
33
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
34
+ generator = Object.create(protoGenerator.prototype),
35
+ context = new Context(tryLocsList || []);
36
+ return defineProperty(generator, "_invoke", {
37
+ value: makeInvokeMethod(innerFn, self, context)
38
+ }), generator;
39
+ }
40
+ function tryCatch(fn, obj, arg) {
41
+ try {
42
+ return {
43
+ type: "normal",
44
+ arg: fn.call(obj, arg)
45
+ };
46
+ } catch (err) {
47
+ return {
48
+ type: "throw",
49
+ arg: err
50
+ };
51
+ }
52
+ }
53
+ exports.wrap = wrap;
54
+ var ContinueSentinel = {};
55
+ function Generator() {}
56
+ function GeneratorFunction() {}
57
+ function GeneratorFunctionPrototype() {}
58
+ var IteratorPrototype = {};
59
+ define(IteratorPrototype, iteratorSymbol, function () {
60
+ return this;
61
+ });
62
+ var getProto = Object.getPrototypeOf,
63
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
64
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
65
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
66
+ function defineIteratorMethods(prototype) {
67
+ ["next", "throw", "return"].forEach(function (method) {
68
+ define(prototype, method, function (arg) {
69
+ return this._invoke(method, arg);
70
+ });
71
+ });
72
+ }
73
+ function AsyncIterator(generator, PromiseImpl) {
74
+ function invoke(method, arg, resolve, reject) {
75
+ var record = tryCatch(generator[method], generator, arg);
76
+ if ("throw" !== record.type) {
77
+ var result = record.arg,
78
+ value = result.value;
79
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
80
+ invoke("next", value, resolve, reject);
81
+ }, function (err) {
82
+ invoke("throw", err, resolve, reject);
83
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
84
+ result.value = unwrapped, resolve(result);
85
+ }, function (error) {
86
+ return invoke("throw", error, resolve, reject);
87
+ });
88
+ }
89
+ reject(record.arg);
90
+ }
91
+ var previousPromise;
92
+ defineProperty(this, "_invoke", {
93
+ value: function (method, arg) {
94
+ function callInvokeWithMethodAndArg() {
95
+ return new PromiseImpl(function (resolve, reject) {
96
+ invoke(method, arg, resolve, reject);
97
+ });
98
+ }
99
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
100
+ }
101
+ });
102
+ }
103
+ function makeInvokeMethod(innerFn, self, context) {
104
+ var state = "suspendedStart";
105
+ return function (method, arg) {
106
+ if ("executing" === state) throw new Error("Generator is already running");
107
+ if ("completed" === state) {
108
+ if ("throw" === method) throw arg;
109
+ return doneResult();
110
+ }
111
+ for (context.method = method, context.arg = arg;;) {
112
+ var delegate = context.delegate;
113
+ if (delegate) {
114
+ var delegateResult = maybeInvokeDelegate(delegate, context);
115
+ if (delegateResult) {
116
+ if (delegateResult === ContinueSentinel) continue;
117
+ return delegateResult;
118
+ }
119
+ }
120
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
121
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
122
+ context.dispatchException(context.arg);
123
+ } else "return" === context.method && context.abrupt("return", context.arg);
124
+ state = "executing";
125
+ var record = tryCatch(innerFn, self, context);
126
+ if ("normal" === record.type) {
127
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
128
+ return {
129
+ value: record.arg,
130
+ done: context.done
131
+ };
132
+ }
133
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
134
+ }
135
+ };
136
+ }
137
+ function maybeInvokeDelegate(delegate, context) {
138
+ var methodName = context.method,
139
+ method = delegate.iterator[methodName];
140
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
141
+ var record = tryCatch(method, delegate.iterator, context.arg);
142
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
143
+ var info = record.arg;
144
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
145
+ }
146
+ function pushTryEntry(locs) {
147
+ var entry = {
148
+ tryLoc: locs[0]
149
+ };
150
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
151
+ }
152
+ function resetTryEntry(entry) {
153
+ var record = entry.completion || {};
154
+ record.type = "normal", delete record.arg, entry.completion = record;
155
+ }
156
+ function Context(tryLocsList) {
157
+ this.tryEntries = [{
158
+ tryLoc: "root"
159
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
160
+ }
161
+ function values(iterable) {
162
+ if (iterable) {
163
+ var iteratorMethod = iterable[iteratorSymbol];
164
+ if (iteratorMethod) return iteratorMethod.call(iterable);
165
+ if ("function" == typeof iterable.next) return iterable;
166
+ if (!isNaN(iterable.length)) {
167
+ var i = -1,
168
+ next = function next() {
169
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
170
+ return next.value = undefined, next.done = !0, next;
171
+ };
172
+ return next.next = next;
173
+ }
174
+ }
175
+ return {
176
+ next: doneResult
177
+ };
178
+ }
179
+ function doneResult() {
180
+ return {
181
+ value: undefined,
182
+ done: !0
183
+ };
184
+ }
185
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
186
+ value: GeneratorFunctionPrototype,
187
+ configurable: !0
188
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
189
+ value: GeneratorFunction,
190
+ configurable: !0
191
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
192
+ var ctor = "function" == typeof genFun && genFun.constructor;
193
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
194
+ }, exports.mark = function (genFun) {
195
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
196
+ }, exports.awrap = function (arg) {
197
+ return {
198
+ __await: arg
199
+ };
200
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
201
+ return this;
202
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
203
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
204
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
205
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
206
+ return result.done ? result.value : iter.next();
207
+ });
208
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
209
+ return this;
210
+ }), define(Gp, "toString", function () {
211
+ return "[object Generator]";
212
+ }), exports.keys = function (val) {
213
+ var object = Object(val),
214
+ keys = [];
215
+ for (var key in object) keys.push(key);
216
+ return keys.reverse(), function next() {
217
+ for (; keys.length;) {
218
+ var key = keys.pop();
219
+ if (key in object) return next.value = key, next.done = !1, next;
220
+ }
221
+ return next.done = !0, next;
222
+ };
223
+ }, exports.values = values, Context.prototype = {
224
+ constructor: Context,
225
+ reset: function (skipTempReset) {
226
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
227
+ },
228
+ stop: function () {
229
+ this.done = !0;
230
+ var rootRecord = this.tryEntries[0].completion;
231
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
232
+ return this.rval;
233
+ },
234
+ dispatchException: function (exception) {
235
+ if (this.done) throw exception;
236
+ var context = this;
237
+ function handle(loc, caught) {
238
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
239
+ }
240
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
241
+ var entry = this.tryEntries[i],
242
+ record = entry.completion;
243
+ if ("root" === entry.tryLoc) return handle("end");
244
+ if (entry.tryLoc <= this.prev) {
245
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
246
+ hasFinally = hasOwn.call(entry, "finallyLoc");
247
+ if (hasCatch && hasFinally) {
248
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
249
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
250
+ } else if (hasCatch) {
251
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
252
+ } else {
253
+ if (!hasFinally) throw new Error("try statement without catch or finally");
254
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
255
+ }
256
+ }
257
+ }
258
+ },
259
+ abrupt: function (type, arg) {
260
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
261
+ var entry = this.tryEntries[i];
262
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
263
+ var finallyEntry = entry;
264
+ break;
265
+ }
266
+ }
267
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
268
+ var record = finallyEntry ? finallyEntry.completion : {};
269
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
270
+ },
271
+ complete: function (record, afterLoc) {
272
+ if ("throw" === record.type) throw record.arg;
273
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
274
+ },
275
+ finish: function (finallyLoc) {
276
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
277
+ var entry = this.tryEntries[i];
278
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
279
+ }
280
+ },
281
+ catch: function (tryLoc) {
282
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
283
+ var entry = this.tryEntries[i];
284
+ if (entry.tryLoc === tryLoc) {
285
+ var record = entry.completion;
286
+ if ("throw" === record.type) {
287
+ var thrown = record.arg;
288
+ resetTryEntry(entry);
289
+ }
290
+ return thrown;
291
+ }
292
+ }
293
+ throw new Error("illegal catch attempt");
294
+ },
295
+ delegateYield: function (iterable, resultName, nextLoc) {
296
+ return this.delegate = {
297
+ iterator: values(iterable),
298
+ resultName: resultName,
299
+ nextLoc: nextLoc
300
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
301
+ }
302
+ }, exports;
303
+ }
304
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
305
+ try {
306
+ var info = gen[key](arg);
307
+ var value = info.value;
308
+ } catch (error) {
309
+ reject(error);
310
+ return;
311
+ }
312
+ if (info.done) {
313
+ resolve(value);
314
+ } else {
315
+ Promise.resolve(value).then(_next, _throw);
316
+ }
317
+ }
318
+ function _asyncToGenerator(fn) {
319
+ return function () {
320
+ var self = this,
321
+ args = arguments;
322
+ return new Promise(function (resolve, reject) {
323
+ var gen = fn.apply(self, args);
324
+ function _next(value) {
325
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
326
+ }
327
+ function _throw(err) {
328
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
329
+ }
330
+ _next(undefined);
331
+ });
332
+ };
333
+ }
334
+ function _extends() {
335
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
336
+ for (var i = 1; i < arguments.length; i++) {
337
+ var source = arguments[i];
338
+ for (var key in source) {
339
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
340
+ target[key] = source[key];
341
+ }
342
+ }
343
+ }
344
+ return target;
345
+ };
346
+ return _extends.apply(this, arguments);
347
+ }
348
+
349
+ function safepal() {
350
+ var instances = new Map();
351
+ var _window = window,
352
+ isSafePal = _window.isSafePal,
353
+ safepal = _window.safepal,
354
+ safepalProvider = _window.safepalProvider;
355
+ if (!isSafePal) return null;
356
+ if (!!safepal && safepal.isSafePalWallet) instances.set(Network.SOLANA, safepal);
357
+ if (safepalProvider && safepalProvider) instances.set(Network.ETHEREUM, safepalProvider);
358
+ if (instances.size === 0) return null;
359
+ return instances;
360
+ }
361
+ function getNonEvmAccounts(_x) {
362
+ return _getNonEvmAccounts.apply(this, arguments);
363
+ }
364
+ function _getNonEvmAccounts() {
365
+ _getNonEvmAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(instances) {
366
+ var solanaInstance, results, solanaResponse, solanaAccounts;
367
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
368
+ while (1) switch (_context.prev = _context.next) {
369
+ case 0:
370
+ solanaInstance = instances.get(Network.SOLANA);
371
+ results = [];
372
+ if (!solanaInstance) {
373
+ _context.next = 8;
374
+ break;
375
+ }
376
+ _context.next = 5;
377
+ return solanaInstance.connect();
378
+ case 5:
379
+ solanaResponse = _context.sent;
380
+ solanaAccounts = solanaResponse.publicKey.toString();
381
+ results.push({
382
+ accounts: [solanaAccounts],
383
+ chainId: Network.SOLANA
384
+ });
385
+ case 8:
386
+ return _context.abrupt("return", results);
387
+ case 9:
388
+ case "end":
389
+ return _context.stop();
390
+ }
391
+ }, _callee);
392
+ }));
393
+ return _getNonEvmAccounts.apply(this, arguments);
394
+ }
395
+
396
+ function getSigners(provider) {
397
+ return defaultSigners({
398
+ provider: provider,
399
+ walletType: WalletType.SAFEPAL,
400
+ supportEvm: true,
401
+ supportSolana: true
402
+ });
403
+ }
404
+
405
+ var WALLET = WalletType.SAFEPAL;
406
+ var config = {
407
+ type: WALLET,
408
+ defaultNetwork: Network.ETHEREUM
409
+ };
410
+ var getInstance = safepal;
411
+ var connect = /*#__PURE__*/function () {
412
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
413
+ var instance, meta, ethInstance, results, evmResult, nonEvmResults;
414
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
415
+ while (1) switch (_context.prev = _context.next) {
416
+ case 0:
417
+ instance = _ref.instance, meta = _ref.meta;
418
+ ethInstance = chooseInstance(instance, meta, Network.ETHEREUM);
419
+ results = [];
420
+ if (!ethInstance) {
421
+ _context.next = 8;
422
+ break;
423
+ }
424
+ _context.next = 6;
425
+ return getEvmAccounts(ethInstance);
426
+ case 6:
427
+ evmResult = _context.sent;
428
+ results.push(evmResult);
429
+ case 8:
430
+ _context.next = 10;
431
+ return getNonEvmAccounts(instance);
432
+ case 10:
433
+ nonEvmResults = _context.sent;
434
+ results = [].concat(results, nonEvmResults);
435
+ return _context.abrupt("return", results);
436
+ case 13:
437
+ case "end":
438
+ return _context.stop();
439
+ }
440
+ }, _callee);
441
+ }));
442
+ return function connect(_x) {
443
+ return _ref2.apply(this, arguments);
444
+ };
445
+ }();
446
+ var subscribe = function subscribe(options) {
447
+ var ethInstance = chooseInstance(options.instance, options.meta, Network.ETHEREUM);
448
+ if (ethInstance) {
449
+ subscribeToEvm(_extends({}, options, {
450
+ instance: ethInstance
451
+ }));
452
+ }
453
+ };
454
+ var switchNetwork = switchNetworkForEvm;
455
+ var canSwitchNetworkTo = canSwitchNetworkToEvm;
456
+ var getSigners$1 = getSigners;
457
+ var getWalletInfo = function getWalletInfo(allBlockChains) {
458
+ var evms = evmBlockchains(allBlockChains);
459
+ var solana = solanaBlockchain(allBlockChains);
460
+ return {
461
+ name: 'SafePal',
462
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',
463
+ installLink: {
464
+ CHROME: 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
465
+ BRAVE: 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
466
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',
467
+ DEFAULT: 'https://www.safepal.com/download'
468
+ },
469
+ color: '#4A21EF',
470
+ supportedChains: [].concat(evms, solana)
471
+ };
472
+ };
473
+
474
+ export { canSwitchNetworkTo, config, connect, getInstance, getSigners$1 as getSigners, getWalletInfo, subscribe, switchNetwork };
475
+ //# sourceMappingURL=provider-safepal.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-safepal.esm.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["import { Network, ProviderConnectResult } from '@rango-dev/wallets-shared';\n\ntype Provider = Map<Network, any>;\n\nexport function safepal() {\n const instances = new Map();\n const { isSafePal, safepal, safepalProvider } = window;\n\n if (!isSafePal) return null;\n\n if (!!safepal && safepal.isSafePalWallet)\n instances.set(Network.SOLANA, safepal);\n\n if (safepalProvider && safepalProvider)\n instances.set(Network.ETHEREUM, safepalProvider);\n\n if (instances.size === 0) return null;\n\n return instances;\n}\n\nexport async function getNonEvmAccounts(\n instances: Provider\n): Promise<ProviderConnectResult[]> {\n const solanaInstance = instances.get(Network.SOLANA);\n const results: ProviderConnectResult[] = [];\n\n if (!!solanaInstance) {\n const solanaResponse = await solanaInstance.connect();\n\n const solanaAccounts: string = solanaResponse.publicKey.toString();\n\n results.push({\n accounts: [solanaAccounts],\n chainId: Network.SOLANA,\n });\n }\n\n return results;\n}\n","import {\n WalletType,\n WalletSigners,\n defaultSigners,\n} from '@rango-dev/wallets-shared';\n\nexport default function getSigners(provider: any): WalletSigners {\n return defaultSigners({\n provider,\n walletType: WalletType.SAFEPAL,\n supportEvm: true,\n supportSolana: true,\n });\n}\n","import {\n Network,\n WalletType,\n CanSwitchNetwork,\n Connect,\n ProviderConnectResult,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n chooseInstance,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n BlockchainMeta,\n WalletInfo,\n evmBlockchains,\n solanaBlockchain,\n} from '@rango-dev/wallets-shared';\nimport { getNonEvmAccounts, safepal as safepal_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.SAFEPAL;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.ETHEREUM,\n};\n\nexport const getInstance = safepal_instance;\nexport const connect: Connect = async ({ instance, meta }) => {\n const ethInstance = chooseInstance(instance, meta, Network.ETHEREUM);\n\n let results: ProviderConnectResult[] = [];\n\n if (ethInstance) {\n const evmResult = await getEvmAccounts(ethInstance);\n results.push(evmResult);\n }\n\n const nonEvmResults = await getNonEvmAccounts(instance);\n results = [...results, ...nonEvmResults];\n\n return results;\n};\n\nexport const subscribe: Subscribe = (options) => {\n const ethInstance = chooseInstance(\n options.instance,\n options.meta,\n Network.ETHEREUM\n );\n\n if (ethInstance) {\n subscribeToEvm({ ...options, instance: ethInstance });\n }\n};\n\nexport const switchNetwork: SwitchNetwork = switchNetworkForEvm;\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm;\n\nexport const getSigners: (provider: any) => WalletSigners = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const evms = evmBlockchains(allBlockChains);\n const solana = solanaBlockchain(allBlockChains);\n return {\n name: 'SafePal',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',\n FIREFOX:\n 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',\n DEFAULT: 'https://www.safepal.com/download',\n },\n color: '#4A21EF',\n supportedChains: [...evms, ...solana],\n };\n};\n"],"names":["safepal","instances","Map","window","isSafePal","safepalProvider","isSafePalWallet","set","Network","SOLANA","ETHEREUM","size","getNonEvmAccounts","solanaInstance","get","results","connect","solanaResponse","solanaAccounts","publicKey","toString","push","accounts","chainId","getSigners","provider","defaultSigners","walletType","WalletType","SAFEPAL","supportEvm","supportSolana","WALLET","config","type","defaultNetwork","getInstance","safepal_instance","instance","meta","ethInstance","chooseInstance","getEvmAccounts","evmResult","nonEvmResults","subscribe","options","subscribeToEvm","switchNetwork","switchNetworkForEvm","canSwitchNetworkTo","canSwitchNetworkToEvm","signer","getWalletInfo","allBlockChains","evms","evmBlockchains","solana","solanaBlockchain","name","img","installLink","CHROME","BRAVE","FIREFOX","DEFAULT","color","supportedChains"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { WalletSigners } from '@rango-dev/wallets-shared';
2
+ export default function getSigners(provider: any): WalletSigners;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@rango-dev/provider-safepal",
3
+ "version": "0.1.11-next.69",
4
+ "license": "MIT",
5
+ "module": "dist/provider-safepal.esm.js",
6
+ "main": "dist/index.js",
7
+ "typings": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "src"
11
+ ],
12
+ "engines": {
13
+ "node": ">=10"
14
+ },
15
+ "scripts": {
16
+ "start": "tsdx watch",
17
+ "build": "tsdx build",
18
+ "test": "tsdx test --passWithNoTests",
19
+ "lint": "tsdx lint",
20
+ "size": "size-limit",
21
+ "analyze": "size-limit --why"
22
+ },
23
+ "peerDependencies": {
24
+ "react": ">=16"
25
+ },
26
+ "husky": {
27
+ "hooks": {
28
+ "pre-commit": "tsdx lint"
29
+ }
30
+ },
31
+ "prettier": {
32
+ "printWidth": 80,
33
+ "semi": true,
34
+ "singleQuote": true,
35
+ "trailingComma": "es5"
36
+ },
37
+ "size-limit": [
38
+ {
39
+ "path": "dist/provider-safepal.cjs.production.min.js",
40
+ "limit": "10 KB"
41
+ },
42
+ {
43
+ "path": "dist/provider-safepal.esm.js",
44
+ "limit": "10 KB"
45
+ }
46
+ ],
47
+ "dependencies": {
48
+ "@rango-dev/wallets-shared": "^0.1.11-next.69"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "gitHead": "35fad4db1d491a9589a8215b0c4a4e2f541d07f2"
54
+ }
@@ -0,0 +1,3 @@
1
+ import { Network } from '@rango-dev/wallets-shared';
2
+
3
+ // export const SUPPORTED_NATIVE_CHAINS = [Network.BTC, Network.BCH, Network.LTC];
package/src/helpers.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { Network, ProviderConnectResult } from '@rango-dev/wallets-shared';
2
+
3
+ type Provider = Map<Network, any>;
4
+
5
+ export function safepal() {
6
+ const instances = new Map();
7
+ const { isSafePal, safepal, safepalProvider } = window;
8
+
9
+ if (!isSafePal) return null;
10
+
11
+ if (!!safepal && safepal.isSafePalWallet)
12
+ instances.set(Network.SOLANA, safepal);
13
+
14
+ if (safepalProvider && safepalProvider)
15
+ instances.set(Network.ETHEREUM, safepalProvider);
16
+
17
+ if (instances.size === 0) return null;
18
+
19
+ return instances;
20
+ }
21
+
22
+ export async function getNonEvmAccounts(
23
+ instances: Provider
24
+ ): Promise<ProviderConnectResult[]> {
25
+ const solanaInstance = instances.get(Network.SOLANA);
26
+ const results: ProviderConnectResult[] = [];
27
+
28
+ if (!!solanaInstance) {
29
+ const solanaResponse = await solanaInstance.connect();
30
+
31
+ const solanaAccounts: string = solanaResponse.publicKey.toString();
32
+
33
+ results.push({
34
+ accounts: [solanaAccounts],
35
+ chainId: Network.SOLANA,
36
+ });
37
+ }
38
+
39
+ return results;
40
+ }
package/src/index.ts ADDED
@@ -0,0 +1,85 @@
1
+ import {
2
+ Network,
3
+ WalletType,
4
+ CanSwitchNetwork,
5
+ Connect,
6
+ ProviderConnectResult,
7
+ Subscribe,
8
+ SwitchNetwork,
9
+ WalletSigners,
10
+ canSwitchNetworkToEvm,
11
+ chooseInstance,
12
+ getEvmAccounts,
13
+ subscribeToEvm,
14
+ switchNetworkForEvm,
15
+ BlockchainMeta,
16
+ WalletInfo,
17
+ evmBlockchains,
18
+ solanaBlockchain,
19
+ } from '@rango-dev/wallets-shared';
20
+ import { getNonEvmAccounts, safepal as safepal_instance } from './helpers';
21
+ import signer from './signer';
22
+
23
+ const WALLET = WalletType.SAFEPAL;
24
+
25
+ export const config = {
26
+ type: WALLET,
27
+ defaultNetwork: Network.ETHEREUM,
28
+ };
29
+
30
+ export const getInstance = safepal_instance;
31
+ export const connect: Connect = async ({ instance, meta }) => {
32
+ const ethInstance = chooseInstance(instance, meta, Network.ETHEREUM);
33
+
34
+ let results: ProviderConnectResult[] = [];
35
+
36
+ if (ethInstance) {
37
+ const evmResult = await getEvmAccounts(ethInstance);
38
+ results.push(evmResult);
39
+ }
40
+
41
+ const nonEvmResults = await getNonEvmAccounts(instance);
42
+ results = [...results, ...nonEvmResults];
43
+
44
+ return results;
45
+ };
46
+
47
+ export const subscribe: Subscribe = (options) => {
48
+ const ethInstance = chooseInstance(
49
+ options.instance,
50
+ options.meta,
51
+ Network.ETHEREUM
52
+ );
53
+
54
+ if (ethInstance) {
55
+ subscribeToEvm({ ...options, instance: ethInstance });
56
+ }
57
+ };
58
+
59
+ export const switchNetwork: SwitchNetwork = switchNetworkForEvm;
60
+
61
+ export const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm;
62
+
63
+ export const getSigners: (provider: any) => WalletSigners = signer;
64
+
65
+ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
66
+ allBlockChains
67
+ ) => {
68
+ const evms = evmBlockchains(allBlockChains);
69
+ const solana = solanaBlockchain(allBlockChains);
70
+ return {
71
+ name: 'SafePal',
72
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/safepal.png',
73
+ installLink: {
74
+ CHROME:
75
+ 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
76
+ BRAVE:
77
+ 'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa',
78
+ FIREFOX:
79
+ 'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet',
80
+ DEFAULT: 'https://www.safepal.com/download',
81
+ },
82
+ color: '#4A21EF',
83
+ supportedChains: [...evms, ...solana],
84
+ };
85
+ };
package/src/signer.ts ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ WalletType,
3
+ WalletSigners,
4
+ defaultSigners,
5
+ } from '@rango-dev/wallets-shared';
6
+
7
+ export default function getSigners(provider: any): WalletSigners {
8
+ return defaultSigners({
9
+ provider,
10
+ walletType: WalletType.SAFEPAL,
11
+ supportEvm: true,
12
+ supportSolana: true,
13
+ });
14
+ }