capsule-corp-ternoa / ternoa-js

Ternoa JavaScript SDK to build on top of the Ternoa Chain ⚙️
https://docs.ternoa.network
Apache License 2.0
24 stars 11 forks source link

parse getMarketplaceData into friendly "human" values #108

Closed ipapandinas closed 2 years ago

ipapandinas commented 2 years ago

The getMarketplaceData() helpers return hexadecimal data that must be parsed into friendly "human" values.

Victor-Salomon commented 2 years ago

now return an object like :

{
  owner: '5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy',
  kind: 'Public',
  commissionFee: { percentage: 12 },
  listingFee: { flat: '13.0000 CAPS' },
  accountList: [ '5Cf8PBw7QiRFNPBTnUoks9Hvkzn8av1qfcgMtSppJvjYcxp6' ],
  offchainData: 'testing purpose'
}

vs before :

{
  owner: '5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy',
  kind: 'Public',
  commissionFee: { flat: '0x00000000000000000de0b6b3a7640000' },
  listingFee: { percentage: 10000 },
  accountList: [ '5Cf8PBw7QiRFNPBTnUoks9Hvkzn8av1qfcgMtSppJvjYcxp6' ],
  offchainData: '0x74657374696e6720707572706f7365'
}

Let's confirm flat format is right

ipapandinas commented 2 years ago

Nice humanization, maybe we can remove CAPS unit from the flat value and use a number type. The parsing will be consistent with the one applied to rounded amounts in event classes (e.g. listingFee: { flat: 13.0000 })