Skip to content

Commit

Permalink
0.0.66 build
Browse files Browse the repository at this point in the history
  • Loading branch information
rise1507 committed Mar 28, 2024
1 parent 31ce05c commit 76dfd07
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dist/tonweb.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tonweb",
"version": "0.0.65",
"version": "0.0.66",
"description": "TonWeb - JavaScript API for TON blockchain",
"main": "src/index.js",
"types": "dist/types/index.d.ts",
Expand Down
22 changes: 13 additions & 9 deletions src/contract/highloadWallet/HighloadQueryId.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,28 @@ class HighloadQueryId {
return q;
}

increase() {
this.bitnumber += 1n;
getNext() {
let newBitnumber = this.bitnumber + 1n;
let newShift = this.shift;

if (this.shift === MAX_SHIFT && this.bitnumber > (MAX_BIT_NUMBER - 1n)) {
if (newShift === MAX_SHIFT && newBitnumber > (MAX_BIT_NUMBER - 1n)) {
throw new Error('Overload'); // NOTE: we left one queryId for emergency withdraw
}

if (this.bitnumber > MAX_BIT_NUMBER) {
this.bitnumber = 0n;
this.shift += 1n;
if (this.shift > MAX_SHIFT) {
if (newBitnumber > MAX_BIT_NUMBER) {
newBitnumber = 0n;
newShift += 1n;
if (newShift > MAX_SHIFT) {
throw new Error('Overload')
}
}

return HighloadQueryId.fromShiftAndBitNumber(newShift, newBitnumber);
}

isEnd() {
return this.bitnumber >= (MAX_BIT_NUMBER - 1n) && this.shift === MAX_SHIFT; // NOTE: we left one queryId for emergency withdraw
hasNext() {
const isEnd = this.bitnumber >= (MAX_BIT_NUMBER - 1n) && this.shift === MAX_SHIFT; // NOTE: we left one queryId for emergency withdraw;
return !isEnd;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TransportWebUSB = require("@ledgerhq/hw-transport-webusb").default;
const TransportWebHID = require("@ledgerhq/hw-transport-webhid").default;
const BluetoothTransport = require("@ledgerhq/hw-transport-web-ble").default;
const {Dns, DnsCollection, DnsItem} = require("./contract/dns").default;
const version = '0.0.65';
const version = '0.0.66';

class TonWeb {
constructor(provider) {
Expand Down
10 changes: 5 additions & 5 deletions src/test-highload-query-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const i4 = HighloadQueryId.fromSeqno(8380415n);
if (i4.toSeqno() !== 8380415n) throw new Error();


const queryId = new HighloadQueryId();
console.log(queryId.getQueryId(), queryId.isEnd());
let queryId = new HighloadQueryId();
console.log(queryId.getQueryId(), queryId.hasNext());

const MAX = (2n ** 13n) * 1023n - 2n;
for (let i = 0; i < MAX; i++) {
queryId.increase();
queryId = queryId.getNext();

const q = queryId.getQueryId();
const q2 = HighloadQueryId.fromQueryId(q);
Expand All @@ -32,11 +32,11 @@ for (let i = 0; i < MAX; i++) {
if (queryId.getBitNumber() !== q3.getBitNumber()) throw new Error()
if (q3.getQueryId() !== q) throw new Error();

if (queryId.isEnd()) {
if (!queryId.hasNext()) {
console.log('END')
}
}
console.log(queryId.shift);
console.log(queryId.bitnumber);

console.log(queryId.getQueryId(), queryId.isEnd());
console.log(queryId.getQueryId(), queryId.hasNext());
4 changes: 2 additions & 2 deletions src/test-highload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const init = async () => {

console.log('Highload-wallet address is ' + highloadAddress.toString(true, true, true));

const queryId = new HighloadQueryId();
queryId.increase();
let queryId = new HighloadQueryId();
queryId = queryId.getNext();

const createAt = Math.floor(Date.now() / 1000) - 60;
console.log(createAt);
Expand Down

0 comments on commit 76dfd07

Please sign in to comment.