@allbridge/bridge-core-sdk 3.27.0-alpha.2 → 3.27.0-alpha.3

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 (50) hide show
  1. package/dist/browser/index.js +2 -2
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/index.js +2 -2
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/src/chains/chain.enums.d.ts +7 -2
  8. package/dist/src/chains/chain.enums.js +5 -0
  9. package/dist/src/chains/chain.enums.js.map +1 -1
  10. package/dist/src/chains/index.js +6 -0
  11. package/dist/src/chains/index.js.map +1 -1
  12. package/dist/src/configs/mainnet.js +1 -0
  13. package/dist/src/configs/mainnet.js.map +1 -1
  14. package/dist/src/services/bridge/index.js +5 -0
  15. package/dist/src/services/bridge/index.js.map +1 -1
  16. package/dist/src/services/bridge/models/bridge.model.d.ts +1 -0
  17. package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
  18. package/dist/src/services/bridge/stx/index.d.ts +15 -0
  19. package/dist/src/services/bridge/stx/index.js +117 -0
  20. package/dist/src/services/bridge/stx/index.js.map +1 -0
  21. package/dist/src/services/bridge/utils.d.ts +3 -1
  22. package/dist/src/services/bridge/utils.js +23 -0
  23. package/dist/src/services/bridge/utils.js.map +1 -1
  24. package/dist/src/services/liquidity-pool/index.js +5 -0
  25. package/dist/src/services/liquidity-pool/index.js.map +1 -1
  26. package/dist/src/services/liquidity-pool/stx/index.d.ts +19 -0
  27. package/dist/src/services/liquidity-pool/stx/index.js +134 -0
  28. package/dist/src/services/liquidity-pool/stx/index.js.map +1 -0
  29. package/dist/src/services/models/index.d.ts +2 -1
  30. package/dist/src/services/models/index.js.map +1 -1
  31. package/dist/src/services/models/stx/clarigen-types.d.ts +657 -0
  32. package/dist/src/services/models/stx/clarigen-types.js +2296 -0
  33. package/dist/src/services/models/stx/clarigen-types.js.map +1 -0
  34. package/dist/src/services/token/index.js +5 -0
  35. package/dist/src/services/token/index.js.map +1 -1
  36. package/dist/src/services/token/stx/index.d.ts +17 -0
  37. package/dist/src/services/token/stx/index.js +50 -0
  38. package/dist/src/services/token/stx/index.js.map +1 -0
  39. package/dist/src/services/utils/stx/get-network.d.ts +2 -0
  40. package/dist/src/services/utils/stx/get-network.js +11 -0
  41. package/dist/src/services/utils/stx/get-network.js.map +1 -0
  42. package/dist/src/services/utils/stx/post-conditions.d.ts +3 -0
  43. package/dist/src/services/utils/stx/post-conditions.js +27 -0
  44. package/dist/src/services/utils/stx/post-conditions.js.map +1 -0
  45. package/dist/src/services/yield/index.js +3 -0
  46. package/dist/src/services/yield/index.js.map +1 -1
  47. package/dist/src/version.d.ts +1 -1
  48. package/dist/src/version.js +1 -1
  49. package/dist/src/version.js.map +1 -1
  50. package/package.json +5 -2
@@ -66,7 +66,11 @@ export declare enum ChainSymbol {
66
66
  /**
67
67
  * The Algorand network.
68
68
  */
69
- ALG = "ALG"
69
+ ALG = "ALG",
70
+ /**
71
+ * The Stacks network.
72
+ */
73
+ STX = "STX"
70
74
  }
71
75
  export declare enum ChainType {
72
76
  EVM = "EVM",
@@ -74,5 +78,6 @@ export declare enum ChainType {
74
78
  TRX = "TRX",
75
79
  SRB = "SRB",
76
80
  SUI = "SUI",
77
- ALG = "ALG"
81
+ ALG = "ALG",
82
+ STX = "STX"
78
83
  }
@@ -71,6 +71,10 @@ var ChainSymbol;
71
71
  * The Algorand network.
72
72
  */
73
73
  ChainSymbol["ALG"] = "ALG";
74
+ /**
75
+ * The Stacks network.
76
+ */
77
+ ChainSymbol["STX"] = "STX";
74
78
  })(ChainSymbol || (exports.ChainSymbol = ChainSymbol = {}));
75
79
  var ChainType;
76
80
  (function (ChainType) {
@@ -80,5 +84,6 @@ var ChainType;
80
84
  ChainType["SRB"] = "SRB";
81
85
  ChainType["SUI"] = "SUI";
82
86
  ChainType["ALG"] = "ALG";
87
+ ChainType["STX"] = "STX";
83
88
  })(ChainType || (exports.ChainType = ChainType = {}));
84
89
  //# sourceMappingURL=chain.enums.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain.enums.js","sourceRoot":"","sources":["../../../src/chains/chain.enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAqFX;AArFD,WAAY,WAAW;IACrB;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,4BAAa,CAAA;IAEb;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;AACb,CAAC,EArFW,WAAW,2BAAX,WAAW,QAqFtB;AAED,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,8BAAiB,CAAA;IACjB,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAPW,SAAS,yBAAT,SAAS,QAOpB","sourcesContent":["export enum ChainSymbol {\n /**\n * The BNB Smart Chain main network.\n */\n BSC = \"BSC\",\n\n /**\n * The Ethereum main network.\n */\n ETH = \"ETH\",\n\n /**\n * The Base main network.\n */\n BAS = \"BAS\",\n\n /**\n * The Solana network.\n */\n SOL = \"SOL\",\n\n /**\n * The TRON network.\n */\n TRX = \"TRX\",\n\n /**\n * The Polygon network.\n */\n POL = \"POL\",\n\n /**\n * The Arbitrum network.\n */\n ARB = \"ARB\",\n\n /**\n * The Celo network.\n */\n CEL = \"CEL\",\n\n /**\n * The Avalanche main network.\n */\n AVA = \"AVA\",\n\n /**\n * The Soroban network.\n */\n SRB = \"SRB\",\n\n /**\n * The Stellar network.\n */\n STLR = \"STLR\",\n\n /**\n * The OP Mainnet network.\n */\n OPT = \"OPT\",\n\n /**\n * The SUI network.\n */\n SUI = \"SUI\",\n\n /**\n * The Sonic network.\n */\n SNC = \"SNC\",\n\n /**\n * The Unichain network.\n */\n UNI = \"UNI\",\n\n /**\n * The Linea network.\n */\n LIN = \"LIN\",\n\n /**\n * The Algorand network.\n */\n ALG = \"ALG\",\n}\n\nexport enum ChainType {\n EVM = \"EVM\",\n SOLANA = \"SOLANA\",\n TRX = \"TRX\",\n SRB = \"SRB\",\n SUI = \"SUI\",\n ALG = \"ALG\",\n}\n"]}
1
+ {"version":3,"file":"chain.enums.js","sourceRoot":"","sources":["../../../src/chains/chain.enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,WA0FX;AA1FD,WAAY,WAAW;IACrB;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,4BAAa,CAAA;IAEb;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;IAEX;;OAEG;IACH,0BAAW,CAAA;AACb,CAAC,EA1FW,WAAW,2BAAX,WAAW,QA0FtB;AAED,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,8BAAiB,CAAA;IACjB,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB","sourcesContent":["export enum ChainSymbol {\n /**\n * The BNB Smart Chain main network.\n */\n BSC = \"BSC\",\n\n /**\n * The Ethereum main network.\n */\n ETH = \"ETH\",\n\n /**\n * The Base main network.\n */\n BAS = \"BAS\",\n\n /**\n * The Solana network.\n */\n SOL = \"SOL\",\n\n /**\n * The TRON network.\n */\n TRX = \"TRX\",\n\n /**\n * The Polygon network.\n */\n POL = \"POL\",\n\n /**\n * The Arbitrum network.\n */\n ARB = \"ARB\",\n\n /**\n * The Celo network.\n */\n CEL = \"CEL\",\n\n /**\n * The Avalanche main network.\n */\n AVA = \"AVA\",\n\n /**\n * The Soroban network.\n */\n SRB = \"SRB\",\n\n /**\n * The Stellar network.\n */\n STLR = \"STLR\",\n\n /**\n * The OP Mainnet network.\n */\n OPT = \"OPT\",\n\n /**\n * The SUI network.\n */\n SUI = \"SUI\",\n\n /**\n * The Sonic network.\n */\n SNC = \"SNC\",\n\n /**\n * The Unichain network.\n */\n UNI = \"UNI\",\n\n /**\n * The Linea network.\n */\n LIN = \"LIN\",\n\n /**\n * The Algorand network.\n */\n ALG = \"ALG\",\n\n /**\n * The Stacks network.\n */\n STX = \"STX\",\n}\n\nexport enum ChainType {\n EVM = \"EVM\",\n SOLANA = \"SOLANA\",\n TRX = \"TRX\",\n SRB = \"SRB\",\n SUI = \"SUI\",\n ALG = \"ALG\",\n STX = \"STX\",\n}\n"]}
@@ -13,6 +13,7 @@ const chainDecimalsByType = {
13
13
  SRB: 7,
14
14
  SUI: 9,
15
15
  ALG: 6,
16
+ STX: 6,
16
17
  };
17
18
  const defaultProperties = {
18
19
  [chain_enums_1.ChainSymbol.BSC]: {
@@ -111,6 +112,11 @@ const defaultProperties = {
111
112
  name: "Algorand",
112
113
  chainType: chain_enums_1.ChainType.ALG,
113
114
  },
115
+ [chain_enums_1.ChainSymbol.STX]: {
116
+ chainSymbol: chain_enums_1.ChainSymbol.STX,
117
+ name: "Stacks",
118
+ chainType: chain_enums_1.ChainType.STX,
119
+ },
114
120
  };
115
121
  exports.Chains = (() => {
116
122
  let chainProperties = { ...defaultProperties };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chains/index.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,+CAAuD;AAGvD;;GAEG;AACH,MAAM,mBAAmB,GAA8B;IACrD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,MAAM,iBAAiB,GAAyC;IAC9D,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;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eAAe,CAAC,WAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,qBAAQ,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,mBAAmB;YACjB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,sBAAsB,CAAC,SAAoB;YACzC,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import { SdkError } from \"../exceptions\";\nimport { ChainSymbol, ChainType } from \"./chain.enums\";\nimport { BasicChainProperties } from \"./models\";\n\n/**\n * Native gas tokens decimals by ChainType\n */\nconst chainDecimalsByType: Record<ChainType, number> = {\n EVM: 18,\n SOLANA: 9,\n TRX: 6,\n SRB: 7,\n SUI: 9,\n ALG: 6,\n};\n\nconst defaultProperties: Record<string, BasicChainProperties> = {\n [ChainSymbol.BSC]: {\n chainSymbol: ChainSymbol.BSC,\n chainId: \"0x38\",\n name: \"BNB Chain\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.ETH]: {\n chainSymbol: ChainSymbol.ETH,\n chainId: \"0x1\",\n name: \"Ethereum\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.BAS]: {\n chainSymbol: ChainSymbol.BAS,\n chainId: \"0x2105\",\n name: \"Base\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.ARB]: {\n chainSymbol: ChainSymbol.ARB,\n chainId: \"0xa4b1\",\n name: \"Arbitrum\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.AVA]: {\n chainSymbol: ChainSymbol.AVA,\n chainId: \"0xa86a\",\n name: \"Avalanche\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.CEL]: {\n chainSymbol: ChainSymbol.CEL,\n chainId: \"0xa4ec\",\n name: \"Celo\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.POL]: {\n chainSymbol: ChainSymbol.POL,\n chainId: \"0x89\",\n name: \"Polygon\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.OPT]: {\n chainSymbol: ChainSymbol.OPT,\n chainId: \"0xa\",\n name: \"OP Mainnet\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.SNC]: {\n chainSymbol: ChainSymbol.SNC,\n chainId: \"0x92\",\n name: \"Sonic\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.UNI]: {\n chainSymbol: ChainSymbol.UNI,\n chainId: \"0x82\",\n name: \"Unichain\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.LIN]: {\n chainSymbol: ChainSymbol.LIN,\n chainId: \"0xe708\",\n name: \"Linea\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.SOL]: {\n chainSymbol: ChainSymbol.SOL,\n name: \"Solana\",\n chainType: ChainType.SOLANA,\n },\n [ChainSymbol.TRX]: {\n chainSymbol: ChainSymbol.TRX,\n name: \"Tron\",\n chainType: ChainType.TRX,\n },\n [ChainSymbol.SRB]: {\n chainSymbol: ChainSymbol.SRB,\n name: \"Stellar\",\n chainType: ChainType.SRB,\n },\n [ChainSymbol.STLR]: {\n chainSymbol: ChainSymbol.STLR,\n name: \"Stellar\",\n chainType: ChainType.SRB,\n },\n [ChainSymbol.SUI]: {\n chainSymbol: ChainSymbol.SUI,\n name: \"Sui\",\n chainType: ChainType.SUI,\n },\n [ChainSymbol.ALG]: {\n chainSymbol: ChainSymbol.ALG,\n name: \"Algorand\",\n chainType: ChainType.ALG,\n },\n};\n\nexport const Chains = (() => {\n let chainProperties: Record<string, BasicChainProperties> = { ...defaultProperties };\n\n return {\n addChainsProperties(additionalProperties?: Record<string, BasicChainProperties>) {\n chainProperties = { ...chainProperties, ...additionalProperties };\n },\n\n getChainProperty(chainSymbol: string): BasicChainProperties {\n const property = chainProperties[chainSymbol];\n if (!property) {\n throw new SdkError(`Cannot find chain properties for ${chainSymbol}`);\n }\n return property;\n },\n\n getChainsProperties(): Record<string, BasicChainProperties> {\n return chainProperties;\n },\n\n getChainDecimalsByType(chainType: ChainType): number {\n return chainDecimalsByType[chainType];\n },\n };\n})();\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chains/index.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,+CAAuD;AAGvD;;GAEG;AACH,MAAM,mBAAmB,GAA8B;IACrD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,MAAM,iBAAiB,GAAyC;IAC9D,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE,uBAAS,CAAC,GAAG;KACzB;IACD,CAAC,yBAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,yBAAW,CAAC,GAAG;QAC5B,OAAO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IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,qBAAQ,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,mBAAmB;YACjB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,sBAAsB,CAAC,SAAoB;YACzC,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import { SdkError } from \"../exceptions\";\nimport { ChainSymbol, ChainType } from \"./chain.enums\";\nimport { BasicChainProperties } from \"./models\";\n\n/**\n * Native gas tokens decimals by ChainType\n */\nconst chainDecimalsByType: Record<ChainType, number> = {\n EVM: 18,\n SOLANA: 9,\n TRX: 6,\n SRB: 7,\n SUI: 9,\n ALG: 6,\n STX: 6,\n};\n\nconst defaultProperties: Record<string, BasicChainProperties> = {\n [ChainSymbol.BSC]: {\n chainSymbol: ChainSymbol.BSC,\n chainId: \"0x38\",\n name: \"BNB Chain\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.ETH]: {\n chainSymbol: ChainSymbol.ETH,\n chainId: \"0x1\",\n name: \"Ethereum\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.BAS]: {\n chainSymbol: ChainSymbol.BAS,\n chainId: \"0x2105\",\n name: \"Base\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.ARB]: {\n chainSymbol: ChainSymbol.ARB,\n chainId: \"0xa4b1\",\n name: \"Arbitrum\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.AVA]: {\n chainSymbol: ChainSymbol.AVA,\n chainId: \"0xa86a\",\n name: \"Avalanche\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.CEL]: {\n chainSymbol: ChainSymbol.CEL,\n chainId: \"0xa4ec\",\n name: \"Celo\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.POL]: {\n chainSymbol: ChainSymbol.POL,\n chainId: \"0x89\",\n name: \"Polygon\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.OPT]: {\n chainSymbol: ChainSymbol.OPT,\n chainId: \"0xa\",\n name: \"OP Mainnet\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.SNC]: {\n chainSymbol: ChainSymbol.SNC,\n chainId: \"0x92\",\n name: \"Sonic\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.UNI]: {\n chainSymbol: ChainSymbol.UNI,\n chainId: \"0x82\",\n name: \"Unichain\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.LIN]: {\n chainSymbol: ChainSymbol.LIN,\n chainId: \"0xe708\",\n name: \"Linea\",\n chainType: ChainType.EVM,\n },\n [ChainSymbol.SOL]: {\n chainSymbol: ChainSymbol.SOL,\n name: \"Solana\",\n chainType: ChainType.SOLANA,\n },\n [ChainSymbol.TRX]: {\n chainSymbol: ChainSymbol.TRX,\n name: \"Tron\",\n chainType: ChainType.TRX,\n },\n [ChainSymbol.SRB]: {\n chainSymbol: ChainSymbol.SRB,\n name: \"Stellar\",\n chainType: ChainType.SRB,\n },\n [ChainSymbol.STLR]: {\n chainSymbol: ChainSymbol.STLR,\n name: \"Stellar\",\n chainType: ChainType.SRB,\n },\n [ChainSymbol.SUI]: {\n chainSymbol: ChainSymbol.SUI,\n name: \"Sui\",\n chainType: ChainType.SUI,\n },\n [ChainSymbol.ALG]: {\n chainSymbol: ChainSymbol.ALG,\n name: \"Algorand\",\n chainType: ChainType.ALG,\n },\n [ChainSymbol.STX]: {\n chainSymbol: ChainSymbol.STX,\n name: \"Stacks\",\n chainType: ChainType.STX,\n },\n};\n\nexport const Chains = (() => {\n let chainProperties: Record<string, BasicChainProperties> = { ...defaultProperties };\n\n return {\n addChainsProperties(additionalProperties?: Record<string, BasicChainProperties>) {\n chainProperties = { ...chainProperties, ...additionalProperties };\n },\n\n getChainProperty(chainSymbol: string): BasicChainProperties {\n const property = chainProperties[chainSymbol];\n if (!property) {\n throw new SdkError(`Cannot find chain properties for ${chainSymbol}`);\n }\n return property;\n },\n\n getChainsProperties(): Record<string, BasicChainProperties> {\n return chainProperties;\n },\n\n getChainDecimalsByType(chainType: ChainType): number {\n return chainDecimalsByType[chainType];\n },\n };\n})();\n"]}
@@ -34,5 +34,6 @@ exports.nodeRpcUrlsDefault = {
34
34
  SRB: "https://rpc.stellar.org:443",
35
35
  STLR: "https://horizon.stellar.org",
36
36
  SUI: "https://fullnode.mainnet.sui.io",
37
+ STX: "https://api.hiro.so",
37
38
  };
38
39
  //# sourceMappingURL=mainnet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mainnet.js","sourceRoot":"","sources":["../../../src/configs/mainnet.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAA4B;IAC9C,UAAU,EAAE,uCAAuC;IACnD,kBAAkB,EAAE,EAAE;IACtB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,iCAAiC;IAC7C,0BAA0B,EAAE,6CAA6C;IACzE,iBAAiB,EAAE,8CAA8C;IACjE,wBAAwB,EAAE,gDAAgD;IAC1E,WAAW,EAAE,iCAAiC;IAC9C,UAAU,EAAE;QACV,wBAAwB,EAAE,8CAA8C;QACxE,wBAAwB,EAAE,8CAA8C;QACxE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;KAChF;IACD,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAmB;IAC7C,YAAY,EAAE,qCAAqC;IACnD,UAAU,EAAE,yBAAyB;CACtC,CAAC;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAAgB;IAC7C,GAAG,EAAE,qCAAqC;IAC1C,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,6BAA6B;IAClC,IAAI,EAAE,6BAA6B;IACnC,GAAG,EAAE,iCAAiC;CACvC,CAAC","sourcesContent":["import { AllbridgeCoreSdkOptions, NodeRpcUrls, NodeUrlsConfig } from \"../index\";\n\nexport const mainnet: AllbridgeCoreSdkOptions = {\n coreApiUrl: \"https://core.api.allbridgecoreapi.net\",\n coreApiQueryParams: {},\n coreApiHeaders: {},\n jupiterUrl: \"https://lite-api.jup.ag/swap/v1\",\n wormholeMessengerProgramId: \"worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth\",\n solanaLookUpTable: \"2JcBAEVnAwVo4u8d61iqgHPrzZuugur7cVTjWubsVLHj\",\n sorobanNetworkPassphrase: \"Public Global Stellar Network ; September 2015\",\n tronJsonRpc: \"https://api.trongrid.io/jsonrpc\",\n cctpParams: {\n cctpTransmitterProgramId: \"CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd\",\n cctpTokenMessengerMinter: \"CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3\",\n cctpDomains: { ETH: 0, AVA: 1, OPT: 2, ARB: 3, SOL: 5, BAS: 6, POL: 7, SUI: 8 },\n },\n cachePoolInfoChainSec: 20,\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n * @deprecated use {@link nodeRpcUrlsDefault}\n */\nexport const nodeUrlsDefault: NodeUrlsConfig = {\n solanaRpcUrl: \"https://api.mainnet-beta.solana.com\",\n tronRpcUrl: \"https://api.trongrid.io\",\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n */\nexport const nodeRpcUrlsDefault: NodeRpcUrls = {\n SOL: \"https://api.mainnet-beta.solana.com\",\n TRX: \"https://api.trongrid.io\",\n SRB: \"https://rpc.stellar.org:443\",\n STLR: \"https://horizon.stellar.org\",\n SUI: \"https://fullnode.mainnet.sui.io\",\n};\n"]}
1
+ {"version":3,"file":"mainnet.js","sourceRoot":"","sources":["../../../src/configs/mainnet.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAA4B;IAC9C,UAAU,EAAE,uCAAuC;IACnD,kBAAkB,EAAE,EAAE;IACtB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,iCAAiC;IAC7C,0BAA0B,EAAE,6CAA6C;IACzE,iBAAiB,EAAE,8CAA8C;IACjE,wBAAwB,EAAE,gDAAgD;IAC1E,WAAW,EAAE,iCAAiC;IAC9C,UAAU,EAAE;QACV,wBAAwB,EAAE,8CAA8C;QACxE,wBAAwB,EAAE,8CAA8C;QACxE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;KAChF;IACD,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAmB;IAC7C,YAAY,EAAE,qCAAqC;IACnD,UAAU,EAAE,yBAAyB;CACtC,CAAC;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAAgB;IAC7C,GAAG,EAAE,qCAAqC;IAC1C,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,6BAA6B;IAClC,IAAI,EAAE,6BAA6B;IACnC,GAAG,EAAE,iCAAiC;IACtC,GAAG,EAAE,qBAAqB;CAC3B,CAAC","sourcesContent":["import { AllbridgeCoreSdkOptions, NodeRpcUrls, NodeUrlsConfig } from \"../index\";\n\nexport const mainnet: AllbridgeCoreSdkOptions = {\n coreApiUrl: \"https://core.api.allbridgecoreapi.net\",\n coreApiQueryParams: {},\n coreApiHeaders: {},\n jupiterUrl: \"https://lite-api.jup.ag/swap/v1\",\n wormholeMessengerProgramId: \"worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth\",\n solanaLookUpTable: \"2JcBAEVnAwVo4u8d61iqgHPrzZuugur7cVTjWubsVLHj\",\n sorobanNetworkPassphrase: \"Public Global Stellar Network ; September 2015\",\n tronJsonRpc: \"https://api.trongrid.io/jsonrpc\",\n cctpParams: {\n cctpTransmitterProgramId: \"CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd\",\n cctpTokenMessengerMinter: \"CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3\",\n cctpDomains: { ETH: 0, AVA: 1, OPT: 2, ARB: 3, SOL: 5, BAS: 6, POL: 7, SUI: 8 },\n },\n cachePoolInfoChainSec: 20,\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n * @deprecated use {@link nodeRpcUrlsDefault}\n */\nexport const nodeUrlsDefault: NodeUrlsConfig = {\n solanaRpcUrl: \"https://api.mainnet-beta.solana.com\",\n tronRpcUrl: \"https://api.trongrid.io\",\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n */\nexport const nodeRpcUrlsDefault: NodeRpcUrls = {\n SOL: \"https://api.mainnet-beta.solana.com\",\n TRX: \"https://api.trongrid.io\",\n SRB: \"https://rpc.stellar.org:443\",\n STLR: \"https://horizon.stellar.org\",\n SUI: \"https://fullnode.mainnet.sui.io\",\n STX: \"https://api.hiro.so\",\n};\n"]}
@@ -16,6 +16,7 @@ const evm_1 = require("./evm");
16
16
  const raw_bridge_transaction_builder_1 = require("./raw-bridge-transaction-builder");
17
17
  const sol_1 = require("./sol");
18
18
  const srb_1 = require("./srb");
19
+ const stx_1 = require("./stx");
19
20
  const sui_1 = require("./sui");
20
21
  const trx_1 = require("./trx");
21
22
  class DefaultBridgeService {
@@ -152,6 +153,10 @@ function getChainBridgeService(chainSymbol, api, nodeRpcUrlsConfig, params, prov
152
153
  return new alg_1.AlgBridgeService(algorand, api);
153
154
  }
154
155
  }
156
+ case index_1.ChainType.STX: {
157
+ const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);
158
+ return new stx_1.StxBridgeService(nodeRpcUrl, api);
159
+ }
155
160
  }
156
161
  }
157
162
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":";;;AAoIA,gCAwBC;AAED,sDAmEC;AAjOD,qEAAmE;AAEnE,qCAAkC;AAClC,+BAA4B;AAE5B,yCAAsC;AACtC,yEAAiE;AAEjE,iDAAuF;AACvF,uCAA6F;AAE7F,6CAAiF;AAGjF,+BAAyC;AACzC,+BAAyC;AAEzC,qFAAmH;AACnH,+BAA4C;AAC5C,+BAAyC;AACzC,+BAAyC;AACzC,+BAA0C;AAuD1C,MAAa,oBAAoB;IAIrB;IACA;IACA;IACA;IANH,YAAY,CAA8B;IAEjD,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,EAC/B,YAA0B;QAH1B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;QAC/B,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,YAAY,GAAG,IAAI,mEAAkC,CAAC,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3G,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,CAAgC,EAAE,CAAsB;QACzE,IAAI,QAA8B,CAAC;QACnC,IAAI,MAA0B,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC;YACN,QAAQ,GAAG,CAAa,CAAC;YACzB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAuB,CAAC;QACnC,CAAC;QACD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3D,OAAO,MAA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,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,KAAK,GAAG,QAAmB,CAAC;gBAClC,MAAM,QAAQ,GAAG,8BAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvD,OAAO,IAAI,sBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBAChE,MAAM,QAAQ,GAAG,8BAAc,CAAC,UAAU,CAAC;oBACzC,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;iBACpC,CAAC,CAAC;gBACH,OAAO,IAAI,sBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { CCTPDoesNotSupportedError, OFTDoesNotSupportedError } from \"../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3 } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { AlgBridgeService } from \"./alg\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, ChainBridgeService, CheckAllowanceParams, GetAllowanceParams, SendParams } from \"./models\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { SrbBridgeService } from \"./srb\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService);\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = getSpender(approveData.token, approveData.messenger);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).send(params);\n }\n}\n\nexport function getSpender(token: TokenWithChainDetails, messenger: Messenger = Messenger.ALLBRIDGE): string {\n switch (messenger) {\n case Messenger.CCTP:\n if (token.cctpAddress) {\n return token.cctpAddress;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n case Messenger.CCTP_V2:\n if (token.cctpV2Address) {\n return token.cctpV2Address;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP V2 protocol\");\n }\n case Messenger.OFT:\n if (token.oftBridgeAddress) {\n return token.oftBridgeAddress;\n } else {\n throw new OFTDoesNotSupportedError(\"Such route does not support OFT protocol\");\n }\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return token.bridgeAddress;\n }\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterParams: {\n jupiterUrl: params.jupiterUrl,\n jupiterApiKeyHeader: params.jupiterApiKeyHeader,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgBridgeService(algorand, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgBridgeService(algorand, api);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":";;;AAqIA,gCAwBC;AAED,sDAuEC;AAtOD,qEAAmE;AAEnE,qCAAkC;AAClC,+BAA4B;AAE5B,yCAAsC;AACtC,yEAAiE;AAEjE,iDAAuF;AACvF,uCAA6F;AAE7F,6CAAiF;AAGjF,+BAAyC;AACzC,+BAAyC;AAEzC,qFAAmH;AACnH,+BAA4C;AAC5C,+BAAyC;AACzC,+BAAyC;AACzC,+BAAyC;AACzC,+BAA0C;AAuD1C,MAAa,oBAAoB;IAIrB;IACA;IACA;IACA;IANH,YAAY,CAA8B;IAEjD,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,EAC/B,YAA0B;QAH1B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;QAC/B,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,YAAY,GAAG,IAAI,mEAAkC,CAAC,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3G,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,CAAgC,EAAE,CAAsB;QACzE,IAAI,QAA8B,CAAC;QACnC,IAAI,MAA0B,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC;YACN,QAAQ,GAAG,CAAa,CAAC;YACzB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAuB,CAAC;QACnC,CAAC;QACD,MAAM,OAAO,GAAG,U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,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,KAAK,GAAG,QAAmB,CAAC;gBAClC,MAAM,QAAQ,GAAG,8BAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvD,OAAO,IAAI,sBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBAChE,MAAM,QAAQ,GAAG,8BAAc,CAAC,UAAU,CAAC;oBACzC,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;iBACpC,CAAC,CAAC;gBACH,OAAO,IAAI,sBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAChE,OAAO,IAAI,sBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { CCTPDoesNotSupportedError, OFTDoesNotSupportedError } from \"../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3 } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { AlgBridgeService } from \"./alg\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, ChainBridgeService, CheckAllowanceParams, GetAllowanceParams, SendParams } from \"./models\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { SrbBridgeService } from \"./srb\";\nimport { StxBridgeService } from \"./stx\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService);\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = getSpender(approveData.token, approveData.messenger);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).send(params);\n }\n}\n\nexport function getSpender(token: TokenWithChainDetails, messenger: Messenger = Messenger.ALLBRIDGE): string {\n switch (messenger) {\n case Messenger.CCTP:\n if (token.cctpAddress) {\n return token.cctpAddress;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n case Messenger.CCTP_V2:\n if (token.cctpV2Address) {\n return token.cctpV2Address;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP V2 protocol\");\n }\n case Messenger.OFT:\n if (token.oftBridgeAddress) {\n return token.oftBridgeAddress;\n } else {\n throw new OFTDoesNotSupportedError(\"Such route does not support OFT protocol\");\n }\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return token.bridgeAddress;\n }\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterParams: {\n jupiterUrl: params.jupiterUrl,\n jupiterApiKeyHeader: params.jupiterApiKeyHeader,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgBridgeService(algorand, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgBridgeService(algorand, api);\n }\n }\n case ChainType.STX: {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new StxBridgeService(nodeRpcUrl, api);\n }\n }\n}\n"]}
@@ -177,6 +177,7 @@ export type TxSendParamsEvm = TxSendParamsTyped<string>;
177
177
  export type TxSendParamsSui = TxSendParamsTyped<string>;
178
178
  export type TxSendParamsTrx = TxSendParamsTyped<Buffer>;
179
179
  export type TxSendParamsAlg = TxSendParamsTyped<Buffer>;
180
+ export type TxSendParamsStx = TxSendParamsTyped<Buffer>;
180
181
  export type TxSendParamsSol = TxSendParamsTyped<number[]>;
181
182
  export type TxSendParamsSrb = TxSendParamsTyped<number[]>;
182
183
  export interface TxSendParamsTyped<T> {
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenWithChainDetails;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsAlg = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
1
+ {"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenWithChainDetails;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsAlg = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsStx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
@@ -0,0 +1,15 @@
1
+ import { ChainType } from "../../../chains/chain.enums";
2
+ import { AllbridgeCoreClient } from "../../../client/core-api/core-client-base";
3
+ import { RawStxTransaction, TransactionResponse } from "../../models";
4
+ import { ChainBridgeService } from "../models/bridge";
5
+ import { SendParams, SwapParams } from "../models/bridge.model";
6
+ export declare class StxBridgeService extends ChainBridgeService {
7
+ nodeRpcUrl: string;
8
+ api: AllbridgeCoreClient;
9
+ chainType: ChainType.STX;
10
+ private client;
11
+ constructor(nodeRpcUrl: string, api: AllbridgeCoreClient);
12
+ send(_params: SendParams): Promise<TransactionResponse>;
13
+ buildRawTransactionSend(params: SendParams): Promise<RawStxTransaction>;
14
+ buildRawTransactionSwap(params: SwapParams): Promise<RawStxTransaction>;
15
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StxBridgeService = void 0;
4
+ const core_1 = require("@clarigen/core");
5
+ const transactions_1 = require("@stacks/transactions");
6
+ const chain_enums_1 = require("../../../chains/chain.enums");
7
+ const exceptions_1 = require("../../../exceptions");
8
+ const models_1 = require("../../../models");
9
+ const clarigen_types_1 = require("../../models/stx/clarigen-types");
10
+ const get_network_1 = require("../../utils/stx/get-network");
11
+ const post_conditions_1 = require("../../utils/stx/post-conditions");
12
+ const bridge_1 = require("../models/bridge");
13
+ const utils_1 = require("../utils");
14
+ class StxBridgeService extends bridge_1.ChainBridgeService {
15
+ nodeRpcUrl;
16
+ api;
17
+ chainType = chain_enums_1.ChainType.STX;
18
+ client;
19
+ constructor(nodeRpcUrl, api) {
20
+ super();
21
+ this.nodeRpcUrl = nodeRpcUrl;
22
+ this.api = api;
23
+ const network = (0, get_network_1.getStxNetwork)(this.nodeRpcUrl);
24
+ this.client = new core_1.ClarigenClient(network);
25
+ }
26
+ send(_params) {
27
+ throw new exceptions_1.MethodNotSupportedError();
28
+ }
29
+ async buildRawTransactionSend(params) {
30
+ const txSendParams = await (0, utils_1.prepareTxSendParams)(this.chainType, params, this.api);
31
+ const { contractAddress: bridgeAddress, messenger, toChainId, toAccountAddress, toTokenAddress } = txSendParams;
32
+ const amount = BigInt(txSendParams.amount);
33
+ const postFungiblePostCondition = (0, post_conditions_1.getFungiblePostCondition)(amount, "lte", params.fromAccountAddress, params.sourceToken.tokenAddress, "example-token");
34
+ const postStxPostCondition = (0, post_conditions_1.getStxPostCondition)(0, "gte", params.sourceToken.bridgeAddress);
35
+ const postConditions = [postFungiblePostCondition, postStxPostCondition];
36
+ let totalFee = BigInt(txSendParams.fee);
37
+ if (txSendParams.extraGas) {
38
+ totalFee = totalFee + BigInt(txSendParams.extraGas);
39
+ }
40
+ const isPayWithStable = txSendParams.gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN;
41
+ let feeTokenAmount;
42
+ if (isPayWithStable) {
43
+ feeTokenAmount = totalFee;
44
+ }
45
+ else {
46
+ feeTokenAmount = 0n;
47
+ const postUserStxPostCondition = (0, post_conditions_1.getStxPostCondition)(totalFee, "lte", params.fromAccountAddress);
48
+ postConditions.push(postUserStxPostCondition);
49
+ }
50
+ const [contractPrincipal] = (0, transactions_1.parseContractId)(bridgeAddress);
51
+ const bridge = (0, core_1.contractFactory)(clarigen_types_1.stacksContracts.bridge, bridgeAddress);
52
+ const { contractAddress, contractName, functionName, functionArgs } = bridge.swapAndBridge({
53
+ ftRef: params.sourceToken.tokenAddress,
54
+ poolRef: params.sourceToken.poolAddress,
55
+ messengerRef: `${contractPrincipal}.messenger`,
56
+ gasOracleRef: `${contractPrincipal}.gas-oracle`,
57
+ amount,
58
+ recipient: Uint8Array.from(toAccountAddress),
59
+ destinationChainId: toChainId,
60
+ receiveToken: Uint8Array.from(toTokenAddress),
61
+ nonce: Uint8Array.from((0, utils_1.getNonce)()),
62
+ messengerId: messenger,
63
+ feeNativeAmount: totalFee,
64
+ feeTokenAmount: feeTokenAmount,
65
+ });
66
+ const privateKey = (0, transactions_1.makeRandomPrivKey)();
67
+ const publicKey = (0, transactions_1.privateKeyToPublic)(privateKey);
68
+ const txOptions = {
69
+ contractAddress,
70
+ contractName,
71
+ functionName,
72
+ functionArgs,
73
+ publicKey,
74
+ validateWithAbi: true,
75
+ network: this.client.network,
76
+ postConditions,
77
+ postConditionMode: transactions_1.PostConditionMode.Deny,
78
+ };
79
+ const transaction = await (0, transactions_1.makeUnsignedContractCall)(txOptions);
80
+ return transaction.serialize();
81
+ }
82
+ async buildRawTransactionSwap(params) {
83
+ const txSwapParams = (0, utils_1.prepareTxSwapParams)(this.chainType, params);
84
+ const amount = BigInt(txSwapParams.amount);
85
+ const minimumReceiveAmount = BigInt(txSwapParams.minimumReceiveAmount);
86
+ const bridgeAddress = params.sourceToken.bridgeAddress;
87
+ const bridge = (0, core_1.contractFactory)(clarigen_types_1.stacksContracts.bridge, bridgeAddress);
88
+ const { contractAddress, contractName, functionName, functionArgs } = bridge.swap({
89
+ amount,
90
+ sendPoolRef: params.sourceToken.poolAddress,
91
+ sendFtRef: params.sourceToken.tokenAddress,
92
+ receivePoolRef: params.destinationToken.poolAddress,
93
+ receiveFtRef: params.destinationToken.tokenAddress,
94
+ recipient: params.toAccountAddress,
95
+ receiveAmountMin: minimumReceiveAmount,
96
+ });
97
+ const privateKey = (0, transactions_1.makeRandomPrivKey)();
98
+ const publicKey = (0, transactions_1.privateKeyToPublic)(privateKey);
99
+ const postFungibleCondition = (0, post_conditions_1.getFungiblePostCondition)(amount, "lte", params.fromAccountAddress, params.sourceToken.tokenAddress, "example-token");
100
+ const postFungibleMinReceiveCondition = (0, post_conditions_1.getFungiblePostCondition)(minimumReceiveAmount, "gte", params.destinationToken.poolAddress, params.destinationToken.tokenAddress, "example-token");
101
+ const txOptions = {
102
+ contractAddress,
103
+ contractName,
104
+ functionName,
105
+ functionArgs,
106
+ publicKey,
107
+ validateWithAbi: true,
108
+ network: this.client.network,
109
+ postConditions: [postFungibleCondition, postFungibleMinReceiveCondition],
110
+ postConditionMode: transactions_1.PostConditionMode.Deny,
111
+ };
112
+ const transaction = await (0, transactions_1.makeUnsignedContractCall)(txOptions);
113
+ return transaction.serialize();
114
+ }
115
+ }
116
+ exports.StxBridgeService = StxBridgeService;
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/stx/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AACjE,uDAQ8B;AAC9B,6DAAwD;AAExD,oDAA8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,EAAE,MAAM,CAAC,gBAAgB,CAAC,YAAY;YAClD,SAAS,EAAE,MAAM,CAAC,gBAAgB;YAClC,gBAAgB,EAAE,oBAAoB;SACvC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,IAAA,gCAAiB,GAAE,CAAC;QACvC,MAAM,SAAS,GAAG,IAAA,iCAAkB,EAAC,UAAU,CAAC,CAAC;QAEjD,MAAM,qBAAqB,GAAG,IAAA,0CAAwB,EACpD,MAAM,EACN,KAAK,EACL,MAAM,CAAC,kBAAkB,EACzB,MAAM,CAAC,WAAW,CAAC,YAAY,EAC/B,eAAe,CAChB,CAAC;QAEF,MAAM,+BAA+B,GAAG,IAAA,0CAAwB,EAC9D,oBAAoB,EACpB,KAAK,EACL,MAAM,CAAC,gBAAgB,CAAC,WAAW,EACnC,MAAM,CAAC,gBAAgB,CAAC,YAAY,EACpC,eAAe,CAChB,CAAC;QAEF,MAAM,SAAS,GAAG;YAChB,eAAe;YACf,YAAY;YACZ,YAAY;YACZ,YAAY;YACZ,SAAS;YACT,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,cAAc,EAAE,CAAC,qBAAqB,EAAE,+BAA+B,CAAC;YACxE,iBAAiB,EAAE,gCAAiB,CAAC,IAAI;SAC1C,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAwB,EAAC,SAAS,CAAC,CAAC;QAC9D,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;CACF;AAvID,4CAuIC","sourcesContent":["import { ClarigenClient, contractFactory } from \"@clarigen/core\";\nimport {\n ContractIdString,\n makeRandomPrivKey,\n makeUnsignedContractCall,\n parseContractId,\n PostCondition,\n PostConditionMode,\n privateKeyToPublic,\n} from \"@stacks/transactions\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError } from \"../../../exceptions\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { RawStxTransaction, TransactionResponse } from \"../../models\";\nimport { stacksContracts as contracts } from \"../../models/stx/clarigen-types\";\nimport { getStxNetwork } from \"../../utils/stx/get-network\";\nimport { getFungiblePostCondition, getStxPostCondition } from \"../../utils/stx/post-conditions\";\nimport { ChainBridgeService } from \"../models/bridge\";\nimport { SendParams, SwapParams } from \"../models/bridge.model\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class StxBridgeService extends ChainBridgeService {\n chainType: ChainType.STX = ChainType.STX;\n\n private client: ClarigenClient;\n\n constructor(\n public nodeRpcUrl: string,\n public api: AllbridgeCoreClient\n ) {\n super();\n const network = getStxNetwork(this.nodeRpcUrl);\n this.client = new ClarigenClient(network);\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawStxTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { contractAddress: bridgeAddress, messenger, toChainId, toAccountAddress, toTokenAddress } = txSendParams;\n const amount = BigInt(txSendParams.amount);\n\n const postFungiblePostCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n \"example-token\"\n );\n const postStxPostCondition = getStxPostCondition(0, \"gte\", params.sourceToken.bridgeAddress);\n const postConditions: PostCondition[] = [postFungiblePostCondition, postStxPostCondition];\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n const isPayWithStable = txSendParams.gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN;\n\n let feeTokenAmount: bigint;\n if (isPayWithStable) {\n feeTokenAmount = totalFee;\n } else {\n feeTokenAmount = 0n;\n const postUserStxPostCondition = getStxPostCondition(totalFee, \"lte\", params.fromAccountAddress);\n postConditions.push(postUserStxPostCondition);\n }\n\n const [contractPrincipal] = parseContractId(bridgeAddress as ContractIdString);\n\n const bridge = contractFactory(contracts.bridge, bridgeAddress);\n const { contractAddress, contractName, functionName, functionArgs } = bridge.swapAndBridge({\n ftRef: params.sourceToken.tokenAddress,\n poolRef: params.sourceToken.poolAddress,\n messengerRef: `${contractPrincipal}.messenger`,\n gasOracleRef: `${contractPrincipal}.gas-oracle`,\n amount,\n recipient: Uint8Array.from(toAccountAddress),\n destinationChainId: toChainId,\n receiveToken: Uint8Array.from(toTokenAddress),\n nonce: Uint8Array.from(getNonce()),\n messengerId: messenger,\n feeNativeAmount: totalFee,\n feeTokenAmount: feeTokenAmount,\n });\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions,\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawStxTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n const amount = BigInt(txSwapParams.amount);\n const minimumReceiveAmount = BigInt(txSwapParams.minimumReceiveAmount);\n\n const bridgeAddress = params.sourceToken.bridgeAddress;\n const bridge = contractFactory(contracts.bridge, bridgeAddress);\n const { contractAddress, contractName, functionName, functionArgs } = bridge.swap({\n amount,\n sendPoolRef: params.sourceToken.poolAddress,\n sendFtRef: params.sourceToken.tokenAddress,\n receivePoolRef: params.destinationToken.poolAddress,\n receiveFtRef: params.destinationToken.tokenAddress,\n recipient: params.toAccountAddress,\n receiveAmountMin: minimumReceiveAmount,\n });\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const postFungibleCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n \"example-token\"\n );\n\n const postFungibleMinReceiveCondition = getFungiblePostCondition(\n minimumReceiveAmount,\n \"gte\",\n params.destinationToken.poolAddress,\n params.destinationToken.tokenAddress,\n \"example-token\"\n );\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions: [postFungibleCondition, postFungibleMinReceiveCondition],\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n}\n"]}
@@ -2,7 +2,7 @@ import { Messenger } from "../../client/core-api/core-api.model";
2
2
  import { AllbridgeCoreClient } from "../../client/core-api/core-client-base";
3
3
  import { ChainType, ExtraGasMaxLimitResponse, GasFeeOptions, SwapParams } from "../../models";
4
4
  import { ChainDetailsMap, TokenWithChainDetails } from "../../tokens-info";
5
- import { SendParams, TxSendParams, TxSendParamsAlg, TxSendParamsEvm, TxSendParamsSol, TxSendParamsSrb, TxSendParamsSui, TxSendParamsTrx, TxSwapParams, TxSwapParamsEvm, TxSwapParamsSol, TxSwapParamsSrb, TxSwapParamsSui, TxSwapParamsTrx } from "./models";
5
+ import { SendParams, TxSendParams, TxSendParamsAlg, TxSendParamsEvm, TxSendParamsSol, TxSendParamsSrb, TxSendParamsStx, TxSendParamsSui, TxSendParamsTrx, TxSwapParams, TxSwapParamsEvm, TxSwapParamsSol, TxSwapParamsSrb, TxSwapParamsSui, TxSwapParamsTrx } from "./models";
6
6
  export declare function formatAddress(address: string, from: ChainType, to: ChainType.EVM | ChainType.SUI): string;
7
7
  export declare function formatAddress(address: string, from: ChainType, to: ChainType.TRX): Buffer;
8
8
  export declare function formatAddress(address: string, from: ChainType, to: ChainType.SOLANA | ChainType.SRB): number[];
@@ -11,6 +11,7 @@ export declare function normalizeSuiHex(hex: string): string;
11
11
  export declare function hexToBuffer(hex: string): Buffer;
12
12
  export declare function evmAddressToBuffer32(address: string): Buffer;
13
13
  export declare function algAddressToBuffer32(address: string): Buffer;
14
+ export declare function stxAddressToBuffer32(address: string): Buffer;
14
15
  export declare function tronAddressToBuffer32(address: string): Buffer;
15
16
  export declare function tronAddressToEthAddress(address: string): string;
16
17
  export declare function getTokenByTokenAddress(chainDetailsMap: ChainDetailsMap, chainSymbol: string, tokenAddress: string): TokenWithChainDetails;
@@ -23,6 +24,7 @@ export declare function prepareTxSwapParams(bridgeChainType: ChainType, params:
23
24
  export declare function prepareTxSendParams(bridgeChainType: ChainType.EVM | ChainType.SUI, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsEvm | TxSendParamsSui>;
24
25
  export declare function prepareTxSendParams(bridgeChainType: ChainType.TRX, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsTrx>;
25
26
  export declare function prepareTxSendParams(bridgeChainType: ChainType.ALG, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsAlg>;
27
+ export declare function prepareTxSendParams(bridgeChainType: ChainType.STX, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsStx>;
26
28
  export declare function prepareTxSendParams(bridgeChainType: ChainType.SOLANA | ChainType.SRB, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsSol | TxSendParamsSrb>;
27
29
  export declare function prepareTxSendParams(bridgeChainType: ChainType, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParams>;
28
30
  export declare function getGasFeeOptions(sourceChainToken: TokenWithChainDetails, destinationAllbridgeChainId: number, messenger: Messenger, api: AllbridgeCoreClient): Promise<GasFeeOptions>;
@@ -31,6 +31,7 @@ exports.normalizeSuiHex = normalizeSuiHex;
31
31
  exports.hexToBuffer = hexToBuffer;
32
32
  exports.evmAddressToBuffer32 = evmAddressToBuffer32;
33
33
  exports.algAddressToBuffer32 = algAddressToBuffer32;
34
+ exports.stxAddressToBuffer32 = stxAddressToBuffer32;
34
35
  exports.tronAddressToBuffer32 = tronAddressToBuffer32;
35
36
  exports.tronAddressToEthAddress = tronAddressToEthAddress;
36
37
  exports.getTokenByTokenAddress = getTokenByTokenAddress;
@@ -42,11 +43,13 @@ exports.getGasFeeOptions = getGasFeeOptions;
42
43
  exports.getExtraGasMaxLimits = getExtraGasMaxLimits;
43
44
  exports.isSendParams = isSendParams;
44
45
  const web3_js_1 = require("@solana/web3.js");
46
+ const transactions_1 = require("@stacks/transactions");
45
47
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
46
48
  const algosdk_1 = __importStar(require("algosdk"));
47
49
  const big_js_1 = require("big.js");
48
50
  const randombytes_1 = __importDefault(require("randombytes"));
49
51
  const tronweb_1 = require("tronweb");
52
+ const web3_1 = require("web3");
50
53
  const chains_1 = require("../../chains");
51
54
  const core_api_model_1 = require("../../client/core-api/core-api.model");
52
55
  const exceptions_1 = require("../../exceptions");
@@ -80,6 +83,10 @@ function formatAddress(address, from, to) {
80
83
  buffer = algAddressToBuffer32(address);
81
84
  break;
82
85
  }
86
+ case models_1.ChainType.STX: {
87
+ buffer = stxAddressToBuffer32(address);
88
+ break;
89
+ }
83
90
  }
84
91
  switch (to) {
85
92
  case models_1.ChainType.EVM: {
@@ -100,6 +107,9 @@ function formatAddress(address, from, to) {
100
107
  case models_1.ChainType.ALG: {
101
108
  return buffer;
102
109
  }
110
+ case models_1.ChainType.STX: {
111
+ return buffer;
112
+ }
103
113
  }
104
114
  }
105
115
  function normalizeSuiHex(hex) {
@@ -124,6 +134,19 @@ function algAddressToBuffer32(address) {
124
134
  }
125
135
  throw new exceptions_1.SdkError(`Unexpected Alg address: ${address}`);
126
136
  }
137
+ function stxAddressToBuffer32(address) {
138
+ if (address.includes(".")) {
139
+ const [addr, name] = (0, transactions_1.parseContractId)(address);
140
+ if (!addr || !name) {
141
+ throw new exceptions_1.SdkError(`Unexpected Alg address: ${address}`);
142
+ }
143
+ const hashBytes = Buffer.from((0, transactions_1.createAddress)(addr).hash160, "hex");
144
+ const hash = web3_1.Web3.utils.keccak256(Buffer.concat([hashBytes, Buffer.from(name)]));
145
+ return hexToBuffer(hash);
146
+ }
147
+ const hashBytes = Buffer.from((0, transactions_1.createAddress)(address).hash160, "hex");
148
+ return bufferToSize(hashBytes, 32);
149
+ }
127
150
  function tronAddressToBuffer32(address) {
128
151
  const ethAddress = tronAddressToEthAddress(address);
129
152
  const buffer = hexToBuffer(ethAddress);