Comparing version 0.1.1 to 0.1.2
@@ -1,1 +0,1 @@ | ||
"use strict";var Schema=require("./ContractSchema");var fs=require("fs-extra");var path=require("path");var _=require("lodash");function Artifactor(destination){this.destination=destination}Artifactor.prototype.save=function(object){var self=this;return new Promise(function(accept,reject){object=Schema.normalize(object);if(!object.contractName){return reject(new Error("You must specify a contract name."))}var output_path=object.contractName;output_path=path.join(self.destination,output_path);output_path=path.resolve(output_path);output_path=output_path+".json";fs.readFile(output_path,{encoding:"utf8"},function(err,json){var finalObject=object;if(!err){var existingObjDirty;try{existingObjDirty=JSON.parse(json)}catch(e){reject(e)}finalObject=Schema.normalize(existingObjDirty);var finalNetworks={};_.merge(finalNetworks,finalObject.networks,object.networks);_.assign(finalObject,object);finalObject.networks=finalNetworks}finalObject.updatedAt=new Date().toISOString();fs.outputFile(output_path,JSON.stringify(finalObject,null,2),"utf8",function(err){if(err)return reject(err);accept()})})})};Artifactor.prototype.saveAll=function(objects){var self=this;if(Array.isArray(objects)){var array=objects;objects={};array.forEach(function(item){objects[item.contract_name]=item})}return new Promise(function(accept,reject){fs.stat(self.destination,function(err){if(err){return reject(new Error("Destination "+self.destination+" doesn't exist!"))}accept()})}).then(function(){var promises=[];Object.keys(objects).forEach(function(contractName){var object=objects[contractName];object.contractName=contractName;promises.push(self.save(object))});return Promise.all(promises)})};module.exports=Artifactor; | ||
"use strict";var Schema=require("./ContractSchema");var expect=require("@truffle/expect");var fs=require("fs-extra");var path=require("path");var async=require("async");var _=require("lodash");var debug=require("debug")("artifactor");function Artifactor(destination){this.destination=destination};Artifactor.prototype.save=function(object){var self=this;return new Promise(function(accept,reject){object=Schema.normalize(object);if(object.contractName==null){return reject(new Error("You must specify a contract name."))}var output_path=object.contractName;output_path=path.join(self.destination,output_path);output_path=path.resolve(output_path);output_path=output_path+".json";fs.readFile(output_path,{encoding:"utf8"},function(err,json){var finalObject=object;if(!err){var existingObjDirty;try{existingObjDirty=JSON.parse(json)}catch(e){reject(e)}finalObject=Schema.normalize(existingObjDirty);var finalNetworks={};_.merge(finalNetworks,finalObject.networks,object.networks);_.assign(finalObject,object);finalObject.networks=finalNetworks}finalObject.updatedAt=new Date().toISOString();fs.outputFile(output_path,JSON.stringify(finalObject,null,2),"utf8",function(err){if(err)return reject(err);accept()})})})};Artifactor.prototype.saveAll=function(objects){var self=this;if(Array.isArray(objects)){var array=objects;objects={};array.forEach(function(item){objects[item.contract_name]=item})}return new Promise(function(accept,reject){fs.stat(self.destination,function(err,stat){if(err){return reject(new Error("Desination "+self.destination+" doesn't exist!"))}accept()})}).then(function(){var promises=[];Object.keys(objects).forEach(function(contractName){var object=objects[contractName];object.contractName=contractName;promises.push(self.save(object))});return Promise.all(promises)})};module.exports=Artifactor; |
@@ -1,1 +0,1 @@ | ||
"use strict";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}var utils=require("./lib/utils");var Box=function(){function Box(){_classCallCheck(this,Box)}_createClass(Box,null,[{key:"unbox",value:function(){var _unbox=_asyncToGenerator(regeneratorRuntime.mark(function _callee(url,destination,options){var boxConfig;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:options=options||{};options.logger=options.logger||{log:function log(){}};options.logger.log("Downloading...");_context.next=5;return utils.downloadBox(url,destination);case 5:options.logger.log("Unpacking...");_context.next=8;return utils.unpackBox(destination);case 8:boxConfig=_context.sent;options.logger.log("Setting up...");_context.next=12;return utils.setupBox(boxConfig,destination);case 12:return _context.abrupt("return",boxConfig);case 13:case"end":return _context.stop();}}},_callee)}));function unbox(_x,_x2,_x3){return _unbox.apply(this,arguments)}return unbox}()}]);return Box}();module.exports=Box; | ||
"use strict";var utils=require("./lib/utils");var tmp=require("tmp");var path=require("path");var Config=require("../Config");var Box={unbox:function unbox(url,destination,options){options=options||{};options.logger=options.logger||{log:function log(){}};return Promise.resolve().then(function(){options.logger.log("Downloading...");return utils.downloadBox(url,destination)}).then(function(){options.logger.log("Unpacking...");return utils.unpackBox(destination)}).then(function(boxConfig){options.logger.log("Setting up...");return utils.setupBox(boxConfig,destination)}).then(function(boxConfig){return boxConfig})},sandbox:function sandbox(name,callback){var self=this;if(typeof name==="function"){callback=name;name="default"}tmp.dir(function(err,dir,cleanupCallback){if(err){return callback(err)}self.unbox("https://github.com/trufflesuite/truffle-init-"+name,dir).then(function(){var config=Config.load(path.join(dir,"tronbox.js"),{});callback(null,config)})["catch"](callback)})}};module.exports=Box; |
@@ -1,1 +0,1 @@ | ||
"use strict";var fs=require("fs-extra");function setDefaults(config){config=config||{};var hooks=config.hooks||{};return{ignore:config.ignore||[],commands:config.commands||{compile:"tronbox compile",migrate:"tronbox migrate",test:"tronbox test"},hooks:{"post-unpack":hooks["post-unpack"]||""}}}function read(path){return fs.readFile(path)["catch"](function(){return"{}"}).then(JSON.parse).then(setDefaults)}module.exports={read:read,setDefaults:setDefaults}; | ||
"use strict";var fs=require("fs-extra");function setDefaults(config){config=config||{};var hooks=config.hooks||{};return{ignore:config.ignore||[],commands:config.commands||{"compile":"tronbox compile","migrate":"tronbox migrate","test":"tronbox test"},hooks:{"post-unpack":hooks["post-unpack"]||""}}}function read(path){return fs.readFile(path)["catch"](function(){return"{}"}).then(JSON.parse).then(setDefaults)}module.exports={read:read,setDefaults:setDefaults}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var fs=require("fs-extra");var path=require("path");var ghdownload=require("github-download");var request=require("request");var vcsurl=require("vcsurl");var parseURL=require("url").parse;var tmp=require("tmp");var exec=require("child_process").exec;var cwd=process.cwd();var config=require("../config");function checkDestination(destination){return Promise.resolve().then(function(){var contents=fs.readdirSync(destination);if(contents.length){var err="Something already exists at the destination. "+"`tronbox init` and `tronbox unbox` must be executed in an empty folder. "+"Stopping to prevent overwriting data.";throw new Error(err)}})}function verifyURL(url){return new Promise(function(accept,reject){var configURL=parseURL(vcsurl(url).replace("github.com","raw.githubusercontent.com").replace(/#.*/,"")+"/master/sunbox.js");var options={method:"HEAD",uri:"https://"+configURL.host+configURL.path};request(options,function(error,r){if(error){return reject(new Error("Error making request to "+options.uri+". Got error: "+error.message+". Please check the format of the requested resource."))}else if(r.statusCode===404){return reject(new Error("tronbox Box at URL "+url+" doesn't exist. If you believe this is an error, please contact tronbox support."))}else if(r.statusCode!==200){return reject(new Error("Error connecting to github.com. Please check your internet connection and try again."))}accept()})})}function setupTempDirectory(){return new Promise(function(accept,reject){tmp.dir({dir:cwd,unsafeCleanup:true},function(err,dir,cleanupCallback){if(err)return reject(err);accept(path.join(dir,"box"),cleanupCallback)})})}function fetchRepository(url,dir){return new Promise(function(accept,reject){ghdownload(url,dir).on("err",function(err){reject(err)}).on("end",function(){accept()})})}function copyTempIntoDestination(tmpDir,destination){return new Promise(function(accept,reject){fs.copy(tmpDir,destination,function(err){if(err)return reject(err);accept()})})}function readBoxConfig(destination){var possibleConfigs=[path.join(destination,"sunbox.json"),path.join(destination,"sunbox-init.json")];var configPath=possibleConfigs.reduce(function(path,alt){return path||fs.existsSync(alt)&&alt},undefined);return config.read(configPath)}function cleanupUnpack(boxConfig,destination){var needingRemoval=boxConfig.ignore||[];needingRemoval.push("sunbox.json");needingRemoval.push("sunbox-init.json");var promises=needingRemoval.map(function(file_path){return path.join(destination,file_path)}).map(function(file_path){return new Promise(function(accept,reject){fs.remove(file_path,function(err){if(err)return reject(err);accept()})})});return Promise.all(promises)}function installBoxDependencies(boxConfig,destination){var postUnpack=boxConfig.hooks["post-unpack"];return new Promise(function(accept,reject){if(postUnpack.length===0){return accept()}exec(postUnpack,{cwd:destination},function(err,stdout,stderr){if(err)return reject(err);accept(stdout,stderr)})})}module.exports={checkDestination:checkDestination,verifyURL:verifyURL,setupTempDirectory:setupTempDirectory,fetchRepository:fetchRepository,copyTempIntoDestination:copyTempIntoDestination,readBoxConfig:readBoxConfig,cleanupUnpack:cleanupUnpack,installBoxDependencies:installBoxDependencies}; | ||
"use strict";var fs=require("fs-extra");var path=require("path");var ghdownload=require("github-download");var request=require("request");var vcsurl=require("vcsurl");var parseURL=require("url").parse;var tmp=require("tmp");var exec=require("child_process").exec;var cwd=require("process").cwd();var config=require("../config");function checkDestination(destination){return Promise.resolve().then(function(){var contents=fs.readdirSync(destination);if(contents.length){var err="Something already exists at the destination. "+"`tronbox init` and `tronbox unbox` must be executed in an empty folder. "+"Stopping to prevent overwriting data.";throw new Error(err)}})}function verifyURL(url){return new Promise(function(accept,reject){var configURL=parseURL(vcsurl(url).replace("github.com","raw.githubusercontent.com").replace(/#.*/,"")+"/master/sunbox.js");var options={method:"HEAD",uri:"https://"+configURL.host+configURL.path};request(options,function(error,r){if(error){return reject(new Error("Error making request to "+options.uri+". Got error: "+error.message+". Please check the format of the requested resource."))}else if(r.statusCode==404){return reject(new Error("tronbox Box at URL "+url+" doesn't exist. If you believe this is an error, please contact tronbox support."))}else if(r.statusCode!=200){return reject(new Error("Error connecting to github.com. Please check your internet connection and try again."))}accept()})})}function setupTempDirectory(){return new Promise(function(accept,reject){tmp.dir({dir:cwd,unsafeCleanup:true},function(err,dir,cleanupCallback){if(err)return reject(err);accept(path.join(dir,"box"),cleanupCallback)})})}function fetchRepository(url,dir){return new Promise(function(accept,reject){ghdownload(url,dir).on("err",function(err){reject(err)}).on("end",function(){accept()})})}function copyTempIntoDestination(tmpDir,destination){return new Promise(function(accept,reject){fs.copy(tmpDir,destination,function(err){if(err)return reject(err);accept()})})}function readBoxConfig(destination){var possibleConfigs=[path.join(destination,"sunbox.json"),path.join(destination,"sunbox-init.json")];var configPath=possibleConfigs.reduce(function(path,alt){return path||fs.existsSync(alt)&&alt},undefined);return config.read(configPath)}function cleanupUnpack(boxConfig,destination){var needingRemoval=boxConfig.ignore||[];needingRemoval.push("sunbox.json");needingRemoval.push("sunbox-init.json");var promises=needingRemoval.map(function(file_path){return path.join(destination,file_path)}).map(function(file_path){return new Promise(function(accept,reject){fs.remove(file_path,function(err){if(err)return reject(err);accept()})})});return Promise.all(promises)}function installBoxDependencies(boxConfig,destination){var postUnpack=boxConfig.hooks["post-unpack"];return new Promise(function(accept,reject){if(postUnpack.length===0){return accept()}exec(postUnpack,{cwd:destination},function(err,stdout,stderr){if(err)return reject(err);accept(stdout,stderr)})})}module.exports={checkDestination:checkDestination,verifyURL:verifyURL,setupTempDirectory:setupTempDirectory,fetchRepository:fetchRepository,copyTempIntoDestination:copyTempIntoDestination,readBoxConfig:readBoxConfig,cleanupUnpack:cleanupUnpack,installBoxDependencies:installBoxDependencies}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var colors=require("colors");var TruffleError=require("@truffle/error");var inherits=require("util").inherits;inherits(CompileError,TruffleError);function CompileError(message){var fancy_message=message.trim()+"\n"+colors.red("Compilation failed. See above.");var normal_message=message.trim();if(/0\.5\.4/.test(normal_message)&&!!~normal_message.indexOf("Source file requires different compiler version")){normal_message=normal_message.split("ParserError:")[0]+"\nParserError: Source file requires different compiler version (current compiler is 0.5.4+commit.7b0de266.mod.Emscripten.clang)";fancy_message=normal_message+"\n"+colors.red("Compilation failed. See above.")}CompileError.super_.call(this,normal_message);this.message=fancy_message}module.exports=CompileError; | ||
"use strict";var colors=require("colors");var TruffleError=require("@truffle/error");var inherits=require("util").inherits;inherits(CompileError,TruffleError);function CompileError(message){var fancy_message=message.trim()+"\n"+colors.red("Compilation failed. See above.");var normal_message=message.trim();if(/0\.5\.4/.test(normal_message)&&!!~normal_message.indexOf("Source file requires different compiler version")){normal_message=normal_message.split("ParserError:")[0]+"\nParserError: Source file requires different compiler version (current compiler is 0.5.4+commit.7b0de266.mod.Emscripten.clang)";fancy_message=normal_message+"\n"+colors.red("Compilation failed. See above.")}CompileError.super_.call(this,normal_message);this.message=fancy_message};module.exports=CompileError; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Profiler=require("./profiler");var OS=require("os");var path=require("path");var CompileError=require("./compileerror");var expect=require("@truffle/expect");var find_contracts=require("@truffle/contract-sources");var Config=require("../Config");var preReleaseCompilerWarning=require("./messages").preReleaseCompilerWarning;var compile=function compile(sources,options,callback){if(typeof options==="function"){callback=options;options={}}if(!options.logger){options.logger=console}expect.options(options,["contracts_directory","solc"]);var _require=require("../TronSolc"),getWrapper=_require.getWrapper;var solc=getWrapper(options);var listeners=process.listeners("uncaughtException");var solc_listener=listeners[listeners.length-1];if(solc_listener){process.removeListener("uncaughtException",solc_listener)}var operatingSystemIndependentSources={};var originalPathMappings={};Object.keys(sources).forEach(function(source){var replacement=source.replace(/\\/g,"/");if(replacement.length>=2&&replacement[1]===":"){replacement="/"+replacement;replacement=replacement.replace(":","")}operatingSystemIndependentSources[replacement]=sources[source];originalPathMappings[replacement]=source});var solcStandardInput={language:"Solidity",sources:{},settings:{evmVersion:options.solc.evmVersion,optimizer:options.solc.optimizer,outputSelection:{"*":{"":["legacyAST","ast"],"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap"]}}}};if(!Object.keys(sources).length){return callback(null,[],[])}Object.keys(operatingSystemIndependentSources).forEach(function(file_path){solcStandardInput.sources[file_path]={content:operatingSystemIndependentSources[file_path]}});var result=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput));var standardOutput=JSON.parse(result);var errors=standardOutput.errors||[];var warnings=[];if(options.strict!==true){warnings=errors.filter(function(error){return error.severity==="warning"&&error.message!==preReleaseCompilerWarning});errors=errors.filter(function(error){return error.severity!=="warning"});if(options.quiet!==true&&warnings.length>0){options.logger.log(OS.EOL+"Compilation warnings encountered:"+OS.EOL);options.logger.log(warnings.map(function(warning){return warning.formattedMessage}).join())}}if(errors.length>0){options.logger.log("");return callback(new CompileError(standardOutput.errors.map(function(error){return error.formattedMessage}).join()))}var contracts=standardOutput.contracts;var files=[];Object.keys(standardOutput.sources).forEach(function(filename){var source=standardOutput.sources[filename];files[source.id]=originalPathMappings[filename]});var returnVal={};Object.keys(contracts).forEach(function(source_path){var files_contracts=contracts[source_path];Object.keys(files_contracts).forEach(function(contract_name){var contract=files_contracts[contract_name];var contract_definition={contract_name:contract_name,sourcePath:originalPathMappings[source_path],source:operatingSystemIndependentSources[source_path],sourceMap:contract.evm.bytecode.sourceMap,deployedSourceMap:contract.evm.deployedBytecode.sourceMap,legacyAST:standardOutput.sources[source_path].legacyAST,ast:standardOutput.sources[source_path].ast,abi:contract.abi,bytecode:"0x"+contract.evm.bytecode.object,deployedBytecode:"0x"+contract.evm.deployedBytecode.object,unlinked_binary:"0x"+contract.evm.bytecode.object,compiler:{name:"solc",version:solc.version()}};contract_definition.abi=orderABI(contract_definition);Object.keys(contract.evm.bytecode.linkReferences).forEach(function(file_name){var fileLinks=contract.evm.bytecode.linkReferences[file_name];Object.keys(fileLinks).forEach(function(library_name){var linkReferences=fileLinks[library_name]||[];contract_definition.bytecode=replaceLinkReferences(contract_definition.bytecode,linkReferences,library_name);contract_definition.unlinked_binary=replaceLinkReferences(contract_definition.unlinked_binary,linkReferences,library_name)})});Object.keys(contract.evm.deployedBytecode.linkReferences).forEach(function(file_name){var fileLinks=contract.evm.deployedBytecode.linkReferences[file_name];Object.keys(fileLinks).forEach(function(library_name){var linkReferences=fileLinks[library_name]||[];contract_definition.deployedBytecode=replaceLinkReferences(contract_definition.deployedBytecode,linkReferences,library_name)})});returnVal[contract_name]=contract_definition})});callback(null,returnVal,files)};function replaceLinkReferences(bytecode,linkReferences,libraryName){var linkId="__"+libraryName;while(linkId.length<40){linkId+="_"}linkReferences.forEach(function(ref){var start=ref.start*2+2;bytecode=bytecode.substring(0,start)+linkId+bytecode.substring(start+40)});return bytecode}function orderABI(contract){var contract_definition;var ordered_function_names=[];for(var i=0;i<contract.legacyAST.children.length;i++){var definition=contract.legacyAST.children[i];if(definition.name!=="ContractDefinition"||definition.attributes.name!==contract.contract_name){continue}contract_definition=definition;break}if(!contract_definition)return contract.abi;if(!contract_definition.children)return contract.abi;contract_definition.children.forEach(function(child){if(child.name==="FunctionDefinition"){ordered_function_names.push(child.attributes.name)}});var functions_to_remove=ordered_function_names.reduce(function(obj,value,index){obj[value]=index;return obj},{});var function_definitions=contract.abi.filter(function(item){return functions_to_remove[item.name]!=null});function_definitions=function_definitions.sort(function(item_a,item_b){var a=functions_to_remove[item_a.name];var b=functions_to_remove[item_b.name];if(a>b)return 1;if(a<b)return-1;return 0});var newABI=[];contract.abi.forEach(function(item){if(functions_to_remove[item.name]!=null)return;newABI.push(item)});Array.prototype.push.apply(newABI,function_definitions);return newABI}compile.all=function(options,callback){find_contracts(options.contracts_directory,function(err,files){options.paths=files;compile.with_dependencies(options,callback)})};compile.necessary=function(options,callback){options.logger=options.logger||console;Profiler.updated(options,function(err,updated){if(err)return callback(err);if(updated.length===0&&options.quiet!==true){return callback(null,[],{})}options.paths=updated;compile.with_dependencies(options,callback)})};compile.with_dependencies=function(options,callback){options.logger=options.logger||console;options.contracts_directory=options.contracts_directory||process.cwd();expect.options(options,["paths","working_directory","contracts_directory","resolver"]);var config=Config["default"]().merge(options);Profiler.required_sources(config["with"]({paths:options.paths,base_path:options.contracts_directory,resolver:options.resolver}),function(err,result){if(err)return callback(err);if(!options.quiet){Object.keys(result).sort().forEach(function(import_path){var display_path=import_path;if(path.isAbsolute(import_path)){display_path="."+path.sep+path.relative(options.working_directory,import_path)}options.logger.log("Compiling "+display_path+"...")})}compile(result,options,callback)})};module.exports=compile; | ||
"use strict";var Profiler=require("./profiler");var OS=require("os");var path=require("path");var fs=require("fs");var async=require("async");var CompileError=require("./compileerror");var expect=require("@truffle/expect");var find_contracts=require("@truffle/contract-sources");var Config=require("../Config");var debug=require("debug")("compile");var preReleaseCompilerWarning=require("./messages").preReleaseCompilerWarning;var compile=function compile(sources,options,callback){if(typeof options=="function"){callback=options;options={}}if(options.logger==null){options.logger=console}expect.options(options,["contracts_directory","solc"]);var _require=require("../TronSolc"),getWrapper=_require.getWrapper;var solc=getWrapper(options);var listeners=process.listeners("uncaughtException");var solc_listener=listeners[listeners.length-1];if(solc_listener){process.removeListener("uncaughtException",solc_listener)}var operatingSystemIndependentSources={};var originalPathMappings={};Object.keys(sources).forEach(function(source){var replacement=source.replace(/\\/g,"/");if(replacement.length>=2&&replacement[1]==":"){replacement="/"+replacement;replacement=replacement.replace(":","")}operatingSystemIndependentSources[replacement]=sources[source];originalPathMappings[replacement]=source});var solcStandardInput={language:"Solidity",sources:{},settings:{evmVersion:options.solc.evmVersion,optimizer:options.solc.optimizer,outputSelection:{"*":{"":["legacyAST","ast"],"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap"]}}}};if(Object.keys(sources).length==0){return callback(null,[],[])}Object.keys(operatingSystemIndependentSources).forEach(function(file_path){solcStandardInput.sources[file_path]={content:operatingSystemIndependentSources[file_path]}});var result=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput));var standardOutput=JSON.parse(result);var errors=standardOutput.errors||[];var warnings=[];if(options.strict!==true){warnings=errors.filter(function(error){return error.severity==="warning"&&error.message!==preReleaseCompilerWarning});errors=errors.filter(function(error){return error.severity!="warning"});if(options.quiet!==true&&warnings.length>0){options.logger.log(OS.EOL+"Compilation warnings encountered:"+OS.EOL);options.logger.log(warnings.map(function(warning){return warning.formattedMessage}).join())}}if(errors.length>0){options.logger.log("");return callback(new CompileError(standardOutput.errors.map(function(error){return error.formattedMessage}).join()))}var contracts=standardOutput.contracts;var files=[];Object.keys(standardOutput.sources).forEach(function(filename){var source=standardOutput.sources[filename];files[source.id]=originalPathMappings[filename]});var returnVal={};Object.keys(contracts).forEach(function(source_path){var files_contracts=contracts[source_path];Object.keys(files_contracts).forEach(function(contract_name){var contract=files_contracts[contract_name];var contract_definition={contract_name:contract_name,sourcePath:originalPathMappings[source_path],source:operatingSystemIndependentSources[source_path],sourceMap:contract.evm.bytecode.sourceMap,deployedSourceMap:contract.evm.deployedBytecode.sourceMap,legacyAST:standardOutput.sources[source_path].legacyAST,ast:standardOutput.sources[source_path].ast,abi:contract.abi,bytecode:"0x"+contract.evm.bytecode.object,deployedBytecode:"0x"+contract.evm.deployedBytecode.object,unlinked_binary:"0x"+contract.evm.bytecode.object,compiler:{"name":"solc","version":solc.version()}};contract_definition.abi=orderABI(contract_definition);Object.keys(contract.evm.bytecode.linkReferences).forEach(function(file_name){var fileLinks=contract.evm.bytecode.linkReferences[file_name];Object.keys(fileLinks).forEach(function(library_name){var linkReferences=fileLinks[library_name]||[];contract_definition.bytecode=replaceLinkReferences(contract_definition.bytecode,linkReferences,library_name);contract_definition.unlinked_binary=replaceLinkReferences(contract_definition.unlinked_binary,linkReferences,library_name)})});Object.keys(contract.evm.deployedBytecode.linkReferences).forEach(function(file_name){var fileLinks=contract.evm.deployedBytecode.linkReferences[file_name];Object.keys(fileLinks).forEach(function(library_name){var linkReferences=fileLinks[library_name]||[];contract_definition.deployedBytecode=replaceLinkReferences(contract_definition.deployedBytecode,linkReferences,library_name)})});returnVal[contract_name]=contract_definition})});callback(null,returnVal,files)};function replaceLinkReferences(bytecode,linkReferences,libraryName){var linkId="__"+libraryName;while(linkId.length<40){linkId+="_"}linkReferences.forEach(function(ref){var start=ref.start*2+2;bytecode=bytecode.substring(0,start)+linkId+bytecode.substring(start+40)});return bytecode};function orderABI(contract){var contract_definition;var ordered_function_names=[];var ordered_functions=[];for(var i=0;i<contract.legacyAST.children.length;i++){var definition=contract.legacyAST.children[i];if(definition.name!=="ContractDefinition"||definition.attributes.name!==contract.contract_name){continue}contract_definition=definition;break}if(!contract_definition)return contract.abi;if(!contract_definition.children)return contract.abi;contract_definition.children.forEach(function(child){if(child.name=="FunctionDefinition"){ordered_function_names.push(child.attributes.name)}});var functions_to_remove=ordered_function_names.reduce(function(obj,value,index){obj[value]=index;return obj},{});var function_definitions=contract.abi.filter(function(item){return functions_to_remove[item.name]!=null});function_definitions=function_definitions.sort(function(item_a,item_b){var a=functions_to_remove[item_a.name];var b=functions_to_remove[item_b.name];if(a>b)return 1;if(a<b)return-1;return 0});var newABI=[];contract.abi.forEach(function(item){if(functions_to_remove[item.name]!=null)return;newABI.push(item)});Array.prototype.push.apply(newABI,function_definitions);return newABI}compile.all=function(options,callback){var self=this;find_contracts(options.contracts_directory,function(err,files){options.paths=files;compile.with_dependencies(options,callback)})};compile.necessary=function(options,callback){var self=this;options.logger=options.logger||console;Profiler.updated(options,function(err,updated){if(err)return callback(err);if(updated.length==0&&options.quiet!=true){return callback(null,[],{})}options.paths=updated;compile.with_dependencies(options,callback)})};compile.with_dependencies=function(options,callback){options.logger=options.logger||console;options.contracts_directory=options.contracts_directory||process.cwd();expect.options(options,["paths","working_directory","contracts_directory","resolver"]);var config=Config["default"]().merge(options);var self=this;Profiler.required_sources(config["with"]({paths:options.paths,base_path:options.contracts_directory,resolver:options.resolver}),function(err,result){if(err)return callback(err);if(options.quiet!=true){Object.keys(result).sort().forEach(function(import_path){var display_path=import_path;if(path.isAbsolute(import_path)){display_path="."+path.sep+path.relative(options.working_directory,import_path)}options.logger.log("Compiling "+display_path+"...")})}compile(result,options,callback)})};module.exports=compile; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var CompileError=require("./compileerror");var _require=require("../TronSolc"),getWrapper=_require.getWrapper;var fs=require("fs");var path=require("path");var listeners=process.listeners("uncaughtException");var solc_listener=listeners[listeners.length-1];if(solc_listener){process.removeListener("uncaughtException",solc_listener)}var preReleaseCompilerWarning=require("./messages").preReleaseCompilerWarning;var installedContractsDir="installed_contracts";module.exports={parse:function parse(body,fileName,options){var build_remappings=function build_remappings(){var remappings=[];if(fs.existsSync("ethpm.json")){var ethpm=JSON.parse(fs.readFileSync("ethpm.json"));for(var pkg in ethpm.dependencies){remappings.push(pkg+"/="+path.join(installedContractsDir,pkg,"contracts","/"))}}return remappings};fileName=fileName||"ParsedContract.sol";var remappings=build_remappings();var solcStandardInput={language:"Solidity",sources:_defineProperty({},fileName,{content:body}),settings:{remappings:remappings,outputSelection:{"*":{"":["ast"]}}}};var solc=getWrapper(options);var output=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput),function(file_path){var contents;if(fs.existsSync(file_path)){contents=fs.readFileSync(file_path,{encoding:"UTF-8"})}else{contents="pragma solidity ^0.4.0;"}return{contents:contents}});output=JSON.parse(output);var errors=output.errors?output.errors.filter(function(solidity_error){return solidity_error.message.indexOf(preReleaseCompilerWarning)<0}):[];errors=output.errors?output.errors.filter(function(solidity_error){return solidity_error.severity!=="warning"}):[];if(errors.length>0){throw new CompileError(errors[0].formattedMessage)}return{contracts:Object.keys(output.contracts[fileName]),ast:output.sources[fileName].ast}},parseImports:function parseImports(body,options){var importErrorKey="TRUFFLE_IMPORT";var failingImportFileName="__Truffle__NotFound.sol";body=body+"\n\nimport '"+failingImportFileName+"';\n";var solcStandardInput={language:"Solidity",sources:{"ParsedContract.sol":{content:body}},settings:{outputSelection:{"ParsedContract.sol":{"*":[]}}}};var solc=getWrapper(options);var output=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput),function(){return{error:importErrorKey}});output=JSON.parse(output);var errors=output.errors.filter(function(solidity_error){return solidity_error.message.indexOf(preReleaseCompilerWarning)<0});var nonImportErrors=errors.filter(function(solidity_error){return solidity_error.formattedMessage.indexOf(importErrorKey)<0});if(nonImportErrors.length>0){throw new CompileError(nonImportErrors[0].formattedMessage)}var imports=errors.filter(function(solidity_error){return solidity_error.message.indexOf(failingImportFileName)<0}).map(function(solidity_error){var matches=solidity_error.formattedMessage.match(/import[^'"]+("|')([^'"]+)("|');/);return matches[2]});return imports}}; | ||
"use strict";function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var CompileError=require("./compileerror");var _require=require("../TronSolc"),getWrapper=_require.getWrapper;var fs=require("fs");var path=require("path");var listeners=process.listeners("uncaughtException");var solc_listener=listeners[listeners.length-1];if(solc_listener){process.removeListener("uncaughtException",solc_listener)}var preReleaseCompilerWarning=require("./messages").preReleaseCompilerWarning;var installedContractsDir="installed_contracts";module.exports={parse:function parse(body,fileName,options){var build_remappings=function build_remappings(){var remappings=[];if(fs.existsSync("ethpm.json")){ethpm=JSON.parse(fs.readFileSync("ethpm.json"));for(pkg in ethpm.dependencies){remappings.push(pkg+"/="+path.join(installedContractsDir,pkg,"contracts","/"))}}return remappings};var fileName=fileName||"ParsedContract.sol";var remappings=build_remappings();var solcStandardInput={language:"Solidity",sources:_defineProperty({},fileName,{content:body}),settings:{remappings:remappings,outputSelection:{"*":{"":["ast"]}}}};var solc=getWrapper(options);var output=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput),function(file_path){if(fs.existsSync(file_path)){contents=fs.readFileSync(file_path,{encoding:"UTF-8"})}else{contents="pragma solidity ^0.4.0;"}return{contents:contents}});output=JSON.parse(output);var errors=output.errors?output.errors.filter(function(solidity_error){return solidity_error.message.indexOf(preReleaseCompilerWarning)<0}):[];var warnings=output.errors?output.errors.filter(function(solidity_error){return solidity_error.severity=="warning"}):[];var errors=output.errors?output.errors.filter(function(solidity_error){return solidity_error.severity!="warning"}):[];if(errors.length>0){throw new CompileError(errors[0].formattedMessage)}return{contracts:Object.keys(output.contracts[fileName]),ast:output.sources[fileName].ast}},parseImports:function parseImports(body,options){var self=this;var importErrorKey="TRUFFLE_IMPORT";var failingImportFileName="__Truffle__NotFound.sol";body=body+"\n\nimport '"+failingImportFileName+"';\n";var solcStandardInput={language:"Solidity",sources:{"ParsedContract.sol":{content:body}},settings:{outputSelection:{"ParsedContract.sol":{"*":[]}}}};var solc=getWrapper(options);var output=solc[solc.compileStandard?"compileStandard":"compile"](JSON.stringify(solcStandardInput),function(){return{error:importErrorKey}});output=JSON.parse(output);var errors=output.errors.filter(function(solidity_error){return solidity_error.message.indexOf(preReleaseCompilerWarning)<0});var nonImportErrors=errors.filter(function(solidity_error){return solidity_error.formattedMessage.indexOf(importErrorKey)<0});if(nonImportErrors.length>0){throw new CompileError(nonImportErrors[0].formattedMessage)}var imports=errors.filter(function(solidity_error){return solidity_error.message.indexOf(failingImportFileName)<0}).map(function(solidity_error){var matches=solidity_error.formattedMessage.match(/import[^'"]+("|')([^'"]+)("|');/);return matches[2]});return imports}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var path=require("path");var async=require("async");var fs=require("fs");var Graph=require("graphlib").Graph;var Parser=require("./parser");var expect=require("@truffle/expect");var find_contracts=require("@truffle/contract-sources");module.exports={updated:function updated(options,callback){expect.options(options,["resolver"]);var contracts_directory=options.contracts_directory;var build_directory=options.contracts_build_directory;function getFiles(done){if(options.files){done(null,options.files)}else{find_contracts(contracts_directory,done)}}var sourceFilesArtifacts={};var sourceFilesArtifactsUpdatedTimes={};var updatedFiles=[];async.series([function(c){getFiles(function(err,files){if(err)return c(err);files.forEach(function(sourceFile){sourceFilesArtifacts[sourceFile]=[]});c()})},function(c){fs.readdir(build_directory,function(err,build_files){if(err){if(err.message.indexOf("ENOENT: no such file or directory")>=0){build_files=[]}else{return c(err)}}build_files=build_files.filter(function(build_file){return path.extname(build_file)===".json"});async.map(build_files,function(buildFile,finished){fs.readFile(path.join(build_directory,buildFile),"utf8",function(err,body){if(err)return finished(err);finished(null,body)})},function(err,jsonData){if(err)return c(err);try{for(var i=0;i<jsonData.length;i++){var data=JSON.parse(jsonData[i]);if(!sourceFilesArtifacts[data.sourcePath]){sourceFilesArtifacts[data.sourcePath]=[]}sourceFilesArtifacts[data.sourcePath].push(data)}}catch(e){return c(e)}c()})})},function(c){Object.keys(sourceFilesArtifacts).forEach(function(sourceFile){var artifacts=sourceFilesArtifacts[sourceFile];sourceFilesArtifactsUpdatedTimes[sourceFile]=artifacts.reduce(function(minimum,current){var updatedAt=new Date(current.updatedAt).getTime();if(updatedAt<minimum){return updatedAt}return minimum},Number.MAX_SAFE_INTEGER);if(sourceFilesArtifactsUpdatedTimes[sourceFile]===Number.MAX_SAFE_INTEGER){sourceFilesArtifactsUpdatedTimes[sourceFile]=0}});c()},function(c){var sourceFiles=Object.keys(sourceFilesArtifacts);async.map(sourceFiles,function(sourceFile,finished){fs.stat(sourceFile,function(err,stat){if(err){stat=null}finished(null,stat)})},function(err,sourceFileStats){if(err)return callback(err);sourceFiles.forEach(function(sourceFile,index){var sourceFileStat=sourceFileStats[index];if(!sourceFileStat){return}var artifactsUpdatedTime=sourceFilesArtifactsUpdatedTimes[sourceFile]||0;var sourceFileUpdatedTime=(sourceFileStat.mtime||sourceFileStat.ctime).getTime();if(sourceFileUpdatedTime>artifactsUpdatedTime){updatedFiles.push(sourceFile)}});c()})}],function(err){callback(err,updatedFiles)})},required_sources:function required_sources(options,callback){var self=this;expect.options(options,["paths","base_path","resolver"]);var paths=this.convert_to_absolute_paths(options.paths,options.base_path);function findRequiredSources(dependsGraph,done){var required={};function hasBeenTraversed(import_path){return required[import_path]!=null}function include(import_path){required[import_path]=dependsGraph.node(import_path)}function walk_down(import_path){if(hasBeenTraversed(import_path)){return}include(import_path);var dependencies=dependsGraph.successors(import_path);if(dependencies.length>0){dependencies.forEach(walk_down)}}function walk_from(import_path){if(hasBeenTraversed(import_path)){return}var ancestors=dependsGraph.predecessors(import_path);var dependencies=dependsGraph.successors(import_path);include(import_path);if(ancestors&&ancestors.length>0){ancestors.forEach(walk_from)}if(dependencies&&dependencies.length>0){dependencies.forEach(walk_down)}}paths.forEach(walk_from);done(null,required)}find_contracts(options.base_path,function(err,allPaths){if(err)return callback(err);allPaths=allPaths.concat(paths);self.dependency_graph(allPaths,options.resolver,function(err,dependsGraph){if(err)return callback(err);findRequiredSources(dependsGraph,callback)})})},convert_to_absolute_paths:function convert_to_absolute_paths(paths,base){var self=this;return paths.map(function(p){if(path.isAbsolute(p))return p;if(!self.isExplicitlyRelative(p))return p;return path.resolve(path.join(base,p))})},isExplicitlyRelative:function isExplicitlyRelative(import_path){return import_path.indexOf(".")===0},dependency_graph:function dependency_graph(paths,resolver,callback){var self=this;var dependsGraph=new Graph;var imports_cache={};paths=paths.map(function(p){return[p,null]});async.whilst(function(){return paths.length>0},function(finished){var current=paths.shift();var import_path=current[0];var imported_from=current[1];if(dependsGraph.hasNode(import_path)&&imports_cache[import_path]!=null){return finished()}resolver.resolve(import_path,imported_from,function(err,resolved_body,resolved_path,source){if(err)return finished(err);if(dependsGraph.hasNode(resolved_path)&&imports_cache[resolved_path]!=null){return finished()}dependsGraph.setNode(resolved_path,resolved_body);var imports;try{imports=Parser.parseImports(resolved_body,resolver.options)}catch(e){e.message="Error parsing "+import_path+": "+e.message;return finished(e)}imports=imports.map(function(dependency_path){if(self.isExplicitlyRelative(dependency_path)){dependency_path=source.resolve_dependency_path(import_path,dependency_path)}if(!dependsGraph.hasEdge(import_path,dependency_path)){dependsGraph.setEdge(import_path,dependency_path)}return[dependency_path,import_path]});imports_cache[import_path]=imports;Array.prototype.push.apply(paths,imports);finished()})},function(err){if(err)return callback(err);callback(null,dependsGraph)})},defined_contracts:function defined_contracts(directory,callback){function getFiles(callback){if(Array.isArray(directory)){callback(null,directory)}else{find_contracts(directory,callback)}}getFiles(function(err,files){if(err)return callback(err);var promises=files.map(function(file){return new Promise(function(accept,reject){fs.readFile(file,"utf8",function(err,body){if(err)return reject(err);var output;try{output=Parser.parse(body)}catch(e){e.message="Error parsing "+file+": "+e.message;return reject(e)}accept(output.contracts)})}).then(function(contract_names){var returnVal={};contract_names.forEach(function(contract_name){returnVal[contract_name]=file});return returnVal})});Promise.all(promises).then(function(objects){var contract_source_paths={};objects.forEach(function(object){Object.keys(object).forEach(function(contract_name){contract_source_paths[contract_name]=object[contract_name]})});callback(null,contract_source_paths)})["catch"](callback)})}}; | ||
"use strict";var path=require("path");var async=require("async");var fs=require("fs");var Graph=require("graphlib").Graph;var isAcyclic=require("graphlib/lib/alg").isAcyclic;var Parser=require("./parser");var CompileError=require("./compileerror");var expect=require("@truffle/expect");var find_contracts=require("@truffle/contract-sources");var debug=require("debug")("compile:profiler");module.exports={updated:function updated(options,callback){var self=this;expect.options(options,["resolver"]);var contracts_directory=options.contracts_directory;var build_directory=options.contracts_build_directory;function getFiles(done){if(options.files){done(null,options.files)}else{find_contracts(contracts_directory,done)}}var sourceFilesArtifacts={};var sourceFilesArtifactsUpdatedTimes={};var updatedFiles=[];async.series([function(c){getFiles(function(err,files){if(err)return c(err);files.forEach(function(sourceFile){sourceFilesArtifacts[sourceFile]=[]});c()})},function(c){fs.readdir(build_directory,function(err,build_files){if(err){if(err.message.indexOf("ENOENT: no such file or directory")>=0){build_files=[]}else{return c(err)}}build_files=build_files.filter(function(build_file){return path.extname(build_file)==".json"});async.map(build_files,function(buildFile,finished){fs.readFile(path.join(build_directory,buildFile),"utf8",function(err,body){if(err)return finished(err);finished(null,body)})},function(err,jsonData){if(err)return c(err);try{for(var i=0;i<jsonData.length;i++){var data=JSON.parse(jsonData[i]);if(sourceFilesArtifacts[data.sourcePath]==null){sourceFilesArtifacts[data.sourcePath]=[]}sourceFilesArtifacts[data.sourcePath].push(data)}}catch(e){return c(e)}c()})})},function(c){Object.keys(sourceFilesArtifacts).forEach(function(sourceFile){var artifacts=sourceFilesArtifacts[sourceFile];sourceFilesArtifactsUpdatedTimes[sourceFile]=artifacts.reduce(function(minimum,current){var updatedAt=new Date(current.updatedAt).getTime();if(updatedAt<minimum){return updatedAt}return minimum},Number.MAX_SAFE_INTEGER);if(sourceFilesArtifactsUpdatedTimes[sourceFile]==Number.MAX_SAFE_INTEGER){sourceFilesArtifactsUpdatedTimes[sourceFile]=0}});c()},function(c){var sourceFiles=Object.keys(sourceFilesArtifacts);async.map(sourceFiles,function(sourceFile,finished){fs.stat(sourceFile,function(err,stat){if(err){stat=null}finished(null,stat)})},function(err,sourceFileStats){if(err)return callback(err);sourceFiles.forEach(function(sourceFile,index){var sourceFileStat=sourceFileStats[index];if(sourceFileStat==null){return}var artifactsUpdatedTime=sourceFilesArtifactsUpdatedTimes[sourceFile]||0;var sourceFileUpdatedTime=(sourceFileStat.mtime||sourceFileStat.ctime).getTime();if(sourceFileUpdatedTime>artifactsUpdatedTime){updatedFiles.push(sourceFile)}});c()})}],function(err){callback(err,updatedFiles)})},required_sources:function required_sources(options,callback){var self=this;expect.options(options,["paths","base_path","resolver"]);var paths=this.convert_to_absolute_paths(options.paths,options.base_path);function findRequiredSources(dependsGraph,done){var required={};function hasBeenTraversed(import_path){return required[import_path]!=null}function include(import_path){required[import_path]=dependsGraph.node(import_path)}function walk_down(import_path){if(hasBeenTraversed(import_path)){return}include(import_path);var dependencies=dependsGraph.successors(import_path);if(dependencies.length>0){dependencies.forEach(walk_down)}}function walk_from(import_path){if(hasBeenTraversed(import_path)){return}var ancestors=dependsGraph.predecessors(import_path);var dependencies=dependsGraph.successors(import_path);include(import_path);if(ancestors&&ancestors.length>0){ancestors.forEach(walk_from)}if(dependencies&&dependencies.length>0){dependencies.forEach(walk_down)}}paths.forEach(walk_from);done(null,required)}find_contracts(options.base_path,function(err,allPaths){if(err)return callback(err);allPaths=allPaths.concat(paths);self.dependency_graph(allPaths,options.resolver,function(err,dependsGraph){if(err)return callback(err);findRequiredSources(dependsGraph,callback)})})},convert_to_absolute_paths:function convert_to_absolute_paths(paths,base){var self=this;return paths.map(function(p){if(path.isAbsolute(p))return p;if(!self.isExplicitlyRelative(p))return p;return path.resolve(path.join(base,p))})},isExplicitlyRelative:function isExplicitlyRelative(import_path){return import_path.indexOf(".")==0},dependency_graph:function dependency_graph(paths,resolver,callback){var self=this;var dependsGraph=new Graph;var imports_cache={};paths=paths.map(function(p){return[p,null]});async.whilst(function(){return paths.length>0},function(finished){var current=paths.shift();var import_path=current[0];var imported_from=current[1];if(dependsGraph.hasNode(import_path)&&imports_cache[import_path]!=null){return finished()}resolver.resolve(import_path,imported_from,function(err,resolved_body,resolved_path,source){if(err)return finished(err);if(dependsGraph.hasNode(resolved_path)&&imports_cache[resolved_path]!=null){return finished()}dependsGraph.setNode(resolved_path,resolved_body);var imports;try{imports=Parser.parseImports(resolved_body,resolver.options)}catch(e){e.message="Error parsing "+import_path+": "+e.message;return finished(e)}imports=imports.map(function(dependency_path){if(self.isExplicitlyRelative(dependency_path)){dependency_path=source.resolve_dependency_path(import_path,dependency_path)}if(!dependsGraph.hasEdge(import_path,dependency_path)){dependsGraph.setEdge(import_path,dependency_path)}return[dependency_path,import_path]});imports_cache[import_path]=imports;Array.prototype.push.apply(paths,imports);finished()})},function(err){if(err)return callback(err);callback(null,dependsGraph)})},defined_contracts:function defined_contracts(directory,callback){function getFiles(callback){if(Array.isArray(directory)){callback(null,directory)}else{find_contracts(directory,callback)}}getFiles(function(err,files){if(err)return callback(err);var promises=files.map(function(file){return new Promise(function(accept,reject){fs.readFile(file,"utf8",function(err,body){if(err)return reject(err);var output;try{output=Parser.parse(body)}catch(e){e.message="Error parsing "+file+": "+e.message;return reject(e)}accept(output.contracts)})}).then(function(contract_names){var returnVal={};contract_names.forEach(function(contract_name){returnVal[contract_name]=file});return returnVal})});Promise.all(promises).then(function(objects){var contract_source_paths={};objects.forEach(function(object){Object.keys(object).forEach(function(contract_name){contract_source_paths[contract_name]=object[contract_name]})});callback(null,contract_source_paths)})["catch"](callback)})}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _=require("lodash");var path=require("path");var _require=require("./TronWrap"),constants=_require.constants;var Provider=require("./Provider");var TruffleError=require("@truffle/error");var Module=require("module");var findUp=require("find-up");var originalrequire=require("original-require");var DEFAULT_CONFIG_FILENAME="sunbox.js";var BACKUP_CONFIG_FILENAME="sunbox-config.js";function Config(truffle_directory,working_directory,network){var self=this;var default_tx_values=constants.deployParameters;this._values={truffle_directory:truffle_directory||path.resolve(path.join(__dirname,"../")),working_directory:working_directory||process.cwd(),network:network,networks:{},verboseRpc:false,privateKey:null,fullHost:null,mainFullHost:null,sideFullHost:null,mainGateway:null,sideGateway:null,chainId:null,fullNode:null,solidityNode:null,eventServer:null,feeLimit:null,userFeePercentage:null,originEnergyLimit:null,tokenValue:null,tokenId:null,callValue:null,from:null,build:null,resolver:null,artifactor:null,ethpm:{ipfs_host:"ipfs.infura.io",ipfs_protocol:"https",registry:"0x8011df4830b4f696cd81393997e5371b93338878",install_provider_uri:"https://ropsten.infura.io/truffle"},solc:{optimizer:{enabled:false,runs:200},evmVersion:"byzantium"},logger:{log:function log(){}}};var props={truffle_directory:function truffle_directory(){},working_directory:function working_directory(){},network:function network(){},networks:function networks(){},verboseRpc:function verboseRpc(){},build:function build(){},resolver:function resolver(){},artifactor:function artifactor(){},ethpm:function ethpm(){},solc:function solc(){},logger:function logger(){},build_directory:function build_directory(){return path.join(self.working_directory,"build")},contracts_directory:function contracts_directory(){return path.join(self.working_directory,"contracts")},contracts_build_directory:function contracts_build_directory(){return path.join(self.build_directory,"contracts")},migrations_directory:function migrations_directory(){return path.join(self.working_directory,"migrations")},test_directory:function test_directory(){return path.join(self.working_directory,"test")},test_file_extension_regexp:function test_file_extension_regexp(){return /.*\.(js|es|es6|jsx|sol)$/},example_project_directory:function example_project_directory(){return path.join(self.truffle_directory,"example")},network_id:{get:function get(){try{return self.network_config.network_id}catch(e){return null}},set:function set(){throw new Error("Do not set config.network_id. Instead, set config.networks and then config.networks[<network name>].network_id")}},network_config:{get:function get(){var network=self.network;if(!network){throw new Error("Network not set. Cannot determine network to use.")}return _.extend({},default_tx_values,self.networks[network]||{})},set:function set(){throw new Error("Don't set config.network_config. Instead, set config.networks with the desired values.")}},from:{get:function get(){try{return self.network_config.from}catch(e){return default_tx_values.from}},set:function set(){throw new Error("Don't set config.from directly. Instead, set config.networks and then config.networks[<network name>].from")}},privateKey:{get:function get(){try{return self.network_config.privateKey}catch(e){return default_tx_values.privateKey}},set:function set(){throw new Error("Don't set config.privateKey directly. Instead, set config.networks and then config.networks[<network name>].privateKey")}},fullHost:{get:function get(){try{return self.network_config.mainFullHost}catch(e){return default_tx_values.fullHost}},set:function set(){throw new Error("Don't set config.fullHost directly. Instead, set config.networks and then config.networks[<network name>].fullHost")}},mainFullHost:{get:function get(){try{return self.network_config.mainFullHost}catch(e){return default_tx_values.mainFullHost}},set:function set(){throw new Error("Don't set config.mainFullHost directly. Instead, set config.networks and then config.networks[<network name>].mainFullHost")}},sideFullHost:{get:function get(){try{return self.network_config.sideFullHost}catch(e){return default_tx_values.sideFullHost}},set:function set(){throw new Error("Don't set config.sideFullHost directly. Instead, set config.networks and then config.networks[<network name>].sideFullHost")}},mainGateway:{get:function get(){try{return self.network_config.mainGateway}catch(e){return default_tx_values.mainGateway}},set:function set(){throw new Error("Don't set config.mainGateway directly. Instead, set config.networks and then config.networks[<network name>].mainGateway")}},sideGateway:{get:function get(){try{return self.network_config.sideGateway}catch(e){return default_tx_values.sideGateway}},set:function set(){throw new Error("Don't set config.sideGateway directly. Instead, set config.networks and then config.networks[<network name>].sideGateway")}},chainId:{get:function get(){try{return self.network_config.chainId}catch(e){return default_tx_values.chainId}},set:function set(){throw new Error("Don't set config.chainId directly. Instead, set config.networks and then config.networks[<network name>].chainId")}},fullNode:{get:function get(){try{return self.network_config.fullNode}catch(e){return default_tx_values.fullNode}},set:function set(){throw new Error("Don't set config.fullNode directly. Instead, set config.networks and then config.networks[<network name>].fullNode")}},solidityNode:{get:function get(){try{return self.network_config.solidityNode}catch(e){return default_tx_values.solidityNode}},set:function set(){throw new Error("Don't set config.solidityNode directly. Instead, set config.networks and then config.networks[<network name>].solidityNode")}},eventServer:{get:function get(){try{return self.network_config.eventServer}catch(e){return default_tx_values.eventServer}},set:function set(){throw new Error("Don't set config.eventServer directly. Instead, set config.networks and then config.networks[<network name>].eventServer")}},userFeePercentage:{get:function get(){try{return self.network_config.userFeePercentage||self.network_config.consume_user_resource_percent}catch(e){return default_tx_values.userFeePercentage}},set:function set(){throw new Error("Don't set config.userFeePercentage directly. Instead, set config.networks and then config.networks[<network name>].userFeePercentage")}},feeLimit:{get:function get(){try{return self.network_config.feeLimit||self.network_config.fee_limit}catch(e){return default_tx_values.feeLimit}},set:function set(){throw new Error("Don't set config.feeLimit directly. Instead, set config.networks and then config.networks[<network name>].feeLimit")}},originEnergyLimit:{get:function get(){try{return self.network_config.originEnergyLimit}catch(e){return default_tx_values.originEnergyLimit}},set:function set(){throw new Error("Don't set config.originEnergyLimit directly. Instead, set config.networks and then config.networks[<network name>].originEnergyLimit")}},tokenValue:{get:function get(){try{return self.network_config.tokenValue}catch(e){}},set:function set(){throw new Error("Don't set config.tokenValue directly. Instead, set config.networks and then config.networks[<network name>].tokenValue")}},tokenId:{get:function get(){try{return self.network_config.tokenId}catch(e){}},set:function set(){throw new Error("Don't set config.tokenId directly. Instead, set config.networks and then config.networks[<network name>].tokenId")}},provider:{get:function get(){if(!self.network){return null}var options=self.network_config;options.verboseRpc=self.verboseRpc;return Provider.create(options)},set:function set(){throw new Error("Don't set config.provider directly. Instead, set config.networks and then set config.networks[<network name>].provider")}},callValue:{get:function get(){try{return self.network_config.callValue||self.network_config.call_value}catch(e){return default_tx_values.callValue}},set:function set(){throw new Error("Don't set config.callValue directly. Instead, set config.networks and then config.networks[<network name>].callValue")}}};Object.keys(props).forEach(function(prop){self.addProp(prop,props[prop])})}Config.prototype.addProp=function(key,obj){Object.defineProperty(this,key,{get:obj.get||function(){return this._values[key]||obj()},set:obj.set||function(val){this._values[key]=val},configurable:true,enumerable:true})};Config.prototype.normalize=function(obj){var clone={};Object.keys(obj).forEach(function(key){try{clone[key]=obj[key]}catch(e){}});return clone};Config.prototype["with"]=function(obj){var normalized=this.normalize(obj);var current=this.normalize(this);return _.extend({},current,normalized)};Config.prototype.merge=function(obj){var self=this;var clone=this.normalize(obj);Object.keys(obj).forEach(function(key){try{self[key]=clone[key]}catch(e){}});return this};Config["default"]=function(){return new Config};Config.detect=function(options,filename){var search;!filename?search=[DEFAULT_CONFIG_FILENAME,BACKUP_CONFIG_FILENAME]:search=filename;var file=findUp.sync(search,{cwd:options.working_directory||options.workingDirectory});if(!file){throw new TruffleError("Could not find suitable configuration file.")}return this.load(file,options)};Config.load=function(file,options){var config=new Config;config.working_directory=path.dirname(path.resolve(file));delete require.cache[Module._resolveFilename(file,module)];var static_config=originalrequire(file);config.merge(static_config);config.merge(options);return config};module.exports=Config; | ||
"use strict";var _=require("lodash");var path=require("path");var _require=require("./TronWrap"),constants=_require.constants;var Provider=require("./Provider");var TruffleError=require("@truffle/error");var Module=require("module");var findUp=require("find-up");var originalrequire=require("original-require");var DEFAULT_CONFIG_FILENAME="sunbox.js";var BACKUP_CONFIG_FILENAME="sunbox-config.js";function Config(truffle_directory,working_directory,network){var self=this;var default_tx_values=constants.deployParameters;this._values={truffle_directory:truffle_directory||path.resolve(path.join(__dirname,"../")),working_directory:working_directory||process.cwd(),network:network,networks:{},verboseRpc:false,privateKey:null,fullHost:null,mainFullHost:null,sideFullHost:null,mainGateway:null,sideGateway:null,chainId:null,fullNode:null,solidityNode:null,eventServer:null,feeLimit:null,userFeePercentage:null,originEnergyLimit:null,tokenValue:null,tokenId:null,callValue:null,from:null,build:null,resolver:null,artifactor:null,ethpm:{ipfs_host:"ipfs.infura.io",ipfs_protocol:"https",registry:"0x8011df4830b4f696cd81393997e5371b93338878",install_provider_uri:"https://ropsten.infura.io/truffle"},solc:{optimizer:{enabled:false,runs:200},evmVersion:"byzantium"},logger:{log:function log(){}}};var props={truffle_directory:function truffle_directory(){},working_directory:function working_directory(){},network:function network(){},networks:function networks(){},verboseRpc:function verboseRpc(){},build:function build(){},resolver:function resolver(){},artifactor:function artifactor(){},ethpm:function ethpm(){},solc:function solc(){},logger:function logger(){},build_directory:function build_directory(){return path.join(self.working_directory,"build")},contracts_directory:function contracts_directory(){return path.join(self.working_directory,"contracts")},contracts_build_directory:function contracts_build_directory(){return path.join(self.build_directory,"contracts")},migrations_directory:function migrations_directory(){return path.join(self.working_directory,"migrations")},test_directory:function test_directory(){return path.join(self.working_directory,"test")},test_file_extension_regexp:function test_file_extension_regexp(){return /.*\.(js|es|es6|jsx|sol)$/},example_project_directory:function example_project_directory(){return path.join(self.truffle_directory,"example")},network_id:{get:function get(){try{return self.network_config.network_id}catch(e){return null}},set:function set(val){throw new Error("Do not set config.network_id. Instead, set config.networks and then config.networks[<network name>].network_id")}},network_config:{get:function get(){var network=self.network;if(network==null){throw new Error("Network not set. Cannot determine network to use.")}var conf=self.networks[network];if(conf==null){config={}}conf=_.extend({},default_tx_values,conf);return conf},set:function set(val){throw new Error("Don't set config.network_config. Instead, set config.networks with the desired values.")}},from:{get:function get(){try{return self.network_config.from}catch(e){return default_tx_values.from}},set:function set(val){throw new Error("Don't set config.from directly. Instead, set config.networks and then config.networks[<network name>].from")}},privateKey:{get:function get(){try{return self.network_config.privateKey}catch(e){return default_tx_values.privateKey}},set:function set(val){throw new Error("Don't set config.privateKey directly. Instead, set config.networks and then config.networks[<network name>].privateKey")}},fullHost:{get:function get(){try{return self.network_config.mainFullHost}catch(e){return default_tx_values.fullHost}},set:function set(){throw new Error("Don't set config.fullHost directly. Instead, set config.networks and then config.networks[<network name>].fullHost")}},mainFullHost:{get:function get(){try{return self.network_config.mainFullHost}catch(e){return default_tx_values.mainFullHost}},set:function set(){throw new Error("Don't set config.mainFullHost directly. Instead, set config.networks and then config.networks[<network name>].mainFullHost")}},sideFullHost:{get:function get(){try{return self.network_config.sideFullHost}catch(e){return default_tx_values.sideFullHost}},set:function set(){throw new Error("Don't set config.sideFullHost directly. Instead, set config.networks and then config.networks[<network name>].sideFullHost")}},mainGateway:{get:function get(){try{return self.network_config.mainGateway}catch(e){return default_tx_values.mainGateway}},set:function set(){throw new Error("Don't set config.mainGateway directly. Instead, set config.networks and then config.networks[<network name>].mainGateway")}},sideGateway:{get:function get(){try{return self.network_config.sideGateway}catch(e){return default_tx_values.sideGateway}},set:function set(){throw new Error("Don't set config.sideGateway directly. Instead, set config.networks and then config.networks[<network name>].sideGateway")}},chainId:{get:function get(){try{return self.network_config.chainId}catch(e){return default_tx_values.chainId}},set:function set(){throw new Error("Don't set config.chainId directly. Instead, set config.networks and then config.networks[<network name>].chainId")}},fullNode:{get:function get(){try{return self.network_config.fullNode}catch(e){return default_tx_values.fullNode}},set:function set(){throw new Error("Don't set config.fullNode directly. Instead, set config.networks and then config.networks[<network name>].fullNode")}},solidityNode:{get:function get(){try{return self.network_config.solidityNode}catch(e){return default_tx_values.solidityNode}},set:function set(val){throw new Error("Don't set config.solidityNode directly. Instead, set config.networks and then config.networks[<network name>].solidityNode")}},eventServer:{get:function get(){try{return self.network_config.eventServer}catch(e){return default_tx_values.eventServer}},set:function set(val){throw new Error("Don't set config.eventServer directly. Instead, set config.networks and then config.networks[<network name>].eventServer")}},userFeePercentage:{get:function get(){try{return self.network_config.userFeePercentage||self.network_config.consume_user_resource_percent}catch(e){return default_tx_values.userFeePercentage}},set:function set(val){throw new Error("Don't set config.userFeePercentage directly. Instead, set config.networks and then config.networks[<network name>].userFeePercentage")}},feeLimit:{get:function get(){try{return self.network_config.feeLimit||self.network_config.fee_limit}catch(e){return default_tx_values.feeLimit}},set:function set(val){throw new Error("Don't set config.feeLimit directly. Instead, set config.networks and then config.networks[<network name>].feeLimit")}},originEnergyLimit:{get:function get(){try{return self.network_config.originEnergyLimit}catch(e){return default_tx_values.originEnergyLimit}},set:function set(val){throw new Error("Don't set config.originEnergyLimit directly. Instead, set config.networks and then config.networks[<network name>].originEnergyLimit")}},tokenValue:{get:function get(){try{return self.network_config.tokenValue}catch(e){}},set:function set(val){throw new Error("Don't set config.tokenValue directly. Instead, set config.networks and then config.networks[<network name>].tokenValue")}},tokenId:{get:function get(){try{return self.network_config.tokenId}catch(e){}},set:function set(val){throw new Error("Don't set config.tokenId directly. Instead, set config.networks and then config.networks[<network name>].tokenId")}},provider:{get:function get(){if(!self.network){return null}var options=self.network_config;options.verboseRpc=self.verboseRpc;return Provider.create(options)},set:function set(val){throw new Error("Don't set config.provider directly. Instead, set config.networks and then set config.networks[<network name>].provider")}},callValue:{get:function get(){try{return self.network_config.callValue||self.network_config.call_value}catch(e){return default_tx_values.callValue}},set:function set(val){throw new Error("Don't set config.callValue directly. Instead, set config.networks and then config.networks[<network name>].callValue")}}};Object.keys(props).forEach(function(prop){self.addProp(prop,props[prop])})};Config.prototype.addProp=function(key,obj){Object.defineProperty(this,key,{get:obj.get||function(){return this._values[key]||obj()},set:obj.set||function(val){this._values[key]=val},configurable:true,enumerable:true})};Config.prototype.normalize=function(obj){var clone={};Object.keys(obj).forEach(function(key){try{clone[key]=obj[key]}catch(e){}});return clone};Config.prototype["with"]=function(obj){var normalized=this.normalize(obj);var current=this.normalize(this);return _.extend({},current,normalized)};Config.prototype.merge=function(obj){var self=this;var clone=this.normalize(obj);Object.keys(obj).forEach(function(key){try{self[key]=clone[key]}catch(e){}});return this};Config["default"]=function(){return new Config};Config.detect=function(options,filename){var search;!filename?search=[DEFAULT_CONFIG_FILENAME,BACKUP_CONFIG_FILENAME]:search=filename;var file=findUp.sync(search,{cwd:options.working_directory||options.workingDirectory});if(file==null){throw new TruffleError("Could not find suitable configuration file.")}return this.load(file,options)};Config.load=function(file,options){var config=new Config;config.working_directory=path.dirname(path.resolve(file));delete require.cache[Module._resolveFilename(file,module)];var static_config=originalrequire(file);config.merge(static_config);config.merge(options);return config};module.exports=Config; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){if(!(Symbol.iterator in Object(arr)||Object.prototype.toString.call(arr)==="[object Arguments]")){return}var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}var ethJSABI=require("ethjs-abi");var TronWrap=require("../TronWrap");var _require=require("../TronWrap"),constants=_require.constants;var BigNumber=require("bignumber.js");var StatusError=require("./statuserror.js");var contract=function(module){function Provider(provider){this.provider=provider}var tronWrap;Provider.prototype.send=function(){return this.provider.send.apply(this.provider,arguments)};Provider.prototype.sendAsync=function(){return this.provider.sendAsync.apply(this.provider,arguments)};var Utils={is_object:function is_object(val){return _typeof(val)==="object"&&!Array.isArray(val)},is_big_number:function is_big_number(val){if(_typeof(val)!=="object")return false;try{new BigNumber(val);return true}catch(e){return false}},decodeLogs:function decodeLogs(C,instance,logs){return logs.map(function(log){var logABI=C.events[log.topics[0]];if(!logABI){return null}var copy=Utils.merge({},log);function partialABI(fullABI,indexed){var inputs=fullABI.inputs.filter(function(i){return i.indexed===indexed});var partial={inputs:inputs,name:fullABI.name,type:fullABI.type,anonymous:fullABI.anonymous};return partial}var argTopics=logABI.anonymous?copy.topics:copy.topics.slice(1);var indexedData="0x"+argTopics.map(function(topics){return topics.slice(2)}).join("");var indexedParams=ethJSABI.decodeEvent(partialABI(logABI,true),indexedData);var notIndexedData=copy.data;var notIndexedParams=ethJSABI.decodeEvent(partialABI(logABI,false),notIndexedData);copy.event=logABI.name;copy.args=logABI.inputs.reduce(function(acc,current){var val=indexedParams[current.name];if(val===undefined){val=notIndexedParams[current.name]}acc[current.name]=val;return acc},{});Object.keys(copy.args).forEach(function(key){var val=copy.args[key];if(val.constructor.isBN){copy.args[key]=BigNumber("0x"+val.toString(16))}});delete copy.data;delete copy.topics;return copy}).filter(function(log){return log!=null})},promisifyFunction:function promisifyFunction(fn,C){return function(){var instance=this;var args=Array.prototype.slice.call(arguments);var tx_params={};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}tx_params=Utils.merge(C.class_defaults,tx_params);return new Promise(function(accept,reject){var callback=function callback(error,result){if(error!=null){reject(error)}else{accept(result)}};args.push(tx_params,callback);fn.apply(instance.contract,args)})}},synchronizeFunction:function synchronizeFunction(fn,instance,C){var self=this;return function(){var args=Array.prototype.slice.call(arguments);var tx_params={};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}tx_params=Utils.merge(C.class_defaults,tx_params);return new Promise(function(accept,reject){var callback=function callback(error,tx){if(error!=null){reject(error);return}var timeout;if(C.synchronization_timeout===0||C.synchronization_timeout!==undefined){timeout=C.synchronization_timeout}else{timeout=240000}var start=new Date().getTime();var make_attempt=function make_attempt(){C.web3.eth.getTransactionReceipt(tx,function(err,receipt){if(err&&!err.toString().includes("unknown transaction")){return reject(err)}if(receipt!=null){if(parseInt(receipt.status,16)===0){var statusError=new StatusError(tx_params,tx,receipt);return reject(statusError)}else{return accept({tx:tx,receipt:receipt,logs:Utils.decodeLogs(C,instance,receipt.logs)})}}if(timeout>0&&new Date().getTime()-start>timeout){return reject(new Error("Transaction "+tx+" wasn't processed in "+timeout/1000+" seconds!"))}setTimeout(make_attempt,1000)})};make_attempt()};args.push(tx_params,callback);fn.apply(self,args)})}},merge:function merge(){var merged={};var args=Array.prototype.slice.call(arguments);for(var i=0;i<args.length;i++){var object=args[i];var keys=Object.keys(object);for(var j=0;j<keys.length;j++){var key=keys[j];var value=object[key];merged[key]=value}}return merged},parallel:function parallel(arr,callback){callback=callback||function(){};if(!arr.length){return callback(null,[])}var index=0;var results=new Array(arr.length);arr.forEach(function(fn,position){fn(function(err,result){if(err){callback(err);callback=function callback(){}}else{index++;results[position]=result;if(index>=arr.length){callback(null,results)}}})})},bootstrap:function bootstrap(fn){Object.keys(fn._static_methods).forEach(function(key){fn[key]=fn._static_methods[key].bind(fn)});Object.keys(fn._properties).forEach(function(key){fn.addProp(key,fn._properties[key])});return fn},linkBytecode:function linkBytecode(bytecode,links){Object.keys(links).forEach(function(library_name){var library_address=links[library_name];var regex=new RegExp("__"+library_name+"_+","g");bytecode=bytecode.replace(regex,library_address.replace("0x","").replace("41",""))});return bytecode}};function Contract(contract){var constructor=this.constructor;this.abi=constructor.abi;if(typeof contract==="string"){this.address=contract}else{this.allEvents=contract.allEvents;this.contract=contract;this.address=contract.address}}function toCamelCase(str){return str.replace(/_([a-z])/g,function(g){return g[1].toUpperCase()})}function filterEnergyParameter(args){var deployParameters=Object.keys(constants.deployParameters);var lastArg=args[args.length-1];if(_typeof(lastArg)!=="object"||Array.isArray(lastArg))return[args,{}];args.pop();var res={};for(var property in lastArg){var camelCased=toCamelCase(property);if(~deployParameters.indexOf(camelCased)){res[camelCased]=lastArg[property]}}return[args,res]}Contract._static_methods={initTronWeb:function initTronWeb(options){if(!tronWrap){tronWrap=TronWrap(options)}},setProvider:function setProvider(provider){if(!provider){throw new Error("Invalid provider passed to setProvider(); provider is "+provider)}this.currentProvider=provider},"new":function _new(){var self=this;if(!this.currentProvider){throw new Error(this.contractName+" error: Please call setProvider() first before calling new().")}var _filterEnergyParamete=filterEnergyParameter(Array.prototype.slice.call(arguments)),_filterEnergyParamete2=_slicedToArray(_filterEnergyParamete,2),args=_filterEnergyParamete2[0],params=_filterEnergyParamete2[1];if(!this.bytecode){throw new Error(this._json.contractName+" error: contract binary not set. Can't deploy new instance.")}var regex=/__[^_]+_+/g;var unlinked_libraries=self.binary.match(regex);if(unlinked_libraries!=null){unlinked_libraries=unlinked_libraries.map(function(name){return name.replace(/_/g,"")}).sort().filter(function(name,index,arr){if(index+1>=arr.length){return true}return name!==arr[index+1]}).join(", ");throw new Error(self.contractName+" contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of "+self._json.contractName+": "+unlinked_libraries)}return new Promise(function(accept,reject){var tx_params={parameters:args};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}var constructor=self.abi.filter(function(item){return item.type==="constructor"});if(constructor.length&&constructor[0].inputs.length!==args.length){throw new Error(self.contractName+" contract constructor expected "+constructor[0].inputs.length+" arguments, received "+args.length)}tx_params=Utils.merge(self.class_defaults,tx_params);if(!tx_params.data){tx_params.data=self.binary}tx_params.contractName=self.contractName;for(var param in params){tx_params[param]=params[param]}tx_params.abi=self.abi;tronWrap._deployContract(tx_params,_callback);function _callback(err,res){if(err){reject(err);return}accept(new self(res.address))}})},at:function at(){throw new Error("The construct contractArtifacts.at(address) is not currently supported by TronBox. It will be in the future. Stay in touch.")},call:function call(methodName){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var self=this;var methodArgs={};var lastArg=args[args.length-1];if(!Array.isArray(lastArg)&&_typeof(lastArg)==="object"){methodArgs=args.pop()}if(!methodArgs.call_value){methodArgs.call_value=0}if(Array.isArray(args[0])){if(Array.isArray(args[0][0])){args=args[0]}else{var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=self.abi[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var item=_step.value;if(item.name===methodName){if(!/\[\]$/.test(item.inputs[0].type)){args=args[0]}}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}}var option={};return new Promise(function(accept,reject){function _callback(err,res){if(err){reject(err);return}accept(res)}option=Utils.merge({address:self.address,methodName:methodName,args:args,abi:self.abi,methodArgs:methodArgs},self.defaults());tronWrap.triggerContract(option,_callback)})},deployed:function deployed(){var self=this;return new Promise(function(accept,reject){if(!self.isDeployed()){throw new Error(self.contractName+" has not been deployed to detected network")}TronWrap().trx.getContract(self.address).then(function(res){var abi=res.abi&&res.abi.entrys?res.abi.entrys:[];var _loop=function _loop(i){var item=abi[i];if(self.hasOwnProperty(item.name))return"continue";if(/(function|event)/i.test(item.type)&&item.name){var f=function f(){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}return self.call.apply(null,[item.name].concat(args))};self[item.name]=f;self[item.name].call=f}};for(var i=0;i<abi.length;i++){var _ret=_loop(i);if(_ret==="continue")continue}accept(self)})["catch"](function(err){reject(err)})})},defaults:function defaults(class_defaults){if(!this.class_defaults){this.class_defaults={}}if(!class_defaults){class_defaults={}}var self=this;Object.keys(class_defaults).forEach(function(key){var value=class_defaults[key];self.class_defaults[key]=value});return this.class_defaults},hasNetwork:function hasNetwork(network_id){return this._json.networks[network_id+""]!=null},isDeployed:function isDeployed(){if(!this.network_id){return false}if(!this._json.networks[this.network_id]){return false}return!!this.network.address},setNetwork:function setNetwork(network_id){if(!network_id)return;this.network_id=network_id+""},resetAddress:function resetAddress(){delete this.network.address},link:function link(name,address){var self=this;if(typeof name==="function"){var _contract=name;if(!_contract.isDeployed()){throw new Error("Cannot link contract without an address.")}this.link(_contract.contractName,_contract.address);Object.keys(_contract.events).forEach(function(topic){self.network.events[topic]=_contract.events[topic]});return}if(_typeof(name)==="object"){var obj=name;Object.keys(obj).forEach(function(name){var a=obj[name];self.link(name,a)});return}if(!this._json.networks[this.network_id]){this._json.networks[this.network_id]={events:{},links:{}}}this.network.links[name]=address},clone:function clone(json){var self=this;json=json||{};var temp=function TruffleContract(){this.constructor=temp;return Contract.apply(this,arguments)};temp.prototype=Object.create(self.prototype);var network_id;if(_typeof(json)!=="object"){network_id=json;json=self._json}json=Utils.merge({},self._json||{},json);temp._static_methods=this._static_methods;temp._properties=this._properties;temp._property_values={};temp._json=json;Utils.bootstrap(temp);temp.class_defaults=temp.prototype.defaults||{};if(network_id){temp.setNetwork(network_id)}Object.keys(json).forEach(function(key){if(key.indexOf("x-")!==0)return;temp[key]=json[key]});return temp},addProp:function addProp(key,fn){var self=this;var getter=function getter(){if(fn.get!=null){return fn.get.call(self)}return self._property_values[key]||fn.call(self)};var setter=function setter(val){if(fn.set!=null){fn.set.call(self,val);return}throw new Error(key+" property is immutable")};var definition={};definition.enumerable=false;definition.configurable=false;definition.get=getter;definition.set=setter;Object.defineProperty(this,key,definition)},toJSON:function toJSON(){return this._json}};Contract._properties={contract_name:{get:function get(){return this.contractName},set:function set(val){this.contractName=val}},contractName:{get:function get(){return this._json.contractName||"Contract"},set:function set(val){this._json.contractName=val}},abi:{get:function get(){return this._json.abi},set:function set(val){this._json.abi=val}},network:function network(){var network_id=this.network_id;if(!network_id){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(!this._json.networks[network_id]){throw new Error(this.contractName+" has no network configuration for its current network id ("+network_id+").")}var returnVal=this._json.networks[network_id];if(!returnVal.links){returnVal.links={}}if(!returnVal.events){returnVal.events={}}return returnVal},networks:function networks(){return this._json.networks},address:{get:function get(){var address=this.network.address;if(!address){throw new Error("Cannot find deployed address: "+this.contractName+" not deployed or address not set.")}return address},set:function set(val){if(!val){throw new Error("Cannot set deployed address; malformed value: "+val)}var network_id=this.network_id;if(!network_id){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(!this._json.networks[network_id]){this._json.networks[network_id]={events:{},links:{}}}this.network.address=val}},transactionHash:{get:function get(){var transactionHash=this.network.transactionHash;if(transactionHash===null){throw new Error("Could not find transaction hash for "+this.contractName)}return transactionHash},set:function set(val){this.network.transactionHash=val}},links:function links(){if(!this.network_id){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(!this._json.networks[this.network_id]){return{}}return this.network.links||{}},events:function events(){return[]},binary:function binary(){return Utils.linkBytecode(this.bytecode,this.links)},deployedBinary:function deployedBinary(){return Utils.linkBytecode(this.deployedBytecode,this.links)},unlinked_binary:{get:function get(){return this.bytecode},set:function set(val){this.bytecode=val}},bytecode:{get:function get(){return this._json.bytecode},set:function set(val){this._json.bytecode=val}},deployedBytecode:{get:function get(){var code=this._json.deployedBytecode;if(code.indexOf("0x")!==0){code="0x"+code}return code},set:function set(val){var code=val;if(val.indexOf("0x")!==0){code="0x"+code}this._json.deployedBytecode=code}},sourceMap:{get:function get(){return this._json.sourceMap},set:function set(val){this._json.sourceMap=val}},deployedSourceMap:{get:function get(){return this._json.deployedSourceMap},set:function set(val){this._json.deployedSourceMap=val}},source:{get:function get(){return this._json.source},set:function set(val){this._json.source=val}},sourcePath:{get:function get(){return this._json.sourcePath},set:function set(val){this._json.sourcePath=val}},legacyAST:{get:function get(){return this._json.legacyAST},set:function set(val){this._json.legacyAST=val}},ast:{get:function get(){return this._json.ast},set:function set(val){this._json.ast=val}},compiler:{get:function get(){return this._json.compiler},set:function set(val){this._json.compiler=val}},schema_version:function schema_version(){return this.schemaVersion},schemaVersion:function schemaVersion(){return this._json.schemaVersion},updated_at:function updated_at(){return this.updatedAt},updatedAt:function updatedAt(){try{return this.network.updatedAt||this._json.updatedAt}catch(e){return this._json.updatedAt}}};Utils.bootstrap(Contract);module.exports=Contract;return Contract}(module||{}); | ||
"use strict";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(arr,i){if(!(Symbol.iterator in Object(arr)||Object.prototype.toString.call(arr)==="[object Arguments]")){return}var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}var ethJSABI=require("ethjs-abi");var TronWrap=require("../TronWrap");var _require=require("../TronWrap"),constants=_require.constants;var BigNumber=require("bignumber.js");var StatusError=require("./statuserror.js");var contract=function(module){function Provider(provider){this.provider=provider}var tronWrap;Provider.prototype.send=function(){return this.provider.send.apply(this.provider,arguments)};Provider.prototype.sendAsync=function(){return this.provider.sendAsync.apply(this.provider,arguments)};var Utils={is_object:function is_object(val){return _typeof(val)=="object"&&!Array.isArray(val)},is_big_number:function is_big_number(val){if(_typeof(val)!="object")return false;try{new BigNumber(val);return true}catch(e){return false}},decodeLogs:function decodeLogs(C,instance,logs){return logs.map(function(log){var logABI=C.events[log.topics[0]];if(logABI==null){return null}var copy=Utils.merge({},log);function partialABI(fullABI,indexed){var inputs=fullABI.inputs.filter(function(i){return i.indexed===indexed});var partial={inputs:inputs,name:fullABI.name,type:fullABI.type,anonymous:fullABI.anonymous};return partial}var argTopics=logABI.anonymous?copy.topics:copy.topics.slice(1);var indexedData="0x"+argTopics.map(function(topics){return topics.slice(2)}).join("");var indexedParams=ethJSABI.decodeEvent(partialABI(logABI,true),indexedData);var notIndexedData=copy.data;var notIndexedParams=ethJSABI.decodeEvent(partialABI(logABI,false),notIndexedData);copy.event=logABI.name;copy.args=logABI.inputs.reduce(function(acc,current){var val=indexedParams[current.name];if(val===undefined){val=notIndexedParams[current.name]}acc[current.name]=val;return acc},{});Object.keys(copy.args).forEach(function(key){var val=copy.args[key];if(val.constructor.isBN){copy.args[key]=BigNumber("0x"+val.toString(16))}});delete copy.data;delete copy.topics;return copy}).filter(function(log){return log!=null})},promisifyFunction:function promisifyFunction(fn,C){var self=this;return function(){var instance=this;var args=Array.prototype.slice.call(arguments);var tx_params={};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}tx_params=Utils.merge(C.class_defaults,tx_params);return new Promise(function(accept,reject){var callback=function callback(error,result){if(error!=null){reject(error)}else{accept(result)}};args.push(tx_params,callback);fn.apply(instance.contract,args)})}},synchronizeFunction:function synchronizeFunction(fn,instance,C){var self=this;return function(){var args=Array.prototype.slice.call(arguments);var tx_params={};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}tx_params=Utils.merge(C.class_defaults,tx_params);return new Promise(function(accept,reject){var callback=function callback(error,tx){if(error!=null){reject(error);return}var timeout;if(C.synchronization_timeout===0||C.synchronization_timeout!==undefined){timeout=C.synchronization_timeout}else{timeout=240000}var start=new Date().getTime();var make_attempt=function make_attempt(){C.web3.eth.getTransactionReceipt(tx,function(err,receipt){if(err&&!err.toString().includes("unknown transaction")){return reject(err)}if(receipt!=null){if(parseInt(receipt.status,16)==0){var statusError=new StatusError(tx_params,tx,receipt);return reject(statusError)}else{return accept({tx:tx,receipt:receipt,logs:Utils.decodeLogs(C,instance,receipt.logs)})}}if(timeout>0&&new Date().getTime()-start>timeout){return reject(new Error("Transaction "+tx+" wasn't processed in "+timeout/1000+" seconds!"))}setTimeout(make_attempt,1000)})};make_attempt()};args.push(tx_params,callback);fn.apply(self,args)})}},merge:function merge(){var merged={};var args=Array.prototype.slice.call(arguments);for(var i=0;i<args.length;i++){var object=args[i];var keys=Object.keys(object);for(var j=0;j<keys.length;j++){var key=keys[j];var value=object[key];merged[key]=value}}return merged},parallel:function parallel(arr,callback){callback=callback||function(){};if(!arr.length){return callback(null,[])}var index=0;var results=new Array(arr.length);arr.forEach(function(fn,position){fn(function(err,result){if(err){callback(err);callback=function callback(){}}else{index++;results[position]=result;if(index>=arr.length){callback(null,results)}}})})},bootstrap:function bootstrap(fn){Object.keys(fn._static_methods).forEach(function(key){fn[key]=fn._static_methods[key].bind(fn)});Object.keys(fn._properties).forEach(function(key){fn.addProp(key,fn._properties[key])});return fn},linkBytecode:function linkBytecode(bytecode,links){Object.keys(links).forEach(function(library_name){var library_address=links[library_name];var regex=new RegExp("__"+library_name+"_+","g");bytecode=bytecode.replace(regex,library_address.replace("0x","").replace("41",""))});return bytecode}};function Contract(contract){var constructor=this.constructor;this.abi=constructor.abi;if(typeof contract=="string"){this.address=contract}else{this.allEvents=contract.allEvents;this.contract=contract;this.address=contract.address}};function toCamelCase(str){return str.replace(/_([a-z])/g,function(g){return g[1].toUpperCase()})}function filterEnergyParameter(args){var deployParameters=Object.keys(constants.deployParameters);var lastArg=args[args.length-1];if(_typeof(lastArg)!=="object"||Array.isArray(lastArg))return[args,{}];args.pop();var res={};for(var property in lastArg){var camelCased=toCamelCase(property);if(!!~deployParameters.indexOf(camelCased)){res[camelCased]=lastArg[property]}}return[args,res]}Contract._static_methods={initTronWeb:function initTronWeb(options){if(!tronWrap){tronWrap=TronWrap(options)}},setProvider:function setProvider(provider){if(!provider){throw new Error("Invalid provider passed to setProvider(); provider is "+provider)}var wrapped=new Provider(provider);this.currentProvider=provider},"new":function _new(){var self=this;if(this.currentProvider==null){throw new Error(this.contractName+" error: Please call setProvider() first before calling new().")}var _filterEnergyParamete=filterEnergyParameter(Array.prototype.slice.call(arguments)),_filterEnergyParamete2=_slicedToArray(_filterEnergyParamete,2),args=_filterEnergyParamete2[0],params=_filterEnergyParamete2[1];if(!this.bytecode){throw new Error(this._json.contractName+" error: contract binary not set. Can't deploy new instance.")}var regex=/__[^_]+_+/g;var unlinked_libraries=self.binary.match(regex);if(unlinked_libraries!=null){unlinked_libraries=unlinked_libraries.map(function(name){return name.replace(/_/g,"")}).sort().filter(function(name,index,arr){if(index+1>=arr.length){return true}return name!=arr[index+1]}).join(", ");throw new Error(self.contractName+" contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of "+self._json.contractName+": "+unlinked_libraries)}return new Promise(function(accept,reject){var tx_params={parameters:args};var last_arg=args[args.length-1];if(Utils.is_object(last_arg)&&!Utils.is_big_number(last_arg)){tx_params=args.pop()}var constructor=self.abi.filter(function(item){return item.type==="constructor"});if(constructor.length&&constructor[0].inputs.length!==args.length){throw new Error(self.contractName+" contract constructor expected "+constructor[0].inputs.length+" arguments, received "+args.length)}tx_params=Utils.merge(self.class_defaults,tx_params);if(tx_params.data==null){tx_params.data=self.binary}tx_params.contractName=self.contractName;for(var param in params){tx_params[param]=params[param]}tx_params.abi=self.abi;tronWrap._deployContract(tx_params,_callback);function _callback(err,res){if(err){reject(err);return}accept(new self(res.address))}})},at:function at(address){var self=this;throw new Error("The construct contractArtifacts.at(address) is not currently supported by TronBox. It will be in the future. Stay in touch.");if(address==null||typeof address!="string"||address.length!=42){throw new Error("Invalid address passed to "+this._json.contractName+".at(): "+address)}var contract=new this(address);contract.then=function(fn){return new Promise(function(){var instance=new self(address);return new Promise(function(accept,reject){tronWrap._getContract(address,function(err,contractAddress){if(err)return reject(err);if(!contractAddress||contractAddress.replace(/^0x/,"").replace(/0/g,"")===""){return reject(new Error("Cannot create instance of "+self.contractName+"; no code at address "+address))}accept(instance)})})}).then(fn)};return contract},call:function call(methodName){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var self=this;var methodArgs={};var lastArg=args[args.length-1];if(!Array.isArray(lastArg)&&_typeof(lastArg)==="object"){methodArgs=args.pop()}if(!methodArgs.call_value){methodArgs.call_value=0}if(Array.isArray(args[0])){if(Array.isArray(args[0][0])){args=args[0]}else{var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=self.abi[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var item=_step.value;if(item.name===methodName){if(!/\[\]$/.test(item.inputs[0].type)){args=args[0]}}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}}var option={};return new Promise(function(accept,reject){function _callback(err,res){if(err){reject(err);return}accept(res)}option=Utils.merge({address:self.address,methodName:methodName,args:args,abi:self.abi,methodArgs:methodArgs},self.defaults());tronWrap.triggerContract(option,_callback)})},deployed:function deployed(){var self=this;return new Promise(function(accept,reject){if(!self.isDeployed()){throw new Error(self.contractName+" has not been deployed to detected network")}TronWrap().trx.getContract(self.address).then(function(res){var abi=res.abi&&res.abi.entrys?res.abi.entrys:[];var _loop=function _loop(){var item=abi[i];if(self.hasOwnProperty(item.name))return"continue";if(/(function|event)/i.test(item.type)&&item.name){var f=function f(){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}return self.call.apply(null,[item.name].concat(args))};self[item.name]=f;self[item.name].call=f}};for(var i=0;i<abi.length;i++){var _ret=_loop();if(_ret==="continue")continue}accept(self)})["catch"](function(err){reject(err)})})},defaults:function defaults(class_defaults){if(this.class_defaults==null){this.class_defaults={}}if(class_defaults==null){class_defaults={}}var self=this;Object.keys(class_defaults).forEach(function(key){var value=class_defaults[key];self.class_defaults[key]=value});return this.class_defaults},hasNetwork:function hasNetwork(network_id){return this._json.networks[network_id+""]!=null},isDeployed:function isDeployed(){if(this.network_id==null){return false}if(this._json.networks[this.network_id]==null){return false}return!!this.network.address},setNetwork:function setNetwork(network_id){if(!network_id)return;this.network_id=network_id+""},resetAddress:function resetAddress(){delete this.network.address},link:function link(name,address){var self=this;if(typeof name=="function"){var contract=name;if(contract.isDeployed()==false){throw new Error("Cannot link contract without an address.")}this.link(contract.contractName,contract.address);Object.keys(contract.events).forEach(function(topic){self.network.events[topic]=contract.events[topic]});return}if(_typeof(name)=="object"){var obj=name;Object.keys(obj).forEach(function(name){var a=obj[name];self.link(name,a)});return}if(this._json.networks[this.network_id]==null){this._json.networks[this.network_id]={events:{},links:{}}}this.network.links[name]=address},clone:function clone(json){var self=this;json=json||{};var temp=function TruffleContract(){this.constructor=temp;return Contract.apply(this,arguments)};temp.prototype=Object.create(self.prototype);var network_id;if(_typeof(json)!="object"){network_id=json;json=self._json}json=Utils.merge({},self._json||{},json);temp._static_methods=this._static_methods;temp._properties=this._properties;temp._property_values={};temp._json=json;Utils.bootstrap(temp);temp.class_defaults=temp.prototype.defaults||{};if(network_id){temp.setNetwork(network_id)}Object.keys(json).forEach(function(key){if(key.indexOf("x-")!=0)return;temp[key]=json[key]});return temp},addProp:function addProp(key,fn){var self=this;var getter=function getter(){if(fn.get!=null){return fn.get.call(self)}return self._property_values[key]||fn.call(self)};var setter=function setter(val){if(fn.set!=null){fn.set.call(self,val);return}throw new Error(key+" property is immutable")};var definition={};definition.enumerable=false;definition.configurable=false;definition.get=getter;definition.set=setter;Object.defineProperty(this,key,definition)},toJSON:function toJSON(){return this._json}};Contract._properties={contract_name:{get:function get(){return this.contractName},set:function set(val){this.contractName=val}},contractName:{get:function get(){return this._json.contractName||"Contract"},set:function set(val){this._json.contractName=val}},abi:{get:function get(){return this._json.abi},set:function set(val){this._json.abi=val}},network:function network(){var network_id=this.network_id;if(network_id==null){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(this._json.networks[network_id]==null){throw new Error(this.contractName+" has no network configuration for its current network id ("+network_id+").")}var returnVal=this._json.networks[network_id];if(returnVal.links==null){returnVal.links={}}if(returnVal.events==null){returnVal.events={}}return returnVal},networks:function networks(){return this._json.networks},address:{get:function get(){var address=this.network.address;if(address==null){throw new Error("Cannot find deployed address: "+this.contractName+" not deployed or address not set.")}return address},set:function set(val){if(val==null){throw new Error("Cannot set deployed address; malformed value: "+val)}var network_id=this.network_id;if(network_id==null){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(this._json.networks[network_id]==null){this._json.networks[network_id]={events:{},links:{}}}this.network.address=val}},transactionHash:{get:function get(){var transactionHash=this.network.transactionHash;if(transactionHash===null){throw new Error("Could not find transaction hash for "+this.contractName)}return transactionHash},set:function set(val){this.network.transactionHash=val}},links:function links(){if(!this.network_id){throw new Error(this.contractName+" has no network id set, cannot lookup artifact data. Either set the network manually using "+this.contractName+".setNetwork(), run "+this.contractName+".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.")}if(this._json.networks[this.network_id]==null){return{}}return this.network.links||{}},events:function events(){return[];var events;if(this._json.networks[this.network_id]==null){events={}}else{events=this.network.events||{}}var abi=this.abi;abi.forEach(function(item){if(item.type!="event")return;var signature=item.name+"(";item.inputs.forEach(function(input,index){signature+=input.type;if(index<item.inputs.length-1){signature+=","}});signature+=")";var topic=TronWrap().sha3(signature);events[topic]=item});return events},binary:function binary(){return Utils.linkBytecode(this.bytecode,this.links)},deployedBinary:function deployedBinary(){return Utils.linkBytecode(this.deployedBytecode,this.links)},unlinked_binary:{get:function get(){return this.bytecode},set:function set(val){this.bytecode=val}},bytecode:{get:function get(){return this._json.bytecode},set:function set(val){this._json.bytecode=val}},deployedBytecode:{get:function get(){var code=this._json.deployedBytecode;if(code.indexOf("0x")!=0){code="0x"+code}return code},set:function set(val){var code=val;if(val.indexOf("0x")!=0){code="0x"+code}this._json.deployedBytecode=code}},sourceMap:{get:function get(){return this._json.sourceMap},set:function set(val){this._json.sourceMap=val}},deployedSourceMap:{get:function get(){return this._json.deployedSourceMap},set:function set(val){this._json.deployedSourceMap=val}},source:{get:function get(){return this._json.source},set:function set(val){this._json.source=val}},sourcePath:{get:function get(){return this._json.sourcePath},set:function set(val){this._json.sourcePath=val}},legacyAST:{get:function get(){return this._json.legacyAST},set:function set(val){this._json.legacyAST=val}},ast:{get:function get(){return this._json.ast},set:function set(val){this._json.ast=val}},compiler:{get:function get(){return this._json.compiler},set:function set(val){this._json.compiler=val}},schema_version:function schema_version(){return this.schemaVersion},schemaVersion:function schemaVersion(){return this._json.schemaVersion},updated_at:function updated_at(){return this.updatedAt},updatedAt:function updatedAt(){try{return this.network.updatedAt||this._json.updatedAt}catch(e){return this._json.updatedAt}}};Utils.bootstrap(Contract);module.exports=Contract;return Contract}(module||{}); |
@@ -1,1 +0,1 @@ | ||
"use strict";var TruffleError=require("@truffle/error");var inherits=require("util").inherits;inherits(StatusError,TruffleError);var defaultGas=90000;function StatusError(args,tx,receipt){var message;var gasLimit=parseInt(args.gas)||defaultGas;if(receipt.gasUsed===gasLimit){message="Transaction: "+tx+" exited with an error (status 0) after consuming all gas.\n"+"Please check that the transaction:\n"+" - satisfies all conditions set by Solidity `assert` statements.\n"+" - has enough gas to execute the full transaction.\n"+" - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds)."}else{message="Transaction: "+tx+" exited with an error (status 0).\n"+"Please check that the transaction:\n"+" - satisfies all conditions set by Solidity `require` statements.\n"+" - does not trigger a Solidity `revert` statement.\n"}StatusError.super_.call(this,message);this.tx=tx;this.receipt=receipt}module.exports=StatusError; | ||
"use strict";var TruffleError=require("@truffle/error");var inherits=require("util").inherits;var web3=require("web3-mock");inherits(StatusError,TruffleError);var defaultGas=90000;function StatusError(args,tx,receipt){var message;var gasLimit=parseInt(args.gas)||defaultGas;if(receipt.gasUsed===gasLimit){message="Transaction: "+tx+" exited with an error (status 0) after consuming all gas.\n"+"Please check that the transaction:\n"+" - satisfies all conditions set by Solidity `assert` statements.\n"+" - has enough gas to execute the full transaction.\n"+" - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds)."}else{message="Transaction: "+tx+" exited with an error (status 0).\n"+"Please check that the transaction:\n"+" - satisfies all conditions set by Solidity `require` statements.\n"+" - does not trigger a Solidity `revert` statement.\n"}StatusError.super_.call(this,message);this.tx=tx;this.receipt=receipt}module.exports=StatusError; |
@@ -1,1 +0,1 @@ | ||
"use strict";var pkgVersion="2.0.1";var Ajv=require("ajv");var contractObjectSchema=require("./spec/contract-object.spec.json");var networkObjectSchema=require("./spec/network-object.spec.json");var abiSchema=require("./spec/abi.spec.json");var properties={contractName:{sources:["contractName","contract_name"]},abi:{sources:["abi","interface"],transform:function transform(value){if(typeof value==="string"){try{value=JSON.parse(value)}catch(e){value=undefined}}return value}},bytecode:{sources:["bytecode","binary","unlinked_binary","evm.bytecode.object"],transform:function transform(value){if(value&&value.indexOf("0x")!==0){value="0x"+value}return value}},deployedBytecode:{sources:["deployedBytecode","runtimeBytecode","evm.deployedBytecode.object"],transform:function transform(value){if(value&&value.indexOf("0x")!==0){value="0x"+value}return value}},sourceMap:{sources:["sourceMap","srcmap","evm.bytecode.sourceMap"]},deployedSourceMap:{sources:["deployedSourceMap","srcmapRuntime","evm.deployedBytecode.sourceMap"]},source:{},sourcePath:{},ast:{},legacyAST:{transform:function transform(value,obj){var schemaVersion=obj.schemaVersion||"0.0.0";if(schemaVersion[0]<2){return obj.ast}else{return value}}},compiler:{},networks:{transform:function transform(value){if(value===undefined){value={}}return value}},schemaVersion:{sources:["schemaVersion","schema_version"]},updatedAt:{sources:["updatedAt","updated_at"],transform:function transform(value){if(typeof value==="number"){value=new Date(value).toISOString()}return value}}};function getter(key,transform){if(transform===undefined){transform=function transform(x){return x}}return function(obj){try{return transform(obj[key])}catch(e){return undefined}}}function chain(){var getters=Array.prototype.slice.call(arguments);return function(obj){return getters.reduce(function(cur,get){return get(cur)},obj)}}var TruffleContractSchema={validate:function validate(contractObj){var ajv=new Ajv({useDefaults:true});ajv.addSchema(abiSchema);ajv.addSchema(networkObjectSchema);ajv.addSchema(contractObjectSchema);if(ajv.validate("contract-object.spec.json",contractObj)){return contractObj}else{throw ajv.errors}},normalize:function normalize(objDirty,options){options=options||{};var normalized={};Object.keys(properties).forEach(function(key){var property=properties[key];var value;var sources=property.sources||[key];for(var i=0;value===undefined&&i<sources.length;i++){var source=sources[i];if(typeof source==="string"){var traversals=source.split(".").map(function(k){return getter(k)});source=chain.apply(null,traversals)}value=source(objDirty)}if(property.transform){value=property.transform(value,objDirty)}normalized[key]=value});Object.keys(objDirty).forEach(function(key){if(key.indexOf("x-")===0){normalized[key]=getter(key)(objDirty)}});normalized.schemaVersion=pkgVersion;if(options.validate){this.validate(normalized)}return normalized}};module.exports=TruffleContractSchema; | ||
"use strict";var sha3=require("crypto-js/sha3");var pkgVersion="2.0.1";var Ajv=require("ajv");var contractObjectSchema=require("./spec/contract-object.spec.json");var networkObjectSchema=require("./spec/network-object.spec.json");var abiSchema=require("./spec/abi.spec.json");var properties={"contractName":{"sources":["contractName","contract_name"]},"abi":{"sources":["abi","interface"],"transform":function transform(value){if(typeof value==="string"){try{value=JSON.parse(value)}catch(e){value=undefined}}return value}},"bytecode":{"sources":["bytecode","binary","unlinked_binary","evm.bytecode.object"],"transform":function transform(value){if(value&&value.indexOf("0x")!=0){value="0x"+value}return value}},"deployedBytecode":{"sources":["deployedBytecode","runtimeBytecode","evm.deployedBytecode.object"],"transform":function transform(value){if(value&&value.indexOf("0x")!=0){value="0x"+value}return value}},"sourceMap":{"sources":["sourceMap","srcmap","evm.bytecode.sourceMap"]},"deployedSourceMap":{"sources":["deployedSourceMap","srcmapRuntime","evm.deployedBytecode.sourceMap"]},"source":{},"sourcePath":{},"ast":{},"legacyAST":{"transform":function transform(value,obj){var schemaVersion=obj.schemaVersion||"0.0.0";if(schemaVersion[0]<2){return obj.ast}else{return value}}},"compiler":{},"networks":{"transform":function transform(value){if(value===undefined){value={}}return value}},"schemaVersion":{"sources":["schemaVersion","schema_version"]},"updatedAt":{"sources":["updatedAt","updated_at"],"transform":function transform(value){if(typeof value==="number"){value=new Date(value).toISOString()}return value}}};function getter(key,transform){if(transform===undefined){transform=function transform(x){return x}}return function(obj){try{return transform(obj[key])}catch(e){return undefined}}}function chain(){var getters=Array.prototype.slice.call(arguments);return function(obj){return getters.reduce(function(cur,get){return get(cur)},obj)}}var TruffleContractSchema={validate:function validate(contractObj){var ajv=new Ajv({useDefaults:true});ajv.addSchema(abiSchema);ajv.addSchema(networkObjectSchema);ajv.addSchema(contractObjectSchema);if(ajv.validate("contract-object.spec.json",contractObj)){return contractObj}else{throw ajv.errors}},normalize:function normalize(objDirty,options){options=options||{};var normalized={};Object.keys(properties).forEach(function(key){var property=properties[key];var value;var sources=property.sources||[key];for(var i=0;value===undefined&&i<sources.length;i++){var source=sources[i];if(typeof source==="string"){var traversals=source.split(".").map(function(k){return getter(k)});source=chain.apply(null,traversals)}value=source(objDirty)}if(property.transform){value=property.transform(value,objDirty)}normalized[key]=value});Object.keys(objDirty).forEach(function(key){if(key.indexOf("x-")===0){normalized[key]=getter(key)(objDirty)}});normalized.schemaVersion=pkgVersion;if(options.validate){this.validate(normalized)}return normalized}};module.exports=TruffleContractSchema; |
@@ -5,19 +5,11 @@ { | ||
"title": "ABI", | ||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/definitions/Event" | ||
}, | ||
{ | ||
"$ref": "#/definitions/ConstructorFunction" | ||
}, | ||
{ | ||
"$ref": "#/definitions/FallbackFunction" | ||
}, | ||
{ | ||
"$ref": "#/definitions/NormalFunction" | ||
} | ||
] | ||
}, | ||
"items": { "oneOf": [ | ||
{ "$ref": "#/definitions/Event" }, | ||
{ "$ref": "#/definitions/ConstructorFunction" }, | ||
{ "$ref": "#/definitions/FallbackFunction" }, | ||
{ "$ref": "#/definitions/NormalFunction" } | ||
]}, | ||
"definitions": { | ||
@@ -28,31 +20,17 @@ "Name": { | ||
}, | ||
"Type": { | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"pattern": "^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\\[[0-9]*\\])?$" | ||
}, | ||
{ | ||
"pattern": "^address(\\[[0-9]*\\])?$" | ||
}, | ||
{ | ||
"pattern": "^bool(\\[[0-9]*\\])?$" | ||
}, | ||
{ | ||
"pattern": "^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\\[[0-9]*\\])?$" | ||
}, | ||
{ | ||
"pattern": "^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\\[[0-9]*\\])?" | ||
}, | ||
{ | ||
"pattern": "^bytes$" | ||
}, | ||
{ | ||
"pattern": "^function(\\[[0-9]*\\])?$" | ||
}, | ||
{ | ||
"pattern": "^string$" | ||
} | ||
{ "pattern": "^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\\[[0-9]*\\])?$" }, | ||
{ "pattern": "^address(\\[[0-9]*\\])?$"}, | ||
{ "pattern": "^bool(\\[[0-9]*\\])?$"}, | ||
{ "pattern": "^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\\[[0-9]*\\])?$" }, | ||
{ "pattern": "^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\\[[0-9]*\\])?" }, | ||
{ "pattern": "^bytes$" }, | ||
{ "pattern": "^function(\\[[0-9]*\\])?$" }, | ||
{ "pattern": "^string$" } | ||
] | ||
}, | ||
"StateMutability": { | ||
@@ -67,2 +45,3 @@ "type": "string", | ||
}, | ||
"NormalFunction": { | ||
@@ -73,21 +52,13 @@ "type": "object", | ||
"type": "string", | ||
"enum": [ | ||
"function" | ||
], | ||
"enum": ["function"], | ||
"default": "function" | ||
}, | ||
"name": { | ||
"$ref": "#/definitions/Name" | ||
}, | ||
"name": { "$ref": "#/definitions/Name" }, | ||
"inputs": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Parameter" | ||
} | ||
"items": { "$ref": "#/definitions/Parameter" } | ||
}, | ||
"outputs": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Parameter" | ||
}, | ||
"items": { "$ref": "#/definitions/Parameter" }, | ||
"default": [] | ||
@@ -98,17 +69,9 @@ }, | ||
}, | ||
"constant": { | ||
"type": "boolean" | ||
}, | ||
"payable": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
"constant": { "type": "boolean" }, | ||
"payable": { "type": "boolean", "default": false } | ||
}, | ||
"required": [ | ||
"name", | ||
"inputs", | ||
"constant" | ||
], | ||
"required": ["name", "inputs", "constant"], | ||
"additionalProperties": false | ||
}, | ||
"ConstructorFunction": { | ||
@@ -119,23 +82,14 @@ "type": "object", | ||
"type": "string", | ||
"enum": [ | ||
"constructor" | ||
] | ||
"enum": ["constructor"] | ||
}, | ||
"inputs": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Parameter" | ||
} | ||
"items": { "$ref": "#/definitions/Parameter" } | ||
}, | ||
"payable": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
"payable": { "type": "boolean", "default": false } | ||
}, | ||
"required": [ | ||
"type", | ||
"inputs" | ||
], | ||
"required": ["type", "inputs"], | ||
"additionalProperties": false | ||
}, | ||
"FallbackFunction": { | ||
@@ -146,19 +100,11 @@ "type": "object", | ||
"type": "string", | ||
"enum": [ | ||
"fallback" | ||
] | ||
"enum": ["fallback"] | ||
}, | ||
"constant": { | ||
"type": "boolean" | ||
}, | ||
"payable": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
"constant": { "type": "boolean" }, | ||
"payable": { "type": "boolean", "default": false } | ||
}, | ||
"required": [ | ||
"type" | ||
], | ||
"required": ["type"], | ||
"additionalProperties": false | ||
}, | ||
"Event": { | ||
@@ -169,62 +115,34 @@ "type": "object", | ||
"type": "string", | ||
"enum": [ | ||
"event" | ||
] | ||
"enum": ["event"] | ||
}, | ||
"name": { | ||
"$ref": "#/definitions/Name" | ||
}, | ||
"name": { "$ref": "#/definitions/Name" }, | ||
"inputs": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/EventParameter" | ||
} | ||
"items": { "$ref": "#/definitions/EventParameter" } | ||
}, | ||
"anonymous": { | ||
"type": "boolean" | ||
} | ||
"anonymous": { "type": "boolean" } | ||
}, | ||
"required": [ | ||
"type", | ||
"name", | ||
"inputs", | ||
"anonymous" | ||
], | ||
"required": ["type", "name", "inputs", "anonymous"], | ||
"additionalProperties": false | ||
}, | ||
"Parameter": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"$ref": "#/definitions/Name" | ||
}, | ||
"type": { | ||
"$ref": "#/definitions/Type" | ||
} | ||
"name": { "$ref": "#/definitions/Name" }, | ||
"type": { "$ref": "#/definitions/Type" } | ||
}, | ||
"required": [ | ||
"name", | ||
"type" | ||
] | ||
"required": ["name", "type"] | ||
}, | ||
"EventParameter": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"$ref": "#/definitions/Name" | ||
}, | ||
"type": { | ||
"$ref": "#/definitions/Type" | ||
}, | ||
"indexed": { | ||
"type": "boolean" | ||
} | ||
"name": { "$ref": "#/definitions/Name" }, | ||
"type": { "$ref": "#/definitions/Type" }, | ||
"indexed": { "type": "boolean" } | ||
}, | ||
"required": [ | ||
"name", | ||
"type", | ||
"indexed" | ||
] | ||
"required": ["name", "type", "indexed"] | ||
} | ||
} | ||
} |
@@ -6,2 +6,3 @@ { | ||
"description": "Describes a contract consumable by Truffle, possibly including deployed instances on networks", | ||
"type": "object", | ||
@@ -11,6 +12,4 @@ "properties": { | ||
"allOf": [ | ||
{ "$ref": "#/definitions/ContractName" }, | ||
{ | ||
"$ref": "#/definitions/ContractName" | ||
}, | ||
{ | ||
"description": "Name used to identify the contract", | ||
@@ -23,8 +22,4 @@ "default": "Contract" | ||
"allOf": [ | ||
{ | ||
"$ref": "abi.spec.json#" | ||
}, | ||
{ | ||
"description": "Interface description returned by compiler for source" | ||
} | ||
{ "$ref": "abi.spec.json#"}, | ||
{ "description": "Interface description returned by compiler for source" } | ||
] | ||
@@ -34,8 +29,4 @@ }, | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/Bytecode" | ||
}, | ||
{ | ||
"description": "Bytecode sent as contract-creation transaction data, with unresolved link references" | ||
} | ||
{ "$ref": "#/definitions/Bytecode" }, | ||
{ "description": "Bytecode sent as contract-creation transaction data, with unresolved link references" } | ||
] | ||
@@ -45,8 +36,4 @@ }, | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/Bytecode" | ||
}, | ||
{ | ||
"description": "On-chain deployed contract bytecode, with unresolved link references" | ||
} | ||
{ "$ref": "#/definitions/Bytecode" }, | ||
{ "description": "On-chain deployed contract bytecode, with unresolved link references" } | ||
] | ||
@@ -56,8 +43,4 @@ }, | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/SourceMap" | ||
}, | ||
{ | ||
"description": "Source mapping for contract-creation transaction data bytecode" | ||
} | ||
{ "$ref": "#/definitions/SourceMap" }, | ||
{ "description": "Source mapping for contract-creation transaction data bytecode" } | ||
] | ||
@@ -67,31 +50,15 @@ }, | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/SourceMap" | ||
}, | ||
{ | ||
"description": "Source mapping for contract bytecode" | ||
} | ||
{ "$ref": "#/definitions/SourceMap" }, | ||
{ "description": "Source mapping for contract bytecode" } | ||
] | ||
}, | ||
"source": { | ||
"$ref": "#/definitions/Source" | ||
}, | ||
"sourcePath": { | ||
"$ref": "#/definitions/SourcePath" | ||
}, | ||
"ast": { | ||
"$ref": "#/definitions/AST" | ||
}, | ||
"legacyAST": { | ||
"$ref": "#/definitions/LegacyAST" | ||
}, | ||
"source": { "$ref": "#/definitions/Source" }, | ||
"sourcePath": { "$ref": "#/definitions/SourcePath" }, | ||
"ast": { "$ref": "#/definitions/AST" }, | ||
"legacyAST": { "$ref": "#/definitions/LegacyAST" }, | ||
"compiler": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"version": { | ||
"type": "string" | ||
} | ||
"name": {"type": "string"}, | ||
"version": {"type": "string"} | ||
} | ||
@@ -101,11 +68,7 @@ }, | ||
"patternProperties": { | ||
"^[a-zA-Z0-9]+$": { | ||
"$ref": "network-object.spec.json#" | ||
} | ||
"^[a-zA-Z0-9]+$": { "$ref": "network-object.spec.json#"} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"schemaVersion": { | ||
"$ref": "#/definitions/SchemaVersion" | ||
}, | ||
"schemaVersion": { "$ref": "#/definitions/SchemaVersion" }, | ||
"updatedAt": { | ||
@@ -120,20 +83,11 @@ "type": "string", | ||
"patternProperties": { | ||
"^x-": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "object" | ||
}, | ||
{ | ||
"type": "array" | ||
} | ||
] | ||
} | ||
"^x-": { "anyOf": [ | ||
{ "type": "string" }, | ||
{ "type": "number" }, | ||
{ "type": "object" }, | ||
{ "type": "array" } | ||
]} | ||
}, | ||
"additionalProperties": false, | ||
"definitions": { | ||
@@ -144,2 +98,3 @@ "ContractName": { | ||
}, | ||
"Bytecode": { | ||
@@ -149,5 +104,7 @@ "type": "string", | ||
}, | ||
"Source": { | ||
"type": "string" | ||
}, | ||
"SourceMap": { | ||
@@ -159,11 +116,15 @@ "type": "string", | ||
}, | ||
"SourcePath": { | ||
"type": "string" | ||
}, | ||
"AST": { | ||
"type": "object" | ||
}, | ||
"LegacyAST": { | ||
"type": "object" | ||
}, | ||
"SchemaVersion": { | ||
@@ -170,0 +131,0 @@ "type": "string", |
@@ -5,16 +5,11 @@ { | ||
"title": "Network Object", | ||
"type": "object", | ||
"properties": { | ||
"address": { | ||
"$ref": "#/definitions/Address" | ||
}, | ||
"transactionHash": { | ||
"$ref": "#/definitions/TransactionHash" | ||
}, | ||
"address": { "$ref": "#/definitions/Address" }, | ||
"transactionHash": { "$ref": "#/definitions/TransactionHash" }, | ||
"events": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^0x[a-fA-F0-9]{64}$": { | ||
"$ref": "abi.spec.json#/definitions/Event" | ||
} | ||
"^0x[a-fA-F0-9]{64}$": { "$ref": "abi.spec.json#/definitions/Event"} | ||
}, | ||
@@ -26,5 +21,3 @@ "additionalProperties": false | ||
"patternProperties": { | ||
"^[a-zA-Z_][a-zA-Z0-9_]*$": { | ||
"$ref": "#/definitions/Link" | ||
} | ||
"^[a-zA-Z_][a-zA-Z0-9_]*$": { "$ref": "#/definitions/Link" } | ||
}, | ||
@@ -35,2 +28,3 @@ "additionalProperties": false | ||
"additionalProperties": false, | ||
"definitions": { | ||
@@ -41,2 +35,3 @@ "Address": { | ||
}, | ||
"TransactionHash": { | ||
@@ -46,14 +41,11 @@ "type": "string", | ||
}, | ||
"Link": { | ||
"type": "object", | ||
"properties": { | ||
"address": { | ||
"$ref": "#/definitions/Address" | ||
}, | ||
"address": { "$ref": "#/definitions/Address" }, | ||
"events": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^0x[a-fA-F0-9]{64}$": { | ||
"$ref": "abi.spec.json#/definitions/Event" | ||
} | ||
"^0x[a-fA-F0-9]{64}$": { "$ref": "abi.spec.json#/definitions/Event"} | ||
}, | ||
@@ -60,0 +52,0 @@ "additionalProperties": false |
@@ -1,1 +0,1 @@ | ||
"use strict";var OS=require("os");var dir=require("node-dir");var path=require("path");var async=require("async");var debug=require("debug")("lib:debug");var commandReference={o:"step over",i:"step into",u:"step out",n:"step next",";":"step instruction",p:"print instruction",h:"print this help",v:"print variables and values",":":"evaluate expression - see `v`","+":"add watch expression (`+:<expr>`)","-":"remove watch expression (-:<expr>)","?":"list existing watch expressions",b:"toggle breakpoint",c:"continue until breakpoint",q:"quit"};var DebugUtils={gatherArtifacts:function gatherArtifacts(config){return new Promise(function(accept,reject){dir.files(config.contracts_build_directory,function(err,files){if(err)return reject(err);var contracts=files.filter(function(file_path){return path.extname(file_path)===".json"}).map(function(file_path){return path.basename(file_path,".json")}).map(function(contract_name){return config.resolver.require(contract_name)});async.each(contracts,function(abstraction,finished){finished()},function(err){if(err)return reject(err);accept(contracts.map(function(contract){debug("contract.sourcePath: %o",contract.sourcePath);return{contractName:contract.contractName,source:contract.source,sourceMap:contract.sourceMap,sourcePath:contract.sourcePath,binary:contract.binary,ast:contract.ast,deployedBinary:contract.deployedBinary,deployedSourceMap:contract.deployedSourceMap}}))})})})},formatStartMessage:function formatStartMessage(){var lines=["","Gathering transaction data...",""];return lines.join(OS.EOL)},formatCommandDescription:function formatCommandDescription(commandId){return"("+commandId+") "+commandReference[commandId]},formatAffectedInstances:function formatAffectedInstances(instances){var hasAllSource=true;var lines=Object.keys(instances).map(function(address){var instance=instances[address];if(instance.contractName){return" "+address+" - "+instance.contractName}if(!instance.source){hasAllSource=false}return" "+address+"(UNKNOWN)"});if(!hasAllSource){lines.push("");lines.push("Warning: The source code for one or more contracts could not be found.")}return lines.join(OS.EOL)},formatHelp:function formatHelp(lastCommand){if(!lastCommand){lastCommand="n"}var prefix=["Commands:","(enter) last command entered ("+commandReference[lastCommand]+")"];var commandSections=[["o","i","u","n"],[";","p","h","q"],["b","c"],["+","-"],["?"],["v",":"]].map(function(shortcuts){return shortcuts.map(DebugUtils.formatCommandDescription).join(", ")});var suffix=[""];var lines=prefix.concat(commandSections).concat(suffix);return lines.join(OS.EOL)},formatLineNumberPrefix:function formatLineNumberPrefix(line,number,cols,tab){if(!tab){tab=" "}var prefix=number+"";while(prefix.length<cols){prefix=" "+prefix}prefix+=": ";return prefix+line.replace(/\t/g,tab)},formatLinePointer:function formatLinePointer(line,startCol,endCol,padding,tab){if(!tab){tab=" "}padding+=2;var prefix="";while(prefix.length<padding){prefix+=" "}var output="";for(var i=0;i<line.length;i++){var pointedAt=i>=startCol&&i<endCol;var isTab=line[i]==="\t";var additional=void 0;if(isTab){additional=tab}else{additional=" "}if(pointedAt){additional=additional.replace(/./g,"^")}output+=additional}return prefix+output},formatRangeLines:function formatRangeLines(source,range,contextBefore){if(!contextBefore){contextBefore=2}var startBeforeIndex=Math.max(range.start.line-contextBefore,0);var prefixLength=(range.start.line+1+"").length;var beforeLines=source.filter(function(line,index){return index>=startBeforeIndex&&index<range.start.line}).map(function(line,index){var number=startBeforeIndex+index+1;return DebugUtils.formatLineNumberPrefix(line,number,prefixLength)});var line=source[range.start.line];var number=range.start.line+1;var pointerStart=range.start.column;var pointerEnd;if(range.end&&range.start.line===range.end.line){pointerEnd=range.end.column}else{pointerEnd=line.length}var allLines=beforeLines.concat([DebugUtils.formatLineNumberPrefix(line,number,prefixLength),DebugUtils.formatLinePointer(line,pointerStart,pointerEnd,prefixLength)]);return allLines.join(OS.EOL)},formatInstruction:function formatInstruction(traceIndex,instruction){return"("+traceIndex+") "+instruction.name+" "+(instruction.pushData||"")},formatStack:function formatStack(stack){var formatted=stack.map(function(item,index){item=" "+item;if(index===stack.length-1){item+=" (top)"}return item});if(!stack.length){formatted.push(" No data on stack.")}return formatted.join(OS.EOL)}};module.exports=DebugUtils; | ||
"use strict";var OS=require("os");var dir=require("node-dir");var path=require("path");var async=require("async");var debug=require("debug")("lib:debug");var commandReference={"o":"step over","i":"step into","u":"step out","n":"step next",";":"step instruction","p":"print instruction","h":"print this help","v":"print variables and values",":":"evaluate expression - see `v`","+":"add watch expression (`+:<expr>`)","-":"remove watch expression (-:<expr>)","?":"list existing watch expressions","b":"toggle breakpoint","c":"continue until breakpoint","q":"quit"};var DebugUtils={gatherArtifacts:function gatherArtifacts(config){return new Promise(function(accept,reject){dir.files(config.contracts_build_directory,function(err,files){if(err)return reject(err);var contracts=files.filter(function(file_path){return path.extname(file_path)==".json"}).map(function(file_path){return path.basename(file_path,".json")}).map(function(contract_name){return config.resolver.require(contract_name)});async.each(contracts,function(abstraction,finished){finished()},function(err){if(err)return reject(err);accept(contracts.map(function(contract){debug("contract.sourcePath: %o",contract.sourcePath);return{contractName:contract.contractName,source:contract.source,sourceMap:contract.sourceMap,sourcePath:contract.sourcePath,binary:contract.binary,ast:contract.ast,deployedBinary:contract.deployedBinary,deployedSourceMap:contract.deployedSourceMap}}))})})})},formatStartMessage:function formatStartMessage(){var lines=["","Gathering transaction data...",""];return lines.join(OS.EOL)},formatCommandDescription:function formatCommandDescription(commandId){return"("+commandId+") "+commandReference[commandId]},formatAffectedInstances:function formatAffectedInstances(instances){var hasAllSource=true;var lines=Object.keys(instances).map(function(address){var instance=instances[address];if(instance.contractName){return" "+address+" - "+instance.contractName}if(!instance.source){hasAllSource=false}return" "+address+"(UNKNOWN)"});if(!hasAllSource){lines.push("");lines.push("Warning: The source code for one or more contracts could not be found.")}return lines.join(OS.EOL)},formatHelp:function formatHelp(lastCommand){if(!lastCommand){lastCommand="n"}var prefix=["Commands:","(enter) last command entered ("+commandReference[lastCommand]+")"];var commandSections=[["o","i","u","n"],[";","p","h","q"],["b","c"],["+","-"],["?"],["v",":"]].map(function(shortcuts){return shortcuts.map(DebugUtils.formatCommandDescription).join(", ")});var suffix=[""];var lines=prefix.concat(commandSections).concat(suffix);return lines.join(OS.EOL)},formatLineNumberPrefix:function formatLineNumberPrefix(line,number,cols,tab){if(!tab){tab=" "}var prefix=number+"";while(prefix.length<cols){prefix=" "+prefix}prefix+=": ";return prefix+line.replace(/\t/g,tab)},formatLinePointer:function formatLinePointer(line,startCol,endCol,padding,tab){if(!tab){tab=" "}padding+=2;var prefix="";while(prefix.length<padding){prefix+=" "}var output="";for(var i=0;i<line.length;i++){var pointedAt=i>=startCol&&i<endCol;var isTab=line[i]=="\t";var additional;if(isTab){additional=tab}else{additional=" "}if(pointedAt){additional=additional.replace(/./g,"^")}output+=additional}return prefix+output},formatRangeLines:function formatRangeLines(source,range,contextBefore){var outputLines=[];if(contextBefore==undefined){contextBefore=2};var startBeforeIndex=Math.max(range.start.line-contextBefore,0);var prefixLength=(range.start.line+1+"").length;var beforeLines=source.filter(function(line,index){return index>=startBeforeIndex&&index<range.start.line}).map(function(line,index){var number=startBeforeIndex+index+1;return DebugUtils.formatLineNumberPrefix(line,number,prefixLength)});var line=source[range.start.line];var number=range.start.line+1;var pointerStart=range.start.column;var pointerEnd;if(range.end&&range.start.line==range.end.line){pointerEnd=range.end.column}else{pointerEnd=line.length}var allLines=beforeLines.concat([DebugUtils.formatLineNumberPrefix(line,number,prefixLength),DebugUtils.formatLinePointer(line,pointerStart,pointerEnd,prefixLength)]);return allLines.join(OS.EOL)},formatInstruction:function formatInstruction(traceIndex,instruction){return"("+traceIndex+") "+instruction.name+" "+(instruction.pushData||"")},formatStack:function formatStack(stack){var formatted=stack.map(function(item,index){item=" "+item;if(index==stack.length-1){item+=" (top)"}return item});if(stack.length==0){formatted.push(" No data on stack.")}return formatted.join(OS.EOL)}};module.exports=DebugUtils; |
@@ -1,1 +0,1 @@ | ||
"use strict";var expect=require("@truffle/expect");var DeferredChain=require("./src/deferredchain");var deploy=require("./src/actions/deploy");var deployMany=require("./src/actions/deploymany");var link=require("./src/actions/link");var create=require("./src/actions/new");var _require=require("../TronWrap"),dlog=_require.dlog;function Deployer(options){var self=this;options=options||{};expect.options(options,["provider","network","network_id"]);this.chain=new DeferredChain;this.logger=options.logger||{log:function log(){}};this.known_contracts={};(options.contracts||[]).forEach(function(contract){self.known_contracts[contract.contract_name]=contract});this.network=options.network;this.network_id=options.network_id;this.provider=options.provider;this.basePath=options.basePath||process.cwd()}Deployer.prototype.start=function(){return this.chain.start()};Deployer.prototype.link=function(library,destinations){return this.queueOrExec(link(library,destinations,this))};Deployer.prototype.deploy=function(){var args=Array.prototype.slice.call(arguments);var contract=args.shift();if(Array.isArray(contract)){dlog("Deploy many");return this.queueOrExec(deployMany(contract,this))}else{dlog("Deploy one");return this.queueOrExec(deploy(contract,args,this))}};Deployer.prototype["new"]=function(){var args=Array.prototype.slice.call(arguments);var contract=args.shift();return this.queueOrExec(create(contract,args,this))};Deployer.prototype.exec=function(){throw new Error("deployer.exec() has been deprecated; please seen the tronbox-require package for integration.")};Deployer.prototype.then=function(fn){var self=this;return this.queueOrExec(function(){self.logger.log("Running step...");return fn(this)})};Deployer.prototype.queueOrExec=function(fn){if(this.chain.started){return new Promise(function(accept){accept()}).then(fn)}else{return this.chain.then(fn)}};module.exports=Deployer; | ||
"use strict";var expect=require("@truffle/expect");var DeferredChain=require("./src/deferredchain");var deploy=require("./src/actions/deploy");var deployMany=require("./src/actions/deploymany");var link=require("./src/actions/link");var create=require("./src/actions/new");var _require=require("../TronWrap"),dlog=_require.dlog;function Deployer(options){var self=this;options=options||{};expect.options(options,["provider","network","network_id"]);this.chain=new DeferredChain;this.logger=options.logger||{log:function log(){}};this.known_contracts={};(options.contracts||[]).forEach(function(contract){self.known_contracts[contract.contract_name]=contract});this.network=options.network;this.network_id=options.network_id;this.provider=options.provider;this.basePath=options.basePath||process.cwd()};Deployer.prototype.start=function(){return this.chain.start()};Deployer.prototype.link=function(library,destinations){return this.queueOrExec(link(library,destinations,this))};Deployer.prototype.deploy=function(){var args=Array.prototype.slice.call(arguments);var contract=args.shift();if(Array.isArray(contract)){dlog("Deploy many");return this.queueOrExec(deployMany(contract,this))}else{dlog("Deploy one");return this.queueOrExec(deploy(contract,args,this))}};Deployer.prototype["new"]=function(){var args=Array.prototype.slice.call(arguments);var contract=args.shift();return this.queueOrExec(create(contract,args,this))};Deployer.prototype.exec=function(file){throw new Error("deployer.exec() has been deprecated; please seen the tronbox-require package for integration.")};Deployer.prototype.then=function(fn){var self=this;return this.queueOrExec(function(){self.logger.log("Running step...");return fn(this)})};Deployer.prototype.queueOrExec=function(fn){var self=this;if(this.chain.started==true){return new Promise(function(accept,reject){accept()}).then(fn)}else{return this.chain.then(fn)}};module.exports=Deployer; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}var TronWrap=require("../../../TronWrap");var _require=require("../../../TronWrap"),dlog=_require.dlog;module.exports=function(contract,args,deployer){return function(){var should_deploy=true;return Promise.all(args).then(function(new_args){if(new_args.length>0){var last_arg=new_args[new_args.length-1];if(_typeof(last_arg)==="object"&&last_arg.overwrite===false&&contract.isDeployed()){should_deploy=false}delete last_arg.overwrite}if(should_deploy===true){var prefix="Deploying ";if(contract.isDeployed()){prefix="Replacing "}deployer.logger.log(prefix+contract.contract_name+"...");dlog(new_args);return contract["new"].apply(contract,new_args)}else{return contract.deployed()}}).then(function(instance){var tronWrap=TronWrap();if(should_deploy===true){deployer.logger.log(contract.contract_name+":\n (base58) "+tronWrap.address.fromHex(instance.address)+"\n (hex) "+instance.address)}else{deployer.logger.log("Didn't deploy "+contract.contract_name+"; using "+instance.address)}contract.address=instance.address;dlog("Instance name:",instance&&instance.constructor?instance.constructor.contractName:null);return instance})}}; | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}var TronWrap=require("../../../TronWrap");var _require=require("../../../TronWrap"),dlog=_require.dlog;module.exports=function(contract,args,deployer){return function(){var should_deploy=true;return Promise.all(args).then(function(new_args){if(new_args.length>0){var last_arg=new_args[new_args.length-1];if(_typeof(last_arg)=="object"&&last_arg.overwrite===false&&contract.isDeployed()){should_deploy=false}delete last_arg.overwrite}if(should_deploy==true){var prefix="Deploying ";if(contract.isDeployed()){prefix="Replacing "}deployer.logger.log(prefix+contract.contract_name+"...");dlog(new_args);return contract["new"].apply(contract,new_args)}else{return contract.deployed()}}).then(function(instance){var tronWrap=TronWrap();if(should_deploy==true){deployer.logger.log(contract.contract_name+":\n (base58) "+tronWrap.address.fromHex(instance.address)+"\n (hex) "+instance.address)}else{deployer.logger.log("Didn't deploy "+contract.contract_name+"; using "+instance.address)}contract.address=instance.address;dlog("Instance name:",instance&&instance.constructor?instance.constructor.contractName:null);return instance})}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";module.exports=function(contract,args,deployer){return function(){deployer.logger.log("Creating new instance of "+contract.contract_name);return Promise.all(args).then(function(){return contract["new"].apply(contract,args)})}}; | ||
"use strict";module.exports=function(contract,args,deployer){return function(){deployer.logger.log("Creating new instance of "+contract.contract_name);return Promise.all(args).then(function(new_args){return contract["new"].apply(contract,args)})}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function DeferredChain(){var self=this;this.chain=new Promise(function(accept,reject){self._accept=accept;self._reject=reject});this["await"]=new Promise(function(){self._done=arguments[0];self._error=arguments[1]});this.started=false}DeferredChain.prototype.then=function(fn){var self=this;this.chain=this.chain.then(function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,args)});this.chain=this.chain["catch"](function(e){self._error(e)});return this};DeferredChain.prototype["catch"]=function(fn){this.chain=this.chain["catch"](function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,args)});return this};DeferredChain.prototype.start=function(){this.started=true;this.chain=this.chain.then(this._done);this._accept();return this["await"]};module.exports=DeferredChain; | ||
"use strict";function DeferredChain(){var self=this;this.chain=new Promise(function(accept,reject){self._accept=accept;self._reject=reject});this["await"]=new Promise(function(){self._done=arguments[0];self._error=arguments[1]});this.started=false};DeferredChain.prototype.then=function(fn){var self=this;this.chain=this.chain.then(function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,args)});this.chain=this.chain["catch"](function(e){self._error(e)});return this};DeferredChain.prototype["catch"]=function(fn){var self=this;this.chain=this.chain["catch"](function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,args)});return this};DeferredChain.prototype.start=function(){this.started=true;this.chain=this.chain.then(this._done);this._accept();return this["await"]};module.exports=DeferredChain; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}module.exports={link:function link(library,destinations,logger){logger=logger||console;if(!Array.isArray(destinations)){destinations=[destinations]}if(!library.contract_name){throw new Error("Cannot link a library with no name.")}var hasAddress=false;if(_typeof(library.isDeployed)){hasAddress=library.isDeployed()}else{hasAddress=library.address}if(!hasAddress){throw new Error("Cannot link library: "+library.contract_name+" has no address. Has it been deployed?")}destinations.forEach(function(destination){if(destination.links[library.contract_name]===library.address)return;if(destination.unlinked_binary.indexOf(library.contract_name)<0)return;logger.log("Linking "+library.contract_name+" to "+destination.contract_name);destination.link(library)})}}; | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}module.exports={link:function link(library,destinations,logger){var self=this;logger=logger||console;if(!Array.isArray(destinations)){destinations=[destinations]}if(library.contract_name==null){throw new Error("Cannot link a library with no name.")}var hasAddress=false;if(_typeof(library.isDeployed)){hasAddress=library.isDeployed()}else{hasAddress=library.address!=null}if(!hasAddress){throw new Error("Cannot link library: "+library.contract_name+" has no address. Has it been deployed?")}destinations.forEach(function(destination){if(destination.links[library.contract_name]==library.address)return;if(destination.unlinked_binary.indexOf(library.contract_name)<0)return;logger.log("Linking "+library.contract_name+" to "+destination.contract_name);destination.link(library)})}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var dir=require("node-dir");var path=require("path");var ResolverIntercept=require("./resolverintercept");var Require=require("../Require");var async=require("async");var expect=require("@truffle/expect");var Deployer=require("../Deployer");var TronWrap=require("../TronWrap");var logErrorAndExit=require("../TronWrap").logErrorAndExit;var tronWrap;function Migration(file){this.file=path.resolve(file);this.number=parseInt(path.basename(file))}Migration.prototype.run=function(options,callback){var self=this;var logger=options.logger;logger.log("Running migration: "+path.relative(options.migrations_directory,this.file));var resolver=new ResolverIntercept(options.resolver);tronWrap=TronWrap(options);var context={tronWrap:tronWrap};var deployer=new Deployer({logger:{log:function log(msg){logger.log(" "+msg)}},network:options.network,network_id:options.network_id,provider:options.provider,basePath:path.dirname(this.file)});var finish=function finish(err){if(err)return callback(err);deployer.start().then(_asyncToGenerator(regeneratorRuntime.mark(function _callee(){var Migrations,result;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!(options.save===false)){_context.next=2;break}return _context.abrupt("return");case 2:Migrations=resolver.require("./Migrations.sol");if(!(Migrations&&Migrations.isDeployed())){_context.next=9;break}logger.log("Saving successful migration to network...");_context.next=7;return Migrations.deployed();case 7:result=Migrations.call("setCompleted",[self.number]);return _context.abrupt("return",Promise.resolve(result));case 9:case"end":return _context.stop();}}},_callee)}))).then(function(){if(options.save===false)return;logger.log("Saving artifacts...");return options.artifactor.saveAll(resolver.contracts())}).then(function(){process.nextTick(callback)})["catch"](function(e){logErrorAndExit(logger,e)})};var fn=Require.file({file:self.file,context:context,resolver:resolver,args:[deployer]});if(!fn||!fn.length||fn.length===0){return callback(new Error("Migration "+self.file+" invalid or does not take any parameters"))}fn(deployer,options.network,options.networks[options.network].from);finish()};var Migrate={Migration:Migration,assemble:function assemble(options,callback){dir.files(options.migrations_directory,function(err,files){if(err)return callback(err);options.allowed_extensions=options.allowed_extensions||/^\.(js|es6?)$/;var migrations=files.filter(function(file){return isNaN(parseInt(path.basename(file)))===false}).filter(function(file){return path.extname(file).match(options.allowed_extensions)!=null}).map(function(file){return new Migration(file,options.network)});migrations=migrations.sort(function(a,b){if(a.number>b.number){return 1}else if(a.number<b.number){return-1}return 0});callback(null,migrations)})},run:function run(options,callback){var self=this;expect.options(options,["working_directory","migrations_directory","contracts_build_directory","provider","artifactor","resolver","network","network_id","logger","from"]);if(options.reset===true){return this.runAll(options,callback)}self.lastCompletedMigration(options,function(err,last_migration){if(err)return callback(err);self.runFrom(last_migration+1,options,callback)})},runFrom:function runFrom(number,options,callback){var self=this;this.assemble(options,function(err,migrations){if(err)return callback(err);while(migrations.length>0){if(migrations[0].number>=number){break}migrations.shift()}if(options.to){migrations=migrations.filter(function(migration){return migration.number<=options.to})}self.runMigrations(migrations,options,callback)})},runAll:function runAll(options,callback){this.runFrom(0,options,callback)},runMigrations:function runMigrations(migrations,options,callback){var clone={};Object.keys(options).forEach(function(key){clone[key]=options[key]});if(options.quiet){clone.logger={log:function log(){}}}clone.provider=this.wrapProvider(options.provider,clone.logger);clone.resolver=this.wrapResolver(options.resolver,clone.provider);async.eachSeries(migrations,function(migration,finished){migration.run(clone,function(err){if(err)return finished(err);finished()})},callback)},wrapProvider:function wrapProvider(provider,logger){var printTransaction=function printTransaction(tx_hash){logger.log(" ... "+tx_hash)};return{send:function send(payload){var result=provider.send(payload);if(payload.method==="eth_sendTransaction"){printTransaction(result.result)}return result},sendAsync:function sendAsync(payload,callback){provider.sendAsync(payload,function(err,result){if(err)return callback(err);if(payload.method==="eth_sendTransaction"){printTransaction(result.result)}callback(err,result)})}}},wrapResolver:function wrapResolver(resolver,provider){return{require:function require(import_path,search_path){var abstraction=resolver.require(import_path,search_path);abstraction.setProvider(provider);return abstraction},resolve:resolver.resolve}},lastCompletedMigration:function lastCompletedMigration(options,callback){if(!tronWrap){tronWrap=TronWrap()}var Migrations=options.resolver.require("Migrations");if(Migrations.isDeployed()===false){return callback(null,0)}Migrations.deployed().then(function(migrations){return tronWrap.filterMatchFunction("last_completed_migration",migrations.abi)?migrations.call("last_completed_migration"):migrations.call("lastCompletedMigration")}).then(function(completed_migration){var value=_typeof(completed_migration)==="object"?completed_migration:"0";callback(null,tronWrap._toNumber(value))})["catch"](function(){callback(null,0)})},needsMigrating:function needsMigrating(options,callback){var self=this;if(options.reset){return callback(null,true)}this.lastCompletedMigration(options,function(err,number){if(err)return callback(err);self.assemble(options,function(err,migrations){if(err)return callback(err);while(migrations.length>0){if(migrations[0].number>=number){break}migrations.shift()}callback(null,migrations.length>1)})})}};module.exports=Migrate; | ||
"use strict";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var fs=require("fs");var dir=require("node-dir");var path=require("path");var ResolverIntercept=require("./resolverintercept");var Require=require("@truffle/require");var async=require("async");var expect=require("@truffle/expect");var Deployer=require("../Deployer");var chalk=require("chalk");var TronWrap=require("../TronWrap");var logErrorAndExit=require("../TronWrap").logErrorAndExit;var tronWrap;function Migration(file){this.file=path.resolve(file);this.number=parseInt(path.basename(file))};function sleep(millis){return new Promise(function(resolve){return setTimeout(resolve,millis)})}Migration.prototype.run=function(options,callback){var self=this;var logger=options.logger;logger.log("Running migration: "+path.relative(options.migrations_directory,this.file));var resolver=new ResolverIntercept(options.resolver);tronWrap=TronWrap(options);var context={tronWrap:tronWrap};var deployer=new Deployer({logger:{log:function log(msg){logger.log(" "+msg)}},network:options.network,network_id:options.network_id,provider:options.provider,basePath:path.dirname(this.file)});var finish=function finish(err){if(err)return callback(err);deployer.start().then(_asyncToGenerator(regeneratorRuntime.mark(function _callee(){var Migrations,result;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!(options.save===false)){_context.next=2;break}return _context.abrupt("return");case 2:Migrations=resolver.require("./Migrations.sol");if(!(Migrations&&Migrations.isDeployed())){_context.next=9;break}logger.log("Saving successful migration to network...");_context.next=7;return Migrations.deployed();case 7:result=Migrations.call("setCompleted",[self.number]);return _context.abrupt("return",Promise.resolve(result));case 9:case"end":return _context.stop();}}},_callee)}))).then(function(){if(options.save===false)return;logger.log("Saving artifacts...");return options.artifactor.saveAll(resolver.contracts())}).then(function(){process.nextTick(callback)})["catch"](function(e){logErrorAndExit(logger,e)})};var fn=Require.file({file:self.file,context:context,resolver:resolver,args:[deployer]});if(!fn||!fn.length||fn.length===0){return callback(new Error("Migration "+self.file+" invalid or does not take any parameters"))}fn(deployer,options.network,options.networks[options.network].from);finish()};var Migrate={Migration:Migration,assemble:function assemble(options,callback){dir.files(options.migrations_directory,function(err,files){if(err)return callback(err);options.allowed_extensions=options.allowed_extensions||/^\.(js|es6?)$/;var migrations=files.filter(function(file){return isNaN(parseInt(path.basename(file)))===false}).filter(function(file){return path.extname(file).match(options.allowed_extensions)!=null}).map(function(file){return new Migration(file,options.network)});migrations=migrations.sort(function(a,b){if(a.number>b.number){return 1}else if(a.number<b.number){return-1}return 0});callback(null,migrations)})},run:function run(options,callback){var self=this;expect.options(options,["working_directory","migrations_directory","contracts_build_directory","provider","artifactor","resolver","network","network_id","logger","from"]);if(options.reset===true){return this.runAll(options,callback)}self.lastCompletedMigration(options,function(err,last_migration){if(err)return callback(err);self.runFrom(last_migration+1,options,callback)})},runFrom:function runFrom(number,options,callback){var self=this;this.assemble(options,function(err,migrations){if(err)return callback(err);while(migrations.length>0){if(migrations[0].number>=number){break}migrations.shift()}if(options.to){migrations=migrations.filter(function(migration){return migration.number<=options.to})}self.runMigrations(migrations,options,callback)})},runAll:function runAll(options,callback){this.runFrom(0,options,callback)},runMigrations:function runMigrations(migrations,options,callback){var clone={};Object.keys(options).forEach(function(key){clone[key]=options[key]});if(options.quiet){clone.logger={log:function log(){}}}clone.provider=this.wrapProvider(options.provider,clone.logger);clone.resolver=this.wrapResolver(options.resolver,clone.provider);async.eachSeries(migrations,function(migration,finished){migration.run(clone,function(err){if(err)return finished(err);finished()})},callback)},wrapProvider:function wrapProvider(provider,logger){var printTransaction=function printTransaction(tx_hash){logger.log(" ... "+tx_hash)};return{send:function send(payload){var result=provider.send(payload);if(payload.method=="eth_sendTransaction"){printTransaction(result.result)}return result},sendAsync:function sendAsync(payload,callback){provider.sendAsync(payload,function(err,result){if(err)return callback(err);if(payload.method=="eth_sendTransaction"){printTransaction(result.result)}callback(err,result)})}}},wrapResolver:function wrapResolver(resolver,provider){return{require:function require(import_path,search_path){var abstraction=resolver.require(import_path,search_path);abstraction.setProvider(provider);return abstraction},resolve:resolver.resolve}},lastCompletedMigration:function lastCompletedMigration(options,callback){var Migrations;if(!tronWrap){tronWrap=TronWrap()}Migrations=options.resolver.require("Migrations");if(Migrations.isDeployed()===false){return callback(null,0)}Migrations.deployed().then(function(migrations){return tronWrap.filterMatchFunction("last_completed_migration",migrations.abi)?migrations.call("last_completed_migration"):migrations.call("lastCompletedMigration")}).then(function(completed_migration){var value=_typeof(completed_migration)=="object"?completed_migration:"0";callback(null,tronWrap._toNumber(value))})["catch"](function(){callback(null,0)})},needsMigrating:function needsMigrating(options,callback){var self=this;if(options.reset==true){return callback(null,true)}this.lastCompletedMigration(options,function(err,number){if(err)return callback(err);self.assemble(options,function(err,migrations){if(err)return callback(err);while(migrations.length>0){if(migrations[0].number>=number){break}migrations.shift()}callback(null,migrations.length>1)})})}};module.exports=Migrate; |
@@ -1,1 +0,1 @@ | ||
"use strict";function ResolverIntercept(resolver){this.resolver=resolver;this.cache={}}ResolverIntercept.prototype.require=function(import_path){import_path=import_path.replace(/\.sol$/i,"");if(this.cache[import_path]){return this.cache[import_path]}var resolved=this.resolver.require(import_path);this.cache[import_path]=resolved;resolved.synchronization_timeout=0;return resolved};ResolverIntercept.prototype.contracts=function(){var self=this;return Object.keys(this.cache).map(function(key){return self.cache[key]})};module.exports=ResolverIntercept; | ||
"use strict";var path=require("path");function ResolverIntercept(resolver){this.resolver=resolver;this.cache={}};ResolverIntercept.prototype.require=function(import_path){import_path=import_path.replace(/\.sol$/i,"");if(this.cache[import_path]){return this.cache[import_path]}var resolved=this.resolver.require(import_path);this.cache[import_path]=resolved;resolved.synchronization_timeout=0;return resolved};ResolverIntercept.prototype.contracts=function(){var self=this;return Object.keys(this.cache).map(function(key){return self.cache[key]})};module.exports=ResolverIntercept; |
@@ -1,1 +0,1 @@ | ||
"use strict";var inherits=require("util").inherits;var TruffleError=require("@truffle/error");var NOT_CONNECTED_MESSAGE="Invalid JSON RPC response: \"\"";function ProviderError(message){if(message===NOT_CONNECTED_MESSAGE){message="Could not connect to your Ethereum client. "+"Please check that your Ethereum client:\n"+" - is running\n"+" - is accepting RPC connections (i.e., \"--rpc\" option is used in geth)\n"+" - is accessible over the network\n"+" - is properly configured in your sunbox configuration file (sunbox.js)\n"}ProviderError.super_.call(this,message);this.message=message}inherits(ProviderError,TruffleError);module.exports=ProviderError; | ||
"use strict";var inherits=require("util").inherits;var TruffleError=require("@truffle/error");var NOT_CONNECTED_MESSAGE="Invalid JSON RPC response: \"\"";function ProviderError(message,error){if(message==NOT_CONNECTED_MESSAGE){message="Could not connect to your Ethereum client. "+"Please check that your Ethereum client:\n"+" - is running\n"+" - is accepting RPC connections (i.e., \"--rpc\" option is used in geth)\n"+" - is accessible over the network\n"+" - is properly configured in your sunbox configuration file (sunbox.js)\n"}ProviderError.super_.call(this,message);this.message=message}inherits(ProviderError,TruffleError);module.exports=ProviderError; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _require=require("../TronWrap"),TronWeb=_require.TronWeb;var wrapper=require("./wrapper");module.exports={wrap:function wrap(provider,options){return wrapper.wrap(provider,options)},create:function create(options){var provider;if(options.provider&&typeof options.provider==="function"){provider=options.provider()}else if(options.provider){provider=options.provider}else{var HttpProvider=TronWeb.providers.HttpProvider;HttpProvider.prototype.send=function(payload){var request=this.prepareRequest(false);try{request.send(JSON.stringify(payload))}catch(error){throw new Error("Invalid Connection (".concat(this.host,")"))}var result=request.responseText;try{result=JSON.parse(result)}catch(e){throw new Error("Invalid Response (".concat(request.responseText,")"))}return result};HttpProvider.prototype.sendAsync=function(payload,callback){var request=this.prepareRequest(true);request.onreadystatechange=function(){if(request.readyState===4&&request.timeout!==1){var result=request.responseText;var error=null;try{result=JSON.parse(result)}catch(e){error=new Error("Invalid Response (".concat(request.responseText,")"))}callback(error,result)}};request.ontimeout=function(){throw new Error("Connection Timeout (".concat(this.timeout,")"))};try{request.send(JSON.stringify(payload))}catch(error){callback(new Error("Invalid Connection (".concat(this.host,")")))}return request};provider=new HttpProvider(options.fullHost)}return this.wrap(provider,options)},test_connection:function test_connection(provider,callback){callback(null,true)}}; | ||
"use strict";var _require=require("../TronWrap"),TronWeb=_require.TronWeb;var wrapper=require("./wrapper");module.exports={wrap:function wrap(provider,options){return wrapper.wrap(provider,options)},create:function create(options){var provider;if(options.provider&&typeof options.provider=="function"){provider=options.provider()}else if(options.provider){provider=options.provider}else{var HttpProvider=TronWeb.providers.HttpProvider;HttpProvider.prototype.send=function(payload){var request=this.prepareRequest(false);try{request.send(JSON.stringify(payload))}catch(error){throw errors.InvalidConnection(this.host)}var result=request.responseText;try{result=JSON.parse(result)}catch(e){throw errors.InvalidResponse(request.responseText)}return result};HttpProvider.prototype.sendAsync=function(payload,callback){var request=this.prepareRequest(true);request.onreadystatechange=function(){if(request.readyState===4&&request.timeout!==1){var result=request.responseText;var error=null;try{result=JSON.parse(result)}catch(e){error=errors.InvalidResponse(request.responseText)}callback(error,result)}};request.ontimeout=function(){callback(errors.ConnectionTimeout(this.timeout))};try{request.send(JSON.stringify(payload))}catch(error){callback(errors.InvalidConnection(this.host))}return request};provider=new HttpProvider(options.fullHost)}return this.wrap(provider,options)},test_connection:function test_connection(provider,callback){callback(null,true)}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var provision=function provision(abstraction,options){if(options.provider){abstraction.setProvider(options.provider)}if(options.network_id){abstraction.setNetwork(options.network_id)}["from","fee_limit","consume_user_resource_percent","privateKey","call_value"].forEach(function(key){if(options[key]){var obj={};obj[key]=options[key];abstraction.defaults(obj)}});return abstraction};module.exports=provision; | ||
"use strict";var provision=function provision(abstraction,options){var self=this;if(options.provider){abstraction.setProvider(options.provider)}if(options.network_id){abstraction.setNetwork(options.network_id)}["from","fee_limit","consume_user_resource_percent","privateKey","call_value"].forEach(function(key){if(options[key]){var obj={};obj[key]=options[key];abstraction.defaults(obj)}});return abstraction};module.exports=provision; |
@@ -1,1 +0,1 @@ | ||
"use strict";var path=require("path");var fs=require("fs");function EPM(working_directory,contracts_build_directory){this.working_directory=working_directory;this.contracts_build_directory=contracts_build_directory}EPM.prototype.require=function(import_path){if(import_path.indexOf(".")===0||import_path.indexOf("/")===0){return null}var contract_name=path.basename(import_path,".sol");var separator=import_path.indexOf("/");var package_name=import_path.substring(0,separator);var install_directory=path.join(this.working_directory,"installed_contracts");var lockfile=path.join(install_directory,package_name,"lock.json");try{lockfile=fs.readFileSync(lockfile,"utf8")}catch(e){return null}lockfile=JSON.parse(lockfile);var json={contract_name:contract_name,networks:{}};var contract_types=lockfile.contract_types||{};var type=contract_types[contract_name];if(!type)return null;json.abi=type.abi;json.unlinked_binary=type.bytecode;Object.keys(lockfile.deployments||{}).forEach(function(blockchain){var deployments=lockfile.deployments[blockchain];Object.keys(deployments).forEach(function(name){var deployment=deployments[name];if(deployment.contract_type===contract_name){json.networks[blockchain]={events:{},links:{},address:deployment.address}}})});return json};EPM.prototype.resolve=function(import_path,imported_from,callback){var separator=import_path.indexOf("/");var package_name=import_path.substring(0,separator);var internal_path=import_path.substring(separator+1);var installDir=this.working_directory;var body;while(true){var file_path=path.join(installDir,"installed_contracts",import_path);try{body=fs.readFileSync(file_path,{encoding:"utf8"});break}catch(err){}file_path=path.join(installDir,"installed_contracts",package_name,"contracts",internal_path);try{body=fs.readFileSync(file_path,{encoding:"utf8"});break}catch(err){}var oldInstallDir=installDir;installDir=path.join(installDir,"..");if(installDir===oldInstallDir){break}}return callback(null,body,import_path)},EPM.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);var resolved_dependency_path=path.join(dirname,dependency_path);resolved_dependency_path=resolved_dependency_path.replace(/\\/g,"/");return resolved_dependency_path};module.exports=EPM; | ||
"use strict";var path=require("path");var fs=require("fs");var filter=require("async/filter");var detectSeries=require("async/detectSeries");var eachSeries=require("async/eachSeries");var contract=require("../Contract");var FSSource=require("./fs.js");function EPM(working_directory,contracts_build_directory){this.working_directory=working_directory;this.contracts_build_directory=contracts_build_directory};EPM.prototype.require=function(import_path,search_path){if(import_path.indexOf(".")==0||import_path.indexOf("/")==0){return null}var contract_filename=path.basename(import_path);var contract_name=path.basename(import_path,".sol");var separator=import_path.indexOf("/");var package_name=import_path.substring(0,separator);var install_directory=path.join(this.working_directory,"installed_contracts");var lockfile=path.join(install_directory,package_name,"lock.json");try{lockfile=fs.readFileSync(lockfile,"utf8")}catch(e){return null}lockfile=JSON.parse(lockfile);var json={contract_name:contract_name,networks:{}};var contract_types=lockfile.contract_types||{};var type=contract_types[contract_name];if(!type)return null;json.abi=type.abi;json.unlinked_binary=type.bytecode;Object.keys(lockfile.deployments||{}).forEach(function(blockchain){var deployments=lockfile.deployments[blockchain];Object.keys(deployments).forEach(function(name){var deployment=deployments[name];if(deployment.contract_type==contract_name){json.networks[blockchain]={events:{},links:{},address:deployment.address}}})});return json};EPM.prototype.resolve=function(import_path,imported_from,callback){var separator=import_path.indexOf("/");var package_name=import_path.substring(0,separator);var internal_path=import_path.substring(separator+1);var installDir=this.working_directory;var body;while(true){var file_path=path.join(installDir,"installed_contracts",import_path);try{body=fs.readFileSync(file_path,{encoding:"utf8"});break}catch(err){}file_path=path.join(installDir,"installed_contracts",package_name,"contracts",internal_path);try{body=fs.readFileSync(file_path,{encoding:"utf8"});break}catch(err){}var oldInstallDir=installDir;installDir=path.join(installDir,"..");if(installDir===oldInstallDir){break}}return callback(null,body,import_path)},EPM.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);var resolved_dependency_path=path.join(dirname,dependency_path);resolved_dependency_path=resolved_dependency_path.replace(/\\/g,"/");return resolved_dependency_path};module.exports=EPM; |
@@ -1,1 +0,1 @@ | ||
"use strict";var path=require("path");var fs=require("fs");var eachSeries=require("async/eachSeries");function FS(working_directory,contracts_build_directory){this.working_directory=working_directory;this.contracts_build_directory=contracts_build_directory}FS.prototype.require=function(import_path,search_path){search_path=search_path||this.contracts_build_directory;import_path=import_path.replace(/\//g,path.sep);var contract_name=this.getContractName(import_path,search_path);if(path.isAbsolute(import_path)){if(import_path.indexOf(this.working_directory)!==0){return null}import_path="./"+import_path.replace(this.working_directory)}try{var result=fs.readFileSync(path.join(search_path,contract_name+".json"),"utf8");return JSON.parse(result)}catch(e){return null}};FS.prototype.getContractName=function(sourcePath,searchPath){searchPath=searchPath||this.contracts_build_directory;var filenames=fs.readdirSync(searchPath);for(var i=0;i<filenames.length;i++){var filename=filenames[i];var artifact=JSON.parse(fs.readFileSync(path.resolve(searchPath,filename)));if(artifact.sourcePath===sourcePath){return artifact.contractName}}return path.basename(sourcePath,".sol")};FS.prototype.resolve=function(import_path,imported_from,callback){imported_from=imported_from||"";var possible_paths=[import_path,path.join(path.dirname(imported_from),import_path)];var resolved_body=null;var resolved_path=null;eachSeries(possible_paths,function(possible_path,finished){if(resolved_body!=null){return finished()}fs.readFile(possible_path,{encoding:"utf8"},function(err,body){if(body){resolved_body=body;resolved_path=possible_path}return finished()})},function(err){if(err)return callback(err);callback(null,resolved_body,resolved_path)})};FS.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);return path.resolve(path.join(dirname,dependency_path))};module.exports=FS; | ||
"use strict";var path=require("path");var fs=require("fs");var eachSeries=require("async/eachSeries");function FS(working_directory,contracts_build_directory){this.working_directory=working_directory;this.contracts_build_directory=contracts_build_directory}FS.prototype.require=function(import_path,search_path){search_path=search_path||this.contracts_build_directory;import_path=import_path.replace(/\//g,path.sep);var contract_name=this.getContractName(import_path,search_path);if(path.isAbsolute(import_path)){if(import_path.indexOf(this.working_directory)!=0){return null}import_path="./"+import_path.replace(this.working_directory)}try{var result=fs.readFileSync(path.join(search_path,contract_name+".json"),"utf8");return JSON.parse(result)}catch(e){return null}};FS.prototype.getContractName=function(sourcePath,searchPath){searchPath=searchPath||this.contracts_build_directory;var filenames=fs.readdirSync(searchPath);for(var i=0;i<filenames.length;i++){var filename=filenames[i];var artifact=JSON.parse(fs.readFileSync(path.resolve(searchPath,filename)));if(artifact.sourcePath==sourcePath){return artifact.contractName}};return path.basename(sourcePath,".sol")};FS.prototype.resolve=function(import_path,imported_from,callback){imported_from=imported_from||"";var possible_paths=[import_path,path.join(path.dirname(imported_from),import_path)];var resolved_body=null;var resolved_path=null;eachSeries(possible_paths,function(possible_path,finished){if(resolved_body!=null){return finished()}fs.readFile(possible_path,{encoding:"utf8"},function(err,body){if(body){resolved_body=body;resolved_path=possible_path}return finished()})},function(err){if(err)return callback(err);callback(null,resolved_body,resolved_path)})};FS.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);return path.resolve(path.join(dirname,dependency_path))};module.exports=FS; |
@@ -1,1 +0,1 @@ | ||
"use strict";var EPMSource=require("./epm");var NPMSource=require("./npm");var FSSource=require("./fs");var whilst=require("async/whilst");var contract=require("../Contract");var expect=require("@truffle/expect");var provision=require("../Provisioner");function Resolver(options){expect.options(options,["working_directory","contracts_build_directory"]);this.options=options;this.sources=[new EPMSource(options.working_directory,options.contracts_build_directory),new NPMSource(options.working_directory),new FSSource(options.working_directory,options.contracts_build_directory)]}Resolver.prototype.require=function(import_path,search_path){var self=this;for(var i=0;i<this.sources.length;i++){var source=this.sources[i];var result=source.require(import_path,search_path);if(result){var abstraction=contract(result);provision(abstraction,self.options);return abstraction}}throw new Error("Could not find artifacts for "+import_path+" from any sources")};Resolver.prototype.resolve=function(import_path,imported_from,callback){var self=this;if(typeof imported_from==="function"){callback=imported_from;imported_from=null}var resolved_body=null;var resolved_path=null;var current_index=-1;var current_source;whilst(function(){return!resolved_body&¤t_index<self.sources.length-1},function(next){current_index+=1;current_source=self.sources[current_index];current_source.resolve(import_path,imported_from,function(err,body,file_path){if(!err&&body){resolved_body=body;resolved_path=file_path}next(err)})},function(err){if(err)return callback(err);if(!resolved_body){var message="Could not find "+import_path+" from any sources";if(imported_from){message+="; imported from "+imported_from}return callback(new Error(message))}callback(null,resolved_body,resolved_path,current_source)})};module.exports=Resolver; | ||
"use strict";var EPMSource=require("./epm");var NPMSource=require("./npm");var FSSource=require("./fs");var whilst=require("async/whilst");var contract=require("../Contract");var expect=require("@truffle/expect");var provision=require("../Provisioner");function Resolver(options){expect.options(options,["working_directory","contracts_build_directory"]);this.options=options;this.sources=[new EPMSource(options.working_directory,options.contracts_build_directory),new NPMSource(options.working_directory),new FSSource(options.working_directory,options.contracts_build_directory)]};Resolver.prototype.require=function(import_path,search_path){var self=this;for(var i=0;i<this.sources.length;i++){var source=this.sources[i];var result=source.require(import_path,search_path);if(result){var abstraction=contract(result);provision(abstraction,self.options);return abstraction}}throw new Error("Could not find artifacts for "+import_path+" from any sources")};Resolver.prototype.resolve=function(import_path,imported_from,callback){var self=this;if(typeof imported_from=="function"){callback=imported_from;imported_from=null}var resolved_body=null;var resolved_path=null;var current_index=-1;var current_source;whilst(function(){return!resolved_body&¤t_index<self.sources.length-1},function(next){current_index+=1;current_source=self.sources[current_index];current_source.resolve(import_path,imported_from,function(err,body,file_path){if(!err&&body){resolved_body=body;resolved_path=file_path}next(err)})},function(err){if(err)return callback(err);if(!resolved_body){var message="Could not find "+import_path+" from any sources";if(imported_from){message+="; imported from "+imported_from}return callback(new Error(message))}callback(null,resolved_body,resolved_path,current_source)})};module.exports=Resolver; |
@@ -1,1 +0,1 @@ | ||
"use strict";var path=require("path");var fs=require("fs");function NPM(working_directory){this.working_directory=working_directory}NPM.prototype.require=function(import_path,search_path){if(import_path.indexOf(".")===0||import_path.indexOf("/")===0){return null}var contract_name=path.basename(import_path,".sol");var regex=new RegExp("(.*)/".concat(contract_name));var package_name="";var matched=regex.exec(import_path);if(matched){package_name=matched[1]}var expected_path=path.join(search_path||this.working_directory,"node_modules",package_name,"build","contracts",contract_name+".json");try{var result=fs.readFileSync(expected_path,"utf8");return JSON.parse(result)}catch(e){return null}};NPM.prototype.resolve=function(import_path,imported_from,callback){var body;var modulesDir=this.working_directory;while(true){var expected_path=path.join(modulesDir,"node_modules",import_path);try{body=fs.readFileSync(expected_path,{encoding:"utf8"});break}catch(err){}var oldModulesDir=modulesDir;modulesDir=path.join(modulesDir,"..");if(modulesDir===oldModulesDir){break}}return callback(null,body,import_path)};NPM.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);return path.join(dirname,dependency_path)};NPM.prototype.provision_contracts=function(callback){callback(null,{})};module.exports=NPM; | ||
"use strict";var path=require("path");var fs=require("fs");function NPM(working_directory){this.working_directory=working_directory};NPM.prototype.require=function(import_path,search_path){if(import_path.indexOf(".")==0||import_path.indexOf("/")==0){return null}var contract_name=path.basename(import_path,".sol");var regex=new RegExp("(.*)/".concat(contract_name));var package_name="";var matched=regex.exec(import_path);if(matched){package_name=matched[1]}var expected_path=path.join(search_path||this.working_directory,"node_modules",package_name,"build","contracts",contract_name+".json");try{var result=fs.readFileSync(expected_path,"utf8");return JSON.parse(result)}catch(e){return null}};NPM.prototype.resolve=function(import_path,imported_from,callback){var body;var modulesDir=this.working_directory;while(true){var expected_path=path.join(modulesDir,"node_modules",import_path);try{var body=fs.readFileSync(expected_path,{encoding:"utf8"});break}catch(err){}var oldModulesDir=modulesDir;modulesDir=path.join(modulesDir,"..");if(modulesDir===oldModulesDir){break}}return callback(null,body,import_path)};NPM.prototype.resolve_dependency_path=function(import_path,dependency_path){var dirname=path.dirname(import_path);return path.join(dirname,dependency_path)};NPM.prototype.provision_contracts=function(callback){callback(null,{})};module.exports=NPM; |
@@ -1,1 +0,1 @@ | ||
"use strict";var wrapper=require("solc/wrapper");var _require=require("../../package"),name=_require.name;var path=require("path");var fs=require("fs-extra");var homedir=require("homedir");var _require2=require("child_process"),execSync=_require2.execSync;var supportedVersions=["0.4.24","0.4.25","0.5.4","0.5.8"];var maxVersion="0.5.9";function getWrapper(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var params=options.networkInfo.parameters;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=params[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var p=_step.value;if(p.key==="getAllowTvmSolidity059"){if(p.value){supportedVersions.push("0.5.9");break}}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}catch(e){}var compilerVersion="0.5.4";var solcDir=path.join(homedir(),".tronbox","solc");if(options.networks){if(options.networks.useZeroFourCompiler){compilerVersion="0.4.25"}else if(options.networks.useZeroFiveCompiler){compilerVersion="0.5.4"}try{var version=options.networks.compilers.solc.version;if(supportedVersions.includes(version)){compilerVersion=version}else{console.error("Error:\nTronBox supports only the following versions:\n".concat(supportedVersions.join(" - "),"\n"));process.exit()}}catch(e){}}var soljsonPath=path.join(solcDir,"soljson_v".concat(compilerVersion,".js"));if(!fs.existsSync(soljsonPath)){if(process.env.TRONBOX_NAME){name=process.env.TRONBOX_NAME}var output=execSync("".concat(name," --download-compiler ").concat(compilerVersion)).toString();if(output.indexOf("Permission required")!==-1){console.error("\nError: Permissions required.\n\nMost likely, you installed Node as root.\nPlease, download the compiler manually, running:\n\ntronbox --download-compiler ".concat(compilerVersion,"\n"));process.exit()}}var soljson=eval("require")(soljsonPath);return wrapper(soljson)}module.exports.getWrapper=getWrapper;module.exports.supportedVersions=supportedVersions;module.exports.maxVersion=maxVersion; | ||
"use strict";var wrapper=require("solc/wrapper");var _require=require("../../package"),name=_require.name;var path=require("path");var fs=require("fs-extra");var homedir=require("homedir");var _require2=require("child_process"),execSync=_require2.execSync;var supportedVersions=["0.4.24","0.4.25","0.5.4","0.5.8"];function getWrapper(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var params=options.networkInfo.parameters;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=params[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var p=_step.value;if(p.key==="getAllowTvmSolidity059"){if(p.value){supportedVersions.push("0.5.9");break}}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}catch(e){}var compilerVersion="0.5.4";var solcDir=path.join(homedir(),".tronbox","solc");if(options.networks){if(options.networks.useZeroFourCompiler){compilerVersion="0.4.25"}else if(options.networks.useZeroFiveCompiler){compilerVersion="0.5.4"}try{var version=options.networks.compilers.solc.version;if(supportedVersions.includes(version)){compilerVersion=version}else{console.error("Error:\nTronBox supports only the following versions:\n".concat(supportedVersions.join(" - "),"\n"));process.exit()}}catch(e){}}var soljsonPath=path.join(solcDir,"soljson_v".concat(compilerVersion,".js"));if(!fs.existsSync(soljsonPath)){if(process.env.TRONBOX_NAME){name=process.env.TRONBOX_NAME}execSync("".concat(name," --download-compiler ").concat(compilerVersion)).toString()}var soljson=eval("require")(soljsonPath);return wrapper(soljson)}module.exports.getWrapper=getWrapper;module.exports.supportedVersions=supportedVersions; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(iter){if(Symbol.iterator in Object(iter)||Object.prototype.toString.call(iter)==="[object Arguments]")return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr)){for(var i=0,arr2=new Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var _TronWeb=require("tronweb");var _SunWeb=require("sunweb");var chalk=require("chalk");var constants=require("./constants");var axios=require("axios");var instance;function TronWrap(){this._toNumber=toNumber;this.EventList=[];this.filterMatchFunction=filterMatchFunction;instance=this;return instance}function toNumber(value){if(!value)return null;if(typeof value==="string"){value=/^0x/.test(value)?value:"0x"+value}else{value=value.toNumber()}return value}function filterMatchFunction(method,abi){var methodObj=abi.filter(function(item){return item.name===method});if(!methodObj||methodObj.length===0){return null}methodObj=methodObj[0];var parametersObj=methodObj.inputs.map(function(item){return item.type});return{"function":methodObj.name+"("+parametersObj.join(",")+")",parameter:parametersObj,methodName:methodObj.name,methodType:methodObj.type}}function sleep(millis){return new Promise(function(resolve){return setTimeout(resolve,millis)})}function filterNetworkConfig(options){var userFeePercentage=typeof options.userFeePercentage==="number"?options.userFeePercentage:typeof options.consume_user_resource_percent==="number"?options.consume_user_resource_percent:constants.deployParameters.userFeePercentage;return{fullNode:options.fullNode||options.fullHost||options.mainFullHost,mainFullHost:options.mainFullHost,sideFullHost:options.sideFullHost,mainGateway:options.mainGateway,sideGateway:options.sideGateway,chainId:options.chainId,feeLimit:options.feeLimit||options.fee_limit||constants.deployParameters.feeLimit,originEnergyLimit:options.originEnergyLimit||options.origin_energy_limit||constants.deployParameters.originEnergyLimit,callValue:options.callValue||options.call_value||constants.deployParameters.callValue,tokenValue:options.tokenValue||options.token_value||options.call_token_value,tokenId:options.tokenId||options.token_id,userFeePercentage:userFeePercentage}}function init(options){var extraOptions=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(instance){return instance}if(extraOptions.verify&&(!options||!options.privateKey||!(options.fullHost||options.fullNode&&options.solidityNode&&options.eventServer))){if(!options){throw new Error("It was not possible to instantiate TronWeb. The chosen network does not exist in your \"sunbox.js\".")}else{throw new Error("It was not possible to instantiate TronWeb. Some required parameters are missing in your \"sunbox.js\".")}}var mainchain=new _TronWeb(options.fullNode||options.mainFullHost,options.solidityNode||options.mainFullHost,options.eventServer||options.mainFullHost,options.privateKey);var sidechain=new _TronWeb(options.fullNode||options.sideFullHost,options.solidityNode||options.sideFullHost,options.eventServer||options.sideFullHost,options.privateKey);var sunweb=new _SunWeb(mainchain,sidechain,options.mainGateway,options.sideGateway,options.chainId);TronWrap.prototype=sunweb.sidechain;var tronWrap=TronWrap.prototype;tronWrap.networkConfig=filterNetworkConfig(options);if(extraOptions.log){tronWrap._log=extraOptions.log}tronWrap._getNetworkInfo=_asyncToGenerator(regeneratorRuntime.mark(function _callee(){var info,res;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:info={parameters:{},nodeinfo:{}};_context.prev=1;_context.next=4;return Promise.all([tronWrap.trx.getChainParameters(),tronWrap.trx.getNodeInfo()]);case 4:res=_context.sent;info.parameters=res[0]||{};info.nodeinfo=res[1]||{};_context.next=11;break;case 9:_context.prev=9;_context.t0=_context["catch"](1);case 11:return _context.abrupt("return",Promise.resolve(info));case 12:case"end":return _context.stop();}}},_callee,null,[[1,9]])}));tronWrap._getNetwork=function(callback){callback&&callback(null,options.network_id)};var defaultAddress=tronWrap.address.fromPrivateKey(tronWrap.defaultPrivateKey);tronWrap._accounts=[defaultAddress];tronWrap._privateKeyByAccount={};tronWrap._privateKeyByAccount[defaultAddress]=tronWrap.defaultPrivateKey;tronWrap._getAccounts=function(callback){var _this=this;var self=this;return new Promise(function(accept){function cb(){if(callback){callback(null,self._accounts);accept()}else{accept(self._accounts)}}if(self._accountsRequested){return cb()}return axios.get(self.networkConfig.fullNode+"/admin/accounts-json").then(function(_ref2){var data=_ref2.data;data=Array.isArray(data)?data:data.privateKeys;if(data.length>0&&data[0].length===64){self._accounts=[];self._privateKeyByAccount={};var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=data[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var account=_step.value;var address=_this.address.fromPrivateKey(account);self._privateKeyByAccount[address]=account;self._accounts.push(address)}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}self._accountsRequested=true;return cb()})["catch"](function(){self._accountsRequested=true;return cb()})})};tronWrap._getContract=function(){var _ref3=_asyncToGenerator(regeneratorRuntime.mark(function _callee2(address,callback){var contractInstance;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.next=2;return tronWrap.trx.getContract(address||"");case 2:contractInstance=_context2.sent;if(contractInstance){callback&&callback(null,contractInstance.contract_address)}else{callback(new Error("no code"))}case 4:case"end":return _context2.stop();}}},_callee2)}));return function(_x,_x2){return _ref3.apply(this,arguments)}}();tronWrap._deployContract=function(option,callback){var myContract=this.contract();var originEnergyLimit=option.originEnergyLimit||this.networkConfig.originEnergyLimit;if(originEnergyLimit<0||originEnergyLimit>constants.deployParameters.originEnergyLimit){throw new Error("Origin Energy Limit must be > 0 and <= 10,000,000")}var userFeePercentage=typeof options.userFeePercentage==="number"?options.userFeePercentage:this.networkConfig.userFeePercentage;this._new(myContract,{bytecode:option.data,feeLimit:option.feeLimit||this.networkConfig.feeLimit,callValue:option.callValue||this.networkConfig.callValue,userFeePercentage:userFeePercentage,originEnergyLimit:originEnergyLimit,abi:option.abi,parameters:option.parameters,name:option.contractName},option.privateKey).then(function(){callback(null,myContract);option.address=myContract.address})["catch"](function(reason){callback(new Error(reason))})};tronWrap._new=function(){var _ref4=_asyncToGenerator(regeneratorRuntime.mark(function _callee3(myContract,options){var privateKey,signedTransaction,address,transaction,result,contract,i,e,url,_args3=arguments;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:privateKey=_args3.length>2&&_args3[2]!==undefined?_args3[2]:tronWrap.defaultPrivateKey;_context3.prev=1;address=tronWrap.address.fromPrivateKey(privateKey);_context3.next=5;return tronWrap.transactionBuilder.createSmartContract(options,address);case 5:transaction=_context3.sent;_context3.next=8;return tronWrap.trx.sign(transaction,privateKey);case 8:signedTransaction=_context3.sent;_context3.next=11;return tronWrap.trx.sendRawTransaction(signedTransaction);case 11:result=_context3.sent;if(!(!result||_typeof(result)!=="object")){_context3.next=14;break}return _context3.abrupt("return",Promise.reject("Error while broadcasting the transaction to create the contract ".concat(options.name,". Most likely, the creator has either insufficient bandwidth or energy.")));case 14:if(!result.code){_context3.next=16;break}return _context3.abrupt("return",Promise.reject("".concat(result.code," (").concat(tronWrap.toUtf8(result.message),") while broadcasting the transaction to create the contract ").concat(options.name)));case 16:dlog("Contract broadcasted",{result:result.result,transaction_id:transaction.txID,address:transaction.contract_address});i=0;case 18:if(!(i<10)){_context3.next=38;break}_context3.prev=19;dlog("Requesting contract");_context3.next=23;return tronWrap.trx.getContract(signedTransaction.contract_address);case 23:contract=_context3.sent;dlog("Contract requested");if(!contract.contract_address){_context3.next=28;break}dlog("Contract found");return _context3.abrupt("break",38);case 28:_context3.next=33;break;case 30:_context3.prev=30;_context3.t0=_context3["catch"](19);dlog("Contract does not exist yet");case 33:_context3.next=35;return sleep(500);case 35:i++;_context3.next=18;break;case 38:dlog("Reading contract data");if(!(!contract||!contract.contract_address)){_context3.next=41;break}throw new Error("Contract does not exist");case 41:myContract.address=contract.contract_address;myContract.bytecode=contract.bytecode;myContract.deployed=true;myContract.loadAbi(contract.abi.entrys);dlog("Contract deployed");return _context3.abrupt("return",Promise.resolve(myContract));case 49:_context3.prev=49;_context3.t1=_context3["catch"](1);if(_context3.t1.toString().includes("does not exist")){url=this.networkConfig.fullNode+"/wallet/gettransactionbyid?value="+signedTransaction.txID;e="Contract "+chalk.bold(options.name)+" has not been deployed on the network.\nFor more details, check the transaction at:\n"+chalk.blue(url)+"\nIf the transaction above is empty, most likely, your address had no bandwidth/energy to deploy the contract."}return _context3.abrupt("return",Promise.reject(e||_context3.t1));case 53:case"end":return _context3.stop();}}},_callee3,this,[[1,49],[19,30]])}));return function(_x3,_x4){return _ref4.apply(this,arguments)}}();tronWrap.triggerContract=function(option,callback){var myContract=this.contract(option.abi,option.address);var callSend="send";option.abi.forEach(function(val){if(val.name===option.methodName){callSend=/payable/.test(val.stateMutability)?"send":"call"}});option.methodArgs||(option.methodArgs={});option.methodArgs.from||(option.methodArgs.from=this._accounts[0]);dlog(option.methodName,option.args,options.methodArgs);var privateKey;if(callSend==="send"&&option.methodArgs.from){privateKey=this._privateKeyByAccount[option.methodArgs.from]}this._getNetworkInfo().then(function(info){if(info.compilerVersion==="1"){delete option.methodArgs.tokenValue;delete option.methodArgs.tokenId}return myContract[option.methodName].apply(myContract,_toConsumableArray(option.args))[callSend](option.methodArgs||{},privateKey)}).then(function(res){callback(null,res)})["catch"](function(reason){if(_typeof(reason)==="object"&&reason.error){reason=reason.error}if(process.env.CURRENT==="test"){callback(reason)}else{logErrorAndExit(console,reason)}})};return new TronWrap}var logErrorAndExit=function logErrorAndExit(logger,err){function log(str){try{logger.error(str)}catch(err){console.error(str)}}var msg=typeof err==="string"?err:err.message;if(msg){msg=msg.replace(/^error(:|) /i,"");if(msg==="Invalid URL provided to HttpProvider"){msg="Either invalid or wrong URL provided to HttpProvider. Verify the configuration in your \"sunbox.js\""}log(chalk.red(chalk.bold("ERROR:"),msg))}else{log("Error encountered, bailing. Network state unknown.")}process.exit()};var dlog=function dlog(){if(process.env.DEBUG_MODE){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}for(var i=0;i<args.length;i++){if(_typeof(args[i])==="object"){try{args[i]=JSON.stringify(args[i],null,2)}catch(err){}}}console.debug(chalk.blue(args.join(" ")))}};module.exports=init;module.exports.config=function(){return console.info("config")};module.exports.constants=constants;module.exports.logErrorAndExit=logErrorAndExit;module.exports.dlog=dlog;module.exports.sleep=sleep;module.exports.TronWeb=_TronWeb; | ||
"use strict";function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(iter){if(Symbol.iterator in Object(iter)||Object.prototype.toString.call(iter)==="[object Arguments]")return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr)){for(var i=0,arr2=new Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var _TronWeb=require("tronweb");var _SunWeb=require("sunweb");var chalk=require("chalk");var constants=require("./constants");var axios=require("axios");var instance;function TronWrap(){this._toNumber=toNumber;this.EventList=[];this.filterMatchFunction=filterMatchFunction;instance=this;return instance}function toNumber(value){if(!value)return null;if(typeof value==="string"){value=/^0x/.test(value)?value:"0x"+value}else{value=value.toNumber()}return value}function filterMatchFunction(method,abi){var methodObj=abi.filter(function(item){return item.name===method});if(!methodObj||methodObj.length===0){return null}methodObj=methodObj[0];var parametersObj=methodObj.inputs.map(function(item){return item.type});return{"function":methodObj.name+"("+parametersObj.join(",")+")",parameter:parametersObj,methodName:methodObj.name,methodType:methodObj.type}}function sleep(millis){return new Promise(function(resolve){return setTimeout(resolve,millis)})}function filterNetworkConfig(options){var userFeePercentage=typeof options.userFeePercentage==="number"?options.userFeePercentage:typeof options.consume_user_resource_percent==="number"?options.consume_user_resource_percent:constants.deployParameters.userFeePercentage;return{fullNode:options.fullNode||options.fullHost||options.mainFullHost,mainFullHost:options.mainFullHost,sideFullHost:options.sideFullHost,mainGateway:options.mainGateway,sideGateway:options.sideGateway,chainId:options.chainId,feeLimit:options.feeLimit||options.fee_limit||constants.deployParameters.feeLimit,originEnergyLimit:options.originEnergyLimit||options.origin_energy_limit||constants.deployParameters.originEnergyLimit,callValue:options.callValue||options.call_value||constants.deployParameters.callValue,tokenValue:options.tokenValue||options.token_value||options.call_token_value,tokenId:options.tokenId||options.token_id,userFeePercentage:userFeePercentage}}function init(options,extraOptions){if(instance){return instance}if(extraOptions.verify&&(!options||!options.privateKey||!(options.fullHost||options.fullNode&&options.solidityNode&&options.eventServer))){if(!options){throw new Error("It was not possible to instantiate TronWeb. The chosen network does not exist in your \"sunbox.js\".")}else{throw new Error("It was not possible to instantiate TronWeb. Some required parameters are missing in your \"sunbox.js\".")}}var mainchain=new _TronWeb(options.fullNode||options.mainFullHost,options.solidityNode||options.mainFullHost,options.eventServer||options.mainFullHost,options.privateKey);var sidechain=new _TronWeb(options.fullNode||options.sideFullHost,options.solidityNode||options.sideFullHost,options.eventServer||options.sideFullHost,options.privateKey);var sunweb=new _SunWeb(mainchain,sidechain,options.mainGateway,options.sideGateway,options.chainId);TronWrap.prototype=sunweb.sidechain;var tronWrap=TronWrap.prototype;tronWrap.networkConfig=filterNetworkConfig(options);if(extraOptions.log){tronWrap._log=extraOptions.log}tronWrap._getNetworkInfo=_asyncToGenerator(regeneratorRuntime.mark(function _callee(){var info,res;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:info={parameters:{},nodeinfo:{}};_context.prev=1;_context.next=4;return Promise.all([tronWrap.trx.getChainParameters(),tronWrap.trx.getNodeInfo()]);case 4:res=_context.sent;info.parameters=res[0]||{};info.nodeinfo=res[1]||{};_context.next=11;break;case 9:_context.prev=9;_context.t0=_context["catch"](1);case 11:return _context.abrupt("return",Promise.resolve(info));case 12:case"end":return _context.stop();}}},_callee,null,[[1,9]])}));tronWrap._getNetwork=function(callback){callback&&callback(null,options.network_id)};var defaultAddress=tronWrap.address.fromPrivateKey(tronWrap.defaultPrivateKey);tronWrap._accounts=[defaultAddress];tronWrap._privateKeyByAccount={};tronWrap._privateKeyByAccount[defaultAddress]=tronWrap.defaultPrivateKey;tronWrap._getAccounts=function(callback){var _this=this;var self=this;return new Promise(function(accept,reject){function cb(){if(callback){callback(null,self._accounts);accept()}else{accept(self._accounts)}}if(self._accountsRequested){return cb()}return axios.get(self.networkConfig.fullNode+"/admin/accounts-json").then(function(_ref2){var data=_ref2.data;data=Array.isArray(data)?data:data.privateKeys;if(data.length>0&&data[0].length===64){self._accounts=[];self._privateKeyByAccount={};var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=data[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var account=_step.value;var address=_this.address.fromPrivateKey(account);self._privateKeyByAccount[address]=account;self._accounts.push(address)}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}self._accountsRequested=true;return cb()})["catch"](function(err){self._accountsRequested=true;return cb()})})};tronWrap._getContract=function(){var _ref3=_asyncToGenerator(regeneratorRuntime.mark(function _callee2(address,callback){var contractInstance;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.next=2;return tronWrap.trx.getContract(address||"");case 2:contractInstance=_context2.sent;if(contractInstance){callback&&callback(null,contractInstance.contract_address)}else{callback(new Error("no code"))}case 4:case"end":return _context2.stop();}}},_callee2)}));return function(_x,_x2){return _ref3.apply(this,arguments)}}();tronWrap._deployContract=function(option,callback){var myContract=this.contract();var originEnergyLimit=option.originEnergyLimit||this.networkConfig.originEnergyLimit;if(originEnergyLimit<0||originEnergyLimit>constants.deployParameters.originEnergyLimit){throw new Error("Origin Energy Limit must be > 0 and <= 10,000,000")}var userFeePercentage=typeof options.userFeePercentage==="number"?options.userFeePercentage:this.networkConfig.userFeePercentage;this._new(myContract,{bytecode:option.data,feeLimit:option.feeLimit||this.networkConfig.feeLimit,callValue:option.callValue||this.networkConfig.callValue,userFeePercentage:userFeePercentage,originEnergyLimit:originEnergyLimit,abi:option.abi,parameters:option.parameters,name:option.contractName},option.privateKey).then(function(result){callback(null,myContract);option.address=myContract.address})["catch"](function(reason){callback(new Error(reason))})};tronWrap._new=function(){var _ref4=_asyncToGenerator(regeneratorRuntime.mark(function _callee3(myContract,options){var privateKey,callback,signedTransaction,address,transaction,result,contract,i,url,_args3=arguments;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:privateKey=_args3.length>2&&_args3[2]!==undefined?_args3[2]:tronWrap.defaultPrivateKey;callback=_args3.length>3?_args3[3]:undefined;_context3.prev=2;address=tronWrap.address.fromPrivateKey(privateKey);_context3.next=6;return tronWrap.transactionBuilder.createSmartContract(options,address);case 6:transaction=_context3.sent;_context3.next=9;return tronWrap.trx.sign(transaction,privateKey);case 9:signedTransaction=_context3.sent;_context3.next=12;return tronWrap.trx.sendRawTransaction(signedTransaction);case 12:result=_context3.sent;if(!(!result||_typeof(result)!=="object")){_context3.next=15;break}return _context3.abrupt("return",Promise.reject("Error while broadcasting the transaction to create the contract ".concat(options.name,". Most likely, the creator has either insufficient bandwidth or energy.")));case 15:if(!result.code){_context3.next=17;break}return _context3.abrupt("return",Promise.reject("".concat(result.code," (").concat(tronWrap.toUtf8(result.message),") while broadcasting the transaction to create the contract ").concat(options.name)));case 17:dlog("Contract broadcasted",{result:result.result,transaction_id:transaction.txID,address:transaction.contract_address});i=0;case 19:if(!(i<10)){_context3.next=39;break}_context3.prev=20;dlog("Requesting contract");_context3.next=24;return tronWrap.trx.getContract(signedTransaction.contract_address);case 24:contract=_context3.sent;dlog("Contract requested");if(!contract.contract_address){_context3.next=29;break}dlog("Contract found");return _context3.abrupt("break",39);case 29:_context3.next=34;break;case 31:_context3.prev=31;_context3.t0=_context3["catch"](20);dlog("Contract does not exist yet");case 34:_context3.next=36;return sleep(500);case 36:i++;_context3.next=19;break;case 39:dlog("Reading contract data");if(!(!contract||!contract.contract_address)){_context3.next=42;break}throw new Error("Contract does not exist");case 42:myContract.address=contract.contract_address;myContract.bytecode=contract.bytecode;myContract.deployed=true;myContract.loadAbi(contract.abi.entrys);dlog("Contract deployed");return _context3.abrupt("return",Promise.resolve(myContract));case 50:_context3.prev=50;_context3.t1=_context3["catch"](2);if(_context3.t1.toString().includes("does not exist")){url=this.networkConfig.fullNode+"/wallet/gettransactionbyid?value="+signedTransaction.txID;_context3.t1="Contract "+chalk.bold(options.name)+" has not been deployed on the network.\nFor more details, check the transaction at:\n"+chalk.blue(url)+"\nIf the transaction above is empty, most likely, your address had no bandwidth/energy to deploy the contract."}return _context3.abrupt("return",Promise.reject(_context3.t1));case 54:case"end":return _context3.stop();}}},_callee3,this,[[2,50],[20,31]])}));return function(_x3,_x4){return _ref4.apply(this,arguments)}}();tronWrap.triggerContract=function(option,callback){var myContract=this.contract(option.abi,option.address);var callSend="send";option.abi.forEach(function(val){if(val.name===option.methodName){callSend=/payable/.test(val.stateMutability)?"send":"call"}});option.methodArgs||(option.methodArgs={});option.methodArgs.from||(option.methodArgs.from=this._accounts[0]);dlog(option.methodName,option.args,options.methodArgs);var privateKey;if(callSend==="send"&&option.methodArgs.from){privateKey=this._privateKeyByAccount[option.methodArgs.from]}this._getNetworkInfo().then(function(info){if(info.compilerVersion==="1"){delete option.methodArgs.tokenValue;delete option.methodArgs.tokenId}return myContract[option.methodName].apply(myContract,_toConsumableArray(option.args))[callSend](option.methodArgs||{},privateKey)}).then(function(res){callback(null,res)})["catch"](function(reason){if(_typeof(reason)==="object"&&reason.error){reason=reason.error}if(process.env.CURRENT==="test"){callback(reason)}else{logErrorAndExit(console,reason)}})};return new TronWrap}var logErrorAndExit=function logErrorAndExit(logger,err){function log(str){try{logger.error(str)}catch(err){console.error(str)}}var msg=typeof err==="string"?err:err.message;if(msg){msg=msg.replace(/^error(:|) /i,"");if(msg==="Invalid URL provided to HttpProvider"){msg="Either invalid or wrong URL provided to HttpProvider. Verify the configuration in your \"sunbox.js\""}log(chalk.red(chalk.bold("ERROR:"),msg))}else{log("Error encountered, bailing. Network state unknown.")}process.exit()};var dlog=function dlog(){if(process.env.DEBUG_MODE){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}for(var i=0;i<args.length;i++){if(_typeof(args[i])==="object"){try{args[i]=JSON.stringify(args[i],null,2)}catch(err){}}}console.log(chalk.blue(args.join(" ")))}};module.exports=init;module.exports.config=function(){return console.log("config")};module.exports.constants=constants;module.exports.logErrorAndExit=logErrorAndExit;module.exports.dlog=dlog;module.exports.sleep=sleep;module.exports.TronWeb=_TronWeb; |
@@ -1,1 +0,1 @@ | ||
"use strict";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var mkdirp=require("mkdirp");var path=require("path");var Config=require("./Config");var _compile=require("./Compile");var expect=require("@truffle/expect");var Resolver=require("./Resolver");var Artifactor=require("./Artifactor");var OS=require("os");var TronWrap=require("./TronWrap");function getCompilerVersion(_x){return _getCompilerVersion.apply(this,arguments)}function _getCompilerVersion(){_getCompilerVersion=_asyncToGenerator(regeneratorRuntime.mark(function _callee(options){var config,tronWrap,networkInfo;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}_context.prev=2;tronWrap=TronWrap(config.networks[config.network],{verify:true,log:options.log});_context.next=6;return tronWrap._getNetworkInfo();case 6:networkInfo=_context.sent;return _context.abrupt("return",Promise.resolve(networkInfo||{}));case 10:_context.prev=10;_context.t0=_context["catch"](2);return _context.abrupt("return",Promise.resolve({}));case 13:case"end":return _context.stop();}}},_callee,null,[[2,10]])}));return _getCompilerVersion.apply(this,arguments)}var Contracts={compile:function compile(options,callback){var self=this;expect.options(options,["contracts_build_directory"]);expect.one(options,["contracts_directory","files"]);var config=Config["default"]().merge(options);if(!config.resolver){config.resolver=new Resolver(config)}if(!config.artifactor){config.artifactor=new Artifactor(config.contracts_build_directory)}function finished(err,contracts,paths){if(err)return callback(err);if(contracts!=null&&Object.keys(contracts).length>0){self.write_contracts(contracts,config,function(err,abstractions){callback(err,abstractions,paths)})}else{callback(null,[],paths)}}function start(){if(config.all===true||config.compileAll===true){_compile.all(config,finished)}else{_compile.necessary(config,finished)}}getCompilerVersion(options).then(function(networkInfo){config.networkInfo=networkInfo;start()})["catch"](start)},write_contracts:function write_contracts(contracts,options,callback){var logger=options.logger||console;mkdirp(options.contracts_build_directory,function(err){if(err!=null){callback(err);return}if(!options.quiet&&!options.quietWrite){logger.log("Writing artifacts to ."+path.sep+path.relative(options.working_directory,options.contracts_build_directory)+OS.EOL)}var extra_opts={network_id:options.network_id};options.artifactor.saveAll(contracts,extra_opts).then(function(){callback(null,contracts)})["catch"](callback)})}};module.exports=Contracts; | ||
"use strict";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var async=require("async");var fs=require("fs");var mkdirp=require("mkdirp");var path=require("path");var Config=require("./Config");var _compile=require("./Compile");var expect=require("@truffle/expect");var _=require("lodash");var Resolver=require("./Resolver");var Artifactor=require("./Artifactor");var OS=require("os");var TronWrap=require("./TronWrap");function getCompilerVersion(_x){return _getCompilerVersion.apply(this,arguments)}function _getCompilerVersion(){_getCompilerVersion=_asyncToGenerator(regeneratorRuntime.mark(function _callee(options){var config,tronWrap,networkInfo;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}_context.prev=2;tronWrap=TronWrap(config.networks[config.network],{verify:true,log:options.log});_context.next=6;return tronWrap._getNetworkInfo();case 6:networkInfo=_context.sent;return _context.abrupt("return",Promise.resolve(networkInfo||{}));case 10:_context.prev=10;_context.t0=_context["catch"](2);return _context.abrupt("return",Promise.resolve({}));case 13:case"end":return _context.stop();}}},_callee,null,[[2,10]])}));return _getCompilerVersion.apply(this,arguments)}var Contracts={compile:function compile(options,callback){var self=this;expect.options(options,["contracts_build_directory"]);expect.one(options,["contracts_directory","files"]);var config=Config["default"]().merge(options);if(!config.resolver){config.resolver=new Resolver(config)}if(!config.artifactor){config.artifactor=new Artifactor(config.contracts_build_directory)}function finished(err,contracts,paths){if(err)return callback(err);if(contracts!=null&&Object.keys(contracts).length>0){self.write_contracts(contracts,config,function(err,abstractions){callback(err,abstractions,paths)})}else{callback(null,[],paths)}};function start(){if(config.all===true||config.compileAll===true){_compile.all(config,finished)}else{_compile.necessary(config,finished)}}getCompilerVersion(options).then(function(networkInfo){config.networkInfo=networkInfo;start()})["catch"](function(err){return start()})},write_contracts:function write_contracts(contracts,options,callback){var logger=options.logger||console;mkdirp(options.contracts_build_directory,function(err,result){if(err!=null){callback(err);return}if(options.quiet!=true&&options.quietWrite!=true){logger.log("Writing artifacts to ."+path.sep+path.relative(options.working_directory,options.contracts_build_directory)+OS.EOL)}var extra_opts={network_id:options.network_id};options.artifactor.saveAll(contracts,extra_opts).then(function(){callback(null,contracts)})["catch"](callback)})}};module.exports=Contracts; |
@@ -1,1 +0,1 @@ | ||
"use strict";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var path=require("path");var fs=require("fs-extra");var homedir=require("homedir");var req=require("superagent");function downloader(_x){return _downloader.apply(this,arguments)}function _downloader(){_downloader=_asyncToGenerator(regeneratorRuntime.mark(function _callee(compilerVersion){var dir,soljsonPath,res;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dir=path.join(homedir(),".tronbox","solc");soljsonPath=path.join(dir,"soljson_v".concat(compilerVersion,".js"));_context.next=4;return fs.ensureDir(path.join(dir));case 4:_context.next=6;return req.get("https://tron-us.github.io/tron-solc-bin/bin/soljson_v".concat(compilerVersion,".js")).responseType("blob");case 6:res=_context.sent;if(!(res&&res.body)){_context.next=13;break}_context.next=10;return fs.writeFile(soljsonPath,res.body);case 10:if(!fs.existsSync(soljsonPath)){console.error("Error. Permission required.")}else{console.info("Compiler downloaded.")}_context.next=14;break;case 13:console.error("Error. Wrong Solidity compiler version.");case 14:process.exit();case 15:case"end":return _context.stop();}}},_callee)}));return _downloader.apply(this,arguments)}module.exports=downloader; | ||
"use strict";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var path=require("path");var fs=require("fs-extra");var homedir=require("homedir");var req=require("superagent");function downloader(_x){return _downloader.apply(this,arguments)}function _downloader(){_downloader=_asyncToGenerator(regeneratorRuntime.mark(function _callee(compilerVersion){var dir,soljsonPath,res;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dir=path.join(homedir(),".tronbox","solc");soljsonPath=path.join(dir,"soljson_v".concat(compilerVersion,".js"));_context.next=4;return fs.ensureDir(path.join(dir));case 4:_context.next=6;return req.get("https://tron-us.github.io/tron-solc-bin/bin/soljson_v".concat(compilerVersion,".js")).responseType("blob");case 6:res=_context.sent;if(!(res&&res.body)){_context.next=12;break}_context.next=10;return fs.writeFile(soljsonPath,res.body);case 10:_context.next=13;break;case 12:console.log("Error. Wrong Solidity compiler version.");case 13:process.exit();case 14:case"end":return _context.stop();}}},_callee)}));return _downloader.apply(this,arguments)}module.exports=downloader; |
@@ -1,1 +0,2 @@ | ||
"use strict";var path=require("path");var spawn=require("child_process").spawn;var cli_path=path.resolve(path.join(__dirname,"./index.js"));var args=[cli_path,"exec"];Array.prototype.push.apply(args,process.argv.slice(2));var cmd=spawn("node",args);cmd.stdout.on("data",function(data){console.info(data.toString())});cmd.stderr.on("data",function(data){console.error(data.toString())});cmd.on("close",function(code){process.exit(code)});cmd.on("error",function(err){throw err}); | ||
#!/usr/bin/env node | ||
"use strict";var path=require("path");var spawn=require("child_process").spawn;var cli_path=path.resolve(path.join(__dirname,"./index.js"));var args=[cli_path,"exec"];Array.prototype.push.apply(args,process.argv.slice(2));var cmd=spawn("node",args);cmd.stdout.on("data",function(data){console.log(data.toString())});cmd.stderr.on("data",function(data){console.error(data.toString())});cmd.on("close",function(code){process.exit(code)});cmd.on("error",function(err){throw err}); |
@@ -1,1 +0,1 @@ | ||
"use strict";require("source-map-support/register");var Command=require("./lib/command");var TaskError=require("./lib/errors/taskerror");var TruffleError=require("@truffle/error");var version=require("./lib/version");var OS=require("os");var downloader=require("./downloader");var command=new Command(require("./lib/commands"));var options={logger:console};var commands=process.argv.slice(2);if(commands[0]==="--download-compiler"&&commands[1]){downloader(commands[1])}else{command.run(process.argv.slice(2),options,function(err){if(err){if(err instanceof TaskError){command.args.usage("Tronbox v"+(version.bundle||version.core)+" - a development framework for tronweb"+OS.EOL+OS.EOL+"Usage: tronbox <command> [options]").epilog("See more at https://developers.tron.network/docs/tron-box-user-guide").showHelp()}else{if(err instanceof TruffleError){console.error(err.message)}else if(typeof err==="number"){process.exit(err)}else{console.error(err.stack||err.toString())}}process.exit(1)}var handles=process._getActiveHandles();handles.forEach(function(handle){if(typeof handle.close==="function"){handle.close()}})})} | ||
"use strict";require("source-map-support/register");var Config=require("./components/Config");var Command=require("./lib/command");var TaskError=require("./lib/errors/taskerror");var TruffleError=require("@truffle/error");var version=require("./lib/version");var OS=require("os");var downloader=require("./downloader");var command=new Command(require("./lib/commands"));var options={logger:console};var commands=process.argv.slice(2);if(commands[0]==="--download-compiler"&&commands[1]){downloader(commands[1])}else{var command=new Command(require("./lib/commands"));var options={logger:console};command.run(process.argv.slice(2),options,function(err){if(err){if(err instanceof TaskError){command.args.usage("Tronbox v"+(version.bundle||version.core)+" - a development framework for tronweb"+OS.EOL+OS.EOL+"Usage: tronbox <command> [options]").epilog("See more at https://developers.tron.network/docs/tron-box-user-guide").showHelp()}else{if(err instanceof TruffleError){console.log(err.message)}else if(typeof err=="number"){process.exit(err)}else{console.log(err.stack||err.toString())}}process.exit(1)}var handles=process._getActiveHandles();handles.forEach(function(handle){if(typeof handle.close==="function"){handle.close()}})})} |
@@ -1,1 +0,1 @@ | ||
"use strict";var BigNumber=require("bignumber.js");module.exports=function(chai){var assert=chai.assert;chai.Assertion.addProperty("address",function(){this.assert(this._obj.length===42,"expected #{this} to be a 42 character address (0x...)","expected #{this} to not be a 42 character address (0x...)");var number=BigNumber(this._obj);this.assert(number.equals(0)===false,"expected address #{this} to not be zero","you shouldn't ever see this.")});assert.isAddress=function(val,exp,msg){return new chai.Assertion(val,msg).to.be.address}}; | ||
"use strict";var BigNumber=require("bignumber.js");module.exports=function(chai,utils){var assert=chai.assert;chai.Assertion.addProperty("address",function(){this.assert(this._obj.length===42,"expected #{this} to be a 42 character address (0x...)","expected #{this} to not be a 42 character address (0x...)");var number=BigNumber(this._obj);this.assert(number.equals(0)===false,"expected address #{this} to not be zero","you shouldn't ever see this.")});assert.isAddress=function(val,exp,msg){return new chai.Assertion(val,msg).to.be.address}}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var mkdirp=require("mkdirp");var del=require("del");var Contracts=require("../components/WorkflowCompile");var BuildError=require("./errors/builderror");var child_process=require("child_process");var spawnargs=require("spawn-args");var _=require("lodash");var expect=require("@truffle/expect");function CommandBuilder(command){this.command=command}CommandBuilder.prototype.build=function(options,callback){console.debug("Running `"+this.command+"`...");var args=spawnargs(this.command);var ps=args.shift();var cmd=child_process.spawn(ps,args,{detached:false,cwd:options.working_directory,env:_.merge(process.env,{WORKING_DIRECTORY:options.working_directory,BUILD_DESTINATION_DIRECTORY:options.destination_directory,BUILD_CONTRACTS_DIRECTORY:options.contracts_build_directory})});cmd.stdout.on("data",function(data){console.debug(data.toString())});cmd.stderr.on("data",function(data){console.debug("build error: "+data)});cmd.on("close",function(code){var error=null;if(code!==0){error="Command exited with code "+code}callback(error)})};var Build={clean:function clean(options,callback){var destination=options.build_directory;var contracts_build_directory=options.contracts_build_directory;del([destination+"/*","!"+contracts_build_directory]).then(function(){mkdirp(destination,callback)})},build:function build(options,callback){expect.options(options,["build_directory","working_directory","contracts_build_directory","networks"]);var builder=options.build;options.destination_directory=options.build_directory;if(typeof builder==="undefined"){if(!options.quiet){return callback(new BuildError("No build configuration specified. Can't build."))}return callback()}if(typeof builder==="string"){builder=new CommandBuilder(builder)}else if(typeof builder!=="function"){if(!builder.build){return callback(new BuildError("Build configuration can no longer be specified as an object. Please see our documentation for an updated list of supported build configurations."))}}else{builder={build:builder}}var clean=this.clean;if(builder.hasOwnProperty("clean")){clean=builder.clean}clean(options,function(err){if(err)return callback(err);Contracts.compile(options,function(err){if(err)return callback(err);builder.build(options,function(err){if(!err)return callback();if(typeof err==="string"){err=new BuildError(err)}callback(err)})})})}};module.exports=Build; | ||
"use strict";var async=require("async");var mkdirp=require("mkdirp");var del=require("del");var fs=require("fs");var Contracts=require("../components/WorkflowCompile");var BuildError=require("./errors/builderror");var child_process=require("child_process");var spawnargs=require("spawn-args");var _=require("lodash");var expect=require("@truffle/expect");var contract=require("../components/Contract");function CommandBuilder(command){this.command=command};CommandBuilder.prototype.build=function(options,callback){console.log("Running `"+this.command+"`...");var args=spawnargs(this.command);var ps=args.shift();var cmd=child_process.spawn(ps,args,{detached:false,cwd:options.working_directory,env:_.merge(process.env,{WORKING_DIRECTORY:options.working_directory,BUILD_DESTINATION_DIRECTORY:options.destination_directory,BUILD_CONTRACTS_DIRECTORY:options.contracts_build_directory})});cmd.stdout.on("data",function(data){console.log(data.toString())});cmd.stderr.on("data",function(data){console.log("build error: "+data)});cmd.on("close",function(code){var error=null;if(code!==0){error="Command exited with code "+code}callback(error)})};var Build={clean:function clean(options,callback){var destination=options.build_directory;var contracts_build_directory=options.contracts_build_directory;del([destination+"/*","!"+contracts_build_directory]).then(function(){mkdirp(destination,callback)})},build:function build(options,callback){var self=this;expect.options(options,["build_directory","working_directory","contracts_build_directory","networks"]);var key="build";if(options.dist){key="dist"}var logger=options.logger||console;var builder=options.build;options.destination_directory=options.build_directory;if(typeof builder=="undefined"){if(options.quiet!=true){return callback(new BuildError("No build configuration specified. Can't build."))}return callback()}if(typeof builder=="string"){builder=new CommandBuilder(builder)}else if(typeof builder!=="function"){if(builder.build==null){return callback(new BuildError("Build configuration can no longer be specified as an object. Please see our documentation for an updated list of supported build configurations."))}}else{builder={build:builder}}var clean=this.clean;if(builder.hasOwnProperty("clean")){clean=builder.clean}clean(options,function(err){if(err)return callback(err);Contracts.compile(options,function(err){if(err)return callback(err);builder.build(options,function(err){if(!err)return callback();if(typeof err=="string"){err=new BuildError(err)}callback(err)})})})},dist:function dist(config,callback){this.build(config["with"]({key:"dist"}),callback)}};module.exports=Build; |
@@ -1,1 +0,1 @@ | ||
"use strict";var TaskError=require("./errors/taskerror");var yargs=require("yargs/yargs");var _=require("lodash");function Command(commands){this.commands=commands;var args=yargs();Object.keys(this.commands).forEach(function(command){args=args.command(commands[command])});this.args=args}Command.prototype.getCommand=function(str,noAliases){var _this=this;var argv=this.args.parse(str);if(argv._.length===0){return null}var input=argv._[0];var chosenCommand=null;if(this.commands[input]){chosenCommand=input}else if(noAliases!==true){(function(){var currentLength=1;var availableCommandNames=Object.keys(_this.commands);while(currentLength<=input.length){var possibleCommands=availableCommandNames.filter(function(possibleCommand){return possibleCommand.substring(0,currentLength)===input.substring(0,currentLength)});if(possibleCommands.length===1){chosenCommand=possibleCommands[0];break}currentLength+=1}})()}if(!chosenCommand){return null}var command=this.commands[chosenCommand];return{name:chosenCommand,argv:argv,command:command}};Command.prototype.run=function(command,options,callback){if(typeof options==="function"){callback=options;options={}}var result=this.getCommand(command,typeof options.noAliases==="boolean"?options.noAliases:true);if(!result){return callback(new TaskError("Cannot find command: "+command))}var argv=result.argv;if(argv._){argv._.shift()}delete argv["$0"];var clone={};Object.keys(options).forEach(function(key){try{clone[key]=options[key]}catch(e){}});options=_.extend(clone,argv);try{result.command.run(options,callback)}catch(err){callback(err)}};module.exports=Command; | ||
"use strict";var TaskError=require("./errors/taskerror");var yargs=require("yargs/yargs");var _=require("lodash");function Command(commands){this.commands=commands;var args=yargs();Object.keys(this.commands).forEach(function(command){args=args.command(commands[command])});this.args=args};Command.prototype.getCommand=function(str,noAliases){var argv=this.args.parse(str);if(argv._.length==0){return null}var input=argv._[0];var chosenCommand=null;if(this.commands[input]){chosenCommand=input}else if(noAliases!==true){var currentLength=1;var availableCommandNames=Object.keys(this.commands);while(currentLength<=input.length){var possibleCommands=availableCommandNames.filter(function(possibleCommand){return possibleCommand.substring(0,currentLength)==input.substring(0,currentLength)});if(possibleCommands.length==1){chosenCommand=possibleCommands[0];break}currentLength+=1}}if(chosenCommand==null){return null}var command=this.commands[chosenCommand];return{name:chosenCommand,argv:argv,command:command}};Command.prototype.run=function(command,options,callback){if(typeof options=="function"){callback=options;options={}}var result=this.getCommand(command,typeof options.noAliases==="boolean"?options.noAliases:true);if(result==null){return callback(new TaskError("Cannot find command: "+command))}var argv=result.argv;if(argv._){argv._.shift()}delete argv["$0"];var clone={};Object.keys(options).forEach(function(key){try{clone[key]=options[key]}catch(e){}});options=_.extend(clone,argv);try{result.command.run(options,callback)}catch(err){callback(err)}};module.exports=Command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var command={command:"console",description:"Run a console with contract abstractions and commands available",builder:{},run:function run(options,done){process.env.CURRENT="console";var Config=require("../../components/Config");var Console=require("../console");var Environment=require("../environment");var TronWrap=require("../../components/TronWrap");var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}var commands=require("./index");var excluded=["console","init","watch","serve"];var available_commands=Object.keys(commands).filter(function(name){return excluded.indexOf(name)===-1});var console_commands={};available_commands.forEach(function(name){console_commands[name]=commands[name]});Environment.detect(config,function(err){if(err)return done(err);var c=new Console(console_commands,config["with"]({noAliases:true}));c.start(done)})}};module.exports=command; | ||
"use strict";var command={command:"console",description:"Run a console with contract abstractions and commands available",builder:{},run:function run(options,done){process.env.CURRENT="console";var Config=require("../../components/Config");var Console=require("../console");var Environment=require("../environment");var TruffleError=require("@truffle/error");var TronWrap=require("../../components/TronWrap");var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}var commands=require("./index");var excluded=["console","init","watch","serve"];var available_commands=Object.keys(commands).filter(function(name){return excluded.indexOf(name)==-1});var console_commands={};available_commands.forEach(function(name){console_commands[name]=commands[name]});Environment.detect(config,function(err){if(err)return done(err);var c=new Console(console_commands,config["with"]({noAliases:true}));c.start(done)})}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";module.exports={init:require("./init"),compile:require("./compile"),migrate:require("./migrate"),deploy:require("./deploy"),build:require("./build"),test:require("./test"),console:require("./console"),watch:require("./watch"),serve:require("./serve"),unbox:require("./unbox"),version:require("./version")}; | ||
"use strict";module.exports={init:require("./init"),compile:require("./compile"),migrate:require("./migrate"),deploy:require("./deploy"),build:require("./build"),test:require("./test"),console:require("./console"),create:require("./create"),watch:require("./watch"),serve:require("./serve"),exec:require("./exec"),unbox:require("./unbox"),version:require("./version")}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var command={command:"migrate",description:"Run migrations to deploy contracts",builder:{reset:{type:"boolean","default":false},"compile-all":{describe:"recompile all contracts",type:"boolean","default":false},f:{describe:"Specify a migration number to run from",type:"number"}},run:function run(options,done){process.env.CURRENT="migrate";var OS=require("os");var Config=require("../../components/Config");var Contracts=require("../../components/WorkflowCompile");var Migrate=require("../../components/Migrate");var Environment=require("../environment");var TronWrap=require("../../components/TronWrap");var _require=require("../../components/TronWrap"),dlog=_require.dlog;var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}function runMigrations(callback){if(options.f){Migrate.runFrom(options.f,config,done)}else{Migrate.needsMigrating(config,function(err,needsMigrating){if(err)return callback(err);if(needsMigrating){dlog("Starting migration");Migrate.run(config,done)}else{config.logger.log("Network up to date.");callback()}})}}Contracts.compile(config,function(err){if(err)return done(err);Environment.detect(config,function(err){if(err)return done(err);var dryRun=options.dryRun===true;var networkMessage="Using network '"+config.network+"'";if(dryRun){networkMessage+=" (dry run)"}config.logger.log(networkMessage+"."+OS.EOL);runMigrations(done)})})}};module.exports=command; | ||
"use strict";var command={command:"migrate",description:"Run migrations to deploy contracts",builder:{reset:{type:"boolean","default":false},"compile-all":{describe:"recompile all contracts",type:"boolean","default":false},f:{describe:"Specify a migration number to run from",type:"number"}},run:function run(options,done){process.env.CURRENT="migrate";var OS=require("os");var Config=require("../../components/Config");var Contracts=require("../../components/WorkflowCompile");var Resolver=require("../../components/Resolver");var Artifactor=require("../../components/Artifactor");var Migrate=require("../../components/Migrate");var Environment=require("../environment");var temp=require("temp");var copy=require("../copy");var TronWrap=require("../../components/TronWrap");var _require=require("../../components/TronWrap"),dlog=_require.dlog;var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network&&config.networks.development){config.network="development"}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}function runMigrations(callback){if(options.f){Migrate.runFrom(options.f,config,done)}else{Migrate.needsMigrating(config,function(err,needsMigrating){if(err)return callback(err);if(needsMigrating){dlog("Starting migration");Migrate.run(config,done)}else{config.logger.log("Network up to date.");callback()}})}};Contracts.compile(config,function(err){if(err)return done(err);Environment.detect(config,function(err){if(err)return done(err);var dryRun=options.dryRun===true;var networkMessage="Using network '"+config.network+"'";if(dryRun){networkMessage+=" (dry run)"}config.logger.log(networkMessage+"."+OS.EOL);runMigrations(done)})})}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var command={command:"test",description:"Run JavaScript and Solidity tests",builder:{},run:function run(options,done){var OS=require("os");var dir=require("node-dir");var temp=require("temp");var Config=require("../../components/Config");var Artifactor=require("../../components/Artifactor");var Test=require("../test");var fs=require("fs");var copy=require("../copy");var Environment=require("../environment");var TronWrap=require("../../components/TronWrap");var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network){if(config.networks.development)config.network="development";else if(config.networks.test)config.network="test"}if(!config.network){console.error("\nERROR: Neither development nor test network has been set in tronbox.js\n");return}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}process.env.CURRENT="test";var ipcDisconnect;var files=[];if(options.file){files=[options.file]}else if(options._.length>0){Array.prototype.push.apply(files,options._)}function getFiles(callback){if(files.length!==0){return callback(null,files)}dir.files(config.test_directory,callback)}getFiles(function(err,files){if(err)return done(err);files=files.filter(function(file){return file.match(config.test_file_extension_regexp)!=null});temp.mkdir("test-",function(err,temporaryDirectory){if(err)return done(err);function cleanup(){var args=arguments;temp.cleanup(function(){done.apply(null,args);if(ipcDisconnect){ipcDisconnect()}})}function run(){config.artifactor=new Artifactor(temporaryDirectory);Test.run(config["with"]({test_files:files,contracts_build_directory:temporaryDirectory}),cleanup)}var environmentCallback=function environmentCallback(err){if(err)return done(err);fs.stat(config.contracts_build_directory,function(err){if(err)return run();copy(config.contracts_build_directory,temporaryDirectory,function(err){if(err)return done(err);config.logger.log("Using network '"+config.network+"'."+OS.EOL);run()})})};if(config.networks[config.network]){Environment.detect(config,environmentCallback)}else{throw new Error("No development/test environment set in tronbox.js")}})})}};module.exports=command; | ||
"use strict";var command={command:"test",description:"Run JavaScript and Solidity tests",builder:{},run:function run(options,done){var OS=require("os");var dir=require("node-dir");var temp=require("temp");var Config=require("../../components/Config");var Artifactor=require("../../components/Artifactor");var Test=require("../test");var fs=require("fs");var copy=require("../copy");var Environment=require("../environment");var TronWrap=require("../../components/TronWrap");var logErrorAndExit=require("../../components/TronWrap").logErrorAndExit;var config=Config.detect(options);if(!config.network){if(config.networks.development)config.network="development";else if(config.networks.test)config.network="test"}if(!config.network){console.error("\nERROR: Neither development nor test network has been set in tronbox.js\n");return}try{TronWrap(config.networks[config.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}process.env.CURRENT="test";var ipcDisconnect;var files=[];if(options.file){files=[options.file]}else if(options._.length>0){Array.prototype.push.apply(files,options._)}function getFiles(callback){if(files.length!=0){return callback(null,files)}dir.files(config.test_directory,callback)};getFiles(function(err,files){if(err)return done(err);files=files.filter(function(file){return file.match(config.test_file_extension_regexp)!=null});temp.mkdir("test-",function(err,temporaryDirectory){if(err)return done(err);function cleanup(){var args=arguments;temp.cleanup(function(err){done.apply(null,args);if(ipcDisconnect){ipcDisconnect()}})};function run(){config.artifactor=new Artifactor(temporaryDirectory);Test.run(config["with"]({test_files:files,contracts_build_directory:temporaryDirectory}),cleanup)};var environmentCallback=function environmentCallback(err){if(err)return done(err);fs.stat(config.contracts_build_directory,function(err,stat){if(err)return run();copy(config.contracts_build_directory,temporaryDirectory,function(err){if(err)return done(err);config.logger.log("Using network '"+config.network+"'."+OS.EOL);run()})})};if(config.networks[config.network]){Environment.detect(config,environmentCallback)}else{throw new Error("No development/test environment set in tronbox.js")}})})}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";function normalizeURL(url){url=url||"https://github.com/llwslc/bare-box";if(url.indexOf("://")!==-1||url.indexOf("git@")!==-1){return url}if(url.split("/").length===2){return"https://github.com/"+url}if(url.indexOf("/")===-1){if(url.indexOf("-box")===-1){url=url+"-box"}return"https://github.com/llwslc/"+url}throw new Error("Box specified in invalid format")}function formatCommands(commands){var names=Object.keys(commands);var maxLength=Math.max.apply(null,names.map(function(name){return name.length}));return names.map(function(name){var spacing=Array(maxLength-name.length+1).join(" ");return" "+name+": "+spacing+commands[name]})}var command={command:"unbox",description:"Download a tronbox Box, a pre-built tronbox project",builder:{},run:function run(options,done){var Config=require("../../components/Config");var Box=require("../../components/Box");var OS=require("os");var config=Config["default"]()["with"]({logger:console});var url=normalizeURL(options._[0]);Box.unbox(url,options.working_directory||config.working_directory,{logger:config.logger}).then(function(boxConfig){config.logger.log("Unbox successful. Sweet!"+OS.EOL);var commandMessages=formatCommands(boxConfig.commands);if(commandMessages.length>0){config.logger.log("Commands:"+OS.EOL)}commandMessages.forEach(function(message){config.logger.log(message)});if(boxConfig.epilogue){config.logger.log(boxConfig.epilogue.replace("\n",OS.EOL))}done()})["catch"](done)}};module.exports=command; | ||
"use strict";function normalizeURL(url){url=url||"https://github.com/llwslc/bare-box";if(url.indexOf("://")!=-1||url.indexOf("git@")!=-1){return url}if(url.split("/").length==2){return"https://github.com/"+url}if(url.indexOf("/")==-1){if(url.indexOf("-box")==-1){url=url+"-box"}return"https://github.com/llwslc/"+url}throw new Error("Box specified in invalid format")}function formatCommands(commands){var names=Object.keys(commands);var maxLength=Math.max.apply(null,names.map(function(name){return name.length}));return names.map(function(name){var spacing=Array(maxLength-name.length+1).join(" ");return" "+name+": "+spacing+commands[name]})}var command={command:"unbox",description:"Download a tronbox Box, a pre-built tronbox project",builder:{},run:function run(options,done){var Config=require("../../components/Config");var Box=require("../../components/Box");var OS=require("os");var config=Config["default"]()["with"]({logger:console});var url=normalizeURL(options._[0]);Box.unbox(url,options.working_directory||config.working_directory,{logger:config.logger}).then(function(boxConfig){config.logger.log("Unbox successful. Sweet!"+OS.EOL);var commandMessages=formatCommands(boxConfig.commands);if(commandMessages.length>0){config.logger.log("Commands:"+OS.EOL)}commandMessages.forEach(function(message){config.logger.log(message)});if(boxConfig.epilogue){config.logger.log(boxConfig.epilogue.replace("\n",OS.EOL))}done()})["catch"](done)}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _require=require("../../components/TronSolc"),maxVersion=_require.maxVersion;var command={command:"version",description:"Show version number and exit",builder:{},run:function run(options,done){process.env.CURRENT="version";var version=require("../version");var bundle_version;if(version.bundle){bundle_version="v"+version.bundle}else{bundle_version="(unbundled)"}options.logger.log("Tronbox "+bundle_version);options.logger.log("Solidity v"+maxVersion+" (tron-solc)");done()}};module.exports=command; | ||
"use strict";var _require=require("../../components/TronSolc"),supportedVersions=_require.supportedVersions;var command={command:"version",description:"Show version number and exit",builder:{},run:function run(options,done){process.env.CURRENT="version";var version=require("../version");var bundle_version;if(version.bundle){bundle_version="v"+version.bundle}else{bundle_version="(unbundled)"}options.logger.log("Tronbox "+bundle_version);options.logger.log("Solidity v"+supportedVersions[supportedVersions.length-1]+" (tron-solc)");done()}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var command={command:"watch",description:"Watch filesystem for changes and rebuild the project automatically",builder:{},run:function run(options){process.env.CURRENT="watch";var Build=require("../build");var Config=require("../../components/Config");var chokidar=require("chokidar");var path=require("path");var colors=require("colors");var Contracts=require("../../components/WorkflowCompile");var TruffleError=require("@truffle/error");var config=Config.detect(options);var printSuccess=function printSuccess(){config.logger.log(colors.green("Completed without errors on "+new Date().toString()))};var printFailure=function printFailure(err){if(err instanceof TruffleError){console.error(err.message)}else{console.error(err.stack||err.toString())}};var working=false;var needs_rebuild=true;var needs_recompile=true;var watchPaths=[path.join(config.working_directory,"app/**/*"),path.join(config.contracts_build_directory,"/**/*"),path.join(config.contracts_directory,"/**/*"),path.join(config.working_directory,"sunbox-config.js"),path.join(config.working_directory,"sunbox.js")];chokidar.watch(watchPaths,{ignored:/[/\\]\./,cwd:config.working_directory,ignoreInitial:true}).on("all",function(event,filePath){var display_path=path.join("./",filePath.replace(config.working_directory,""));config.logger.log(colors.cyan(">> File "+display_path+" changed."));needs_rebuild=true;if(path.join(config.working_directory,filePath).indexOf(config.contracts_directory)>=0){needs_recompile=true}});var check_rebuild=function check_rebuild(){if(working){setTimeout(check_rebuild,200);return}if(needs_rebuild){needs_rebuild=false;if(config.build!=null){config.logger.log("Rebuilding...");working=true;Build.build(config,function(err){if(err){printFailure(err)}else{printSuccess()}working=false})}}else if(needs_recompile){needs_recompile=false;working=true;Contracts.compile(config,function(err){if(err){printFailure(err)}working=false})}setTimeout(check_rebuild,200)};check_rebuild()}};module.exports=command; | ||
"use strict";var command={command:"watch",description:"Watch filesystem for changes and rebuild the project automatically",builder:{},run:function run(options,done){process.env.CURRENT="watch";var Build=require("../build");var Config=require("../../components/Config");var chokidar=require("chokidar");var path=require("path");var colors=require("colors");var Contracts=require("../../components/WorkflowCompile");var TruffleError=require("@truffle/error");var config=Config.detect(options);var printSuccess=function printSuccess(){config.logger.log(colors.green("Completed without errors on "+new Date().toString()))};var printFailure=function printFailure(err){if(err instanceof TruffleError){console.log(err.message)}else{console.log(err.stack||err.toString())}};var working=false;var needs_rebuild=true;var needs_recompile=true;var watchPaths=[path.join(config.working_directory,"app/**/*"),path.join(config.contracts_build_directory,"/**/*"),path.join(config.contracts_directory,"/**/*"),path.join(config.working_directory,"sunbox-config.js"),path.join(config.working_directory,"sunbox.js")];chokidar.watch(watchPaths,{ignored:/[\/\\]\./,cwd:config.working_directory,ignoreInitial:true}).on("all",function(event,filePath){var display_path=path.join("./",filePath.replace(config.working_directory,""));config.logger.log(colors.cyan(">> File "+display_path+" changed."));needs_rebuild=true;if(path.join(config.working_directory,filePath).indexOf(config.contracts_directory)>=0){needs_recompile=true}});var check_rebuild=function check_rebuild(){if(working){setTimeout(check_rebuild,200);return}if(needs_rebuild==true){needs_rebuild=false;if(config.build!=null){config.logger.log("Rebuilding...");working=true;Build.build(config,function(err){if(err){printFailure(err)}else{printSuccess()}working=false})}}else if(needs_recompile==true){needs_recompile=false;working=true;Contracts.compile(config,function(err){if(err){printFailure(err)}working=false})}setTimeout(check_rebuild,200)};check_rebuild()}};module.exports=command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var ReplManager=require("./repl");var Command=require("./command");var provision=require("../components/Provisioner");var contract=require("../components/Contract");var TronWrap=require("../components/TronWrap");var vm=require("vm");var expect=require("@truffle/expect");var TruffleError=require("@truffle/error");var fs=require("fs");var path=require("path");var EventEmitter=require("events");var inherits=require("util").inherits;var logErrorAndExit=require("../components/TronWrap").logErrorAndExit;inherits(Console,EventEmitter);function Console(tasks,options){EventEmitter.call(this);var self=this;expect.options(options,["working_directory","contracts_directory","contracts_build_directory","migrations_directory","network","network_id","provider","resolver","build_directory"]);this.options=options;this.repl=options.repl||new ReplManager(options);this.command=new Command(tasks);if(!options.network&&options.networks.development){options.network="development"}try{this.tronWrap=TronWrap(options.networks[options.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}this.repl.on("exit",function(){self.emit("exit")})}Console.prototype.start=function(callback){var self=this;if(!this.repl){this.repl=new ReplManager(this.options)}this.options.repl=this.repl;this.provision(function(err,abstractions){if(err){self.options.logger.log("Unexpected error: Cannot provision contracts while instantiating the console.");self.options.logger.log(err.stack||err.message||err)}self.repl.start({prompt:"tronbox("+self.options.network+")> ",context:{tronWrap:self.tronWrap},interpreter:self.interpret.bind(self),done:callback});self.resetContractsInConsoleContext(abstractions)})};Console.prototype.provision=function(callback){var self=this;fs.readdir(this.options.contracts_build_directory,function(err,files){if(err){}var promises=[];files=files||[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){fs.readFile(path.join(self.options.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(new Error("Cannot parse "+file+": "+e.message))}accept(body)})}))});Promise.all(promises).then(function(json_blobs){var abstractions=json_blobs.map(function(json){var abstraction=contract(json);provision(abstraction,self.options);return abstraction});self.resetContractsInConsoleContext(abstractions);callback(null,abstractions)})["catch"](callback)})};Console.prototype.resetContractsInConsoleContext=function(abstractions){var self=this;abstractions=abstractions||[];var contextVars={};abstractions.forEach(function(abstraction){contextVars[abstraction.contract_name]=abstraction});self.repl.setContextVars(contextVars)};Console.prototype.interpret=function(cmd,context,filename,callback){var self=this;if(this.command.getCommand(cmd.trim(),this.options.noAliases)!=null){return self.command.run(cmd.trim(),this.options,function(err){if(err){if(err instanceof TruffleError){console.error(err.message)}else{console.error(err.stack||err.toString())}return callback()}self.provision(function(err){callback(err)})})}var result;try{result=vm.runInContext(cmd,context,{displayErrors:false})}catch(e){return callback(e)}Promise.resolve(result).then(function(res){callback(null,res)})["catch"](callback)};module.exports=Console; | ||
"use strict";var ReplManager=require("./repl");var Command=require("./command");var provision=require("../components/Provisioner");var contract=require("../components/Contract");var TronWrap=require("../components/TronWrap");var vm=require("vm");var expect=require("@truffle/expect");var _=require("lodash");var TruffleError=require("@truffle/error");var fs=require("fs");var os=require("os");var path=require("path");var EventEmitter=require("events");var inherits=require("util").inherits;var logErrorAndExit=require("../components/TronWrap").logErrorAndExit;inherits(Console,EventEmitter);function Console(tasks,options){EventEmitter.call(this);var self=this;expect.options(options,["working_directory","contracts_directory","contracts_build_directory","migrations_directory","network","network_id","provider","resolver","build_directory"]);this.options=options;this.repl=options.repl||new ReplManager(options);this.command=new Command(tasks);if(!options.network&&options.networks.development){options.network="development"}try{this.tronWrap=TronWrap(options.networks[options.network],{verify:true,log:options.log})}catch(err){logErrorAndExit(console,err.message)}this.repl.on("exit",function(){self.emit("exit")})};Console.prototype.start=function(callback){var self=this;if(!this.repl){this.repl=new Repl(this.options)}this.options.repl=this.repl;this.provision(function(err,abstractions){if(err){self.options.logger.log("Unexpected error: Cannot provision contracts while instantiating the console.");self.options.logger.log(err.stack||err.message||err)}self.repl.start({prompt:"tronbox("+self.options.network+")> ",context:{tronWrap:self.tronWrap},interpreter:self.interpret.bind(self),done:callback});self.resetContractsInConsoleContext(abstractions)})};Console.prototype.provision=function(callback){var self=this;fs.readdir(this.options.contracts_build_directory,function(err,files){if(err){}var promises=[];files=files||[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){fs.readFile(path.join(self.options.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(new Error("Cannot parse "+file+": "+e.message))}accept(body)})}))});Promise.all(promises).then(function(json_blobs){var abstractions=json_blobs.map(function(json){var abstraction=contract(json);provision(abstraction,self.options);return abstraction});self.resetContractsInConsoleContext(abstractions);callback(null,abstractions)})["catch"](callback)})};Console.prototype.resetContractsInConsoleContext=function(abstractions){var self=this;abstractions=abstractions||[];var contextVars={};abstractions.forEach(function(abstraction){contextVars[abstraction.contract_name]=abstraction});self.repl.setContextVars(contextVars)};Console.prototype.interpret=function(cmd,context,filename,callback){var self=this;if(this.command.getCommand(cmd.trim(),this.options.noAliases)!=null){return self.command.run(cmd.trim(),this.options,function(err){if(err){if(err instanceof TruffleError){console.log(err.message)}else{console.log(err.stack||err.toString())}return callback()}self.provision(function(err,abstractions){callback(err)})})}var result;try{result=vm.runInContext(cmd,context,{displayErrors:false})}catch(e){return callback(e)}Promise.resolve(result).then(function(res){callback(null,res)})["catch"](callback)};module.exports=Console; |
@@ -1,1 +0,1 @@ | ||
"use strict";var cpr=require("cpr");var fs=require("fs");var _=require("lodash");var cpr_options={deleteFirst:false,overwrite:false,confirm:true};var copy=function copy(from,to,extra_options,callback){if(typeof extra_options==="function"){callback=extra_options;extra_options={}}var options=_.merge(_.clone(cpr_options),extra_options);cpr(from,to,options,function(err,files){var new_files=[];files=files||[];var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=files[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var file=_step.value;if(file.match(/.*PLACEHOLDER.*/)!=null){fs.unlinkSync(file);continue}new_files.push(file)}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}callback(err,new_files)})};copy.file=function(from,to,callback){var readStream=fs.createReadStream(from,"utf8");var writeStream=fs.createWriteStream(to,"utf8");readStream.on("error",function(err){callback(err);callback=function callback(){}});writeStream.on("error",function(err){callback(err);callback=function callback(){}});writeStream.on("finish",function(){callback()});readStream.pipe(writeStream)};module.exports=copy; | ||
"use strict";var cpr=require("cpr");var fs=require("fs");var _=require("lodash");var cpr_options={deleteFirst:false,overwrite:false,confirm:true};var copy=function copy(from,to,extra_options,callback){if(typeof extra_options=="function"){callback=extra_options;extra_options={}}var options=_.merge(_.clone(cpr_options),extra_options);cpr(from,to,options,function(err,files){var new_files=[];files=files||[];var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=files[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var file=_step.value;if(file.match(/.*PLACEHOLDER.*/)!=null){fs.unlinkSync(file);continue}new_files.push(file)}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}callback(err,new_files)})};copy.file=function(from,to,callback){var readStream=fs.createReadStream(from,"utf8");var writeStream=fs.createWriteStream(to,"utf8");readStream.on("error",function(err){callback(err);callback=function callback(){}});writeStream.on("error",function(err){callback(err);callback=function callback(){}});writeStream.on("finish",function(){callback()});readStream.pipe(writeStream)};module.exports=copy; |
@@ -1,1 +0,1 @@ | ||
"use strict";var TruffleError=require("@truffle/error");var expect=require("@truffle/expect");var Resolver=require("../components/Resolver");var Artifactor=require("../components/Artifactor");var TronWrap=require("../components/TronWrap");var Environment={detect:function detect(config,callback){expect.options(config,["networks"]);if(!config.resolver){config.resolver=new Resolver(config)}if(!config.artifactor){config.artifactor=new Artifactor(config.contracts_build_directory)}if(!config.network&&config.networks["development"]){config.network="development"}if(!config.network){return callback(new Error("No network specified. Cannot determine current network."))}var network_config=config.networks[config.network];if(!network_config){return callback(new TruffleError("Unknown network \""+config.network+"\". See your tronbox configuration file for available networks."))}var network_id=config.networks[config.network].network_id;if(!network_id){return callback(new Error("You must specify a network_id in your '"+config.network+"' configuration in order to use this network."))}var tronWrap=TronWrap();function detectNetworkId(done){if(network_id!=="*"){return done(null,network_id)}network_id="*";config.networks[config.network].network_id=network_id;done(null,network_id)}function detectFromAddress(done){if(config.from){return done()}tronWrap._getAccounts(function(err,accounts){if(err)return done(err);config.networks[config.network].from=accounts[0];config.networks[config.network].privateKey=tronWrap._privateKeyByAccount[accounts[0]];done()})}detectNetworkId(function(err){if(err)return callback(err);detectFromAddress(callback)})},fork:function fork(config,callback){expect.options(config,["from"]);var forkedNetwork=config.network+"-fork";config.networks[forkedNetwork]={network_id:config.network_id,provider:undefined,from:config.from};config.network=forkedNetwork;callback()},develop:function develop(config,testrpcOptions,callback){expect.options(config,["networks"]);var network=config.network||"develop";config.networks[network]={network_id:testrpcOptions.network_id,provider:""};config.network=network;Environment.detect(config,callback)}};module.exports=Environment; | ||
"use strict";var TruffleError=require("@truffle/error");var expect=require("@truffle/expect");var Resolver=require("../components/Resolver");var Artifactor=require("../components/Artifactor");var spawn=require("child_process").spawn;var path=require("path");var TronWrap=require("../components/TronWrap");var Environment={detect:function detect(config,callback){expect.options(config,["networks"]);if(!config.resolver){config.resolver=new Resolver(config)}if(!config.artifactor){config.artifactor=new Artifactor(config.contracts_build_directory)}if(!config.network&&config.networks["development"]){config.network="development"}if(!config.network){return callback(new Error("No network specified. Cannot determine current network."))}var network_config=config.networks[config.network];if(!network_config){return callback(new TruffleError("Unknown network \""+config.network+"\". See your tronbox configuration file for available networks."))}var network_id=config.networks[config.network].network_id;if(network_id==null){return callback(new Error("You must specify a network_id in your '"+config.network+"' configuration in order to use this network."))}var tronWrap=TronWrap();function detectNetworkId(done){if(network_id!="*"){return done(null,network_id)}network_id="*";config.networks[config.network].network_id=network_id;done(null,network_id)}function detectFromAddress(done){if(config.from){return done()}tronWrap._getAccounts(function(err,accounts){if(err)return done(err);config.networks[config.network].from=accounts[0];config.networks[config.network].privateKey=tronWrap._privateKeyByAccount[accounts[0]];done()})}detectNetworkId(function(err){if(err)return callback(err);detectFromAddress(callback)})},fork:function fork(config,callback){expect.options(config,["from"]);var upstreamNetwork=config.network;var upstreamConfig=config.networks[upstreamNetwork];var forkedNetwork=config.network+"-fork";config.networks[forkedNetwork]={network_id:config.network_id,provider:undefined,from:config.from};config.network=forkedNetwork;callback()},develop:function develop(config,testrpcOptions,callback){var self=this;expect.options(config,["networks"]);var network=config.network||"develop";var url="http://".concat(testrpcOptions.host,":").concat(testrpcOptions.port,"/");config.networks[network]={network_id:testrpcOptions.network_id,provider:""};config.network=network;Environment.detect(config,callback)}};module.exports=Environment; |
@@ -1,1 +0,1 @@ | ||
"use strict";var TruffleError=require("@truffle/error");var inherits=require("util").inherits;inherits(TaskError,TruffleError);function TaskError(message){TaskError.super_.call(this,message)}module.exports=TaskError; | ||
"use strict";var TruffleError=require("@truffle/error");var inherits=require("util").inherits;inherits(TaskError,TruffleError);function TaskError(message){TaskError.super_.call(this,message)};module.exports=TaskError; |
@@ -1,1 +0,1 @@ | ||
"use strict";var fs=require("fs");var path=require("path");var OS=require("os");var BlockchainUtils=require("truffle-blockchain-utils");var Provider=require("../components/Provider");var async=require("async");var Networks={deployed:function deployed(options,callback){fs.readdir(options.contracts_build_directory,function(err,files){if(err){files=[]}var promises=[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){fs.readFile(path.join(options.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(e)}accept(body)})}))});Promise.all(promises).then(function(binaries){var ids_to_names={};var networks={};Object.keys(options.networks).forEach(function(network_name){var network=options.networks[network_name];var network_id=network.network_id;if(!network_id){return}ids_to_names[network_id]=network_name;networks[network_name]={}});binaries.forEach(function(json){Object.keys(json.networks).forEach(function(network_id){var network_name=ids_to_names[network_id]||network_id;if(!networks[network_name]){networks[network_name]={}}var address=json.networks[network_id].address;if(!address)return;networks[network_name][json.contractName]=address})});callback(null,networks)})["catch"](callback)})},display:function display(config,callback){this.deployed(config,function(err,networks){if(err)return callback(err);var network_names=Object.keys(networks).sort();var star_networks=network_names.filter(function(network_name){return config.networks[network_name]!=null&&config.networks[network_name].network_id==="*"});network_names=network_names.filter(function(network_name){return star_networks.indexOf(network_name)<0});var unknown_networks=network_names.filter(function(network_name){var configured_networks=Object.keys(config.networks);var found=false;for(var i=0;i<configured_networks.length;i++){var configured_network_name=configured_networks[i];if(network_name===configured_network_name){found=true;break}}return!found});if(star_networks.length>0&&network_names.length>0&&unknown_networks.length>0){config.logger.log(OS.EOL+"The following networks are configured to match any network id ('*'):"+OS.EOL);star_networks.forEach(function(network_name){config.logger.log(" "+network_name)});config.logger.log(OS.EOL+"Closely inspect the deployed networks below, and use `tronbox networks --clean` to remove any networks that don't match your configuration. You should not use the wildcard configuration ('*') for staging and production networks for which you intend to deploy your application.")}network_names.forEach(function(network_name){config.logger.log("");var output=Object.keys(networks[network_name]).sort().map(function(contract_name){var address=networks[network_name][contract_name];return contract_name+": "+address});if(output.length===0){output=["No contracts deployed."]}var message="Network: ";var is_id=config.networks[network_name]==null;if(is_id){message+="UNKNOWN (id: "+network_name+")"}else{message+=network_name+" (id: "+config.networks[network_name].network_id+")"}config.logger.log(message);config.logger.log(" "+output.join("\n "))});if(network_names.length===0){config.logger.log(OS.EOL+"Contracts have not been deployed to any network.")}config.logger.log("");callback()})},clean:function clean(config,callback){fs.readdir(config.contracts_build_directory,function(err,files){if(err)return callback(err);var configured_networks=Object.keys(config.networks);var promises=[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){var file_path=path.join(config.contracts_build_directory,file);fs.readFile(file_path,"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(e)}Object.keys(body.networks).forEach(function(installed_network_id){var found=false;for(var i=0;i<configured_networks.length;i++){var configured_network=configured_networks[i];if(installed_network_id===config.networks[configured_network].network_id){found=true;break}}if(!found){delete body.networks[installed_network_id]}});fs.writeFile(file_path,JSON.stringify(body,null,2),"utf8",function(err){if(err)return reject(err);accept(body)})})}))});Promise.all(promises).then(function(){callback()})["catch"](callback)})},asURIs:function asURIs(options,networks,callback){if(typeof networks==="function"){callback=networks;networks=Object.keys(options.networks)}var result={uris:{},failed:[]};async.each(networks,function(network_name,finished){var provider=Provider.create(options.networks[network_name]);BlockchainUtils.asURI(provider,function(err,uri){if(err){result.failed.push(network_name)}else{result.uris[network_name]=uri}finished()})},function(err){if(err)return callback(err);callback(null,result)})},matchesNetwork:function matchesNetwork(network_id,network_options,callback){var first=network_id+"";var second=network_options.network_id+"";if(first===second){return callback(null,true)}var isFirstANumber=isNaN(parseInt(network_id))===false;var isSecondANumber=isNaN(parseInt(network_options.network_id))===false;if(isFirstANumber&&isSecondANumber){return callback(null,false)}}};module.exports=Networks; | ||
"use strict";var fs=require("fs");var path=require("path");var OS=require("os");var BlockchainUtils=require("truffle-blockchain-utils");var Provider=require("../components/Provider");var async=require("async");var Networks={deployed:function deployed(options,callback){fs.readdir(options.contracts_build_directory,function(err,files){if(err){files=[]}var promises=[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){fs.readFile(path.join(options.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(e)}accept(body)})}))});Promise.all(promises).then(function(binaries){var ids_to_names={};var networks={};Object.keys(options.networks).forEach(function(network_name){var network=options.networks[network_name];var network_id=network.network_id;if(network_id==null){return}ids_to_names[network_id]=network_name;networks[network_name]={}});binaries.forEach(function(json){Object.keys(json.networks).forEach(function(network_id){var network_name=ids_to_names[network_id]||network_id;if(networks[network_name]==null){networks[network_name]={}}var address=json.networks[network_id].address;if(address==null)return;networks[network_name][json.contractName]=address})});callback(null,networks)})["catch"](callback)})},display:function display(config,callback){this.deployed(config,function(err,networks){if(err)return callback(err);var network_names=Object.keys(networks).sort();var star_networks=network_names.filter(function(network_name){return config.networks[network_name]!=null&&config.networks[network_name].network_id=="*"});network_names=network_names.filter(function(network_name){return star_networks.indexOf(network_name)<0});var unknown_networks=network_names.filter(function(network_name){var configured_networks=Object.keys(config.networks);var found=false;for(var i=0;i<configured_networks.length;i++){var configured_network_name=configured_networks[i];if(network_name==configured_network_name){found=true;break}}return!found});if(star_networks.length>0&&network_names.length>0&&unknown_networks.length>0){config.logger.log(OS.EOL+"The following networks are configured to match any network id ('*'):"+OS.EOL);star_networks.forEach(function(network_name){config.logger.log(" "+network_name)});config.logger.log(OS.EOL+"Closely inspect the deployed networks below, and use `tronbox networks --clean` to remove any networks that don't match your configuration. You should not use the wildcard configuration ('*') for staging and production networks for which you intend to deploy your application.")}network_names.forEach(function(network_name){config.logger.log("");var output=Object.keys(networks[network_name]).sort().map(function(contract_name){var address=networks[network_name][contract_name];return contract_name+": "+address});if(output.length==0){output=["No contracts deployed."]}var message="Network: ";var is_id=config.networks[network_name]==null;if(is_id){message+="UNKNOWN (id: "+network_name+")"}else{message+=network_name+" (id: "+config.networks[network_name].network_id+")"}config.logger.log(message);config.logger.log(" "+output.join("\n "))});if(network_names.length==0){config.logger.log(OS.EOL+"Contracts have not been deployed to any network.")}config.logger.log("");callback()})},clean:function clean(config,callback){fs.readdir(config.contracts_build_directory,function(err,files){if(err)return callback(err);var configured_networks=Object.keys(config.networks);var promises=[];files.forEach(function(file){promises.push(new Promise(function(accept,reject){var file_path=path.join(config.contracts_build_directory,file);fs.readFile(file_path,"utf8",function(err,body){if(err)return reject(err);try{body=JSON.parse(body)}catch(e){return reject(e)}Object.keys(body.networks).forEach(function(installed_network_id){var found=false;for(var i=0;i<configured_networks.length;i++){var configured_network=configured_networks[i];if(installed_network_id==config.networks[configured_network].network_id){found=true;break}}if(found==false){delete body.networks[installed_network_id]}});fs.writeFile(file_path,JSON.stringify(body,null,2),"utf8",function(err){if(err)return reject(err);accept(body)})})}))});Promise.all(promises).then(function(){callback()})["catch"](callback)})},asURIs:function asURIs(options,networks,callback){if(typeof networks=="function"){callback=networks;networks=Object.keys(options.networks)}var result={uris:{},failed:[]};async.each(networks,function(network_name,finished){var provider=Provider.create(options.networks[network_name]);BlockchainUtils.asURI(provider,function(err,uri){if(err){result.failed.push(network_name)}else{result.uris[network_name]=uri}finished()})},function(err){if(err)return callback(err);callback(null,result)})},matchesNetwork:function matchesNetwork(network_id,network_options,callback){var provider=Provider.create(network_options);var first=network_id+"";var second=network_options.network_id+"";if(first==second){return callback(null,true)}var isFirstANumber=isNaN(parseInt(network_id))===false;var isSecondANumber=isNaN(parseInt(network_options.network_id))===false;if(isFirstANumber&&isSecondANumber){return callback(null,false)}}};module.exports=Networks; |
@@ -1,1 +0,1 @@ | ||
"use strict";var repl=require("repl");var expect=require("@truffle/expect");var async=require("async");var EventEmitter=require("events");var inherits=require("util").inherits;var TronWrap=require("../components/TronWrap");inherits(ReplManager,EventEmitter);function ReplManager(options){EventEmitter.call(this);expect.options(options,["working_directory","contracts_directory","contracts_build_directory","migrations_directory","network","network_id","provider","resolver","build_directory"]);this.options=options;this.repl=options.repl;this.contexts=[]}ReplManager.prototype.start=function(options){var self=this;global.tronWeb=TronWrap();this.contexts.push({prompt:options.prompt,interpreter:options.interpreter,done:options.done});var currentContext=this.contexts[this.contexts.length-1];if(!this.repl){this.repl=repl.start({prompt:currentContext.prompt,eval:this.interpret.bind(this)});this.repl.on("exit",function(){var doneFunctions=self.contexts.map(function(context){return context.done?function(){context.done()}:function(){}});async.series(doneFunctions,function(){process.exit()})})}this.repl.on("exit",function(){self.emit("exit")});this.repl.setPrompt(options.prompt);this.setContextVars(options.context||{})};ReplManager.prototype.setContextVars=function(obj){var self=this;if(this.repl){Object.keys(obj).forEach(function(key){self.repl.context[key]=obj[key]})}};ReplManager.prototype.stop=function(callback){var oldContext=this.contexts.pop();if(oldContext.done){oldContext.done()}var currentContext=this.contexts[this.contexts.length-1];if(currentContext){this.repl.setPrompt(currentContext.prompt)}else{process.exit()}if(callback){callback()}};ReplManager.prototype.interpret=function(cmd,context,filename,callback){var currentContext=this.contexts[this.contexts.length-1];currentContext.interpreter(cmd,context,filename,callback)};module.exports=ReplManager; | ||
"use strict";var repl=require("repl");var Command=require("./command");var provision=require("../components/Provisioner");var contract=require("../components/Contract");var vm=require("vm");var expect=require("@truffle/expect");var _=require("lodash");var TruffleError=require("@truffle/error");var fs=require("fs");var os=require("os");var path=require("path");var async=require("async");var EventEmitter=require("events");var inherits=require("util").inherits;var TronWrap=require("../components/TronWrap");inherits(ReplManager,EventEmitter);function ReplManager(options){EventEmitter.call(this);expect.options(options,["working_directory","contracts_directory","contracts_build_directory","migrations_directory","network","network_id","provider","resolver","build_directory"]);this.options=options;this.repl=options.repl;this.contexts=[]};ReplManager.prototype.start=function(options){var self=this;global.tronWeb=TronWrap();this.contexts.push({prompt:options.prompt,interpreter:options.interpreter,done:options.done});var currentContext=this.contexts[this.contexts.length-1];if(!this.repl){this.repl=repl.start({prompt:currentContext.prompt,eval:this.interpret.bind(this)});this.repl.on("exit",function(){var doneFunctions=self.contexts.map(function(context){return context.done?function(){context.done()}:function(){}});async.series(doneFunctions,function(err){process.exit()})})}this.repl.on("exit",function(){self.emit("exit")});this.repl.setPrompt(options.prompt);this.setContextVars(options.context||{})};ReplManager.prototype.setContextVars=function(obj){var self=this;if(this.repl){Object.keys(obj).forEach(function(key){self.repl.context[key]=obj[key]})}};ReplManager.prototype.stop=function(callback){var oldContext=this.contexts.pop();if(oldContext.done){oldContext.done()}var currentContext=this.contexts[this.contexts.length-1];if(currentContext){this.repl.setPrompt(currentContext.prompt)}else{process.exit()}if(callback){callback()}};ReplManager.prototype.interpret=function(cmd,context,filename,callback){var currentContext=this.contexts[this.contexts.length-1];currentContext.interpreter(cmd,context,filename,callback)};module.exports=ReplManager; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Mocha=require("mocha");var chai=require("chai");var path=require("path");var Config=require("../components/Config");var Contracts=require("../components/WorkflowCompile");var Resolver=require("../components/Resolver");var TestRunner=require("./testing/testrunner");var TestResolver=require("./testing/testresolver");var TestSource=require("./testing/testsource");var expect=require("@truffle/expect");var Migrate=require("../components/Migrate");var Profiler=require("../components/Compile/profiler");var originalrequire=require("original-require");var TronWrap=require("../components/TronWrap");chai.use(require("./assertions"));var Test={run:function run(options,callback){var self=this;expect.options(options,["contracts_directory","contracts_build_directory","migrations_directory","test_files","network","network_id","provider"]);var config=Config["default"]().merge(options);config.test_files=config.test_files.map(function(test_file){return path.resolve(test_file)});var warn=config.logger.warn;config.logger.warn=function(message){if(message!=="cannot find event for log"&&warn){warn.apply(console,arguments)}};var mocha=this.createMocha(config);var js_tests=config.test_files.filter(function(file){return path.extname(file)!==".sol"});var sol_tests=config.test_files.filter(function(file){return path.extname(file)===".sol"});js_tests.forEach(function(file){delete originalrequire.cache[file];mocha.addFile(file)});var accounts=[];var runner;var test_resolver;var tronWrap=TronWrap();tronWrap._getAccounts().then(function(accs){accounts=accs;if(!config.from){config.from=accounts[0]}if(!config.resolver){config.resolver=new Resolver(config)}var test_source=new TestSource(config);test_resolver=new TestResolver(config.resolver,test_source,config.contracts_build_directory);test_resolver.cache_on=false;return self.compileContractsWithTestFilesIfNeeded(sol_tests,config,test_resolver)}).then(function(){runner=new TestRunner(config);console.info("Deploying contracts to development network...");return self.performInitialDeploy(config,test_resolver)}).then(function(){console.info("Preparing Javascript tests (if any)...");return self.setJSTestGlobals(accounts,test_resolver,runner)}).then(function(){process.on("unhandledRejection",function(reason){throw reason});mocha.run(function(failures){config.logger.warn=warn;callback(failures)})})["catch"](callback)},createMocha:function createMocha(config){var mochaConfig=config.mocha||{};if(config.colors!=null){mochaConfig.useColors=config.colors}if(!mochaConfig.useColors){mochaConfig.useColors=true}var mocha=new Mocha(mochaConfig);return mocha},compileContractsWithTestFilesIfNeeded:function compileContractsWithTestFilesIfNeeded(solidity_test_files,config,test_resolver){return new Promise(function(accept,reject){Profiler.updated(config["with"]({resolver:test_resolver}),function(err,updated){if(err)return reject(err);updated=updated||[];Contracts.compile(config["with"]({all:config.compileAll===true,files:updated.concat(solidity_test_files),resolver:test_resolver,quiet:false,quietWrite:true}),function(err,abstractions,paths){if(err)return reject(err);accept(paths)})})})},performInitialDeploy:function performInitialDeploy(config,resolver){return new Promise(function(accept,reject){Migrate.run(config["with"]({reset:true,resolver:resolver,quiet:true}),function(err){if(err)return reject(err);accept()})})},setJSTestGlobals:function setJSTestGlobals(accounts,test_resolver,runner){return new Promise(function(accept){global.assert=chai.assert;global.expect=chai.expect;global.artifacts={require:function require(import_path){return test_resolver.require(import_path)}};var template=function template(tests){this.timeout(runner.TEST_TIMEOUT);before("prepare suite",function(done){this.timeout(runner.BEFORE_TIMEOUT);runner.initialize(done)});beforeEach("before test",function(done){runner.startTest(this,done)});afterEach("after test",function(done){runner.endTest(this,done)});tests(accounts)};global.contract=function(name,tests){Mocha.describe("Contract: "+name,function(){template.bind(this,tests)()})};global.contract.only=function(name,tests){Mocha.describe.only("Contract: "+name,function(){template.bind(this,tests)()})};global.contract.skip=function(name,tests){Mocha.describe.skip("Contract: "+name,function(){template.bind(this,tests)()})};accept()})}};module.exports=Test; | ||
"use strict";var Mocha=require("mocha");var chai=require("chai");var path=require("path");var fs=require("fs");var Config=require("../components/Config");var Contracts=require("../components/WorkflowCompile");var Resolver=require("../components/Resolver");var TestRunner=require("./testing/testrunner");var TestResolver=require("./testing/testresolver");var TestSource=require("./testing/testsource");var expect=require("@truffle/expect");var find_contracts=require("@truffle/contract-sources");var Migrate=require("../components/Migrate");var Profiler=require("../components/Compile/profiler");var async=require("async");var originalrequire=require("original-require");var TronWrap=require("../components/TronWrap");chai.use(require("./assertions"));var Test={run:function run(options,callback){var self=this;expect.options(options,["contracts_directory","contracts_build_directory","migrations_directory","test_files","network","network_id","provider"]);var config=Config["default"]().merge(options);config.test_files=config.test_files.map(function(test_file){return path.resolve(test_file)});var warn=config.logger.warn;config.logger.warn=function(message){if(message!=="cannot find event for log"&&warn){warn.apply(console,arguments)}};var mocha=this.createMocha(config);var js_tests=config.test_files.filter(function(file){return path.extname(file)!==".sol"});var sol_tests=config.test_files.filter(function(file){return path.extname(file)===".sol"});js_tests.forEach(function(file){delete originalrequire.cache[file];mocha.addFile(file)});var dependency_paths=[];var testContracts=[];var accounts=[];var runner;var test_resolver;var tronWrap=TronWrap();tronWrap._getAccounts().then(function(accs){accounts=accs;if(!config.from){config.from=accounts[0]}if(!config.resolver){config.resolver=new Resolver(config)}var test_source=new TestSource(config);test_resolver=new TestResolver(config.resolver,test_source,config.contracts_build_directory);test_resolver.cache_on=false;return self.compileContractsWithTestFilesIfNeeded(sol_tests,config,test_resolver)}).then(function(paths){dependency_paths=paths;testContracts=sol_tests.map(function(test_file_path){var built_name="./"+path.basename(test_file_path);return test_resolver.require(built_name)});runner=new TestRunner(config);console.log("Deploying contracts to development network...");return self.performInitialDeploy(config,test_resolver)}).then(function(){console.log("Preparing Javascript tests (if any)...");return self.setJSTestGlobals(accounts,test_resolver,runner)}).then(function(){process.on("unhandledRejection",function(reason,p){throw reason});mocha.run(function(failures){config.logger.warn=warn;callback(failures)})})["catch"](callback)},createMocha:function createMocha(config){var mochaConfig=config.mocha||{};if(config.colors!=null){mochaConfig.useColors=config.colors}if(mochaConfig.useColors==null){mochaConfig.useColors=true}var mocha=new Mocha(mochaConfig);return mocha},compileContractsWithTestFilesIfNeeded:function compileContractsWithTestFilesIfNeeded(solidity_test_files,config,test_resolver){return new Promise(function(accept,reject){Profiler.updated(config["with"]({resolver:test_resolver}),function(err,updated){if(err)return reject(err);updated=updated||[];Contracts.compile(config["with"]({all:config.compileAll===true,files:updated.concat(solidity_test_files),resolver:test_resolver,quiet:false,quietWrite:true}),function(err,abstractions,paths){if(err)return reject(err);accept(paths)})})})},performInitialDeploy:function performInitialDeploy(config,resolver){return new Promise(function(accept,reject){Migrate.run(config["with"]({reset:true,resolver:resolver,quiet:true}),function(err){if(err)return reject(err);accept()})})},setJSTestGlobals:function setJSTestGlobals(accounts,test_resolver,runner){return new Promise(function(accept,reject){global.assert=chai.assert;global.expect=chai.expect;global.artifacts={require:function require(import_path){return test_resolver.require(import_path)}};var template=function template(tests){this.timeout(runner.TEST_TIMEOUT);before("prepare suite",function(done){this.timeout(runner.BEFORE_TIMEOUT);runner.initialize(done)});beforeEach("before test",function(done){runner.startTest(this,done)});afterEach("after test",function(done){runner.endTest(this,done)});tests(accounts)};global.contract=function(name,tests){Mocha.describe("Contract: "+name,function(){template.bind(this,tests)()})};global.contract.only=function(name,tests){Mocha.describe.only("Contract: "+name,function(){template.bind(this,tests)()})};global.contract.skip=function(name,tests){Mocha.describe.skip("Contract: "+name,function(){template.bind(this,tests)()})};accept()})}};module.exports=Test; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Config=require("../../components/Config");var Migrate=require("../../components/Migrate");var TestResolver=require("./testresolver");var TestSource=require("./testsource");var expect=require("@truffle/expect");var contract=require("../../components/Contract");var path=require("path");var _=require("lodash");var async=require("async");var fs=require("fs");var TronWrap=require("../../components/TronWrap");var TronWeb=require("tronweb");var waitForTransactionReceipt=require("./waitForTransactionReceipt");function TestRunner(options){options=options||{};expect.options(options,["resolver","provider","contracts_build_directory"]);this.config=Config["default"]().merge(options);this.logger=options.logger||console;this.initial_resolver=options.resolver;this.provider=options.provider;this.can_snapshot=false;this.first_snapshot=false;this.initial_snapshot=null;this.known_events={};this.tronwrap=TronWrap();global.tronWeb=new TronWeb(this.tronwrap.fullNode,this.tronwrap.solidityNode,this.tronwrap.eventServer,this.tronwrap.defaultPrivateKey);global.waitForTransactionReceipt=waitForTransactionReceipt(tronWeb);this.currentTestStartBlock=null;this.BEFORE_TIMEOUT=120000;this.TEST_TIMEOUT=300000}TestRunner.prototype.initialize=function(callback){var self=this;var test_source=new TestSource(self.config);this.config.resolver=new TestResolver(self.initial_resolver,test_source,self.config.contracts_build_directory);var afterStateReset=function afterStateReset(err){if(err)return callback(err);fs.readdir(self.config.contracts_build_directory,function(err,files){if(err)return callback(err);files=_.filter(files,function(file){return path.extname(file)===".json"});async.map(files,function(file,finished){fs.readFile(path.join(self.config.contracts_build_directory,file),"utf8",finished)},function(err,data){if(err)return callback(err);var contracts=data.map(JSON.parse).map(contract);var abis=_.flatMap(contracts,"abi");abis.map(function(abi){if(/event/i.test(abi.type)){var signature=abi.name+"("+_.map(abi.inputs,"type").join(",")+")";self.known_events[self.tronwrap.sha3(signature)]={signature:signature,abi_entry:abi}}});callback()})})};afterStateReset()};TestRunner.prototype.deploy=function(callback){Migrate.run(this.config["with"]({reset:true,quiet:true}),callback)};TestRunner.prototype.resetState=function(callback){this.deploy(callback)};TestRunner.prototype.startTest=function(mocha,callback){callback()};TestRunner.prototype.endTest=function(mocha,callback){if(mocha.currentTest.state!=="failed"){return callback()}callback()};TestRunner.prototype.snapshot=function(callback){this.rpc("evm_snapshot",function(err,result){if(err)return callback(err);callback(null,result.result)})},TestRunner.prototype.revert=function(snapshot_id,callback){this.rpc("evm_revert",[snapshot_id],callback)};TestRunner.prototype.rpc=function(method,arg,cb){var req={jsonrpc:"2.0",method:method,id:new Date().getTime()};if(arguments.length===3){req.params=arg}else{cb=arg}var intermediary=function intermediary(err,result){if(err!=null){cb(err);return}if(result.error!=null){cb(new Error("RPC Error: "+(result.error.message||result.error)));return}cb(null,result)};this.provider.sendAsync(req,intermediary)};module.exports=TestRunner; | ||
"use strict";var Config=require("../../components/Config");var Migrate=require("../../components/Migrate");var TestResolver=require("./testresolver");var TestSource=require("./testsource");var expect=require("@truffle/expect");var contract=require("../../components/Contract");var path=require("path");var _=require("lodash");var async=require("async");var fs=require("fs");var TronWrap=require("../../components/TronWrap");var TronWeb=require("tronweb");var waitForTransactionReceipt=require("./waitForTransactionReceipt");function TestRunner(options){options=options||{};expect.options(options,["resolver","provider","contracts_build_directory"]);this.config=Config["default"]().merge(options);this.logger=options.logger||console;this.initial_resolver=options.resolver;this.provider=options.provider;this.can_snapshot=false;this.first_snapshot=false;this.initial_snapshot=null;this.known_events={};this.tronwrap=TronWrap();global.tronWeb=new TronWeb(this.tronwrap.fullNode,this.tronwrap.solidityNode,this.tronwrap.eventServer,this.tronwrap.defaultPrivateKey);global.waitForTransactionReceipt=waitForTransactionReceipt(tronWeb);this.currentTestStartBlock=null;this.BEFORE_TIMEOUT=120000;this.TEST_TIMEOUT=300000};TestRunner.prototype.initialize=function(callback){var self=this;var test_source=new TestSource(self.config);this.config.resolver=new TestResolver(self.initial_resolver,test_source,self.config.contracts_build_directory);var afterStateReset=function afterStateReset(err){if(err)return callback(err);fs.readdir(self.config.contracts_build_directory,function(err,files){if(err)return callback(err);files=_.filter(files,function(file){return path.extname(file)===".json"});async.map(files,function(file,finished){fs.readFile(path.join(self.config.contracts_build_directory,file),"utf8",finished)},function(err,data){if(err)return callback(err);var contracts=data.map(JSON.parse).map(contract);var abis=_.flatMap(contracts,"abi");abis.map(function(abi){if(/event/i.test(abi.type)){var signature=abi.name+"("+_.map(abi.inputs,"type").join(",")+")";self.known_events[self.tronwrap.sha3(signature)]={signature:signature,abi_entry:abi}}});callback()})})};afterStateReset()};TestRunner.prototype.deploy=function(callback){Migrate.run(this.config["with"]({reset:true,quiet:true}),callback)};TestRunner.prototype.resetState=function(callback){var self=this;this.deploy(callback)};TestRunner.prototype.startTest=function(mocha,callback){var self=this;callback()};TestRunner.prototype.endTest=function(mocha,callback){var self=this;if(mocha.currentTest.state!="failed"){return callback()}callback()};TestRunner.prototype.snapshot=function(callback){this.rpc("evm_snapshot",function(err,result){if(err)return callback(err);callback(null,result.result)})},TestRunner.prototype.revert=function(snapshot_id,callback){this.rpc("evm_revert",[snapshot_id],callback)};TestRunner.prototype.rpc=function(method,arg,cb){var req={jsonrpc:"2.0",method:method,id:new Date().getTime()};if(arguments.length==3){req.params=arg}else{cb=arg}var intermediary=function intermediary(err,result){if(err!=null){cb(err);return}if(result.error!=null){cb(new Error("RPC Error: "+(result.error.message||result.error)));return}cb(null,result)};this.provider.sendAsync(req,intermediary)};module.exports=TestRunner; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Deployed=require("./deployed");var path=require("path");var fs=require("fs");var contract=require("../../components/Contract");var find_contracts=require("@truffle/contract-sources");function TestSource(config){this.config=config}TestSource.prototype.require=function(){return null};TestSource.prototype.resolve=function(import_path,callback){var self=this;if(import_path==="truffle/DeployedAddresses.sol"){return find_contracts(this.config.contracts_directory,function(err,source_files){fs.readdir(self.config.contracts_build_directory,function(err,abstraction_files){if(err)return callback(err);var mapping={};var blacklist=["Assert","DeployedAddresses"];source_files.forEach(function(file){var name=path.basename(file,".sol");if(blacklist.indexOf(name)>=0)return;mapping[name]=false});abstraction_files.forEach(function(file){var name=path.basename(file,".json");if(blacklist.indexOf(name)>=0)return;mapping[name]=false});var promises=abstraction_files.map(function(file){return new Promise(function(accept,reject){fs.readFile(path.join(self.config.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);accept(body)})})});Promise.all(promises).then(function(files_data){var addresses=files_data.map(function(data){return JSON.parse(data)}).map(function(json){return contract(json)}).map(function(c){c.setNetwork(self.config.network_id);if(c.isDeployed()){return c.address}return null});addresses.forEach(function(address,i){var name=path.basename(abstraction_files[i],".json");if(blacklist.indexOf(name)>=0)return;mapping[name]=address});return Deployed.makeSolidityDeployedAddressesLibrary(mapping)}).then(function(addressSource){callback(null,addressSource,import_path)})["catch"](callback)})})}if(import_path==="truffle/Assert.sol"){return fs.readFile(path.resolve(path.join(__dirname,"Assert.sol")),{encoding:"utf8"},function(err,body){callback(err,body,import_path)})}return callback()};TestSource.prototype.resolve_dependency_path=function(import_path,dependency_path){return dependency_path};module.exports=TestSource; | ||
"use strict";var Deployed=require("./deployed");var path=require("path");var fs=require("fs");var contract=require("../../components/Contract");var find_contracts=require("@truffle/contract-sources");function TestSource(config){this.config=config};TestSource.prototype.require=function(import_path){return null};TestSource.prototype.resolve=function(import_path,callback){var self=this;if(import_path=="truffle/DeployedAddresses.sol"){return find_contracts(this.config.contracts_directory,function(err,source_files){fs.readdir(self.config.contracts_build_directory,function(err,abstraction_files){if(err)return callback(err);var mapping={};var blacklist=["Assert","DeployedAddresses"];source_files.forEach(function(file){var name=path.basename(file,".sol");if(blacklist.indexOf(name)>=0)return;mapping[name]=false});abstraction_files.forEach(function(file){var name=path.basename(file,".json");if(blacklist.indexOf(name)>=0)return;mapping[name]=false});var promises=abstraction_files.map(function(file){return new Promise(function(accept,reject){fs.readFile(path.join(self.config.contracts_build_directory,file),"utf8",function(err,body){if(err)return reject(err);accept(body)})})});Promise.all(promises).then(function(files_data){var addresses=files_data.map(function(data){return JSON.parse(data)}).map(function(json){return contract(json)}).map(function(c){c.setNetwork(self.config.network_id);if(c.isDeployed()){return c.address}return null});addresses.forEach(function(address,i){var name=path.basename(abstraction_files[i],".json");if(blacklist.indexOf(name)>=0)return;mapping[name]=address});return Deployed.makeSolidityDeployedAddressesLibrary(mapping)}).then(function(addressSource){callback(null,addressSource,import_path)})["catch"](callback)})})}if(import_path=="truffle/Assert.sol"){return fs.readFile(path.resolve(path.join(__dirname,"Assert.sol")),{encoding:"utf8"},function(err,body){callback(err,body,import_path)})}return callback()};TestSource.prototype.resolve_dependency_path=function(import_path,dependency_path){return dependency_path};module.exports=TestSource; |
{ | ||
"name": "sunbox", | ||
"namespace": "tronprotocol", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "SunBox - Simple development framework for Tron SunNetwork", | ||
@@ -10,4 +10,4 @@ "dependencies": { | ||
"@truffle/expect": "0.0.11", | ||
"@truffle/require": "^2.0.24", | ||
"@truffle/solidity-utils": "^1.2.5", | ||
"ajv": "^6.10.2", | ||
"async": "2.6.1", | ||
@@ -28,5 +28,3 @@ "axios": "^0.18.0", | ||
"finalhandler": "^1.1.2", | ||
"find-up": "^4.1.0", | ||
"fs-extra": "^8.1.0", | ||
"github-download": "^0.5.0", | ||
"graphlib": "^2.1.7", | ||
@@ -40,3 +38,2 @@ "homedir": "^0.6.0", | ||
"original-require": "1.0.1", | ||
"request": "^2.88.0", | ||
"safe-eval": "^0.4.1", | ||
@@ -52,3 +49,3 @@ "semver": "^6.1.1", | ||
"tronweb": "^2.7.2", | ||
"vcsurl": "^0.1.1", | ||
"truffle-init": "^1.0.7", | ||
"web3-mock": "1.0.1", | ||
@@ -62,4 +59,2 @@ "yargs": "^8.0.2" | ||
"electron": "^6.0.12", | ||
"eslint": "^6.6.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"glob": "^7.1.2", | ||
@@ -82,3 +77,2 @@ "js-scrypt": "^0.2.0", | ||
"prepare": "npm run build", | ||
"lint": "find src -name '*.js' | xargs node_modules/.bin/eslint", | ||
"build": "scripts/build.sh" | ||
@@ -85,0 +79,0 @@ }, |
# TronBox | ||
Simple development framework for tronweb | ||
**TronBox is a fork of [Truffle](https://www.trufflesuite.com/truffle) [code](https://github.com/trufflesuite/truffle)** | ||
Simple development framework for tronweb | ||
**TronBox is a fork of [Truffle](https://www.trufflesuite.com/truffle) [code](https://github.com/trufflesuite/truffle)** | ||
@@ -94,3 +94,3 @@ [TronBox Documentation](https://developers.tron.network/docs/tron-box-user-guide) | ||
This command will invoke all migration scripts within the migrations directory. If your previous migration was successful, `tronbox migrate` will invoke a newly created migration. If there is no new migration script, this command will have no operational effect. Instead, you can use the option `--reset` to restart the migration script.<br> | ||
This command will invoke all migration scripts within the migrations directory. If your previous migration was successful, `tronbox migrate` will invoke a newly created migration. If there is no new migration script, this command will have no operational effect. Instead, you can use the option `--reset` to restart the migration script.<br> | ||
@@ -127,3 +127,3 @@ `tronbox migrate --reset` | ||
The console supports the `tronbox` command. For example, you can invoke `migrate --reset` in the console. The result is the same as invoking `tronbox migrate --reset` in the command. | ||
The console supports the `tronbox` command. For example, you can invoke `migrate --reset` in the console. The result is the same as invoking `tronbox migrate --reset` in the command. | ||
<br> | ||
@@ -235,3 +235,3 @@ | ||
TronBox does not supports all the Solidity compilers. | ||
TronBox does not supports all the Solidity compilers. | ||
Supported versions: | ||
@@ -244,18 +244,14 @@ ``` | ||
0.5.9 | ||
``` | ||
``` | ||
## Latest version is 2.7.5 | ||
## Latest version is 2.3.16 | ||
## Recent history (selected) | ||
__2.7.5__ | ||
* More refactoring | ||
* Show alert if compilers cannot be downloaded | ||
__3.0.0__ | ||
* Full refactoring | ||
* Add support for Solidity compiler 0.5.9 | ||
__2.7.4__ | ||
* Partial refactoring | ||
* Add support for Solidity compiler 0.5.9 | ||
__2.5.2__ | ||
* Fix bug in compiler wrapper calls | ||
* Fix bug in compiler wrapper calls | ||
@@ -262,0 +258,0 @@ __2.5.0__ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 5 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances in 1 package
193291
42
14
97
311
68
290
45
8
+ Added@truffle/require@^2.0.24
+ Addedtruffle-init@^1.0.7
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@ensdomains/address-encoder@0.1.9(transitive)
+ Added@ensdomains/ens@0.4.5(transitive)
+ Added@ensdomains/ensjs@2.1.0(transitive)
+ Added@ensdomains/resolver@0.2.4(transitive)
+ Added@ethereumjs/common@2.5.0(transitive)
+ Added@ethereumjs/rlp@4.0.1(transitive)
+ Added@ethereumjs/tx@3.3.2(transitive)
+ Added@ethereumjs/util@8.0.2(transitive)
+ Added@ethersproject/abi@5.7.0(transitive)
+ Added@ethersproject/abstract-provider@5.7.0(transitive)
+ Added@ethersproject/abstract-signer@5.7.0(transitive)
+ Added@ethersproject/address@5.7.0(transitive)
+ Added@ethersproject/base64@5.7.0(transitive)
+ Added@ethersproject/basex@5.7.0(transitive)
+ Added@ethersproject/bignumber@5.7.0(transitive)
+ Added@ethersproject/bytes@5.7.0(transitive)
+ Added@ethersproject/constants@5.7.0(transitive)
+ Added@ethersproject/contracts@5.7.0(transitive)
+ Added@ethersproject/hash@5.7.0(transitive)
+ Added@ethersproject/hdnode@5.7.0(transitive)
+ Added@ethersproject/json-wallets@5.7.0(transitive)
+ Added@ethersproject/keccak256@5.7.0(transitive)
+ Added@ethersproject/logger@5.7.0(transitive)
+ Added@ethersproject/networks@5.7.1(transitive)
+ Added@ethersproject/pbkdf2@5.7.0(transitive)
+ Added@ethersproject/properties@5.7.0(transitive)
+ Added@ethersproject/providers@5.7.2(transitive)
+ Added@ethersproject/random@5.7.0(transitive)
+ Added@ethersproject/rlp@5.7.0(transitive)
+ Added@ethersproject/sha2@5.7.0(transitive)
+ Added@ethersproject/signing-key@5.7.0(transitive)
+ Added@ethersproject/solidity@5.7.0(transitive)
+ Added@ethersproject/strings@5.7.0(transitive)
+ Added@ethersproject/transactions@5.7.0(transitive)
+ Added@ethersproject/units@5.7.0(transitive)
+ Added@ethersproject/wallet@5.7.0(transitive)
+ Added@ethersproject/web@5.7.1(transitive)
+ Added@ethersproject/wordlists@5.7.0(transitive)
+ Added@ganache/console.log@0.3.0(transitive)
+ Added@ganache/utils@0.3.0(transitive)
+ Added@noble/hashes@1.2.0(transitive)
+ Added@noble/secp256k1@1.7.1(transitive)
+ Added@scure/base@1.1.9(transitive)
+ Added@scure/bip32@1.1.5(transitive)
+ Added@scure/bip39@1.1.1(transitive)
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@solidity-parser/parser@0.19.0(transitive)
+ Added@szmarczak/http-timer@4.0.65.0.1(transitive)
+ Added@truffle/abi-utils@1.0.3(transitive)
+ Added@truffle/blockchain-utils@0.1.9(transitive)
+ Added@truffle/codec@0.17.3(transitive)
+ Added@truffle/compile-common@0.9.8(transitive)
+ Added@truffle/compile-solidity@6.0.79(transitive)
+ Added@truffle/config@1.3.61(transitive)
+ Added@truffle/contract@4.6.31(transitive)
+ Added@truffle/contract-schema@3.4.16(transitive)
+ Added@truffle/contract-sources@0.2.1(transitive)
+ Added@truffle/dashboard-message-bus-client@0.1.12(transitive)
+ Added@truffle/dashboard-message-bus-common@0.1.7(transitive)
+ Added@truffle/debug-utils@6.0.57(transitive)
+ Added@truffle/error@0.0.60.2.2(transitive)
+ Added@truffle/events@0.1.25(transitive)
+ Added@truffle/expect@0.1.7(transitive)
+ Added@truffle/interface-adapter@0.5.37(transitive)
+ Added@truffle/profiler@0.1.53(transitive)
+ Added@truffle/promise-tracker@0.1.7(transitive)
+ Added@truffle/provider@0.3.13(transitive)
+ Added@truffle/provisioner@0.2.84(transitive)
+ Added@truffle/require@2.1.43(transitive)
+ Added@truffle/resolver@9.0.53(transitive)
+ Added@truffle/spinners@0.2.5(transitive)
+ Added@trufflesuite/bigint-buffer@1.1.9(transitive)
+ Added@trufflesuite/chromafi@3.0.0(transitive)
+ Added@trufflesuite/spinnies@0.1.1(transitive)
+ Added@types/bn.js@5.1.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@12.20.55(transitive)
+ Added@types/pbkdf2@3.1.2(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Added@types/secp256k1@4.0.6(transitive)
+ Addedabi-to-sol@0.7.1(transitive)
+ Addedabortcontroller-polyfill@1.7.8(transitive)
+ Addedajv@8.17.1(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedatomically@1.7.0(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedaxios@1.5.0(transitive)
+ Addedaxios-retry@3.9.1(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbech32@1.1.4(transitive)
+ Addedbetter-ajv-errors@0.8.2(transitive)
+ Addedbig-integer@1.6.36(transitive)
+ Addedbig.js@6.2.2(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedbufferutil@4.0.9(transitive)
+ Addedcacheable-lookup@5.0.46.1.0(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcamel-case@3.0.0(transitive)
+ Addedcamelcase@3.0.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchange-case@3.0.2(transitive)
+ Addedcheerio@1.0.0(transitive)
+ Addedcheerio-select@2.1.0(transitive)
+ Addedcids@0.7.5(transitive)
+ Addedclass-is@1.1.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcode-error-fragment@0.0.230(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@2.20.38.3.0(transitive)
+ Addedconf@10.2.0(transitive)
+ Addedconfigstore@4.0.0(transitive)
+ Addedconstant-case@2.0.0(transitive)
+ Addedcontent-hash@2.5.2(transitive)
+ Addedcore-js@3.40.0(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addedcross-fetch@3.2.0(transitive)
+ Addedcrypto-addr-codec@0.1.8(transitive)
+ Addedcrypto-random-string@1.0.0(transitive)
+ Addedcss-select@5.1.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addedd@1.0.2(transitive)
+ Addeddebounce-fn@4.0.0(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddelay@5.0.0(transitive)
+ Addeddetect-indent@5.0.0(transitive)
+ Addeddetect-installed@2.0.4(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.2.2(transitive)
+ Addeddot-case@2.1.1(transitive)
+ Addeddot-prop@4.2.16.0.1(transitive)
+ Addedemittery@0.10.00.4.1(transitive)
+ Addedencoding-sniffer@0.2.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedenv-paths@2.2.1(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedeth-lib@0.2.8(transitive)
+ Addedethereum-cryptography@0.1.31.2.0(transitive)
+ Addedethereumjs-util@7.1.5(transitive)
+ Addedethers@5.7.2(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedeventemitter3@4.0.4(transitive)
+ Addedexpand-tilde@2.0.2(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfast-check@3.1.1(transitive)
+ Addedfast-uri@3.0.6(transitive)
+ Addedfind-up@1.1.23.0.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfor-each@0.3.4(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedform-data-encoder@1.7.1(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedget-installed-path@2.1.14.0.8(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedglobal-modules@1.0.0(transitive)
+ Addedglobal-prefix@1.0.2(transitive)
+ Addedgot@11.8.612.1.0(transitive)
+ Addedgrapheme-splitter@1.0.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedheader-case@1.0.1(transitive)
+ Addedhighlight.js@10.7.3(transitive)
+ Addedhighlightjs-solidity@2.0.6(transitive)
+ Addedhomedir-polyfill@1.0.3(transitive)
+ Addedhtmlparser2@9.1.0(transitive)
+ Addedhttp2-wrapper@1.0.32.2.1(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-lower-case@1.1.3(transitive)
+ Addedis-obj@1.0.12.0.0(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-retry-allowed@2.2.0(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedis-upper-case@1.1.2(transitive)
+ Addedis-utf8@0.2.1(transitive)
+ Addedisomorphic-ws@4.0.1(transitive)
+ Addediter-tools@7.5.3(transitive)
+ Addedjs-sha3@0.8.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedjson-schema-typed@7.0.3(transitive)
+ Addedjson-to-ast@2.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedkeccak@3.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedleven@3.1.0(transitive)
+ Addedload-json-file@1.1.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedlodash.assign@4.2.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedlower-case@1.1.4(transitive)
+ Addedlower-case-first@1.0.2(transitive)
+ Addedlowercase-keys@3.0.0(transitive)
+ Addedmimic-fn@3.1.0(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedmultibase@0.6.10.7.0(transitive)
+ Addedmulticodec@0.5.71.0.4(transitive)
+ Addedmultihashes@0.4.21(transitive)
+ Addednano-base32@1.0.1(transitive)
+ Addedneodoc@2.0.2(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedno-case@2.3.2(transitive)
+ Addednode-abort-controller@3.1.1(transitive)
+ Addednode-addon-api@2.0.25.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-gyp-build@4.3.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addednpm-programmatic@0.0.6(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedoboe@2.1.5(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedos-locale@1.4.0(transitive)
+ Addedp-cancelable@2.1.13.0.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedparam-case@2.1.1(transitive)
+ Addedparse-passwd@1.0.0(transitive)
+ Addedparse5@7.2.1(transitive)
+ Addedparse5-htmlparser2-tree-adapter@7.1.0(transitive)
+ Addedparse5-parser-stream@7.1.2(transitive)
+ Addedpascal-case@2.0.1(transitive)
+ Addedpath-case@2.1.1(transitive)
+ Addedpath-exists@2.1.0(transitive)
+ Addedpath-type@1.1.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpkg-up@3.1.0(transitive)
+ Addedpossible-typed-array-names@1.1.0(transitive)
+ Addedprettier@2.8.8(transitive)
+ Addedprettier-plugin-solidity@1.4.2(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedpure-rand@5.0.5(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedread-pkg@1.1.0(transitive)
+ Addedread-pkg-up@1.0.1(transitive)
+ Addedrequire-from-string@1.2.1(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
+ Addedresolve-dir@1.0.1(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedripemd160-min@0.0.6(transitive)
+ Addedrlp@2.2.7(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedscrypt-js@3.0.1(transitive)
+ Addedsecp256k1@4.0.4(transitive)
+ Addedseedrandom@3.0.5(transitive)
+ Addedsentence-case@2.1.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsha3@2.1.4(transitive)
+ Addedsnake-case@2.1.0(transitive)
+ Addedsolc@0.4.260.8.21(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-bom@2.0.0(transitive)
+ Addedstrip-indent@2.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedswap-case@1.1.2(transitive)
+ Addedswarm-js@0.1.42(transitive)
+ Addedtestrpc@0.0.1(transitive)
+ Addedtiny-typed-emitter@2.1.0(transitive)
+ Addedtitle-case@2.1.1(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtruffle-config@1.1.20(transitive)
+ Addedtruffle-init@1.0.7(transitive)
+ Addedtruffle-provider@0.1.16(transitive)
+ Addedtype@2.7.3(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedundici@6.21.1(transitive)
+ Addedunique-string@1.0.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedupper-case@1.1.3(transitive)
+ Addedupper-case-first@1.1.2(transitive)
+ Addedutf-8-validate@5.0.10(transitive)
+ Addedutil@0.12.5(transitive)
+ Addeduuid@9.0.1(transitive)
+ Addedvarint@5.0.2(transitive)
+ Addedweb3@1.10.0(transitive)
+ Addedweb3-bzz@1.10.0(transitive)
+ Addedweb3-core@1.10.0(transitive)
+ Addedweb3-core-helpers@1.10.0(transitive)
+ Addedweb3-core-method@1.10.0(transitive)
+ Addedweb3-core-promievent@1.10.0(transitive)
+ Addedweb3-core-requestmanager@1.10.0(transitive)
+ Addedweb3-core-subscriptions@1.10.0(transitive)
+ Addedweb3-eth@1.10.0(transitive)
+ Addedweb3-eth-abi@1.10.0(transitive)
+ Addedweb3-eth-accounts@1.10.0(transitive)
+ Addedweb3-eth-contract@1.10.0(transitive)
+ Addedweb3-eth-ens@1.10.0(transitive)
+ Addedweb3-eth-iban@1.10.0(transitive)
+ Addedweb3-eth-personal@1.10.0(transitive)
+ Addedweb3-net@1.10.0(transitive)
+ Addedweb3-providers-http@1.10.0(transitive)
+ Addedweb3-providers-ipc@1.10.0(transitive)
+ Addedweb3-providers-ws@1.10.0(transitive)
+ Addedweb3-shh@1.10.0(transitive)
+ Addedweb3-utils@1.10.0(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwebsocket@1.0.35(transitive)
+ Addedwhatwg-encoding@3.1.1(transitive)
+ Addedwhatwg-mimetype@4.0.0(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwhich-module@1.0.0(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
+ Addedwindow-size@0.2.0(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedws@7.4.67.5.10(transitive)
+ Addedxdg-basedir@3.0.0(transitive)
+ Addedyaeti@0.0.6(transitive)
+ Addedyargs@4.8.1(transitive)
+ Addedyargs-parser@2.4.1(transitive)
- Removedajv@^6.10.2
- Removedfind-up@^4.1.0
- Removedgithub-download@^0.5.0
- Removedrequest@^2.88.0
- Removedvcsurl@^0.1.1
- Removedfind-up@4.1.0(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedprepend-http@2.0.0(transitive)
- Removedurl-parse-lax@3.0.0(transitive)