es/contract/aci.js
function transformDecodedData (aci, result, { skipTransformDecoded = false, addressPrefix = 'ak' } = {}) {
  if (skipTransformDecoded) return result
  const { t, generic } = readType(aci, true)

  switch (t) {
    case SOPHIA_TYPES.bool:
      return !!result.value
    case SOPHIA_TYPES.address:
      return result.value === 0
        ? 0
        : encodeAddress(toBytes(result.value, true), addressPrefix)
    case SOPHIA_TYPES.map:
      const [keyT, valueT] = generic
      return result.value
        .reduce(
          (acc, { key, val }, i) => {
            key = transformDecodedData(keyT, { value: key.value })
            val = transformDecodedData(valueT, { value: val.value })
            acc[i] = { key, val }
            return acc
          },
          {}
        )
    case SOPHIA_TYPES.list:
      return result.value.map(({ value }) => transformDecodedData(generic, { value }))
    case SOPHIA_TYPES.tuple:
      return result.value.map(({ value }, i) => { return transformDecodedData(generic[i], { value }) })
    case SOPHIA_TYPES.record:
      return result.value.reduce(
        (acc, { name, value }, i) =>
          ({
            ...acc,
            [generic[i].name]: transformDecodedData(generic[i].type, { value })
          }),
        {}
      )
  }
  return result.value
}
function transformDecodedData (aci, result, { skipTransformDecoded = false, addressPrefix = 'ak' } = {}) {
  if (skipTransformDecoded) return result
  const { t, generic } = readType(aci, true)

  switch (t) {
    case SOPHIA_TYPES.bool:
      return !!result.value
    case SOPHIA_TYPES.address:
      return result.value === 0
        ? 0
        : encodeAddress(toBytes(result.value, true), addressPrefix)
    case SOPHIA_TYPES.map:
      const [keyT, valueT] = generic
      return result.value
        .reduce(
          (acc, { key, val }, i) => {
            key = transformDecodedData(keyT, { value: key.value })
            val = transformDecodedData(valueT, { value: val.value })
            acc[i] = { key, val }
            return acc
          },
          {}
        )
    case SOPHIA_TYPES.list:
      return result.value.map(({ value }) => transformDecodedData(generic, { value }))
    case SOPHIA_TYPES.tuple:
      return result.value.map(({ value }, i) => { return transformDecodedData(generic[i], { value }) })
    case SOPHIA_TYPES.record:
      return result.value.reduce(
        (acc, { name, value }, i) =>
          ({
            ...acc,
            [generic[i].name]: transformDecodedData(generic[i].type, { value })
          }),
        {}
      )
  }
  return result.value
}
function transformDecodedData ( aci , result , { skipTransformDecoded = false , addressPrefix = 'ak' } = { } ) { if ( skipTransformDecoded ) return result const { t , generic } = readType ( aci , true ) switch ( t ) { case SOPHIA_TYPES . bool : return ! ! result . value case SOPHIA_TYPES . address : return result . value === 0 ? 0 : encodeAddress ( toBytes ( result . value , true ) , addressPrefix ) case SOPHIA_TYPES . map : const [ keyT , valueT ] = generic return result . value . reduce ( ( acc , { key , val } , i ) => { key = transformDecodedData ( keyT , { value : key . value } ) val = transformDecodedData ( valueT , { value : val . value } ) acc [ i ] = { key , val } return acc } , { } ) case SOPHIA_TYPES . list : return result . value . map ( ( { value } ) => transformDecodedData ( generic , { value } ) ) case SOPHIA_TYPES . tuple : return result . value . map ( ( { value } , i ) => { return transformDecodedData ( generic [ i ] , { value } ) } ) case SOPHIA_TYPES . record : return result . value . reduce ( ( acc , { name , value } , i ) => ( { ... acc , [ generic [ i ] . name ] : transformDecodedData ( generic [ i ] . type , { value } ) } ) , { } ) } return result . value }
Transform decoded data to JS type
@param aci
@param result
@param transformDecodedData
@return {*}
Transform decoded data to JS type