@rozoai/intent-pay 0.1.38-beta.3 → 0.1.38-beta.5

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 (67) hide show
  1. package/build/components/Common/TokenChainLogo/index.d.ts +1 -7
  2. package/build/components/Spinners/TokenLogoSpinner/index.d.ts +1 -6
  3. package/build/hooks/useDepositAddressOptions.d.ts +2 -3
  4. package/build/hooks/usePaymentState.d.ts +5 -11
  5. package/build/hooks/useRozoPay.d.ts +4 -4
  6. package/build/hooks/useSolanaPaymentOptions.d.ts +1 -1
  7. package/build/hooks/useStellarPaymentOptions.d.ts +1 -1
  8. package/build/hooks/useWalletPaymentOptions.d.ts +7 -12
  9. package/build/package.json.js +2 -2
  10. package/build/payment/createPaymentPayload.d.ts +3 -3
  11. package/build/payment/paymentFsm.d.ts +2 -25
  12. package/build/provider/PayContext.d.ts +3 -3
  13. package/build/src/components/Common/ConnectorList/index.js +3 -2
  14. package/build/src/components/Common/ConnectorList/index.js.map +1 -1
  15. package/build/src/components/Common/OptionsList/styles.js +5 -5
  16. package/build/src/components/Common/OptionsList/styles.js.map +1 -1
  17. package/build/src/components/Common/OrderHeader/index.js +32 -16
  18. package/build/src/components/Common/OrderHeader/index.js.map +1 -1
  19. package/build/src/components/Common/TokenChainLogo/index.js +3 -26
  20. package/build/src/components/Common/TokenChainLogo/index.js.map +1 -1
  21. package/build/src/components/Pages/PayWithToken/index.js +4 -15
  22. package/build/src/components/Pages/PayWithToken/index.js.map +1 -1
  23. package/build/src/components/Pages/SelectDepositAddressChain/index.js +17 -6
  24. package/build/src/components/Pages/SelectDepositAddressChain/index.js.map +1 -1
  25. package/build/src/components/Pages/SelectMethod/index.js.map +1 -1
  26. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +26 -64
  27. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +1 -1
  28. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +38 -40
  29. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
  30. package/build/src/components/Pages/WaitingDepositAddress/index.js +33 -110
  31. package/build/src/components/Pages/WaitingDepositAddress/index.js.map +1 -1
  32. package/build/src/components/RozoPayButton/index.js +45 -18
  33. package/build/src/components/RozoPayButton/index.js.map +1 -1
  34. package/build/src/components/RozoPayModal/index.js.map +1 -1
  35. package/build/src/components/Spinners/TokenLogoSpinner/index.js +2 -5
  36. package/build/src/components/Spinners/TokenLogoSpinner/index.js.map +1 -1
  37. package/build/src/hooks/useDepositAddressOptions.js +9 -19
  38. package/build/src/hooks/useDepositAddressOptions.js.map +1 -1
  39. package/build/src/hooks/useExternalPaymentOptions.js +1 -1
  40. package/build/src/hooks/usePaymentState.js +72 -195
  41. package/build/src/hooks/usePaymentState.js.map +1 -1
  42. package/build/src/hooks/useRozoPay.js +2 -4
  43. package/build/src/hooks/useRozoPay.js.map +1 -1
  44. package/build/src/hooks/useSolanaPaymentOptions.js +13 -45
  45. package/build/src/hooks/useSolanaPaymentOptions.js.map +1 -1
  46. package/build/src/hooks/useStellarPaymentOptions.js +11 -40
  47. package/build/src/hooks/useStellarPaymentOptions.js.map +1 -1
  48. package/build/src/hooks/useTokenOptions.js +3 -4
  49. package/build/src/hooks/useTokenOptions.js.map +1 -1
  50. package/build/src/hooks/useWalletPaymentOptions.js +22 -54
  51. package/build/src/hooks/useWalletPaymentOptions.js.map +1 -1
  52. package/build/src/payment/createPaymentPayload.js +12 -37
  53. package/build/src/payment/createPaymentPayload.js.map +1 -1
  54. package/build/src/payment/paymentEffects.js +8 -120
  55. package/build/src/payment/paymentEffects.js.map +1 -1
  56. package/build/src/payment/paymentFsm.js.map +1 -1
  57. package/build/src/types/chainAddress.js +11 -3
  58. package/build/src/types/chainAddress.js.map +1 -1
  59. package/build/src/utils/format.js +18 -84
  60. package/build/src/utils/format.js.map +1 -1
  61. package/build/src/utils/token.js +5 -21
  62. package/build/src/utils/token.js.map +1 -1
  63. package/build/utils/format.d.ts +7 -45
  64. package/build/utils/token.d.ts +2 -6
  65. package/package.json +2 -2
  66. package/build/src/utils/wallets.js +0 -12
  67. package/build/src/utils/wallets.js.map +0 -1
@@ -1,12 +1,8 @@
1
1
  import { TokenSymbol, supportedTokens } from '@rozoai/intent-common';
2
- export { isNativeToken } from '@rozoai/intent-common';
3
2
 
4
3
  /**
5
4
  * Converts preferredSymbol array to preferredTokens array.
6
- * Explicit preferredSymbol values are respected as given (USDC, USDT, EURC,
7
- * or native ETH/BNB/POL/SOL/XLM). When neither preferredSymbol nor
8
- * preferredTokens is provided, defaults to stablecoins plus native tokens
9
- * so native options aren't silently filtered out of the default request.
5
+ * Only USDC, USDT, and EURC symbols are allowed.
10
6
  * Finds tokens matching the symbols across supported chains (Base, Polygon, Ethereum, Solana, Stellar).
11
7
  */
12
8
  function convertPreferredSymbolsToTokens(symbols, existingPreferredTokens) {
@@ -15,28 +11,16 @@ function convertPreferredSymbolsToTokens(symbols, existingPreferredTokens) {
15
11
  if (existingPreferredTokens !== undefined) {
16
12
  return existingPreferredTokens.filter((v) => !!v);
17
13
  }
18
- const nativeSymbols = [
19
- TokenSymbol.ETH,
20
- TokenSymbol.BNB,
21
- TokenSymbol.POL,
22
- TokenSymbol.SOL,
23
- TokenSymbol.XLM,
24
- ];
25
- // If no preferredSymbol provided, default to stablecoins plus native tokens
14
+ // If no preferredSymbol provided, default to USDC and USDT
26
15
  const symbolsToUse = symbols && symbols.length > 0
27
16
  ? symbols
28
- : [TokenSymbol.USDC, TokenSymbol.USDT, ...nativeSymbols];
17
+ : [TokenSymbol.USDC, TokenSymbol.USDT];
29
18
  // Validate that only allowed symbols are used
30
- const allowedSymbols = [
31
- TokenSymbol.USDC,
32
- TokenSymbol.USDT,
33
- TokenSymbol.EURC,
34
- ...nativeSymbols,
35
- ];
19
+ const allowedSymbols = [TokenSymbol.USDC, TokenSymbol.USDT, TokenSymbol.EURC];
36
20
  const validSymbols = symbolsToUse.filter((s) => allowedSymbols.includes(s));
37
21
  const invalidSymbols = symbolsToUse.filter((s) => !allowedSymbols.includes(s));
38
22
  if (invalidSymbols.length > 0) {
39
- console.warn(`[RozoPay] Invalid preferredSymbol values: ${invalidSymbols.join(", ")}. Allowed: ${allowedSymbols.join(", ")}.`);
23
+ console.warn(`[RozoPay] Invalid preferredSymbol values: ${invalidSymbols.join(", ")}. Only USDC, USDT, and EURC are allowed.`);
40
24
  }
41
25
  if (validSymbols.length === 0) {
42
26
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"token.js","sources":["../../../src/utils/token.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;;;AAOG;AACa,SAAA,+BAA+B,CAC7C,OAAkC,EAClC,uBAA4C,EAAA;;;AAI5C,IAAA,IAAI,uBAAuB,KAAK,SAAS,EAAE;AACzC,QAAA,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACnD;AAED,IAAA,MAAM,aAAa,GAAG;AACpB,QAAA,WAAW,CAAC,GAAG;AACf,QAAA,WAAW,CAAC,GAAG;AACf,QAAA,WAAW,CAAC,GAAG;AACf,QAAA,WAAW,CAAC,GAAG;AACf,QAAA,WAAW,CAAC,GAAG;KAChB,CAAC;;IAGF,MAAM,YAAY,GAChB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;AAC3B,UAAE,OAAO;AACT,UAAE,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,aAAa,CAAC,CAAC;;AAG7D,IAAA,MAAM,cAAc,GAAG;AACrB,QAAA,WAAW,CAAC,IAAI;AAChB,QAAA,WAAW,CAAC,IAAI;AAChB,QAAA,WAAW,CAAC,IAAI;AAChB,QAAA,GAAG,aAAa;KACjB,CAAC;AACF,IAAA,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,C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Token, type Token } from "@rozoai/intent-common";
1
+ import { BigIntStr, RozoPayToken } from "@rozoai/intent-common";
2
2
  export declare const USD_DECIMALS = 2;
3
+ export declare function formatTokenAmount(amount: number, decimals: number): string;
4
+ /**
5
+
3
6
  /**
4
7
  * Round a number to a given number of decimal places
5
8
  *
@@ -16,7 +19,7 @@ export declare function roundDecimals(value: number, decimals: number, round: "u
16
19
  * @param round - The rounding strategy to use ("up", "down", or "nearest")
17
20
  * @returns The formatted USD amount
18
21
  */
19
- export declare function formatUsd(usd: number, round?: "up" | "down" | "nearest", fiatISO?: string): string;
22
+ export declare function formatUsd(usd: number, round?: "up" | "down" | "nearest", fiatISO?: string, decimals?: number): string;
20
23
  /**
21
24
  * Round a USD amount to `USD_DECIMALS` precision
22
25
  */
@@ -25,6 +28,8 @@ export declare function roundUsd(usd: number, round?: "up" | "down" | "nearest")
25
28
  * Round a token amount to `displayDecimals` precision
26
29
  */
27
30
  export declare function roundTokenAmount(amount: bigint | BigIntStr, token: RozoPayToken, round?: "up" | "down" | "nearest"): string;
31
+ /** Strip trailing zeros from a decimal token amount string. e.g. "0.01600" → "0.016" */
32
+ export declare function trimTokenAmount(amount: string): string;
28
33
  /**
29
34
  * Round a token amount in units to `displayDecimals` precision
30
35
  */
@@ -47,46 +52,3 @@ export declare function usdToRoundedTokenAmount(usd: number, token: RozoPayToken
47
52
  * @returns The formatted USD amount
48
53
  */
49
54
  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,11 +1,7 @@
1
- import { isNativeToken, Token, TokenSymbol } from "@rozoai/intent-common";
2
- export { isNativeToken };
1
+ import { Token, TokenSymbol } from "@rozoai/intent-common";
3
2
  /**
4
3
  * Converts preferredSymbol array to preferredTokens array.
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.
4
+ * Only USDC, USDT, and EURC symbols are allowed.
9
5
  * Finds tokens matching the symbols across supported chains (Base, Polygon, Ethereum, Solana, Stellar).
10
6
  */
11
7
  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.38-beta.3",
3
+ "version": "0.1.38-beta.5",
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.24-beta.2",
51
+ "@rozoai/intent-common": "0.1.26-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,12 +0,0 @@
1
- const isWalletInstalled = (name) => {
2
- if (typeof window === "undefined")
3
- return false;
4
- const { ethereum } = window;
5
- return !!(ethereum?.[`is${name}`] ||
6
- (ethereum?.providers &&
7
- ethereum?.providers.find((provider) => provider?.[`is${name}`])));
8
- };
9
- const isPhantom = () => isWalletInstalled("Phantom");
10
-
11
- export { isPhantom, isWalletInstalled };
12
- //# sourceMappingURL=wallets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallets.js","sources":["../../../src/utils/wallets.ts"],"sourcesContent":[null],"names":[],"mappings":"AAOa,MAAA,iBAAiB,GAAG,CAAC,IAAY,KAAI;IAChD,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK,CAAC;AAChD,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,EACN,QAAQ,GAAG,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAC;SACtB,QAAQ,EAAE,SAAS;YAClB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,GAAG,KAAK,IAAI,CAAA,CAAE,CAAC,CAAC,CAAC,CACnE,CAAC;AACJ,EAAE;AASW,MAAA,SAAS,GAAG,MAAM,iBAAiB,CAAC,SAAS;;;;"}