@paybutton/react 2.0.2 → 2.0.4

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.
@@ -11,7 +11,7 @@ export interface PayButtonProps extends ButtonProps {
11
11
  text?: string;
12
12
  hoverText?: string;
13
13
  successText?: string;
14
- randomSatoshis?: boolean;
14
+ randomSatoshis?: boolean | number;
15
15
  hideToasts?: boolean;
16
16
  disabled?: boolean;
17
17
  goalAmount?: number | string;
@@ -9,7 +9,7 @@ export interface PaymentDialogProps extends ButtonProps {
9
9
  currency?: currency;
10
10
  theme?: ThemeName | Theme;
11
11
  successText?: string;
12
- randomSatoshis?: boolean;
12
+ randomSatoshis?: boolean | number;
13
13
  hideToasts?: boolean;
14
14
  goalAmount?: number | string;
15
15
  disableEnforceFocus?: boolean;
@@ -20,7 +20,7 @@ export interface WidgetProps {
20
20
  animation?: animation;
21
21
  currencyObject?: currencyObject | undefined;
22
22
  setCurrencyObject: Function;
23
- randomSatoshis?: boolean;
23
+ randomSatoshis?: boolean | number;
24
24
  price?: number;
25
25
  editable?: boolean;
26
26
  setNewTxs: Function;
@@ -6,7 +6,7 @@ export interface WidgetContainerProps extends Omit<WidgetProps, 'loading' | 'suc
6
6
  active?: boolean;
7
7
  amount?: number;
8
8
  currency?: currency;
9
- randomSatoshis?: boolean;
9
+ randomSatoshis?: boolean | number;
10
10
  displayCurrency?: cryptoCurrency;
11
11
  hideToasts?: boolean;
12
12
  onSuccess?: (txid: string, amount: BigNumber) => void;
@@ -1,3 +1,4 @@
1
1
  import { cryptoCurrency } from './api-client';
2
- export declare const randomizeSatoshis: (amount: number, addressType: cryptoCurrency) => number;
2
+ export declare const getNSatoshis: (amount: number, randomSatoshis: boolean | number, satsPrecision: number) => number;
3
+ export declare const randomizeSatoshis: (amount: number, addressType: cryptoCurrency, randomSatoshis: boolean | number) => number;
3
4
  export default randomizeSatoshis;
@@ -4,8 +4,8 @@ export declare type currencyObject = {
4
4
  string: string;
5
5
  currency: string;
6
6
  };
7
- export declare const getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: boolean) => currencyObject;
7
+ export declare const getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: boolean | number) => currencyObject;
8
8
  declare const _default: {
9
- getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: boolean) => currencyObject;
9
+ getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: number | boolean) => currencyObject;
10
10
  };
11
11
  export default _default;
@@ -5,8 +5,9 @@ export * from './Theme';
5
5
  export default themes;
6
6
  export declare enum ThemeName {
7
7
  ORANGE = "orange",
8
- PAYBUTTON = "paybutton"
8
+ PAYBUTTON = "paybutton",
9
+ XEC = "xec"
9
10
  }
10
11
  export declare const getTheme: (name?: ThemeName) => Theme;
11
12
  export declare const ThemeProvider: React.Provider<Theme | undefined>;
12
- export declare const useTheme: (defaultTheme?: ThemeName | Theme | undefined) => Theme;
13
+ export declare const useTheme: (defaultTheme?: ThemeName | Theme | undefined, isXec?: boolean | undefined) => Theme;
@@ -0,0 +1,3 @@
1
+ import Theme from '../Theme';
2
+ declare const theme: Theme;
3
+ export default theme;
@@ -1,5 +1,10 @@
1
- export declare const validateCashAddress: (to: string) => boolean;
1
+ import { currency } from '../util/api-client';
2
+ export declare const isValidCashAddress: (address: string) => boolean;
3
+ export declare const isValidXecAddress: (address: string) => boolean;
4
+ export declare const getCurrencyTypeFromAddress: (address: string) => currency;
2
5
  declare const _default: {
3
- validateCashAddress: (to: string) => boolean;
6
+ isValidCashAddress: (address: string) => boolean;
7
+ isValidXecAddress: (address: string) => boolean;
8
+ getCurrencyTypeFromAddress: (address: string) => currency;
4
9
  };
5
10
  export default _default;
@@ -1,106 +1,71 @@
1
- export declare const getAddressDetails: (address: string, rootUrl?: string | undefined) => Promise<AddressDetails>;
2
- export declare const getSatoshiBalance: (address: string, rootUrl?: string | undefined) => Promise<{
3
- satoshis: number;
4
- }>;
5
- export declare const getUTXOs: (address: string, rootUrl?: string | undefined) => Promise<UtxoDetails>;
6
- export declare const getFiatPrice: (currency: currency) => Promise<PriceData>;
1
+ import { Socket } from 'socket.io-client';
2
+ export declare const DEFAULT_WS_URL = "https://socket.paybutton.org";
3
+ export declare const DEFAULT_API_URL = "https://api.paybutton.org";
4
+ export declare const getAddressDetails: (address: string, rootUrl?: string) => Promise<Transaction[]>;
5
+ declare type TxBroadcast = 'NewTx' | 'OldTx';
6
+ export interface BroadcastTxData {
7
+ address: string;
8
+ txs: Transaction[];
9
+ messageType: TxBroadcast;
10
+ }
11
+ export declare const setListener: (socket: Socket, setNewTxs: Function) => void;
12
+ export declare const getAddressBalance: (address: string, rootUrl?: string) => Promise<number>;
13
+ export declare const getUTXOs: (address: string, rootUrl?: string) => Promise<UtxoDetails>;
14
+ export declare const getBchFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
15
+ export declare const getXecFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
16
+ export declare const getFiatPrice: (fiat: fiatCurrency, crypto: cryptoCurrency, rootUrl?: string) => Promise<PriceData>;
7
17
  export declare const getTransactionDetails: (txid: string, rootUrl?: string) => Promise<TransactionDetails>;
8
18
  declare const _default: {
9
- getAddressDetails: (address: string, rootUrl?: string | undefined) => Promise<AddressDetails>;
19
+ getAddressDetails: (address: string, rootUrl?: string) => Promise<Transaction[]>;
10
20
  getTransactionDetails: (txid: string, rootUrl?: string) => Promise<TransactionDetails>;
11
- getFiatPrice: (currency: currency) => Promise<PriceData>;
12
- getSatoshiBalance: (address: string, rootUrl?: string | undefined) => Promise<{
13
- satoshis: number;
14
- }>;
21
+ getBchFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
22
+ getXecFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
23
+ getAddressBalance: (address: string, rootUrl?: string) => Promise<number>;
15
24
  };
16
25
  export default _default;
17
- export declare type fiatCurrency = 'USD' | 'CAD' | 'EUR' | 'GBP' | 'AUD';
18
- export declare type cryptoCurrency = 'BCH' | 'SAT' | 'bits';
26
+ export declare const fiatCurrencies: readonly ["USD", "CAD", "EUR", "GBP", "AUD"];
27
+ declare type fiatCurrenciesTuple = typeof fiatCurrencies;
28
+ export declare type fiatCurrency = fiatCurrenciesTuple[number];
29
+ export declare const cryptoCurrencies: readonly ["BCH", "XEC"];
30
+ declare type cryptoCurrenciesTuple = typeof cryptoCurrencies;
31
+ export declare type cryptoCurrency = cryptoCurrenciesTuple[number];
19
32
  export declare type currency = cryptoCurrency | fiatCurrency;
20
- export interface AddressDetails {
21
- confirmedTransactionsList: [ConfirmedTransaction];
22
- unconfirmedTransactionsList: [UnconfirmedTransaction];
23
- }
24
- export interface ConfirmedTransaction {
33
+ export declare function isFiat(unknownString: string): unknownString is fiatCurrency;
34
+ export declare function isCrypto(unknownString: string): unknownString is cryptoCurrency;
35
+ export declare function isValidCurrency(unknownString: string): unknownString is cryptoCurrency;
36
+ export declare const getCashtabProviderStatus: () => boolean;
37
+ export interface Transaction {
38
+ id: string;
25
39
  hash: string;
26
- version: number;
27
- inputsList: {
28
- index: number;
29
- outpoint: {
30
- hash: string;
31
- index: number;
32
- };
33
- signatureScript: string;
34
- sequence: number;
35
- value: number;
36
- previousScript: string;
37
- address: string;
38
- }[];
39
- outputsList: {
40
- index: number;
41
- value: number;
42
- pubkeyScript: string;
43
- address: string;
44
- scriptClass: string;
45
- disassembledScript: string;
46
- }[];
47
- lockTime: number;
48
- size: number;
40
+ amount: string;
41
+ confirmed: boolean;
49
42
  timestamp: number;
50
- confirmations: number;
51
- blockHeight: number;
52
- blockHash: string;
53
- slpTransactionInfo: {
54
- slpAction: number;
55
- validityJudgement: number;
56
- parseError: string;
57
- tokenId: string;
58
- burnFlagsList: [];
43
+ addressId: string;
44
+ createdAt: string;
45
+ updatedAt: string;
46
+ address: {
47
+ id: string;
48
+ address: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ networkId: number;
52
+ lastSynced: string;
59
53
  };
60
- }
61
- export interface UnconfirmedTransaction {
62
- transaction: {
63
- hash: string;
64
- version: number;
65
- inputsList: {
66
- index: number;
67
- outpoint: {
68
- hash: string;
69
- index: number;
70
- };
71
- signatureScript: string;
72
- sequence: number;
73
- value: number;
74
- previousScript: string;
75
- address: string;
76
- }[];
77
- outputsList: {
78
- index: number;
79
- value: number;
80
- pubkeyScript: string;
81
- address: string;
82
- scriptClass: string;
83
- disassembledScript: string;
84
- }[];
85
- lockTime: number;
86
- size: number;
87
- timestamp: number;
88
- confirmations: number;
89
- blockHeight: number;
90
- blockHash: string;
91
- slpTransactionInfo: {
92
- slpAction: number;
93
- validityJudgement: number;
94
- parseError: string;
95
- tokenId: string;
96
- burnFlagsList: [];
54
+ prices: [{
55
+ priceId: number;
56
+ transactionId: string;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ price: {
60
+ id: number;
61
+ value: string;
62
+ createdAt: string;
63
+ updatedAt: string;
64
+ timestamp: number;
65
+ networkId: 1;
66
+ quoteId: 1;
97
67
  };
98
- };
99
- addedTime: number;
100
- addedHeight: number;
101
- fee: number;
102
- feePerKb: number;
103
- startingPriority: number;
68
+ }];
104
69
  }
105
70
  export interface UtxoDetails {
106
71
  outputsList: [Output];
@@ -1,14 +1,19 @@
1
1
  import { currency } from './api-client';
2
+ export declare const DECIMALS: {
3
+ BCH: number;
4
+ XEC: number;
5
+ FIAT: number;
6
+ };
2
7
  export declare const amount: (x?: number | null | undefined) => string | undefined;
3
8
  export declare const formatPrice: (price: number, currencyType: currency, precision?: number) => string;
4
9
  export declare const formatComma: (number: number) => string;
5
10
  export declare const formatBCH: (bch: string) => string;
6
- export declare const formatBits: (bits: string | number) => string;
11
+ export declare const formatXEC: (xec: string) => string;
7
12
  declare const _default: {
8
13
  amount: (x?: number | null | undefined) => string | undefined;
9
14
  formatPrice: (price: number, currencyType: currency, precision?: number) => string;
10
15
  formatComma: (number: number) => string;
11
16
  formatBCH: (bch: string) => string;
12
- formatBits: (bits: string | number) => string;
17
+ formatXEC: (xec: string) => string;
13
18
  };
14
19
  export default _default;
@@ -1,19 +1,11 @@
1
- import { fiatCurrency } from './api-client';
2
- export declare type cryptoCurrency = 'BCH' | 'SAT' | 'bits';
3
- export declare type currency = cryptoCurrency | fiatCurrency;
4
- export declare const satoshisToBch: (satoshis: number) => number;
5
- export declare const bchToSatoshis: (bch: number) => number;
1
+ import { currency } from './api-client';
6
2
  export declare type currencyObject = {
7
3
  float: number;
8
4
  string: string;
9
5
  currency: string;
10
- BCHstring?: string | undefined;
11
- satoshis?: number | undefined;
12
6
  };
13
7
  export declare const getCurrencyObject: (amount: number, currencyType: currency) => currencyObject;
14
8
  declare const _default: {
15
- satoshisToBch: (satoshis: number) => number;
16
- bchToSatoshis: (bch: number) => number;
17
9
  getCurrencyObject: (amount: number, currencyType: currency) => currencyObject;
18
10
  };
19
11
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybutton/react",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "The easiest way to accept eCash online",
5
5
  "author": "poldridge",
6
6
  "license": "MIT",