Jesulonimi21 / Swift-Algorand-Sdk

A Swift Sdk for interacting with the Algorand Blockchain
MIT License
19 stars 13 forks source link

getAssetById return metadataHash nil #30

Open LucaInfante opened 2 years ago

LucaInfante commented 2 years ago

When I try to retrieve an asset with getAssetById I obtain always metadataHash to nil.

If I try with PureStake the metadataHash is populated. Can you help me?

stefanomondino commented 2 years ago

Ciao @LucaInfante (nice to meet you - I know your brother :D),

I'd love to doublecheck with @Jesulonimi21 on this.

At the moment, according to docs, we should expect this payload:

https://developer.algorand.org/docs/rest-apis/algod/v2/#assetparams

where metadataHash is optional.

I see two problems here -> https://github.com/Jesulonimi21/Swift-Algorand-Sdk/blob/main/Sources/swift-algorand-sdk/model/AssetParamsData.swift

1) metadataHash is not mapped in CodingKeys 2) metadataHash is defined as [UInt8], but it's returned as an hash string - it will never work.

We should add a custom decoding/encoding part like we did for other entities.

@LucaInfante is there any chance you could provide us an example JSON (with no sensitive data) we could use in unit tests so that we are sure we are not introducing regressions?

I've tried this

curl --location --request GET 'https://testnet-algorand.api.purestake.io:443/ps2/v2/assets/86247232' \
--header 'X-API-Key: ADRySlL0NK5trzqZGAE3q1xxIqlQdSfk1nbHxTNe'

from @Jesulonimi21 example but there's no metadataHash involved

Thanks!

stefanomondino commented 2 years ago

@LucaInfante can you try linked PR (#34) and see if it works?