Skip to content

Commit

Permalink
sudt: fix read uint128
Browse files Browse the repository at this point in the history
  • Loading branch information
douyixuan committed Sep 16, 2024
1 parent b2dc4de commit 09a37d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/encoding/binary/binary.cell
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/sudt.cell
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 09a37d9

Please sign in to comment.