zigap-utils 3.0.5 → 3.1.0-preview.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.
- package/README.md +129 -129
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +973 -967
- package/dist/utils/session.d.ts +1 -0
- package/package.json +68 -63
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
  
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
|
package/dist/index.d.ts
CHANGED