New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

boxdjs

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boxdjs - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

dist/boxd/core/split/util.js

5

.eslintrc.json

@@ -31,6 +31,2 @@ {

],
"quotes": [
"error",
"single"
],
"semi": [

@@ -49,2 +45,3 @@ "error",

"no-param-reassign": 0,
"quotes": 0,
"@typescript-eslint/indent": 0,

@@ -51,0 +48,0 @@ "@typescript-eslint/explicit-function-return-type": 0,

30

dist/boxd/account/account-manager.js

@@ -13,27 +13,13 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var privatekey_1 = __importDefault(require("../util/crypto/privatekey"));
var AccountManager = /** @class */ (function () {
function AccountManager(acc_list, updateAccount) {
if (updateAccount === void 0) { updateAccount = function (new_acc_list) {
function AccountManager(acc_list, update_func) {
if (update_func === void 0) { update_func = function (new_acc_list) {
return new_acc_list;
}; }
this.acc_list = acc_list;
this.updateAccount = updateAccount;
this.update_func = update_func;
}
/**
* @func New_PrivateKey_Object
* @param [*privkey]
* @returns [privateKey]
* @memberof AccountManager
*/
AccountManager.prototype.newPrivateKey = function (privkey) {
var privk = new privatekey_1.default(privkey);
return privk.privKey;
};
/**
* @func Add_New_Account_to_Account_List
* @func add_New_Account_to_Account_List
* @param {*cryptoJSON}

@@ -45,4 +31,4 @@ * @memberof AccountManager

var updateTime = Date.now();
/* console.log('acc_list:', this.acc_list)
console.log('address:', address) */
// console.log('acc_list:', this.acc_list)
// console.log('address:', address)
if (this.acc_list[address]) {

@@ -54,6 +40,6 @@ console.warn('This Account already existed. It will be rewrited...');

}, otherInfo);
this.updateAccount && this.updateAccount(this.acc_list);
this.update_func && this.update_func(this.acc_list);
};
/**
* @func Sort_Account_List
* @func Sort_account_list
* @returns [account_list]

@@ -60,0 +46,0 @@ * @memberof AccountManager

@@ -46,153 +46,137 @@ "use strict";

var util_1 = __importDefault(require("../util/util"));
var OPCODE_TYPE = 'hex';
/**
* @class [Account]
*/
var Account = /** @class */ (function () {
function Account() {
}
var Account;
(function (Account) {
var _this = this;
/**
* @func Dump_P2PKH_address_from_PrivateKey
* @func Dump_P2PKH_address_from_privateKey
* @param [*privKey]
* @returns [P2PKH_Address]
* @returns [P2PKH_address]
* @memberof Account
*/
Account.prototype.dumpAddrFromPrivKey = function (privKey) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE);
}
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.toP2PKHAddress;
}
Account.dumpAddrFromPrivKey = function (privKey) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex');
}
catch (err) {
console.log('dumpAddrFromPrivKey Error !');
throw new Error(err);
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.toP2PKHAddress;
}
else {
throw new Error('Private key format error !');
}
};
/**
* @func Dump_PublicKey_from_PrivateKey
* @func Dump_publicKey_from_privateKey
* @param [*privKey]
* @returns [PublicKey]
* @returns [publicKey]
* @memberof Account
*/
Account.prototype.dumpPubKeyFromPrivKey = function (privKey) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE);
}
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.toPublicKey().toString(OPCODE_TYPE);
}
Account.dumpPubKeyFromPrivKey = function (privKey) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex');
}
catch (err) {
console.log('dumpPubKeyFromPrivKey Error !');
throw new Error(err);
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.toPublicKey().toString('hex');
}
else {
throw new Error('Private key format error !');
}
};
/**
* @func Dump_Crypto_from_PrivateKey
* @func Dump_cryptoJson_from_privateKey
* @param [*privKey]
* @param [*pwd]
* @returns [CryptoJson]
* @returns [cryptoJson]
* @memberof Account
*/
Account.prototype.dumpCryptoFromPrivKey = function (privKey, pwd) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE);
}
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.getCryptoByPrivKey(pwd);
}
Account.dumpCryptoFromPrivKey = function (privKey, pwd) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex');
}
catch (err) {
console.log('dumpKeyStoreFromPrivKey Error !');
throw new Error(err);
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.getCryptoByPrivKey(pwd);
}
else {
throw new Error('Private key format error !');
}
};
/**
* @func Dump_PublicKey_Hash_from_PrivateKey
* @func Dump_publicKey_hash_from_privateKey
* @param [*privKey]
* @returns [PublicKey_hash]
* @returns [publicKey_hash]
* @memberof Account
*/
Account.prototype.dumpPubKeyHashFromPrivKey = function (privKey) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE);
}
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.pkh;
}
Account.dumpPubKeyHashFromPrivKey = function (privKey) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex');
}
catch (err) {
console.log('dumpPubKeyHashFromPrivKey Error !');
throw new Error(err);
if (verify_1.default.isPrivate(privKey)) {
var privK = new privatekey_1.default(privKey);
return privK.privKey.pkh;
}
else {
throw new Error('Private key format error !');
}
};
/**
* @func Dump_PublicKey_Hash_from_Address
* @func Dump_publicKey_hash_from_address
* @param [*addr]
* @returns [PublicKey]
* @returns [publicKey]
* @memberof Account
*/
Account.prototype.dumpPubKeyHashFromAddr = function (addr) {
Account.dumpPubKeyHashFromAddr = function (addr) {
return util_1.default.box2HexAddr(addr);
};
/**
* @func Dump_PrivateKey_from_Crypto
* @func Dump_privateKey_from_crypto.json
* @param [*cryptoJSON]
* @param [*pwd]
* @returns [PrivateKey]
* @returns [privKey]
* @memberof Account
*/
Account.prototype.dumpPrivKeyFromCrypto = function (cryptoJSON, pwd) {
return __awaiter(this, void 0, void 0, function () {
var cpt, kdfParams, saltBuffer, derivedKey, aesKey, sha256Key, mac, privateKeyHexStr, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
cpt = cryptoJSON.crypto;
kdfParams = cpt.kdfparams;
saltBuffer = Buffer.from(kdfParams.salt, OPCODE_TYPE);
derivedKey = crypto_json_1.default.getDerivedKey(pwd, saltBuffer, kdfParams.n, kdfParams.r, kdfParams.p, kdfParams.dklen);
aesKey = derivedKey.slice(0, 16).toString(OPCODE_TYPE);
sha256Key = derivedKey.slice(16, 32).toString(OPCODE_TYPE);
mac = aes_1.default.getMac(sha256Key, cpt.ciphertext);
if (mac !== cpt.mac) {
throw new Error('Wrong passphrase !');
}
return [4 /*yield*/, aes_1.default.getCiphertext(aesKey, cpt.ciphertext, cpt.cipherparams.iv)];
case 1:
privateKeyHexStr = _a.sent();
if (!privateKeyHexStr) {
throw new Error('Privat Key not found !');
}
Account.dumpPrivKeyFromCrypto = function (cryptoJSON, pwd) { return __awaiter(_this, void 0, void 0, function () {
var cpt, kdfParams, saltBuffer, derivedKey, aesKey, sha256Key, mac, privateKeyHexStr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cpt = cryptoJSON.crypto;
kdfParams = cpt.kdfparams;
saltBuffer = Buffer.from(kdfParams.salt, 'hex');
derivedKey = crypto_json_1.default.getDerivedKey(pwd, saltBuffer, kdfParams.n, kdfParams.r, kdfParams.p, kdfParams.dklen);
aesKey = derivedKey.slice(0, 16).toString('hex');
sha256Key = derivedKey.slice(16, 32).toString('hex');
mac = aes_1.default.getMac(sha256Key, cpt.ciphertext);
if (mac !== cpt.mac) {
throw new Error('Wrong passphrase !');
}
return [4 /*yield*/, aes_1.default.getCiphertext(aesKey, cpt.ciphertext, cpt.cipherparams.iv)];
case 1:
privateKeyHexStr = _a.sent();
if (privateKeyHexStr) {
return [2 /*return*/, privateKeyHexStr];
case 2:
err_1 = _a.sent();
console.log('dumpPrivKeyFromCrypto Error !');
throw new Error(err_1);
case 3: return [2 /*return*/];
}
});
}
else {
throw new Error('Private Key not found !');
}
return [2 /*return*/];
}
});
};
}); };
/**
* @func Get_account_Crypto_by_Password
* @func Get_account_crypto_by_password
* @param [*pwd]
* @param [*privKey]
* @returns [Crypto]
* @returns [cryptoJson]
* @memberof Account
*/
Account.prototype.getCryptoByPwd = function (pwd, privKey) {
if (privKey && privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE);
Account.getCryptoByPwd = function (pwd, privKey) {
if (privKey) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex');
}
if (!verify_1.default.isPrivate(privKey)) {
throw new Error('Private key format error !');
}
}

@@ -208,4 +192,3 @@ var privK = new privatekey_1.default(privKey);

};
return Account;
}());
})(Account || (Account = {}));
exports.default = Account;

@@ -10,3 +10,4 @@ "use strict";

var feature_1 = __importDefault(require("./core/feature"));
var util_1 = __importDefault(require("../boxd/core/token/util"));
var util_1 = __importDefault(require("../boxd/util/util"));
// import Grpc from '../boxd/util/grpc'
var boxd = {

@@ -17,4 +18,5 @@ Account: account_1.default,

Feature: feature_1.default,
util: util_1.default
// Grpc,
Util: util_1.default
};
exports.default = boxd;

@@ -57,8 +57,9 @@ "use strict";

var privatekey_1 = __importDefault(require("../util/crypto/privatekey"));
var util_1 = __importDefault(require("./tx/util"));
var util_1 = __importDefault(require("../util/util"));
/**
* @class [Api]
* @extends Fetch
* @constructs _fetch # user incoming
* @constructs endpoint string # user incoming
* @constructs _fetch user incoming
* @constructs endpoint user incoming
* @constructs fetch_type http / rpc
*/

@@ -65,0 +66,0 @@ var Api = /** @class */ (function (_super) {

@@ -42,3 +42,2 @@ "use strict";

var util_1 = __importDefault(require("../../../util/util"));
var util_2 = __importDefault(require("./util"));
var isObject_1 = __importDefault(require("lodash/isObject"));

@@ -111,3 +110,3 @@ var isArray_1 = __importDefault(require("lodash/isArray"));

switch (_a.label) {
case 0: return [4 /*yield*/, util_2.default.rawEncode(types, params).toString('hex')];
case 0: return [4 /*yield*/, util_1.default.rawEncode(types, params).toString('hex')];
case 1: return [2 /*return*/, _a.sent()];

@@ -171,3 +170,3 @@ }

}
var result = util_2.default.rawDecode(outputs, bytes);
var result = util_1.default.rawDecode(outputs, bytes);
var returnValues = {};

@@ -174,0 +173,0 @@ var decodedValue;

@@ -347,5 +347,5 @@ "use strict";

}
var Util;
(function (Util) {
Util.rawEncode = function (types, values) {
var AbiUtil;
(function (AbiUtil) {
AbiUtil.rawEncode = function (types, values) {
var output = [];

@@ -389,3 +389,3 @@ var data = [];

};
Util.rawDecode = function (types, data) {
AbiUtil.rawDecode = function (types, data) {
var ret = [];

@@ -412,3 +412,3 @@ data = Buffer.from(data);

};
})(Util || (Util = {}));
exports.default = Util;
})(AbiUtil || (AbiUtil = {}));
exports.default = AbiUtil;

@@ -59,8 +59,9 @@ "use strict";

var api_1 = __importDefault(require("../core/api"));
var util_1 = __importDefault(require("./tx/util"));
var util_1 = __importDefault(require("../util/util"));
/**
* @class [Feature]
* @extends Fetch
* @constructs _fetch # user incoming
* @constructs endpoint string # user incoming
* @constructs _fetch user incoming
* @constructs endpoint user incoming
* @constructs fetch_type http / rpc
*/

@@ -73,23 +74,35 @@ var Feature = /** @class */ (function (_super) {

/**
* @export Sign_transaction_by_Crypto.json
* @export Sign_transaction_by_priv_key.json
* @param [*unsigned_tx]
* @param [*priv_key_hex_str]
* @returns [signed_tx]
*/
Feature.prototype.signTxByPrivKey = function (unsigned_tx, priv_key_hex_str) {
return __awaiter(this, void 0, void 0, function () {
var privk, unsigned_tx_p;
return __generator(this, function (_a) {
privk = new privatekey_1.default(priv_key_hex_str);
unsigned_tx_p = {
privKey: priv_key_hex_str,
unsignedTx: unsigned_tx,
protocalTx: null
};
return [2 /*return*/, privk.signTxByPrivKey(unsigned_tx_p)];
});
});
};
/**
* @export Sign_transaction_by_crypto.json
* @param [*unsigned_tx]
* @returns [signed_tx]
*/
Feature.prototype.signTxByCrypto = function (unsigned_tx) {
return __awaiter(this, void 0, void 0, function () {
var acc, privKey, unsigned_tx_p, privk;
var privKeyHexStr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
acc = new account_1.default();
return [4 /*yield*/, acc.dumpPrivKeyFromCrypto(unsigned_tx.crypto, unsigned_tx.pwd)];
case 0: return [4 /*yield*/, account_1.default.dumpPrivKeyFromCrypto(unsigned_tx.crypto, unsigned_tx.pwd)];
case 1:
privKey = _a.sent();
unsigned_tx_p = {
privKey: privKey,
unsignedTx: unsigned_tx.unsignedTx,
protocalTx: null
};
privk = new privatekey_1.default(privKey);
return [2 /*return*/, privk.signTxByPrivKey(unsigned_tx_p)];
privKeyHexStr = _a.sent();
return [2 /*return*/, this.signTxByPrivKey(unsigned_tx.unsignedTx, privKeyHexStr)];
}

@@ -100,3 +113,3 @@ });

/**
* @export Make_BOX_transaction_by_Crypto.json
* @export Make_BOX_transaction_by_crypto.json
* @param [*org_tx]

@@ -108,3 +121,3 @@ * @step [make_privKey->fetch_utxos->make_unsigned_tx->sign_tx->send_tx]

return __awaiter(this, void 0, void 0, function () {
var _a, from, to, amounts, fee, acc, privKey, total_to, to_map, cor, utxo_res, unsigned_tx, signed_tx;
var _a, from, to, amounts, fee, privKey, total_to, to_map, api, utxo_res, unsigned_tx, signed_tx;
return __generator(this, function (_b) {

@@ -114,4 +127,3 @@ switch (_b.label) {

_a = org_tx.tx, from = _a.from, to = _a.to, amounts = _a.amounts, fee = _a.fee;
acc = new account_1.default();
return [4 /*yield*/, acc.dumpPrivKeyFromCrypto(org_tx.crypto, org_tx.pwd)];
return [4 /*yield*/, account_1.default.dumpPrivKeyFromCrypto(org_tx.crypto, org_tx.pwd)];
case 1:

@@ -130,4 +142,4 @@ privKey = _b.sent();

total_to = total_to.add(new bn_js_1.default(fee, 10));
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.fetchUtxos({
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.fetchUtxos({
addr: from,

@@ -151,3 +163,3 @@ amount: total_to.toString()

unsigned_tx = _b.sent();
return [4 /*yield*/, cor.signTxByPrivKey({
return [4 /*yield*/, api.signTxByPrivKey({
unsignedTx: unsigned_tx.tx_json,

@@ -161,3 +173,3 @@ protocalTx: unsigned_tx.protocalTx,

signed_tx = _b.sent();
return [4 /*yield*/, cor.sendTx(signed_tx)];
return [4 /*yield*/, api.sendTx(signed_tx)];
case 6:

@@ -172,3 +184,3 @@ /* send tx to boxd */

/**
* @export Make_Split_transaction_by_Crypto.json
* @export Make_split_transaction_by_crypto.json
* @param [*org_tx]

@@ -179,8 +191,8 @@ * @returns [Promise<sent_tx>] { splitAddr: string; hash: string }

return __awaiter(this, void 0, void 0, function () {
var cor, unsigned_tx, signed_tx, tx_result;
var api, unsigned_tx, signed_tx, tx_result, split_addr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.makeUnsignedSplitAddrTx(org_tx.tx)];
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.makeUnsignedSplitAddrTx(org_tx.tx)];
case 1:

@@ -198,6 +210,16 @@ unsigned_tx = _a.sent();

signed_tx = _a.sent();
return [4 /*yield*/, cor.sendTx(signed_tx)];
return [4 /*yield*/, api.sendTx(signed_tx)];
case 3:
tx_result = _a.sent();
return [2 /*return*/, Object.assign(tx_result, { splitAddr: unsigned_tx.splitAddr })];
return [4 /*yield*/, util_1.default.calcSplitAddr({
addrs: org_tx.tx.addrs,
weights: org_tx.tx.weights,
txHash: tx_result.hash,
index: tx_result['index']
})];
case 4:
split_addr = _a.sent();
return [2 /*return*/, Object.assign(tx_result, {
splitAddr: split_addr
})];
}

@@ -208,3 +230,3 @@ });

/**
* @export Issue_Token_by_Crypto.json
* @export Issue_token_by_crypto.json
* @param [*org_tx]

@@ -215,8 +237,8 @@ * @returns [Promise<sent_tx>] { hash: string }

return __awaiter(this, void 0, void 0, function () {
var cor, unsigned_tx, signed_tx;
var api, unsigned_tx, signed_tx;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.makeUnsignedTokenIssueTx(org_tx.tx)];
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.makeUnsignedTokenIssueTx(org_tx.tx)];
case 1:

@@ -234,3 +256,3 @@ unsigned_tx = _a.sent();

signed_tx = _a.sent();
return [4 /*yield*/, cor.sendTx(signed_tx)];
return [4 /*yield*/, api.sendTx(signed_tx)];
case 3: return [2 /*return*/, _a.sent()];

@@ -242,3 +264,3 @@ }

/**
* @export Make_Token_Transaction_by_Crypto.json
* @export Make_token_transaction_by_crypto.json
* @param [*org_tx]

@@ -249,8 +271,8 @@ * @returns [Promise<sent_tx>] { hash: string }

return __awaiter(this, void 0, void 0, function () {
var cor, unsigned_tx, signed_tx;
var api, unsigned_tx, signed_tx;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.makeUnsignedTokenTx(org_tx.tx)];
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.makeUnsignedTokenTx(org_tx.tx)];
case 1:

@@ -268,3 +290,3 @@ unsigned_tx = _a.sent();

signed_tx = _a.sent();
return [4 /*yield*/, cor.sendTx(signed_tx)];
return [4 /*yield*/, api.sendTx(signed_tx)];
case 3: return [2 /*return*/, _a.sent()];

@@ -276,14 +298,44 @@ }

/**
* @export Make_Contract_transaction_by_Crypto.json
* @export Make_contract_transaction_by_priv_key.json
* @param [*org_tx]
* @param [*priv_key_hex_str]
* @returns [Promise<sent_tx>] { hash: string }
*/
Feature.prototype.makeContractTxByPrivKey = function (org_tx, priv_key_hex_str) {
return __awaiter(this, void 0, void 0, function () {
var api, unsigned_tx, signed_tx, tx_result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.makeUnsignedContractTx(org_tx)];
case 1:
unsigned_tx = _a.sent();
return [4 /*yield*/, this.signTxByPrivKey({
tx: unsigned_tx.tx,
rawMsgs: unsigned_tx.rawMsgs
}, priv_key_hex_str)];
case 2:
signed_tx = _a.sent();
return [4 /*yield*/, api.sendTx(signed_tx)];
case 3:
tx_result = _a.sent();
return [2 /*return*/, { hash: tx_result.hash, contractAddr: unsigned_tx.contract_addr }];
}
});
});
};
/**
* @export Make_contract_transaction_by_crypto.json
* @param [*org_tx]
* @returns [Promise<sent_tx>] { hash: string }
*/
Feature.prototype.makeContractTxByCrypto = function (org_tx) {
return __awaiter(this, void 0, void 0, function () {
var cor, unsigned_tx, signed_tx, tx_result;
var api, unsigned_tx, signed_tx, tx_result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.makeUnsignedContractTx(org_tx.tx)];
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.makeUnsignedContractTx(org_tx.tx)];
case 1:

@@ -301,3 +353,3 @@ unsigned_tx = _a.sent();

signed_tx = _a.sent();
return [4 /*yield*/, cor.sendTx(signed_tx)];
return [4 /*yield*/, api.sendTx(signed_tx)];
case 3:

@@ -311,3 +363,3 @@ tx_result = _a.sent();

/**
* @export Call_Contract
* @export Call_contract
* @param [*org_tx]

@@ -318,8 +370,8 @@ * @returns [Promise<sent_tx>] { result: string }

return __awaiter(this, void 0, void 0, function () {
var cor, result;
var api, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cor = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, cor.callContract(callParams)];
api = new api_1.default(this._fetch, this.endpoint, this.fetch_type);
return [4 /*yield*/, api.callContract(callParams)];
case 1:

@@ -326,0 +378,0 @@ result = _a.sent();

@@ -8,19 +8,19 @@ "use strict";

var util_1 = __importDefault(require("../../util/util"));
var Util;
(function (Util) {
var op_hash_len = 32;
var op_hash_len = 32;
/**
* @func Get_Uint32
* @param [*buf]
*/
var getUint32 = function (buf) {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
};
var TokenUtil;
(function (TokenUtil) {
/**
* @func getUint32
* @param [*buf] Buffer
*/
var getUint32 = function (buf) {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
};
/**
* @export hash+index=>token_address
* @param [*opHash] string
* @param [*index] number
* @returns [token_address] string
*/
Util.encodeTokenAddr = function (token_addr) {
* @export hash+index=>token_address
* @param [*opHash] token hash
* @param [*index] token index
* @returns [token_address]
*/
TokenUtil.encodeTokenAddr = function (token_addr) {
var opHash = token_addr.opHash, index = token_addr.index;

@@ -32,7 +32,7 @@ var before = Buffer.from(opHash, 'hex');

/**
* @func token_address=>hash+index
* @param [*token_address] string
* @returns [{hash,index}] object
*/
Util.decodeTokenAddr = function (token_address) {
* @func token_address=>hash+index
* @param [*token_address]
* @returns [{hash,index}]
*/
TokenUtil.decodeTokenAddr = function (token_address) {
var token_addr_buf = bs58_1.default.decode(token_address);

@@ -46,3 +46,3 @@ var opHash = token_addr_buf.slice(0, op_hash_len).toString('hex');

};
})(Util || (Util = {}));
exports.default = Util;
})(TokenUtil || (TokenUtil = {}));
exports.default = TokenUtil;

@@ -10,4 +10,4 @@ "use strict";

var util_1 = __importDefault(require("../../util/util"));
var Util;
(function (Util) {
var TxUtil;
(function (TxUtil) {
/**

@@ -21,3 +21,3 @@ * @func Make_Unsigned_transaction_handle

*/
Util.makeUnsignedTxHandle = function (param) {
TxUtil.makeUnsignedTxHandle = function (param) {
// console.log('makeUnsignedTxHandle param ===', JSON.stringify(param))

@@ -54,6 +54,5 @@ var from = param.from, to_map = param.to_map, fee = param.fee, utxo_list = param.utxo_list, is_raw = param.is_raw;

/* vout */
var acc = new account_1.default();
var op = new util_1.default.Opcoder('');
Object.keys(to_map).forEach(function (to_addr) {
var pub_hash = acc.dumpPubKeyHashFromAddr(to_addr);
var pub_hash = account_1.default.dumpPubKeyHashFromAddr(to_addr);
// console.log('pub_hash_1 :', pub_hash)

@@ -63,7 +62,7 @@ // + script_pub_key

.reset('')
.add(util_1.default.getHexStrFromNumber(op.OP_DUP))
.add(util_1.default.getHexStrFromNumber(op.OP_HASH_160))
.add(util_1.default.to16StrFromNumber(op.OP_DUP))
.add(util_1.default.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(util_1.default.getHexStrFromNumber(op.OP_EQUAL_VERIFY))
.add(util_1.default.getHexStrFromNumber(op.OP_CHECK_SIG))
.add(util_1.default.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(util_1.default.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode();

@@ -87,3 +86,3 @@ // console.log('script :', script.toString('base64'))

// console.log('charge :', charge)
var pub_hash = acc.dumpPubKeyHashFromAddr(from);
var pub_hash = account_1.default.dumpPubKeyHashFromAddr(from);
// console.log('pub_hash_2 :', pub_hash)

@@ -93,7 +92,7 @@ // + script_pub_key

.reset('')
.add(util_1.default.getHexStrFromNumber(op.OP_DUP))
.add(util_1.default.getHexStrFromNumber(op.OP_HASH_160))
.add(util_1.default.to16StrFromNumber(op.OP_DUP))
.add(util_1.default.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(util_1.default.getHexStrFromNumber(op.OP_EQUAL_VERIFY))
.add(util_1.default.getHexStrFromNumber(op.OP_CHECK_SIG))
.add(util_1.default.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(util_1.default.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode();

@@ -197,3 +196,3 @@ // console.log('script :', script.toString('base64'))

};
})(Util || (Util = {}));
exports.default = Util;
})(TxUtil || (TxUtil = {}));
exports.default = TxUtil;

@@ -32,22 +32,21 @@ "use strict";

/**
* @export get-DerivedKey-by-Passphrase
* @param [passphrase] string
* @param [salt] Buffer
* @param [n] number
* @param [r] number
* @param [p] number
* @param [dklen] number
* @returns Buffer
*/
* @export get-DerivedKey-by-Passphrase
* @param [passphrase] string
* @param [salt] Buffer
* @param [n] number
* @param [r] number
* @param [p] number
* @param [dklen] number
* @returns Buffer
*/
CryptoJson.getDerivedKey = function (passphrase, salt, n, r, p, dklen) {
return scrypt_js_1.default(Buffer.from(passphrase), salt, n, r, p, dklen, function (progress) {
console.log('progress:', progress);
});
return scrypt_js_1.default(Buffer.from(passphrase), salt, n, r, p, dklen);
// delete progress
};
/**
* @export get-Crypto-by-PrivateKey&Passphrase
* @param [privateKey] privateKey
* @param [passphrase] string
* @returns [CryptoJson] CryptoJson
*/
* @export get-Crypto-by-PrivateKey&Passphrase
* @param [privateKey] privateKey
* @param [passphrase] string
* @returns [CryptoJson] CryptoJson
*/
CryptoJson.getCryptoByPrivKey = function (privateKey, passphrase) {

@@ -90,46 +89,46 @@ if (!privateKey) {

/**
* @export unlock-PrivateKey-by-Passphrase
* @param [ksJSON] object
* @param [passphrase] string
* @returns [privateKeyHexStr]
*/
* @export unlock-PrivateKey-by-Passphrase
* @param [ksJSON] object
* @param [passphrase] string
* @returns [privateKeyHexStr]
*/
/* export const unlockPrivateKeyWithPassphrase = (
ksJSON: { crypto },
passphrase: string
) => {
if (!passphrase) {
throw new Error('Passphrase is require!')
}
if (!ksJSON) {
throw new Error('ksJSON is require!')
}
const cpt = ksJSON.crypto
const kdfParams = cpt.kdfparams
const saltBuffer = Buffer.from(kdfParams.salt, _STRING_ENC_)
const derivedKey = getDerivedKey(
passphrase,
saltBuffer,
kdfParams.n,
kdfParams.r,
kdfParams.p,
kdfParams.dklen
)
const aesKey = derivedKey.slice(0, 16).toString(_STRING_ENC_)
const sha256Key = derivedKey.slice(16, 32).toString(_STRING_ENC_)
const mac = Aes.getMac(sha256Key, cpt.ciphertext)
if (mac !== cpt.mac) {
throw new Error('passphrase is error!')
}
const privateKeyHexStr = Aes.getCiphertext(
aesKey,
cpt.ciphertext,
cpt.cipherparams.iv
)
if (!privateKeyHexStr) {
throw new Error("Can't find privateKey!")
}
return privateKeyHexStr
} */
ksJSON: { crypto },
passphrase: string
) => {
if (!passphrase) {
throw new Error('Passphrase is require!')
}
if (!ksJSON) {
throw new Error('ksJSON is require!')
}
const cpt = ksJSON.crypto
const kdfParams = cpt.kdfparams
const saltBuffer = Buffer.from(kdfParams.salt, _STRING_ENC_)
const derivedKey = getDerivedKey(
passphrase,
saltBuffer,
kdfParams.n,
kdfParams.r,
kdfParams.p,
kdfParams.dklen
)
const aesKey = derivedKey.slice(0, 16).toString(_STRING_ENC_)
const sha256Key = derivedKey.slice(16, 32).toString(_STRING_ENC_)
const mac = Aes.getMac(sha256Key, cpt.ciphertext)
if (mac !== cpt.mac) {
throw new Error('passphrase is error!')
}
const privateKeyHexStr = Aes.getCiphertext(
aesKey,
cpt.ciphertext,
cpt.cipherparams.iv
)
if (!privateKeyHexStr) {
throw new Error("Can't find privateKey!")
}
return privateKeyHexStr
} */
})(CryptoJson || (CryptoJson = {}));
exports.default = CryptoJson;

@@ -8,3 +8,2 @@ "use strict";

var util_1 = __importDefault(require("../util"));
var OPCODE_TYPE = 'hex';
var Ecpair;

@@ -68,3 +67,4 @@ (function (Ecpair) {

Ecpair.getECfromPrivKey = function (privkey, options) {
privkey = Buffer.from(privkey, OPCODE_TYPE);
// console.log('==> getECfromPrivKey')
privkey = Buffer.from(privkey, 'hex');
if (!tiny_secp256k1_1.default.isPrivate(privkey))

@@ -71,0 +71,0 @@ throw new TypeError('Private key not in range [1, n)');

@@ -47,3 +47,2 @@ "use strict";

var crypto_json_1 = __importDefault(require("./crypto-json"));
var OPCODE_TYPE = 'hex';
var prefix = {

@@ -63,3 +62,3 @@ P2PKH: '1326',

* @param [*pwd]
* @returns [cryptoJSON]
* @returns [crypto.json]
* @memberof PrivateKey *

@@ -105,3 +104,3 @@ */

if (unsigned_tx.protocalTx) {
return [2 /*return*/, unsigned_tx.protocalTx.serializeBinary().toString(OPCODE_TYPE)];
return [2 /*return*/, unsigned_tx.protocalTx.serializeBinary().toString('hex')];
}

@@ -121,5 +120,5 @@ else {

var sha256Content = prefixHex + _this.privKey.pkh;
var checksum = hash_1.default.sha256(hash_1.default.sha256(Buffer.from(sha256Content, OPCODE_TYPE))).slice(0, 4);
var content = sha256Content.concat(checksum.toString(OPCODE_TYPE));
return bs58_1.default.encode(Buffer.from(content, OPCODE_TYPE));
var checksum = hash_1.default.sha256(hash_1.default.sha256(Buffer.from(sha256Content, 'hex'))).slice(0, 4);
var content = sha256Content.concat(checksum.toString('hex'));
return bs58_1.default.encode(Buffer.from(content, 'hex'));
};

@@ -131,4 +130,8 @@ /**

this.getPubKeyHashByPrivKey = function () {
return hash_1.default.hash160(_this.privKey.toPublicKey().toBuffer()).toString(OPCODE_TYPE);
return hash_1.default.hash160(_this.privKey.toPublicKey().toBuffer()).toString('hex');
};
console.log('privkey_str :', privkey_str);
if (privkey_str) {
privkey_str = privkey_str.padStart(64, '0');
}
this.privKey = new bitcore_lib_1.default.PrivateKey(privkey_str);

@@ -135,0 +138,0 @@ this.privKey.signMsg = function (sigHash) {

@@ -79,3 +79,3 @@ "use strict";

else {
_this = _super.call(this, 'Unknow Error!') || this;
_this = _super.call(this, 'Unknow Error !') || this;
}

@@ -123,12 +123,9 @@ Object.setPrototypeOf(_this, HttpError.prototype);

console.log(result);
return [2 /*return*/, result
// result.code = response.status
// result.statusText = response.statusText
];
throw new HttpError(result);
case 3: return [4 /*yield*/, response.json()
// console.log('[fetch] Result:', result)
// console.log('[fetch] Result :', result)
];
case 4:
result = _a.sent();
// console.log('[fetch] Result:', result)
// console.log('[fetch] Result :', result)
if (result.code) {

@@ -140,3 +137,3 @@ if (result.code === 0) {

else {
// console.log('[fetch] Error: code !== 0')
// console.log('[fetch] Error : code !== 0')
throw new HttpError(result);

@@ -143,0 +140,0 @@ }

@@ -14,8 +14,12 @@ "use strict";

var isNumber_1 = __importDefault(require("lodash/isNumber"));
var util_1 = __importDefault(require("../core/contract/abi/util"));
var util_2 = __importDefault(require("../core/split/util"));
var util_3 = __importDefault(require("../core/token/util"));
var util_4 = __importDefault(require("../core/tx/util"));
var OP_0 = var_1.default.OP_0, OP_PUSH_DATA_1 = var_1.default.OP_PUSH_DATA_1, OP_PUSH_DATA_2 = var_1.default.OP_PUSH_DATA_2, OP_PUSH_DATA_4 = var_1.default.OP_PUSH_DATA_4, OP_DUP = var_1.default.OP_DUP, OP_HASH_160 = var_1.default.OP_HASH_160, OP_EQUAL_VERIFY = var_1.default.OP_EQUAL_VERIFY, OP_CHECK_SIG = var_1.default.OP_CHECK_SIG;
var OPCODE_TYPE = 'hex';
var PREFIXSTR2BYTES = {
b1: Buffer.from([0x13, 0x26]),
b2: Buffer.from([0x13, 0x28]),
b3: Buffer.from([0x13, 0x2a])
b3: Buffer.from([0x13, 0x2a]),
b5: Buffer.from([0x13, 0x30])
};

@@ -41,3 +45,3 @@ /* keccak = BEGIN = */

/* keccak = END = */
var _flattenTypes = function _flattenTypes(includeTuple, puts) {
var _flattenTypes = function (includeTuple, puts) {
var types = [];

@@ -71,8 +75,8 @@ puts.forEach(function (param) {

};
var Util;
(function (Util) {
Util.getHexStrFromNumber = function (num) { return (num & 255).toString(16); };
Util.getBufFromNumber = function (num) { return num & 255; };
var CommonUtil;
(function (CommonUtil) {
CommonUtil.to16StrFromNumber = function (num) { return (num & 255).toString(16); };
CommonUtil.getBufFromNumber = function (num) { return num & 255; };
/**
* @export Put_Uint16
* @func Put_Uint16
* @param [*bytes]

@@ -82,7 +86,7 @@ * @param [*uint16]

*/
Util.putUint16 = function (bytes, uint16) {
CommonUtil.putUint16 = function (bytes, uint16) {
if (bytes.length < 2) {
return new Error('The length of the bytes should more than 2 !');
}
bytes[0] = Util.getBufFromNumber(uint16);
bytes[0] = CommonUtil.getBufFromNumber(uint16);
bytes[1] = uint16 >> 8;

@@ -101,6 +105,6 @@ return bytes;

this.OP_CHECK_SIG = OP_CHECK_SIG;
this.opcode = Buffer.from(org_code, OPCODE_TYPE);
this.opcode = Buffer.from(org_code, 'hex');
}
Opcoder.prototype.reset = function (org_code) {
this.opcode = Buffer.from(org_code, OPCODE_TYPE);
this.opcode = Buffer.from(org_code, 'hex');
return this;

@@ -119,8 +123,12 @@ };

if (!isBuf) {
and_buf = Buffer.from(and_buf, OPCODE_TYPE);
and_buf = Buffer.from(and_buf, 'hex');
}
var and_len = and_buf.length;
var and_len_str = Util.getHexStrFromNumber(and_len);
var and_len_str = CommonUtil.to16StrFromNumber(and_len);
// console.log('and_len_str :', and_len_str)
if (and_len < OP_PUSH_DATA_1) {
this.opcode = Buffer.from(this.opcode.toString(OPCODE_TYPE) + and_len_str, OPCODE_TYPE);
this.opcode = Buffer.concat([
this.opcode,
Buffer.from(and_len_str, 'hex')
]);
}

@@ -130,4 +138,4 @@ else if (and_len <= 0xff) {

this.opcode,
Buffer.from(Util.getHexStrFromNumber(OP_PUSH_DATA_1), OPCODE_TYPE),
Buffer.from(and_len_str, OPCODE_TYPE)
Buffer.from(CommonUtil.to16StrFromNumber(OP_PUSH_DATA_1), 'hex'),
Buffer.from(and_len_str, 'hex')
]);

@@ -137,6 +145,6 @@ }

var buf = Buffer.alloc(2);
buf = Util.putUint16(buf, and_len);
buf = CommonUtil.putUint16(buf, and_len);
this.opcode = Buffer.concat([
this.opcode,
Buffer.from(Util.getHexStrFromNumber(OP_PUSH_DATA_2), OPCODE_TYPE),
Buffer.from(CommonUtil.to16StrFromNumber(OP_PUSH_DATA_2), 'hex'),
buf

@@ -147,6 +155,6 @@ ]);

var buf = Buffer.alloc(4);
buf = Util.putUint16(buf, and_len);
buf = CommonUtil.putUint16(buf, and_len);
this.opcode = Buffer.concat([
this.opcode,
Buffer.from(Util.getHexStrFromNumber(OP_PUSH_DATA_4), OPCODE_TYPE),
Buffer.from(CommonUtil.to16StrFromNumber(OP_PUSH_DATA_4), 'hex'),
buf

@@ -161,5 +169,5 @@ ]);

}());
Util.Opcoder = Opcoder;
CommonUtil.Opcoder = Opcoder;
/**
* @export put-Uint32
* @func Put-Uint32
* TODO: it not support int32 now

@@ -170,7 +178,7 @@ * @param [*bytes]

*/
Util.putUint32 = function (bytes, uint32) {
CommonUtil.putUint32 = function (bytes, uint32) {
if (bytes.length < 4) {
return new Error('The length of the bytes should more than 4 !');
}
bytes[0] = Util.getBufFromNumber(uint32);
bytes[0] = CommonUtil.getBufFromNumber(uint32);
bytes[1] = uint32 >> 8;

@@ -182,8 +190,8 @@ bytes[2] = uint32 >> 16;

/**
* @export signature-Script
* @param [*sigBuf] Buffer
* @param [*Buffer] Buffer
* @returns [end] Buffer
* @func Signature-Script
* @param [*sigBuf]
* @param [*Buffer]
* @returns [end]
*/
Util.signatureScript = function (sigBuf, pubKeyBuf) {
CommonUtil.signatureScript = function (sigBuf, pubKeyBuf) {
var op = new Opcoder([]);

@@ -196,7 +204,7 @@ return op

/**
* @export get-SignHash
* @param [*protobuf] string
* @func Get-SignHash
* @param [*protobuf]
* @returns
*/
Util.getSignHash = function (protobuf) {
CommonUtil.getSignHash = function (protobuf) {
if (typeof protobuf === 'string') {

@@ -209,3 +217,3 @@ return hash_1.default.hash256(Buffer.from(protobuf, 'base64'));

};
Util.jsonInterfaceMethodToString = function (json) {
CommonUtil.jsonInterfaceMethodToString = function (json) {
if (isObject_1.default(json) && json.name && json.name.includes('(')) {

@@ -218,3 +226,3 @@ return json.name;

};
Util.keccak256 = function (value) {
CommonUtil.keccak256 = function (value) {
if (isHexStrict(value) && /^0x/i.test(value.toString())) {

@@ -232,10 +240,10 @@ value = hexToBytes(value);

/**
* Returns a `Boolean` on whether or not the a `String` starts with '0x'
* @param {String} str the string input value
* @return {Boolean} a boolean if it is or is not hex prefixed
* @func # Returns a `Boolean` on whether or not the a `String` starts with '0x'
* @param [*str] str the string input value
* @return [boolean] a boolean if it is or is not hex prefixed
* @throws if the str input is not a string
*/
Util.isHexPrefixed = function (str) {
CommonUtil.isHexPrefixed = function (str) {
if (typeof str !== 'string') {
throw new Error('[is-hex-prefixed] value must be type \'string\', is currently type ' +
throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " +
typeof str +

@@ -247,21 +255,21 @@ ', while checking isHexPrefixed.');

/**
* Removes '0x' from a given `String` is present
* @param {String} str the string value
* @return {String|Optional} a string by pass if necessary
* @func # Removes '0x' from a given `String` is present
* @param [*str] str the string value
* @return [string|optional] a string by pass if necessary
*/
Util.stripHexPrefix = function (str) {
CommonUtil.stripHexPrefix = function (str) {
if (typeof str !== 'string') {
return str;
}
return Util.isHexPrefixed(str) ? str.slice(2) : str;
return CommonUtil.isHexPrefixed(str) ? str.slice(2) : str;
};
/**
* Convert hex address to box address format
* @param {String} prefix: the box address prefix
* @param {hexAddr} hexAddr: hex address without '0x' prefix
* @return {String} box address, starting with "b"
* @func # Convert hex address to box address format
* @param [*prefix] string # the box address prefix
* @param [*hexAddr] string # hex address without '0x' prefix
* @return [string] box address, starting with "b"
* @throws when prefix is not expected
*/
Util.hex2BoxAddr = function (prefix, hexAddr) {
if (prefix !== ('b1' || 'b2' || 'b3')) {
CommonUtil.hex2BoxAddr = function (prefix, hexAddr) {
if (!['b1', 'b2', 'b3', 'b5'].includes(prefix)) {
throw new Error('Incorrect address prefix !');

@@ -274,22 +282,17 @@ }

/**
* Convert box address to hex address format
* @param {boxAddr} boxAddr: address in box format, starting with 'b'
* @return {String} hex address
* @func Convert_box_address_to_hex_address_format
* @param [*box_addr] string # address in box format, starting with 'b'
* @return [string] hex address
* @throws if convertion fails
*/
Util.box2HexAddr = function (boxAddr) {
try {
var pubKey_hash = verify_1.default.isAddr(boxAddr);
if (pubKey_hash) {
return pubKey_hash.slice(2).toString(OPCODE_TYPE);
}
console.log('dumpPubKeyHashFromAddr Error !');
CommonUtil.box2HexAddr = function (box_addr) {
var pubKey_hash = verify_1.default.isBoxAddr(box_addr);
if (pubKey_hash) {
return pubKey_hash.slice(2).toString('hex');
}
else {
throw new Error('dumpPubKeyHashFromAddr Error');
}
catch (err) {
console.log('dumpPubKeyHashFromAddr Error !');
throw new Error(err);
}
};
})(Util || (Util = {}));
exports.default = Util;
})(CommonUtil || (CommonUtil = {}));
exports.default = Object.assign(CommonUtil, util_1.default, util_2.default, util_3.default, util_4.default);

@@ -9,3 +9,2 @@ "use strict";

var hash_1 = __importDefault(require("../util/crypto/hash"));
var OPCODE_TYPE = 'hex';
var _typeof2 = function (obj) {

@@ -31,25 +30,40 @@ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {

(function (Verify) {
Verify.isPrivate = function (privKey) {
if (tiny_secp256k1_1.default.isPrivate(Buffer.from(privKey, OPCODE_TYPE))) {
return privKey;
/**
* @func get_check_sum
* @param [*hex]
* @returns [check_sum]
*/
Verify.getCheckSum = function (hex) {
if (hex instanceof Buffer) {
return hash_1.default.sha256(hash_1.default.sha256(hex)).slice(0, 4);
}
else {
throw new Error('The private key entered is not a valid one !');
return hash_1.default.sha256(hash_1.default.sha256(Buffer.from(hex, 'hex'))).slice(0, 4);
}
};
Verify.getCheckSum = function (hex) {
if (hex instanceof Buffer) {
return hash_1.default.sha256(hash_1.default.sha256(hex)).slice(0, 4);
/**
* @func check_is_private_key
* @param [*privKey]
* @returns [boolean]
*/
Verify.isPrivate = function (privKey) {
if (tiny_secp256k1_1.default.isPrivate(Buffer.from(privKey, 'hex'))) {
return privKey;
}
else {
return hash_1.default.sha256(hash_1.default.sha256(Buffer.from(hex, OPCODE_TYPE))).slice(0, 4);
return false;
}
};
Verify.isAddr = function (addr) {
if (addr.substring(0, 2) !== ('b1' || 'b2' || 'b3')) {
throw new Error('Incorrect address format !');
/**
* @func check_is_BOX_address
* @param [*addr]
* @returns [pubkey_hash]
*/
Verify.isBoxAddr = function (addr) {
if (!['b1', 'b2', 'b3', 'b5'].includes(addr.substring(0, 2))) {
throw new Error('[isBoxAddr] Incorrect address format !');
}
var decoded = bs58_1.default.decode(addr);
if (decoded.length < 4) {
throw new Error("Address length = " + decoded.length + ": is too short !");
throw new Error("[isBoxAddr] Address length = " + decoded.length + ": is too short !");
}

@@ -60,12 +74,6 @@ var len = decoded.length;

if (!checksum.equals(decoded.slice(len - 4))) {
throw new Error('Incorrect address format !');
throw new Error('[isBoxAddr] Incorrect address format !');
}
return pubkey_hash;
};
Verify.isPublic = function (privKey) {
console.log('privKey:', privKey);
};
Verify.isPublicHash = function (pubkey_hash) {
console.log('pubkey_hash:', pubkey_hash);
};
Verify._typeof = function (obj) {

@@ -72,0 +80,0 @@ if (typeof Symbol === 'function' &&

{
"name": "boxdjs",
"version": "1.0.3",
"version": "1.0.4",
"description": "A Javascript implementation of BOX Payout blockchain on NodeJS or Browser.",

@@ -18,2 +18,4 @@ "main": "dist/boxd/boxd.js",

"dependencies": {
"@grpc/proto-loader": "^0.5.1",
"base-x": "3.0.2",
"bitcore-lib": "^0.16.0",

@@ -25,2 +27,3 @@ "bn.js": "^4.11.5",

"google-protobuf": "^3.9.0-rc.1",
"grpc": "^1.22.2",
"isomorphic-fetch": "^2.2.1",

@@ -138,2 +141,2 @@ "lodash": "^4.17.11",

}
}
}

@@ -1,2 +0,1 @@

import PrivateKey from '../util/crypto/privatekey'
import UtilInterface from '../util/interface'

@@ -6,7 +5,7 @@

public acc_list: { [acc_addr: string]: UtilInterface.Account }
public updateAccount
public update_func
public constructor(
acc_list: { [acc_addr: string]: UtilInterface.Account },
updateAccount: object = (new_acc_list: object) => {
update_func: object = (new_acc_list: object) => {
return new_acc_list

@@ -16,18 +15,7 @@ }

this.acc_list = acc_list
this.updateAccount = updateAccount
this.update_func = update_func
}
/**
* @func New_PrivateKey_Object
* @param [*privkey]
* @returns [privateKey]
* @memberof AccountManager
*/
public newPrivateKey(privkey: string): object {
const privk = new PrivateKey(privkey)
return privk.privKey
}
/**
* @func Add_New_Account_to_Account_List
* @func add_New_Account_to_Account_List
* @param {*cryptoJSON}

@@ -39,4 +27,4 @@ * @memberof AccountManager

const updateTime = Date.now()
/* console.log('acc_list:', this.acc_list)
console.log('address:', address) */
// console.log('acc_list:', this.acc_list)
// console.log('address:', address)
if (this.acc_list[address]) {

@@ -52,7 +40,7 @@ console.warn('This Account already existed. It will be rewrited...')

}
this.updateAccount && this.updateAccount(this.acc_list)
this.update_func && this.update_func(this.acc_list)
}
/**
* @func Sort_Account_List
* @func Sort_account_list
* @returns [account_list]

@@ -59,0 +47,0 @@ * @memberof AccountManager

@@ -8,100 +8,86 @@ import CryptoJson from '../util/crypto/crypto-json'

const OPCODE_TYPE = 'hex'
/**
* @class [Account]
*/
export default class Account {
namespace Account {
/**
* @func Dump_P2PKH_address_from_PrivateKey
* @func Dump_P2PKH_address_from_privateKey
* @param [*privKey]
* @returns [P2PKH_Address]
* @returns [P2PKH_address]
* @memberof Account
*/
public dumpAddrFromPrivKey(privKey: string | Buffer) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE)
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.toP2PKHAddress
}
} catch (err) {
console.log('dumpAddrFromPrivKey Error !')
throw new Error(err)
export const dumpAddrFromPrivKey = (privKey: string | Buffer) => {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex')
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.toP2PKHAddress
} else {
throw new Error('Private key format error !')
}
}
/**
* @func Dump_PublicKey_from_PrivateKey
* @func Dump_publicKey_from_privateKey
* @param [*privKey]
* @returns [PublicKey]
* @returns [publicKey]
* @memberof Account
*/
public dumpPubKeyFromPrivKey(privKey: string | Buffer) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE)
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.toPublicKey().toString(OPCODE_TYPE)
}
} catch (err) {
console.log('dumpPubKeyFromPrivKey Error !')
throw new Error(err)
export const dumpPubKeyFromPrivKey = (privKey: string | Buffer) => {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex')
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.toPublicKey().toString('hex')
} else {
throw new Error('Private key format error !')
}
}
/**
* @func Dump_Crypto_from_PrivateKey
* @func Dump_cryptoJson_from_privateKey
* @param [*privKey]
* @param [*pwd]
* @returns [CryptoJson]
* @returns [cryptoJson]
* @memberof Account
*/
public dumpCryptoFromPrivKey(privKey: string | Buffer, pwd: string) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE)
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.getCryptoByPrivKey(pwd)
}
} catch (err) {
console.log('dumpKeyStoreFromPrivKey Error !')
throw new Error(err)
export const dumpCryptoFromPrivKey = (
privKey: string | Buffer,
pwd: string
) => {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex')
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.getCryptoByPrivKey(pwd)
} else {
throw new Error('Private key format error !')
}
}
/**
* @func Dump_PublicKey_Hash_from_PrivateKey
* @func Dump_publicKey_hash_from_privateKey
* @param [*privKey]
* @returns [PublicKey_hash]
* @returns [publicKey_hash]
* @memberof Account
*/
public dumpPubKeyHashFromPrivKey(privKey: string | Buffer) {
try {
if (privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE)
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.pkh
}
} catch (err) {
console.log('dumpPubKeyHashFromPrivKey Error !')
throw new Error(err)
export const dumpPubKeyHashFromPrivKey = (privKey: string | Buffer) => {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex')
}
if (Verify.isPrivate(privKey)) {
const privK = new PrivateKey(privKey)
return privK.privKey.pkh
} else {
throw new Error('Private key format error !')
}
}
/**
* @func Dump_PublicKey_Hash_from_Address
* @func Dump_publicKey_hash_from_address
* @param [*addr]
* @returns [PublicKey]
* @returns [publicKey]
* @memberof Account
*/
public dumpPubKeyHashFromAddr(addr: string) {
export const dumpPubKeyHashFromAddr = (addr: string) => {
return Util.box2HexAddr(addr)

@@ -111,43 +97,39 @@ }

/**
* @func Dump_PrivateKey_from_Crypto
* @func Dump_privateKey_from_crypto.json
* @param [*cryptoJSON]
* @param [*pwd]
* @returns [PrivateKey]
* @returns [privKey]
* @memberof Account
*/
public async dumpPrivKeyFromCrypto(
export const dumpPrivKeyFromCrypto = async (
cryptoJSON: UtilInterface.Crypto,
pwd: string
) {
) => {
// console.log('dumpPrivKeyFromCrypto param:', cryptoJSON, pwd)
try {
const cpt = cryptoJSON.crypto
const kdfParams = cpt.kdfparams
const saltBuffer = Buffer.from(kdfParams.salt, OPCODE_TYPE)
const derivedKey = CryptoJson.getDerivedKey(
pwd,
saltBuffer,
kdfParams.n,
kdfParams.r,
kdfParams.p,
kdfParams.dklen
)
const aesKey = derivedKey.slice(0, 16).toString(OPCODE_TYPE)
const sha256Key = derivedKey.slice(16, 32).toString(OPCODE_TYPE)
const mac = Aes.getMac(sha256Key, cpt.ciphertext)
if (mac !== cpt.mac) {
throw new Error('Wrong passphrase !')
}
const privateKeyHexStr = await Aes.getCiphertext(
aesKey,
cpt.ciphertext,
cpt.cipherparams.iv
)
if (!privateKeyHexStr) {
throw new Error('Privat Key not found !')
}
const cpt = cryptoJSON.crypto
const kdfParams = cpt.kdfparams
const saltBuffer = Buffer.from(kdfParams.salt, 'hex')
const derivedKey = CryptoJson.getDerivedKey(
pwd,
saltBuffer,
kdfParams.n,
kdfParams.r,
kdfParams.p,
kdfParams.dklen
)
const aesKey = derivedKey.slice(0, 16).toString('hex')
const sha256Key = derivedKey.slice(16, 32).toString('hex')
const mac = Aes.getMac(sha256Key, cpt.ciphertext)
if (mac !== cpt.mac) {
throw new Error('Wrong passphrase !')
}
const privateKeyHexStr = await Aes.getCiphertext(
aesKey,
cpt.ciphertext,
cpt.cipherparams.iv
)
if (privateKeyHexStr) {
return privateKeyHexStr
} catch (err) {
console.log('dumpPrivKeyFromCrypto Error !')
throw new Error(err)
} else {
throw new Error('Private Key not found !')
}

@@ -157,11 +139,16 @@ }

/**
* @func Get_account_Crypto_by_Password
* @func Get_account_crypto_by_password
* @param [*pwd]
* @param [*privKey]
* @returns [Crypto]
* @returns [cryptoJson]
* @memberof Account
*/
public getCryptoByPwd(pwd: string, privKey?: string | Buffer) {
if (privKey && privKey instanceof Buffer) {
privKey = privKey.toString(OPCODE_TYPE)
export const getCryptoByPwd = (pwd: string, privKey?: string | Buffer) => {
if (privKey) {
if (privKey instanceof Buffer) {
privKey = privKey.toString('hex')
}
if (!Verify.isPrivate(privKey)) {
throw new Error('Private key format error !')
}
}

@@ -178,1 +165,3 @@ const privK = new PrivateKey(privKey)

}
export default Account

@@ -5,4 +5,4 @@ import Account from './account/account'

import Feature from './core/feature'
import TokenUtil from '../boxd/core/token/util'
import Util from '../boxd/util/util'
// import Grpc from '../boxd/util/grpc'

@@ -14,6 +14,6 @@ const boxd = {

Feature,
Util,
util: TokenUtil
// Grpc,
Util
}
export default boxd

@@ -14,3 +14,3 @@ import BN from 'bn.js'

import TxResponse from './tx/response'
import TxUtil from './tx/util'
import Util from '../util/util'

@@ -20,4 +20,5 @@ /**

* @extends Fetch
* @constructs _fetch # user incoming
* @constructs endpoint string # user incoming
* @constructs _fetch user incoming
* @constructs endpoint user incoming
* @constructs fetch_type http / rpc
*/

@@ -202,3 +203,3 @@ export default class Api extends Fetch {

const utxo_list = utxo_res.utxos
let unsigned_tx = await TxUtil.makeUnsignedTxHandle({
let unsigned_tx = await Util.makeUnsignedTxHandle({
from: addr,

@@ -205,0 +206,0 @@ to_map: to,

@@ -1,3 +0,2 @@

import CommonUtil from '../../../util/util'
import AbiUtil from './util'
import Util from '../../../util/util'
import isObject from 'lodash/isObject'

@@ -15,5 +14,5 @@ import isArray from 'lodash/isArray'

if (isObject(functionName)) {
functionName = CommonUtil.jsonInterfaceMethodToString(functionName)
functionName = Util.jsonInterfaceMethodToString(functionName)
}
const keccaked = await CommonUtil.keccak256(functionName)
const keccaked = await Util.keccak256(functionName)
if (keccaked) {

@@ -34,6 +33,6 @@ return keccaked.slice(2, 10)

if (isObject(functionName)) {
functionName = CommonUtil.jsonInterfaceMethodToString(functionName)
functionName = Util.jsonInterfaceMethodToString(functionName)
}
return CommonUtil.keccak256(functionName)
return Util.keccak256(functionName)
}

@@ -60,3 +59,3 @@

public async encodeParameters(types: string[], params: any[]) {
return await AbiUtil.rawEncode(types, params).toString('hex')
return await Util.rawEncode(types, params).toString('hex')
}

@@ -108,3 +107,3 @@

const result = AbiUtil.rawDecode(outputs, bytes)
const result = Util.rawDecode(outputs, bytes)
let returnValues = {}

@@ -111,0 +110,0 @@ let decodedValue

import BN from 'bn.js'
import CommonUtil from '../../../util/util'
import Util from '../../../util/util'
import isObject from 'lodash/isObject'

@@ -22,4 +22,4 @@

if (type === 'string') {
if (CommonUtil.isHexPrefixed(arg)) {
return new BN(CommonUtil.stripHexPrefix(arg), 16)
if (Util.isHexPrefixed(arg)) {
return new BN(Util.stripHexPrefix(arg), 16)
} else {

@@ -364,3 +364,3 @@ return new BN(arg, 10)

namespace Util {
namespace AbiUtil {
export const rawEncode = (types, values) => {

@@ -428,2 +428,2 @@ var output: any = []

export default Util
export default AbiUtil

@@ -9,4 +9,5 @@ import BN from 'bn.js'

import PrivateKey from '../util/crypto/privatekey'
import Core from '../core/api'
import TxUtil from './tx/util'
import Api from '../core/api'
import Util from '../util/util'
import UtilInterface from '../util/interface'

@@ -16,4 +17,5 @@ /**

* @extends Fetch
* @constructs _fetch # user incoming
* @constructs endpoint string # user incoming
* @constructs _fetch user incoming
* @constructs endpoint user incoming
* @constructs fetch_type http / rpc
*/

@@ -26,18 +28,16 @@ export default class Feature extends Fetch {

/**
* @export Sign_transaction_by_Crypto.json
* @export Sign_transaction_by_priv_key.json
* @param [*unsigned_tx]
* @param [*priv_key_hex_str]
* @returns [signed_tx]
*/
public async signTxByCrypto(unsigned_tx: TxRequest.SignedTxByCryptoReq) {
const acc = new Account()
const privKey = await acc.dumpPrivKeyFromCrypto(
unsigned_tx.crypto,
unsigned_tx.pwd
)
public async signTxByPrivKey(unsigned_tx: UtilInterface.UnsignedTx, priv_key_hex_str: string) {
const privk = new PrivateKey(priv_key_hex_str)
const unsigned_tx_p = {
privKey,
unsignedTx: unsigned_tx.unsignedTx,
privKey: priv_key_hex_str,
unsignedTx: unsigned_tx,
protocalTx: null
}
const privk = new PrivateKey(privKey)
return privk.signTxByPrivKey(unsigned_tx_p)

@@ -47,3 +47,17 @@ }

/**
* @export Make_BOX_transaction_by_Crypto.json
* @export Sign_transaction_by_crypto.json
* @param [*unsigned_tx]
* @returns [signed_tx]
*/
public async signTxByCrypto(unsigned_tx: TxRequest.SignedTxByCryptoReq) {
const privKeyHexStr = await Account.dumpPrivKeyFromCrypto(
unsigned_tx.crypto,
unsigned_tx.pwd
)
return this.signTxByPrivKey(unsigned_tx.unsignedTx, privKeyHexStr)
}
/**
* @export Make_BOX_transaction_by_crypto.json
* @param [*org_tx]

@@ -57,6 +71,8 @@ * @step [make_privKey->fetch_utxos->make_unsigned_tx->sign_tx->send_tx]

const { from, to, amounts, fee } = org_tx.tx
const acc = new Account()
/* make privKey */
const privKey = await acc.dumpPrivKeyFromCrypto(org_tx.crypto, org_tx.pwd)
const privKey = await Account.dumpPrivKeyFromCrypto(
org_tx.crypto,
org_tx.pwd
)
let total_to = new BN(0, 10)

@@ -72,4 +88,4 @@ let to_map = {}

// console.log('fetchUtxos param :', from, total_to.toString())
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const utxo_res = await cor.fetchUtxos({
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const utxo_res = await api.fetchUtxos({
addr: from,

@@ -82,3 +98,3 @@ amount: total_to.toString()

/* make unsigned tx */
const unsigned_tx = await TxUtil.makeUnsignedTxHandle({
const unsigned_tx = await Util.makeUnsignedTxHandle({
from,

@@ -90,3 +106,3 @@ to_map,

/* sign tx by privKey */
const signed_tx = await cor.signTxByPrivKey({
const signed_tx = await api.signTxByPrivKey({
unsignedTx: unsigned_tx.tx_json,

@@ -97,3 +113,4 @@ protocalTx: unsigned_tx.protocalTx,

/* send tx to boxd */
return await cor.sendTx(signed_tx)
return await api.sendTx(signed_tx)
} else {

@@ -105,3 +122,3 @@ throw new Error('Fetch utxos Error')

/**
* @export Make_Split_transaction_by_Crypto.json
* @export Make_split_transaction_by_crypto.json
* @param [*org_tx]

@@ -113,4 +130,4 @@ * @returns [Promise<sent_tx>] { splitAddr: string; hash: string }

): Promise<{ splitAddr: string; hash: string }> {
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await cor.makeUnsignedSplitAddrTx(org_tx.tx)
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await api.makeUnsignedSplitAddrTx(org_tx.tx)
const signed_tx = await this.signTxByCrypto({

@@ -124,8 +141,17 @@ unsignedTx: {

})
const tx_result = await cor.sendTx(signed_tx)
return Object.assign(tx_result, { splitAddr: unsigned_tx.splitAddr })
const tx_result = await api.sendTx(signed_tx)
const split_addr = await Util.calcSplitAddr({
addrs: org_tx.tx.addrs,
weights: org_tx.tx.weights,
txHash: tx_result.hash,
index: tx_result['index']
})
return Object.assign(tx_result, {
splitAddr: split_addr
})
}
/**
* @export Issue_Token_by_Crypto.json
* @export Issue_token_by_crypto.json
* @param [*org_tx]

@@ -137,4 +163,4 @@ * @returns [Promise<sent_tx>] { hash: string }

): Promise<{ hash: string }> {
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await cor.makeUnsignedTokenIssueTx(org_tx.tx)
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await api.makeUnsignedTokenIssueTx(org_tx.tx)
const signed_tx = await this.signTxByCrypto({

@@ -148,7 +174,8 @@ unsignedTx: {

})
return await cor.sendTx(signed_tx)
return await api.sendTx(signed_tx)
}
/**
* @export Make_Token_Transaction_by_Crypto.json
* @export Make_token_transaction_by_crypto.json
* @param [*org_tx]

@@ -160,4 +187,4 @@ * @returns [Promise<sent_tx>] { hash: string }

): Promise<{ hash: string }> {
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await cor.makeUnsignedTokenTx(org_tx.tx)
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await api.makeUnsignedTokenTx(org_tx.tx)
const signed_tx = await this.signTxByCrypto({

@@ -171,15 +198,37 @@ unsignedTx: {

})
return await cor.sendTx(signed_tx)
return await api.sendTx(signed_tx)
}
/**
* @export Make_Contract_transaction_by_Crypto.json
* @export Make_contract_transaction_by_priv_key.json
* @param [*org_tx]
* @param [*priv_key_hex_str]
* @returns [Promise<sent_tx>] { hash: string }
*/
public async makeContractTxByPrivKey(
org_tx: ContractRequest.OriginalContractReq, priv_key_hex_str: string
): Promise<{ hash: string; contractAddr: string }> {
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await api.makeUnsignedContractTx(org_tx)
const signed_tx = await this.signTxByPrivKey({
tx: unsigned_tx.tx,
rawMsgs: unsigned_tx.rawMsgs
}, priv_key_hex_str)
const tx_result = await api.sendTx(signed_tx)
return { hash: tx_result.hash, contractAddr: unsigned_tx.contract_addr }
}
/**
* @export Make_contract_transaction_by_crypto.json
* @param [*org_tx]
* @returns [Promise<sent_tx>] { hash: string }
*/
public async makeContractTxByCrypto(
org_tx: ContractRequest.ContractTxByCryptoReq
): Promise<{ hash: string; contractAddr: string }> {
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await cor.makeUnsignedContractTx(org_tx.tx)
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const unsigned_tx = await api.makeUnsignedContractTx(org_tx.tx)

@@ -194,3 +243,4 @@ const signed_tx = await this.signTxByCrypto({

})
const tx_result = await cor.sendTx(signed_tx)
const tx_result = await api.sendTx(signed_tx)
return { hash: tx_result.hash, contractAddr: unsigned_tx.contract_addr }

@@ -200,3 +250,3 @@ }

/**
* @export Call_Contract
* @export Call_contract
* @param [*org_tx]

@@ -208,6 +258,7 @@ * @returns [Promise<sent_tx>] { result: string }

): Promise<{ result: string }> {
const cor = new Core(this._fetch, this.endpoint, this.fetch_type)
const result = await cor.callContract(callParams)
const api = new Api(this._fetch, this.endpoint, this.fetch_type)
const result = await api.callContract(callParams)
return { result: result.output }
}
}
import UtilInterface from '../../util/interface'
namespace Request {
export interface SplitAddrTxReq {
from: string;
addrs: string[];
weights: number[];
fee: string;
}
export interface SplitAddrTxReq {
from: string;
addrs: string[];
weights: number[];
fee: string;
}
export interface MakeSplitTxByCryptoReq {
tx: SplitAddrTxReq;
crypto: UtilInterface.Crypto;
pwd: string;
}
export interface MakeSplitTxByCryptoReq {
tx: SplitAddrTxReq;
crypto: UtilInterface.Crypto;
pwd: string;
}
export interface CalcSplitAddrReq {
addrs: string[];
weights: number[];
txHash: string;
index: number;
}
}
export default Request
import bs58 from 'bs58'
import CommonUtil from '../../util/util'
namespace Util {
const op_hash_len = 32
/**
* @func getUint32
* @param [*buf] Buffer
*/
const getUint32 = (buf: Buffer) => {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)
}
import Util from '../../util/util'
/**
const op_hash_len = 32
/**
* @func Get_Uint32
* @param [*buf]
*/
const getUint32 = (buf: Buffer) => {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)
}
namespace TokenUtil {
/**
* @export hash+index=>token_address
* @param [*opHash] string
* @param [*index] number
* @returns [token_address] string
* @param [*opHash] token hash
* @param [*index] token index
* @returns [token_address]
*/
export const encodeTokenAddr = (token_addr: {
opHash: string;
index: number;
}): string => {
const { opHash, index } = token_addr
const before = Buffer.from(opHash, 'hex')
const end = CommonUtil.putUint32(Buffer.alloc(4), Number(index))
return bs58.encode(Buffer.concat([before, Buffer.from(':'), end]))
}
export const encodeTokenAddr = (token_addr: {
opHash: string;
index: number;
}): string => {
const { opHash, index } = token_addr
const before = Buffer.from(opHash, 'hex')
const end = Util.putUint32(Buffer.alloc(4), Number(index))
return bs58.encode(Buffer.concat([before, Buffer.from(':'), end]))
}
/**
/**
* @func token_address=>hash+index
* @param [*token_address] string
* @returns [{hash,index}] object
* @param [*token_address]
* @returns [{hash,index}]
*/
export const decodeTokenAddr = (token_address: string) => {
const token_addr_buf = bs58.decode(token_address)
const opHash = token_addr_buf.slice(0, op_hash_len).toString('hex')
const index = getUint32(token_addr_buf.slice(op_hash_len + 1))
return {
opHash,
index
}
export const decodeTokenAddr = (token_address: string) => {
const token_addr_buf = bs58.decode(token_address)
const opHash = token_addr_buf.slice(0, op_hash_len).toString('hex')
const index = getUint32(token_addr_buf.slice(op_hash_len + 1))
return {
opHash,
index
}
}
}
export default Util
export default TokenUtil
import BN from 'bn.js'
import block_pb from '../../util/protobuf-js/block_pb.js'
import Account from '../../account/account'
import CommonUtil from '../../util/util'
import Util from '../../util/util'
import TxRequest from './request'
namespace Util {
namespace TxUtil {
/**

@@ -54,6 +54,5 @@ * @func Make_Unsigned_transaction_handle

/* vout */
const acc = new Account()
const op = new CommonUtil.Opcoder('')
const op = new Util.Opcoder('')
Object.keys(to_map).forEach(to_addr => {
const pub_hash = acc.dumpPubKeyHashFromAddr(to_addr)
const pub_hash = Account.dumpPubKeyHashFromAddr(to_addr)
// console.log('pub_hash_1 :', pub_hash)

@@ -64,7 +63,7 @@

.reset('')
.add(CommonUtil.to16StrFromNumber(op.OP_DUP))
.add(CommonUtil.to16StrFromNumber(op.OP_HASH_160))
.add(Util.to16StrFromNumber(op.OP_DUP))
.add(Util.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(CommonUtil.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.to16StrFromNumber(op.OP_CHECK_SIG))
.add(Util.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(Util.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode()

@@ -92,3 +91,3 @@ // console.log('script :', script.toString('base64'))

// console.log('charge :', charge)
const pub_hash = acc.dumpPubKeyHashFromAddr(from)
const pub_hash = Account.dumpPubKeyHashFromAddr(from)
// console.log('pub_hash_2 :', pub_hash)

@@ -99,7 +98,7 @@

.reset('')
.add(CommonUtil.to16StrFromNumber(op.OP_DUP))
.add(CommonUtil.to16StrFromNumber(op.OP_HASH_160))
.add(Util.to16StrFromNumber(op.OP_DUP))
.add(Util.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(CommonUtil.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.to16StrFromNumber(op.OP_CHECK_SIG))
.add(Util.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(Util.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode()

@@ -209,2 +208,2 @@ // console.log('script :', script.toString('base64'))

export default Util
export default TxUtil
import ecc from 'tiny-secp256k1'
import CommonUtil from '../util'
import Util from '../util'
const OPCODE_TYPE = 'hex'
namespace Ecpair {

@@ -55,9 +53,9 @@ function canonicalizeInt(b: Buffer | Uint8Array) {

b1[0] = 0x30
b1[1] = CommonUtil.getBufFromNumber(length - 2)
b1[1] = Util.getBufFromNumber(length - 2)
b1[2] = 0x02
b1[3] = CommonUtil.getBufFromNumber(rb.length)
b1[3] = Util.getBufFromNumber(rb.length)
const b3 = Buffer.alloc(2)
b3[0] = 0x02
b3[1] = CommonUtil.getBufFromNumber(sb.length)
b3[1] = Util.getBufFromNumber(sb.length)

@@ -73,3 +71,4 @@ const allBytes = Buffer.concat([b1, rb, b3, sb])

export const getECfromPrivKey = function(privkey, options?) {
privkey = Buffer.from(privkey, OPCODE_TYPE)
// console.log('==> getECfromPrivKey')
privkey = Buffer.from(privkey, 'hex')
if (!ecc.isPrivate(privkey))

@@ -76,0 +75,0 @@ throw new TypeError('Private key not in range [1, n)')

@@ -5,7 +5,6 @@ import bitcore from 'bitcore-lib'

import Ecpair from './ecpair'
import CommonUtil from '../util'
import Util from '../util'
import CryptoJson from './crypto-json'
import UtilInterface from '../interface'
const OPCODE_TYPE = 'hex'
const prefix = {

@@ -24,2 +23,6 @@ P2PKH: '1326',

public constructor(privkey_str) {
console.log('privkey_str :', privkey_str)
if (privkey_str) {
privkey_str = privkey_str.padStart(64, '0')
}
this.privKey = new bitcore.PrivateKey(privkey_str)

@@ -38,3 +41,3 @@ this.privKey.signMsg = sigHash => {

* @param [*pwd]
* @returns [cryptoJSON]
* @returns [crypto.json]
* @memberof PrivateKey *

@@ -60,6 +63,6 @@ */

for (let idx = 0; idx < tx.vin.length; idx++) {
const sigHashBuf = CommonUtil.getSignHash(rawMsgs[idx])
const sigHashBuf = Util.getSignHash(rawMsgs[idx])
const eccPrivKey = _privKey && Ecpair.getECfromPrivKey(_privKey)
const signBuf = eccPrivKey.sign(sigHashBuf).sig
const scriptSig = await CommonUtil.signatureScript(
const scriptSig = await Util.signatureScript(
signBuf,

@@ -75,3 +78,3 @@ this.privKey.toPublicKey().toBuffer()

if (unsigned_tx.protocalTx) {
return unsigned_tx.protocalTx.serializeBinary().toString(OPCODE_TYPE)
return unsigned_tx.protocalTx.serializeBinary().toString('hex')
} else {

@@ -89,6 +92,6 @@ return tx

const checksum = Hash.sha256(
Hash.sha256(Buffer.from(sha256Content, OPCODE_TYPE))
Hash.sha256(Buffer.from(sha256Content, 'hex'))
).slice(0, 4)
const content = sha256Content.concat(checksum.toString(OPCODE_TYPE))
return bs58.encode(Buffer.from(content, OPCODE_TYPE))
const content = sha256Content.concat(checksum.toString('hex'))
return bs58.encode(Buffer.from(content, 'hex'))
}

@@ -101,6 +104,4 @@

public getPubKeyHashByPrivKey = () => {
return Hash.hash160(this.privKey.toPublicKey().toBuffer()).toString(
OPCODE_TYPE
)
return Hash.hash160(this.privKey.toPublicKey().toBuffer()).toString('hex')
}
}

@@ -32,3 +32,3 @@ /**

} else {
super('Unknow Error!')
super('Unknow Error !')
}

@@ -70,10 +70,6 @@ Object.setPrototypeOf(this, HttpError.prototype)

console.log(result)
return result
// result.code = response.status
// result.statusText = response.statusText
throw new HttpError(result)
}
result = await response.json()
// console.log('[fetch] Result:', result)
// console.log('[fetch] Result :', result)
if (result.code) {

@@ -84,3 +80,3 @@ if (result.code === 0) {

} else {
// console.log('[fetch] Error: code !== 0')
// console.log('[fetch] Error : code !== 0')
throw new HttpError(result)

@@ -87,0 +83,0 @@ }

@@ -93,4 +93,52 @@ namespace Interface {

}
interface LogsReq {
hash: string;
from: number;
to: number;
addresses: string[];
topics: string[];
}
export interface RegisterReq {
type: number;
info?: {
logs_req: LogsReq;
};
}
interface BlockDetail {
version: number;
height: number;
time_stamp: number;
size: number;
hash: string;
prev_block_hash: string;
coin_base: string;
confirmed: boolean;
signature: string;
TxDetail: [];
}
interface LogDetail {
address: string;
topics: string[];
data: string;
block_number: number;
tx_hash: string;
tx_index: number;
block_hash: string;
index: number;
removed: boolean;
}
export interface ListenedData {
type: number;
data?: {
block: BlockDetail;
logs: LogDetail[];
};
}
}
export default Interface

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-var-requires */
/**

@@ -11,10 +10,10 @@ * @fileoverview

var jspb = require('google-protobuf')
var goog = jspb
var global = Function('return this')()
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
var block_pb = require('./block_pb.js')
goog.object.extend(proto, block_pb)
goog.exportSymbol('proto.rpcpb.BaseResponse', null, global)
goog.exportSymbol('proto.rpcpb.Utxo', null, global)
var block_pb = require('./block_pb.js');
goog.object.extend(proto, block_pb);
goog.exportSymbol('proto.rpcpb.BaseResponse', null, global);
goog.exportSymbol('proto.rpcpb.Utxo', null, global);
/**

@@ -30,6 +29,6 @@ * Generated by JsPbCodeGenerator.

*/
proto.rpcpb.Utxo = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null)
}
goog.inherits(proto.rpcpb.Utxo, jspb.Message)
proto.rpcpb.Utxo = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.rpcpb.Utxo, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -40,3 +39,3 @@ /**

*/
proto.rpcpb.Utxo.displayName = 'proto.rpcpb.Utxo'
proto.rpcpb.Utxo.displayName = 'proto.rpcpb.Utxo';
}

@@ -53,6 +52,6 @@ /**

*/
proto.rpcpb.BaseResponse = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null)
}
goog.inherits(proto.rpcpb.BaseResponse, jspb.Message)
proto.rpcpb.BaseResponse = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.rpcpb.BaseResponse, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -63,3 +62,3 @@ /**

*/
proto.rpcpb.BaseResponse.displayName = 'proto.rpcpb.BaseResponse'
proto.rpcpb.BaseResponse.displayName = 'proto.rpcpb.BaseResponse';
}

@@ -70,40 +69,40 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.Utxo.prototype.toObject = function (opt_includeInstance) {
return proto.rpcpb.Utxo.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.Utxo.prototype.toObject = function(opt_includeInstance) {
return proto.rpcpb.Utxo.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.Utxo} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.Utxo.toObject = function (includeInstance, msg) {
var f, obj = {
outPoint: (f = msg.getOutPoint()) && block_pb.OutPoint.toObject(includeInstance, f),
txOut: (f = msg.getTxOut()) && block_pb.TxOut.toObject(includeInstance, f),
blockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0),
isCoinbase: jspb.Message.getFieldWithDefault(msg, 4, false),
isSpent: jspb.Message.getFieldWithDefault(msg, 5, false)
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.Utxo} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.Utxo.toObject = function(includeInstance, msg) {
var f, obj = {
outPoint: (f = msg.getOutPoint()) && block_pb.OutPoint.toObject(includeInstance, f),
txOut: (f = msg.getTxOut()) && block_pb.TxOut.toObject(includeInstance, f),
blockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0),
isCoinbase: jspb.Message.getFieldWithDefault(msg, 4, false),
isSpent: jspb.Message.getFieldWithDefault(msg, 5, false)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -117,7 +116,7 @@

*/
proto.rpcpb.Utxo.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.rpcpb.Utxo
return proto.rpcpb.Utxo.deserializeBinaryFromReader(msg, reader)
}
proto.rpcpb.Utxo.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.rpcpb.Utxo;
return proto.rpcpb.Utxo.deserializeBinaryFromReader(msg, reader);
};

@@ -132,38 +131,38 @@

*/
proto.rpcpb.Utxo.deserializeBinaryFromReader = function (msg, reader) {
proto.rpcpb.Utxo.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new block_pb.OutPoint
reader.readMessage(value, block_pb.OutPoint.deserializeBinaryFromReader)
msg.setOutPoint(value)
break
var value = new block_pb.OutPoint;
reader.readMessage(value,block_pb.OutPoint.deserializeBinaryFromReader);
msg.setOutPoint(value);
break;
case 2:
var value = new block_pb.TxOut
reader.readMessage(value, block_pb.TxOut.deserializeBinaryFromReader)
msg.setTxOut(value)
break
var value = new block_pb.TxOut;
reader.readMessage(value,block_pb.TxOut.deserializeBinaryFromReader);
msg.setTxOut(value);
break;
case 3:
var value = /** @type {number} */ (reader.readUint32())
msg.setBlockHeight(value)
break
var value = /** @type {number} */ (reader.readUint32());
msg.setBlockHeight(value);
break;
case 4:
var value = /** @type {boolean} */ (reader.readBool())
msg.setIsCoinbase(value)
break
var value = /** @type {boolean} */ (reader.readBool());
msg.setIsCoinbase(value);
break;
case 5:
var value = /** @type {boolean} */ (reader.readBool())
msg.setIsSpent(value)
break
var value = /** @type {boolean} */ (reader.readBool());
msg.setIsSpent(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -175,7 +174,7 @@

*/
proto.rpcpb.Utxo.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.rpcpb.Utxo.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.rpcpb.Utxo.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.rpcpb.Utxo.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -190,5 +189,5 @@

*/
proto.rpcpb.Utxo.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getOutPoint()
proto.rpcpb.Utxo.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getOutPoint();
if (f != null) {

@@ -199,5 +198,5 @@ writer.writeMessage(

block_pb.OutPoint.serializeBinaryToWriter
)
);
}
f = message.getTxOut()
f = message.getTxOut();
if (f != null) {

@@ -208,5 +207,5 @@ writer.writeMessage(

block_pb.TxOut.serializeBinaryToWriter
)
);
}
f = message.getBlockHeight()
f = message.getBlockHeight();
if (f !== 0) {

@@ -216,5 +215,5 @@ writer.writeUint32(

f
)
);
}
f = message.getIsCoinbase()
f = message.getIsCoinbase();
if (f) {

@@ -224,5 +223,5 @@ writer.writeBool(

f
)
);
}
f = message.getIsSpent()
f = message.getIsSpent();
if (f) {

@@ -232,5 +231,5 @@ writer.writeBool(

f
)
);
}
}
};

@@ -242,12 +241,12 @@

*/
proto.rpcpb.Utxo.prototype.getOutPoint = function () {
proto.rpcpb.Utxo.prototype.getOutPoint = function() {
return /** @type{?proto.corepb.OutPoint} */ (
jspb.Message.getWrapperField(this, block_pb.OutPoint, 1))
}
jspb.Message.getWrapperField(this, block_pb.OutPoint, 1));
};
/** @param {?proto.corepb.OutPoint|undefined} value */
proto.rpcpb.Utxo.prototype.setOutPoint = function (value) {
jspb.Message.setWrapperField(this, 1, value)
}
proto.rpcpb.Utxo.prototype.setOutPoint = function(value) {
jspb.Message.setWrapperField(this, 1, value);
};

@@ -258,5 +257,5 @@

*/
proto.rpcpb.Utxo.prototype.clearOutPoint = function () {
this.setOutPoint(undefined)
}
proto.rpcpb.Utxo.prototype.clearOutPoint = function() {
this.setOutPoint(undefined);
};

@@ -268,5 +267,5 @@

*/
proto.rpcpb.Utxo.prototype.hasOutPoint = function () {
return jspb.Message.getField(this, 1) != null
}
proto.rpcpb.Utxo.prototype.hasOutPoint = function() {
return jspb.Message.getField(this, 1) != null;
};

@@ -278,12 +277,12 @@

*/
proto.rpcpb.Utxo.prototype.getTxOut = function () {
proto.rpcpb.Utxo.prototype.getTxOut = function() {
return /** @type{?proto.corepb.TxOut} */ (
jspb.Message.getWrapperField(this, block_pb.TxOut, 2))
}
jspb.Message.getWrapperField(this, block_pb.TxOut, 2));
};
/** @param {?proto.corepb.TxOut|undefined} value */
proto.rpcpb.Utxo.prototype.setTxOut = function (value) {
jspb.Message.setWrapperField(this, 2, value)
}
proto.rpcpb.Utxo.prototype.setTxOut = function(value) {
jspb.Message.setWrapperField(this, 2, value);
};

@@ -294,5 +293,5 @@

*/
proto.rpcpb.Utxo.prototype.clearTxOut = function () {
this.setTxOut(undefined)
}
proto.rpcpb.Utxo.prototype.clearTxOut = function() {
this.setTxOut(undefined);
};

@@ -304,5 +303,5 @@

*/
proto.rpcpb.Utxo.prototype.hasTxOut = function () {
return jspb.Message.getField(this, 2) != null
}
proto.rpcpb.Utxo.prototype.hasTxOut = function() {
return jspb.Message.getField(this, 2) != null;
};

@@ -314,11 +313,11 @@

*/
proto.rpcpb.Utxo.prototype.getBlockHeight = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0))
}
proto.rpcpb.Utxo.prototype.getBlockHeight = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0));
};
/** @param {number} value */
proto.rpcpb.Utxo.prototype.setBlockHeight = function (value) {
jspb.Message.setProto3IntField(this, 3, value)
}
proto.rpcpb.Utxo.prototype.setBlockHeight = function(value) {
jspb.Message.setProto3IntField(this, 3, value);
};

@@ -332,11 +331,11 @@

*/
proto.rpcpb.Utxo.prototype.getIsCoinbase = function () {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 4, false))
}
proto.rpcpb.Utxo.prototype.getIsCoinbase = function() {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 4, false));
};
/** @param {boolean} value */
proto.rpcpb.Utxo.prototype.setIsCoinbase = function (value) {
jspb.Message.setProto3BooleanField(this, 4, value)
}
proto.rpcpb.Utxo.prototype.setIsCoinbase = function(value) {
jspb.Message.setProto3BooleanField(this, 4, value);
};

@@ -350,11 +349,11 @@

*/
proto.rpcpb.Utxo.prototype.getIsSpent = function () {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 5, false))
}
proto.rpcpb.Utxo.prototype.getIsSpent = function() {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 5, false));
};
/** @param {boolean} value */
proto.rpcpb.Utxo.prototype.setIsSpent = function (value) {
jspb.Message.setProto3BooleanField(this, 5, value)
}
proto.rpcpb.Utxo.prototype.setIsSpent = function(value) {
jspb.Message.setProto3BooleanField(this, 5, value);
};

@@ -366,37 +365,37 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.BaseResponse.prototype.toObject = function (opt_includeInstance) {
return proto.rpcpb.BaseResponse.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.BaseResponse.prototype.toObject = function(opt_includeInstance) {
return proto.rpcpb.BaseResponse.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.BaseResponse} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.BaseResponse.toObject = function (includeInstance, msg) {
var f, obj = {
code: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, '')
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.BaseResponse} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.BaseResponse.toObject = function(includeInstance, msg) {
var f, obj = {
code: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -410,7 +409,7 @@

*/
proto.rpcpb.BaseResponse.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.rpcpb.BaseResponse
return proto.rpcpb.BaseResponse.deserializeBinaryFromReader(msg, reader)
}
proto.rpcpb.BaseResponse.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.rpcpb.BaseResponse;
return proto.rpcpb.BaseResponse.deserializeBinaryFromReader(msg, reader);
};

@@ -425,24 +424,24 @@

*/
proto.rpcpb.BaseResponse.deserializeBinaryFromReader = function (msg, reader) {
proto.rpcpb.BaseResponse.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {number} */ (reader.readInt32())
msg.setCode(value)
break
var value = /** @type {number} */ (reader.readInt32());
msg.setCode(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString())
msg.setMessage(value)
break
var value = /** @type {string} */ (reader.readString());
msg.setMessage(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -454,7 +453,7 @@

*/
proto.rpcpb.BaseResponse.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.rpcpb.BaseResponse.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.rpcpb.BaseResponse.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.rpcpb.BaseResponse.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -469,5 +468,5 @@

*/
proto.rpcpb.BaseResponse.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getCode()
proto.rpcpb.BaseResponse.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getCode();
if (f !== 0) {

@@ -477,5 +476,5 @@ writer.writeInt32(

f
)
);
}
f = message.getMessage()
f = message.getMessage();
if (f.length > 0) {

@@ -485,5 +484,5 @@ writer.writeString(

f
)
);
}
}
};

@@ -495,11 +494,11 @@

*/
proto.rpcpb.BaseResponse.prototype.getCode = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0))
}
proto.rpcpb.BaseResponse.prototype.getCode = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};
/** @param {number} value */
proto.rpcpb.BaseResponse.prototype.setCode = function (value) {
jspb.Message.setProto3IntField(this, 1, value)
}
proto.rpcpb.BaseResponse.prototype.setCode = function(value) {
jspb.Message.setProto3IntField(this, 1, value);
};

@@ -511,13 +510,13 @@

*/
proto.rpcpb.BaseResponse.prototype.getMessage = function () {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ''))
}
proto.rpcpb.BaseResponse.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.rpcpb.BaseResponse.prototype.setMessage = function (value) {
jspb.Message.setProto3StringField(this, 2, value)
}
proto.rpcpb.BaseResponse.prototype.setMessage = function(value) {
jspb.Message.setProto3StringField(this, 2, value);
};
goog.object.extend(exports, proto.rpcpb)
goog.object.extend(exports, proto.rpcpb);

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-var-requires */
/**

@@ -11,8 +10,8 @@ * @fileoverview

var jspb = require('google-protobuf')
var goog = jspb
var global = Function('return this')()
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
goog.exportSymbol('proto.rpcpb.ClaimReq', null, global)
goog.exportSymbol('proto.rpcpb.ClaimResp', null, global)
goog.exportSymbol('proto.rpcpb.ClaimReq', null, global);
goog.exportSymbol('proto.rpcpb.ClaimResp', null, global);
/**

@@ -28,6 +27,6 @@ * Generated by JsPbCodeGenerator.

*/
proto.rpcpb.ClaimReq = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null)
}
goog.inherits(proto.rpcpb.ClaimReq, jspb.Message)
proto.rpcpb.ClaimReq = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.rpcpb.ClaimReq, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -38,3 +37,3 @@ /**

*/
proto.rpcpb.ClaimReq.displayName = 'proto.rpcpb.ClaimReq'
proto.rpcpb.ClaimReq.displayName = 'proto.rpcpb.ClaimReq';
}

@@ -51,6 +50,6 @@ /**

*/
proto.rpcpb.ClaimResp = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null)
}
goog.inherits(proto.rpcpb.ClaimResp, jspb.Message)
proto.rpcpb.ClaimResp = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.rpcpb.ClaimResp, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -61,3 +60,3 @@ /**

*/
proto.rpcpb.ClaimResp.displayName = 'proto.rpcpb.ClaimResp'
proto.rpcpb.ClaimResp.displayName = 'proto.rpcpb.ClaimResp';
}

@@ -68,37 +67,37 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.ClaimReq.prototype.toObject = function (opt_includeInstance) {
return proto.rpcpb.ClaimReq.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.ClaimReq.prototype.toObject = function(opt_includeInstance) {
return proto.rpcpb.ClaimReq.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.ClaimReq} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.ClaimReq.toObject = function (includeInstance, msg) {
var f, obj = {
addr: jspb.Message.getFieldWithDefault(msg, 1, ''),
amount: jspb.Message.getFieldWithDefault(msg, 2, 0)
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.ClaimReq} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.ClaimReq.toObject = function(includeInstance, msg) {
var f, obj = {
addr: jspb.Message.getFieldWithDefault(msg, 1, ""),
amount: jspb.Message.getFieldWithDefault(msg, 2, 0)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -112,7 +111,7 @@

*/
proto.rpcpb.ClaimReq.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.rpcpb.ClaimReq
return proto.rpcpb.ClaimReq.deserializeBinaryFromReader(msg, reader)
}
proto.rpcpb.ClaimReq.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.rpcpb.ClaimReq;
return proto.rpcpb.ClaimReq.deserializeBinaryFromReader(msg, reader);
};

@@ -127,24 +126,24 @@

*/
proto.rpcpb.ClaimReq.deserializeBinaryFromReader = function (msg, reader) {
proto.rpcpb.ClaimReq.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString())
msg.setAddr(value)
break
var value = /** @type {string} */ (reader.readString());
msg.setAddr(value);
break;
case 2:
var value = /** @type {number} */ (reader.readUint64())
msg.setAmount(value)
break
var value = /** @type {number} */ (reader.readUint64());
msg.setAmount(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -156,7 +155,7 @@

*/
proto.rpcpb.ClaimReq.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.rpcpb.ClaimReq.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.rpcpb.ClaimReq.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.rpcpb.ClaimReq.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -171,5 +170,5 @@

*/
proto.rpcpb.ClaimReq.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getAddr()
proto.rpcpb.ClaimReq.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getAddr();
if (f.length > 0) {

@@ -179,5 +178,5 @@ writer.writeString(

f
)
);
}
f = message.getAmount()
f = message.getAmount();
if (f !== 0) {

@@ -187,5 +186,5 @@ writer.writeUint64(

f
)
);
}
}
};

@@ -197,11 +196,11 @@

*/
proto.rpcpb.ClaimReq.prototype.getAddr = function () {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ''))
}
proto.rpcpb.ClaimReq.prototype.getAddr = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.rpcpb.ClaimReq.prototype.setAddr = function (value) {
jspb.Message.setProto3StringField(this, 1, value)
}
proto.rpcpb.ClaimReq.prototype.setAddr = function(value) {
jspb.Message.setProto3StringField(this, 1, value);
};

@@ -213,11 +212,11 @@

*/
proto.rpcpb.ClaimReq.prototype.getAmount = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0))
}
proto.rpcpb.ClaimReq.prototype.getAmount = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};
/** @param {number} value */
proto.rpcpb.ClaimReq.prototype.setAmount = function (value) {
jspb.Message.setProto3IntField(this, 2, value)
}
proto.rpcpb.ClaimReq.prototype.setAmount = function(value) {
jspb.Message.setProto3IntField(this, 2, value);
};

@@ -229,38 +228,38 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.ClaimResp.prototype.toObject = function (opt_includeInstance) {
return proto.rpcpb.ClaimResp.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.rpcpb.ClaimResp.prototype.toObject = function(opt_includeInstance) {
return proto.rpcpb.ClaimResp.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.ClaimResp} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.ClaimResp.toObject = function (includeInstance, msg) {
var f, obj = {
code: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, ''),
hash: jspb.Message.getFieldWithDefault(msg, 3, '')
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.rpcpb.ClaimResp} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.rpcpb.ClaimResp.toObject = function(includeInstance, msg) {
var f, obj = {
code: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, ""),
hash: jspb.Message.getFieldWithDefault(msg, 3, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -274,7 +273,7 @@

*/
proto.rpcpb.ClaimResp.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.rpcpb.ClaimResp
return proto.rpcpb.ClaimResp.deserializeBinaryFromReader(msg, reader)
}
proto.rpcpb.ClaimResp.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.rpcpb.ClaimResp;
return proto.rpcpb.ClaimResp.deserializeBinaryFromReader(msg, reader);
};

@@ -289,28 +288,28 @@

*/
proto.rpcpb.ClaimResp.deserializeBinaryFromReader = function (msg, reader) {
proto.rpcpb.ClaimResp.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {number} */ (reader.readInt32())
msg.setCode(value)
break
var value = /** @type {number} */ (reader.readInt32());
msg.setCode(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString())
msg.setMessage(value)
break
var value = /** @type {string} */ (reader.readString());
msg.setMessage(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString())
msg.setHash(value)
break
var value = /** @type {string} */ (reader.readString());
msg.setHash(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -322,7 +321,7 @@

*/
proto.rpcpb.ClaimResp.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.rpcpb.ClaimResp.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.rpcpb.ClaimResp.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.rpcpb.ClaimResp.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -337,5 +336,5 @@

*/
proto.rpcpb.ClaimResp.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getCode()
proto.rpcpb.ClaimResp.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getCode();
if (f !== 0) {

@@ -345,5 +344,5 @@ writer.writeInt32(

f
)
);
}
f = message.getMessage()
f = message.getMessage();
if (f.length > 0) {

@@ -353,5 +352,5 @@ writer.writeString(

f
)
);
}
f = message.getHash()
f = message.getHash();
if (f.length > 0) {

@@ -361,5 +360,5 @@ writer.writeString(

f
)
);
}
}
};

@@ -371,11 +370,11 @@

*/
proto.rpcpb.ClaimResp.prototype.getCode = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0))
}
proto.rpcpb.ClaimResp.prototype.getCode = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};
/** @param {number} value */
proto.rpcpb.ClaimResp.prototype.setCode = function (value) {
jspb.Message.setProto3IntField(this, 1, value)
}
proto.rpcpb.ClaimResp.prototype.setCode = function(value) {
jspb.Message.setProto3IntField(this, 1, value);
};

@@ -387,11 +386,11 @@

*/
proto.rpcpb.ClaimResp.prototype.getMessage = function () {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ''))
}
proto.rpcpb.ClaimResp.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.rpcpb.ClaimResp.prototype.setMessage = function (value) {
jspb.Message.setProto3StringField(this, 2, value)
}
proto.rpcpb.ClaimResp.prototype.setMessage = function(value) {
jspb.Message.setProto3StringField(this, 2, value);
};

@@ -403,13 +402,13 @@

*/
proto.rpcpb.ClaimResp.prototype.getHash = function () {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ''))
}
proto.rpcpb.ClaimResp.prototype.getHash = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.rpcpb.ClaimResp.prototype.setHash = function (value) {
jspb.Message.setProto3StringField(this, 3, value)
}
proto.rpcpb.ClaimResp.prototype.setHash = function(value) {
jspb.Message.setProto3StringField(this, 3, value);
};
goog.object.extend(exports, proto.rpcpb)
goog.object.extend(exports, proto.rpcpb);

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-var-requires */
/**

@@ -11,7 +10,8 @@ * @fileoverview

var jspb = require('google-protobuf')
var goog = jspb
var global = Function('return this')()
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
goog.exportSymbol('proto.corepb.Log', null, global)
goog.exportSymbol('proto.corepb.HashLog', null, global);
goog.exportSymbol('proto.corepb.Log', null, global);
/**

@@ -27,6 +27,27 @@ * Generated by JsPbCodeGenerator.

*/
proto.corepb.Log = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.Log.repeatedFields_, null)
proto.corepb.Log = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.Log.repeatedFields_, null);
};
goog.inherits(proto.corepb.Log, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.corepb.Log.displayName = 'proto.corepb.Log';
}
goog.inherits(proto.corepb.Log, jspb.Message)
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.corepb.HashLog = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.HashLog.repeatedFields_, null);
};
goog.inherits(proto.corepb.HashLog, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -37,3 +58,3 @@ /**

*/
proto.corepb.Log.displayName = 'proto.corepb.Log'
proto.corepb.HashLog.displayName = 'proto.corepb.HashLog';
}

@@ -46,3 +67,3 @@

*/
proto.corepb.Log.repeatedFields_ = [2]
proto.corepb.Log.repeatedFields_ = [2];

@@ -52,44 +73,43 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Log.prototype.toObject = function (opt_includeInstance) {
return proto.corepb.Log.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Log.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.Log.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Log} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Log.toObject = function (includeInstance, msg) {
var f, obj = {
address: msg.getAddress_asB64(),
topicsList: msg.getTopicsList_asB64(),
data: msg.getData_asB64(),
blockNumber: jspb.Message.getFieldWithDefault(msg, 4, 0),
txHash: msg.getTxHash_asB64(),
txIndex: jspb.Message.getFieldWithDefault(msg, 6, 0),
blockHash: msg.getBlockHash_asB64(),
index: jspb.Message.getFieldWithDefault(msg, 8, 0),
removed: jspb.Message.getFieldWithDefault(msg, 9, false)
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Log} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Log.toObject = function(includeInstance, msg) {
var f, obj = {
address: msg.getAddress_asB64(),
topicsList: msg.getTopicsList_asB64(),
data: msg.getData_asB64(),
blockNumber: jspb.Message.getFieldWithDefault(msg, 4, 0),
txHash: msg.getTxHash_asB64(),
txIndex: jspb.Message.getFieldWithDefault(msg, 6, 0),
index: jspb.Message.getFieldWithDefault(msg, 8, 0),
removed: jspb.Message.getFieldWithDefault(msg, 9, false)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -103,7 +123,7 @@

*/
proto.corepb.Log.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.corepb.Log
return proto.corepb.Log.deserializeBinaryFromReader(msg, reader)
}
proto.corepb.Log.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.Log;
return proto.corepb.Log.deserializeBinaryFromReader(msg, reader);
};

@@ -118,52 +138,48 @@

*/
proto.corepb.Log.deserializeBinaryFromReader = function (msg, reader) {
proto.corepb.Log.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.setAddress(value)
break
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setAddress(value);
break;
case 2:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.addTopics(value)
break
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.addTopics(value);
break;
case 3:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.setData(value)
break
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setData(value);
break;
case 4:
var value = /** @type {number} */ (reader.readUint64())
msg.setBlockNumber(value)
break
var value = /** @type {number} */ (reader.readUint64());
msg.setBlockNumber(value);
break;
case 5:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.setTxHash(value)
break
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setTxHash(value);
break;
case 6:
var value = /** @type {number} */ (reader.readUint32())
msg.setTxIndex(value)
break
case 7:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.setBlockHash(value)
break
var value = /** @type {number} */ (reader.readUint32());
msg.setTxIndex(value);
break;
case 8:
var value = /** @type {number} */ (reader.readUint32())
msg.setIndex(value)
break
var value = /** @type {number} */ (reader.readUint32());
msg.setIndex(value);
break;
case 9:
var value = /** @type {boolean} */ (reader.readBool())
msg.setRemoved(value)
break
var value = /** @type {boolean} */ (reader.readBool());
msg.setRemoved(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -175,7 +191,7 @@

*/
proto.corepb.Log.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.corepb.Log.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.corepb.Log.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.Log.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -190,5 +206,5 @@

*/
proto.corepb.Log.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getAddress_asU8()
proto.corepb.Log.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getAddress_asU8();
if (f.length > 0) {

@@ -198,5 +214,5 @@ writer.writeBytes(

f
)
);
}
f = message.getTopicsList_asU8()
f = message.getTopicsList_asU8();
if (f.length > 0) {

@@ -206,5 +222,5 @@ writer.writeRepeatedBytes(

f
)
);
}
f = message.getData_asU8()
f = message.getData_asU8();
if (f.length > 0) {

@@ -214,5 +230,5 @@ writer.writeBytes(

f
)
);
}
f = message.getBlockNumber()
f = message.getBlockNumber();
if (f !== 0) {

@@ -222,5 +238,5 @@ writer.writeUint64(

f
)
);
}
f = message.getTxHash_asU8()
f = message.getTxHash_asU8();
if (f.length > 0) {

@@ -230,5 +246,5 @@ writer.writeBytes(

f
)
);
}
f = message.getTxIndex()
f = message.getTxIndex();
if (f !== 0) {

@@ -238,12 +254,5 @@ writer.writeUint32(

f
)
);
}
f = message.getBlockHash_asU8()
if (f.length > 0) {
writer.writeBytes(
7,
f
)
}
f = message.getIndex()
f = message.getIndex();
if (f !== 0) {

@@ -253,5 +262,5 @@ writer.writeUint32(

f
)
);
}
f = message.getRemoved()
f = message.getRemoved();
if (f) {

@@ -261,5 +270,5 @@ writer.writeBool(

f
)
);
}
}
};

@@ -271,5 +280,5 @@

*/
proto.corepb.Log.prototype.getAddress = function () {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ''))
}
proto.corepb.Log.prototype.getAddress = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};

@@ -282,6 +291,6 @@

*/
proto.corepb.Log.prototype.getAddress_asB64 = function () {
proto.corepb.Log.prototype.getAddress_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getAddress()))
}
this.getAddress()));
};

@@ -296,12 +305,12 @@

*/
proto.corepb.Log.prototype.getAddress_asU8 = function () {
proto.corepb.Log.prototype.getAddress_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getAddress()))
}
this.getAddress()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Log.prototype.setAddress = function (value) {
jspb.Message.setProto3BytesField(this, 1, value)
}
proto.corepb.Log.prototype.setAddress = function(value) {
jspb.Message.setProto3BytesField(this, 1, value);
};

@@ -313,5 +322,5 @@

*/
proto.corepb.Log.prototype.getTopicsList = function () {
return /** @type {!(Array<!Uint8Array>|Array<string>)} */ (jspb.Message.getRepeatedField(this, 2))
}
proto.corepb.Log.prototype.getTopicsList = function() {
return /** @type {!(Array<!Uint8Array>|Array<string>)} */ (jspb.Message.getRepeatedField(this, 2));
};

@@ -324,6 +333,6 @@

*/
proto.corepb.Log.prototype.getTopicsList_asB64 = function () {
proto.corepb.Log.prototype.getTopicsList_asB64 = function() {
return /** @type {!Array<string>} */ (jspb.Message.bytesListAsB64(
this.getTopicsList()))
}
this.getTopicsList()));
};

@@ -338,12 +347,12 @@

*/
proto.corepb.Log.prototype.getTopicsList_asU8 = function () {
proto.corepb.Log.prototype.getTopicsList_asU8 = function() {
return /** @type {!Array<!Uint8Array>} */ (jspb.Message.bytesListAsU8(
this.getTopicsList()))
}
this.getTopicsList()));
};
/** @param {!(Array<!Uint8Array>|Array<string>)} value */
proto.corepb.Log.prototype.setTopicsList = function (value) {
jspb.Message.setField(this, 2, value || [])
}
proto.corepb.Log.prototype.setTopicsList = function(value) {
jspb.Message.setField(this, 2, value || []);
};

@@ -355,5 +364,5 @@

*/
proto.corepb.Log.prototype.addTopics = function (value, opt_index) {
jspb.Message.addToRepeatedField(this, 2, value, opt_index)
}
proto.corepb.Log.prototype.addTopics = function(value, opt_index) {
jspb.Message.addToRepeatedField(this, 2, value, opt_index);
};

@@ -364,5 +373,5 @@

*/
proto.corepb.Log.prototype.clearTopicsList = function () {
this.setTopicsList([])
}
proto.corepb.Log.prototype.clearTopicsList = function() {
this.setTopicsList([]);
};

@@ -374,5 +383,5 @@

*/
proto.corepb.Log.prototype.getData = function () {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, ''))
}
proto.corepb.Log.prototype.getData = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};

@@ -385,6 +394,6 @@

*/
proto.corepb.Log.prototype.getData_asB64 = function () {
proto.corepb.Log.prototype.getData_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getData()))
}
this.getData()));
};

@@ -399,12 +408,12 @@

*/
proto.corepb.Log.prototype.getData_asU8 = function () {
proto.corepb.Log.prototype.getData_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getData()))
}
this.getData()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Log.prototype.setData = function (value) {
jspb.Message.setProto3BytesField(this, 3, value)
}
proto.corepb.Log.prototype.setData = function(value) {
jspb.Message.setProto3BytesField(this, 3, value);
};

@@ -416,11 +425,11 @@

*/
proto.corepb.Log.prototype.getBlockNumber = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0))
}
proto.corepb.Log.prototype.getBlockNumber = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
};
/** @param {number} value */
proto.corepb.Log.prototype.setBlockNumber = function (value) {
jspb.Message.setProto3IntField(this, 4, value)
}
proto.corepb.Log.prototype.setBlockNumber = function(value) {
jspb.Message.setProto3IntField(this, 4, value);
};

@@ -432,5 +441,5 @@

*/
proto.corepb.Log.prototype.getTxHash = function () {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 5, ''))
}
proto.corepb.Log.prototype.getTxHash = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
};

@@ -443,6 +452,6 @@

*/
proto.corepb.Log.prototype.getTxHash_asB64 = function () {
proto.corepb.Log.prototype.getTxHash_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getTxHash()))
}
this.getTxHash()));
};

@@ -457,12 +466,12 @@

*/
proto.corepb.Log.prototype.getTxHash_asU8 = function () {
proto.corepb.Log.prototype.getTxHash_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getTxHash()))
}
this.getTxHash()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Log.prototype.setTxHash = function (value) {
jspb.Message.setProto3BytesField(this, 5, value)
}
proto.corepb.Log.prototype.setTxHash = function(value) {
jspb.Message.setProto3BytesField(this, 5, value);
};

@@ -474,10 +483,92 @@

*/
proto.corepb.Log.prototype.getTxIndex = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0))
}
proto.corepb.Log.prototype.getTxIndex = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0));
};
/** @param {number} value */
proto.corepb.Log.prototype.setTxIndex = function (value) {
jspb.Message.setProto3IntField(this, 6, value)
proto.corepb.Log.prototype.setTxIndex = function(value) {
jspb.Message.setProto3IntField(this, 6, value);
};
/**
* optional uint32 index = 8;
* @return {number}
*/
proto.corepb.Log.prototype.getIndex = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 8, 0));
};
/** @param {number} value */
proto.corepb.Log.prototype.setIndex = function(value) {
jspb.Message.setProto3IntField(this, 8, value);
};
/**
* optional bool removed = 9;
* Note that Boolean fields may be set to 0/1 when serialized from a Java server.
* You should avoid comparisons like {@code val === true/false} in those cases.
* @return {boolean}
*/
proto.corepb.Log.prototype.getRemoved = function() {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 9, false));
};
/** @param {boolean} value */
proto.corepb.Log.prototype.setRemoved = function(value) {
jspb.Message.setProto3BooleanField(this, 9, value);
};
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.corepb.HashLog.repeatedFields_ = [2];
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.HashLog.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.HashLog.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.HashLog} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashLog.toObject = function(includeInstance, msg) {
var f, obj = {
address: msg.getAddress_asB64(),
topicsList: msg.getTopicsList_asB64(),
data: msg.getData_asB64()
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -487,72 +578,226 @@

/**
* optional bytes block_hash = 7;
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.corepb.HashLog}
*/
proto.corepb.HashLog.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.HashLog;
return proto.corepb.HashLog.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.corepb.HashLog} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.corepb.HashLog}
*/
proto.corepb.HashLog.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setAddress(value);
break;
case 2:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.addTopics(value);
break;
case 3:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setData(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.corepb.HashLog.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.HashLog.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.corepb.HashLog} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashLog.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getAddress_asU8();
if (f.length > 0) {
writer.writeBytes(
1,
f
);
}
f = message.getTopicsList_asU8();
if (f.length > 0) {
writer.writeRepeatedBytes(
2,
f
);
}
f = message.getData_asU8();
if (f.length > 0) {
writer.writeBytes(
3,
f
);
}
};
/**
* optional bytes address = 1;
* @return {!(string|Uint8Array)}
*/
proto.corepb.Log.prototype.getBlockHash = function () {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 7, ''))
}
proto.corepb.HashLog.prototype.getAddress = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/**
* optional bytes block_hash = 7;
* This is a type-conversion wrapper around `getBlockHash()`
* optional bytes address = 1;
* This is a type-conversion wrapper around `getAddress()`
* @return {string}
*/
proto.corepb.Log.prototype.getBlockHash_asB64 = function () {
proto.corepb.HashLog.prototype.getAddress_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getBlockHash()))
}
this.getAddress()));
};
/**
* optional bytes block_hash = 7;
* optional bytes address = 1;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getBlockHash()`
* This is a type-conversion wrapper around `getAddress()`
* @return {!Uint8Array}
*/
proto.corepb.Log.prototype.getBlockHash_asU8 = function () {
proto.corepb.HashLog.prototype.getAddress_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getBlockHash()))
}
this.getAddress()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Log.prototype.setBlockHash = function (value) {
jspb.Message.setProto3BytesField(this, 7, value)
}
proto.corepb.HashLog.prototype.setAddress = function(value) {
jspb.Message.setProto3BytesField(this, 1, value);
};
/**
* optional uint32 index = 8;
* @return {number}
* repeated bytes topics = 2;
* @return {!(Array<!Uint8Array>|Array<string>)}
*/
proto.corepb.Log.prototype.getIndex = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 8, 0))
}
proto.corepb.HashLog.prototype.getTopicsList = function() {
return /** @type {!(Array<!Uint8Array>|Array<string>)} */ (jspb.Message.getRepeatedField(this, 2));
};
/** @param {number} value */
proto.corepb.Log.prototype.setIndex = function (value) {
jspb.Message.setProto3IntField(this, 8, value)
}
/**
* repeated bytes topics = 2;
* This is a type-conversion wrapper around `getTopicsList()`
* @return {!Array<string>}
*/
proto.corepb.HashLog.prototype.getTopicsList_asB64 = function() {
return /** @type {!Array<string>} */ (jspb.Message.bytesListAsB64(
this.getTopicsList()));
};
/**
* optional bool removed = 9;
* Note that Boolean fields may be set to 0/1 when serialized from a Java server.
* You should avoid comparisons like {@code val === true/false} in those cases.
* @return {boolean}
* repeated bytes topics = 2;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getTopicsList()`
* @return {!Array<!Uint8Array>}
*/
proto.corepb.Log.prototype.getRemoved = function () {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 9, false))
}
proto.corepb.HashLog.prototype.getTopicsList_asU8 = function() {
return /** @type {!Array<!Uint8Array>} */ (jspb.Message.bytesListAsU8(
this.getTopicsList()));
};
/** @param {boolean} value */
proto.corepb.Log.prototype.setRemoved = function (value) {
jspb.Message.setProto3BooleanField(this, 9, value)
}
/** @param {!(Array<!Uint8Array>|Array<string>)} value */
proto.corepb.HashLog.prototype.setTopicsList = function(value) {
jspb.Message.setField(this, 2, value || []);
};
goog.object.extend(exports, proto.corepb)
/**
* @param {!(string|Uint8Array)} value
* @param {number=} opt_index
*/
proto.corepb.HashLog.prototype.addTopics = function(value, opt_index) {
jspb.Message.addToRepeatedField(this, 2, value, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.corepb.HashLog.prototype.clearTopicsList = function() {
this.setTopicsList([]);
};
/**
* optional bytes data = 3;
* @return {!(string|Uint8Array)}
*/
proto.corepb.HashLog.prototype.getData = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/**
* optional bytes data = 3;
* This is a type-conversion wrapper around `getData()`
* @return {string}
*/
proto.corepb.HashLog.prototype.getData_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getData()));
};
/**
* optional bytes data = 3;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getData()`
* @return {!Uint8Array}
*/
proto.corepb.HashLog.prototype.getData_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getData()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.HashLog.prototype.setData = function(value) {
jspb.Message.setProto3BytesField(this, 3, value);
};
goog.object.extend(exports, proto.corepb);

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-var-requires */
/**

@@ -11,8 +10,12 @@ * @fileoverview

var jspb = require('google-protobuf')
var goog = jspb
var global = Function('return this')()
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
goog.exportSymbol('proto.corepb.Receipt', null, global)
goog.exportSymbol('proto.corepb.Receipts', null, global)
var log_pb = require('./log_pb.js');
goog.object.extend(proto, log_pb);
goog.exportSymbol('proto.corepb.HashReceipt', null, global);
goog.exportSymbol('proto.corepb.HashReceipts', null, global);
goog.exportSymbol('proto.corepb.Receipt', null, global);
goog.exportSymbol('proto.corepb.Receipts', null, global);
/**

@@ -28,6 +31,27 @@ * Generated by JsPbCodeGenerator.

*/
proto.corepb.Receipt = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null)
proto.corepb.Receipt = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.Receipt.repeatedFields_, null);
};
goog.inherits(proto.corepb.Receipt, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.corepb.Receipt.displayName = 'proto.corepb.Receipt';
}
goog.inherits(proto.corepb.Receipt, jspb.Message)
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.corepb.Receipts = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.Receipts.repeatedFields_, null);
};
goog.inherits(proto.corepb.Receipts, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -38,3 +62,3 @@ /**

*/
proto.corepb.Receipt.displayName = 'proto.corepb.Receipt'
proto.corepb.Receipts.displayName = 'proto.corepb.Receipts';
}

@@ -51,6 +75,27 @@ /**

*/
proto.corepb.Receipts = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.Receipts.repeatedFields_, null)
proto.corepb.HashReceipt = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.HashReceipt.repeatedFields_, null);
};
goog.inherits(proto.corepb.HashReceipt, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.corepb.HashReceipt.displayName = 'proto.corepb.HashReceipt';
}
goog.inherits(proto.corepb.Receipts, jspb.Message)
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.corepb.HashReceipts = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.corepb.HashReceipts.repeatedFields_, null);
};
goog.inherits(proto.corepb.HashReceipts, jspb.Message);
if (goog.DEBUG && !COMPILED) {

@@ -61,45 +106,55 @@ /**

*/
proto.corepb.Receipts.displayName = 'proto.corepb.Receipts'
proto.corepb.HashReceipts.displayName = 'proto.corepb.HashReceipts';
}
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.corepb.Receipt.repeatedFields_ = [5];
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Receipt.prototype.toObject = function (opt_includeInstance) {
return proto.corepb.Receipt.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Receipt.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.Receipt.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Receipt} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Receipt.toObject = function (includeInstance, msg) {
var f, obj = {
txHash: msg.getTxHash_asB64(),
txIndex: jspb.Message.getFieldWithDefault(msg, 2, 0),
failed: jspb.Message.getFieldWithDefault(msg, 3, false),
gasUsed: jspb.Message.getFieldWithDefault(msg, 4, 0)
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Receipt} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Receipt.toObject = function(includeInstance, msg) {
var f, obj = {
txHash: msg.getTxHash_asB64(),
txIndex: jspb.Message.getFieldWithDefault(msg, 2, 0),
failed: jspb.Message.getFieldWithDefault(msg, 3, false),
gasUsed: jspb.Message.getFieldWithDefault(msg, 4, 0),
logsList: jspb.Message.toObjectList(msg.getLogsList(),
log_pb.Log.toObject, includeInstance),
bloom: msg.getBloom_asB64()
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -113,7 +168,7 @@

*/
proto.corepb.Receipt.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.corepb.Receipt
return proto.corepb.Receipt.deserializeBinaryFromReader(msg, reader)
}
proto.corepb.Receipt.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.Receipt;
return proto.corepb.Receipt.deserializeBinaryFromReader(msg, reader);
};

@@ -128,32 +183,41 @@

*/
proto.corepb.Receipt.deserializeBinaryFromReader = function (msg, reader) {
proto.corepb.Receipt.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!Uint8Array} */ (reader.readBytes())
msg.setTxHash(value)
break
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setTxHash(value);
break;
case 2:
var value = /** @type {number} */ (reader.readUint32())
msg.setTxIndex(value)
break
var value = /** @type {number} */ (reader.readUint32());
msg.setTxIndex(value);
break;
case 3:
var value = /** @type {boolean} */ (reader.readBool())
msg.setFailed(value)
break
var value = /** @type {boolean} */ (reader.readBool());
msg.setFailed(value);
break;
case 4:
var value = /** @type {number} */ (reader.readUint64())
msg.setGasUsed(value)
break
var value = /** @type {number} */ (reader.readUint64());
msg.setGasUsed(value);
break;
case 5:
var value = new log_pb.Log;
reader.readMessage(value,log_pb.Log.deserializeBinaryFromReader);
msg.addLogs(value);
break;
case 6:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setBloom(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -165,7 +229,7 @@

*/
proto.corepb.Receipt.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.corepb.Receipt.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.corepb.Receipt.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.Receipt.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -180,5 +244,5 @@

*/
proto.corepb.Receipt.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getTxHash_asU8()
proto.corepb.Receipt.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getTxHash_asU8();
if (f.length > 0) {

@@ -188,5 +252,5 @@ writer.writeBytes(

f
)
);
}
f = message.getTxIndex()
f = message.getTxIndex();
if (f !== 0) {

@@ -196,5 +260,5 @@ writer.writeUint32(

f
)
);
}
f = message.getFailed()
f = message.getFailed();
if (f) {

@@ -204,5 +268,5 @@ writer.writeBool(

f
)
);
}
f = message.getGasUsed()
f = message.getGasUsed();
if (f !== 0) {

@@ -212,5 +276,20 @@ writer.writeUint64(

f
)
);
}
}
f = message.getLogsList();
if (f.length > 0) {
writer.writeRepeatedMessage(
5,
f,
log_pb.Log.serializeBinaryToWriter
);
}
f = message.getBloom_asU8();
if (f.length > 0) {
writer.writeBytes(
6,
f
);
}
};

@@ -222,5 +301,5 @@

*/
proto.corepb.Receipt.prototype.getTxHash = function () {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ''))
}
proto.corepb.Receipt.prototype.getTxHash = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};

@@ -233,6 +312,6 @@

*/
proto.corepb.Receipt.prototype.getTxHash_asB64 = function () {
proto.corepb.Receipt.prototype.getTxHash_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getTxHash()))
}
this.getTxHash()));
};

@@ -247,12 +326,12 @@

*/
proto.corepb.Receipt.prototype.getTxHash_asU8 = function () {
proto.corepb.Receipt.prototype.getTxHash_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getTxHash()))
}
this.getTxHash()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Receipt.prototype.setTxHash = function (value) {
jspb.Message.setProto3BytesField(this, 1, value)
}
proto.corepb.Receipt.prototype.setTxHash = function(value) {
jspb.Message.setProto3BytesField(this, 1, value);
};

@@ -264,11 +343,11 @@

*/
proto.corepb.Receipt.prototype.getTxIndex = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0))
}
proto.corepb.Receipt.prototype.getTxIndex = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};
/** @param {number} value */
proto.corepb.Receipt.prototype.setTxIndex = function (value) {
jspb.Message.setProto3IntField(this, 2, value)
}
proto.corepb.Receipt.prototype.setTxIndex = function(value) {
jspb.Message.setProto3IntField(this, 2, value);
};

@@ -282,11 +361,11 @@

*/
proto.corepb.Receipt.prototype.getFailed = function () {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 3, false))
}
proto.corepb.Receipt.prototype.getFailed = function() {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 3, false));
};
/** @param {boolean} value */
proto.corepb.Receipt.prototype.setFailed = function (value) {
jspb.Message.setProto3BooleanField(this, 3, value)
}
proto.corepb.Receipt.prototype.setFailed = function(value) {
jspb.Message.setProto3BooleanField(this, 3, value);
};

@@ -298,15 +377,88 @@

*/
proto.corepb.Receipt.prototype.getGasUsed = function () {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0))
}
proto.corepb.Receipt.prototype.getGasUsed = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
};
/** @param {number} value */
proto.corepb.Receipt.prototype.setGasUsed = function (value) {
jspb.Message.setProto3IntField(this, 4, value)
}
proto.corepb.Receipt.prototype.setGasUsed = function(value) {
jspb.Message.setProto3IntField(this, 4, value);
};
/**
* repeated Log logs = 5;
* @return {!Array<!proto.corepb.Log>}
*/
proto.corepb.Receipt.prototype.getLogsList = function() {
return /** @type{!Array<!proto.corepb.Log>} */ (
jspb.Message.getRepeatedWrapperField(this, log_pb.Log, 5));
};
/** @param {!Array<!proto.corepb.Log>} value */
proto.corepb.Receipt.prototype.setLogsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 5, value);
};
/**
* @param {!proto.corepb.Log=} opt_value
* @param {number=} opt_index
* @return {!proto.corepb.Log}
*/
proto.corepb.Receipt.prototype.addLogs = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.corepb.Log, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.corepb.Receipt.prototype.clearLogsList = function() {
this.setLogsList([]);
};
/**
* optional bytes bloom = 6;
* @return {!(string|Uint8Array)}
*/
proto.corepb.Receipt.prototype.getBloom = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
};
/**
* optional bytes bloom = 6;
* This is a type-conversion wrapper around `getBloom()`
* @return {string}
*/
proto.corepb.Receipt.prototype.getBloom_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getBloom()));
};
/**
* optional bytes bloom = 6;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getBloom()`
* @return {!Uint8Array}
*/
proto.corepb.Receipt.prototype.getBloom_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getBloom()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.Receipt.prototype.setBloom = function(value) {
jspb.Message.setProto3BytesField(this, 6, value);
};
/**
* List of repeated fields within this message type.

@@ -316,3 +468,3 @@ * @private {!Array<number>}

*/
proto.corepb.Receipts.repeatedFields_ = [1]
proto.corepb.Receipts.repeatedFields_ = [1];

@@ -322,37 +474,37 @@

if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Receipts.prototype.toObject = function (opt_includeInstance) {
return proto.corepb.Receipts.toObject(opt_includeInstance, this)
}
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.Receipts.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.Receipts.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Receipts} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Receipts.toObject = function (includeInstance, msg) {
var f, obj = {
receiptsList: jspb.Message.toObjectList(msg.getReceiptsList(),
proto.corepb.Receipt.toObject, includeInstance)
}
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.Receipts} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.Receipts.toObject = function(includeInstance, msg) {
var f, obj = {
receiptsList: jspb.Message.toObjectList(msg.getReceiptsList(),
proto.corepb.Receipt.toObject, includeInstance)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg
}
return obj
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -366,7 +518,7 @@

*/
proto.corepb.Receipts.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes)
var msg = new proto.corepb.Receipts
return proto.corepb.Receipts.deserializeBinaryFromReader(msg, reader)
}
proto.corepb.Receipts.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.Receipts;
return proto.corepb.Receipts.deserializeBinaryFromReader(msg, reader);
};

@@ -381,21 +533,21 @@

*/
proto.corepb.Receipts.deserializeBinaryFromReader = function (msg, reader) {
proto.corepb.Receipts.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break
break;
}
var field = reader.getFieldNumber()
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new proto.corepb.Receipt
reader.readMessage(value, proto.corepb.Receipt.deserializeBinaryFromReader)
msg.addReceipts(value)
break
var value = new proto.corepb.Receipt;
reader.readMessage(value,proto.corepb.Receipt.deserializeBinaryFromReader);
msg.addReceipts(value);
break;
default:
reader.skipField()
break
reader.skipField();
break;
}
}
return msg
}
return msg;
};

@@ -407,7 +559,7 @@

*/
proto.corepb.Receipts.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter()
proto.corepb.Receipts.serializeBinaryToWriter(this, writer)
return writer.getResultBuffer()
}
proto.corepb.Receipts.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.Receipts.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};

@@ -422,5 +574,5 @@

*/
proto.corepb.Receipts.serializeBinaryToWriter = function (message, writer) {
var f = undefined
f = message.getReceiptsList()
proto.corepb.Receipts.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getReceiptsList();
if (f.length > 0) {

@@ -431,5 +583,5 @@ writer.writeRepeatedMessage(

proto.corepb.Receipt.serializeBinaryToWriter
)
);
}
}
};

@@ -441,12 +593,12 @@

*/
proto.corepb.Receipts.prototype.getReceiptsList = function () {
proto.corepb.Receipts.prototype.getReceiptsList = function() {
return /** @type{!Array<!proto.corepb.Receipt>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.corepb.Receipt, 1))
}
jspb.Message.getRepeatedWrapperField(this, proto.corepb.Receipt, 1));
};
/** @param {!Array<!proto.corepb.Receipt>} value */
proto.corepb.Receipts.prototype.setReceiptsList = function (value) {
jspb.Message.setRepeatedWrapperField(this, 1, value)
}
proto.corepb.Receipts.prototype.setReceiptsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 1, value);
};

@@ -459,4 +611,66 @@

*/
proto.corepb.Receipts.prototype.addReceipts = function (opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.corepb.Receipt, opt_index)
proto.corepb.Receipts.prototype.addReceipts = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.corepb.Receipt, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.corepb.Receipts.prototype.clearReceiptsList = function() {
this.setReceiptsList([]);
};
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.corepb.HashReceipt.repeatedFields_ = [5];
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.HashReceipt.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.HashReceipt.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.HashReceipt} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashReceipt.toObject = function(includeInstance, msg) {
var f, obj = {
txHash: msg.getTxHash_asB64(),
txIndex: jspb.Message.getFieldWithDefault(msg, 2, 0),
failed: jspb.Message.getFieldWithDefault(msg, 3, false),
gasUsed: jspb.Message.getFieldWithDefault(msg, 4, 0),
logsList: jspb.Message.toObjectList(msg.getLogsList(),
log_pb.HashLog.toObject, includeInstance),
bloom: msg.getBloom_asB64()
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}

@@ -466,9 +680,440 @@

/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.corepb.HashReceipt}
*/
proto.corepb.HashReceipt.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.HashReceipt;
return proto.corepb.HashReceipt.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.corepb.HashReceipt} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.corepb.HashReceipt}
*/
proto.corepb.HashReceipt.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setTxHash(value);
break;
case 2:
var value = /** @type {number} */ (reader.readUint32());
msg.setTxIndex(value);
break;
case 3:
var value = /** @type {boolean} */ (reader.readBool());
msg.setFailed(value);
break;
case 4:
var value = /** @type {number} */ (reader.readUint64());
msg.setGasUsed(value);
break;
case 5:
var value = new log_pb.HashLog;
reader.readMessage(value,log_pb.HashLog.deserializeBinaryFromReader);
msg.addLogs(value);
break;
case 6:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setBloom(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.corepb.HashReceipt.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.HashReceipt.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.corepb.HashReceipt} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashReceipt.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getTxHash_asU8();
if (f.length > 0) {
writer.writeBytes(
1,
f
);
}
f = message.getTxIndex();
if (f !== 0) {
writer.writeUint32(
2,
f
);
}
f = message.getFailed();
if (f) {
writer.writeBool(
3,
f
);
}
f = message.getGasUsed();
if (f !== 0) {
writer.writeUint64(
4,
f
);
}
f = message.getLogsList();
if (f.length > 0) {
writer.writeRepeatedMessage(
5,
f,
log_pb.HashLog.serializeBinaryToWriter
);
}
f = message.getBloom_asU8();
if (f.length > 0) {
writer.writeBytes(
6,
f
);
}
};
/**
* optional bytes tx_hash = 1;
* @return {!(string|Uint8Array)}
*/
proto.corepb.HashReceipt.prototype.getTxHash = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/**
* optional bytes tx_hash = 1;
* This is a type-conversion wrapper around `getTxHash()`
* @return {string}
*/
proto.corepb.HashReceipt.prototype.getTxHash_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getTxHash()));
};
/**
* optional bytes tx_hash = 1;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getTxHash()`
* @return {!Uint8Array}
*/
proto.corepb.HashReceipt.prototype.getTxHash_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getTxHash()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.HashReceipt.prototype.setTxHash = function(value) {
jspb.Message.setProto3BytesField(this, 1, value);
};
/**
* optional uint32 tx_index = 2;
* @return {number}
*/
proto.corepb.HashReceipt.prototype.getTxIndex = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};
/** @param {number} value */
proto.corepb.HashReceipt.prototype.setTxIndex = function(value) {
jspb.Message.setProto3IntField(this, 2, value);
};
/**
* optional bool failed = 3;
* Note that Boolean fields may be set to 0/1 when serialized from a Java server.
* You should avoid comparisons like {@code val === true/false} in those cases.
* @return {boolean}
*/
proto.corepb.HashReceipt.prototype.getFailed = function() {
return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 3, false));
};
/** @param {boolean} value */
proto.corepb.HashReceipt.prototype.setFailed = function(value) {
jspb.Message.setProto3BooleanField(this, 3, value);
};
/**
* optional uint64 gas_used = 4;
* @return {number}
*/
proto.corepb.HashReceipt.prototype.getGasUsed = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
};
/** @param {number} value */
proto.corepb.HashReceipt.prototype.setGasUsed = function(value) {
jspb.Message.setProto3IntField(this, 4, value);
};
/**
* repeated HashLog logs = 5;
* @return {!Array<!proto.corepb.HashLog>}
*/
proto.corepb.HashReceipt.prototype.getLogsList = function() {
return /** @type{!Array<!proto.corepb.HashLog>} */ (
jspb.Message.getRepeatedWrapperField(this, log_pb.HashLog, 5));
};
/** @param {!Array<!proto.corepb.HashLog>} value */
proto.corepb.HashReceipt.prototype.setLogsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 5, value);
};
/**
* @param {!proto.corepb.HashLog=} opt_value
* @param {number=} opt_index
* @return {!proto.corepb.HashLog}
*/
proto.corepb.HashReceipt.prototype.addLogs = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.corepb.HashLog, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.corepb.Receipts.prototype.clearReceiptsList = function () {
this.setReceiptsList([])
proto.corepb.HashReceipt.prototype.clearLogsList = function() {
this.setLogsList([]);
};
/**
* optional bytes bloom = 6;
* @return {!(string|Uint8Array)}
*/
proto.corepb.HashReceipt.prototype.getBloom = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
};
/**
* optional bytes bloom = 6;
* This is a type-conversion wrapper around `getBloom()`
* @return {string}
*/
proto.corepb.HashReceipt.prototype.getBloom_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getBloom()));
};
/**
* optional bytes bloom = 6;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getBloom()`
* @return {!Uint8Array}
*/
proto.corepb.HashReceipt.prototype.getBloom_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getBloom()));
};
/** @param {!(string|Uint8Array)} value */
proto.corepb.HashReceipt.prototype.setBloom = function(value) {
jspb.Message.setProto3BytesField(this, 6, value);
};
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.corepb.HashReceipts.repeatedFields_ = [1];
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.corepb.HashReceipts.prototype.toObject = function(opt_includeInstance) {
return proto.corepb.HashReceipts.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.corepb.HashReceipts} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashReceipts.toObject = function(includeInstance, msg) {
var f, obj = {
receiptsList: jspb.Message.toObjectList(msg.getReceiptsList(),
proto.corepb.HashReceipt.toObject, includeInstance)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
goog.object.extend(exports, proto.corepb)
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.corepb.HashReceipts}
*/
proto.corepb.HashReceipts.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.corepb.HashReceipts;
return proto.corepb.HashReceipts.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.corepb.HashReceipts} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.corepb.HashReceipts}
*/
proto.corepb.HashReceipts.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new proto.corepb.HashReceipt;
reader.readMessage(value,proto.corepb.HashReceipt.deserializeBinaryFromReader);
msg.addReceipts(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.corepb.HashReceipts.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.corepb.HashReceipts.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.corepb.HashReceipts} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.corepb.HashReceipts.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getReceiptsList();
if (f.length > 0) {
writer.writeRepeatedMessage(
1,
f,
proto.corepb.HashReceipt.serializeBinaryToWriter
);
}
};
/**
* repeated HashReceipt receipts = 1;
* @return {!Array<!proto.corepb.HashReceipt>}
*/
proto.corepb.HashReceipts.prototype.getReceiptsList = function() {
return /** @type{!Array<!proto.corepb.HashReceipt>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.corepb.HashReceipt, 1));
};
/** @param {!Array<!proto.corepb.HashReceipt>} value */
proto.corepb.HashReceipts.prototype.setReceiptsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 1, value);
};
/**
* @param {!proto.corepb.HashReceipt=} opt_value
* @param {number=} opt_index
* @return {!proto.corepb.HashReceipt}
*/
proto.corepb.HashReceipts.prototype.addReceipts = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.corepb.HashReceipt, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.corepb.HashReceipts.prototype.clearReceiptsList = function() {
this.setReceiptsList([]);
};
goog.object.extend(exports, proto.corepb);

@@ -9,2 +9,6 @@ import bs58 from 'bs58'

import isNumber from 'lodash/isNumber'
import AbiUtil from '../core/contract/abi/util'
import SplitUtil from '../core/split/util'
import TokenUtil from '../core/token/util'
import TxUtil from '../core/tx/util'

@@ -21,3 +25,3 @@ const {

} = Opcode
const OPCODE_TYPE = 'hex'
const PREFIXSTR2BYTES = {

@@ -52,3 +56,3 @@ b1: Buffer.from([0x13, 0x26]),

const _flattenTypes = function _flattenTypes(includeTuple, puts) {
const _flattenTypes = (includeTuple, puts) => {
let types: any = []

@@ -83,3 +87,3 @@ puts.forEach(function(param) {

namespace Util {
namespace CommonUtil {
export const to16StrFromNumber = (num: number) => (num & 255).toString(16)

@@ -90,3 +94,3 @@

/**
* @export Put_Uint16
* @func Put_Uint16
* @param [*bytes]

@@ -118,7 +122,7 @@ * @param [*uint16]

public constructor(org_code) {
this.opcode = Buffer.from(org_code, OPCODE_TYPE)
this.opcode = Buffer.from(org_code, 'hex')
}
public reset(org_code) {
this.opcode = Buffer.from(org_code, OPCODE_TYPE)
this.opcode = Buffer.from(org_code, 'hex')
return this

@@ -139,3 +143,3 @@ }

if (!isBuf) {
and_buf = Buffer.from(and_buf, OPCODE_TYPE)
and_buf = Buffer.from(and_buf, 'hex')
}

@@ -148,3 +152,3 @@ const and_len = and_buf.length

this.opcode,
Buffer.from(and_len_str, OPCODE_TYPE)
Buffer.from(and_len_str, 'hex')
])

@@ -154,4 +158,4 @@ } else if (and_len <= 0xff) {

this.opcode,
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_1), OPCODE_TYPE),
Buffer.from(and_len_str, OPCODE_TYPE)
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_1), 'hex'),
Buffer.from(and_len_str, 'hex')
])

@@ -163,3 +167,3 @@ } else if (and_len <= 0xffff) {

this.opcode,
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_2), OPCODE_TYPE),
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_2), 'hex'),
buf

@@ -172,3 +176,3 @@ ])

this.opcode,
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_4), OPCODE_TYPE),
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_4), 'hex'),
buf

@@ -186,3 +190,3 @@ ])

/**
* @export put-Uint32
* @func Put-Uint32
* TODO: it not support int32 now

@@ -206,6 +210,6 @@ * @param [*bytes]

/**
* @export signature-Script
* @param [*sigBuf] Buffer
* @param [*Buffer] Buffer
* @returns [end] Buffer
* @func Signature-Script
* @param [*sigBuf]
* @param [*Buffer]
* @returns [end]
*/

@@ -224,4 +228,4 @@ export const signatureScript = (

/**
* @export get-SignHash
* @param [*protobuf] string
* @func Get-SignHash
* @param [*protobuf]
* @returns

@@ -259,5 +263,5 @@ */

/**
* Returns a `Boolean` on whether or not the a `String` starts with '0x'
* @param {String} str the string input value
* @return {Boolean} a boolean if it is or is not hex prefixed
* @func # Returns a `Boolean` on whether or not the a `String` starts with '0x'
* @param [*str] str the string input value
* @return [boolean] a boolean if it is or is not hex prefixed
* @throws if the str input is not a string

@@ -268,3 +272,3 @@ */

throw new Error(
'[is-hex-prefixed] value must be type \'string\', is currently type ' +
"[is-hex-prefixed] value must be type 'string', is currently type " +
typeof str +

@@ -279,5 +283,5 @@ ', while checking isHexPrefixed.'

/**
* Removes '0x' from a given `String` is present
* @param {String} str the string value
* @return {String|Optional} a string by pass if necessary
* @func # Removes '0x' from a given `String` is present
* @param [*str] str the string value
* @return [string|optional] a string by pass if necessary
*/

@@ -293,6 +297,6 @@ export const stripHexPrefix = str => {

/**
* Convert hex address to box address format
* @param {String} prefix: the box address prefix
* @param {hexAddr} hexAddr: hex address without '0x' prefix
* @return {String} box address, starting with "b"
* @func # Convert hex address to box address format
* @param [*prefix] string # the box address prefix
* @param [*hexAddr] string # hex address without '0x' prefix
* @return [string] box address, starting with "b"
* @throws when prefix is not expected

@@ -312,18 +316,13 @@ */

/**
* Convert box address to hex address format
* @param {boxAddr} boxAddr: address in box format, starting with 'b'
* @return {String} hex address
* @func Convert_box_address_to_hex_address_format
* @param [*box_addr] string # address in box format, starting with 'b'
* @return [string] hex address
* @throws if convertion fails
*/
export const box2HexAddr = (boxAddr: string) => {
try {
const pubKey_hash = Verify.isAddr(boxAddr)
if (pubKey_hash) {
return pubKey_hash.slice(2).toString(OPCODE_TYPE)
}
console.log('dumpPubKeyHashFromAddr Error !')
export const box2HexAddr = (box_addr: string) => {
const pubKey_hash = Verify.isBoxAddr(box_addr)
if (pubKey_hash) {
return pubKey_hash.slice(2).toString('hex')
} else {
throw new Error('dumpPubKeyHashFromAddr Error')
} catch (err) {
console.log('dumpPubKeyHashFromAddr Error !')
throw new Error(err)
}

@@ -333,2 +332,2 @@ }

export default Util
export default Object.assign(CommonUtil, AbiUtil, SplitUtil, TokenUtil, TxUtil)

@@ -5,3 +5,2 @@ import tinySecp from 'tiny-secp256k1'

const OPCODE_TYPE = 'hex'
let _typeof2 = obj => {

@@ -26,25 +25,42 @@ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {

namespace Verify {
export const isPrivate = (privKey: string) => {
if (tinySecp.isPrivate(Buffer.from(privKey, OPCODE_TYPE))) {
return privKey
/**
* @func get_check_sum
* @param [*hex]
* @returns [check_sum]
*/
export const getCheckSum = (hex: string | Buffer) => {
if (hex instanceof Buffer) {
return Hash.sha256(Hash.sha256(hex)).slice(0, 4)
} else {
throw new Error('The private key entered is not a valid one !')
return Hash.sha256(Hash.sha256(Buffer.from(hex, 'hex'))).slice(0, 4)
}
}
export const getCheckSum = (hex: string | Buffer) => {
if (hex instanceof Buffer) {
return Hash.sha256(Hash.sha256(hex)).slice(0, 4)
/**
* @func check_is_private_key
* @param [*privKey]
* @returns [boolean]
*/
export const isPrivate = (privKey: string) => {
if (tinySecp.isPrivate(Buffer.from(privKey, 'hex'))) {
return privKey
} else {
return Hash.sha256(Hash.sha256(Buffer.from(hex, OPCODE_TYPE))).slice(0, 4)
return false
}
}
export const isAddr = (addr: string) => {
/**
* @func check_is_BOX_address
* @param [*addr]
* @returns [pubkey_hash]
*/
export const isBoxAddr = (addr: string) => {
if (!['b1', 'b2', 'b3', 'b5'].includes(addr.substring(0, 2))) {
throw new Error('Incorrect address format !')
throw new Error('[isBoxAddr] Incorrect address format !')
}
const decoded = bs58.decode(addr)
if (decoded.length < 4) {
throw new Error(`Address length = ${decoded.length}: is too short !`)
throw new Error(
`[isBoxAddr] Address length = ${decoded.length}: is too short !`
)
}

@@ -55,3 +71,3 @@ const len = decoded.length

if (!checksum.equals(decoded.slice(len - 4))) {
throw new Error('Incorrect address format !')
throw new Error('[isBoxAddr] Incorrect address format !')
}

@@ -61,10 +77,2 @@ return pubkey_hash

export const isPublic = privKey => {
console.log('privKey:', privKey)
}
export const isPublicHash = pubkey_hash => {
console.log('pubkey_hash:', pubkey_hash)
}
export let _typeof = obj => {

@@ -71,0 +79,0 @@ if (

import 'jest'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Account from '../src/boxd/account/account'
import AccountManager from '../src/boxd/account/account-manager'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
let acc_list_result
const OPCODE_TYPE = 'hex'
const acc_buf = Buffer.from(Mock.acc_privateKey, OPCODE_TYPE) // private key (buffer ed)
const updateAccount = (new_acc_list = {}) => {
const acc_buf = Buffer.from(Mock.acc_privateKey, 'hex') // private key (buffer ed)
const update_func = (new_acc_list = {}) => {
// console.log('new_acc_list :', new_acc_list)
acc_list_result = new_acc_list
}
const acc = new Account()
const accManager = new AccountManager(Mock.acc_list, updateAccount)
const accManager = new AccountManager(Mock.acc_list, update_func)
test('Dump publicKey from privateKey (string | Buffer)', async () => {
try {
expect(await acc.dumpAddrFromPrivKey(Mock.acc_privateKey)).toEqual(
expect(await Account.dumpAddrFromPrivKey(Mock.acc_privateKey)).toEqual(
Mock.acc_addr
)
expect(await acc.dumpAddrFromPrivKey(acc_buf)).toEqual(Mock.acc_addr)
expect(await Account.dumpAddrFromPrivKey(acc_buf)).toEqual(Mock.acc_addr)
} catch (err) {

@@ -32,3 +30,3 @@ console.error('Dump publicKey from privateKey Error :', err)

expect(
typeof (await acc.dumpCryptoFromPrivKey(
typeof (await Account.dumpCryptoFromPrivKey(
Mock.acc_privateKey,

@@ -39,3 +37,3 @@ Mock.acc_pwd

expect(
typeof (await acc.dumpCryptoFromPrivKey(acc_buf, Mock.acc_pwd))
typeof (await Account.dumpCryptoFromPrivKey(acc_buf, Mock.acc_pwd))
).toEqual('object')

@@ -50,6 +48,8 @@ } catch (err) {

try {
expect(await acc.dumpPubKeyFromPrivKey(Mock.acc_privateKey)).toEqual(
expect(await Account.dumpPubKeyFromPrivKey(Mock.acc_privateKey)).toEqual(
Mock.acc_publicKey
)
expect(await acc.dumpPubKeyFromPrivKey(acc_buf)).toEqual(Mock.acc_publicKey)
expect(await Account.dumpPubKeyFromPrivKey(acc_buf)).toEqual(
Mock.acc_publicKey
)
} catch (err) {

@@ -63,8 +63,8 @@ console.error('Dump publicKey from privateKey Error :', err)

try {
expect(await acc.dumpPubKeyHashFromPrivKey(Mock.acc_privateKey)).toEqual(
expect(
await Account.dumpPubKeyHashFromPrivKey(Mock.acc_privateKey)
).toEqual(Mock.acc_publickey_hash)
expect(await Account.dumpPubKeyHashFromPrivKey(acc_buf)).toEqual(
Mock.acc_publickey_hash
)
expect(await acc.dumpPubKeyHashFromPrivKey(acc_buf)).toEqual(
Mock.acc_publickey_hash
)
} catch (err) {

@@ -78,3 +78,3 @@ console.error('Dump publicKey hash from privateKey Error :', err)

try {
expect(await acc.dumpPubKeyHashFromAddr(Mock.acc_addr)).toEqual(
expect(await Account.dumpPubKeyHashFromAddr(Mock.acc_addr)).toEqual(
Mock.acc_publickey_hash

@@ -91,3 +91,3 @@ )

expect(
await acc.dumpPrivKeyFromCrypto(Keystore.keystore, Mock.acc_pwd)
await Account.dumpPrivKeyFromCrypto(Keystore.keystore, Mock.acc_pwd)
).toEqual(Mock.acc_privateKey)

@@ -102,3 +102,3 @@ } catch (err) {

try {
expect(await acc.dumpPubKeyHashFromAddr(Mock.acc_addr)).toEqual(
expect(await Account.dumpPubKeyHashFromAddr(Mock.acc_addr)).toEqual(
Mock.acc_publickey_hash

@@ -115,3 +115,3 @@ )

// create a crypto without privateKey
const { cryptoJSON, P2PKH } = await acc.getCryptoByPwd(Mock.acc_pwd)
const { cryptoJSON, P2PKH } = await Account.getCryptoByPwd(Mock.acc_pwd)
expect(cryptoJSON.address).toEqual(P2PKH)

@@ -133,3 +133,3 @@ await accManager.addToAccList(cryptoJSON, {

// import a crypto with privateKey
const { cryptoJSON, P2PKH } = await acc.getCryptoByPwd(
const { cryptoJSON, P2PKH } = await Account.getCryptoByPwd(
Mock.acc_pwd,

@@ -153,5 +153,5 @@ Mock.acc_privateKey

try {
const { cryptoJSON, P2PKH } = await acc.getCryptoByPwd(
const { cryptoJSON, P2PKH } = await Account.getCryptoByPwd(
Mock.acc_pwd,
await acc.dumpPrivKeyFromCrypto(Keystore.keystore, Mock.acc_pwd)
await Account.dumpPrivKeyFromCrypto(Keystore.keystore, Mock.acc_pwd)
)

@@ -158,0 +158,0 @@ expect(cryptoJSON.address).toEqual(P2PKH)

import 'jest'
import BN from 'bn.js'
import AbiCoder from '../src/boxd/core/contract/abi/abicoder'
import BN from 'bn.js'

@@ -5,0 +5,0 @@ const abi = new AbiCoder()

import 'jest'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Api from '../src/boxd/core/api'
import Mock from './json/mock.json'
const cor = new Api(fetch, Mock.endpoint_dev, 'http')
let node_id
const api = new Api(fetch, Mock.endpoint_dev, 'http')
test('Get node info', async () => {
try {
const node_info = await cor.getNodeInfo()
const node_info = await api.getNodeInfo()
// console.log('node_info :', JSON.stringify(node_info))

@@ -24,3 +24,3 @@ node_id = node_info.nodes[0].id

try {
expect(await cor.getBlockHashByHeight(Mock.blockHeight))
expect(await api.getBlockHashByHeight(Mock.blockHeight))
} catch (err) {

@@ -34,3 +34,3 @@ console.error('Get block hash by Height Error :', err)

try {
expect(await cor.getBlockByHeight(Mock.blockHeight))
expect(await api.getBlockByHeight(Mock.blockHeight))
} catch (err) {

@@ -44,3 +44,3 @@ console.error('Get block by Height Error :', err)

try {
expect(await cor.getBlockByHash(Mock.blockHash))
expect(await api.getBlockByHash(Mock.blockHash))
} catch (err) {

@@ -54,3 +54,3 @@ console.error('Get block by Hash Error :', err)

try {
expect(await cor.getBlockHeaderByHash(Mock.blockHash))
expect(await api.getBlockHeaderByHash(Mock.blockHash))
} catch (err) {

@@ -64,3 +64,3 @@ console.error('Get block header by Hash Error :', err)

try {
expect(await cor.getBlockHeaderByHeight(Mock.blockHeight))
expect(await api.getBlockHeaderByHeight(Mock.blockHeight))
} catch (err) {

@@ -74,3 +74,3 @@ console.error('Get block header by Height Error :', err)

try {
expect(await cor.getBlockHeight())
expect(await api.getBlockHeight())
} catch (err) {

@@ -84,3 +84,3 @@ console.error('Get block Height Error :', err)

try {
expect(await cor.viewBlockDetail(Mock.blockHash))
expect(await api.viewBlockDetail(Mock.blockHash))
} catch (err) {

@@ -87,0 +87,0 @@ console.error('View block detail Error :', err)

import 'jest'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import AbiCoder from '../src/boxd/core/contract/abi/abicoder'
import Api from '../src/boxd/core/api'
import Feature from '../src/boxd/core/feature'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Util from '../src/boxd/util/util'
const abi = new AbiCoder()
// base58 format
let src = Mock.acc_addr_4
let contractAddr
// hex format
const abi = new AbiCoder()
const srcHexAddr = Util.box2HexAddr(src)
const anotherHexAddr = Util.box2HexAddr(Mock.acc_addr_1)
let contractAddr
const cor = new Api(fetch, Mock.endpoint_dev, 'http')
const api = new Api(fetch, Mock.endpoint_dev, 'http')
const feature = new Feature(fetch, Mock.endpoint_dev, 'http')

@@ -104,3 +102,3 @@

await cor
await api
.getNonce(src)

@@ -143,3 +141,3 @@ .then(result => {

console.log('contract deployed at: ' + tx_result.contractAddr)
const tx_detail = await cor.viewTxDetail(tx_result.hash)
const tx_detail = await api.viewTxDetail(tx_result.hash)
expect(tx_detail.detail.hash).toEqual(tx_result.hash)

@@ -187,3 +185,3 @@ contractAddr = tx_result.contractAddr

await sleep(5000)
const tx_detail = await cor.viewTxDetail(tx_result.hash)
const tx_detail = await api.viewTxDetail(tx_result.hash)
expect(tx_detail.detail.hash).toEqual(tx_result.hash)

@@ -200,5 +198,5 @@ expect(await getBalance()).toEqual(initBalance + depositAmount)

test('Get logs', async () => {
const logs = await cor.getLogs(Mock.constract_logs_req)
const logs = await api.getLogs(Mock.constract_logs_req)
expect(logs)
// console.log('logs :', logs)
})
import 'jest'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Api from '../src/boxd/core/api'
import Mock from './json/mock.json'
import Feature from '../src/boxd/core/feature'
import Keystore from './json/keystore.json'
const cor = new Api(fetch, Mock.endpoint_dev, 'http')
const api = new Api(fetch, Mock.endpoint_dev, 'http')
const feature = new Feature(fetch, Mock.endpoint_dev, 'http')
jest.setTimeout(10000)
test('Make a split contract transaction', async () => {

@@ -26,3 +24,3 @@ try {

// console.log('tx_result :', tx_result)
const tx_detail = await cor.viewTxDetail(tx_result.hash)
const tx_detail = await api.viewTxDetail(tx_result.hash)
// console.log('tx_detail :', tx_detail)

@@ -29,0 +27,0 @@ expect(tx_detail.detail.hash).toEqual(tx_result.hash)

import 'jest'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Api from '../src/boxd/core/api'
import Feature from '../src/boxd/core/feature'
import TokenUtil from '../src/boxd/core/token/util'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Util from '../src/boxd/util/util'
const cor = new Api(fetch, Mock.endpoint_dev, 'http')
const api = new Api(fetch, Mock.endpoint_dev, 'http')
const feature = new Feature(fetch, Mock.endpoint_dev, 'http')
let token_hash
jest.setTimeout(15000)
test('Issue a token & get the token balance', async done => {

@@ -33,3 +31,3 @@ try {

// console.log('tx_result :', issue_result)
const tx_detail = await cor.viewTxDetail(issue_result.hash)
const tx_detail = await api.viewTxDetail(issue_result.hash)
// console.log('tx_detail :', tx_detail)

@@ -39,3 +37,3 @@ expect(tx_detail.detail.hash).toEqual(issue_result.hash)

token_hash = issue_result.hash
const token_addr = await TokenUtil.encodeTokenAddr({
const token_addr = await Util.encodeTokenAddr({
opHash: token_hash,

@@ -45,8 +43,8 @@ index: 0

// test func [TokenUtil.decodeTokenAddr]
const { opHash, index } = await TokenUtil.decodeTokenAddr(token_addr)
const { opHash, index } = await Util.decodeTokenAddr(token_addr)
expect(opHash).toEqual(token_hash)
expect(index).toEqual(0)
// test func [Core.getTokenbalances]
// test func [Api.getTokenbalances]
setTimeout(async () => {
const token_balances = await cor.getTokenbalances({
const token_balances = await api.getTokenbalances({
addrs: [Mock.acc_addr_2, Mock.acc_addr_2],

@@ -56,3 +54,3 @@ tokenHash: token_hash,

})
console.log('token_balances:', token_balances)
// console.log('token_balances:', token_balances)
expect(

@@ -83,5 +81,5 @@ Number(token_balances.balances[1]) / Math.pow(10, Mock.token_decimal)

}
console.log('param :', param)
// console.log('param :', param)
const token_result = await feature.makeTokenTxByCrypto(param)
const token_detail = await cor.viewTxDetail(token_result.hash)
const token_detail = await api.viewTxDetail(token_result.hash)
// console.log('token_detail:', token_detail)

@@ -88,0 +86,0 @@ expect(token_detail.detail.hash).toEqual(token_result.hash)

import 'jest'
import fetch from 'isomorphic-fetch'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
import Api from '../src/boxd/core/api'
import Feature from '../src/boxd/core/feature'
import Mock from './json/mock.json'
import Keystore from './json/keystore.json'
const cor = new Api(fetch, Mock.endpoint_dev, 'http')
const api = new Api(fetch, Mock.endpoint_dev, 'http')
const feature = new Feature(fetch, Mock.endpoint_dev, 'http')

@@ -25,3 +25,3 @@

})
const tx_detail = await cor.viewTxDetail(tx_result.hash)
const tx_detail = await api.viewTxDetail(tx_result.hash)
expect(tx_detail.detail.hash).toEqual(tx_result.hash)

@@ -36,3 +36,3 @@ } catch (err) {

try {
const box_balance = await cor.getBalances([
const box_balance = await api.getBalances([
Mock.acc_addr_3,

@@ -53,3 +53,3 @@ Mock.acc_addr_3

try {
const unsigned_tx = await cor.makeUnsignedTx({
const unsigned_tx = await api.makeUnsignedTx({
from: Mock.acc_addr_3,

@@ -61,3 +61,3 @@ to: Mock.to_addrs,

// console.log('unsigned_tx:', JSON.stringify(unsigned_tx))
const signed_tx = await cor.signTxByPrivKey({
const signed_tx = await api.signTxByPrivKey({
unsignedTx: {

@@ -92,3 +92,3 @@ tx: unsigned_tx.tx,

try {
const created_tx = await cor.createRawTx({
const created_tx = await api.createRawTx({
addr: Mock.acc_addr_3,

@@ -101,3 +101,3 @@ to: Mock.to_map,

// console.log('created_tx :', JSON.stringify(created_tx))
const sent_tx = await cor.sendTx(created_tx)
const sent_tx = await api.sendTx(created_tx)
// console.log('sent_tx :', JSON.stringify(sent_tx))

@@ -107,3 +107,3 @@ expect(sent_tx['code']).toBe(0)

// Row
/* const created_tx_row = await cor.createRawTx(
/* const created_tx_row = await api.createRawTx(
{

@@ -119,3 +119,3 @@ addr: Mock.acc_addr_3,

console.log('created_tx_row :', created_tx_row)
const sent_tx_row = await cor.sendRawTx(created_tx_row)
const sent_tx_row = await api.sendRawTx(created_tx_row)
console.log('sent_tx_row :', JSON.stringify(sent_tx_row)) */

@@ -129,5 +129,5 @@ } catch (err) {

// USING
/* test('faucet', async () => {
test('faucet', async () => {
try {
const faucet_res = await cor.faucet({
const faucet_res = await api.faucet({
addr: Mock.acc_addr_4,

@@ -141,2 +141,2 @@ amount: 30000000000

}
}) */
})

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc