@rango-dev/provider-metamask 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 declare function metamask(): any;
@@ -0,0 +1,12 @@
1
+ import { WalletType, CanSwitchNetwork, Connect, Subscribe, SwitchNetwork, WalletSigners, BlockchainMeta, WalletInfo } from '@rango-dev/wallets-shared';
2
+ import { metamask as metamask_instance } from './helpers';
3
+ export declare const config: {
4
+ type: WalletType;
5
+ };
6
+ export declare const getInstance: typeof metamask_instance;
7
+ export declare const connect: Connect;
8
+ export declare const subscribe: Subscribe;
9
+ export declare const switchNetwork: SwitchNetwork;
10
+ export declare const canSwitchNetworkTo: CanSwitchNetwork;
11
+ export declare const getSigners: (provider: any) => WalletSigners;
12
+ 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-metamask.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./provider-metamask.cjs.development.js')
8
+ }
@@ -0,0 +1,424 @@
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
+
339
+ function metamask() {
340
+ var isCoinbaseWalletAvailable = !!walletsShared.getCoinbaseInstance();
341
+ var _window = window,
342
+ ethereum = _window.ethereum;
343
+ // Some wallets overriding the metamask. So we need to get it properly.
344
+ if (isCoinbaseWalletAvailable) {
345
+ // Getting intance from overrided structure from coinbase.
346
+ return walletsShared.getCoinbaseInstance('metamask');
347
+ } else {
348
+ if (!!ethereum && ethereum.isMetaMask) {
349
+ return ethereum;
350
+ }
351
+ }
352
+ return null;
353
+ }
354
+
355
+ function getSigners(provider) {
356
+ return walletsShared.defaultSigners({
357
+ walletType: walletsShared.WalletType.META_MASK,
358
+ provider: provider,
359
+ supportEvm: true
360
+ });
361
+ }
362
+
363
+ var WALLET = walletsShared.WalletType.META_MASK;
364
+ var config = {
365
+ type: WALLET
366
+ };
367
+ var getInstance = metamask;
368
+ var connect = /*#__PURE__*/function () {
369
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
370
+ var instance, _yield$getEvmAccounts, accounts, chainId;
371
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
372
+ while (1) switch (_context.prev = _context.next) {
373
+ case 0:
374
+ instance = _ref.instance;
375
+ _context.next = 3;
376
+ return walletsShared.getEvmAccounts(instance);
377
+ case 3:
378
+ _yield$getEvmAccounts = _context.sent;
379
+ accounts = _yield$getEvmAccounts.accounts;
380
+ chainId = _yield$getEvmAccounts.chainId;
381
+ return _context.abrupt("return", {
382
+ accounts: accounts,
383
+ chainId: chainId
384
+ });
385
+ case 7:
386
+ case "end":
387
+ return _context.stop();
388
+ }
389
+ }, _callee);
390
+ }));
391
+ return function connect(_x) {
392
+ return _ref2.apply(this, arguments);
393
+ };
394
+ }();
395
+ var subscribe = walletsShared.subscribeToEvm;
396
+ var switchNetwork = walletsShared.switchNetworkForEvm;
397
+ var canSwitchNetworkTo = walletsShared.canSwitchNetworkToEvm;
398
+ var getSigners$1 = getSigners;
399
+ var getWalletInfo = function getWalletInfo(allBlockChains) {
400
+ var evms = walletsShared.evmBlockchains(allBlockChains);
401
+ return {
402
+ name: 'MetaMask',
403
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',
404
+ installLink: {
405
+ CHROME: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
406
+ BRAVE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
407
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',
408
+ EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',
409
+ DEFAULT: 'https://metamask.io/download/'
410
+ },
411
+ color: '#dac7ae',
412
+ supportedChains: evms
413
+ };
414
+ };
415
+
416
+ exports.canSwitchNetworkTo = canSwitchNetworkTo;
417
+ exports.config = config;
418
+ exports.connect = connect;
419
+ exports.getInstance = getInstance;
420
+ exports.getSigners = getSigners$1;
421
+ exports.getWalletInfo = getWalletInfo;
422
+ exports.subscribe = subscribe;
423
+ exports.switchNetwork = switchNetwork;
424
+ //# sourceMappingURL=provider-metamask.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-metamask.cjs.development.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["import { getCoinbaseInstance } from '@rango-dev/wallets-shared';\n\nexport function metamask() {\n const isCoinbaseWalletAvailable = !!getCoinbaseInstance();\n const { ethereum } = window;\n\n // Some wallets overriding the metamask. So we need to get it properly.\n if (isCoinbaseWalletAvailable) {\n // Getting intance from overrided structure from coinbase.\n return getCoinbaseInstance('metamask');\n } else {\n if (!!ethereum && ethereum.isMetaMask) {\n return ethereum;\n }\n }\n return null;\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 walletType: WalletType.META_MASK,\n provider,\n supportEvm: true,\n });\n}\n","import {\n WalletType,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n evmBlockchains,\n BlockchainMeta,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { metamask as metamask_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.META_MASK;\n\nexport const config = {\n type: WALLET,\n};\n\nexport const getInstance = metamask_instance;\nexport const connect: Connect = async ({ instance }) => {\n // Note: We need to get `chainId` here, because for the first time\n // after opening the browser, wallet is locked, and don't give us accounts and chainId\n // on `check` phase, so `network` will be null. For this case we need to get chainId\n // whenever we are requesting accounts.\n const { accounts, chainId } = await getEvmAccounts(instance);\n\n return {\n accounts,\n chainId,\n };\n};\n\nexport const subscribe: Subscribe = subscribeToEvm;\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 return {\n name: 'MetaMask',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n\n FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',\n EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',\n DEFAULT: 'https://metamask.io/download/',\n },\n color: '#dac7ae',\n supportedChains: evms,\n };\n};\n"],"names":["metamask","isCoinbaseWalletAvailable","getCoinbaseInstance","window","ethereum","isMetaMask","getSigners","provider","defaultSigners","walletType","WalletType","META_MASK","supportEvm","WALLET","config","type","getInstance","metamask_instance","connect","instance","getEvmAccounts","accounts","chainId","subscribe","subscribeToEvm","switchNetwork","switchNetworkForEvm","canSwitchNetworkTo","canSwitchNetworkToEvm","signer","getWalletInfo","allBlockChains","evms","evmBlockchains","name","img","installLink","CHROME","BRAVE","FIREFOX","EDGE","DEFAULT","color","supportedChains"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEgBA,QAAQ;EACtB,IAAMC,yBAAyB,GAAG,CAAC,CAACC,iCAAmB,EAAE;EACzD,cAAqBC,MAAM;IAAnBC,QAAQ,WAARA,QAAQ;;EAGhB,IAAIH,yBAAyB,EAAE;;IAE7B,OAAOC,iCAAmB,CAAC,UAAU,CAAC;GACvC,MAAM;IACL,IAAI,CAAC,CAACE,QAAQ,IAAIA,QAAQ,CAACC,UAAU,EAAE;MACrC,OAAOD,QAAQ;;;EAGnB,OAAO,IAAI;AACb;;SCVwBE,UAAU,CAACC,QAAa;EAC9C,OAAOC,4BAAc,CAAC;IACpBC,UAAU,EAAEC,wBAAU,CAACC,SAAS;IAChCJ,QAAQ,EAARA,QAAQ;IACRK,UAAU,EAAE;GACb,CAAC;AACJ;;ACMA,IAAMC,MAAM,GAAGH,wBAAU,CAACC,SAAS;AAEnC,IAAaG,MAAM,GAAG;EACpBC,IAAI,EAAEF;CACP;AAED,IAAaG,WAAW,GAAGC;AAC3B,IAAaC,OAAO;EAAA,oFAAY;IAAA;IAAA;MAAA;QAAA;UAASC,QAAQ,QAARA,QAAQ;UAAA;UAAA,OAKXC,4BAAc,CAACD,QAAQ,CAAC;QAAA;UAAA;UAApDE,QAAQ,yBAARA,QAAQ;UAAEC,OAAO,yBAAPA,OAAO;UAAA,iCAElB;YACLD,QAAQ,EAARA,QAAQ;YACRC,OAAO,EAAPA;WACD;QAAA;QAAA;UAAA;;;GACF;EAAA,gBAXYJ,OAAO;IAAA;;AAAA,GAWnB;AAED,IAAaK,SAAS,GAAcC;AAEpC,IAAaC,aAAa,GAAkBC;AAE5C,IAAaC,kBAAkB,GAAqBC;AAEpD,IAAatB,YAAU,GAAqCuB;AAE5D,IAAaC,aAAa,GAAqD,SAAlEA,aAAa,CACxBC,cAAc;EAEd,IAAMC,IAAI,GAAGC,4BAAc,CAACF,cAAc,CAAC;EAC3C,OAAO;IACLG,IAAI,EAAE,UAAU;IAChBC,GAAG,EAAE,qGAAqG;IAC1GC,WAAW,EAAE;MACXC,MAAM,EACJ,2FAA2F;MAC7FC,KAAK,EACH,2FAA2F;MAE7FC,OAAO,EAAE,+DAA+D;MACxEC,IAAI,EAAE,sGAAsG;MAC5GC,OAAO,EAAE;KACV;IACDC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAEX;GAClB;AACH,CAAC;;;;;;;;;;;"}
@@ -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},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new O(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f={};function p(){}function v(){}function d(){}var y={};s(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(j([])));m&&m!==r&&n.call(m,a)&&(y=m);var w=d.prototype=p.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var r;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,c){var u=h(t[o],t,i);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,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=k(a,r);if(c){if(c===f)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=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function k(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,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function L(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function j(t){if(t){var e=t[a];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:S}}function S(){return{value:void 0,done:!0}}return v.prototype=d,o(w,"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(w),t},t.awrap=function(t){return{__await:t}},b(x.prototype),s(x.prototype,c,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"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=j,O.prototype={constructor:O,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(_),!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 a.type="throw",a.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 i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.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 i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},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),f},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),_(r),f}},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;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function r(t,e,r,n,o,i,a){try{var c=t[i](a),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,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}var o={type:t.WalletType.META_MASK},i=function(){var r=n(e().mark((function r(n){var o,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=n.instance,e.next=3,t.getEvmAccounts(o);case 3:return e.abrupt("return",{accounts:(i=e.sent).accounts,chainId:i.chainId});case 7:case"end":return e.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}(),a=t.subscribeToEvm,c=t.switchNetworkForEvm;exports.canSwitchNetworkTo=t.canSwitchNetworkToEvm,exports.config=o,exports.connect=i,exports.getInstance=function(){var e=!!t.getCoinbaseInstance(),r=window.ethereum;return e?t.getCoinbaseInstance("metamask"):r&&r.isMetaMask?r:null},exports.getSigners=function(e){return t.defaultSigners({walletType:t.WalletType.META_MASK,provider:e,supportEvm:!0})},exports.getWalletInfo=function(e){return{name:"MetaMask",img:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg",installLink:{CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en",BRAVE:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en",FIREFOX:"https://addons.mozilla.org/en-US/firefox/addon/ether-metamask",EDGE:"https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US",DEFAULT:"https://metamask.io/download/"},color:"#dac7ae",supportedChains:t.evmBlockchains(e)}},exports.subscribe=a,exports.switchNetwork=c;
2
+ //# sourceMappingURL=provider-metamask.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-metamask.cjs.production.min.js","sources":["../src/index.ts","../src/helpers.ts","../src/signer.ts"],"sourcesContent":["import {\n WalletType,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n evmBlockchains,\n BlockchainMeta,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { metamask as metamask_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.META_MASK;\n\nexport const config = {\n type: WALLET,\n};\n\nexport const getInstance = metamask_instance;\nexport const connect: Connect = async ({ instance }) => {\n // Note: We need to get `chainId` here, because for the first time\n // after opening the browser, wallet is locked, and don't give us accounts and chainId\n // on `check` phase, so `network` will be null. For this case we need to get chainId\n // whenever we are requesting accounts.\n const { accounts, chainId } = await getEvmAccounts(instance);\n\n return {\n accounts,\n chainId,\n };\n};\n\nexport const subscribe: Subscribe = subscribeToEvm;\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 return {\n name: 'MetaMask',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n\n FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',\n EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',\n DEFAULT: 'https://metamask.io/download/',\n },\n color: '#dac7ae',\n supportedChains: evms,\n };\n};\n","import { getCoinbaseInstance } from '@rango-dev/wallets-shared';\n\nexport function metamask() {\n const isCoinbaseWalletAvailable = !!getCoinbaseInstance();\n const { ethereum } = window;\n\n // Some wallets overriding the metamask. So we need to get it properly.\n if (isCoinbaseWalletAvailable) {\n // Getting intance from overrided structure from coinbase.\n return getCoinbaseInstance('metamask');\n } else {\n if (!!ethereum && ethereum.isMetaMask) {\n return ethereum;\n }\n }\n return null;\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 walletType: WalletType.META_MASK,\n provider,\n supportEvm: true,\n });\n}\n"],"names":["config","type","WalletType","META_MASK","connect","instance","_context","getEvmAccounts","accounts","_yield$getEvmAccounts","chainId","subscribe","subscribeToEvm","switchNetwork","switchNetworkForEvm","canSwitchNetworkToEvm","isCoinbaseWalletAvailable","getCoinbaseInstance","ethereum","window","isMetaMask","provider","defaultSigners","walletType","supportEvm","allBlockChains","name","img","installLink","CHROME","BRAVE","FIREFOX","EDGE","DEFAULT","color","supportedChains","evmBlockchains"],"mappings":"k3NAkBA,IAEaA,EAAS,CACpBC,KAHaC,aAAWC,WAObC,aAAO,kBAAY,cAAA,QAAA,6BAAA,6BAAA,OAAiB,OAARC,IAAAA,SAAQC,SAKXC,iBAAeF,GAAS,OAAnC,yBAElB,CACLG,UAH0DC,UAApDD,SAINE,UAJgBA,UAKjB,OAAA,UAAA,0BACF,mBAXmB,mCAaPC,EAAuBC,iBAEvBC,EAA+BC,iDAEQC,0FCvClD,IAAMC,IAA8BC,wBAC5BC,EAAaC,OAAbD,SAGR,OAAIF,EAEKC,sBAAoB,YAErBC,GAAYA,EAASE,WAClBF,EAGJ,kCCT0BG,GACjC,OAAOC,iBAAe,CACpBC,WAAYrB,aAAWC,UACvBkB,SAAAA,EACAG,YAAY,2BFoC+D,SAC7EC,GAGA,MAAO,CACLC,KAAM,WACNC,IAAK,sGACLC,YAAa,CACXC,OACE,4FACFC,MACE,4FAEFC,QAAS,gEACTC,KAAM,uGACNC,QAAS,iCAEXC,MAAO,UACPC,gBAfWC,iBAAeX"}
@@ -0,0 +1,413 @@
1
+ import { getCoinbaseInstance, defaultSigners, WalletType, subscribeToEvm, switchNetworkForEvm, canSwitchNetworkToEvm, evmBlockchains, 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
+
335
+ function metamask() {
336
+ var isCoinbaseWalletAvailable = !!getCoinbaseInstance();
337
+ var _window = window,
338
+ ethereum = _window.ethereum;
339
+ // Some wallets overriding the metamask. So we need to get it properly.
340
+ if (isCoinbaseWalletAvailable) {
341
+ // Getting intance from overrided structure from coinbase.
342
+ return getCoinbaseInstance('metamask');
343
+ } else {
344
+ if (!!ethereum && ethereum.isMetaMask) {
345
+ return ethereum;
346
+ }
347
+ }
348
+ return null;
349
+ }
350
+
351
+ function getSigners(provider) {
352
+ return defaultSigners({
353
+ walletType: WalletType.META_MASK,
354
+ provider: provider,
355
+ supportEvm: true
356
+ });
357
+ }
358
+
359
+ var WALLET = WalletType.META_MASK;
360
+ var config = {
361
+ type: WALLET
362
+ };
363
+ var getInstance = metamask;
364
+ var connect = /*#__PURE__*/function () {
365
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
366
+ var instance, _yield$getEvmAccounts, accounts, chainId;
367
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
368
+ while (1) switch (_context.prev = _context.next) {
369
+ case 0:
370
+ instance = _ref.instance;
371
+ _context.next = 3;
372
+ return getEvmAccounts(instance);
373
+ case 3:
374
+ _yield$getEvmAccounts = _context.sent;
375
+ accounts = _yield$getEvmAccounts.accounts;
376
+ chainId = _yield$getEvmAccounts.chainId;
377
+ return _context.abrupt("return", {
378
+ accounts: accounts,
379
+ chainId: chainId
380
+ });
381
+ case 7:
382
+ case "end":
383
+ return _context.stop();
384
+ }
385
+ }, _callee);
386
+ }));
387
+ return function connect(_x) {
388
+ return _ref2.apply(this, arguments);
389
+ };
390
+ }();
391
+ var subscribe = subscribeToEvm;
392
+ var switchNetwork = switchNetworkForEvm;
393
+ var canSwitchNetworkTo = canSwitchNetworkToEvm;
394
+ var getSigners$1 = getSigners;
395
+ var getWalletInfo = function getWalletInfo(allBlockChains) {
396
+ var evms = evmBlockchains(allBlockChains);
397
+ return {
398
+ name: 'MetaMask',
399
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',
400
+ installLink: {
401
+ CHROME: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
402
+ BRAVE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
403
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',
404
+ EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',
405
+ DEFAULT: 'https://metamask.io/download/'
406
+ },
407
+ color: '#dac7ae',
408
+ supportedChains: evms
409
+ };
410
+ };
411
+
412
+ export { canSwitchNetworkTo, config, connect, getInstance, getSigners$1 as getSigners, getWalletInfo, subscribe, switchNetwork };
413
+ //# sourceMappingURL=provider-metamask.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-metamask.esm.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["import { getCoinbaseInstance } from '@rango-dev/wallets-shared';\n\nexport function metamask() {\n const isCoinbaseWalletAvailable = !!getCoinbaseInstance();\n const { ethereum } = window;\n\n // Some wallets overriding the metamask. So we need to get it properly.\n if (isCoinbaseWalletAvailable) {\n // Getting intance from overrided structure from coinbase.\n return getCoinbaseInstance('metamask');\n } else {\n if (!!ethereum && ethereum.isMetaMask) {\n return ethereum;\n }\n }\n return null;\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 walletType: WalletType.META_MASK,\n provider,\n supportEvm: true,\n });\n}\n","import {\n WalletType,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n SwitchNetwork,\n WalletSigners,\n canSwitchNetworkToEvm,\n getEvmAccounts,\n subscribeToEvm,\n switchNetworkForEvm,\n evmBlockchains,\n BlockchainMeta,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { metamask as metamask_instance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletType.META_MASK;\n\nexport const config = {\n type: WALLET,\n};\n\nexport const getInstance = metamask_instance;\nexport const connect: Connect = async ({ instance }) => {\n // Note: We need to get `chainId` here, because for the first time\n // after opening the browser, wallet is locked, and don't give us accounts and chainId\n // on `check` phase, so `network` will be null. For this case we need to get chainId\n // whenever we are requesting accounts.\n const { accounts, chainId } = await getEvmAccounts(instance);\n\n return {\n accounts,\n chainId,\n };\n};\n\nexport const subscribe: Subscribe = subscribeToEvm;\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 return {\n name: 'MetaMask',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',\n\n FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',\n EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',\n DEFAULT: 'https://metamask.io/download/',\n },\n color: '#dac7ae',\n supportedChains: evms,\n };\n};\n"],"names":["metamask","isCoinbaseWalletAvailable","getCoinbaseInstance","window","ethereum","isMetaMask","getSigners","provider","defaultSigners","walletType","WalletType","META_MASK","supportEvm","WALLET","config","type","getInstance","metamask_instance","connect","instance","getEvmAccounts","accounts","chainId","subscribe","subscribeToEvm","switchNetwork","switchNetworkForEvm","canSwitchNetworkTo","canSwitchNetworkToEvm","signer","getWalletInfo","allBlockChains","evms","evmBlockchains","name","img","installLink","CHROME","BRAVE","FIREFOX","EDGE","DEFAULT","color","supportedChains"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEgBA,QAAQ;EACtB,IAAMC,yBAAyB,GAAG,CAAC,CAACC,mBAAmB,EAAE;EACzD,cAAqBC,MAAM;IAAnBC,QAAQ,WAARA,QAAQ;;EAGhB,IAAIH,yBAAyB,EAAE;;IAE7B,OAAOC,mBAAmB,CAAC,UAAU,CAAC;GACvC,MAAM;IACL,IAAI,CAAC,CAACE,QAAQ,IAAIA,QAAQ,CAACC,UAAU,EAAE;MACrC,OAAOD,QAAQ;;;EAGnB,OAAO,IAAI;AACb;;SCVwBE,UAAU,CAACC,QAAa;EAC9C,OAAOC,cAAc,CAAC;IACpBC,UAAU,EAAEC,UAAU,CAACC,SAAS;IAChCJ,QAAQ,EAARA,QAAQ;IACRK,UAAU,EAAE;GACb,CAAC;AACJ;;ACMA,IAAMC,MAAM,GAAGH,UAAU,CAACC,SAAS;AAEnC,IAAaG,MAAM,GAAG;EACpBC,IAAI,EAAEF;CACP;AAED,IAAaG,WAAW,GAAGC;AAC3B,IAAaC,OAAO;EAAA,oFAAY;IAAA;IAAA;MAAA;QAAA;UAASC,QAAQ,QAARA,QAAQ;UAAA;UAAA,OAKXC,cAAc,CAACD,QAAQ,CAAC;QAAA;UAAA;UAApDE,QAAQ,yBAARA,QAAQ;UAAEC,OAAO,yBAAPA,OAAO;UAAA,iCAElB;YACLD,QAAQ,EAARA,QAAQ;YACRC,OAAO,EAAPA;WACD;QAAA;QAAA;UAAA;;;GACF;EAAA,gBAXYJ,OAAO;IAAA;;AAAA,GAWnB;AAED,IAAaK,SAAS,GAAcC,cAAc;AAElD,IAAaC,aAAa,GAAkBC,mBAAmB;AAE/D,IAAaC,kBAAkB,GAAqBC,qBAAqB;AAEzE,IAAatB,YAAU,GAAqCuB;AAE5D,IAAaC,aAAa,GAAqD,SAAlEA,aAAa,CACxBC,cAAc;EAEd,IAAMC,IAAI,GAAGC,cAAc,CAACF,cAAc,CAAC;EAC3C,OAAO;IACLG,IAAI,EAAE,UAAU;IAChBC,GAAG,EAAE,qGAAqG;IAC1GC,WAAW,EAAE;MACXC,MAAM,EACJ,2FAA2F;MAC7FC,KAAK,EACH,2FAA2F;MAE7FC,OAAO,EAAE,+DAA+D;MACxEC,IAAI,EAAE,sGAAsG;MAC5GC,OAAO,EAAE;KACV;IACDC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAEX;GAClB;AACH,CAAC;;;;"}
@@ -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-metamask",
3
+ "version": "0.1.11-next.69",
4
+ "license": "MIT",
5
+ "module": "dist/provider-metamask.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-metamask.cjs.production.min.js",
40
+ "limit": "10 KB"
41
+ },
42
+ {
43
+ "path": "dist/provider-metamask.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
+ }
package/src/helpers.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { getCoinbaseInstance } from '@rango-dev/wallets-shared';
2
+
3
+ export function metamask() {
4
+ const isCoinbaseWalletAvailable = !!getCoinbaseInstance();
5
+ const { ethereum } = window;
6
+
7
+ // Some wallets overriding the metamask. So we need to get it properly.
8
+ if (isCoinbaseWalletAvailable) {
9
+ // Getting intance from overrided structure from coinbase.
10
+ return getCoinbaseInstance('metamask');
11
+ } else {
12
+ if (!!ethereum && ethereum.isMetaMask) {
13
+ return ethereum;
14
+ }
15
+ }
16
+ return null;
17
+ }
package/src/index.ts ADDED
@@ -0,0 +1,67 @@
1
+ import {
2
+ WalletType,
3
+ CanSwitchNetwork,
4
+ Connect,
5
+ Subscribe,
6
+ SwitchNetwork,
7
+ WalletSigners,
8
+ canSwitchNetworkToEvm,
9
+ getEvmAccounts,
10
+ subscribeToEvm,
11
+ switchNetworkForEvm,
12
+ evmBlockchains,
13
+ BlockchainMeta,
14
+ WalletInfo,
15
+ } from '@rango-dev/wallets-shared';
16
+ import { metamask as metamask_instance } from './helpers';
17
+ import signer from './signer';
18
+
19
+ const WALLET = WalletType.META_MASK;
20
+
21
+ export const config = {
22
+ type: WALLET,
23
+ };
24
+
25
+ export const getInstance = metamask_instance;
26
+ export const connect: Connect = async ({ instance }) => {
27
+ // Note: We need to get `chainId` here, because for the first time
28
+ // after opening the browser, wallet is locked, and don't give us accounts and chainId
29
+ // on `check` phase, so `network` will be null. For this case we need to get chainId
30
+ // whenever we are requesting accounts.
31
+ const { accounts, chainId } = await getEvmAccounts(instance);
32
+
33
+ return {
34
+ accounts,
35
+ chainId,
36
+ };
37
+ };
38
+
39
+ export const subscribe: Subscribe = subscribeToEvm;
40
+
41
+ export const switchNetwork: SwitchNetwork = switchNetworkForEvm;
42
+
43
+ export const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm;
44
+
45
+ export const getSigners: (provider: any) => WalletSigners = signer;
46
+
47
+ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
48
+ allBlockChains
49
+ ) => {
50
+ const evms = evmBlockchains(allBlockChains);
51
+ return {
52
+ name: 'MetaMask',
53
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/metamask.svg',
54
+ installLink: {
55
+ CHROME:
56
+ 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
57
+ BRAVE:
58
+ 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en',
59
+
60
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask',
61
+ EDGE: 'https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm?hl=en-US',
62
+ DEFAULT: 'https://metamask.io/download/',
63
+ },
64
+ color: '#dac7ae',
65
+ supportedChains: evms,
66
+ };
67
+ };
package/src/signer.ts ADDED
@@ -0,0 +1,13 @@
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
+ walletType: WalletType.META_MASK,
10
+ provider,
11
+ supportEvm: true,
12
+ });
13
+ }