@ant-design/web3-wagmi 2.7.1 → 2.7.2

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,14 @@
1
1
  # @ant-design/web3-wagmi
2
2
 
3
+ ## 2.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 3f7d7a6: build: set targets chrome 100
8
+ - Updated dependencies [3f7d7a6]
9
+ - @ant-design/web3-assets@1.10.1
10
+ - @ant-design/web3-common@1.12.1
11
+
3
12
  ## 2.7.1
4
13
 
5
14
  ### Patch Changes
package/dist/esm/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { injected } from 'wagmi/connectors';
2
- var isEIP6963Connector = function isEIP6963Connector(connector) {
2
+ const isEIP6963Connector = connector => {
3
3
  if (connector.type === injected.type && connector.icon && connector.id && connector.name) {
4
4
  return true;
5
5
  }
@@ -1,17 +1,3 @@
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); }); }; }
4
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
- 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."); }
6
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
- 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."); }
10
- 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); }
11
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- 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); }
15
1
  import React from 'react';
16
2
  import { Web3ConfigProvider } from '@ant-design/web3-common';
17
3
  import { useAccount, useBalance, useConfig, useConnect, useEnsAvatar, useEnsName, useSwitchChain } from 'wagmi';
@@ -20,125 +6,112 @@ import { isEIP6963Connector } from "../utils";
20
6
  import { EIP6963Wallet } from "../wallets/eip6963";
21
7
  import { getNFTMetadata } from "./methods";
22
8
  import { jsx as _jsx } from "react/jsx-runtime";
23
- export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(props) {
24
- var _availableChains$, _availableChains$2;
25
- var children = props.children,
26
- chainAssets = props.chainAssets,
27
- walletFactorys = props.walletFactorys,
28
- availableChains = props.availableChains,
29
- availableConnectors = props.availableConnectors,
30
- _props$ens = props.ens,
31
- ens = _props$ens === void 0 ? true : _props$ens,
32
- balance = props.balance,
33
- locale = props.locale,
34
- eip6963 = props.eip6963;
35
- var _useAccount = useAccount(),
36
- address = _useAccount.address,
37
- isDisconnected = _useAccount.isDisconnected,
38
- chain = _useAccount.chain;
39
- var config = useConfig();
40
- var _useConnect = useConnect(),
41
- connectAsync = _useConnect.connectAsync;
42
- var _useSwitchChain = useSwitchChain(),
43
- switchChain = _useSwitchChain.switchChain;
44
- var _useBalance = useBalance({
45
- address: address
46
- }),
47
- balanceData = _useBalance.data;
48
- var _useEnsName = useEnsName({
49
- address: address
50
- }),
51
- ensName = _useEnsName.data;
52
- var _useEnsAvatar = useEnsAvatar({
53
- name: ensName !== null && ensName !== void 0 ? ensName : undefined
54
- }),
55
- ensAvatar = _useEnsAvatar.data;
56
- var account = address && !isDisconnected ? {
57
- address: address,
9
+ export const AntDesignWeb3ConfigProvider = props => {
10
+ const {
11
+ children,
12
+ chainAssets,
13
+ walletFactorys,
14
+ availableChains,
15
+ availableConnectors,
16
+ ens = true,
17
+ balance,
18
+ locale,
19
+ eip6963
20
+ } = props;
21
+ const {
22
+ address,
23
+ isDisconnected,
24
+ chain
25
+ } = useAccount();
26
+ const config = useConfig();
27
+ const {
28
+ connectAsync
29
+ } = useConnect();
30
+ const {
31
+ switchChain
32
+ } = useSwitchChain();
33
+ const {
34
+ data: balanceData
35
+ } = useBalance({
36
+ address
37
+ });
38
+ const {
39
+ data: ensName
40
+ } = useEnsName({
41
+ address
42
+ });
43
+ const {
44
+ data: ensAvatar
45
+ } = useEnsAvatar({
46
+ name: ensName ?? undefined
47
+ });
48
+ const account = address && !isDisconnected ? {
49
+ address,
58
50
  name: ensName && ens ? ensName : undefined,
59
- avatar: ensAvatar !== null && ensAvatar !== void 0 ? ensAvatar : undefined
51
+ avatar: ensAvatar ?? undefined
60
52
  } : undefined;
61
- var findConnectorByName = function findConnectorByName(name) {
62
- var commonConnector = availableConnectors.find(function (item) {
63
- return item.name === name && !isEIP6963Connector(item);
64
- });
53
+ const findConnectorByName = name => {
54
+ const commonConnector = availableConnectors.find(item => item.name === name && !isEIP6963Connector(item));
65
55
  if (!eip6963) {
66
56
  return commonConnector;
67
57
  }
68
- var eip6963Connector = availableConnectors.find(function (item) {
69
- return item.name === name && isEIP6963Connector(item);
70
- });
58
+ const eip6963Connector = availableConnectors.find(item => item.name === name && isEIP6963Connector(item));
71
59
  return eip6963Connector || commonConnector;
72
60
  };
73
- var wallets = React.useMemo(function () {
74
- var autoAddEIP6963Wallets = [];
75
- availableConnectors.forEach(function (connector) {
61
+ const wallets = React.useMemo(() => {
62
+ const autoAddEIP6963Wallets = [];
63
+ availableConnectors.forEach(connector => {
76
64
  if (isEIP6963Connector(connector)) {
77
65
  // check is need auto add eip6963 wallet
78
- if (_typeof(eip6963) === 'object' && eip6963 !== null && eip6963 !== void 0 && eip6963.autoAddInjectedWallets && !walletFactorys.find(function (item) {
79
- return item.connectors.includes(connector.name);
80
- })) {
66
+ if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactorys.find(item => item.connectors.includes(connector.name))) {
81
67
  // not config wallet and find the wallet in connectors, auto add it
82
68
  autoAddEIP6963Wallets.push(EIP6963Wallet().create([connector]));
83
69
  }
84
70
  // Do not need check eip6963 wallet
85
71
  return;
86
72
  }
87
- var walletFactory = walletFactorys.find(function (factory) {
88
- return factory.connectors.includes(connector.name);
89
- });
90
- if (!(walletFactory !== null && walletFactory !== void 0 && walletFactory.create)) {
73
+ const walletFactory = walletFactorys.find(factory => factory.connectors.includes(connector.name));
74
+ if (!walletFactory?.create) {
91
75
  // check user wallets config and console.error for alert
92
- console.error("Can not find wallet factory for ".concat(connector.name, ", you should config it in WagmiWeb3ConfigProvider 'wallets'."));
76
+ console.error(`Can not find wallet factory for ${connector.name}, you should config it in WagmiWeb3ConfigProvider 'wallets'.`);
93
77
  }
94
78
  });
95
79
 
96
80
  // Generate Wallet for @ant-design/web3
97
- var supportWallets = walletFactorys.map(function (factory) {
98
- var connectors = factory.connectors.map(findConnectorByName).filter(function (item) {
99
- return !!item;
100
- });
81
+ const supportWallets = walletFactorys.map(factory => {
82
+ const connectors = factory.connectors.map(findConnectorByName).filter(item => !!item);
101
83
  if (connectors.length === 0 && !eip6963) {
102
84
  // Not config connector for this wallet factory and not use eip6963, ignore it.
103
- console.error("Can not find connector for ".concat(factory.connectors.join(','), ", ignore the wallet. Please config connectors or add eip6963 config in WagmiWeb3ConfigProvider."));
85
+ console.error(`Can not find connector for ${factory.connectors.join(',')}, ignore the wallet. Please config connectors or add eip6963 config in WagmiWeb3ConfigProvider.`);
104
86
  return null;
105
87
  }
106
88
  return factory.create(connectors);
107
- }).filter(function (item) {
108
- return item !== null;
109
- });
110
- return [].concat(_toConsumableArray(supportWallets), autoAddEIP6963Wallets);
89
+ }).filter(item => item !== null);
90
+ return [...supportWallets, ...autoAddEIP6963Wallets];
111
91
  }, [availableConnectors, walletFactorys, eip6963]);
112
- var chainList = React.useMemo(function () {
113
- return availableChains.map(function (item) {
114
- var c = chainAssets === null || chainAssets === void 0 ? void 0 : chainAssets.find(function (asset) {
92
+ const chainList = React.useMemo(() => {
93
+ return availableChains.map(item => {
94
+ const c = chainAssets?.find(asset => {
115
95
  return asset.id === item.id;
116
96
  });
117
- if (c !== null && c !== void 0 && c.id) {
97
+ if (c?.id) {
118
98
  return {
119
99
  id: c.id,
120
100
  name: c.name,
121
101
  icon: c.icon
122
102
  };
123
103
  }
124
- console.error("Can not find chain ".concat(item.id, ", you should config it in WagmiWeb3ConfigProvider 'chains'."));
104
+ console.error(`Can not find chain ${item.id}, you should config it in WagmiWeb3ConfigProvider 'chains'.`);
125
105
  return null;
126
- }).filter(function (item) {
127
- return item !== null;
128
- });
106
+ }).filter(item => item !== null);
129
107
  }, [availableChains, chainAssets]);
130
- var chainId = (chain === null || chain === void 0 ? void 0 : chain.id) || (availableChains === null || availableChains === void 0 || (_availableChains$ = availableChains[0]) === null || _availableChains$ === void 0 ? void 0 : _availableChains$.id);
131
- var chainName = (chain === null || chain === void 0 ? void 0 : chain.name) || (availableChains === null || availableChains === void 0 || (_availableChains$2 = availableChains[0]) === null || _availableChains$2 === void 0 ? void 0 : _availableChains$2.name);
132
- var _React$useState = React.useState(undefined),
133
- _React$useState2 = _slicedToArray(_React$useState, 2),
134
- currentChain = _React$useState2[0],
135
- setCurrentChain = _React$useState2[1];
136
- React.useEffect(function () {
137
- setCurrentChain(function (prevChain) {
108
+ const chainId = chain?.id || availableChains?.[0]?.id;
109
+ const chainName = chain?.name || availableChains?.[0]?.name;
110
+ const [currentChain, setCurrentChain] = React.useState(undefined);
111
+ React.useEffect(() => {
112
+ setCurrentChain(prevChain => {
138
113
  // not connected any chain, keep current chain
139
- var newChain = chainAssets === null || chainAssets === void 0 ? void 0 : chainAssets.find(function (item) {
140
- return (item === null || item === void 0 ? void 0 : item.id) === chainId;
141
- });
114
+ let newChain = chainAssets?.find(item => item?.id === chainId);
142
115
  if (!newChain && chainId) {
143
116
  newChain = {
144
117
  id: chainId,
@@ -148,121 +121,63 @@ export var AntDesignWeb3ConfigProvider = function AntDesignWeb3ConfigProvider(pr
148
121
  return newChain || prevChain;
149
122
  });
150
123
  }, [chainAssets, availableChains, chainId, chainName]);
151
- var currency = currentChain === null || currentChain === void 0 ? void 0 : currentChain.nativeCurrency;
152
- var getNFTMetadataFunc = React.useCallback( /*#__PURE__*/function () {
153
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
154
- var contractAddress, tokenId;
155
- return _regeneratorRuntime().wrap(function _callee$(_context) {
156
- while (1) switch (_context.prev = _context.next) {
157
- case 0:
158
- contractAddress = _ref.address, tokenId = _ref.tokenId;
159
- return _context.abrupt("return", getNFTMetadata(config, contractAddress, tokenId, chain === null || chain === void 0 ? void 0 : chain.id));
160
- case 2:
161
- case "end":
162
- return _context.stop();
163
- }
164
- }, _callee);
165
- }));
166
- return function (_x) {
167
- return _ref2.apply(this, arguments);
168
- };
169
- }(), [chain === null || chain === void 0 ? void 0 : chain.id]);
124
+ const currency = currentChain?.nativeCurrency;
125
+ const getNFTMetadataFunc = React.useCallback(async ({
126
+ address: contractAddress,
127
+ tokenId
128
+ }) => getNFTMetadata(config, contractAddress, tokenId, chain?.id), [chain?.id]);
170
129
  return /*#__PURE__*/_jsx(Web3ConfigProvider, {
171
130
  locale: locale,
172
131
  availableChains: chainList,
173
132
  chain: currentChain,
174
133
  account: account,
175
134
  balance: balance ? {
176
- symbol: balanceData === null || balanceData === void 0 ? void 0 : balanceData.symbol,
177
- value: balanceData === null || balanceData === void 0 ? void 0 : balanceData.value,
178
- decimals: balanceData === null || balanceData === void 0 ? void 0 : balanceData.decimals,
179
- icon: currency === null || currency === void 0 ? void 0 : currency.icon
135
+ symbol: balanceData?.symbol,
136
+ value: balanceData?.value,
137
+ decimals: balanceData?.decimals,
138
+ icon: currency?.icon
180
139
  } : undefined,
181
140
  availableWallets: wallets,
182
141
  addressPrefix: "0x",
183
- connect: ( /*#__PURE__*/function () {
184
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(wallet, options) {
185
- var _getWagmiConnector, _ref4;
186
- var connector, _yield$connectAsync, accounts;
187
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
188
- while (1) switch (_context2.prev = _context2.next) {
189
- case 0:
190
- _context2.next = 2;
191
- return wallet === null || wallet === void 0 || (_getWagmiConnector = (_ref4 = wallet).getWagmiConnector) === null || _getWagmiConnector === void 0 ? void 0 : _getWagmiConnector.call(_ref4, options);
192
- case 2:
193
- connector = _context2.sent;
194
- if (!connector && wallet) {
195
- connector = findConnectorByName(wallet.name);
196
- }
197
- if (connector) {
198
- _context2.next = 6;
199
- break;
200
- }
201
- throw new Error("Can not find connector for ".concat(wallet === null || wallet === void 0 ? void 0 : wallet.name));
202
- case 6:
203
- _context2.next = 8;
204
- return connectAsync({
205
- connector: connector,
206
- chainId: currentChain === null || currentChain === void 0 ? void 0 : currentChain.id
207
- });
208
- case 8:
209
- _yield$connectAsync = _context2.sent;
210
- accounts = _yield$connectAsync.accounts;
211
- return _context2.abrupt("return", {
212
- address: accounts === null || accounts === void 0 ? void 0 : accounts[0]
213
- });
214
- case 11:
215
- case "end":
216
- return _context2.stop();
217
- }
218
- }, _callee2);
219
- }));
220
- return function (_x2, _x3) {
221
- return _ref3.apply(this, arguments);
222
- };
223
- }()),
224
- disconnect: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
225
- var _getAccount, connector;
226
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
227
- while (1) switch (_context3.prev = _context3.next) {
228
- case 0:
229
- // await disconnectAsync();
230
- // TODO@jeasonstudio: wagmi useDisconnect hook 在处理多实例(config)共存时,
231
- // 存在一些状态处理的 bug,暂时用更低阶 API 代替。
232
- _getAccount = getAccount(config), connector = _getAccount.connector;
233
- _context3.next = 3;
234
- return disconnect(config, {
235
- connector: connector
236
- });
237
- case 3:
238
- case "end":
239
- return _context3.stop();
240
- }
241
- }, _callee3);
242
- })),
243
- switchChain: ( /*#__PURE__*/function () {
244
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(newChain) {
245
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
246
- while (1) switch (_context4.prev = _context4.next) {
247
- case 0:
248
- if (!chain) {
249
- // hava not connected any chain
250
- setCurrentChain(newChain);
251
- } else {
252
- switchChain === null || switchChain === void 0 || switchChain({
253
- chainId: newChain.id
254
- });
255
- }
256
- case 1:
257
- case "end":
258
- return _context4.stop();
259
- }
260
- }, _callee4);
261
- }));
262
- return function (_x4) {
263
- return _ref6.apply(this, arguments);
142
+ connect: async (wallet, options) => {
143
+ let connector = await wallet?.getWagmiConnector?.(options);
144
+ if (!connector && wallet) {
145
+ connector = findConnectorByName(wallet.name);
146
+ }
147
+ if (!connector) {
148
+ throw new Error(`Can not find connector for ${wallet?.name}`);
149
+ }
150
+ const {
151
+ accounts
152
+ } = await connectAsync({
153
+ connector,
154
+ chainId: currentChain?.id
155
+ });
156
+ return {
157
+ address: accounts?.[0]
264
158
  };
265
- }()),
159
+ },
160
+ disconnect: async () => {
161
+ // await disconnectAsync();
162
+ // TODO@jeasonstudio: wagmi useDisconnect hook 在处理多实例(config)共存时,
163
+ // 存在一些状态处理的 bug,暂时用更低阶 API 代替。
164
+ const {
165
+ connector
166
+ } = getAccount(config);
167
+ await disconnect(config, {
168
+ connector
169
+ });
170
+ },
171
+ switchChain: async newChain => {
172
+ if (!chain) {
173
+ // hava not connected any chain
174
+ setCurrentChain(newChain);
175
+ } else {
176
+ switchChain?.({
177
+ chainId: newChain.id
178
+ });
179
+ }
180
+ },
266
181
  getNFTMetadata: getNFTMetadataFunc,
267
182
  children: children
268
183
  });
@@ -1,18 +1,3 @@
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
- var _excluded = ["children", "wallets", "chains", "ens", "locale", "balance", "config", "queryClient", "eip6963"];
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
- 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."); }
10
- 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); }
11
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
1
  import React from 'react';
17
2
  // Built in popular chains
18
3
  import { Mainnet } from '@ant-design/web3-assets';
@@ -20,26 +5,25 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
20
5
  import { WagmiProvider } from 'wagmi';
21
6
  import { AntDesignWeb3ConfigProvider } from "./config-provider";
22
7
  import { jsx as _jsx } from "react/jsx-runtime";
23
- export function WagmiWeb3ConfigProvider(_ref) {
24
- var children = _ref.children,
25
- _ref$wallets = _ref.wallets,
26
- wallets = _ref$wallets === void 0 ? [] : _ref$wallets,
27
- _ref$chains = _ref.chains,
28
- chains = _ref$chains === void 0 ? [] : _ref$chains,
29
- ens = _ref.ens,
30
- locale = _ref.locale,
31
- balance = _ref.balance,
32
- config = _ref.config,
33
- queryClient = _ref.queryClient,
34
- eip6963 = _ref.eip6963,
35
- restProps = _objectWithoutProperties(_ref, _excluded);
36
- var chainAssets = [].concat(_toConsumableArray(chains), [Mainnet]);
37
- var mergedQueryClient = React.useMemo(function () {
38
- return queryClient !== null && queryClient !== void 0 ? queryClient : new QueryClient();
8
+ export function WagmiWeb3ConfigProvider({
9
+ children,
10
+ wallets = [],
11
+ chains = [],
12
+ ens,
13
+ locale,
14
+ balance,
15
+ config,
16
+ queryClient,
17
+ eip6963,
18
+ ...restProps
19
+ }) {
20
+ const chainAssets = [...chains, Mainnet];
21
+ const mergedQueryClient = React.useMemo(() => {
22
+ return queryClient ?? new QueryClient();
39
23
  }, [queryClient]);
40
- return /*#__PURE__*/_jsx(WagmiProvider, _objectSpread(_objectSpread({
41
- config: config
42
- }, restProps), {}, {
24
+ return /*#__PURE__*/_jsx(WagmiProvider, {
25
+ config: config,
26
+ ...restProps,
43
27
  children: /*#__PURE__*/_jsx(QueryClientProvider, {
44
28
  client: mergedQueryClient,
45
29
  children: /*#__PURE__*/_jsx(AntDesignWeb3ConfigProvider, {
@@ -54,5 +38,5 @@ export function WagmiWeb3ConfigProvider(_ref) {
54
38
  children: children
55
39
  })
56
40
  })
57
- }));
41
+ });
58
42
  }
@@ -1,50 +1,25 @@
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 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); } }
4
- 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); }); }; }
5
1
  import { fillAddressWith0x, requestWeb3Asset } from '@ant-design/web3-common';
6
2
  import { readContract } from 'wagmi/actions';
7
- export function getNFTMetadata(_x, _x2, _x3, _x4) {
8
- return _getNFTMetadata.apply(this, arguments);
9
- }
10
- function _getNFTMetadata() {
11
- _getNFTMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, address, tokenId, chainId) {
12
- var tokenURI, metaInfo;
13
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14
- while (1) switch (_context.prev = _context.next) {
15
- case 0:
16
- _context.next = 2;
17
- return readContract(config, {
18
- address: fillAddressWith0x(address),
19
- args: [tokenId],
20
- chainId: chainId,
21
- abi: [{
22
- name: 'tokenURI',
23
- inputs: [{
24
- name: 'tokenId',
25
- type: 'uint256'
26
- }],
27
- outputs: [{
28
- name: '',
29
- type: 'string'
30
- }],
31
- stateMutability: 'view',
32
- type: 'function'
33
- }],
34
- functionName: 'tokenURI'
35
- });
36
- case 2:
37
- tokenURI = _context.sent;
38
- _context.next = 5;
39
- return requestWeb3Asset(tokenURI);
40
- case 5:
41
- metaInfo = _context.sent;
42
- return _context.abrupt("return", metaInfo);
43
- case 7:
44
- case "end":
45
- return _context.stop();
46
- }
47
- }, _callee);
48
- }));
49
- return _getNFTMetadata.apply(this, arguments);
3
+ export async function getNFTMetadata(config, address, tokenId, chainId) {
4
+ const tokenURI = await readContract(config, {
5
+ address: fillAddressWith0x(address),
6
+ args: [tokenId],
7
+ chainId,
8
+ abi: [{
9
+ name: 'tokenURI',
10
+ inputs: [{
11
+ name: 'tokenId',
12
+ type: 'uint256'
13
+ }],
14
+ outputs: [{
15
+ name: '',
16
+ type: 'string'
17
+ }],
18
+ stateMutability: 'view',
19
+ type: 'function'
20
+ }],
21
+ functionName: 'tokenURI'
22
+ });
23
+ const metaInfo = await requestWeb3Asset(tokenURI);
24
+ return metaInfo;
50
25
  }