2 * An asset is a type of value that can be issued on a blockchain. All units of
3 * a given asset are fungible. Units of an asset can be transacted directly
4 * between parties without the involvement of the issuer.
6 * @typedef {Object} Asset
9 * @property {String} id
10 * Globally unique identifier of the asset.
11 * Asset specifies the asset id as the hash of:
12 * - the asset's issuance program
13 * - the core's VM version
14 * - the hash of asset definition
16 * @property {String} alias
17 * User specified, unique identifier in one Bytom node.
19 * @property {String} issuanceProgram
21 * @property {Key[]} keys
22 * The list of keys used to issue units of the asset.
24 * @property {Number} quorum
25 * The number of signatures required to issue new units of the asset.
27 * @property {Object} defintion
28 * User-specified, arbitrary/unstructured data visible across Bytom
29 * blockchain networks. assets specify the definition in their
30 * issuance programs, rendering the definition immutable.
34 * API for interacting with {@link Asset assets}.
38 const assetsApi = (connection) => {
41 * @typedef {Object} createRequest
43 * @property {String} [alias]
44 * User specified, unique identifier.
46 * @property {Object} [defintion]
47 * User-specified, arbitrary/unstructured data visible across blockchain networks.
49 * @property {String[]} root_xpubs
50 * Optional. The list of keys used to create the asset.
52 * @property {Number} quorum
53 * Optional. the default value is 1, threshold of keys that must sign a transaction to spend asset units controlled by the account.
55 * @property {String} [issuance_program]
56 * Optional. User-specified, contract program.
64 * @param {module:AssetsApi~createRequest} params - Parameters for asset creation.
65 * @returns {Promise<Asset>} Newly created asset.
67 create: (params) => connection.request('/create-asset', params),
70 * List all assets in one Bytom node.
72 * @returns {Promise<Array<Asset>>} target assets.
74 listAll: () => connection.request('/list-assets', {}),
77 * Get asset by the asset id.
79 * @param {module:AssetsApi~id} id - Asset id.
80 * @returns {Promise<Asset>} target asset.
82 list: (id) => connection.request('/get-asset', {id}),
87 * @param {object} params - Parameters for asset update.
88 * @param {String} params.id - id of asset.
89 * @param {String} params.alias - new alias of asset.
91 updateAlias: (params) => connection.request('/update-asset-alias', params)
95 export default assetsApi