Skip to content

Commit 6c5b4ed

Browse files
Merge pull request #374 from HathorNetwork/master
2 parents bf61a29 + 82a94dd commit 6c5b4ed

File tree

8 files changed

+120
-336
lines changed

8 files changed

+120
-336
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

db/seeders/20250416132150-add-htr-token.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
module.exports = {
44
up: async (queryInterface) => {
5+
// Check if HTR token already exists
6+
const [existing] = await queryInterface.sequelize.query(
7+
"SELECT id FROM token WHERE id = '00'"
8+
);
9+
10+
if (existing.length > 0) {
11+
console.log('HTR token already exists, skipping.');
12+
return;
13+
}
14+
515
// Count unique transactions for HTR
616
const [results] = await queryInterface.sequelize.query(
717
"SELECT COUNT(DISTINCT tx_id) AS count FROM tx_output WHERE token_id = '00'"
@@ -14,6 +24,7 @@ module.exports = {
1424
name: 'Hathor',
1525
symbol: 'HTR',
1626
transactions: htrTxCount,
27+
version: 0, // TokenVersion.NATIVE
1728
}]);
1829
},
1930

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hathor-wallet-service",
3-
"version": "1.11.0",
3+
"version": "1.12.0",
44
"workspaces": [
55
"packages/common",
66
"packages/daemon",

packages/wallet-service/src/api/tokens.ts

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ import 'source-map-support/register';
33
import { walletIdProxyHandler } from '@src/commons';
44
import {
55
getWalletTokens,
6-
getTotalSupply,
7-
getTotalTransactions,
8-
getTokenInformation,
9-
getAuthorityUtxo,
106
} from '@src/db';
117
import {
12-
TokenInfo,
13-
} from '@src/types';
14-
import { getDbConnection } from '@src/utils';
8+
closeDbConnection,
9+
getDbConnection,
10+
} from '@src/utils';
1511
import { ApiError } from '@src/api/errors';
1612
import { closeDbAndGetError, warmupMiddleware, txIdJoiValidator } from '@src/api/utils';
13+
import fullnode from '@src/fullnode';
1714
import Joi from 'joi';
18-
import { bigIntUtils, constants } from '@hathor/wallet-lib';
1915
import middy from '@middy/core';
2016
import cors from '@middy/http-cors';
2117
import errorHandler from '@src/api/middlewares/errorHandler';
@@ -49,8 +45,9 @@ const getTokenDetailsParamsSchema = Joi.object({
4945
* Get token details
5046
*
5147
* This lambda is called by API Gateway on GET /wallet/tokens/:token_id/details
48+
* It proxies the request to the fullnode's thin_wallet/token API
5249
*/
53-
export const getTokenDetails = middy(walletIdProxyHandler(async (walletId, event) => {
50+
export const getTokenDetails = middy(walletIdProxyHandler(async (_walletId, event) => {
5451
const params = event.pathParameters || {};
5552

5653
const { value, error } = getTokenDetailsParamsSchema.validate(params, {
@@ -68,51 +65,44 @@ export const getTokenDetails = middy(walletIdProxyHandler(async (walletId, event
6865
}
6966

7067
const tokenId = value.token_id;
71-
const tokenInfo: TokenInfo = await getTokenInformation(mysql, tokenId);
7268

73-
if (tokenId === constants.NATIVE_TOKEN_UID) {
74-
const details = [{
75-
message: 'Invalid tokenId',
76-
}];
77-
78-
return closeDbAndGetError(mysql, ApiError.INVALID_PAYLOAD, { details });
79-
}
80-
81-
if (!tokenInfo) {
82-
const details = [{
83-
message: 'Token not found',
84-
}];
85-
86-
return closeDbAndGetError(mysql, ApiError.TOKEN_NOT_FOUND, { details });
87-
}
88-
89-
const [
90-
totalSupply,
91-
totalTransactions,
92-
meltAuthority,
93-
mintAuthority,
94-
] = await Promise.all([
95-
getTotalSupply(mysql, tokenId),
96-
getTotalTransactions(mysql, tokenId),
97-
getAuthorityUtxo(mysql, tokenId, Number(constants.TOKEN_MELT_MASK)),
98-
getAuthorityUtxo(mysql, tokenId, Number(constants.TOKEN_MINT_MASK)),
99-
]);
100-
101-
return {
102-
statusCode: 200,
103-
body: bigIntUtils.JSONBigInt.stringify({
104-
success: true,
105-
details: {
106-
tokenInfo,
107-
totalSupply,
108-
totalTransactions,
109-
authorities: {
110-
mint: mintAuthority !== null,
111-
melt: meltAuthority !== null,
69+
try {
70+
const data = await fullnode.getTokenDetails(tokenId);
71+
72+
if (!data?.success) {
73+
return {
74+
statusCode: 404,
75+
body: JSON.stringify({
76+
success: false,
77+
error: ApiError.TOKEN_NOT_FOUND,
78+
details: [{ message: 'Token not found' }],
79+
}),
80+
};
81+
}
82+
83+
return {
84+
statusCode: 200,
85+
body: JSON.stringify({
86+
success: true,
87+
details: {
88+
tokenInfo: {
89+
id: tokenId,
90+
name: data.name,
91+
symbol: data.symbol,
92+
version: data.version,
93+
},
94+
totalSupply: data.total,
95+
totalTransactions: data.transactions_count,
96+
authorities: {
97+
mint: data.can_mint,
98+
melt: data.can_melt,
99+
},
112100
},
113-
},
114-
}),
115-
};
101+
}),
102+
};
103+
} finally {
104+
await closeDbConnection(mysql);
105+
}
116106
})).use(cors())
117107
.use(warmupMiddleware())
118108
.use(errorHandler());

packages/wallet-service/src/fullnode.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ export const create = (baseURL = BASE_URL) => {
118118
return response.data;
119119
}
120120

121+
const getTokenDetails = async (tokenId: string) => {
122+
const response = await api.get('thin_wallet/token', {
123+
data: null,
124+
params: { id: tokenId },
125+
headers: { 'content-type': 'application/json' },
126+
});
127+
128+
return response.data;
129+
}
130+
121131
return {
122132
api, // exported so we can mock it on the tests
123133
version,
@@ -129,6 +139,7 @@ export const create = (baseURL = BASE_URL) => {
129139
getNCState,
130140
getNCHistory,
131141
getNCBlueprintInfo,
142+
getTokenDetails,
132143
};
133144
};
134145

0 commit comments

Comments
 (0)