conseiljs
Advanced tools
Comparing version 5.0.5 to 5.0.6-1
@@ -37,2 +37,3 @@ /// <reference types="node" /> | ||
function simpleHash(payload: Buffer, length: number): Buffer; | ||
function calculateContractAddress(operationHash: string, index: number): string; | ||
} |
@@ -443,3 +443,27 @@ "use strict"; | ||
} | ||
function calculateContractAddress(operationHash, index) { | ||
const decoded = bs58check_1.default.decode(operationHash).slice(2); | ||
let decodedAndOperationPrefix = []; | ||
for (let i = 0; i < decoded.length; i++) { | ||
decodedAndOperationPrefix.push(decoded[i]); | ||
} | ||
decodedAndOperationPrefix = decodedAndOperationPrefix.concat([ | ||
(index & 0xff000000) >> 24, | ||
(index & 0x00ff0000) >> 16, | ||
(index & 0x0000ff00) >> 8, | ||
index & 0x000000ff, | ||
]); | ||
const hash = blakejs.blake2b(new Uint8Array(decodedAndOperationPrefix), null, 20); | ||
const smartContractAddressPrefix = new Uint8Array([2, 90, 121]); | ||
const prefixedBytes = mergeBytes(smartContractAddressPrefix, hash); | ||
return bs58check_1.default.encode(prefixedBytes); | ||
} | ||
TezosMessageUtils.calculateContractAddress = calculateContractAddress; | ||
function mergeBytes(a, b) { | ||
const merged = new Uint8Array(a.length + b.length); | ||
merged.set(a); | ||
merged.set(b, a.length); | ||
return merged; | ||
} | ||
})(TezosMessageUtils = exports.TezosMessageUtils || (exports.TezosMessageUtils = {})); | ||
//# sourceMappingURL=TezosMessageUtil.js.map |
import * as TezosRPCTypes from '../../types/tezos/TezosRPCResponseTypes'; | ||
export declare namespace TezosNodeReader { | ||
function getDelegate(server: string, accountHash: string): Promise<string | undefined>; | ||
function getBlock(server: string, hash?: string, chainid?: string): Promise<TezosRPCTypes.TezosBlock>; | ||
@@ -4,0 +5,0 @@ function getBlockHead(server: string): Promise<TezosRPCTypes.TezosBlock>; |
@@ -39,2 +39,9 @@ "use strict"; | ||
} | ||
function getDelegate(server, accountHash) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const contractData = yield getAccountForBlock(server, 'head', accountHash); | ||
return contractData.delegate; | ||
}); | ||
} | ||
TezosNodeReader.getDelegate = getDelegate; | ||
function getBlock(server, hash = 'head', chainid = 'main') { | ||
@@ -41,0 +48,0 @@ return performGetRequest(server, `chains/${chainid}/blocks/${hash}`).then(json => { return json; }); |
@@ -35,3 +35,4 @@ import { KeyStore, Signer } from '../../types/ExternalInterfaces'; | ||
}>; | ||
function dryRunOperation(server: string, chainid: string, ...operations: TezosP2PMessageTypes.Operation[]): Promise<Response>; | ||
function parseRPCError(response: string): void; | ||
} |
@@ -130,3 +130,4 @@ "use strict"; | ||
const blockHead = yield TezosNodeReader_1.TezosNodeReader.getBlockAtOffset(server, offset); | ||
const forgedOperationGroup = forgeOperations(blockHead.hash, operations); | ||
const blockHash = blockHead.hash.slice(0, 51); | ||
const forgedOperationGroup = forgeOperations(blockHash, operations); | ||
const opSignature = yield signer.signOperation(Buffer.from(TezosConstants_1.TezosConstants.OperationGroupWatermark + forgedOperationGroup, 'hex')); | ||
@@ -136,3 +137,3 @@ const signedOpGroup = Buffer.concat([Buffer.from(forgedOperationGroup, 'hex'), opSignature]); | ||
const opPair = { bytes: signedOpGroup, signature: base58signature }; | ||
const appliedOp = yield preapplyOperation(server, blockHead.hash, blockHead.protocol, operations, opPair); | ||
const appliedOp = yield preapplyOperation(server, blockHash, blockHead.protocol, operations, opPair); | ||
const injectedOperation = yield injectOperation(server, opPair); | ||
@@ -349,9 +350,3 @@ return { results: appliedOp[0], operationGroupID: injectedOperation }; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fake_signature = 'edsigu6xFLH2NpJ1VcYshpjW99Yc1TAL1m2XBqJyXrxcZQgBMo8sszw2zm626yjpA3pWMhjpsahLrWdmvX9cqhd4ZEUchuBuFYy'; | ||
const fake_chainid = 'NetXdQprcVkpaWU'; | ||
const fake_branch = 'BL94i2ShahPx3BoNs6tJdXDdGeoJ9ukwujUA2P8WJwULYNdimmq'; | ||
const response = yield performPostRequest(server, `chains/${chainid}/blocks/head/helpers/scripts/run_operation`, { chain_id: fake_chainid, operation: { branch: fake_branch, contents: operations, signature: fake_signature } }); | ||
const responseText = yield response.text(); | ||
parseRPCError(responseText); | ||
const responseJSON = JSON.parse(responseText); | ||
const responseJSON = yield dryRunOperation(server, chainid, ...operations); | ||
let gas = 0; | ||
@@ -379,2 +374,15 @@ let storageCost = 0; | ||
TezosNodeWriter.estimateOperation = estimateOperation; | ||
function dryRunOperation(server, chainid, ...operations) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fake_signature = 'edsigu6xFLH2NpJ1VcYshpjW99Yc1TAL1m2XBqJyXrxcZQgBMo8sszw2zm626yjpA3pWMhjpsahLrWdmvX9cqhd4ZEUchuBuFYy'; | ||
const fake_chainid = 'NetXdQprcVkpaWU'; | ||
const fake_branch = 'BL94i2ShahPx3BoNs6tJdXDdGeoJ9ukwujUA2P8WJwULYNdimmq'; | ||
const response = yield performPostRequest(server, `chains/${chainid}/blocks/head/helpers/scripts/run_operation`, { chain_id: fake_chainid, operation: { branch: fake_branch, contents: operations, signature: fake_signature } }); | ||
const responseText = yield response.text(); | ||
parseRPCError(responseText); | ||
const responseJSON = JSON.parse(responseText); | ||
return responseJSON; | ||
}); | ||
} | ||
TezosNodeWriter.dryRunOperation = dryRunOperation; | ||
function parseRPCError(response) { | ||
@@ -381,0 +389,0 @@ let errors = ''; |
@@ -6,5 +6,6 @@ export * from './chain/tezos/TezosContractIntrospector'; | ||
export * from './chain/tezos/TezosNodeWriter'; | ||
export * from './chain/tezos/contracts/TezosContractUtils'; | ||
export * from './chain/tezos/contracts/BabylonDelegationHelper'; | ||
export * from './chain/tezos/contracts/CryptonomicNameServiceHelper'; | ||
export * from './chain/tezos/contracts/DexterTokenHelper'; | ||
export * from './chain/tezos/contracts/DexterPoolHelper'; | ||
export * from './chain/tezos/contracts/MurbardMultisigHelper'; | ||
@@ -18,2 +19,3 @@ export * from './chain/tezos/contracts/StakerDAOTokenHelper'; | ||
export * from './chain/tezos/contracts/TzbtcTokenHelper'; | ||
export * from './chain/tezos/contracts/WrappedTezosHelper'; | ||
export * from './reporting/tezos/TezosConseilClient'; | ||
@@ -20,0 +22,0 @@ export * from './reporting/ConseilDataClient'; |
@@ -18,5 +18,6 @@ "use strict"; | ||
__export(require("./chain/tezos/TezosNodeWriter")); | ||
__export(require("./chain/tezos/contracts/TezosContractUtils")); | ||
__export(require("./chain/tezos/contracts/BabylonDelegationHelper")); | ||
__export(require("./chain/tezos/contracts/CryptonomicNameServiceHelper")); | ||
__export(require("./chain/tezos/contracts/DexterTokenHelper")); | ||
__export(require("./chain/tezos/contracts/DexterPoolHelper")); | ||
__export(require("./chain/tezos/contracts/MurbardMultisigHelper")); | ||
@@ -30,2 +31,3 @@ __export(require("./chain/tezos/contracts/StakerDAOTokenHelper")); | ||
__export(require("./chain/tezos/contracts/TzbtcTokenHelper")); | ||
__export(require("./chain/tezos/contracts/WrappedTezosHelper")); | ||
__export(require("./reporting/tezos/TezosConseilClient")); | ||
@@ -32,0 +34,0 @@ __export(require("./reporting/ConseilDataClient")); |
@@ -8,5 +8,6 @@ export declare function registerLogger(logger: any): void; | ||
export * from "./chain/tezos/TezosNodeWriter"; | ||
export * from './chain/tezos/contracts/TezosContractUtils'; | ||
export * from './chain/tezos/contracts/BabylonDelegationHelper'; | ||
export * from './chain/tezos/contracts/CryptonomicNameServiceHelper'; | ||
export * from './chain/tezos/contracts/DexterTokenHelper'; | ||
export * from './chain/tezos/contracts/DexterPoolHelper'; | ||
export * from './chain/tezos/contracts/MurbardMultisigHelper'; | ||
@@ -20,2 +21,3 @@ export * from './chain/tezos/contracts/StakerDAOTokenHelper'; | ||
export * from './chain/tezos/contracts/TzbtcTokenHelper'; | ||
export * from './chain/tezos/contracts/WrappedTezosHelper'; | ||
export * from "./reporting/tezos/TezosConseilClient"; | ||
@@ -22,0 +24,0 @@ export * from './reporting/ConseilDataClient'; |
@@ -24,5 +24,6 @@ "use strict"; | ||
__export(require("./chain/tezos/TezosNodeWriter")); | ||
__export(require("./chain/tezos/contracts/TezosContractUtils")); | ||
__export(require("./chain/tezos/contracts/BabylonDelegationHelper")); | ||
__export(require("./chain/tezos/contracts/CryptonomicNameServiceHelper")); | ||
__export(require("./chain/tezos/contracts/DexterTokenHelper")); | ||
__export(require("./chain/tezos/contracts/DexterPoolHelper")); | ||
__export(require("./chain/tezos/contracts/MurbardMultisigHelper")); | ||
@@ -36,2 +37,3 @@ __export(require("./chain/tezos/contracts/StakerDAOTokenHelper")); | ||
__export(require("./chain/tezos/contracts/TzbtcTokenHelper")); | ||
__export(require("./chain/tezos/contracts/WrappedTezosHelper")); | ||
__export(require("./reporting/tezos/TezosConseilClient")); | ||
@@ -38,0 +40,0 @@ __export(require("./reporting/ConseilDataClient")); |
@@ -29,2 +29,3 @@ "use strict"; | ||
headers: { 'apiKey': serverInfo.apiKey, 'Content-Type': 'application/json' }, | ||
cache: 'no-store', | ||
body: JSON.stringify(query) | ||
@@ -31,0 +32,0 @@ }) |
@@ -11,6 +11,11 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ConseilQueryBuilder_1 = require("../ConseilQueryBuilder"); | ||
const QueryTypes_1 = require("../../types/conseil/QueryTypes"); | ||
const LoggerSelector_1 = __importDefault(require("../../utils/LoggerSelector")); | ||
const ConseilDataClient_1 = require("../ConseilDataClient"); | ||
const ConseilQueryBuilder_1 = require("../ConseilQueryBuilder"); | ||
const log = LoggerSelector_1.default.log; | ||
var TezosConseilClient; | ||
@@ -141,6 +146,10 @@ (function (TezosConseilClient) { | ||
const initialLevel = (yield getBlockHead(serverInfo, network))['level']; | ||
const timeOffset = 180000; | ||
const startTime = (new Date).getTime() - timeOffset; | ||
const estimatedEndTime = startTime + timeOffset + duration * blocktime * 1000; | ||
log.debug(`TezosConseilClient.awaitOperationConfirmation looking for ${hash} since ${initialLevel} at ${(new Date(startTime).toUTCString())}, +${duration}`); | ||
let currentLevel = initialLevel; | ||
let operationQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.blankQuery(); | ||
operationQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addPredicate(operationQuery, 'operation_group_hash', QueryTypes_1.ConseilOperator.EQ, [hash], false); | ||
operationQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addPredicate(operationQuery, 'timestamp', QueryTypes_1.ConseilOperator.AFTER, [(new Date).getTime() - 60000], false); | ||
operationQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.addPredicate(operationQuery, 'timestamp', QueryTypes_1.ConseilOperator.AFTER, [startTime], false); | ||
operationQuery = ConseilQueryBuilder_1.ConseilQueryBuilder.setLimit(operationQuery, 1); | ||
@@ -156,2 +165,5 @@ while (initialLevel + duration > currentLevel) { | ||
} | ||
if ((new Date).getTime() > estimatedEndTime) { | ||
break; | ||
} | ||
yield new Promise(resolve => setTimeout(resolve, blocktime * 1000)); | ||
@@ -158,0 +170,0 @@ } |
@@ -9,5 +9,5 @@ /// <reference types="node" /> | ||
getSignerCurve: () => SignerCurve; | ||
signOperation: (bytes: Buffer) => Promise<Buffer>; | ||
signText: (message: string) => Promise<string>; | ||
signTextHash: (message: string) => Promise<string>; | ||
signOperation: (bytes: Buffer, password?: string) => Promise<Buffer>; | ||
signText: (message: string, password?: string) => Promise<string>; | ||
signTextHash: (message: string, password?: string) => Promise<string>; | ||
} | ||
@@ -14,0 +14,0 @@ export interface KeyStore { |
@@ -6,3 +6,3 @@ export declare namespace TezosConstants { | ||
const DefaultDelegationStorageLimit = 0; | ||
const DefaultDelegationGasLimit = 10000; | ||
const DefaultDelegationGasLimit = 1101; | ||
const DefaultAccountOriginationStorageLimit = 496; | ||
@@ -9,0 +9,0 @@ const DefaultAccountOriginationGasLimit = 10600; |
@@ -9,3 +9,3 @@ "use strict"; | ||
TezosConstants.DefaultDelegationStorageLimit = 0; | ||
TezosConstants.DefaultDelegationGasLimit = 10000; | ||
TezosConstants.DefaultDelegationGasLimit = 1101; | ||
TezosConstants.DefaultAccountOriginationStorageLimit = 496; | ||
@@ -12,0 +12,0 @@ TezosConstants.DefaultAccountOriginationGasLimit = 10600; |
@@ -102,9 +102,5 @@ export interface TezosBlock { | ||
balance: string; | ||
delegate?: ContractDelegate; | ||
delegate?: string; | ||
script?: any; | ||
counter: string; | ||
} | ||
export interface ContractDelegate { | ||
setable: boolean; | ||
value: string; | ||
} |
{ | ||
"name": "conseiljs", | ||
"version": "5.0.5", | ||
"version": "5.0.6-1", | ||
"description": "Client-side library for Tezos dApp development.", | ||
@@ -5,0 +5,0 @@ "browser": "dist/index-web.js", |
@@ -12,3 +12,3 @@ # ConseilJS-core | ||
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, [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-DsZ98An5RJlEquKpG7VziukP7Zqae8IlsF9VmTnz41Ga8FvAx6Hvn0hMkpBj3pms" | ||
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
766043
136
7416
1