Skip to content

Commit

Permalink
Merge 42ae9a2 into 5d77161
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymoussprocket committed Feb 16, 2021
2 parents 5d77161 + 42ae9a2 commit 8f88c63
Show file tree
Hide file tree
Showing 25 changed files with 1,016 additions and 671 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -59,7 +59,7 @@ Project [honeybadger](https://github.com/Cryptonomic/honeybadger), which is the
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs/dist-web/conseiljs.min.js"
integrity="sha384-PNgOUrCFUbpIF6W1GSjxT8Iwjfe4nt2+mtT7IRsI//8P7akhhrmedJ0DFZqrzDty"
integrity="sha384-sEYMVfIFpMORsZMgO4YyC0/fVSRBZjbkCYnA5A6HxBpKbxhbLG475Ru1hOjWSK7f"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs-softsigner/dist-web/conseiljs-softsigner.min.js"
integrity="sha384-V1iaajn0x/SMFcZ9Y/xNQmqQSKyll6Dzt27U6OWiv8NdbHTVaHOGHdQ8g0G68HPd"
Expand Down
2 changes: 1 addition & 1 deletion dist-web/conseiljs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/README.md
Expand Up @@ -52,7 +52,7 @@ Unlike the nodejs sample, it's not possible to configure fetch or logger referen
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs/dist-web/conseiljs.min.js"
integrity="sha384-PNgOUrCFUbpIF6W1GSjxT8Iwjfe4nt2+mtT7IRsI//8P7akhhrmedJ0DFZqrzDty"
integrity="sha384-sEYMVfIFpMORsZMgO4YyC0/fVSRBZjbkCYnA5A6HxBpKbxhbLG475Ru1hOjWSK7f"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs-softsigner/dist-web/conseiljs-softsigner.min.js"
crossorigin="anonymous"></script>
Expand Down
38 changes: 3 additions & 35 deletions grammar/tezos/Micheline.ne
@@ -1,8 +1,8 @@
@preprocessor typescript

@{%
const moo = require("moo");
const bigInt = require("big-integer");
import { TezosMessageUtils } from '../TezosMessageUtil';
import * as moo from 'moo';

// https://gitlab.com/tezos/tezos/-/blob/master/src/proto_008_PtEdoTez/lib_protocol/michelson_v1_primitives.ml#L1088
export const 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"'];
Expand Down Expand Up @@ -59,7 +59,7 @@ anyArray -> %lbracket %rbracket {% function(d) { return '0200000000'; } %}
const staticIntToHex = d => {
const prefix = '00';
const text = d[6].toString();
const value = writeSignedInt(parseInt(text.substring(1, text.length - 1))); // strip double quotes
const value = TezosMessageUtils.writeSignedInt(text.substring(1, text.length - 1)); // strip double quotes

return prefix + value;
};
Expand Down Expand Up @@ -194,36 +194,4 @@ const encodePrimitive = p => {
const encodeLength = l => {
return ('0000000' + l.toString(16)).slice(-8);
}

const writeSignedInt = value => {
if (value === 0) { return '00'; }

const n = bigInt(value).abs();
const l = n.bitLength().toJSNumber();
let arr: any = [];
let v = n;
for (let i = 0; i < l; i += 7) {
let byte = bigInt.zero;

if (i === 0) {
byte = v.and(0x3f); // first byte makes room for sign flag
v = v.shiftRight(6);
} else {
byte = v.and(0x7f); // NOT base128 encoded
v = v.shiftRight(7);
}

if (value < 0 && i === 0) { byte = byte.or(0x40); } // set sign flag

if (i + 7 < l) { byte = byte.or(0x80); } // set next byte flag
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('');
}
%}

0 comments on commit 8f88c63

Please sign in to comment.