Sha256: 7f3aa29067c1d67460a66472fc48b4621e36a4f9ab27fb387ca10399752a0ed4

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

/**
 * @module index
 */
import {ICancelLeaseParams, WithId, WithProofs, WithSender} from '../transactions'
import { binary } from '@waves/marshall'
import { signBytes, blake2b, base58Encode } from '@waves/ts-lib-crypto'
import {addProof, getSenderPublicKey, convertToPairs, networkByte, fee} from '../generic'
import { TSeedTypes } from '../types'
import { validate } from '../validators'
import { txToProtoBytes } from '../proto-serialize'
import { DEFAULT_VERSIONS } from '../defaultVersions'
import {CancelLeaseTransaction, TRANSACTION_TYPE} from '@waves/ts-types'


/* @echo DOCS */
export function cancelLease(params: ICancelLeaseParams, seed: TSeedTypes): CancelLeaseTransaction & WithId & WithProofs
export function cancelLease(paramsOrTx: ICancelLeaseParams & WithSender | CancelLeaseTransaction, seed?: TSeedTypes): CancelLeaseTransaction & WithId & WithProofs
export function cancelLease(paramsOrTx: any, seed?: TSeedTypes): CancelLeaseTransaction & WithId & WithProofs{
  const type = TRANSACTION_TYPE.CANCEL_LEASE
  const version = paramsOrTx.version || DEFAULT_VERSIONS.CANCEL_LEASE
  const seedsAndIndexes = convertToPairs(seed)
  const senderPublicKey = getSenderPublicKey(seedsAndIndexes, paramsOrTx)

  const tx: CancelLeaseTransaction & WithId & WithProofs = {
    type,
    version,
    senderPublicKey,
    leaseId: paramsOrTx.leaseId,
    fee: fee(paramsOrTx, 100000),
    timestamp: paramsOrTx.timestamp || Date.now(),
    chainId: networkByte(paramsOrTx.chainId, 87),
    proofs: paramsOrTx.proofs || [],
    id: '',
  }

  validate.cancelLease(tx)

  const bytes = version > 2 ? txToProtoBytes(tx) : binary.serializeTx(tx)

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

  return tx
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/waves-transactions/src/transactions/cancel-lease.ts