@reyaxyz/sdk 0.106.11 → 0.106.13
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 +1 -1
- package/dist/config/index.js +1 -35
- package/dist/config/index.js.map +1 -1
- package/dist/types/config/index.d.ts +1 -5
- package/dist/types/config/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/config/index.ts +0 -40
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
package/dist/config/index.js
CHANGED
|
@@ -51,7 +51,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.
|
|
54
|
+
exports.getAlphaTermsModuleClient = exports.getTransactionModuleClient = exports.configureSDK = exports.getSdkEnvironment = exports.AlphaTermsModule = exports.TransactionModule = void 0;
|
|
55
55
|
var common_1 = require("@reyaxyz/common");
|
|
56
56
|
var TransactionModule = /** @class */ (function (_super) {
|
|
57
57
|
__extends(TransactionModule, _super);
|
|
@@ -110,36 +110,9 @@ var AlphaTermsModule = /** @class */ (function (_super) {
|
|
|
110
110
|
return AlphaTermsModule;
|
|
111
111
|
}(common_1.RestClient));
|
|
112
112
|
exports.AlphaTermsModule = AlphaTermsModule;
|
|
113
|
-
var ApiInteractionsModule = /** @class */ (function (_super) {
|
|
114
|
-
__extends(ApiInteractionsModule, _super);
|
|
115
|
-
function ApiInteractionsModule() {
|
|
116
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
117
|
-
}
|
|
118
|
-
ApiInteractionsModule.prototype.createSLOrder = function (accountId, marketId, isLong, stopPrice, signerWallet, nonce, signature) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
-
var uri;
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
uri = "/api/conditional-orders/sl/create-order";
|
|
123
|
-
return [2 /*return*/, this.post(uri, {}, {
|
|
124
|
-
accountId: accountId,
|
|
125
|
-
marketId: marketId,
|
|
126
|
-
isLong: isLong,
|
|
127
|
-
stopPrice: stopPrice,
|
|
128
|
-
signerWallet: signerWallet,
|
|
129
|
-
nonce: nonce,
|
|
130
|
-
signature: signature,
|
|
131
|
-
status: common_1.StopLossOrderStatus.PENDING,
|
|
132
|
-
})];
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
return ApiInteractionsModule;
|
|
137
|
-
}(common_1.RestClient));
|
|
138
|
-
exports.ApiInteractionsModule = ApiInteractionsModule;
|
|
139
113
|
// Internal state
|
|
140
114
|
var transactionModule = new TransactionModule(common_1.API_CLIENT_CONFIGS['test'].apiEndpoint);
|
|
141
115
|
var alphaTermsModule = new AlphaTermsModule(common_1.API_CLIENT_CONFIGS['test'].apiEndpoint);
|
|
142
|
-
var apiInteractionsModule = new ApiInteractionsModule(common_1.API_CLIENT_CONFIGS['test'].apiEndpoint);
|
|
143
116
|
var sdkEnv = 'test';
|
|
144
117
|
var getSdkEnvironment = function () {
|
|
145
118
|
return sdkEnv;
|
|
@@ -151,7 +124,6 @@ var configureSDK = function (environment) {
|
|
|
151
124
|
sdkEnv = environment;
|
|
152
125
|
transactionModule = new TransactionModule(config.apiEndpoint);
|
|
153
126
|
alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);
|
|
154
|
-
apiInteractionsModule = new ApiInteractionsModule(config.apiEndpoint);
|
|
155
127
|
};
|
|
156
128
|
exports.configureSDK = configureSDK;
|
|
157
129
|
var getTransactionModuleClient = function () {
|
|
@@ -166,10 +138,4 @@ var getAlphaTermsModuleClient = function () {
|
|
|
166
138
|
return alphaTermsModule;
|
|
167
139
|
};
|
|
168
140
|
exports.getAlphaTermsModuleClient = getAlphaTermsModuleClient;
|
|
169
|
-
var getApiInteractionsModule = function () {
|
|
170
|
-
if (!apiInteractionsModule)
|
|
171
|
-
throw new Error('SDK is not configured! Call configureSDK()');
|
|
172
|
-
return apiInteractionsModule;
|
|
173
|
-
};
|
|
174
|
-
exports.getApiInteractionsModule = getApiInteractionsModule;
|
|
175
141
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAYzB;IAAuC,qCAAU;IAAjD;;IAwCA,CAAC;IAvCO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;gBAEhC,GAAG,GAAG,uCAAuC,CAAC;gBACpD,uFAAuF;gBACvF,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,MAAM,EAAE,MAAM;wBACd,eAAe,iBAAA;wBACf,QAAQ,UAAA;qBACT,CACF,EAAC;;;KACH;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,A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OvB;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,yBAAyB,GAAG;IACvC,IAAI,CAAC,gBAAgB;QACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC","sourcesContent":["import {\n Address,\n API_CLIENT_CONFIGS,\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\ntype AlphaTermsData = {\n walletAddress: Address;\n link: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ) {\n const uri = `/api/transaction-gelato/executeGelato`;\n // const uri = `/api/transaction/execute`; //switch between Gelato and internal relayer\n return this.post<TransactionExecutionOutput>(\n uri,\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\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 AlphaTermsModule extends RestClient {\n async registerAlphaSignature(params: AlphaTermsData): Promise<void> {\n // Build formData object.\n const formData = new FormData();\n formData.append('walletAddress', params.walletAddress);\n formData.append('signedLink', params.link);\n\n const uri = '/api/tos/alpha-signatures';\n return this.post(uri, undefined, formData, undefined);\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\n\nlet sdkEnv: ServiceConfig['environment'] = 'test';\n\nexport const getSdkEnvironment = (): ServiceConfig['environment'] => {\n return sdkEnv;\n};\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n const config = API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n sdkEnv = environment;\n transactionModule = new TransactionModule(config.apiEndpoint);\n alphaTermsModule = new AlphaTermsModule(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 getAlphaTermsModuleClient = (): AlphaTermsModule => {\n if (!alphaTermsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return alphaTermsModule;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, RestClient, ServiceConfig, TransactionExecutionMetadata, TransactionExecutionOutput
|
|
1
|
+
import { Address, RestClient, ServiceConfig, TransactionExecutionMetadata, TransactionExecutionOutput } from '@reyaxyz/common';
|
|
2
2
|
export type TxData = {
|
|
3
3
|
to: string;
|
|
4
4
|
data: string;
|
|
@@ -16,13 +16,9 @@ export declare class TransactionModule extends RestClient {
|
|
|
16
16
|
export declare class AlphaTermsModule extends RestClient {
|
|
17
17
|
registerAlphaSignature(params: AlphaTermsData): Promise<void>;
|
|
18
18
|
}
|
|
19
|
-
export declare class ApiInteractionsModule extends RestClient {
|
|
20
|
-
createSLOrder(accountId: number, marketId: number, isLong: boolean, stopPrice: number, signerWallet: string, nonce: bigint, signature: string): Promise<StopLossOrder>;
|
|
21
|
-
}
|
|
22
19
|
export declare const getSdkEnvironment: () => ServiceConfig['environment'];
|
|
23
20
|
export declare const configureSDK: (environment: ServiceConfig['environment']) => void;
|
|
24
21
|
export declare const getTransactionModuleClient: () => TransactionModule;
|
|
25
22
|
export declare const getAlphaTermsModuleClient: () => AlphaTermsModule;
|
|
26
|
-
export declare const getApiInteractionsModule: () => ApiInteractionsModule;
|
|
27
23
|
export {};
|
|
28
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,UAAU,EACV,aAAa,EACb,4BAA4B,EAC5B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,UAAU,EACV,aAAa,EACb,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,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;IAelC,sBAAsB,CAC1B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;oBAGmB,OAAO;;CAYzC;AAED,qBAAa,gBAAiB,SAAQ,UAAU;IACxC,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CASpE;AAYD,eAAO,MAAM,iBAAiB,QAAO,aAAa,CAAC,aAAa,CAE/D,CAAC;AAEF,eAAO,MAAM,YAAY,gBACV,aAAa,CAAC,aAAa,CAAC,KACxC,IAKF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO,gBAI5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/sdk",
|
|
3
|
-
"version": "0.106.
|
|
3
|
+
"version": "0.106.13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@reyaxyz/common": "0.
|
|
32
|
+
"@reyaxyz/common": "0.159.0",
|
|
33
33
|
"bignumber.js": "^9.1.2",
|
|
34
34
|
"ethers": "6.9.0"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@8.3.1",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c03627efd9914e03fff856c5ab4c0113efd51bbe"
|
|
38
38
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
ServiceConfig,
|
|
6
6
|
TransactionExecutionMetadata,
|
|
7
7
|
TransactionExecutionOutput,
|
|
8
|
-
StopLossOrderStatus,
|
|
9
|
-
StopLossOrder,
|
|
10
8
|
} from '@reyaxyz/common';
|
|
11
9
|
|
|
12
10
|
export type TxData = {
|
|
@@ -73,34 +71,6 @@ export class AlphaTermsModule extends RestClient {
|
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
export class ApiInteractionsModule extends RestClient {
|
|
77
|
-
async createSLOrder(
|
|
78
|
-
accountId: number,
|
|
79
|
-
marketId: number,
|
|
80
|
-
isLong: boolean,
|
|
81
|
-
stopPrice: number,
|
|
82
|
-
signerWallet: string,
|
|
83
|
-
nonce: bigint,
|
|
84
|
-
signature: string,
|
|
85
|
-
) {
|
|
86
|
-
const uri = `/api/conditional-orders/sl/create-order`;
|
|
87
|
-
return this.post<StopLossOrder>(
|
|
88
|
-
uri,
|
|
89
|
-
{},
|
|
90
|
-
{
|
|
91
|
-
accountId: accountId,
|
|
92
|
-
marketId: marketId,
|
|
93
|
-
isLong: isLong,
|
|
94
|
-
stopPrice: stopPrice,
|
|
95
|
-
signerWallet: signerWallet,
|
|
96
|
-
nonce: nonce,
|
|
97
|
-
signature: signature,
|
|
98
|
-
status: StopLossOrderStatus.PENDING,
|
|
99
|
-
},
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
74
|
// Internal state
|
|
105
75
|
let transactionModule: TransactionModule = new TransactionModule(
|
|
106
76
|
API_CLIENT_CONFIGS['test'].apiEndpoint,
|
|
@@ -108,9 +78,6 @@ let transactionModule: TransactionModule = new TransactionModule(
|
|
|
108
78
|
let alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(
|
|
109
79
|
API_CLIENT_CONFIGS['test'].apiEndpoint,
|
|
110
80
|
);
|
|
111
|
-
let apiInteractionsModule: ApiInteractionsModule = new ApiInteractionsModule(
|
|
112
|
-
API_CLIENT_CONFIGS['test'].apiEndpoint,
|
|
113
|
-
);
|
|
114
81
|
|
|
115
82
|
let sdkEnv: ServiceConfig['environment'] = 'test';
|
|
116
83
|
|
|
@@ -125,7 +92,6 @@ export const configureSDK = (
|
|
|
125
92
|
sdkEnv = environment;
|
|
126
93
|
transactionModule = new TransactionModule(config.apiEndpoint);
|
|
127
94
|
alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);
|
|
128
|
-
apiInteractionsModule = new ApiInteractionsModule(config.apiEndpoint);
|
|
129
95
|
};
|
|
130
96
|
|
|
131
97
|
export const getTransactionModuleClient = (): TransactionModule => {
|
|
@@ -139,9 +105,3 @@ export const getAlphaTermsModuleClient = (): AlphaTermsModule => {
|
|
|
139
105
|
throw new Error('SDK is not configured! Call configureSDK()');
|
|
140
106
|
return alphaTermsModule;
|
|
141
107
|
};
|
|
142
|
-
|
|
143
|
-
export const getApiInteractionsModule = (): ApiInteractionsModule => {
|
|
144
|
-
if (!apiInteractionsModule)
|
|
145
|
-
throw new Error('SDK is not configured! Call configureSDK()');
|
|
146
|
-
return apiInteractionsModule;
|
|
147
|
-
};
|