@myx-trade/sdk 0.1.223 → 0.1.225

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
@@ -1648,7 +1648,7 @@ declare class Account {
1648
1648
  message: string;
1649
1649
  data?: undefined;
1650
1650
  }>;
1651
- setUserFeeData(address: string, deadline: number, params: {
1651
+ setUserFeeData(address: string, chainId: number, deadline: number, params: {
1652
1652
  tier: number;
1653
1653
  referrer: string;
1654
1654
  totalReferralRebatePct: number;
@@ -1718,7 +1718,7 @@ declare class Seamless {
1718
1718
  data: {
1719
1719
  masterAddress: string;
1720
1720
  seamlessAccount: string;
1721
- authorized: boolean;
1721
+ authorized: true;
1722
1722
  };
1723
1723
  }>;
1724
1724
  exportSeamlessPrivateKey({ password, apiKey }: {
package/dist/index.d.ts CHANGED
@@ -1648,7 +1648,7 @@ declare class Account {
1648
1648
  message: string;
1649
1649
  data?: undefined;
1650
1650
  }>;
1651
- setUserFeeData(address: string, deadline: number, params: {
1651
+ setUserFeeData(address: string, chainId: number, deadline: number, params: {
1652
1652
  tier: number;
1653
1653
  referrer: string;
1654
1654
  totalReferralRebatePct: number;
@@ -1718,7 +1718,7 @@ declare class Seamless {
1718
1718
  data: {
1719
1719
  masterAddress: string;
1720
1720
  seamlessAccount: string;
1721
- authorized: boolean;
1721
+ authorized: true;
1722
1722
  };
1723
1723
  }>;
1724
1724
  exportSeamlessPrivateKey({ password, apiKey }: {
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.223",
1810
+ version: "0.1.225",
1811
1811
  private: false,
1812
1812
  publishConfig: {
1813
1813
  access: "public"
@@ -21389,20 +21389,10 @@ var Account = class {
21389
21389
  };
21390
21390
  }
21391
21391
  }
21392
- async setUserFeeData(address, deadline, params, signature) {
21392
+ async setUserFeeData(address, chainId, deadline, params, signature) {
21393
21393
  const config = this.configManager.getConfig();
21394
- const brokerContract = new import_ethers26.ethers.Contract(
21395
- config.brokerAddress,
21396
- Broker_default,
21397
- config.signer
21398
- );
21399
- const nonce = await brokerContract.userNonces(address);
21400
- if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21401
- throw new MyxSDKError(
21402
- "REQUEST_FAILED" /* RequestFailed */,
21403
- "Invalid nonce, please try again"
21404
- );
21405
- }
21394
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
21395
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
21406
21396
  if (deadline < (0, import_dayjs3.default)().unix()) {
21407
21397
  throw new MyxSDKError(
21408
21398
  "REQUEST_FAILED" /* RequestFailed */,
@@ -21422,12 +21412,53 @@ var Account = class {
21422
21412
  signature
21423
21413
  };
21424
21414
  try {
21425
- const rs = await brokerContract.setUserFeeData(feeData);
21426
- const receipt = await rs?.wait(1);
21427
- return {
21428
- code: 0,
21429
- data: receipt
21430
- };
21415
+ if (config.seamlessMode && authorized && seamlessWallet) {
21416
+ const isEnoughGas = await this.utils.checkSeamlessGas(address);
21417
+ if (!isEnoughGas) {
21418
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
21419
+ }
21420
+ const forwarderContract = await getForwarderContract(chainId);
21421
+ const accountContract = new import_ethers26.ethers.Contract(
21422
+ config.brokerAddress,
21423
+ Account_default,
21424
+ seamlessWallet
21425
+ );
21426
+ const functionHash = accountContract.interface.encodeFunctionData("setUserFeeData", [feeData]);
21427
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
21428
+ const forwardTxParams = {
21429
+ from: seamlessWallet.address ?? "",
21430
+ to: config.brokerAddress,
21431
+ value: "0",
21432
+ gas: "350000",
21433
+ deadline: (0, import_dayjs3.default)().add(60, "minute").unix(),
21434
+ data: functionHash,
21435
+ nonce: nonce.toString()
21436
+ };
21437
+ const rs = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
21438
+ return {
21439
+ code: 0,
21440
+ data: rs
21441
+ };
21442
+ } else {
21443
+ const brokerContract = new import_ethers26.ethers.Contract(
21444
+ config.brokerAddress,
21445
+ Broker_default,
21446
+ config.signer
21447
+ );
21448
+ const nonce = await brokerContract.userNonces(address);
21449
+ if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21450
+ throw new MyxSDKError(
21451
+ "REQUEST_FAILED" /* RequestFailed */,
21452
+ "Invalid nonce, please try again"
21453
+ );
21454
+ }
21455
+ const rs = await brokerContract.setUserFeeData(feeData);
21456
+ const receipt = await rs?.wait(1);
21457
+ return {
21458
+ code: 0,
21459
+ data: receipt
21460
+ };
21461
+ }
21431
21462
  } catch (error) {
21432
21463
  return {
21433
21464
  code: -1,
@@ -21997,7 +22028,11 @@ var Seamless = class {
21997
22028
  });
21998
22029
  const privateKey = decrypted.toString(import_crypto_js.default.enc.Utf8);
21999
22030
  const wallet = new import_ethers27.ethers.Wallet(privateKey);
22000
- const isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address, chainId);
22031
+ let isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address, chainId);
22032
+ if (!isAuthorized) {
22033
+ await this.authorizeSeamlessAccount({ approve: true, seamlessAddress: wallet.address, chainId });
22034
+ isAuthorized = true;
22035
+ }
22001
22036
  this.configManager.updateSeamlessWallet({
22002
22037
  masterAddress,
22003
22038
  wallet,
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.223",
1734
+ version: "0.1.225",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -21313,20 +21313,10 @@ var Account = class {
21313
21313
  };
21314
21314
  }
21315
21315
  }
21316
- async setUserFeeData(address, deadline, params, signature) {
21316
+ async setUserFeeData(address, chainId, deadline, params, signature) {
21317
21317
  const config = this.configManager.getConfig();
21318
- const brokerContract = new ethers8.Contract(
21319
- config.brokerAddress,
21320
- Broker_default,
21321
- config.signer
21322
- );
21323
- const nonce = await brokerContract.userNonces(address);
21324
- if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21325
- throw new MyxSDKError(
21326
- "REQUEST_FAILED" /* RequestFailed */,
21327
- "Invalid nonce, please try again"
21328
- );
21329
- }
21318
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
21319
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
21330
21320
  if (deadline < dayjs3().unix()) {
21331
21321
  throw new MyxSDKError(
21332
21322
  "REQUEST_FAILED" /* RequestFailed */,
@@ -21346,12 +21336,53 @@ var Account = class {
21346
21336
  signature
21347
21337
  };
21348
21338
  try {
21349
- const rs = await brokerContract.setUserFeeData(feeData);
21350
- const receipt = await rs?.wait(1);
21351
- return {
21352
- code: 0,
21353
- data: receipt
21354
- };
21339
+ if (config.seamlessMode && authorized && seamlessWallet) {
21340
+ const isEnoughGas = await this.utils.checkSeamlessGas(address);
21341
+ if (!isEnoughGas) {
21342
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
21343
+ }
21344
+ const forwarderContract = await getForwarderContract(chainId);
21345
+ const accountContract = new ethers8.Contract(
21346
+ config.brokerAddress,
21347
+ Account_default,
21348
+ seamlessWallet
21349
+ );
21350
+ const functionHash = accountContract.interface.encodeFunctionData("setUserFeeData", [feeData]);
21351
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
21352
+ const forwardTxParams = {
21353
+ from: seamlessWallet.address ?? "",
21354
+ to: config.brokerAddress,
21355
+ value: "0",
21356
+ gas: "350000",
21357
+ deadline: dayjs3().add(60, "minute").unix(),
21358
+ data: functionHash,
21359
+ nonce: nonce.toString()
21360
+ };
21361
+ const rs = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
21362
+ return {
21363
+ code: 0,
21364
+ data: rs
21365
+ };
21366
+ } else {
21367
+ const brokerContract = new ethers8.Contract(
21368
+ config.brokerAddress,
21369
+ Broker_default,
21370
+ config.signer
21371
+ );
21372
+ const nonce = await brokerContract.userNonces(address);
21373
+ if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21374
+ throw new MyxSDKError(
21375
+ "REQUEST_FAILED" /* RequestFailed */,
21376
+ "Invalid nonce, please try again"
21377
+ );
21378
+ }
21379
+ const rs = await brokerContract.setUserFeeData(feeData);
21380
+ const receipt = await rs?.wait(1);
21381
+ return {
21382
+ code: 0,
21383
+ data: receipt
21384
+ };
21385
+ }
21355
21386
  } catch (error) {
21356
21387
  return {
21357
21388
  code: -1,
@@ -21921,7 +21952,11 @@ var Seamless = class {
21921
21952
  });
21922
21953
  const privateKey = decrypted.toString(CryptoJS.enc.Utf8);
21923
21954
  const wallet = new ethers9.Wallet(privateKey);
21924
- const isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address, chainId);
21955
+ let isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address, chainId);
21956
+ if (!isAuthorized) {
21957
+ await this.authorizeSeamlessAccount({ approve: true, seamlessAddress: wallet.address, chainId });
21958
+ isAuthorized = true;
21959
+ }
21925
21960
  this.configManager.updateSeamlessWallet({
21926
21961
  masterAddress,
21927
21962
  wallet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.223",
3
+ "version": "0.1.225",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"