From 09a37d9c86c8d66a77c5d3464572d1444f0d8c79 Mon Sep 17 00:00:00 2001 From: Cedric <14017092+douyixuan@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:30:44 +0800 Subject: [PATCH] sudt: fix read uint128 --- pkg/encoding/binary/binary.cell | 2 +- tests/examples/sudt.cell | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/encoding/binary/binary.cell b/pkg/encoding/binary/binary.cell index 684b9b9..36bc67c 100644 --- a/pkg/encoding/binary/binary.cell +++ b/pkg/encoding/binary/binary.cell @@ -345,7 +345,7 @@ func ReadUint128(r io.Reader, order ByteOrder) uint128 { bs := make([]byte, 16) n, err := io.ReadFull(r, bs) if err.NotNone() { - return uint128(0) + return 0u128 } return order.Uint128(bs) } diff --git a/tests/examples/sudt.cell b/tests/examples/sudt.cell index 25e0e3d..7cab55c 100644 --- a/tests/examples/sudt.cell +++ b/tests/examples/sudt.cell @@ -42,17 +42,17 @@ func main() { // sudt cell // data: amount uint128 // https://docs-xi-two.vercel.app/docs/rfcs/0025-simple-udt/0025-simple-udt#sudt-cell - inSum := 0 + inSum := 0u128 for i := 0; i < ckb.scriptInputCells(); i++ { raw := ckb.loadInputCellData(i) - amount := binary.ReadUint64FromSlice(raw, binary.LittleEndian) + amount := binary.ReadUint128FromSlice(raw, binary.LittleEndian) inSum += amount } - outSum := 0 + outSum := 0u128 for i := 0; i < ckb.scriptOutputCells(); i++ { raw := ckb.loadOutputCellData(i) - amount := binary.ReadUint64FromSlice(raw, binary.LittleEndian) + amount := binary.ReadUint128FromSlice(raw, binary.LittleEndian) inSum += amount }