@proton/wrap-constants 0.1.1 → 0.2.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 (49) hide show
  1. package/dist/coins.d.ts +42 -9
  2. package/dist/constants.d.ts +10 -0
  3. package/dist/graph.d.ts +30 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/math.d.ts +17 -0
  6. package/dist/parsers/actions.d.ts +1323 -0
  7. package/dist/parsers/address.d.ts +932 -0
  8. package/dist/parsers/auth.d.ts +1816 -0
  9. package/dist/parsers/base.d.ts +35 -0
  10. package/dist/parsers/currency.d.ts +236 -0
  11. package/dist/parsers/deposit.d.ts +63 -0
  12. package/dist/parsers/dex.d.ts +508 -0
  13. package/dist/parsers/index.d.ts +12 -0
  14. package/dist/parsers/otc.d.ts +46 -0
  15. package/dist/parsers/pool.d.ts +51 -0
  16. package/dist/parsers/withdraw.d.ts +1053 -0
  17. package/dist/parsers/withdrawalHistory.d.ts +98 -0
  18. package/dist/parsers/wrap.d.ts +109 -0
  19. package/dist/utils.d.ts +1 -0
  20. package/dist/wrap-constants.cjs.development.js +1325 -310
  21. package/dist/wrap-constants.cjs.development.js.map +1 -1
  22. package/dist/wrap-constants.cjs.production.min.js +1 -1
  23. package/dist/wrap-constants.cjs.production.min.js.map +1 -1
  24. package/dist/wrap-constants.esm.js +1303 -311
  25. package/dist/wrap-constants.esm.js.map +1 -1
  26. package/package.json +14 -8
  27. package/src/coins.ts +563 -149
  28. package/src/constants.ts +41 -14
  29. package/src/graph.ts +126 -0
  30. package/src/index.ts +3 -1
  31. package/src/math.ts +112 -0
  32. package/src/parsers/actions.ts +82 -0
  33. package/src/parsers/address.ts +27 -0
  34. package/src/parsers/auth.ts +22 -0
  35. package/src/parsers/base.ts +18 -0
  36. package/src/parsers/currency.ts +89 -0
  37. package/src/parsers/deposit.ts +30 -0
  38. package/src/parsers/dex.ts +167 -0
  39. package/src/parsers/index.ts +12 -0
  40. package/src/parsers/otc.ts +23 -0
  41. package/src/parsers/pool.ts +51 -0
  42. package/src/parsers/withdraw.ts +39 -0
  43. package/src/parsers/withdrawalHistory.ts +23 -0
  44. package/src/parsers/wrap.ts +41 -0
  45. package/src/utils.ts +12 -1
  46. package/dist/parsers.d.ts +0 -849
  47. package/dist/pools.d.ts +0 -31
  48. package/src/parsers.ts +0 -258
  49. package/src/pools.ts +0 -26
package/dist/pools.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { Coin } from "./coins";
2
- import { ExtendedAsset } from "./parsers";
3
- export interface Pool {
4
- lt_symbol: string;
5
- creator: string;
6
- memo: string;
7
- pool1: ExtendedToken;
8
- pool2: ExtendedToken;
9
- hash: string;
10
- fee: {
11
- exchange_fee: number;
12
- add_liquidity_fee: number;
13
- remove_liquidity_fee: number;
14
- };
15
- liquidityUsd?: number;
16
- }
17
- export declare type ExtendedToken = Coin & ExtendedAsset & {
18
- key: string;
19
- };
20
- export declare type PoolTable = {
21
- pool1: ExtendedToken & {
22
- rate: number;
23
- };
24
- pool2: ExtendedToken & {
25
- rate: number;
26
- };
27
- path: {
28
- data: Pool;
29
- }[];
30
- getPathString: () => string;
31
- } | undefined;
package/src/parsers.ts DELETED
@@ -1,258 +0,0 @@
1
- import * as z from 'zod'
2
- import { WRAP_CONTRACT } from './constants'
3
-
4
- export enum Status {
5
- PENDING = 'pending',
6
- SUCCESS = 'success',
7
- FAIL = 'fail',
8
- PROCESSING = 'processing'
9
- }
10
-
11
- export const accountParser = z.string().regex(/^[.1-5a-z]{0,12}[.1-5a-j]?$/)
12
-
13
- export const authorizationParser = z.object({
14
- actor: accountParser,
15
- permission: z.string()
16
- })
17
- export type Authorization = z.infer<typeof authorizationParser>
18
-
19
- export const rawTransactionParser = z.object({
20
- expiration: z.string(),
21
- ref_block_num: z.number(),
22
- ref_block_prefix: z.number(),
23
- max_net_usage_words: z.number(),
24
- max_cpu_usage_ms: z.number(),
25
- delay_sec: z.number(),
26
- context_free_actions: z.array(z.any()),
27
- transaction_extensions: z.array(z.any())
28
- })
29
-
30
- export const generateAuthParser = z.object({
31
- signer: authorizationParser,
32
- signatures: z.array(z.string()),
33
- transaction: rawTransactionParser.merge(z.object({
34
- actions: z.array(z.object({
35
- account: accountParser,
36
- name: z.string(),
37
- data: z.object({
38
- time: z.string(),
39
- protonAccount: z.string()
40
- }),
41
- authorization: z.array(authorizationParser).min(1)
42
- }))
43
- }))
44
- })
45
- export type GenerateAuth = z.infer<typeof generateAuthParser>
46
-
47
- export const generateAddressBodyParser = z.object({
48
- coin: z.string(),
49
- wallet: z.string(),
50
- }).merge(generateAuthParser)
51
- export type GenerateAddressBody = z.infer<typeof generateAddressBodyParser>
52
-
53
- export const generateAddressResponse = z.object({
54
- id: z.string(), // "2448834505708930950",
55
- address: z.string(), // "0x617C03C1E2Bf81C062A4CEfbE312c070E1d86d18",
56
- coin: z.string(), // "ETH",
57
- wallet: z.string(), // "ETH",
58
- memo: z.string().optional()
59
- })
60
- export type GenerateAddressResponse = z.infer<typeof generateAddressResponse>
61
-
62
- export const depositBodyParser = z.object({
63
- id: z.string(), // "0x000010203121388fac991"
64
- externalId: z.string().optional(), // "2510473254188091220"
65
- type: z.string(), // "transfer"
66
- hash: z.string(), // "0x000010203121388fac991"
67
- coin: z.string(), // "ETH" or "XPR"
68
- wallet: z.string(), // "ETH-ROPSTEN" or "XPR-MAINNET"
69
- })
70
- export type DepositBody = z.infer<typeof depositBodyParser>
71
-
72
- export const withdrawBodyParser = z.object({
73
- signer: authorizationParser,
74
- signatures: z.array(z.string()).min(1),
75
- transaction: rawTransactionParser.merge(z.object({
76
- actions: z.array(z.object({
77
- account: accountParser,
78
- name: z.literal('transfer'),
79
- data: z.object({
80
- from: z.string().refine((val) => val !== WRAP_CONTRACT, {
81
- message: `${WRAP_CONTRACT} must be receiver`,
82
- }),
83
- to: z.literal(WRAP_CONTRACT),
84
- quantity: z.string(),
85
- memo: z.string()
86
- }),
87
- authorization: z.array(authorizationParser).min(1)
88
- })).min(1)
89
- })),
90
- quoteId: z.string()
91
- })
92
- export type WithdrawBody = z.infer<typeof withdrawBodyParser>
93
-
94
- export const withdrawMetalResponseParser = z.object({
95
- success: z.boolean(),
96
- id: z.string(),
97
- })
98
- export type WithdrawMetalResponse = z.infer<typeof withdrawMetalResponseParser>
99
-
100
- export const withdrawHistoryMetalSwapParser = z.object({
101
- id: z.string(),
102
- status: z.string(),
103
- amount: z.string(),
104
- currency: z.string(),
105
- network: z.string(),
106
- created: z.string(),
107
- withdrawalAddress: z.string(),
108
- withdrawalHash: z.string().optional()
109
- })
110
- export type WithdrawHistoryMetalSwap = z.infer<typeof withdrawHistoryMetalSwapParser>
111
-
112
- export const withdrawHistoryMetalResponseParser = z.object({
113
- swaps: z.array(withdrawHistoryMetalSwapParser),
114
- page: z.number(),
115
- pageSize: z.number(),
116
- numberOfElements: z.number(),
117
- totalPages: z.number(),
118
- totalElements: z.number()
119
- })
120
- export type WithdrawHistoryMetalResponse = z.infer<typeof withdrawHistoryMetalResponseParser>
121
-
122
- const ExtendedAssetParser = z.object({
123
- quantity: z.string(),
124
- contract: accountParser
125
- })
126
- export type ExtendedAsset = z.infer<typeof ExtendedAssetParser>
127
-
128
- export const wrapStartParser = z.object({
129
- balance: ExtendedAssetParser,
130
- txid: z.string(),
131
- coin: z.string(),
132
- wallet: z.string(),
133
- deposit_address: z.string(),
134
- confirmations: z.number()
135
- })
136
- export type WrapStart = z.infer<typeof wrapStartParser>
137
-
138
- export const wrapSetConfParser = z.object({
139
- wrap_hash: z.string(),
140
- confirmations: z.number()
141
- })
142
- export type WrapSetConf = z.infer<typeof wrapSetConfParser>
143
-
144
- export const wrapParser = z.object({
145
- index: z.number(),
146
- proton_account: z.string(),
147
- balance: ExtendedAssetParser,
148
- txid: z.string(),
149
- coin: z.string(),
150
- wallet: z.string(),
151
- deposit_address: z.string(),
152
- status: z.nativeEnum(Status),
153
- finish_txid: z.string(),
154
- wrap_hash: z.string(),
155
- confirmations: z.number(),
156
- })
157
- export type Wrap = z.infer<typeof wrapParser>
158
-
159
- export const transactionParser = z.object({
160
- coin: z.string(), // "BTC"
161
- wallet: z.string(), // "BTC"
162
- blockhash: z.string().optional().nullable(), // "000000000000000000089b270eb99f75107d6a9cde37ec944cb80a2998df7b43"
163
- txid: z.string(), // "b4781422be95fee8fbbf720e3e0fa9705ae834474ef25f5724cdd0f5d23211ed"
164
- type: z.string(), // "receive" or "send"
165
- height: z.number().optional().nullable(), // 643159
166
- confirmations: z.number(), // 18369
167
- state: z.string(), // "confirmed"
168
- entries: z.array(z.object({
169
- address: z.string(), // "1CgGHR9bUakXhLz1eBapvP4PDDtta5pHx1"
170
- wallet: z.string(), // "BTC"
171
- value: z.number(), // 84456
172
- valueString: z.string(), // "84456"
173
- isChange: z.boolean(), // false
174
- })),
175
- outputs: z.array(z.object({
176
- address: z.string(), // "1CgGHR9bUakXhLz1eBapvP4PDDtta5pHx1"
177
- wallet: z.string(), // "BTC"
178
- fromWallet: z.string(), // "BTC"
179
- value: z.number(), // 84456
180
- valueString: z.string(), // "84456"
181
- coinbase: z.boolean(), // false
182
- })),
183
- value: z.number(), // 84456
184
- valueString: z.string(), // "84456"
185
- pending: z.boolean(), // false
186
- instant: z.boolean(), // false
187
- })
188
- export type Transaction = z.infer<typeof transactionParser>
189
-
190
- export const addressParser = z.object({
191
- index: z.number(),
192
- account: accountParser,
193
- coin: z.string(),
194
- address: z.string(),
195
- wallet: z.string(),
196
- address_hash: z.string(),
197
- })
198
- export type Address = z.infer<typeof addressParser>
199
-
200
- export const otcOrderResponseParser = z.object({
201
- success: z.boolean(),
202
- transaction_id: z.string(),
203
- errormsg: z.string().optional()
204
- })
205
- export type OtcOrderResponse = z.infer<typeof otcOrderResponseParser>
206
-
207
- export const otcQuoteBodyParser = z.object({
208
- baseAmount: z.number(),
209
- baseSymbol: z.string(),
210
- quoteSymbol: z.string()
211
- })
212
- export type OtcQuoteBody = z.infer<typeof otcQuoteBodyParser>
213
-
214
- export const otcQuoteResponseParser = z.object({
215
- success: z.boolean(),
216
- token: z.string(),
217
- qty: z.number(),
218
- errormsg: z.string().optional()
219
- })
220
- export type OtcQuoteResponse = z.infer<typeof otcQuoteResponseParser>
221
-
222
- export const rateParser = z.object({
223
- counterCurrency: z.string(),
224
- price: z.number(),
225
- priceChangePercent: z.number(),
226
- marketCap: z.number(),
227
- volume: z.number(),
228
- timestamp: z.number()
229
- })
230
- export type Rate = z.infer<typeof rateParser>
231
-
232
- export const exchangeRateParser = z.object({
233
- contract: z.string(),
234
- symbol: z.string(),
235
- rank: z.number(),
236
- rates: z.array(rateParser)
237
- })
238
- export type ExchangeRate = z.infer<typeof exchangeRateParser>
239
-
240
- export const exchangeRatesParser = z.array(exchangeRateParser)
241
- export type ExchangeRates = z.infer<typeof exchangeRatesParser>
242
-
243
- export const withdrawalFeeQuoteParser = z.object({
244
- quoteId: z.string(),
245
- estimatedFee: z.string(),
246
- currency: z.string(),
247
- network: z.string(),
248
- })
249
- export type WithdrawalFeeQuote = z.infer<typeof withdrawalFeeQuoteParser>
250
-
251
- export interface CurrencyStat {
252
- supply: string;
253
- max_supply: string;
254
- issuer: string;
255
- }
256
- export interface CurrencyStats {
257
- [key: string]: CurrencyStat;
258
- }
package/src/pools.ts DELETED
@@ -1,26 +0,0 @@
1
- import { Coin } from "./coins"
2
- import { ExtendedAsset } from "./parsers"
3
-
4
- export interface Pool {
5
- lt_symbol: string;
6
- creator: string;
7
- memo: string;
8
- pool1: ExtendedToken;
9
- pool2: ExtendedToken;
10
- hash: string;
11
- fee: {
12
- exchange_fee: number;
13
- add_liquidity_fee: number;
14
- remove_liquidity_fee: number;
15
- };
16
- liquidityUsd?: number;
17
- }
18
-
19
- export type ExtendedToken = Coin & ExtendedAsset & { key: string; }
20
-
21
- export type PoolTable = {
22
- pool1: ExtendedToken & { rate: number; };
23
- pool2: ExtendedToken & { rate: number; };
24
- path: { data: Pool }[];
25
- getPathString: () => string;
26
- } | undefined