UNPKG

openchain-sdk-yxl-ts

Version:

OpenChain SDK for browser

34 lines (29 loc) 879 B
import protobuf from 'protobufjs'; import long from 'long'; import bundleJson from '../../crypto/protobuf/bundle.js'; /** * issueAsset operation * @param {string} args * @returns {string} */ export default function (args) { try { const { sourceAddress, code, assetAmount, metadata } = args; const root = protobuf.Root.fromJSON(bundleJson); const issueAsset = root.lookupType('protocol.OperationIssueAsset'); const issueAssetMsg = issueAsset.create({ sourceAddress, code: code, amount: long.fromValue(assetAmount), }); const operation = root.lookupType('protocol.Operation'); return operation.create({ issueAsset: issueAssetMsg, type: operation.Type.ISSUE_ASSET, }); // const buffer = operation.encode(operationMsg).finish(); // return buffer.toString('hex'); } catch (err) { throw err; } };