llama-pay-sdk 3.1.1 → 3.3.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.
Files changed (62) hide show
  1. package/lib/CashoutClient.d.ts +3 -4
  2. package/lib/CashoutClient.d.ts.map +1 -1
  3. package/lib/CashoutClient.js +12 -5
  4. package/lib/CashoutClient.js.map +1 -1
  5. package/lib/MerapiClient.d.ts +22 -7
  6. package/lib/MerapiClient.d.ts.map +1 -1
  7. package/lib/MerapiClient.js +160 -58
  8. package/lib/MerapiClient.js.map +1 -1
  9. package/lib/index.d.ts +1 -0
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.js.map +1 -1
  12. package/lib/models/cashout/CashoutLimits.d.ts +9 -0
  13. package/lib/models/cashout/CashoutLimits.d.ts.map +1 -0
  14. package/lib/models/cashout/{CashCode.js → CashoutLimits.js} +1 -1
  15. package/lib/models/cashout/CashoutLimits.js.map +1 -0
  16. package/lib/models/cashout/{ConfirmSecureWordResponse.d.ts → CreateCashoutResponse.d.ts} +2 -2
  17. package/lib/models/cashout/CreateCashoutResponse.d.ts.map +1 -0
  18. package/lib/models/{wac/CashCode.js → cashout/CreateCashoutResponse.js} +1 -1
  19. package/lib/models/cashout/CreateCashoutResponse.js.map +1 -0
  20. package/package.json +1 -1
  21. package/src/CashoutClient.ts +14 -8
  22. package/src/MerapiClient.ts +237 -72
  23. package/src/index.ts +1 -0
  24. package/src/models/cashout/CashoutLimits.ts +8 -0
  25. package/src/models/cashout/{ConfirmSecureWordResponse.ts → CreateCashoutResponse.ts} +1 -1
  26. package/lib/data/CashoutClient.d.ts +0 -23
  27. package/lib/data/CashoutClient.d.ts.map +0 -1
  28. package/lib/data/CashoutClient.js +0 -88
  29. package/lib/data/CashoutClient.js.map +0 -1
  30. package/lib/data/DoraApiClient.d.ts +0 -30
  31. package/lib/data/DoraApiClient.d.ts.map +0 -1
  32. package/lib/data/DoraApiClient.js +0 -34
  33. package/lib/data/DoraApiClient.js.map +0 -1
  34. package/lib/data/HttpClient.d.ts +0 -28
  35. package/lib/data/HttpClient.d.ts.map +0 -1
  36. package/lib/data/HttpClient.js +0 -69
  37. package/lib/data/HttpClient.js.map +0 -1
  38. package/lib/data/MerapiClient.d.ts +0 -81
  39. package/lib/data/MerapiClient.d.ts.map +0 -1
  40. package/lib/data/MerapiClient.js +0 -122
  41. package/lib/data/MerapiClient.js.map +0 -1
  42. package/lib/data/WacClient.d.ts +0 -36
  43. package/lib/data/WacClient.d.ts.map +0 -1
  44. package/lib/data/WacClient.js +0 -87
  45. package/lib/data/WacClient.js.map +0 -1
  46. package/lib/models/cashout/CashCode.d.ts +0 -14
  47. package/lib/models/cashout/CashCode.d.ts.map +0 -1
  48. package/lib/models/cashout/CashCode.js.map +0 -1
  49. package/lib/models/cashout/ConfirmSecureWordResponse.d.ts.map +0 -1
  50. package/lib/models/cashout/ConfirmSecureWordResponse.js +0 -3
  51. package/lib/models/cashout/ConfirmSecureWordResponse.js.map +0 -1
  52. package/lib/models/wac/Atm.d.ts +0 -19
  53. package/lib/models/wac/Atm.d.ts.map +0 -1
  54. package/lib/models/wac/Atm.js +0 -3
  55. package/lib/models/wac/Atm.js.map +0 -1
  56. package/lib/models/wac/CashCode.d.ts +0 -14
  57. package/lib/models/wac/CashCode.d.ts.map +0 -1
  58. package/lib/models/wac/CashCode.js.map +0 -1
  59. /package/lib/models/cashout/{CashOutRequest.d.ts → CashoutRequest.d.ts} +0 -0
  60. /package/lib/models/cashout/{CashOutRequest.d.ts.map → CashoutRequest.d.ts.map} +0 -0
  61. /package/lib/models/cashout/{CashOutRequest.js → CashoutRequest.js} +0 -0
  62. /package/lib/models/cashout/{CashOutRequest.js.map → CashoutRequest.js.map} +0 -0
@@ -1,4 +1,9 @@
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios'
2
+ import { getBundleId, getDeviceId, getUserAgent } from './device-info'
1
3
  import { BalanceResponse } from './models/Balance'
4
+ import { Atm } from './models/cashout/Atm'
5
+ import { CashoutRequest } from './models/cashout/CashoutRequest'
6
+ import { CreateCashoutResponse } from './models/cashout/CreateCashoutResponse'
2
7
  import { FeatureFlags } from './models/FeatureFlags'
3
8
  import {
4
9
  ICreditCardMultisigWallet,
@@ -7,11 +12,8 @@ import {
7
12
  import { ITokenInfo } from './models/ITokenInfo'
8
13
  import { ITransaction } from './models/ITransaction'
9
14
  import { IUser } from './models/IUser'
10
- import { getBundleId, getDeviceId, getUserAgent } from './device-info'
11
- import { HttpClient } from './HttpClient'
12
15
  import ResponseWrapper from './models/ResponseWrapper'
13
-
14
- type Headers = { [key: string]: string }
16
+ import { CashoutLimits } from './models/cashout/CashoutLimits'
15
17
 
16
18
  type AuthTokenProvider = () => Promise<string | null>
17
19
 
@@ -25,57 +27,80 @@ type Response<T> = {
25
27
  }
26
28
 
27
29
  export class MerapiClient {
28
- http: HttpClient
29
- headers: Headers = {
30
- 'Content-Type': 'application/json',
31
- Accept: 'application/json'
32
- }
30
+ http: AxiosInstance
31
+
32
+ private deviceId?: string
33
+ private userAgent?: string
34
+ private bundleId?: string
35
+
33
36
  afterRequestCallback?: (
34
37
  responseBody: any,
35
- req: globalThis.Response
38
+ response: AxiosResponse
36
39
  ) => void | Promise<void>
40
+
37
41
  authTokenProvider?: AuthTokenProvider
38
42
 
39
43
  constructor(params: { baseUrl: string; clientId: string }) {
40
- this.http = new HttpClient(params.baseUrl, this.headers)
41
- this.headers['X-Client-Id'] = params.clientId
42
- this.http.setBeforeRequestCallback(async (req) => {
43
- if (!this.headers['X-Device-ID']) {
44
- this.headers['X-Device-ID'] = await getDeviceId()
45
- }
46
- if (!this.headers['User-Agent']) {
47
- this.headers['User-Agent'] = await getUserAgent()
48
- }
49
- if (!this.headers['X-Bundle-Id']) {
50
- this.headers['X-Bundle-Id'] = await getBundleId()
51
- }
52
- const authToken = await this.authTokenProvider?.call(null)
53
- if (authToken) {
54
- req.headers['Authorization'] = authToken
55
- }
44
+ this.http = axios.create({
45
+ baseURL: params.baseUrl,
46
+ timeout: 30 * 1000,
47
+ headers: {
48
+ 'Content-Type': 'application/json',
49
+ Accept: 'application/json',
50
+ 'X-Client-Id': params.clientId
51
+ },
52
+ validateStatus: () => true
56
53
  })
57
- this.http.setAfterRequestCallback(async (res) => {
58
- if (!res.ok) {
59
- const body = await res.json().catch((e) => null)
60
- this.afterRequestCallback?.call(null, body, res)
61
- throw new Error(
62
- body?.error?.server_message ||
63
- body?.error?.code ||
64
- res.statusText
65
- )
54
+
55
+ this.http.interceptors.request.use(
56
+ async (config) => {
57
+ config.headers = config.headers ?? {}
58
+
59
+ if (!this.deviceId) this.deviceId = await getDeviceId()
60
+ if (!this.userAgent) this.userAgent = await getUserAgent()
61
+ if (!this.bundleId) this.bundleId = await getBundleId()
62
+
63
+ const token = await this.authTokenProvider?.()
64
+
65
+ if (token) config.headers.Authorization = token
66
+ if (this.deviceId) config.headers['X-Device-ID'] = this.deviceId
67
+ if (this.userAgent)
68
+ config.headers['User-Agent'] = this.userAgent
69
+ if (this.bundleId) config.headers['X-Bundle-Id'] = this.bundleId
70
+
71
+ return config
72
+ },
73
+ (error) => Promise.reject(error)
74
+ )
75
+
76
+ this.http.interceptors.response.use(
77
+ (response) => {
78
+ const body = response.data
79
+
80
+ this.afterRequestCallback?.call(null, body, response)
81
+
82
+ const errorMessage =
83
+ body?.error?.server_message || body?.error?.code
84
+ if (errorMessage) {
85
+ return Promise.reject(new Error(errorMessage))
86
+ }
87
+ return response
88
+ },
89
+ (error) => {
90
+ return Promise.reject(error)
66
91
  }
67
- })
92
+ )
68
93
  }
69
94
 
70
95
  setAuthTokenProvider(provider: AuthTokenProvider) {
71
96
  this.authTokenProvider = provider
72
97
  }
73
98
 
74
- generateLoginCode = (params: {
99
+ generateLoginCode = async (params: {
75
100
  contact: string
76
101
  password?: string
77
102
  }): Promise<void> => {
78
- return this.http.post('/wallet/login/code', params)
103
+ await this.http.post('/wallet/login/code', params)
79
104
  }
80
105
 
81
106
  confirmLoginCode = async (params: {
@@ -84,16 +109,15 @@ export class MerapiClient {
84
109
  }): Promise<{
85
110
  sessionKey: string
86
111
  }> => {
87
- const result: ResponseWrapper<{ sessionKey: string }> =
88
- await this.http.post<Response<{ sessionKey: string }>>(
89
- '/wallet/login/confirm',
90
- params
91
- )
92
- return result.data
112
+ return this.http
113
+ .post<
114
+ Response<{ sessionKey: string }>
115
+ >('/wallet/login/confirm', params)
116
+ .then((res) => res.data.data)
93
117
  }
94
118
 
95
- getCurrentUser = (): Promise<IUser> => {
96
- return this.http.get('/wallet/users/me')
119
+ getCurrentUser = async (): Promise<IUser> => {
120
+ return this.http.get<IUser>('/wallet/users/me').then((res) => res.data)
97
121
  }
98
122
 
99
123
  getBalances = (
@@ -102,9 +126,11 @@ export class MerapiClient {
102
126
  tokenAddress: string | null
103
127
  }[]
104
128
  ): Promise<BalanceResponse[]> => {
105
- return this.http.post(`/wallet/blockchain/${address}/get-balance`, {
106
- tokens
107
- })
129
+ return this.http
130
+ .post(`/wallet/blockchain/${address}/get-balance`, {
131
+ tokens
132
+ })
133
+ .then((res) => res.data)
108
134
  }
109
135
 
110
136
  setUserPublicAddress = async (params: { address: string }) => {
@@ -112,7 +138,9 @@ export class MerapiClient {
112
138
  }
113
139
 
114
140
  getDefaultTokens = (): Promise<ITokenInfo[]> => {
115
- return this.http.get(`/wallet/blockchain/tokens`)
141
+ return this.http
142
+ .get<ITokenInfo[]>(`/wallet/blockchain/tokens`)
143
+ .then((res) => res.data)
116
144
  }
117
145
 
118
146
  createMultisigWallet = (params: {
@@ -120,7 +148,9 @@ export class MerapiClient {
120
148
  signers: string[]
121
149
  threshold: number
122
150
  }): Promise<IGeneralMultisigWallet> => {
123
- return this.http.post('/wallet/wallets', params)
151
+ return this.http
152
+ .post<IGeneralMultisigWallet>('/wallet/wallets', params)
153
+ .then((res) => res.data)
124
154
  }
125
155
 
126
156
  acceptMultisigWallet = async (walletId: string) => {
@@ -128,7 +158,9 @@ export class MerapiClient {
128
158
  }
129
159
 
130
160
  getMultisigWallets = (): Promise<IGeneralMultisigWallet[]> => {
131
- return this.http.get('/wallet/wallets')
161
+ return this.http
162
+ .get<IGeneralMultisigWallet[]>('/wallet/wallets')
163
+ .then((res) => res.data)
132
164
  }
133
165
 
134
166
  createMultisigTransaction = (params: {
@@ -139,49 +171,64 @@ export class MerapiClient {
139
171
  tokenAddress: string | null
140
172
  remark: string | null
141
173
  }): Promise<ITransaction> => {
142
- return this.http.post('/wallet/tx', params)
174
+ return this.http
175
+ .post<ITransaction>('/wallet/tx', params)
176
+ .then((res) => res.data)
143
177
  }
144
178
 
145
179
  getMultisigWalletTransactions = (
146
180
  walletId: string
147
181
  ): Promise<ITransaction[]> => {
148
- return this.http.get(`/wallet/wallets/${walletId}/tx`)
182
+ return this.http
183
+ .get<ITransaction[]>(`/wallet/wallets/${walletId}/tx`)
184
+ .then((res) => res.data)
149
185
  }
150
186
 
151
187
  getMultisigWalletTransaction = async (
152
188
  txId: string
153
189
  ): Promise<ITransaction> => {
154
- return this.http.get(`/wallet/tx/${txId}`)
190
+ return this.http
191
+ .get<ITransaction>(`/wallet/tx/${txId}`)
192
+ .then((res) => res.data)
155
193
  }
156
194
 
157
195
  addMultisigTxSignature = (
158
196
  txId: string,
159
197
  data: { txid: string; address: string; signature: string }
160
198
  ): Promise<ITransaction> => {
161
- return this.http.post(`/wallet/tx/${txId}/signature`, data)
199
+ return this.http
200
+ .post<ITransaction>(`/wallet/tx/${txId}/signature`, data)
201
+ .then((res) => res.data)
162
202
  }
163
203
 
164
204
  executeTransaction = (txId: string): Promise<ITransaction> => {
165
- return this.http.post(`/wallet/tx/${txId}/execute`, { txid: txId })
205
+ return this.http
206
+ .post<ITransaction>(`/wallet/tx/${txId}/execute`, { txid: txId })
207
+ .then((res) => res.data)
166
208
  }
167
209
 
168
- getCCWallet = (): Promise<ICreditCardMultisigWallet | null> => {
169
- return this.http.get('/wallet/ccwallet').then((wallet) => {
170
- if (wallet && Object.keys(wallet).length > 0) {
171
- return wallet as ICreditCardMultisigWallet
172
- }
173
- return null
174
- })
210
+ getCCWallet = async (): Promise<ICreditCardMultisigWallet | null> => {
211
+ const response =
212
+ await this.http.get<ICreditCardMultisigWallet>('/wallet/ccwallet')
213
+ const wallet = response.data
214
+ if (wallet && Object.keys(wallet).length > 0) {
215
+ return wallet as ICreditCardMultisigWallet
216
+ }
217
+ return null
175
218
  }
176
219
 
177
220
  getCCWalletTransactions = (walletId: string): Promise<ITransaction[]> => {
178
- return this.http.get(`/wallet/ccwallet/${walletId}/tx`)
221
+ return this.http
222
+ .get<ITransaction[]>(`/wallet/ccwallet/${walletId}/tx`)
223
+ .then((res) => res.data)
179
224
  }
180
225
 
181
226
  createCCWallet = (params: {
182
227
  pan: string
183
228
  }): Promise<ICreditCardMultisigWallet> => {
184
- return this.http.post('/wallet/ccwallet', params)
229
+ return this.http
230
+ .post<ICreditCardMultisigWallet>('/wallet/ccwallet', params)
231
+ .then((res) => res.data)
185
232
  }
186
233
 
187
234
  executePosTransaction = (params: {
@@ -192,15 +239,21 @@ export class MerapiClient {
192
239
  merchant: string
193
240
  confirmations?: number
194
241
  }): Promise<ITransaction> => {
195
- return this.http.post('/wallet/tx/pos', params)
242
+ return this.http
243
+ .post<ITransaction>('/wallet/tx/pos', params)
244
+ .then((res) => res.data)
196
245
  }
197
246
 
198
247
  getTokenInfo = async (tokenAddress: string): Promise<ITokenInfo | null> => {
199
- return this.http.get(`/wallet/blockchain/${tokenAddress}/token-info`)
248
+ return this.http
249
+ .get<ITokenInfo | null>(
250
+ `/wallet/blockchain/${tokenAddress}/token-info`
251
+ )
252
+ .then((res) => res.data)
200
253
  }
201
254
 
202
255
  getFeatureFlags = async (): Promise<FeatureFlags> => {
203
- // TOOD: remove mock
256
+ // TODO: remove mock
204
257
  return {
205
258
  multisignatureWallet: true,
206
259
  paymentWallet: true
@@ -211,9 +264,121 @@ export class MerapiClient {
211
264
  walletId: string,
212
265
  hash: string
213
266
  ): Promise<ITransaction> => {
214
- return this.http.post(`/wallet/ccwallet/${walletId}/topup`, {
215
- walletId,
216
- hash
267
+ return this.http
268
+ .post<ITransaction>(`/wallet/ccwallet/${walletId}/topup`, {
269
+ walletId,
270
+ hash
271
+ })
272
+ .then((res) => res.data)
273
+ }
274
+
275
+ // cashout
276
+
277
+ getCashoutLimits = async (): Promise<CashoutLimits> => {
278
+ return this.http
279
+ .get<CashoutLimits>('/cashout/limits')
280
+ .then((res) => res.data)
281
+ }
282
+
283
+ getAtmList = async () => {
284
+ const response =
285
+ await this.http.get<ResponseWrapper<{ items: Atm[] }>>(
286
+ '/cashout/atm/list'
287
+ )
288
+ return response.data.data.items
289
+ }
290
+
291
+ sendVerificationWord = async (params: {
292
+ firstName: string
293
+ lastName: string
294
+ phoneNumber: string
295
+ }) => {
296
+ const data = new URLSearchParams()
297
+ data.append('first_name', params.firstName)
298
+ data.append('last_name', params.lastName)
299
+ data.append('phone_number', params.phoneNumber)
300
+ data.append('word_code', '1')
301
+ data.append('_t', new Date().getTime().toString())
302
+
303
+ await this.http.post('/cashout/pcode/verify', data, {
304
+ headers: {
305
+ 'Content-Type': 'application/x-www-form-urlencoded'
306
+ }
217
307
  })
218
308
  }
309
+
310
+ createCashoutRequest = async (params: {
311
+ atmId: string
312
+ amount: string
313
+ }): Promise<CreateCashoutResponse> => {
314
+ const data = new URLSearchParams()
315
+ data.append('atm_id', params.atmId)
316
+ data.append('amount', params.amount)
317
+ data.append('_t', new Date().getTime().toString())
318
+
319
+ const response = await this.http.post<
320
+ ResponseWrapper<{
321
+ items: [
322
+ {
323
+ secure_code: string
324
+ address: string
325
+ usd_amount: number
326
+ btc_amount: number
327
+ btc_whole_unit_price: number
328
+ }
329
+ ]
330
+ }>
331
+ >('/cashout/pcode', data, {
332
+ headers: {
333
+ 'Content-Type': 'application/x-www-form-urlencoded'
334
+ }
335
+ })
336
+ const result = response.data.data.items[0]
337
+
338
+ return {
339
+ secureCode: result.secure_code,
340
+ address: result.address,
341
+ usdAmount: result.usd_amount,
342
+ btcAmount: result.btc_amount,
343
+ btcWholeUnitPrice: result.btc_whole_unit_price
344
+ }
345
+ }
346
+
347
+ getCashOutRequest = async (cashCode: string): Promise<CashoutRequest> => {
348
+ const response = await this.http.get<
349
+ ResponseWrapper<{
350
+ items: [
351
+ {
352
+ pcode: null
353
+ status: 'A' | string
354
+ address: string
355
+ usd_amount: number
356
+ btc_amount: number
357
+ btc_whole_unit_price: number
358
+ expiration: string
359
+ atm_id: number
360
+ loc_description: string
361
+ loc_lat: number
362
+ loc_lon: number
363
+ }
364
+ ]
365
+ }>
366
+ >(`/cashout/pcode/${cashCode}`)
367
+ const result = response.data.data.items[0]
368
+
369
+ return {
370
+ id: cashCode,
371
+ pcode: result.pcode,
372
+ status: result.status as any,
373
+ address: result.address,
374
+ usdAmount: result.usd_amount,
375
+ btcAmount: result.btc_amount,
376
+ btcWholeUnitPrice: result.btc_whole_unit_price,
377
+ expiration: result.expiration,
378
+ atmId: result.atm_id,
379
+ locDescription: result.loc_description,
380
+ locLat: result.loc_lat,
381
+ locLon: result.loc_lon
382
+ }
383
+ }
219
384
  }
package/src/index.ts CHANGED
@@ -33,4 +33,5 @@ export { CashoutClient } from './CashoutClient'
33
33
  export { Atm } from './models/cashout/Atm'
34
34
  export { CashoutStatus } from './models/cashout/CashoutStatus'
35
35
  export { CashoutRequest } from './models/cashout/CashoutRequest'
36
+ export { CreateCashoutResponse } from './models/cashout/CreateCashoutResponse'
36
37
  export * as crypto from './crypto'
@@ -0,0 +1,8 @@
1
+ export interface CashoutLimits {
2
+ minAmount: number
3
+ maxAmount: number
4
+ maxAmountVerified: number
5
+ yearSummaryAmount: number
6
+ yearSummaryAmountVerified: number
7
+ verified: boolean
8
+ }
@@ -1,4 +1,4 @@
1
- export interface ConfirmSecureWordResponse {
1
+ export interface CreateCashoutResponse {
2
2
  secureCode: string
3
3
  address: string
4
4
  usdAmount: number
@@ -1,23 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { Atm } from '../models/cashout/Atm';
3
- import { CashoutRequest } from '../models/cashout/CashoutRequest';
4
- import { ConfirmSecureWordResponse } from '../models/cashout/ConfirmSecureWordResponse';
5
- export declare class CashoutClient {
6
- http: AxiosInstance;
7
- constructor();
8
- setAuthToken(sessionKey: string): void;
9
- guestLogin: () => Promise<string>;
10
- getAtmList: () => Promise<Atm[]>;
11
- sendVerificationWord: (params: {
12
- firstName: string;
13
- lastName: string;
14
- phoneNumber: string;
15
- }) => Promise<void>;
16
- confirmVerificationWord: (params: {
17
- atmId: string;
18
- amount: string;
19
- verificationCode: string;
20
- }) => Promise<ConfirmSecureWordResponse>;
21
- getCashOutRequest: (cashCode: string) => Promise<CashoutRequest>;
22
- }
23
- //# sourceMappingURL=CashoutClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CashoutClient.d.ts","sourceRoot":"","sources":["../../src/data/CashoutClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAA;AAEvF,qBAAa,aAAa;IACtB,IAAI,EAAE,aAAa,CAAA;;IA6BnB,YAAY,CAAC,UAAU,EAAE,MAAM;IAI/B,UAAU,wBAQT;IAED,UAAU,uBAMT;IAED,oBAAoB,GAAU,QAAQ;QAClC,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QAChB,WAAW,EAAE,MAAM,CAAA;KACtB,mBASA;IAED,uBAAuB,GAAU,QAAQ;QACrC,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QACd,gBAAgB,EAAE,MAAM,CAAA;KAC3B,KAAG,OAAO,CAAC,yBAAyB,CAAC,CA6BrC;IAED,iBAAiB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,cAAc,CAAC,CAoCpE;CACJ"}
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CashoutClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class CashoutClient {
9
- constructor() {
10
- this.guestLogin = async () => {
11
- const response = await this.http.post('/wac/guest/login');
12
- const sessionKey = await response.data.data.sessionKey;
13
- this.http.defaults.headers.common['Authorization'] = sessionKey;
14
- return sessionKey;
15
- };
16
- this.getAtmList = async () => {
17
- const response = await this.http.get('/wac/atm/list');
18
- return response.data.data.items;
19
- };
20
- this.sendVerificationWord = async (params) => {
21
- const data = new URLSearchParams();
22
- data.append('first_name', params.firstName);
23
- data.append('last_name', params.lastName);
24
- data.append('phone_number', params.phoneNumber);
25
- data.append('word_code', '1');
26
- data.append('_t', new Date().getTime().toString());
27
- await this.http.post('/wac/pcode/verify', data);
28
- };
29
- this.confirmVerificationWord = async (params) => {
30
- const data = new URLSearchParams();
31
- data.append('atm_id', params.amount);
32
- data.append('amount', params.amount);
33
- data.append('verification_code', params.verificationCode);
34
- data.append('_t', new Date().getTime().toString());
35
- const response = await this.http.post('/wac/pcode', data);
36
- const result = response.data.data.items[0];
37
- return {
38
- secureCode: result.secure_code,
39
- address: result.address,
40
- usdAmount: result.usd_amount,
41
- btcAmount: result.btc_amount,
42
- btcWholeUnitPrice: result.btc_whole_unit_price
43
- };
44
- };
45
- this.getCashOutRequest = async (cashCode) => {
46
- const response = await this.http.get(`/wac/pcode/${cashCode}`);
47
- const result = response.data.data.items[0];
48
- return {
49
- id: cashCode,
50
- pcode: result.pcode,
51
- status: result.status,
52
- address: result.address,
53
- usdAmount: result.usd_amount,
54
- btcAmount: result.btc_amount,
55
- btcWholeUnitPrice: result.btc_whole_unit_price,
56
- expiration: result.expiration,
57
- atmId: result.atm_id,
58
- locDescription: result.loc_description,
59
- locLat: result.loc_lat,
60
- locLon: result.loc_lon
61
- };
62
- };
63
- const baseURL = 'https://genmega.rampatm.net/wac';
64
- this.http = axios_1.default.create({
65
- baseURL,
66
- timeout: 30 * 1000,
67
- headers: {
68
- Accept: '*/*'
69
- },
70
- validateStatus: () => true
71
- });
72
- this.http.interceptors.response.use((response) => {
73
- const result = response.data;
74
- const errorMessage = result?.error?.server_message || result?.error?.code;
75
- if (errorMessage) {
76
- return Promise.reject(new Error(errorMessage));
77
- }
78
- return response;
79
- }, (error) => {
80
- return Promise.reject(error);
81
- });
82
- }
83
- setAuthToken(sessionKey) {
84
- this.http.defaults.headers.common['Authorization'] = sessionKey;
85
- }
86
- }
87
- exports.CashoutClient = CashoutClient;
88
- //# sourceMappingURL=CashoutClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CashoutClient.js","sourceRoot":"","sources":["../../src/data/CashoutClient.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4C;AAM5C,MAAa,aAAa;IAGtB;QA+BA,eAAU,GAAG,KAAK,IAAI,EAAE;YACpB,MAAM,QAAQ,GACV,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAChB,kBAAkB,CACrB,CAAA;YACL,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAA;YACtD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,UAAU,CAAA;YAC/D,OAAO,UAAU,CAAA;QACrB,CAAC,CAAA;QAED,eAAU,GAAG,KAAK,IAAI,EAAE;YACpB,MAAM,QAAQ,GACV,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CACf,eAAe,CAClB,CAAA;YACL,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAA;QACnC,CAAC,CAAA;QAED,yBAAoB,GAAG,KAAK,EAAE,MAI7B,EAAE,EAAE;YACD,MAAM,IAAI,GAA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AAM,GAAG,QAAQ,CAAC,IAAI,CAAA;YAC5B,MAAM,YAAY,GACd,MAAM,EAAE,KAAK,EAAE,cAAc,IAAI,MAAM,EAAE,KAAK,EAAE,IAAI,CAAA;YACxD,IAAI,YAAY,EAAE,CAAC;gBACf,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;YAClD,CAAC;YACD,OAAO,QAAQ,CAAA;QACnB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACN,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC,CACJ,CAAA;IACL,CAAC;IAED,YAAY,CAAC,UAAkB;QAC3B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,UAAU,CAAA;IACnE,CAAC;CA2GJ;AA3ID,sCA2IC"}
@@ -1,30 +0,0 @@
1
- import { ERC20Transaction, NativeTransaction } from '../models/Transaction';
2
- import { HttpClient } from './HttpClient';
3
- type Headers = {
4
- [key: string]: string;
5
- };
6
- export declare class DoraApiClient {
7
- http: HttpClient;
8
- headers: Headers;
9
- constructor();
10
- getTransactions: (address: string, params?: {
11
- offset: number;
12
- size: number;
13
- }) => Promise<{
14
- data: NativeTransaction[];
15
- totalCount: number;
16
- pageSize: number;
17
- offset: number;
18
- }>;
19
- getERC20Transactions: (address: string, contract: string, params?: {
20
- offset: number;
21
- size: number;
22
- }) => Promise<{
23
- data: ERC20Transaction[];
24
- totalCount: number;
25
- pageSize: number;
26
- offset: number;
27
- }>;
28
- }
29
- export {};
30
- //# sourceMappingURL=DoraApiClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DoraApiClient.d.ts","sourceRoot":"","sources":["../../src/data/DoraApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,KAAK,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAExC,qBAAa,aAAa;IACtB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAGf;;IAOD,eAAe,GACX,SAAS,MAAM,EACf,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAC1C,OAAO,CAAC;QACP,IAAI,EAAE,iBAAiB,EAAE,CAAA;QACzB,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAC,CAUD;IAED,oBAAoB,GAChB,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAC1C,OAAO,CAAC;QACP,IAAI,EAAE,gBAAgB,EAAE,CAAA;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAC,CAUD;CACJ"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DoraApiClient = void 0;
4
- const HttpClient_1 = require("./HttpClient");
5
- class DoraApiClient {
6
- constructor() {
7
- this.headers = {
8
- 'Content-Type': 'application/json',
9
- Accept: 'application/json'
10
- };
11
- this.getTransactions = (address, params) => {
12
- if (!params) {
13
- params = {
14
- offset: 0,
15
- size: 1000
16
- };
17
- }
18
- return this.http.get(`/account/txlist/${address}?offset=${params.offset}&pageSize=${params.size}`);
19
- };
20
- this.getERC20Transactions = (address, contract, params) => {
21
- if (!params) {
22
- params = {
23
- offset: 0,
24
- size: 1000
25
- };
26
- }
27
- return this.http.get(`/account/txlist/erc20/${address}?contract=${contract}?offset=${params.offset}&pageSize=${params.size}`);
28
- };
29
- const doraUrl = 'https://dora.testnet.ethpar.net/api';
30
- this.http = new HttpClient_1.HttpClient(doraUrl, this.headers);
31
- }
32
- }
33
- exports.DoraApiClient = DoraApiClient;
34
- //# sourceMappingURL=DoraApiClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DoraApiClient.js","sourceRoot":"","sources":["../../src/data/DoraApiClient.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAIzC,MAAa,aAAa;IAOtB;QALA,YAAO,GAAY;YACf,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;SAC7B,CAAA;QAOD,oBAAe,GAAG,CACd,OAAe,EACf,MAAyC,EAM1C,EAAE;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,MAAM,GAAG;oBACL,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,IAAI;iBACb,CAAA;YACL,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAChB,mBAAmB,OAAO,WAAW,MAAM,CAAC,MAAM,aAAa,MAAM,CAAC,IAAI,EAAE,CAC/E,CAAA;QACL,CAAC,CAAA;QAED,yBAAoB,GAAG,CACnB,OAAe,EACf,QAAgB,EAChB,MAAyC,EAM1C,EAAE;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,MAAM,GAAG;oBACL,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,IAAI;iBACb,CAAA;YACL,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAChB,yBAAyB,OAAO,aAAa,QAAQ,WAAW,MAAM,CAAC,MAAM,aAAa,MAAM,CAAC,IAAI,EAAE,CAC1G,CAAA;QACL,CAAC,CAAA;QA3CG,MAAM,OAAO,GAAG,qCAAqC,CAAA;QACrD,IAAI,CAAC,IAAI,GAAG,IAAI,uBAAU,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACrD,CAAC;CA0CJ;AApDD,sCAoDC"}