@@ -39,6 +39,7 @@ import {
39
39
TxByIdToken ,
40
40
PushDeviceSettings ,
41
41
FullNodeApiVersionResponse ,
42
+ TxInfo ,
42
43
} from '@src/types' ;
43
44
import {
44
45
getUnixTimestamp ,
@@ -426,7 +427,7 @@ export const getWalletAddressDetail = async (mysql: ServerlessMysql, walletId: s
426
427
FROM \`address\`
427
428
WHERE \`wallet_id\` = ?
428
429
AND \`address\` = ?` ,
429
- [ walletId , address ] ) ;
430
+ [ walletId , address ] ) ;
430
431
431
432
if ( results . length > 0 ) {
432
433
const data = results [ 0 ] ;
@@ -1160,12 +1161,12 @@ export const updateAddressLockedBalance = async (
1160
1161
\`unlocked_authorities\` = (unlocked_authorities | ?)
1161
1162
WHERE \`address\` = ?
1162
1163
AND \`token_id\` = ?` , [
1163
- tokenBalance . unlockedAmount ,
1164
- tokenBalance . unlockedAmount ,
1165
- tokenBalance . unlockedAuthorities . toInteger ( ) ,
1166
- address ,
1167
- token ,
1168
- ] ,
1164
+ tokenBalance . unlockedAmount ,
1165
+ tokenBalance . unlockedAmount ,
1166
+ tokenBalance . unlockedAuthorities . toInteger ( ) ,
1167
+ address ,
1168
+ token ,
1169
+ ] ,
1169
1170
) ;
1170
1171
1171
1172
// if any authority has been unlocked, we have to refresh the locked authorities
@@ -1201,7 +1202,7 @@ export const updateAddressLockedBalance = async (
1201
1202
)
1202
1203
WHERE \`address\` = ?
1203
1204
AND \`token_id\` = ?` ,
1204
- [ address , token , address , token ] ) ;
1205
+ [ address , token , address , token ] ) ;
1205
1206
}
1206
1207
}
1207
1208
}
@@ -1233,7 +1234,7 @@ export const updateWalletLockedBalance = async (
1233
1234
WHERE \`wallet_id\` = ?
1234
1235
AND \`token_id\` = ?` ,
1235
1236
[ tokenBalance . unlockedAmount , tokenBalance . unlockedAmount ,
1236
- tokenBalance . unlockedAuthorities . toInteger ( ) , walletId , token ] ,
1237
+ tokenBalance . unlockedAuthorities . toInteger ( ) , walletId , token ] ,
1237
1238
) ;
1238
1239
1239
1240
// if any authority has been unlocked, we have to refresh the locked authorities
@@ -1418,7 +1419,7 @@ export const getWalletTokens = async (
1418
1419
) ;
1419
1420
1420
1421
for ( const result of results ) {
1421
- tokenList . push ( < string > result . token_id ) ;
1422
+ tokenList . push ( < string > result . token_id ) ;
1422
1423
}
1423
1424
1424
1425
return tokenList ;
@@ -1464,7 +1465,7 @@ LEFT OUTER JOIN transaction ON transaction.tx_id = wallet_tx_history.tx_id
1464
1465
ORDER BY wallet_tx_history.timestamp
1465
1466
DESC
1466
1467
LIMIT ?, ?` ,
1467
- [ walletId , tokenId , skip , count ] ) ;
1468
+ [ walletId , tokenId , skip , count ] ) ;
1468
1469
1469
1470
for ( const result of results ) {
1470
1471
const tx : TxTokenBalance = {
@@ -2080,7 +2081,7 @@ export const markUtxosAsVoided = async (
2080
2081
UPDATE \`tx_output\`
2081
2082
SET \`voided\` = TRUE
2082
2083
WHERE \`tx_id\` IN (?)` ,
2083
- [ txIds ] ) ;
2084
+ [ txIds ] ) ;
2084
2085
} ;
2085
2086
2086
2087
/**
@@ -2818,15 +2819,15 @@ export const existsPushDevice = async (
2818
2819
mysql : ServerlessMysql ,
2819
2820
deviceId : string ,
2820
2821
walletId : string ,
2821
- ) : Promise < boolean > => {
2822
+ ) : Promise < boolean > => {
2822
2823
const [ { count } ] = await mysql . query (
2823
2824
`
2824
2825
SELECT COUNT(1) as \`count\`
2825
2826
FROM \`push_devices\` pd
2826
2827
WHERE device_id = ?
2827
2828
AND wallet_id = ?` ,
2828
2829
[ deviceId , walletId ] ,
2829
- ) as unknown as Array < { count } > ;
2830
+ ) as unknown as Array < { count } > ;
2830
2831
2831
2832
return count > 0 ;
2832
2833
} ;
@@ -2846,7 +2847,7 @@ export const registerPushDevice = async (
2846
2847
enablePush : boolean ,
2847
2848
enableShowAmounts : boolean ,
2848
2849
} ,
2849
- ) : Promise < void > => {
2850
+ ) : Promise < void > => {
2850
2851
await mysql . query (
2851
2852
`
2852
2853
INSERT
@@ -2895,7 +2896,7 @@ export const updatePushDevice = async (
2895
2896
enablePush : boolean ,
2896
2897
enableShowAmounts : boolean ,
2897
2898
} ,
2898
- ) : Promise < void > => {
2899
+ ) : Promise < void > => {
2899
2900
await mysql . query (
2900
2901
`
2901
2902
UPDATE \`push_devices\`
@@ -2918,7 +2919,7 @@ export const unregisterPushDevice = async (
2918
2919
mysql : ServerlessMysql ,
2919
2920
deviceId : string ,
2920
2921
walletId ?: string ,
2921
- ) : Promise < void > => {
2922
+ ) : Promise < void > => {
2922
2923
if ( walletId ) {
2923
2924
await mysql . query (
2924
2925
`
@@ -2952,39 +2953,40 @@ export const getTransactionById = async (
2952
2953
txId : string ,
2953
2954
walletId : string ,
2954
2955
) : Promise < TxByIdToken [ ] > => {
2955
- const result = await mysql . query ( `
2956
+ const result = await mysql . query < TxByIdToken [ ] > ( `
2956
2957
SELECT
2957
- transaction.tx_id AS tx_id
2958
+ transaction.tx_id AS txId
2958
2959
, transaction.timestamp AS timestamp
2959
2960
, transaction.version AS version
2960
2961
, transaction.voided AS voided
2961
2962
, transaction.height AS height
2962
2963
, transaction.weight AS weight
2963
2964
, wallet_tx_history.balance AS balance
2964
- , wallet_tx_history.token_id AS token_id
2965
- , token.name AS name
2966
- , token.symbol AS symbol
2965
+ , wallet_tx_history.token_id AS tokenId
2966
+ , token.name AS tokenName
2967
+ , token.symbol AS tokenSymbol
2967
2968
FROM wallet_tx_history
2968
- INNER JOIN transaction ON transaction.tx_id = wallet_tx_history.tx_id
2969
+ INNER JOIN transaction ON transaction.tx_id = wallet_tx_history.txId
2969
2970
INNER JOIN token ON wallet_tx_history.token_id = token.id
2970
2971
WHERE transaction.tx_id = ?
2971
2972
AND transaction.voided = FALSE
2972
2973
AND wallet_tx_history.wallet_id = ?` ,
2973
- // eslint-disable-next-line camelcase
2974
- [ txId , walletId ] ) as Array < { tx_id , timestamp , version , voided , weight , balance , token_id , name , symbol } > ;
2974
+ // eslint-disable-next-line camelcase
2975
+ [ txId , walletId ] ) ;
2975
2976
2976
2977
const txTokens = [ ] ;
2977
2978
result . forEach ( ( eachTxToken ) => {
2978
2979
const txToken = {
2979
- txId : eachTxToken . tx_id ,
2980
+ txId : eachTxToken . txId ,
2980
2981
timestamp : eachTxToken . timestamp ,
2981
2982
version : eachTxToken . version ,
2982
2983
voided : ! ! eachTxToken . voided ,
2983
2984
weight : eachTxToken . weight ,
2985
+ height : eachTxToken . height ,
2984
2986
balance : eachTxToken . balance ,
2985
- tokenId : eachTxToken . token_id ,
2986
- tokenName : eachTxToken . name ,
2987
- tokenSymbol : eachTxToken . symbol ,
2987
+ tokenId : eachTxToken . tokenId ,
2988
+ tokenName : eachTxToken . tokenName ,
2989
+ tokenSymbol : eachTxToken . tokenSymbol ,
2988
2990
} as TxByIdToken ;
2989
2991
txTokens . push ( txToken ) ;
2990
2992
} ) ;
@@ -3001,7 +3003,7 @@ export const getTransactionById = async (
3001
3003
export const existsWallet = async (
3002
3004
mysql : ServerlessMysql ,
3003
3005
walletId : string ,
3004
- ) : Promise < boolean > => {
3006
+ ) : Promise < boolean > => {
3005
3007
const [ { count } ] = ( await mysql . query (
3006
3008
`
3007
3009
SELECT COUNT(1) as \`count\`
@@ -3022,15 +3024,15 @@ export const existsWallet = async (
3022
3024
export const getPushDevice = async (
3023
3025
mysql : ServerlessMysql ,
3024
3026
deviceId : string ,
3025
- ) : Promise < PushDevice | null > => {
3027
+ ) : Promise < PushDevice | null > => {
3026
3028
const [ pushDevice ] = await mysql . query (
3027
3029
`
3028
3030
SELECT *
3029
3031
FROM \`push_devices\`
3030
3032
WHERE device_id = ?` ,
3031
3033
[ deviceId ] ,
3032
- // eslint-disable-next-line camelcase
3033
- ) as Array < { wallet_id , device_id , push_provider , enable_push , enable_show_amounts } > ;
3034
+ // eslint-disable-next-line camelcase
3035
+ ) as Array < { wallet_id , device_id , push_provider , enable_push , enable_show_amounts } > ;
3034
3036
3035
3037
if ( ! pushDevice ) {
3036
3038
return null ;
@@ -3055,7 +3057,7 @@ export const getPushDevice = async (
3055
3057
export const getPushDeviceSettingsList = async (
3056
3058
mysql : ServerlessMysql ,
3057
3059
walletIdList : string [ ] ,
3058
- ) : Promise < PushDeviceSettings [ ] > => {
3060
+ ) : Promise < PushDeviceSettings [ ] > => {
3059
3061
const pushDeviceSettingsResult = await mysql . query (
3060
3062
`
3061
3063
SELECT wallet_id
@@ -3065,8 +3067,8 @@ export const getPushDeviceSettingsList = async (
3065
3067
FROM \`push_devices\`
3066
3068
WHERE wallet_id in (?)` ,
3067
3069
[ walletIdList ] ,
3068
- // eslint-disable-next-line camelcase
3069
- ) as Array < { wallet_id , device_id , enable_push , enable_show_amounts } > ;
3070
+ // eslint-disable-next-line camelcase
3071
+ ) as Array < { wallet_id , device_id , enable_push , enable_show_amounts } > ;
3070
3072
3071
3073
const pushDeviceSettignsList = pushDeviceSettingsResult . map ( ( each ) => ( {
3072
3074
walletId : each . wallet_id ,
@@ -3127,7 +3129,7 @@ export const getTokenSymbols = async (
3127
3129
) ;
3128
3130
3129
3131
if ( results . length === 0 ) return null ;
3130
- return results . reduce ( ( prev : Record < string , string > , token : { id : string , symbol : string } ) => {
3132
+ return results . reduce ( ( prev : Record < string , string > , token : { id : string , symbol : string } ) => {
3131
3133
// eslint-disable-next-line no-param-reassign
3132
3134
prev [ token . id ] = token . symbol ;
3133
3135
return prev ;
0 commit comments