|
1 | 1 | import { Subject, Subscription } from 'rxjs' |
| 2 | +import { AddressPrefix } from '@nervosnetwork/ckb-sdk-utils' |
2 | 3 | import Utils from 'services/sync/utils' |
3 | 4 | import logger from 'utils/logger' |
4 | 5 | import GetBlocks from 'services/sync/get-blocks' |
| 6 | +import NetworksService from 'services/networks' |
5 | 7 | import { Transaction, TransactionWithStatus } from 'types/cell-types' |
6 | 8 | import TypeConvert from 'types/type-convert' |
7 | 9 | import BlockNumber from 'services/sync/block-number' |
@@ -211,7 +213,10 @@ export default class IndexerQueue { |
211 | 213 | blockHash: transactionWithStatus.txStatus.blockHash! |
212 | 214 | } |
213 | 215 | if (type === TxPointType.CreatedBy && this.latestCreatedBy.includes(txUniqueFlag)) { |
214 | | - const address = LockUtils.lockScriptToAddress(transaction.outputs![parseInt(txPoint.index, 16)].lock) |
| 216 | + const address = LockUtils.lockScriptToAddress( |
| 217 | + transaction.outputs![parseInt(txPoint.index, 16)].lock, |
| 218 | + NetworksService.getInstance().isMainnet ? AddressPrefix.Mainnet : AddressPrefix.Testnet |
| 219 | + ) |
215 | 220 | AddressesUsedSubject.getSubject().next({ |
216 | 221 | addresses: [address], |
217 | 222 | url: this.url, |
@@ -273,13 +278,19 @@ export default class IndexerQueue { |
273 | 278 |
|
274 | 279 | let address: string | undefined |
275 | 280 | if (type === TxPointType.CreatedBy) { |
276 | | - address = LockUtils.lockScriptToAddress(transaction.outputs![parseInt(txPoint.index, 16)].lock) |
| 281 | + address = LockUtils.lockScriptToAddress( |
| 282 | + transaction.outputs![parseInt(txPoint.index, 16)].lock, |
| 283 | + NetworksService.getInstance().isMainnet ? AddressPrefix.Mainnet : AddressPrefix.Testnet |
| 284 | + ) |
277 | 285 | this.latestCreatedBy.push(txUniqueFlag) |
278 | 286 | } else if (type === TxPointType.ConsumedBy) { |
279 | 287 | const input = txEntity.inputs[parseInt(txPoint.index, 16)] |
280 | 288 | const output = await IndexerTransaction.updateInputLockHash(input.outPointTxHash!, input.outPointIndex!) |
281 | 289 | if (output) { |
282 | | - address = LockUtils.lockScriptToAddress(output.lock) |
| 290 | + address = LockUtils.lockScriptToAddress( |
| 291 | + output.lock, |
| 292 | + NetworksService.getInstance().isMainnet ? AddressPrefix.Mainnet : AddressPrefix.Testnet |
| 293 | + ) |
283 | 294 | } |
284 | 295 | } |
285 | 296 | if (address) { |
|
0 commit comments