Skip to content

Commit

Permalink
Merge pull request #21 from Gusarich/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Volkov authored Jan 25, 2024
2 parents 13459c3 + a886735 commit 63cbe8d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
6 changes: 4 additions & 2 deletions src/boc/Builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,14 @@ export class Builder {

/**
* Complete cell
* @param opts options
* @returns cell
*/
endCell() {
endCell(opts?: { exotic?: boolean }) {
return new Cell({
bits: this._bits.build(),
refs: this._refs
refs: this._refs,
exotic: opts?.exotic
});
}

Expand Down
34 changes: 12 additions & 22 deletions src/dict/generateMerkleProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,21 @@ import { DictionaryKeyTypes, Dictionary, DictionaryKey } from './Dictionary';
import { readUnaryLength } from './utils/readUnaryLength';

function convertToPrunedBranch(c: Cell): Cell {
return new Cell({
exotic: true,
bits: beginCell()
.storeUint(1, 8)
.storeUint(1, 8)
.storeBuffer(c.hash(0))
.storeUint(c.depth(0), 16)
.endCell()
.beginParse()
.loadBits(288),
});
return beginCell()
.storeUint(1, 8)
.storeUint(1, 8)
.storeBuffer(c.hash(0))
.storeUint(c.depth(0), 16)
.endCell({ exotic: true });
}

function convertToMerkleProof(c: Cell): Cell {
return new Cell({
exotic: true,
bits: beginCell()
.storeUint(3, 8)
.storeBuffer(c.hash(0))
.storeUint(c.depth(0), 16)
.endCell()
.beginParse()
.loadBits(280),
refs: [c],
});
return beginCell()
.storeUint(3, 8)
.storeBuffer(c.hash(0))
.storeUint(c.depth(0), 16)
.storeRef(c)
.endCell({ exotic: true });
}

function doGenerateMerkleProof(
Expand Down
22 changes: 9 additions & 13 deletions src/dict/generateMerkleUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ import { DictionaryKeyTypes, Dictionary, DictionaryKey } from './Dictionary';
import { generateMerkleProof } from './generateMerkleProof';

function convertToMerkleUpdate(c1: Cell, c2: Cell): Cell {
return new Cell({
exotic: true,
bits: beginCell()
.storeUint(4, 8)
.storeBuffer(c1.hash(0))
.storeBuffer(c2.hash(0))
.storeUint(c1.depth(0), 16)
.storeUint(c2.depth(0), 16)
.endCell()
.beginParse()
.loadBits(552),
refs: [c1, c2],
});
return beginCell()
.storeUint(4, 8)
.storeBuffer(c1.hash(0))
.storeBuffer(c2.hash(0))
.storeUint(c1.depth(0), 16)
.storeUint(c2.depth(0), 16)
.storeRef(c1)
.storeRef(c2)
.endCell({ exotic: true });
}

export function generateMerkleUpdate<K extends DictionaryKeyTypes, V>(
Expand Down

0 comments on commit 63cbe8d

Please sign in to comment.