@myx-trade/sdk 0.1.210 → 0.1.212
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +37 -3
- package/dist/index.mjs +37 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1807,7 +1807,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1807
1807
|
// package.json
|
|
1808
1808
|
var package_default = {
|
|
1809
1809
|
name: "@myx-trade/sdk",
|
|
1810
|
-
version: "0.1.
|
|
1810
|
+
version: "0.1.212",
|
|
1811
1811
|
private: false,
|
|
1812
1812
|
publishConfig: {
|
|
1813
1813
|
access: "public"
|
|
@@ -20281,6 +20281,36 @@ var Utils = class {
|
|
|
20281
20281
|
};
|
|
20282
20282
|
}
|
|
20283
20283
|
}
|
|
20284
|
+
formatErrorMessage(error) {
|
|
20285
|
+
if (typeof error === "string") {
|
|
20286
|
+
return error;
|
|
20287
|
+
}
|
|
20288
|
+
if (error instanceof MyxSDKError) {
|
|
20289
|
+
return error.message;
|
|
20290
|
+
}
|
|
20291
|
+
if (error?.code === "ACTION_REJECTED" || error?.code === 4001 || error?.info?.error?.code === 4001 || typeof error?.message === "string" && (error.message.toLowerCase().includes("user rejected") || error.message.toLowerCase().includes("denied"))) {
|
|
20292
|
+
return "User Rejected";
|
|
20293
|
+
}
|
|
20294
|
+
if (error?.data) {
|
|
20295
|
+
const errorData = error.data;
|
|
20296
|
+
const selector = typeof errorData === "string" && errorData.startsWith("0x") ? errorData.slice(0, 10).toLowerCase() : null;
|
|
20297
|
+
if (selector) {
|
|
20298
|
+
const errorKey = Object.keys(customErrorMapping).find(
|
|
20299
|
+
(k) => k.toLowerCase() === selector
|
|
20300
|
+
);
|
|
20301
|
+
if (errorKey) {
|
|
20302
|
+
return customErrorMapping[errorKey];
|
|
20303
|
+
}
|
|
20304
|
+
}
|
|
20305
|
+
}
|
|
20306
|
+
if (error?.reason) {
|
|
20307
|
+
return error.reason;
|
|
20308
|
+
}
|
|
20309
|
+
if (error?.message) {
|
|
20310
|
+
return error.message;
|
|
20311
|
+
}
|
|
20312
|
+
return JSON.stringify(error);
|
|
20313
|
+
}
|
|
20284
20314
|
};
|
|
20285
20315
|
|
|
20286
20316
|
// src/manager/account/index.ts
|
|
@@ -21294,7 +21324,6 @@ var Account = class {
|
|
|
21294
21324
|
}
|
|
21295
21325
|
async getAccountVipInfo(chainId, address) {
|
|
21296
21326
|
const config = this.configManager.getConfig();
|
|
21297
|
-
const contractAddress = getContractAddressByChainId(chainId);
|
|
21298
21327
|
const provider = await getJSONProvider(chainId);
|
|
21299
21328
|
const brokerContract = new import_ethers26.ethers.Contract(
|
|
21300
21329
|
config.brokerAddress,
|
|
@@ -21303,9 +21332,14 @@ var Account = class {
|
|
|
21303
21332
|
);
|
|
21304
21333
|
const latestBlock = await provider.getBlock("latest");
|
|
21305
21334
|
const deadline = (latestBlock?.timestamp ?? (0, import_dayjs3.default)().unix()) + 60 * 5;
|
|
21335
|
+
this.logger.info("deadline-->", deadline);
|
|
21306
21336
|
try {
|
|
21337
|
+
this.logger.info("brokerContract-->", config.brokerAddress);
|
|
21338
|
+
this.logger.info("address-->", address);
|
|
21307
21339
|
const accountVipInfo = await brokerContract.userFeeData(address);
|
|
21340
|
+
this.logger.info("accountVipInfo-->", accountVipInfo);
|
|
21308
21341
|
const nonce = await brokerContract.userNonces(address);
|
|
21342
|
+
this.logger.info("nonce-->", nonce);
|
|
21309
21343
|
return {
|
|
21310
21344
|
code: 0,
|
|
21311
21345
|
data: { ...accountVipInfo, nonce: nonce.toString(), deadline }
|
|
@@ -21352,7 +21386,7 @@ var Account = class {
|
|
|
21352
21386
|
config.signer
|
|
21353
21387
|
);
|
|
21354
21388
|
const nonce = await brokerContract.userNonces(address);
|
|
21355
|
-
if (nonce.toString() !== params.nonce.toString()) {
|
|
21389
|
+
if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
|
|
21356
21390
|
throw new MyxSDKError(
|
|
21357
21391
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
21358
21392
|
"Invalid nonce, please try again"
|
package/dist/index.mjs
CHANGED
|
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1731
1731
|
// package.json
|
|
1732
1732
|
var package_default = {
|
|
1733
1733
|
name: "@myx-trade/sdk",
|
|
1734
|
-
version: "0.1.
|
|
1734
|
+
version: "0.1.212",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -20205,6 +20205,36 @@ var Utils = class {
|
|
|
20205
20205
|
};
|
|
20206
20206
|
}
|
|
20207
20207
|
}
|
|
20208
|
+
formatErrorMessage(error) {
|
|
20209
|
+
if (typeof error === "string") {
|
|
20210
|
+
return error;
|
|
20211
|
+
}
|
|
20212
|
+
if (error instanceof MyxSDKError) {
|
|
20213
|
+
return error.message;
|
|
20214
|
+
}
|
|
20215
|
+
if (error?.code === "ACTION_REJECTED" || error?.code === 4001 || error?.info?.error?.code === 4001 || typeof error?.message === "string" && (error.message.toLowerCase().includes("user rejected") || error.message.toLowerCase().includes("denied"))) {
|
|
20216
|
+
return "User Rejected";
|
|
20217
|
+
}
|
|
20218
|
+
if (error?.data) {
|
|
20219
|
+
const errorData = error.data;
|
|
20220
|
+
const selector = typeof errorData === "string" && errorData.startsWith("0x") ? errorData.slice(0, 10).toLowerCase() : null;
|
|
20221
|
+
if (selector) {
|
|
20222
|
+
const errorKey = Object.keys(customErrorMapping).find(
|
|
20223
|
+
(k) => k.toLowerCase() === selector
|
|
20224
|
+
);
|
|
20225
|
+
if (errorKey) {
|
|
20226
|
+
return customErrorMapping[errorKey];
|
|
20227
|
+
}
|
|
20228
|
+
}
|
|
20229
|
+
}
|
|
20230
|
+
if (error?.reason) {
|
|
20231
|
+
return error.reason;
|
|
20232
|
+
}
|
|
20233
|
+
if (error?.message) {
|
|
20234
|
+
return error.message;
|
|
20235
|
+
}
|
|
20236
|
+
return JSON.stringify(error);
|
|
20237
|
+
}
|
|
20208
20238
|
};
|
|
20209
20239
|
|
|
20210
20240
|
// src/manager/account/index.ts
|
|
@@ -21218,7 +21248,6 @@ var Account = class {
|
|
|
21218
21248
|
}
|
|
21219
21249
|
async getAccountVipInfo(chainId, address) {
|
|
21220
21250
|
const config = this.configManager.getConfig();
|
|
21221
|
-
const contractAddress = getContractAddressByChainId(chainId);
|
|
21222
21251
|
const provider = await getJSONProvider(chainId);
|
|
21223
21252
|
const brokerContract = new ethers8.Contract(
|
|
21224
21253
|
config.brokerAddress,
|
|
@@ -21227,9 +21256,14 @@ var Account = class {
|
|
|
21227
21256
|
);
|
|
21228
21257
|
const latestBlock = await provider.getBlock("latest");
|
|
21229
21258
|
const deadline = (latestBlock?.timestamp ?? dayjs3().unix()) + 60 * 5;
|
|
21259
|
+
this.logger.info("deadline-->", deadline);
|
|
21230
21260
|
try {
|
|
21261
|
+
this.logger.info("brokerContract-->", config.brokerAddress);
|
|
21262
|
+
this.logger.info("address-->", address);
|
|
21231
21263
|
const accountVipInfo = await brokerContract.userFeeData(address);
|
|
21264
|
+
this.logger.info("accountVipInfo-->", accountVipInfo);
|
|
21232
21265
|
const nonce = await brokerContract.userNonces(address);
|
|
21266
|
+
this.logger.info("nonce-->", nonce);
|
|
21233
21267
|
return {
|
|
21234
21268
|
code: 0,
|
|
21235
21269
|
data: { ...accountVipInfo, nonce: nonce.toString(), deadline }
|
|
@@ -21276,7 +21310,7 @@ var Account = class {
|
|
|
21276
21310
|
config.signer
|
|
21277
21311
|
);
|
|
21278
21312
|
const nonce = await brokerContract.userNonces(address);
|
|
21279
|
-
if (nonce.toString() !== params.nonce.toString()) {
|
|
21313
|
+
if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
|
|
21280
21314
|
throw new MyxSDKError(
|
|
21281
21315
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
21282
21316
|
"Invalid nonce, please try again"
|