Sha256: b7b4ae4a1ecd6c6475379f083555b85872ff268aaca89d8ba8b2e05b5b4d1a93
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
/** * @module index */ import { base58Encode, blake2b, concat, signBytes } from '@waves/ts-lib-crypto' import { serializePrimitives } from '@waves/marshall' const {BASE58_STRING} = serializePrimitives import { getSenderPublicKey, convertToPairs } from '../generic' import { ICancelOrderParams, ICancelOrder } from '../transactions' import { validate } from '../validators' import { TPrivateKey } from '../types' export const cancelOrderParamsToBytes = (cancelOrderParams:{sender: string, orderId: string}) => concat( BASE58_STRING(cancelOrderParams.sender), BASE58_STRING(cancelOrderParams.orderId) ) export function cancelOrder(params: ICancelOrderParams, seed?: string | TPrivateKey): ICancelOrder { const seedsAndIndexes = convertToPairs(seed) const senderPublicKey = params.senderPublicKey || getSenderPublicKey(seedsAndIndexes, {senderPublicKey: undefined}) const bytes = concat(BASE58_STRING(senderPublicKey), BASE58_STRING(params.orderId)) const signature = params.signature || ( seed != null && signBytes(seed, bytes)) || '' const hash = base58Encode(blake2b(Uint8Array.from(bytes))) const cancelOrderBody: ICancelOrder = { sender: senderPublicKey, orderId: params.orderId, signature, hash, } validate.cancelOrder(cancelOrderBody) return cancelOrderBody }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
waves_lib-0.1.0 | js/node_modules/@waves/waves-transactions/src/requests/cancel-order.ts |