Skip to content

Commit

Permalink
Merge pull request #570 from oasisprotocol/pro-wh/bugfix/nullowner
Browse files Browse the repository at this point in the history
storage: handle NULL NFT owner
  • Loading branch information
pro-wh authored Nov 22, 2023
2 parents 9e19dd3 + 5b876a7 commit 69df944
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1579,8 +1579,9 @@ func (c *StorageClient) RuntimeEVMNFTs(ctx context.Context, limit *uint64, offse
var contractAddrContextVersion int
var contractAddrData []byte
var tokenType sql.NullInt32
var ownerAddrContextIdentifier string
var ownerAddrContextVersion int
// Owner might not be known, so these preimage fields are also nilable.
var ownerAddrContextIdentifier *string
var ownerAddrContextVersion *int
var ownerAddrData []byte
var metadataAccessedN sql.NullTime
if err = res.rows.Scan(
Expand Down Expand Up @@ -1617,9 +1618,11 @@ func (c *StorageClient) RuntimeEVMNFTs(ctx context.Context, limit *uint64, offse
if tokenType.Valid {
nft.Token.Type = translateTokenType(common.TokenType(tokenType.Int32))
}
if ownerEthAddr, err1 := EVMEthAddrFromPreimage(ownerAddrContextIdentifier, ownerAddrContextVersion, ownerAddrData); err1 == nil {
ownerECAddr := ethCommon.BytesToAddress(ownerEthAddr)
nft.OwnerEth = common.Ptr(ownerECAddr.String())
if nft.Owner != nil {
if ownerEthAddr, err1 := EVMEthAddrFromPreimage(*ownerAddrContextIdentifier, *ownerAddrContextVersion, ownerAddrData); err1 == nil {
ownerECAddr := ethCommon.BytesToAddress(ownerEthAddr)
nft.OwnerEth = common.Ptr(ownerECAddr.String())
}
}
if metadataAccessedN.Valid {
nft.MetadataAccessed = common.Ptr(metadataAccessedN.Time.String())
Expand Down

0 comments on commit 69df944

Please sign in to comment.