github.com/status-im/status-go@v1.1.0/services/wallet/thirdparty/opensea/client_v2_test.go (about)

     1  package opensea
     2  
     3  import (
     4  	"encoding/json"
     5  	"math/big"
     6  	"testing"
     7  
     8  	"github.com/ethereum/go-ethereum/common"
     9  
    10  	"github.com/status-im/status-go/services/wallet/bigint"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestUnmarshallDetailedAsset(t *testing.T) {
    16  	nftJSON := `{"nft": {"identifier": "7", "collection": "test-cool-cats-v3", "contract": "0x9a95631794a42d30c47f214fbe02a72585df35e1", "token_standard": "erc721", "name": "Cool Cat #7", "description": "Cool Cats also live on Rinkeby for testing purposes!", "image_url": "https://i.seadn.io/gae/blGPn5DZZXjGkrwx5EICajgepVjogYxNEnvDWBECCiFy7OXJkaW--d9OgO4gXqZzkFhd87pd_ckOyS-nEGLVymPjccavrznJGJ4XgA?w=500&auto=format", "metadata_url": "https://BetaTestPetMetadataServer.grampabacon.repl.co/cat/7", "created_at": "2022-10-05T14:29:31.966382", "updated_at": "2022-10-05T14:29:43.889730", "is_disabled": false, "is_nsfw": false, "is_suspicious": false, "creator": "0x772b92a6abe5129f8ef91d164cc757dd9bbd0bc7", "traits": [{"trait_type": "tier", "display_type": null, "max_value": null, "trait_count": 0, "order": null, "value": "cool_2"}], "owners": [{"address": "0x0000000000000000000000000000000000000001", "quantity": 1}], "rarity": null}}`
    17  	expectedNFT := DetailedNFT{
    18  		TokenID:       &bigint.BigInt{Int: big.NewInt(7)},
    19  		Collection:    "test-cool-cats-v3",
    20  		Contract:      common.HexToAddress("0x9a95631794a42d30c47f214fbe02a72585df35e1"),
    21  		TokenStandard: "erc721",
    22  		Name:          "Cool Cat #7",
    23  		Description:   "Cool Cats also live on Rinkeby for testing purposes!",
    24  		ImageURL:      "https://i.seadn.io/gae/blGPn5DZZXjGkrwx5EICajgepVjogYxNEnvDWBECCiFy7OXJkaW--d9OgO4gXqZzkFhd87pd_ckOyS-nEGLVymPjccavrznJGJ4XgA?w=500&auto=format",
    25  		MetadataURL:   "https://BetaTestPetMetadataServer.grampabacon.repl.co/cat/7",
    26  		Owners: []OwnerV2{
    27  			{
    28  				Address:  common.HexToAddress("0x0000000000000000000000000000000000000001"),
    29  				Quantity: &bigint.BigInt{Int: big.NewInt(1)},
    30  			},
    31  		},
    32  		Traits: []TraitV2{
    33  			{
    34  				TraitType:   "tier",
    35  				DisplayType: "",
    36  				MaxValue:    "",
    37  				TraitCount:  0,
    38  				Order:       "",
    39  				Value:       "cool_2",
    40  			},
    41  		},
    42  	}
    43  
    44  	nftContainer := DetailedNFTContainer{}
    45  	err := json.Unmarshal([]byte(nftJSON), &nftContainer)
    46  	assert.NoError(t, err)
    47  	assert.Equal(t, expectedNFT, nftContainer.NFT)
    48  }