conseiljs
Advanced tools
Comparing version 5.0.3-beta.1 to 5.0.3-beta.2
/// <reference types="node" /> | ||
import { SignedOperationGroup } from '../../types/tezos/TezosChainTypes'; | ||
import { TezosParameterFormat } from '../../types/tezos/TezosChainTypes'; | ||
import { SignerCurve } from "../../types/ExternalInterfaces"; | ||
export declare namespace TezosMessageUtils { | ||
@@ -26,4 +27,4 @@ function writeBoolean(value: boolean): string; | ||
function writeKeyWithHint(key: string, hint: string): Buffer; | ||
function readSignatureWithHint(b: Buffer | Uint8Array, hint: string): string; | ||
function writeSignatureWithHint(sig: string, hint: string): Buffer; | ||
function readSignatureWithHint(b: Buffer | Uint8Array, hint: string | SignerCurve): string; | ||
function writeSignatureWithHint(sig: string, hint: string | SignerCurve): Buffer; | ||
function readBufferWithHint(b: Buffer | Uint8Array, hint: string): string; | ||
@@ -30,0 +31,0 @@ function writeBufferWithHint(b: string): Buffer; |
@@ -18,2 +18,3 @@ "use strict"; | ||
const TezosChainTypes_1 = require("../../types/tezos/TezosChainTypes"); | ||
const ExternalInterfaces_1 = require("../../types/ExternalInterfaces"); | ||
var TezosMessageUtils; | ||
@@ -254,5 +255,11 @@ (function (TezosMessageUtils) { | ||
const sig = !(b instanceof Buffer) ? Buffer.from(b) : b; | ||
if (hint === 'edsig') { | ||
if (hint === 'edsig' || hint === ExternalInterfaces_1.SignerCurve.ED25519) { | ||
return bs58check_1.default.encode(Buffer.from('09f5cd8612' + sig.toString('hex'), 'hex')); | ||
} | ||
else if (hint === 'spsig' || hint === ExternalInterfaces_1.SignerCurve.SECP256K1) { | ||
return bs58check_1.default.encode(Buffer.from('0d7365133f' + sig.toString('hex'), 'hex')); | ||
} | ||
else if (hint === 'p2sig' || hint === ExternalInterfaces_1.SignerCurve.SECP256R1) { | ||
return bs58check_1.default.encode(Buffer.from('36f02c34' + sig.toString('hex'), 'hex')); | ||
} | ||
else { | ||
@@ -264,5 +271,11 @@ throw new Error(`Unrecognized signature hint, '${hint}'`); | ||
function writeSignatureWithHint(sig, hint) { | ||
if (hint === 'edsig') { | ||
return bs58check_1.default.decode(sig).slice(5); | ||
if (hint === 'edsig' || hint === ExternalInterfaces_1.SignerCurve.ED25519) { | ||
return bs58check_1.default.decode(sig).slice("edsig".length); | ||
} | ||
else if (hint === 'spsig' || hint === ExternalInterfaces_1.SignerCurve.SECP256K1) { | ||
return bs58check_1.default.decode(sig).slice("spsig".length); | ||
} | ||
else if (hint === 'p2sig' || hint === ExternalInterfaces_1.SignerCurve.SECP256R1) { | ||
return bs58check_1.default.decode(sig).slice("p2sig".length); | ||
} | ||
else { | ||
@@ -269,0 +282,0 @@ throw new Error(`Unrecognized key hint, '${hint}'`); |
@@ -132,4 +132,4 @@ "use strict"; | ||
const signedOpGroup = Buffer.concat([Buffer.from(forgedOperationGroup, 'hex'), opSignature]); | ||
const hexSignature = TezosMessageUtil_1.TezosMessageUtils.readSignatureWithHint(opSignature, 'edsig'); | ||
const opPair = { bytes: signedOpGroup, signature: hexSignature }; | ||
const base58signature = TezosMessageUtil_1.TezosMessageUtils.readSignatureWithHint(opSignature, signer.getSignerCurve()); | ||
const opPair = { bytes: signedOpGroup, signature: base58signature }; | ||
const appliedOp = yield preapplyOperation(server, blockHead.hash, blockHead.protocol, operations, opPair); | ||
@@ -136,0 +136,0 @@ const injectedOperation = yield injectOperation(server, opPair); |
/// <reference types="node" /> | ||
export declare enum SignerCurve { | ||
ED25519 = 0, | ||
SECP256K1 = 1, | ||
SECP256R1 = 2 | ||
} | ||
export interface Signer { | ||
getSignerCurve: () => SignerCurve; | ||
signOperation: (bytes: Buffer) => Promise<Buffer>; | ||
@@ -4,0 +10,0 @@ signText: (message: string) => Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SignerCurve; | ||
(function (SignerCurve) { | ||
SignerCurve[SignerCurve["ED25519"] = 0] = "ED25519"; | ||
SignerCurve[SignerCurve["SECP256K1"] = 1] = "SECP256K1"; | ||
SignerCurve[SignerCurve["SECP256R1"] = 2] = "SECP256R1"; | ||
})(SignerCurve = exports.SignerCurve || (exports.SignerCurve = {})); | ||
var KeyStoreType; | ||
@@ -4,0 +10,0 @@ (function (KeyStoreType) { |
{ | ||
"name": "conseiljs", | ||
"version": "5.0.3-beta.1", | ||
"version": "5.0.3-beta.2", | ||
"description": "Client-side library for dApp development.", | ||
@@ -5,0 +5,0 @@ "browser": "dist/index-web.js", |
@@ -59,3 +59,3 @@ # ConseilJS-core | ||
<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs/dist-web/conseiljs.min.js" | ||
integrity="sha384-D5Exnkq8hYVfQqoWvZOQsohtT45+lj0YGbHmwdeJPeqCcM0zxXjmCRRsaf+Ch2eg" | ||
integrity="sha384-mllZxQ+Ere67uVRYEjvM4xgiXKfiLzzpLdGD2J4N24fNWpQBVRt17Wvf324/5E0K" | ||
crossorigin="anonymous"></script> | ||
@@ -62,0 +62,0 @@ ``` |
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
690654
6646