From 9f915d90978beb703e9ec0b3cb507472ab877a72 Mon Sep 17 00:00:00 2001 From: npty <78221556+npty@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:52:33 +0700 Subject: [PATCH] feat: add stellar add gas function (#338) --- package.json | 5 +- pnpm-lock.yaml | 247 +++++++++++++++--- src/constants/GasToken.ts | 2 - .../AxelarGMPRecoveryAPI.ts | 79 ++++++ .../constants/chain/mainnet.ts | 5 - .../constants/chain/testnet.ts | 5 - .../helpers/stellarHelper.ts | 16 ++ 7 files changed, 304 insertions(+), 55 deletions(-) create mode 100644 src/libs/TransactionRecoveryApi/helpers/stellarHelper.ts diff --git a/package.json b/package.json index 4c5b4f6..a415b84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@axelar-network/axelarjs-sdk", - "version": "0.17.0", + "version": "0.17.1-alpha.9", "description": "The JavaScript SDK for Axelar Network", "repository": { "type": "git", @@ -48,6 +48,7 @@ "@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/networks": "^5.7.1", "@ethersproject/providers": "^5.7.2", + "@stellar/stellar-sdk": "^13.0.0", "@types/uuid": "^8.3.1", "bech32": "^2.0.0", "clone-deep": "^4.0.1", @@ -89,7 +90,7 @@ "rimraf": "^5.0.1", "strip-ansi": "^6.0.0", "ts-node": "^10.9.1", - "typescript": "^4.8.4", + "typescript": "^5.6.3", "vitest": "^0.32.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7067b17..c917d0d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ dependencies: '@ethersproject/providers': specifier: ^5.7.2 version: 5.7.2 + '@stellar/stellar-sdk': + specifier: ^13.0.0 + version: 13.0.0 '@types/uuid': specifier: ^8.3.1 version: 8.3.1 @@ -87,10 +90,10 @@ devDependencies: version: 2.0.1 '@typescript-eslint/eslint-plugin': specifier: ^5.39.0 - version: 5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@4.8.4) + version: 5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@5.6.3) '@typescript-eslint/parser': specifier: ^5.30.0 - version: 5.30.0(eslint@8.24.0)(typescript@4.8.4) + version: 5.30.0(eslint@8.24.0)(typescript@5.6.3) chalk: specifier: ^4.1.2 version: 4.1.2 @@ -105,7 +108,7 @@ devDependencies: version: 8.8.0(eslint@8.24.0) eslint-config-standard-with-typescript: specifier: ^23.0.0 - version: 23.0.0(@typescript-eslint/eslint-plugin@5.39.0)(eslint-plugin-import@2.26.0)(eslint-plugin-n@15.3.0)(eslint-plugin-promise@6.0.1)(eslint@8.24.0)(typescript@4.8.4) + version: 23.0.0(@typescript-eslint/eslint-plugin@5.39.0)(eslint-plugin-import@2.26.0)(eslint-plugin-n@15.3.0)(eslint-plugin-promise@6.0.1)(eslint@8.24.0)(typescript@5.6.3) eslint-plugin-import: specifier: ^2.26.0 version: 2.26.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0) @@ -144,10 +147,10 @@ devDependencies: version: 6.0.1 ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@20.2.5)(typescript@4.8.4) + version: 10.9.1(@types/node@20.2.5)(typescript@5.6.3) typescript: - specifier: ^4.8.4 - version: 4.8.4 + specifier: ^5.6.3 + version: 5.6.3 vitest: specifier: ^0.32.0 version: 0.32.0 @@ -2196,6 +2199,38 @@ packages: resolution: {integrity: sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==} dev: false + /@stellar/js-xdr@3.1.2: + resolution: {integrity: sha512-VVolPL5goVEIsvuGqDc5uiKxV03lzfWdvYg1KikvwheDmTBO68CKDji3bAZ/kppZrx5iTA8z3Ld5yuytcvhvOQ==} + dev: false + + /@stellar/stellar-base@13.0.1: + resolution: {integrity: sha512-Xbd12mc9Oj/130Tv0URmm3wXG77XMshZtZ2yNCjqX5ZbMD5IYpbBs3DVCteLU/4SLj/Fnmhh1dzhrQXnk4r+pQ==} + dependencies: + '@stellar/js-xdr': 3.1.2 + base32.js: 0.1.0 + bignumber.js: 9.1.2 + buffer: 6.0.3 + sha.js: 2.4.11 + tweetnacl: 1.0.3 + optionalDependencies: + sodium-native: 4.3.1 + dev: false + + /@stellar/stellar-sdk@13.0.0: + resolution: {integrity: sha512-+wvmKi+XWwu27nLYTM17EgBdpbKohEkOfCIK4XKfsI4WpMXAqvnqSm98i9h5dAblNB+w8BJqzGs1JY0PtTGm4A==} + dependencies: + '@stellar/stellar-base': 13.0.1 + axios: 1.7.7 + bignumber.js: 9.1.2 + eventsource: 2.0.2 + feaxios: 0.0.20 + randombytes: 2.1.0 + toml: 3.0.0 + urijs: 1.19.11 + transitivePeerDependencies: + - debug + dev: false + /@szmarczak/http-timer@5.0.1: resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==} engines: {node: '>=14.16'} @@ -2300,7 +2335,7 @@ packages: resolution: {integrity: sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==} dev: false - /@typescript-eslint/eslint-plugin@5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@4.8.4): + /@typescript-eslint/eslint-plugin@5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@5.6.3): resolution: {integrity: sha512-xVfKOkBm5iWMNGKQ2fwX5GVgBuHmZBO1tCRwXmY5oAIsPscfwm2UADDuNB8ZVYCtpQvJK4xpjrK7jEhcJ0zY9A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2311,22 +2346,22 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@5.6.3) '@typescript-eslint/scope-manager': 5.39.0 - '@typescript-eslint/type-utils': 5.39.0(eslint@8.24.0)(typescript@4.8.4) - '@typescript-eslint/utils': 5.39.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/type-utils': 5.39.0(eslint@8.24.0)(typescript@5.6.3) + '@typescript-eslint/utils': 5.39.0(eslint@8.24.0)(typescript@5.6.3) debug: 4.3.4 eslint: 8.24.0 ignore: 5.2.4 regexpp: 3.2.0 semver: 7.5.1 - tsutils: 3.21.0(typescript@4.8.4) - typescript: 4.8.4 + tsutils: 3.21.0(typescript@5.6.3) + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.30.0(eslint@8.24.0)(typescript@4.8.4): + /@typescript-eslint/parser@5.30.0(eslint@8.24.0)(typescript@5.6.3): resolution: {integrity: sha512-2oYYUws5o2liX6SrFQ5RB88+PuRymaM2EU02/9Ppoyu70vllPnHVO7ioxDdq/ypXHA277R04SVjxvwI8HmZpzA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2338,10 +2373,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.30.0 '@typescript-eslint/types': 5.30.0 - '@typescript-eslint/typescript-estree': 5.30.0(typescript@4.8.4) + '@typescript-eslint/typescript-estree': 5.30.0(typescript@5.6.3) debug: 4.3.4 eslint: 8.24.0 - typescript: 4.8.4 + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true @@ -2362,7 +2397,7 @@ packages: '@typescript-eslint/visitor-keys': 5.39.0 dev: true - /@typescript-eslint/type-utils@5.39.0(eslint@8.24.0)(typescript@4.8.4): + /@typescript-eslint/type-utils@5.39.0(eslint@8.24.0)(typescript@5.6.3): resolution: {integrity: sha512-KJHJkOothljQWzR3t/GunL0TPKY+fGJtnpl+pX+sJ0YiKTz3q2Zr87SGTmFqsCMFrLt5E0+o+S6eQY0FAXj9uA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2372,12 +2407,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.39.0(typescript@4.8.4) - '@typescript-eslint/utils': 5.39.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/typescript-estree': 5.39.0(typescript@5.6.3) + '@typescript-eslint/utils': 5.39.0(eslint@8.24.0)(typescript@5.6.3) debug: 4.3.4 eslint: 8.24.0 - tsutils: 3.21.0(typescript@4.8.4) - typescript: 4.8.4 + tsutils: 3.21.0(typescript@5.6.3) + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true @@ -2392,7 +2427,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.30.0(typescript@4.8.4): + /@typescript-eslint/typescript-estree@5.30.0(typescript@5.6.3): resolution: {integrity: sha512-hDEawogreZB4n1zoqcrrtg/wPyyiCxmhPLpZ6kmWfKF5M5G0clRLaEexpuWr31fZ42F96SlD/5xCt1bT5Qm4Nw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2407,13 +2442,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.1 - tsutils: 3.21.0(typescript@4.8.4) - typescript: 4.8.4 + tsutils: 3.21.0(typescript@5.6.3) + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/typescript-estree@5.39.0(typescript@4.8.4): + /@typescript-eslint/typescript-estree@5.39.0(typescript@5.6.3): resolution: {integrity: sha512-qLFQP0f398sdnogJoLtd43pUgB18Q50QSA+BTE5h3sUxySzbWDpTSdgt4UyxNSozY/oDK2ta6HVAzvGgq8JYnA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2428,13 +2463,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.1 - tsutils: 3.21.0(typescript@4.8.4) - typescript: 4.8.4 + tsutils: 3.21.0(typescript@5.6.3) + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.39.0(eslint@8.24.0)(typescript@4.8.4): + /@typescript-eslint/utils@5.39.0(eslint@8.24.0)(typescript@5.6.3): resolution: {integrity: sha512-+DnY5jkpOpgj+EBtYPyHRjXampJfC0yUZZzfzLuUWVZvCuKqSdJVC8UhdWipIw7VKNTfwfAPiOWzYkAwuIhiAg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2443,7 +2478,7 @@ packages: '@types/json-schema': 7.0.12 '@typescript-eslint/scope-manager': 5.39.0 '@typescript-eslint/types': 5.39.0 - '@typescript-eslint/typescript-estree': 5.39.0(typescript@4.8.4) + '@typescript-eslint/typescript-estree': 5.39.0(typescript@5.6.3) eslint: 8.24.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.24.0) @@ -2666,6 +2701,10 @@ packages: lodash: 4.17.21 dev: true + /asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: false + /available-typed-arrays@1.0.5: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} @@ -2689,6 +2728,16 @@ packages: transitivePeerDependencies: - debug + /axios@1.7.7: + resolution: {integrity: sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==} + dependencies: + follow-redirects: 1.15.9 + form-data: 4.0.1 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + dev: false + /babel-plugin-polyfill-corejs2@0.3.3(@babel/core@7.22.1): resolution: {integrity: sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==} peerDependencies: @@ -2729,6 +2778,11 @@ packages: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true + /base32.js@0.1.0: + resolution: {integrity: sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==} + engines: {node: '>=0.12.0'} + dev: false + /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -2739,6 +2793,10 @@ packages: resolution: {integrity: sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==} dev: false + /bignumber.js@9.1.2: + resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} + dev: false + /binary-extensions@2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} @@ -2793,7 +2851,6 @@ packages: dependencies: base64-js: 1.5.1 ieee754: 1.2.1 - dev: true /bufferutil@4.0.5: resolution: {integrity: sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==} @@ -2932,6 +2989,13 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true + /combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + dev: false + /concat-map@0.0.1: resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: true @@ -3081,6 +3145,11 @@ packages: has-property-descriptors: 1.0.0 object-keys: 1.1.1 + /delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + dev: false + /diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -3282,7 +3351,7 @@ packages: eslint: 8.24.0 dev: true - /eslint-config-standard-with-typescript@23.0.0(@typescript-eslint/eslint-plugin@5.39.0)(eslint-plugin-import@2.26.0)(eslint-plugin-n@15.3.0)(eslint-plugin-promise@6.0.1)(eslint@8.24.0)(typescript@4.8.4): + /eslint-config-standard-with-typescript@23.0.0(@typescript-eslint/eslint-plugin@5.39.0)(eslint-plugin-import@2.26.0)(eslint-plugin-n@15.3.0)(eslint-plugin-promise@6.0.1)(eslint@8.24.0)(typescript@5.6.3): resolution: {integrity: sha512-iaaWifImn37Z1OXbNW1es7KI+S7D408F9ys0bpaQf2temeBWlvb0Nc5qHkOgYaRb5QxTZT32GGeN1gtswASOXA==} peerDependencies: '@typescript-eslint/eslint-plugin': ^5.0.0 @@ -3292,14 +3361,14 @@ packages: eslint-plugin-promise: ^6.0.0 typescript: '*' dependencies: - '@typescript-eslint/eslint-plugin': 5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@4.8.4) - '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/eslint-plugin': 5.39.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0)(typescript@5.6.3) + '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@5.6.3) eslint: 8.24.0 eslint-config-standard: 17.0.0(eslint-plugin-import@2.26.0)(eslint-plugin-n@15.3.0)(eslint-plugin-promise@6.0.1)(eslint@8.24.0) eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.30.0)(eslint@8.24.0) eslint-plugin-n: 15.3.0(eslint@8.24.0) eslint-plugin-promise: 6.0.1(eslint@8.24.0) - typescript: 4.8.4 + typescript: 5.6.3 transitivePeerDependencies: - supports-color dev: true @@ -3349,7 +3418,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@5.6.3) debug: 3.2.7(supports-color@5.5.0) eslint: 8.24.0 eslint-import-resolver-node: 0.3.7 @@ -3378,7 +3447,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@4.8.4) + '@typescript-eslint/parser': 5.30.0(eslint@8.24.0)(typescript@5.6.3) array-includes: 3.1.6 array.prototype.flat: 1.3.1 debug: 2.6.9 @@ -3613,6 +3682,11 @@ packages: - bufferutil - utf-8-validate + /eventsource@2.0.2: + resolution: {integrity: sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==} + engines: {node: '>=12.0.0'} + dev: false + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -3646,6 +3720,12 @@ packages: reusify: 1.0.4 dev: true + /feaxios@0.0.20: + resolution: {integrity: sha512-g3hm2YDNffNxA3Re3Hd8ahbpmDee9Fv1Pb1C/NoWsjY7mtD8nyNeJytUzn+DK0Hyl9o6HppeWOrtnqgmhOYfWA==} + dependencies: + is-retry-allowed: 3.0.0 + dev: false + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -3689,6 +3769,16 @@ packages: debug: optional: true + /follow-redirects@1.15.9: + resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: false + /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: @@ -3708,6 +3798,15 @@ packages: engines: {node: '>= 14.17'} dev: true + /form-data@4.0.1: + resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: false + /fs-extra@10.1.0: resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} engines: {node: '>=12'} @@ -3975,7 +4074,6 @@ packages: /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - dev: true /ignore-by-default@1.0.1: resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==} @@ -4127,6 +4225,11 @@ packages: has-tostringtag: 1.0.0 dev: true + /is-retry-allowed@3.0.0: + resolution: {integrity: sha512-9xH0xvoggby+u0uGF7cZXdrutWiBiaFG8ZT4YFPXL8NzkyAwX3AKGLeFQLvzDpM430+nDFBZ1LHkie/8ocL06A==} + engines: {node: '>=12'} + dev: false + /is-shared-array-buffer@1.0.2: resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==} dependencies: @@ -4441,6 +4544,18 @@ packages: picomatch: 2.3.1 dev: true + /mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: false + + /mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: false + /mimic-response@3.1.0: resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} engines: {node: '>=10'} @@ -4549,6 +4664,13 @@ packages: requiresBuild: true dev: true + /node-gyp-build@4.8.3: + resolution: {integrity: sha512-EMS95CMJzdoSKoIiXo8pxKoL8DYxwIZXYlLmgPb8KUv794abpnLK6ynsCAWNliOjREKruYKdzbh76HHYUHX7nw==} + hasBin: true + requiresBuild: true + dev: false + optional: true + /node-releases@2.0.12: resolution: {integrity: sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==} dev: true @@ -4866,6 +4988,10 @@ packages: long: 5.2.3 dev: false + /proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + dev: false + /pstree.remy@1.1.8: resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==} dev: true @@ -4884,6 +5010,12 @@ packages: engines: {node: '>=10'} dev: true + /randombytes@2.1.0: + resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + dependencies: + safe-buffer: 5.2.1 + dev: false + /rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true @@ -5055,7 +5187,6 @@ packages: /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - dev: true /safe-regex-test@1.0.0: resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} @@ -5101,6 +5232,14 @@ packages: lru-cache: 6.0.0 dev: true + /sha.js@2.4.11: + resolution: {integrity: sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==} + hasBin: true + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + dev: false + /shallow-clone@3.0.1: resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} engines: {node: '>=8'} @@ -5189,6 +5328,14 @@ packages: - supports-color dev: false + /sodium-native@4.3.1: + resolution: {integrity: sha512-YdP64gAdpIKHfL4ttuX4aIfjeunh9f+hNeQJpE9C8UMndB3zkgZ7YmmGT4J2+v6Ibyp6Wem8D1TcSrtdW0bqtg==} + requiresBuild: true + dependencies: + node-gyp-build: 4.8.3 + dev: false + optional: true + /source-map-js@1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} @@ -5389,6 +5536,10 @@ packages: is-number: 7.0.0 dev: true + /toml@3.0.0: + resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==} + dev: false + /touch@3.1.0: resolution: {integrity: sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==} hasBin: true @@ -5400,7 +5551,7 @@ packages: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: false - /ts-node@10.9.1(@types/node@20.2.5)(typescript@4.8.4): + /ts-node@10.9.1(@types/node@20.2.5)(typescript@5.6.3): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -5426,7 +5577,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 4.8.4 + typescript: 5.6.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -5444,16 +5595,20 @@ packages: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true - /tsutils@3.21.0(typescript@4.8.4): + /tsutils@3.21.0(typescript@5.6.3): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 4.8.4 + typescript: 5.6.3 dev: true + /tweetnacl@1.0.3: + resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} + dev: false + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -5485,6 +5640,12 @@ packages: hasBin: true dev: true + /typescript@5.6.3: + resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} + engines: {node: '>=14.17'} + hasBin: true + dev: true + /ufo@1.1.2: resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} dev: true @@ -5547,6 +5708,10 @@ packages: punycode: 2.3.0 dev: true + /urijs@1.19.11: + resolution: {integrity: sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==} + dev: false + /utf-8-validate@5.0.7: resolution: {integrity: sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==} engines: {node: '>=6.14.2'} diff --git a/src/constants/GasToken.ts b/src/constants/GasToken.ts index 17c46ce..b869211 100644 --- a/src/constants/GasToken.ts +++ b/src/constants/GasToken.ts @@ -45,7 +45,6 @@ export const nativeGasTokenSymbol: Record = { [GMPStatus.CANNOT_FETCH_STATUS]: ApproveGatewayError.FETCHING_STATUS_FAILED, [GMPStatus.DEST_EXECUTED]: ApproveGatewayError.ALREADY_EXECUTED, @@ -115,6 +118,15 @@ export type SendOptions = { timeoutTimestamp?: number; }; +export type AddGasStellarParams = { + senderAddress: string; // the contract address that initiates the gateway contract call. + tokenAddress?: string; // defaults to native token, XLM. + contractAddress?: string; // custom contract address. this will be useful for testnet since it's reset every quarter. + amount: string; // the token amount to pay for the gas fee + spender: string; // The address that pays for the gas fee. + messageId: string; // The message ID of the transaction. +}; + export type AutocalculateGasOptions = { gasMultipler?: number; }; @@ -859,6 +871,73 @@ export class AxelarGMPRecoveryAPI extends AxelarRecoveryApi { } } + /** + * Builds an XDR transaction to add gas payment to the Axelar Gas Service contract. + * + * This function creates a Stellar transaction that adds gas payment to the Axelar Gas Service. + * The payment is made in native XLM token by default and is used to cover the execution costs of + * cross-chain messages. + * + * @example + * ```typescript + * const xdr = await sdk.addGasToStellarChain{ + * senderAddress: 'GCXXX...', // The address that sent the cross-chain message via the `axelar_gateway` + * messageId: 'tx-123', + * amount: '10000000', // the token amount to pay for the gas fee + * spender: 'GXXX...' // The spender pays for the gas fee. + * }); + * + * // Sign with Freighter wallet + * const signedXDR = await window.freighter.signTransaction(xdr); + * ``` + * + * @param {AddGasStellarParams} params - The parameters for the add gas transaction + * @returns {Promise} The transaction encoded as an XDR string, ready for signing + */ + public async addGasToStellarChain(params: AddGasStellarParams): Promise { + const isDevnet = this.environment === Environment.DEVNET; + + // TODO: remove this once this supports on mainnet + if (!isDevnet) throw new Error("This method only supports on devnet"); + + const { senderAddress, messageId, contractAddress, tokenAddress, amount, spender } = params; + + // TODO: Replace with the value from the config file + const contractId = + contractAddress || "CDBPOARU5MFSC7ZWXTVPVKDZRHKOPS5RCY2VP2OKOBLCMQM3NKVP6HO7"; + + const server = new StellarSdk.rpc.Server("https://soroban-testnet.stellar.org"); + + // this will be StellarSdk.Networks.PUBLIC once mainnet is supported + const networkPassphrase = StellarSdk.Networks.TESTNET; + + const caller = StellarSdk.nativeToScVal(StellarSdk.Address.fromString(senderAddress), { + type: "address", + }); + + const contract = new StellarSdk.Contract(contractId); + const nativeAssetAddress = StellarSdk.Asset.native().contractId(networkPassphrase); + + const operation = contract.call( + "add_gas", + caller, + StellarSdk.nativeToScVal(messageId, { type: "string" }), + StellarSdk.nativeToScVal(spender, { type: "address" }), + tokenToScVal(tokenAddress || nativeAssetAddress, amount || "1") + ); + + const spenderAccount = await server.getAccount(spender); + const transaction = new StellarSdk.TransactionBuilder(spenderAccount, { + fee: StellarSdk.BASE_FEE, + networkPassphrase, + }) + .addOperation(operation) + .setTimeout(30) + .build(); + + return transaction.toXDR(); + } + public async addGasToCosmosChain({ gasLimit, autocalculateGasOptions, diff --git a/src/libs/TransactionRecoveryApi/constants/chain/mainnet.ts b/src/libs/TransactionRecoveryApi/constants/chain/mainnet.ts index b891186..c7b0af4 100644 --- a/src/libs/TransactionRecoveryApi/constants/chain/mainnet.ts +++ b/src/libs/TransactionRecoveryApi/constants/chain/mainnet.ts @@ -9,7 +9,6 @@ export const rpcMap: Partial> = { [EvmChain.ETHEREUM]: "https://ethereum.publicnode.com", [EvmChain.AURORA]: "https://mainnet.aurora.dev", [EvmChain.BINANCE]: "https://bsc-dataseed.binance.org", - [EvmChain.BNBCHAIN]: "https://bsc-dataseed.binance.org", [EvmChain.ARBITRUM]: "https://arb1.arbitrum.io/rpc", [EvmChain.CELO]: "https://forno.celo.org", [EvmChain.KAVA]: "https://evm.kava.io", @@ -63,10 +62,6 @@ export const networkInfo: Partial> = { chainId: 56, name: EvmChain.BINANCE, }, - [EvmChain.BNBCHAIN]: { - chainId: 56, - name: EvmChain.BNBCHAIN, - }, [EvmChain.ARBITRUM]: { chainId: 42161, name: EvmChain.ARBITRUM, diff --git a/src/libs/TransactionRecoveryApi/constants/chain/testnet.ts b/src/libs/TransactionRecoveryApi/constants/chain/testnet.ts index afd7d8e..f596163 100644 --- a/src/libs/TransactionRecoveryApi/constants/chain/testnet.ts +++ b/src/libs/TransactionRecoveryApi/constants/chain/testnet.ts @@ -8,7 +8,6 @@ export const rpcMap: Record = { [EvmChain.AVALANCHE]: "https://api.avax-test.network/ext/bc/C/rpc", [EvmChain.AURORA]: "https://testnet.aurora.dev", [EvmChain.BINANCE]: "https://data-seed-prebsc-1-s1.binance.org:8545", - [EvmChain.BNBCHAIN]: "https://data-seed-prebsc-1-s1.binance.org:8545", [EvmChain.CELO]: "https://alfajores-forno.celo-testnet.org", [EvmChain.KAVA]: "https://evm.testnet.kava.io", "filecoin-2": "https://rpc.ankr.com/filecoin_testnet", @@ -57,10 +56,6 @@ export const networkInfo: Record = { chainId: 97, name: EvmChain.BINANCE, }, - [EvmChain.BNBCHAIN]: { - chainId: 97, - name: EvmChain.BNBCHAIN, - }, [EvmChain.CELO]: { chainId: 44787, name: EvmChain.CELO, diff --git a/src/libs/TransactionRecoveryApi/helpers/stellarHelper.ts b/src/libs/TransactionRecoveryApi/helpers/stellarHelper.ts new file mode 100644 index 0000000..524e99c --- /dev/null +++ b/src/libs/TransactionRecoveryApi/helpers/stellarHelper.ts @@ -0,0 +1,16 @@ +import { nativeToScVal, Address } from "@stellar/stellar-sdk"; + +export function tokenToScVal(tokenAddress: string, tokenAmount: string) { + return nativeToScVal( + { + address: Address.fromString(tokenAddress), + amount: tokenAmount, + }, + { + type: { + address: ["symbol", "address"], + amount: ["symbol", "i128"], + }, + } + ); +}