Skip to content

Commit

Permalink
Merge branch 'fix-multisig' of https://github.com/yanguoyu/neuron int…
Browse files Browse the repository at this point in the history
…o fix-multisig
  • Loading branch information
yanguoyu committed Jan 17, 2024
2 parents 1b6598c + c7c9555 commit 57d0150
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .ckb-light-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.4
v0.3.5
2 changes: 1 addition & 1 deletion packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@ckb-lumos/rpc": "0.21.1",
"@iarna/toml": "2.2.5",
"@ledgerhq/hw-transport-node-hid": "6.27.22",
"@spore-sdk/core": "0.1.0-beta.9",
"@spore-sdk/core": "0.1.0-beta.14",
"archiver": "6.0.1",
"async": "3.2.5",
"bn.js": "4.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ export default class IndexerCacheService {
continue
}

for (const { lockHash, address } of mappings) {
for (const { lockHash } of mappings) {
indexerCaches.push(
IndexerTxHashCache.fromObject({
txHash: transaction.hash!,
blockNumber: parseInt(transaction.blockNumber!),
lockHash,
address,
walletId: this.walletId,
})
)
Expand Down Expand Up @@ -267,7 +266,6 @@ export default class IndexerCacheService {
txHash: v.txHash,
blockNumber: parseInt(v.blockNumber!),
lockHash: v.lockHash,
address: v.address,
walletId: v.walletId,
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ export default class IndexerTxHashCache extends BaseEntity {
@Index()
lockHash!: string

@Column({
type: 'character',
length: 32,
})
@Index()
address!: string

@Column({
type: 'character',
length: 32,
Expand Down Expand Up @@ -54,12 +47,11 @@ export default class IndexerTxHashCache extends BaseEntity {
})
updatedAt!: Date

static fromObject(obj: { txHash: string; blockNumber: number; lockHash: string; address: string; walletId: string }) {
static fromObject(obj: { txHash: string; blockNumber: number; lockHash: string; walletId: string }) {
const result = new IndexerTxHashCache()
result.txHash = obj.txHash
result.blockNumber = obj.blockNumber
result.lockHash = obj.lockHash
result.address = obj.address
result.walletId = obj.walletId
result.isProcessed = false
return result
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {MigrationInterface, QueryRunner, TableColumn} from "typeorm";

export class RemoveAddressInIndexerCache1704357651876 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('indexer_tx_hash_cache', 'address')
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.addColumn('indexer_tx_hash_cache', new TableColumn({
name: 'address',
type: 'character(32)',
isNullable: false,
}))
}

}
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 @@ -59,6 +59,7 @@ import { TxLockAddArgs1694746034975 } from './migrations/1694746034975-TxLockAdd
import { IndexerTxHashCacheRemoveField1701234043431 } from './migrations/1701234043431-IndexerTxHashCacheRemoveField'
import { CreateCellLocalInfo1701234043432 } from './migrations/1701234043432-CreateCellLocalInfo'
import { RenameSyncProgress1702781527414 } from './migrations/1702781527414-RenameSyncProgress'
import { RemoveAddressInIndexerCache1704357651876 } from './migrations/1704357651876-RemoveAddressInIndexerCache'

export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError'

Expand Down Expand Up @@ -134,6 +135,7 @@ const connectOptions = async (genesisBlockHash: string): Promise<SqliteConnectio
IndexerTxHashCacheRemoveField1701234043431,
CreateCellLocalInfo1701234043432,
RenameSyncProgress1702781527414,
RemoveAddressInIndexerCache1704357651876,
],
logger: 'simple-console',
logging,
Expand Down
7 changes: 2 additions & 5 deletions packages/neuron-wallet/src/services/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import MultisigConfigModel from '../models/multisig-config'
import MultisigOutput from '../database/chain/entities/multisig-output'
import { bytes } from '@ckb-lumos/codec'
import { generateRPC } from '../utils/ckb-rpc'
import { getClusterCellById, SporeData, unpackToRawClusterData } from '@spore-sdk/core'
import { getClusterById, SporeData, unpackToRawClusterData } from '@spore-sdk/core'
import NetworksService from './networks'
import { LOCKTIME_ARGS_LENGTH, MIN_CELL_CAPACITY } from '../utils/const'
import HdPublicKeyInfo from '../database/chain/entities/hd-public-key-info'
Expand Down Expand Up @@ -383,10 +383,7 @@ export default class CellsService {
return
}

const clusterCell = await getClusterCellById(
clusterId,
assetAccountInfo.getSporeConfig(currentNetwork.remote)
)
const clusterCell = await getClusterById(clusterId, assetAccountInfo.getSporeConfig(currentNetwork.remote))
const { name, description } = unpackToRawClusterData(clusterCell.data)
clusterInfos[clusterId] = { name, description }
} catch {
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import NetworksService from './networks'
import { generateRPC } from '../utils/ckb-rpc'
import CellsService from './cells'
import hd from '@ckb-lumos/hd'
import { getClusterCellByOutPoint } from '@spore-sdk/core'
import { getClusterByOutPoint } from '@spore-sdk/core'
import CellDep, { DepType } from '../models/chain/cell-dep'
import { dao } from '@ckb-lumos/common-scripts'

Expand Down Expand Up @@ -606,7 +606,7 @@ export default class TransactionSender {

// https://github.com/sporeprotocol/spore-sdk/blob/05f2cbe1c03d03e334ebd3b440b5b3b20ec67da7/packages/core/src/api/joints/spore.ts#L154-L158
const clusterDep = await (async () => {
const clusterCell = await getClusterCellByOutPoint(outPoint, assetAccountInfo.getSporeConfig(rpcUrl)).then(
const clusterCell = await getClusterByOutPoint(outPoint, assetAccountInfo.getSporeConfig(rpcUrl)).then(
_ => _,
() => undefined
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ describe('unit tests for IndexerConnector', () => {
txHash: 'hash1',
blockNumber: 10,
lockHash: script.computeHash(),
address,
walletId,
}),
]
Expand All @@ -165,7 +164,6 @@ describe('unit tests for IndexerConnector', () => {
txHash: 'hash2',
blockNumber: 2,
lockHash: script.computeHash(),
address,
walletId,
}),
]
Expand Down
Loading

0 comments on commit 57d0150

Please sign in to comment.