@dynamic-labs/wagmi-connector 0.15.6 → 0.15.7

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/index.cjs CHANGED
@@ -1293,6 +1293,46 @@ class Connector extends wagmi.Connector {
1293
1293
  }
1294
1294
  }
1295
1295
 
1296
+ const SyncDynamicWagmi = ({
1297
+ children,
1298
+ connector
1299
+ }) => {
1300
+ const {
1301
+ status: clientStatus
1302
+ } = wagmi.useClient();
1303
+ const {
1304
+ walletConnector
1305
+ } = sdkReact.useDynamicContext();
1306
+ const {
1307
+ connect,
1308
+ status
1309
+ } = wagmi.useConnect();
1310
+ const {
1311
+ disconnect
1312
+ } = wagmi.useDisconnect();
1313
+ if (walletConnector) {
1314
+ // after connection is successful, re-setup event listeners after a short delay
1315
+ // so that they are not cleared by the teardown in useWalletEventListeners
1316
+ if (status === 'success') {
1317
+ setTimeout(() => {
1318
+ connector === null || connector === void 0 ? void 0 : connector.setupEventListeners();
1319
+ }, 100);
1320
+ }
1321
+ }
1322
+ React.useEffect(() => {
1323
+ if (!walletConnector) {
1324
+ disconnect();
1325
+ } else if (connector && clientStatus !== 'connected') {
1326
+ connect({
1327
+ connector
1328
+ });
1329
+ }
1330
+ }, [clientStatus, connect, connector, disconnect, walletConnector]);
1331
+ // use React.createElement to prevent bunding react/jsx-runtime,
1332
+ // which is not compatible when bundling apps using React 17
1333
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children);
1334
+ };
1335
+
1296
1336
  var objectDefineProperties = {};
1297
1337
 
1298
1338
  var DESCRIPTORS$1 = descriptors;
@@ -1426,11 +1466,192 @@ var addToUnscopables$2 = function (key) {
1426
1466
  ArrayPrototype[UNSCOPABLES][key] = true;
1427
1467
  };
1428
1468
 
1469
+ var $$2 = _export;
1470
+ var $includes = arrayIncludes.includes;
1471
+ var fails$2 = fails$c;
1472
+ var addToUnscopables$1 = addToUnscopables$2;
1473
+
1474
+ // FF99+ bug
1475
+ var BROKEN_ON_SPARSE = fails$2(function () {
1476
+ return !Array(1).includes();
1477
+ });
1478
+
1479
+ // `Array.prototype.includes` method
1480
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
1481
+ $$2({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
1482
+ includes: function includes(el /* , fromIndex = 0 */) {
1483
+ return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
1484
+ }
1485
+ });
1486
+
1487
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1488
+ addToUnscopables$1('includes');
1489
+
1490
+ var isObject$1 = isObject$7;
1491
+ var classof$2 = classofRaw$1;
1492
+ var wellKnownSymbol$7 = wellKnownSymbol$a;
1493
+
1494
+ var MATCH$1 = wellKnownSymbol$7('match');
1495
+
1496
+ // `IsRegExp` abstract operation
1497
+ // https://tc39.es/ecma262/#sec-isregexp
1498
+ var isRegexp = function (it) {
1499
+ var isRegExp;
1500
+ return isObject$1(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$2(it) == 'RegExp');
1501
+ };
1502
+
1503
+ var isRegExp = isRegexp;
1504
+
1505
+ var $TypeError$1 = TypeError;
1506
+
1507
+ var notARegexp = function (it) {
1508
+ if (isRegExp(it)) {
1509
+ throw $TypeError$1("The method doesn't accept regular expressions");
1510
+ } return it;
1511
+ };
1512
+
1513
+ var wellKnownSymbol$6 = wellKnownSymbol$a;
1514
+
1515
+ var TO_STRING_TAG$3 = wellKnownSymbol$6('toStringTag');
1516
+ var test = {};
1517
+
1518
+ test[TO_STRING_TAG$3] = 'z';
1519
+
1520
+ var toStringTagSupport = String(test) === '[object z]';
1521
+
1522
+ var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1523
+ var isCallable$4 = isCallable$f;
1524
+ var classofRaw = classofRaw$1;
1525
+ var wellKnownSymbol$5 = wellKnownSymbol$a;
1526
+
1527
+ var TO_STRING_TAG$2 = wellKnownSymbol$5('toStringTag');
1528
+ var $Object$1 = Object;
1529
+
1530
+ // ES3 wrong here
1531
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1532
+
1533
+ // fallback for IE11 Script Access Denied error
1534
+ var tryGet = function (it, key) {
1535
+ try {
1536
+ return it[key];
1537
+ } catch (error) { /* empty */ }
1538
+ };
1539
+
1540
+ // getting tag from ES6+ `Object.prototype.toString`
1541
+ var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1542
+ var O, tag, result;
1543
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1544
+ // @@toStringTag case
1545
+ : typeof (tag = tryGet(O = $Object$1(it), TO_STRING_TAG$2)) == 'string' ? tag
1546
+ // builtinTag case
1547
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1548
+ // ES3 arguments fallback
1549
+ : (result = classofRaw(O)) == 'Object' && isCallable$4(O.callee) ? 'Arguments' : result;
1550
+ };
1551
+
1552
+ var classof = classof$1;
1553
+
1554
+ var $String$1 = String;
1555
+
1556
+ var toString$1 = function (argument) {
1557
+ if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
1558
+ return $String$1(argument);
1559
+ };
1560
+
1561
+ var wellKnownSymbol$4 = wellKnownSymbol$a;
1562
+
1563
+ var MATCH = wellKnownSymbol$4('match');
1564
+
1565
+ var correctIsRegexpLogic = function (METHOD_NAME) {
1566
+ var regexp = /./;
1567
+ try {
1568
+ '/./'[METHOD_NAME](regexp);
1569
+ } catch (error1) {
1570
+ try {
1571
+ regexp[MATCH] = false;
1572
+ return '/./'[METHOD_NAME](regexp);
1573
+ } catch (error2) { /* empty */ }
1574
+ } return false;
1575
+ };
1576
+
1577
+ var $$1 = _export;
1578
+ var uncurryThis$1 = functionUncurryThis;
1579
+ var notARegExp = notARegexp;
1580
+ var requireObjectCoercible = requireObjectCoercible$3;
1581
+ var toString = toString$1;
1582
+ var correctIsRegExpLogic = correctIsRegexpLogic;
1583
+
1584
+ var stringIndexOf = uncurryThis$1(''.indexOf);
1585
+
1586
+ // `String.prototype.includes` method
1587
+ // https://tc39.es/ecma262/#sec-string.prototype.includes
1588
+ $$1({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
1589
+ includes: function includes(searchString /* , position = 0 */) {
1590
+ return !!~stringIndexOf(
1591
+ toString(requireObjectCoercible(this)),
1592
+ toString(notARegExp(searchString)),
1593
+ arguments.length > 1 ? arguments[1] : undefined
1594
+ );
1595
+ }
1596
+ });
1597
+
1598
+ /**
1599
+ * this is to map chains from Dynamic to the corresponding chain in Wagmi, if it exists.
1600
+ * this is so that the exact same chain object is used across renders, which is important for
1601
+ * the underlying ethers library to work correctly.
1602
+ */
1603
+ const mapping = {};
1604
+ Object.values(allChains__namespace).forEach(chain => {
1605
+ mapping[chain.id] = chain;
1606
+ });
1607
+ const mapDynamicChainToWagmi = dynamicChain => {
1608
+ var _a, _b, _c, _d, _e;
1609
+ const wagmiChain = mapping[dynamicChain.chainId];
1610
+ if (wagmiChain) {
1611
+ return wagmiChain;
1612
+ }
1613
+ const rpcUrls = {
1614
+ default: {
1615
+ http: dynamicChain.rpcUrls
1616
+ }
1617
+ };
1618
+ const alchemyUrl = (_a = dynamicChain.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a.find(url => url.includes('alchemy'));
1619
+ if (alchemyUrl) {
1620
+ rpcUrls.alchemy = {
1621
+ http: [alchemyUrl]
1622
+ };
1623
+ }
1624
+ const infuraUrl = (_b = dynamicChain.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b.find(url => url.includes('infura'));
1625
+ if (infuraUrl) {
1626
+ rpcUrls.infura = {
1627
+ http: [infuraUrl]
1628
+ };
1629
+ }
1630
+ return {
1631
+ blockExplorers: {
1632
+ default: {
1633
+ name: '',
1634
+ url: (_d = (_c = dynamicChain.blockExplorerUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : ''
1635
+ }
1636
+ },
1637
+ id: dynamicChain.chainId,
1638
+ name: (_e = dynamicChain.vanityName) !== null && _e !== void 0 ? _e : dynamicChain.chainName,
1639
+ nativeCurrency: dynamicChain.nativeCurrency,
1640
+ network: dynamicChain.chainName,
1641
+ rpcUrls
1642
+ };
1643
+ };
1644
+
1645
+ const getWagmiChainsFromDynamicChains = dynamicChains => {
1646
+ const mappedChains = dynamicChains.map(mapDynamicChainToWagmi);
1647
+ return mappedChains.length > 0 ? mappedChains : [wagmi.mainnet];
1648
+ };
1649
+
1429
1650
  var iterators = {};
1430
1651
 
1431
- var fails$2 = fails$c;
1652
+ var fails$1 = fails$c;
1432
1653
 
1433
- var correctPrototypeGetter = !fails$2(function () {
1654
+ var correctPrototypeGetter = !fails$1(function () {
1434
1655
  function F() { /* empty */ }
1435
1656
  F.prototype.constructor = null;
1436
1657
  // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
@@ -1438,35 +1659,35 @@ var correctPrototypeGetter = !fails$2(function () {
1438
1659
  });
1439
1660
 
1440
1661
  var hasOwn$1 = hasOwnProperty_1;
1441
- var isCallable$4 = isCallable$f;
1662
+ var isCallable$3 = isCallable$f;
1442
1663
  var toObject = toObject$3;
1443
1664
  var sharedKey = sharedKey$3;
1444
1665
  var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
1445
1666
 
1446
1667
  var IE_PROTO = sharedKey('IE_PROTO');
1447
- var $Object$1 = Object;
1448
- var ObjectPrototype = $Object$1.prototype;
1668
+ var $Object = Object;
1669
+ var ObjectPrototype = $Object.prototype;
1449
1670
 
1450
1671
  // `Object.getPrototypeOf` method
1451
1672
  // https://tc39.es/ecma262/#sec-object.getprototypeof
1452
1673
  // eslint-disable-next-line es/no-object-getprototypeof -- safe
1453
- var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf : function (O) {
1674
+ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
1454
1675
  var object = toObject(O);
1455
1676
  if (hasOwn$1(object, IE_PROTO)) return object[IE_PROTO];
1456
1677
  var constructor = object.constructor;
1457
- if (isCallable$4(constructor) && object instanceof constructor) {
1678
+ if (isCallable$3(constructor) && object instanceof constructor) {
1458
1679
  return constructor.prototype;
1459
- } return object instanceof $Object$1 ? ObjectPrototype : null;
1680
+ } return object instanceof $Object ? ObjectPrototype : null;
1460
1681
  };
1461
1682
 
1462
- var fails$1 = fails$c;
1463
- var isCallable$3 = isCallable$f;
1464
- var isObject$1 = isObject$7;
1683
+ var fails = fails$c;
1684
+ var isCallable$2 = isCallable$f;
1685
+ var isObject = isObject$7;
1465
1686
  var getPrototypeOf$1 = objectGetPrototypeOf;
1466
1687
  var defineBuiltIn$1 = defineBuiltIn$3;
1467
- var wellKnownSymbol$7 = wellKnownSymbol$a;
1688
+ var wellKnownSymbol$3 = wellKnownSymbol$a;
1468
1689
 
1469
- var ITERATOR$2 = wellKnownSymbol$7('iterator');
1690
+ var ITERATOR$2 = wellKnownSymbol$3('iterator');
1470
1691
  var BUGGY_SAFARI_ITERATORS$1 = false;
1471
1692
 
1472
1693
  // `%IteratorPrototype%` object
@@ -1484,7 +1705,7 @@ if ([].keys) {
1484
1705
  }
1485
1706
  }
1486
1707
 
1487
- var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$1(function () {
1708
+ var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails(function () {
1488
1709
  var test = {};
1489
1710
  // FF44- legacy iterators case
1490
1711
  return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
@@ -1494,7 +1715,7 @@ if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
1494
1715
 
1495
1716
  // `%IteratorPrototype%[@@iterator]()` method
1496
1717
  // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1497
- if (!isCallable$3(IteratorPrototype$2[ITERATOR$2])) {
1718
+ if (!isCallable$2(IteratorPrototype$2[ITERATOR$2])) {
1498
1719
  defineBuiltIn$1(IteratorPrototype$2, ITERATOR$2, function () {
1499
1720
  return this;
1500
1721
  });
@@ -1507,14 +1728,14 @@ var iteratorsCore = {
1507
1728
 
1508
1729
  var defineProperty$1 = objectDefineProperty.f;
1509
1730
  var hasOwn = hasOwnProperty_1;
1510
- var wellKnownSymbol$6 = wellKnownSymbol$a;
1731
+ var wellKnownSymbol$2 = wellKnownSymbol$a;
1511
1732
 
1512
- var TO_STRING_TAG$3 = wellKnownSymbol$6('toStringTag');
1733
+ var TO_STRING_TAG$1 = wellKnownSymbol$2('toStringTag');
1513
1734
 
1514
1735
  var setToStringTag$2 = function (target, TAG, STATIC) {
1515
1736
  if (target && !STATIC) target = target.prototype;
1516
- if (target && !hasOwn(target, TO_STRING_TAG$3)) {
1517
- defineProperty$1(target, TO_STRING_TAG$3, { configurable: true, value: TAG });
1737
+ if (target && !hasOwn(target, TO_STRING_TAG$1)) {
1738
+ defineProperty$1(target, TO_STRING_TAG$1, { configurable: true, value: TAG });
1518
1739
  }
1519
1740
  };
1520
1741
 
@@ -1534,19 +1755,19 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
1534
1755
  return IteratorConstructor;
1535
1756
  };
1536
1757
 
1537
- var isCallable$2 = isCallable$f;
1758
+ var isCallable$1 = isCallable$f;
1538
1759
 
1539
- var $String$1 = String;
1540
- var $TypeError$1 = TypeError;
1760
+ var $String = String;
1761
+ var $TypeError = TypeError;
1541
1762
 
1542
1763
  var aPossiblePrototype$1 = function (argument) {
1543
- if (typeof argument == 'object' || isCallable$2(argument)) return argument;
1544
- throw $TypeError$1("Can't set " + $String$1(argument) + ' as a prototype');
1764
+ if (typeof argument == 'object' || isCallable$1(argument)) return argument;
1765
+ throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
1545
1766
  };
1546
1767
 
1547
1768
  /* eslint-disable no-proto -- safe */
1548
1769
 
1549
- var uncurryThis$1 = functionUncurryThis;
1770
+ var uncurryThis = functionUncurryThis;
1550
1771
  var anObject = anObject$5;
1551
1772
  var aPossiblePrototype = aPossiblePrototype$1;
1552
1773
 
@@ -1560,7 +1781,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1560
1781
  var setter;
1561
1782
  try {
1562
1783
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1563
- setter = uncurryThis$1(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1784
+ setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1564
1785
  setter(test, []);
1565
1786
  CORRECT_SETTER = test instanceof Array;
1566
1787
  } catch (error) { /* empty */ }
@@ -1573,17 +1794,17 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1573
1794
  };
1574
1795
  }() : undefined);
1575
1796
 
1576
- var $$2 = _export;
1797
+ var $ = _export;
1577
1798
  var call = functionCall;
1578
1799
  var FunctionName = functionName;
1579
- var isCallable$1 = isCallable$f;
1800
+ var isCallable = isCallable$f;
1580
1801
  var createIteratorConstructor = iteratorCreateConstructor;
1581
1802
  var getPrototypeOf = objectGetPrototypeOf;
1582
1803
  var setPrototypeOf = objectSetPrototypeOf;
1583
1804
  var setToStringTag = setToStringTag$2;
1584
1805
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
1585
1806
  var defineBuiltIn = defineBuiltIn$3;
1586
- var wellKnownSymbol$5 = wellKnownSymbol$a;
1807
+ var wellKnownSymbol$1 = wellKnownSymbol$a;
1587
1808
  var Iterators$1 = iterators;
1588
1809
  var IteratorsCore = iteratorsCore;
1589
1810
 
@@ -1591,7 +1812,7 @@ var PROPER_FUNCTION_NAME = FunctionName.PROPER;
1591
1812
  var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
1592
1813
  var IteratorPrototype = IteratorsCore.IteratorPrototype;
1593
1814
  var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
1594
- var ITERATOR$1 = wellKnownSymbol$5('iterator');
1815
+ var ITERATOR$1 = wellKnownSymbol$1('iterator');
1595
1816
  var KEYS = 'keys';
1596
1817
  var VALUES = 'values';
1597
1818
  var ENTRIES = 'entries';
@@ -1628,7 +1849,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1628
1849
  if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
1629
1850
  if (setPrototypeOf) {
1630
1851
  setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
1631
- } else if (!isCallable$1(CurrentIteratorPrototype[ITERATOR$1])) {
1852
+ } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$1])) {
1632
1853
  defineBuiltIn(CurrentIteratorPrototype, ITERATOR$1, returnThis);
1633
1854
  }
1634
1855
  }
@@ -1658,7 +1879,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1658
1879
  if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1659
1880
  defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
1660
1881
  }
1661
- } else $$2({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1882
+ } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1662
1883
  }
1663
1884
 
1664
1885
  // define iterator
@@ -1677,7 +1898,7 @@ var createIterResultObject$1 = function (value, done) {
1677
1898
  };
1678
1899
 
1679
1900
  var toIndexedObject = toIndexedObject$5;
1680
- var addToUnscopables$1 = addToUnscopables$2;
1901
+ var addToUnscopables = addToUnscopables$2;
1681
1902
  var Iterators = iterators;
1682
1903
  var InternalStateModule = internalState;
1683
1904
  var defineProperty = objectDefineProperty.f;
@@ -1728,9 +1949,9 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
1728
1949
  var values = Iterators.Arguments = Iterators.Array;
1729
1950
 
1730
1951
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1731
- addToUnscopables$1('keys');
1732
- addToUnscopables$1('values');
1733
- addToUnscopables$1('entries');
1952
+ addToUnscopables('keys');
1953
+ addToUnscopables('values');
1954
+ addToUnscopables('entries');
1734
1955
 
1735
1956
  // V8 ~ Chrome 45- bug
1736
1957
  if (DESCRIPTORS && values.name !== 'values') try {
@@ -1786,10 +2007,10 @@ var DOMIterables = domIterables;
1786
2007
  var DOMTokenListPrototype = domTokenListPrototype;
1787
2008
  var ArrayIteratorMethods = es_array_iterator;
1788
2009
  var createNonEnumerableProperty = createNonEnumerableProperty$4;
1789
- var wellKnownSymbol$4 = wellKnownSymbol$a;
2010
+ var wellKnownSymbol = wellKnownSymbol$a;
1790
2011
 
1791
- var ITERATOR = wellKnownSymbol$4('iterator');
1792
- var TO_STRING_TAG$2 = wellKnownSymbol$4('toStringTag');
2012
+ var ITERATOR = wellKnownSymbol('iterator');
2013
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
1793
2014
  var ArrayValues = ArrayIteratorMethods.values;
1794
2015
 
1795
2016
  var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
@@ -1800,8 +2021,8 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1800
2021
  } catch (error) {
1801
2022
  CollectionPrototype[ITERATOR] = ArrayValues;
1802
2023
  }
1803
- if (!CollectionPrototype[TO_STRING_TAG$2]) {
1804
- createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$2, COLLECTION_NAME);
2024
+ if (!CollectionPrototype[TO_STRING_TAG]) {
2025
+ createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
1805
2026
  }
1806
2027
  if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
1807
2028
  // some Chrome versions have non-configurable methods on DOMTokenList
@@ -1820,243 +2041,6 @@ for (var COLLECTION_NAME in DOMIterables) {
1820
2041
 
1821
2042
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
1822
2043
 
1823
- const IsBrowser = ({
1824
- children
1825
- }) => {
1826
- const [isBrowser, setIsBrowser] = React.useState(false);
1827
- // this useEffect does not run during SSR
1828
- React.useEffect(() => {
1829
- setIsBrowser(true);
1830
- }, []);
1831
- if (!isBrowser) {
1832
- // Justification: We specifically need to return an element instead of null
1833
- // in order to have stable content during SSR
1834
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment);
1835
- }
1836
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children);
1837
- };
1838
-
1839
- const SyncDynamicWagmi = ({
1840
- children,
1841
- connector
1842
- }) => {
1843
- const {
1844
- status: clientStatus
1845
- } = wagmi.useClient();
1846
- const {
1847
- walletConnector
1848
- } = sdkReact.useDynamicContext();
1849
- const {
1850
- connect,
1851
- status
1852
- } = wagmi.useConnect();
1853
- const {
1854
- disconnect
1855
- } = wagmi.useDisconnect();
1856
- if (walletConnector) {
1857
- // after connection is successful, re-setup event listeners after a short delay
1858
- // so that they are not cleared by the teardown in useWalletEventListeners
1859
- if (status === 'success') {
1860
- setTimeout(() => {
1861
- connector === null || connector === void 0 ? void 0 : connector.setupEventListeners();
1862
- }, 100);
1863
- }
1864
- }
1865
- React.useEffect(() => {
1866
- if (!walletConnector) {
1867
- disconnect();
1868
- } else if (connector && clientStatus !== 'connected') {
1869
- connect({
1870
- connector
1871
- });
1872
- }
1873
- }, [clientStatus, connect, connector, disconnect, walletConnector]);
1874
- // use React.createElement to prevent bunding react/jsx-runtime,
1875
- // which is not compatible when bundling apps using React 17
1876
- return /*#__PURE__*/React__default["default"].createElement(IsBrowser, null, children);
1877
- };
1878
-
1879
- var $$1 = _export;
1880
- var $includes = arrayIncludes.includes;
1881
- var fails = fails$c;
1882
- var addToUnscopables = addToUnscopables$2;
1883
-
1884
- // FF99+ bug
1885
- var BROKEN_ON_SPARSE = fails(function () {
1886
- return !Array(1).includes();
1887
- });
1888
-
1889
- // `Array.prototype.includes` method
1890
- // https://tc39.es/ecma262/#sec-array.prototype.includes
1891
- $$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
1892
- includes: function includes(el /* , fromIndex = 0 */) {
1893
- return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
1894
- }
1895
- });
1896
-
1897
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1898
- addToUnscopables('includes');
1899
-
1900
- var isObject = isObject$7;
1901
- var classof$2 = classofRaw$1;
1902
- var wellKnownSymbol$3 = wellKnownSymbol$a;
1903
-
1904
- var MATCH$1 = wellKnownSymbol$3('match');
1905
-
1906
- // `IsRegExp` abstract operation
1907
- // https://tc39.es/ecma262/#sec-isregexp
1908
- var isRegexp = function (it) {
1909
- var isRegExp;
1910
- return isObject(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$2(it) == 'RegExp');
1911
- };
1912
-
1913
- var isRegExp = isRegexp;
1914
-
1915
- var $TypeError = TypeError;
1916
-
1917
- var notARegexp = function (it) {
1918
- if (isRegExp(it)) {
1919
- throw $TypeError("The method doesn't accept regular expressions");
1920
- } return it;
1921
- };
1922
-
1923
- var wellKnownSymbol$2 = wellKnownSymbol$a;
1924
-
1925
- var TO_STRING_TAG$1 = wellKnownSymbol$2('toStringTag');
1926
- var test = {};
1927
-
1928
- test[TO_STRING_TAG$1] = 'z';
1929
-
1930
- var toStringTagSupport = String(test) === '[object z]';
1931
-
1932
- var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1933
- var isCallable = isCallable$f;
1934
- var classofRaw = classofRaw$1;
1935
- var wellKnownSymbol$1 = wellKnownSymbol$a;
1936
-
1937
- var TO_STRING_TAG = wellKnownSymbol$1('toStringTag');
1938
- var $Object = Object;
1939
-
1940
- // ES3 wrong here
1941
- var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1942
-
1943
- // fallback for IE11 Script Access Denied error
1944
- var tryGet = function (it, key) {
1945
- try {
1946
- return it[key];
1947
- } catch (error) { /* empty */ }
1948
- };
1949
-
1950
- // getting tag from ES6+ `Object.prototype.toString`
1951
- var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1952
- var O, tag, result;
1953
- return it === undefined ? 'Undefined' : it === null ? 'Null'
1954
- // @@toStringTag case
1955
- : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
1956
- // builtinTag case
1957
- : CORRECT_ARGUMENTS ? classofRaw(O)
1958
- // ES3 arguments fallback
1959
- : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
1960
- };
1961
-
1962
- var classof = classof$1;
1963
-
1964
- var $String = String;
1965
-
1966
- var toString$1 = function (argument) {
1967
- if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
1968
- return $String(argument);
1969
- };
1970
-
1971
- var wellKnownSymbol = wellKnownSymbol$a;
1972
-
1973
- var MATCH = wellKnownSymbol('match');
1974
-
1975
- var correctIsRegexpLogic = function (METHOD_NAME) {
1976
- var regexp = /./;
1977
- try {
1978
- '/./'[METHOD_NAME](regexp);
1979
- } catch (error1) {
1980
- try {
1981
- regexp[MATCH] = false;
1982
- return '/./'[METHOD_NAME](regexp);
1983
- } catch (error2) { /* empty */ }
1984
- } return false;
1985
- };
1986
-
1987
- var $ = _export;
1988
- var uncurryThis = functionUncurryThis;
1989
- var notARegExp = notARegexp;
1990
- var requireObjectCoercible = requireObjectCoercible$3;
1991
- var toString = toString$1;
1992
- var correctIsRegExpLogic = correctIsRegexpLogic;
1993
-
1994
- var stringIndexOf = uncurryThis(''.indexOf);
1995
-
1996
- // `String.prototype.includes` method
1997
- // https://tc39.es/ecma262/#sec-string.prototype.includes
1998
- $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
1999
- includes: function includes(searchString /* , position = 0 */) {
2000
- return !!~stringIndexOf(
2001
- toString(requireObjectCoercible(this)),
2002
- toString(notARegExp(searchString)),
2003
- arguments.length > 1 ? arguments[1] : undefined
2004
- );
2005
- }
2006
- });
2007
-
2008
- /**
2009
- * this is to map chains from Dynamic to the corresponding chain in Wagmi, if it exists.
2010
- * this is so that the exact same chain object is used across renders, which is important for
2011
- * the underlying ethers library to work correctly.
2012
- */
2013
- const mapping = {};
2014
- Object.values(allChains__namespace).forEach(chain => {
2015
- mapping[chain.id] = chain;
2016
- });
2017
- const mapDynamicChainToWagmi = dynamicChain => {
2018
- var _a, _b, _c, _d, _e;
2019
- const wagmiChain = mapping[dynamicChain.chainId];
2020
- if (wagmiChain) {
2021
- return wagmiChain;
2022
- }
2023
- const rpcUrls = {
2024
- default: {
2025
- http: dynamicChain.rpcUrls
2026
- }
2027
- };
2028
- const alchemyUrl = (_a = dynamicChain.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a.find(url => url.includes('alchemy'));
2029
- if (alchemyUrl) {
2030
- rpcUrls.alchemy = {
2031
- http: [alchemyUrl]
2032
- };
2033
- }
2034
- const infuraUrl = (_b = dynamicChain.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b.find(url => url.includes('infura'));
2035
- if (infuraUrl) {
2036
- rpcUrls.infura = {
2037
- http: [infuraUrl]
2038
- };
2039
- }
2040
- return {
2041
- blockExplorers: {
2042
- default: {
2043
- name: '',
2044
- url: (_d = (_c = dynamicChain.blockExplorerUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : ''
2045
- }
2046
- },
2047
- id: dynamicChain.chainId,
2048
- name: (_e = dynamicChain.vanityName) !== null && _e !== void 0 ? _e : dynamicChain.chainName,
2049
- nativeCurrency: dynamicChain.nativeCurrency,
2050
- network: dynamicChain.chainName,
2051
- rpcUrls
2052
- };
2053
- };
2054
-
2055
- const getWagmiChainsFromDynamicChains = dynamicChains => {
2056
- const mappedChains = dynamicChains.map(mapDynamicChainToWagmi);
2057
- return mappedChains.length > 0 ? mappedChains : [wagmi.mainnet];
2058
- };
2059
-
2060
2044
  const getWagmiProvidersFromDynamicChains = dynamicChains => {
2061
2045
  var _a;
2062
2046
  const wagmiProviders = [];