From 8f446dd4075d531873bd311d5b2e1c92e962d790 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:13:33 +0800 Subject: [PATCH] feat: add `Address.Bytes32()` (#572) --- common/types.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/types.go b/common/types.go index aadca87f82..d308b8e8f7 100644 --- a/common/types.go +++ b/common/types.go @@ -245,6 +245,12 @@ func (a Address) Cmp(other Address) int { // Bytes gets the string representation of the underlying address. func (a Address) Bytes() []byte { return a[:] } +func (a Address) Bytes32() []byte { + ret := make([]byte, 32) + copy(ret, a.Bytes()) + return ret +} + // Big converts an address to a big integer. func (a Address) Big() *big.Int { return new(big.Int).SetBytes(a[:]) }