@reyaxyz/sdk 0.152.6 → 0.152.8

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 CHANGED
@@ -6,5 +6,15 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-34.17%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-64.86%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-21.05%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-33.62%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-36.13%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-65.65%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-25.26%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-34.97%25-red.svg?style=flat) |
10
10
 
11
+ ## Environments
12
+
13
+ Supported environments are `production`, `staging`, `devnet`, `localmainnet`
14
+ and `localtestnet`. Choose an environment explicitly before using the clients,
15
+ for example `configureSDK('devnet')`.
16
+
17
+ The retired backend's `test` environment is no longer supported. Existing callers
18
+ must choose the intended active environment; unsupported names throw instead of
19
+ falling back or redirecting to another deployment. Devnet1 continues to use the
20
+ live reya-cronos chain (89346162) and its own API and WebSocket endpoints.
@@ -109,10 +109,12 @@ var GeneralRestModule = /** @class */ (function (_super) {
109
109
  }(common_1.RestClient));
110
110
  exports.GeneralRestModule = GeneralRestModule;
111
111
  // Internal state
112
- var transactionModule = new TransactionModule((0, common_1.getApiClientConfig)('test').apiEndpoint);
113
- var generalRestModule = new GeneralRestModule((0, common_1.getApiClientConfig)('test').apiEndpoint);
112
+ var transactionModule;
113
+ var generalRestModule;
114
114
  var config;
115
115
  var getSdkConfig = function () {
116
+ if (!config)
117
+ throw new Error('SDK is not configured! Call configureSDK()');
116
118
  return config;
117
119
  };
118
120
  exports.getSdkConfig = getSdkConfig;
@@ -130,7 +132,7 @@ var getTransactionModuleClient = function () {
130
132
  };
131
133
  exports.getTransactionModuleClient = getTransactionModuleClient;
132
134
  var getGeneralRestModuleClient = function () {
133
- if (!transactionModule)
135
+ if (!generalRestModule)
134
136
  throw new Error('SDK is not configured! Call configureSDK()');
135
137
  return generalRestModule;
136
138
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAOzB;IAAuC,qCAAU;IAAjD;;IAwCA,CAAC;IAvCO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;;4BAEvB,qBAAM,IAAI,CAAC,IAAI,CAC5B,qCAAqC,EACrC,EAAE,EACF;4BACE,MAAM,EAAE,MAAM;4BACd,eAAe,iBAAA;4BACf,QAAQ,UAAA;yBACT,CACF,EAAA;;wBARK,MAAM,GAAG,SAQd;wBAED,sBAAO,MAAM,EAAC;;;;KACf;IAEK,kDAAsB,GAA5B,UACE,eAAuB,EACvB,eAAuB,EACvB,aAAqB,EACrB,MAAc,EACd,OAAe,EACf,IAAY;;;;gBAEN,GAAG,GAAG,wBAAiB,eAAe,8BAA2B,CAAC;gBACxE,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,OAAO,EAAE,eAAe;wBACxB,eAAe,EAAE,aAAa;wBAC9B,MAAM,QAAA;wBACN,QAAQ,EAAE,OAAO;wBACjB,IAAI,EAAE,IAAI;qBACX,CACF,EAAC;;;KACH;IACH,wBAAC;AAAD,CAAC,AAxCD,CAAuC,mBAAU,GAwChD;AAxCY,8CAAiB;AA0C9B;IAAuC,qCAAU;IAAjD;;IAMA,CAAC;IALO,6CAAiB,GAAvB;;;gBACE,sBAAO,IAAI,CAAC,GAAG,CACb,2DAAoD,KAAK,CAAE,CAC5D,EAAC;;;KACH;IACH,wBAAC;AAAD,CAAC,AAND,CAAuC,mBAAU,GAMhD;AANY,8CAAiB;AAQ9B,iBAAiB;AACjB,IAAI,iBAAiB,GAAsB,IAAI,iBAAiB,CAC9D,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC,WAAW,CACvC,CAAC;AAEF,IAAI,iBAAiB,GAAsB,IAAI,iBAAiB,CAC9D,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC,WAAW,CACvC,CAAC;AAEF,IAAI,MAAqB,CAAC;AAEnB,IAAM,YAAY,GAAG;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEF,gCAAgC;AACzB,IAAM,YAAY,GAAG,UAC1B,WAAyC;IAEzC,MAAM,GAAG,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAAC;IACzC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9D,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAChE,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC","sourcesContent":["import {\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n CollateralWithHaircut,\n getApiClientConfig,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ): Promise<TransactionExecutionOutput> {\n const result = await this.post<TransactionExecutionOutput>(\n '/api/transaction-gelato/executeReya',\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n\n return result;\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class GeneralRestModule extends RestClient {\n async getCollateralInfo(): Promise<CollateralWithHaircut[]> {\n return this.get<CollateralWithHaircut[]>(\n `/api/tokens/available-collaterals/excluding-rusd/${false}`,\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\n getApiClientConfig('test').apiEndpoint,\n);\n\nlet generalRestModule: GeneralRestModule = new GeneralRestModule(\n getApiClientConfig('test').apiEndpoint,\n);\n\nlet config: ServiceConfig;\n\nexport const getSdkConfig = (): ServiceConfig => {\n return config;\n};\n\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n config = getApiClientConfig(environment);\n transactionModule = new TransactionModule(config.apiEndpoint);\n generalRestModule = new GeneralRestModule(config.apiEndpoint);\n};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n\nexport const getGeneralRestModuleClient = (): GeneralRestModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return generalRestModule;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,gBAGvB;AAEF,gCAAgC;AACzB,IAAM,YAAY,GAAG,UAC1B,WAAyC;IAEzC,MAAM,GAAG,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAAC;IACzC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9D,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAChE,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC","sourcesContent":["import {\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n CollateralWithHaircut,\n getApiClientConfig,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ): Promise<TransactionExecutionOutput> {\n const result = await this.post<TransactionExecutionOutput>(\n '/api/transaction-gelato/executeReya',\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n\n return result;\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class GeneralRestModule extends RestClient {\n async getCollateralInfo(): Promise<CollateralWithHaircut[]> {\n return this.get<CollateralWithHaircut[]>(\n `/api/tokens/available-collaterals/excluding-rusd/${false}`,\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule | undefined;\nlet generalRestModule: GeneralRestModule | undefined;\n\nlet config: ServiceConfig | undefined;\n\nexport const getSdkConfig = (): ServiceConfig => {\n if (!config) throw new Error('SDK is not configured! Call configureSDK()');\n return config;\n};\n\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n config = getApiClientConfig(environment);\n transactionModule = new TransactionModule(config.apiEndpoint);\n generalRestModule = new GeneralRestModule(config.apiEndpoint);\n};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n\nexport const getGeneralRestModuleClient = (): GeneralRestModule => {\n if (!generalRestModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return generalRestModule;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC,0BAA0B,CAAC;IAchC,sBAAsB,CAC1B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,E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CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.152.6",
3
+ "version": "0.152.8",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -27,17 +27,15 @@
27
27
  "test": "pnpm test:types && npx jest --silent",
28
28
  "test:coverage": "jest test --coverage",
29
29
  "generate:coverage-badges": "npx istanbul-badges-readme --silent",
30
- "test:spot-order": "npx ts-node scripts/test-spot-order.ts",
31
- "test:cancel-spot-order": "npx ts-node scripts/test-cancel-spot-order.ts",
32
30
  "test:types": "tsc -p tsconfig.test-types.json"
33
31
  },
34
32
  "dependencies": {
35
- "@reyaxyz/api-v2-sdk": "0.309.0",
36
- "@reyaxyz/common": "0.365.0",
33
+ "@reyaxyz/api-v2-sdk": "0.309.1",
34
+ "@reyaxyz/common": "0.365.2",
37
35
  "axios": "1.6.2",
38
36
  "bignumber.js": "9.1.2",
39
37
  "ethers": "6.17.0"
40
38
  },
41
39
  "packageManager": "pnpm@8.3.1",
42
- "gitHead": "8bef4d5aa630fab81e24fe4cf684c82bba19710a"
40
+ "gitHead": "f09c1b532eddac6cd1d4324d12a9b13cb989f608"
43
41
  }
@@ -63,17 +63,13 @@ export class GeneralRestModule extends RestClient {
63
63
  }
64
64
 
65
65
  // Internal state
66
- let transactionModule: TransactionModule = new TransactionModule(
67
- getApiClientConfig('test').apiEndpoint,
68
- );
66
+ let transactionModule: TransactionModule | undefined;
67
+ let generalRestModule: GeneralRestModule | undefined;
69
68
 
70
- let generalRestModule: GeneralRestModule = new GeneralRestModule(
71
- getApiClientConfig('test').apiEndpoint,
72
- );
73
-
74
- let config: ServiceConfig;
69
+ let config: ServiceConfig | undefined;
75
70
 
76
71
  export const getSdkConfig = (): ServiceConfig => {
72
+ if (!config) throw new Error('SDK is not configured! Call configureSDK()');
77
73
  return config;
78
74
  };
79
75
 
@@ -93,7 +89,7 @@ export const getTransactionModuleClient = (): TransactionModule => {
93
89
  };
94
90
 
95
91
  export const getGeneralRestModuleClient = (): GeneralRestModule => {
96
- if (!transactionModule)
92
+ if (!generalRestModule)
97
93
  throw new Error('SDK is not configured! Call configureSDK()');
98
94
  return generalRestModule;
99
95
  };