Digitex dev update #0: Custodian app code refactoring and TRON blockchain 1

Digitex dev update #0: Custodian app code refactoring and TRON blockchain

Digitex
• Aleksei Veledinskii
July 9, 2021

As you may have noticed, we’ve recently changed the way features are being deployed. Since March 2021, our team located in Kyiv (Kiev) has worked hard to deliver previously promised features. 

Some of these features, such as the DUSD stablecoin, were canceled. Meanwhile, we included some new, really cool, and helpful features.

Some examples? New UX design, spot market trading, improved KYC process, Blockfunder IEO token launch platform, and Blockfarm staking platform. 

It may seem that our work paused last month, as no UI features were released, but we are here to show how much activity has been going on.

We decided to publish weekly dev updates to show what’s in progress and achieved, and more importantly, keeping in touch with our community. 

We’re focusing on Custodian app improvement

Custodian service are one of the most critical applications of the Digitex.io exchange. Those functions connect with the different blockchains and are responsible for cryptos’ deposits and withdrawals. We previously planned a code refactoring for 4Q21, but one case forced us to start with it as soon as possible: USD Tether (USDT) deposits.

In May 2021, our support agents received several requests for USDT transfers in and out of the exchange. At that time, Digitex.io didn’t support USDT, as only USD Coin (USDC) was available. Therefore, we decided to add USDT ERC-20, giving users the ability to make deposits and withdrawals. We immediately started working on it.

Our initial plan was very comprehensive:

  1. Full code review;
  2. Code refactoring, making it more readable, flexible, and scalable.
  3. Adding USDT ERC-20 support;
  4. Adding support for other Ethereum-compatible blockchains: Binance Smart Chain, Ethereum Classic, and TRON.

All this might seem too much work to add a single token, but it can get tricky when you need to improve based on legacy code from the previous team.

Keep in mind that the legacy code was primarily made for Ethereum blockchain — hence, trying to modify functions would likely create conflicts and unexpected bugs. So, ultimately, we decided to rebuild the entire application architecture.

Code review: the initial step

The codebase we inherited from the previous team wasn’t in the best condition,” — said Nikita Vysotskyi, Digitex.io developer. They faced the following problems:

  1. Plenty of duplicate code;
  2. Barely readable and large functions;
  3. Incomplete structure of the app models.

The structure of the models (database tables) which would allow working with multiple networks had not been completed. Some models were inherited, while others simply copied with repeating fields“, — Nikita said.

As mentioned by our Digitex.io developer, adding USDT ERC-20 could be done without refactoring, but the TRON network, for example, has a slightly different interface. Moreover, TRON does not provide workable Python libraries for its HTTP API, requiring a separate client.

To avoid aggravating issues with the code duplication, unnecessary large functions, and allowing the project TRON network inclusion, we decided to carry out a complete refactoring of the Custodian application.

Code refactoring: the second step

Our desired Custodian app included the ability to expand our spot markets listings and add featured blockchains. Therefore, the following steps were scripted:

  1. Remove, where possible and appropriate, duplicated code, while adjusting and improving its overall structure;
  2. Move the components’ general logic into abstract base classes;
  3. Transfer from abstract network interaction logic to concrete classes;
  4. Rebuild the structure of the models containing abstract models with common fields and behavior, which required migrating data to new tables;
  5. Update the testing system and make sure that the new code covers all proposed requirements.

As Nikita explained, “Thus, we get a code that is easier to improve on, add support for other networks, including previously incompatible ones, while at the same time it is easier to maintain, read, and test.

Refactoring old code of the exchange’s mission-critical subsystems that had no significant changes for more than 2 years is very difficult to execute. It takes very precise planning and testing of each development step: from planning architecture changes to the new codebase, smooth deployment, and migrations“, commented Pavel Yuschenko, Digitex.io CTO.

As we learned from our team, the building process was a tiresome but pleasant experience, and the overall happiness of its members was paramount: it’s the team members who create our products, our value. In addition, Nikita, as a developer, likes to dig into new things, and we are always trying to create such opportunities for them.” – Pavel.

I enjoyed diving into it because I had to dig through a bunch of new information, uncovered a new approach (decentralized networks, blocks, etc.), and got to work with a new codebase. The blockchain itself is a rather interesting technology: I especially liked the idea of ​​implementing smart contracts (e.g., executing the Solidity code remotely within the Network).” – Nikita Vysotskyi.

He then added: “I will continue to monitor the development of blockchain technology, as I noticed that the community is growing and there is plenty of activity and interest around it.”

What are the benefits of code refactoring?

Now you can see the benefits from our Custodian app codebase refactoring: adding new Blockchains (according to our future plans, shhhh!) and new listings to the exchange. So, what other benefits might there be?

Within the first iteration of the code refactoring, we added USDT ERC-20 to the exchange. Some underlying changes, although invisible for most users, allows us to:

  1. Reduce costs for deploying users’ wallets to the blockchain;
  2. Lower fees for transferring funds in and out of the exchange’s hot wallet.

Also, there are a bunch of upcoming infrastructure benefits. For example, after we fully deploy the new Custodian app to production, adding new markets with users’ most popular coins, even those based on different blockchains, will be more accessible, secure, and fast. 

In a nutshell, those are the real winners from the updates: our traders at Digitex.io.

Bye! See you next Friday with Dev update #1.

July 9, 2021
Digitex

Digitex dev update #0: Custodian app code refactoring and TRON blockchain

Aleksei Veledinskii
Digitex dev update #0: Custodian app code refactoring and TRON blockchain 2

As you may have noticed, we’ve recently changed the way features are being deployed. Since March 2021, our team located in Kyiv (Kiev) has worked hard to deliver previously promised features. 

Some of these features, such as the DUSD stablecoin, were canceled. Meanwhile, we included some new, really cool, and helpful features.

Some examples? New UX design, spot market trading, improved KYC process, Blockfunder IEO token launch platform, and Blockfarm staking platform. 

It may seem that our work paused last month, as no UI features were released, but we are here to show how much activity has been going on.

We decided to publish weekly dev updates to show what’s in progress and achieved, and more importantly, keeping in touch with our community. 

We’re focusing on Custodian app improvement

Custodian service are one of the most critical applications of the Digitex.io exchange. Those functions connect with the different blockchains and are responsible for cryptos’ deposits and withdrawals. We previously planned a code refactoring for 4Q21, but one case forced us to start with it as soon as possible: USD Tether (USDT) deposits.

In May 2021, our support agents received several requests for USDT transfers in and out of the exchange. At that time, Digitex.io didn’t support USDT, as only USD Coin (USDC) was available. Therefore, we decided to add USDT ERC-20, giving users the ability to make deposits and withdrawals. We immediately started working on it.

Our initial plan was very comprehensive:

  1. Full code review;
  2. Code refactoring, making it more readable, flexible, and scalable.
  3. Adding USDT ERC-20 support;
  4. Adding support for other Ethereum-compatible blockchains: Binance Smart Chain, Ethereum Classic, and TRON.

All this might seem too much work to add a single token, but it can get tricky when you need to improve based on legacy code from the previous team.

Keep in mind that the legacy code was primarily made for Ethereum blockchain — hence, trying to modify functions would likely create conflicts and unexpected bugs. So, ultimately, we decided to rebuild the entire application architecture.

Code review: the initial step

The codebase we inherited from the previous team wasn’t in the best condition,” — said Nikita Vysotskyi, Digitex.io developer. They faced the following problems:

  1. Plenty of duplicate code;
  2. Barely readable and large functions;
  3. Incomplete structure of the app models.

The structure of the models (database tables) which would allow working with multiple networks had not been completed. Some models were inherited, while others simply copied with repeating fields“, — Nikita said.

As mentioned by our Digitex.io developer, adding USDT ERC-20 could be done without refactoring, but the TRON network, for example, has a slightly different interface. Moreover, TRON does not provide workable Python libraries for its HTTP API, requiring a separate client.

To avoid aggravating issues with the code duplication, unnecessary large functions, and allowing the project TRON network inclusion, we decided to carry out a complete refactoring of the Custodian application.

Code refactoring: the second step

Our desired Custodian app included the ability to expand our spot markets listings and add featured blockchains. Therefore, the following steps were scripted:

  1. Remove, where possible and appropriate, duplicated code, while adjusting and improving its overall structure;
  2. Move the components’ general logic into abstract base classes;
  3. Transfer from abstract network interaction logic to concrete classes;
  4. Rebuild the structure of the models containing abstract models with common fields and behavior, which required migrating data to new tables;
  5. Update the testing system and make sure that the new code covers all proposed requirements.

As Nikita explained, “Thus, we get a code that is easier to improve on, add support for other networks, including previously incompatible ones, while at the same time it is easier to maintain, read, and test.

Refactoring old code of the exchange’s mission-critical subsystems that had no significant changes for more than 2 years is very difficult to execute. It takes very precise planning and testing of each development step: from planning architecture changes to the new codebase, smooth deployment, and migrations“, commented Pavel Yuschenko, Digitex.io CTO.

As we learned from our team, the building process was a tiresome but pleasant experience, and the overall happiness of its members was paramount: it’s the team members who create our products, our value. In addition, Nikita, as a developer, likes to dig into new things, and we are always trying to create such opportunities for them.” – Pavel.

I enjoyed diving into it because I had to dig through a bunch of new information, uncovered a new approach (decentralized networks, blocks, etc.), and got to work with a new codebase. The blockchain itself is a rather interesting technology: I especially liked the idea of ​​implementing smart contracts (e.g., executing the Solidity code remotely within the Network).” – Nikita Vysotskyi.

He then added: “I will continue to monitor the development of blockchain technology, as I noticed that the community is growing and there is plenty of activity and interest around it.”

What are the benefits of code refactoring?

Now you can see the benefits from our Custodian app codebase refactoring: adding new Blockchains (according to our future plans, shhhh!) and new listings to the exchange. So, what other benefits might there be?

Within the first iteration of the code refactoring, we added USDT ERC-20 to the exchange. Some underlying changes, although invisible for most users, allows us to:

  1. Reduce costs for deploying users’ wallets to the blockchain;
  2. Lower fees for transferring funds in and out of the exchange’s hot wallet.

Also, there are a bunch of upcoming infrastructure benefits. For example, after we fully deploy the new Custodian app to production, adding new markets with users’ most popular coins, even those based on different blockchains, will be more accessible, secure, and fast. 

In a nutshell, those are the real winners from the updates: our traders at Digitex.io.

Bye! See you next Friday with Dev update #1.

Latest News