@myx-trade/sdk 0.1.205 → 0.1.207

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 CHANGED
@@ -1640,6 +1640,7 @@ declare class Account {
1640
1640
  referrer: string;
1641
1641
  totalReferralRebatePct: number;
1642
1642
  referrerRebatePct: number;
1643
+ nonce: string;
1643
1644
  }, signature: string): Promise<{
1644
1645
  code: number;
1645
1646
  data: any;
package/dist/index.d.ts CHANGED
@@ -1640,6 +1640,7 @@ declare class Account {
1640
1640
  referrer: string;
1641
1641
  totalReferralRebatePct: number;
1642
1642
  referrerRebatePct: number;
1643
+ nonce: string;
1643
1644
  }, signature: string): Promise<{
1644
1645
  code: number;
1645
1646
  data: any;
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.205",
1810
+ version: "0.1.207",
1811
1811
  private: false,
1812
1812
  publishConfig: {
1813
1813
  access: "public"
@@ -21293,18 +21293,22 @@ var Account = class {
21293
21293
  }
21294
21294
  }
21295
21295
  async getAccountVipInfo(chainId, address) {
21296
+ const config = this.configManager.getConfig();
21296
21297
  const contractAddress = getContractAddressByChainId(chainId);
21297
21298
  const provider = await getJSONProvider(chainId);
21298
- const dataProviderContract = new import_ethers26.ethers.Contract(
21299
- contractAddress.DATA_PROVIDER,
21299
+ const brokerContract = new import_ethers26.ethers.Contract(
21300
+ config.brokerAddress,
21300
21301
  Broker_default,
21301
21302
  provider
21302
21303
  );
21304
+ const latestBlock = await provider.getBlock("latest");
21305
+ const deadline = (latestBlock?.timestamp ?? (0, import_dayjs3.default)().unix()) + 60 * 5;
21303
21306
  try {
21304
- const accountVipInfo = await dataProviderContract.userFeeData(address);
21307
+ const accountVipInfo = await brokerContract.userFeeData(address);
21308
+ const nonce = await brokerContract.userNonces(address);
21305
21309
  return {
21306
21310
  code: 0,
21307
- data: accountVipInfo
21311
+ data: { ...accountVipInfo, nonce: nonce.toString(), deadline }
21308
21312
  };
21309
21313
  } catch (error) {
21310
21314
  return {
@@ -21347,9 +21351,21 @@ var Account = class {
21347
21351
  Broker_default,
21348
21352
  config.signer
21349
21353
  );
21354
+ const nonce = await brokerContract.userNonces(address);
21355
+ if (nonce.toString() !== params.nonce.toString()) {
21356
+ throw new MyxSDKError(
21357
+ "REQUEST_FAILED" /* RequestFailed */,
21358
+ "Invalid nonce, please try again"
21359
+ );
21360
+ }
21361
+ if (deadline < (0, import_dayjs3.default)().unix()) {
21362
+ throw new MyxSDKError(
21363
+ "REQUEST_FAILED" /* RequestFailed */,
21364
+ "Invalid deadline, please try again"
21365
+ );
21366
+ }
21350
21367
  try {
21351
- const nonce = await config.signer?.getNonce();
21352
- const rs = await brokerContract.setUserFeeData([address, nonce, deadline, [
21368
+ const rs = await brokerContract.setUserFeeData([address, params.nonce, deadline, [
21353
21369
  params.tier,
21354
21370
  params.referrer,
21355
21371
  params.totalReferralRebatePct,
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.205",
1734
+ version: "0.1.207",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -21217,18 +21217,22 @@ var Account = class {
21217
21217
  }
21218
21218
  }
21219
21219
  async getAccountVipInfo(chainId, address) {
21220
+ const config = this.configManager.getConfig();
21220
21221
  const contractAddress = getContractAddressByChainId(chainId);
21221
21222
  const provider = await getJSONProvider(chainId);
21222
- const dataProviderContract = new ethers8.Contract(
21223
- contractAddress.DATA_PROVIDER,
21223
+ const brokerContract = new ethers8.Contract(
21224
+ config.brokerAddress,
21224
21225
  Broker_default,
21225
21226
  provider
21226
21227
  );
21228
+ const latestBlock = await provider.getBlock("latest");
21229
+ const deadline = (latestBlock?.timestamp ?? dayjs3().unix()) + 60 * 5;
21227
21230
  try {
21228
- const accountVipInfo = await dataProviderContract.userFeeData(address);
21231
+ const accountVipInfo = await brokerContract.userFeeData(address);
21232
+ const nonce = await brokerContract.userNonces(address);
21229
21233
  return {
21230
21234
  code: 0,
21231
- data: accountVipInfo
21235
+ data: { ...accountVipInfo, nonce: nonce.toString(), deadline }
21232
21236
  };
21233
21237
  } catch (error) {
21234
21238
  return {
@@ -21271,9 +21275,21 @@ var Account = class {
21271
21275
  Broker_default,
21272
21276
  config.signer
21273
21277
  );
21278
+ const nonce = await brokerContract.userNonces(address);
21279
+ if (nonce.toString() !== params.nonce.toString()) {
21280
+ throw new MyxSDKError(
21281
+ "REQUEST_FAILED" /* RequestFailed */,
21282
+ "Invalid nonce, please try again"
21283
+ );
21284
+ }
21285
+ if (deadline < dayjs3().unix()) {
21286
+ throw new MyxSDKError(
21287
+ "REQUEST_FAILED" /* RequestFailed */,
21288
+ "Invalid deadline, please try again"
21289
+ );
21290
+ }
21274
21291
  try {
21275
- const nonce = await config.signer?.getNonce();
21276
- const rs = await brokerContract.setUserFeeData([address, nonce, deadline, [
21292
+ const rs = await brokerContract.setUserFeeData([address, params.nonce, deadline, [
21277
21293
  params.tier,
21278
21294
  params.referrer,
21279
21295
  params.totalReferralRebatePct,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.205",
3
+ "version": "0.1.207",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"