How to use the @waves/protobuf-serialization.waves function in @waves/protobuf-serialization

To help you get started, we’ve selected a few @waves/protobuf-serialization 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
const orderFromProto = (po: wavesProto.waves.IOrder): TOrder => ({
  version: po.version! as 1 | 2 | 3,
  senderPublicKey: base58Encode(po.senderPublicKey!),
  matcherPublicKey: base58Encode(po.matcherPublicKey!),
  assetPair: {
    amountAsset: po!.assetPair!.amountAssetId == null ? null : base58Encode(po!.assetPair!.amountAssetId),
    priceAsset: po!.assetPair!.priceAssetId == null ? null : base58Encode(po!.assetPair!.priceAssetId)
  },
  // @ts-ignore
  chainId: po.chainId,
  orderType: po.orderSide === wavesProto.waves.Order.Side.BUY ? 'buy' : 'sell',
  amount: po.amount!.toString(),
  price: po.price!.toString(),
  timestamp: po.timestamp!.toNumber(),
  expiration: po.expiration!.toNumber(),
  matcherFee: po.matcherFee!.amount!.toNumber(),
  matcherFeeAssetId: po.matcherFee!.assetId == null ? null : base58Encode(po.matcherFee!.assetId),
})
github wavesplatform / waves-transactions / src / proto-serialize.ts View on Github external
const orderToProto = (o: IOrder & { chainId: number }): wavesProto.waves.IOrder => ({
  chainId: o.chainId,
  senderPublicKey: base58Decode(o.senderPublicKey),
  matcherPublicKey: base58Decode(o.matcherPublicKey),
  assetPair: {
    amountAssetId: o.assetPair.amountAsset == null ? null : base58Decode(o.assetPair.amountAsset),
    priceAssetId: o.assetPair.priceAsset == null ? null : base58Decode(o.assetPair.priceAsset)
  },
  orderSide: o.orderType === "buy" ? undefined : wavesProto.waves.Order.Side.SELL,
  amount: Long.fromValue(o.amount),
  price: Long.fromValue(o.price),
  timestamp: Long.fromValue(o.timestamp),
  expiration: Long.fromValue(o.expiration),
  matcherFee: amountToProto(o.matcherFee, null),
  version: o.version,
  proofs: o.proofs.map(base58Decode),
})

@waves/protobuf-serialization

Generated types and methods for encoding and decoding protobuf messages as well as working with gRPC services.

MIT
Latest version published 9 months ago

Package Health Score

59 / 100
Full package analysis

Popular @waves/protobuf-serialization functions

Similar packages