@hinkal/common 0.0.140 → 0.0.141

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.
Files changed (2) hide show
  1. package/index.mjs +211 -27
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { disconnect, getAccount, connect, signMessage, switchNetwork, watchAccount, watchNetwork } from "@wagmi/core";
2
1
  const S3_BASE_URL = "https://hinkal-s3-assets.s3.us-west-1.amazonaws.com/assets/", IMAGE_PATHS = {
3
2
  CHEVRON: `${S3_BASE_URL}Chevron.svg`,
4
3
  MOON: `${S3_BASE_URL}Moon.svg`,
@@ -232384,7 +232383,7 @@ const homestead = {
232384
232383
  bnb: { chainId: 56, name: "bnb" },
232385
232384
  bnbt: { chainId: 97, name: "bnbt" }
232386
232385
  };
232387
- function getNetwork(C) {
232386
+ function getNetwork$1(C) {
232388
232387
  if (C == null)
232389
232388
  return null;
232390
232389
  if (typeof C == "number") {
@@ -233574,7 +233573,7 @@ class BaseProvider extends Provider {
233574
233573
  }
233575
233574
  // @TODO: Remove this and just use getNetwork
233576
233575
  static getNetwork(I) {
233577
- return getNetwork(I ?? "homestead");
233576
+ return getNetwork$1(I ?? "homestead");
233578
233577
  }
233579
233578
  ccipReadFetch(I, l, Z) {
233580
233579
  return __awaiter$m(this, void 0, void 0, function* () {
@@ -236165,7 +236164,7 @@ function getDefaultProvider$1(C, I) {
236165
236164
  logger$3.throwArgumentError("unsupported URL scheme", "network", C);
236166
236165
  }
236167
236166
  }
236168
- const l = getNetwork(C);
236167
+ const l = getNetwork$1(C);
236169
236168
  return (!l || !l._defaultProvider) && logger$3.throwError("unsupported getDefaultProvider network", Logger.errors.NETWORK_ERROR, {
236170
236169
  operation: "getDefaultProvider",
236171
236170
  network: C
@@ -236208,7 +236207,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
236208
236207
  Web3Provider,
236209
236208
  WebSocketProvider,
236210
236209
  getDefaultProvider: getDefaultProvider$1,
236211
- getNetwork,
236210
+ getNetwork: getNetwork$1,
236212
236211
  isCommunityResourcable,
236213
236212
  isCommunityResource,
236214
236213
  showThrottleMessage
@@ -249528,20 +249527,20 @@ var state = {
249528
249527
  getHighWaterMark
249529
249528
  }, browser$3 = deprecate;
249530
249529
  function deprecate(C, I) {
249531
- if (config("noDeprecation"))
249530
+ if (config$1("noDeprecation"))
249532
249531
  return C;
249533
249532
  var l = !1;
249534
249533
  function Z() {
249535
249534
  if (!l) {
249536
- if (config("throwDeprecation"))
249535
+ if (config$1("throwDeprecation"))
249537
249536
  throw new Error(I);
249538
- config("traceDeprecation") ? console.trace(I) : console.warn(I), l = !0;
249537
+ config$1("traceDeprecation") ? console.trace(I) : console.warn(I), l = !0;
249539
249538
  }
249540
249539
  return C.apply(this, arguments);
249541
249540
  }
249542
249541
  return Z;
249543
249542
  }
249544
- function config(C) {
249543
+ function config$1(C) {
249545
249544
  try {
249546
249545
  if (!commonjsGlobal.localStorage)
249547
249546
  return !1;
@@ -276558,28 +276557,21 @@ var doEval = function C(I) {
276558
276557
  }
276559
276558
  }
276560
276559
  return B;
276561
- }, callBind$2 = { exports: {} }, esDefineProperty, hasRequiredEsDefineProperty;
276562
- function requireEsDefineProperty() {
276563
- if (hasRequiredEsDefineProperty)
276564
- return esDefineProperty;
276565
- hasRequiredEsDefineProperty = 1;
276566
- var C = getIntrinsic, I = C("%Object.defineProperty%", !0) || !1;
276567
- if (I)
276568
- try {
276569
- I({}, "a", { value: 1 });
276570
- } catch {
276571
- I = !1;
276572
- }
276573
- return esDefineProperty = I, esDefineProperty;
276574
- }
276575
- var GetIntrinsic$2 = getIntrinsic, $gOPD = GetIntrinsic$2("%Object.getOwnPropertyDescriptor%", !0);
276560
+ }, callBind$2 = { exports: {} }, GetIntrinsic$3 = getIntrinsic, $defineProperty$2 = GetIntrinsic$3("%Object.defineProperty%", !0) || !1;
276561
+ if ($defineProperty$2)
276562
+ try {
276563
+ $defineProperty$2({}, "a", { value: 1 });
276564
+ } catch {
276565
+ $defineProperty$2 = !1;
276566
+ }
276567
+ var esDefineProperty = $defineProperty$2, GetIntrinsic$2 = getIntrinsic, $gOPD = GetIntrinsic$2("%Object.getOwnPropertyDescriptor%", !0);
276576
276568
  if ($gOPD)
276577
276569
  try {
276578
276570
  $gOPD([], "length");
276579
276571
  } catch {
276580
276572
  $gOPD = null;
276581
276573
  }
276582
- var gopd$1 = $gOPD, $defineProperty$1 = requireEsDefineProperty(), $SyntaxError = syntax, $TypeError$1 = type, gopd = gopd$1, defineDataProperty$1 = function(I, l, Z) {
276574
+ var gopd$1 = $gOPD, $defineProperty$1 = esDefineProperty, $SyntaxError = syntax, $TypeError$1 = type, gopd = gopd$1, defineDataProperty$1 = function(I, l, Z) {
276583
276575
  if (!I || typeof I != "object" && typeof I != "function")
276584
276576
  throw new $TypeError$1("`obj` must be an object or a function`");
276585
276577
  if (typeof l != "string" && typeof l != "symbol")
@@ -276604,7 +276596,7 @@ var gopd$1 = $gOPD, $defineProperty$1 = requireEsDefineProperty(), $SyntaxError
276604
276596
  I[l] = Z;
276605
276597
  else
276606
276598
  throw new $SyntaxError("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");
276607
- }, $defineProperty = requireEsDefineProperty(), hasPropertyDescriptors = function() {
276599
+ }, $defineProperty = esDefineProperty, hasPropertyDescriptors = function() {
276608
276600
  return !!$defineProperty;
276609
276601
  };
276610
276602
  hasPropertyDescriptors.hasArrayLengthDefineBug = function() {
@@ -276641,7 +276633,7 @@ var hasPropertyDescriptors_1 = hasPropertyDescriptors, GetIntrinsic$1 = getIntri
276641
276633
  )), I;
276642
276634
  };
276643
276635
  (function(C) {
276644
- var I = functionBind, l = getIntrinsic, Z = setFunctionLength, d = type, W = l("%Function.prototype.apply%"), T = l("%Function.prototype.call%"), B = l("%Reflect.apply%", !0) || I.call(T, W), o = requireEsDefineProperty(), D = l("%Math.max%");
276636
+ var I = functionBind, l = getIntrinsic, Z = setFunctionLength, d = type, W = l("%Function.prototype.apply%"), T = l("%Function.prototype.call%"), B = l("%Reflect.apply%", !0) || I.call(T, W), o = esDefineProperty, D = l("%Math.max%");
276645
276637
  C.exports = function(S) {
276646
276638
  if (typeof S != "function")
276647
276639
  throw new d("a function is required");
@@ -413604,6 +413596,198 @@ const workerViteURL = {
413604
413596
  __proto__: null,
413605
413597
  workerViteURL
413606
413598
  }, Symbol.toStringTag, { value: "Module" }));
413599
+ var ConnectorNotFoundError = class extends Error {
413600
+ constructor() {
413601
+ super(...arguments), this.name = "ConnectorNotFoundError", this.message = "Connector not found";
413602
+ }
413603
+ };
413604
+ function shallow$1(C, I) {
413605
+ if (Object.is(C, I))
413606
+ return !0;
413607
+ if (typeof C != "object" || C === null || typeof I != "object" || I === null)
413608
+ return !1;
413609
+ if (C instanceof Map && I instanceof Map) {
413610
+ if (C.size !== I.size)
413611
+ return !1;
413612
+ for (const [Z, d] of C)
413613
+ if (!Object.is(d, I.get(Z)))
413614
+ return !1;
413615
+ return !0;
413616
+ }
413617
+ if (C instanceof Set && I instanceof Set) {
413618
+ if (C.size !== I.size)
413619
+ return !1;
413620
+ for (const Z of C)
413621
+ if (!I.has(Z))
413622
+ return !1;
413623
+ return !0;
413624
+ }
413625
+ const l = Object.keys(C);
413626
+ if (l.length !== Object.keys(I).length)
413627
+ return !1;
413628
+ for (const Z of l)
413629
+ if (!Object.prototype.hasOwnProperty.call(I, Z) || !Object.is(C[Z], I[Z]))
413630
+ return !1;
413631
+ return !0;
413632
+ }
413633
+ var ConnectorAlreadyConnectedError = class extends Error {
413634
+ constructor() {
413635
+ super(...arguments), this.name = "ConnectorAlreadyConnectedError", this.message = "Connector already connected";
413636
+ }
413637
+ }, SwitchChainNotSupportedError = class extends Error {
413638
+ constructor({ connector: C }) {
413639
+ super(`"${C.name}" does not support programmatic chain switching.`), this.name = "SwitchChainNotSupportedError";
413640
+ }
413641
+ }, config;
413642
+ function getConfig() {
413643
+ if (!config)
413644
+ throw new Error(
413645
+ "No wagmi config found. Ensure you have set up a config: https://wagmi.sh/react/config"
413646
+ );
413647
+ return config;
413648
+ }
413649
+ async function connect({ chainId: C, connector: I }) {
413650
+ const l = getConfig(), Z = l.connector;
413651
+ if (Z && I.id === Z.id)
413652
+ throw new ConnectorAlreadyConnectedError();
413653
+ try {
413654
+ l.setState((W) => ({ ...W, status: "connecting" }));
413655
+ const d = await I.connect({ chainId: C });
413656
+ return l.setLastUsedConnector(I.id), l.setState((W) => ({
413657
+ ...W,
413658
+ connector: I,
413659
+ chains: I?.chains,
413660
+ data: d,
413661
+ status: "connected"
413662
+ })), l.storage.setItem("connected", !0), { ...d, connector: I };
413663
+ } catch (d) {
413664
+ throw l.setState((W) => ({
413665
+ ...W,
413666
+ status: W.connector ? "connected" : "disconnected"
413667
+ })), d;
413668
+ }
413669
+ }
413670
+ async function disconnect() {
413671
+ const C = getConfig();
413672
+ C.connector && await C.connector.disconnect(), C.clearState(), C.storage.removeItem("connected");
413673
+ }
413674
+ async function getWalletClient({
413675
+ chainId: C
413676
+ } = {}) {
413677
+ return await getConfig().connector?.getWalletClient?.({ chainId: C }) || null;
413678
+ }
413679
+ function getAccount() {
413680
+ const { data: C, connector: I, status: l } = getConfig();
413681
+ switch (l) {
413682
+ case "connected":
413683
+ return {
413684
+ address: C?.account,
413685
+ connector: I,
413686
+ isConnected: !0,
413687
+ isConnecting: !1,
413688
+ isDisconnected: !1,
413689
+ isReconnecting: !1,
413690
+ status: l
413691
+ };
413692
+ case "reconnecting":
413693
+ return {
413694
+ address: C?.account,
413695
+ connector: I,
413696
+ isConnected: !!C?.account,
413697
+ isConnecting: !1,
413698
+ isDisconnected: !1,
413699
+ isReconnecting: !0,
413700
+ status: l
413701
+ };
413702
+ case "connecting":
413703
+ return {
413704
+ address: C?.account,
413705
+ connector: I,
413706
+ isConnected: !1,
413707
+ isConnecting: !0,
413708
+ isDisconnected: !1,
413709
+ isReconnecting: !1,
413710
+ status: l
413711
+ };
413712
+ case "disconnected":
413713
+ return {
413714
+ address: void 0,
413715
+ connector: void 0,
413716
+ isConnected: !1,
413717
+ isConnecting: !1,
413718
+ isDisconnected: !0,
413719
+ isReconnecting: !1,
413720
+ status: l
413721
+ };
413722
+ }
413723
+ }
413724
+ function getNetwork() {
413725
+ const C = getConfig(), I = C.data?.chain?.id, l = C.chains ?? [], Z = [
413726
+ ...C.publicClient?.chains || [],
413727
+ ...l
413728
+ ].find((d) => d.id === I) ?? {
413729
+ id: I,
413730
+ name: `Chain ${I}`,
413731
+ network: `${I}`,
413732
+ nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
413733
+ rpcUrls: {
413734
+ default: { http: [""] },
413735
+ public: { http: [""] }
413736
+ }
413737
+ };
413738
+ return {
413739
+ chain: I ? {
413740
+ ...Z,
413741
+ ...C.data?.chain,
413742
+ id: I
413743
+ } : void 0,
413744
+ chains: l
413745
+ };
413746
+ }
413747
+ async function signMessage(C) {
413748
+ const I = await getWalletClient();
413749
+ if (!I)
413750
+ throw new ConnectorNotFoundError();
413751
+ return await I.signMessage({
413752
+ message: C.message
413753
+ });
413754
+ }
413755
+ async function switchNetwork({
413756
+ chainId: C
413757
+ }) {
413758
+ const { connector: I } = getConfig();
413759
+ if (!I)
413760
+ throw new ConnectorNotFoundError();
413761
+ if (!I.switchChain)
413762
+ throw new SwitchChainNotSupportedError({
413763
+ connector: I
413764
+ });
413765
+ return I.switchChain(C);
413766
+ }
413767
+ function watchAccount(C, { selector: I = (l) => l } = {}) {
413768
+ const l = getConfig(), Z = () => C(getAccount());
413769
+ return l.subscribe(
413770
+ ({ data: W, connector: T, status: B }) => I({
413771
+ address: W?.account,
413772
+ connector: T,
413773
+ status: B
413774
+ }),
413775
+ Z,
413776
+ {
413777
+ equalityFn: shallow$1
413778
+ }
413779
+ );
413780
+ }
413781
+ function watchNetwork(C, { selector: I = (l) => l } = {}) {
413782
+ const l = getConfig(), Z = () => C(getNetwork());
413783
+ return l.subscribe(
413784
+ ({ data: W, chains: T }) => I({ chainId: W?.chain?.id, chains: T }),
413785
+ Z,
413786
+ {
413787
+ equalityFn: shallow$1
413788
+ }
413789
+ );
413790
+ }
413607
413791
  class Wagmiv1ProviderAdapter {
413608
413792
  connector;
413609
413793
  chainId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.0.140",
3
+ "version": "0.0.141",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"