zigap-utils 0.0.507 → 0.0.801
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.
- package/README.md +130 -9
- package/dist/components/PaymentQR/PaymentQR.d.ts +4 -0
- package/dist/components/PaymentQR/PaymentQR.types.d.ts +20 -0
- package/dist/components/PaymentQR/index.d.ts +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.es.js +2337 -2246
- package/dist/utils/login.d.ts +0 -1
- package/dist/utils/payment.d.ts +14 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/zigap/qr.d.ts +3 -1
- 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='
|
|
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
|
|
66
|
-
|
|
|
67
|
-
| `dapp`
|
|
68
|
-
| `url`
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `onReceive`
|
|
72
|
-
| `
|
|
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.
|
|
@@ -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;
|