Skip to content

Commit 75e07dc

Browse files
committed
Merge branch 'master' into feat/events-downloader
2 parents 5d64c78 + 59c7def commit 75e07dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4913
-687
lines changed

.codebuild/build.sh

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ deploy_hathor_network_account() {
2323
exit=true;
2424
fi;
2525

26-
# Checks whether there is a file called "rollback_testnet_production", which is used by our other CodeBuild to indicate that this is a testnet-production rollback
27-
if [ -f "rollback_testnet_production" ]; then
28-
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
29-
for var in "${!testnet_@}"; do
30-
export ${var#testnet_}="${!var}"
31-
done
32-
make deploy-lambdas-testnet;
33-
send_slack_message "Rollback performed on testnet-production to: ${GIT_REF_TO_DEPLOY}";
34-
exit=true;
35-
fi;
36-
3726
if [ "$exit" = true ]; then
3827
echo "Rollbacks performed successfully. Exiting now.";
3928
exit 0;
@@ -67,44 +56,6 @@ deploy_hathor_network_account() {
6756
elif expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
6857
echo $GIT_REF_TO_DEPLOY > /tmp/docker_image_tag
6958

70-
# --- Testnet ---
71-
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
72-
for var in "${!testnet_@}"; do
73-
export ${var#testnet_}="${!var}"
74-
done
75-
76-
make migrate;
77-
make build-daemon;
78-
make deploy-lambdas-testnet;
79-
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
80-
make push-daemon;
81-
82-
# Unsets all the testnet env vars so we make sure they don't leak to other deploys
83-
for var in "${!testnet_@}"; do
84-
unset ${var#testnet_}
85-
done
86-
87-
send_slack_message "New version deployed to testnet-production: ${GIT_REF_TO_DEPLOY}"
88-
89-
# --- Testnet Hotel ---
90-
# Gets all env vars with `testnethotel_` prefix and re-exports them without the prefix
91-
for var in "${!testnethotel_@}"; do
92-
export ${var#testnethotel_}="${!var}"
93-
done
94-
95-
make migrate;
96-
make build-daemon;
97-
make deploy-lambdas-testnet-hotel;
98-
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
99-
make push-daemon;
100-
101-
# Unsets all the testnet env vars so we make sure they don't leak to other deploys
102-
for var in "${!testnethotel_@}"; do
103-
unset ${var#testnethotel_}
104-
done
105-
106-
send_slack_message "New version deployed to testnet-hotel: ${GIT_REF_TO_DEPLOY}"
107-
10859
# --- Testnet India ---
10960
# Gets all env vars with `testnetindia_` prefix and re-exports them without the prefix
11061
for var in "${!testnetindia_@}"; do

.codebuild/buildspec.yml

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ env:
2626
dev_PUSH_NOTIFICATION_ENABLED: "true"
2727
dev_PUSH_ALLOWED_PROVIDERS: "android,ios"
2828
dev_APPLICATION_NAME: "wallet-service-dev"
29-
testnet_DEFAULT_SERVER: "https://wallet-service.private-nodes.testnet.hathor.network/v1a/"
30-
testnet_WS_DOMAIN: "ws.wallet-service.testnet.hathor.network"
31-
testnet_NETWORK: "testnet"
32-
testnet_LOG_LEVEL: "debug"
33-
testnet_NFT_AUTO_REVIEW_ENABLED: "true"
34-
testnet_EXPLORER_STAGE: "testnet"
35-
testnet_EXPLORER_SERVICE_LAMBDA_ENDPOINT: "https://lambda.eu-central-1.amazonaws.com"
36-
testnet_WALLET_SERVICE_LAMBDA_ENDPOINT: "https://lambda.eu-central-1.amazonaws.com"
37-
testnet_PUSH_NOTIFICATION_ENABLED: "true"
38-
testnet_PUSH_ALLOWED_PROVIDERS: "android,ios"
39-
testnet_APPLICATION_NAME: "wallet-service-testnet"
40-
testnethotel_DEFAULT_SERVER: "https://wallet-service.private-nodes.hotel.testnet.hathor.network/v1a/"
41-
testnethotel_WS_DOMAIN: "ws.wallet-service.hotel.testnet.hathor.network"
42-
testnethotel_NETWORK: "testnet"
43-
testnethotel_LOG_LEVEL: "debug"
44-
testnethotel_NFT_AUTO_REVIEW_ENABLED: "true"
45-
testnethotel_EXPLORER_STAGE: "hotel"
46-
testnethotel_EXPLORER_SERVICE_LAMBDA_ENDPOINT: "https://lambda.eu-central-1.amazonaws.com"
47-
testnethotel_WALLET_SERVICE_LAMBDA_ENDPOINT: "https://lambda.eu-central-1.amazonaws.com"
48-
testnethotel_PUSH_NOTIFICATION_ENABLED: "true"
49-
testnethotel_PUSH_ALLOWED_PROVIDERS: "android,ios"
50-
testnethotel_APPLICATION_NAME: "wallet-service-testnet-hotel"
5129
testnetindia_DEFAULT_SERVER: "https://wallet-service.private-nodes.india.testnet.hathor.network/v1a/"
5230
testnetindia_WS_DOMAIN: "ws.wallet-service.india.testnet.hathor.network"
5331
testnetindia_NETWORK: "testnet"
@@ -113,58 +91,6 @@ env:
11391
dev_ALERT_MANAGER_REGION: "WalletService/dev:ALERT_MANAGER_REGION"
11492
dev_ALERT_MANAGER_TOPIC: "WalletService/dev:ALERT_MANAGER_TOPIC"
11593
dev_ALERT_MANAGER_ACCOUNT_ID: "WalletService/dev:ALERT_MANAGER_ACCOUNT_ID"
116-
# Testnet secrets
117-
testnet_ACCOUNT_ID: "WalletService/testnet:account_id"
118-
testnet_AUTH_SECRET: "WalletService/testnet:auth_secret"
119-
testnet_AWS_VPC_DEFAULT_SG_ID: "WalletService/testnet:aws_vpc_default_sg_id"
120-
testnet_AWS_SUBNET_ID_1: "WalletService/testnet:aws_subnet_id_1"
121-
testnet_AWS_SUBNET_ID_2: "WalletService/testnet:aws_subnet_id_2"
122-
testnet_AWS_SUBNET_ID_3: "WalletService/testnet:aws_subnet_id_3"
123-
testnet_DB_NAME: "WalletService/rds/testnet:dbname"
124-
testnet_DB_USER: "WalletService/rds/testnet:username"
125-
testnet_DB_PASS: "WalletService/rds/testnet:password"
126-
testnet_DB_ENDPOINT: "WalletService/rds/testnet:host"
127-
testnet_DB_PORT: "WalletService/rds/testnet:port"
128-
testnet_REDIS_URL: "WalletService/redis/testnet:url"
129-
testnet_REDIS_PASSWORD: "WalletService/redis/testnet:password"
130-
testnet_FIREBASE_PROJECT_ID: "WalletService/testnet:FIREBASE_PROJECT_ID"
131-
testnet_FIREBASE_PRIVATE_KEY_ID: "WalletService/testnet:FIREBASE_PRIVATE_KEY_ID"
132-
testnet_FIREBASE_PRIVATE_KEY: "WalletService/testnet:FIREBASE_PRIVATE_KEY"
133-
testnet_FIREBASE_CLIENT_EMAIL: "WalletService/testnet:FIREBASE_CLIENT_EMAIL"
134-
testnet_FIREBASE_CLIENT_ID: "WalletService/testnet:FIREBASE_CLIENT_ID"
135-
testnet_FIREBASE_AUTH_URI: "WalletService/testnet:FIREBASE_AUTH_URI"
136-
testnet_FIREBASE_TOKEN_URI: "WalletService/testnet:FIREBASE_TOKEN_URI"
137-
testnet_FIREBASE_AUTH_PROVIDER_X509_CERT_URL: "WalletService/testnet:FIREBASE_AUTH_PROVIDER_X509_CERT_URL"
138-
testnet_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/testnet:FIREBASE_CLIENT_X509_CERT_URL"
139-
testnet_ALERT_MANAGER_REGION: "WalletService/testnet:ALERT_MANAGER_REGION"
140-
testnet_ALERT_MANAGER_TOPIC: "WalletService/testnet:ALERT_MANAGER_TOPIC"
141-
testnet_ALERT_MANAGER_ACCOUNT_ID: "WalletService/testnet:ALERT_MANAGER_ACCOUNT_ID"
142-
# Testnet Hotel secrets
143-
testnethotel_ACCOUNT_ID: "WalletService/testnet-hotel:account_id"
144-
testnethotel_AUTH_SECRET: "WalletService/testnet-hotel:auth_secret"
145-
testnethotel_AWS_VPC_DEFAULT_SG_ID: "WalletService/testnet-hotel:aws_vpc_default_sg_id"
146-
testnethotel_AWS_SUBNET_ID_1: "WalletService/testnet-hotel:aws_subnet_id_1"
147-
testnethotel_AWS_SUBNET_ID_2: "WalletService/testnet-hotel:aws_subnet_id_2"
148-
testnethotel_AWS_SUBNET_ID_3: "WalletService/testnet-hotel:aws_subnet_id_3"
149-
testnethotel_DB_NAME: "WalletService/rds/testnet-hotel:dbname"
150-
testnethotel_DB_USER: "WalletService/rds/testnet-hotel:username"
151-
testnethotel_DB_PASS: "WalletService/rds/testnet-hotel:password"
152-
testnethotel_DB_ENDPOINT: "WalletService/rds/testnet-hotel:host"
153-
testnethotel_DB_PORT: "WalletService/rds/testnet-hotel:port"
154-
testnethotel_REDIS_URL: "WalletService/redis/testnet-hotel:url"
155-
testnethotel_REDIS_PASSWORD: "WalletService/redis/testnet-hotel:password"
156-
testnethotel_FIREBASE_PROJECT_ID: "WalletService/testnet-hotel:FIREBASE_PROJECT_ID"
157-
testnethotel_FIREBASE_PRIVATE_KEY_ID: "WalletService/testnet-hotel:FIREBASE_PRIVATE_KEY_ID"
158-
testnethotel_FIREBASE_PRIVATE_KEY: "WalletService/testnet-hotel:FIREBASE_PRIVATE_KEY"
159-
testnethotel_FIREBASE_CLIENT_EMAIL: "WalletService/testnet-hotel:FIREBASE_CLIENT_EMAIL"
160-
testnethotel_FIREBASE_CLIENT_ID: "WalletService/testnet-hotel:FIREBASE_CLIENT_ID"
161-
testnethotel_FIREBASE_AUTH_URI: "WalletService/testnet-hotel:FIREBASE_AUTH_URI"
162-
testnethotel_FIREBASE_TOKEN_URI: "WalletService/testnet-hotel:FIREBASE_TOKEN_URI"
163-
testnethotel_FIREBASE_AUTH_PROVIDER_X509_CERT_URL: "WalletService/testnet-hotel:FIREBASE_AUTH_PROVIDER_X509_CERT_URL"
164-
testnethotel_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/testnet-hotel:FIREBASE_CLIENT_X509_CERT_URL"
165-
testnethotel_ALERT_MANAGER_REGION: "WalletService/testnet-hotel:ALERT_MANAGER_REGION"
166-
testnethotel_ALERT_MANAGER_TOPIC: "WalletService/testnet-hotel:ALERT_MANAGER_TOPIC"
167-
testnethotel_ALERT_MANAGER_ACCOUNT_ID: "WalletService/testnet-hotel:ALERT_MANAGER_ACCOUNT_ID"
16894
# Testnet India secrets
16995
testnetindia_ACCOUNT_ID: "WalletService/testnet-india:account_id"
17096
testnetindia_AUTH_SECRET: "WalletService/testnet-india:auth_secret"

Makefile

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ build-service:
1818
push-daemon:
1919
bash scripts/push-daemon.sh
2020

21-
.PHONY: deploy-lambdas-nano-testnet
22-
deploy-lambdas-nano-testnet:
23-
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage nano --region eu-central-1 --aws-profile nano-testnet
24-
25-
.PHONY: deploy-lambdas-nano-testnet-bravo
26-
deploy-lambdas-nano-testnet-bravo:
27-
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage nano-bravo --region eu-central-1 --aws-profile nano-testnet
28-
29-
.PHONY: deploy-lambdas-nano-testnet-hackaton
30-
deploy-lambdas-nano-testnet-hackaton:
31-
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage hackaton --region eu-central-1 --aws-profile nano-testnet-hackaton
32-
3321
.PHONY: deploy-lambdas-ekvilibro-testnet
3422
deploy-lambdas-ekvilibro-testnet:
3523
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage ekvilibro --region eu-central-1 --aws-profile ekvilibro
@@ -42,14 +30,6 @@ deploy-lambdas-ekvilibro-mainnet:
4230
deploy-lambdas-dev-testnet:
4331
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage dev-testnet --region eu-central-1
4432

45-
.PHONY: deploy-lambdas-testnet
46-
deploy-lambdas-testnet:
47-
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage testnet --region eu-central-1
48-
49-
.PHONY: deploy-lambdas-testnet-hotel
50-
deploy-lambdas-testnet-hotel:
51-
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage hotel --region eu-central-1
52-
5333
.PHONY: deploy-lambdas-testnet-india
5434
deploy-lambdas-testnet-india:
5535
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage india --region eu-central-1

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,35 @@ Refer to https://github.com/HathorNetwork/rfcs/blob/master/projects/wallet-servi
77
### Local environment
88

99
#### System dependencies
10+
```
11+
Node: 22x
12+
yarn: v4 (yarn-berry)
13+
```
1014

11-
You need nodejs installed on your enviroment, we suggest the latest Active LTS version (v18.x.x).
15+
#### Install nix (preferred)
1216

13-
#### Clone the project and install dependencies
17+
For a better developer experience we suggest nix usage for managing the enviroment. Visit this [link](https://nixos.org/download/#download-nix) to download it.
1418

15-
`git clone https://github.com/HathorNetwork/hathor-wallet-service-sync_daemon.git`
19+
To enable the commands `nix develop` and `nix build` using flakes, add the following to your `/etc/nix/nix.conf` file:
20+
21+
```
22+
# see https://nixos.org/manual/nix/stable/command-ref/conf-file
23+
sandbox = true
24+
experimental-features = nix-command flakes
25+
```
1626

17-
`npm install`
27+
#### Clone the project and install dependencies
28+
```sh
29+
$ git clone https://github.com/HathorNetwork/hathor-wallet-service.git
30+
```
31+
To initialize nix dev environment:
32+
```sh
33+
$ nix develop
34+
```
35+
then, install the depencies:
36+
```sh
37+
yarn
38+
```
1839

1940
#### Add env variables or an .env file to the repository:
2041

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up(queryInterface, Sequelize) {
6+
await queryInterface.createTable('token_creation', {
7+
token_id: {
8+
type: Sequelize.STRING(64),
9+
allowNull: false,
10+
primaryKey: true,
11+
references: {
12+
model: 'token',
13+
key: 'id',
14+
},
15+
onDelete: 'CASCADE',
16+
onUpdate: 'CASCADE',
17+
},
18+
tx_id: {
19+
type: Sequelize.STRING(64),
20+
allowNull: false,
21+
comment: 'Transaction ID that created the token (regular or nano contract)',
22+
},
23+
created_at: {
24+
type: Sequelize.DATE,
25+
allowNull: false,
26+
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
27+
},
28+
});
29+
30+
// Add index on tx_id for efficient lookups when voiding transactions
31+
await queryInterface.addIndex('token_creation', ['tx_id'], {
32+
name: 'token_creation_tx_id_idx',
33+
});
34+
},
35+
36+
async down(queryInterface, Sequelize) {
37+
await queryInterface.dropTable('token_creation');
38+
},
39+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up(queryInterface, Sequelize) {
6+
await queryInterface.addColumn('token_creation', 'first_block', {
7+
type: Sequelize.STRING(64),
8+
allowNull: true,
9+
comment: 'First block hash that confirmed the nano contract execution that created this token',
10+
});
11+
12+
await queryInterface.addIndex('token_creation', ['first_block'], {
13+
name: 'token_creation_first_block_idx',
14+
});
15+
},
16+
17+
async down(queryInterface) {
18+
await queryInterface.removeIndex('token_creation', 'token_creation_first_block_idx');
19+
await queryInterface.removeColumn('token_creation', 'first_block');
20+
},
21+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
module.exports = {
4+
up: async (queryInterface) => {
5+
// Check if index exists
6+
const [indexes] = await queryInterface.sequelize.query(`
7+
SELECT COUNT(DISTINCT index_name) as count
8+
FROM information_schema.statistics
9+
WHERE table_schema = DATABASE()
10+
AND table_name = 'tx_output'
11+
AND index_name = 'idx_tx_output_locked_heightlock';
12+
`);
13+
14+
// Only create if it doesn't exist
15+
if (indexes[0].count === 0) {
16+
await queryInterface.sequelize.query(`
17+
CREATE INDEX idx_tx_output_locked_heightlock
18+
ON tx_output (locked, heightlock);
19+
`);
20+
}
21+
},
22+
23+
down: async (queryInterface) => {
24+
// Check if index exists before dropping
25+
const [indexes] = await queryInterface.sequelize.query(`
26+
SELECT COUNT(DISTINCT index_name) as count
27+
FROM information_schema.statistics
28+
WHERE table_schema = DATABASE()
29+
AND table_name = 'tx_output'
30+
AND index_name = 'idx_tx_output_locked_heightlock';
31+
`);
32+
33+
if (indexes[0].count > 0) {
34+
await queryInterface.sequelize.query(`
35+
DROP INDEX idx_tx_output_locked_heightlock ON tx_output;
36+
`);
37+
}
38+
},
39+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
module.exports = {
4+
up: async (queryInterface) => {
5+
// Check if index exists
6+
const [indexes] = await queryInterface.sequelize.query(`
7+
SELECT COUNT(DISTINCT index_name) as count
8+
FROM information_schema.statistics
9+
WHERE table_schema = DATABASE()
10+
AND table_name = 'tx_output'
11+
AND index_name = 'idx_tx_output_locked_timelock';
12+
`);
13+
14+
// Only create if it doesn't exist
15+
if (indexes[0].count === 0) {
16+
await queryInterface.sequelize.query(`
17+
CREATE INDEX idx_tx_output_locked_timelock
18+
ON tx_output (locked, timelock);
19+
`);
20+
}
21+
},
22+
23+
down: async (queryInterface) => {
24+
// Check if index exists before dropping
25+
const [indexes] = await queryInterface.sequelize.query(`
26+
SELECT COUNT(DISTINCT index_name) as count
27+
FROM information_schema.statistics
28+
WHERE table_schema = DATABASE()
29+
AND table_name = 'tx_output'
30+
AND index_name = 'idx_tx_output_locked_timelock';
31+
`);
32+
33+
if (indexes[0].count > 0) {
34+
await queryInterface.sequelize.query(`
35+
DROP INDEX idx_tx_output_locked_timelock ON tx_output;
36+
`);
37+
}
38+
},
39+
};

0 commit comments

Comments
 (0)