Skip to content

Commit

Permalink
Merge pull request #15 from nervina-labs/develop
Browse files Browse the repository at this point in the history
Release v0.2.10
  • Loading branch information
duanyytop authored Mar 25, 2024
2 parents 24c2bb0 + d615e19 commit a3c7fdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervina-labs/ckb-dex",
"version": "0.2.9",
"version": "0.2.10",
"description": "The JavaScript SDK for CKB DEX",
"author": "duanyytop <duanyytop@gmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/order/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { serializeScript } from '@nervosnetwork/ckb-sdk-utils'

// minimum occupied capacity and 1 ckb for transaction fee
// assume UDT cell data size is 16bytes
export const calculateUdtCellCapacity = (lock: CKBComponents.Script, udtType: CKBComponents.Script): bigint => {
export const calculateUdtCellCapacity = (lock: CKBComponents.Script, udtType?: CKBComponents.Script): bigint => {
const lockArgsSize = remove0x(lock.args).length / 2
const typeArgsSize = remove0x(udtType.args).length / 2
const typeArgsSize = udtType ? remove0x(udtType.args).length / 2 : 32
const cellSize = 33 + lockArgsSize + 33 + typeArgsSize + 8 + 16
return BigInt(cellSize + 1) * CKB_UNIT
}
Expand Down
6 changes: 3 additions & 3 deletions src/order/maker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const calculateNFTMakerListPackage = (seller: string | CKBComponents.Scri
return BigInt(orderArgsSize - sellerLockArgsSize) * CKB_UNIT
}

export const calculateUDTMakerListPackage = (seller: string | CKBComponents.Script, assetType: Hex | CKBComponents.Script): bigint => {
export const calculateUDTMakerListPackage = (seller: string | CKBComponents.Script, assetType?: Hex | CKBComponents.Script): bigint => {
const sellerLock = typeof seller === 'string' ? addressToScript(seller) : seller

// The setup and totalValue are only used as a placeholder and does not affect the final size calculation.
Expand All @@ -42,9 +42,9 @@ export const calculateUDTMakerListPackage = (seller: string | CKBComponents.Scri
...getDexLockScript(false),
args: orderArgs.toHex(),
}
const assetTypeScript = typeof assetType === 'string' ? (blockchain.Script.unpack(assetType) as CKBComponents.Script) : assetType
const typeScript = typeof assetType === 'string' ? (blockchain.Script.unpack(assetType) as CKBComponents.Script) : assetType

return calculateUdtCellCapacity(orderLock, assetTypeScript)
return calculateUdtCellCapacity(orderLock, typeScript)
}

export const buildMakerTx = async ({
Expand Down

0 comments on commit a3c7fdb

Please sign in to comment.