@@ -5,7 +5,7 @@ import { payFeeByFeeRate } from "@ckb-lumos/common-scripts/lib/common";
5
5
import { addCellDep } from "@ckb-lumos/common-scripts/lib/helper" ;
6
6
import { List } from "immutable" ;
7
7
import { computeScriptHash } from "@ckb-lumos/base/lib/utils" ;
8
- import { bytes , number } from "@ckb-lumos/codec" ;
8
+ import { bytes } from "@ckb-lumos/codec" ;
9
9
import { blockchain } from "@ckb-lumos/base" ;
10
10
11
11
export const { AGGRON4 } = config . predefined ;
@@ -122,7 +122,7 @@ export async function transferCKB2SUDT(issuerPrivateKey: string, holderPrivateKe
122
122
break ;
123
123
}
124
124
inputs = inputs . push ( cell ) ;
125
- total = total . add ( number . Uint128LE . unpack ( cell . data ) ) ;
125
+ total = total . add ( sudt . unpackAmount ( cell . data ) ) ;
126
126
}
127
127
return inputs ;
128
128
} ) ;
@@ -146,7 +146,7 @@ export async function transferCKB2SUDT(issuerPrivateKey: string, holderPrivateKe
146
146
lock : holderAccountInfo . lockScript ,
147
147
type : issuerTypeScript ,
148
148
} ,
149
- data : bytes . hexify ( number . Uint128LE . pack ( SUDTAmount ) ) ,
149
+ data : sudt . packAmount ( SUDTAmount ) ,
150
150
} ;
151
151
152
152
console . log ( calculateSUDTAmountSum ( issuerSUDTCells ) . toBigInt ( ) ) ;
@@ -157,7 +157,7 @@ export async function transferCKB2SUDT(issuerPrivateKey: string, holderPrivateKe
157
157
lock : issuerAccountInfo . lockScript ,
158
158
type : issuerTypeScript ,
159
159
} ,
160
- data : bytes . hexify ( number . Uint128LE . pack ( calculateSUDTAmountSum ( issuerSUDTCells ) . sub ( SUDTAmount ) ) ) ,
160
+ data : sudt . packAmount ( calculateSUDTAmountSum ( issuerSUDTCells ) . sub ( SUDTAmount ) ) ,
161
161
} ;
162
162
163
163
SUDTTargetOutput . cellOutput . capacity = BI . from ( helpers . minimalCellCapacity ( SUDTTargetOutput ) ) . toHexString ( ) ;
@@ -274,7 +274,7 @@ export function calculateSUDTAmountSum(cells: Cell[]) {
274
274
let amount = BI . from ( 0 ) ;
275
275
for ( const cell of cells ) {
276
276
if ( cell . cellOutput . type ?. codeHash === AGGRON4 . SCRIPTS . SUDT . CODE_HASH ) {
277
- amount = amount . add ( number . Uint128LE . unpack ( cell . data ) ) ;
277
+ amount = amount . add ( sudt . unpackAmount ( cell . data ) ) ;
278
278
}
279
279
}
280
280
@@ -310,7 +310,7 @@ export async function fetchSUDTBalance(address: string, issuerLockScript: Script
310
310
let amount = BI . from ( 0 ) ;
311
311
312
312
for await ( const cell of collector . collect ( ) ) {
313
- amount = amount . add ( number . Uint128LE . unpack ( cell . data ) ) ;
313
+ amount = amount . add ( sudt . unpackAmount ( cell . data ) ) ;
314
314
}
315
315
return amount ;
316
316
}
2 commit comments
vercel[bot] commentedon Aug 7, 2023
Successfully deployed to the following URLs:
lumos-website – ./
lumos-website.vercel.app
lumos-website-magickbase.vercel.app
lumos-website-git-develop-magickbase.vercel.app
github-actions[bot] commentedon Aug 7, 2023
🚀 New canary release:
0.0.0-canary-5d1862f-20230807025040