Socket
Socket
Sign inDemoInstall

@taquito/michelson-encoder

Package Overview
Dependencies
Maintainers
2
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/michelson-encoder - npm Package Compare versions

Comparing version 8.0.0-alpha.0 to 8.0.0-beta.1

57

dist/lib/schema/storage.js

@@ -22,2 +22,33 @@ "use strict";

var schemaTypeSymbol = Symbol.for('taquito-schema-type-symbol');
// collapse comb pair
function collapse(val, prim) {
var _b, _c;
if (prim === void 0) { prim = pair_1.PairToken.prim; }
if (Array.isArray(val)) {
return collapse({
prim: prim,
args: val,
}, prim);
}
if (val.prim === prim && ((_b = val.args) === null || _b === void 0 ? void 0 : _b.length) > 2) {
return __assign(__assign({}, val), { args: [val.args[0], {
prim: prim,
args: (_c = val.args) === null || _c === void 0 ? void 0 : _c.slice(1),
}] });
}
return val;
}
function deepEqual(a, b) {
var ac = collapse(a);
var bc = collapse(b);
return ac.prim === bc.prim &&
(ac.args === undefined && bc.args === undefined ||
ac.args !== undefined && bc.args !== undefined &&
ac.args.length === bc.args.length &&
ac.args.every(function (v, i) { var _b; return deepEqual(v, (_b = bc.args) === null || _b === void 0 ? void 0 : _b[i]); })) &&
(ac.annots === undefined && bc.annots === undefined ||
ac.annots !== undefined && bc.annots !== undefined &&
ac.annots.length === bc.annots.length &&
ac.annots.every(function (v, i) { var _b; return v === ((_b = bc.annots) === null || _b === void 0 ? void 0 : _b[i]); }));
}
/**

@@ -136,2 +167,28 @@ * @warn Our current smart contract abstraction feature is currently in preview. It's API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.

};
/**
* @description Look up in top-level pairs of the storage to find a value matching the specified type
*
* @returns The first value found that match the type or `undefined` if no value is found
*
* @param storage storage to parse to find the value
* @param valueType type of value to look for
*
*/
Schema.prototype.FindFirstInTopLevelPair = function (storage, valueType) {
return this.findValue(this.root['val'], storage, valueType);
};
Schema.prototype.findValue = function (schema, storage, valueToFind) {
if (deepEqual(valueToFind, schema)) {
return storage;
}
if (Array.isArray(schema) || schema['prim'] === 'pair') {
var sch = collapse(schema);
var str = collapse(storage, 'Pair');
if (sch.args === undefined || str.args === undefined) {
throw new Error('Tokens have no arguments'); // unlikely
}
return this.findValue(sch.args[0], str.args[0], valueToFind) ||
this.findValue(sch.args[1], str.args[1], valueToFind);
}
};
return Schema;

@@ -138,0 +195,0 @@ }());

4

dist/lib/tokens/createToken.js

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

var tokens_1 = require("./tokens");
var pair_1 = require("./pair");
var InvalidTokenError = /** @class */ (function () {

@@ -16,2 +17,5 @@ function InvalidTokenError(message, data) {

function createToken(val, idx) {
if (Array.isArray(val)) {
return new pair_1.PairToken(val, idx, createToken);
}
var t = tokens_1.tokens.find(function (x) { return x.prim === val.prim; });

@@ -18,0 +22,0 @@ if (!t) {

29

dist/lib/tokens/pair.js

@@ -62,12 +62,20 @@ "use strict";

// collapse comb pair
function collapse(val) {
function collapse(val, prim) {
if (prim === void 0) { prim = PairToken.prim; }
if (Array.isArray(val)) {
return collapse({
prim: prim,
args: val,
}, prim);
}
if (val.args === undefined) {
throw new Error('Token has no arguments');
}
if (val.args.length > 2) {
return [val.args[0], {
prim: val.prim,
prim: prim,
args: val.args.slice(1),
}];
}
else {
return [val.args[0], val.args[1]];
}
return [val.args[0], val.args[1]];
}

@@ -77,7 +85,6 @@ var PairToken = /** @class */ (function (_super) {

function PairToken(val, idx, fac) {
var _this = _super.call(this, val, idx, fac) || this;
_this.val = val;
_this.idx = idx;
_this.fac = fac;
return _this;
return _super.call(this, Array.isArray(val) ? {
prim: PairToken.prim,
args: val,
} : val, idx, fac) || this;
}

@@ -200,3 +207,3 @@ PairToken.prototype.args = function () {

PairToken.prototype.Execute = function (val, semantics) {
var args = collapse(val);
var args = collapse(val, 'Pair');
return this.traversal(function (leftToken) { return leftToken.Execute(args[0], semantics); }, function (rightToken) { return rightToken.Execute(args[1], semantics); });

@@ -203,0 +210,0 @@ };

@@ -37,3 +37,14 @@ import { MichelsonV1Expression, ScriptResponse } from '@taquito/rpc';

ComputeState(tx: RpcTransaction[], state: any): any;
/**
* @description Look up in top-level pairs of the storage to find a value matching the specified type
*
* @returns The first value found that match the type or `undefined` if no value is found
*
* @param storage storage to parse to find the value
* @param valueType type of value to look for
*
*/
FindFirstInTopLevelPair<T extends MichelsonV1Expression>(storage: any, valueType: any): T | undefined;
private findValue;
}
export {};
import { TokenFactory, Semantic, ComparableToken } from './token';
export declare class PairToken extends ComparableToken {
protected val: {
prim: string;
args: any[];
annots: any[];
};
protected idx: number;
protected fac: TokenFactory;
static prim: string;

@@ -15,3 +8,3 @@ constructor(val: {

annots: any[];
}, idx: number, fac: TokenFactory);
} | any[], idx: number, fac: TokenFactory);
private args;

@@ -18,0 +11,0 @@ private tokens;

@@ -16,3 +16,3 @@ import { MichelsonV1Expression } from '@taquito/rpc';

prim: string;
args: any[];
args?: any[];
annots?: any[];

@@ -24,3 +24,3 @@ };

prim: string;
args: any[];
args?: any[];
annots?: any[];

@@ -27,0 +27,0 @@ }, idx: number, fac: TokenFactory);

{
"name": "@taquito/michelson-encoder",
"version": "8.0.0-alpha.0",
"version": "8.0.0-beta.1",
"description": "converts michelson data and types into convenient JS/TS objects",

@@ -70,4 +70,4 @@ "keywords": [

"dependencies": {
"@taquito/rpc": "^8.0.0-alpha.0",
"@taquito/utils": "^8.0.0-alpha.0",
"@taquito/rpc": "^8.0.0-beta.1",
"@taquito/utils": "^8.0.0-beta.1",
"bignumber.js": "^9.0.1",

@@ -104,3 +104,3 @@ "fast-json-stable-stringify": "^2.1.0"

},
"gitHead": "66f5a4487644cf9e57d153b35ec535250e6b82b6"
"gitHead": "1a563e06fb2fad0fce858026b6a195f307118940"
}

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 too big to display

Sorry, the diff of this file is not supported yet

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

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