Skip to content

Commit

Permalink
delete ;
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Mar 2, 2022
1 parent b8da57f commit cbe3765
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions packages/ckb-sdk-core/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ describe('ckb', () => {
.mockResolvedValueOnce({ dao: '0x9bafffa73e432e3c94c6f9db34cb25009f9e4efe4b5fd60200ea63c6d4ffb407' })
}
const res = await ckb.calculateDaoMaximumWithdraw({ tx: '', index: '0x0' }, '')
expect(res).toBe('1000183501854');
ckb.rpc = rpc;
expect(res).toBe('1000183501854')
ckb.rpc = rpc
})
it('another normal withdraw hash', async () => {
ckb.rpc = {
Expand Down Expand Up @@ -249,8 +249,8 @@ describe('ckb', () => {
.mockResolvedValueOnce({ dao: '0xd87090655733433c2395d67a64ce2500d73e963e54ccda0200f244c504a4b707' })
}
const res = await ckb.calculateDaoMaximumWithdraw({index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691')
expect(res).toBe('30000000155');
ckb.rpc = rpc;
expect(res).toBe('30000000155')
ckb.rpc = rpc
})
it('normal withdraw outputpoint', async () => {
ckb.rpc = {
Expand Down Expand Up @@ -292,15 +292,15 @@ describe('ckb', () => {
.mockResolvedValueOnce({ dao: '0xd87090655733433c2395d67a64ce2500d73e963e54ccda0200f244c504a4b707' })
}
const res = await ckb.calculateDaoMaximumWithdraw({index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691')
expect(res).toBe('30000000155');
ckb.rpc = rpc;
expect(res).toBe('30000000155')
ckb.rpc = rpc
})
it('exception', async () => {
ckb.rpc = {
getTransaction: jest.fn().mockResolvedValueOnce({ txStatus: {}})
}
await expect(ckb.calculateDaoMaximumWithdraw({ tx: '', index: '0x0' }, '')).rejects.toThrow('Transaction is not committed yet')
ckb.rpc = rpc;
ckb.rpc = rpc
})
})
})
14 changes: 7 additions & 7 deletions packages/ckb-sdk-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,17 @@ class CKB {
let tx = await this.rpc.getTransaction(depositOutPoint.txHash)
if (tx.txStatus.status !== 'committed') throw new Error('Transaction is not committed yet')
const depositBlockHash = tx.txStatus.blockHash
let celloutput = tx.transaction.outputs[+depositOutPoint.index];
let celloutputData = tx.transaction.outputsData[+depositOutPoint.index];
let withdrawBlockHash: CKBComponents.Hash;
let celloutput = tx.transaction.outputs[+depositOutPoint.index]
let celloutputData = tx.transaction.outputsData[+depositOutPoint.index]
let withdrawBlockHash: CKBComponents.Hash
if (typeof withdraw === 'string') {
withdrawBlockHash = withdraw
} else {
tx = await this.rpc.getTransaction(withdraw.txHash);
tx = await this.rpc.getTransaction(withdraw.txHash)
if (tx.txStatus.status !== 'committed') throw new Error('Transaction is not committed yet')
withdrawBlockHash = tx.txStatus.blockHash;
celloutput = tx.transaction.outputs[+withdraw.index];
celloutputData = tx.transaction.outputsData[+withdraw.index];
withdrawBlockHash = tx.txStatus.blockHash
celloutput = tx.transaction.outputs[+withdraw.index]
celloutputData = tx.transaction.outputsData[+withdraw.index]
}
const [depositHeader, withDrawHeader] = await Promise.all([
this.rpc.getHeader(depositBlockHash),
Expand Down
12 changes: 6 additions & 6 deletions packages/ckb-sdk-utils/__tests__/utils/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('calculate-maximum-withdraw', () => {
"codeHash":"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
"hashType":"type"
}
};
}
expect(
calculateMaximumWithdraw(
outputCell,
Expand All @@ -107,9 +107,9 @@ describe('calculate-maximum-withdraw', () => {
})

describe('extract header dao', () => {
const DAOData = extractDAOData('0x1aaf2ca6847c223c3ef9e8c069c9250020212a6311e2d30200609349396eb407');
expect(DAOData.c).toBe('0x3c227c84a62caf1a');
expect(DAOData.ar).toBe('0x0025c969c0e8f93e');
expect(DAOData.s).toBe('0x02d3e211632a2120');
expect(DAOData.u).toBe('0x07b46e3949936000');
const DAOData = extractDAOData('0x1aaf2ca6847c223c3ef9e8c069c9250020212a6311e2d30200609349396eb407')
expect(DAOData.c).toBe('0x3c227c84a62caf1a')
expect(DAOData.ar).toBe('0x0025c969c0e8f93e')
expect(DAOData.s).toBe('0x02d3e211632a2120')
expect(DAOData.u).toBe('0x07b46e3949936000')
})
16 changes: 8 additions & 8 deletions packages/ckb-sdk-utils/__tests__/utils/occupiedCapacity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ describe('script occupied', () => {
args: '0x',
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
hashType: 'type'
});
expect(occupied).toBe(33);
})
expect(occupied).toBe(33)
})
it('with args', () => {
const occupied = scriptOccupied({
args: '0x00ffee',
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
hashType: 'type'
});
expect(occupied).toBe(36);
})
expect(occupied).toBe(36)
})
})

Expand All @@ -29,8 +29,8 @@ describe('cell occupied', () => {
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
hashType: 'type'
},
});
expect(occupied).toBe(41);
})
expect(occupied).toBe(41)
})
it('with type', () => {
const occupied = cellOccupied({
Expand All @@ -45,7 +45,7 @@ describe('cell occupied', () => {
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
hashType: 'type'
}
});
expect(occupied).toBe(76);
})
expect(occupied).toBe(76)
})
})

0 comments on commit cbe3765

Please sign in to comment.