From 814c792f31055c2f86a74728eb7c98a54afb73a8 Mon Sep 17 00:00:00 2001 From: nikspz <83953535+nikspz@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:16:14 +0700 Subject: [PATCH 1/3] fix/ update package.json on staging --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31f467fc88..c4c0e1ec69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hummingbot-gateway", - "version": "1.16.0", + "version": "1.17.0", "description": "Middleware that helps Hummingbot clients access standardized DEX API endpoints on different blockchain networks", "main": "index.js", "license": "Apache-2.0", From 5d5dd22b36824fee0b1d94dd403f018019951625 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 13:37:38 +0000 Subject: [PATCH 2/3] Bump socket.io-parser from 4.2.2 to 4.2.4 Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.2 to 4.2.4. - [Release notes](https://github.com/socketio/socket.io-parser/releases) - [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/socket.io-parser/compare/4.2.2...4.2.4) --- updated-dependencies: - dependency-name: socket.io-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 370 +++++++++++++++++++++++++++--------------------------- 1 file changed, 185 insertions(+), 185 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7d06a4b314..1b59d4a6e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -987,137 +987,137 @@ "@ethersproject-xdc/abi@file:vendor/@ethersproject-xdc/abi": version "5.7.0" dependencies: - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/hash" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/hash" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abi-5.7.0-96d078a1-80cd-4b7a-9730-dedded86cc1b-1686225288604/node_modules/@ethersproject-xdc/strings" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/hash" "file:vendor/@ethersproject-xdc/hash" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" "@ethersproject-xdc/abstract-provider@file:vendor/@ethersproject-xdc/abstract-provider": version "5.7.0" dependencies: - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/networks" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/networks" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/transactions" - "@ethersproject-xdc/web" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-provider-5.7.0-5e41186b-3d49-41fa-b218-d2a9b551688e-1686225288603/node_modules/@ethersproject-xdc/web" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/networks" "file:vendor/@ethersproject-xdc/networks" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" + "@ethersproject-xdc/web" "file:vendor/@ethersproject-xdc/web" "@ethersproject-xdc/abstract-signer@file:vendor/@ethersproject-xdc/abstract-signer": version "5.7.0" dependencies: - "@ethersproject-xdc/abstract-provider" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-signer-5.7.0-ad6702a7-47b2-4a62-8e93-4110c299c077-1686225288602/node_modules/@ethersproject-xdc/abstract-provider" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-signer-5.7.0-ad6702a7-47b2-4a62-8e93-4110c299c077-1686225288602/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-signer-5.7.0-ad6702a7-47b2-4a62-8e93-4110c299c077-1686225288602/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-signer-5.7.0-ad6702a7-47b2-4a62-8e93-4110c299c077-1686225288602/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-abstract-signer-5.7.0-ad6702a7-47b2-4a62-8e93-4110c299c077-1686225288602/node_modules/@ethersproject-xdc/properties" + "@ethersproject-xdc/abstract-provider" "file:vendor/@ethersproject-xdc/abstract-provider" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" "@ethersproject-xdc/address@file:vendor/@ethersproject-xdc/address": version "5.7.0" dependencies: - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-address-5.7.0-5d10c9bf-60df-49eb-a1dc-1630f4c35eb3-1686225288603/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-address-5.7.0-5d10c9bf-60df-49eb-a1dc-1630f4c35eb3-1686225288603/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-address-5.7.0-5d10c9bf-60df-49eb-a1dc-1630f4c35eb3-1686225288603/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-address-5.7.0-5d10c9bf-60df-49eb-a1dc-1630f4c35eb3-1686225288603/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/rlp" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-address-5.7.0-5d10c9bf-60df-49eb-a1dc-1630f4c35eb3-1686225288603/node_modules/@ethersproject-xdc/rlp" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/rlp" "file:vendor/@ethersproject-xdc/rlp" "@ethersproject-xdc/base64@file:vendor/@ethersproject-xdc/base64": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-base64-5.7.0-85a2392e-cc58-4207-bce4-e24cb01386e5-1686225288603/node_modules/@ethersproject-xdc/bytes" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" "@ethersproject-xdc/basex@file:vendor/@ethersproject-xdc/basex": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-basex-5.7.0-b5082aa2-28ce-49dd-8f17-5abde9298d9e-1686225288603/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-basex-5.7.0-b5082aa2-28ce-49dd-8f17-5abde9298d9e-1686225288603/node_modules/@ethersproject-xdc/properties" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" "@ethersproject-xdc/bignumber@file:vendor/@ethersproject-xdc/bignumber": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-bignumber-5.7.0-60351a46-94cc-44e9-927b-0b140d67c105-1686225288605/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-bignumber-5.7.0-60351a46-94cc-44e9-927b-0b140d67c105-1686225288605/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" bn.js "^5.2.1" "@ethersproject-xdc/bytes@file:vendor/@ethersproject-xdc/bytes": version "5.7.0" dependencies: - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-bytes-5.7.0-0c530d22-8d9f-46db-9652-f95d88cdf83c-1686225288604/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/constants@file:vendor/@ethersproject-xdc/constants": version "5.7.0" dependencies: - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-constants-5.7.0-083cb356-dfbe-4cc1-8428-69da215d953d-1686225288606/node_modules/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" "@ethersproject-xdc/contracts@file:vendor/@ethersproject-xdc/contracts": version "5.6.0" dependencies: - "@ethersproject-xdc/abi" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/abi" - "@ethersproject-xdc/abstract-provider" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/abstract-provider" - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-contracts-5.6.0-16f0da67-c5fe-41ee-95f3-939689043c5a-1686225288605/node_modules/@ethersproject-xdc/transactions" + "@ethersproject-xdc/abi" "file:vendor/@ethersproject-xdc/abi" + "@ethersproject-xdc/abstract-provider" "file:vendor/@ethersproject-xdc/abstract-provider" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" "@ethersproject-xdc/hash@file:vendor/@ethersproject-xdc/hash": version "5.7.0" dependencies: - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/base64" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/base64" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hash-5.7.0-a7759acf-bef8-4757-802b-2ec177275b5b-1686225288608/node_modules/@ethersproject-xdc/strings" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/base64" "file:vendor/@ethersproject-xdc/base64" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" "@ethersproject-xdc/hdnode@file:vendor/@ethersproject-xdc/hdnode": version "5.7.0" dependencies: - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/basex" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/basex" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/pbkdf2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/pbkdf2" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/sha2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/sha2" - "@ethersproject-xdc/signing-key" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/signing-key" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/strings" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/transactions" - "@ethersproject-xdc/wordlists" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-hdnode-5.7.0-a2bd75ae-01f0-4270-9973-8f1aa5a8512b-1686225288607/node_modules/@ethersproject-xdc/wordlists" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/basex" "file:vendor/@ethersproject-xdc/basex" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/pbkdf2" "file:vendor/@ethersproject-xdc/pbkdf2" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/sha2" "file:vendor/@ethersproject-xdc/sha2" + "@ethersproject-xdc/signing-key" "file:vendor/@ethersproject-xdc/signing-key" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" + "@ethersproject-xdc/wordlists" "file:vendor/@ethersproject-xdc/wordlists" "@ethersproject-xdc/json-wallets@file:vendor/@ethersproject-xdc/json-wallets": version "5.6.0" dependencies: - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/hdnode" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/hdnode" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/pbkdf2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/pbkdf2" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/random" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/random" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/strings" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-json-wallets-5.6.0-ff3f4393-e794-4c7d-9864-79c7ba46bcb1-1686225288606/node_modules/@ethersproject-xdc/transactions" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/hdnode" "file:vendor/@ethersproject-xdc/hdnode" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/pbkdf2" "file:vendor/@ethersproject-xdc/pbkdf2" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/random" "file:vendor/@ethersproject-xdc/random" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" aes-js "3.0.0" scrypt-js "3.0.1" "@ethersproject-xdc/keccak256@file:vendor/@ethersproject-xdc/keccak256": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-keccak256-5.7.0-f0728b49-5c1d-4b33-9e4f-c611bec82a32-1686225288608/node_modules/@ethersproject-xdc/bytes" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" js-sha3 "0.8.0" "@ethersproject-xdc/logger@file:vendor/@ethersproject-xdc/logger": @@ -1126,67 +1126,67 @@ "@ethersproject-xdc/networks@file:vendor/@ethersproject-xdc/networks": version "5.7.1" dependencies: - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-networks-5.7.1-5508d5d5-e011-45d7-8a8b-f326387e9be1-1686225288606/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/pbkdf2@file:vendor/@ethersproject-xdc/pbkdf2": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-pbkdf2-5.7.0-5f457302-61b1-4a7f-98ec-d6182890704f-1686225288606/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/sha2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-pbkdf2-5.7.0-5f457302-61b1-4a7f-98ec-d6182890704f-1686225288606/node_modules/@ethersproject-xdc/sha2" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/sha2" "file:vendor/@ethersproject-xdc/sha2" "@ethersproject-xdc/properties@file:vendor/@ethersproject-xdc/properties": version "5.7.0" dependencies: - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-properties-5.7.0-2a9931db-de8b-4973-b43e-ba7525c0d08b-1686225288609/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/providers@file:vendor/@ethersproject-xdc/providers": version "5.6.2" dependencies: - "@ethersproject-xdc/abstract-provider" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/abstract-provider" - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/basex" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/basex" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/hash" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/hash" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/networks" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/networks" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/random" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/random" - "@ethersproject-xdc/rlp" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/rlp" - "@ethersproject-xdc/sha2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/sha2" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/strings" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/transactions" - "@ethersproject-xdc/web" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-providers-5.6.2-adb85a3d-006b-4730-b1c2-75655f672ec3-1686225288607/node_modules/@ethersproject-xdc/web" + "@ethersproject-xdc/abstract-provider" "file:vendor/@ethersproject-xdc/abstract-provider" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/basex" "file:vendor/@ethersproject-xdc/basex" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/hash" "file:vendor/@ethersproject-xdc/hash" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/networks" "file:vendor/@ethersproject-xdc/networks" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/random" "file:vendor/@ethersproject-xdc/random" + "@ethersproject-xdc/rlp" "file:vendor/@ethersproject-xdc/rlp" + "@ethersproject-xdc/sha2" "file:vendor/@ethersproject-xdc/sha2" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" + "@ethersproject-xdc/web" "file:vendor/@ethersproject-xdc/web" bech32 "1.1.4" ws "7.4.6" "@ethersproject-xdc/random@file:vendor/@ethersproject-xdc/random": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-random-5.7.0-9db0074d-fce3-493c-9738-364069bab1d5-1686225288615/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-random-5.7.0-9db0074d-fce3-493c-9738-364069bab1d5-1686225288615/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/rlp@file:vendor/@ethersproject-xdc/rlp": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-rlp-5.7.0-28796498-07b8-4a0c-9f53-35b21e68d308-1686225288609/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-rlp-5.7.0-28796498-07b8-4a0c-9f53-35b21e68d308-1686225288609/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/sha2@file:vendor/@ethersproject-xdc/sha2": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-sha2-5.7.0-2cd17dd8-580c-4a1d-aaa1-5159fa742627-1686225288611/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-sha2-5.7.0-2cd17dd8-580c-4a1d-aaa1-5159fa742627-1686225288611/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" hash.js "1.1.7" "@ethersproject-xdc/signing-key@file:vendor/@ethersproject-xdc/signing-key": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-signing-key-5.7.0-ca28fe36-94a4-4f8b-befc-401a79120b68-1686225288614/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-signing-key-5.7.0-ca28fe36-94a4-4f8b-befc-401a79120b68-1686225288614/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-signing-key-5.7.0-ca28fe36-94a4-4f8b-befc-401a79120b68-1686225288614/node_modules/@ethersproject-xdc/properties" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" bn.js "^5.2.1" elliptic "6.5.4" hash.js "1.1.7" @@ -1194,76 +1194,76 @@ "@ethersproject-xdc/solidity@file:vendor/@ethersproject-xdc/solidity": version "5.6.0" dependencies: - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/sha2" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/sha2" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-solidity-5.6.0-46a0cfbf-923f-4142-a1f4-702004c712fa-1686225288611/node_modules/@ethersproject-xdc/strings" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/sha2" "file:vendor/@ethersproject-xdc/sha2" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" "@ethersproject-xdc/strings@file:vendor/@ethersproject-xdc/strings": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-strings-5.7.0-f026bd56-0138-413e-8186-7600e2c653c3-1686225288609/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-strings-5.7.0-f026bd56-0138-413e-8186-7600e2c653c3-1686225288609/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-strings-5.7.0-f026bd56-0138-413e-8186-7600e2c653c3-1686225288609/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/transactions@file:vendor/@ethersproject-xdc/transactions": version "5.7.0" dependencies: - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/rlp" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/rlp" - "@ethersproject-xdc/signing-key" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-transactions-5.7.0-d1852b10-1a09-4c3a-847a-0f072be4cf58-1686225288615/node_modules/@ethersproject-xdc/signing-key" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/rlp" "file:vendor/@ethersproject-xdc/rlp" + "@ethersproject-xdc/signing-key" "file:vendor/@ethersproject-xdc/signing-key" "@ethersproject-xdc/units@file:vendor/@ethersproject-xdc/units": version "5.6.0" dependencies: - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-units-5.6.0-4ff8605f-1474-48e7-999a-2afe9110ccdc-1686225288615/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-units-5.6.0-4ff8605f-1474-48e7-999a-2afe9110ccdc-1686225288615/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-units-5.6.0-4ff8605f-1474-48e7-999a-2afe9110ccdc-1686225288615/node_modules/@ethersproject-xdc/logger" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" "@ethersproject-xdc/wallet@file:vendor/@ethersproject-xdc/wallet": version "5.6.0" dependencies: - "@ethersproject-xdc/abstract-provider" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/abstract-provider" - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/hash" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/hash" - "@ethersproject-xdc/hdnode" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/hdnode" - "@ethersproject-xdc/json-wallets" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/json-wallets" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/random" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/random" - "@ethersproject-xdc/signing-key" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/signing-key" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/transactions" - "@ethersproject-xdc/wordlists" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wallet-5.6.0-7e2abba1-0462-4d24-b419-158f0d508715-1686225288616/node_modules/@ethersproject-xdc/wordlists" + "@ethersproject-xdc/abstract-provider" "file:vendor/@ethersproject-xdc/abstract-provider" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/hash" "file:vendor/@ethersproject-xdc/hash" + "@ethersproject-xdc/hdnode" "file:vendor/@ethersproject-xdc/hdnode" + "@ethersproject-xdc/json-wallets" "file:vendor/@ethersproject-xdc/json-wallets" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/random" "file:vendor/@ethersproject-xdc/random" + "@ethersproject-xdc/signing-key" "file:vendor/@ethersproject-xdc/signing-key" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" + "@ethersproject-xdc/wordlists" "file:vendor/@ethersproject-xdc/wordlists" "@ethersproject-xdc/web@file:vendor/@ethersproject-xdc/web": version "5.7.1" dependencies: - "@ethersproject-xdc/base64" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-web-5.7.1-fb65e4ae-6b80-4541-91a8-be9683776f97-1686225288616/node_modules/@ethersproject-xdc/base64" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-web-5.7.1-fb65e4ae-6b80-4541-91a8-be9683776f97-1686225288616/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-web-5.7.1-fb65e4ae-6b80-4541-91a8-be9683776f97-1686225288616/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-web-5.7.1-fb65e4ae-6b80-4541-91a8-be9683776f97-1686225288616/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-web-5.7.1-fb65e4ae-6b80-4541-91a8-be9683776f97-1686225288616/node_modules/@ethersproject-xdc/strings" + "@ethersproject-xdc/base64" "file:vendor/@ethersproject-xdc/base64" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" "@ethersproject-xdc/wordlists@file:vendor/@ethersproject-xdc/wordlists": version "5.7.0" dependencies: - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wordlists-5.7.0-f12d668b-cde2-4092-9834-ea8b338a4446-1686225288614/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/hash" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wordlists-5.7.0-f12d668b-cde2-4092-9834-ea8b338a4446-1686225288614/node_modules/@ethersproject-xdc/hash" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wordlists-5.7.0-f12d668b-cde2-4092-9834-ea8b338a4446-1686225288614/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wordlists-5.7.0-f12d668b-cde2-4092-9834-ea8b338a4446-1686225288614/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-@ethersproject-xdc-wordlists-5.7.0-f12d668b-cde2-4092-9834-ea8b338a4446-1686225288614/node_modules/@ethersproject-xdc/strings" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/hash" "file:vendor/@ethersproject-xdc/hash" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" "@ethersproject/abi@5.7.0", "@ethersproject/abi@^5.0.12", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.4.0", "@ethersproject/abi@^5.5.0", "@ethersproject/abi@^5.6.3", "@ethersproject/abi@^5.7.0": version "5.7.0" @@ -8695,36 +8695,36 @@ ethereumjs-util@^6.0.0, ethereumjs-util@^6.2.1: "ethers-xdc@file:./vendor/ethers-xdc": version "5.7.2" dependencies: - "@ethersproject-xdc/abi" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/abi" - "@ethersproject-xdc/abstract-provider" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/abstract-provider" - "@ethersproject-xdc/abstract-signer" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/abstract-signer" - "@ethersproject-xdc/address" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/address" - "@ethersproject-xdc/base64" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/base64" - "@ethersproject-xdc/basex" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/basex" - "@ethersproject-xdc/bignumber" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/bignumber" - "@ethersproject-xdc/bytes" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/bytes" - "@ethersproject-xdc/constants" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/constants" - "@ethersproject-xdc/contracts" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/contracts" - "@ethersproject-xdc/hash" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/hash" - "@ethersproject-xdc/hdnode" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/hdnode" - "@ethersproject-xdc/json-wallets" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/json-wallets" - "@ethersproject-xdc/keccak256" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/keccak256" - "@ethersproject-xdc/logger" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/logger" - "@ethersproject-xdc/networks" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/networks" - "@ethersproject-xdc/pbkdf2" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/pbkdf2" - "@ethersproject-xdc/properties" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/properties" - "@ethersproject-xdc/providers" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/providers" - "@ethersproject-xdc/random" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/random" - "@ethersproject-xdc/rlp" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/rlp" - "@ethersproject-xdc/sha2" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/sha2" - "@ethersproject-xdc/signing-key" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/signing-key" - "@ethersproject-xdc/solidity" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/solidity" - "@ethersproject-xdc/strings" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/strings" - "@ethersproject-xdc/transactions" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/transactions" - "@ethersproject-xdc/units" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/units" - "@ethersproject-xdc/wallet" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/wallet" - "@ethersproject-xdc/web" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/web" - "@ethersproject-xdc/wordlists" "file:../../../../Library/Caches/Yarn/v6/npm-ethers-xdc-5.7.2-11e40edf-e947-4d7f-a15f-0d701ca269e6-1686225288593/node_modules/@ethersproject-xdc/wordlists" + "@ethersproject-xdc/abi" "file:vendor/@ethersproject-xdc/abi" + "@ethersproject-xdc/abstract-provider" "file:vendor/@ethersproject-xdc/abstract-provider" + "@ethersproject-xdc/abstract-signer" "file:vendor/@ethersproject-xdc/abstract-signer" + "@ethersproject-xdc/address" "file:vendor/@ethersproject-xdc/address" + "@ethersproject-xdc/base64" "file:vendor/@ethersproject-xdc/base64" + "@ethersproject-xdc/basex" "file:vendor/@ethersproject-xdc/basex" + "@ethersproject-xdc/bignumber" "file:vendor/@ethersproject-xdc/bignumber" + "@ethersproject-xdc/bytes" "file:vendor/@ethersproject-xdc/bytes" + "@ethersproject-xdc/constants" "file:vendor/@ethersproject-xdc/constants" + "@ethersproject-xdc/contracts" "file:vendor/@ethersproject-xdc/contracts" + "@ethersproject-xdc/hash" "file:vendor/@ethersproject-xdc/hash" + "@ethersproject-xdc/hdnode" "file:vendor/@ethersproject-xdc/hdnode" + "@ethersproject-xdc/json-wallets" "file:vendor/@ethersproject-xdc/json-wallets" + "@ethersproject-xdc/keccak256" "file:vendor/@ethersproject-xdc/keccak256" + "@ethersproject-xdc/logger" "file:vendor/@ethersproject-xdc/logger" + "@ethersproject-xdc/networks" "file:vendor/@ethersproject-xdc/networks" + "@ethersproject-xdc/pbkdf2" "file:vendor/@ethersproject-xdc/pbkdf2" + "@ethersproject-xdc/properties" "file:vendor/@ethersproject-xdc/properties" + "@ethersproject-xdc/providers" "file:vendor/@ethersproject-xdc/providers" + "@ethersproject-xdc/random" "file:vendor/@ethersproject-xdc/random" + "@ethersproject-xdc/rlp" "file:vendor/@ethersproject-xdc/rlp" + "@ethersproject-xdc/sha2" "file:vendor/@ethersproject-xdc/sha2" + "@ethersproject-xdc/signing-key" "file:vendor/@ethersproject-xdc/signing-key" + "@ethersproject-xdc/solidity" "file:vendor/@ethersproject-xdc/solidity" + "@ethersproject-xdc/strings" "file:vendor/@ethersproject-xdc/strings" + "@ethersproject-xdc/transactions" "file:vendor/@ethersproject-xdc/transactions" + "@ethersproject-xdc/units" "file:vendor/@ethersproject-xdc/units" + "@ethersproject-xdc/wallet" "file:vendor/@ethersproject-xdc/wallet" + "@ethersproject-xdc/web" "file:vendor/@ethersproject-xdc/web" + "@ethersproject-xdc/wordlists" "file:vendor/@ethersproject-xdc/wordlists" ethers@4.0.0-beta.3: version "4.0.0-beta.3" @@ -14906,9 +14906,9 @@ socket.io-client@^4.6.1: socket.io-parser "~4.2.1" socket.io-parser@~4.2.1: - version "4.2.2" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.2.tgz#1dd384019e25b7a3d374877f492ab34f2ad0d206" - integrity sha512-DJtziuKypFkMMHCm2uIshOYC7QaylbtzQwiMYDuCKy3OPkjLzu4B2vAhTlqipRHHzrI0NJeBAizTK7X+6m1jVw== + version "4.2.4" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.4.tgz#c806966cf7270601e47469ddeec30fbdfda44c83" + integrity sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew== dependencies: "@socket.io/component-emitter" "~3.1.0" debug "~4.3.1" From 0ddfe2332798cad88aab0d28d58c2fc00c75f4ee Mon Sep 17 00:00:00 2001 From: vic-en Date: Wed, 5 Jul 2023 04:37:59 -0500 Subject: [PATCH 3/3] refactor chains --- docs/swagger/algorand-routes.yml | 73 --- .../{evm-routes.yml => chain-routes.yml} | 36 +- docs/swagger/cosmos-routes.yml | 57 --- docs/swagger/definitions.yml | 394 +-------------- docs/swagger/injective-routes.yml | 89 ---- docs/swagger/near-routes.yml | 63 --- docs/swagger/swagger.yml | 12 +- src/amm/amm.controllers.ts | 20 +- src/app.ts | 21 +- src/chains/algorand/algorand.controller.ts | 152 +++--- src/chains/algorand/algorand.routes.ts | 91 ---- src/chains/algorand/algorand.ts | 7 + src/chains/avalanche/avalanche.ts | 3 + .../binance-smart-chain.ts | 10 +- src/chains/chain.controller.ts | 156 ++++++ .../chain.requests.ts} | 0 src/chains/chain.routes.ts | 231 +++++++++ src/chains/cosmos/cosmos.controllers.ts | 107 ++-- src/chains/cosmos/cosmos.routes.ts | 74 --- src/chains/cosmos/cosmos.ts | 3 + src/chains/cronos/cronos.ts | 3 + src/chains/ethereum/ethereum-base.ts | 4 +- src/chains/ethereum/ethereum.controllers.ts | 456 ----------------- src/chains/ethereum/ethereum.requests.ts | 3 +- src/chains/ethereum/ethereum.ts | 5 +- src/chains/ethereum/evm.controllers.ts | 472 ++++++++++++++++++ src/{evm => chains/ethereum}/evm.nonce.ts | 8 +- .../ethereum}/evm.tx-storage.ts | 4 +- src/chains/harmony/harmony.ts | 3 + src/chains/injective/injective.controllers.ts | 76 +-- src/chains/injective/injective.requests.ts | 11 +- src/chains/injective/injective.routes.ts | 122 ----- src/chains/injective/injective.ts | 5 +- src/chains/injective/injective.validators.ts | 20 +- src/chains/near/near.base.ts | 2 +- src/chains/near/near.controllers.ts | 253 +++++----- src/chains/near/near.routes.ts | 87 ---- src/chains/near/near.ts | 3 + src/chains/polygon/polygon.ts | 3 + src/chains/xdc/xdc.base.ts | 4 +- src/chains/xdc/xdc.controllers.ts | 19 + src/evm/evm.routes.ts | 133 ----- src/network/network.controllers.ts | 49 +- src/network/network.routes.ts | 110 ---- src/services/base.ts | 6 +- src/services/common-interfaces.ts | 5 +- test-helpers/curl/curl.sh | 92 ++-- ...gon_key.json.json => add_polygon_key.json} | 0 .../curl/requests/eth_allowances.json | 4 +- test-helpers/curl/requests/eth_nonce.json | 4 +- .../requests/injective_transfer_to_bank.json | 3 +- .../requests/injective_transfer_to_sub.json | 3 +- .../ethereum/ethereum.controllers.test.ts | 34 +- test/chains/ethereum/evm.nonce.test.ts | 2 +- .../harmony/harmony.controllers.test.ts | 31 +- test/chains/near/near.controllers.test.ts | 24 +- test/evm.nonce.mock.ts | 2 +- test/services/evm.nonce.test.ts | 2 +- test/services/evm.tx-storage.test.ts | 2 +- 59 files changed, 1384 insertions(+), 2284 deletions(-) delete mode 100644 docs/swagger/algorand-routes.yml rename docs/swagger/{evm-routes.yml => chain-routes.yml} (81%) delete mode 100644 docs/swagger/cosmos-routes.yml delete mode 100644 docs/swagger/injective-routes.yml delete mode 100644 docs/swagger/near-routes.yml delete mode 100644 src/chains/algorand/algorand.routes.ts create mode 100644 src/chains/chain.controller.ts rename src/{evm/evm.requests.ts => chains/chain.requests.ts} (100%) create mode 100644 src/chains/chain.routes.ts delete mode 100644 src/chains/cosmos/cosmos.routes.ts delete mode 100644 src/chains/ethereum/ethereum.controllers.ts create mode 100644 src/chains/ethereum/evm.controllers.ts rename src/{evm => chains/ethereum}/evm.nonce.ts (98%) rename src/{evm => chains/ethereum}/evm.tx-storage.ts (92%) delete mode 100644 src/chains/injective/injective.routes.ts delete mode 100644 src/chains/near/near.routes.ts create mode 100644 src/chains/xdc/xdc.controllers.ts delete mode 100644 src/evm/evm.routes.ts delete mode 100644 src/network/network.routes.ts rename test-helpers/curl/requests/{add_polygon_key.json.json => add_polygon_key.json} (100%) diff --git a/docs/swagger/algorand-routes.yml b/docs/swagger/algorand-routes.yml deleted file mode 100644 index 3bd24e87f7..0000000000 --- a/docs/swagger/algorand-routes.yml +++ /dev/null @@ -1,73 +0,0 @@ -paths: - /algorand/poll: - post: - tags: - - 'algorand' - summary: 'Poll the status of a transaction' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/AlgorandPollRequest' - responses: - '200': - schema: - $ref: '#/definitions/AlgorandPollResponse' - /algorand/balances: - post: - tags: - - 'algorand' - summary: 'Get the balances of an account' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/BalancesRequest' - responses: - '200': - schema: - $ref: '#/definitions/BalancesResponse' - /algorand/assets: - get: - tags: - - 'algorand' - summary: 'Get assets info' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'query' - name: 'query' - required: true - schema: - $ref: '#/definitions/AlgorandAssetsRequest' - /algorand/opt-in: - post: - tags: - - 'algorand' - summary: 'Opt into an asset' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/AlgorandOptInRequest' - responses: - '200': - schema: - $ref: '#/definitions/AlgorandOptInResponse' \ No newline at end of file diff --git a/docs/swagger/evm-routes.yml b/docs/swagger/chain-routes.yml similarity index 81% rename from docs/swagger/evm-routes.yml rename to docs/swagger/chain-routes.yml index 6e7a292af2..cd706fc471 100644 --- a/docs/swagger/evm-routes.yml +++ b/docs/swagger/chain-routes.yml @@ -1,8 +1,8 @@ paths: - /evm/nonce: + /chain/nonce: post: tags: - - 'evm' + - 'chain' summary: 'Get the current nonce for the provided private key' operationId: 'nonce' consumes: @@ -20,10 +20,10 @@ paths: schema: $ref: '#/definitions/NonceResponse' - /evm/nextNonce: + /chain/nextNonce: post: tags: - - 'evm' + - 'chain' summary: 'Get the next nonce for the provided private key' operationId: 'nonce' consumes: @@ -41,10 +41,10 @@ paths: schema: $ref: '#/definitions/NonceResponse' - /evm/allowances: + /chain/allowances: post: tags: - - 'evm' + - 'chain' summary: 'Get the ERC20 allowances for a spender on a given private key' operationId: 'allowances' consumes: @@ -61,10 +61,10 @@ paths: '200': schema: $ref: '#/definitions/AllowancesResponse' - /evm/approve: + /chain/approve: post: tags: - - 'evm' + - 'chain' summary: 'Create an ERC20 approval for a spender on an private key' operationId: 'approve' consumes: @@ -82,10 +82,10 @@ paths: schema: $ref: '#/definitions/ApproveResponse' - /evm/cancel: + /chain/cancel: post: tags: - - 'evm' + - 'chain' summary: 'Cancel transaction' operationId: 'cancel' consumes: @@ -102,3 +102,19 @@ paths: '200': schema: $ref: '#/definitions/CancelResponse' + + /chain/transfer: + post: + tags: + - 'chain' + summary: 'Transfer balance' + parameters: + - in: 'body' + name: 'body' + required: true + schema: + $ref: '#/definitions/TransferRequest' + produces: + - 'application/json' + responses: + '200' diff --git a/docs/swagger/cosmos-routes.yml b/docs/swagger/cosmos-routes.yml deleted file mode 100644 index 38d44d4f28..0000000000 --- a/docs/swagger/cosmos-routes.yml +++ /dev/null @@ -1,57 +0,0 @@ -paths: - /cosmos: - get: - tags: - - 'cosmos' - summary: 'View the Cosmos network and RPC URL that gateway is configured to use' - description: 'The user can change this by editing src/chains/cosmos/cosmos.config.ts' - operationId: 'root' - produces: - - 'application/json' - responses: - '200': - description: 'Cosmos config' - schema: - $ref: '#/definitions/CosmosConfigResponse' - - /cosmos/balances: - post: - tags: - - 'cosmos' - summary: 'Get the balances of a Cosmos wallet' - operationId: 'balances' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/CosmosBalanceRequest' - responses: - '200': - schema: - $ref: '#/definitions/BalancesResponse' - - /cosmos/poll: - post: - tags: - - 'cosmos' - summary: 'Poll the status of a Cosmos transaction' - operationId: 'poll' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/CosmosPollRequest' - responses: - '200': - schema: - $ref: '#/definitions/CosmosPollResponse' diff --git a/docs/swagger/definitions.yml b/docs/swagger/definitions.yml index 0763752f16..7c231e9813 100644 --- a/docs/swagger/definitions.yml +++ b/docs/swagger/definitions.yml @@ -154,70 +154,6 @@ definitions: type: 'string' example: '{"ETH": "1.5", "WETH": "100","DAI": "300"}' - InjectiveBankBalance: - type: 'object' - required: - - 'token' - - 'amount' - properties: - token: - type: 'string' - example: 'inj' - amount: - type: 'string' - example: '1.25' - - InjectiveSubaccountBalanceSub: - type: 'object' - required: - - 'token' - - 'totalBalance' - - 'availableBalance' - properties: - token: - type: 'string' - example: 'inj' - totalBalance: - type: 'string' - example: '100.0' - availableBalance: - type: 'string' - example: '15.0' - - InjectiveSubaccountBalancesWithId: - type: 'object' - required: - - 'subaccountId' - - 'balances' - properties: - subaccountId: - type: 'string' - example: '0' - balances: - type: 'array' - item: - $ref: '#/definitions/InjectiveSubaccountBalanceSub' - example: '{"token": "inj", "tokenBalance": "100.0", "availableBalance": "15.0"}' - - InjectiveBalancesResponse: - type: 'object' - required: - - 'injectiveAddress' - - 'balances' - - 'subaccounts' - properties: - injectiveAddress: - type: 'string' - example: 'inj1l2sjl5gzl6rz8jffn3etq0j9zpljwu44ed7zuc' - balances: - type: 'array' - item: - $ref: '#/definitions/InjectiveBankBalance' - subaccoutns: - type: 'array' - item: - $ref: '#/definitions/InjectiveSubaccountBalancesWithId' - ApproveRequest: type: 'object' required: @@ -292,53 +228,6 @@ definitions: type: 'object' example: '{"type": 2,"chainId": 42,"nonce": 129,"maxPriorityFeePerGas": "94000000000","maxFeePerGas": "94000000000","gasPrice": null,"gasLimit": "100000","to": "0xd0A1E359811322d97991E03f863a0C30C2cF029C","value": "0","data": "0x095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","accessList": [],"hash": "0xa321bbe8888c3bc88ecb1ad4f03f22a71e6f5715dfcb19e0a2dca9036c981b6d","v": 1,"r": "0x47c517271885b7041d81bcd65cd050a5d6be3fbd67a8f1660ac8d7e68fc8221f","s": "0x7c62e114b2cb0eae6236b597fb4aacb01c51e56afd7f734e6039d83aa400ba82","from": "0xFaA12FD102FE8623C9299c72B03E45107F2772B5","confirmations": 0}' # noqa: documentation - InjectivePollResponse: - type: 'object' - required: - - 'blockNumber' - - 'hash' - - 'gasWanted' - - 'gasLimit' - - 'gasUsed' - - 'sequences' - properties: - blockNumber: - type: 'number' - example: 123456 - hash: - type: 'string' - example: '0xaaaaaaaaaabbbb' - gasWanted: - type: 'number' - example: 1000000 - gasLimit: - type: 'number' - example: 2000000 - gasUsed: - type: 'number' - example: 1000000 - sequences: - type: 'array' - items: 'number' - example: [ 1,2 ] - - InjectivePollRequest: - type: 'object' - required: - - 'txHash' - - 'chain' - - 'network' - properties: - txHash: - type: 'string' - example: '0xa321bbe8888c3bc88ecb1ad4f03f22a71e6f5715dfcb19e0a2dca9036c981b6d' # noqa: documentation - chain: - type: 'string' - example: 'injective' - network: - type: 'string' - example: 'mainnet' - PollRequest: type: 'object' required: @@ -711,86 +600,6 @@ definitions: - type: 'boolean' - type: 'number' - CosmosConfigResponse: - type: 'object' - required: - - 'network' - - 'rpcUrl' - - 'connection' - - 'timestamp' - properties: - network: - type: 'string' - example: 'mainnet' - rpcUrl: - type: 'string' - example: 'https://rpc.cosmos.network/' - connection: - type: 'boolean' - example: true - timestamp: - type: 'integer' - example: 1641889489132 - - CosmosBalanceRequest: - type: 'object' - required: - - 'address' - - 'tokenSymbols' - properties: - address: - type: 'string' - example: 'cosmos1pc8m5m7n0z8xe7sx2tawkvc0v6qkjql83js0dr' - tokenSymbols: - type: 'array' - items: 'string' - example: [ 'ATOM', 'NETA' ] - - CosmosPollRequest: - type: 'object' - required: - - 'txHash' - properties: - txHash: - type: 'string' - example: 'E0E02A6C27A75F4442B0746676BDAF5F66AFF1E71928C54624A35B48D5A4B3AF' - - CosmosPollResponse: - type: 'object' - required: - - 'network' - - 'timestamp' - - 'txHash' - - 'currentBlock' - - 'txBlock' - - 'gasUsed' - - 'gasWanted' - - 'txData' - properties: - network: - type: 'string' - example: 'mainnet' - timestamp: - type: 'integer' - example: 1636368085740 - currentBlock: - type: 'integer' - example: 112646487 - txHash: - type: 'string' - example: 'oaMWkrYr1g9JBcDUPRqz21cJBxowM4CEbDy2FsCgNK569CjZSr4wa51d4k9DpTRJU8GUHfp3e9YX2pGXaBS5Tta' - txBlock: - type: 'number' - example: 11581899 - gasUsed: - type: 'number' - example: 89054 - gasWanted: - type: 'number' - example: 130000 - txData: - $ref: '#/definitions/CosmosTransaction' - TokensResponse: type: 'object' required: @@ -2055,12 +1864,13 @@ definitions: type: 'array' example: [] - TransferToSubAccountRequest: + TransferRequest: type: 'object' required: - 'chain' - 'network' - - 'address' + - 'from' + - 'to' - 'subaccountId' - 'amount' - 'token' @@ -2071,7 +1881,10 @@ definitions: network: type: 'string' example: 'mainnet' - address: + from: + type: 'string' + example: '0x...' + to: type: 'string' example: '0x...' amount: @@ -2081,103 +1894,6 @@ definitions: type: 'string' example: 'inj' - NearBalancesRequest: - type: 'object' - required: - - 'address' - - 'tokenSymbols' - - 'chain' - - 'network' - properties: - privateKey: - type: 'string' - example: 'hummingbot.near' - tokenSymbols: - type: 'array' - items: 'string' - example: [ "NEAR", "ETH", "AURORA" ] - chain: - type: 'string' - example: 'near' - network: - type: 'string' - example: 'testnet' - - NearBalancesResponse: - type: 'object' - required: - - 'network' - - 'timestamp' - - 'latency' - - 'balances' - properties: - network: - type: 'string' - example: 'testnet' - timestamp: - type: 'integer' - example: 1636368085740 - latency: - type: 'number' - example: 0.5 - balances: - type: 'object' - properties: - id: - type: 'string' - name: - type: 'string' - example: '{"NEAR": "1.5", "ETH": "100", "AURORA": "300"}' - - NearPollRequest: - type: 'object' - required: - - 'address' - - 'txHash' - - 'chain' - - 'network' - properties: - address: - type: 'string' - example: 'hummingbot.near' - txHash: - type: 'string' - example: 'HnpRwb8PjrtLjExxz4YxdiyJ2AwuRFhZHKa9WUASwyxk' - chain: - type: 'string' - example: 'near' - network: - type: 'string' - example: 'testnet' - - NearPollResponse: - type: 'object' - required: - - 'network' - - 'timestamp' - - 'currentBlock' - - 'txHash' - - 'txStatus' - - 'txReceipt' - properties: - network: - type: 'string' - example: 'testnet' - timestamp: - type: 'integer' - example: 1636368085740 - currentBlock: - type: 'integer' - example: 28243911 - txHash: - type: 'string' - example: 'HnpRwb8PjrtLjExxz4YxdiyJ2AwuRFhZHKa9WUASwyxk' - txStatus: - type: 'number' - example: 1 - txReceipt: - type: 'object' - PerpClobPostOrderRequest: type: 'object' required: @@ -2323,102 +2039,6 @@ definitions: type: 'string' example: '1.234' - AlgorandPollRequest: - type: 'object' - required: - - 'network' - - 'txHash' - properties: - network: - type: 'string' - example: 'testnet' - txHash: - type: 'string' - example: 'T3ZUYEJ5Y7KEDKITIXO4B5OWU4SBVGOFCPOYGZQHF2XZGENZUBQA' - - AlgorandPollResponse: - type: 'object' - required: - - 'currentBlock' - - 'txBlock' - - 'txHash' - - 'fee' - properties: - currentBlock: - type: 'integer' - example: 28243911 - txBlock: - type: 'integer' - example: 28243910 - txHash: - type: 'string' - example: 'T3ZUYEJ5Y7KEDKITIXO4B5OWU4SBVGOFCPOYGZQHF2XZGENZUBQA' - fee: - type: 'integer' - example: 1000 - - AlgorandAssetsRequest: - type: 'object' - properties: - network: - type: 'string' - example: 'testnet' - assetSymbols: - type: 'array' - items: 'string' - example: [ 'ALGO', 'USDC' ] - - AlgorandAssetsResponse: - type: 'object' - required: - - 'assets' - properties: - assets: - type: 'array' - items: 'object' - example: [ { symbol: 'ALGO', assetId: 0, decimal: 6 } ] - - AlgorandOptInRequest: - type: 'object' - required: - - 'network' - - 'address' - - 'assetSymbol' - properties: - network: - type: 'string' - example: 'testnet' - address: - type: 'string' - example: 'T3ZUYEJ5Y7KEDKITIXO4B5OWU4SBVGOFCPOYGZQHF2XZGENZUBQA' - assetSymbol: - type: 'string' - example: 'USDC' - - AlgorandOptInResponse: - type: 'object' - required: - - 'network' - - 'timestamp' - - 'latency' - - 'assetId' - - 'transactionResponse' - properties: - network: - type: 'string' - example: 'testnet' - timestamp: - type: 'integer' - example: 163636808574 - latency: - type: 'number' - example: 0.5 - assetId: - type: 'string' - example: 'USDC' - transactionResponse: - type: 'object' - ClobBatchOrdersRequest: type: 'object' required: diff --git a/docs/swagger/injective-routes.yml b/docs/swagger/injective-routes.yml deleted file mode 100644 index 557226ee61..0000000000 --- a/docs/swagger/injective-routes.yml +++ /dev/null @@ -1,89 +0,0 @@ -paths: - /injective/balances: - post: - tags: - - 'injective' - summary: 'Get the balances of an injective public key' - operationId: 'balances' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/BalancesRequest' - responses: - '200': - schema: - $ref: '#/definitions/InjectiveBalancesResponse' - - /injective/block/current: - post: - tags: - - 'injective' - summary: 'Get the current block number for an injective network' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/NetworkSelectionRequest' - produces: - - 'application/json' - responses: - '200' - - /injective/poll: - post: - tags: - - 'injective' - summary: 'Poll the status of a transaction' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/InjectivePollRequest' - responses: - '200': - schema: - $ref: '#/definitions/InjectivePollResponse' - - /injective/transfer/to/bank: - post: - tags: - - 'injective' - summary: 'Transfer subaccount balance to bank' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/TransferToSubAccountRequest' - produces: - - 'application/json' - responses: - '200' - - /injective/transfer/to/sub: - post: - tags: - - 'injective' - summary: 'Transfer bank balance to subaccount balance' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/TransferToSubAccountRequest' - produces: - - 'application/json' - responses: - '200' \ No newline at end of file diff --git a/docs/swagger/near-routes.yml b/docs/swagger/near-routes.yml deleted file mode 100644 index cafdd30f30..0000000000 --- a/docs/swagger/near-routes.yml +++ /dev/null @@ -1,63 +0,0 @@ -paths: - /near/balances: - get: - tags: - - 'near' - summary: 'Get the balances of an Near private key' - operationId: 'near.balances' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/NearBalancesRequest' - responses: - '200': - schema: - $ref: '#/definitions/NearBalancesResponse' - - /near/tokens: - get: - tags: - - 'near' - summary: 'Request token information and balance of requested token symbol' - operationId: 'near.token' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/NetworkSelectionRequest' - responses: - '200': - schema: - $ref: '#/definitions/TokensResponse' - - /near/poll: - post: - tags: - - 'near' - summary: 'Poll the status of a Near transaction' - operationId: 'near.poll' - consumes: - - 'application/json' - produces: - - 'application/json' - parameters: - - in: 'body' - name: 'body' - required: true - schema: - $ref: '#/definitions/NearPollRequest' - responses: - '200': - schema: - $ref: '#/definitions/NearPollResponse' diff --git a/docs/swagger/swagger.yml b/docs/swagger/swagger.yml index 5fc6f46c12..bef77055aa 100644 --- a/docs/swagger/swagger.yml +++ b/docs/swagger/swagger.yml @@ -27,16 +27,8 @@ tags: description: 'Interact with CLOB perpetual decentralized exchanges' - name: 'amm/liquidity' description: 'Interact with AMM LP contracts' - - name: 'evm' - description: 'Interact with EVM based blockchains' - - name: 'algorand' - description: 'Interact with the Algorand blockchain' - - name: 'cosmos' - description: 'Interact with the Cosmos blockchain' - - name: 'near' - description: 'Interact with the Near blockchain' - - name: 'injective' - description: 'Interact with the Injective blockchain' + - name: 'chain' + description: 'Interact with primary chain properties' schemes: - 'http' diff --git a/src/amm/amm.controllers.ts b/src/amm/amm.controllers.ts index 76c1a8e3d4..74f3d927ab 100644 --- a/src/amm/amm.controllers.ts +++ b/src/amm/amm.controllers.ts @@ -58,7 +58,7 @@ import { getConnector, } from '../services/connection-manager'; import { - Ethereumish, + Chain as Ethereumish, Nearish, NetworkSelectionRequest, Perpish, @@ -79,9 +79,12 @@ export async function price(req: PriceRequest): Promise { req.chain, req.network ); - const connector: Uniswapish | RefAMMish | Tinyman | ZigZagish= await getConnector< - Uniswapish | RefAMMish | Tinyman | ZigZagish - >(req.chain, req.network, req.connector); + const connector: Uniswapish | RefAMMish | Tinyman | ZigZagish = + await getConnector( + req.chain, + req.network, + req.connector + ); // we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish if ('routerAbi' in connector) { @@ -100,9 +103,12 @@ export async function trade(req: TradeRequest): Promise { req.chain, req.network ); - const connector: Uniswapish | RefAMMish | Tinyman | ZigZagish = await getConnector< - Uniswapish | RefAMMish | Tinyman | ZigZagish - >(req.chain, req.network, req.connector); + const connector: Uniswapish | RefAMMish | Tinyman | ZigZagish = + await getConnector( + req.chain, + req.network, + req.connector + ); // we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish if ('routerAbi' in connector) { diff --git a/src/app.ts b/src/app.ts index 286244c103..8e6af2bf72 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,7 +2,6 @@ import express from 'express'; import { Request, Response, NextFunction } from 'express'; import { ConfigRoutes } from './services/config/config.routes'; -import { CosmosRoutes } from './chains/cosmos/cosmos.routes'; import { WalletRoutes } from './services/wallet/wallet.routes'; import { logger } from './services/logger'; import { addHttps } from './https'; @@ -14,17 +13,13 @@ import { } from './services/error-handler'; import { ConfigManagerV2 } from './services/config-manager-v2'; import { SwaggerManager } from './services/swagger-manager'; -import { NetworkRoutes } from './network/network.routes'; import { ConnectorsRoutes } from './connectors/connectors.routes'; -import { EVMRoutes } from './evm/evm.routes'; import { AmmRoutes, AmmLiquidityRoutes, PerpAmmRoutes } from './amm/amm.routes'; -import { AlgorandRoutes } from './chains/algorand/algorand.routes'; -import { InjectiveRoutes } from './chains/injective/injective.routes'; -import { NearRoutes } from './chains/near/near.routes'; import { CLOBRoutes, PerpClobRoutes } from './clob/clob.routes'; import morgan from 'morgan'; import swaggerUi from 'swagger-ui-express'; +import { ChainRoutes } from './chains/chain.routes'; export const gatewayApp = express(); @@ -48,10 +43,7 @@ gatewayApp.use( // mount sub routers gatewayApp.use('/config', ConfigRoutes.router); -gatewayApp.use('/network', NetworkRoutes.router); -gatewayApp.use('/evm', EVMRoutes.router); -gatewayApp.use('/algorand', AlgorandRoutes.router); -gatewayApp.use('/injective', InjectiveRoutes.router); +gatewayApp.use('/chain', ChainRoutes.router); gatewayApp.use('/connectors', ConnectorsRoutes.router); gatewayApp.use('/amm', AmmRoutes.router); @@ -60,8 +52,6 @@ gatewayApp.use('/amm/liquidity', AmmLiquidityRoutes.router); gatewayApp.use('/wallet', WalletRoutes.router); gatewayApp.use('/clob', CLOBRoutes.router); gatewayApp.use('/clob/perp', PerpClobRoutes.router); -gatewayApp.use('/cosmos', CosmosRoutes.router); -gatewayApp.use('/near', NearRoutes.router); // a simple route to test that the server is running gatewayApp.get('/', (_req: Request, res: Response) => { @@ -103,12 +93,7 @@ export const swaggerDocument = SwaggerManager.generateSwaggerJson( './docs/swagger/wallet-routes.yml', './docs/swagger/amm-routes.yml', './docs/swagger/amm-liquidity-routes.yml', - './docs/swagger/evm-routes.yml', - './docs/swagger/network-routes.yml', - './docs/swagger/algorand-routes.yml', - './docs/swagger/near-routes.yml', - './docs/swagger/cosmos-routes.yml', - './docs/swagger/injective-routes.yml', + './docs/swagger/chain-routes.yml', ] ); diff --git a/src/chains/algorand/algorand.controller.ts b/src/chains/algorand/algorand.controller.ts index 8e60686c7f..877136d5fa 100644 --- a/src/chains/algorand/algorand.controller.ts +++ b/src/chains/algorand/algorand.controller.ts @@ -3,22 +3,22 @@ import { AssetsRequest, AssetsResponse, OptInRequest, - OptInResponse, PollRequest, PollResponse, } from '../algorand/algorand.requests'; import { Algorand } from './algorand'; -import { - BalanceRequest, - BalanceResponse, -} from '../../network/network.requests'; -import { latency } from '../../services/base'; +import { BalanceRequest } from '../../network/network.requests'; import { HttpException, - NETWORK_ERROR_CODE, TOKEN_NOT_SUPPORTED_ERROR_CODE, TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, } from '../../services/error-handler'; +import { + validateAlgorandBalanceRequest, + validateAlgorandPollRequest, + validateAssetsRequest, + validateOptInRequest, +} from './algorand.validators'; async function getInitializedAlgorand(network: string): Promise { const algorand = Algorand.getInstance(network); @@ -30,96 +30,86 @@ async function getInitializedAlgorand(network: string): Promise { return algorand; } -export async function poll( - algorand: Algorand, - req: PollRequest -): Promise { - return await algorand.getTransaction(req.txHash); -} +export class AlgorandController { + static async poll( + algorand: Algorand, + req: PollRequest + ): Promise { + validateAlgorandPollRequest(req); -export async function balances( - chain: Algorand, - request: BalanceRequest -): Promise { - const initTime = Date.now(); - const balances: Record = {}; + return await algorand.getTransaction(req.txHash); + } - const account = await chain.getAccountFromAddress(request.address); + static async balances(chain: Algorand, request: BalanceRequest) { + validateAlgorandBalanceRequest(request); - if (request.tokenSymbols.includes(chain.nativeTokenSymbol)) { - balances[chain.nativeTokenSymbol] = await chain.getNativeBalance(account); - } + const balances: Record = {}; - for (const token of request.tokenSymbols) { - if (token === chain.nativeTokenSymbol) continue; - balances[token] = await chain.getAssetBalance(account, token); - } + const account = await chain.getAccountFromAddress(request.address); - return { - network: request.network, - timestamp: initTime, - latency: latency(initTime, Date.now()), - balances: balances, - }; -} + if (request.tokenSymbols.includes(chain.nativeTokenSymbol)) { + balances[chain.nativeTokenSymbol] = await chain.getNativeBalance(account); + } -export async function getAssets( - request: AssetsRequest -): Promise { - if (request.network === undefined) { - throw new HttpException( - 500, - 'Missing network parameter', - NETWORK_ERROR_CODE - ); + for (const token of request.tokenSymbols) { + if (token === chain.nativeTokenSymbol) continue; + balances[token] = await chain.getAssetBalance(account, token); + } + + return { + balances: balances, + }; } - let assets: AlgorandAsset[] = []; - const algorand = await getInitializedAlgorand(request.network); + static async getTokens( + algorand: Algorand, + request: AssetsRequest + ): Promise { + validateAssetsRequest(request); + + let assets: AlgorandAsset[] = []; - if (!request.assetSymbols) { - assets = algorand.storedAssetList; - } else { - let assetSymbols; - if (typeof request.assetSymbols === 'string') { - assetSymbols = [request.assetSymbols]; + if (!request.assetSymbols) { + assets = algorand.storedAssetList; } else { - assetSymbols = request.assetSymbols; - } - for (const a of assetSymbols as []) { - assets.push(algorand.getAssetForSymbol(a) as AlgorandAsset); + let assetSymbols; + if (typeof request.assetSymbols === 'string') { + assetSymbols = [request.assetSymbols]; + } else { + assetSymbols = request.assetSymbols; + } + for (const a of assetSymbols as []) { + assets.push(algorand.getAssetForSymbol(a) as AlgorandAsset); + } } + + return { + assets: assets, + }; } - return { - assets: assets, - }; -} + static async approve(request: OptInRequest) { + validateOptInRequest(request); -export async function optIn(request: OptInRequest): Promise { - const initTime = Date.now(); + const algorand = await getInitializedAlgorand(request.network); + const asset = algorand.getAssetForSymbol(request.assetSymbol); - const algorand = await getInitializedAlgorand(request.network); - const asset = algorand.getAssetForSymbol(request.assetSymbol); + if (asset === undefined) { + throw new HttpException( + 500, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + request.assetSymbol, + TOKEN_NOT_SUPPORTED_ERROR_CODE + ); + } - if (asset === undefined) { - throw new HttpException( - 500, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + request.assetSymbol, - TOKEN_NOT_SUPPORTED_ERROR_CODE + const transactionResponse = await algorand.optIn( + request.address, + request.assetSymbol ); - } - const transactionResponse = await algorand.optIn( - request.address, - request.assetSymbol - ); - - return { - network: request.network, - timestamp: initTime, - latency: latency(initTime, Date.now()), - assetId: (asset as AlgorandAsset).assetId, - transactionResponse: transactionResponse, - }; + return { + assetId: (asset as AlgorandAsset).assetId, + transactionResponse: transactionResponse, + }; + } } diff --git a/src/chains/algorand/algorand.routes.ts b/src/chains/algorand/algorand.routes.ts deleted file mode 100644 index 365d3c831d..0000000000 --- a/src/chains/algorand/algorand.routes.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* eslint-disable no-inner-declarations */ -/* eslint-disable @typescript-eslint/ban-types */ -import { Response, Router, Request, NextFunction } from 'express'; -import { asyncHandler } from '../../services/error-handler'; -import { - AssetsRequest, - AssetsResponse, - PollRequest, - PollResponse, - OptInRequest, - OptInResponse, -} from './algorand.requests'; -import { - validateAlgorandBalanceRequest, - validateAlgorandPollRequest, - validateAssetsRequest, - validateOptInRequest, -} from './algorand.validators'; -import { getInitializedChain } from '../../services/connection-manager'; -import { Algorand } from './algorand'; -import { balances, getAssets, optIn, poll } from './algorand.controller'; -import { - BalanceRequest, - BalanceResponse, -} from '../../network/network.requests'; - -export namespace AlgorandRoutes { - export const router = Router(); - - router.post( - '/poll', - asyncHandler( - async ( - req: Request<{}, {}, PollRequest>, - res: Response - ) => { - validateAlgorandPollRequest(req.body); - const algorand = await getInitializedChain( - 'algorand', - req.body.network - ); - res.status(200).json(await poll(algorand, req.body)); - } - ) - ); - - router.post( - '/balances', - asyncHandler( - async ( - req: Request<{}, {}, BalanceRequest>, - res: Response, - _next: NextFunction - ) => { - validateAlgorandBalanceRequest(req.body); - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - - res.status(200).json(await balances(chain, req.body)); - } - ) - ); - - router.get( - '/assets', - asyncHandler( - async ( - req: Request<{}, {}, {}, AssetsRequest>, - res: Response - ) => { - validateAssetsRequest(req.query); - res.status(200).json(await getAssets(req.query)); - } - ) - ); - - router.post( - '/opt-in', - asyncHandler( - async ( - req: Request<{}, {}, OptInRequest>, - res: Response - ) => { - validateOptInRequest(req.body); - res.status(200).json(await optIn(req.body)); - } - ) - ); -} diff --git a/src/chains/algorand/algorand.ts b/src/chains/algorand/algorand.ts index b1ce86ffce..62f22bb2d9 100644 --- a/src/chains/algorand/algorand.ts +++ b/src/chains/algorand/algorand.ts @@ -14,6 +14,7 @@ import fse from 'fs-extra'; import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase'; import axios from 'axios'; import { promises as fs } from 'fs'; +import { AlgorandController } from './algorand.controller'; type AssetListType = TokenListType; @@ -31,6 +32,7 @@ export class Algorand { public gasPrice: number; public gasLimit: number; public gasCost: number; + public controller: typeof AlgorandController; constructor( network: string, @@ -49,6 +51,7 @@ export class Algorand { this.gasPrice = 0; this.gasLimit = 0; this.gasCost = 0.001; + this.controller = AlgorandController; } public get algod(): Algodv2 { @@ -290,4 +293,8 @@ export class Algorand { } return assetData; } + + public get storedTokenList() { + return this._assetMap; + } } diff --git a/src/chains/avalanche/avalanche.ts b/src/chains/avalanche/avalanche.ts index 92df9da9bc..6c5da3644b 100644 --- a/src/chains/avalanche/avalanche.ts +++ b/src/chains/avalanche/avalanche.ts @@ -10,6 +10,7 @@ import { OpenoceanConfig } from '../../connectors/openocean/openocean.config'; import { Ethereumish } from '../../services/common-interfaces'; import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; +import { EVMController } from '../ethereum/evm.controllers'; export class Avalanche extends EthereumBase implements Ethereumish { private static _instances: { [name: string]: Avalanche }; @@ -17,6 +18,7 @@ export class Avalanche extends EthereumBase implements Ethereumish { private _gasPriceRefreshInterval: number | null; private _nativeTokenSymbol: string; private _chain: string; + public controller; private constructor(network: string) { const config = getAvalancheConfig('avalanche', network); @@ -42,6 +44,7 @@ export class Avalanche extends EthereumBase implements Ethereumish { : null; this.updateGasPrice(); + this.controller = EVMController; } public static getInstance(network: string): Avalanche { diff --git a/src/chains/binance-smart-chain/binance-smart-chain.ts b/src/chains/binance-smart-chain/binance-smart-chain.ts index 6c11a744b4..e04dbbe313 100644 --- a/src/chains/binance-smart-chain/binance-smart-chain.ts +++ b/src/chains/binance-smart-chain/binance-smart-chain.ts @@ -4,11 +4,12 @@ import { Contract, Transaction, Wallet } from 'ethers'; import { EthereumBase } from '../ethereum/ethereum-base'; import { getEthereumConfig as getBinanceSmartChainConfig } from '../ethereum/ethereum.config'; import { Provider } from '@ethersproject/abstract-provider'; -import { Ethereumish } from '../../services/common-interfaces'; +import { Chain as Ethereumish } from '../../services/common-interfaces'; import { PancakeSwapConfig } from '../../connectors/pancakeswap/pancakeswap.config'; import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; import { OpenoceanConfig } from '../../connectors/openocean/openocean.config'; +import { EVMController } from '../ethereum/evm.controllers'; export class BinanceSmartChain extends EthereumBase implements Ethereumish { private static _instances: { [name: string]: BinanceSmartChain }; @@ -16,6 +17,7 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish { private _gasPrice: number; private _gasPriceRefreshInterval: number | null; private _nativeTokenSymbol: string; + public controller; private constructor(network: string) { const config = getBinanceSmartChainConfig('binance-smart-chain', network); @@ -39,6 +41,7 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish { : null; this.updateGasPrice(); + this.controller = EVMController; } public static getInstance(network: string): BinanceSmartChain { @@ -102,7 +105,10 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish { this._chain ); } else if (reqSpender === 'openocean') { - spender = OpenoceanConfig.config.routerAddress('binance-smart-chain', this._chain); + spender = OpenoceanConfig.config.routerAddress( + 'binance-smart-chain', + this._chain + ); } else { spender = reqSpender; } diff --git a/src/chains/chain.controller.ts b/src/chains/chain.controller.ts new file mode 100644 index 0000000000..58f8f4d8b7 --- /dev/null +++ b/src/chains/chain.controller.ts @@ -0,0 +1,156 @@ +import { latency } from '../services/base'; + +import { Chain } from '../services/common-interfaces'; +import { + BalanceRequest, + BalanceResponse, + PollRequest, + PollResponse, + TokensRequest, + TokensResponse, +} from '../network/network.requests'; +import { + NonceRequest, + NonceResponse, + AllowancesRequest, + AllowancesResponse, + ApproveRequest, + ApproveResponse, + CancelRequest, + CancelResponse, +} from './chain.requests'; +import { + TransferRequest, + TransferResponse, +} from './injective/injective.requests'; + +export async function poll( + chain: Chain, + req: PollRequest +): Promise { + const initTime = Date.now(); + const poll = await chain.controller.poll(chain, req); + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...poll, + }; +} + +export async function nonce( + chain: Chain, + req: NonceRequest +): Promise { + const initTime = Date.now(); + const nonce = await chain.controller.nonce(chain, req); + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...nonce, + }; +} + +export async function nextNonce( + chain: Chain, + req: NonceRequest +): Promise { + const initTime = Date.now(); + const nextNonce = await chain.controller.nextNonce(chain, req); + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...nextNonce, + }; +} + +export async function getTokens( + chain: Chain, + req: TokensRequest +): Promise { + const initTime = Date.now(); + const tokens = await chain.controller.getTokens(chain, req); + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...tokens, + }; +} + +export async function allowances( + chain: Chain, + req: AllowancesRequest +): Promise { + const initTime = Date.now(); + const allowances = await chain.controller.allowances(chain, req); + + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...allowances, + }; +} + +export async function balances( + chain: Chain, + req: BalanceRequest +): Promise { + const initTime = Date.now(); + const balances = await chain.controller.balances(chain, req); + + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...balances, + }; +} + +export async function approve( + chain: Chain, + req: ApproveRequest +): Promise { + const initTime = Date.now(); + const approveTx = await chain.controller.approve(chain, req); + + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...approveTx, + }; +} + +export async function cancel( + chain: Chain, + req: CancelRequest +): Promise { + const initTime = Date.now(); + const cancelTx = await chain.controller.cancel(chain, req); + + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...cancelTx, + }; +} + +export async function transfer( + chain: Chain, + req: TransferRequest +): Promise { + const initTime = Date.now(); + const transfer = await chain.controller.transfer(chain, req); + + return { + network: chain.chain, + timestamp: initTime, + latency: latency(initTime, Date.now()), + ...transfer, + }; +} diff --git a/src/evm/evm.requests.ts b/src/chains/chain.requests.ts similarity index 100% rename from src/evm/evm.requests.ts rename to src/chains/chain.requests.ts diff --git a/src/chains/chain.routes.ts b/src/chains/chain.routes.ts new file mode 100644 index 0000000000..9488c9050a --- /dev/null +++ b/src/chains/chain.routes.ts @@ -0,0 +1,231 @@ +/* eslint-disable no-inner-declarations */ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/ban-types */ +import { NextFunction, Request, Response, Router } from 'express'; +import { Chain } from '../services/common-interfaces'; +import { ConfigManagerV2 } from '../services/config-manager-v2'; +import { asyncHandler } from '../services/error-handler'; +import { + mkRequestValidator, + RequestValidator, + validateTxHash, +} from '../services/validators'; +import { + validateChain as validateEthereumChain, + validateNetwork as validateEthereumNetwork, +} from '../chains/ethereum/ethereum.validators'; +import { validateNonceRequest } from './ethereum/ethereum.validators'; + +import { getInitializedChain } from '../services/connection-manager'; +import { + AllowancesRequest, + AllowancesResponse, + ApproveRequest, + ApproveResponse, + CancelRequest, + CancelResponse, + NonceRequest, + NonceResponse, +} from './chain.requests'; +import { getStatus } from '../network/network.controllers'; +import { + StatusRequest, + StatusResponse, + BalanceRequest, + BalanceResponse, + PollRequest, + PollResponse, + TokensRequest, + TokensResponse, +} from '../network/network.requests'; +import { + allowances, + approve, + balances, + cancel, + getTokens, + nextNonce, + nonce, + poll, + transfer, +} from './chain.controller'; +import { + TransferRequest, + TransferResponse, +} from './injective/injective.requests'; + +export const validatePollRequest: RequestValidator = mkRequestValidator([ + validateTxHash, +]); + +export const validateTokensRequest: RequestValidator = mkRequestValidator([ + validateEthereumChain, + validateEthereumNetwork, +]); + +export namespace ChainRoutes { + export const router = Router(); + + router.get( + '/status', + asyncHandler( + async ( + req: Request<{}, {}, {}, StatusRequest>, + res: Response + ) => { + res.status(200).json(await getStatus(req.query)); + } + ) + ); + + router.get('/config', (_req: Request, res: Response) => { + res.status(200).json(ConfigManagerV2.getInstance().allConfigurations); + }); + + router.post( + '/balances', + asyncHandler( + async ( + req: Request<{}, {}, BalanceRequest>, + res: Response, + _next: NextFunction + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + + res.status(200).json(await balances(chain, req.body)); + } + ) + ); + + router.post( + '/poll', + asyncHandler( + async ( + req: Request<{}, {}, PollRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await poll(chain, req.body)); + } + ) + ); + + router.get( + '/tokens', + asyncHandler( + async ( + req: Request<{}, {}, {}, TokensRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.query.chain as string, + req.query.network as string + ); + res.status(200).json(await getTokens(chain, req.query)); + } + ) + ); + + router.post( + '/nextNonce', + asyncHandler( + async ( + req: Request<{}, {}, NonceRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await nextNonce(chain, req.body)); + } + ) + ); + + router.post( + '/nonce', + asyncHandler( + async ( + req: Request<{}, {}, NonceRequest>, + res: Response + ) => { + validateNonceRequest(req.body); + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await nonce(chain, req.body)); + } + ) + ); + + router.post( + '/allowances', + asyncHandler( + async ( + req: Request<{}, {}, AllowancesRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await allowances(chain, req.body)); + } + ) + ); + + router.post( + '/approve', + asyncHandler( + async ( + req: Request<{}, {}, ApproveRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await approve(chain, req.body)); + } + ) + ); + + router.post( + '/cancel', + asyncHandler( + async ( + req: Request<{}, {}, CancelRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await cancel(chain, req.body)); + } + ) + ); + + router.post( + '/transfer', + asyncHandler( + async ( + req: Request<{}, {}, TransferRequest>, + res: Response + ) => { + const chain = await getInitializedChain( + req.body.chain, + req.body.network + ); + res.status(200).json(await transfer(chain, req.body)); + } + ) + ); +} diff --git a/src/chains/cosmos/cosmos.controllers.ts b/src/chains/cosmos/cosmos.controllers.ts index 3444650d25..ce4b8c9629 100644 --- a/src/chains/cosmos/cosmos.controllers.ts +++ b/src/chains/cosmos/cosmos.controllers.ts @@ -1,52 +1,18 @@ import { Cosmos } from './cosmos'; -import { - CosmosBalanceRequest, - CosmosBalanceResponse, - CosmosPollRequest, - CosmosPollResponse, -} from './cosmos.requests'; -import { latency, TokenValue, tokenValueToString } from '../../services/base'; +import { CosmosBalanceRequest, CosmosPollRequest } from './cosmos.requests'; +import { TokenValue, tokenValueToString } from '../../services/base'; import { HttpException, TOKEN_NOT_SUPPORTED_ERROR_CODE, TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, } from '../../services/error-handler'; +import { + validateCosmosBalanceRequest, + validateCosmosPollRequest, +} from './cosmos.validators'; const { decodeTxRaw } = require('@cosmjs/proto-signing'); -export async function balances( - cosmosish: Cosmos, - req: CosmosBalanceRequest -): Promise { - const initTime = Date.now(); - - const wallet = await cosmosish.getWallet(req.address, 'cosmos'); - - const { tokenSymbols } = req; - - tokenSymbols.forEach((symbol: string) => { - const token = cosmosish.getTokenForSymbol(symbol); - - if (!token) { - throw new HttpException( - 500, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + symbol, - TOKEN_NOT_SUPPORTED_ERROR_CODE - ); - } - }); - - const balances = await cosmosish.getBalances(wallet); - const filteredBalances = toCosmosBalances(balances, tokenSymbols); - - return { - network: cosmosish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - balances: filteredBalances, - }; -} - export const toCosmosBalances = ( balances: Record, tokenSymbols: Array @@ -66,22 +32,47 @@ export const toCosmosBalances = ( return walletBalances; }; -export async function poll( - cosmos: Cosmos, - req: CosmosPollRequest -): Promise { - const initTime = Date.now(); - const transaction = await cosmos.getTransaction(req.txHash); - const currentBlock = await cosmos.getCurrentBlockNumber(); - - return { - network: cosmos.chain, - timestamp: initTime, - txHash: req.txHash, - currentBlock, - txBlock: transaction.height, - gasUsed: transaction.gasUsed, - gasWanted: transaction.gasWanted, - txData: decodeTxRaw(transaction.tx), - }; +export class CosmosController { + static async balances(cosmosish: Cosmos, req: CosmosBalanceRequest) { + validateCosmosBalanceRequest(req); + + const wallet = await cosmosish.getWallet(req.address, 'cosmos'); + + const { tokenSymbols } = req; + + tokenSymbols.forEach((symbol: string) => { + const token = cosmosish.getTokenForSymbol(symbol); + + if (!token) { + throw new HttpException( + 500, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + symbol, + TOKEN_NOT_SUPPORTED_ERROR_CODE + ); + } + }); + + const balances = await cosmosish.getBalances(wallet); + const filteredBalances = toCosmosBalances(balances, tokenSymbols); + + return { + balances: filteredBalances, + }; + } + + static async poll(cosmos: Cosmos, req: CosmosPollRequest) { + validateCosmosPollRequest(req); + + const transaction = await cosmos.getTransaction(req.txHash); + const currentBlock = await cosmos.getCurrentBlockNumber(); + + return { + txHash: req.txHash, + currentBlock, + txBlock: transaction.height, + gasUsed: transaction.gasUsed, + gasWanted: transaction.gasWanted, + txData: decodeTxRaw(transaction.tx), + }; + } } diff --git a/src/chains/cosmos/cosmos.routes.ts b/src/chains/cosmos/cosmos.routes.ts deleted file mode 100644 index 9d1b514017..0000000000 --- a/src/chains/cosmos/cosmos.routes.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ -import { NextFunction, Router, Request, Response } from 'express'; -import { verifyCosmosIsAvailable } from './cosmos-middlewares'; -import { asyncHandler } from '../../services/error-handler'; -import { Cosmos } from './cosmos'; -import { balances, poll } from './cosmos.controllers'; -import { - CosmosBalanceResponse, - CosmosBalanceRequest, - CosmosPollRequest, - CosmosPollResponse, -} from './cosmos.requests'; -import { - validateCosmosBalanceRequest, - validateCosmosPollRequest, -} from './cosmos.validators'; - -export namespace CosmosRoutes { - export const router = Router(); - export const getCosmos = async (request: Request) => { - const cosmos = await Cosmos.getInstance(request.body.network); - await cosmos.init(); - - return cosmos; - }; - - router.use(asyncHandler(verifyCosmosIsAvailable)); - - router.get( - '/', - asyncHandler(async (_req: Request, res: Response) => { - const { rpcUrl, chain } = await getCosmos(_req); - - res.status(200).json({ - network: chain, - rpcUrl: rpcUrl, - connection: true, - timestamp: Date.now(), - }); - }) - ); - - // Get balance for wallet - router.post( - '/balances', - asyncHandler( - async ( - req: Request<{}, {}, CosmosBalanceRequest>, - res: Response, - _next: NextFunction - ) => { - const cosmos = await getCosmos(req); - validateCosmosBalanceRequest(req.body); - res.status(200).json(await balances(cosmos, req.body)); - } - ) - ); - - // Gets status information about given transaction hash - router.post( - '/poll', - asyncHandler( - async ( - req: Request<{}, {}, CosmosPollRequest>, - res: Response - ) => { - const cosmos = await getCosmos(req); - - validateCosmosPollRequest(req.body); - res.status(200).json(await poll(cosmos, req.body)); - } - ) - ); -} diff --git a/src/chains/cosmos/cosmos.ts b/src/chains/cosmos/cosmos.ts index 6917c9a659..2238437eb3 100644 --- a/src/chains/cosmos/cosmos.ts +++ b/src/chains/cosmos/cosmos.ts @@ -2,6 +2,7 @@ import { Cosmosish } from '../../services/common-interfaces'; import { CosmosBase } from './cosmos-base'; import { getCosmosConfig } from './cosmos.config'; import { logger } from '../../services/logger'; +import { CosmosController } from './cosmos.controllers'; export class Cosmos extends CosmosBase implements Cosmosish { private static _instances: { [name: string]: Cosmos }; @@ -11,6 +12,7 @@ export class Cosmos extends CosmosBase implements Cosmosish { private _requestCount: number; private _metricsLogInterval: number; private _metricTimer; + public controller; private constructor(network: string) { const config = getCosmosConfig('cosmos'); @@ -33,6 +35,7 @@ export class Cosmos extends CosmosBase implements Cosmosish { this.metricLogger.bind(this), this.metricsLogInterval ); + this.controller = CosmosController; } public static getInstance(network: string): Cosmos { diff --git a/src/chains/cronos/cronos.ts b/src/chains/cronos/cronos.ts index 00f68a8609..c39a2dfe2d 100755 --- a/src/chains/cronos/cronos.ts +++ b/src/chains/cronos/cronos.ts @@ -9,6 +9,7 @@ import { MadMeerkatConfig } from '../../connectors/mad_meerkat/mad_meerkat.confi import { VVSConfig } from '../../connectors/vvs/vvs.config'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; import { OpenoceanConfig } from '../../connectors/openocean/openocean.config'; +import { EVMController } from '../ethereum/evm.controllers'; export class Cronos extends EthereumBase implements Ethereumish { private static _instances: { [name: string]: Cronos }; @@ -16,6 +17,7 @@ export class Cronos extends EthereumBase implements Ethereumish { private _gasPriceRefreshInterval: number | null; private _nativeTokenSymbol: string; private _chain: string; + public controller; private constructor(network: string) { const config = getCronosConfig('cronos', network); @@ -40,6 +42,7 @@ export class Cronos extends EthereumBase implements Ethereumish { : null; this.updateGasPrice(); + this.controller = EVMController; } public static getInstance(network: string): Cronos { diff --git a/src/chains/ethereum/ethereum-base.ts b/src/chains/ethereum/ethereum-base.ts index 08e1e9723c..64aefbe3a8 100644 --- a/src/chains/ethereum/ethereum-base.ts +++ b/src/chains/ethereum/ethereum-base.ts @@ -11,9 +11,9 @@ import { promises as fs } from 'fs'; import path from 'path'; import { rootPath } from '../../paths'; import { TokenListType, TokenValue, walletPath } from '../../services/base'; -import { EVMNonceManager } from '../../evm/evm.nonce'; +import { EVMNonceManager } from './evm.nonce'; import NodeCache from 'node-cache'; -import { EvmTxStorage } from '../../evm/evm.tx-storage'; +import { EvmTxStorage } from './evm.tx-storage'; import fse from 'fs-extra'; import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase'; import { logger } from '../../services/logger'; diff --git a/src/chains/ethereum/ethereum.controllers.ts b/src/chains/ethereum/ethereum.controllers.ts deleted file mode 100644 index 2b4af46fdf..0000000000 --- a/src/chains/ethereum/ethereum.controllers.ts +++ /dev/null @@ -1,456 +0,0 @@ -import ethers, { - constants, - Wallet, - utils, - BigNumber, - Transaction, -} from 'ethers'; -import { latency, bigNumberWithDecimalToStr } from '../../services/base'; -import { - HttpException, - LOAD_WALLET_ERROR_CODE, - LOAD_WALLET_ERROR_MESSAGE, - TOKEN_NOT_SUPPORTED_ERROR_CODE, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, -} from '../../services/error-handler'; -import { tokenValueToString } from '../../services/base'; -import { TokenInfo } from './ethereum-base'; -import { getConnector } from '../../services/connection-manager'; - -import { - CustomTransactionReceipt, - CustomTransaction, - CustomTransactionResponse, -} from './ethereum.requests'; -import { - Ethereumish, - UniswapLPish, - Uniswapish, - CLOBish, -} from '../../services/common-interfaces'; -import { - NonceRequest, - NonceResponse, - AllowancesRequest, - AllowancesResponse, - ApproveRequest, - ApproveResponse, - CancelRequest, - CancelResponse, -} from '../../evm/evm.requests'; -import { - PollRequest, - PollResponse, - BalanceRequest, - BalanceResponse, -} from '../../network/network.requests'; -import { logger } from '../../services/logger'; - -export async function nonce( - ethereum: Ethereumish, - req: NonceRequest -): Promise { - // get the address via the public key since we generally use the public - // key to interact with gateway and the address is not part of the user config - const wallet = await ethereum.getWallet(req.address); - const nonce = await ethereum.nonceManager.getNonce(wallet.address); - return { nonce }; -} - -export async function nextNonce( - ethereum: Ethereumish, - req: NonceRequest -): Promise { - // get the address via the public key since we generally use the public - // key to interact with gateway and the address is not part of the user config - const wallet = await ethereum.getWallet(req.address); - const nonce = await ethereum.nonceManager.getNextNonce(wallet.address); - return { nonce }; -} - -export const getTokenSymbolsToTokens = ( - ethereum: Ethereumish, - tokenSymbols: Array -): Record => { - const tokens: Record = {}; - - for (let i = 0; i < tokenSymbols.length; i++) { - const symbol = tokenSymbols[i]; - const token = ethereum.getTokenBySymbol(symbol); - if (token) tokens[symbol] = token; - } - - return tokens; -}; - -export async function allowances( - ethereumish: Ethereumish, - req: AllowancesRequest -): Promise { - const initTime = Date.now(); - const wallet = await ethereumish.getWallet(req.address); - const tokens = getTokenSymbolsToTokens(ethereumish, req.tokenSymbols); - const spender = ethereumish.getSpender(req.spender); - - const approvals: Record = {}; - await Promise.all( - Object.keys(tokens).map(async (symbol) => { - // instantiate a contract and pass in provider for read-only access - const contract = ethereumish.getContract( - tokens[symbol].address, - ethereumish.provider - ); - approvals[symbol] = tokenValueToString( - await ethereumish.getERC20Allowance( - contract, - wallet, - spender, - tokens[symbol].decimals - ) - ); - }) - ); - - return { - network: ethereumish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - spender: spender, - approvals: approvals, - }; -} - -export async function balances( - ethereumish: Ethereumish, - req: BalanceRequest -): Promise { - const initTime = Date.now(); - - let wallet: Wallet; - const connector: CLOBish | undefined = req.connector - ? ((await getConnector(req.chain, req.network, req.connector)) as CLOBish) - : undefined; - const balances: Record = {}; - let connectorBalances: { [key: string]: string } | undefined; - - if (!connector?.balances) { - try { - wallet = await ethereumish.getWallet(req.address); - } catch (err) { - throw new HttpException( - 500, - LOAD_WALLET_ERROR_MESSAGE + err, - LOAD_WALLET_ERROR_CODE - ); - } - - const tokens = getTokenSymbolsToTokens(ethereumish, req.tokenSymbols); - if (req.tokenSymbols.includes(ethereumish.nativeTokenSymbol)) { - balances[ethereumish.nativeTokenSymbol] = tokenValueToString( - await ethereumish.getNativeBalance(wallet) - ); - } - await Promise.all( - Object.keys(tokens).map(async (symbol) => { - if (tokens[symbol] !== undefined) { - const address = tokens[symbol].address; - const decimals = tokens[symbol].decimals; - // instantiate a contract and pass in provider for read-only access - const contract = ethereumish.getContract( - address, - ethereumish.provider - ); - const balance = await ethereumish.getERC20Balance( - contract, - wallet, - decimals - ); - balances[symbol] = tokenValueToString(balance); - } - }) - ); - - if (!Object.keys(balances).length) { - throw new HttpException( - 500, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, - TOKEN_NOT_SUPPORTED_ERROR_CODE - ); - } - } else { - // CLOB connector or any other connector that has the concept of separation of account has to implement a balance function - connectorBalances = await connector.balances(req); - } - - return { - network: ethereumish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - balances: connectorBalances || balances, - }; -} - -const toEthereumTransaction = (transaction: Transaction): CustomTransaction => { - let maxFeePerGas = null; - if (transaction.maxFeePerGas) { - maxFeePerGas = transaction.maxFeePerGas.toString(); - } - let maxPriorityFeePerGas = null; - if (transaction.maxPriorityFeePerGas) { - maxPriorityFeePerGas = transaction.maxPriorityFeePerGas.toString(); - } - let gasLimit = null; - if (transaction.gasLimit) { - gasLimit = transaction.gasLimit.toString(); - } - return { - ...transaction, - maxPriorityFeePerGas, - maxFeePerGas, - gasLimit, - value: transaction.value.toString(), - }; -}; - -export async function approve( - ethereumish: Ethereumish, - req: ApproveRequest -): Promise { - const { amount, nonce, address, token, maxFeePerGas, maxPriorityFeePerGas } = - req; - - const spender = ethereumish.getSpender(req.spender); - const initTime = Date.now(); - let wallet: Wallet; - try { - wallet = await ethereumish.getWallet(address); - } catch (err) { - throw new HttpException( - 500, - LOAD_WALLET_ERROR_MESSAGE + err, - LOAD_WALLET_ERROR_CODE - ); - } - const fullToken = ethereumish.getTokenBySymbol(token); - if (!fullToken) { - throw new HttpException( - 500, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + token, - TOKEN_NOT_SUPPORTED_ERROR_CODE - ); - } - const amountBigNumber = amount - ? utils.parseUnits(amount, fullToken.decimals) - : constants.MaxUint256; - - let maxFeePerGasBigNumber; - if (maxFeePerGas) { - maxFeePerGasBigNumber = BigNumber.from(maxFeePerGas); - } - let maxPriorityFeePerGasBigNumber; - if (maxPriorityFeePerGas) { - maxPriorityFeePerGasBigNumber = BigNumber.from(maxPriorityFeePerGas); - } - // instantiate a contract and pass in wallet, which act on behalf of that signer - const contract = ethereumish.getContract(fullToken.address, wallet); - - // convert strings to BigNumber - // call approve function - const approval = await ethereumish.approveERC20( - contract, - wallet, - spender, - amountBigNumber, - nonce, - maxFeePerGasBigNumber, - maxPriorityFeePerGasBigNumber, - ethereumish.gasPrice - ); - - if (approval.hash) { - await ethereumish.txStorage.saveTx( - ethereumish.chain, - ethereumish.chainId, - approval.hash, - new Date(), - ethereumish.gasPrice - ); - } - - return { - network: ethereumish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - tokenAddress: fullToken.address, - spender: spender, - amount: bigNumberWithDecimalToStr(amountBigNumber, fullToken.decimals), - nonce: approval.nonce, - approval: toEthereumTransaction(approval), - }; -} - -// TransactionReceipt from ethers uses BigNumber which is not easy to interpret directly from JSON. -// Transform those BigNumbers to string and pass the rest of the data without changes. - -const toEthereumTransactionReceipt = ( - receipt: ethers.providers.TransactionReceipt | null -): CustomTransactionReceipt | null => { - if (receipt) { - let effectiveGasPrice = null; - if (receipt.effectiveGasPrice) { - effectiveGasPrice = receipt.effectiveGasPrice.toString(); - } - return { - ...receipt, - gasUsed: receipt.gasUsed.toString(), - cumulativeGasUsed: receipt.cumulativeGasUsed.toString(), - effectiveGasPrice, - }; - } - - return null; -}; - -const toEthereumTransactionResponse = ( - response: ethers.providers.TransactionResponse | null -): CustomTransactionResponse | null => { - if (response) { - let gasPrice = null; - if (response.gasPrice) { - gasPrice = response.gasPrice.toString(); - } - return { - ...response, - gasPrice, - gasLimit: response.gasLimit.toString(), - value: response.value.toString(), - }; - } - - return null; -}; - -export function willTxSucceed( - txDuration: number, - txDurationLimit: number, - txGasPrice: number, - currentGasPrice: number -): boolean { - if (txDuration > txDurationLimit && currentGasPrice > txGasPrice) { - return false; - } - return true; -} - -// txStatus -// -1: not in the mempool or failed -// 1: succeeded -// 2: in the mempool and likely to succeed -// 3: in the mempool and likely to fail -// 0: in the mempool but we dont have data to guess its status -export async function poll( - ethereumish: Ethereumish, - req: PollRequest -): Promise { - const initTime = Date.now(); - const currentBlock = await ethereumish.getCurrentBlockNumber(); - const txData = await ethereumish.getTransaction(req.txHash); - let txBlock, txReceipt, txStatus; - if (!txData) { - // tx not found, didn't reach the mempool or it never existed - txBlock = -1; - txReceipt = null; - txStatus = -1; - } else { - txReceipt = await ethereumish.getTransactionReceipt(req.txHash); - if (txReceipt === null) { - // tx is in the mempool - txBlock = -1; - txReceipt = null; - txStatus = 0; - - const transactions = await ethereumish.txStorage.getTxs( - ethereumish.chain, - ethereumish.chainId - ); - - if (transactions[txData.hash]) { - const data: [Date, number] = transactions[txData.hash]; - const now = new Date(); - const txDuration = Math.abs(now.getTime() - data[0].getTime()); - if ( - willTxSucceed(txDuration, 60000 * 3, data[1], ethereumish.gasPrice) - ) { - txStatus = 2; - } else { - txStatus = 3; - } - } - } else { - // tx has been processed - txBlock = txReceipt.blockNumber; - txStatus = typeof txReceipt.status === 'number' ? 1 : -1; - - // decode logs - if (req.connector) { - try { - const connector: Uniswapish | UniswapLPish | CLOBish = - await getConnector( - req.chain, - req.network, - req.connector - ); - - txReceipt.logs = connector.abiDecoder?.decodeLogs(txReceipt.logs); - } catch (e) { - logger.error(e); - } - } - } - } - - logger.info( - `Poll ${ethereumish.chain}, txHash ${req.txHash}, status ${txStatus}.` - ); - return { - network: ethereumish.chain, - currentBlock, - timestamp: initTime, - txHash: req.txHash, - txBlock, - txStatus, - txData: toEthereumTransactionResponse(txData), - txReceipt: toEthereumTransactionReceipt(txReceipt), - }; -} - -export async function cancel( - ethereumish: Ethereumish, - req: CancelRequest -): Promise { - const initTime = Date.now(); - let wallet: Wallet; - try { - wallet = await ethereumish.getWallet(req.address); - } catch (err) { - throw new HttpException( - 500, - LOAD_WALLET_ERROR_MESSAGE + err, - LOAD_WALLET_ERROR_CODE - ); - } - - // call cancelTx function - const cancelTx = await ethereumish.cancelTx(wallet, req.nonce); - - logger.info( - `Cancelled transaction at nonce ${req.nonce}, cancel txHash ${cancelTx.hash}.` - ); - - return { - network: ethereumish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - txHash: cancelTx.hash, - }; -} diff --git a/src/chains/ethereum/ethereum.requests.ts b/src/chains/ethereum/ethereum.requests.ts index dbfa95a58f..d699398aa5 100644 --- a/src/chains/ethereum/ethereum.requests.ts +++ b/src/chains/ethereum/ethereum.requests.ts @@ -1,4 +1,5 @@ import ethers, { Transaction } from 'ethers'; +import { NetworkSelectionRequest } from '../../services/common-interfaces'; // gasUsed and cumulativeGasUsed are BigNumbers // then need to be converted to strings before being @@ -89,7 +90,7 @@ export interface EthereumApproveResponse { approval: CustomTransaction; } -export interface PollRequest { +export interface PollRequest extends NetworkSelectionRequest { txHash: string; } diff --git a/src/chains/ethereum/ethereum.ts b/src/chains/ethereum/ethereum.ts index 7808ad9718..9315258a1e 100644 --- a/src/chains/ethereum/ethereum.ts +++ b/src/chains/ethereum/ethereum.ts @@ -6,7 +6,8 @@ import { getEthereumConfig } from './ethereum.config'; import { Provider } from '@ethersproject/abstract-provider'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; // import { throttleRetryWrapper } from '../../services/retry'; -import { Ethereumish } from '../../services/common-interfaces'; +import { Chain as Ethereumish } from '../../services/common-interfaces'; +import { EVMController } from './evm.controllers'; import { UniswapConfig } from '../../connectors/uniswap/uniswap.config'; import { Perp } from '../../connectors/perp/perp'; @@ -33,6 +34,7 @@ export class Ethereum extends EthereumBase implements Ethereumish { private _requestCount: number; private _metricsLogInterval: number; private _metricTimer; + public controller; private constructor(network: string) { const config = getEthereumConfig('ethereum', network); @@ -65,6 +67,7 @@ export class Ethereum extends EthereumBase implements Ethereumish { this.metricLogger.bind(this), this.metricsLogInterval ); + this.controller = EVMController; } public static getInstance(network: string): Ethereum { diff --git a/src/chains/ethereum/evm.controllers.ts b/src/chains/ethereum/evm.controllers.ts new file mode 100644 index 0000000000..ea6e17b6ab --- /dev/null +++ b/src/chains/ethereum/evm.controllers.ts @@ -0,0 +1,472 @@ +import ethers, { + constants, + Wallet, + utils, + BigNumber, + Transaction, +} from 'ethers'; +import { bigNumberWithDecimalToStr } from '../../services/base'; +import { + HttpException, + LOAD_WALLET_ERROR_CODE, + LOAD_WALLET_ERROR_MESSAGE, + TOKEN_NOT_SUPPORTED_ERROR_CODE, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, +} from '../../services/error-handler'; +import { tokenValueToString } from '../../services/base'; +import { TokenInfo } from './ethereum-base'; +import { getConnector } from '../../services/connection-manager'; + +import { + CustomTransactionReceipt, + CustomTransactionResponse, + PollRequest, +} from './ethereum.requests'; +import { + CLOBish, + Chain as Ethereumish, + UniswapLPish, + Uniswapish, +} from '../../services/common-interfaces'; +import { + NonceRequest, + NonceResponse, + AllowancesRequest, + ApproveRequest, + CancelRequest, +} from '../chain.requests'; +import { BalanceRequest, TokensRequest } from '../../network/network.requests'; +import { logger } from '../../services/logger'; +import { + validateAllowancesRequest, + validateApproveRequest, + validateBalanceRequest, + validateCancelRequest, + validateNonceRequest, +} from './ethereum.validators'; +import { validatePollRequest, validateTokensRequest } from '../chain.routes'; + +// TransactionReceipt from ethers uses BigNumber which is not easy to interpret directly from JSON. +// Transform those BigNumbers to string and pass the rest of the data without changes. + +const toEthereumTransactionReceipt = ( + receipt: ethers.providers.TransactionReceipt | null +): CustomTransactionReceipt | null => { + if (receipt) { + let effectiveGasPrice = null; + if (receipt.effectiveGasPrice) { + effectiveGasPrice = receipt.effectiveGasPrice.toString(); + } + return { + ...receipt, + gasUsed: receipt.gasUsed.toString(), + cumulativeGasUsed: receipt.cumulativeGasUsed.toString(), + effectiveGasPrice, + }; + } + + return null; +}; + +const toEthereumTransactionResponse = ( + response: ethers.providers.TransactionResponse | null +): CustomTransactionResponse | null => { + if (response) { + let gasPrice = null; + if (response.gasPrice) { + gasPrice = response.gasPrice.toString(); + } + return { + ...response, + gasPrice, + gasLimit: response.gasLimit.toString(), + value: response.value.toString(), + }; + } + + return null; +}; + +const toEthereumTransaction = (transaction: Transaction) => { + let maxFeePerGas = null; + if (transaction.maxFeePerGas) { + maxFeePerGas = transaction.maxFeePerGas.toString(); + } + let maxPriorityFeePerGas = null; + if (transaction.maxPriorityFeePerGas) { + maxPriorityFeePerGas = transaction.maxPriorityFeePerGas.toString(); + } + let gasLimit = null; + if (transaction.gasLimit) { + gasLimit = transaction.gasLimit.toString(); + } + return { + ...transaction, + maxPriorityFeePerGas, + maxFeePerGas, + gasLimit, + value: transaction.value.toString(), + }; +}; + +export const willTxSucceed = ( + txDuration: number, + txDurationLimit: number, + txGasPrice: number, + currentGasPrice: number +) => { + if (txDuration > txDurationLimit && currentGasPrice > txGasPrice) { + return false; + } + return true; +}; + +export class EVMController { + // txStatus + // -1: not in the mempool or failed + // 1: succeeded + // 2: in the mempool and likely to succeed + // 3: in the mempool and likely to fail + // 0: in the mempool but we dont have data to guess its status + static async poll(ethereumish: Ethereumish, req: PollRequest) { + validatePollRequest(req); + + const currentBlock = await ethereumish.getCurrentBlockNumber(); + const txData = await ethereumish.getTransaction(req.txHash); + let txBlock, txReceipt, txStatus; + if (!txData) { + // tx not found, didn't reach the mempool or it never existed + txBlock = -1; + txReceipt = null; + txStatus = -1; + } else { + txReceipt = await ethereumish.getTransactionReceipt(req.txHash); + if (txReceipt === null) { + // tx is in the mempool + txBlock = -1; + txReceipt = null; + txStatus = 0; + + const transactions = await ethereumish.txStorage.getTxs( + ethereumish.chain, + ethereumish.chainId + ); + + if (transactions[txData.hash]) { + const data: [Date, number] = transactions[txData.hash]; + const now = new Date(); + const txDuration = Math.abs(now.getTime() - data[0].getTime()); + if ( + willTxSucceed(txDuration, 60000 * 3, data[1], ethereumish.gasPrice) + ) { + txStatus = 2; + } else { + txStatus = 3; + } + } + } else { + // tx has been processed + txBlock = txReceipt.blockNumber; + txStatus = typeof txReceipt.status === 'number' ? 1 : -1; + + // decode logs + if (req.connector) { + try { + const connector: Uniswapish | UniswapLPish | CLOBish = + await getConnector( + req.chain, + req.network, + req.connector + ); + + txReceipt.logs = connector.abiDecoder?.decodeLogs(txReceipt.logs); + } catch (e) { + logger.error(e); + } + } + } + } + + logger.info( + `Poll ${ethereumish.chain}, txHash ${req.txHash}, status ${txStatus}.` + ); + return { + currentBlock, + txHash: req.txHash, + txBlock, + txStatus, + txData: toEthereumTransactionResponse(txData), + txReceipt: toEthereumTransactionReceipt(txReceipt), + }; + } + + static async nonce( + ethereum: Ethereumish, + req: NonceRequest + ): Promise { + validateNonceRequest(req); + // get the address via the public key since we generally use the public + // key to interact with gateway and the address is not part of the user config + const wallet = await ethereum.getWallet(req.address); + const nonce = await ethereum.nonceManager.getNonce(wallet.address); + return { nonce }; + } + + static async nextNonce( + ethereum: Ethereumish, + req: NonceRequest + ): Promise { + validateNonceRequest(req); + // get the address via the public key since we generally use the public + // key to interact with gateway and the address is not part of the user config + const wallet = await ethereum.getWallet(req.address); + const nonce = await ethereum.nonceManager.getNextNonce(wallet.address); + return { nonce }; + } + + static getTokenSymbolsToTokens = ( + ethereum: Ethereumish, + tokenSymbols: Array + ): Record => { + const tokens: Record = {}; + + for (let i = 0; i < tokenSymbols.length; i++) { + const symbol = tokenSymbols[i]; + const token = ethereum.getTokenBySymbol(symbol); + if (token) tokens[symbol] = token; + } + + return tokens; + }; + + static async getTokens(connection: Ethereumish, req: TokensRequest) { + validateTokensRequest(req); + let tokens: TokenInfo[] = []; + if (!req.tokenSymbols) { + tokens = connection.storedTokenList; + } else { + for (const t of req.tokenSymbols as []) { + tokens.push(connection.getTokenForSymbol(t) as TokenInfo); + } + } + + return { tokens }; + } + + static async allowances(ethereumish: Ethereumish, req: AllowancesRequest) { + validateAllowancesRequest(req); + return EVMController.allowancesWithoutValidation(ethereumish, req); + } + + static async allowancesWithoutValidation( + ethereumish: Ethereumish, + req: AllowancesRequest + ) { + const wallet = await ethereumish.getWallet(req.address); + const tokens = EVMController.getTokenSymbolsToTokens( + ethereumish, + req.tokenSymbols + ); + const spender = ethereumish.getSpender(req.spender); + + const approvals: Record = {}; + await Promise.all( + Object.keys(tokens).map(async (symbol) => { + // instantiate a contract and pass in provider for read-only access + const contract = ethereumish.getContract( + tokens[symbol].address, + ethereumish.provider + ); + approvals[symbol] = tokenValueToString( + await ethereumish.getERC20Allowance( + contract, + wallet, + spender, + tokens[symbol].decimals + ) + ); + }) + ); + + return { + spender: spender, + approvals: approvals, + }; + } + + static async balances(ethereumish: Ethereumish, req: BalanceRequest) { + validateBalanceRequest(req); + + let wallet: Wallet; + const connector: CLOBish | undefined = req.connector + ? ((await getConnector(req.chain, req.network, req.connector)) as CLOBish) + : undefined; + const balances: Record = {}; + let connectorBalances: { [key: string]: string } | undefined; + + if (!connector?.balances) { + try { + wallet = await ethereumish.getWallet(req.address); + } catch (err) { + throw new HttpException( + 500, + LOAD_WALLET_ERROR_MESSAGE + err, + LOAD_WALLET_ERROR_CODE + ); + } + + const tokens = EVMController.getTokenSymbolsToTokens( + ethereumish, + req.tokenSymbols + ); + if (req.tokenSymbols.includes(ethereumish.nativeTokenSymbol)) { + balances[ethereumish.nativeTokenSymbol] = tokenValueToString( + await ethereumish.getNativeBalance(wallet) + ); + } + await Promise.all( + Object.keys(tokens).map(async (symbol) => { + if (tokens[symbol] !== undefined) { + const address = tokens[symbol].address; + const decimals = tokens[symbol].decimals; + // instantiate a contract and pass in provider for read-only access + const contract = ethereumish.getContract( + address, + ethereumish.provider + ); + const balance = await ethereumish.getERC20Balance( + contract, + wallet, + decimals + ); + balances[symbol] = tokenValueToString(balance); + } + }) + ); + + if (!Object.keys(balances).length) { + throw new HttpException( + 500, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, + TOKEN_NOT_SUPPORTED_ERROR_CODE + ); + } + } else { + // CLOB connector or any other connector that has the concept of separation of account has to implement a balance function + connectorBalances = await connector.balances(req); + } + + return { + balances: connectorBalances || balances, + }; + } + + static async approve(ethereumish: Ethereumish, req: ApproveRequest) { + validateApproveRequest(req); + return await EVMController.approveWithoutValidation(ethereumish, req); + } + + static async approveWithoutValidation( + ethereumish: Ethereumish, + req: ApproveRequest + ) { + const { + amount, + nonce, + address, + token, + maxFeePerGas, + maxPriorityFeePerGas, + } = req; + + const spender = ethereumish.getSpender(req.spender); + let wallet: Wallet; + try { + wallet = await ethereumish.getWallet(address); + } catch (err) { + throw new HttpException( + 500, + LOAD_WALLET_ERROR_MESSAGE + err, + LOAD_WALLET_ERROR_CODE + ); + } + const fullToken = ethereumish.getTokenBySymbol(token); + if (!fullToken) { + throw new HttpException( + 500, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE + token, + TOKEN_NOT_SUPPORTED_ERROR_CODE + ); + } + const amountBigNumber = amount + ? utils.parseUnits(amount, fullToken.decimals) + : constants.MaxUint256; + + let maxFeePerGasBigNumber; + if (maxFeePerGas) { + maxFeePerGasBigNumber = BigNumber.from(maxFeePerGas); + } + let maxPriorityFeePerGasBigNumber; + if (maxPriorityFeePerGas) { + maxPriorityFeePerGasBigNumber = BigNumber.from(maxPriorityFeePerGas); + } + // instantiate a contract and pass in wallet, which act on behalf of that signer + const contract = ethereumish.getContract(fullToken.address, wallet); + + // convert strings to BigNumber + // call approve function + const approval = await ethereumish.approveERC20( + contract, + wallet, + spender, + amountBigNumber, + nonce, + maxFeePerGasBigNumber, + maxPriorityFeePerGasBigNumber, + ethereumish.gasPrice + ); + + if (approval.hash) { + await ethereumish.txStorage.saveTx( + ethereumish.chain, + ethereumish.chainId, + approval.hash, + new Date(), + ethereumish.gasPrice + ); + } + + return { + tokenAddress: fullToken.address, + spender: spender, + amount: bigNumberWithDecimalToStr(amountBigNumber, fullToken.decimals), + nonce: approval.nonce, + approval: toEthereumTransaction(approval), + }; + } + + static async cancel(ethereumish: Ethereumish, req: CancelRequest) { + validateCancelRequest(req); + let wallet: Wallet; + try { + wallet = await ethereumish.getWallet(req.address); + } catch (err) { + throw new HttpException( + 500, + LOAD_WALLET_ERROR_MESSAGE + err, + LOAD_WALLET_ERROR_CODE + ); + } + + // call cancelTx function + const cancelTx = await ethereumish.cancelTx(wallet, req.nonce); + + logger.info( + `Cancelled transaction at nonce ${req.nonce}, cancel txHash ${cancelTx.hash}.` + ); + + return { + txHash: cancelTx.hash, + }; + } +} diff --git a/src/evm/evm.nonce.ts b/src/chains/ethereum/evm.nonce.ts similarity index 98% rename from src/evm/evm.nonce.ts rename to src/chains/ethereum/evm.nonce.ts index 3de221847c..60c949e4d1 100644 --- a/src/evm/evm.nonce.ts +++ b/src/chains/ethereum/evm.nonce.ts @@ -5,10 +5,10 @@ import { INVALID_NONCE_ERROR_MESSAGE, SERVICE_UNITIALIZED_ERROR_CODE, SERVICE_UNITIALIZED_ERROR_MESSAGE, -} from '../services/error-handler'; -import { LocalStorage } from '../services/local-storage'; -import { logger } from '../services/logger'; -import { ReferenceCountingCloseable } from '../services/refcounting-closeable'; +} from '../../services/error-handler'; +import { LocalStorage } from '../../services/local-storage'; +import { logger } from '../../services/logger'; +import { ReferenceCountingCloseable } from '../../services/refcounting-closeable'; export class NonceInfo { constructor(readonly nonce: number, public expiry: number) {} diff --git a/src/evm/evm.tx-storage.ts b/src/chains/ethereum/evm.tx-storage.ts similarity index 92% rename from src/evm/evm.tx-storage.ts rename to src/chains/ethereum/evm.tx-storage.ts index 907e19d716..c74e6eae2e 100644 --- a/src/evm/evm.tx-storage.ts +++ b/src/chains/ethereum/evm.tx-storage.ts @@ -1,5 +1,5 @@ -import { LocalStorage } from '../services/local-storage'; -import { ReferenceCountingCloseable } from '../services/refcounting-closeable'; +import { LocalStorage } from '../../services/local-storage'; +import { ReferenceCountingCloseable } from '../../services/refcounting-closeable'; // store the timestamp for when a transaction was initiated // this will be used to calculate a heuristic of the likelihood diff --git a/src/chains/harmony/harmony.ts b/src/chains/harmony/harmony.ts index cdcdcec097..fb994ca795 100644 --- a/src/chains/harmony/harmony.ts +++ b/src/chains/harmony/harmony.ts @@ -9,6 +9,7 @@ import { Ethereumish } from '../../services/common-interfaces'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; import { OpenoceanConfig } from '../../connectors/openocean/openocean.config'; import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config'; +import { EVMController } from '../ethereum/evm.controllers'; export class Harmony extends EthereumBase implements Ethereumish { private static _instances: { [name: string]: Harmony }; @@ -19,6 +20,7 @@ export class Harmony extends EthereumBase implements Ethereumish { private _requestCount: number; private _metricsLogInterval: number; private _metricTimer; + public controller; private constructor(network: string) { const config = getHarmonyConfig('harmony', network); @@ -48,6 +50,7 @@ export class Harmony extends EthereumBase implements Ethereumish { this.metricLogger.bind(this), this.metricsLogInterval ); + this.controller = EVMController; } public static getInstance(network: string): Harmony { diff --git a/src/chains/injective/injective.controllers.ts b/src/chains/injective/injective.controllers.ts index c7b6eb0d17..158f6fa21c 100644 --- a/src/chains/injective/injective.controllers.ts +++ b/src/chains/injective/injective.controllers.ts @@ -4,45 +4,51 @@ import { BalancesResponse, PollRequest, PollResponse, - TransferToSubAccountRequest, - TransferToSubAccountResponse, - TransferToBankAccountRequest, - TransferToBankAccountResponse, + TransferRequest, + TransferResponse, } from './injective.requests'; +import { + validateBalanceRequest, + validatePollRequest, + validateTransferRequest, +} from './injective.validators'; -export async function currentBlockNumber( - injective: Injective -): Promise { - return injective.currentBlockNumber(); -} +export class InjectiveController { + static async currentBlockNumber(injective: Injective): Promise { + return injective.currentBlockNumber(); + } -export async function transferToSubAccount( - injective: Injective, - req: TransferToSubAccountRequest -): Promise { - const wallet = await injective.getWallet(req.address); - return injective.transferToSubAccount(wallet, req.amount, req.token); -} + static async transfer( + injective: Injective, + req: TransferRequest + ): Promise { + validateTransferRequest(req); -export async function transferToBankAccount( - injective: Injective, - req: TransferToBankAccountRequest -): Promise { - const wallet = await injective.getWallet(req.address); - return injective.transferToBankAccount(wallet, req.amount, req.token); -} + if (req.from.length > req.to.length) { + const wallet = await injective.getWallet(req.from); + return injective.transferToBankAccount(wallet, req.amount, req.token); + } else { + const wallet = await injective.getWallet(req.to); + return injective.transferToSubAccount(wallet, req.amount, req.token); + } + } -export async function balances( - injective: Injective, - req: BalancesRequest -): Promise { - const wallet = await injective.getWallet(req.address); - return injective.balances(wallet); -} + static async balances( + injective: Injective, + req: BalancesRequest + ): Promise { + validateBalanceRequest(req); + + const wallet = await injective.getWallet(req.address); + return injective.balances(wallet); + } + + static async poll( + injective: Injective, + req: PollRequest + ): Promise { + validatePollRequest(req); -export async function poll( - injective: Injective, - req: PollRequest -): Promise { - return injective.poll(req.txHash); + return injective.poll(req.txHash); + } } diff --git a/src/chains/injective/injective.requests.ts b/src/chains/injective/injective.requests.ts index 957cf7b722..f0bd0be1b2 100644 --- a/src/chains/injective/injective.requests.ts +++ b/src/chains/injective/injective.requests.ts @@ -39,14 +39,11 @@ export type BalancesResponse = { subaccounts: Array; }; -export interface TransferToSubAccountRequest extends NetworkSelectionRequest { - address: string; +export interface TransferRequest extends NetworkSelectionRequest { + to: string; + from: string; amount: string; token: string; } -export type TransferToSubAccountResponse = string; - -export type TransferToBankAccountRequest = TransferToSubAccountRequest; - -export type TransferToBankAccountResponse = TransferToSubAccountResponse; +export type TransferResponse = string; diff --git a/src/chains/injective/injective.routes.ts b/src/chains/injective/injective.routes.ts deleted file mode 100644 index 0894b03957..0000000000 --- a/src/chains/injective/injective.routes.ts +++ /dev/null @@ -1,122 +0,0 @@ -/* eslint-disable no-inner-declarations */ -/* eslint-disable @typescript-eslint/ban-types */ -import { Router, Request, Response } from 'express'; -import { asyncHandler } from '../../services/error-handler'; -import { - balances, - currentBlockNumber, - poll, - transferToBankAccount, - transferToSubAccount, -} from './injective.controllers'; -import { Injective } from './injective'; -import { - BalancesRequest, - BalancesResponse, - PollRequest, - PollResponse, - TransferToBankAccountRequest, - TransferToBankAccountResponse, - TransferToSubAccountRequest, - TransferToSubAccountResponse, -} from './injective.requests'; -import { - validatePollRequest, - validateBalanceRequest, - validateTransferToBankAccountRequest, - validateTransferToSubAccountRequest, -} from './injective.validators'; -import { getInitializedChain } from '../../services/connection-manager'; -import { NetworkSelectionRequest } from '../../services/common-interfaces'; - -export namespace InjectiveRoutes { - export const router = Router(); - - router.get( - '/block/current', - asyncHandler( - async ( - req: Request<{}, {}, NetworkSelectionRequest>, - res: Response - ) => { - const injective = await getInitializedChain( - req.query.chain, - req.query.network - ); - res.status(200).json(await currentBlockNumber(injective)); - } - ) - ); - - router.post( - '/transfer/to/bank', - asyncHandler( - async ( - req: Request<{}, {}, TransferToBankAccountRequest>, - res: Response - ) => { - validateTransferToBankAccountRequest(req.body); - const injective = await getInitializedChain( - req.body.chain, - req.body.network - ); - res - .status(200) - .json(await transferToBankAccount(injective, req.body)); - } - ) - ); - - router.post( - '/transfer/to/sub', - asyncHandler( - async ( - req: Request<{}, {}, TransferToSubAccountRequest>, - res: Response - ) => { - validateTransferToSubAccountRequest(req.body); - const injective = await getInitializedChain( - req.body.chain, - req.body.network - ); - res - .status(200) - .json(await transferToSubAccount(injective, req.body)); - } - ) - ); - - router.post( - '/balances', - asyncHandler( - async ( - req: Request<{}, {}, BalancesRequest>, - res: Response - ) => { - validateBalanceRequest(req.body); - const injective = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await balances(injective, req.body)); - } - ) - ); - - router.post( - '/poll', - asyncHandler( - async ( - req: Request<{}, {}, PollRequest>, - res: Response - ) => { - validatePollRequest(req.body); - const injective = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await poll(injective, req.body)); - } - ) - ); -} diff --git a/src/chains/injective/injective.ts b/src/chains/injective/injective.ts index 4ad21ac06e..a7e48fc1b6 100644 --- a/src/chains/injective/injective.ts +++ b/src/chains/injective/injective.ts @@ -51,8 +51,9 @@ import { import { MsgBroadcasterLocal } from './injective.message'; import LRUCache from 'lru-cache'; import { TokenInfo } from '../../services/base'; -import { EVMNonceManager } from '../../evm/evm.nonce'; +import { EVMNonceManager } from '../ethereum/evm.nonce'; import { AccountDetails } from '@injectivelabs/sdk-ts/dist/cjs/types/auth'; +import { InjectiveController } from './injective.controllers'; export interface InjectiveWallet { ethereumAddress: string; @@ -88,6 +89,7 @@ export class Injective { public maxCacheSize: number; private _blockUpdateIntervalID: number | undefined; private _walletMap: LRUCache; + public controller: typeof InjectiveController; private constructor(network: Network, chainId: ChainId) { this._network = network; @@ -120,6 +122,7 @@ export class Injective { this._walletMap = new LRUCache({ max: this.maxCacheSize, }); + this.controller = InjectiveController; } public static getInstance(networkStr: string): Injective { diff --git a/src/chains/injective/injective.validators.ts b/src/chains/injective/injective.validators.ts index 4163228835..be6139aaba 100644 --- a/src/chains/injective/injective.validators.ts +++ b/src/chains/injective/injective.validators.ts @@ -28,6 +28,18 @@ export const validateAddress: Validator = mkValidator( (val) => typeof val === 'string' ); +export const validateFrom: Validator = mkValidator( + 'from', + invalidAddressError, + (val) => typeof val === 'string' +); + +export const validateTo: Validator = mkValidator( + 'to', + invalidAddressError, + (val) => typeof val === 'string' +); + export const validateBalanceRequest: RequestValidator = mkRequestValidator([ validateNetwork, validateAddress, @@ -50,12 +62,10 @@ export const validateToken: Validator = mkValidator( (val) => typeof val === 'string' ); -export const validateTransferToSubAccountRequest = mkRequestValidator([ +export const validateTransferRequest = mkRequestValidator([ validateNetwork, - validateAddress, + validateFrom, + validateTo, validateAmount, validateToken, ]); - -export const validateTransferToBankAccountRequest = - validateTransferToSubAccountRequest; diff --git a/src/chains/near/near.base.ts b/src/chains/near/near.base.ts index fa60eeb782..763c569e31 100644 --- a/src/chains/near/near.base.ts +++ b/src/chains/near/near.base.ts @@ -12,7 +12,7 @@ import axios from 'axios'; import { promises as fs } from 'fs'; import { TokenListType, TokenValue, walletPath } from '../../services/base'; import NodeCache from 'node-cache'; -import { EvmTxStorage } from '../../evm/evm.tx-storage'; +import { EvmTxStorage } from '../ethereum/evm.tx-storage'; import fse from 'fs-extra'; import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase'; import { logger } from '../../services/logger'; diff --git a/src/chains/near/near.controllers.ts b/src/chains/near/near.controllers.ts index 7244a4ee25..07ca4b8b3d 100644 --- a/src/chains/near/near.controllers.ts +++ b/src/chains/near/near.controllers.ts @@ -1,6 +1,5 @@ import { Account, providers, utils } from 'near-api-js'; import { BigNumber, utils as ethersUtils } from 'ethers'; -import { latency } from '../../services/base'; import { HttpException, OUT_OF_GAS_ERROR_CODE, @@ -12,158 +11,138 @@ import { } from '../../services/error-handler'; import { TokenInfo } from './near.base'; -import { - CancelRequest, - CancelResponse, - PollResponse, - BalanceRequest, - BalanceResponse, -} from './near.requests'; +import { CancelRequest, BalanceRequest, PollRequest } from './near.requests'; import { logger } from '../../services/logger'; import { Nearish } from '../../services/common-interfaces'; -export const getTokenSymbolsToTokens = ( - near: Nearish, - tokenSymbols: Array -): Record => { - const tokens: Record = {}; - - for (let i = 0; i < tokenSymbols.length; i++) { - const symbol = tokenSymbols[i]; - const token = near.getTokenBySymbol(symbol); - if (token) tokens[symbol] = token; - } +export class NearController { + static getTokenSymbolsToTokens = ( + near: Nearish, + tokenSymbols: Array + ): Record => { + const tokens: Record = {}; - return tokens; -}; + for (let i = 0; i < tokenSymbols.length; i++) { + const symbol = tokenSymbols[i]; + const token = near.getTokenBySymbol(symbol); + if (token) tokens[symbol] = token; + } -export async function balances( - nearish: Nearish, - req: BalanceRequest -): Promise { - const initTime = Date.now(); - - let account: Account; - try { - account = await nearish.getWallet(req.address); - } catch (err) { - throw new HttpException( - 500, - LOAD_WALLET_ERROR_MESSAGE + err, - LOAD_WALLET_ERROR_CODE - ); - } - const tokens = getTokenSymbolsToTokens(nearish, req.tokenSymbols); - const balances: Record = {}; - if (req.tokenSymbols.includes(nearish.nativeTokenSymbol)) { - balances[nearish.nativeTokenSymbol] = utils.format.formatNearAmount( - await nearish.getNativeBalance(account) + return tokens; + }; + static async balances(nearish: Nearish, req: BalanceRequest) { + let account: Account; + try { + account = await nearish.getWallet(req.address); + } catch (err) { + throw new HttpException( + 500, + LOAD_WALLET_ERROR_MESSAGE + err, + LOAD_WALLET_ERROR_CODE + ); + } + const tokens = NearController.getTokenSymbolsToTokens( + nearish, + req.tokenSymbols ); - } - await Promise.all( - Object.keys(tokens).map(async (symbol) => { - if ( - tokens[symbol] !== undefined && - symbol !== nearish.nativeTokenSymbol - ) { - const address = tokens[symbol].address; - const decimals = tokens[symbol].decimals; - // instantiate a contract and pass in provider for read-only access - const contract = nearish.getContract(address, account); - const balance: string = await nearish.getFungibleTokenBalance(contract); - balances[symbol] = ethersUtils - .formatUnits(BigNumber.from(balance), decimals) - .toString(); - } - }) - ); - - if (!Object.keys(balances).length) { - throw new HttpException( - 500, - TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, - TOKEN_NOT_SUPPORTED_ERROR_CODE + const balances: Record = {}; + if (req.tokenSymbols.includes(nearish.nativeTokenSymbol)) { + balances[nearish.nativeTokenSymbol] = utils.format.formatNearAmount( + await nearish.getNativeBalance(account) + ); + } + await Promise.all( + Object.keys(tokens).map(async (symbol) => { + if ( + tokens[symbol] !== undefined && + symbol !== nearish.nativeTokenSymbol + ) { + const address = tokens[symbol].address; + const decimals = tokens[symbol].decimals; + // instantiate a contract and pass in provider for read-only access + const contract = nearish.getContract(address, account); + const balance: string = await nearish.getFungibleTokenBalance( + contract + ); + balances[symbol] = ethersUtils + .formatUnits(BigNumber.from(balance), decimals) + .toString(); + } + }) ); - } - return { - network: nearish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - balances: balances, - }; -} + if (!Object.keys(balances).length) { + throw new HttpException( + 500, + TOKEN_NOT_SUPPORTED_ERROR_MESSAGE, + TOKEN_NOT_SUPPORTED_ERROR_CODE + ); + } -// txStatus -// -1: not in the mempool or failed -// 1: succeeded -export async function poll( - nearish: Nearish, - address: string, - txHash: string -): Promise { - const initTime = Date.now(); - const currentBlock = await nearish.getCurrentBlockNumber(); - const txReceipt: providers.FinalExecutionOutcome = - await nearish.getTransaction(txHash, address); - let txStatus = -1; - if ( - typeof txReceipt.status === 'object' && - 'SuccessValue' in txReceipt.status - ) { - txStatus = 1; + return { + balances: balances, + }; } - if ( - txReceipt.transaction_outcome.outcome.gas_burnt / - nearish.gasLimitTransaction > - 0.9 - ) { - throw new HttpException( - 503, - OUT_OF_GAS_ERROR_MESSAGE, - OUT_OF_GAS_ERROR_CODE - ); - } + // txStatus + // -1: not in the mempool or failed + // 1: succeeded + static async poll(nearish: Nearish, body: PollRequest) { + const currentBlock = await nearish.getCurrentBlockNumber(); + const txReceipt: providers.FinalExecutionOutcome = + await nearish.getTransaction(body.txHash, body.address); + let txStatus = -1; + if ( + typeof txReceipt.status === 'object' && + 'SuccessValue' in txReceipt.status + ) { + txStatus = 1; + } - logger.info(`Poll ${nearish.chain}, txHash ${txHash}, status ${txStatus}.`); - return { - network: nearish.chain, - currentBlock, - timestamp: initTime, - txHash: txHash, - txStatus, - txReceipt, - }; -} + if ( + txReceipt.transaction_outcome.outcome.gas_burnt / + nearish.gasLimitTransaction > + 0.9 + ) { + throw new HttpException( + 503, + OUT_OF_GAS_ERROR_MESSAGE, + OUT_OF_GAS_ERROR_CODE + ); + } -export async function cancel( - nearish: Nearish, - req: CancelRequest -): Promise { - const initTime = Date.now(); - let account: Account; - try { - account = await nearish.getWallet(req.address); - } catch (err) { - throw new HttpException( - 500, - LOAD_WALLET_ERROR_MESSAGE + err, - LOAD_WALLET_ERROR_CODE + logger.info( + `Poll ${nearish.chain}, txHash ${body.txHash}, status ${txStatus}.` ); + return { + currentBlock, + txHash: body.txHash, + txStatus, + txReceipt, + }; } - // call cancelTx function - const cancelTx = await nearish.cancelTx(account, req.nonce); + static async cancel(nearish: Nearish, req: CancelRequest) { + let account: Account; + try { + account = await nearish.getWallet(req.address); + } catch (err) { + throw new HttpException( + 500, + LOAD_WALLET_ERROR_MESSAGE + err, + LOAD_WALLET_ERROR_CODE + ); + } - logger.info( - `Cancelled transaction at nonce ${req.nonce}, cancel txHash ${cancelTx}.` - ); + // call cancelTx function + const cancelTx = await nearish.cancelTx(account, req.nonce); - return { - network: nearish.chain, - timestamp: initTime, - latency: latency(initTime, Date.now()), - txHash: cancelTx, - }; + logger.info( + `Cancelled transaction at nonce ${req.nonce}, cancel txHash ${cancelTx}.` + ); + + return { + txHash: cancelTx, + }; + } } diff --git a/src/chains/near/near.routes.ts b/src/chains/near/near.routes.ts deleted file mode 100644 index 28e345cef5..0000000000 --- a/src/chains/near/near.routes.ts +++ /dev/null @@ -1,87 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ -import { Router, Request, Response, NextFunction } from 'express'; -import { Nearish } from '../../services/common-interfaces'; -import { asyncHandler } from '../../services/error-handler'; - -import { getInitializedChain } from '../../services/connection-manager'; -import { BalanceResponse, PollRequest, PollResponse } from './near.requests'; -import { validateBalanceRequest } from './near.validators'; -import * as nearControllers from './near.controllers'; -import { getTokens } from '../../network/network.controllers'; -import { - validatePollRequest, - validateTokensRequest, -} from '../../network/network.routes'; -import { - BalanceRequest, - TokensRequest, - TokensResponse, -} from '../../network/network.requests'; - -export namespace NearRoutes { - export const router = Router(); - - router.post( - '/balances', - asyncHandler( - async ( - req: Request<{}, {}, BalanceRequest>, - res: Response, - _next: NextFunction - ) => { - validateBalanceRequest(req.body); - - const chain = await getInitializedChain( - 'near', - req.body.network - ); - - res - .status(200) - .json( - (await nearControllers.balances(chain, req.body)) as BalanceResponse - ); - } - ) - ); - - router.post( - '/poll', - asyncHandler( - async ( - req: Request<{}, {}, PollRequest>, - res: Response - ) => { - validatePollRequest(req.body); - - const chain = await getInitializedChain( - 'near', - req.body.network - ); - - res - .status(200) - .json( - await nearControllers.poll( - chain, - req.body.address, - req.body.txHash - ) - ); - } - ) - ); - - router.get( - '/tokens', - asyncHandler( - async ( - req: Request<{}, {}, {}, TokensRequest>, - res: Response - ) => { - validateTokensRequest(req.query); - res.status(200).json(await getTokens(req.query)); - } - ) - ); -} diff --git a/src/chains/near/near.ts b/src/chains/near/near.ts index da6bc37fad..6d44e6f72b 100644 --- a/src/chains/near/near.ts +++ b/src/chains/near/near.ts @@ -5,6 +5,7 @@ import { ConfigManagerV2 } from '../../services/config-manager-v2'; import { NearBase } from './near.base'; import { ContractMethods } from 'near-api-js/lib/contract'; import { getNearConfig } from './near.config'; +import { NearController } from './near.controllers'; export class Near extends NearBase { private static _instances: { [name: string]: Near }; @@ -12,6 +13,7 @@ export class Near extends NearBase { private _gasPriceRefreshInterval: number | null; private _nativeTokenSymbol: string; private _chain: string; + public controller; private constructor(network: string) { const config = getNearConfig('near', network); @@ -34,6 +36,7 @@ export class Near extends NearBase { : null; this.updateGasPrice(); + this.controller = NearController; } public static getInstance(network: string): Near { diff --git a/src/chains/polygon/polygon.ts b/src/chains/polygon/polygon.ts index bf97a824eb..39cb2a758c 100644 --- a/src/chains/polygon/polygon.ts +++ b/src/chains/polygon/polygon.ts @@ -10,12 +10,14 @@ import { UniswapConfig } from '../../connectors/uniswap/uniswap.config'; import { Ethereumish } from '../../services/common-interfaces'; import { ConfigManagerV2 } from '../../services/config-manager-v2'; import { OpenoceanConfig } from '../../connectors/openocean/openocean.config'; +import { EVMController } from '../ethereum/evm.controllers'; export class Polygon extends EthereumBase implements Ethereumish { private static _instances: { [name: string]: Polygon }; private _gasPrice: number; private _nativeTokenSymbol: string; private _chain: string; + public controller; private constructor(network: string) { const config = getPolygonConfig('polygon', network); @@ -33,6 +35,7 @@ export class Polygon extends EthereumBase implements Ethereumish { this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; this._gasPrice = config.manualGasPrice; + this.controller = EVMController; } public static getInstance(network: string): Polygon { diff --git a/src/chains/xdc/xdc.base.ts b/src/chains/xdc/xdc.base.ts index 8b65a31ac6..bd718d81f0 100644 --- a/src/chains/xdc/xdc.base.ts +++ b/src/chains/xdc/xdc.base.ts @@ -11,9 +11,9 @@ import { promises as fs } from 'fs'; import path from 'path'; import { rootPath } from '../../paths'; import { TokenListType, TokenValue, walletPath } from '../../services/base'; -import { EVMNonceManager } from '../../evm/evm.nonce'; +import { EVMNonceManager } from '../ethereum/evm.nonce'; import NodeCache from 'node-cache'; -import { EvmTxStorage } from '../../evm/evm.tx-storage'; +import { EvmTxStorage } from '../ethereum/evm.tx-storage'; import fse from 'fs-extra'; import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase'; import { logger } from '../../services/logger'; diff --git a/src/chains/xdc/xdc.controllers.ts b/src/chains/xdc/xdc.controllers.ts new file mode 100644 index 0000000000..6c7ce52100 --- /dev/null +++ b/src/chains/xdc/xdc.controllers.ts @@ -0,0 +1,19 @@ +import { Chain as Ethereumish } from '../../services/common-interfaces'; +import { AllowancesRequest, ApproveRequest } from '../chain.requests'; +import { EVMController } from '../ethereum/evm.controllers'; +import { + validateXdcAllowancesRequest, + validateXdcApproveRequest, +} from './xdc.validators'; + +export class XDCCOntroller extends EVMController { + static async allowances(ethereumish: Ethereumish, req: AllowancesRequest) { + validateXdcAllowancesRequest(req); + return EVMController.allowancesWithoutValidation(ethereumish, req); + } + + static async approve(ethereumish: Ethereumish, req: ApproveRequest) { + validateXdcApproveRequest(req); + return await EVMController.approveWithoutValidation(ethereumish, req); + } +} diff --git a/src/evm/evm.routes.ts b/src/evm/evm.routes.ts deleted file mode 100644 index d064a0c0ac..0000000000 --- a/src/evm/evm.routes.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* eslint-disable no-inner-declarations */ -/* eslint-disable @typescript-eslint/ban-types */ -import { Router, Request, Response } from 'express'; -import { Ethereumish } from '../services/common-interfaces'; -import { asyncHandler } from '../services/error-handler'; -import { - approve, - allowances, - nonce, - nextNonce, - cancel, -} from '../chains/ethereum/ethereum.controllers'; - -import { - validateAllowancesRequest, - validateApproveRequest, - validateCancelRequest, - validateNonceRequest, -} from '../chains/ethereum/ethereum.validators'; -import { - validateXdcApproveRequest, - validateXdcAllowancesRequest, -} from '../chains/xdc/xdc.validators'; - -import { getInitializedChain } from '../services/connection-manager'; -import { - AllowancesRequest, - AllowancesResponse, - ApproveRequest, - ApproveResponse, - CancelRequest, - CancelResponse, - NonceRequest, - NonceResponse, -} from './evm.requests'; - -export namespace EVMRoutes { - export const router = Router(); - - router.post( - '/nextNonce', - asyncHandler( - async ( - req: Request<{}, {}, NonceRequest>, - res: Response - ) => { - validateNonceRequest(req.body); - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await nextNonce(chain, req.body)); - } - ) - ); - - router.post( - '/nonce', - asyncHandler( - async ( - req: Request<{}, {}, NonceRequest>, - res: Response - ) => { - validateNonceRequest(req.body); - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await nonce(chain, req.body)); - } - ) - ); - - router.post( - '/allowances', - asyncHandler( - async ( - req: Request<{}, {}, AllowancesRequest>, - res: Response - ) => { - if (req.body.chain === 'xdc') { - validateXdcAllowancesRequest(req.body); - } else { - validateAllowancesRequest(req.body); - } - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await allowances(chain, req.body)); - } - ) - ); - - router.post( - '/approve', - asyncHandler( - async ( - req: Request<{}, {}, ApproveRequest>, - res: Response - ) => { - if (req.body.chain === 'xdc') { - validateXdcApproveRequest(req.body); - } else { - validateApproveRequest(req.body); - } - - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await approve(chain, req.body)); - } - ) - ); - - router.post( - '/cancel', - asyncHandler( - async ( - req: Request<{}, {}, CancelRequest>, - res: Response - ) => { - validateCancelRequest(req.body); - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - res.status(200).json(await cancel(chain, req.body)); - } - ) - ); -} diff --git a/src/network/network.controllers.ts b/src/network/network.controllers.ts index 9a5a7af320..8e17b35b8d 100644 --- a/src/network/network.controllers.ts +++ b/src/network/network.controllers.ts @@ -1,9 +1,4 @@ -import { - StatusRequest, - StatusResponse, - TokensRequest, - TokensResponse, -} from './network.requests'; +import { StatusRequest, StatusResponse } from './network.requests'; import { Avalanche } from '../chains/avalanche/avalanche'; import { BinanceSmartChain } from '../chains/binance-smart-chain/binance-smart-chain'; import { Ethereum } from '../chains/ethereum/ethereum'; @@ -16,10 +11,8 @@ import { UNKNOWN_CHAIN_ERROR_CODE, UNKNOWN_KNOWN_CHAIN_ERROR_MESSAGE, } from '../services/error-handler'; -import { EthereumBase, TokenInfo } from '../chains/ethereum/ethereum-base'; import { Cronos } from '../chains/cronos/cronos'; import { Near } from '../chains/near/near'; -import { Nearish, Xdcish } from '../services/common-interfaces'; import { Algorand } from '../chains/algorand/algorand'; import { getInitializedChain, @@ -127,43 +120,3 @@ export async function getStatus( return req.chain ? statuses[0] : statuses; } - -export async function getTokens(req: TokensRequest): Promise { - type connectionType = EthereumBase | Nearish | Injective | Xdcish; - let connection: connectionType; - let tokens: TokenInfo[] = []; - - if (req.chain && req.network) { - try { - connection = (await getInitializedChain( - req.chain as string, - req.network as string - )) as connectionType; - } catch (e) { - if (e instanceof UnsupportedChainException) { - throw new HttpException( - 500, - UNKNOWN_KNOWN_CHAIN_ERROR_MESSAGE(req.chain), - UNKNOWN_CHAIN_ERROR_CODE - ); - } - throw e; - } - } else { - throw new HttpException( - 500, - UNKNOWN_KNOWN_CHAIN_ERROR_MESSAGE(req.chain), - UNKNOWN_CHAIN_ERROR_CODE - ); - } - - if (!req.tokenSymbols) { - tokens = connection.storedTokenList; - } else { - for (const t of req.tokenSymbols as []) { - tokens.push(connection.getTokenForSymbol(t) as TokenInfo); - } - } - - return { tokens }; -} diff --git a/src/network/network.routes.ts b/src/network/network.routes.ts deleted file mode 100644 index 8abefae8d7..0000000000 --- a/src/network/network.routes.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ -import { NextFunction, Request, Response, Router } from 'express'; -import * as ethereumControllers from '../chains/ethereum/ethereum.controllers'; -import { Ethereumish } from '../services/common-interfaces'; -import { ConfigManagerV2 } from '../services/config-manager-v2'; -import { getInitializedChain } from '../services/connection-manager'; -import { asyncHandler } from '../services/error-handler'; -import { - mkRequestValidator, - RequestValidator, - validateTxHash, -} from '../services/validators'; -import { getStatus, getTokens } from './network.controllers'; -import { - BalanceRequest, - BalanceResponse, - PollRequest, - PollResponse, - StatusRequest, - StatusResponse, - TokensRequest, - TokensResponse, -} from './network.requests'; -import { - validateBalanceRequest as validateEthereumBalanceRequest, - validateChain as validateEthereumChain, - validateNetwork as validateEthereumNetwork, -} from '../chains/ethereum/ethereum.validators'; - -export const validatePollRequest: RequestValidator = mkRequestValidator([ - validateTxHash, -]); - -export const validateTokensRequest: RequestValidator = mkRequestValidator([ - validateEthereumChain, - validateEthereumNetwork, -]); - -export namespace NetworkRoutes { - export const router = Router(); - - router.get( - '/status', - asyncHandler( - async ( - req: Request<{}, {}, {}, StatusRequest>, - res: Response - ) => { - res.status(200).json(await getStatus(req.query)); - } - ) - ); - - router.get('/config', (_req: Request, res: Response) => { - res.status(200).json(ConfigManagerV2.getInstance().allConfigurations); - }); - - router.post( - '/balances', - asyncHandler( - async ( - req: Request<{}, {}, BalanceRequest>, - res: Response, - _next: NextFunction - ) => { - validateEthereumBalanceRequest(req.body); - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - - res - .status(200) - .json(await ethereumControllers.balances(chain, req.body)); - } - ) - ); - - router.post( - '/poll', - asyncHandler( - async ( - req: Request<{}, {}, PollRequest>, - res: Response - ) => { - validatePollRequest(req.body); - - const chain = await getInitializedChain( - req.body.chain, - req.body.network - ); - - res.status(200).json(await ethereumControllers.poll(chain, req.body)); - } - ) - ); - - router.get( - '/tokens', - asyncHandler( - async ( - req: Request<{}, {}, {}, TokensRequest>, - res: Response - ) => { - validateTokensRequest(req.query); - res.status(200).json(await getTokens(req.query)); - } - ) - ); -} diff --git a/src/services/base.ts b/src/services/base.ts index 772039c5db..7d152a7b50 100644 --- a/src/services/base.ts +++ b/src/services/base.ts @@ -71,8 +71,10 @@ export interface TokenValue { } // we should turn Token into a string when we return as a value in an API call -export const tokenValueToString = (t: TokenValue): string => { - return bigNumberWithDecimalToStr(t.value, t.decimals); +export const tokenValueToString = (t: TokenValue | string): string => { + return typeof t === 'string' + ? t + : bigNumberWithDecimalToStr(t.value, t.decimals); }; // safely parse a JSON from a string to a type. diff --git a/src/services/common-interfaces.ts b/src/services/common-interfaces.ts index d9ff980963..7418ae03d4 100644 --- a/src/services/common-interfaces.ts +++ b/src/services/common-interfaces.ts @@ -674,7 +674,8 @@ export interface BasicChainMethods { chain: string; } -export interface Ethereumish extends BasicChainMethods, EthereumBase { +export interface Chain extends BasicChainMethods, EthereumBase { + controller: any; cancelTx(wallet: Wallet, nonce: number): Promise; getContract( tokenAddress: string, @@ -682,6 +683,8 @@ export interface Ethereumish extends BasicChainMethods, EthereumBase { ): Contract; } +export type Ethereumish = Chain; + export interface Xdcish extends BasicChainMethods, XdcBase { cancelTx(wallet: XdcWallet, nonce: number): Promise; getContract( diff --git a/test-helpers/curl/curl.sh b/test-helpers/curl/curl.sh index bbaffbf6ec..1941928397 100644 --- a/test-helpers/curl/curl.sh +++ b/test-helpers/curl/curl.sh @@ -22,37 +22,37 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app # Network -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:15888/network/status | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:15888/chain/status | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=ethereum&network=goerli" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=ethereum&network=goerli" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=avalanche&network=avalanche" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=avalanche&network=avalanche" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=harmony&network=harmony" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=harmony&network=harmony" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=cronos&network=mainnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=cronos&network=mainnet" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=algorand&network=mainnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=algorand&network=mainnet" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:15888/network/config | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:15888/chain/config | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/network_poll.json)" https://localhost:15888/network/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/network_poll.json)" https://localhost:15888/chain/poll | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=ethereum&network=goerli" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=ethereum&network=goerli" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=polygon&network=mainnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=polygon&network=mainnet" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=polygon&network=mumbai" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=polygon&network=mumbai" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=cronos&network=mainnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=cronos&network=mainnet" | jq -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=xdc&network=xinfin" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=xdc&network=xinfin" | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/network_balances.json)" https://localhost:15888/network/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/network_balances.json)" https://localhost:15888/chain/balances | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_balances.json)" https://localhost:15888/network/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_balances.json)" https://localhost:15888/chain/balances | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_balances.json)" https://localhost:15888/network/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_balances.json)" https://localhost:15888/chain/balances | jq # Wallet @@ -213,61 +213,61 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app # EVM ## nonce -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_nonce.json)" https://localhost:15888/evm/nonce | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_nonce.json)" https://localhost:15888/chain/nonce | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/avalanche_nonce.json)" https://localhost:15888/evm/nonce | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/avalanche_nonce.json)" https://localhost:15888/chain/nonce | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_nonce.json)" https://localhost:15888/evm/nonce | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_nonce.json)" https://localhost:15888/chain/nonce | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_nonce.json)" https://localhost:15888/evm/nonce | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_nonce.json)" https://localhost:15888/chain/nonce | jq ## allowances -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_allowances.json)" https://localhost:15888/evm/allowances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_allowances.json)" https://localhost:15888/chain/allowances | jq ## approve -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_approve.json)" https://localhost:15888/chain/approve | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_perp_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_perp_approve.json)" https://localhost:15888/chain/approve | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/avalanche_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/avalanche_approve.json)" https://localhost:15888/chain/approve | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/cronos_approve.json)" https://localhost:15888/chain/approve | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/bsc_approve.json)" https://localhost:15888/chain/approve | jq -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_approve.json)" https://localhost:15888/chain/approve | jq # Algorand ## post poll -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_poll.json)" https://localhost:15888/algorand/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_poll.json)" https://localhost:15888/chain/poll | jq ## get balances -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_balances.json)" https://localhost:15888/algorand/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_balances.json)" https://localhost:15888/chain/balances | jq ## get assets -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/algorand/assets?network=mainnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?network=mainnet&chain=algorand" | jq ## post opt-in -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_opt_in.json)" https://localhost:15888/algorand/opt-in | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/algorand_opt_in.json)" https://localhost:15888/chain/approve | jq # NEAR ## get balances -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/near_network_balances.json)" https://localhost:15888/near/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/near_network_balances.json)" https://localhost:15888/chain/balances | jq ## get token -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/near/tokens?chain=near&network=testnet" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/tokens?chain=near&network=testnet" | jq ## post poll -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/near_post_poll.json)" https://localhost:15888/near/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/near_post_poll.json)" https://localhost:15888/chain/poll | jq # XDC and XSSWAP ## check for network status, let's us know that gateway knows about xdc -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=xdc&network=apothem" | jq +curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/chain/status?chain=xdc&network=apothem" | jq ## add xdc private key curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/add_xdc_key.json)" https://localhost:15888/wallet/add | jq @@ -279,7 +279,7 @@ curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:1588 curl -s -X DELETE -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/remove_xdc_key.json)" https://localhost:15888/wallet/remove | jq ## test transaction polling -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_poll.json)" https://localhost:15888/network/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_poll.json)" https://localhost:15888/chain/poll | jq ## get xdc swap price curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/price_xdc_xsswap.json)" https://localhost:15888/amm/price | jq @@ -291,10 +291,10 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_xsswap_sell.json)" https://localhost:15888/amm/trade | jq ## allowances check -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_xsswap_allowances.json)" https://localhost:15888/evm/allowances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_xsswap_allowances.json)" https://localhost:15888/chain/allowances | jq ## approve -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_approve.json)" https://localhost:15888/evm/approve | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/xdc_approve.json)" https://localhost:15888/chain/approve | jq # CLOB @@ -368,19 +368,15 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/clob/perp/lastTradePrice?chain=injective&network=mainnet&connector=injective_perpetual&market=INJ-USDT" | jq ### get balances -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_balances.json)" https://localhost:15888/injective/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_balances.json)" https://localhost:15888/chain/balances | jq -### get block number -curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT 'https://localhost:15888/injective/block/current?chain=injective&network=mainnet' | jq - -### get transaction status -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_poll.json)" https://localhost:15888/injective/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_poll.json)" https://localhost:15888/chain/poll | jq ### transfer to bank -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_transfer_to_bank.json)" https://localhost:15888/injective/transfer/to/bank | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_transfer_to_bank.json)" https://localhost:15888/chain/transfer | jq ### transfer from bank -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_transfer_to_sub.json)" https://localhost:15888/injective/transfer/to/sub | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/injective_transfer_to_sub.json)" https://localhost:15888/chain/transfer | jq ## dexalot ### get markets @@ -408,7 +404,7 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/dexalot_batch_delete.json)" https://localhost:15888/clob/batchOrders | jq ### get balances -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/dexalot_balances.json)" https://localhost:15888/network/balances | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/dexalot_balances.json)" https://localhost:15888/chain/balances | jq ### get transaction status -curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/dexalot_poll.json)" https://localhost:15888/network/poll | jq +curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/dexalot_poll.json)" https://localhost:15888/chain/poll | jq diff --git a/test-helpers/curl/requests/add_polygon_key.json.json b/test-helpers/curl/requests/add_polygon_key.json similarity index 100% rename from test-helpers/curl/requests/add_polygon_key.json.json rename to test-helpers/curl/requests/add_polygon_key.json diff --git a/test-helpers/curl/requests/eth_allowances.json b/test-helpers/curl/requests/eth_allowances.json index e6a2118c53..d693d95889 100644 --- a/test-helpers/curl/requests/eth_allowances.json +++ b/test-helpers/curl/requests/eth_allowances.json @@ -1,7 +1,7 @@ { "chain": "ethereum", - "network": "goerli", - "address": "$ETH_ADDRESS", + "network": "mainnet", + "address": "0x010216bB52E46807a07d0101Bb828bA547534F37", "spender": "uniswap", "tokenSymbols": ["DAI", "WETH"] } diff --git a/test-helpers/curl/requests/eth_nonce.json b/test-helpers/curl/requests/eth_nonce.json index a50dd6c245..81c81c6d9d 100644 --- a/test-helpers/curl/requests/eth_nonce.json +++ b/test-helpers/curl/requests/eth_nonce.json @@ -1,5 +1,5 @@ { "chain": "ethereum", - "network": "goerli", - "address": "$ETH_ADDRESS" + "network": "mainnet", + "address": "0x010216bB52E46807a07d0101Bb828bA547534F37" } diff --git a/test-helpers/curl/requests/injective_transfer_to_bank.json b/test-helpers/curl/requests/injective_transfer_to_bank.json index 0d0960311c..a17b7be6bf 100644 --- a/test-helpers/curl/requests/injective_transfer_to_bank.json +++ b/test-helpers/curl/requests/injective_transfer_to_bank.json @@ -2,7 +2,8 @@ "chain": "injective", "network": "mainnet", "connector": "injective", - "address": "$INJECTIVE_SUBACCOUNTID", + "to": "$INJECTIVE_ACCOUNTID", + "from": "$INJECTIVE_SUBACCOUNTID", "amount": "0.10", "token": "USDT" } diff --git a/test-helpers/curl/requests/injective_transfer_to_sub.json b/test-helpers/curl/requests/injective_transfer_to_sub.json index def67c247b..2500d35781 100644 --- a/test-helpers/curl/requests/injective_transfer_to_sub.json +++ b/test-helpers/curl/requests/injective_transfer_to_sub.json @@ -2,7 +2,8 @@ "chain": "injective", "network": "mainnet", "connector": "injective", - "address": "$INJECTIVE_SUBACCOUNTID", + "from": "$INJECTIVE_ACCOUNTID", + "to": "$INJECTIVE_SUBACCOUNTID", "amount": "0.123", "token": "USDT" } diff --git a/test/chains/ethereum/ethereum.controllers.test.ts b/test/chains/ethereum/ethereum.controllers.test.ts index 44fc213d58..6a1fc7d960 100644 --- a/test/chains/ethereum/ethereum.controllers.test.ts +++ b/test/chains/ethereum/ethereum.controllers.test.ts @@ -2,16 +2,6 @@ import { BigNumber } from 'ethers'; import { Ethereum } from '../../../src/chains/ethereum/ethereum'; import { patch, unpatch } from '../../services/patch'; import { TokenInfo } from '../../../src/chains/ethereum/ethereum-base'; -import { - nonce, - nextNonce, - getTokenSymbolsToTokens, - allowances, - approve, - balances, - cancel, - willTxSucceed, -} from '../../../src/chains/ethereum/ethereum.controllers'; import { HttpException, LOAD_WALLET_ERROR_CODE, @@ -20,6 +10,10 @@ import { TOKEN_NOT_SUPPORTED_ERROR_CODE, } from '../../../src/services/error-handler'; import { patchEVMNonceManager } from '../../evm.nonce.mock'; +import { + EVMController, + willTxSucceed, +} from '../../../src/chains/ethereum/evm.controllers'; let eth: Ethereum; beforeAll(async () => { @@ -53,7 +47,7 @@ describe('nonce', () => { }; }); patch(eth.nonceManager, 'getNonce', () => 2); - const n = await nonce(eth, { + const n = await EVMController.nonce(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -68,7 +62,7 @@ describe('nonce', () => { }; }); patch(eth.nonceManager, 'getNextNonce', () => 3); - const n = await nextNonce(eth, { + const n = await EVMController.nextNonce(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -89,7 +83,9 @@ describe('getTokenSymbolsToTokens', () => { patch(eth, 'getTokenBySymbol', () => { return weth; }); - expect(getTokenSymbolsToTokens(eth, ['WETH'])).toEqual({ WETH: weth }); + expect(EVMController.getTokenSymbolsToTokens(eth, ['WETH'])).toEqual({ + WETH: weth, + }); }); }); @@ -118,7 +114,7 @@ describe('allowances', () => { }; }); - const result = await allowances(eth, { + const result = await EVMController.allowances(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -159,7 +155,7 @@ describe('approve', () => { }; }); - const result = await approve(eth, { + const result = await EVMController.approve(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -180,7 +176,7 @@ describe('approve', () => { }); await expect( - approve(eth, { + EVMController.approve(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -212,7 +208,7 @@ describe('approve', () => { }); await expect( - approve(eth, { + EVMController.approve(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -237,7 +233,7 @@ describe('balances', () => { }); await expect( - balances(eth, { + EVMController.balances(eth, { chain: 'ethereum', network: 'goerli', address: zeroAddress, @@ -261,7 +257,7 @@ describe('cancel', () => { }); await expect( - cancel(eth, { + EVMController.cancel(eth, { chain: 'ethereum', network: 'goerli', nonce: 123, diff --git a/test/chains/ethereum/evm.nonce.test.ts b/test/chains/ethereum/evm.nonce.test.ts index ceda3f1a03..edf369ffb5 100644 --- a/test/chains/ethereum/evm.nonce.test.ts +++ b/test/chains/ethereum/evm.nonce.test.ts @@ -12,7 +12,7 @@ import { SERVICE_UNITIALIZED_ERROR_CODE, SERVICE_UNITIALIZED_ERROR_MESSAGE, } from '../../../src/services/error-handler'; -import { EVMNonceManager } from '../../../src/evm/evm.nonce'; +import { EVMNonceManager } from '../../../src/chains/ethereum/evm.nonce'; import { patch, unpatch } from '../../services/patch'; import 'jest-extended'; diff --git a/test/chains/harmony/harmony.controllers.test.ts b/test/chains/harmony/harmony.controllers.test.ts index b5aad06de8..f15f93a670 100644 --- a/test/chains/harmony/harmony.controllers.test.ts +++ b/test/chains/harmony/harmony.controllers.test.ts @@ -2,15 +2,6 @@ import { BigNumber } from 'ethers'; import { Harmony } from '../../../src/chains/harmony/harmony'; import { patch, unpatch } from '../../services/patch'; import { TokenInfo } from '../../../src/chains/ethereum/ethereum-base'; -import { - nonce, - getTokenSymbolsToTokens, - allowances, - approve, - balances, - cancel, - willTxSucceed, -} from '../../../src/chains/ethereum/ethereum.controllers'; import { HttpException, LOAD_WALLET_ERROR_CODE, @@ -19,6 +10,10 @@ import { TOKEN_NOT_SUPPORTED_ERROR_CODE, } from '../../../src/services/error-handler'; import { patchEVMNonceManager } from '../../evm.nonce.mock'; +import { + EVMController, + willTxSucceed, +} from '../../../src/chains/ethereum/evm.controllers'; jest.useFakeTimers(); let harmony: Harmony; @@ -52,7 +47,7 @@ describe('nonce', () => { }; }); patch(harmony.nonceManager, 'getNonce', () => 2); - const n = await nonce(harmony, { + const n = await EVMController.nonce(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -73,7 +68,9 @@ describe('getTokenSymbolsToTokens', () => { patch(harmony, 'getTokenBySymbol', () => { return wone; }); - expect(getTokenSymbolsToTokens(harmony, ['WONE'])).toEqual({ WONE: wone }); + expect(EVMController.getTokenSymbolsToTokens(harmony, ['WONE'])).toEqual({ + WONE: wone, + }); }); }); @@ -102,7 +99,7 @@ describe('allowances', () => { }; }); - const result = await allowances(harmony, { + const result = await EVMController.allowances(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -143,7 +140,7 @@ describe('approve', () => { }; }); - const result = await approve(harmony, { + const result = await EVMController.approve(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -164,7 +161,7 @@ describe('approve', () => { }); await expect( - approve(harmony, { + EVMController.approve(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -196,7 +193,7 @@ describe('approve', () => { }); await expect( - approve(harmony, { + EVMController.approve(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -221,7 +218,7 @@ describe('balances', () => { }); await expect( - balances(harmony, { + EVMController.balances(harmony, { chain: 'harmony', network: 'testnet', address: zeroAddress, @@ -245,7 +242,7 @@ describe('cancel', () => { }); await expect( - cancel(harmony, { + EVMController.cancel(harmony, { chain: 'harmony', network: 'testnet', nonce: 123, diff --git a/test/chains/near/near.controllers.test.ts b/test/chains/near/near.controllers.test.ts index 6caec96273..d2ccf558b9 100644 --- a/test/chains/near/near.controllers.test.ts +++ b/test/chains/near/near.controllers.test.ts @@ -1,12 +1,6 @@ import { Near } from '../../../src/chains/near/near'; import { TokenInfo } from '../../../src/chains/near/near.base'; -import { - balances, - cancel, - getTokenSymbolsToTokens, - poll, -} from '../../../src/chains/near/near.controllers'; -import { PollResponse } from '../../../src/chains/near/near.requests'; +import { NearController } from '../../../src/chains/near/near.controllers'; import { Nearish } from '../../../src/services/common-interfaces'; import { HttpException, @@ -50,9 +44,11 @@ describe('poll', () => { it('return transaction data for given signature', async () => { patchGetCurrentBlockNumber(); patchGetTransaction(); - const n: PollResponse = await poll(near, publicKey, txHash); - expect(n.network).toBe(near.network); - expect(n.timestamp).toBeNumber(); + const n = await NearController.poll(near, { + address: publicKey, + txHash, + network: '', + }); expect(n.currentBlock).toBe(CurrentBlockNumber); expect(n.txHash).toBe(txHash); expect(n.txStatus).toBe(1); @@ -67,7 +63,7 @@ describe('balances', () => { }); await expect( - balances(near, { + NearController.balances(near, { chain: 'near', network: 'testnet', address: publicKey, @@ -91,7 +87,7 @@ describe('cancel', () => { }); await expect( - cancel(near, { + NearController.cancel(near, { chain: 'near', network: 'testnet', nonce: 123, @@ -119,6 +115,8 @@ describe('getTokenSymbolsToTokens', () => { patch(near, 'getTokenBySymbol', () => { return eth; }); - expect(getTokenSymbolsToTokens(near, ['ETH'])).toEqual({ ETH: eth }); + expect(NearController.getTokenSymbolsToTokens(near, ['ETH'])).toEqual({ + ETH: eth, + }); }); }); diff --git a/test/evm.nonce.mock.ts b/test/evm.nonce.mock.ts index 8b94337697..f2232d44a6 100644 --- a/test/evm.nonce.mock.ts +++ b/test/evm.nonce.mock.ts @@ -1,5 +1,5 @@ import { patch } from './services/patch'; -import { EVMNonceManager } from '../src/evm/evm.nonce'; +import { EVMNonceManager } from '../src/chains/ethereum/evm.nonce'; // override values so that nonceManager doesn't crash due to lack of provider // connection diff --git a/test/services/evm.nonce.test.ts b/test/services/evm.nonce.test.ts index a5e375d8ab..541f90de8a 100644 --- a/test/services/evm.nonce.test.ts +++ b/test/services/evm.nonce.test.ts @@ -9,7 +9,7 @@ import { EVMNonceManager, // NonceInfo, // NonceLocalStorage, -} from '../../src/evm/evm.nonce'; +} from '../../src/chains/ethereum/evm.nonce'; // import { ReferenceCountingCloseable } from '../../src/services/refcounting-closeable'; import { patch } from './patch'; diff --git a/test/services/evm.tx-storage.test.ts b/test/services/evm.tx-storage.test.ts index 35d4bbf405..7e4b6fc86d 100644 --- a/test/services/evm.tx-storage.test.ts +++ b/test/services/evm.tx-storage.test.ts @@ -3,7 +3,7 @@ import fsp from 'fs/promises'; import fse from 'fs-extra'; import os from 'os'; import path from 'path'; -import { EvmTxStorage } from '../../src/evm/evm.tx-storage'; +import { EvmTxStorage } from '../../src/chains/ethereum/evm.tx-storage'; import 'jest-extended'; import { ReferenceCountingCloseable } from '../../src/services/refcounting-closeable';