Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { In, MigrationInterface, QueryRunner } from "typeorm";
import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils'
import { ScriptHashType } from "models/chain/script";
import Output from "../entities/output";

export class UpdateOutputChequeLockHash1652945662504 implements MigrationInterface {
name = 'UpdateOutputChequeLockHash1652945662504'

public async up(queryRunner: QueryRunner): Promise<any> {
const errLockHash = [
scriptToHash({
args: '0x' + '0'.repeat(80),
codeHash: process.env.TESTNET_CHEQUE_SCRIPT_CODEHASH!,
hashType: process.env.TESTNET_CHEQUE_SCRIPT_HASHTYPE! as ScriptHashType
}),
scriptToHash({
args: '0x' + '0'.repeat(80),
codeHash: process.env.MAINNET_CHEQUE_SCRIPT_CODEHASH!,
hashType: process.env.MAINNET_CHEQUE_SCRIPT_HASHTYPE! as ScriptHashType
})
]
const chequeOutput = await queryRunner.connection
.getRepository(Output)
.createQueryBuilder('output')
.where({ lockHash: In(errLockHash) })
.getMany()
const updated = chequeOutput.map(output => {
output.lockHash = scriptToHash({
args: output.lockArgs,
hashType: output.lockHashType,
codeHash: output.lockCodeHash
})
return output
})
await queryRunner.manager.save(updated)
}

public async down(): Promise<void> {
// do nothing
}

}
2 changes: 2 additions & 0 deletions packages/neuron-wallet/src/database/chain/ormconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { AddMultisigConfig1646817547204 } from './migrations/1646817547204-AddMu
import { AddMultisigOutput1649729996969 } from './migrations/1649729996969-AddMultisigOutput'
import { UpdateAddressDescription1650984779265 } from './migrations/1650984779265-UpdateAddressDescription'
import { RemoveDuplicateBlake160s1651133703535 } from './migrations/1651133703535-RemoveDuplicateBlake160s'
import { UpdateOutputChequeLockHash1652945662504 } from './migrations/1652945662504-UpdateOutputChequeLockHash'
import { RemoveAddressesMultisigConfig1651820157100 } from './migrations/1651820157100-RemoveAddressesMultisigConfig'

export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError'
Expand Down Expand Up @@ -109,6 +110,7 @@ const connectOptions = async (genesisBlockHash: string): Promise<SqliteConnectio
AddMultisigOutput1649729996969,
UpdateAddressDescription1650984779265,
RemoveDuplicateBlake160s1651133703535,
UpdateOutputChequeLockHash1652945662504,
RemoveAddressesMultisigConfig1651820157100
],
logger: 'simple-console',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,8 @@ export class TransactionGenerator {

const chequeCell = Output.fromObject({
...chequeCellTmp,
// recreate lockHash
lockHash: undefined,
data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
lock: assetAccountInfo.generateChequeScript(
receiverLockScript.computeHash(),
Expand Down