|
|
@@ -104,10 +104,10 @@ export class LpMaintenance {
|
|
|
async checkTokenByAddress(tokenAddress: any, newType: string) {
|
|
|
const tokenDbOBj = this.tokenAssembly[tokenAddress]
|
|
|
|
|
|
- if (this.needUpdate(tokenDbOBj.type, tokenDbOBj.type)) {
|
|
|
+ if (tokenDbOBj && this.needUpdate(tokenDbOBj.type, newType)) {
|
|
|
+ logger.debug(`token:${tokenAddress},${tokenDbOBj.type}->${newType}.`)
|
|
|
tokenDbOBj.type = newType
|
|
|
await History.appendOrUpdate(tokenDbOBj.type, tokenDbOBj.hash, tokenDbOBj.data)
|
|
|
- logger.debug(`token:${tokenAddress},${tokenDbOBj.type}->${tokenDbOBj.type}.`)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -209,22 +209,26 @@ export class LpMaintenance {
|
|
|
|
|
|
if (!this.tokenAssembly[lp.token0]) {
|
|
|
const token0Rst = await History.findByHash(lp.token0)
|
|
|
- const token0DbObj = token0Rst.data
|
|
|
+ const token0DbObj = token0Rst.data[0]
|
|
|
|
|
|
- this.tokenAssembly[lp.token0] = {
|
|
|
- type: token0DbObj.block,
|
|
|
- hash: token0DbObj.hash,
|
|
|
- data: token0DbObj.dataObj
|
|
|
+ if (token0DbObj) {
|
|
|
+ this.tokenAssembly[lp.token0] = {
|
|
|
+ type: token0DbObj.block,
|
|
|
+ hash: token0DbObj.hash,
|
|
|
+ data: JSON.parse(token0DbObj.data)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (!this.tokenAssembly[lp.token1]) {
|
|
|
const token1Rst = await History.findByHash(lp.token1)
|
|
|
- const token1DbObj = token1Rst.data
|
|
|
+ const token1DbObj = token1Rst.data[0]
|
|
|
|
|
|
- this.tokenAssembly[lp.token1] = {
|
|
|
- type: token1DbObj.block,
|
|
|
- hash: token1DbObj.hash,
|
|
|
- data: token1DbObj.dataObj
|
|
|
+ if (token1DbObj) {
|
|
|
+ this.tokenAssembly[lp.token1] = {
|
|
|
+ type: token1DbObj.block,
|
|
|
+ hash: token1DbObj.hash,
|
|
|
+ data: JSON.parse(token1DbObj.data)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|