Comparing version 0.13.0 to 0.14.0
@@ -8,2 +8,3 @@ /// <reference types="node" /> | ||
import { Slice } from "./Slice"; | ||
import { Dictionary } from "../dict/Dictionary"; | ||
/** | ||
@@ -166,2 +167,14 @@ * Start building a cell | ||
/** | ||
* Store dictionary in this builder | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDict<K, V>(dict: Dictionary<K, V>): this; | ||
/** | ||
* Store dictionary in this builder directly | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDictDirect<K, V>(dict: Dictionary<K, V>): this; | ||
/** | ||
* Complete cell | ||
@@ -168,0 +181,0 @@ * @returns cell |
@@ -299,2 +299,20 @@ "use strict"; | ||
/** | ||
* Store dictionary in this builder | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDict(dict) { | ||
dict.store(this); | ||
return this; | ||
} | ||
/** | ||
* Store dictionary in this builder directly | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDictDirect(dict) { | ||
dict.storeDirect(this); | ||
return this; | ||
} | ||
/** | ||
* Complete cell | ||
@@ -301,0 +319,0 @@ * @returns cell |
@@ -9,2 +9,4 @@ "use strict"; | ||
const Builder_1 = require("../Builder"); | ||
const CellType_1 = require("../CellType"); | ||
const exoticPruned_1 = require("./exoticPruned"); | ||
const wallets = [ | ||
@@ -68,2 +70,37 @@ 'B5EE9C72410101010044000084FF0020DDA4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED5441FDF089', | ||
}); | ||
it('should parse accountStateTest.txt', () => { | ||
let boc = Buffer.from(fs_1.default.readFileSync(__dirname + '/__testdata__/accountStateTest.txt', 'utf8'), 'base64'); | ||
let c = (0, serialization_1.deserializeBoc)(boc)[0]; | ||
let b = (0, serialization_1.serializeBoc)(c, { idx: false, crc32: true }); | ||
let c2 = (0, serialization_1.deserializeBoc)(b)[0]; | ||
expect(c2.equals(c)).toBe(true); | ||
}); | ||
it('should parse accountStateTestPruned.txt', () => { | ||
let boc = Buffer.from(fs_1.default.readFileSync(__dirname + '/__testdata__/accountStateTestPruned.txt', 'utf8'), 'base64'); | ||
let c = (0, serialization_1.deserializeBoc)(boc)[0]; | ||
let b = (0, serialization_1.serializeBoc)(c, { idx: false, crc32: true }); | ||
let c2 = (0, serialization_1.deserializeBoc)(b)[0]; | ||
expect(c2.equals(c)).toBe(true); | ||
}); | ||
it('should match pruned state', () => { | ||
let prunedBoc = Buffer.from(fs_1.default.readFileSync(__dirname + '/__testdata__/accountStateTestPruned.txt', 'utf8'), 'base64'); | ||
let pruned = (0, serialization_1.deserializeBoc)(prunedBoc)[0]; | ||
let fullBoc = Buffer.from(fs_1.default.readFileSync(__dirname + '/__testdata__/accountStateTest.txt', 'utf8'), 'base64'); | ||
let full = (0, serialization_1.deserializeBoc)(fullBoc)[0]; | ||
expect(pruned.isExotic).toBe(true); | ||
expect(pruned.type).toBe(CellType_1.CellType.MerkleProof); | ||
let prunedData = pruned.beginParse().loadRef(); | ||
// Load refs | ||
let sc = full.beginParse(); | ||
let fullA = sc.loadRef(); | ||
let fullB = sc.loadRef(); | ||
let sc2 = prunedData.beginParse(); | ||
let prunedA = sc2.loadRef(); | ||
let prunedB = sc2.loadRef(); | ||
let ppA = (0, exoticPruned_1.exoticPruned)(prunedA.bits, prunedA.refs); | ||
let ppB = (0, exoticPruned_1.exoticPruned)(prunedB.bits, prunedB.refs); | ||
// Check hashes | ||
expect(ppA.pruned[0].hash).toMatchObject(fullA.hash()); | ||
expect(ppB.pruned[0].hash).toMatchObject(fullB.hash()); | ||
}); | ||
it('should serialize single cell with a empty bits', () => { | ||
@@ -70,0 +107,0 @@ let cell = (0, Builder_1.beginCell)().endCell(); |
/// <reference types="node" /> | ||
import inspectSymbol from 'symbol.inspect'; | ||
import { Dictionary, DictionaryKey, DictionaryValue } from '../dict/Dictionary'; | ||
import { BitReader } from "./BitReader"; | ||
@@ -229,2 +231,16 @@ import { Cell } from "./Cell"; | ||
/** | ||
* Loads dictionary | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDict<K, V>(key: DictionaryKey<K>, value: DictionaryValue<V>): Dictionary<K, any>; | ||
/** | ||
* Loads dictionary directly from current slice | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDictDirect<K, V>(key: DictionaryKey<K>, value: DictionaryValue<V>): Dictionary<K, V>; | ||
/** | ||
* Convert slice to cell | ||
@@ -243,2 +259,8 @@ */ | ||
clone(): Slice; | ||
/** | ||
* Print slice as string by converting it to cell | ||
* @returns string | ||
*/ | ||
toString(): string; | ||
[inspectSymbol]: () => string; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Slice = void 0; | ||
const symbol_inspect_1 = __importDefault(require("symbol.inspect")); | ||
const Dictionary_1 = require("../dict/Dictionary"); | ||
const Builder_1 = require("./Builder"); | ||
@@ -11,2 +17,3 @@ const strings_1 = require("./utils/strings"); | ||
constructor(reader, refs) { | ||
this[_a] = () => this.toString(); | ||
this._reader = reader; | ||
@@ -341,2 +348,20 @@ this._refs = refs; | ||
/** | ||
* Loads dictionary | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDict(key, value) { | ||
return Dictionary_1.Dictionary.load(key, value, this); | ||
} | ||
/** | ||
* Loads dictionary directly from current slice | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDictDirect(key, value) { | ||
return Dictionary_1.Dictionary.loadDirect(key, value, this); | ||
} | ||
/** | ||
* Convert slice to cell | ||
@@ -361,3 +386,11 @@ */ | ||
} | ||
/** | ||
* Print slice as string by converting it to cell | ||
* @returns string | ||
*/ | ||
toString() { | ||
return this.asCell().toString(); | ||
} | ||
} | ||
exports.Slice = Slice; | ||
_a = symbol_inspect_1.default; |
@@ -13,2 +13,3 @@ export { Address } from './address/Address'; | ||
export { Writable } from './boc/Writable'; | ||
export { Dictionary, DictionaryKey, DictionaryValue } from './dict/Dictionary'; | ||
export { exoticMerkleProof } from './boc/cell/exoticMerkleProof'; | ||
@@ -15,0 +16,0 @@ export { exoticMerkleUpdate } from './boc/cell/exoticMerkleUpdate'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.base32Encode = exports.base32Decode = exports.crc32c = exports.crc16 = exports.fromNano = exports.toNano = exports.BufferMessage = exports.CellMessage = exports.EmptyMessage = exports.CommentMessage = exports.CommonMessageInfo = exports.ExternalMessage = exports.InternalMessage = exports.StateInit = exports.TupleReader = exports.serializeTuple = exports.parseTuple = exports.exoticPruned = exports.exoticMerkleUpdate = exports.exoticMerkleProof = exports.Cell = exports.CellType = exports.Slice = exports.beginCell = exports.Builder = exports.BitBuilder = exports.BitReader = exports.BitString = exports.contractAddress = exports.ADNLAddress = exports.ExternalAddress = exports.Address = void 0; | ||
exports.base32Encode = exports.base32Decode = exports.crc32c = exports.crc16 = exports.fromNano = exports.toNano = exports.BufferMessage = exports.CellMessage = exports.EmptyMessage = exports.CommentMessage = exports.CommonMessageInfo = exports.ExternalMessage = exports.InternalMessage = exports.StateInit = exports.TupleReader = exports.serializeTuple = exports.parseTuple = exports.exoticPruned = exports.exoticMerkleUpdate = exports.exoticMerkleProof = exports.Dictionary = exports.Cell = exports.CellType = exports.Slice = exports.beginCell = exports.Builder = exports.BitBuilder = exports.BitReader = exports.BitString = exports.contractAddress = exports.ADNLAddress = exports.ExternalAddress = exports.Address = void 0; | ||
// Address | ||
@@ -30,2 +30,5 @@ var Address_1 = require("./address/Address"); | ||
Object.defineProperty(exports, "Cell", { enumerable: true, get: function () { return Cell_1.Cell; } }); | ||
// Dict | ||
var Dictionary_1 = require("./dict/Dictionary"); | ||
Object.defineProperty(exports, "Dictionary", { enumerable: true, get: function () { return Dictionary_1.Dictionary; } }); | ||
// Exotics | ||
@@ -32,0 +35,0 @@ var exoticMerkleProof_1 = require("./boc/cell/exoticMerkleProof"); |
{ | ||
"name": "ton-core", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ton-community/ton-core.git", |
@@ -9,2 +9,3 @@ import { Address } from "../address/Address"; | ||
import { writeString } from "./utils/strings"; | ||
import { Dictionary } from "../dict/Dictionary"; | ||
@@ -327,2 +328,22 @@ /** | ||
/** | ||
* Store dictionary in this builder | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDict<K, V>(dict: Dictionary<K, V>) { | ||
dict.store(this); | ||
return this; | ||
} | ||
/** | ||
* Store dictionary in this builder directly | ||
* @param dict dictionary to store | ||
* @returns this builder | ||
*/ | ||
storeDictDirect<K, V>(dict: Dictionary<K, V>) { | ||
dict.storeDirect(this); | ||
return this; | ||
} | ||
/** | ||
* Complete cell | ||
@@ -329,0 +350,0 @@ * @returns cell |
@@ -189,3 +189,3 @@ import inspectSymbol from 'symbol.inspect'; | ||
[inspectSymbol] = () => this.toString() | ||
[inspectSymbol] = () => this.toString(); | ||
} |
import { deserializeBoc, serializeBoc } from "./serialization"; | ||
import fs from 'fs'; | ||
import { beginCell } from "../Builder"; | ||
import { CellType } from "../CellType"; | ||
import { exoticPruned } from "./exoticPruned"; | ||
@@ -72,2 +74,42 @@ const wallets: string[] = [ | ||
it('should parse accountStateTest.txt', () => { | ||
let boc = Buffer.from(fs.readFileSync(__dirname + '/__testdata__/accountStateTest.txt', 'utf8'), 'base64'); | ||
let c = deserializeBoc(boc)[0]; | ||
let b = serializeBoc(c, { idx: false, crc32: true }); | ||
let c2 = deserializeBoc(b)[0]; | ||
expect(c2.equals(c)).toBe(true); | ||
}); | ||
it('should parse accountStateTestPruned.txt', () => { | ||
let boc = Buffer.from(fs.readFileSync(__dirname + '/__testdata__/accountStateTestPruned.txt', 'utf8'), 'base64'); | ||
let c = deserializeBoc(boc)[0]; | ||
let b = serializeBoc(c, { idx: false, crc32: true }); | ||
let c2 = deserializeBoc(b)[0]; | ||
expect(c2.equals(c)).toBe(true); | ||
}); | ||
it('should match pruned state', () => { | ||
let prunedBoc = Buffer.from(fs.readFileSync(__dirname + '/__testdata__/accountStateTestPruned.txt', 'utf8'), 'base64'); | ||
let pruned = deserializeBoc(prunedBoc)[0]; | ||
let fullBoc = Buffer.from(fs.readFileSync(__dirname + '/__testdata__/accountStateTest.txt', 'utf8'), 'base64'); | ||
let full = deserializeBoc(fullBoc)[0]; | ||
expect(pruned.isExotic).toBe(true); | ||
expect(pruned.type).toBe(CellType.MerkleProof); | ||
let prunedData = pruned.beginParse().loadRef(); | ||
// Load refs | ||
let sc = full.beginParse(); | ||
let fullA = sc.loadRef(); | ||
let fullB = sc.loadRef(); | ||
let sc2 = prunedData.beginParse(); | ||
let prunedA = sc2.loadRef(); | ||
let prunedB = sc2.loadRef(); | ||
let ppA = exoticPruned(prunedA.bits, prunedA.refs); | ||
let ppB = exoticPruned(prunedB.bits, prunedB.refs); | ||
// Check hashes | ||
expect(ppA.pruned[0].hash).toMatchObject(fullA.hash()); | ||
expect(ppB.pruned[0].hash).toMatchObject(fullB.hash()); | ||
}); | ||
it('should serialize single cell with a empty bits', () => { | ||
@@ -74,0 +116,0 @@ let cell = beginCell().endCell(); |
@@ -0,1 +1,3 @@ | ||
import inspectSymbol from 'symbol.inspect'; | ||
import { Dictionary, DictionaryKey, DictionaryValue } from '../dict/Dictionary'; | ||
import { BitReader } from "./BitReader"; | ||
@@ -381,2 +383,22 @@ import { beginCell } from "./Builder"; | ||
/** | ||
* Loads dictionary | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDict<K, V>(key: DictionaryKey<K>, value: DictionaryValue<V>) { | ||
return Dictionary.load(key, value, this); | ||
} | ||
/** | ||
* Loads dictionary directly from current slice | ||
* @param key key description | ||
* @param value value description | ||
* @returns Dictionary<K, V> | ||
*/ | ||
loadDictDirect<K, V>(key: DictionaryKey<K>, value: DictionaryValue<V>) { | ||
return Dictionary.loadDirect(key, value, this); | ||
} | ||
/** | ||
* Convert slice to cell | ||
@@ -403,2 +425,12 @@ */ | ||
} | ||
/** | ||
* Print slice as string by converting it to cell | ||
* @returns string | ||
*/ | ||
toString(): string { | ||
return this.asCell().toString(); | ||
} | ||
[inspectSymbol] = () => this.toString(); | ||
} |
@@ -19,2 +19,5 @@ // Address | ||
// Dict | ||
export { Dictionary, DictionaryKey, DictionaryValue } from './dict/Dictionary'; | ||
// Exotics | ||
@@ -21,0 +24,0 @@ export { exoticMerkleProof } from './boc/cell/exoticMerkleProof'; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
718414
220
12390
3