Skip to content

Commit

Permalink
Add nftProtocolRegister
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanzhenzhen committed Jul 12, 2020
1 parent 96f875d commit 408c547
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
39 changes: 38 additions & 1 deletion lib/services/bitcoind.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ Bitcoin.prototype.getAPIMethods = function() {
['nftProtocolOwnerOf', this, this.nftProtocolOwnerOf, 1],
['nftProtocolGetByTxid', this, this.nftProtocolGetByTxid, 1],
['nftProtocolGet', this, this.nftProtocolGet, 1],
['nftProtocolList', this, this.nftProtocolList, 4]
['nftProtocolList', this, this.nftProtocolList, 4],
['nftProtocolRegister', this, this.nftProtocolRegister, 9]
];
return methods;
};
Expand Down Expand Up @@ -2377,6 +2378,42 @@ Bitcoin.prototype.nftProtocolList = function(count, skipFromTip, height, regTxOn
});
};

/**
* Will register a new NFT protocol.
* @param {String} protocolId - NFT protocol ID.
* @param {String} protocolName - NFT protocol name.
* @param {String} ownerAddress - NFT protocol owner address.
* @param {Number} regSign - NFT reg-sign.
* @param {String} metadataMimeType - MIME type describing metadata content type.
* @param {String} metadataSchemaUri - URI to schema (json/xml/binary) describing metadata format.
* @param {Boolean} isTransferable - Defines if this NF token type can be transferred.
* @param {Boolean} isMetadataEmbedded - Defines if metadata is embedded or contains a URI.
* @param {Boolean} maxMetadataSize - Defines maximum metadata length for the NFT.
* @param {Function} callback
*/
Bitcoin.prototype.nftProtocolRegister = function(protocolId, protocolName, ownerAddress, regSign, metadataMimeType, metadataSchemaUri, isTransferable, isMetadataEmbedded, maxMetadataSize, callback) {
var self = this;

if (regSign === undefined) regSign = 2;
if (metadataMimeType === undefined) metadataMimeType = "text/plain";
if (metadataSchemaUri === undefined) metadataSchemaUri = '';
if (isTransferable === undefined) isTransferable = true;
if (isMetadataEmbedded === undefined) isMetadataEmbedded = false;
if (maxMetadataSize === undefined) maxMetadataSize = 255;

regSign = regSign.toString();
isTransferable = isTransferable.toString();
isMetadataEmbedded = isMetadataEmbedded.toString();
maxMetadataSize = maxMetadataSize.toString();

this.client.nfToken("register", protocolId, protocolName, ownerAddress, regSign, metadataMimeType, metadataSchemaUri, isTransferable, isMetadataEmbedded, maxMetadataSize, function(err, response) {
if (err) {
return callback(self._wrapRPCError(err));
}
callback(null, response.result);
});
};

/**
* Called by Node to stop the service.
* @param {Function} callback
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bitcore-node-crown",
"description": "Full node with extended capabilities using Bitcore and Crown Core",
"author": "Crown Developers <[email protected]>",
"version": "0.4.14",
"version": "0.4.15",
"publishConfig": {
"tag": "next"
},
Expand Down

0 comments on commit 408c547

Please sign in to comment.