@taquito/local-forging
Advanced tools
Comparing version 6.0.2-beta.0 to 6.0.3-beta.0
@@ -8,2 +8,31 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var CODEC; | ||
(function (CODEC) { | ||
CODEC["SECRET"] = "secret"; | ||
CODEC["RAW"] = "raw"; | ||
CODEC["TZ1"] = "tz1"; | ||
CODEC["BRANCH"] = "branch"; | ||
CODEC["ZARITH"] = "zarith"; | ||
CODEC["PUBLIC_KEY"] = "public_key"; | ||
CODEC["PKH"] = "pkh"; | ||
CODEC["DELEGATE"] = "delegate"; | ||
CODEC["SCRIPT"] = "script"; | ||
CODEC["BALLOT_STATEMENT"] = "ballotStmt"; | ||
CODEC["PROPOSAL"] = "proposal"; | ||
CODEC["PROPOSAL_ARR"] = "proposalArr"; | ||
CODEC["INT32"] = "int32"; | ||
CODEC["PARAMETERS"] = "parameters"; | ||
CODEC["ADDRESS"] = "address"; | ||
CODEC["OPERATION"] = "operation"; | ||
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account"; | ||
CODEC["OP_DELEGATION"] = "delegation"; | ||
CODEC["OP_TRANSACTION"] = "transaction"; | ||
CODEC["OP_ORIGINATION"] = "origination"; | ||
CODEC["OP_BALLOT"] = "ballot"; | ||
CODEC["OP_ENDORSEMENT"] = "endorsement"; | ||
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation"; | ||
CODEC["OP_REVEAL"] = "reveal"; | ||
CODEC["OP_PROPOSALS"] = "proposals"; | ||
CODEC["MANAGER"] = "manager"; | ||
})(CODEC = exports.CODEC || (exports.CODEC = {})); | ||
// See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar | ||
@@ -10,0 +39,0 @@ exports.opMapping = { |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var codec_1 = require("./codec"); | ||
var constants_1 = require("./constants"); | ||
var codec_2 = require("./michelson/codec"); | ||
var operation_1 = require("./schema/operation"); | ||
var utils_1 = require("./utils"); | ||
exports.decoders = { | ||
secret: function (val) { return utils_1.toHexString(val.consume(20)); }, | ||
raw: function (val) { return utils_1.toHexString(val.consume(32)); }, | ||
tz1: codec_1.tz1Decoder, | ||
branch: codec_1.branchDecoder, | ||
zarith: codec_1.zarithDecoder, | ||
public_key: codec_1.publicKeyDecoder, | ||
pkh: codec_1.pkhDecoder, | ||
delegate: codec_1.delegateDecoder, | ||
int32: codec_1.int32Decoder, | ||
script: codec_2.scriptDecoder, | ||
ballotStmt: codec_1.ballotDecoder, | ||
proposal: codec_1.proposalDecoder, | ||
proposalArr: codec_1.proposalsDecoder, | ||
parameters: codec_1.parametersDecoder, | ||
address: codec_1.addressDecoder, | ||
}; | ||
exports.decoders['operation'] = operation_1.operationDecoder(exports.decoders); | ||
exports.decoders['activate_account'] = function (val) { | ||
exports.decoders = (_a = {}, | ||
_a[constants_1.CODEC.SECRET] = function (val) { return utils_1.toHexString(val.consume(20)); }, | ||
_a[constants_1.CODEC.RAW] = function (val) { return utils_1.toHexString(val.consume(32)); }, | ||
_a[constants_1.CODEC.TZ1] = codec_1.tz1Decoder, | ||
_a[constants_1.CODEC.BRANCH] = codec_1.branchDecoder, | ||
_a[constants_1.CODEC.ZARITH] = codec_1.zarithDecoder, | ||
_a[constants_1.CODEC.PUBLIC_KEY] = codec_1.publicKeyDecoder, | ||
_a[constants_1.CODEC.PKH] = codec_1.pkhDecoder, | ||
_a[constants_1.CODEC.DELEGATE] = codec_1.delegateDecoder, | ||
_a[constants_1.CODEC.INT32] = codec_1.int32Decoder, | ||
_a[constants_1.CODEC.SCRIPT] = codec_2.scriptDecoder, | ||
_a[constants_1.CODEC.BALLOT_STATEMENT] = codec_1.ballotDecoder, | ||
_a[constants_1.CODEC.PROPOSAL] = codec_1.proposalDecoder, | ||
_a[constants_1.CODEC.PROPOSAL_ARR] = codec_1.proposalsDecoder, | ||
_a[constants_1.CODEC.PARAMETERS] = codec_1.parametersDecoder, | ||
_a[constants_1.CODEC.ADDRESS] = codec_1.addressDecoder, | ||
_a); | ||
exports.decoders[constants_1.CODEC.OPERATION] = operation_1.operationDecoder(exports.decoders); | ||
exports.decoders[constants_1.CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.ActivationSchema)(val); | ||
}; | ||
exports.decoders['delegation'] = function (val) { | ||
exports.decoders[constants_1.CODEC.OP_DELEGATION] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.DelegationSchema)(val); | ||
}; | ||
exports.decoders['transaction'] = function (val) { | ||
exports.decoders[constants_1.CODEC.OP_TRANSACTION] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.TransactionSchema)(val); | ||
}; | ||
exports.decoders['origination'] = function (val) { | ||
exports.decoders[constants_1.CODEC.OP_ORIGINATION] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.OriginationSchema)(val); | ||
}; | ||
exports.decoders['ballot'] = function (val) { return operation_1.schemaDecoder(exports.decoders)(operation_1.BallotSchema)(val); }; | ||
exports.decoders['endorsement'] = function (val) { | ||
exports.decoders[constants_1.CODEC.OP_BALLOT] = function (val) { return operation_1.schemaDecoder(exports.decoders)(operation_1.BallotSchema)(val); }; | ||
exports.decoders[constants_1.CODEC.OP_ENDORSEMENT] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.EndorsementSchema)(val); | ||
}; | ||
exports.decoders['seed_nonce_revelation'] = function (val) { | ||
exports.decoders[constants_1.CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.SeedNonceRevelationSchema)(val); | ||
}; | ||
exports.decoders['proposals'] = function (val) { return operation_1.schemaDecoder(exports.decoders)(operation_1.ProposalsSchema)(val); }; | ||
exports.decoders['reveal'] = function (val) { return operation_1.schemaDecoder(exports.decoders)(operation_1.RevealSchema)(val); }; | ||
exports.decoders['manager'] = operation_1.schemaDecoder(exports.decoders)(operation_1.ManagerOperationSchema); | ||
exports.decoders[constants_1.CODEC.OP_PROPOSALS] = function (val) { | ||
return operation_1.schemaDecoder(exports.decoders)(operation_1.ProposalsSchema)(val); | ||
}; | ||
exports.decoders[constants_1.CODEC.OP_REVEAL] = function (val) { return operation_1.schemaDecoder(exports.decoders)(operation_1.RevealSchema)(val); }; | ||
exports.decoders[constants_1.CODEC.MANAGER] = operation_1.schemaDecoder(exports.decoders)(operation_1.ManagerOperationSchema); | ||
//# sourceMappingURL=decoder.js.map |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var codec_1 = require("./codec"); | ||
var constants_1 = require("./constants"); | ||
var codec_2 = require("./michelson/codec"); | ||
var operation_1 = require("./schema/operation"); | ||
exports.encoders = { | ||
secret: function (val) { return val; }, | ||
raw: function (val) { return val; }, | ||
tz1: codec_1.tz1Encoder, | ||
branch: codec_1.branchEncoder, | ||
zarith: codec_1.zarithEncoder, | ||
public_key: codec_1.publicKeyEncoder, | ||
pkh: codec_1.pkhEncoder, | ||
delegate: codec_1.delegateEncoder, | ||
script: codec_2.scriptEncoder, | ||
ballotStmt: codec_1.ballotEncoder, | ||
proposal: codec_1.proposalEncoder, | ||
proposalArr: codec_1.proposalsEncoder, | ||
int32: codec_1.int32Encoder, | ||
parameters: codec_1.parametersEncoder, | ||
address: codec_1.addressEncoder, | ||
}; | ||
exports.encoders['operation'] = operation_1.operationEncoder(exports.encoders); | ||
exports.encoders['activate_account'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.ActivationSchema)(val); }; | ||
exports.encoders['delegation'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.DelegationSchema)(val); }; | ||
exports.encoders['transaction'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.TransactionSchema)(val); }; | ||
exports.encoders['origination'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.OriginationSchema)(val); }; | ||
exports.encoders['ballot'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.BallotSchema)(val); }; | ||
exports.encoders['endorsement'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.EndorsementSchema)(val); }; | ||
exports.encoders['seed_nonce_revelation'] = function (val) { | ||
exports.encoders = (_a = {}, | ||
_a[constants_1.CODEC.SECRET] = function (val) { return val; }, | ||
_a[constants_1.CODEC.RAW] = function (val) { return val; }, | ||
_a[constants_1.CODEC.TZ1] = codec_1.tz1Encoder, | ||
_a[constants_1.CODEC.BRANCH] = codec_1.branchEncoder, | ||
_a[constants_1.CODEC.ZARITH] = codec_1.zarithEncoder, | ||
_a[constants_1.CODEC.PUBLIC_KEY] = codec_1.publicKeyEncoder, | ||
_a[constants_1.CODEC.PKH] = codec_1.pkhEncoder, | ||
_a[constants_1.CODEC.DELEGATE] = codec_1.delegateEncoder, | ||
_a[constants_1.CODEC.SCRIPT] = codec_2.scriptEncoder, | ||
_a[constants_1.CODEC.BALLOT_STATEMENT] = codec_1.ballotEncoder, | ||
_a[constants_1.CODEC.PROPOSAL] = codec_1.proposalEncoder, | ||
_a[constants_1.CODEC.PROPOSAL_ARR] = codec_1.proposalsEncoder, | ||
_a[constants_1.CODEC.INT32] = codec_1.int32Encoder, | ||
_a[constants_1.CODEC.PARAMETERS] = codec_1.parametersEncoder, | ||
_a[constants_1.CODEC.ADDRESS] = codec_1.addressEncoder, | ||
_a); | ||
exports.encoders[constants_1.CODEC.OPERATION] = operation_1.operationEncoder(exports.encoders); | ||
exports.encoders[constants_1.CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.ActivationSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_DELEGATION] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.DelegationSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_TRANSACTION] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.TransactionSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_ORIGINATION] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.OriginationSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_BALLOT] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.BallotSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_ENDORSEMENT] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.EndorsementSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return operation_1.schemaEncoder(exports.encoders)(operation_1.SeedNonceRevelationSchema)(val); | ||
}; | ||
exports.encoders['proposals'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.ProposalsSchema)(val); }; | ||
exports.encoders['reveal'] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.RevealSchema)(val); }; | ||
exports.encoders['manager'] = operation_1.schemaEncoder(exports.encoders)(operation_1.ManagerOperationSchema); | ||
exports.encoders[constants_1.CODEC.OP_PROPOSALS] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.ProposalsSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.OP_REVEAL] = function (val) { return operation_1.schemaEncoder(exports.encoders)(operation_1.RevealSchema)(val); }; | ||
exports.encoders[constants_1.CODEC.MANAGER] = operation_1.schemaEncoder(exports.encoders)(operation_1.ManagerOperationSchema); | ||
//# sourceMappingURL=encoder.js.map |
@@ -6,11 +6,31 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var constants_1 = require("./constants"); | ||
var decoder_1 = require("./decoder"); | ||
var encoder_1 = require("./encoder"); | ||
var uint8array_consumer_1 = require("./uint8array-consumer"); | ||
var constants_2 = require("./constants"); | ||
exports.CODEC = constants_2.CODEC; | ||
__export(require("./decoder")); | ||
__export(require("./encoder")); | ||
__export(require("./uint8array-consumer")); | ||
function getCodec(codec) { | ||
return { | ||
encoder: encoder_1.encoders[codec], | ||
decoder: function (hex) { | ||
var consumer = uint8array_consumer_1.Uint8ArrayConsumer.fromHexString(hex); | ||
return decoder_1.decoders[codec](consumer); | ||
}, | ||
}; | ||
} | ||
exports.getCodec = getCodec; | ||
var LocalForger = /** @class */ (function () { | ||
function LocalForger() { | ||
this.codec = getCodec(constants_1.CODEC.MANAGER); | ||
} | ||
LocalForger.prototype.forge = function (params) { | ||
return Promise.resolve(encoder_1.encoders['manager'](params)); | ||
return Promise.resolve(this.codec.encoder(params)); | ||
}; | ||
LocalForger.prototype.parse = function (hex) { | ||
return Promise.resolve(this.codec.decoder(hex)); | ||
}; | ||
return LocalForger; | ||
@@ -17,0 +37,0 @@ }()); |
@@ -9,2 +9,12 @@ "use strict"; | ||
} | ||
Uint8ArrayConsumer.fromHexString = function (hex) { | ||
var lowHex = hex.toLowerCase(); | ||
if (/^(([a-f]|\d){2})*$/.test(lowHex)) { | ||
var arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map(function (byte) { return parseInt(byte, 16); })); | ||
return new Uint8ArrayConsumer(arr); | ||
} | ||
else { | ||
throw new Error('Invalid hex string'); | ||
} | ||
}; | ||
Uint8ArrayConsumer.prototype.consume = function (count) { | ||
@@ -11,0 +21,0 @@ var subArr = this.arr.subarray(this.offset, this.offset + count); |
@@ -16,2 +16,31 @@ import { Prefix, prefixLength, b58cencode, prefix, buf2hex, b58cdecode } from '@taquito/utils'; | ||
*/ | ||
var CODEC; | ||
(function (CODEC) { | ||
CODEC["SECRET"] = "secret"; | ||
CODEC["RAW"] = "raw"; | ||
CODEC["TZ1"] = "tz1"; | ||
CODEC["BRANCH"] = "branch"; | ||
CODEC["ZARITH"] = "zarith"; | ||
CODEC["PUBLIC_KEY"] = "public_key"; | ||
CODEC["PKH"] = "pkh"; | ||
CODEC["DELEGATE"] = "delegate"; | ||
CODEC["SCRIPT"] = "script"; | ||
CODEC["BALLOT_STATEMENT"] = "ballotStmt"; | ||
CODEC["PROPOSAL"] = "proposal"; | ||
CODEC["PROPOSAL_ARR"] = "proposalArr"; | ||
CODEC["INT32"] = "int32"; | ||
CODEC["PARAMETERS"] = "parameters"; | ||
CODEC["ADDRESS"] = "address"; | ||
CODEC["OPERATION"] = "operation"; | ||
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account"; | ||
CODEC["OP_DELEGATION"] = "delegation"; | ||
CODEC["OP_TRANSACTION"] = "transaction"; | ||
CODEC["OP_ORIGINATION"] = "origination"; | ||
CODEC["OP_BALLOT"] = "ballot"; | ||
CODEC["OP_ENDORSEMENT"] = "endorsement"; | ||
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation"; | ||
CODEC["OP_REVEAL"] = "reveal"; | ||
CODEC["OP_PROPOSALS"] = "proposals"; | ||
CODEC["MANAGER"] = "manager"; | ||
})(CODEC || (CODEC = {})); | ||
// See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar | ||
@@ -187,2 +216,12 @@ var opMapping = { | ||
} | ||
Uint8ArrayConsumer.fromHexString = function (hex) { | ||
var lowHex = hex.toLowerCase(); | ||
if (/^(([a-f]|\d){2})*$/.test(lowHex)) { | ||
var arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map(function (byte) { return parseInt(byte, 16); })); | ||
return new Uint8ArrayConsumer(arr); | ||
} | ||
else { | ||
throw new Error('Invalid hex string'); | ||
} | ||
}; | ||
Uint8ArrayConsumer.prototype.consume = function (count) { | ||
@@ -808,80 +847,97 @@ var subArr = this.arr.subarray(this.offset, this.offset + count); | ||
var encoders = { | ||
secret: function (val) { return val; }, | ||
raw: function (val) { return val; }, | ||
tz1: tz1Encoder, | ||
branch: branchEncoder, | ||
zarith: zarithEncoder, | ||
public_key: publicKeyEncoder, | ||
pkh: pkhEncoder, | ||
delegate: delegateEncoder, | ||
script: scriptEncoder, | ||
ballotStmt: ballotEncoder, | ||
proposal: proposalEncoder, | ||
proposalArr: proposalsEncoder, | ||
int32: int32Encoder, | ||
parameters: parametersEncoder, | ||
address: addressEncoder, | ||
}; | ||
encoders['operation'] = operationEncoder(encoders); | ||
encoders['activate_account'] = function (val) { return schemaEncoder(encoders)(ActivationSchema)(val); }; | ||
encoders['delegation'] = function (val) { return schemaEncoder(encoders)(DelegationSchema)(val); }; | ||
encoders['transaction'] = function (val) { return schemaEncoder(encoders)(TransactionSchema)(val); }; | ||
encoders['origination'] = function (val) { return schemaEncoder(encoders)(OriginationSchema)(val); }; | ||
encoders['ballot'] = function (val) { return schemaEncoder(encoders)(BallotSchema)(val); }; | ||
encoders['endorsement'] = function (val) { return schemaEncoder(encoders)(EndorsementSchema)(val); }; | ||
encoders['seed_nonce_revelation'] = function (val) { | ||
return schemaEncoder(encoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
encoders['proposals'] = function (val) { return schemaEncoder(encoders)(ProposalsSchema)(val); }; | ||
encoders['reveal'] = function (val) { return schemaEncoder(encoders)(RevealSchema)(val); }; | ||
encoders['manager'] = schemaEncoder(encoders)(ManagerOperationSchema); | ||
var decoders = { | ||
secret: function (val) { return toHexString(val.consume(20)); }, | ||
raw: function (val) { return toHexString(val.consume(32)); }, | ||
tz1: tz1Decoder, | ||
branch: branchDecoder, | ||
zarith: zarithDecoder, | ||
public_key: publicKeyDecoder, | ||
pkh: pkhDecoder, | ||
delegate: delegateDecoder, | ||
int32: int32Decoder, | ||
script: scriptDecoder, | ||
ballotStmt: ballotDecoder, | ||
proposal: proposalDecoder, | ||
proposalArr: proposalsDecoder, | ||
parameters: parametersDecoder, | ||
address: addressDecoder, | ||
}; | ||
decoders['operation'] = operationDecoder(decoders); | ||
decoders['activate_account'] = function (val) { | ||
var _a; | ||
var decoders = (_a = {}, | ||
_a[CODEC.SECRET] = function (val) { return toHexString(val.consume(20)); }, | ||
_a[CODEC.RAW] = function (val) { return toHexString(val.consume(32)); }, | ||
_a[CODEC.TZ1] = tz1Decoder, | ||
_a[CODEC.BRANCH] = branchDecoder, | ||
_a[CODEC.ZARITH] = zarithDecoder, | ||
_a[CODEC.PUBLIC_KEY] = publicKeyDecoder, | ||
_a[CODEC.PKH] = pkhDecoder, | ||
_a[CODEC.DELEGATE] = delegateDecoder, | ||
_a[CODEC.INT32] = int32Decoder, | ||
_a[CODEC.SCRIPT] = scriptDecoder, | ||
_a[CODEC.BALLOT_STATEMENT] = ballotDecoder, | ||
_a[CODEC.PROPOSAL] = proposalDecoder, | ||
_a[CODEC.PROPOSAL_ARR] = proposalsDecoder, | ||
_a[CODEC.PARAMETERS] = parametersDecoder, | ||
_a[CODEC.ADDRESS] = addressDecoder, | ||
_a); | ||
decoders[CODEC.OPERATION] = operationDecoder(decoders); | ||
decoders[CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { | ||
return schemaDecoder(decoders)(ActivationSchema)(val); | ||
}; | ||
decoders['delegation'] = function (val) { | ||
decoders[CODEC.OP_DELEGATION] = function (val) { | ||
return schemaDecoder(decoders)(DelegationSchema)(val); | ||
}; | ||
decoders['transaction'] = function (val) { | ||
decoders[CODEC.OP_TRANSACTION] = function (val) { | ||
return schemaDecoder(decoders)(TransactionSchema)(val); | ||
}; | ||
decoders['origination'] = function (val) { | ||
decoders[CODEC.OP_ORIGINATION] = function (val) { | ||
return schemaDecoder(decoders)(OriginationSchema)(val); | ||
}; | ||
decoders['ballot'] = function (val) { return schemaDecoder(decoders)(BallotSchema)(val); }; | ||
decoders['endorsement'] = function (val) { | ||
decoders[CODEC.OP_BALLOT] = function (val) { return schemaDecoder(decoders)(BallotSchema)(val); }; | ||
decoders[CODEC.OP_ENDORSEMENT] = function (val) { | ||
return schemaDecoder(decoders)(EndorsementSchema)(val); | ||
}; | ||
decoders['seed_nonce_revelation'] = function (val) { | ||
decoders[CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return schemaDecoder(decoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
decoders['proposals'] = function (val) { return schemaDecoder(decoders)(ProposalsSchema)(val); }; | ||
decoders['reveal'] = function (val) { return schemaDecoder(decoders)(RevealSchema)(val); }; | ||
decoders['manager'] = schemaDecoder(decoders)(ManagerOperationSchema); | ||
decoders[CODEC.OP_PROPOSALS] = function (val) { | ||
return schemaDecoder(decoders)(ProposalsSchema)(val); | ||
}; | ||
decoders[CODEC.OP_REVEAL] = function (val) { return schemaDecoder(decoders)(RevealSchema)(val); }; | ||
decoders[CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema); | ||
var _a$1; | ||
var encoders = (_a$1 = {}, | ||
_a$1[CODEC.SECRET] = function (val) { return val; }, | ||
_a$1[CODEC.RAW] = function (val) { return val; }, | ||
_a$1[CODEC.TZ1] = tz1Encoder, | ||
_a$1[CODEC.BRANCH] = branchEncoder, | ||
_a$1[CODEC.ZARITH] = zarithEncoder, | ||
_a$1[CODEC.PUBLIC_KEY] = publicKeyEncoder, | ||
_a$1[CODEC.PKH] = pkhEncoder, | ||
_a$1[CODEC.DELEGATE] = delegateEncoder, | ||
_a$1[CODEC.SCRIPT] = scriptEncoder, | ||
_a$1[CODEC.BALLOT_STATEMENT] = ballotEncoder, | ||
_a$1[CODEC.PROPOSAL] = proposalEncoder, | ||
_a$1[CODEC.PROPOSAL_ARR] = proposalsEncoder, | ||
_a$1[CODEC.INT32] = int32Encoder, | ||
_a$1[CODEC.PARAMETERS] = parametersEncoder, | ||
_a$1[CODEC.ADDRESS] = addressEncoder, | ||
_a$1); | ||
encoders[CODEC.OPERATION] = operationEncoder(encoders); | ||
encoders[CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { return schemaEncoder(encoders)(ActivationSchema)(val); }; | ||
encoders[CODEC.OP_DELEGATION] = function (val) { return schemaEncoder(encoders)(DelegationSchema)(val); }; | ||
encoders[CODEC.OP_TRANSACTION] = function (val) { return schemaEncoder(encoders)(TransactionSchema)(val); }; | ||
encoders[CODEC.OP_ORIGINATION] = function (val) { return schemaEncoder(encoders)(OriginationSchema)(val); }; | ||
encoders[CODEC.OP_BALLOT] = function (val) { return schemaEncoder(encoders)(BallotSchema)(val); }; | ||
encoders[CODEC.OP_ENDORSEMENT] = function (val) { return schemaEncoder(encoders)(EndorsementSchema)(val); }; | ||
encoders[CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return schemaEncoder(encoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
encoders[CODEC.OP_PROPOSALS] = function (val) { return schemaEncoder(encoders)(ProposalsSchema)(val); }; | ||
encoders[CODEC.OP_REVEAL] = function (val) { return schemaEncoder(encoders)(RevealSchema)(val); }; | ||
encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema); | ||
function getCodec(codec) { | ||
return { | ||
encoder: encoders[codec], | ||
decoder: function (hex) { | ||
var consumer = Uint8ArrayConsumer.fromHexString(hex); | ||
return decoders[codec](consumer); | ||
}, | ||
}; | ||
} | ||
var LocalForger = /** @class */ (function () { | ||
function LocalForger() { | ||
this.codec = getCodec(CODEC.MANAGER); | ||
} | ||
LocalForger.prototype.forge = function (params) { | ||
return Promise.resolve(encoders['manager'](params)); | ||
return Promise.resolve(this.codec.encoder(params)); | ||
}; | ||
LocalForger.prototype.parse = function (hex) { | ||
return Promise.resolve(this.codec.decoder(hex)); | ||
}; | ||
return LocalForger; | ||
@@ -891,3 +947,3 @@ }()); | ||
export { LocalForger, decoders, encoders, localForger }; | ||
export { CODEC, LocalForger, Uint8ArrayConsumer, decoders, encoders, getCodec, localForger }; | ||
//# sourceMappingURL=taquito-local-forging.es5.js.map |
@@ -21,2 +21,30 @@ (function (global, factory) { | ||
*/ | ||
(function (CODEC) { | ||
CODEC["SECRET"] = "secret"; | ||
CODEC["RAW"] = "raw"; | ||
CODEC["TZ1"] = "tz1"; | ||
CODEC["BRANCH"] = "branch"; | ||
CODEC["ZARITH"] = "zarith"; | ||
CODEC["PUBLIC_KEY"] = "public_key"; | ||
CODEC["PKH"] = "pkh"; | ||
CODEC["DELEGATE"] = "delegate"; | ||
CODEC["SCRIPT"] = "script"; | ||
CODEC["BALLOT_STATEMENT"] = "ballotStmt"; | ||
CODEC["PROPOSAL"] = "proposal"; | ||
CODEC["PROPOSAL_ARR"] = "proposalArr"; | ||
CODEC["INT32"] = "int32"; | ||
CODEC["PARAMETERS"] = "parameters"; | ||
CODEC["ADDRESS"] = "address"; | ||
CODEC["OPERATION"] = "operation"; | ||
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account"; | ||
CODEC["OP_DELEGATION"] = "delegation"; | ||
CODEC["OP_TRANSACTION"] = "transaction"; | ||
CODEC["OP_ORIGINATION"] = "origination"; | ||
CODEC["OP_BALLOT"] = "ballot"; | ||
CODEC["OP_ENDORSEMENT"] = "endorsement"; | ||
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation"; | ||
CODEC["OP_REVEAL"] = "reveal"; | ||
CODEC["OP_PROPOSALS"] = "proposals"; | ||
CODEC["MANAGER"] = "manager"; | ||
})(exports.CODEC || (exports.CODEC = {})); | ||
// See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar | ||
@@ -192,2 +220,12 @@ var opMapping = { | ||
} | ||
Uint8ArrayConsumer.fromHexString = function (hex) { | ||
var lowHex = hex.toLowerCase(); | ||
if (/^(([a-f]|\d){2})*$/.test(lowHex)) { | ||
var arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map(function (byte) { return parseInt(byte, 16); })); | ||
return new Uint8ArrayConsumer(arr); | ||
} | ||
else { | ||
throw new Error('Invalid hex string'); | ||
} | ||
}; | ||
Uint8ArrayConsumer.prototype.consume = function (count) { | ||
@@ -813,80 +851,97 @@ var subArr = this.arr.subarray(this.offset, this.offset + count); | ||
var encoders = { | ||
secret: function (val) { return val; }, | ||
raw: function (val) { return val; }, | ||
tz1: tz1Encoder, | ||
branch: branchEncoder, | ||
zarith: zarithEncoder, | ||
public_key: publicKeyEncoder, | ||
pkh: pkhEncoder, | ||
delegate: delegateEncoder, | ||
script: scriptEncoder, | ||
ballotStmt: ballotEncoder, | ||
proposal: proposalEncoder, | ||
proposalArr: proposalsEncoder, | ||
int32: int32Encoder, | ||
parameters: parametersEncoder, | ||
address: addressEncoder, | ||
}; | ||
encoders['operation'] = operationEncoder(encoders); | ||
encoders['activate_account'] = function (val) { return schemaEncoder(encoders)(ActivationSchema)(val); }; | ||
encoders['delegation'] = function (val) { return schemaEncoder(encoders)(DelegationSchema)(val); }; | ||
encoders['transaction'] = function (val) { return schemaEncoder(encoders)(TransactionSchema)(val); }; | ||
encoders['origination'] = function (val) { return schemaEncoder(encoders)(OriginationSchema)(val); }; | ||
encoders['ballot'] = function (val) { return schemaEncoder(encoders)(BallotSchema)(val); }; | ||
encoders['endorsement'] = function (val) { return schemaEncoder(encoders)(EndorsementSchema)(val); }; | ||
encoders['seed_nonce_revelation'] = function (val) { | ||
return schemaEncoder(encoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
encoders['proposals'] = function (val) { return schemaEncoder(encoders)(ProposalsSchema)(val); }; | ||
encoders['reveal'] = function (val) { return schemaEncoder(encoders)(RevealSchema)(val); }; | ||
encoders['manager'] = schemaEncoder(encoders)(ManagerOperationSchema); | ||
var decoders = { | ||
secret: function (val) { return toHexString(val.consume(20)); }, | ||
raw: function (val) { return toHexString(val.consume(32)); }, | ||
tz1: tz1Decoder, | ||
branch: branchDecoder, | ||
zarith: zarithDecoder, | ||
public_key: publicKeyDecoder, | ||
pkh: pkhDecoder, | ||
delegate: delegateDecoder, | ||
int32: int32Decoder, | ||
script: scriptDecoder, | ||
ballotStmt: ballotDecoder, | ||
proposal: proposalDecoder, | ||
proposalArr: proposalsDecoder, | ||
parameters: parametersDecoder, | ||
address: addressDecoder, | ||
}; | ||
decoders['operation'] = operationDecoder(decoders); | ||
decoders['activate_account'] = function (val) { | ||
var _a; | ||
var decoders = (_a = {}, | ||
_a[exports.CODEC.SECRET] = function (val) { return toHexString(val.consume(20)); }, | ||
_a[exports.CODEC.RAW] = function (val) { return toHexString(val.consume(32)); }, | ||
_a[exports.CODEC.TZ1] = tz1Decoder, | ||
_a[exports.CODEC.BRANCH] = branchDecoder, | ||
_a[exports.CODEC.ZARITH] = zarithDecoder, | ||
_a[exports.CODEC.PUBLIC_KEY] = publicKeyDecoder, | ||
_a[exports.CODEC.PKH] = pkhDecoder, | ||
_a[exports.CODEC.DELEGATE] = delegateDecoder, | ||
_a[exports.CODEC.INT32] = int32Decoder, | ||
_a[exports.CODEC.SCRIPT] = scriptDecoder, | ||
_a[exports.CODEC.BALLOT_STATEMENT] = ballotDecoder, | ||
_a[exports.CODEC.PROPOSAL] = proposalDecoder, | ||
_a[exports.CODEC.PROPOSAL_ARR] = proposalsDecoder, | ||
_a[exports.CODEC.PARAMETERS] = parametersDecoder, | ||
_a[exports.CODEC.ADDRESS] = addressDecoder, | ||
_a); | ||
decoders[exports.CODEC.OPERATION] = operationDecoder(decoders); | ||
decoders[exports.CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { | ||
return schemaDecoder(decoders)(ActivationSchema)(val); | ||
}; | ||
decoders['delegation'] = function (val) { | ||
decoders[exports.CODEC.OP_DELEGATION] = function (val) { | ||
return schemaDecoder(decoders)(DelegationSchema)(val); | ||
}; | ||
decoders['transaction'] = function (val) { | ||
decoders[exports.CODEC.OP_TRANSACTION] = function (val) { | ||
return schemaDecoder(decoders)(TransactionSchema)(val); | ||
}; | ||
decoders['origination'] = function (val) { | ||
decoders[exports.CODEC.OP_ORIGINATION] = function (val) { | ||
return schemaDecoder(decoders)(OriginationSchema)(val); | ||
}; | ||
decoders['ballot'] = function (val) { return schemaDecoder(decoders)(BallotSchema)(val); }; | ||
decoders['endorsement'] = function (val) { | ||
decoders[exports.CODEC.OP_BALLOT] = function (val) { return schemaDecoder(decoders)(BallotSchema)(val); }; | ||
decoders[exports.CODEC.OP_ENDORSEMENT] = function (val) { | ||
return schemaDecoder(decoders)(EndorsementSchema)(val); | ||
}; | ||
decoders['seed_nonce_revelation'] = function (val) { | ||
decoders[exports.CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return schemaDecoder(decoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
decoders['proposals'] = function (val) { return schemaDecoder(decoders)(ProposalsSchema)(val); }; | ||
decoders['reveal'] = function (val) { return schemaDecoder(decoders)(RevealSchema)(val); }; | ||
decoders['manager'] = schemaDecoder(decoders)(ManagerOperationSchema); | ||
decoders[exports.CODEC.OP_PROPOSALS] = function (val) { | ||
return schemaDecoder(decoders)(ProposalsSchema)(val); | ||
}; | ||
decoders[exports.CODEC.OP_REVEAL] = function (val) { return schemaDecoder(decoders)(RevealSchema)(val); }; | ||
decoders[exports.CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema); | ||
var _a$1; | ||
var encoders = (_a$1 = {}, | ||
_a$1[exports.CODEC.SECRET] = function (val) { return val; }, | ||
_a$1[exports.CODEC.RAW] = function (val) { return val; }, | ||
_a$1[exports.CODEC.TZ1] = tz1Encoder, | ||
_a$1[exports.CODEC.BRANCH] = branchEncoder, | ||
_a$1[exports.CODEC.ZARITH] = zarithEncoder, | ||
_a$1[exports.CODEC.PUBLIC_KEY] = publicKeyEncoder, | ||
_a$1[exports.CODEC.PKH] = pkhEncoder, | ||
_a$1[exports.CODEC.DELEGATE] = delegateEncoder, | ||
_a$1[exports.CODEC.SCRIPT] = scriptEncoder, | ||
_a$1[exports.CODEC.BALLOT_STATEMENT] = ballotEncoder, | ||
_a$1[exports.CODEC.PROPOSAL] = proposalEncoder, | ||
_a$1[exports.CODEC.PROPOSAL_ARR] = proposalsEncoder, | ||
_a$1[exports.CODEC.INT32] = int32Encoder, | ||
_a$1[exports.CODEC.PARAMETERS] = parametersEncoder, | ||
_a$1[exports.CODEC.ADDRESS] = addressEncoder, | ||
_a$1); | ||
encoders[exports.CODEC.OPERATION] = operationEncoder(encoders); | ||
encoders[exports.CODEC.OP_ACTIVATE_ACCOUNT] = function (val) { return schemaEncoder(encoders)(ActivationSchema)(val); }; | ||
encoders[exports.CODEC.OP_DELEGATION] = function (val) { return schemaEncoder(encoders)(DelegationSchema)(val); }; | ||
encoders[exports.CODEC.OP_TRANSACTION] = function (val) { return schemaEncoder(encoders)(TransactionSchema)(val); }; | ||
encoders[exports.CODEC.OP_ORIGINATION] = function (val) { return schemaEncoder(encoders)(OriginationSchema)(val); }; | ||
encoders[exports.CODEC.OP_BALLOT] = function (val) { return schemaEncoder(encoders)(BallotSchema)(val); }; | ||
encoders[exports.CODEC.OP_ENDORSEMENT] = function (val) { return schemaEncoder(encoders)(EndorsementSchema)(val); }; | ||
encoders[exports.CODEC.OP_SEED_NONCE_REVELATION] = function (val) { | ||
return schemaEncoder(encoders)(SeedNonceRevelationSchema)(val); | ||
}; | ||
encoders[exports.CODEC.OP_PROPOSALS] = function (val) { return schemaEncoder(encoders)(ProposalsSchema)(val); }; | ||
encoders[exports.CODEC.OP_REVEAL] = function (val) { return schemaEncoder(encoders)(RevealSchema)(val); }; | ||
encoders[exports.CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema); | ||
function getCodec(codec) { | ||
return { | ||
encoder: encoders[codec], | ||
decoder: function (hex) { | ||
var consumer = Uint8ArrayConsumer.fromHexString(hex); | ||
return decoders[codec](consumer); | ||
}, | ||
}; | ||
} | ||
var LocalForger = /** @class */ (function () { | ||
function LocalForger() { | ||
this.codec = getCodec(exports.CODEC.MANAGER); | ||
} | ||
LocalForger.prototype.forge = function (params) { | ||
return Promise.resolve(encoders['manager'](params)); | ||
return Promise.resolve(this.codec.encoder(params)); | ||
}; | ||
LocalForger.prototype.parse = function (hex) { | ||
return Promise.resolve(this.codec.decoder(hex)); | ||
}; | ||
return LocalForger; | ||
@@ -897,4 +952,6 @@ }()); | ||
exports.LocalForger = LocalForger; | ||
exports.Uint8ArrayConsumer = Uint8ArrayConsumer; | ||
exports.decoders = decoders; | ||
exports.encoders = encoders; | ||
exports.getCodec = getCodec; | ||
exports.localForger = localForger; | ||
@@ -901,0 +958,0 @@ |
@@ -0,1 +1,29 @@ | ||
export declare enum CODEC { | ||
SECRET = "secret", | ||
RAW = "raw", | ||
TZ1 = "tz1", | ||
BRANCH = "branch", | ||
ZARITH = "zarith", | ||
PUBLIC_KEY = "public_key", | ||
PKH = "pkh", | ||
DELEGATE = "delegate", | ||
SCRIPT = "script", | ||
BALLOT_STATEMENT = "ballotStmt", | ||
PROPOSAL = "proposal", | ||
PROPOSAL_ARR = "proposalArr", | ||
INT32 = "int32", | ||
PARAMETERS = "parameters", | ||
ADDRESS = "address", | ||
OPERATION = "operation", | ||
OP_ACTIVATE_ACCOUNT = "activate_account", | ||
OP_DELEGATION = "delegation", | ||
OP_TRANSACTION = "transaction", | ||
OP_ORIGINATION = "origination", | ||
OP_BALLOT = "ballot", | ||
OP_ENDORSEMENT = "endorsement", | ||
OP_SEED_NONCE_REVELATION = "seed_nonce_revelation", | ||
OP_REVEAL = "reveal", | ||
OP_PROPOSALS = "proposals", | ||
MANAGER = "manager" | ||
} | ||
export declare const opMapping: { | ||
@@ -2,0 +30,0 @@ [key: string]: string; |
import { ForgeParams, Forger } from '@taquito/taquito'; | ||
import { CODEC } from './constants'; | ||
export { CODEC } from './constants'; | ||
export * from './decoder'; | ||
export * from './encoder'; | ||
export * from './uint8array-consumer'; | ||
export declare function getCodec(codec: CODEC): { | ||
encoder: import("./encoder").Encoder<any>; | ||
decoder: (hex: string) => any; | ||
}; | ||
export declare class LocalForger implements Forger { | ||
private codec; | ||
forge(params: ForgeParams): Promise<string>; | ||
parse(hex: string): Promise<ForgeParams>; | ||
} | ||
export declare const localForger: LocalForger; |
export declare class Uint8ArrayConsumer { | ||
private readonly arr; | ||
private offset; | ||
static fromHexString(hex: string): Uint8ArrayConsumer; | ||
constructor(arr: Uint8Array, offset?: number); | ||
@@ -5,0 +6,0 @@ consume(count: number): Uint8Array; |
{ | ||
"name": "@taquito/local-forging", | ||
"version": "6.0.2-beta.0", | ||
"version": "6.0.3-beta.0", | ||
"description": "Provide local forging functionality to be with taquito", | ||
@@ -14,3 +14,4 @@ "keywords": [ | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"signature.json" | ||
], | ||
@@ -69,7 +70,7 @@ "publishConfig": { | ||
"dependencies": { | ||
"@taquito/utils": "^6.0.2-beta.0", | ||
"@taquito/utils": "^6.0.3-beta.0", | ||
"bignumber.js": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@taquito/taquito": "^6.0.2-beta.0", | ||
"@taquito/taquito": "^6.0.3-beta.0", | ||
"@types/jest": "^23.3.2", | ||
@@ -101,3 +102,3 @@ "@types/node": "^10.14.13", | ||
}, | ||
"gitHead": "dfb54bce9ce9c0a7c2d774eecc83d16cdcd1d91a" | ||
"gitHead": "a461202928941643d73e02dbcdfa7c4c4b5248f9" | ||
} |
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
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
286167
35
3384
+ Added@taquito/utils@6.0.3-beta.1(transitive)
- Removed@taquito/utils@6.0.2-beta.0(transitive)
Updated@taquito/utils@^6.0.3-beta.0