zigap-utils 3.0.4 → 3.1.0-preview.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.
Files changed (3) hide show
  1. package/README.md +129 -129
  2. package/dist/index.es.js +1154 -1151
  3. package/package.json +68 -63
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- ![Zigap Utils](https://img.shields.io/badge/zigap--utils-v1.0.0-blue?style=for-the-badge) ![License](https://img.shields.io/badge/license-ISC-green?style=for-the-badge) ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
5
+ ![Zigap Utils](https://img.shields.io/badge/zigap--utils-v3.1.0-blue?style=for-the-badge) ![License](https://img.shields.io/badge/license-ISC-green?style=for-the-badge) ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
6
6
 
7
7
  **A utility library that helps communicate between dapp and zigap**
8
8
 
@@ -50,25 +50,25 @@ QR code component for user wallet login.
50
50
  import { LoginQR, LoginResultType } from 'zigap-utils';
51
51
 
52
52
  const App = () => {
53
- const [result, setResult] = useState<LoginResultType | null>(null);
54
-
55
- return (
56
- <div>
57
- <LoginQR
58
- dapp='My Awesome Dapp'
59
- url='https://myapp.com'
60
- availableNetworks={['v2xphere', 'v3xphere']}
61
- sigMessage='Welcome to My Dapp!'
62
- validSeconds={600}
63
- onReceive={({ status, result }) => {
64
- if (status === 'SUCCESS') {
65
- console.log('Login successful!', result);
66
- setResult(result as LoginResultType);
67
- }
68
- }}
69
- />
70
- </div>
71
- );
53
+ const [result, setResult] = useState<LoginResultType | null>(null);
54
+
55
+ return (
56
+ <div>
57
+ <LoginQR
58
+ dapp='My Awesome Dapp'
59
+ url='https://myapp.com'
60
+ availableNetworks={['v2xphere', 'v3xphere']}
61
+ sigMessage='Welcome to My Dapp!'
62
+ validSeconds={600}
63
+ onReceive={({ status, result }) => {
64
+ if (status === 'SUCCESS') {
65
+ console.log('Login successful!', result);
66
+ setResult(result as LoginResultType);
67
+ }
68
+ }}
69
+ />
70
+ </div>
71
+ );
72
72
  };
73
73
  ```
74
74
 
@@ -105,14 +105,14 @@ const App = () => {
105
105
 
106
106
  ```tsx
107
107
  interface LoginResultType {
108
- address: string;
109
- network: string;
110
- nickName: string;
111
- token: string;
112
- issuedDateTime: string;
113
- expire: LoginExpireType;
114
- isVerified: boolean;
115
- signature: string;
108
+ address: string;
109
+ network: string;
110
+ nickName: string;
111
+ token: string;
112
+ issuedDateTime: string;
113
+ expire: LoginExpireType;
114
+ isVerified: boolean;
115
+ signature: string;
116
116
  }
117
117
  ```
118
118
 
@@ -128,25 +128,25 @@ QR code component for message signing.
128
128
  import { SignatureQR, SignatureResultType } from 'zigap-utils';
129
129
 
130
130
  const App = () => {
131
- const [result, setResult] = useState<SignatureResultType | null>(null);
132
-
133
- return (
134
- <div>
135
- <SignatureQR
136
- dapp='My Awesome Dapp'
137
- url='https://myapp.com'
138
- availableNetworks={['v2xphere', 'v3xphere']}
139
- sigMessage='I agree to the terms and conditions'
140
- validSeconds={600}
141
- onReceive={({ status, result }) => {
142
- if (status === 'SUCCESS') {
143
- console.log('Signature successful!', result);
144
- setResult(result as SignatureResultType);
145
- }
146
- }}
147
- />
148
- </div>
149
- );
131
+ const [result, setResult] = useState<SignatureResultType | null>(null);
132
+
133
+ return (
134
+ <div>
135
+ <SignatureQR
136
+ dapp='My Awesome Dapp'
137
+ url='https://myapp.com'
138
+ availableNetworks={['v2xphere', 'v3xphere']}
139
+ sigMessage='I agree to the terms and conditions'
140
+ validSeconds={600}
141
+ onReceive={({ status, result }) => {
142
+ if (status === 'SUCCESS') {
143
+ console.log('Signature successful!', result);
144
+ setResult(result as SignatureResultType);
145
+ }
146
+ }}
147
+ />
148
+ </div>
149
+ );
150
150
  };
151
151
  ```
152
152
 
@@ -183,14 +183,14 @@ const App = () => {
183
183
 
184
184
  ```tsx
185
185
  interface SignatureResultType {
186
- address: string;
187
- network: string;
188
- nickName: string;
189
- token: string;
190
- issuedDateTime: string;
191
- expire: SignatureLoginExpireType;
192
- isVerified: boolean;
193
- signature: string;
186
+ address: string;
187
+ network: string;
188
+ nickName: string;
189
+ token: string;
190
+ issuedDateTime: string;
191
+ expire: SignatureLoginExpireType;
192
+ isVerified: boolean;
193
+ signature: string;
194
194
  }
195
195
  ```
196
196
 
@@ -206,31 +206,31 @@ QR code component for transaction sending.
206
206
  import { SendTransactionQR, SendTransactionResultType } from 'zigap-utils';
207
207
 
208
208
  const App = () => {
209
- const [result, setResult] = useState<SendTransactionResultType | null>(null);
210
-
211
- return (
212
- <div>
213
- <SendTransactionQR
214
- dapp='My Awesome Dapp'
215
- url='https://myapp.com'
216
- availableNetworks='v2xphere'
217
- validSeconds={600}
218
- transaction={{
219
- type: 0,
220
- to: '0x1234567890123456789012345678901234567890',
221
- value: '1000000000000000000', // 1 XP
222
- gasLimit: '21000',
223
- gasPrice: '1000000000',
224
- }}
225
- onReceive={({ status, result }) => {
226
- if (status === 'SUCCESS') {
227
- console.log('Transaction Complete!', result);
228
- setResult(result as SendTransactionResultType);
229
- }
230
- }}
231
- />
232
- </div>
233
- );
209
+ const [result, setResult] = useState<SendTransactionResultType | null>(null);
210
+
211
+ return (
212
+ <div>
213
+ <SendTransactionQR
214
+ dapp='My Awesome Dapp'
215
+ url='https://myapp.com'
216
+ availableNetworks='v2xphere'
217
+ validSeconds={600}
218
+ transaction={{
219
+ type: 0,
220
+ to: '0x1234567890123456789012345678901234567890',
221
+ value: '1000000000000000000', // 1 XP
222
+ gasLimit: '21000',
223
+ gasPrice: '1000000000',
224
+ }}
225
+ onReceive={({ status, result }) => {
226
+ if (status === 'SUCCESS') {
227
+ console.log('Transaction Complete!', result);
228
+ setResult(result as SendTransactionResultType);
229
+ }
230
+ }}
231
+ />
232
+ </div>
233
+ );
234
234
  };
235
235
  ```
236
236
 
@@ -260,37 +260,37 @@ const App = () => {
260
260
  ```tsx
261
261
  // Type 0: Legacy (pre-EIP-2718)
262
262
  interface TransactionType0 {
263
- type: 0 | '0x0';
264
- to: string;
265
- data?: string;
266
- value: string;
267
- gasLimit: string;
268
- gasPrice: string;
269
- chainId?: number;
263
+ type: 0 | '0x0';
264
+ to: string;
265
+ data?: string;
266
+ value: string;
267
+ gasLimit: string;
268
+ gasPrice: string;
269
+ chainId?: number;
270
270
  }
271
271
 
272
272
  // Type 1: EIP-2930 (access list)
273
273
  interface TransactionType1 {
274
- type: 1 | '0x1';
275
- to: string;
276
- data?: string;
277
- value: string;
278
- gasLimit: string;
279
- gasPrice: string;
280
- accessList?: AccessList;
281
- chainId?: number;
274
+ type: 1 | '0x1';
275
+ to: string;
276
+ data?: string;
277
+ value: string;
278
+ gasLimit: string;
279
+ gasPrice: string;
280
+ accessList?: AccessList;
281
+ chainId?: number;
282
282
  }
283
283
 
284
284
  // Type 2: EIP-1559 (dynamic fees)
285
285
  interface TransactionType2 {
286
- type: 2 | '0x2';
287
- to: string;
288
- data?: string;
289
- value: string;
290
- gasLimit: string;
291
- maxFeePerGas: string;
292
- maxPriorityFeePerGas: string;
293
- chainId?: number;
286
+ type: 2 | '0x2';
287
+ to: string;
288
+ data?: string;
289
+ value: string;
290
+ gasLimit: string;
291
+ maxFeePerGas: string;
292
+ maxPriorityFeePerGas: string;
293
+ chainId?: number;
294
294
  }
295
295
 
296
296
  type TransactionType = TransactionType0 | TransactionType1 | TransactionType2;
@@ -300,9 +300,9 @@ type TransactionType = TransactionType0 | TransactionType1 | TransactionType2;
300
300
 
301
301
  ```tsx
302
302
  interface SendTransactionResultType {
303
- txHash: string;
304
- status: 0 | 1; // 0 : fail , 1 : success
305
- error: string;
303
+ txHash: string;
304
+ status: 0 | 1; // 0 : fail , 1 : success
305
+ error: string;
306
306
  }
307
307
  ```
308
308
 
@@ -331,13 +331,13 @@ Common style options available for all QR components.
331
331
 
332
332
  ```tsx
333
333
  <LoginQR
334
- // ... other props
335
- size={200}
336
- bgColor='#ffffff'
337
- fgColor='#000000'
338
- isShowLogo={true}
339
- logoSize={40}
340
- style={{ borderRadius: '8px' }}
334
+ // ... other props
335
+ size={200}
336
+ bgColor='#ffffff'
337
+ fgColor='#000000'
338
+ isShowLogo={true}
339
+ logoSize={40}
340
+ style={{ borderRadius: '8px' }}
341
341
  />
342
342
  ```
343
343
 
@@ -357,22 +357,22 @@ Configure how to display during processing.
357
357
 
358
358
  ```tsx
359
359
  <SendTransactionQR
360
- // ... other props
361
- processingMark={{
362
- type: 'CUSTOM',
363
- component: (
364
- <div
365
- style={{
366
- display: 'flex',
367
- alignItems: 'center',
368
- gap: '8px',
369
- }}
370
- >
371
- <div className='spinner'></div>
372
- <span>Processing payment...</span>
373
- </div>
374
- ),
375
- }}
360
+ // ... other props
361
+ processingMark={{
362
+ type: 'CUSTOM',
363
+ component: (
364
+ <div
365
+ style={{
366
+ display: 'flex',
367
+ alignItems: 'center',
368
+ gap: '8px',
369
+ }}
370
+ >
371
+ <div className='spinner'></div>
372
+ <span>Processing payment...</span>
373
+ </div>
374
+ ),
375
+ }}
376
376
  />
377
377
  ```
378
378