@paybutton/react 4.2.0 → 5.0.1

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.
@@ -9,7 +9,7 @@ declare const _default: {
9
9
  color: string;
10
10
  };
11
11
  };
12
- decorators: ((Story: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, import("@storybook/react").Args>) => React.ReactNode)[];
12
+ decorators: ((Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("@storybook/types").Args>) => React.ReactNode)[];
13
13
  argTypes: {
14
14
  onClick: {
15
15
  table: {
@@ -22,4 +22,4 @@ declare const _default: {
22
22
  };
23
23
  };
24
24
  export default _default;
25
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, BarChartProps>;
25
+ export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, BarChartProps>;
@@ -1,23 +1,7 @@
1
- import React from 'react';
2
- import { ButtonProps } from './Button';
3
- declare const _default: {
4
- title: string;
5
- component: {
6
- (props: ButtonProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
7
- defaultProps: ButtonProps;
8
- };
9
- decorators: ((Story: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, import("@storybook/react").Args>) => React.ReactNode)[];
10
- argTypes: {
11
- onClick: {
12
- table: {
13
- disable: boolean;
14
- };
15
- };
16
- };
17
- parameters: {
18
- jest: string[];
19
- };
20
- };
21
- export default _default;
22
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ButtonProps>;
23
- export declare const OrangeTheme: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ButtonProps>;
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import Button from './Button';
3
+ declare const meta: Meta<typeof Button>;
4
+ export default meta;
5
+ declare type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const OrangeTheme: Story;
@@ -6,7 +6,7 @@ declare const _default: {
6
6
  (props: PayButtonProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
7
7
  defaultProps: PayButtonProps;
8
8
  };
9
- decorators: ((Story: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, import("@storybook/react").Args>) => JSX.Element)[];
9
+ decorators: ((Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("@storybook/types").Args>) => JSX.Element)[];
10
10
  argTypes: {
11
11
  onClick: {
12
12
  table: {
@@ -42,8 +42,8 @@ declare const _default: {
42
42
  };
43
43
  };
44
44
  export default _default;
45
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PayButtonProps>;
46
- export declare const OrangeTheme: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PayButtonProps>;
47
- export declare const UsdAmount: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PayButtonProps>;
48
- export declare const withGoal: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PayButtonProps>;
49
- export declare const withUSDGoalCurrency: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PayButtonProps>;
45
+ export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PayButtonProps>;
46
+ export declare const OrangeTheme: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PayButtonProps>;
47
+ export declare const UsdAmount: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PayButtonProps>;
48
+ export declare const withGoal: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PayButtonProps>;
49
+ export declare const withUSDGoalCurrency: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PayButtonProps>;
@@ -16,7 +16,7 @@ declare const _default: {
16
16
  autoClose: boolean;
17
17
  };
18
18
  };
19
- decorators: ((Story: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, import("@storybook/react").Args>) => JSX.Element)[];
19
+ decorators: ((Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("@storybook/types").Args>) => JSX.Element)[];
20
20
  argTypes: {
21
21
  onClick: {
22
22
  table: {
@@ -42,8 +42,8 @@ declare const _default: {
42
42
  };
43
43
  };
44
44
  export default _default;
45
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PaymentDialogProps>;
46
- export declare const OrangeTheme: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PaymentDialogProps>;
47
- export declare const UsdAmount: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PaymentDialogProps>;
48
- export declare const withGoal: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PaymentDialogProps>;
49
- export declare const withUSDGoalCurrency: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, PaymentDialogProps>;
45
+ export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PaymentDialogProps>;
46
+ export declare const OrangeTheme: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PaymentDialogProps>;
47
+ export declare const UsdAmount: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PaymentDialogProps>;
48
+ export declare const withGoal: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PaymentDialogProps>;
49
+ export declare const withUSDGoalCurrency: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, PaymentDialogProps>;
@@ -3,7 +3,7 @@ import { WidgetProps } from './Widget';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  component: React.FunctionComponent<WidgetProps>;
6
- decorators: ((Story: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, import("@storybook/react").Args>) => React.ReactNode)[];
6
+ decorators: ((Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("@storybook/types").Args>) => React.ReactNode)[];
7
7
  argTypes: {
8
8
  success: {
9
9
  control: string;
@@ -26,9 +26,9 @@ declare const _default: {
26
26
  };
27
27
  };
28
28
  export default _default;
29
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
30
- export declare const Success: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
31
- export declare const Loading: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
32
- export declare const OrangeTheme: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
33
- export declare const CustomTheme: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
34
- export declare const WithGoal: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, WidgetProps>;
29
+ export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
30
+ export declare const Success: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
31
+ export declare const Loading: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
32
+ export declare const OrangeTheme: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
33
+ export declare const CustomTheme: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
34
+ export declare const WithGoal: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, WidgetProps>;
@@ -14,4 +14,3 @@ declare const _default: {
14
14
  getAddressBalance: (address: string, rootUrl?: string) => Promise<number | undefined>;
15
15
  };
16
16
  export default _default;
17
- export declare const getCashtabProviderStatus: () => boolean;
@@ -0,0 +1,29 @@
1
+ import { CashtabExtensionUnavailableError, CashtabAddressDeniedError, CashtabTimeoutError } from 'cashtab-connect';
2
+ /**
3
+ * Check if the Cashtab extension is available (with caching)
4
+ * This function caches the result to avoid multiple extension checks per page load
5
+ * @returns Promise<boolean> - true if extension is available, false otherwise
6
+ */
7
+ export declare const getCashtabProviderStatus: () => Promise<boolean>;
8
+ /**
9
+ * Clear the cached extension status (useful for testing or if extension state changes)
10
+ */
11
+ export declare const clearCashtabStatusCache: () => void;
12
+ export declare const initializeCashtabStatus: () => Promise<boolean>;
13
+ export declare const waitForCashtabExtension: (timeout?: number | undefined) => Promise<void>;
14
+ /**
15
+ * Request the user's eCash address from their Cashtab wallet
16
+ * @returns Promise<string> - The user's address
17
+ * @throws {CashtabExtensionUnavailableError} When the Cashtab extension is not available
18
+ * @throws {CashtabAddressDeniedError} When the user denies the address request
19
+ * @throws {CashtabTimeoutError} When the request times out
20
+ */
21
+ export declare const requestCashtabAddress: () => Promise<string>;
22
+ export declare const sendXecWithCashtab: (address: string, amount: string | number) => Promise<any>;
23
+ /**
24
+ * Open Cashtab with a BIP21 payment URL
25
+ * @param bip21Url - The BIP21 formatted payment URL
26
+ * @param fallbackUrl - Optional fallback URL if extension is not available
27
+ */
28
+ export declare const openCashtabPayment: (bip21Url: string, fallbackUrl?: string | undefined) => Promise<void>;
29
+ export { CashtabExtensionUnavailableError, CashtabAddressDeniedError, CashtabTimeoutError };
@@ -0,0 +1,17 @@
1
+ import { ChronikClient, WsEndpoint } from 'chronik-client-cashtokens';
2
+ import { AddressType } from 'ecashaddrjs/dist/types';
3
+ export interface OpReturnData {
4
+ rawMessage: string;
5
+ message: string;
6
+ paymentId: string;
7
+ }
8
+ export declare function getNullDataScriptData(outputScript: string): OpReturnData | null;
9
+ export declare function toHash160(address: string): {
10
+ type: AddressType;
11
+ hash160: string;
12
+ };
13
+ export declare function satoshisToUnit(satoshis: bigint, networkFormat: string): Promise<string>;
14
+ export declare const fromHash160: (networkSlug: string, type: AddressType, hash160: string) => string;
15
+ export declare function outputScriptToAddress(networkSlug: string, outputScript: string | undefined): string | undefined;
16
+ export declare const parseWebsocketMessage: (wsMsg: any, setNewTx: Function, chronik: ChronikClient, address: string) => Promise<void>;
17
+ export declare const initializeChronikWebsocket: (address: string, setNewTx: Function) => Promise<WsEndpoint>;
@@ -1,5 +1,6 @@
1
1
  export * from './address';
2
2
  export * from './api-client';
3
+ export * from './cashtab';
3
4
  export * from './constants';
4
5
  export * from './format';
5
6
  export * from './opReturn';
@@ -13,6 +13,8 @@ export interface EncodeOpReturnParams {
13
13
  paymentId?: string;
14
14
  }
15
15
  export declare function encodeOpReturnProps({ opReturn, disablePaymentId, paymentId }: EncodeOpReturnParams): string;
16
+ export declare function parseStringToArray(str: string): string | string[];
17
+ export declare function parseOpReturnData(opReturnData: string): any;
16
18
  export declare const exportedForTesting: {
17
19
  prependPaymentIdWithPushdata: typeof prependPaymentIdWithPushdata;
18
20
  generatePaymentId: typeof generatePaymentId;
@@ -1,5 +1,5 @@
1
1
  import { Socket } from 'socket.io-client';
2
- import { CheckSuccessInfo } from './types';
2
+ import { CheckSuccessInfo, Transaction } from './types';
3
3
  interface AltpaymentListenerParams {
4
4
  addressType: string;
5
5
  altpaymentSocket: Socket;
@@ -35,4 +35,6 @@ interface SetupTxsSocketParams {
35
35
  checkSuccessInfo?: CheckSuccessInfo;
36
36
  }
37
37
  export declare const setupTxsSocket: (params: SetupTxsSocketParams) => Promise<void>;
38
+ export declare const setupChronikWebSocket: (params: SetupTxsSocketParams) => Promise<void>;
39
+ export declare const onMessage: (transactions: Transaction[], setNewTxs: Function, setDialogOpen?: Function | undefined, checkSuccessInfo?: CheckSuccessInfo | undefined) => void;
38
40
  export {};
@@ -15,6 +15,7 @@ export interface Transaction {
15
15
  address: string;
16
16
  rawMessage?: string;
17
17
  inputAddresses?: string[];
18
+ opReturn?: string;
18
19
  }
19
20
  export interface UtxoDetails {
20
21
  outputsList: [Output];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybutton/react",
3
- "version": "4.2.0",
3
+ "version": "5.0.1",
4
4
  "description": "The easiest way to accept eCash online",
5
5
  "author": "Blockchain Ventures Corp.",
6
6
  "license": "MIT",
@@ -22,39 +22,42 @@
22
22
  "lint": "eslint 'lib/**/*.{ts,tsx}' --fix",
23
23
  "prettier": "prettier --write 'lib/**/*.ts'",
24
24
  "dev": "concurrently yarn:watch yarn:storybook",
25
- "storybook": "start-storybook -p 6006",
25
+ "storybook": "storybook dev -p 6006",
26
26
  "watch": "microbundle watch --jsx React.createElement --no-compress --format modern,cjs",
27
27
  "test": "jest",
28
28
  "test:coverage": "jest --coverage"
29
29
  },
30
30
  "peerDependencies": {
31
- "react": "17.0.0",
32
- "react-dom": "17.0.0"
31
+ "react": "^17.0.0 || ^18.0.0",
32
+ "react-dom": "^17.0.0 || ^18.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/core": "7.18.9",
36
36
  "@popperjs/core": "2.11.5",
37
- "@storybook/addon-a11y": "6.5.9",
38
- "@storybook/addon-actions": "6.5.9",
39
- "@storybook/addon-essentials": "6.5.9",
40
- "@storybook/addon-links": "6.5.9",
41
- "@storybook/node-logger": "6.5.9",
42
- "@storybook/preset-create-react-app": "8.6.12",
43
- "@storybook/react": "6.5.9",
37
+ "@storybook/addon-a11y": "^7.6.17",
38
+ "@storybook/addon-actions": "^7.6.17",
39
+ "@storybook/addon-essentials": "^7.6.17",
40
+ "@storybook/addon-links": "^7.6.17",
41
+ "@storybook/cli": "^7.6.17",
42
+ "@storybook/react": "^7.6.17",
43
+ "@storybook/react-vite": "^7.6.17",
44
44
  "@types/currency-formatter": "1.5.1",
45
+ "@types/decimal.js": "^7.4.3",
45
46
  "@types/lodash": "4.14.182",
47
+ "@types/minimatch": "^6.0.0",
46
48
  "@types/node": "17.0.41",
47
49
  "@types/qrcode.react": "1.0.2",
48
50
  "@types/react": "17.0.0",
49
51
  "@types/react-dom": "17.0.0",
50
- "@typescript-eslint/eslint-plugin": "2.34.0",
51
- "@typescript-eslint/parser": "2.34.0",
52
+ "@typescript-eslint/eslint-plugin": "8.39.1",
53
+ "@typescript-eslint/parser": "8.39.1",
54
+ "@vitejs/plugin-react": "^4.6.0",
52
55
  "babel-eslint": "10.1.0",
53
56
  "babel-loader": "8.2.5",
54
57
  "concurrently": "5.3.0",
55
58
  "cross-env": "7.0.3",
56
59
  "currency-formatter": "1.5.9",
57
- "eslint": "6.8.0",
60
+ "eslint": "9.33.0",
58
61
  "eslint-config-prettier": "6.15.0",
59
62
  "eslint-config-standard": "14.1.1",
60
63
  "eslint-config-standard-react": "9.2.0",
@@ -70,9 +73,13 @@
70
73
  "lint-staged": "10.5.4",
71
74
  "microbundle": "0.12.4",
72
75
  "prettier": "2.7.1",
76
+ "react": "^17.0.0",
77
+ "react-dom": "^17.0.0",
73
78
  "react-is": "16.13.1",
74
79
  "react-scripts": "5.0.1",
80
+ "storybook": "^7.6.17",
75
81
  "typescript": "^4.8.2",
82
+ "vite": "^4.4.5",
76
83
  "yarn-run-all": "^3.1.1"
77
84
  },
78
85
  "dependencies": {
@@ -83,8 +90,12 @@
83
90
  "@types/jest": "^29.5.11",
84
91
  "axios": "1.6.5",
85
92
  "bignumber.js": "9.0.2",
93
+ "cashtab-connect": "^1.1.0",
94
+ "chronik-client-cashtokens": "^3.1.1-rc0",
86
95
  "copy-to-clipboard": "3.3.3",
87
96
  "crypto-js": "^4.2.0",
97
+ "decimal.js": "^10.6.0",
98
+ "ecashaddrjs": "^2.0.0",
88
99
  "jest": "^29.7.0",
89
100
  "lodash": "4.17.21",
90
101
  "notistack": "1.0.10",
@@ -102,6 +113,7 @@
102
113
  },
103
114
  "resolutions": {
104
115
  "@types/react": "17.0.0",
105
- "@types/react-dom": "17.0.0"
116
+ "@types/react-dom": "17.0.0",
117
+ "chronik-client-cashtokens/ecashaddrjs": "^2.0.0"
106
118
  }
107
119
  }