@arcenpay/react 0.0.1 → 0.0.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/dist/index.mjs CHANGED
@@ -1,9 +1,21 @@
1
1
  import {
2
+ ERC7579AutopayModuleABI,
3
+ PlanFactoryABI,
4
+ SubscriptionRegistryABI,
2
5
  deploySmartAccount,
6
+ getChainEnvironment,
7
+ getContractAddresses,
3
8
  isRecoverableSmartAccountFundingError,
9
+ resolveArcenPayBaseUrl,
4
10
  sendSmartAccountTransaction,
5
- updateAutopayConfig
6
- } from "./chunk-LACDYDLO.mjs";
11
+ updateAutopayConfig,
12
+ validateChainEnvironment
13
+ } from "./chunk-JFY4DVS7.mjs";
14
+ import {
15
+ DEFAULT_CHAIN_ID,
16
+ getBlockExplorerUrl,
17
+ getChain
18
+ } from "./chunk-GY2HMODH.mjs";
7
19
  import {
8
20
  __require
9
21
  } from "./chunk-X2BMVUAF.mjs";
@@ -21,14 +33,8 @@ import { WagmiProvider, createConfig, http } from "wagmi";
21
33
  import { sepolia, baseSepolia, base } from "wagmi/chains";
22
34
  import { injected, walletConnect } from "wagmi/connectors";
23
35
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
24
- import {
25
- getChainEnvironment,
26
- DEFAULT_CHAIN_ID,
27
- validateChainEnvironment
28
- } from "@arcenpay/sdk";
29
36
 
30
37
  // src/lib/api.ts
31
- import { resolveArcenPayBaseUrl } from "@arcenpay/sdk";
32
38
  function resolveDashboardBaseUrl(explicit) {
33
39
  return resolveArcenPayBaseUrl({ explicit });
34
40
  }
@@ -246,13 +252,6 @@ import {
246
252
  useState as useState2
247
253
  } from "react";
248
254
  import { createPortal } from "react-dom";
249
- import {
250
- ERC7579AutopayModuleABI,
251
- getBlockExplorerUrl,
252
- getChain,
253
- getContractAddresses,
254
- PlanFactoryABI
255
- } from "@arcenpay/sdk";
256
255
 
257
256
  // src/lib/subscription-lifecycle.ts
258
257
  function buildPlanChangeSuccessMessage(input) {
@@ -7085,12 +7084,12 @@ var ArcenpayEmbed = ArcenEmbed;
7085
7084
  import { useEffect as useEffect5, useMemo as useMemo3, useState as useState5 } from "react";
7086
7085
 
7087
7086
  // src/hooks/useEntitlement.ts
7088
- import { useReadContracts, useWatchBlockNumber, useWatchContractEvent } from "wagmi";
7089
- import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
7090
7087
  import {
7091
- SubscriptionRegistryABI as SubscriptionRegistryABI2,
7092
- getContractAddresses as getContractAddresses2
7093
- } from "@arcenpay/sdk";
7088
+ useReadContracts,
7089
+ useWatchBlockNumber,
7090
+ useWatchContractEvent
7091
+ } from "wagmi";
7092
+ import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
7094
7093
 
7095
7094
  // src/hooks/useCompanyEntitlements.ts
7096
7095
  import { useState as useState3, useEffect as useEffect3, useRef as useRef2, useCallback as useCallback3 } from "react";
@@ -7137,7 +7136,9 @@ function useCompanyEntitlements(options = {}) {
7137
7136
  });
7138
7137
  if (!res.ok) {
7139
7138
  const json2 = await res.json().catch(() => ({}));
7140
- throw new Error(json2.error ?? `HTTP ${res.status}`);
7139
+ throw new Error(
7140
+ json2.error ?? `HTTP ${res.status}`
7141
+ );
7141
7142
  }
7142
7143
  const json = await res.json();
7143
7144
  const list = Array.isArray(json) ? json : json.entitlements ?? [];
@@ -7196,7 +7197,7 @@ var EntitlementError = class extends Error {
7196
7197
  function useEntitlement(walletAddress, featureKey) {
7197
7198
  const ONCHAIN_STALE_AFTER_MS = 3e4;
7198
7199
  const { network, config } = useArcenPay();
7199
- const contracts = getContractAddresses2(network.chainId);
7200
+ const contracts = getContractAddresses(network.chainId);
7200
7201
  const registryAddress = contracts.subscriptionRegistry;
7201
7202
  const lastBlockRefetchAt = useRef3(0);
7202
7203
  const {
@@ -7209,7 +7210,9 @@ function useEntitlement(walletAddress, featureKey) {
7209
7210
  skip: false
7210
7211
  });
7211
7212
  const [tablelandFeatures, setTablelandFeatures] = useState4({});
7212
- const [tablelandUpdatedAt, setTablelandUpdatedAt] = useState4(null);
7213
+ const [tablelandUpdatedAt, setTablelandUpdatedAt] = useState4(
7214
+ null
7215
+ );
7213
7216
  const [tablelandLoading, setTablelandLoading] = useState4(false);
7214
7217
  const [tablelandError, setTablelandError] = useState4(null);
7215
7218
  const walletInvalid = Boolean(walletAddress) && !/^0x[a-fA-F0-9]{40}$/.test(walletAddress || "");
@@ -7222,7 +7225,11 @@ function useEntitlement(walletAddress, featureKey) {
7222
7225
  const providerUrl = config.tablelandConfig?.providerUrl;
7223
7226
  if (!providerUrl) return null;
7224
7227
  return `${providerUrl.replace(/\/$/, "")}/api/entitlements/${walletAddress.toLowerCase()}/flags`;
7225
- }, [config.tablelandConfig?.featureFlagsEndpoint, config.tablelandConfig?.providerUrl, walletAddress]);
7228
+ }, [
7229
+ config.tablelandConfig?.featureFlagsEndpoint,
7230
+ config.tablelandConfig?.providerUrl,
7231
+ walletAddress
7232
+ ]);
7226
7233
  const sequenceRef = useRef3(0);
7227
7234
  const refetchTableland = useCallback4(async () => {
7228
7235
  if (!tablelandFeatureFlagsUrl) {
@@ -7254,7 +7261,9 @@ function useEntitlement(walletAddress, featureKey) {
7254
7261
  if (sequenceRef.current !== seq) return;
7255
7262
  setTablelandFeatures({});
7256
7263
  setTablelandUpdatedAt(null);
7257
- setTablelandError(err instanceof Error ? err : new Error("Feature flags fetch failed."));
7264
+ setTablelandError(
7265
+ err instanceof Error ? err : new Error("Feature flags fetch failed.")
7266
+ );
7258
7267
  } finally {
7259
7268
  if (sequenceRef.current === seq) {
7260
7269
  setTablelandLoading(false);
@@ -7273,14 +7282,14 @@ function useEntitlement(walletAddress, featureKey) {
7273
7282
  contracts: [
7274
7283
  {
7275
7284
  address: registryAddress,
7276
- abi: SubscriptionRegistryABI2,
7285
+ abi: SubscriptionRegistryABI,
7277
7286
  functionName: "getWalletSubscription",
7278
7287
  args: [walletAddress],
7279
7288
  chainId: network.chainId
7280
7289
  },
7281
7290
  {
7282
7291
  address: registryAddress,
7283
- abi: SubscriptionRegistryABI2,
7292
+ abi: SubscriptionRegistryABI,
7284
7293
  functionName: "hasActiveSubscription",
7285
7294
  args: [walletAddress],
7286
7295
  chainId: network.chainId
@@ -7303,21 +7312,21 @@ function useEntitlement(walletAddress, featureKey) {
7303
7312
  contracts: [
7304
7313
  {
7305
7314
  address: registryAddress,
7306
- abi: SubscriptionRegistryABI2,
7315
+ abi: SubscriptionRegistryABI,
7307
7316
  functionName: "isValid",
7308
7317
  args: [tokenId],
7309
7318
  chainId: network.chainId
7310
7319
  },
7311
7320
  {
7312
7321
  address: registryAddress,
7313
- abi: SubscriptionRegistryABI2,
7322
+ abi: SubscriptionRegistryABI,
7314
7323
  functionName: "expiresAt",
7315
7324
  args: [tokenId],
7316
7325
  chainId: network.chainId
7317
7326
  },
7318
7327
  {
7319
7328
  address: registryAddress,
7320
- abi: SubscriptionRegistryABI2,
7329
+ abi: SubscriptionRegistryABI,
7321
7330
  functionName: "getPlanFeatures",
7322
7331
  args: [tokenId],
7323
7332
  chainId: network.chainId
@@ -7358,7 +7367,7 @@ function useEntitlement(walletAddress, featureKey) {
7358
7367
  }, [dashboardFeatures, tablelandFeatures, onChainTierFeatures, featureKey]);
7359
7368
  useWatchContractEvent({
7360
7369
  address: registryAddress,
7361
- abi: SubscriptionRegistryABI2,
7370
+ abi: SubscriptionRegistryABI,
7362
7371
  eventName: "SubscriptionMinted",
7363
7372
  args: walletAddress ? { subscriber: walletAddress } : void 0,
7364
7373
  onLogs: () => {
@@ -7371,7 +7380,7 @@ function useEntitlement(walletAddress, featureKey) {
7371
7380
  });
7372
7381
  useWatchContractEvent({
7373
7382
  address: registryAddress,
7374
- abi: SubscriptionRegistryABI2,
7383
+ abi: SubscriptionRegistryABI,
7375
7384
  eventName: "SubscriptionRenewed",
7376
7385
  args: hasToken ? { tokenId } : void 0,
7377
7386
  onLogs: () => {
@@ -7383,7 +7392,7 @@ function useEntitlement(walletAddress, featureKey) {
7383
7392
  });
7384
7393
  useWatchContractEvent({
7385
7394
  address: registryAddress,
7386
- abi: SubscriptionRegistryABI2,
7395
+ abi: SubscriptionRegistryABI,
7387
7396
  eventName: "SubscriptionCancelled",
7388
7397
  args: hasToken ? { tokenId } : void 0,
7389
7398
  onLogs: () => {
@@ -7396,7 +7405,7 @@ function useEntitlement(walletAddress, featureKey) {
7396
7405
  });
7397
7406
  useWatchContractEvent({
7398
7407
  address: registryAddress,
7399
- abi: SubscriptionRegistryABI2,
7408
+ abi: SubscriptionRegistryABI,
7400
7409
  eventName: "Transfer",
7401
7410
  args: walletAddress ? { to: walletAddress } : void 0,
7402
7411
  onLogs: () => {
@@ -7409,7 +7418,7 @@ function useEntitlement(walletAddress, featureKey) {
7409
7418
  });
7410
7419
  useWatchContractEvent({
7411
7420
  address: registryAddress,
7412
- abi: SubscriptionRegistryABI2,
7421
+ abi: SubscriptionRegistryABI,
7413
7422
  eventName: "Transfer",
7414
7423
  args: walletAddress ? { from: walletAddress } : void 0,
7415
7424
  onLogs: () => {
@@ -7438,7 +7447,13 @@ function useEntitlement(walletAddress, featureKey) {
7438
7447
  if (hasToken) refetchSub();
7439
7448
  void refetchTableland();
7440
7449
  void refetchDashboardEntitlements();
7441
- }, [refetchTokenId, refetchSub, hasToken, refetchTableland, refetchDashboardEntitlements]);
7450
+ }, [
7451
+ refetchTokenId,
7452
+ refetchSub,
7453
+ hasToken,
7454
+ refetchTableland,
7455
+ refetchDashboardEntitlements
7456
+ ]);
7442
7457
  const isLoading = tokenIdLoading || hasToken && subLoading || dashboardLoading || Boolean(tablelandFeatureFlagsUrl) && tablelandLoading;
7443
7458
  const tokenError = tokenIdResult?.[0]?.error;
7444
7459
  const subscriptionError = subscriptionData?.find((entry) => entry?.error)?.error;
@@ -7510,7 +7525,7 @@ async function getLitNodeClient(network = "habanero") {
7510
7525
  let LitNetwork;
7511
7526
  try {
7512
7527
  const [litCore, litConstants] = await Promise.all([
7513
- import("./src-TV3VFBF5.mjs"),
7528
+ import("./src-SAIIENMZ.mjs"),
7514
7529
  import("./src-HMFDWVJP.mjs")
7515
7530
  ]);
7516
7531
  LitNodeClient = litCore.LitNodeClient;
@@ -7582,7 +7597,10 @@ function FeatureFlagGuard({
7582
7597
  onDecryptionError
7583
7598
  }) {
7584
7599
  const { config } = useArcenPay();
7585
- const { features, isSubscribed, isLoading } = useEntitlement(walletAddress, featureKey);
7600
+ const { features, isSubscribed, isLoading } = useEntitlement(
7601
+ walletAddress,
7602
+ featureKey
7603
+ );
7586
7604
  const [decrypting, setDecrypting] = useState5(false);
7587
7605
  const [decryptPassed, setDecryptPassed] = useState5(false);
7588
7606
  const [decryptError, setDecryptError] = useState5(null);
@@ -7652,7 +7670,9 @@ function FeatureFlagGuard({
7652
7670
  sessionSigs = await client.getSessionSigs({
7653
7671
  chain: "ethereum",
7654
7672
  authNeededCallback: async (_params) => authSig,
7655
- expiration: new Date(Date.now() + 24 * 60 * 60 * 1e3).toISOString(),
7673
+ expiration: new Date(
7674
+ Date.now() + 24 * 60 * 60 * 1e3
7675
+ ).toISOString(),
7656
7676
  resourceAbilityRequests: []
7657
7677
  });
7658
7678
  cacheSessionSigs(sessionSigs);
@@ -7727,27 +7747,34 @@ function TemplateRenderer({
7727
7747
  blocks,
7728
7748
  className = ""
7729
7749
  }) {
7730
- return /* @__PURE__ */ jsx4("div", { className: `arcenpay-template-renderer ${className}`, "data-template-name": name, children: blocks.map((block, index) => {
7731
- if (block.type === "heading") {
7732
- return /* @__PURE__ */ jsx4("h2", { children: block.content }, `${block.type}-${index}`);
7733
- }
7734
- if (block.type === "text") {
7735
- return /* @__PURE__ */ jsx4("p", { children: block.content }, `${block.type}-${index}`);
7736
- }
7737
- if (block.type === "price") {
7738
- return /* @__PURE__ */ jsxs2("p", { children: [
7739
- /* @__PURE__ */ jsx4("strong", { children: block.amount }),
7740
- block.interval ? /* @__PURE__ */ jsx4("span", { children: ` ${block.interval}` }) : null
7741
- ] }, `${block.type}-${index}`);
7742
- }
7743
- if (block.type === "feature-list") {
7744
- return /* @__PURE__ */ jsx4("ul", { children: (block.items || []).map((item) => /* @__PURE__ */ jsx4("li", { children: item }, item)) }, `${block.type}-${index}`);
7745
- }
7746
- if (block.type === "cta") {
7747
- return /* @__PURE__ */ jsx4("a", { href: block.href || "#", children: block.content || "Continue" }, `${block.type}-${index}`);
7750
+ return /* @__PURE__ */ jsx4(
7751
+ "div",
7752
+ {
7753
+ className: `arcenpay-template-renderer ${className}`,
7754
+ "data-template-name": name,
7755
+ children: blocks.map((block, index) => {
7756
+ if (block.type === "heading") {
7757
+ return /* @__PURE__ */ jsx4("h2", { children: block.content }, `${block.type}-${index}`);
7758
+ }
7759
+ if (block.type === "text") {
7760
+ return /* @__PURE__ */ jsx4("p", { children: block.content }, `${block.type}-${index}`);
7761
+ }
7762
+ if (block.type === "price") {
7763
+ return /* @__PURE__ */ jsxs2("p", { children: [
7764
+ /* @__PURE__ */ jsx4("strong", { children: block.amount }),
7765
+ block.interval ? /* @__PURE__ */ jsx4("span", { children: ` ${block.interval}` }) : null
7766
+ ] }, `${block.type}-${index}`);
7767
+ }
7768
+ if (block.type === "feature-list") {
7769
+ return /* @__PURE__ */ jsx4("ul", { children: (block.items || []).map((item) => /* @__PURE__ */ jsx4("li", { children: item }, item)) }, `${block.type}-${index}`);
7770
+ }
7771
+ if (block.type === "cta") {
7772
+ return /* @__PURE__ */ jsx4("a", { href: block.href || "#", children: block.content || "Continue" }, `${block.type}-${index}`);
7773
+ }
7774
+ return null;
7775
+ })
7748
7776
  }
7749
- return null;
7750
- }) });
7777
+ );
7751
7778
  }
7752
7779
 
7753
7780
  // src/hooks/useFlag.ts
@@ -7888,7 +7915,9 @@ function useTrack() {
7888
7915
  const track = useCallback7(
7889
7916
  async (name, traits) => {
7890
7917
  if (!session.token) {
7891
- console.warn("[useTrack] Cannot track: no session. Call arcen.identify() first.");
7918
+ console.warn(
7919
+ "[useTrack] Cannot track: no session. Call arcen.identify() first."
7920
+ );
7892
7921
  return;
7893
7922
  }
7894
7923
  try {
@@ -1,3 +1,30 @@
1
+ import {
2
+ C,
3
+ IEvents,
4
+ Po,
5
+ Qe,
6
+ Qo,
7
+ concat as concat2,
8
+ detect,
9
+ f,
10
+ fromString,
11
+ h,
12
+ i,
13
+ init_es,
14
+ init_esm as init_esm2,
15
+ init_index_es,
16
+ init_index_es2,
17
+ init_index_es3,
18
+ init_index_es4,
19
+ init_index_es5 as init_index_es7,
20
+ init_src,
21
+ r,
22
+ require_cjs,
23
+ require_cjs2,
24
+ require_cjs3,
25
+ sn,
26
+ toString as toString2
27
+ } from "./chunk-HPVNNTYF.mjs";
1
28
  import {
2
29
  AbiCoder,
3
30
  AddressZero,
@@ -174,33 +201,6 @@ import {
174
201
  wordlists,
175
202
  zeroPad
176
203
  } from "./chunk-M4NAIVF3.mjs";
177
- import {
178
- C,
179
- IEvents,
180
- Po,
181
- Qe,
182
- Qo,
183
- concat as concat2,
184
- detect,
185
- f,
186
- fromString,
187
- h,
188
- i,
189
- init_es,
190
- init_esm as init_esm2,
191
- init_index_es,
192
- init_index_es2,
193
- init_index_es3,
194
- init_index_es4,
195
- init_index_es5 as init_index_es7,
196
- init_src,
197
- r,
198
- require_cjs,
199
- require_cjs2,
200
- require_cjs3,
201
- sn,
202
- toString as toString2
203
- } from "./chunk-HPVNNTYF.mjs";
204
204
  import "./chunk-RKV353G3.mjs";
205
205
  import {
206
206
  A,
@@ -14995,7 +14995,7 @@ var init_index_es14 = __esm({
14995
14995
  C5 = ["chainChanged", "accountsChanged"];
14996
14996
  P3 = ["chainChanged", "accountsChanged", "message", "disconnect", "connect"];
14997
14997
  D2 = async () => {
14998
- const { createAppKit: s } = await import("./core-GECUTVXD.mjs");
14998
+ const { createAppKit: s } = await import("./core-Y4UECIAE.mjs");
14999
14999
  return s;
15000
15000
  };
15001
15001
  z2 = Object.defineProperty;
@@ -14,7 +14,7 @@ import {
14
14
  n,
15
15
  o,
16
16
  r
17
- } from "./chunk-ZKNFAGRN.mjs";
17
+ } from "./chunk-DK2DW6NJ.mjs";
18
18
  import {
19
19
  AccountController,
20
20
  AlertController,