-
Notifications
You must be signed in to change notification settings - Fork 1
feat: token version #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: token version #261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,38 @@ Refer to https://github.com/HathorNetwork/rfcs/blob/master/projects/wallet-servi | |
|
|
||
| #### System dependencies | ||
|
|
||
| You need nodejs installed on your enviroment, we suggest the latest Active LTS version (v18.x.x). | ||
| ``` | ||
| Node: 20x | ||
| yarn: v4 (yarn-berry) | ||
| ``` | ||
|
|
||
| #### Install nix (preferred) | ||
|
|
||
| For a better developer experience we suggest nix usage for mananing the enviroment. Visit this [link](https://nixos.org/download/#download-nix) to download it. | ||
|
|
||
| To enable the commands `nix develop` and `nix build` using flakes, add the following to your `/etc/nix/nix.conf` file: | ||
|
|
||
| ``` | ||
| experimental-features = nix-command flakes | ||
| ``` | ||
|
|
||
| #### Clone the project and install dependencies | ||
|
|
||
| `git clone https://github.com/HathorNetwork/hathor-wallet-service-sync_daemon.git` | ||
| ```sh | ||
| $ git clone https://github.com/HathorNetwork/hathor-wallet-service-sync_daemon.git | ||
| ``` | ||
|
|
||
| `npm install` | ||
| To initialize nix dev environment: | ||
|
|
||
| ```sh | ||
| $ nix develop | ||
| ``` | ||
|
|
||
| then, install the depencies: | ||
|
|
||
| ```sh | ||
| yarn | ||
| ``` | ||
|
|
||
| #### Add env variables or an .env file to the repository: | ||
|
|
||
|
|
@@ -54,6 +79,16 @@ AWS_SECRET_ACCESS_KEY="..." | |
|
|
||
| These are used for communicating with the alert SQS | ||
|
|
||
| #### Docker images | ||
|
|
||
| Some packages depends on some docker images. To build them you'll need to have Hathor VPN access configured, check this [link](https://github.com/HathorNetwork/ops-tools/blob/master/terraform/wireguard-vpn/SOP.md#adding-a-new-client-to-the-vpn) for it. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which ones? |
||
|
|
||
| #### Db initialize | ||
|
|
||
| Before running the tests, make sure your database is already initialize by running the migrations. | ||
|
|
||
| `nix develop . -c yarn sequelize db:migrate` | ||
|
|
||
| ## Reseeding the HTR Token After Database Reset | ||
|
|
||
| If you need to reset the database (for example, to re-sync it from scratch), you must re-insert the HTR token into the `token` table. This is handled by a seed script that will automatically calculate the correct transaction count for HTR based on the current state of the database. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| "use strict"; | ||
|
|
||
| /** @type {import('sequelize-cli').Migration} */ | ||
| module.exports = { | ||
| async up(queryInterface, Sequelize) { | ||
| queryInterface.addColumn("token", "version", { | ||
| type: Sequelize.INTEGER, | ||
| allowNull: true, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why allow null? What do you think? |
||
| }); | ||
| }, | ||
|
|
||
| async down(queryInterface) { | ||
| queryInterface.removeColumn("token", "version"); | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| "packages/wallet-service" | ||
| ], | ||
| "engines": { | ||
| "node": ">=18" | ||
| "node": ">=20" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should upgrade to 22, since the current lib version already requires node 22 |
||
| }, | ||
| "nohoist": [ | ||
| "**" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,7 @@ export interface TokenInformationRow extends RowDataPacket { | |
| name: string; | ||
| symbol: string; | ||
| transactions: number; | ||
| version?: number | null; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why null? |
||
| created_at: number; | ||
| updated_at: number; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,26 @@ | |
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import { constants } from '@hathor/wallet-lib'; | ||
| import { constants } from "@hathor/wallet-lib"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
|
|
||
| export class TokenInfo { | ||
| export enum TokenInfoVersion { | ||
| DEPOSIT = 1, | ||
|
|
||
| FEE = 2, | ||
| } | ||
|
|
||
| export interface ITokenInfo { | ||
| id: string; | ||
| name: string; | ||
| symbol: string; | ||
| version?: TokenInfoVersion | null; | ||
| } | ||
|
|
||
| export interface ITokenInfoOptions extends ITokenInfo { | ||
| transactions?: number; | ||
| } | ||
|
|
||
| export class TokenInfo implements ITokenInfo { | ||
| id: string; | ||
|
|
||
| name: string; | ||
|
|
@@ -16,26 +33,31 @@ export class TokenInfo { | |
|
|
||
| transactions: number; | ||
|
|
||
| constructor(id: string, name: string, symbol: string, transactions?: number) { | ||
| version?: TokenInfoVersion | null; | ||
|
|
||
| constructor({ id, name, symbol, version, transactions }: ITokenInfoOptions) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.symbol = symbol; | ||
| this.transactions = transactions || 0; | ||
| this.version = version || TokenInfoVersion.DEPOSIT; | ||
|
|
||
| // XXX: get config from settings? | ||
| const hathorConfig = constants.DEFAULT_NATIVE_TOKEN_CONFIG; | ||
|
|
||
| if (this.id === constants.NATIVE_TOKEN_UID) { | ||
| this.name = hathorConfig.name; | ||
| this.symbol = hathorConfig.symbol; | ||
| this.version = null; | ||
| } | ||
| } | ||
|
|
||
| toJSON(): Record<string, unknown> { | ||
| toJSON(): ITokenInfo { | ||
| return { | ||
| id: this.id, | ||
| name: this.name, | ||
| symbol: this.symbol, | ||
| version: this.version, | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| "target": "ES2022", | ||
| "module": "CommonJS", | ||
| "sourceMap": true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace this with
git@github.com:HathorNetwork/hathor-wallet-service.git?