Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

conseiljs

Package Overview
Dependencies
Maintainers
3
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conseiljs - npm Package Compare versions

Comparing version 5.0.6 to 5.0.7-beta.0

2

dist/chain/tezos/contracts/BabylonDelegationHelper.d.ts

@@ -14,3 +14,3 @@ import { KeyStore, Signer } from '../../../types/ExternalInterfaces';

function depositDelegatedFunds(server: string, signer: Signer, keyStore: KeyStore, contract: string, fee: number, amount: number): Promise<TezosTypes.OperationResult>;
function deployManagerContract(server: string, signer: Signer, keyStore: KeyStore, delegate: string, fee: number, amount: number): Promise<TezosTypes.OperationResult>;
function deployManagerContract(server: string, signer: Signer, keyStore: KeyStore, delegate: string, fee: number, amount: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
}

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

BabylonDelegationHelper.depositDelegatedFunds = depositDelegatedFunds;
function deployManagerContract(server, signer, keyStore, delegate, fee, amount) {
function deployManagerContract(server, signer, keyStore, delegate, fee, amount, optimizeFee = false) {
const code = `[ { "prim": "parameter",

@@ -118,3 +118,3 @@ "args":

const storage = `{ "string": "${keyStore.publicKeyHash}" }`;
return TezosNodeWriter_1.TezosNodeWriter.sendContractOriginationOperation(server, signer, keyStore, amount, delegate, fee, 600, 20000, code, storage, TezosTypes.TezosParameterFormat.Micheline);
return TezosNodeWriter_1.TezosNodeWriter.sendContractOriginationOperation(server, signer, keyStore, amount, delegate, fee, 600, 20000, code, storage, TezosTypes.TezosParameterFormat.Micheline, TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee);
}

@@ -121,0 +121,0 @@ BabylonDelegationHelper.deployManagerContract = deployManagerContract;

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

const storageResult = yield TezosNodeReader_1.TezosNodeReader.getContractStorage(server, address);
console.log(JSON.stringify(storageResult));
return {

@@ -46,0 +45,0 @@ balanceMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[1].args[0].int', json: storageResult })[0]),

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

const storageResult = yield TezosNodeReader_1.TezosNodeReader.getContractStorage(server, address);
console.log(JSON.stringify(storageResult));
return {

@@ -61,0 +60,0 @@ balanceMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[1].args[0].int', json: storageResult })[0]),

"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
function id(d) { return d[0]; }
const moo = require("moo");
const bigInt = require("big-integer");
exports.DefaultMichelsonKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"'];
const TezosMessageUtil_1 = require("../TezosMessageUtil");
const moo = __importStar(require("moo"));
exports.DefaultMichelsonKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"', '"LEVEL"', '"SELF_ADDRESS"', '"never"', '"NEVER"', '"UNPAIR"', '"VOTING_POWER"', '"TOTAL_VOTING_POWER"', '"KECCAK"', '"SHA3"', '"PAIRING_CHECK"', '"bls12_381_g1"', '"bls12_381_g2"', '"bls12_381_fr"', '"sapling_state"', '"sapling_transaction"', '"SAPLING_EMPTY_STATE"', '"SAPLING_VERIFY_UPDATE"', '"ticket"', '"TICKET"', '"READ_TICKET"', '"SPLIT_TICKET"', '"JOIN_TICKETS"', '"GET_AND_UPDATE"'];
let _languageKeywords = [...exports.DefaultMichelsonKeywords];

@@ -30,3 +37,3 @@ exports.setKeywordList = list => {

const text = d[6].toString();
const value = writeSignedInt(parseInt(text.substring(1, text.length - 1)));
const value = TezosMessageUtil_1.TezosMessageUtils.writeSignedInt(text.substring(1, text.length - 1));
return prefix + value;

@@ -118,34 +125,2 @@ };

};
const writeSignedInt = value => {
if (value === 0) {
return '00';
}
const n = bigInt(value).abs();
const l = n.bitLength().toJSNumber();
let arr = [];
let v = n;
for (let i = 0; i < l; i += 7) {
let byte = bigInt.zero;
if (i === 0) {
byte = v.and(0x3f);
v = v.shiftRight(6);
}
else {
byte = v.and(0x7f);
v = v.shiftRight(7);
}
if (value < 0 && i === 0) {
byte = byte.or(0x40);
}
if (i + 7 < l) {
byte = byte.or(0x80);
}
arr.push(byte.toJSNumber());
}
if (l % 7 === 0) {
arr[arr.length - 1] = arr[arr.length - 1] | 0x80;
arr.push(1);
}
return arr.map(v => ('0' + v.toString(16)).slice(-2)).join('');
};
;

@@ -159,6 +134,3 @@ ;

{ "name": "main", "symbols": ["staticObject"], "postprocess": id },
{ "name": "main", "symbols": ["primBare"], "postprocess": id },
{ "name": "main", "symbols": ["primArg"], "postprocess": id },
{ "name": "main", "symbols": ["primAnn"], "postprocess": id },
{ "name": "main", "symbols": ["primArgAnn"], "postprocess": id },
{ "name": "main", "symbols": ["primAny"], "postprocess": id },
{ "name": "main", "symbols": ["anyArray"], "postprocess": id },

@@ -165,0 +137,0 @@ { "name": "staticInt$ebnf$1", "symbols": [] },

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

};
const intToJson = d => `{ "int": "${parseInt(d[0])}" }`;
const intToJson = d => `{ "int": "${d[0]}" }`;
const stringToJson = d => `{ "string": ${d[0]} }`;

@@ -374,3 +374,10 @@ const bytesToJson = d => `{ "bytes": "${d[0].toString().slice(2)}" }`;

const singleArgKeywordWithParenToJson = d => `{ "prim": "${d[2]}", "args": [ ${d[(4 + ((d.length === 7) ? 0 : 2))]} ] }`;
const doubleArgKeywordToJson = d => `{ "prim": "${d[0]}", "args": [ ${d[2]}, ${d[4]} ] }`;
const doubleArgKeywordToJson = d => {
if (d.length === 7) {
return `{ "prim": "${d[0]}", "args": [ ${d[2]}, [] ] }`;
}
else {
return `{ "prim": "${d[0]}", "args": [ ${d[2]}, ${d[4]} ] }`;
}
};
const doubleArgParenKeywordToJson = d => `{ "prim": "${d[0]}", "args": [ ${d[4]}, ${d[8]} ] }`;

@@ -411,3 +418,3 @@ const doubleArgInstrKeywordToJson = d => {

const annot = d[1].map(x => `"${x[1]}"`);
return `{ "prim": "${d[0]}", "args": [ ${d[3]}, ${d[5]}, ${d[7]} ], "annots": [${annot}] }`;
return `{ "prim": "${d[0]}", "args": [ ${d[3]}, ${d[5]}, ${d[7]} ], "annots": [${annot}] }`;
};

@@ -436,3 +443,3 @@ const pushToJson = d => {

const dropnToJson = d => `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" } ] }`;
const subContractToJson = d => `{ "prim":"CREATE_CONTRACT", "args": [ [ ${d[4]}, ${d[6]}, {"prim": "code" , "args":[ [ ${d[8]} ] ] } ] ] }`;
const subContractToJson = d => `{ "prim": "CREATE_CONTRACT", "args": [ [ ${d[4]}, ${d[6]}, { "prim": "code" , "args": [ [ ${d[8]} ] ] } ] ] }`;
const instructionListToJson = d => {

@@ -515,3 +522,5 @@ const instructionOne = [d[2]];

{ "name": "data", "symbols": [(lexer.has("singleArgData") ? { type: "singleArgData" } : singleArgData), "_", "data"], "postprocess": singleArgKeywordToJson },
{ "name": "data", "symbols": [(lexer.has("doubleArgData") ? { type: "doubleArgData" } : doubleArgData), "_", "data", "_", (lexer.has("lbrace") ? { type: "lbrace" } : lbrace), "_", (lexer.has("rbrace") ? { type: "rbrace" } : rbrace)], "postprocess": doubleArgKeywordToJson },
{ "name": "data", "symbols": [(lexer.has("doubleArgData") ? { type: "doubleArgData" } : doubleArgData), "_", "data", "_", "data"], "postprocess": doubleArgKeywordToJson },
{ "name": "data", "symbols": [(lexer.has("doubleArgData") ? { type: "doubleArgData" } : doubleArgData), "_", "data", "_", "subInstruction"], "postprocess": doubleArgKeywordToJson },
{ "name": "data", "symbols": ["subData"], "postprocess": id },

@@ -518,0 +527,0 @@ { "name": "data", "symbols": ["subElt"], "postprocess": id },

@@ -9,3 +9,3 @@ /// <reference types="node" />

function writeInt(value: number): string;
function writeSignedInt(value: number): string;
function writeSignedInt(value: number | string): string;
function readInt(hex: string): number;

@@ -12,0 +12,0 @@ function readSignedInt(hex: string): number;

@@ -37,18 +37,17 @@ "use strict";

function writeSignedInt(value) {
if (value === 0) {
if (value === 0 || value === '0') {
return '00';
}
const n = big_integer_1.default(value).abs();
let n = big_integer_1.default(value).abs();
const l = n.bitLength().toJSNumber();
let arr = [];
let v = n;
for (let i = 0; i < l; i += 7) {
let byte = big_integer_1.default.zero;
if (i === 0) {
byte = v.and(0x3f);
v = v.shiftRight(6);
byte = n.and(0x3f);
n = n.shiftRight(6);
}
else {
byte = v.and(0x7f);
v = v.shiftRight(7);
byte = n.and(0x7f);
n = n.shiftRight(7);
}

@@ -345,2 +344,4 @@ if (value < 0 && i === 0) {

}
case 'chain_id': {
}
case 'bytes': {

@@ -347,0 +348,0 @@ const buffer = value.toString('hex');

@@ -7,2 +7,3 @@ import { KeyStore, Signer } from '../../types/ExternalInterfaces';

function forgeOperationsRemotely(server: string, branch: string, operations: TezosP2PMessageTypes.Operation[], chainid?: string): Promise<string>;
function packDataRemotely(server: string, data: string, type: string, gas?: number, chainid?: string): Promise<string>;
function preapplyOperation(server: string, branch: string, protocol: string, operations: TezosP2PMessageTypes.Operation[], signedOpGroup: TezosTypes.SignedOperationGroup, chainid?: string): Promise<TezosTypes.AlphaOperationsWithMetadata[]>;

@@ -14,8 +15,8 @@ function injectOperation(server: string, signedOpGroup: TezosTypes.SignedOperationGroup, chainid?: string): Promise<string>;

function appendRevealOperation(server: string, publicKey: string, accountHash: string, accountOperationIndex: number, operations: TezosP2PMessageTypes.StackableOperation[]): Promise<(TezosP2PMessageTypes.Transaction | TezosP2PMessageTypes.Delegation | TezosP2PMessageTypes.Reveal)[]>;
function sendTransactionOperation(server: string, signer: Signer, keyStore: KeyStore, to: string, amount: number, fee: number, offset?: number): Promise<TezosTypes.OperationResult>;
function sendDelegationOperation(server: string, signer: Signer, keyStore: KeyStore, delegate: string | undefined, fee?: number, offset?: number): Promise<TezosTypes.OperationResult>;
function sendUndelegationOperation(server: string, signer: Signer, keyStore: KeyStore, fee?: number, offset?: number): Promise<TezosTypes.OperationResult>;
function sendContractOriginationOperation(server: string, signer: Signer, keyStore: KeyStore, amount: number, delegate: string | undefined, fee: number, storageLimit: number, gasLimit: number, code: string, storage: string, codeFormat?: TezosTypes.TezosParameterFormat, offset?: number): Promise<TezosTypes.OperationResult>;
function sendTransactionOperation(server: string, signer: Signer, keyStore: KeyStore, to: string, amount: number, fee?: number, offset?: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
function sendDelegationOperation(server: string, signer: Signer, keyStore: KeyStore, delegate: string | undefined, fee?: number, offset?: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
function sendUndelegationOperation(server: string, signer: Signer, keyStore: KeyStore, fee?: number, offset?: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
function sendContractOriginationOperation(server: string, signer: Signer, keyStore: KeyStore, amount: number, delegate: string | undefined, fee: number, storageLimit: number, gasLimit: number, code: string, storage: string, codeFormat?: TezosTypes.TezosParameterFormat, offset?: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
function constructContractOriginationOperation(keyStore: KeyStore, amount: number, delegate: string | undefined, fee: number, storageLimit: number, gasLimit: number, code: string, storage: string, codeFormat: TezosTypes.TezosParameterFormat, counter: number): TezosP2PMessageTypes.Origination;
function sendContractInvocationOperation(server: string, signer: Signer, keyStore: KeyStore, contract: string, amount: number, fee: number, storageLimit: number, gasLimit: number, entrypoint: string | undefined, parameters: string | undefined, parameterFormat?: TezosTypes.TezosParameterFormat, offset?: number): Promise<TezosTypes.OperationResult>;
function sendContractInvocationOperation(server: string, signer: Signer, keyStore: KeyStore, contract: string, amount: number, fee: number, storageLimit: number, gasLimit: number, entrypoint: string | undefined, parameters: string | undefined, parameterFormat?: TezosTypes.TezosParameterFormat, offset?: number, optimizeFee?: boolean): Promise<TezosTypes.OperationResult>;
function constructContractInvocationOperation(publicKeyHash: string, counter: number, to: string, amount: number, fee: number, storageLimit: number, gasLimit: number, entrypoint: string | undefined, parameters: string | undefined, parameterFormat?: TezosTypes.TezosParameterFormat): TezosP2PMessageTypes.Transaction;

@@ -28,2 +29,4 @@ function sendContractPing(server: string, signer: Signer, keyStore: KeyStore, to: string, fee: number, storageLimit: number, gasLimit: number, entrypoint: string | undefined): Promise<TezosTypes.OperationResult>;

storageCost: number;
estimatedFee: number;
estimatedStorageBurn: number;
}>;

@@ -33,9 +36,14 @@ function testContractDeployOperation(server: string, chainid: string, keyStore: KeyStore, amount: number, delegate: string | undefined, fee: number, storageLimit: number, gasLimit: number, code: string, storage: string, codeFormat?: TezosTypes.TezosParameterFormat): Promise<{

storageCost: number;
estimatedFee: number;
estimatedStorageBurn: number;
}>;
function estimateOperationGroup(server: string, chainid: string, operations: Array<TezosP2PMessageTypes.StackableOperation>): Promise<any>;
function estimateOperation(server: string, chainid: string, ...operations: TezosP2PMessageTypes.Operation[]): Promise<{
gas: number;
storageCost: number;
estimatedFee: number;
estimatedStorageBurn: number;
}>;
function dryRunOperation(server: string, chainid: string, ...operations: TezosP2PMessageTypes.Operation[]): Promise<Response>;
function dryRunOperation(server: string, chainid: string, ...operations: TezosP2PMessageTypes.Operation[]): Promise<any>;
function parseRPCError(response: string): void;
}

@@ -94,2 +94,18 @@ "use strict";

TezosNodeWriter.forgeOperationsRemotely = forgeOperationsRemotely;
function packDataRemotely(server, data, type, gas = TezosConstants_1.TezosConstants.OperationGasCap, chainid = 'main') {
return __awaiter(this, void 0, void 0, function* () {
log.debug('TezosNodeWriter.packDataRemotely:');
log.debug(JSON.stringify(data));
log.warn('packDataRemotely() is not intrinsically trustless');
const response = yield performPostRequest(server, `chains/${chainid}/blocks/head/helpers/scripts/pack_data`, { data, type, gas: `${gas}` });
const jsonResponse = yield response.json();
try {
return jsonResponse.packed;
}
catch (e) {
throw new Error(`Could not pack ${data} as ${type}; error ${e}`);
}
});
}
TezosNodeWriter.packDataRemotely = packDataRemotely;
function preapplyOperation(server, branch, protocol, operations, signedOpGroup, chainid = 'main') {

@@ -128,3 +144,3 @@ return __awaiter(this, void 0, void 0, function* () {

TezosNodeWriter.injectOperation = injectOperation;
function sendOperation(server, operations, signer, offset = 54) {
function sendOperation(server, operations, signer, offset = TezosConstants_1.TezosConstants.HeadBranchOffset) {
return __awaiter(this, void 0, void 0, function* () {

@@ -170,4 +186,4 @@ const blockHead = yield TezosNodeReader_1.TezosNodeReader.getBlockAtOffset(server, offset);

counter: counter.toString(),
gas_limit: '10600',
storage_limit: '0',
gas_limit: TezosConstants_1.TezosConstants.DefaultKeyRevealGasLimit.toString(),
storage_limit: TezosConstants_1.TezosConstants.DefaultKeyRevealStorageLimit.toString(),
public_key: publicKey

@@ -185,3 +201,3 @@ };

TezosNodeWriter.appendRevealOperation = appendRevealOperation;
function sendTransactionOperation(server, signer, keyStore, to, amount, fee, offset = 54) {
function sendTransactionOperation(server, signer, keyStore, to, amount, fee = TezosConstants_1.TezosConstants.DefaultSimpleTransactionFee, offset = TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee = false) {
return __awaiter(this, void 0, void 0, function* () {

@@ -200,2 +216,8 @@ const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1;

const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [transaction]);
if (optimizeFee) {
const estimate = yield estimateOperation(server, 'main', ...operations);
transaction.fee = estimate.estimatedFee.toString();
transaction.gas_limit = estimate.gas.toString();
transaction.storage_limit = estimate.storageCost.toString();
}
return sendOperation(server, operations, signer, offset);

@@ -205,3 +227,3 @@ });

TezosNodeWriter.sendTransactionOperation = sendTransactionOperation;
function sendDelegationOperation(server, signer, keyStore, delegate, fee = TezosConstants_1.TezosConstants.DefaultDelegationFee, offset = 54) {
function sendDelegationOperation(server, signer, keyStore, delegate, fee = TezosConstants_1.TezosConstants.DefaultDelegationFee, offset = TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee = false) {
return __awaiter(this, void 0, void 0, function* () {

@@ -214,7 +236,13 @@ const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1;

counter: counter.toString(),
storage_limit: TezosConstants_1.TezosConstants.DefaultDelegationStorageLimit + '',
gas_limit: TezosConstants_1.TezosConstants.DefaultDelegationGasLimit + '',
storage_limit: TezosConstants_1.TezosConstants.DefaultDelegationStorageLimit.toString(),
gas_limit: TezosConstants_1.TezosConstants.DefaultDelegationGasLimit.toString(),
delegate: delegate
};
const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [delegation]);
if (optimizeFee) {
const estimate = yield estimateOperation(server, 'main', ...operations);
delegation.fee = estimate.estimatedFee.toString();
delegation.gas_limit = estimate.gas.toString();
delegation.storage_limit = estimate.storageCost.toString();
}
return sendOperation(server, operations, signer, offset);

@@ -224,9 +252,9 @@ });

TezosNodeWriter.sendDelegationOperation = sendDelegationOperation;
function sendUndelegationOperation(server, signer, keyStore, fee = TezosConstants_1.TezosConstants.DefaultDelegationFee, offset = 54) {
function sendUndelegationOperation(server, signer, keyStore, fee = TezosConstants_1.TezosConstants.DefaultDelegationFee, offset = TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee = false) {
return __awaiter(this, void 0, void 0, function* () {
return sendDelegationOperation(server, signer, keyStore, undefined, fee, offset);
return sendDelegationOperation(server, signer, keyStore, undefined, fee, offset, optimizeFee);
});
}
TezosNodeWriter.sendUndelegationOperation = sendUndelegationOperation;
function sendContractOriginationOperation(server, signer, keyStore, amount, delegate, fee, storageLimit, gasLimit, code, storage, codeFormat = TezosTypes.TezosParameterFormat.Micheline, offset = 54) {
function sendContractOriginationOperation(server, signer, keyStore, amount, delegate, fee, storageLimit, gasLimit, code, storage, codeFormat = TezosTypes.TezosParameterFormat.Micheline, offset = TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee = false) {
return __awaiter(this, void 0, void 0, function* () {

@@ -236,2 +264,10 @@ const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1;

const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [operation]);
if (optimizeFee) {
const estimate = yield estimateOperationGroup(server, 'main', operations);
operation.fee = estimate.estimatedFee.toString();
for (let i = 0; i < operations.length; i++) {
operation.gas_limit = estimate.operationResources[i].gas.toString();
operation.storage_limit = estimate.operationResources[i].storageCost.toString();
}
}
return sendOperation(server, operations, signer, offset);

@@ -267,3 +303,3 @@ });

TezosNodeWriter.constructContractOriginationOperation = constructContractOriginationOperation;
function sendContractInvocationOperation(server, signer, keyStore, contract, amount, fee, storageLimit, gasLimit, entrypoint, parameters, parameterFormat = TezosTypes.TezosParameterFormat.Micheline, offset = 54) {
function sendContractInvocationOperation(server, signer, keyStore, contract, amount, fee, storageLimit, gasLimit, entrypoint, parameters, parameterFormat = TezosTypes.TezosParameterFormat.Micheline, offset = TezosConstants_1.TezosConstants.HeadBranchOffset, optimizeFee = false) {
return __awaiter(this, void 0, void 0, function* () {

@@ -273,2 +309,8 @@ const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1;

const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [transaction]);
if (optimizeFee) {
const estimate = yield estimateOperation(server, 'main', transaction);
transaction.fee = estimate.estimatedFee.toString();
transaction.gas_limit = estimate.gas.toString();
transaction.storage_limit = estimate.storageCost.toString();
}
return sendOperation(server, operations, signer, offset);

@@ -314,3 +356,3 @@ });

TezosNodeWriter.sendContractPing = sendContractPing;
function sendKeyRevealOperation(server, signer, keyStore, fee = TezosConstants_1.TezosConstants.DefaultKeyRevealFee, offset = 54) {
function sendKeyRevealOperation(server, signer, keyStore, fee = TezosConstants_1.TezosConstants.DefaultKeyRevealFee, offset = TezosConstants_1.TezosConstants.HeadBranchOffset) {
return __awaiter(this, void 0, void 0, function* () {

@@ -349,14 +391,42 @@ const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1;

const transaction = constructContractOriginationOperation(keyStore, amount, delegate, fee, storageLimit, gasLimit, code, storage, codeFormat, counter);
const resources = yield estimateOperation(server, chainid, transaction);
const fixedOriginationStorageCost = 257;
return {
gas: resources.gas,
storageCost: resources.storageCost + fixedOriginationStorageCost
};
return estimateOperation(server, chainid, transaction);
});
}
TezosNodeWriter.testContractDeployOperation = testContractDeployOperation;
function estimateOperationGroup(server, chainid, operations) {
return __awaiter(this, void 0, void 0, function* () {
let operationResources = [];
for (let i = 0; i < operations.length; i++) {
const operation = operations[i];
let priorConsumedResources = { gas: 0, storageCost: 0 };
if (i > 0) {
const priorTransactions = operations.slice(0, i);
priorConsumedResources = yield estimateOperation(server, chainid, ...priorTransactions);
}
const currentTransactions = operations.slice(0, i + 1);
const currentConsumedResources = yield TezosNodeWriter.estimateOperation(server, chainid, ...currentTransactions);
const gasLimitDelta = currentConsumedResources.gas - priorConsumedResources.gas;
const storageLimitDelta = currentConsumedResources.storageCost - priorConsumedResources.storageCost;
operationResources.push({
gas: gasLimitDelta + TezosConstants_1.TezosConstants.GasLimitPadding,
storageCost: storageLimitDelta + TezosConstants_1.TezosConstants.StorageLimitPadding
});
}
const gasLimitTotal = operationResources.map(r => r.gas).reduce((a, c) => a + c, 0);
const storageLimitTotal = operationResources.map(r => r.storageCost).reduce((a, c) => a + c, 0);
const forgedOperationGroup = forgeOperations('BMLxA4tQjiu1PT2x3dMiijgvMTQo8AVxkPBPpdtM8hCfiyiC1jz', operations);
const groupSize = forgedOperationGroup.length / 2 + 64;
let estimatedFee = Math.ceil(gasLimitTotal / 10) + TezosConstants_1.TezosConstants.BaseOperationFee + groupSize + TezosConstants_1.TezosConstants.DefaultBakerVig;
const estimatedStorageBurn = Math.ceil(storageLimitTotal * TezosConstants_1.TezosConstants.StorageRate);
if (Number(operations[0].fee) < estimatedFee) {
estimatedFee += 16;
}
log.debug('group estimate', operationResources, estimatedFee, estimatedStorageBurn);
return { operationResources, estimatedFee, estimatedStorageBurn };
});
}
TezosNodeWriter.estimateOperationGroup = estimateOperationGroup;
function estimateOperation(server, chainid, ...operations) {
return __awaiter(this, void 0, void 0, function* () {
const responseJSON = dryRunOperation(server, chainid, ...operations);
const responseJSON = yield dryRunOperation(server, chainid, ...operations);
let gas = 0;

@@ -368,2 +438,5 @@ let storageCost = 0;

storageCost += parseInt(c['metadata']['operation_result']['paid_storage_size_diff']) || 0;
if (c.kind === 'origination') {
storageCost += TezosConstants_1.TezosConstants.EmptyAccountStorageBurn;
}
}

@@ -379,5 +452,13 @@ catch (_a) { }

storageCost += parseInt(result['paid_storage_size_diff']) || 0;
if (result.kind === 'origination') {
storageCost += TezosConstants_1.TezosConstants.EmptyAccountStorageBurn;
}
}
}
return { gas, storageCost };
const forgedOperationGroup = forgeOperations('BMLxA4tQjiu1PT2x3dMiijgvMTQo8AVxkPBPpdtM8hCfiyiC1jz', operations);
const operationSize = forgedOperationGroup.length / 2 + 64;
const estimatedFee = Math.ceil(gas / 10) + TezosConstants_1.TezosConstants.BaseOperationFee + operationSize + TezosConstants_1.TezosConstants.DefaultBakerVig;
const estimatedStorageBurn = Math.ceil(storageCost * TezosConstants_1.TezosConstants.StorageRate);
log.debug(`TezosNodeWriter.estimateOperation; gas: ${gas}, storage: ${storageCost}, fee estimate: ${estimatedFee}, burn estimate: ${estimatedStorageBurn}`);
return { gas, storageCost, estimatedFee, estimatedStorageBurn };
});

@@ -384,0 +465,0 @@ }

@@ -6,2 +6,3 @@ export * from './chain/tezos/TezosContractIntrospector';

export * from './chain/tezos/TezosNodeWriter';
export * from './chain/tezos/contracts/TezosContractUtils';
export * from './chain/tezos/contracts/BabylonDelegationHelper';

@@ -8,0 +9,0 @@ export * from './chain/tezos/contracts/CryptonomicNameServiceHelper';

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

__export(require("./chain/tezos/TezosNodeWriter"));
__export(require("./chain/tezos/contracts/TezosContractUtils"));
__export(require("./chain/tezos/contracts/BabylonDelegationHelper"));

@@ -20,0 +21,0 @@ __export(require("./chain/tezos/contracts/CryptonomicNameServiceHelper"));

@@ -8,2 +8,3 @@ export declare function registerLogger(logger: any): void;

export * from "./chain/tezos/TezosNodeWriter";
export * from './chain/tezos/contracts/TezosContractUtils';
export * from './chain/tezos/contracts/BabylonDelegationHelper';

@@ -10,0 +11,0 @@ export * from './chain/tezos/contracts/CryptonomicNameServiceHelper';

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

__export(require("./chain/tezos/TezosNodeWriter"));
__export(require("./chain/tezos/contracts/TezosContractUtils"));
__export(require("./chain/tezos/contracts/BabylonDelegationHelper"));

@@ -26,0 +27,0 @@ __export(require("./chain/tezos/contracts/CryptonomicNameServiceHelper"));

@@ -38,2 +38,5 @@ "use strict";

return r;
}).catch(e => {
log.error('executeEntityQuery request error, ', e);
return [];
})

@@ -45,2 +48,5 @@ .then(r => {

return response;
}).catch(e => {
log.error('executeEntityQuery response error, ', e);
return [];
});

@@ -47,0 +53,0 @@ });

@@ -28,2 +28,3 @@ import { ConseilQuery, ConseilServerInfo } from "../../types/conseil/QueryTypes";

};
function countKeysInMap(serverInfo: ConseilServerInfo, mapIndex: number): Promise<number>;
}

@@ -313,3 +313,20 @@ "use strict";

TezosConseilClient.getEntityQueryForId = getEntityQueryForId;
function countKeysInMap(serverInfo, mapIndex) {
return __awaiter(this, void 0, void 0, function* () {
let countQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.blankQuery();
countQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addFields(countQuery, 'key');
countQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addPredicate(countQuery, 'big_map_id', QueryTypes_1.ConseilOperator.EQ, [mapIndex]);
countQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addAggregationFunction(countQuery, 'key', QueryTypes_1.ConseilFunction.count);
countQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.setLimit(countQuery, 1);
const result = yield ConseilDataClient_1.ConseilDataClient.executeEntityQuery(serverInfo, 'tezos', serverInfo.network, 'big_map_contents', countQuery);
try {
return result[0]['count_key'];
}
catch (_a) {
return -1;
}
});
}
TezosConseilClient.countKeysInMap = countKeysInMap;
})(TezosConseilClient = exports.TezosConseilClient || (exports.TezosConseilClient = {}));
//# sourceMappingURL=TezosConseilClient.js.map
export declare namespace TezosConstants {
const OperationGroupWatermark = "03";
const DefaultSimpleTransactionFee = 1420;
const DefaultTransactionStorageLimit = 496;
const DefaultTransactionGasLimit = 10600;
const DefaultDelegationFee = 1258;
const DefaultDelegationStorageLimit = 0;
const DefaultDelegationGasLimit = 10000;
const DefaultDelegationGasLimit = 1100;
const DefaultAccountOriginationFee = 1266;
const DefaultAccountOriginationStorageLimit = 496;
const DefaultAccountOriginationGasLimit = 10600;
const DefaultAccountOriginationFee = 1266;
const DefaultKeyRevealFee = 1270;
const DefaultDelegationFee = 1258;
const DefaultKeyRevealStorageLimit = 0;
const DefaultKeyRevealGasLimit = 1100;
const P005ManagerContractWithdrawalGasLimit = 26283;
const P005ManagerContractDepositGasLimit = 15285;
const P005ManagerContractWithdrawalStorageLimit = 496;
const P001StorageRate: number;
const P007StorageRate: number;
const StorageRate: number;
const BaseOperationFee = 100;
const P007OperationGasCap = 1040000;
const OperationGasCap = 1040000;
const OperationStorageCap = 60000;
const EmptyAccountStorageBurn = 257;
const DefaultBakerVig = 100;
const GasLimitPadding = 100;
const StorageLimitPadding = 20;
const HeadBranchOffset = 54;
const DefaultBatchDelay = 25;
const DefaultBlockTime = 60;
}

@@ -6,14 +6,29 @@ "use strict";

TezosConstants.OperationGroupWatermark = '03';
TezosConstants.DefaultSimpleTransactionFee = 1420;
TezosConstants.DefaultTransactionStorageLimit = 496;
TezosConstants.DefaultTransactionGasLimit = 10600;
TezosConstants.DefaultDelegationFee = 1258;
TezosConstants.DefaultDelegationStorageLimit = 0;
TezosConstants.DefaultDelegationGasLimit = 10000;
TezosConstants.DefaultDelegationGasLimit = 1100;
TezosConstants.DefaultAccountOriginationFee = 1266;
TezosConstants.DefaultAccountOriginationStorageLimit = 496;
TezosConstants.DefaultAccountOriginationGasLimit = 10600;
TezosConstants.DefaultAccountOriginationFee = 1266;
TezosConstants.DefaultKeyRevealFee = 1270;
TezosConstants.DefaultDelegationFee = 1258;
TezosConstants.DefaultKeyRevealStorageLimit = 0;
TezosConstants.DefaultKeyRevealGasLimit = 1100;
TezosConstants.P005ManagerContractWithdrawalGasLimit = 26283;
TezosConstants.P005ManagerContractDepositGasLimit = 15285;
TezosConstants.P005ManagerContractWithdrawalStorageLimit = 496;
TezosConstants.P001StorageRate = 1000000 / 1000;
TezosConstants.P007StorageRate = 250000 / 1000;
TezosConstants.StorageRate = TezosConstants.P007StorageRate;
TezosConstants.BaseOperationFee = 100;
TezosConstants.P007OperationGasCap = 1040000;
TezosConstants.OperationGasCap = TezosConstants.P007OperationGasCap;
TezosConstants.OperationStorageCap = 60000;
TezosConstants.EmptyAccountStorageBurn = 257;
TezosConstants.DefaultBakerVig = 100;
TezosConstants.GasLimitPadding = 100;
TezosConstants.StorageLimitPadding = 20;
TezosConstants.HeadBranchOffset = 54;
TezosConstants.DefaultBatchDelay = 25;

@@ -20,0 +35,0 @@ TezosConstants.DefaultBlockTime = 60;

{
"name": "conseiljs",
"version": "5.0.6",
"version": "5.0.7-beta.0",
"description": "Client-side library for Tezos dApp development.",

@@ -73,3 +73,3 @@ "browser": "dist/index-web.js",

"bs58check": "2.1.2",
"jsonpath-plus": "4.0.0",
"jsonpath-plus": "5.0.2",
"moo": "0.5.0",

@@ -79,5 +79,5 @@ "nearley": "2.19.1"

"devDependencies": {
"@types/chai": "4.2.12",
"@types/chai": "4.2.14",
"@types/chai-as-promised": "7.1.3",
"@types/mocha": "8.0.3",
"@types/mocha": "8.2.0",
"@types/nock": "11.1.0",

@@ -93,7 +93,7 @@ "@types/node": "14.0.13",

"coveralls": "3.1.0",
"eslint": "7.9.0",
"eslint": "7.18.0",
"glob": "7.1.6",
"loglevel": "1.7.0",
"mocha": "8.1.3",
"nock": "13.0.4",
"loglevel": "1.7.1",
"mocha": "8.2.1",
"nock": "13.0.6",
"node-fetch": "2.6.1",

@@ -104,4 +104,4 @@ "nyc": "15.1.0",

"tsconfig-paths-webpack-plugin": "3.3.0",
"typedoc": "0.19.2",
"typedoc-plugin-markdown": "3.0.3",
"typedoc": "0.18.0",
"typedoc-plugin-markdown": "2.4.2",
"typescript": "3.8.3",

@@ -108,0 +108,0 @@ "webpack": "4.44.2",

@@ -8,7 +8,7 @@ # ConseilJS-core

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Cryptonomic_ConseilJS&metric=alert_status)](https://sonarcloud.io/dashboard?id=Cryptonomic_ConseilJS)
[![dependencies](https://david-dm.org/Cryptonomic/ConseilJS/status.svg)](https://david-dm.org/Cryptonomic/ConseilJS)
[![conseiljs](https://snyk.io/advisor/npm-package/conseiljs/badge.svg)](https://snyk.io/advisor/npm-package/conseiljs)
A library for building decentralized applications in Typescript and Javascript, currently focused on the [Tezos](http://tezos.com/) platform.
ConseilJS connects to Tezos nodes for live chain data and operations and to [Conseil](https://github.com/Cryptonomic/Conseil) servers for high-performance analytics on blockchain data. Internally, Cryptonomic uses [Nautilus](https://github.com/Cryptonomic/Nautilus) for infrastructure deployments of these services. This is the library at the core of our products, [Arronax](https://arronax.io), [Mininax](https://mininax.io) and certainly [Galleon](https://cryptonomic.tech/galleon.html). There are [ReasonML bindings](https://github.com/Cryptonomic/ConseilJS-ReasonML-Bindings) as well.
ConseilJS connects to Tezos nodes for live chain data and operations and to [Conseil](https://github.com/Cryptonomic/Conseil) servers for high-performance analytics on blockchain data. Internally, Cryptonomic uses [Nautilus](https://github.com/Cryptonomic/Nautilus) for infrastructure deployments of these services. This is the library at the core of our products – [Arronax](https://arronax.io), [Periscope](https://periscope.arronax.io), [Harpoon](https://harpoon.arronax.io) and certainly [Galleon](https://cryptonomic.tech/galleon.html). There are [ReasonML bindings](https://github.com/Cryptonomic/ConseilJS-ReasonML-Bindings) as well.

@@ -21,3 +21,3 @@ Cryptonomic offers an infrastructure service - [Nautilus Cloud](https://nautilus.cloud) which enables quick access to the Tezos platform along with products that make it easier build on it.

For more details on how to use these libraries see their respective readme files: [ConseilJS-core](./blob/master/ConseilJS/docs/README.md), [ConseilJS-softsigner](https://github.com/Cryptonomic/ConseilJS-softsigner/blob/master/README.md), [ConseilJS-ledgersigner](https://github.com/Cryptonomic/ConseilJS-ledgersigner/blob/master/README.md).
For more details on how to use these libraries see their respective readme files: [ConseilJS-core](./blob/master/ConseilJS/docs/README.md), [ConseilJS-softsigner](https://github.com/Cryptonomic/ConseilJS-softsigner/blob/master/README.md), [ConseilJS-ledgersigner](https://github.com/Cryptonomic/ConseilJS-ledgersigner/blob/master/README.md). There is also an [AWS KMS signer](https://www.npmjs.com/package/@tacoinfra/tezos-kms) that is compatible with ConseilJS, maintained by [@tacoinfra](https://github.com/tacoinfra).

@@ -56,3 +56,3 @@ ## Use with Nodejs

TBD
Project [honeybadger](https://github.com/Cryptonomic/honeybadger), which is the basis for [Galleon Mobile](https://apps.apple.com/us/app/galleon-mobile-wallet/id1521872814) us built with ConseilJS as well. Due to limitations of react-native we re-implemented some of the necessary functionality into a [separate module](https://github.com/Cryptonomic/honeybadger/tree/trunk/src/softsigner).

@@ -65,3 +65,3 @@ ## Use with Web

<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs/dist-web/conseiljs.min.js"
integrity="sha384-Y4koW2PhHK4PfHtil6LTWRqMxy3k3ym8AWecTAIuA0cLcJNGFdLmrG2/FXZucfZp"
integrity="sha384-PNgOUrCFUbpIF6W1GSjxT8Iwjfe4nt2+mtT7IRsI//8P7akhhrmedJ0DFZqrzDty"
crossorigin="anonymous"></script>

@@ -68,0 +68,0 @@ <script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs-softsigner/dist-web/conseiljs-softsigner.min.js"

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

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