How to use the @waves/marshall.binary.parserFromSchema function in @waves/marshall

To help you get started, we’ve selected a few @waves/marshall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wavesplatform / waves-transactions / src / proto-serialize.ts View on Github external
break
    case "setScript":
      res.script = t.setScript!.script == null ? null : base64Prefix(base64Encode(t.setScript!.script!.bytes!))
      break
    case "sponsorFee":
      res.minSponsoredAssetFee = t.sponsorFee!.minFee!.amount!.toString()
      res.assetId = base58Encode(t.sponsorFee!.minFee!.assetId!)
      break
    case "setAssetScript":
      res.assetId = base58Encode(t.setAssetScript!.assetId!)
      res.script = base64Prefix(base64Encode(t.setAssetScript!.script!.bytes!))
      break
    case "invokeScript":
      res.dApp = recipientFromProto(t.invokeScript!.dApp!, t.chainId)
      if (t.invokeScript!.functionCall! != null) {
        res.call = binary.parserFromSchema(invokeScriptCallSchema)(t.invokeScript!.functionCall!).value //todo: export function call from marshall and use it directly
      }
      res.payment = t.invokeScript!.payments!.map(p => ({
        amount: p.amount!.toString(),
        assetId: p.assetId == null ? null : base58Encode(p.assetId)
      }))
      break
    case 'updateAssetInfo':
      res.assetId = base58Encode(t.updateAssetInfo!.assetId!)
      res.name = t.updateAssetInfo!.name
      res.description = t.updateAssetInfo!.description
      break
    default:
      throw new Error(`Unsupported tx type ${t.data}`)
  }

  return res