diff --git a/package.json b/package.json index 8c69db2..e3ecc0e 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", diff --git a/src/order/helper.ts b/src/order/helper.ts index cbcf01a..b20d14a 100644 --- a/src/order/helper.ts +++ b/src/order/helper.ts @@ -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 } diff --git a/src/order/maker.ts b/src/order/maker.ts index 926a843..dd2533c 100644 --- a/src/order/maker.ts +++ b/src/order/maker.ts @@ -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. @@ -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 ({