![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
This is the Sero compatible JavaScript API which base on ethereum/web3.js version with v0.20.6 latest maintenance release .It is used by gero client as embed js that can interract with the Sero blockchain. It alse can be as a reference for dApps to interract with the Sero blockchain.
The minimum unit of Sero is ta, and one sero is equivalent to 10 to the 9th power ta.
var unitMap = {
'noether': '0',
'ta': '1',
'Ta': '1',
'sero': '1000000000',
'Sero': '1000000000'
};
/**
* Takes a number of Ta and converts it to any other sero unit.
*
*
* @method fromTa
* @param {Number|String} number can be a number, number string or a HEX of a decimal
* @param {String} unit the unit to convert to, default ether
* @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
*/
var fromTa = function (number, unit) {
var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
return isBigNumber(number) ? returnValue : returnValue.toString(10);
};
/**
* Takes a number of a unit and converts it to ta.
* @method toTa
* @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
* @param {String} unit the unit to convert from, default ether
* @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
*/
var toTa = function (number, unit) {
var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
return isBigNumber(number) ? returnValue : returnValue.toString(10);
};
All the address is showed as base58 string
* Convert a byte array to a base58 string
*
* @method bytesToBase58
* @param {Array} bytes
* @return {String} the base58 string
*/
var bytesToBase58 = function (bytes) {
return base58.encode(bytes);
};
/**
* Convert a base58 string to a byte array
*
* @method base58ToBytes
* @param {String} the base58 string
* @return {Array} bytes
*/
var base58ToBytes = function (bs58) {
return base58.decode(bs58);
}
* Checks if the given string is strictly an address
*
* @method isStrictAddress
* @param {String} address the given base58 adress
* @return {Boolean}
*/
var isStrictAddress = function (address) {
if (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{84,103}$/i.test(address)) {
bytes = base58ToBytes(address)
if (bytes.length !== 128) {
return false;
}
return true;
} else {
return false;
}
};
Create or call contract must post abi and pairs params。the paris is a json string array,the key is solidity params type and the value is function param's value;and no need to splicing method parameters for data param.
gen paris:
/**
* Should be used to encode list of params,used by sero
*
* @method encodeSeroParams
* @param {Array} types
* @param {Array} params
* @return {String} encoded list of params
*/
SolidityCoder.prototype.encodeSeroParams = function (types, params) {
var solidityTypes = this.getSolidityTypes(types);
var encodeds = solidityTypes.map(function (solidityType, index) {
encodedJson ={};
encodedJson[types[index]] = solidityType.encodeSero(params[index], types[index]);
return JSON.stringify(encodedJson);
});
return encodeds;
};
/**
* Should be used to encode list of params,used by sero
*
* @method encodeSeroParams
* @param {Array} types
* @param {Array} params
* @return {String} encoded list of params
*/
SolidityCoder.prototype.encodeSeroParams = function (types, params) {
var solidityTypes = this.getSolidityTypes(types);
var encodeds = solidityTypes.map(function (solidityType, index) {
encodedJson ={};
encodedJson[types[index]] = solidityType.encodeSero(params[index], types[index]);
return JSON.stringify(encodedJson);
});
return encodeds;
};
The method of SendTransaction Json params add pairs、abi、cy、dy key. The abi,pairs only be used when create or call crontract, and dy only be used when call contract that means whether to regenerate a one-time address. The cy is the currency unit of the transaction, default is sero
{
from: sero.accounts[0],
to: sero.accounts[1],
value: 1000,
gas: 30000,
gasPrice: 5,
data: [],
pairs: [],
abi: [],
cy: 'sero',
dy: false
}
The showed transaction info add Zero knowledge proof
/**
* Formats the output of a transaction to its proper values
*
* @method outputTransactionFormatter
* @param {Object} tx
* @returns {Object}
*/
var outputTransactionFormatter = function (tx){
if(tx.blockNumber !== null)
tx.blockNumber = utils.toDecimal(tx.blockNumber);
if(tx.transactionIndex !== null)
tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
tx.nonce = utils.toDecimal(tx.nonce);
tx.gas = utils.toDecimal(tx.gas);
tx.gasPrice = utils.toBigNumber(tx.gasPrice);
tx.value = utils.toBigNumber(tx.value);
if (tx.stx.Desc_Os) {
var in_os = []
var out_os = []
tx.stx.Desc_Os.forEach(function (e) {
var curreny = utils.bytesToString(utils.hexToBytes(utils.fromDecimal(utils.toBigNumber(e.Currency))));
if (e.Ins) {
e.Ins.forEach(function (i) {
var in_o = {};
in_o['currency'] = curreny;
in_o['root'] = i
in_os.push(in_o)
});
}
if (e.Outs) {
e.Outs.forEach(function (o) {
var out_o = {};
out_o['currency'] = curreny;
out_o['value'] = o.Value;
out_o['addr'] = o.Addr;
out_os.push(out_o)
});
}
});
tx.In_Os = in_os;
tx.Out_Os = out_os;
}
tx.Desc_Zs = tx.stx.Desc_Zs;
delete tx.stx
return tx;
};
Add a method in sero.js ,determine if it is your own one-time address
var isMineOAddr = new Method({
name: 'isMineOAddr',
call: 'sero_isMineOAddr',
params: 1,
inputFormatter: [formatters.inputAddressFormatter]
});
npm run-script build
LGPL-3.0+ © 2015 Contributors
FAQs
Sero JavaScript API, middleware to talk to a sero node over RPC
The npm package seb3 receives a total of 0 weekly downloads. As such, seb3 popularity was classified as not popular.
We found that seb3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.