@paybutton/react 2.0.3 → 2.1.0

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.
@@ -19,6 +19,8 @@ export interface PayButtonProps extends ButtonProps {
19
19
  editable?: boolean;
20
20
  onSuccess?: (txid: string, amount: BigNumber) => void;
21
21
  onTransaction?: (txid: string, amount: BigNumber) => void;
22
+ onOpen?: (expectedAmount?: number | string, address?: string) => void;
23
+ onClose?: (success?: boolean) => void;
22
24
  wsBaseUrl?: string;
23
25
  apiBaseUrl?: string;
24
26
  }
@@ -26,6 +26,16 @@ declare const _default: {
26
26
  disable: boolean;
27
27
  };
28
28
  };
29
+ onOpen: {
30
+ table: {
31
+ disable: boolean;
32
+ };
33
+ };
34
+ onClose: {
35
+ table: {
36
+ disable: boolean;
37
+ };
38
+ };
29
39
  onTransaction: {
30
40
  table: {
31
41
  disable: boolean;
@@ -3,10 +3,14 @@ import { Theme, ThemeName } from '../../themes';
3
3
  import { ButtonProps } from '../Button/Button';
4
4
  import { currency } from '../../util/api-client';
5
5
  import BigNumber from 'bignumber.js';
6
+ import { currencyObject } from '../../util/satoshis';
6
7
  export interface PaymentDialogProps extends ButtonProps {
7
8
  to: string;
8
9
  amount?: number | string;
10
+ setAmount: Function;
9
11
  currency?: currency;
12
+ currencyObj?: currencyObject;
13
+ setCurrencyObj: Function;
10
14
  theme?: ThemeName | Theme;
11
15
  successText?: string;
12
16
  randomSatoshis?: boolean | number;
@@ -18,7 +22,7 @@ export interface PaymentDialogProps extends ButtonProps {
18
22
  disableScrollLock?: boolean;
19
23
  active?: boolean;
20
24
  container?: HTMLElement;
21
- onClose?: () => void;
25
+ onClose?: (success?: boolean) => void;
22
26
  onSuccess?: (txid: string, amount: BigNumber) => void;
23
27
  onTransaction?: (txid: string, amount: BigNumber) => void;
24
28
  wsBaseUrl?: string;
@@ -6,10 +6,9 @@ import { currency, Transaction } from '../../util/api-client';
6
6
  export interface WidgetProps {
7
7
  to: string;
8
8
  amount?: number | null | string;
9
- setAmount: Function;
9
+ setAmount?: Function;
10
10
  text?: string;
11
11
  ButtonComponent?: React.ComponentType;
12
- loading: boolean;
13
12
  success: boolean;
14
13
  successText?: string;
15
14
  theme?: ThemeName | Theme;
@@ -19,7 +18,7 @@ export interface WidgetProps {
19
18
  currency?: currency;
20
19
  animation?: animation;
21
20
  currencyObject?: currencyObject | undefined;
22
- setCurrencyObject: Function;
21
+ setCurrencyObject?: Function;
23
22
  randomSatoshis?: boolean | number;
24
23
  price?: number;
25
24
  editable?: boolean;
@@ -1,13 +1,15 @@
1
1
  import React from 'react';
2
- import { cryptoCurrency, currency } from '../../util/api-client';
2
+ import { currency } from '../../util/api-client';
3
+ import { currencyObject } from '../../util/satoshis';
3
4
  import { WidgetProps } from './Widget';
4
5
  import BigNumber from 'bignumber.js';
5
- export interface WidgetContainerProps extends Omit<WidgetProps, 'loading' | 'success' | 'setNewTxs' | 'setCurrencyObject' | 'setAmount'> {
6
+ export interface WidgetContainerProps extends Omit<WidgetProps, 'success' | 'setNewTxs' | 'setCurrencyObject'> {
6
7
  active?: boolean;
7
8
  amount?: number;
8
9
  currency?: currency;
10
+ currencyObj?: currencyObject;
11
+ setCurrencyObj: Function;
9
12
  randomSatoshis?: boolean | number;
10
- displayCurrency?: cryptoCurrency;
11
13
  hideToasts?: boolean;
12
14
  onSuccess?: (txid: string, amount: BigNumber) => void;
13
15
  onTransaction?: (txid: string, amount: BigNumber) => void;
@@ -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 { cryptoCurrency } 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) => cryptoCurrency;
2
5
  declare const _default: {
3
- validateCashAddress: (to: string) => boolean;
6
+ isValidCashAddress: (address: string) => boolean;
7
+ isValidXecAddress: (address: string) => boolean;
8
+ getCurrencyTypeFromAddress: (address: string) => "BCH" | "XEC";
4
9
  };
5
10
  export default _default;
@@ -1,106 +1,69 @@
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 getAddressDetails: (address: string, rootUrl?: string) => Promise<Transaction[]>;
3
+ declare type TxBroadcast = 'NewTx' | 'OldTx';
4
+ export interface BroadcastTxData {
5
+ address: string;
6
+ txs: Transaction[];
7
+ messageType: TxBroadcast;
8
+ }
9
+ export declare const setListener: (socket: Socket, setNewTxs: Function) => void;
10
+ export declare const getAddressBalance: (address: string, rootUrl?: string) => Promise<number>;
11
+ export declare const getUTXOs: (address: string, rootUrl?: string) => Promise<UtxoDetails>;
12
+ export declare const getBchFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
13
+ export declare const getXecFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
14
+ export declare const getFiatPrice: (fiat: fiatCurrency, crypto: cryptoCurrency, rootUrl?: string) => Promise<PriceData>;
7
15
  export declare const getTransactionDetails: (txid: string, rootUrl?: string) => Promise<TransactionDetails>;
8
16
  declare const _default: {
9
- getAddressDetails: (address: string, rootUrl?: string | undefined) => Promise<AddressDetails>;
17
+ getAddressDetails: (address: string, rootUrl?: string) => Promise<Transaction[]>;
10
18
  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
- }>;
19
+ getBchFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
20
+ getXecFiatPrice: (currency: currency, rootUrl?: string) => Promise<PriceData>;
21
+ getAddressBalance: (address: string, rootUrl?: string) => Promise<number>;
15
22
  };
16
23
  export default _default;
17
- export declare type fiatCurrency = 'USD' | 'CAD' | 'EUR' | 'GBP' | 'AUD';
18
- export declare type cryptoCurrency = 'BCH' | 'SAT' | 'bits';
24
+ export declare const fiatCurrencies: readonly ["USD", "CAD", "EUR", "GBP", "AUD"];
25
+ declare type fiatCurrenciesTuple = typeof fiatCurrencies;
26
+ export declare type fiatCurrency = fiatCurrenciesTuple[number];
27
+ export declare const cryptoCurrencies: readonly ["BCH", "XEC"];
28
+ declare type cryptoCurrenciesTuple = typeof cryptoCurrencies;
29
+ export declare type cryptoCurrency = cryptoCurrenciesTuple[number];
19
30
  export declare type currency = cryptoCurrency | fiatCurrency;
20
- export interface AddressDetails {
21
- confirmedTransactionsList: [ConfirmedTransaction];
22
- unconfirmedTransactionsList: [UnconfirmedTransaction];
23
- }
24
- export interface ConfirmedTransaction {
31
+ export declare function isFiat(unknownString: string): unknownString is fiatCurrency;
32
+ export declare function isCrypto(unknownString: string): unknownString is cryptoCurrency;
33
+ export declare function isValidCurrency(unknownString: string): unknownString is cryptoCurrency;
34
+ export declare const getCashtabProviderStatus: () => boolean;
35
+ export interface Transaction {
36
+ id: string;
25
37
  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;
38
+ amount: string;
39
+ confirmed: boolean;
49
40
  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: [];
41
+ addressId: string;
42
+ createdAt: string;
43
+ updatedAt: string;
44
+ address: {
45
+ id: string;
46
+ address: string;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ networkId: number;
50
+ lastSynced: string;
59
51
  };
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: [];
52
+ prices: [{
53
+ priceId: number;
54
+ transactionId: string;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ price: {
58
+ id: number;
59
+ value: string;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ timestamp: number;
63
+ networkId: 1;
64
+ quoteId: 1;
97
65
  };
98
- };
99
- addedTime: number;
100
- addedHeight: number;
101
- fee: number;
102
- feePerKb: number;
103
- startingPriority: number;
66
+ }];
104
67
  }
105
68
  export interface UtxoDetails {
106
69
  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,2 +1,4 @@
1
- export declare const randomizeSatoshis: (amount: number) => number;
1
+ import { cryptoCurrency } from './api-client';
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;
2
4
  export default randomizeSatoshis;
@@ -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
- export declare const getCurrencyObject: (amount: number, currencyType: currency) => currencyObject;
7
+ export declare const getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: boolean | number) => currencyObject;
14
8
  declare const _default: {
15
- satoshisToBch: (satoshis: number) => number;
16
- bchToSatoshis: (bch: number) => number;
17
- getCurrencyObject: (amount: number, currencyType: currency) => currencyObject;
9
+ getCurrencyObject: (amount: number, currencyType: currency, randomSatoshis: number | boolean) => 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.3",
3
+ "version": "2.1.0",
4
4
  "description": "The easiest way to accept eCash online",
5
5
  "author": "poldridge",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "node": ">=10"
16
16
  },
17
17
  "scripts": {
18
- "build": "microbundle --jsx React.createElement --format modern,cjs",
18
+ "build": "microbundle --jsx React.createElement --format modern,cjs && cp -rf dist/react/src/* dist/",
19
19
  "lint": "eslint 'src/**/*.{ts,tsx}' --fix",
20
20
  "prettier": "prettier --write 'src/**/*.ts'",
21
21
  "dev": "concurrently npm:watch npm:storybook",
@@ -1,3 +0,0 @@
1
- import { AddressDetails } from '../util/api-client';
2
- export declare const useAddressDetails: (address: string, active?: boolean) => AddressDetails | undefined;
3
- export default useAddressDetails;
@@ -1,3 +0,0 @@
1
- import { Transaction } from '../util/api-client';
2
- export declare const useAddressDetails: (address: string, active?: boolean) => Transaction[] | undefined;
3
- export default useAddressDetails;