@rozoai/intent-pay 0.1.36 → 0.1.37-beta.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.
Files changed (72) hide show
  1. package/build/components/Common/OptionsList/index.d.ts +1 -0
  2. package/build/components/Common/TokenChainLogo/index.d.ts +7 -1
  3. package/build/components/Spinners/TokenLogoSpinner/index.d.ts +6 -1
  4. package/build/hooks/useDepositAddressOptions.d.ts +3 -2
  5. package/build/hooks/usePaymentState.d.ts +11 -5
  6. package/build/hooks/useRozoPay.d.ts +4 -4
  7. package/build/hooks/useSolanaPaymentOptions.d.ts +1 -1
  8. package/build/hooks/useStellarPaymentOptions.d.ts +1 -1
  9. package/build/hooks/useWalletPaymentOptions.d.ts +12 -7
  10. package/build/package.json.js +2 -2
  11. package/build/payment/createPaymentPayload.d.ts +3 -3
  12. package/build/payment/paymentFsm.d.ts +25 -2
  13. package/build/provider/PayContext.d.ts +3 -3
  14. package/build/src/components/Common/AmountInput/index.js +1 -1
  15. package/build/src/components/Common/AmountInput/index.js.map +1 -1
  16. package/build/src/components/Common/ConnectorList/index.js +2 -3
  17. package/build/src/components/Common/ConnectorList/index.js.map +1 -1
  18. package/build/src/components/Common/OptionsList/index.js +3 -1
  19. package/build/src/components/Common/OptionsList/index.js.map +1 -1
  20. package/build/src/components/Common/TokenChainLogo/index.js +26 -3
  21. package/build/src/components/Common/TokenChainLogo/index.js.map +1 -1
  22. package/build/src/components/Pages/PayWithToken/index.js +15 -4
  23. package/build/src/components/Pages/PayWithToken/index.js.map +1 -1
  24. package/build/src/components/Pages/SelectDepositAddressChain/index.js +6 -17
  25. package/build/src/components/Pages/SelectDepositAddressChain/index.js.map +1 -1
  26. package/build/src/components/Pages/SelectMethod/index.js +1 -3
  27. package/build/src/components/Pages/SelectMethod/index.js.map +1 -1
  28. package/build/src/components/Pages/Solana/ConnectorSolana/index.js +31 -2
  29. package/build/src/components/Pages/Solana/ConnectorSolana/index.js.map +1 -1
  30. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +57 -24
  31. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +1 -1
  32. package/build/src/components/Pages/Stellar/ConnectorStellar/index.js +13 -1
  33. package/build/src/components/Pages/Stellar/ConnectorStellar/index.js.map +1 -1
  34. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +33 -36
  35. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
  36. package/build/src/components/Pages/WaitingDepositAddress/index.js +110 -33
  37. package/build/src/components/Pages/WaitingDepositAddress/index.js.map +1 -1
  38. package/build/src/components/RozoPayModal/index.js +20 -11
  39. package/build/src/components/RozoPayModal/index.js.map +1 -1
  40. package/build/src/components/Spinners/TokenLogoSpinner/index.js +5 -2
  41. package/build/src/components/Spinners/TokenLogoSpinner/index.js.map +1 -1
  42. package/build/src/hooks/useDepositAddressOptions.js +19 -9
  43. package/build/src/hooks/useDepositAddressOptions.js.map +1 -1
  44. package/build/src/hooks/usePaymentState.js +185 -71
  45. package/build/src/hooks/usePaymentState.js.map +1 -1
  46. package/build/src/hooks/useRozoPay.js +4 -2
  47. package/build/src/hooks/useRozoPay.js.map +1 -1
  48. package/build/src/hooks/useSolanaPaymentOptions.js +45 -12
  49. package/build/src/hooks/useSolanaPaymentOptions.js.map +1 -1
  50. package/build/src/hooks/useStellarPaymentOptions.js +40 -10
  51. package/build/src/hooks/useStellarPaymentOptions.js.map +1 -1
  52. package/build/src/hooks/useTokenOptions.js +4 -3
  53. package/build/src/hooks/useTokenOptions.js.map +1 -1
  54. package/build/src/hooks/useWalletPaymentOptions.js +54 -21
  55. package/build/src/hooks/useWalletPaymentOptions.js.map +1 -1
  56. package/build/src/payment/createPaymentPayload.js +38 -13
  57. package/build/src/payment/createPaymentPayload.js.map +1 -1
  58. package/build/src/payment/paymentEffects.js +4 -5
  59. package/build/src/payment/paymentEffects.js.map +1 -1
  60. package/build/src/payment/paymentFsm.js.map +1 -1
  61. package/build/src/provider/RozoPayProvider.js +15 -6
  62. package/build/src/provider/RozoPayProvider.js.map +1 -1
  63. package/build/src/utils/format.js +82 -13
  64. package/build/src/utils/format.js.map +1 -1
  65. package/build/src/utils/token.js +21 -5
  66. package/build/src/utils/token.js.map +1 -1
  67. package/build/utils/format.d.ts +44 -3
  68. package/build/utils/token.d.ts +6 -2
  69. package/package.json +2 -2
  70. package/build/hooks/refreshUtils.d.ts +0 -19
  71. package/build/src/hooks/refreshUtils.js +0 -40
  72. package/build/src/hooks/refreshUtils.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { BigIntStr, RozoPayToken } from "@rozoai/intent-common";
1
+ import { BigIntStr, RozoPayToken, type Token } from "@rozoai/intent-common";
2
2
  export declare const USD_DECIMALS = 2;
3
3
  /**
4
4
  * Round a number to a given number of decimal places
@@ -25,8 +25,6 @@ export declare function roundUsd(usd: number, round?: "up" | "down" | "nearest")
25
25
  * Round a token amount to `displayDecimals` precision
26
26
  */
27
27
  export declare function roundTokenAmount(amount: bigint | BigIntStr, token: RozoPayToken, round?: "up" | "down" | "nearest"): string;
28
- /** Strip trailing zeros from a decimal token amount string. e.g. "0.01600" → "0.016" */
29
- export declare function trimTokenAmount(amount: string): string;
30
28
  /**
31
29
  * Round a token amount in units to `displayDecimals` precision
32
30
  */
@@ -49,3 +47,46 @@ export declare function usdToRoundedTokenAmount(usd: number, token: RozoPayToken
49
47
  * @returns The formatted USD amount
50
48
  */
51
49
  export declare function tokenAmountToRoundedUsd(amount: bigint | BigIntStr, token: RozoPayToken, round?: "up" | "down" | "nearest"): string;
50
+ /**
51
+ * Build a Stellar SEP-0007 `pay` URI that opens a Stellar wallet with the
52
+ * destination, amount, asset, and optional memo pre-filled.
53
+ *
54
+ * Native XLM uses asset_code=XLM with no asset_issuer. Custom assets use the
55
+ * token address (issuer) and token symbol parsed from the Rozo token object.
56
+ */
57
+ export declare function generateStellarDeepLink({ amountUnits, recipientAddress, token, memo, }: {
58
+ amountUnits: string;
59
+ recipientAddress: string;
60
+ token: Token;
61
+ memo?: string | null;
62
+ }): string;
63
+ /**
64
+ * Convert a `RozoPayTokenAmount.amount` value to a full-precision, human-readable
65
+ * decimal string suitable for sending to the backend (checkout/create-payment
66
+ * payloads, on-chain transfer amounts, etc).
67
+ *
68
+ * `amount` is documented as `BigIntStr` (integer base units, e.g. lamports/wei)
69
+ * but some endpoints (e.g. Solana tRPC payment options) have been observed to
70
+ * return an already-human-readable decimal string instead (e.g. "0.012985327").
71
+ * `BigInt()` throws on decimal strings, so this detects the shape first:
72
+ * - Contains a "." → already a decimal token amount, pass through as-is.
73
+ * - Otherwise → integer base units, convert via `formatUnits`.
74
+ */
75
+ export declare function tokenBaseAmountToDecimalString(amount: bigint | string, decimals: number): string;
76
+ /**
77
+ * Inverse of `tokenBaseAmountToDecimalString`: convert a
78
+ * `RozoPayTokenAmount.amount` value to an integer base-units bigint, suitable
79
+ * for on-chain transfer instructions (e.g. lamports for SOL, raw SPL/ERC20
80
+ * transfer amounts).
81
+ *
82
+ * Same shape ambiguity as above — detects a decimal string (already
83
+ * human-readable) and converts it up to base units via `parseUnits`;
84
+ * otherwise assumes the string is already an integer base-units amount.
85
+ */
86
+ /**
87
+ * Strip trailing zeros from a non-native token amount string for display.
88
+ * "0.0200" → "0.02", "1.5000" → "1.5", "1.0" → "1"
89
+ * Only for display — never use for calculations or on-chain amounts.
90
+ */
91
+ export declare function trimTokenAmount(amount: string): string;
92
+ export declare function tokenAmountToBaseUnits(amount: bigint | BigIntStr, decimals: number): bigint;
@@ -1,7 +1,11 @@
1
- import { Token, TokenSymbol } from "@rozoai/intent-common";
1
+ import { isNativeToken, Token, TokenSymbol } from "@rozoai/intent-common";
2
+ export { isNativeToken };
2
3
  /**
3
4
  * Converts preferredSymbol array to preferredTokens array.
4
- * Only USDC, USDT, and EURC symbols are allowed.
5
+ * Explicit preferredSymbol values are respected as given (USDC, USDT, EURC,
6
+ * or native ETH/BNB/POL/SOL/XLM). When neither preferredSymbol nor
7
+ * preferredTokens is provided, defaults to stablecoins plus native tokens
8
+ * so native options aren't silently filtered out of the default request.
5
9
  * Finds tokens matching the symbols across supported chains (Base, Polygon, Ethereum, Solana, Stellar).
6
10
  */
7
11
  export declare function convertPreferredSymbolsToTokens(symbols: TokenSymbol[] | undefined, existingPreferredTokens: Token[] | undefined): Token[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozoai/intent-pay",
3
- "version": "0.1.36",
3
+ "version": "0.1.37-beta.1",
4
4
  "private": false,
5
5
  "description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
6
6
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "@reown/appkit": "^1.7.0",
49
49
  "@rollup/plugin-image": "^3.0.3",
50
50
  "@rollup/plugin-typescript": "^12.1.2",
51
- "@rozoai/intent-common": "0.1.23",
51
+ "@rozoai/intent-common": "0.1.24-beta.1",
52
52
  "@solana/spl-memo": "^0.2.5",
53
53
  "@solana/spl-token": "^0.4.14",
54
54
  "@solana/wallet-adapter-base": "^0.9.27",
@@ -1,19 +0,0 @@
1
- /**
2
- * Utility functions for managing refreshable options
3
- */
4
- export interface RefreshState {
5
- lastExecutedParams: React.MutableRefObject<string | null>;
6
- isApiCallInProgress: React.MutableRefObject<boolean>;
7
- }
8
- /**
9
- * Creates a refresh function that resets the state and calls the provided fetch function
10
- */
11
- export declare function createRefreshFunction<T>(fetchFunction: () => Promise<T>, refreshState: RefreshState): () => Promise<void>;
12
- /**
13
- * Checks if a refresh should be skipped based on current state
14
- */
15
- export declare function shouldSkipRefresh(paramsKey: string, refreshState: RefreshState): boolean;
16
- /**
17
- * Sets up the refresh state for a new API call
18
- */
19
- export declare function setupRefreshState(paramsKey: string, refreshState: RefreshState): void;
@@ -1,40 +0,0 @@
1
- /**
2
- * Utility functions for managing refreshable options
3
- */
4
- /**
5
- * Creates a refresh function that resets the state and calls the provided fetch function
6
- */
7
- function createRefreshFunction(fetchFunction, refreshState) {
8
- return async () => {
9
- // Reset the last executed params to force a refresh
10
- refreshState.lastExecutedParams.current = null;
11
- // Reset API call in progress flag
12
- refreshState.isApiCallInProgress.current = false;
13
- // Call the fetch function
14
- await fetchFunction();
15
- };
16
- }
17
- /**
18
- * Checks if a refresh should be skipped based on current state
19
- */
20
- function shouldSkipRefresh(paramsKey, refreshState) {
21
- // Skip if we've already executed with these exact parameters
22
- if (refreshState.lastExecutedParams.current === paramsKey) {
23
- return true;
24
- }
25
- // Skip if we're already making an API call to prevent concurrent requests
26
- if (refreshState.isApiCallInProgress.current) {
27
- return true;
28
- }
29
- return false;
30
- }
31
- /**
32
- * Sets up the refresh state for a new API call
33
- */
34
- function setupRefreshState(paramsKey, refreshState) {
35
- refreshState.lastExecutedParams.current = paramsKey;
36
- refreshState.isApiCallInProgress.current = true;
37
- }
38
-
39
- export { createRefreshFunction, setupRefreshState, shouldSkipRefresh };
40
- //# sourceMappingURL=refreshUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refreshUtils.js","sources":["../../../src/hooks/refreshUtils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;AAOH;;AAEG;AACa,SAAA,qBAAqB,CACnC,aAA+B,EAC/B,YAA0B,EAAA;IAE1B,OAAO,YAAW;;AAEhB,QAAA,YAAY,CAAC,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAC;;AAG/C,QAAA,YAAY,CAAC,mBAAmB,CAAC,OAAO,GAAG,KAAK,CAAC;;QAGjD,MAAM,aAAa,EAAE,CAAC;AACxB,KAAC,CAAC;AACJ,CAAC;AAED;;AAEG;AACa,SAAA,iBAAiB,CAAC,SAAiB,EAAE,YAA0B,EAAA;;IAE7E,IAAI,YAAY,CAAC,kBAAkB,CAAC,OAAO,KAAK,SAAS,EAAE;AACzD,QAAA,OAAO,IAAI,CAAC;KACb;;AAGD,IAAA,IAAI,YAAY,CAAC,mBAAmB,CAAC,OAAO,EAAE;AAC5C,QAAA,OAAO,IAAI,CAAC;KACb;AAED,IAAA,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;AAEG;AACa,SAAA,iBAAiB,CAAC,SAAiB,EAAE,YAA0B,EAAA;AAC7E,IAAA,YAAY,CAAC,kBAAkB,CAAC,OAAO,GAAG,SAAS,CAAC;AACpD,IAAA,YAAY,CAAC,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;AAClD;;;;"}