@vostokplatform/waves-api
Advanced tools
Comparing version 1.18.10 to 1.19.0
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WavesAPI=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var request=require("./utils/request");var NodeAPI=require("./api/node/index");var MatcherAPI=require("./api/matcher/index");var constants=require("./constants");var config_1=require("./config");var tools_1=require("./tools");var WavesAPI=function(){function WavesAPI(initialConfiguration){this.Seed=signature_generator_1.Seed;this.byteProcessors=signature_generator_1.ByteProcessor;this.config=config_1.default;this.constants=constants;this.crypto=signature_generator_1.utils.crypto;this.request=request;this.tools=tools_1.default;this.API={Node:NodeAPI,Matcher:MatcherAPI};if(this instanceof WavesAPI){this.config.clear();this.config.set(initialConfiguration);if(WavesAPI._instance===null){WavesAPI._instance=this}else{return WavesAPI._instance}}else{return new WavesAPI(initialConfiguration)}}return WavesAPI}();function create(config){return new WavesAPI(config)}exports.create=create;exports.MAINNET_CONFIG=constants.DEFAULT_MAINNET_CONFIG;exports.TESTNET_CONFIG=constants.DEFAULT_TESTNET_CONFIG},{"./api/matcher/index":2,"./api/node/index":11,"./config":18,"./constants":19,"./tools":24,"./utils/request":27,"@vostokplatform/signature-generator":undefined}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var info_1=require("./info");var orderbooks_1=require("./orderbooks");exports.getMatcherKey=info_1.default.getMatcherKey;exports.getOrderbooks=orderbooks_1.default.getOrderbooks;exports.getOrderbook=orderbooks_1.default.getOrderbook;exports.getOrders=orderbooks_1.default.getOrders;exports.getAllOrders=orderbooks_1.default.getAllOrders;exports.createOrder=orderbooks_1.default.createOrder;exports.cancelOrder=orderbooks_1.default.cancelOrder;exports.deleteOrder=orderbooks_1.default.deleteOrder},{"./info":3,"./orderbooks":4}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(1,0,request_1.processJSON);exports.default={getMatcherKey:function(){return fetch("/")}}},{"../../utils/request":27}],4:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var request_1=require("../../utils/request");var remap_1=require("../../utils/remap");var request_2=require("../../utils/request");var orderbooks_x_1=require("./orderbooks.x");var fetch=request_1.createFetchWrapper(1,0,request_1.processJSON);var preCreateOrderAsync=function(data){return orderbooks_x_1.createOrderSchema.parse(data)};var postCreateOrder=function(data){data.assetPair={amountAsset:remap_1.normalizeAssetId(data.amountAsset),priceAsset:remap_1.normalizeAssetId(data.priceAsset)};delete data.amountAsset;delete data.priceAsset;return data};var postCancelOrder=remap_1.createRemapper({senderPublicKey:"sender"});var generateCancelLikeRequest=function(type){return function(amountAssetId,priceAssetId,orderId,keyPair){var data={senderPublicKey:keyPair.publicKey,orderId:orderId};var authData=new signature_generator_1.CANCEL_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){return postCancelOrder(__assign({},data,{signature:signature}))}).then(function(tx){return fetch("/orderbook/"+amountAssetId+"/"+priceAssetId+"/"+type,__assign({},request_2.POST_TEMPLATE,{body:JSON.stringify(tx)}))})}};exports.default={getOrderbooks:function(){return fetch("/orderbook")},getOrderbook:function(assetOne,assetTwo){return fetch("/orderbook/"+assetOne+"/"+assetTwo)},getOrders:function(assetOne,assetTwo,keyPair){var data={senderPublicKey:keyPair.publicKey,timestamp:remap_1.getTimestamp()};var authData=new signature_generator_1.AUTH_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){var preparedData=__assign({},data,{signature:signature});return fetch("/orderbook/"+assetOne+"/"+assetTwo+"/publicKey/"+keyPair.publicKey,{headers:{Timestamp:preparedData.timestamp,Signature:preparedData.signature}})})},getAllOrders:function(keyPair){var data={senderPublicKey:keyPair.publicKey,timestamp:remap_1.getTimestamp()};var authData=new signature_generator_1.AUTH_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){var preparedData=__assign({},data,{signature:signature});return fetch("/orderbook/"+keyPair.publicKey,{headers:{Timestamp:preparedData.timestamp,Signature:preparedData.signature}})})},createOrder:request_1.wrapTxRequest(signature_generator_1.CREATE_ORDER_SIGNATURE,preCreateOrderAsync,postCreateOrder,function(postParams){return fetch("/orderbook",postParams)}),cancelOrder:generateCancelLikeRequest("cancel"),deleteOrder:generateCancelLikeRequest("delete")}},{"../../utils/remap":26,"../../utils/request":27,"./orderbooks.x":5,"@vostokplatform/signature-generator":undefined}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var remap_1=require("../../utils/remap");var constants_1=require("../../constants");var schemaFields_1=require("../schemaFields");exports.createOrderSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,matcherPublicKey:schemaFields_1.default.publicKey,amountAsset:schemaFields_1.default.assetId,priceAsset:schemaFields_1.default.assetId,orderType:{type:ts_api_validator_1.StringPart,required:true,isValid:function(orderType){return orderType==="buy"||orderType==="sell"}},amount:{type:ts_api_validator_1.NumberPart,required:true},price:{type:ts_api_validator_1.NumberPart,required:true},timestamp:schemaFields_1.default.timestamp,expiration:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(expiration){if(expiration){return remap_1.getTimestamp(expiration)}else{var date=new Date(remap_1.getTimestamp());return date.setDate(date.getDate()+constants_1.DEFAULT_ORDER_EXPIRATION_DAYS)}}},matcherFee:schemaFields_1.default.matcherFee}})},{"../../constants":19,"../../utils/remap":26,"../schemaFields":17,"ts-api-validator":undefined}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var constants_1=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={balance:function(address,confirmations){if(!confirmations){return fetch("/addresses/balance/"+address)}else{return fetch("/addresses/balance/"+address+"/"+confirmations)}},balanceDetails:function(address){return fetch("/addresses/balance/details/"+address)},data:function(address,offset,limit){if(offset===void 0){offset=constants_1.DEFAULT_PAGING_OFFSET}if(limit===void 0){limit=constants_1.DEFAULT_PAGING_LIMIT}return fetch("/addresses/data/"+address+"?offset="+offset+"&limit="+limit)}}},{"../../constants":19,"../../utils/request":27}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={byAlias:function(alias){return fetch("/alias/by-alias/"+alias)},byAddress:function(address){return fetch("/alias/by-address/"+address)}}},{"../../utils/request":27}],8:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var addresses_1=require("./addresses");var constants=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={balances:function(address){return fetch("/assets/balance/"+address)},balance:function(address,assetId){if(assetId===constants.WAVES){return addresses_1.default.balance(address)}else{return fetch("/assets/balance/"+address+"/"+assetId)}},distribution:function(assetId){return fetch("/assets/"+assetId+"/distribution")}}},{"../../constants":19,"../../utils/request":27,"./addresses":6}],9:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(signature){return fetch("/blocks/signature/"+signature)},at:function(height){return fetch("/blocks/at/"+height)},first:function(){return fetch("/blocks/first")},last:function(){return fetch("/blocks/last")},height:function(){return fetch("/blocks/height")}}},{"../../utils/request":27}],10:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var constants_1=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(id,offset,limit){if(offset===void 0){offset=constants_1.DEFAULT_PAGING_OFFSET}if(limit===void 0){limit=constants_1.DEFAULT_PAGING_LIMIT}return fetch("/contracts/"+id+"?offset="+offset+"&limit="+limit)},getKey:function(id,key){return fetch("/contracts/"+id+"/"+key)},getExecutedTxFor:function(id){return fetch("/contracts/executed-tx-for/"+id)}}},{"../../constants":19,"../../utils/request":27}],11:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var addresses_1=require("./addresses");var aliases_1=require("./aliases");var assets_1=require("./assets");var blocks_1=require("./blocks");var contracts_1=require("./contracts");var leasing_1=require("./leasing");var transactions_1=require("./transactions");var peers_1=require("./peers");var utils_1=require("./utils");exports.addresses=addresses_1.default;exports.aliases=aliases_1.default;exports.assets=assets_1.default;exports.blocks=blocks_1.default;exports.contracts=contracts_1.default;exports.leasing=leasing_1.default;exports.transactions=transactions_1.default;exports.peers=peers_1.default;exports.utils=utils_1.default},{"./addresses":6,"./aliases":7,"./assets":8,"./blocks":9,"./contracts":10,"./leasing":12,"./peers":13,"./transactions":14,"./utils":16}],12:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={getAllActiveLeases:function(address){return fetch("/leasing/active/"+address).then(function(list){return list.map(function(tx){tx.status="active";return tx})})}}},{"../../utils/request":27}],13:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={connected:function(){return fetch("/peers/connected")}}},{"../../utils/request":27}],14:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var WavesError_1=require("../../errors/WavesError");var constants=require("../../constants");var config_1=require("../../config");var requests=require("./transactions.x");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(id){if(id===constants.WAVES){return Promise.resolve(constants.WAVES_V1_ISSUE_TX)}else{return fetch("/transactions/info/"+id)}},getList:function(address,limit){if(limit===void 0){limit=config_1.default.getRequestParams().limit}return fetch("/transactions/address/"+address+"/limit/"+limit).then(function(array){return array[0]})},utxSize:function(){return fetch("/transactions/unconfirmed/size")},utxGet:function(id){return fetch("/transactions/unconfirmed/info/"+id)},utxGetList:function(){return fetch("/transactions/unconfirmed")},broadcast:function(type,data,keys){switch(type){case constants.ISSUE_TX_NAME:return requests.sendIssueTx(data,keys);case constants.TRANSFER_TX_NAME:return requests.sendTransferTx(data,keys);case constants.REISSUE_TX_NAME:return requests.sendReissueTx(data,keys);case constants.BURN_TX_NAME:return requests.sendBurnTx(data,keys);case constants.LEASE_TX_NAME:return requests.sendLeaseTx(data,keys);case constants.CANCEL_LEASING_TX_NAME:return requests.sendCancelLeasingTx(data,keys);case constants.CREATE_ALIAS_TX_NAME:return requests.sendCreateAliasTx(data,keys);case constants.MASS_TRANSFER_TX_NAME:return requests.sendMassTransferTx(data,keys);case constants.DATA_TX_NAME:return requests.sendDataTx(data,keys);case constants.SET_SCRIPT_TX_NAME:return requests.sendSetScriptTx(data,keys);case constants.SPONSORSHIP_TX_NAME:return requests.sendSponsorshipTx(data,keys);case constants.PERMISSION_TX_NAME:return requests.sendPermissionTx(data,keys);case constants.DOCKER_CREATE_TX_NAME:return requests.sendDockerCreateTx(data,keys);case constants.DOCKER_CALL_TX_NAME:return requests.sendDockerCallTx(data,keys);case constants.DOCKER_DISABLE_TX_NAME:return requests.sendDockerDisableTx(data,keys);default:throw new WavesError_1.default("Wrong transaction type: "+type,data)}},sign:function(type,data,keys){switch(type){case constants.ISSUE_TX_NAME:return requests.sendSignedIssueTx(data,keys);case constants.TRANSFER_TX_NAME:return requests.sendSignedTransferTx(data,keys);case constants.REISSUE_TX_NAME:return requests.sendSignedReissueTx(data,keys);case constants.BURN_TX_NAME:return requests.sendSignedBurnTx(data,keys);case constants.LEASE_TX_NAME:return requests.sendSignedLeaseTx(data,keys);case constants.CANCEL_LEASING_TX_NAME:return requests.sendSignedCancelLeasingTx(data,keys);case constants.CREATE_ALIAS_TX_NAME:return requests.sendSignedCreateAliasTx(data,keys);case constants.MASS_TRANSFER_TX_NAME:return requests.sendSignedMassTransferTx(data,keys);case constants.DATA_TX_NAME:return requests.sendSignedDataTx(data,keys);case constants.SET_SCRIPT_TX_NAME:return requests.sendSignedSetScriptTx(data,keys);case constants.SPONSORSHIP_TX_NAME:return requests.sendSignedSponsorshipTx(data,keys);case constants.PERMISSION_TX_NAME:return requests.sendSignedPermissionTx(data,keys);case constants.DOCKER_CREATE_TX_NAME:return requests.sendSignedDockerCreateTx(data,keys);case constants.DOCKER_CALL_TX_NAME:return requests.sendSignedDockerCallTx(data,keys);case constants.DOCKER_DISABLE_TX_NAME:return requests.sendSignedDockerDisableTx(data,keys);default:throw new WavesError_1.default("Wrong transaction type: "+type,data)}},rawBroadcast:function(data){return fetch(constants.BROADCAST_PATH,__assign({},request_1.POST_TEMPLATE,{body:JSON.stringify(data)}))},signOnNode:function(data){return fetch("/transactions/sign")}}},{"../../config":18,"../../constants":19,"../../errors/WavesError":20,"../../utils/request":27,"./transactions.x":15}],15:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var signature_generator_1=require("@vostokplatform/signature-generator");var schemaFields_1=require("../schemaFields");var remap_1=require("../../utils/remap");var request_1=require("../../utils/request");var constants=require("../../constants");var config_1=require("../../config");var bignumber_1=require("../../libs/bignumber");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);var AnyPart=function(_super){__extends(AnyPart,_super);function AnyPart(){return _super!==null&&_super.apply(this,arguments)||this}AnyPart.prototype.getValue=function(data){return data};return AnyPart}(ts_api_validator_1.BasePart);function getSignedTx(data){return{data:new Promise(function(resolve){resolve(JSON.parse(data.body))})}}exports.issueSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,name:{type:ts_api_validator_1.StringPart,required:true},description:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},script:{type:ts_api_validator_1.StringPart,required:false,defaultValue:"base64:AQa3b8tH"},quantity:{type:ts_api_validator_1.StringPart,required:true},precision:{type:ts_api_validator_1.NumberPart,required:true,isValid:remap_1.precisionCheck},reissuable:schemaFields_1.default.reissuable,fee:schemaFields_1.default.issueFee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preIssue=function(data){return exports.issueSchema.parse(data)};exports.postIssue=remap_1.createRemapper({transactionType:null,precision:"decimals",type:constants.ISSUE_TX,version:constants.ISSUE_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendIssueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.issue,exports.preIssue,exports.postIssue,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedIssueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.issue,exports.preIssue,exports.postIssue,function(postParams){return getSignedTx(postParams).data},true);exports.transferSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,recipient:schemaFields_1.default.recipient,assetId:schemaFields_1.default.assetId,amount:{type:ts_api_validator_1.StringPart,required:true},feeAssetId:{type:ts_api_validator_1.StringPart,required:false,defaultValue:constants.WAVES},fee:schemaFields_1.default.fee,attachment:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},timestamp:schemaFields_1.default.timestamp}});exports.preTransfer=function(data){return exports.transferSchema.parse(data)};exports.postTransfer=remap_1.createRemapper({transactionType:null,assetId:remap_1.normalizeAssetId,feeAssetId:remap_1.normalizeAssetId,attachment:{from:"string",to:"base58"},recipient:{from:"raw",to:"prefixed"},amount:{from:"string",to:"bignumber"},type:constants.TRANSFER_TX,version:constants.TRANSFER_TX_VERSION});exports.sendTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.transfer,exports.preTransfer,exports.postTransfer,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.transfer,exports.preTransfer,exports.postTransfer,function(postParams){return getSignedTx(postParams).data},true);exports.reissueSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,quantity:{type:ts_api_validator_1.StringPart,required:true},reissuable:schemaFields_1.default.reissuable,fee:schemaFields_1.default.issueFee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preReissue=function(data){return exports.reissueSchema.parse(data)};exports.postReissue=remap_1.createRemapper({transactionType:null,type:constants.REISSUE_TX,version:constants.REISSUE_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendReissueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.reissue,exports.preReissue,exports.postReissue,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedReissueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.reissue,exports.preReissue,exports.postReissue,function(postParams){return getSignedTx(postParams).data},true);exports.burnSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,quantity:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preBurn=function(data){return exports.burnSchema.parse(data)};exports.postBurn=remap_1.createRemapper({transactionType:null,type:constants.BURN_TX,version:constants.BURN_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendBurnTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.burn,exports.preBurn,exports.postBurn,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedBurnTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.burn,exports.preBurn,exports.postBurn,function(postParams){return getSignedTx(postParams).data},true);exports.leaseSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,recipient:schemaFields_1.default.recipient,amount:{type:ts_api_validator_1.NumberPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preLease=function(data){return exports.leaseSchema.parse(data)};exports.postLease=remap_1.createRemapper({transactionType:null,recipient:{from:"raw",to:"prefixed"},type:constants.LEASE_TX,version:constants.LEASE_TX_VERSION});exports.sendLeaseTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.lease,exports.preLease,exports.postLease,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedLeaseTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.lease,exports.preLease,exports.postLease,function(postParams){return getSignedTx(postParams).data},true);exports.cancelLeasingSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,leaseId:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preCancelLeasing=function(data){return exports.cancelLeasingSchema.parse(data)};exports.postCancelLeasing=remap_1.createRemapper({transactionType:null,transactionId:"txId",type:constants.CANCEL_LEASING_TX,version:constants.CANCEL_LEASING_TX_VERSION});exports.sendCancelLeasingTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.cancelLeasing,exports.preCancelLeasing,exports.postCancelLeasing,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedCancelLeasingTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.cancelLeasing,exports.preCancelLeasing,exports.postCancelLeasing,function(postParams){return getSignedTx(postParams).data},true);exports.createAliasSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,alias:{type:ts_api_validator_1.StringPart,required:true,parseValue:remap_1.removeAliasPrefix},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preCreateAlias=function(data){return exports.createAliasSchema.parse(data)};exports.postCreateAlias=remap_1.createRemapper({transactionType:null,type:constants.CREATE_ALIAS_TX,version:constants.CREATE_ALIAS_TX_VERSION});exports.sendCreateAliasTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.createAlias,exports.preCreateAlias,exports.postCreateAlias,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedCreateAliasTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.createAlias,exports.preCreateAlias,exports.postCreateAlias,function(postParams){return getSignedTx(postParams).data},true);exports.massTransferSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,transfers:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{recipient:schemaFields_1.default.recipient,amount:{type:ts_api_validator_1.StringPart,required:true}}},defaultValue:[]},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee,attachment:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""}}});exports.preMassTransfer=function(data){return exports.massTransferSchema.parse(data)};exports.postMassTransfer=remap_1.createRemapper({transactionType:null,assetId:remap_1.normalizeAssetId,attachment:{from:"string",to:"base58"},transfers:{from:"raw",to:"prefixed",path:"transfers"},type:constants.MASS_TRANSFER_TX,version:constants.MASS_TRANSFER_TX_VERSION});exports.sendMassTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.massTransfer,exports.preMassTransfer,exports.postMassTransfer,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedMassTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.massTransfer,exports.preMassTransfer,exports.postMassTransfer,function(postParams){return getSignedTx(postParams).data},true);exports.dataSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,authorPublicKey:schemaFields_1.default.publicKey,data:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preData=function(data){return exports.dataSchema.parse(data)};exports.postData=function(d){var data=JSON.parse(JSON.stringify(d.data));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{data:data,transactionType:null,type:constants.DATA_TX,version:constants.DATA_TX_VERSION});return result};exports.sendDataTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.data,exports.preData,exports.postData,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedDataTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.data,exports.preData,exports.postData,function(postParams){return getSignedTx(postParams).data},true);exports.setScriptSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{name:{type:ts_api_validator_1.StringPart,required:true},description:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},senderPublicKey:schemaFields_1.default.publicKey,script:{type:ts_api_validator_1.StringPart,required:true},chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee}});exports.preSetScript=function(data){return exports.setScriptSchema.parse(data)};exports.postSetScript=remap_1.createRemapper({transactionType:null,type:constants.SET_SCRIPT_TX,version:constants.SET_SCRIPT_TX_VERSION});exports.sendSetScriptTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.setScript,exports.preSetScript,exports.postSetScript,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedSetScriptTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.setScript,exports.preSetScript,exports.postSetScript,function(postParams){return getSignedTx(postParams).data},true);exports.sponsorshipSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,minSponsoredAssetFee:{type:ts_api_validator_1.NumberPart,required:true},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee}});exports.preSponsorship=function(data){return exports.sponsorshipSchema.parse(data)};exports.postSponsorship=remap_1.createRemapper({transactionType:null,type:constants.SPONSORSHIP_TX,version:constants.SPONSORSHIP_TX_VERSION});exports.sendSponsorshipTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.sponsorship,exports.preSponsorship,exports.postSponsorship,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedSponsorshipTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.sponsorship,exports.preSponsorship,exports.postSponsorship,function(postParams){return getSignedTx(postParams).data},true);exports.permissionSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,timestamp:schemaFields_1.default.timestamp,opType:{type:ts_api_validator_1.StringPart,required:true},role:{type:ts_api_validator_1.StringPart,required:true},target:{type:ts_api_validator_1.StringPart,required:true},dueTimestamp:{type:ts_api_validator_1.NumberPart,required:false},fee:schemaFields_1.default.fee}});exports.prePermit=function(data){return exports.permissionSchema.parse(data)};exports.postPermit=remap_1.createRemapper({transactionType:null,type:constants.PERMISSION_TX,version:constants.PERMISSION_TX_VERSION});exports.sendPermissionTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.permit,exports.prePermit,exports.postPermit,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedPermissionTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.permit,exports.prePermit,exports.postPermit,function(postParams){return getSignedTx(postParams).data},true);exports.dockerCreateSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,image:{type:ts_api_validator_1.StringPart,required:true},imageHash:{type:ts_api_validator_1.StringPart,required:true},contractName:{type:ts_api_validator_1.StringPart,required:true},params:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerCreate=function(data){return exports.dockerCreateSchema.parse(data)};exports.postDockerCreate=function(d){var data=JSON.parse(JSON.stringify(d.params));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{params:data,transactionType:null,type:constants.DOCKER_CREATE_TX,version:constants.DOCKER_CREATE_TX_VERSION});return result};exports.sendSignedDockerCreateTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCreate,exports.preDockerCreate,exports.postDockerCreate,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerCreateTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCreate,exports.preDockerCreate,exports.postDockerCreate,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.dockerCallSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,authorPublicKey:schemaFields_1.default.publicKey,contractId:{type:ts_api_validator_1.StringPart,required:true},params:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerCall=function(data){return exports.dockerCallSchema.parse(data)};exports.postDockerCall=function(d){var data=JSON.parse(JSON.stringify(d.params));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{params:data,transactionType:null,type:constants.DOCKER_CALL_TX,version:constants.DOCKER_CALL_TX_VERSION});return result};exports.sendSignedDockerCallTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCall,exports.preDockerCall,exports.postDockerCall,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerCallTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCall,exports.preDockerCall,exports.postDockerCall,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.dockerDisableSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,contractId:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerDisable=function(data){return exports.dockerDisableSchema.parse(data)};exports.postDockerDisable=function(d){return __assign({},d,{transactionType:null,type:constants.DOCKER_DISABLE_TX,version:constants.DOCKER_DISABLE_TX_VERSION})};exports.sendSignedDockerDisableTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerDisable,exports.preDockerDisable,exports.postDockerDisable,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerDisableTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerDisable,exports.preDockerDisable,exports.postDockerDisable,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true)},{"../../config":18,"../../constants":19,"../../libs/bignumber":22,"../../utils/remap":26,"../../utils/request":27,"../schemaFields":17,"@vostokplatform/signature-generator":undefined,"ts-api-validator":undefined}],16:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={time:function(){return fetch("/utils/time").then(function(t){return t.system})},script:{compile:function(code){return fetch("/utils/script/compile",{method:"POST",body:code}).then(function(response){return response.script})}}}},{"../../utils/request":27}],17:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var remap_1=require("../utils/remap");var constants=require("../constants");exports.default={publicKey:{type:ts_api_validator_1.StringPart,required:true},assetId:{type:ts_api_validator_1.StringPart,required:true},fee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_FEE},issueFee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_ISSUE_FEE},matcherFee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_MATCHER_FEE},recipient:{type:ts_api_validator_1.StringPart,required:true,parseValue:remap_1.removeRecipientPrefix},reissuable:{type:ts_api_validator_1.BooleanPart,required:false,defaultValue:false},timestamp:{type:ts_api_validator_1.NumberPart,required:true,parseValue:remap_1.getTimestamp}}},{"../constants":19,"../utils/remap":26,"ts-api-validator":undefined}],18:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var constants_1=require("./constants");var request_1=require("./utils/request");var config=Object.create(null);function checkRequiredFields(conf){if(!conf.networkByte)throw new Error("Missing network byte");if(!conf.nodeAddress)throw new Error("Missing node address");if(!conf.matcherAddress)throw new Error("Missing matcher address")}exports.default={getNetworkByte:function(){return config.networkByte},getNodeAddress:function(){return config.nodeAddress},isCryptoGost:function(){return config.crypto==="gost"},getMatcherAddress:function(){return config.matcherAddress},getMinimumSeedLength:function(){return config.minimumSeedLength},getRequestParams:function(){return{offset:config.requestOffset,limit:config.requestLimit}},getAssetFactory:function(){return config.assetFactory},getLogLevel:function(){return config.logLevel},getTimeDiff:function(){return config.timeDiff},get:function(){return __assign({},config)},set:function(newConfig){signature_generator_1.config.set(newConfig);if(Object.keys(config).length===0){newConfig=__assign({},constants_1.DEFAULT_BASIC_CONFIG,newConfig)}Object.keys(newConfig).forEach(function(key){switch(key){case"nodeAddress":case"matcherAddress":config[key]=request_1.normalizeHost(newConfig[key]);break;default:config[key]=newConfig[key];break}});checkRequiredFields(config)},clear:function(){Object.keys(config).forEach(function(key){delete config[key]})}}},{"./constants":19,"./utils/request":27,"@vostokplatform/signature-generator":undefined}],19:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});exports.WAVES="WAVES";exports.MAINNET_BYTE="D".charCodeAt(0);exports.TESTNET_BYTE="D".charCodeAt(0);exports.INITIAL_NONCE=0;exports.ADDRESS_BYTE=1;exports.ALIAS_BYTE=2;exports.ISSUE_TX=3;exports.TRANSFER_TX=4;exports.REISSUE_TX=5;exports.BURN_TX=6;exports.EXCHANGE_TX=7;exports.LEASE_TX=8;exports.CANCEL_LEASING_TX=9;exports.CREATE_ALIAS_TX=10;exports.MASS_TRANSFER_TX=11;exports.DATA_TX=12;exports.SET_SCRIPT_TX=13;exports.SPONSORSHIP_TX=14;exports.PERMISSION_TX=102;exports.DOCKER_CREATE_TX=103;exports.DOCKER_CALL_TX=104;exports.DOCKER_DISABLE_TX=106;exports.ISSUE_TX_VERSION=2;exports.TRANSFER_TX_VERSION=2;exports.REISSUE_TX_VERSION=2;exports.BURN_TX_VERSION=2;exports.EXCHANGE_TX_VERSION=2;exports.LEASE_TX_VERSION=2;exports.CANCEL_LEASING_TX_VERSION=2;exports.CREATE_ALIAS_TX_VERSION=2;exports.MASS_TRANSFER_TX_VERSION=1;exports.DATA_TX_VERSION=1;exports.SET_SCRIPT_TX_VERSION=1;exports.SPONSORSHIP_TX_VERSION=1;exports.PERMISSION_TX_VERSION=1;exports.DOCKER_CREATE_TX_VERSION=1;exports.DOCKER_CALL_TX_VERSION=1;exports.DOCKER_DISABLE_TX_VERSION=1;exports.ISSUE_TX_NAME="issue";exports.TRANSFER_TX_NAME="transfer";exports.REISSUE_TX_NAME="reissue";exports.BURN_TX_NAME="burn";exports.EXCHANGE_TX_NAME="exchange";exports.LEASE_TX_NAME="lease";exports.CANCEL_LEASING_TX_NAME="cancelLeasing";exports.CREATE_ALIAS_TX_NAME="createAlias";exports.MASS_TRANSFER_TX_NAME="massTransfer";exports.DATA_TX_NAME="data";exports.SET_SCRIPT_TX_NAME="setScript";exports.SPONSORSHIP_TX_NAME="sponsorship";exports.PERMISSION_TX_NAME="permit";exports.DOCKER_CREATE_TX_NAME="dockerCreate";exports.DOCKER_CALL_TX_NAME="dockerCall";exports.DOCKER_DISABLE_TX_NAME="dockerDisable";exports.PRIVATE_KEY_LENGTH=32;exports.PUBLIC_KEY_LENGTH=32;exports.PUBLIC_KEY_GOST_LENGTH=64;exports.MINIMUM_FEE=1e5;exports.MINIMUM_ISSUE_FEE=1e8;exports.MINIMUM_MATCHER_FEE=3e5;exports.MINIMUM_DATA_FEE_PER_KB=1e5;exports.TRANSFER_ATTACHMENT_BYTE_LIMIT=140;exports.DEFAULT_MIN_SEED_LENGTH=25;exports.DEFAULT_ORDER_EXPIRATION_DAYS=20;exports.DEFAULT_PAGING_LIMIT=50;exports.DEFAULT_PAGING_OFFSET=0;exports.DEFAULT_BASIC_CONFIG={minimumSeedLength:exports.DEFAULT_MIN_SEED_LENGTH,requestOffset:0,requestLimit:100,logLevel:"warning",timeDiff:0,crypto:"waves"};exports.DEFAULT_MAINNET_CONFIG=__assign({},exports.DEFAULT_BASIC_CONFIG,{networkByte:exports.MAINNET_BYTE,nodeAddress:"https://nodes.wavesplatform.com",matcherAddress:"https://matcher.wavesplatform.com/matcher"});exports.DEFAULT_TESTNET_CONFIG=__assign({},exports.DEFAULT_BASIC_CONFIG,{networkByte:exports.TESTNET_BYTE,nodeAddress:"https://testnet1.wavesnodes.com",matcherAddress:"https://testnet1.wavesnodes.com/matcher"});exports.WAVES_V1_ISSUE_TX={assetId:exports.WAVES,decimals:8,description:"",fee:0,height:0,id:exports.WAVES,name:"Waves",quantity:1e8*Math.pow(10,8),reissuable:false,sender:exports.WAVES,senderPublicKey:"",signature:"",timestamp:14604192e5,type:exports.ISSUE_TX};exports.BROADCAST_PATH="/transactions/broadcast"},{}],20:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});function paddedMessage(message){return"\n"+message+"\n"}function resolveData(data){if(data instanceof Error){return paddedMessage(data.toString())}else if(data){try{return paddedMessage(JSON.stringify(data,null,2))}catch(e){return paddedMessage("Not possible to retrieve error data")}}else{return paddedMessage("No additional data provided")}}var WavesError=function(_super){__extends(WavesError,_super);function WavesError(message,data){var _this=_super.call(this,message+":\n"+resolveData(data))||this;_this.name="WavesError";_this.data=data;if(Error.captureStackTrace){Error.captureStackTrace(_this,WavesError)}return _this}return WavesError}(Error);exports.default=WavesError},{}],21:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});var WavesError_1=require("./WavesError");var FAILED_TO_FETCH="Failed to fetch";function normalizeErrorData(data){if(!data.error&&data.message&&data.message.indexOf(FAILED_TO_FETCH)!==-1){return{error:-1,message:"failed to fetch"}}else{return data}}var WavesRequestError=function(_super){__extends(WavesRequestError,_super);function WavesRequestError(url,data){var _this=_super.call(this,"Server request to '"+url+"' has failed",normalizeErrorData(data))||this;_this.name="WavesRequestError";return _this}return WavesRequestError}(WavesError_1.default);exports.default=WavesRequestError},{"./WavesError":20}],22:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var bignumber_js_1=require("bignumber.js");bignumber_js_1.default.config({ROUNDING_MODE:bignumber_js_1.default.ROUND_DOWN});exports.default=bignumber_js_1.default},{"bignumber.js":undefined}],23:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var fetchSubstitute=function(){if(typeof window!=="undefined"){return window.fetch.bind(window)}else if(typeof exports==="object"&&typeof module!=="undefined"){return require("node-fetch")}else if(typeof self!=="undefined"){return self.fetch.bind(self)}else{throw new Error("Your environment is not defined")}}();exports.default=fetchSubstitute},{"node-fetch":undefined}],24:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var config_1=require("./config");var constants_1=require("./constants");var transactions_1=require("./utils/transactions");var base58ToString_1=require("./utils/base58ToString");exports.default={getAddressFromPublicKey:function(publicKey){var publicKeyBytes=signature_generator_1.libs.base58.decode(publicKey);return config_1.default.isCryptoGost()?signature_generator_1.utils.cryptoGost.buildRawAddress(publicKeyBytes):signature_generator_1.utils.crypto.buildRawAddress(publicKeyBytes)},calculateTimeDiff:function(nodeTime,userTime){return nodeTime-userTime},base58:{encode:signature_generator_1.libs.base58.encode,decode:signature_generator_1.libs.base58.decode,base58ToString:base58ToString_1.base58ToString},getMinimumDataTxFee:function(data){var emptyDataTx=new signature_generator_1.TX_TYPE_MAP.data({authorPublicKey:"11111111111111111111111111111111",senderPublicKey:"11111111111111111111111111111111",timestamp:0,fee:"",data:data});return emptyDataTx.getBytes().then(function(bytes){return Math.ceil(bytes.length/1024)*constants_1.MINIMUM_DATA_FEE_PER_KB})},createTransaction:transactions_1.createTransaction}},{"./config":18,"./constants":19,"./utils/base58ToString":25,"./utils/transactions":28,"@vostokplatform/signature-generator":undefined}],25:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");function base58ToString(base58String){var arr=signature_generator_1.libs.base58.decode(base58String);var str=String.fromCharCode.apply(null,arr);return decodeURIComponent(escape(str))}exports.base58ToString=base58ToString},{"@vostokplatform/signature-generator":undefined}],26:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var constants_1=require("../constants");var config_1=require("../config");var bignumber_1=require("../libs/bignumber");function normalizeAssetId(original){if(!original||original===constants_1.WAVES){return""}else{return original}}exports.normalizeAssetId=normalizeAssetId;function removeRecipientPrefix(original){if(original.slice(0,8)==="address:"){return original.slice(8)}else{return original}}exports.removeRecipientPrefix=removeRecipientPrefix;function removeAliasPrefix(original){if(original.slice(0,6)==="alias:"){return original.slice(8)}else{return original}}exports.removeAliasPrefix=removeAliasPrefix;function getTimestamp(timestamp){return(timestamp||Date.now())+config_1.default.getTimeDiff()}exports.getTimestamp=getTimestamp;function precisionCheck(precision){return precision>=0&&precision<=8}exports.precisionCheck=precisionCheck;function castFromBytesToBase58(bytes,sliceIndex){var processedBytes=Uint8Array.from(Array.prototype.slice.call(bytes,sliceIndex));return signature_generator_1.libs.base58.encode(processedBytes)}function castFromStringToBase58(str,sliceIndex){var processedBytes=Uint8Array.from(Array.prototype.slice.call(unescape(encodeURIComponent(str)).split("").map(function(e){return e.charCodeAt(0)}),sliceIndex));return signature_generator_1.libs.base58.encode(processedBytes)}function castFromRawToPrefixed(raw){if(raw.length>30){return"address:"+raw}else{var networkCharacter=String.fromCharCode(config_1.default.getNetworkByte());return"alias:"+networkCharacter+":"+raw}}function createRemapper(rules){return function(data){return Object.keys(__assign({},data,rules)).reduce(function(result,key){var rule=rules[key];if(typeof rule==="function"){result[key]=rule(data[key])}else if(typeof rule==="string"){result[rule]=data[key]}else if(rule&&typeof rule==="object"){if(rule.from==="bytes"&&rule.to==="base58"){result[key]=castFromBytesToBase58(data[key],rule.slice||0)}else if(rule.from==="string"&&rule.to==="base58"){result[key]=castFromStringToBase58(data[key],rule.slice||0)}else if(rule.from==="string"&&rule.to==="bignumber"){result[key]=new bignumber_1.default(data[key])}else if(rule.from==="raw"&&rule.to==="prefixed"){if(data[key].length&&data[key][0].recipient){result[rule.path||key]=data[key].map(function(o){return __assign({},o,{amount:new bignumber_1.default(o.amount),recipient:castFromRawToPrefixed(o.recipient)})})}else{result[rule.path||key]=castFromRawToPrefixed(data[key])}}}else if(rule!==null){result[key]=typeof data[key]!=="undefined"?data[key]:rule}return result},Object.create(null))}}exports.createRemapper=createRemapper},{"../config":18,"../constants":19,"../libs/bignumber":22,"@vostokplatform/signature-generator":undefined}],27:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var create=require("parse-json-bignumber");var WavesRequestError_1=require("../errors/WavesRequestError");var fetch_1=require("../libs/fetch");var config_1=require("../config");var bignumber_1=require("../libs/bignumber");var SAFE_JSON_PARSE=create({BigNumber:bignumber_1.default}).parse;var SAFE_JSON_STRINGIFY=create({BigNumber:bignumber_1.default}).stringify;exports.POST_TEMPLATE={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"}};var key=function(product,version){return product+"/"+version};var hostResolvers=(_a={},_a[key(0,0)]=function(){return config_1.default.getNodeAddress()},_a[key(1,0)]=function(){return config_1.default.getMatcherAddress()},_a);function normalizeHost(host){return host.replace(/\/+$/,"")}exports.normalizeHost=normalizeHost;function normalizePath(path){return("/"+path).replace(/\/+/g,"/").replace(/\/$/,"")}exports.normalizePath=normalizePath;function processJSON(res){if(res.ok){return res.text().then(SAFE_JSON_PARSE)}else{return res.json().then(Promise.reject.bind(Promise))}}exports.processJSON=processJSON;function handleError(url,data){throw new WavesRequestError_1.default(url,data)}function createFetchWrapper(product,version,pipe){var resolveHost=hostResolvers[key(product,version)];return function(path,options){var url=resolveHost()+normalizePath(path);var request=fetch_1.default(url,options);if(pipe){return request.then(pipe).catch(function(data){return handleError(url,data)})}else{return request.catch(function(data){return handleError(url,data)})}}}exports.createFetchWrapper=createFetchWrapper;function wrapTxRequest(SignatureGenerator,preRemapAsync,postRemap,callback,withProofs){if(withProofs===void 0){withProofs=false}return function(data,keyPair){return preRemapAsync(__assign({},data,{senderPublicKey:keyPair.publicKey})).then(function(validatedData){var transaction=new SignatureGenerator(validatedData);return transaction.getSignature(keyPair.privateKey).then(function(signature){return postRemap(__assign({},validatedData,withProofs?{proofs:[signature]}:{signature:signature}))}).then(function(tx){var sendData=__assign({},exports.POST_TEMPLATE,{rejectUnauthorized:false,body:SAFE_JSON_STRINGIFY(tx,null,null)});console.log(sendData);return callback(sendData)})})}}exports.wrapTxRequest=wrapTxRequest;var _a},{"../config":18,"../errors/WavesRequestError":21,"../libs/bignumber":22,"../libs/fetch":23,"parse-json-bignumber":undefined}],28:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var txHelpers=require("../api/node/transactions.x");var capitalize=function(name){return name.slice(0,1).toUpperCase()+name.slice(1)};var TransactionWrapper=function(){function TransactionWrapper(signatureGenerator,validatedData,postRemap,proofs){this.signatureGenerator=signatureGenerator;this.validatedData=validatedData;this.postRemap=postRemap;this.proofs=proofs;this._privateKeys=[]}TransactionWrapper.prototype.addProof=function(privateKey){this._privateKeys.push(privateKey);return this};TransactionWrapper.prototype.getJSON=function(){var _this=this;return Promise.all(this._privateKeys.map(function(privateKey){return _this.signatureGenerator.getSignature(privateKey)})).then(function(newProofs){return _this.postRemap(__assign({},_this.validatedData,{proofs:[].concat(_this.proofs,newProofs)}))})};return TransactionWrapper}();exports.createTransaction=function(type,data){var name=capitalize(type);var preRemap=txHelpers["pre"+name];var postRemap=txHelpers["post"+name];if(!preRemap||!postRemap||!signature_generator_1.TX_TYPE_MAP[type]){throw new Error("Unknown transaction type: "+type)}var proofs=data.proofs||[];return preRemap(data).then(function(validatedData){var signatureGenerator=new signature_generator_1.TX_TYPE_MAP[type](validatedData);return new TransactionWrapper(signatureGenerator,validatedData,postRemap,proofs)})}},{"../api/node/transactions.x":15,"@vostokplatform/signature-generator":undefined}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WavesAPI=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var request=require("./utils/request");var NodeAPI=require("./api/node/index");var MatcherAPI=require("./api/matcher/index");var constants=require("./constants");var config_1=require("./config");var tools_1=require("./tools");var WavesAPI=function(){function WavesAPI(initialConfiguration){this.Seed=signature_generator_1.Seed;this.byteProcessors=signature_generator_1.ByteProcessor;this.config=config_1.default;this.constants=constants;this.crypto=signature_generator_1.utils.crypto;this.request=request;this.tools=tools_1.default;this.API={Node:NodeAPI,Matcher:MatcherAPI};if(this instanceof WavesAPI){this.config.clear();this.config.set(initialConfiguration);if(WavesAPI._instance===null){WavesAPI._instance=this}else{return WavesAPI._instance}}else{return new WavesAPI(initialConfiguration)}}return WavesAPI}();function create(config){return new WavesAPI(config)}exports.create=create;exports.MAINNET_CONFIG=constants.DEFAULT_MAINNET_CONFIG;exports.TESTNET_CONFIG=constants.DEFAULT_TESTNET_CONFIG},{"./api/matcher/index":2,"./api/node/index":11,"./config":18,"./constants":19,"./tools":24,"./utils/request":27,"@vostokplatform/signature-generator":undefined}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var info_1=require("./info");var orderbooks_1=require("./orderbooks");exports.getMatcherKey=info_1.default.getMatcherKey;exports.getOrderbooks=orderbooks_1.default.getOrderbooks;exports.getOrderbook=orderbooks_1.default.getOrderbook;exports.getOrders=orderbooks_1.default.getOrders;exports.getAllOrders=orderbooks_1.default.getAllOrders;exports.createOrder=orderbooks_1.default.createOrder;exports.cancelOrder=orderbooks_1.default.cancelOrder;exports.deleteOrder=orderbooks_1.default.deleteOrder},{"./info":3,"./orderbooks":4}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(1,0,request_1.processJSON);exports.default={getMatcherKey:function(){return fetch("/")}}},{"../../utils/request":27}],4:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var request_1=require("../../utils/request");var remap_1=require("../../utils/remap");var request_2=require("../../utils/request");var orderbooks_x_1=require("./orderbooks.x");var fetch=request_1.createFetchWrapper(1,0,request_1.processJSON);var preCreateOrderAsync=function(data){return orderbooks_x_1.createOrderSchema.parse(data)};var postCreateOrder=function(data){data.assetPair={amountAsset:remap_1.normalizeAssetId(data.amountAsset),priceAsset:remap_1.normalizeAssetId(data.priceAsset)};delete data.amountAsset;delete data.priceAsset;return data};var postCancelOrder=remap_1.createRemapper({senderPublicKey:"sender"});var generateCancelLikeRequest=function(type){return function(amountAssetId,priceAssetId,orderId,keyPair){var data={senderPublicKey:keyPair.publicKey,orderId:orderId};var authData=new signature_generator_1.CANCEL_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){return postCancelOrder(__assign({},data,{signature:signature}))}).then(function(tx){return fetch("/orderbook/"+amountAssetId+"/"+priceAssetId+"/"+type,__assign({},request_2.POST_TEMPLATE,{body:JSON.stringify(tx)}))})}};exports.default={getOrderbooks:function(){return fetch("/orderbook")},getOrderbook:function(assetOne,assetTwo){return fetch("/orderbook/"+assetOne+"/"+assetTwo)},getOrders:function(assetOne,assetTwo,keyPair){var data={senderPublicKey:keyPair.publicKey,timestamp:remap_1.getTimestamp()};var authData=new signature_generator_1.AUTH_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){var preparedData=__assign({},data,{signature:signature});return fetch("/orderbook/"+assetOne+"/"+assetTwo+"/publicKey/"+keyPair.publicKey,{headers:{Timestamp:preparedData.timestamp,Signature:preparedData.signature}})})},getAllOrders:function(keyPair){var data={senderPublicKey:keyPair.publicKey,timestamp:remap_1.getTimestamp()};var authData=new signature_generator_1.AUTH_ORDER_SIGNATURE(data);return authData.getSignature(keyPair.privateKey).then(function(signature){var preparedData=__assign({},data,{signature:signature});return fetch("/orderbook/"+keyPair.publicKey,{headers:{Timestamp:preparedData.timestamp,Signature:preparedData.signature}})})},createOrder:request_1.wrapTxRequest(signature_generator_1.CREATE_ORDER_SIGNATURE,preCreateOrderAsync,postCreateOrder,function(postParams){return fetch("/orderbook",postParams)}),cancelOrder:generateCancelLikeRequest("cancel"),deleteOrder:generateCancelLikeRequest("delete")}},{"../../utils/remap":26,"../../utils/request":27,"./orderbooks.x":5,"@vostokplatform/signature-generator":undefined}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var remap_1=require("../../utils/remap");var constants_1=require("../../constants");var schemaFields_1=require("../schemaFields");exports.createOrderSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,matcherPublicKey:schemaFields_1.default.publicKey,amountAsset:schemaFields_1.default.assetId,priceAsset:schemaFields_1.default.assetId,orderType:{type:ts_api_validator_1.StringPart,required:true,isValid:function(orderType){return orderType==="buy"||orderType==="sell"}},amount:{type:ts_api_validator_1.NumberPart,required:true},price:{type:ts_api_validator_1.NumberPart,required:true},timestamp:schemaFields_1.default.timestamp,expiration:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(expiration){if(expiration){return remap_1.getTimestamp(expiration)}else{var date=new Date(remap_1.getTimestamp());return date.setDate(date.getDate()+constants_1.DEFAULT_ORDER_EXPIRATION_DAYS)}}},matcherFee:schemaFields_1.default.matcherFee}})},{"../../constants":19,"../../utils/remap":26,"../schemaFields":17,"ts-api-validator":undefined}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var constants_1=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={balance:function(address,confirmations){if(!confirmations){return fetch("/addresses/balance/"+address)}else{return fetch("/addresses/balance/"+address+"/"+confirmations)}},balanceDetails:function(address){return fetch("/addresses/balance/details/"+address)},data:function(address,offset,limit){if(offset===void 0){offset=constants_1.DEFAULT_PAGING_OFFSET}if(limit===void 0){limit=constants_1.DEFAULT_PAGING_LIMIT}return fetch("/addresses/data/"+address+"?offset="+offset+"&limit="+limit)}}},{"../../constants":19,"../../utils/request":27}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={byAlias:function(alias){return fetch("/alias/by-alias/"+alias)},byAddress:function(address){return fetch("/alias/by-address/"+address)}}},{"../../utils/request":27}],8:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var addresses_1=require("./addresses");var constants=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={balances:function(address){return fetch("/assets/balance/"+address)},balance:function(address,assetId){if(assetId===constants.WAVES){return addresses_1.default.balance(address)}else{return fetch("/assets/balance/"+address+"/"+assetId)}},distribution:function(assetId){return fetch("/assets/"+assetId+"/distribution")}}},{"../../constants":19,"../../utils/request":27,"./addresses":6}],9:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(signature){return fetch("/blocks/signature/"+signature)},at:function(height){return fetch("/blocks/at/"+height)},first:function(){return fetch("/blocks/first")},last:function(){return fetch("/blocks/last")},height:function(){return fetch("/blocks/height")}}},{"../../utils/request":27}],10:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var constants_1=require("../../constants");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(id,offset,limit){if(offset===void 0){offset=constants_1.DEFAULT_PAGING_OFFSET}if(limit===void 0){limit=constants_1.DEFAULT_PAGING_LIMIT}return fetch("/contracts/"+id+"?offset="+offset+"&limit="+limit)},getKey:function(id,key){return fetch("/contracts/"+id+"/"+key)},getExecutedTxFor:function(id){return fetch("/contracts/executed-tx-for/"+id)}}},{"../../constants":19,"../../utils/request":27}],11:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var addresses_1=require("./addresses");var aliases_1=require("./aliases");var assets_1=require("./assets");var blocks_1=require("./blocks");var contracts_1=require("./contracts");var leasing_1=require("./leasing");var transactions_1=require("./transactions");var peers_1=require("./peers");var utils_1=require("./utils");exports.addresses=addresses_1.default;exports.aliases=aliases_1.default;exports.assets=assets_1.default;exports.blocks=blocks_1.default;exports.contracts=contracts_1.default;exports.leasing=leasing_1.default;exports.transactions=transactions_1.default;exports.peers=peers_1.default;exports.utils=utils_1.default},{"./addresses":6,"./aliases":7,"./assets":8,"./blocks":9,"./contracts":10,"./leasing":12,"./peers":13,"./transactions":14,"./utils":16}],12:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={getAllActiveLeases:function(address){return fetch("/leasing/active/"+address).then(function(list){return list.map(function(tx){tx.status="active";return tx})})}}},{"../../utils/request":27}],13:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={connected:function(){return fetch("/peers/connected")}}},{"../../utils/request":27}],14:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var WavesError_1=require("../../errors/WavesError");var constants=require("../../constants");var config_1=require("../../config");var requests=require("./transactions.x");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={get:function(id){if(id===constants.WAVES){return Promise.resolve(constants.WAVES_V1_ISSUE_TX)}else{return fetch("/transactions/info/"+id)}},getList:function(address,limit){if(limit===void 0){limit=config_1.default.getRequestParams().limit}return fetch("/transactions/address/"+address+"/limit/"+limit).then(function(array){return array[0]})},utxSize:function(){return fetch("/transactions/unconfirmed/size")},utxGet:function(id){return fetch("/transactions/unconfirmed/info/"+id)},utxGetList:function(){return fetch("/transactions/unconfirmed")},broadcast:function(type,data,keys){switch(type){case constants.ISSUE_TX_NAME:return requests.sendIssueTx(data,keys);case constants.TRANSFER_TX_NAME:return requests.sendTransferTx(data,keys);case constants.REISSUE_TX_NAME:return requests.sendReissueTx(data,keys);case constants.BURN_TX_NAME:return requests.sendBurnTx(data,keys);case constants.LEASE_TX_NAME:return requests.sendLeaseTx(data,keys);case constants.CANCEL_LEASING_TX_NAME:return requests.sendCancelLeasingTx(data,keys);case constants.CREATE_ALIAS_TX_NAME:return requests.sendCreateAliasTx(data,keys);case constants.MASS_TRANSFER_TX_NAME:return requests.sendMassTransferTx(data,keys);case constants.DATA_TX_NAME:return requests.sendDataTx(data,keys);case constants.SET_SCRIPT_TX_NAME:return requests.sendSetScriptTx(data,keys);case constants.SPONSORSHIP_TX_NAME:return requests.sendSponsorshipTx(data,keys);case constants.PERMISSION_TX_NAME:return requests.sendPermissionTx(data,keys);case constants.DOCKER_CREATE_TX_NAME:return requests.sendDockerCreateTx(data,keys);case constants.DOCKER_CALL_TX_NAME:return requests.sendDockerCallTx(data,keys);case constants.DOCKER_DISABLE_TX_NAME:return requests.sendDockerDisableTx(data,keys);case constants.POLICY_REGISTER_NODE_TX_NAME:return requests.sendNodeRegistry(data,keys);default:throw new WavesError_1.default("Wrong transaction type: "+type,data)}},sign:function(type,data,keys){switch(type){case constants.ISSUE_TX_NAME:return requests.sendSignedIssueTx(data,keys);case constants.TRANSFER_TX_NAME:return requests.sendSignedTransferTx(data,keys);case constants.REISSUE_TX_NAME:return requests.sendSignedReissueTx(data,keys);case constants.BURN_TX_NAME:return requests.sendSignedBurnTx(data,keys);case constants.LEASE_TX_NAME:return requests.sendSignedLeaseTx(data,keys);case constants.CANCEL_LEASING_TX_NAME:return requests.sendSignedCancelLeasingTx(data,keys);case constants.CREATE_ALIAS_TX_NAME:return requests.sendSignedCreateAliasTx(data,keys);case constants.MASS_TRANSFER_TX_NAME:return requests.sendSignedMassTransferTx(data,keys);case constants.DATA_TX_NAME:return requests.sendSignedDataTx(data,keys);case constants.SET_SCRIPT_TX_NAME:return requests.sendSignedSetScriptTx(data,keys);case constants.SPONSORSHIP_TX_NAME:return requests.sendSignedSponsorshipTx(data,keys);case constants.PERMISSION_TX_NAME:return requests.sendSignedPermissionTx(data,keys);case constants.DOCKER_CREATE_TX_NAME:return requests.sendSignedDockerCreateTx(data,keys);case constants.DOCKER_CALL_TX_NAME:return requests.sendSignedDockerCallTx(data,keys);case constants.DOCKER_DISABLE_TX_NAME:return requests.sendSignedDockerDisableTx(data,keys);case constants.POLICY_REGISTER_NODE_TX_NAME:return requests.signNodeRegistry(data,keys);default:throw new WavesError_1.default("Wrong transaction type: "+type,data)}},rawBroadcast:function(data){return fetch(constants.BROADCAST_PATH,__assign({},request_1.POST_TEMPLATE,{body:JSON.stringify(data)}))},signOnNode:function(data){return fetch("/transactions/sign")}}},{"../../config":18,"../../constants":19,"../../errors/WavesError":20,"../../utils/request":27,"./transactions.x":15}],15:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var signature_generator_1=require("@vostokplatform/signature-generator");var schemaFields_1=require("../schemaFields");var remap_1=require("../../utils/remap");var request_1=require("../../utils/request");var constants=require("../../constants");var config_1=require("../../config");var bignumber_1=require("../../libs/bignumber");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);var AnyPart=function(_super){__extends(AnyPart,_super);function AnyPart(){return _super!==null&&_super.apply(this,arguments)||this}AnyPart.prototype.getValue=function(data){return data};return AnyPart}(ts_api_validator_1.BasePart);function getSignedTx(data){return{data:new Promise(function(resolve){resolve(JSON.parse(data.body))})}}exports.issueSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,name:{type:ts_api_validator_1.StringPart,required:true},description:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},script:{type:ts_api_validator_1.StringPart,required:false,defaultValue:"base64:AQa3b8tH"},quantity:{type:ts_api_validator_1.StringPart,required:true},precision:{type:ts_api_validator_1.NumberPart,required:true,isValid:remap_1.precisionCheck},reissuable:schemaFields_1.default.reissuable,fee:schemaFields_1.default.issueFee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preIssue=function(data){return exports.issueSchema.parse(data)};exports.postIssue=remap_1.createRemapper({transactionType:null,precision:"decimals",type:constants.ISSUE_TX,version:constants.ISSUE_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendIssueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.issue,exports.preIssue,exports.postIssue,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedIssueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.issue,exports.preIssue,exports.postIssue,function(postParams){return getSignedTx(postParams).data},true);exports.transferSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,recipient:schemaFields_1.default.recipient,assetId:schemaFields_1.default.assetId,amount:{type:ts_api_validator_1.StringPart,required:true},feeAssetId:{type:ts_api_validator_1.StringPart,required:false,defaultValue:constants.WAVES},fee:schemaFields_1.default.fee,attachment:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},timestamp:schemaFields_1.default.timestamp}});exports.preTransfer=function(data){return exports.transferSchema.parse(data)};exports.postTransfer=remap_1.createRemapper({transactionType:null,assetId:remap_1.normalizeAssetId,feeAssetId:remap_1.normalizeAssetId,attachment:{from:"string",to:"base58"},recipient:{from:"raw",to:"prefixed"},amount:{from:"string",to:"bignumber"},type:constants.TRANSFER_TX,version:constants.TRANSFER_TX_VERSION});exports.sendTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.transfer,exports.preTransfer,exports.postTransfer,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.transfer,exports.preTransfer,exports.postTransfer,function(postParams){return getSignedTx(postParams).data},true);exports.reissueSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,quantity:{type:ts_api_validator_1.StringPart,required:true},reissuable:schemaFields_1.default.reissuable,fee:schemaFields_1.default.issueFee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preReissue=function(data){return exports.reissueSchema.parse(data)};exports.postReissue=remap_1.createRemapper({transactionType:null,type:constants.REISSUE_TX,version:constants.REISSUE_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendReissueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.reissue,exports.preReissue,exports.postReissue,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedReissueTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.reissue,exports.preReissue,exports.postReissue,function(postParams){return getSignedTx(postParams).data},true);exports.burnSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,quantity:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preBurn=function(data){return exports.burnSchema.parse(data)};exports.postBurn=remap_1.createRemapper({transactionType:null,type:constants.BURN_TX,version:constants.BURN_TX_VERSION,quantity:{from:"string",to:"bignumber"}});exports.sendBurnTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.burn,exports.preBurn,exports.postBurn,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedBurnTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.burn,exports.preBurn,exports.postBurn,function(postParams){return getSignedTx(postParams).data},true);exports.leaseSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,recipient:schemaFields_1.default.recipient,amount:{type:ts_api_validator_1.NumberPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preLease=function(data){return exports.leaseSchema.parse(data)};exports.postLease=remap_1.createRemapper({transactionType:null,recipient:{from:"raw",to:"prefixed"},type:constants.LEASE_TX,version:constants.LEASE_TX_VERSION});exports.sendLeaseTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.lease,exports.preLease,exports.postLease,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedLeaseTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.lease,exports.preLease,exports.postLease,function(postParams){return getSignedTx(postParams).data},true);exports.cancelLeasingSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,leaseId:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp,chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}}}});exports.preCancelLeasing=function(data){return exports.cancelLeasingSchema.parse(data)};exports.postCancelLeasing=remap_1.createRemapper({transactionType:null,transactionId:"txId",type:constants.CANCEL_LEASING_TX,version:constants.CANCEL_LEASING_TX_VERSION});exports.sendCancelLeasingTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.cancelLeasing,exports.preCancelLeasing,exports.postCancelLeasing,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedCancelLeasingTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.cancelLeasing,exports.preCancelLeasing,exports.postCancelLeasing,function(postParams){return getSignedTx(postParams).data},true);exports.createAliasSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,alias:{type:ts_api_validator_1.StringPart,required:true,parseValue:remap_1.removeAliasPrefix},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preCreateAlias=function(data){return exports.createAliasSchema.parse(data)};exports.postCreateAlias=remap_1.createRemapper({transactionType:null,type:constants.CREATE_ALIAS_TX,version:constants.CREATE_ALIAS_TX_VERSION});exports.sendCreateAliasTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.createAlias,exports.preCreateAlias,exports.postCreateAlias,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedCreateAliasTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.createAlias,exports.preCreateAlias,exports.postCreateAlias,function(postParams){return getSignedTx(postParams).data},true);exports.massTransferSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,transfers:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{recipient:schemaFields_1.default.recipient,amount:{type:ts_api_validator_1.StringPart,required:true}}},defaultValue:[]},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee,attachment:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""}}});exports.preMassTransfer=function(data){return exports.massTransferSchema.parse(data)};exports.postMassTransfer=remap_1.createRemapper({transactionType:null,assetId:remap_1.normalizeAssetId,attachment:{from:"string",to:"base58"},transfers:{from:"raw",to:"prefixed",path:"transfers"},type:constants.MASS_TRANSFER_TX,version:constants.MASS_TRANSFER_TX_VERSION});exports.sendMassTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.massTransfer,exports.preMassTransfer,exports.postMassTransfer,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedMassTransferTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.massTransfer,exports.preMassTransfer,exports.postMassTransfer,function(postParams){return getSignedTx(postParams).data},true);exports.dataSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,authorPublicKey:schemaFields_1.default.publicKey,data:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preData=function(data){return exports.dataSchema.parse(data)};exports.postData=function(d){var data=JSON.parse(JSON.stringify(d.data));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{data:data,transactionType:null,type:constants.DATA_TX,version:constants.DATA_TX_VERSION});return result};exports.sendDataTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.data,exports.preData,exports.postData,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedDataTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.data,exports.preData,exports.postData,function(postParams){return getSignedTx(postParams).data},true);exports.setScriptSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{name:{type:ts_api_validator_1.StringPart,required:true},description:{type:ts_api_validator_1.StringPart,required:false,defaultValue:""},senderPublicKey:schemaFields_1.default.publicKey,script:{type:ts_api_validator_1.StringPart,required:true},chainId:{type:ts_api_validator_1.NumberPart,required:true,parseValue:function(){return config_1.default.getNetworkByte()}},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee}});exports.preSetScript=function(data){return exports.setScriptSchema.parse(data)};exports.postSetScript=remap_1.createRemapper({transactionType:null,type:constants.SET_SCRIPT_TX,version:constants.SET_SCRIPT_TX_VERSION});exports.sendSetScriptTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.setScript,exports.preSetScript,exports.postSetScript,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedSetScriptTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.setScript,exports.preSetScript,exports.postSetScript,function(postParams){return getSignedTx(postParams).data},true);exports.sponsorshipSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,assetId:schemaFields_1.default.assetId,minSponsoredAssetFee:{type:ts_api_validator_1.NumberPart,required:true},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee}});exports.preSponsorship=function(data){return exports.sponsorshipSchema.parse(data)};exports.postSponsorship=remap_1.createRemapper({transactionType:null,type:constants.SPONSORSHIP_TX,version:constants.SPONSORSHIP_TX_VERSION});exports.sendSponsorshipTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.sponsorship,exports.preSponsorship,exports.postSponsorship,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedSponsorshipTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.sponsorship,exports.preSponsorship,exports.postSponsorship,function(postParams){return getSignedTx(postParams).data},true);exports.permissionSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,timestamp:schemaFields_1.default.timestamp,opType:{type:ts_api_validator_1.StringPart,required:true},role:{type:ts_api_validator_1.StringPart,required:true},target:{type:ts_api_validator_1.StringPart,required:true},dueTimestamp:{type:ts_api_validator_1.NumberPart,required:false},fee:schemaFields_1.default.fee}});exports.prePermit=function(data){return exports.permissionSchema.parse(data)};exports.postPermit=remap_1.createRemapper({transactionType:null,type:constants.PERMISSION_TX,version:constants.PERMISSION_TX_VERSION});exports.sendPermissionTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.permit,exports.prePermit,exports.postPermit,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.sendSignedPermissionTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.permit,exports.prePermit,exports.postPermit,function(postParams){return getSignedTx(postParams).data},true);exports.dockerCreateSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,image:{type:ts_api_validator_1.StringPart,required:true},imageHash:{type:ts_api_validator_1.StringPart,required:true},contractName:{type:ts_api_validator_1.StringPart,required:true},params:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerCreate=function(data){return exports.dockerCreateSchema.parse(data)};exports.postDockerCreate=function(d){var data=JSON.parse(JSON.stringify(d.params));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{params:data,transactionType:null,type:constants.DOCKER_CREATE_TX,version:constants.DOCKER_CREATE_TX_VERSION});return result};exports.sendSignedDockerCreateTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCreate,exports.preDockerCreate,exports.postDockerCreate,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerCreateTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCreate,exports.preDockerCreate,exports.postDockerCreate,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.dockerCallSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,authorPublicKey:schemaFields_1.default.publicKey,contractId:{type:ts_api_validator_1.StringPart,required:true},params:{type:ts_api_validator_1.ArrayPart,content:{type:ts_api_validator_1.ObjectPart,required:true,content:{type:{type:ts_api_validator_1.StringPart,required:true},key:{type:ts_api_validator_1.StringPart,required:true},value:{type:AnyPart,required:true}}},defaultValue:[]},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerCall=function(data){return exports.dockerCallSchema.parse(data)};exports.postDockerCall=function(d){var data=JSON.parse(JSON.stringify(d.params));data.forEach(function(e){if(e.type==="integer"&&typeof e.value==="string"){e.value=new bignumber_1.default(e.value)}return e});var result=__assign({},d,{params:data,transactionType:null,type:constants.DOCKER_CALL_TX,version:constants.DOCKER_CALL_TX_VERSION});return result};exports.sendSignedDockerCallTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCall,exports.preDockerCall,exports.postDockerCall,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerCallTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerCall,exports.preDockerCall,exports.postDockerCall,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.dockerDisableSchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,contractId:{type:ts_api_validator_1.StringPart,required:true},fee:schemaFields_1.default.fee,timestamp:schemaFields_1.default.timestamp}});exports.preDockerDisable=function(data){return exports.dockerDisableSchema.parse(data)};exports.postDockerDisable=function(d){return __assign({},d,{transactionType:null,type:constants.DOCKER_DISABLE_TX,version:constants.DOCKER_DISABLE_TX_VERSION})};exports.sendSignedDockerDisableTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerDisable,exports.preDockerDisable,exports.postDockerDisable,function(postParams){return getSignedTx(postParams).data},true);exports.sendDockerDisableTx=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.dockerDisable,exports.preDockerDisable,exports.postDockerDisable,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true);exports.nodeRegistrySchema=new ts_api_validator_1.Schema({type:ts_api_validator_1.ObjectPart,required:true,content:{senderPublicKey:schemaFields_1.default.publicKey,targetPubKey:schemaFields_1.default.publicKey,nodeName:{type:ts_api_validator_1.StringPart,required:true},opType:{type:ts_api_validator_1.StringPart,required:true},timestamp:schemaFields_1.default.timestamp,fee:schemaFields_1.default.fee}});exports.preNodeRegistry=function(data){return exports.nodeRegistrySchema.parse(data)};exports.postNodeRegistry=function(d){return __assign({},d,{transactionType:null,type:constants.POLICY_REGISTER_NODE_TX,version:constants.POLICY_REGISTER_NODE_TX_VERSION})};exports.signNodeRegistry=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.policyRegisterNode,exports.preNodeRegistry,exports.postNodeRegistry,function(postParams){return getSignedTx(postParams).data},true);exports.sendNodeRegistry=request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.policyRegisterNode,exports.preNodeRegistry,exports.postNodeRegistry,function(postParams){return fetch(constants.BROADCAST_PATH,postParams)},true)},{"../../config":18,"../../constants":19,"../../libs/bignumber":22,"../../utils/remap":26,"../../utils/request":27,"../schemaFields":17,"@vostokplatform/signature-generator":undefined,"ts-api-validator":undefined}],16:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var request_1=require("../../utils/request");var fetch=request_1.createFetchWrapper(0,0,request_1.processJSON);exports.default={time:function(){return fetch("/utils/time").then(function(t){return t.system})},script:{compile:function(code){return fetch("/utils/script/compile",{method:"POST",body:code}).then(function(response){return response.script})}}}},{"../../utils/request":27}],17:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ts_api_validator_1=require("ts-api-validator");var remap_1=require("../utils/remap");var constants=require("../constants");exports.default={publicKey:{type:ts_api_validator_1.StringPart,required:true},assetId:{type:ts_api_validator_1.StringPart,required:true},fee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_FEE},issueFee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_ISSUE_FEE},matcherFee:{type:ts_api_validator_1.NumberPart,required:false,defaultValue:constants.MINIMUM_MATCHER_FEE},recipient:{type:ts_api_validator_1.StringPart,required:true,parseValue:remap_1.removeRecipientPrefix},reissuable:{type:ts_api_validator_1.BooleanPart,required:false,defaultValue:false},timestamp:{type:ts_api_validator_1.NumberPart,required:true,parseValue:remap_1.getTimestamp}}},{"../constants":19,"../utils/remap":26,"ts-api-validator":undefined}],18:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var constants_1=require("./constants");var request_1=require("./utils/request");var config=Object.create(null);function checkRequiredFields(conf){if(!conf.networkByte)throw new Error("Missing network byte");if(!conf.nodeAddress)throw new Error("Missing node address");if(!conf.matcherAddress)throw new Error("Missing matcher address")}exports.default={getNetworkByte:function(){return config.networkByte},getNodeAddress:function(){return config.nodeAddress},isCryptoGost:function(){return config.crypto==="gost"},getMatcherAddress:function(){return config.matcherAddress},getMinimumSeedLength:function(){return config.minimumSeedLength},getRequestParams:function(){return{offset:config.requestOffset,limit:config.requestLimit}},getAssetFactory:function(){return config.assetFactory},getLogLevel:function(){return config.logLevel},getTimeDiff:function(){return config.timeDiff},get:function(){return __assign({},config)},set:function(newConfig){signature_generator_1.config.set(newConfig);if(Object.keys(config).length===0){newConfig=__assign({},constants_1.DEFAULT_BASIC_CONFIG,newConfig)}Object.keys(newConfig).forEach(function(key){switch(key){case"nodeAddress":case"matcherAddress":config[key]=request_1.normalizeHost(newConfig[key]);break;default:config[key]=newConfig[key];break}});checkRequiredFields(config)},clear:function(){Object.keys(config).forEach(function(key){delete config[key]})}}},{"./constants":19,"./utils/request":27,"@vostokplatform/signature-generator":undefined}],19:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});exports.WAVES="WAVES";exports.MAINNET_BYTE="D".charCodeAt(0);exports.TESTNET_BYTE="D".charCodeAt(0);exports.INITIAL_NONCE=0;exports.ADDRESS_BYTE=1;exports.ALIAS_BYTE=2;exports.ISSUE_TX=3;exports.TRANSFER_TX=4;exports.REISSUE_TX=5;exports.BURN_TX=6;exports.EXCHANGE_TX=7;exports.LEASE_TX=8;exports.CANCEL_LEASING_TX=9;exports.CREATE_ALIAS_TX=10;exports.MASS_TRANSFER_TX=11;exports.DATA_TX=12;exports.SET_SCRIPT_TX=13;exports.SPONSORSHIP_TX=14;exports.PERMISSION_TX=102;exports.DOCKER_CREATE_TX=103;exports.DOCKER_CALL_TX=104;exports.DOCKER_DISABLE_TX=106;exports.POLICY_REGISTER_NODE_TX=111;exports.ISSUE_TX_VERSION=2;exports.TRANSFER_TX_VERSION=2;exports.REISSUE_TX_VERSION=2;exports.BURN_TX_VERSION=2;exports.EXCHANGE_TX_VERSION=2;exports.LEASE_TX_VERSION=2;exports.CANCEL_LEASING_TX_VERSION=2;exports.CREATE_ALIAS_TX_VERSION=2;exports.MASS_TRANSFER_TX_VERSION=1;exports.DATA_TX_VERSION=1;exports.SET_SCRIPT_TX_VERSION=1;exports.SPONSORSHIP_TX_VERSION=1;exports.PERMISSION_TX_VERSION=1;exports.DOCKER_CREATE_TX_VERSION=1;exports.DOCKER_CALL_TX_VERSION=1;exports.DOCKER_DISABLE_TX_VERSION=1;exports.POLICY_REGISTER_NODE_TX_VERSION=1;exports.ISSUE_TX_NAME="issue";exports.TRANSFER_TX_NAME="transfer";exports.REISSUE_TX_NAME="reissue";exports.BURN_TX_NAME="burn";exports.EXCHANGE_TX_NAME="exchange";exports.LEASE_TX_NAME="lease";exports.CANCEL_LEASING_TX_NAME="cancelLeasing";exports.CREATE_ALIAS_TX_NAME="createAlias";exports.MASS_TRANSFER_TX_NAME="massTransfer";exports.DATA_TX_NAME="data";exports.SET_SCRIPT_TX_NAME="setScript";exports.SPONSORSHIP_TX_NAME="sponsorship";exports.PERMISSION_TX_NAME="permit";exports.DOCKER_CREATE_TX_NAME="dockerCreate";exports.DOCKER_CALL_TX_NAME="dockerCall";exports.DOCKER_DISABLE_TX_NAME="dockerDisable";exports.POLICY_REGISTER_NODE_TX_NAME="policyRegisterNode";exports.PRIVATE_KEY_LENGTH=32;exports.PUBLIC_KEY_LENGTH=32;exports.PUBLIC_KEY_GOST_LENGTH=64;exports.MINIMUM_FEE=1e5;exports.MINIMUM_ISSUE_FEE=1e8;exports.MINIMUM_MATCHER_FEE=3e5;exports.MINIMUM_DATA_FEE_PER_KB=1e5;exports.TRANSFER_ATTACHMENT_BYTE_LIMIT=140;exports.DEFAULT_MIN_SEED_LENGTH=25;exports.DEFAULT_ORDER_EXPIRATION_DAYS=20;exports.DEFAULT_PAGING_LIMIT=50;exports.DEFAULT_PAGING_OFFSET=0;exports.DEFAULT_BASIC_CONFIG={minimumSeedLength:exports.DEFAULT_MIN_SEED_LENGTH,requestOffset:0,requestLimit:100,logLevel:"warning",timeDiff:0,crypto:"waves"};exports.DEFAULT_MAINNET_CONFIG=__assign({},exports.DEFAULT_BASIC_CONFIG,{networkByte:exports.MAINNET_BYTE,nodeAddress:"https://nodes.wavesplatform.com",matcherAddress:"https://matcher.wavesplatform.com/matcher"});exports.DEFAULT_TESTNET_CONFIG=__assign({},exports.DEFAULT_BASIC_CONFIG,{networkByte:exports.TESTNET_BYTE,nodeAddress:"https://testnet1.wavesnodes.com",matcherAddress:"https://testnet1.wavesnodes.com/matcher"});exports.WAVES_V1_ISSUE_TX={assetId:exports.WAVES,decimals:8,description:"",fee:0,height:0,id:exports.WAVES,name:"Waves",quantity:1e8*Math.pow(10,8),reissuable:false,sender:exports.WAVES,senderPublicKey:"",signature:"",timestamp:14604192e5,type:exports.ISSUE_TX};exports.BROADCAST_PATH="/transactions/broadcast"},{}],20:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});function paddedMessage(message){return"\n"+message+"\n"}function resolveData(data){if(data instanceof Error){return paddedMessage(data.toString())}else if(data){try{return paddedMessage(JSON.stringify(data,null,2))}catch(e){return paddedMessage("Not possible to retrieve error data")}}else{return paddedMessage("No additional data provided")}}var WavesError=function(_super){__extends(WavesError,_super);function WavesError(message,data){var _this=_super.call(this,message+":\n"+resolveData(data))||this;_this.name="WavesError";_this.data=data;if(Error.captureStackTrace){Error.captureStackTrace(_this,WavesError)}return _this}return WavesError}(Error);exports.default=WavesError},{}],21:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});var WavesError_1=require("./WavesError");var FAILED_TO_FETCH="Failed to fetch";function normalizeErrorData(data){if(!data.error&&data.message&&data.message.indexOf(FAILED_TO_FETCH)!==-1){return{error:-1,message:"failed to fetch"}}else{return data}}var WavesRequestError=function(_super){__extends(WavesRequestError,_super);function WavesRequestError(url,data){var _this=_super.call(this,"Server request to '"+url+"' has failed",normalizeErrorData(data))||this;_this.name="WavesRequestError";return _this}return WavesRequestError}(WavesError_1.default);exports.default=WavesRequestError},{"./WavesError":20}],22:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var bignumber_js_1=require("bignumber.js");bignumber_js_1.default.config({ROUNDING_MODE:bignumber_js_1.default.ROUND_DOWN});exports.default=bignumber_js_1.default},{"bignumber.js":undefined}],23:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var fetchSubstitute=function(){if(typeof window!=="undefined"){return window.fetch.bind(window)}else if(typeof exports==="object"&&typeof module!=="undefined"){return require("node-fetch")}else if(typeof self!=="undefined"){return self.fetch.bind(self)}else{throw new Error("Your environment is not defined")}}();exports.default=fetchSubstitute},{"node-fetch":undefined}],24:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var config_1=require("./config");var constants_1=require("./constants");var transactions_1=require("./utils/transactions");var base58ToString_1=require("./utils/base58ToString");exports.default={getAddressFromPublicKey:function(publicKey){var publicKeyBytes=signature_generator_1.libs.base58.decode(publicKey);return config_1.default.isCryptoGost()?signature_generator_1.utils.cryptoGost.buildRawAddress(publicKeyBytes):signature_generator_1.utils.crypto.buildRawAddress(publicKeyBytes)},calculateTimeDiff:function(nodeTime,userTime){return nodeTime-userTime},base58:{encode:signature_generator_1.libs.base58.encode,decode:signature_generator_1.libs.base58.decode,base58ToString:base58ToString_1.base58ToString},getMinimumDataTxFee:function(data){var emptyDataTx=new signature_generator_1.TX_TYPE_MAP.data({authorPublicKey:"11111111111111111111111111111111",senderPublicKey:"11111111111111111111111111111111",timestamp:0,fee:"",data:data});return emptyDataTx.getBytes().then(function(bytes){return Math.ceil(bytes.length/1024)*constants_1.MINIMUM_DATA_FEE_PER_KB})},createTransaction:transactions_1.createTransaction}},{"./config":18,"./constants":19,"./utils/base58ToString":25,"./utils/transactions":28,"@vostokplatform/signature-generator":undefined}],25:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");function base58ToString(base58String){var arr=signature_generator_1.libs.base58.decode(base58String);var str=String.fromCharCode.apply(null,arr);return decodeURIComponent(escape(str))}exports.base58ToString=base58ToString},{"@vostokplatform/signature-generator":undefined}],26:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var constants_1=require("../constants");var config_1=require("../config");var bignumber_1=require("../libs/bignumber");function normalizeAssetId(original){if(!original||original===constants_1.WAVES){return""}else{return original}}exports.normalizeAssetId=normalizeAssetId;function removeRecipientPrefix(original){if(original.slice(0,8)==="address:"){return original.slice(8)}else{return original}}exports.removeRecipientPrefix=removeRecipientPrefix;function removeAliasPrefix(original){if(original.slice(0,6)==="alias:"){return original.slice(8)}else{return original}}exports.removeAliasPrefix=removeAliasPrefix;function getTimestamp(timestamp){return(timestamp||Date.now())+config_1.default.getTimeDiff()}exports.getTimestamp=getTimestamp;function precisionCheck(precision){return precision>=0&&precision<=8}exports.precisionCheck=precisionCheck;function castFromBytesToBase58(bytes,sliceIndex){var processedBytes=Uint8Array.from(Array.prototype.slice.call(bytes,sliceIndex));return signature_generator_1.libs.base58.encode(processedBytes)}function castFromStringToBase58(str,sliceIndex){var processedBytes=Uint8Array.from(Array.prototype.slice.call(unescape(encodeURIComponent(str)).split("").map(function(e){return e.charCodeAt(0)}),sliceIndex));return signature_generator_1.libs.base58.encode(processedBytes)}function castFromRawToPrefixed(raw){if(raw.length>30){return"address:"+raw}else{var networkCharacter=String.fromCharCode(config_1.default.getNetworkByte());return"alias:"+networkCharacter+":"+raw}}function createRemapper(rules){return function(data){return Object.keys(__assign({},data,rules)).reduce(function(result,key){var rule=rules[key];if(typeof rule==="function"){result[key]=rule(data[key])}else if(typeof rule==="string"){result[rule]=data[key]}else if(rule&&typeof rule==="object"){if(rule.from==="bytes"&&rule.to==="base58"){result[key]=castFromBytesToBase58(data[key],rule.slice||0)}else if(rule.from==="string"&&rule.to==="base58"){result[key]=castFromStringToBase58(data[key],rule.slice||0)}else if(rule.from==="string"&&rule.to==="bignumber"){result[key]=new bignumber_1.default(data[key])}else if(rule.from==="raw"&&rule.to==="prefixed"){if(data[key].length&&data[key][0].recipient){result[rule.path||key]=data[key].map(function(o){return __assign({},o,{amount:new bignumber_1.default(o.amount),recipient:castFromRawToPrefixed(o.recipient)})})}else{result[rule.path||key]=castFromRawToPrefixed(data[key])}}}else if(rule!==null){result[key]=typeof data[key]!=="undefined"?data[key]:rule}return result},Object.create(null))}}exports.createRemapper=createRemapper},{"../config":18,"../constants":19,"../libs/bignumber":22,"@vostokplatform/signature-generator":undefined}],27:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var create=require("parse-json-bignumber");var WavesRequestError_1=require("../errors/WavesRequestError");var fetch_1=require("../libs/fetch");var config_1=require("../config");var bignumber_1=require("../libs/bignumber");var SAFE_JSON_PARSE=create({BigNumber:bignumber_1.default}).parse;var SAFE_JSON_STRINGIFY=create({BigNumber:bignumber_1.default}).stringify;exports.POST_TEMPLATE={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"}};var key=function(product,version){return product+"/"+version};var hostResolvers=(_a={},_a[key(0,0)]=function(){return config_1.default.getNodeAddress()},_a[key(1,0)]=function(){return config_1.default.getMatcherAddress()},_a);function normalizeHost(host){return host.replace(/\/+$/,"")}exports.normalizeHost=normalizeHost;function normalizePath(path){return("/"+path).replace(/\/+/g,"/").replace(/\/$/,"")}exports.normalizePath=normalizePath;function processJSON(res){if(res.ok){return res.text().then(SAFE_JSON_PARSE)}else{return res.json().then(Promise.reject.bind(Promise))}}exports.processJSON=processJSON;function handleError(url,data){throw new WavesRequestError_1.default(url,data)}function createFetchWrapper(product,version,pipe){var resolveHost=hostResolvers[key(product,version)];return function(path,options){var url=resolveHost()+normalizePath(path);var request=fetch_1.default(url,options);if(pipe){return request.then(pipe).catch(function(data){return handleError(url,data)})}else{return request.catch(function(data){return handleError(url,data)})}}}exports.createFetchWrapper=createFetchWrapper;function wrapTxRequest(SignatureGenerator,preRemapAsync,postRemap,callback,withProofs){if(withProofs===void 0){withProofs=false}return function(data,keyPair){return preRemapAsync(__assign({},data,{senderPublicKey:keyPair.publicKey})).then(function(validatedData){var transaction=new SignatureGenerator(validatedData);return transaction.getSignature(keyPair.privateKey).then(function(signature){return postRemap(__assign({},validatedData,withProofs?{proofs:[signature]}:{signature:signature}))}).then(function(tx){var sendData=__assign({},exports.POST_TEMPLATE,{rejectUnauthorized:false,body:SAFE_JSON_STRINGIFY(tx,null,null)});console.log(sendData);return callback(sendData)})})}}exports.wrapTxRequest=wrapTxRequest;var _a},{"../config":18,"../errors/WavesRequestError":21,"../libs/bignumber":22,"../libs/fetch":23,"parse-json-bignumber":undefined}],28:[function(require,module,exports){"use strict";var __assign=this&&this.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var signature_generator_1=require("@vostokplatform/signature-generator");var txHelpers=require("../api/node/transactions.x");var capitalize=function(name){return name.slice(0,1).toUpperCase()+name.slice(1)};var TransactionWrapper=function(){function TransactionWrapper(signatureGenerator,validatedData,postRemap,proofs){this.signatureGenerator=signatureGenerator;this.validatedData=validatedData;this.postRemap=postRemap;this.proofs=proofs;this._privateKeys=[]}TransactionWrapper.prototype.addProof=function(privateKey){this._privateKeys.push(privateKey);return this};TransactionWrapper.prototype.getJSON=function(){var _this=this;return Promise.all(this._privateKeys.map(function(privateKey){return _this.signatureGenerator.getSignature(privateKey)})).then(function(newProofs){return _this.postRemap(__assign({},_this.validatedData,{proofs:[].concat(_this.proofs,newProofs)}))})};return TransactionWrapper}();exports.createTransaction=function(type,data){var name=capitalize(type);var preRemap=txHelpers["pre"+name];var postRemap=txHelpers["post"+name];if(!preRemap||!postRemap||!signature_generator_1.TX_TYPE_MAP[type]){throw new Error("Unknown transaction type: "+type)}var proofs=data.proofs||[];return preRemap(data).then(function(validatedData){var signatureGenerator=new signature_generator_1.TX_TYPE_MAP[type](validatedData);return new TransactionWrapper(signatureGenerator,validatedData,postRemap,proofs)})}},{"../api/node/transactions.x":15,"@vostokplatform/signature-generator":undefined}]},{},[1])(1)}); |
{ | ||
"name": "@vostokplatform/waves-api", | ||
"version": "1.18.10", | ||
"version": "1.19.0", | ||
"description": "Vostok client-side API library", | ||
@@ -46,3 +46,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@vostokplatform/signature-generator": "1.4.4", | ||
"@vostokplatform/signature-generator": "1.4.7", | ||
"bignumber.js": "7.2.1", | ||
@@ -49,0 +49,0 @@ "crypto-js": "3.1.9-1", |
@@ -72,2 +72,4 @@ "use strict"; | ||
return requests.sendDockerDisableTx(data, keys); | ||
case constants.POLICY_REGISTER_NODE_TX_NAME: | ||
return requests.sendNodeRegistry(data, keys); | ||
default: | ||
@@ -109,2 +111,4 @@ throw new WavesError_1.default("Wrong transaction type: " + type, data); | ||
return requests.sendSignedDockerDisableTx(data, keys); | ||
case constants.POLICY_REGISTER_NODE_TX_NAME: | ||
return requests.signNodeRegistry(data, keys); | ||
default: | ||
@@ -111,0 +115,0 @@ throw new WavesError_1.default("Wrong transaction type: " + type, data); |
@@ -79,1 +79,6 @@ import { TTransactionRequest } from '../../utils/request'; | ||
export declare const sendDockerDisableTx: TTransactionRequest; | ||
export declare const nodeRegistrySchema: Schema; | ||
export declare const preNodeRegistry: (data: any) => Promise<any>; | ||
export declare const postNodeRegistry: (d: any) => any; | ||
export declare const signNodeRegistry: TTransactionRequest; | ||
export declare const sendNodeRegistry: TTransactionRequest; |
@@ -679,2 +679,32 @@ "use strict"; | ||
}, true); | ||
exports.nodeRegistrySchema = new ts_api_validator_1.Schema({ | ||
type: ts_api_validator_1.ObjectPart, | ||
required: true, | ||
content: { | ||
senderPublicKey: schemaFields_1.default.publicKey, | ||
targetPubKey: schemaFields_1.default.publicKey, | ||
nodeName: { | ||
type: ts_api_validator_1.StringPart, | ||
required: true | ||
}, | ||
opType: { | ||
type: ts_api_validator_1.StringPart, | ||
required: true | ||
}, | ||
timestamp: schemaFields_1.default.timestamp, | ||
fee: schemaFields_1.default.fee | ||
} | ||
}); | ||
exports.preNodeRegistry = function (data) { | ||
return exports.nodeRegistrySchema.parse(data); | ||
}; | ||
exports.postNodeRegistry = function (d) { | ||
return __assign({}, d, { transactionType: null, type: constants.POLICY_REGISTER_NODE_TX, version: constants.POLICY_REGISTER_NODE_TX_VERSION }); | ||
}; | ||
exports.signNodeRegistry = request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.policyRegisterNode, exports.preNodeRegistry, exports.postNodeRegistry, function (postParams) { | ||
return getSignedTx(postParams).data; | ||
}, true); | ||
exports.sendNodeRegistry = request_1.wrapTxRequest(signature_generator_1.TX_TYPE_MAP.policyRegisterNode, exports.preNodeRegistry, exports.postNodeRegistry, function (postParams) { | ||
return fetch(constants.BROADCAST_PATH, postParams); | ||
}, true); | ||
//# sourceMappingURL=transactions.x.js.map |
@@ -25,2 +25,3 @@ import { IWavesBasicConfig, IWavesConfig } from '../interfaces'; | ||
export declare const DOCKER_DISABLE_TX: TRANSACTION_TYPE_NUMBER; | ||
export declare const POLICY_REGISTER_NODE_TX: TRANSACTION_TYPE_NUMBER; | ||
export declare const ISSUE_TX_VERSION: TRANSACTION_TYPE_VERSION; | ||
@@ -42,2 +43,3 @@ export declare const TRANSFER_TX_VERSION: TRANSACTION_TYPE_VERSION; | ||
export declare const DOCKER_DISABLE_TX_VERSION: TRANSACTION_TYPE_VERSION; | ||
export declare const POLICY_REGISTER_NODE_TX_VERSION: TRANSACTION_TYPE_VERSION; | ||
export declare const ISSUE_TX_NAME: TRANSACTION_TYPE; | ||
@@ -59,2 +61,3 @@ export declare const TRANSFER_TX_NAME: TRANSACTION_TYPE; | ||
export declare const DOCKER_DISABLE_TX_NAME: TRANSACTION_TYPE; | ||
export declare const POLICY_REGISTER_NODE_TX_NAME: TRANSACTION_TYPE; | ||
export declare const PRIVATE_KEY_LENGTH = 32; | ||
@@ -61,0 +64,0 @@ export declare const PUBLIC_KEY_LENGTH = 32; |
@@ -33,2 +33,3 @@ "use strict"; | ||
exports.DOCKER_DISABLE_TX = 106 /* DOCKER_DISABLE */; | ||
exports.POLICY_REGISTER_NODE_TX = 111 /* POLICY_REGISTER_NODE */; | ||
exports.ISSUE_TX_VERSION = 2 /* ISSUE */; | ||
@@ -50,2 +51,3 @@ exports.TRANSFER_TX_VERSION = 2 /* TRANSFER */; | ||
exports.DOCKER_DISABLE_TX_VERSION = 1 /* DOCKER_DISABLE */; | ||
exports.POLICY_REGISTER_NODE_TX_VERSION = 1 /* POLICY_REGISTER_NODE */; | ||
exports.ISSUE_TX_NAME = "issue" /* ISSUE */; | ||
@@ -67,2 +69,3 @@ exports.TRANSFER_TX_NAME = "transfer" /* TRANSFER */; | ||
exports.DOCKER_DISABLE_TX_NAME = "dockerDisable" /* DOCKER_DISABLE */; | ||
exports.POLICY_REGISTER_NODE_TX_NAME = "policyRegisterNode" /* POLICY_REGISTER_NODE */; | ||
exports.PRIVATE_KEY_LENGTH = 32; | ||
@@ -69,0 +72,0 @@ exports.PUBLIC_KEY_LENGTH = 32; |
@@ -70,2 +70,5 @@ import { createFetchWrapper, PRODUCTS, VERSIONS, processJSON, POST_TEMPLATE } from '../../utils/request'; | ||
return requests.sendDockerDisableTx(data, keys); | ||
case constants.POLICY_REGISTER_NODE_TX_NAME: | ||
return requests.sendNodeRegistry(data, keys); | ||
default: | ||
@@ -108,2 +111,5 @@ throw new WavesError(`Wrong transaction type: ${type}`, data); | ||
return requests.sendSignedDockerDisableTx(data, keys); | ||
case constants.POLICY_REGISTER_NODE_TX_NAME: | ||
return requests.signNodeRegistry(data, keys); | ||
default: | ||
@@ -110,0 +116,0 @@ throw new WavesError(`Wrong transaction type: ${type}`, data); |
@@ -798,1 +798,43 @@ import {TTransactionRequest} from '../../utils/request'; | ||
}, true) as TTransactionRequest; | ||
export const nodeRegistrySchema = new Schema({ | ||
type: ObjectPart, | ||
required: true, | ||
content: { | ||
senderPublicKey: schemaFields.publicKey, | ||
targetPubKey: schemaFields.publicKey, | ||
nodeName: { | ||
type: StringPart, | ||
required: true | ||
}, | ||
opType: { | ||
type: StringPart, | ||
required: true | ||
}, | ||
timestamp: schemaFields.timestamp, | ||
fee: schemaFields.fee | ||
} | ||
}); | ||
export const preNodeRegistry= (data) => { | ||
return nodeRegistrySchema.parse(data) | ||
}; | ||
export const postNodeRegistry = d => { | ||
return { | ||
...d, | ||
transactionType: null, | ||
type: constants.POLICY_REGISTER_NODE_TX, | ||
version: constants.POLICY_REGISTER_NODE_TX_VERSION | ||
}; | ||
}; | ||
export const signNodeRegistry= wrapTxRequest(TX_TYPE_MAP.policyRegisterNode, preNodeRegistry, postNodeRegistry, (postParams: any) => { | ||
return getSignedTx(postParams).data; | ||
}, true) as TTransactionRequest; | ||
export const sendNodeRegistry = wrapTxRequest(TX_TYPE_MAP.policyRegisterNode, preNodeRegistry, postNodeRegistry, (postParams: any) => { | ||
return fetch(constants.BROADCAST_PATH, postParams); | ||
}, true) as TTransactionRequest; |
@@ -34,2 +34,5 @@ import {IWavesBasicConfig, IWavesConfig} from '../interfaces'; | ||
export const POLICY_REGISTER_NODE_TX = TRANSACTION_TYPE_NUMBER.POLICY_REGISTER_NODE; | ||
export const ISSUE_TX_VERSION = TRANSACTION_TYPE_VERSION.ISSUE; | ||
@@ -53,2 +56,3 @@ export const TRANSFER_TX_VERSION = TRANSACTION_TYPE_VERSION.TRANSFER; | ||
export const DOCKER_DISABLE_TX_VERSION = TRANSACTION_TYPE_VERSION.DOCKER_DISABLE; | ||
export const POLICY_REGISTER_NODE_TX_VERSION = TRANSACTION_TYPE_VERSION.POLICY_REGISTER_NODE; | ||
@@ -74,2 +78,4 @@ | ||
export const POLICY_REGISTER_NODE_TX_NAME = TRANSACTION_TYPE.POLICY_REGISTER_NODE; | ||
export const PRIVATE_KEY_LENGTH = 32; | ||
@@ -76,0 +82,0 @@ export const PUBLIC_KEY_LENGTH = 32; |
@@ -17,4 +17,4 @@ // todo not needed. for manual testing purposes only | ||
networkByte: 84, | ||
nodeAddress: 'https://obama.dev.vostokservices.com/nodeAddress', | ||
matcherAddress: 'https://obama.dev.vostokservices.com/nodeAddress', | ||
nodeAddress: 'https://ford.vostokservices.com/nodeAddress', | ||
matcherAddress: 'https://ford.vostokservices.com/nodeAddress', | ||
crypto: 'waves' | ||
@@ -38,4 +38,4 @@ }; | ||
// privateKey: 'F2W3jcpP1acrH62FVs97FkMPoqkvumwkXD7BepkZgwWM' | ||
privateKey: '96oQip2JkSZtWhb3XbpeyTeDVS1FGyRiGuJEucMuwHAC', | ||
publicKey: 'GQCWTLnXsw7WE7zzGGwnDNmV6Cmc5Bdd1E69TqoS1Jj7' | ||
privateKey: '4p8KKTt5ExEFDXSV6BSoSD472ANdqq4yZQXgjp7gSBPG', | ||
publicKey: 'faf2Rwo9WUoiVchf7dSahT33pS7TZLETRWrRw39Asti' | ||
} | ||
@@ -290,2 +290,16 @@ }; | ||
console.log(responseData); | ||
});*/ | ||
});*/ | ||
const r = { | ||
//senderPublicKey | ||
targetPubKey: 'faf2Rwo9WUoiVchf7dSahT33pS7TZLETRWrRw39Asti', | ||
nodeName: 'nodanoda', | ||
opType: 'remove', | ||
timestamp: Date.now(), | ||
fee: 100000000 | ||
}; | ||
Waves.API.Node.transactions.broadcast('policyRegisterNode', r, seed.keyPair).then((responseData) => { | ||
console.log('registry',responseData); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4169522
70645
186
+ Added@vostokplatform/signature-generator@1.4.7(transitive)
- Removed@vostokplatform/signature-generator@1.4.4(transitive)