@bluxcc/react 0.1.0 → 0.1.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.
Files changed (70) hide show
  1. package/LICENSE +80 -0
  2. package/README.md +101 -1
  3. package/dist/assets/Icons.d.ts +12 -1
  4. package/dist/assets/bluxLogo.d.ts +3 -1
  5. package/dist/assets/logos.d.ts +6 -1
  6. package/dist/chains.d.ts +8 -0
  7. package/dist/components/Button/buttonVariants.d.ts +2 -2
  8. package/dist/components/Button/index.d.ts +13 -6
  9. package/dist/components/CardItem/index.d.ts +10 -0
  10. package/dist/components/Input/OTPInput.d.ts +3 -0
  11. package/dist/components/Input/index.d.ts +16 -0
  12. package/dist/components/Modal/Header/index.d.ts +3 -3
  13. package/dist/components/Modal/index.d.ts +3 -4
  14. package/dist/components/Transaction/History/index.d.ts +10 -0
  15. package/dist/components/Transaction/Summery/index.d.ts +9 -0
  16. package/dist/constants/index.d.ts +6 -2
  17. package/dist/containers/BluxModal/content.d.ts +11 -0
  18. package/dist/containers/BluxModal/index.d.ts +7 -0
  19. package/dist/containers/ConnectModal/content.d.ts +11 -0
  20. package/dist/containers/ConnectModal/index.d.ts +2 -1
  21. package/dist/containers/Pages/Activity/index.d.ts +3 -0
  22. package/dist/containers/Pages/ConfirmCode/index.d.ts +3 -0
  23. package/dist/containers/Pages/OnBoarding/index.d.ts +7 -0
  24. package/dist/containers/Pages/Profile/index.d.ts +3 -0
  25. package/dist/containers/Pages/Send/index.d.ts +3 -0
  26. package/dist/containers/Pages/SignTransaction/index.d.ts +3 -0
  27. package/dist/containers/Pages/Successful/index.d.ts +3 -0
  28. package/dist/containers/Pages/Waiting/index.d.ts +3 -0
  29. package/dist/context/provider.d.ts +1 -1
  30. package/dist/hooks/useAccount.d.ts +12 -0
  31. package/dist/hooks/useBlux.d.ts +4 -2
  32. package/dist/hooks/useGoogleFont.d.ts +1 -4
  33. package/dist/index.cjs.js +1406 -0
  34. package/dist/index.cjs.js.map +1 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.esm.js +1399 -1
  37. package/dist/index.esm.js.map +1 -1
  38. package/dist/types/index.d.ts +95 -23
  39. package/dist/useStellar/index.d.ts +2 -0
  40. package/dist/useStellar/useBalance.d.ts +8 -0
  41. package/dist/utils/BN.d.ts +3 -0
  42. package/dist/utils/capitalizeFirstLetter.d.ts +2 -0
  43. package/dist/utils/getBorderRadius.d.ts +2 -1
  44. package/dist/utils/getContrastColor.d.ts +2 -0
  45. package/dist/utils/getHorizonServer.d.ts +6 -0
  46. package/dist/utils/getInitialHeight.d.ts +2 -0
  47. package/dist/utils/getNetworkByPassphrase.d.ts +1 -0
  48. package/dist/utils/getNetworkPassphrase.d.ts +1 -0
  49. package/dist/utils/getTransactionDetails.d.ts +6 -0
  50. package/dist/utils/handleIcons.d.ts +2 -1
  51. package/dist/utils/handleLogos.d.ts +3 -0
  52. package/dist/utils/humanizeAmount.d.ts +3 -0
  53. package/dist/utils/initializeRabetMobile.d.ts +2 -1
  54. package/dist/utils/mappedWallets.d.ts +6 -3
  55. package/dist/utils/signTransactionHandler.d.ts +3 -0
  56. package/dist/utils/stellar/getExplorerUrl.d.ts +2 -0
  57. package/dist/utils/stellar/getNetworkByPassphrase.d.ts +2 -0
  58. package/dist/utils/stellar/getNetworkPassphrase.d.ts +2 -0
  59. package/dist/utils/stellar/getStellarServer.d.ts +6 -0
  60. package/dist/utils/stellar/getTransactionDetails.d.ts +7 -0
  61. package/dist/utils/stellar/signTransaction.d.ts +3 -0
  62. package/dist/utils/stellar/submitTransaction.d.ts +3 -0
  63. package/dist/utils/submitTransaction.d.ts +2 -0
  64. package/dist/wallets/configs/albedoConfig.d.ts +2 -2
  65. package/dist/wallets/configs/freighterConfig.d.ts +2 -2
  66. package/dist/wallets/configs/lobstrConfig.d.ts +2 -2
  67. package/dist/wallets/configs/rabetConfig.d.ts +2 -2
  68. package/dist/wallets/configs/xbullConfig.d.ts +2 -2
  69. package/dist/wallets/walletsConfig.d.ts +2 -2
  70. package/package.json +9 -16
@@ -1,3 +1,8 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon';
3
+ /**
4
+ * Enum representing the supported wallets in the system.
5
+ */
1
6
  export declare enum SupportedWallets {
2
7
  Rabet = "Rabet",
3
8
  Albedo = "Albedo",
@@ -5,6 +10,9 @@ export declare enum SupportedWallets {
5
10
  Xbull = "xBull",
6
11
  Lobstr = "LOBSTR"
7
12
  }
13
+ /**
14
+ * Enum defining the various Stellar network environments.
15
+ */
8
16
  export declare enum WalletNetwork {
9
17
  PUBLIC = "Public Global Stellar Network ; September 2015",
10
18
  TESTNET = "Test SDF Network ; September 2015",
@@ -12,23 +20,56 @@ export declare enum WalletNetwork {
12
20
  SANDBOX = "Local Sandbox Stellar Network ; September 2022",
13
21
  STANDALONE = "Standalone Network ; February 2017"
14
22
  }
23
+ export interface AccountData {
24
+ id: string;
25
+ sequence: string;
26
+ subentry_count: number;
27
+ thresholds: Horizon.HorizonApi.AccountThresholds;
28
+ balances: Horizon.HorizonApi.BalanceLine[];
29
+ xlmBalance: string;
30
+ transactions?: Horizon.ServerApi.TransactionRecord[];
31
+ }
32
+ /**
33
+ * Configuration options for the provider.
34
+ */
15
35
  export interface IProviderConfig {
16
36
  appName: string;
17
- networkPassphrase: string;
37
+ appLogo?: string;
38
+ network: string;
18
39
  }
40
+ /**
41
+ * Information about the connected wallet.
42
+ */
19
43
  export interface WalletInfo {
20
- name: SupportedWallets | null;
44
+ name: SupportedWallets;
21
45
  address: string | null;
22
46
  }
47
+ /**
48
+ * User-related information within the context.
49
+ */
23
50
  export interface IUser {
24
51
  wallet: WalletInfo | null;
25
52
  }
53
+ /**
54
+ * Context state management interface.
55
+ */
26
56
  export interface ContextState {
27
- value: ContextValues;
28
- setValue: React.Dispatch<React.SetStateAction<ContextValues>>;
57
+ value: ContextInterface;
58
+ setValue: React.Dispatch<React.SetStateAction<ContextInterface>>;
59
+ route: Routes;
60
+ setRoute: React.Dispatch<React.SetStateAction<Routes>>;
29
61
  }
30
- export type SupportedFonts = 'Manrope' | 'Inter' | 'JetBrains Mono' | 'PP Editorial Sans';
62
+ /**
63
+ * Supported font options for UI customization.
64
+ */
65
+ export type SupportedFonts = 'Manrope' | 'Inter' | 'JetBrains Mono' | 'Lora';
66
+ /**
67
+ * Supported corner radius styles for UI elements.
68
+ */
31
69
  export type CornerRadius = 'none' | 'full' | 'sm' | 'md' | 'lg';
70
+ /**
71
+ * Appearance customization options.
72
+ */
32
73
  export interface IAppearance {
33
74
  theme: 'light' | 'dark';
34
75
  background: string;
@@ -38,41 +79,72 @@ export interface IAppearance {
38
79
  cornerRadius: CornerRadius;
39
80
  cover: string;
40
81
  }
41
- export interface ContextValues {
82
+ /**
83
+ * Structure of the global context values.
84
+ */
85
+ export interface ContextInterface {
42
86
  config: IProviderConfig;
43
87
  appearance: IAppearance;
44
88
  user: IUser;
45
- openModal: boolean;
46
- ready: boolean;
89
+ isModalOpen: boolean;
90
+ isReady: boolean;
47
91
  isDemo: boolean;
48
92
  isAuthenticated: boolean;
49
- isConnecting: boolean;
93
+ availableWallets: WalletInterface[];
94
+ waitingStatus: 'connecting' | 'signing';
95
+ signTransaction: {
96
+ xdr: string;
97
+ resolver: ((value: HorizonApi.SubmitTransactionResponse) => void) | null;
98
+ result: HorizonApi.SubmitTransactionResponse | null;
99
+ };
50
100
  }
51
- export declare enum ModalView {
52
- CHOOSE_WALLET = "CHOOSE_WALLET",
53
- CONNECTING = "CONNECTING",
54
- PROFILE = "PROFILE"
101
+ /**
102
+ * Enum defining different modal views.
103
+ */
104
+ export declare enum Routes {
105
+ ONBOARDING = "ONBOARDING",// View for selecting a wallet
106
+ WAITING = "WAITING",// View for connection process
107
+ SUCCESSFUL = "SUCCESSFUL",// View for connection success process
108
+ PROFILE = "PROFILE",// User profile view
109
+ SIGN_TRANSACTION = "SIGN_TRANSACTION",// User sign transaction view
110
+ SEND = "SEND",// User sign transaction view
111
+ ACTIVITY = "ACTIVITY"
55
112
  }
56
- export interface ModalState {
57
- view: ModalView;
113
+ /**
114
+ * Modal state management interface.
115
+ */
116
+ export interface ModalRoute {
117
+ route: Routes;
58
118
  showAllWallets: boolean;
59
119
  }
120
+ /**
121
+ * Defines the heights for different modal views.
122
+ */
60
123
  export interface ModalHeights {
61
- [ModalView.PROFILE]: number;
62
- [ModalView.CONNECTING]: number;
63
- [ModalView.CHOOSE_WALLET]: number;
124
+ [Routes.PROFILE]: number;
125
+ [Routes.WAITING]: number;
126
+ [Routes.ONBOARDING]: number;
127
+ [Routes.SUCCESSFUL]: number;
128
+ [Routes.SIGN_TRANSACTION]: number;
129
+ [Routes.SEND]: number;
130
+ [Routes.ACTIVITY]: number;
64
131
  }
132
+ /**
133
+ * Represents the result of a successful wallet connection.
134
+ */
65
135
  export interface ConnectResult {
66
136
  publicKey: string;
67
137
  }
138
+ /**
139
+ * Represents the result of a signed transaction.
140
+ */
68
141
  export interface SignResult {
69
142
  signedXdr: string;
70
143
  }
71
- export declare enum networksEnum {
72
- PUBLIC = "mainnet",
73
- TESTNET = "testnet"
74
- }
75
- export interface WalletActions {
144
+ /**
145
+ * Defines the available actions for interacting with a wallet.
146
+ */
147
+ export interface WalletInterface {
76
148
  name: SupportedWallets;
77
149
  website: string;
78
150
  isAvailable: () => Promise<boolean> | boolean;
@@ -0,0 +1,2 @@
1
+ import useBalance from "./useBalance";
2
+ export { useBalance, };
@@ -0,0 +1,8 @@
1
+ type UseBalanceParameters = {
2
+ address: string;
3
+ blockNumber?: number;
4
+ chainId?: number;
5
+ enabled?: boolean;
6
+ };
7
+ declare const useBalance: (_params: UseBalanceParameters) => number;
8
+ export default useBalance;
@@ -0,0 +1,3 @@
1
+ import BigNumber from 'bignumber.js';
2
+ declare const BN: typeof BigNumber;
3
+ export default BN;
@@ -0,0 +1,2 @@
1
+ declare const capitalizeFirstLetter: (str: string) => string;
2
+ export default capitalizeFirstLetter;
@@ -1,2 +1,3 @@
1
1
  import { CornerRadius } from '../types';
2
- export declare const getBorderRadius: (cornerRadius: CornerRadius) => string;
2
+ declare const getBorderRadius: (cornerRadius: CornerRadius) => string;
3
+ export default getBorderRadius;
@@ -0,0 +1,2 @@
1
+ declare const getContrastColor: (bgColor: string) => string;
2
+ export default getContrastColor;
@@ -0,0 +1,6 @@
1
+ import { HORIZON_SERVERS } from '../constants';
2
+ import { Horizon } from '@stellar/stellar-sdk';
3
+ type HorizonServer = Horizon.Server;
4
+ type NetworkKey = keyof typeof HORIZON_SERVERS;
5
+ export declare const getHorizonServer: (network: NetworkKey) => HorizonServer;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Routes } from '../types';
2
+ export declare const getInitialHeight: (route: Routes) => number;
@@ -0,0 +1 @@
1
+ export declare const getNetworkByPassphrase: (passphrase: string) => string;
@@ -0,0 +1 @@
1
+ export declare const getNetworkPassphrase: (network: string) => string;
@@ -0,0 +1,6 @@
1
+ export declare const getTransactionDetails: (xdr: string, networkPassPhrase: string) => {
2
+ action: "createAccount" | "payment" | "pathPaymentStrictReceive" | "pathPaymentStrictSend" | "createPassiveSellOffer" | "manageSellOffer" | "manageBuyOffer" | "setOptions" | "changeTrust" | "allowTrust" | "accountMerge" | "inflation" | "manageData" | "bumpSequence" | "createClaimableBalance" | "claimClaimableBalance" | "beginSponsoringFutureReserves" | "endSponsoringFutureReserves" | "revokeSponsorship" | "clawback" | "clawbackClaimableBalance" | "setTrustLineFlags" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "invokeHostFunction" | "extendFootprintTtl" | "restoreFootprint";
3
+ operations: number;
4
+ sender: string;
5
+ estimatedFee: number;
6
+ };
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
- export declare const handleIcons: (walletName: string) => React.JSX.Element | null;
2
+ declare const handleIcons: (walletName: string) => React.JSX.Element | null;
3
+ export default handleIcons;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const handleLogos: (walletName: string) => React.JSX.Element | null;
3
+ export default handleLogos;
@@ -0,0 +1,3 @@
1
+ export declare function sevenDigit(number: number | string): string;
2
+ declare function humanizeAmount(amount: number | string, big?: boolean): string;
3
+ export default humanizeAmount;
@@ -1 +1,2 @@
1
- export declare const initializeRabetMobile: () => void;
1
+ declare const initializeRabetMobile: () => void;
2
+ export default initializeRabetMobile;
@@ -1,4 +1,7 @@
1
- export declare const mappedWallets: {
2
- wallet: import("../types").WalletActions;
1
+ import { WalletInterface } from '../types';
2
+ export type MappedWallet = {
3
+ wallet: WalletInterface;
3
4
  isAvailable: boolean;
4
- }[];
5
+ };
6
+ declare const getMappedWallets: () => Promise<MappedWallet[]>;
7
+ export default getMappedWallets;
@@ -0,0 +1,3 @@
1
+ import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon';
2
+ import { WalletActions } from '../types';
3
+ export declare const signTransactionHandler: (wallet: WalletActions, xdr: string, address: string, networkPassphrase: string, resolver: ((value: HorizonApi.SubmitTransactionResponse) => void) | null) => Promise<HorizonApi.SubmitTransactionResponse>;
@@ -0,0 +1,2 @@
1
+ declare const getExplorerUrl: (networkPassphrase: string, endpoint: string) => string;
2
+ export default getExplorerUrl;
@@ -0,0 +1,2 @@
1
+ declare const getNetworkByPassphrase: (passphrase: string) => string;
2
+ export default getNetworkByPassphrase;
@@ -0,0 +1,2 @@
1
+ declare const getNetworkPassphrase: (network: string) => string;
2
+ export default getNetworkPassphrase;
@@ -0,0 +1,6 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ import { HORIZON_SERVERS } from '../../constants';
3
+ type HorizonServer = Horizon.Server;
4
+ type NetworkKey = keyof typeof HORIZON_SERVERS;
5
+ declare const getStellarServer: (network: NetworkKey) => HorizonServer;
6
+ export default getStellarServer;
@@ -0,0 +1,7 @@
1
+ declare const getTransactionDetails: (xdr: string) => {
2
+ action: "createAccount" | "payment" | "pathPaymentStrictReceive" | "pathPaymentStrictSend" | "createPassiveSellOffer" | "manageSellOffer" | "manageBuyOffer" | "setOptions" | "changeTrust" | "allowTrust" | "accountMerge" | "inflation" | "manageData" | "bumpSequence" | "createClaimableBalance" | "claimClaimableBalance" | "beginSponsoringFutureReserves" | "endSponsoringFutureReserves" | "revokeSponsorship" | "clawback" | "clawbackClaimableBalance" | "setTrustLineFlags" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "invokeHostFunction" | "extendFootprintTtl" | "restoreFootprint";
3
+ operations: number;
4
+ sender: string;
5
+ estimatedFee: number;
6
+ };
7
+ export default getTransactionDetails;
@@ -0,0 +1,3 @@
1
+ import { WalletInterface } from '../../types';
2
+ declare const signTransaction: (wallet: WalletInterface, xdr: string, address: string, network: string) => Promise<import("@stellar/stellar-sdk/lib/horizon").HorizonApi.SubmitTransactionResponse>;
3
+ export default signTransaction;
@@ -0,0 +1,3 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ declare const submitTransaction: (xdr: string, network: string) => Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
3
+ export default submitTransaction;
@@ -0,0 +1,2 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ export declare const submitTransaction: (xdr: string, networkPassPhrase: string) => Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
@@ -1,2 +1,2 @@
1
- import { WalletActions } from '../../types';
2
- export declare const albedoConfig: WalletActions;
1
+ import { WalletInterface } from '../../types';
2
+ export declare const albedoConfig: WalletInterface;
@@ -1,2 +1,2 @@
1
- import { WalletActions } from '../../types';
2
- export declare const freighterConfig: WalletActions;
1
+ import { WalletInterface } from '../../types';
2
+ export declare const freighterConfig: WalletInterface;
@@ -1,2 +1,2 @@
1
- import { WalletActions } from '../../types';
2
- export declare const lobstrConfig: WalletActions;
1
+ import { WalletInterface } from '../../types';
2
+ export declare const lobstrConfig: WalletInterface;
@@ -1,2 +1,2 @@
1
- import { WalletActions } from '../../types';
2
- export declare const rabetConfig: WalletActions;
1
+ import { WalletInterface } from '../../types';
2
+ export declare const rabetConfig: WalletInterface;
@@ -1,2 +1,2 @@
1
- import { WalletActions } from '../../types';
2
- export declare const xBullConfig: WalletActions;
1
+ import { WalletInterface } from '../../types';
2
+ export declare const xBullConfig: WalletInterface;
@@ -1,2 +1,2 @@
1
- import { SupportedWallets, WalletActions } from '../types';
2
- export declare const walletsConfig: Record<SupportedWallets, WalletActions>;
1
+ import { SupportedWallets, WalletInterface } from '../types';
2
+ export declare const walletsConfig: Record<SupportedWallets, WalletInterface>;
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "@bluxcc/react",
3
- "author": "Blux",
4
- "version": "0.1.0",
3
+ "author": "Blux team",
4
+ "version": "0.1.2",
5
5
  "homepage": "https://blux.cc",
6
6
  "description": "Connecting to the Stellar Ecosystem and Beyond",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
- "url": "git+https://github.com/bluxcc"
9
+ "url": "git+https://github.com/bluxcc/blux"
13
10
  },
14
11
  "type": "module",
15
12
  "main": "dist/index.esm.js",
@@ -23,24 +20,23 @@
23
20
  }
24
21
  },
25
22
  "engines": {
26
- "node": ">=16.0.0"
23
+ "node": ">=14.0.0"
27
24
  },
28
25
  "files": [
29
26
  "dist"
30
27
  ],
31
28
  "scripts": {
32
- "dev": "rollup -c rollup.config.js --watch",
33
- "build": "rollup -c rollup.config.js",
34
- "prepare": "rollup -c rollup.config.js",
35
- "lint": "eslint src -c eslint.config.js"
29
+ "dev": "rollup -c rollup.config.dev.js --watch",
30
+ "build": "rollup -c rollup.config.prod.js"
36
31
  },
37
32
  "peerDependencies": {
38
33
  "@albedo-link/intent": "^0.12.0",
39
34
  "@creit.tech/xbull-wallet-connect": "^0.3.0",
40
35
  "@lobstrco/signer-extension-api": "^1.0.0-beta.0",
41
36
  "@stellar/freighter-api": "^3.0.0",
42
- "react": "^19.0.0",
43
- "react-dom": "^19.0.0"
37
+ "@stellar/stellar-sdk": "^13.1.0",
38
+ "react": ">=17.0.0",
39
+ "react-dom": ">=17.0.0"
44
40
  },
45
41
  "devDependencies": {
46
42
  "@eslint/js": "^9.17.0",
@@ -65,9 +61,6 @@
65
61
  "typescript": "^5.7.2",
66
62
  "typescript-eslint": "^8.19.1"
67
63
  },
68
- "dependencies": {
69
- "clsx": "^2.1.1"
70
- },
71
64
  "optionalDependencies": {
72
65
  "@rollup/rollup-darwin-x64": "4.30.1",
73
66
  "@rollup/rollup-linux-x64-gnu": "4.6.1"