Skip to content

Commit

Permalink
fixed CPoolSwap not to use bigint to parse (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Apr 28, 2021
1 parent 4569f64 commit ac72093
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/jellyfish-transaction/src/script/defi/dftx_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BufferComposer, ComposableBuffer } from '../../buffer/buffer_composer'
import { Script } from '../../tx'
import { CScript } from '../../tx_composer'
import { SmartBuffer } from 'smart-buffer'
import { readBigNumberUInt64, writeBigNumberUInt64 } from '../../buffer/buffer_bignumber'

// Disabling no-return-assign makes the code cleaner with the setter and getter */
/* eslint-disable no-return-assign */
Expand Down Expand Up @@ -39,14 +40,14 @@ export class CPoolSwap extends ComposableBuffer<PoolSwap> {
ComposableBuffer.varUInt(() => ps.toTokenId, v => ps.toTokenId = v),
{
fromBuffer (buffer: SmartBuffer) {
const integer = new BigNumber(buffer.readBigUInt64LE().toString())
const fraction = new BigNumber(buffer.readBigUInt64LE().toString())
const integer = readBigNumberUInt64(buffer)
const fraction = readBigNumberUInt64(buffer)
ps.maxPrice = { integer, fraction }
},
toBuffer (buffer: SmartBuffer) {
const { integer, fraction } = ps.maxPrice
buffer.writeBigUInt64LE(BigInt(integer.toString(10)))
buffer.writeBigUInt64LE(BigInt(fraction.toString(10)))
writeBigNumberUInt64(integer, buffer)
writeBigNumberUInt64(fraction, buffer)
}
}
]
Expand Down

0 comments on commit ac72093

Please sign in to comment.