How to use @waves/marshall - 10 common examples

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 / requests / order.ts View on Github external
price,
    amount,
    timestamp: t,
    expiration: expiration || t + 29 * 24 * 60 * 60 * 1000,
    matcherFee: matcherFee || 300000,
    matcherPublicKey,
    senderPublicKey,
    proofs,
    id: '',
  }

  if (ord.version === 3) {
    ord.matcherFeeAssetId = paramsOrOrder.matcherFeeAssetId === 'WAVES' ? null : paramsOrOrder.matcherFeeAssetId
  }

  const bytes = binary.serializeOrder(ord)

  seedsAndIndexes.forEach(([s, i]) => addProof(ord, signBytes(s, bytes), i))

  validate.order(ord)

  ord.id = base58Encode(blake2b(bytes))

  // OrderV1 uses signature instead of proofs
  if (ord.version === undefined || ord.version === 1) (ord as any).signature = ord.proofs && ord.proofs[0]

  return ord
}
github wavesplatform / waves-transactions / src / transactions / mass-transfer.ts View on Github external
const tx: IMassTransferTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    assetId: normalizeAssetId(paramsOrTx.assetId),
    transfers: paramsOrTx.transfers,
    fee: fee(paramsOrTx, 100000 + Math.ceil(0.5 * paramsOrTx.transfers.length) * 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    attachment: paramsOrTx.attachment || '',
    proofs: paramsOrTx.proofs || [],
    id: '', //TODO: invalid id for masstransfer tx
  }

  validate.massTransfer(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / set-script.ts View on Github external
const tx: ISetScriptTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    chainId: networkByte(paramsOrTx.chainId, 87),
    fee: fee(paramsOrTx, 1000000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
    script: base64Prefix(paramsOrTx.script),
  }

  validate.setScript(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s,i]) => addProof(tx, signBytes(s, bytes),i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / issue.ts View on Github external
name: paramsOrTx.name,
    description: paramsOrTx.description,
    quantity: paramsOrTx.quantity,
    script: paramsOrTx.script == null ? undefined : base64Prefix(paramsOrTx.script)!,
    decimals: paramsOrTx.decimals == null ? 8 : paramsOrTx.decimals,
    reissuable: paramsOrTx.reissuable || false,
    fee: paramsOrTx.quantity === 1 ? fee(paramsOrTx, 1000000) : fee(paramsOrTx, 100000000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    chainId: networkByte(paramsOrTx.chainId, 87),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }

  validate.issue(tx)

  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / alias.ts View on Github external
const tx: IAliasTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    alias: paramsOrTx.alias,
    fee: fee(paramsOrTx, 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    chainId: networkByte(paramsOrTx.chainId, 87),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }

  validate.alias(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))

  const idBytes = [bytes[0], ...bytes.slice(36, -16)]
  tx.id = base58Encode(blake2b(Uint8Array.from(idBytes)))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / exchange.ts View on Github external
senderPublicKey,
    order1: paramsOrTx.order1,
    order2: paramsOrTx.order2,
    price: paramsOrTx.price,
    amount: paramsOrTx.amount,
    buyMatcherFee: paramsOrTx.buyMatcherFee,
    sellMatcherFee: paramsOrTx.sellMatcherFee,
    fee: fee(paramsOrTx, 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }
  
  validate.exchange(tx)

  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))

  return {...tx, id: base58Encode(blake2b(bytes))}
}
github wavesplatform / waves-transactions / src / transactions / set-asset-script.ts View on Github external
const tx: ISetAssetScriptTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    assetId: paramsOrTx.assetId,
    chainId: networkByte(paramsOrTx.chainId, 87),
    fee: fee(paramsOrTx, 100000000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
    script: base64Prefix(paramsOrTx.script),
  }
  
  validate.setAssetScript(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / burn.ts View on Github external
const tx: IBurnTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    assetId: paramsOrTx.assetId,
    quantity: paramsOrTx.quantity,
    chainId: networkByte(paramsOrTx.chainId, 87),
    fee: fee(paramsOrTx, 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }
  
  validate.burn(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / lease.ts View on Github external
const tx: ILeaseTransaction & WithId = {
    type,
    version,
    senderPublicKey,
    amount: paramsOrTx.amount,
    recipient: paramsOrTx.recipient,
    fee: fee(paramsOrTx, 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }

  validate.lease(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}
github wavesplatform / waves-transactions / src / transactions / reissue.ts View on Github external
type,
    version,
    senderPublicKey,
    assetId: paramsOrTx.assetId,
    quantity: paramsOrTx.quantity,
    reissuable: paramsOrTx.reissuable,
    chainId: networkByte(paramsOrTx.chainId, 87),
    fee: fee(paramsOrTx,100000000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }
  
  validate.reissue(tx)
  
  const bytes = binary.serializeTx(tx)

  seedsAndIndexes.forEach(([s,i]) => addProof(tx, signBytes(s, bytes),i))
  tx.id = base58Encode(blake2b(bytes))

  return tx
}