Updated FoodCoin Registry smart-contract(Ropsten test network). Added api methods for Verificators in smart-contract

This commit is contained in:
Said Syakin 2018-03-22 18:39:37 +04:00
parent 5d542aa35c
commit aaa32f5300
2 changed files with 252 additions and 28 deletions

File diff suppressed because one or more lines are too long

View file

@ -421,19 +421,9 @@ web3._extend({
// FoodCoin method to send transaction with formatted data payload // FoodCoin method to send transaction with formatted data payload
new web3._extend.Method({ new web3._extend.Method({
name: 'sendTransactionWithData', name: 'sendTransactionWithData',
call: function(args) { call: 'eth_sendTransactionWithData',
if (args[1]) { params: 2,
if (!web3._extend.utils.isObject(args[1])) { inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null]
args[1] = "{\"description\":\"" + args[1] + "\"}"
} else {
args[1] = JSON.stringify(args[1])
}
args[0].data = web3.fromUtf8(args[1])
}
return 'eth_sendTransaction'
},
params: 1,
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
}), }),
// FoodCoin method to get formatted transaction info // FoodCoin method to get formatted transaction info
new web3._extend.Method({ new web3._extend.Method({
@ -463,7 +453,7 @@ web3._extend({
// Example: food.getRegistryVar({accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', creatorAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name'}); // Example: food.getRegistryVar({accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', creatorAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name'});
new web3._extend.Method({ new web3._extend.Method({
name: 'getRegistryVar', name: 'getRegistryVar',
call: 'eth_getVarFoodRegistry', call: 'eth_getVarFR',
params: 2, params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter] inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter]
}), }),
@ -471,9 +461,49 @@ web3._extend({
// Example: food.setRegistryVar({from:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name', varValue:'John'}); // Example: food.setRegistryVar({from:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name', varValue:'John'});
new web3._extend.Method({ new web3._extend.Method({
name: 'setRegistryVar', name: 'setRegistryVar',
call: 'eth_setVarFoodRegistry', call: 'eth_setVarFR',
params: 1, params: 1,
inputFormatter: [null] inputFormatter: [null]
}),
// Adds verificator to the list of verificators.
// parameters:
// VerificatorAddress - address of a verificator
// IssuedTimeStamp - verificator's license issued timestamp
// ValidUntilTimeStamp - verificator's license valid until timestamp
new web3._extend.Method({
name: 'addVerificator',
call: 'eth_addVerificator',
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({
name: 'getVerificatorsCount',
call: 'eth_getVerificatorsCount',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
outputFormatter: function (tx) {
if(tx !== null)
tx = web3.toDecimal(tx);
return tx;
}
}),
new web3._extend.Method({
name: 'getVerificatorsIndex',
call: 'eth_getVerificatorsIndex',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
}),
new web3._extend.Method({
name: 'getVerificatorAtIndex',
call: 'eth_getVerificatorAtIndex',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
}),
new web3._extend.Method({
name: 'updateVerificatorLicenseExpiration',
call: 'eth_updateVerificatorLicenseExpiration',
params: 1,
inputFormatter: [null],
}), }),
], ],
properties: [ properties: [