@myx-trade/sdk 0.1.217 → 0.1.218

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.
Files changed (3) hide show
  1. package/dist/index.js +16 -107
  2. package/dist/index.mjs +16 -107
  3. package/package.json +1 -1
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.217",
1810
+ version: "0.1.218",
1811
1811
  private: false,
1812
1812
  publishConfig: {
1813
1813
  access: "public"
@@ -21732,22 +21732,11 @@ var import_ethers27 = require("ethers");
21732
21732
  var import_dayjs4 = __toESM(require("dayjs"));
21733
21733
 
21734
21734
  // src/utils/index.ts
21735
- function getChainDomainConfig(chainId, address) {
21736
- return CHAIN_DOMAIN?.[chainId]?.[address];
21737
- }
21738
- var CHAIN_DOMAIN = {
21739
- [421614 /* ARB_TESTNET */]: {
21740
- [getContractAddressByChainId(421614 /* ARB_TESTNET */).USDC]: {
21741
- name: "USDC",
21742
- version: "2",
21743
- chainId: 421614 /* ARB_TESTNET */.toString(),
21744
- verifyingContract: getContractAddressByChainId(421614 /* ARB_TESTNET */).USDC
21745
- }
21746
- }
21747
- };
21748
21735
  var getEIP712Domain = async (contract) => {
21749
21736
  try {
21750
21737
  const eip712Domain = await contract.eip712Domain();
21738
+ console.log("eip712Domain-->", eip712Domain.name);
21739
+ console.log("eip712Domain.version-->", eip712Domain.version);
21751
21740
  return {
21752
21741
  name: eip712Domain.name,
21753
21742
  version: eip712Domain.version,
@@ -21759,27 +21748,6 @@ var getEIP712Domain = async (contract) => {
21759
21748
  throw new Error(`Error fetching EIP712 domain: ${error}`);
21760
21749
  }
21761
21750
  };
21762
- function wait(ms) {
21763
- return new Promise((resolve) => setTimeout(resolve, ms));
21764
- }
21765
- function waitRandom(min, max) {
21766
- return wait(min + Math.round(Math.random() * Math.max(0, max - min)));
21767
- }
21768
- var CanceledError = class extends Error {
21769
- constructor() {
21770
- super();
21771
- this.name = "CanceledError";
21772
- this.message = "Retryable was canceled";
21773
- this.name = "CanceledError";
21774
- }
21775
- };
21776
- var RetryableError = class extends Error {
21777
- constructor() {
21778
- super();
21779
- this.name = "RetryableError";
21780
- this.name = "RetryableError";
21781
- }
21782
- };
21783
21751
  var TimeoutError = class extends Error {
21784
21752
  constructor() {
21785
21753
  super();
@@ -21788,47 +21756,6 @@ var TimeoutError = class extends Error {
21788
21756
  this.name = "TimeoutError";
21789
21757
  }
21790
21758
  };
21791
- function retry(fn, { n, minWait, maxWait }) {
21792
- let completed = false;
21793
- let rejectCancelled;
21794
- const promise = new Promise(async (resolve, reject) => {
21795
- rejectCancelled = reject;
21796
- while (true) {
21797
- let result;
21798
- try {
21799
- result = await fn();
21800
- if (!completed) {
21801
- resolve(result);
21802
- completed = true;
21803
- }
21804
- break;
21805
- } catch (error) {
21806
- if (completed) {
21807
- break;
21808
- }
21809
- if (n <= 0 || !(error instanceof RetryableError)) {
21810
- if (error instanceof RetryableError) {
21811
- reject(new TimeoutError());
21812
- } else {
21813
- reject(error);
21814
- }
21815
- completed = true;
21816
- break;
21817
- }
21818
- n--;
21819
- }
21820
- await waitRandom(minWait, maxWait);
21821
- }
21822
- });
21823
- return {
21824
- promise,
21825
- cancel: () => {
21826
- if (completed) return;
21827
- completed = true;
21828
- rejectCancelled(new CanceledError());
21829
- }
21830
- };
21831
- }
21832
21759
 
21833
21760
  // src/manager/seamless/index.ts
21834
21761
  var import_bytes = require("@ethersproject/bytes");
@@ -21877,9 +21804,8 @@ var charFill = (ping) => {
21877
21804
  return ping + paddedString;
21878
21805
  };
21879
21806
  var getIvMapString = () => import_crypto_js.default.enc.Utf8.parse(seamlessNonceString);
21880
- async function signPermit(provider, contract, owner, spender, value, nonce, deadline, chainId) {
21881
- const chainDomainConfig = getChainDomainConfig(chainId, contract.target);
21882
- const domain = chainDomainConfig ?? await getEIP712Domain(contract);
21807
+ async function signPermit(provider, contract, owner, spender, value, nonce, deadline) {
21808
+ const domain = await getEIP712Domain(contract);
21883
21809
  const types = {
21884
21810
  Permit: [
21885
21811
  { name: "owner", type: "address" },
@@ -21938,8 +21864,7 @@ var Seamless = class {
21938
21864
  brokerAddress,
21939
21865
  import_ethers27.ethers.MaxUint256.toString(),
21940
21866
  nonces.toString(),
21941
- deadline.toString(),
21942
- chainId
21867
+ deadline.toString()
21943
21868
  );
21944
21869
  const forwarderSignPermit = await signPermit(
21945
21870
  config.signer,
@@ -21949,8 +21874,7 @@ var Seamless = class {
21949
21874
  forwarderAddress,
21950
21875
  import_ethers27.ethers.MaxUint256.toString(),
21951
21876
  (nonces + BigInt(1)).toString(),
21952
- deadline.toString(),
21953
- chainId
21877
+ deadline.toString()
21954
21878
  );
21955
21879
  const brokerSeamlessUSDPermitParams = {
21956
21880
  token: erc20Contract.target,
@@ -21973,7 +21897,7 @@ var Seamless = class {
21973
21897
  r: forwarderSignPermit.r,
21974
21898
  s: forwarderSignPermit.s
21975
21899
  };
21976
- this.logger.info("forwarderPermitParams-->", forwarderPermitParams);
21900
+ this.logger.info("forwarderPermitParams brokerSeamlessUSDPermitParams-->", brokerSeamlessUSDPermitParams, forwarderPermitParams);
21977
21901
  return [brokerSeamlessUSDPermitParams, forwarderPermitParams];
21978
21902
  } catch (error) {
21979
21903
  this.logger.error("error-->", error);
@@ -21997,6 +21921,7 @@ var Seamless = class {
21997
21921
  chainId: forwarderJsonRpcContractDomain.chainId,
21998
21922
  verifyingContract: forwarderJsonRpcContractDomain.verifyingContract
21999
21923
  };
21924
+ this.logger.info("domain-->", domain);
22000
21925
  const walletProvider = provider ?? await getSignerProvider(chainId);
22001
21926
  const signature = await walletProvider.signTypedData(domain, contractTypes, {
22002
21927
  from,
@@ -22040,7 +21965,6 @@ var Seamless = class {
22040
21965
  }
22041
21966
  const forwarderContract = await getForwarderContract(chainId, 1 /* Signer */);
22042
21967
  const nonce = await forwarderContract.nonces(masterAddress);
22043
- this.logger.info("permitParams-->", permitParams);
22044
21968
  const functionHash = forwarderContract.interface.encodeFunctionData("permitAndApproveForwarder", [
22045
21969
  seamlessAddress,
22046
21970
  approve2,
@@ -22057,32 +21981,17 @@ var Seamless = class {
22057
21981
  deadline
22058
21982
  }, chainId);
22059
21983
  if (!txRs.data?.txHash) {
22060
- const retryOptions = { n: 10, minWait: 250, maxWait: 1e3 };
22061
- const { promise } = retry(async () => {
21984
+ try {
22062
21985
  const getRs = await this.api.fetchForwarderGetApi({
22063
21986
  requestId: txRs.data?.requestId
22064
21987
  });
22065
- if (getRs.data?.status === 9 /* EXECUTED */) {
22066
- if (getRs.data?.txHash) {
22067
- txRs.data.txHash = getRs.data.txHash;
22068
- return {
22069
- code: 0,
22070
- data: {
22071
- seamlessAccount: seamlessAddress,
22072
- authorized: approve2
22073
- }
22074
- };
22075
- } else {
22076
- throw new MyxSDKError("OPERATION_FAILED" /* OperationFailed */, "Operation failed, please try again later");
21988
+ return {
21989
+ code: 0,
21990
+ data: {
21991
+ seamlessAccount: seamlessAddress,
21992
+ authorized: approve2
22077
21993
  }
22078
- } else if ([2 /* BROADCAST_FAILED */, 3 /* TIMEOUT_CANCEL */].includes(getRs?.data?.status)) {
22079
- throw new MyxSDKError("OPERATION_FAILED" /* OperationFailed */, "Operation failed, please try again later");
22080
- }
22081
- throw new RetryableError();
22082
- }, retryOptions);
22083
- try {
22084
- const rs = await promise;
22085
- return rs;
21994
+ };
22086
21995
  } catch (err) {
22087
21996
  if (err instanceof TimeoutError) {
22088
21997
  throw new MyxSDKError("TIMEOUT" /* Timeout */, "Your request timed out, 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.217",
1734
+ version: "0.1.218",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -21656,22 +21656,11 @@ import { toUtf8Bytes, keccak256, hexlify, ethers as ethers9, isHexString, getByt
21656
21656
  import dayjs4 from "dayjs";
21657
21657
 
21658
21658
  // src/utils/index.ts
21659
- function getChainDomainConfig(chainId, address) {
21660
- return CHAIN_DOMAIN?.[chainId]?.[address];
21661
- }
21662
- var CHAIN_DOMAIN = {
21663
- [421614 /* ARB_TESTNET */]: {
21664
- [getContractAddressByChainId(421614 /* ARB_TESTNET */).USDC]: {
21665
- name: "USDC",
21666
- version: "2",
21667
- chainId: 421614 /* ARB_TESTNET */.toString(),
21668
- verifyingContract: getContractAddressByChainId(421614 /* ARB_TESTNET */).USDC
21669
- }
21670
- }
21671
- };
21672
21659
  var getEIP712Domain = async (contract) => {
21673
21660
  try {
21674
21661
  const eip712Domain = await contract.eip712Domain();
21662
+ console.log("eip712Domain-->", eip712Domain.name);
21663
+ console.log("eip712Domain.version-->", eip712Domain.version);
21675
21664
  return {
21676
21665
  name: eip712Domain.name,
21677
21666
  version: eip712Domain.version,
@@ -21683,27 +21672,6 @@ var getEIP712Domain = async (contract) => {
21683
21672
  throw new Error(`Error fetching EIP712 domain: ${error}`);
21684
21673
  }
21685
21674
  };
21686
- function wait(ms) {
21687
- return new Promise((resolve) => setTimeout(resolve, ms));
21688
- }
21689
- function waitRandom(min, max) {
21690
- return wait(min + Math.round(Math.random() * Math.max(0, max - min)));
21691
- }
21692
- var CanceledError = class extends Error {
21693
- constructor() {
21694
- super();
21695
- this.name = "CanceledError";
21696
- this.message = "Retryable was canceled";
21697
- this.name = "CanceledError";
21698
- }
21699
- };
21700
- var RetryableError = class extends Error {
21701
- constructor() {
21702
- super();
21703
- this.name = "RetryableError";
21704
- this.name = "RetryableError";
21705
- }
21706
- };
21707
21675
  var TimeoutError = class extends Error {
21708
21676
  constructor() {
21709
21677
  super();
@@ -21712,47 +21680,6 @@ var TimeoutError = class extends Error {
21712
21680
  this.name = "TimeoutError";
21713
21681
  }
21714
21682
  };
21715
- function retry(fn, { n, minWait, maxWait }) {
21716
- let completed = false;
21717
- let rejectCancelled;
21718
- const promise = new Promise(async (resolve, reject) => {
21719
- rejectCancelled = reject;
21720
- while (true) {
21721
- let result;
21722
- try {
21723
- result = await fn();
21724
- if (!completed) {
21725
- resolve(result);
21726
- completed = true;
21727
- }
21728
- break;
21729
- } catch (error) {
21730
- if (completed) {
21731
- break;
21732
- }
21733
- if (n <= 0 || !(error instanceof RetryableError)) {
21734
- if (error instanceof RetryableError) {
21735
- reject(new TimeoutError());
21736
- } else {
21737
- reject(error);
21738
- }
21739
- completed = true;
21740
- break;
21741
- }
21742
- n--;
21743
- }
21744
- await waitRandom(minWait, maxWait);
21745
- }
21746
- });
21747
- return {
21748
- promise,
21749
- cancel: () => {
21750
- if (completed) return;
21751
- completed = true;
21752
- rejectCancelled(new CanceledError());
21753
- }
21754
- };
21755
- }
21756
21683
 
21757
21684
  // src/manager/seamless/index.ts
21758
21685
  import { splitSignature } from "@ethersproject/bytes";
@@ -21801,9 +21728,8 @@ var charFill = (ping) => {
21801
21728
  return ping + paddedString;
21802
21729
  };
21803
21730
  var getIvMapString = () => CryptoJS.enc.Utf8.parse(seamlessNonceString);
21804
- async function signPermit(provider, contract, owner, spender, value, nonce, deadline, chainId) {
21805
- const chainDomainConfig = getChainDomainConfig(chainId, contract.target);
21806
- const domain = chainDomainConfig ?? await getEIP712Domain(contract);
21731
+ async function signPermit(provider, contract, owner, spender, value, nonce, deadline) {
21732
+ const domain = await getEIP712Domain(contract);
21807
21733
  const types = {
21808
21734
  Permit: [
21809
21735
  { name: "owner", type: "address" },
@@ -21862,8 +21788,7 @@ var Seamless = class {
21862
21788
  brokerAddress,
21863
21789
  ethers9.MaxUint256.toString(),
21864
21790
  nonces.toString(),
21865
- deadline.toString(),
21866
- chainId
21791
+ deadline.toString()
21867
21792
  );
21868
21793
  const forwarderSignPermit = await signPermit(
21869
21794
  config.signer,
@@ -21873,8 +21798,7 @@ var Seamless = class {
21873
21798
  forwarderAddress,
21874
21799
  ethers9.MaxUint256.toString(),
21875
21800
  (nonces + BigInt(1)).toString(),
21876
- deadline.toString(),
21877
- chainId
21801
+ deadline.toString()
21878
21802
  );
21879
21803
  const brokerSeamlessUSDPermitParams = {
21880
21804
  token: erc20Contract.target,
@@ -21897,7 +21821,7 @@ var Seamless = class {
21897
21821
  r: forwarderSignPermit.r,
21898
21822
  s: forwarderSignPermit.s
21899
21823
  };
21900
- this.logger.info("forwarderPermitParams-->", forwarderPermitParams);
21824
+ this.logger.info("forwarderPermitParams brokerSeamlessUSDPermitParams-->", brokerSeamlessUSDPermitParams, forwarderPermitParams);
21901
21825
  return [brokerSeamlessUSDPermitParams, forwarderPermitParams];
21902
21826
  } catch (error) {
21903
21827
  this.logger.error("error-->", error);
@@ -21921,6 +21845,7 @@ var Seamless = class {
21921
21845
  chainId: forwarderJsonRpcContractDomain.chainId,
21922
21846
  verifyingContract: forwarderJsonRpcContractDomain.verifyingContract
21923
21847
  };
21848
+ this.logger.info("domain-->", domain);
21924
21849
  const walletProvider = provider ?? await getSignerProvider(chainId);
21925
21850
  const signature = await walletProvider.signTypedData(domain, contractTypes, {
21926
21851
  from,
@@ -21964,7 +21889,6 @@ var Seamless = class {
21964
21889
  }
21965
21890
  const forwarderContract = await getForwarderContract(chainId, 1 /* Signer */);
21966
21891
  const nonce = await forwarderContract.nonces(masterAddress);
21967
- this.logger.info("permitParams-->", permitParams);
21968
21892
  const functionHash = forwarderContract.interface.encodeFunctionData("permitAndApproveForwarder", [
21969
21893
  seamlessAddress,
21970
21894
  approve2,
@@ -21981,32 +21905,17 @@ var Seamless = class {
21981
21905
  deadline
21982
21906
  }, chainId);
21983
21907
  if (!txRs.data?.txHash) {
21984
- const retryOptions = { n: 10, minWait: 250, maxWait: 1e3 };
21985
- const { promise } = retry(async () => {
21908
+ try {
21986
21909
  const getRs = await this.api.fetchForwarderGetApi({
21987
21910
  requestId: txRs.data?.requestId
21988
21911
  });
21989
- if (getRs.data?.status === 9 /* EXECUTED */) {
21990
- if (getRs.data?.txHash) {
21991
- txRs.data.txHash = getRs.data.txHash;
21992
- return {
21993
- code: 0,
21994
- data: {
21995
- seamlessAccount: seamlessAddress,
21996
- authorized: approve2
21997
- }
21998
- };
21999
- } else {
22000
- throw new MyxSDKError("OPERATION_FAILED" /* OperationFailed */, "Operation failed, please try again later");
21912
+ return {
21913
+ code: 0,
21914
+ data: {
21915
+ seamlessAccount: seamlessAddress,
21916
+ authorized: approve2
22001
21917
  }
22002
- } else if ([2 /* BROADCAST_FAILED */, 3 /* TIMEOUT_CANCEL */].includes(getRs?.data?.status)) {
22003
- throw new MyxSDKError("OPERATION_FAILED" /* OperationFailed */, "Operation failed, please try again later");
22004
- }
22005
- throw new RetryableError();
22006
- }, retryOptions);
22007
- try {
22008
- const rs = await promise;
22009
- return rs;
21918
+ };
22010
21919
  } catch (err) {
22011
21920
  if (err instanceof TimeoutError) {
22012
21921
  throw new MyxSDKError("TIMEOUT" /* Timeout */, "Your request timed out, please try again");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.217",
3
+ "version": "0.1.218",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"