zigap-utils 0.0.508 → 0.0.802

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 (38) hide show
  1. package/README.md +130 -9
  2. package/dist/App.d.ts +2 -0
  3. package/dist/components/AddressProvideQR/AddressProvideQR.d.ts +4 -0
  4. package/dist/components/AddressProvideQR/AddressProvideQR.types.d.ts +18 -0
  5. package/dist/components/AddressProvideQR/index.d.ts +2 -0
  6. package/dist/components/AirdropQR/AirdropQR.d.ts +4 -0
  7. package/dist/components/AirdropQR/AirdropQR.types.d.ts +17 -0
  8. package/dist/components/AirdropQR/index.d.ts +2 -0
  9. package/dist/components/LoginQR/LoginQR.d.ts +4 -0
  10. package/dist/components/LoginQR/LoginQR.types.d.ts +57 -0
  11. package/dist/components/LoginQR/index.d.ts +2 -0
  12. package/dist/components/PaymentQR/PaymentQR.d.ts +4 -0
  13. package/dist/components/PaymentQR/PaymentQR.types.d.ts +20 -0
  14. package/dist/components/PaymentQR/index.d.ts +2 -0
  15. package/dist/components/index.d.ts +4 -0
  16. package/dist/hooks/index.d.ts +1 -0
  17. package/dist/hooks/useZigap.d.ts +15 -0
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.es.js +7056 -0
  20. package/dist/main.d.ts +1 -0
  21. package/dist/utils/addressProvide.d.ts +9 -0
  22. package/dist/utils/airdrop.d.ts +9 -0
  23. package/dist/utils/cryptoUtils.d.ts +19 -0
  24. package/dist/utils/login.d.ts +15 -0
  25. package/dist/utils/payment.d.ts +14 -0
  26. package/dist/utils/socketInstance.d.ts +9 -0
  27. package/dist/utils/types.d.ts +28 -0
  28. package/dist/validation/hashing.d.ts +2 -0
  29. package/dist/validation/token.d.ts +5 -0
  30. package/dist/xphere/enc.d.ts +12 -0
  31. package/dist/xphere/index.d.ts +13 -0
  32. package/dist/xphere/sign.d.ts +18 -0
  33. package/dist/xphere/util.d.ts +10 -0
  34. package/dist/xphere/validation.d.ts +10 -0
  35. package/dist/zigap/index.d.ts +7 -0
  36. package/dist/zigap/qr.d.ts +10 -0
  37. package/dist/zigap/types.d.ts +4 -0
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -2,24 +2,39 @@
2
2
 
3
3
  It is a library that collects utils that help communicate between dapp and zigap.<br /> You can find out more at https://seoul-labs.gitbook.io/zigap-utils
4
4
 
5
+ <br />
6
+ <br />
7
+
5
8
  ## Installation
6
9
 
7
10
  ```
8
11
  npm i zigap-utils
9
12
  ```
10
13
 
14
+ <br />
15
+ <br />
16
+
11
17
  ## Usage
12
18
 
19
+ > \_ INDEX
20
+ >
21
+ > 1. <b>Login</b>
22
+ > 2. <b>Payment QR (Send)</b> > <br/>
23
+ > >
24
+
25
+ ### 1. Login
26
+
13
27
  ```ts
14
28
  import { LoginQR } from 'zigap-utils';
15
29
 
16
30
  const App = () => {
31
+
17
32
  ...
18
33
 
19
34
  return (
20
35
  <div>
21
36
  <LoginQR
22
- dapp='yourDappName'
37
+ dapp='your Dapp Name'
23
38
  url='http://sample.yours.com'
24
39
  availableNetworks={['xphere']}
25
40
  isShowLogo={false}
@@ -42,8 +57,55 @@ const App = () => {
42
57
 
43
58
  <br />
44
59
 
60
+ ### 2. Payment QR
61
+
62
+ ```ts
63
+ import { PaymentQR } from 'zigap-utils';
64
+
65
+ const App = () => {
66
+ const [result1, setResult1] = useState<undefined | string>(undefined);
67
+
68
+ ...
69
+
70
+ return (
71
+ <div>
72
+ <PaymentQR
73
+ network={'network name'}
74
+ dapp='your dapp name'
75
+ address='address'
76
+ amount='100'
77
+ validSeconds={10000}
78
+ onReceive={({ status }) => {
79
+ if (status === 'SUCCESS') {
80
+ setResult1('succeed');
81
+ } else if (status === 'REQUEST' || status === 'ACCOUNT') {
82
+ setResult1(`processing - ${status}`);
83
+ } else {
84
+ setResult1('failed');
85
+ }
86
+ }}
87
+ size={200}
88
+ processingMark={{
89
+ type: 'NONE',
90
+ }}
91
+ />
92
+
93
+ <div>
94
+ {result1 === undefined ? <span>before start</span> : <span>{result1}</span>}
95
+ </div>
96
+ </div>
97
+ )
98
+ }
99
+ ```
100
+
101
+ <br />
102
+
45
103
  ---
46
104
 
105
+ ---
106
+
107
+ <br />
108
+
47
109
  ### `LoginQR` props
48
110
 
49
111
  | prop | type | description |
@@ -62,14 +124,19 @@ const App = () => {
62
124
 
63
125
  ### `AddressProvideQR` props
64
126
 
65
- | prop type | type | description |
66
- | ------------------- | ------------- | ----------------------------------------------- |
67
- | `dapp` | string | Name of the dapp to use |
68
- | `url` | string | The url of dapp to connect |
69
- | `availableNetworks` | string[] | List of connectable networks in dapp |
70
- | `validSeconds` | number | QR code valid time(seconds) |
71
- | `onReceive` | (res) => void | Function called after login request |
72
- | `icon` | string | Your dapp icon url to be displayed on zigap app |
127
+ | prop type | required | type | default value | description |
128
+ | ------------------------ | -------- | --------------- | ------------- | --------------------------------------- |
129
+ | `dapp` | true | `string` | | Name of the dapp to use |
130
+ | `url` | true | `string` | | The url of dapp to connect |
131
+ | `availavailableNetworks` | true | `string[]` | | List of connectable networks in dapp |
132
+ | `validTime` | true | `number` | | QR code valid time(seconds) |
133
+ | `onReceive` | true | (value) => void | | Function called after login request |
134
+ | `size` | false | `number` | 128 | canvas width |
135
+ | `bgColor` | false | `string` | #fff | background color |
136
+ | `fgColor` | false | `string` | #000 | foreground color |
137
+ | `style` | false | `CSSProperties` | custom | css style |
138
+ | `isShowLogo` | false | `boolean` | false | Zigap logo in the middle of the QR code |
139
+ | `logoSize` | false | `number` | 30 | logo width & height |
73
140
 
74
141
  <br>
75
142
 
@@ -86,6 +153,60 @@ const App = () => {
86
153
 
87
154
  <br>
88
155
 
156
+ ### `PaymentQR` props
157
+
158
+ | Prop | Required | Type | Description |
159
+ | --- | --- | --- | --- |
160
+ | `network` | true | `string` | The name of the network to use (e.g., "xphere"). |
161
+ | `dapp` | true | `string` | The name of the DApp initiating the payment request. |
162
+ | `address` | true | `string` | The recipient's address for the payment. |
163
+ | `amount` | true | `string` | The amount to be paid. |
164
+ | `description` | false | `string` | A brief description of the payment. |
165
+ | `info` | false | `object` | Additional information related to the payment. |
166
+ | `validSeconds` | true | `number` | The duration (in seconds) for which the QR code is valid. |
167
+ | `isShowLogo` | false | `boolean` | Whether to display your DApp’s logo in the QR code. |
168
+ | `logoSize` | false | `number` | The size of the logo displayed in the QR code (in pixels). |
169
+ | `size` | true | `number` | The size of the generated QR code (in pixels). |
170
+ | `onReceive` | true | `(res : { status: string }) => void` | Callback function that handles payment status updates. |
171
+ | `processingMark` | false | `type: DEFAULT or CUSTOM or NONE` | Configures the appearance of the QR code while processing. |
172
+
173
+ #### Payment Statuses
174
+
175
+ The `onReceive` callback provides the following statuses:
176
+
177
+ - `SUCCESS` : Payment was successful.
178
+ - `REQUEST` : Payment has been requested and is in progress.
179
+ - `ACCOUNT` : Account selection or preparation is in progress.
180
+ - `ERROR` : An error occurred during payment.
181
+
182
+ #### Processing Mark Options
183
+
184
+ - `DEFAULT` : Displays a default "processing..." message during payment.
185
+ - `CUSTOM` : Allows you to pass a custom React component to display during processing.
186
+ - `NONE` : No visual indicator is shown during processing.
187
+
188
+ #### Example Usage of processingMark
189
+
190
+ To use a custom component:
191
+
192
+ ```js
193
+ <PaymentQR
194
+ ...
195
+ processingMark={{
196
+ type: 'CUSTOM',
197
+ component: <div>Loading your payment...</div>,
198
+ }}
199
+ />
200
+ ```
201
+
202
+ <br>
203
+
204
+ ---
205
+
206
+ ---
207
+
208
+ <br>
209
+
89
210
  ### `useZigap`
90
211
 
91
212
  useZigap is a hook that fetches the information of the logged-in user in the zigap app and provides a logout function.
package/dist/App.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const App: () => import("react/jsx-runtime").JSX.Element;
2
+ export default App;
@@ -0,0 +1,4 @@
1
+ import { AddressProvideQRProps } from './AddressProvideQR.types';
2
+
3
+ declare const AddressProvideQR: ({ availableNetworks, dapp, url, validSeconds, onReceive, isShowLogo, logoSize, icon, ...props }: AddressProvideQRProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default AddressProvideQR;
@@ -0,0 +1,18 @@
1
+ import { CommonStyleType } from 'src/components/LoginQR/LoginQR.types';
2
+
3
+ export type AddressProvideResultType = {
4
+ isSuccess: boolean;
5
+ address?: string;
6
+ network?: string;
7
+ nickName?: string;
8
+ };
9
+ export type AddressProvideQRProps = {
10
+ availableNetworks: string[];
11
+ dapp: string;
12
+ url: string;
13
+ validSeconds: number;
14
+ icon?: string;
15
+ onReceive: (res: {
16
+ isSuccess: boolean;
17
+ }) => void;
18
+ } & CommonStyleType;
@@ -0,0 +1,2 @@
1
+ export { default as AddressProvideQR } from './AddressProvideQR';
2
+ export * from './AddressProvideQR.types';
@@ -0,0 +1,4 @@
1
+ import { AirdropQRProps } from './AirdropQR.types';
2
+
3
+ declare const AirdropQR: ({ availableNetworks, dapp, validSeconds, onReceive, isShowLogo, logoSize, icon, ...props }: AirdropQRProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default AirdropQR;
@@ -0,0 +1,17 @@
1
+ import { CommonStyleType } from 'src/components/LoginQR/LoginQR.types';
2
+
3
+ export type AirdropResultType = {
4
+ isSuccess: boolean;
5
+ address?: string;
6
+ network?: string;
7
+ nickName?: string;
8
+ };
9
+ export type AirdropQRProps = {
10
+ availableNetworks: string[];
11
+ dapp: string;
12
+ validSeconds: number;
13
+ icon?: string;
14
+ onReceive: (res: {
15
+ isSuccess: boolean;
16
+ }) => void;
17
+ } & CommonStyleType;
@@ -0,0 +1,2 @@
1
+ export { default as AirdropQR } from './AirdropQR';
2
+ export * from './AirdropQR.types';
@@ -0,0 +1,4 @@
1
+ import { LoginQRProps } from './LoginQR.types';
2
+
3
+ declare const LoginQR: ({ availableNetworks, dapp, url, sigMessage, onReceive, validSeconds, isShowLogo, logoSize, expire, icon, size, processingMark, ...props }: LoginQRProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default LoginQR;
@@ -0,0 +1,57 @@
1
+ import { CSSProperties } from 'react';
2
+
3
+ export type CommonStyleType = {
4
+ size?: number;
5
+ bgColor?: string;
6
+ fgColor?: string;
7
+ style?: CSSProperties;
8
+ isShowLogo?: boolean;
9
+ logoSize?: number;
10
+ };
11
+ export type PayloadType = {
12
+ publicKey: string;
13
+ message: string;
14
+ };
15
+ export type AccountType = {
16
+ address: string;
17
+ network: string;
18
+ nickName: string;
19
+ };
20
+ export type NoneLoginExpire = {
21
+ type: 'NONE';
22
+ seconds?: never;
23
+ };
24
+ export type FixedOrExtensionLoginExpire = {
25
+ type: 'FIX' | 'EXTEND';
26
+ seconds: number;
27
+ };
28
+ export type LoginExpireType = FixedOrExtensionLoginExpire | NoneLoginExpire;
29
+ export type LoginResultType = {
30
+ address: string;
31
+ network: string;
32
+ nickName: string;
33
+ token: string;
34
+ issuedDateTime: string;
35
+ expire: LoginExpireType;
36
+ };
37
+ export type ProcessingMarkType = {
38
+ type: 'DEFAULT';
39
+ } | {
40
+ type: 'CUSTOM';
41
+ component: React.ReactNode;
42
+ } | {
43
+ type: 'NONE';
44
+ };
45
+ export type LoginQRProps = {
46
+ availableNetworks: string[];
47
+ dapp: string;
48
+ url: string;
49
+ sigMessage: string;
50
+ validSeconds: number;
51
+ onReceive?: (res: {
52
+ status: 'REQUEST' | 'ACCOUNT' | 'SUCCESS' | 'ERROR';
53
+ }) => void;
54
+ expire: LoginExpireType;
55
+ icon?: string;
56
+ processingMark?: ProcessingMarkType;
57
+ } & CommonStyleType;
@@ -0,0 +1,2 @@
1
+ export { default as LoginQR } from './LoginQR';
2
+ export * from './LoginQR.types';
@@ -0,0 +1,4 @@
1
+ import { PaymentQRProps } from './PaymentQR.types';
2
+
3
+ declare const PaymentQR: ({ network, dapp, address, amount, description, info, onReceive, validSeconds, isShowLogo, logoSize, size, processingMark, ...props }: PaymentQRProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default PaymentQR;
@@ -0,0 +1,20 @@
1
+ import { CommonStyleType, ProcessingMarkType } from 'src/components/LoginQR/LoginQR.types';
2
+
3
+ export type PaymentResultType = {
4
+ from: string;
5
+ txHash: string;
6
+ status: string;
7
+ };
8
+ export type PaymentQRProps = {
9
+ network: string;
10
+ dapp: string;
11
+ address: string;
12
+ amount: string;
13
+ description?: string;
14
+ info?: string;
15
+ validSeconds: number;
16
+ onReceive?: (res: {
17
+ status: 'REQUEST' | 'ACCOUNT' | 'SUCCESS' | 'ERROR';
18
+ }) => void;
19
+ processingMark?: ProcessingMarkType;
20
+ } & CommonStyleType;
@@ -0,0 +1,2 @@
1
+ export { default as PaymentQR } from './PaymentQR';
2
+ export * from './PaymentQR.types';
@@ -0,0 +1,4 @@
1
+ export * from './LoginQR';
2
+ export * from './PaymentQR';
3
+ export * from './AddressProvideQR';
4
+ export * from './AirdropQR';
@@ -0,0 +1 @@
1
+ export { default as useZigap } from './useZigap';
@@ -0,0 +1,15 @@
1
+ export declare const LOGIN_RES_KEY = "userInfo";
2
+ export declare const TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
3
+ declare const useZigap: () => {
4
+ userInfo: {
5
+ address: string | undefined;
6
+ network: string | undefined;
7
+ nickName: string | undefined;
8
+ token: string | undefined;
9
+ issuedDateTime: string | undefined;
10
+ expireDateTime: string | undefined;
11
+ };
12
+ logout: () => void;
13
+ isWindowLoaded: boolean;
14
+ };
15
+ export default useZigap;
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './xphere';
3
+ export * from './zigap';
4
+ export * from './hooks';