@accesly/react 1.3.2 → 1.4.1
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/.tsbuildinfo +1 -1
- package/dist/index.cjs +36 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, CognitoConfig, AuthClient, SessionStorage, DeviceStore, TelemetrySink, TokenManager, AccesslyEndpoints, AuthStatus, CredentialRecord, EncryptedEnvelope, WalletHistoryItem } from '@accesly/core';
|
|
1
|
+
import { Environment, CognitoConfig, AuthClient, SessionStorage, DeviceStore, TelemetrySink, TokenManager, AccesslyEndpoints, AuthStatus, CredentialRecord, TransferAsset, EncryptedEnvelope, WalletHistoryItem } from '@accesly/core';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -389,8 +389,8 @@ interface FundTestnetResult {
|
|
|
389
389
|
readonly reason?: 'mainnet-not-supported' | 'friendbot-error' | 'already-funded' | 'funded-now';
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
392
|
-
* Input para `tx.send(...)` — manda XLM desde el Smart Account del
|
|
393
|
-
* cualquier address Stellar (G… clásico o C… contrato).
|
|
392
|
+
* Input para `tx.send(...)` — manda XLM o USDC desde el Smart Account del
|
|
393
|
+
* usuario a cualquier address Stellar (G… clásico o C… contrato).
|
|
394
394
|
*
|
|
395
395
|
* El SDK orquesta todo el flujo: simulate → ECDH F2 → reconstruct seed →
|
|
396
396
|
* sign auth entry → submit. El caller solo entrega los inputs sensibles que
|
|
@@ -399,8 +399,18 @@ interface FundTestnetResult {
|
|
|
399
399
|
interface SendXlmInput {
|
|
400
400
|
/** Destinatario. G… (clásico) o C… (contrato). */
|
|
401
401
|
readonly destinationAddress: string;
|
|
402
|
-
/**
|
|
402
|
+
/**
|
|
403
|
+
* Monto en unidades atómicas (1e-7 para ambos XLM y USDC). Base-10 string
|
|
404
|
+
* para evitar precisión. Ejemplo: `"12500000"` = 1.25 XLM o 1.25 USDC.
|
|
405
|
+
*/
|
|
403
406
|
readonly amountStroops: string;
|
|
407
|
+
/**
|
|
408
|
+
* Asset a transferir. Default `'XLM'` (backwards compat con apps <1.4 que
|
|
409
|
+
* no pasaban este field). Para USDC el Smart Account debe tener el rule 1
|
|
410
|
+
* (USDC_SAC tx_target) activado — si no, el backend devuelve 409 y la app
|
|
411
|
+
* debe disparar el flow "Activar USDC".
|
|
412
|
+
*/
|
|
413
|
+
readonly asset?: TransferAsset;
|
|
404
414
|
/**
|
|
405
415
|
* F1 (Shamir share encoded incluyendo el byte de índice) ya en plano —
|
|
406
416
|
* típicamente desencriptado client-side via WebAuthn PRF antes de llamar.
|
|
@@ -683,8 +693,8 @@ interface UseWalletStatusResult {
|
|
|
683
693
|
declare function useWalletStatus(): UseWalletStatusResult;
|
|
684
694
|
|
|
685
695
|
/**
|
|
686
|
-
* `useBalance(walletAddress?)` — devuelve
|
|
687
|
-
* con push real-time vía SSE.
|
|
696
|
+
* `useBalance(walletAddress?)` — devuelve los balances XLM y USDC del Smart
|
|
697
|
+
* Account con push real-time vía SSE.
|
|
688
698
|
*
|
|
689
699
|
* Si SSE está configurado (env tiene `walletStreamUrl` y `EventSource` existe),
|
|
690
700
|
* el hook se suscribe al canal `balance` del `wallet-stream` Lambda y se
|
|
@@ -695,12 +705,20 @@ declare function useWalletStatus(): UseWalletStatusResult;
|
|
|
695
705
|
*
|
|
696
706
|
* El `walletAddress` se auto-resuelve desde el `DeviceStore` si no se pasa
|
|
697
707
|
* (cubrir el caso "wallet del user actual sin tener que pasarla a mano").
|
|
708
|
+
*
|
|
709
|
+
* **Multi-asset (1.4.0+):** además de `stroops`/`xlm` (XLM) ahora devuelve
|
|
710
|
+
* `usdc` (formatted) y `usdcAtomic` (micro-USDC, 1e-7). Backwards compat:
|
|
711
|
+
* apps en 1.3 que solo leen `stroops`/`xlm` siguen funcionando sin cambios.
|
|
698
712
|
*/
|
|
699
713
|
interface UseBalanceResult {
|
|
700
|
-
/**
|
|
714
|
+
/** XLM en stroops (string base-10). `null` mientras se carga o no hay address. */
|
|
701
715
|
readonly stroops: string | null;
|
|
702
|
-
/**
|
|
716
|
+
/** XLM formatted (sin trailing zeros). `null` mientras se carga. */
|
|
703
717
|
readonly xlm: string | null;
|
|
718
|
+
/** USDC formatted (sin trailing zeros). `null` mientras se carga o si el SAC nunca registró la cuenta. */
|
|
719
|
+
readonly usdc: string | null;
|
|
720
|
+
/** USDC en unidades atómicas (1e-7 USDC). `null` mientras se carga. */
|
|
721
|
+
readonly usdcAtomic: string | null;
|
|
704
722
|
readonly isLoading: boolean;
|
|
705
723
|
readonly error: Error | null;
|
|
706
724
|
/** Fuerza fetch HTTP inmediato (útil tras una operación del user). */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, CognitoConfig, AuthClient, SessionStorage, DeviceStore, TelemetrySink, TokenManager, AccesslyEndpoints, AuthStatus, CredentialRecord, EncryptedEnvelope, WalletHistoryItem } from '@accesly/core';
|
|
1
|
+
import { Environment, CognitoConfig, AuthClient, SessionStorage, DeviceStore, TelemetrySink, TokenManager, AccesslyEndpoints, AuthStatus, CredentialRecord, TransferAsset, EncryptedEnvelope, WalletHistoryItem } from '@accesly/core';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -389,8 +389,8 @@ interface FundTestnetResult {
|
|
|
389
389
|
readonly reason?: 'mainnet-not-supported' | 'friendbot-error' | 'already-funded' | 'funded-now';
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
392
|
-
* Input para `tx.send(...)` — manda XLM desde el Smart Account del
|
|
393
|
-
* cualquier address Stellar (G… clásico o C… contrato).
|
|
392
|
+
* Input para `tx.send(...)` — manda XLM o USDC desde el Smart Account del
|
|
393
|
+
* usuario a cualquier address Stellar (G… clásico o C… contrato).
|
|
394
394
|
*
|
|
395
395
|
* El SDK orquesta todo el flujo: simulate → ECDH F2 → reconstruct seed →
|
|
396
396
|
* sign auth entry → submit. El caller solo entrega los inputs sensibles que
|
|
@@ -399,8 +399,18 @@ interface FundTestnetResult {
|
|
|
399
399
|
interface SendXlmInput {
|
|
400
400
|
/** Destinatario. G… (clásico) o C… (contrato). */
|
|
401
401
|
readonly destinationAddress: string;
|
|
402
|
-
/**
|
|
402
|
+
/**
|
|
403
|
+
* Monto en unidades atómicas (1e-7 para ambos XLM y USDC). Base-10 string
|
|
404
|
+
* para evitar precisión. Ejemplo: `"12500000"` = 1.25 XLM o 1.25 USDC.
|
|
405
|
+
*/
|
|
403
406
|
readonly amountStroops: string;
|
|
407
|
+
/**
|
|
408
|
+
* Asset a transferir. Default `'XLM'` (backwards compat con apps <1.4 que
|
|
409
|
+
* no pasaban este field). Para USDC el Smart Account debe tener el rule 1
|
|
410
|
+
* (USDC_SAC tx_target) activado — si no, el backend devuelve 409 y la app
|
|
411
|
+
* debe disparar el flow "Activar USDC".
|
|
412
|
+
*/
|
|
413
|
+
readonly asset?: TransferAsset;
|
|
404
414
|
/**
|
|
405
415
|
* F1 (Shamir share encoded incluyendo el byte de índice) ya en plano —
|
|
406
416
|
* típicamente desencriptado client-side via WebAuthn PRF antes de llamar.
|
|
@@ -683,8 +693,8 @@ interface UseWalletStatusResult {
|
|
|
683
693
|
declare function useWalletStatus(): UseWalletStatusResult;
|
|
684
694
|
|
|
685
695
|
/**
|
|
686
|
-
* `useBalance(walletAddress?)` — devuelve
|
|
687
|
-
* con push real-time vía SSE.
|
|
696
|
+
* `useBalance(walletAddress?)` — devuelve los balances XLM y USDC del Smart
|
|
697
|
+
* Account con push real-time vía SSE.
|
|
688
698
|
*
|
|
689
699
|
* Si SSE está configurado (env tiene `walletStreamUrl` y `EventSource` existe),
|
|
690
700
|
* el hook se suscribe al canal `balance` del `wallet-stream` Lambda y se
|
|
@@ -695,12 +705,20 @@ declare function useWalletStatus(): UseWalletStatusResult;
|
|
|
695
705
|
*
|
|
696
706
|
* El `walletAddress` se auto-resuelve desde el `DeviceStore` si no se pasa
|
|
697
707
|
* (cubrir el caso "wallet del user actual sin tener que pasarla a mano").
|
|
708
|
+
*
|
|
709
|
+
* **Multi-asset (1.4.0+):** además de `stroops`/`xlm` (XLM) ahora devuelve
|
|
710
|
+
* `usdc` (formatted) y `usdcAtomic` (micro-USDC, 1e-7). Backwards compat:
|
|
711
|
+
* apps en 1.3 que solo leen `stroops`/`xlm` siguen funcionando sin cambios.
|
|
698
712
|
*/
|
|
699
713
|
interface UseBalanceResult {
|
|
700
|
-
/**
|
|
714
|
+
/** XLM en stroops (string base-10). `null` mientras se carga o no hay address. */
|
|
701
715
|
readonly stroops: string | null;
|
|
702
|
-
/**
|
|
716
|
+
/** XLM formatted (sin trailing zeros). `null` mientras se carga. */
|
|
703
717
|
readonly xlm: string | null;
|
|
718
|
+
/** USDC formatted (sin trailing zeros). `null` mientras se carga o si el SAC nunca registró la cuenta. */
|
|
719
|
+
readonly usdc: string | null;
|
|
720
|
+
/** USDC en unidades atómicas (1e-7 USDC). `null` mientras se carga. */
|
|
721
|
+
readonly usdcAtomic: string | null;
|
|
704
722
|
readonly isLoading: boolean;
|
|
705
723
|
readonly error: Error | null;
|
|
706
724
|
/** Fuerza fetch HTTP inmediato (útil tras una operación del user). */
|
package/dist/index.js
CHANGED
|
@@ -665,6 +665,10 @@ function useAccesly() {
|
|
|
665
665
|
* passkey + derivación HKDF + ensureWallet en una sola llamada.
|
|
666
666
|
*/
|
|
667
667
|
async bootstrap(input) {
|
|
668
|
+
try {
|
|
669
|
+
await ctx.tokenManager.getValidIdToken();
|
|
670
|
+
} catch {
|
|
671
|
+
}
|
|
668
672
|
const enc = new TextEncoder();
|
|
669
673
|
const userIdHash = sha256(enc.encode(input.email));
|
|
670
674
|
const prfSalt = getRandomBytes(32);
|
|
@@ -795,7 +799,8 @@ function useAccesly() {
|
|
|
795
799
|
const explorerBase = networkPassphrase === "Public Global Stellar Network ; September 2015" ? "https://stellar.expert/explorer/public/tx/" : "https://stellar.expert/explorer/testnet/tx/";
|
|
796
800
|
const sim = await ctx.endpoints.simulateTx({
|
|
797
801
|
amountStroops: input.amountStroops,
|
|
798
|
-
destinationAddress: input.destinationAddress
|
|
802
|
+
destinationAddress: input.destinationAddress,
|
|
803
|
+
...input.asset ? { asset: input.asset } : {}
|
|
799
804
|
});
|
|
800
805
|
const ephemeral = generateX25519Keypair();
|
|
801
806
|
const ephemeralPubBase64 = base64FromBytes(ephemeral.publicKey);
|
|
@@ -836,7 +841,8 @@ function useAccesly() {
|
|
|
836
841
|
ledger: Math.floor(Date.now() / 1e3),
|
|
837
842
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
838
843
|
to: input.destinationAddress,
|
|
839
|
-
amountStroops: input.amountStroops
|
|
844
|
+
amountStroops: input.amountStroops,
|
|
845
|
+
...input.asset ? { asset: input.asset } : {}
|
|
840
846
|
});
|
|
841
847
|
}
|
|
842
848
|
}
|
|
@@ -1491,6 +1497,8 @@ function useBalance(walletAddress) {
|
|
|
1491
1497
|
);
|
|
1492
1498
|
const [stroops, setStroops] = useState(null);
|
|
1493
1499
|
const [xlm, setXlm] = useState(null);
|
|
1500
|
+
const [usdc, setUsdc] = useState(null);
|
|
1501
|
+
const [usdcAtomic, setUsdcAtomic] = useState(null);
|
|
1494
1502
|
const [isLoading, setIsLoading] = useState(true);
|
|
1495
1503
|
const [error, setError] = useState(null);
|
|
1496
1504
|
const walletRef = useStableRef3(wallet);
|
|
@@ -1524,8 +1532,15 @@ function useBalance(walletAddress) {
|
|
|
1524
1532
|
if (!resolvedAddress) return;
|
|
1525
1533
|
try {
|
|
1526
1534
|
const res = await endpointsRef.current.walletBalance(resolvedAddress);
|
|
1527
|
-
setStroops(res.xlm.stroops);
|
|
1528
|
-
setXlm(res.xlm.xlm);
|
|
1535
|
+
setStroops(res.xlm.atomic ?? res.xlm.stroops);
|
|
1536
|
+
setXlm(res.xlm.formatted ?? res.xlm.xlm);
|
|
1537
|
+
if (res.usdc) {
|
|
1538
|
+
setUsdc(res.usdc.formatted);
|
|
1539
|
+
setUsdcAtomic(res.usdc.atomic);
|
|
1540
|
+
} else {
|
|
1541
|
+
setUsdc(null);
|
|
1542
|
+
setUsdcAtomic(null);
|
|
1543
|
+
}
|
|
1529
1544
|
setError(null);
|
|
1530
1545
|
} catch (err) {
|
|
1531
1546
|
setError(err);
|
|
@@ -1544,8 +1559,22 @@ function useBalance(walletAddress) {
|
|
|
1544
1559
|
resolvedAddress,
|
|
1545
1560
|
"balance",
|
|
1546
1561
|
(data) => {
|
|
1547
|
-
|
|
1548
|
-
|
|
1562
|
+
const d = data;
|
|
1563
|
+
const xlmField = d["xlm"];
|
|
1564
|
+
if (xlmField && typeof xlmField === "object") {
|
|
1565
|
+
const x = xlmField;
|
|
1566
|
+
if (typeof x.atomic === "string") setStroops(x.atomic);
|
|
1567
|
+
if (typeof x.formatted === "string") setXlm(x.formatted);
|
|
1568
|
+
} else if (typeof xlmField === "string") {
|
|
1569
|
+
setXlm(xlmField);
|
|
1570
|
+
}
|
|
1571
|
+
if (typeof d["stroops"] === "string") setStroops(d["stroops"]);
|
|
1572
|
+
const usdcField = d["usdc"];
|
|
1573
|
+
if (usdcField && typeof usdcField === "object") {
|
|
1574
|
+
const u = usdcField;
|
|
1575
|
+
if (typeof u.formatted === "string") setUsdc(u.formatted);
|
|
1576
|
+
if (typeof u.atomic === "string") setUsdcAtomic(u.atomic);
|
|
1577
|
+
}
|
|
1549
1578
|
setError(null);
|
|
1550
1579
|
setIsLoading(false);
|
|
1551
1580
|
}
|
|
@@ -1576,7 +1605,7 @@ function useBalance(walletAddress) {
|
|
|
1576
1605
|
const refresh = useCallback(async () => {
|
|
1577
1606
|
await doFetchRef.current();
|
|
1578
1607
|
}, [doFetchRef]);
|
|
1579
|
-
return { stroops, xlm, isLoading, error, refresh };
|
|
1608
|
+
return { stroops, xlm, usdc, usdcAtomic, isLoading, error, refresh };
|
|
1580
1609
|
}
|
|
1581
1610
|
|
|
1582
1611
|
// src/hooks/useWalletActivity.ts
|