@ant-design/web3-wagmi 2.4.5 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @ant-design/web3-wagmi
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8a6d1c7: feat: add mobile wallet
8
+
9
+ ### Patch Changes
10
+
11
+ - 752dddd: refactor(wagmi): use ens hook instead of low-level api
12
+ - 6511134: refactor: remove useless proxyConnectorName
13
+ - Updated dependencies [6511134]
14
+ - Updated dependencies [8a6d1c7]
15
+ - @ant-design/web3-assets@1.8.0
16
+ - @ant-design/web3-common@1.10.1
17
+
3
18
  ## 2.4.5
4
19
 
5
20
  ### Patch Changes
@@ -1,11 +1,11 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, 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 define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("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 handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
8
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, 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 define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("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 handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
10
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -15,10 +15,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import React from 'react';
16
16
  import { fillAddressWith0x, Web3ConfigProvider } from '@ant-design/web3-common';
17
17
  import { disconnect, getAccount } from '@wagmi/core';
18
- import { useAccount, useBalance, useConfig, useConnect, useSwitchChain } from 'wagmi';
18
+ import { useAccount, useBalance, useConfig, useConnect, useEnsName, useSwitchChain } from 'wagmi';
19
19
  import { isEIP6963Connector } from "../utils";
20
20
  import { EIP6963Wallet } from "../wallets/eip6963";
21
- import { addNameToAccount, getNFTMetadata } from "./methods";
21
+ import { getNFTMetadata } from "./methods";
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(props) {
24
24
  var _availableChains$, _availableChains$2;
@@ -48,43 +48,24 @@ export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(pr
48
48
  address: balance && account ? fillAddressWith0x(account.address) : undefined
49
49
  }),
50
50
  balanceData = _useBalance.data;
51
+ var _useEnsName = useEnsName({
52
+ address: address
53
+ }),
54
+ ensName = _useEnsName.data;
51
55
  React.useEffect(function () {
52
56
  if (!address || isDisconnected) {
53
57
  setAccount(undefined);
58
+ } else if (ens && ensName) {
59
+ setAccount({
60
+ address: fillAddressWith0x(address),
61
+ name: ensName
62
+ });
54
63
  } else {
55
- var updateAccounts = /*#__PURE__*/function () {
56
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
57
- var a;
58
- return _regeneratorRuntime().wrap(function _callee$(_context) {
59
- while (1) switch (_context.prev = _context.next) {
60
- case 0:
61
- a = {
62
- address: address
63
- };
64
- setAccount(a);
65
- if (!ens) {
66
- _context.next = 8;
67
- break;
68
- }
69
- _context.t0 = setAccount;
70
- _context.next = 6;
71
- return addNameToAccount(config, a);
72
- case 6:
73
- _context.t1 = _context.sent;
74
- (0, _context.t0)(_context.t1);
75
- case 8:
76
- case "end":
77
- return _context.stop();
78
- }
79
- }, _callee);
80
- }));
81
- return function updateAccounts() {
82
- return _ref.apply(this, arguments);
83
- };
84
- }();
85
- updateAccounts();
64
+ setAccount({
65
+ address: fillAddressWith0x(address)
66
+ });
86
67
  }
87
- }, [address, isDisconnected, chain, ens]);
68
+ }, [address, isDisconnected, ens, ensName]);
88
69
  var findConnectorByName = function findConnectorByName(name) {
89
70
  var commonConnector = availableConnectors.find(function (item) {
90
71
  return item.name === name && !isEIP6963Connector(item);
@@ -177,21 +158,21 @@ export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(pr
177
158
  }, [chainAssets, availableChains, chainId, chainName]);
178
159
  var currency = currentChain === null || currentChain === void 0 ? void 0 : currentChain.nativeCurrency;
179
160
  var getNFTMetadataFunc = React.useCallback( /*#__PURE__*/function () {
180
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
161
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
181
162
  var contractAddress, tokenId;
182
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
183
- while (1) switch (_context2.prev = _context2.next) {
163
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
164
+ while (1) switch (_context.prev = _context.next) {
184
165
  case 0:
185
- contractAddress = _ref2.address, tokenId = _ref2.tokenId;
186
- return _context2.abrupt("return", getNFTMetadata(config, contractAddress, tokenId, chain === null || chain === void 0 ? void 0 : chain.id));
166
+ contractAddress = _ref.address, tokenId = _ref.tokenId;
167
+ return _context.abrupt("return", getNFTMetadata(config, contractAddress, tokenId, chain === null || chain === void 0 ? void 0 : chain.id));
187
168
  case 2:
188
169
  case "end":
189
- return _context2.stop();
170
+ return _context.stop();
190
171
  }
191
- }, _callee2);
172
+ }, _callee);
192
173
  }));
193
174
  return function (_x) {
194
- return _ref3.apply(this, arguments);
175
+ return _ref2.apply(this, arguments);
195
176
  };
196
177
  }(), [chain === null || chain === void 0 ? void 0 : chain.id]);
197
178
  return /*#__PURE__*/_jsx(Web3ConfigProvider, {
@@ -208,63 +189,63 @@ export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(pr
208
189
  availableWallets: wallets,
209
190
  addressPrefix: "0x",
210
191
  connect: ( /*#__PURE__*/function () {
211
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(wallet, options) {
212
- var _getWagmiConnector, _ref5;
192
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(wallet, options) {
193
+ var _getWagmiConnector, _ref4;
213
194
  var connector;
214
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
215
- while (1) switch (_context3.prev = _context3.next) {
195
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
196
+ while (1) switch (_context2.prev = _context2.next) {
216
197
  case 0:
217
- _context3.next = 2;
218
- return wallet === null || wallet === void 0 || (_getWagmiConnector = (_ref5 = wallet).getWagmiConnector) === null || _getWagmiConnector === void 0 ? void 0 : _getWagmiConnector.call(_ref5, options);
198
+ _context2.next = 2;
199
+ return wallet === null || wallet === void 0 || (_getWagmiConnector = (_ref4 = wallet).getWagmiConnector) === null || _getWagmiConnector === void 0 ? void 0 : _getWagmiConnector.call(_ref4, options);
219
200
  case 2:
220
- connector = _context3.sent;
201
+ connector = _context2.sent;
221
202
  if (!connector && wallet) {
222
203
  connector = findConnectorByName(wallet.name);
223
204
  }
224
205
  if (connector) {
225
- _context3.next = 6;
206
+ _context2.next = 6;
226
207
  break;
227
208
  }
228
209
  throw new Error("Can not find connector for ".concat(wallet === null || wallet === void 0 ? void 0 : wallet.name));
229
210
  case 6:
230
- _context3.next = 8;
211
+ _context2.next = 8;
231
212
  return connectAsync({
232
213
  connector: connector,
233
214
  chainId: currentChain === null || currentChain === void 0 ? void 0 : currentChain.id
234
215
  });
235
216
  case 8:
236
217
  case "end":
237
- return _context3.stop();
218
+ return _context2.stop();
238
219
  }
239
- }, _callee3);
220
+ }, _callee2);
240
221
  }));
241
222
  return function (_x2, _x3) {
242
- return _ref4.apply(this, arguments);
223
+ return _ref3.apply(this, arguments);
243
224
  };
244
225
  }()),
245
- disconnect: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
226
+ disconnect: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
246
227
  var _getAccount, connector;
247
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
248
- while (1) switch (_context4.prev = _context4.next) {
228
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
229
+ while (1) switch (_context3.prev = _context3.next) {
249
230
  case 0:
250
231
  // await disconnectAsync();
251
232
  // TODO@jeasonstudio: wagmi useDisconnect hook 在处理多实例(config)共存时,
252
233
  // 存在一些状态处理的 bug,暂时用更低阶 API 代替。
253
234
  _getAccount = getAccount(config), connector = _getAccount.connector;
254
- _context4.next = 3;
235
+ _context3.next = 3;
255
236
  return disconnect(config, {
256
237
  connector: connector
257
238
  });
258
239
  case 3:
259
240
  case "end":
260
- return _context4.stop();
241
+ return _context3.stop();
261
242
  }
262
- }, _callee4);
243
+ }, _callee3);
263
244
  })),
264
245
  switchChain: ( /*#__PURE__*/function () {
265
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(newChain) {
266
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
267
- while (1) switch (_context5.prev = _context5.next) {
246
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(newChain) {
247
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
248
+ while (1) switch (_context4.prev = _context4.next) {
268
249
  case 0:
269
250
  if (!chain) {
270
251
  // hava not connected any chain
@@ -276,12 +257,12 @@ export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(pr
276
257
  }
277
258
  case 1:
278
259
  case "end":
279
- return _context5.stop();
260
+ return _context4.stop();
280
261
  }
281
- }, _callee5);
262
+ }, _callee4);
282
263
  }));
283
264
  return function (_x4) {
284
- return _ref7.apply(this, arguments);
265
+ return _ref6.apply(this, arguments);
285
266
  };
286
267
  }()),
287
268
  getNFTMetadata: getNFTMetadataFunc,
@@ -1,2 +1 @@
1
- export * from './addNameToAccount';
2
1
  export * from './getNFTMetadata';
@@ -1,2 +1 @@
1
- export * from "./addNameToAccount";
2
1
  export * from "./getNFTMetadata";
@@ -6,3 +6,4 @@ export * from './safeheron';
6
6
  export * from './universal-wallet';
7
7
  export * from './okx-wallet';
8
8
  export * from './im-token';
9
+ export * from './mobile-wallet';
@@ -5,4 +5,5 @@ export * from "./token-pocket";
5
5
  export * from "./safeheron";
6
6
  export * from "./universal-wallet";
7
7
  export * from "./okx-wallet";
8
- export * from "./im-token";
8
+ export * from "./im-token";
9
+ export * from "./mobile-wallet";
@@ -0,0 +1,2 @@
1
+ import { type EthereumWalletConnect } from './wallet-connect';
2
+ export declare const MobileWallet: EthereumWalletConnect;
@@ -0,0 +1,11 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { metadata_MobileConnect } from '@ant-design/web3-assets';
8
+ import { WalletConnect } from "./wallet-connect";
9
+ export var MobileWallet = function MobileWallet(metadata) {
10
+ return WalletConnect(_objectSpread(_objectSpread({}, metadata_MobileConnect), metadata));
11
+ };
@@ -1,7 +1,6 @@
1
1
  import type { WalletMetadata } from '@ant-design/web3-common';
2
2
  import type { WalletFactory } from '../interface';
3
- type EthereumWalletConnect = (metadata?: Partial<WalletMetadata> & {
3
+ export type EthereumWalletConnect = (metadata?: Partial<WalletMetadata> & {
4
4
  useWalletConnectOfficialModal?: boolean;
5
5
  }) => WalletFactory;
6
6
  export declare const WalletConnect: EthereumWalletConnect;
7
- export {};
@@ -56,18 +56,35 @@ export var WalletConnect = function WalletConnect(metadata) {
56
56
  };
57
57
  }();
58
58
  return _objectSpread(_objectSpread({}, metadata_WalletConnect), {}, {
59
- hasWalletReady: function () {
60
- var _hasWalletReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
59
+ getWagmiConnector: function () {
60
+ var _getWagmiConnector = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
61
61
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
62
62
  while (1) switch (_context2.prev = _context2.next) {
63
63
  case 0:
64
- return _context2.abrupt("return", true);
64
+ return _context2.abrupt("return", connectors === null || connectors === void 0 ? void 0 : connectors[0]);
65
65
  case 1:
66
66
  case "end":
67
67
  return _context2.stop();
68
68
  }
69
69
  }, _callee2);
70
70
  }));
71
+ function getWagmiConnector() {
72
+ return _getWagmiConnector.apply(this, arguments);
73
+ }
74
+ return getWagmiConnector;
75
+ }(),
76
+ hasWalletReady: function () {
77
+ var _hasWalletReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
78
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
79
+ while (1) switch (_context3.prev = _context3.next) {
80
+ case 0:
81
+ return _context3.abrupt("return", true);
82
+ case 1:
83
+ case "end":
84
+ return _context3.stop();
85
+ }
86
+ }, _callee3);
87
+ }));
71
88
  function hasWalletReady() {
72
89
  return _hasWalletReady.apply(this, arguments);
73
90
  }
@@ -43,22 +43,25 @@ const AntDesignWeb3ConfigProvider = props => {
43
43
  } = (0, _wagmi.useBalance)({
44
44
  address: balance && account ? (0, _web3Common.fillAddressWith0x)(account.address) : undefined
45
45
  });
46
+ const {
47
+ data: ensName
48
+ } = (0, _wagmi.useEnsName)({
49
+ address
50
+ });
46
51
  _react.default.useEffect(() => {
47
52
  if (!address || isDisconnected) {
48
53
  setAccount(undefined);
54
+ } else if (ens && ensName) {
55
+ setAccount({
56
+ address: (0, _web3Common.fillAddressWith0x)(address),
57
+ name: ensName
58
+ });
49
59
  } else {
50
- const updateAccounts = async () => {
51
- const a = {
52
- address
53
- };
54
- setAccount(a);
55
- if (ens) {
56
- setAccount(await (0, _methods.addNameToAccount)(config, a));
57
- }
58
- };
59
- updateAccounts();
60
+ setAccount({
61
+ address: (0, _web3Common.fillAddressWith0x)(address)
62
+ });
60
63
  }
61
- }, [address, isDisconnected, chain, ens]);
64
+ }, [address, isDisconnected, ens, ensName]);
62
65
  const findConnectorByName = name => {
63
66
  const commonConnector = availableConnectors.find(item => item.name === name && !(0, _utils.isEIP6963Connector)(item));
64
67
  if (!eip6963) {
@@ -1,2 +1 @@
1
- export * from './addNameToAccount';
2
1
  export * from './getNFTMetadata';
@@ -3,17 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _addNameToAccount = require("./addNameToAccount");
7
- Object.keys(_addNameToAccount).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _addNameToAccount[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _addNameToAccount[key];
14
- }
15
- });
16
- });
17
6
  var _getNFTMetadata = require("./getNFTMetadata");
18
7
  Object.keys(_getNFTMetadata).forEach(function (key) {
19
8
  if (key === "default" || key === "__esModule") return;
@@ -6,3 +6,4 @@ export * from './safeheron';
6
6
  export * from './universal-wallet';
7
7
  export * from './okx-wallet';
8
8
  export * from './im-token';
9
+ export * from './mobile-wallet';
@@ -90,4 +90,15 @@ Object.keys(_imToken).forEach(function (key) {
90
90
  return _imToken[key];
91
91
  }
92
92
  });
93
+ });
94
+ var _mobileWallet = require("./mobile-wallet");
95
+ Object.keys(_mobileWallet).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _mobileWallet[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _mobileWallet[key];
102
+ }
103
+ });
93
104
  });
@@ -0,0 +1,2 @@
1
+ import { type EthereumWalletConnect } from './wallet-connect';
2
+ export declare const MobileWallet: EthereumWalletConnect;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MobileWallet = void 0;
7
+ var _web3Assets = require("@ant-design/web3-assets");
8
+ var _walletConnect = require("./wallet-connect");
9
+ const MobileWallet = metadata => {
10
+ return (0, _walletConnect.WalletConnect)({
11
+ ..._web3Assets.metadata_MobileConnect,
12
+ ...metadata
13
+ });
14
+ };
15
+ exports.MobileWallet = MobileWallet;
@@ -1,7 +1,6 @@
1
1
  import type { WalletMetadata } from '@ant-design/web3-common';
2
2
  import type { WalletFactory } from '../interface';
3
- type EthereumWalletConnect = (metadata?: Partial<WalletMetadata> & {
3
+ export type EthereumWalletConnect = (metadata?: Partial<WalletMetadata> & {
4
4
  useWalletConnectOfficialModal?: boolean;
5
5
  }) => WalletFactory;
6
6
  export declare const WalletConnect: EthereumWalletConnect;
7
- export {};
@@ -33,6 +33,9 @@ const WalletConnect = metadata => {
33
33
  };
34
34
  return {
35
35
  ..._web3Assets.metadata_WalletConnect,
36
+ getWagmiConnector: async () => {
37
+ return connectors?.[0];
38
+ },
36
39
  hasWalletReady: async () => {
37
40
  return true;
38
41
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/web3-wagmi",
3
- "version": "2.4.5",
3
+ "version": "2.5.0",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -39,14 +39,14 @@
39
39
  "dependencies": {
40
40
  "debug": "^4.3.4",
41
41
  "@wagmi/core": "^2.9.6",
42
- "@ant-design/web3-assets": "1.7.2",
43
- "@ant-design/web3-common": "1.10.0"
42
+ "@ant-design/web3-assets": "1.8.0",
43
+ "@ant-design/web3-common": "1.10.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/debug": "^4.1.12",
47
47
  "@wagmi/core": "^2.9.3",
48
48
  "father": "^4.4.0",
49
- "typescript": "^5.4.4",
49
+ "typescript": "^5.4.5",
50
50
  "wagmi": "^2.8.6",
51
51
  "@tanstack/react-query": "^5.37.1",
52
52
  "viem": "^2.10.3"
@@ -1,3 +0,0 @@
1
- import type { Account } from '@ant-design/web3-common';
2
- import type { Config } from 'wagmi';
3
- export declare function addNameToAccount(config: Config, account: Account, chainId?: number): Promise<Account>;
@@ -1,37 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, 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 define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("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 handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
- import { getEnsName } from '@wagmi/core';
11
- export function addNameToAccount(_x, _x2, _x3) {
12
- return _addNameToAccount.apply(this, arguments);
13
- }
14
- function _addNameToAccount() {
15
- _addNameToAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, account, chainId) {
16
- var name;
17
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- _context.next = 2;
21
- return getEnsName(config, {
22
- address: account.address,
23
- chainId: chainId
24
- });
25
- case 2:
26
- name = _context.sent;
27
- return _context.abrupt("return", _objectSpread(_objectSpread({}, account), {}, {
28
- name: name !== null && name !== void 0 ? name : undefined
29
- }));
30
- case 4:
31
- case "end":
32
- return _context.stop();
33
- }
34
- }, _callee);
35
- }));
36
- return _addNameToAccount.apply(this, arguments);
37
- }
@@ -1,3 +0,0 @@
1
- import type { Account } from '@ant-design/web3-common';
2
- import type { Config } from 'wagmi';
3
- export declare function addNameToAccount(config: Config, account: Account, chainId?: number): Promise<Account>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.addNameToAccount = addNameToAccount;
7
- var _core = require("@wagmi/core");
8
- async function addNameToAccount(config, account, chainId) {
9
- const name = await (0, _core.getEnsName)(config, {
10
- address: account.address,
11
- chainId
12
- });
13
- return {
14
- ...account,
15
- name: name ?? undefined
16
- };
17
- }