diff --git a/packages/neuron-wallet/src/services/cells.ts b/packages/neuron-wallet/src/services/cells.ts index 666ea6d7a9..8af295d2eb 100644 --- a/packages/neuron-wallet/src/services/cells.ts +++ b/packages/neuron-wallet/src/services/cells.ts @@ -10,12 +10,15 @@ export const MIN_CELL_CAPACITY = '6100000000' /* eslint no-await-in-loop: "warn" */ /* eslint no-restricted-syntax: "warn" */ export default class CellsService { + // exclude hasData = true and typeScript != null public static getBalance = async (lockHashes: string[], status: OutputStatus): Promise => { const cells: OutputEntity[] = await getConnection() .getRepository(OutputEntity) .find({ where: { lockHash: In(lockHashes), + hasData: false, + typeScript: null, status, }, }) diff --git a/packages/neuron-wallet/src/services/tx/transaction-persistor.ts b/packages/neuron-wallet/src/services/tx/transaction-persistor.ts index 0508fe0b77..e0e5e8f4fa 100644 --- a/packages/neuron-wallet/src/services/tx/transaction-persistor.ts +++ b/packages/neuron-wallet/src/services/tx/transaction-persistor.ts @@ -133,6 +133,7 @@ export class TransactionPersistor { } } + const outputsData = transaction.outputsData! const outputs: OutputEntity[] = await Promise.all( transaction.outputs!.map(async (o, index) => { const output = new OutputEntity() @@ -143,6 +144,15 @@ export class TransactionPersistor { output.lockHash = o.lockHash! output.transaction = tx output.status = outputStatus + if (o.type) { + output.typeScript = o.type + } + const data = outputsData[index] + if (data && data !== '0x') { + output.hasData = true + } else { + output.hasData = false + } return output }) ) diff --git a/packages/neuron-wallet/src/types/type-convert.ts b/packages/neuron-wallet/src/types/type-convert.ts index 7512600cdb..35b382b07a 100644 --- a/packages/neuron-wallet/src/types/type-convert.ts +++ b/packages/neuron-wallet/src/types/type-convert.ts @@ -41,6 +41,7 @@ export default class TypeConvert { witnesses: transaction.witnesses, inputs: transaction.inputs.map(input => TypeConvert.toInput(input)), outputs: transaction.outputs.map(output => TypeConvert.toOutput(output)), + outputsData: transaction.outputsData, } if (blockHeader) { tx.timestamp = blockHeader.timestamp @@ -72,9 +73,14 @@ export default class TypeConvert { } static toOutput(output: CKBComponents.CellOutput): Cell { + let type: Script | undefined + if (output.type) { + type = TypeConvert.toScript(output.type) + } return { capacity: output.capacity.toString(), lock: TypeConvert.toScript(output.lock), + type, } }