Skip to content

Commit 09a37d9

Browse files
committed
sudt: fix read uint128
1 parent b2dc4de commit 09a37d9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/encoding/binary/binary.cell

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func ReadUint128(r io.Reader, order ByteOrder) uint128 {
345345
bs := make([]byte, 16)
346346
n, err := io.ReadFull(r, bs)
347347
if err.NotNone() {
348-
return uint128(0)
348+
return 0u128
349349
}
350350
return order.Uint128(bs)
351351
}

tests/examples/sudt.cell

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ func main() {
4242
// sudt cell
4343
// data: amount uint128
4444
// https://docs-xi-two.vercel.app/docs/rfcs/0025-simple-udt/0025-simple-udt#sudt-cell
45-
inSum := 0
45+
inSum := 0u128
4646
for i := 0; i < ckb.scriptInputCells(); i++ {
4747
raw := ckb.loadInputCellData(i)
48-
amount := binary.ReadUint64FromSlice(raw, binary.LittleEndian)
48+
amount := binary.ReadUint128FromSlice(raw, binary.LittleEndian)
4949
inSum += amount
5050
}
5151

52-
outSum := 0
52+
outSum := 0u128
5353
for i := 0; i < ckb.scriptOutputCells(); i++ {
5454
raw := ckb.loadOutputCellData(i)
55-
amount := binary.ReadUint64FromSlice(raw, binary.LittleEndian)
55+
amount := binary.ReadUint128FromSlice(raw, binary.LittleEndian)
5656
inSum += amount
5757
}
5858

0 commit comments

Comments
 (0)