@proton/wrap-constants 0.0.32 → 0.0.36

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/src/coins.ts CHANGED
@@ -50,6 +50,7 @@ export interface Coin {
50
50
  xtokenContract : string;
51
51
  wallets : Wallet[];
52
52
  image : string;
53
+ coingeckoId : string;
53
54
  balance? : Asset;
54
55
  }
55
56
 
@@ -134,7 +135,8 @@ export const initializeCoins = (protonChain: string): {
134
135
  }
135
136
  ]: []),
136
137
  ],
137
- image: '/img/tokens/xpr.png'
138
+ image: '/img/tokens/xpr.png',
139
+ coingeckoId: 'proton'
138
140
  },
139
141
  {
140
142
  allowSwap: true,
@@ -186,7 +188,8 @@ export const initializeCoins = (protonChain: string): {
186
188
  hasWithdrawMemo: false
187
189
  }]: [])
188
190
  ],
189
- image: '/img/tokens/xusdc.png'
191
+ image: '/img/tokens/xusdc.png',
192
+ coingeckoId: 'usd-coin'
190
193
  },
191
194
  {
192
195
  allowSwap: true,
@@ -209,7 +212,8 @@ export const initializeCoins = (protonChain: string): {
209
212
  hasWithdrawMemo: false
210
213
  }]: [])
211
214
  ],
212
- image: '/img/tokens/xmt.png'
215
+ image: '/img/tokens/xmt.png',
216
+ coingeckoId: 'metal'
213
217
  },
214
218
  {
215
219
  allowSwap: true,
@@ -241,7 +245,8 @@ export const initializeCoins = (protonChain: string): {
241
245
  hasWithdrawMemo: false
242
246
  }]: [])
243
247
  ],
244
- image: '/img/tokens/xbtc.png'
248
+ image: '/img/tokens/xbtc.png',
249
+ coingeckoId: 'bitcoin'
245
250
  },
246
251
  {
247
252
  allowSwap: true,
@@ -273,7 +278,8 @@ export const initializeCoins = (protonChain: string): {
273
278
  hasWithdrawMemo: false
274
279
  }]: [])
275
280
  ],
276
- image: '/img/tokens/xeth.png'
281
+ image: '/img/tokens/xeth.png',
282
+ coingeckoId: 'ethereum'
277
283
  },
278
284
  {
279
285
  allowSwap: IS_MAINNET,
@@ -305,7 +311,8 @@ export const initializeCoins = (protonChain: string): {
305
311
  hasWithdrawMemo: false
306
312
  }]: [])
307
313
  ],
308
- image: '/img/tokens/xusdt.png'
314
+ image: '/img/tokens/xusdt.png',
315
+ coingeckoId: 'tether'
309
316
  },
310
317
  {
311
318
  allowSwap: false,
@@ -328,7 +335,8 @@ export const initializeCoins = (protonChain: string): {
328
335
  hasWithdrawMemo: false
329
336
  }]: [])
330
337
  ],
331
- image: '/img/tokens/xtusd.png'
338
+ image: '/img/tokens/xtusd.png',
339
+ coingeckoId: 'true-usd'
332
340
  },
333
341
  {
334
342
  allowSwap: false,
@@ -351,7 +359,8 @@ export const initializeCoins = (protonChain: string): {
351
359
  hasWithdrawMemo: false
352
360
  }]: [])
353
361
  ],
354
- image: '/img/tokens/xpax.png'
362
+ image: '/img/tokens/xpax.png',
363
+ coingeckoId: 'usdp'
355
364
  },
356
365
  {
357
366
  allowSwap: false,
@@ -383,7 +392,8 @@ export const initializeCoins = (protonChain: string): {
383
392
  hasWithdrawMemo: false
384
393
  }]: [])
385
394
  ],
386
- image: '/img/tokens/xpaxg.png'
395
+ image: '/img/tokens/xpaxg.png',
396
+ coingeckoId: 'pax-gold'
387
397
  },
388
398
  {
389
399
  allowSwap: IS_MAINNET,
@@ -415,7 +425,8 @@ export const initializeCoins = (protonChain: string): {
415
425
  hasWithdrawMemo: false
416
426
  }]: [])
417
427
  ],
418
- image: '/img/tokens/xuni.png'
428
+ image: '/img/tokens/xuni.png',
429
+ coingeckoId: 'uniswap'
419
430
  },
420
431
  {
421
432
  allowSwap: false,
@@ -438,7 +449,8 @@ export const initializeCoins = (protonChain: string): {
438
449
  hasWithdrawMemo: false
439
450
  }]: [])
440
451
  ],
441
- image: '/img/tokens/xinch.png'
452
+ image: '/img/tokens/xinch.png',
453
+ coingeckoId: '1inch'
442
454
  },
443
455
  {
444
456
  allowSwap: false,
@@ -461,7 +473,8 @@ export const initializeCoins = (protonChain: string): {
461
473
  hasWithdrawMemo: false
462
474
  }]: [])
463
475
  ],
464
- image: '/img/tokens/xlink.png'
476
+ image: '/img/tokens/xlink.png',
477
+ coingeckoId: 'chainlink'
465
478
  },
466
479
  {
467
480
  allowSwap: IS_MAINNET,
@@ -493,7 +506,8 @@ export const initializeCoins = (protonChain: string): {
493
506
  hasWithdrawMemo: false
494
507
  }]: [])
495
508
  ],
496
- image: '/img/tokens/xltc.png'
509
+ image: '/img/tokens/xltc.png',
510
+ coingeckoId: 'litecoin'
497
511
  },
498
512
  {
499
513
  allowSwap: IS_MAINNET,
@@ -525,7 +539,8 @@ export const initializeCoins = (protonChain: string): {
525
539
  hasWithdrawMemo: false
526
540
  }]: [])
527
541
  ],
528
- image: '/img/tokens/xbch.png'
542
+ image: '/img/tokens/xbch.png',
543
+ coingeckoId: 'bitcoin-cash'
529
544
  },
530
545
  {
531
546
  allowSwap: false,
@@ -557,7 +572,8 @@ export const initializeCoins = (protonChain: string): {
557
572
  hasWithdrawMemo: true
558
573
  }]: [])
559
574
  ],
560
- image: '/img/tokens/xxlm.png'
575
+ image: '/img/tokens/xxlm.png',
576
+ coingeckoId: 'stellar'
561
577
  },
562
578
  {
563
579
  allowSwap: IS_MAINNET,
@@ -570,7 +586,8 @@ export const initializeCoins = (protonChain: string): {
570
586
  xtokenPrecision: 4,
571
587
  xtokenContract: 'sense',
572
588
  wallets: [],
573
- image: '/img/tokens/xsense.png'
589
+ image: '/img/tokens/xsense.png',
590
+ coingeckoId: 'sense'
574
591
  },
575
592
  {
576
593
  allowSwap: false,
@@ -593,7 +610,8 @@ export const initializeCoins = (protonChain: string): {
593
610
  hasWithdrawMemo: false
594
611
  }]: [])
595
612
  ],
596
- image: '/img/tokens/xdot.png'
613
+ image: '/img/tokens/xdot.png',
614
+ coingeckoId: 'polkadot'
597
615
  },
598
616
  {
599
617
  allowSwap: true,
@@ -616,7 +634,8 @@ export const initializeCoins = (protonChain: string): {
616
634
  hasWithdrawMemo: false
617
635
  }]: [])
618
636
  ],
619
- image: '/img/tokens/xbnb.png'
637
+ image: '/img/tokens/xbnb.png',
638
+ coingeckoId: 'binancecoin'
620
639
  },
621
640
  {
622
641
  allowSwap: true,
@@ -648,7 +667,8 @@ export const initializeCoins = (protonChain: string): {
648
667
  hasWithdrawMemo: true
649
668
  }]: [])
650
669
  ],
651
- image: '/img/tokens/xeos.png'
670
+ image: '/img/tokens/xeos.png',
671
+ coingeckoId: 'eos'
652
672
  },
653
673
  {
654
674
  allowSwap: false,
@@ -671,7 +691,8 @@ export const initializeCoins = (protonChain: string): {
671
691
  hasWithdrawMemo: false
672
692
  }]: [])
673
693
  ],
674
- image: '/img/tokens/xhbar.png'
694
+ image: '/img/tokens/xhbar.png',
695
+ coingeckoId: 'hedera-hashgraph'
675
696
  },
676
697
 
677
698
  // Synthethic
@@ -696,7 +717,8 @@ export const initializeCoins = (protonChain: string): {
696
717
  hasWithdrawMemo: false
697
718
  }]: []),
698
719
  ],
699
- image: '/img/tokens/xdoge.png'
720
+ image: '/img/tokens/xdoge.png',
721
+ coingeckoId: 'dogecoin'
700
722
  },
701
723
  {
702
724
  allowSwap: IS_MAINNET,
@@ -719,7 +741,8 @@ export const initializeCoins = (protonChain: string): {
719
741
  hasWithdrawMemo: false
720
742
  }]: [])
721
743
  ],
722
- image: '/img/tokens/xada.png'
744
+ image: '/img/tokens/xada.png',
745
+ coingeckoId: 'cardano'
723
746
  },
724
747
  {
725
748
  allowSwap: false,
@@ -732,7 +755,8 @@ export const initializeCoins = (protonChain: string): {
732
755
  xtokenPrecision: 6,
733
756
  xtokenContract: 'xtokens',
734
757
  wallets: [],
735
- image: '/img/tokens/xtheta.png'
758
+ image: '/img/tokens/xtheta.png',
759
+ coingeckoId: 'theta-token'
736
760
  },
737
761
  {
738
762
  allowSwap: false,
@@ -745,7 +769,8 @@ export const initializeCoins = (protonChain: string): {
745
769
  xtokenPrecision: 6,
746
770
  xtokenContract: 'xtokens',
747
771
  wallets: [],
748
- image: '/img/tokens/xfil.png'
772
+ image: '/img/tokens/xfil.png',
773
+ coingeckoId: 'filecoin'
749
774
  },
750
775
  {
751
776
  allowSwap: false,
@@ -758,7 +783,8 @@ export const initializeCoins = (protonChain: string): {
758
783
  xtokenPrecision: 6,
759
784
  xtokenContract: 'xtokens',
760
785
  wallets: [],
761
- image: '/img/tokens/xtrx.png'
786
+ image: '/img/tokens/xtrx.png',
787
+ coingeckoId: 'tron'
762
788
  },
763
789
  // End synthetic
764
790
  ]
@@ -0,0 +1,68 @@
1
+ import * as z from 'zod'
2
+ import { ZodRawShape } from 'zod/lib/src/types/base'
3
+ import { accountParser, authorizationsParser } from './base'
4
+
5
+ const rawTransactionParser = z.object({
6
+ expiration : z.string(),
7
+ ref_block_num : z.number(),
8
+ ref_block_prefix : z.number(),
9
+ max_net_usage_words : z.number(),
10
+ max_cpu_usage_ms : z.number(),
11
+ delay_sec : z.number(),
12
+ context_free_actions : z.array(z.any()),
13
+ transaction_extensions: z.array(z.any())
14
+ })
15
+
16
+ export const baseActionParser = <T extends ZodRawShape>(contract: string, action: string, data: T) => z.object({
17
+ account: contract === '*' ? accountParser : z.literal(contract),
18
+ name: z.literal(action),
19
+ data: z.object(data),
20
+ authorization: authorizationsParser
21
+ })
22
+
23
+ export const baseActionSerializedParser = <T extends ZodRawShape>(contract: string, action: string, data: T) => z.object({
24
+ account: contract === '*' ? accountParser : z.literal(contract),
25
+ name: z.literal(action),
26
+ data: z.string().or(z.object(data)),
27
+ authorization: authorizationsParser
28
+ })
29
+
30
+ export const webauthActionParser = <T extends ZodRawShape>(contract: string, action: string, data: T) => z.object({
31
+ account: z.literal('webauthn'),
32
+ name: z.literal('exec'),
33
+ data: z.object({
34
+ account: accountParser,
35
+ key: z.object({
36
+ key: z.array(z.string().or(z.object({
37
+ modulus: z.string(),
38
+ exponent: z.string()
39
+ }))),
40
+ user_presence: z.number(),
41
+ rpid: z.string()
42
+ }),
43
+ nonce: z.number(),
44
+ permissions: authorizationsParser,
45
+ signature: z.object({
46
+ auth_data: z.string(),
47
+ client_json: z.string(),
48
+ signature: z.string()
49
+ }),
50
+ trx: rawTransactionParser.merge(
51
+ z.object({
52
+ actions: z.array(
53
+ baseActionSerializedParser(contract, action, data)
54
+ ).length(1)
55
+ })
56
+ )
57
+ }),
58
+ authorization: authorizationsParser
59
+ })
60
+
61
+ export const singleActionTransactionParser = <T extends ZodRawShape>(contract: string, action: string, data: T) => {
62
+ const baseAction = baseActionParser(contract, action, data)
63
+ const webauthAction = webauthActionParser(contract, action, data)
64
+
65
+ return rawTransactionParser.merge(z.object({
66
+ actions: z.array(baseAction.or(webauthAction)).length(1)
67
+ }))
68
+ }
@@ -0,0 +1,27 @@
1
+ import * as z from 'zod'
2
+ import { accountParser } from './base'
3
+ import { generateAuthParser } from './auth'
4
+
5
+ export const addressParser = z.object({
6
+ index : z.number(),
7
+ account : accountParser,
8
+ chain : z.string(),
9
+ address : z.string(),
10
+ address_hash: z.string(),
11
+ })
12
+ export type Address = z.infer<typeof addressParser>
13
+
14
+ export const generateAddressBodyParser = z.object({
15
+ coin: z.string(),
16
+ wallet: z.string(),
17
+ }).merge(generateAuthParser)
18
+ export type GenerateAddressBody = z.infer<typeof generateAddressBodyParser>
19
+
20
+ export const generateAddressResponse = z.object({
21
+ id : z.string(), // "2448834505708930950",
22
+ address: z.string(), // "0x617C03C1E2Bf81C062A4CEfbE312c070E1d86d18",
23
+ coin : z.string(), // "ETH",
24
+ wallet : z.string(), // "ETH",
25
+ memo : z.string().optional()
26
+ })
27
+ export type GenerateAddressResponse = z.infer<typeof generateAddressResponse>
@@ -0,0 +1,23 @@
1
+ import * as z from 'zod'
2
+ import { baseActionParser, singleActionTransactionParser } from './actions'
3
+ import { authorizationParser } from './base'
4
+ import { WRAP_CONTRACT, WRAP_AUTH_ACTION } from '../constants'
5
+ import { ZodRawShape } from 'zod/lib/src/types/base'
6
+
7
+ export const createAbstractAuthParser = (contract: string, action: string, data: ZodRawShape) => {
8
+ return z.object({
9
+ signer : authorizationParser,
10
+ signatures : z.array(z.string()).length(1),
11
+ transaction: singleActionTransactionParser(contract, action, data)
12
+ })
13
+ }
14
+
15
+ const generateAuthData = {
16
+ time: z.string(),
17
+ protonAccount: z.string()
18
+ }
19
+ const generateAuthActionsBaseParser = baseActionParser(WRAP_CONTRACT, WRAP_AUTH_ACTION, generateAuthData)
20
+ export type GenerateAuthBaseAction = z.infer<typeof generateAuthActionsBaseParser>
21
+
22
+ export const generateAuthParser = createAbstractAuthParser(WRAP_CONTRACT, WRAP_AUTH_ACTION, generateAuthData)
23
+ export type GenerateAuth = z.infer<typeof generateAuthParser>
@@ -0,0 +1,18 @@
1
+ import * as z from 'zod'
2
+
3
+ export const accountParser = z.string().regex(/^[.1-5a-z]{0,12}[.1-5a-j]?$/)
4
+
5
+ export const authorizationParser = z.object({
6
+ actor : accountParser,
7
+ permission: z.string()
8
+ })
9
+ export type Authorization = z.infer<typeof authorizationParser>
10
+
11
+ export const authorizationsParser = z.array(authorizationParser).min(1)
12
+ export type Authorizations = z.infer<typeof authorizationsParser>
13
+
14
+ export const ExtendedAssetParser = z.object({
15
+ quantity: z.string(),
16
+ contract: accountParser
17
+ })
18
+ export type ExtendedAsset = z.infer<typeof ExtendedAssetParser>
@@ -0,0 +1,31 @@
1
+ import * as z from 'zod'
2
+
3
+ export interface CurrencyStat {
4
+ supply : string;
5
+ max_supply: string;
6
+ issuer : string;
7
+ }
8
+ export interface CurrencyStats {
9
+ [key: string]: CurrencyStat;
10
+ }
11
+
12
+ export const rateParser = z.object({
13
+ counterCurrency : z.string(),
14
+ price : z.number(),
15
+ priceChangePercent: z.number(),
16
+ marketCap : z.number(),
17
+ volume : z.number(),
18
+ timestamp : z.number()
19
+ })
20
+ export type Rate = z.infer<typeof rateParser>
21
+
22
+ export const exchangeRateParser = z.object({
23
+ contract: z.string(),
24
+ symbol : z.string(),
25
+ rank : z.number(),
26
+ rates : z.array(rateParser)
27
+ })
28
+ export type ExchangeRate = z.infer<typeof exchangeRateParser>
29
+
30
+ export const exchangeRatesParser = z.array(exchangeRateParser)
31
+ export type ExchangeRates = z.infer<typeof exchangeRatesParser>
@@ -0,0 +1,30 @@
1
+ import * as z from 'zod'
2
+
3
+ export enum Type {
4
+ RECEIVE = 'receive',
5
+ SEND = 'send'
6
+ }
7
+
8
+ export const depositBodyParser = z.object({
9
+ id : z.string(), // "0x000010203121388fac991"
10
+ type : z.nativeEnum(Type), // "receive" or "send"
11
+ hash : z.string(), // "0x000010203121388fac991"
12
+ coin : z.string(), // "ETH" or "XPR"
13
+ wallet : z.string(), // "ETH-ROPSTEN" or "XPR-MAINNET"
14
+ })
15
+ export type DepositBody = z.infer<typeof depositBodyParser>
16
+
17
+ export const transactionParser = z.object({
18
+ id : z.string(), // "2629304740076324677"
19
+ wallet : z.string(), // "ETH"
20
+ value : z.number(), // 10000000000000000
21
+ valueString : z.string(), // "10000000000000000"
22
+ address : z.string(), // "0x0000"
23
+ type : z.nativeEnum(Type), // "receive" or "send"
24
+ state : z.string(), // "confirmed"
25
+ confirmations : z.number(), // 1
26
+ hash : z.string(), // "b4781422be95fee8fbbf720e3e0fa9705ae834474ef25f5724cdd0f5d23211ed"
27
+ blockHash : z.string().optional().nullable(), // "000000000000000000089b270eb99f75107d6a9cde37ec944cb80a2998df7b43"
28
+ blockHeight : z.number().optional().nullable(), // 643159
29
+ })
30
+ export type Transaction = z.infer<typeof transactionParser>
@@ -0,0 +1,10 @@
1
+ export * from './actions'
2
+ export * from './address'
3
+ export * from './auth'
4
+ export * from './base'
5
+ export * from './currency'
6
+ export * from './deposit'
7
+ export * from './otc'
8
+ export * from './withdraw'
9
+ export * from './withdrawalHistory'
10
+ export * from './wrap'
@@ -0,0 +1,23 @@
1
+ import * as z from 'zod'
2
+
3
+ export const otcOrderResponseParser = z.object({
4
+ success : z.boolean(),
5
+ transaction_id: z.string(),
6
+ errormsg : z.string().optional()
7
+ })
8
+ export type OtcOrderResponse = z.infer<typeof otcOrderResponseParser>
9
+
10
+ export const otcQuoteBodyParser = z.object({
11
+ baseAmount : z.number(),
12
+ baseSymbol : z.string(),
13
+ quoteSymbol: z.string()
14
+ })
15
+ export type OtcQuoteBody = z.infer<typeof otcQuoteBodyParser>
16
+
17
+ export const otcQuoteResponseParser = z.object({
18
+ success : z.boolean(),
19
+ token : z.string(),
20
+ qty : z.number(),
21
+ errormsg: z.string().optional()
22
+ })
23
+ export type OtcQuoteResponse = z.infer<typeof otcQuoteResponseParser>
@@ -0,0 +1,39 @@
1
+ import * as z from 'zod'
2
+ import { singleActionTransactionParser } from './actions'
3
+ import { authorizationParser } from './base'
4
+ import { WRAP_CONTRACT } from '../constants'
5
+ import { baseActionParser } from './actions'
6
+
7
+ const withdrawData = {
8
+ from: z.string().refine((val) => val !== WRAP_CONTRACT, {
9
+ message: `${WRAP_CONTRACT} must be receiver`,
10
+ }),
11
+ to: z.literal(WRAP_CONTRACT),
12
+ quantity: z.string(),
13
+ memo: z.string()
14
+ }
15
+ const withdrawBodyBaseAction = baseActionParser('*', 'transfer', withdrawData)
16
+ export type WithdrawBodyBaseAction = z.infer<typeof withdrawBodyBaseAction>
17
+
18
+ export const withdrawBodyParser = z.object({
19
+ signer : authorizationParser,
20
+ signatures : z.array(z.string()).length(1),
21
+ transaction: singleActionTransactionParser('*', 'transfer', withdrawData),
22
+ quoteId: z.string(),
23
+ provider: z.string().optional()
24
+ })
25
+ export type WithdrawBody = z.infer<typeof withdrawBodyParser>
26
+
27
+ export const withdrawMetalResponseParser = z.object({
28
+ success: z.boolean(),
29
+ id : z.string(),
30
+ })
31
+ export type WithdrawMetalResponse = z.infer<typeof withdrawMetalResponseParser>
32
+
33
+ export const withdrawalFeeQuoteParser = z.object({
34
+ quoteId : z.string(),
35
+ estimatedFee: z.string(),
36
+ currency : z.string(),
37
+ network : z.string(),
38
+ })
39
+ export type WithdrawalFeeQuote = z.infer<typeof withdrawalFeeQuoteParser>
@@ -0,0 +1,23 @@
1
+ import * as z from 'zod'
2
+
3
+ export const withdrawHistoryMetalSwapParser = z.object({
4
+ id : z.string(),
5
+ status : z.string(),
6
+ amount : z.string(),
7
+ currency : z.string(),
8
+ network : z.string(),
9
+ created : z.string(),
10
+ withdrawalAddress: z.string(),
11
+ withdrawalHash : z.string().optional()
12
+ })
13
+ export type WithdrawHistoryMetalSwap = z.infer<typeof withdrawHistoryMetalSwapParser>
14
+
15
+ export const withdrawHistoryMetalResponseParser = z.object({
16
+ swaps : z.array(withdrawHistoryMetalSwapParser),
17
+ page : z.number(),
18
+ pageSize : z.number(),
19
+ numberOfElements: z.number(),
20
+ totalPages : z.number(),
21
+ totalElements : z.number()
22
+ })
23
+ export type WithdrawHistoryMetalResponse = z.infer<typeof withdrawHistoryMetalResponseParser>
@@ -0,0 +1,41 @@
1
+ import * as z from 'zod'
2
+ import { ExtendedAssetParser } from './base'
3
+
4
+ export enum Status {
5
+ PENDING = 'pending',
6
+ SUCCESS = 'success',
7
+ FAIL = 'fail',
8
+ PROCESSING = 'processing'
9
+ }
10
+
11
+ export const wrapStartParser = z.object({
12
+ balance : ExtendedAssetParser,
13
+ id : z.string(),
14
+ txid : z.string(),
15
+ chain : z.string(),
16
+ deposit_address: z.string(),
17
+ confirmations : z.number()
18
+ })
19
+
20
+ export type WrapStart = z.infer<typeof wrapStartParser>
21
+
22
+ export const wrapSetConfParser = z.object({
23
+ wrap_hash : z.string(),
24
+ confirmations: z.number()
25
+ })
26
+ export type WrapSetConf = z.infer<typeof wrapSetConfParser>
27
+
28
+ export const wrapParser = z.object({
29
+ index : z.number(),
30
+ proton_account : z.string(),
31
+ balance : ExtendedAssetParser,
32
+ id : z.string(),
33
+ txid : z.string(),
34
+ chain : z.string(),
35
+ deposit_address: z.string(),
36
+ status : z.nativeEnum(Status),
37
+ finish_txid : z.string(),
38
+ wrap_hash : z.string(),
39
+ confirmations : z.number(),
40
+ })
41
+ export type Wrap = z.infer<typeof wrapParser>