@rango-dev/queue-manager-rango-preset 0.1.11-next.2 → 0.1.11-next.4

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.
@@ -1,3 +1,3 @@
1
1
  import { RangoClient } from 'rango-sdk';
2
- export declare const httpService: RangoClient;
2
+ export declare const httpService: () => RangoClient;
3
3
  //# sourceMappingURL=httpService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,eAAO,MAAM,WAAW,aAGvB,CAAC"}
1
+ {"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAKxC,eAAO,MAAM,WAAW,mBAIvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/queue-manager-rango-preset",
3
- "version": "0.1.11-next.2",
3
+ "version": "0.1.11-next.4",
4
4
  "license": "MIT",
5
5
  "module": "dist/queue-manager-rango-preset.esm.js",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,7 @@ async function checkTransactionStatus({
42
42
  let status: TransactionStatusResponse | null = null;
43
43
  try {
44
44
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
- status = await httpService.checkStatus({
45
+ status = await httpService().checkStatus({
46
46
  requestId: swap.requestId,
47
47
  txId: txId!,
48
48
  step: currentStep.id,
@@ -177,7 +177,7 @@ async function checkApprovalStatus({
177
177
  const currentStep = getCurrentStep(swap)!;
178
178
  let isApproved = false;
179
179
  try {
180
- const response = await httpService.checkApproval(
180
+ const response = await httpService().checkApproval(
181
181
  swap.requestId,
182
182
  currentStep.executedTransactionId || ''
183
183
  );
@@ -69,7 +69,7 @@ export async function createTransaction(
69
69
  // Getting transcation from server.
70
70
 
71
71
  const { transaction } = await throwOnOK(
72
- httpService.createTransaction(request)
72
+ httpService().createTransaction(request)
73
73
  );
74
74
 
75
75
  if (transaction) {
package/src/configs.ts ADDED
@@ -0,0 +1,26 @@
1
+ export interface Configs {
2
+ API_KEY: string;
3
+ }
4
+
5
+ // this API key is limited and
6
+ // it is only for test purpose
7
+ const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
8
+
9
+ let configs: Configs = {
10
+ API_KEY: RANGO_PUBLIC_API_KEY,
11
+ };
12
+
13
+ export function getConfig(name: keyof Configs) {
14
+ return configs[name];
15
+ }
16
+
17
+ export function setConfig(name: keyof Configs, value: any) {
18
+ configs[name] = value;
19
+
20
+ return value;
21
+ }
22
+
23
+ export function initConfig(nextConfigs: Configs) {
24
+ configs = structuredClone(nextConfigs);
25
+ return configs;
26
+ }
package/src/constants.ts CHANGED
@@ -1,6 +1,3 @@
1
- export const RANGO_DAPP_API_KEY = process.env.REACT_APP_API_KEY;
2
- export const RANGO_DAPP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
3
-
4
1
  export const ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES =
5
2
  'Waiting for other swaps to complete';
6
3
  export const ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
package/src/helpers.ts CHANGED
@@ -186,7 +186,8 @@ export function updateSwapStatus({
186
186
  : details;
187
187
  const walletType = getRelatedWalletOrNull(swap, currentStep!)?.walletType;
188
188
  swap.extraMessageSeverity = MessageSeverity.error;
189
- httpService
189
+
190
+ httpService()
190
191
  .reportFailure({
191
192
  requestId: swap.requestId,
192
193
  step: currentStep?.id || 1,
package/src/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { Configs, initConfig } from './configs';
2
+ import { SwapQueueDef } from './types';
3
+ import { swapQueueDef } from './queueDef';
4
+
1
5
  export { PrettyError, prettifyErrorMessage } from './shared-errors';
2
6
  export { SwapQueueContext, SwapStorage } from './types';
3
7
  export {
@@ -24,5 +28,9 @@ export {
24
28
  splitWalletNetwork,
25
29
  resetRunningSwapNotifsOnPageLoad,
26
30
  } from './helpers';
27
- export { swapQueueDef } from './queueDef';
28
31
  export { useMigration, useQueueManager } from './hooks';
32
+
33
+ export function makeQueueDefinition(configs: Configs): SwapQueueDef {
34
+ initConfig(configs);
35
+ return swapQueueDef;
36
+ }
@@ -1,7 +1,10 @@
1
1
  import { RangoClient } from 'rango-sdk';
2
- import { RANGO_DAPP_API_KEY, RANGO_DAPP_API_BASE_URL } from '../constants';
2
+ import { getConfig } from '../configs';
3
3
 
4
- export const httpService = new RangoClient(
5
- RANGO_DAPP_API_KEY || '',
6
- RANGO_DAPP_API_BASE_URL
7
- );
4
+ let rango: RangoClient | undefined = undefined;
5
+
6
+ export const httpService = () => {
7
+ if (rango) return rango;
8
+ rango = new RangoClient(getConfig('API_KEY'));
9
+ return rango;
10
+ };