@bluxcc/react 0.1.4 → 0.1.6

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 (56) hide show
  1. package/dist/assets/Icons.d.ts +1 -0
  2. package/dist/components/Modal/Backdrop/index.d.ts +2 -1
  3. package/dist/components/Modal/index.d.ts +2 -1
  4. package/dist/components/Transaction/History/index.d.ts +8 -6
  5. package/dist/components/Transaction/Summery/index.d.ts +1 -1
  6. package/dist/constants/index.d.ts +2 -1
  7. package/dist/constants/networkDetails.d.ts +8 -0
  8. package/dist/containers/BluxModal/content.d.ts +4 -2
  9. package/dist/containers/Pages/WrongNetwork/index.d.ts +3 -0
  10. package/dist/context/provider.d.ts +2 -2
  11. package/dist/context/useCheckWalletNetwork.d.ts +3 -0
  12. package/dist/hooks/useAccount.d.ts +1 -1
  13. package/dist/hooks/useBlux.d.ts +5 -4
  14. package/dist/hooks/useCheckProvider.d.ts +2 -0
  15. package/dist/hooks/useCustomNetwork.d.ts +7 -0
  16. package/dist/index.cjs.js +1 -1
  17. package/dist/index.cjs.js.map +1 -1
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.esm.js +1 -1
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/networks.d.ts +1 -1
  22. package/dist/types/index.d.ts +34 -15
  23. package/dist/useStellar/index.d.ts +6 -2
  24. package/dist/useStellar/useAccount.d.ts +12 -0
  25. package/dist/useStellar/useBalance.d.ts +11 -6
  26. package/dist/useStellar/useNetwork.d.ts +2 -0
  27. package/dist/useStellar/useSwitchNetwork.d.ts +5 -0
  28. package/dist/useStellar/useTransactions.d.ts +18 -0
  29. package/dist/utils/formatDate.d.ts +2 -0
  30. package/dist/utils/getBorderRadius.d.ts +1 -1
  31. package/dist/utils/getWalletNetwork.d.ts +1 -1
  32. package/dist/utils/network/getNetworkRpc.d.ts +4 -0
  33. package/dist/utils/stellar/getTransactionDetails.d.ts +3 -3
  34. package/dist/utils/stellar/signTransaction.d.ts +1 -1
  35. package/dist/utils/stellar/submitTransaction.d.ts +2 -1
  36. package/dist/utils/toTitleFormat.d.ts +2 -0
  37. package/package.json +3 -1
  38. package/dist/chains.d.ts +0 -8
  39. package/dist/components/Button/buttonVariants.d.ts +0 -9
  40. package/dist/containers/ConnectModal/content.d.ts +0 -11
  41. package/dist/containers/ConnectModal/index.d.ts +0 -7
  42. package/dist/containers/ModalState/Connecting/index.d.ts +0 -3
  43. package/dist/containers/ModalState/OnBoarding/index.d.ts +0 -7
  44. package/dist/containers/ModalState/Profile/index.d.ts +0 -3
  45. package/dist/hooks/useConnectModal.d.ts +0 -12
  46. package/dist/hooks/useGoogleFont.d.ts +0 -2
  47. package/dist/utils/BN.d.ts +0 -3
  48. package/dist/utils/getHorizonServer.d.ts +0 -6
  49. package/dist/utils/getInitialHeight.d.ts +0 -2
  50. package/dist/utils/getNetworkByPassphrase.d.ts +0 -1
  51. package/dist/utils/getNetworkPassphrase.d.ts +0 -1
  52. package/dist/utils/getTransactionDetails.d.ts +0 -6
  53. package/dist/utils/handleIcons.d.ts +0 -3
  54. package/dist/utils/setWalletNetwork.d.ts +0 -3
  55. package/dist/utils/signTransactionHandler.d.ts +0 -3
  56. package/dist/utils/submitTransaction.d.ts +0 -2
@@ -1,4 +1,4 @@
1
- import { Networks } from "@stellar/stellar-sdk";
1
+ import { Networks } from '@stellar/stellar-sdk';
2
2
  export declare const networks: {
3
3
  mainnet: Networks;
4
4
  testnet: Networks;
@@ -1,7 +1,6 @@
1
- import { Horizon } from '@stellar/stellar-sdk';
1
+ import { Horizon, rpc } from '@stellar/stellar-sdk';
2
+ import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon';
2
3
  import { Url } from '../utils/network/url';
3
- import { Fallback } from '../utils/network/fallback';
4
- import { History } from '../utils/stellar/getTransactions';
5
4
  /**
6
5
  * Enum representing the supported wallets in the system.
7
6
  */
@@ -29,23 +28,31 @@ export interface AccountData {
29
28
  subentry_count: number;
30
29
  balances: Horizon.HorizonApi.BalanceLine[];
31
30
  thresholds: Horizon.HorizonApi.AccountThresholds;
32
- transactions?: History[];
31
+ transactions?: Horizon.ServerApi.TransactionRecord[];
33
32
  }
34
33
  interface IServers {
35
- horizon?: Url | Fallback;
36
- soroban?: Url | Fallback;
34
+ horizon: Url;
35
+ soroban: Url;
37
36
  }
38
37
  export type ITransports = Record<string, IServers>;
39
38
  /**
40
- * Configuration options for the provider.
39
+ * BluxProvider.config
41
40
  */
42
41
  export interface IProviderConfig {
43
42
  appName: string;
44
43
  networks: string[];
45
- appearance: IAppearance;
44
+ defaultNetwork: string;
45
+ appearance?: Partial<IAppearance>;
46
46
  transports?: ITransports;
47
47
  loginMethods?: Array<'wallet' | 'email' | 'sms' | 'google' | 'twitter' | 'discord' | 'github' | 'passkey'>;
48
48
  }
49
+ /**
50
+ * context.value.config
51
+ * Appearance will be set to default values if the user does not provider appearance (or provides some of the values in Appearance)
52
+ */
53
+ export interface IConfig extends IProviderConfig {
54
+ appearance: IAppearance;
55
+ }
49
56
  /**
50
57
  * Information about the connected wallet.
51
58
  */
@@ -74,28 +81,30 @@ export interface ContextState {
74
81
  /**
75
82
  * Supported font options for UI customization.
76
83
  */
77
- export type SupportedFonts = 'Manrope' | 'Inter' | 'JetBrains Mono' | 'Lora';
78
84
  /**
79
85
  * Supported corner radius styles for UI elements.
80
86
  */
81
- export type CornerRadius = 'none' | 'full' | 'sm' | 'md' | 'lg';
82
87
  /**
83
88
  * Appearance customization options.
84
89
  */
85
90
  export interface IAppearance {
86
91
  theme: 'light' | 'dark';
87
92
  background: string;
93
+ bgField: string;
88
94
  accent: string;
89
95
  textColor: string;
90
- font: SupportedFonts;
91
- cornerRadius: CornerRadius;
96
+ font: string;
97
+ cornerRadius: string;
98
+ borderColor: string;
99
+ borderWidth: string;
100
+ includeBorders: boolean;
92
101
  logo?: React.ImgHTMLAttributes<HTMLImageElement>['src'];
93
102
  }
94
103
  /**
95
104
  * Structure of the global context values.
96
105
  */
97
106
  export interface ContextInterface {
98
- config: IProviderConfig;
107
+ config: IConfig;
99
108
  user: IUser;
100
109
  isModalOpen: boolean;
101
110
  isReady: boolean;
@@ -103,10 +112,16 @@ export interface ContextInterface {
103
112
  isAuthenticated: boolean;
104
113
  availableWallets: WalletInterface[];
105
114
  waitingStatus: 'connecting' | 'signing';
115
+ activeNetwork: string;
106
116
  signTransaction: {
107
117
  xdr: string;
108
- resolver: ((value: Horizon.HorizonApi.SubmitTransactionResponse) => void) | null;
109
- result: Horizon.HorizonApi.SubmitTransactionResponse | null;
118
+ network: string;
119
+ resolver: ((value: HorizonApi.SubmitTransactionResponse) => void) | null;
120
+ result: HorizonApi.SubmitTransactionResponse | null;
121
+ };
122
+ servers: {
123
+ horizon: Horizon.Server;
124
+ soroban: rpc.Server;
110
125
  };
111
126
  }
112
127
  /**
@@ -114,6 +129,7 @@ export interface ContextInterface {
114
129
  */
115
130
  export declare enum Routes {
116
131
  ONBOARDING = "ONBOARDING",// View for selecting a wallet
132
+ WRONG_NETWORK = "WRONG_NETWORK",// View for selecting a wallet
117
133
  WAITING = "WAITING",// View for connection process
118
134
  SUCCESSFUL = "SUCCESSFUL",// View for connection success process
119
135
  PROFILE = "PROFILE",// User profile view
@@ -158,6 +174,9 @@ export interface GetNetworkResult {
158
174
  network: string;
159
175
  passphrase: string;
160
176
  }
177
+ export interface ISendTransactionOptions {
178
+ network?: string;
179
+ }
161
180
  /**
162
181
  * Defines the available actions for interacting with a wallet.
163
182
  */
@@ -1,2 +1,6 @@
1
- import useBalance from "./useBalance";
2
- export { useBalance, };
1
+ import useAccount from './useAccount';
2
+ import useBalance from './useBalance';
3
+ import useNetwork from './useNetwork';
4
+ import useTransactions from './useTransactions';
5
+ import useSwitchNetwork from './useSwitchNetwork';
6
+ export { useAccount, useBalance, useNetwork, useTransactions, useSwitchNetwork, };
@@ -0,0 +1,12 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ interface UseAccountProps {
3
+ address?: string;
4
+ network?: string;
5
+ }
6
+ interface UseAccountResult {
7
+ loading: boolean;
8
+ error: Error | null;
9
+ account: Horizon.AccountResponse | null;
10
+ }
11
+ declare const useAccount: (params?: UseAccountProps) => UseAccountResult;
12
+ export default useAccount;
@@ -1,8 +1,13 @@
1
- type UseBalanceParameters = {
2
- address: string;
3
- blockNumber?: number;
4
- chainId?: number;
5
- enabled?: boolean;
1
+ import { Asset } from "@stellar/stellar-sdk";
2
+ type UseBalanceParams = {
3
+ address?: string;
4
+ network?: string;
5
+ asset?: string | Asset;
6
6
  };
7
- declare const useBalance: (_params: UseBalanceParameters) => number;
7
+ interface UseBalanceResult {
8
+ loading: boolean;
9
+ error: Error | null;
10
+ balance: string | null;
11
+ }
12
+ declare const useBalance: ({ asset, address, network }: UseBalanceParams) => UseBalanceResult;
8
13
  export default useBalance;
@@ -0,0 +1,2 @@
1
+ declare const useNetwork: () => string;
2
+ export default useNetwork;
@@ -0,0 +1,5 @@
1
+ declare const useSwitchNetwork: () => {
2
+ switchNetwork: (newNetwork: string) => void;
3
+ networks: string[];
4
+ };
5
+ export default useSwitchNetwork;
@@ -0,0 +1,18 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ interface UseTransactionsProps<T extends boolean = false> {
3
+ limit?: number;
4
+ address?: string;
5
+ network?: string;
6
+ includeOperations?: T;
7
+ }
8
+ interface TransactionRecordWithOperations extends Omit<Horizon.ServerApi.TransactionRecord, 'operations'> {
9
+ operations: Horizon.ServerApi.OperationRecord[];
10
+ }
11
+ type TransactionRecord<T extends boolean> = T extends true ? TransactionRecordWithOperations : Horizon.ServerApi.TransactionRecord;
12
+ interface UseTransactionsResult<T extends boolean> {
13
+ loading: boolean;
14
+ error: Error | null;
15
+ transactions: TransactionRecord<T>[] | null;
16
+ }
17
+ declare const useTransactions: <T extends boolean = false>(params?: UseTransactionsProps<T>) => UseTransactionsResult<T>;
18
+ export default useTransactions;
@@ -0,0 +1,2 @@
1
+ declare const formatDate: (isoString: string) => string;
2
+ export default formatDate;
@@ -1,3 +1,3 @@
1
1
  import { CornerRadius } from '../types';
2
- declare const getBorderRadius: (cornerRadius: CornerRadius) => string;
2
+ declare const getBorderRadius: (cornerRadius: CornerRadius | string) => string;
3
3
  export default getBorderRadius;
@@ -1,3 +1,3 @@
1
1
  import { WalletInterface } from '../types';
2
- declare const getWalletNetwork: (wallet: WalletInterface, networks: string[]) => Promise<string>;
2
+ declare const getWalletNetwork: (wallet: WalletInterface) => Promise<string>;
3
3
  export default getWalletNetwork;
@@ -0,0 +1,4 @@
1
+ import { ITransports } from "../../types";
2
+ import { NetworkDetails } from "../../constants/networkDetails";
3
+ declare const getNetworkRpc: (network: string, transports: ITransports) => NetworkDetails;
4
+ export default getNetworkRpc;
@@ -1,7 +1,7 @@
1
- declare const getTransactionDetails: (xdr: string) => {
2
- action: "payment" | "createAccount" | "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";
1
+ declare const getTransactionDetails: (xdr: string, network: 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
3
  operations: number;
4
4
  sender: string;
5
5
  estimatedFee: number;
6
- };
6
+ } | null;
7
7
  export default getTransactionDetails;
@@ -1,3 +1,3 @@
1
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>;
2
+ declare const signTransaction: (wallet: WalletInterface, xdr: string, address: string, network: string) => Promise<string>;
3
3
  export default signTransaction;
@@ -1,3 +1,4 @@
1
1
  import { Horizon } from '@stellar/stellar-sdk';
2
- declare const submitTransaction: (xdr: string, network: string) => Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
2
+ import { ITransports } from '../../types';
3
+ declare const submitTransaction: (xdr: string, network: string, transports: ITransports) => Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
3
4
  export default submitTransaction;
@@ -0,0 +1,2 @@
1
+ declare const toTitleFormat: (str: string) => string;
2
+ export default toTitleFormat;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bluxcc/react",
3
3
  "author": "Blux team",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "homepage": "https://blux.cc",
6
6
  "description": "Connecting to the Stellar Ecosystem and Beyond",
7
7
  "repository": {
@@ -54,6 +54,8 @@
54
54
  "eslint-plugin-react-hooks": "^5.1.0",
55
55
  "globals": "^15.14.0",
56
56
  "postcss": "^8.4.49",
57
+ "prettier": "^3.5.3",
58
+ "prettier-plugin-tailwindcss": "^0.6.11",
57
59
  "rollup": "^4.29.1",
58
60
  "rollup-plugin-peer-deps-external": "^2.2.4",
59
61
  "rollup-plugin-postcss": "^4.0.2",
package/dist/chains.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Networks } from "@stellar/stellar-sdk";
2
- export declare const chains: {
3
- mainnet: Networks;
4
- testnet: Networks;
5
- sandbox: Networks;
6
- futurenet: Networks;
7
- standalone: Networks;
8
- };
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { ButtonProps } from './index';
3
- interface IconButtonProps extends ButtonProps {
4
- icon: React.ReactNode;
5
- name: string;
6
- }
7
- export declare const ButtonWithIcon: ({ icon, name, ...props }: IconButtonProps) => React.JSX.Element;
8
- export declare const ButtonWithIconAndArrow: ({ icon, name, ...props }: IconButtonProps) => React.JSX.Element;
9
- export {};
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { Routes } from '../../types';
3
- interface ModalContentProps {
4
- showAllWallets: boolean;
5
- setShowAllWallets: (show: boolean) => void;
6
- }
7
- export declare const modalContent: Record<Routes, {
8
- title: string;
9
- Component: React.FC<ModalContentProps>;
10
- }>;
11
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface ConnectModalProps {
3
- isOpen: boolean;
4
- closeModal: () => void;
5
- }
6
- export default function ConnectModal({ isOpen, closeModal }: ConnectModalProps): React.JSX.Element;
7
- export {};
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const Connecting: () => React.JSX.Element;
3
- export default Connecting;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- type OnBoardingProps = {
3
- showAllWallets: boolean;
4
- setShowAllWallets: (value: boolean) => void;
5
- };
6
- declare const OnBoarding: ({ showAllWallets, setShowAllWallets }: OnBoardingProps) => React.JSX.Element;
7
- export default OnBoarding;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const Profile: () => React.JSX.Element;
3
- export default Profile;
@@ -1,12 +0,0 @@
1
- import { ModalState } from '../types';
2
- export interface UseConnectModalReturn {
3
- modalState: ModalState;
4
- handleGoBack: () => void;
5
- setShowAllWallets: (show: boolean) => void;
6
- closeModal: () => void;
7
- modalHeader: string;
8
- showBackButton: boolean;
9
- showCloseButton: boolean;
10
- initialHeight: number;
11
- }
12
- export declare const useConnectModal: () => UseConnectModalReturn;
@@ -1,2 +0,0 @@
1
- import { SupportedFonts } from '../types';
2
- export declare function useGoogleFonts(): SupportedFonts;
@@ -1,3 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- declare const BN: typeof BigNumber;
3
- export default BN;
@@ -1,6 +0,0 @@
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 {};
@@ -1,2 +0,0 @@
1
- import { Routes } from '../types';
2
- export declare const getInitialHeight: (route: Routes) => number;
@@ -1 +0,0 @@
1
- export declare const getNetworkByPassphrase: (passphrase: string) => string;
@@ -1 +0,0 @@
1
- export declare const getNetworkPassphrase: (network: string) => string;
@@ -1,6 +0,0 @@
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,3 +0,0 @@
1
- import React from 'react';
2
- declare const handleIcons: (walletName: string) => React.JSX.Element | null;
3
- export default handleIcons;
@@ -1,3 +0,0 @@
1
- import { WalletInterface } from "../types";
2
- declare const setWalletNetwork: (wallet: WalletInterface, networks: string[]) => Promise<string>;
3
- export default setWalletNetwork;
@@ -1,3 +0,0 @@
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>;
@@ -1,2 +0,0 @@
1
- import { Horizon } from '@stellar/stellar-sdk';
2
- export declare const submitTransaction: (xdr: string, networkPassPhrase: string) => Promise<Horizon.HorizonApi.SubmitTransactionResponse>;