Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ton-watcher

Package Overview
Dependencies
Maintainers
0
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ton-watcher - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

1

build/modules/txs/TransferQueu.d.ts

@@ -8,3 +8,2 @@ import { TonInteractionV4 } from "../../modules/wallet/CoreV4";

private logger;
private currentSeqNo;
constructor(ton: TonInteractionV4, logger?: (msg: string) => void);

@@ -11,0 +10,0 @@ transfer(priority: number, address: string, amount: string, name: Tokens, message?: string): Promise<{

23

build/modules/txs/TransferQueu.js

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

logger;
currentSeqNo = -1;
constructor(ton, logger) {

@@ -34,10 +33,8 @@ this.queue = new Queue_1.PriorityQueue(5, 1);

const bigIntAmount = (0, stringNumber_1.strToBigInt)(amount, 9);
if (this.currentSeqNo !== -1) {
await this.waitNewSeqNo(this.currentSeqNo);
}
const { message, messageHash, seqno } = await this.ton.transferTonMessage(address, bigIntAmount, msg, true);
this.logger(`TON transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.sendMsg(message, seqno);
await this.sendMsg(message);
this.logger(`TON transfer sent ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
// const data = await this.waitMsgHash(messageHash);
await this.waitNewSeqNo(seqno);
this.logger(`TON transfer done ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);

@@ -51,5 +48,2 @@ return { msgHash: messageHash, seqno };

}
if (this.currentSeqNo !== -1) {
await this.waitNewSeqNo(this.currentSeqNo);
}
const bigIntAmount = (0, stringNumber_1.strToBigInt)(amount, jettons[name].decimals);

@@ -62,14 +56,9 @@ const balance = await this.ton.fetchJettonWalletBalance(jettons[name].jettonMasterAddress.toRawString(), address);

this.logger(`Jetton ${name} transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.sendMsg(message, seqno);
await this.sendMsg(message);
this.logger(`Jetton ${name} transfer sent ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
// const data = await this.waitMsgHash(messageHash);
this.logger(`Jetton ${name} transfer done ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.waitNewSeqNo(seqno);
return { msgHash: messageHash, seqno };
}
async sendMsg(msg, seqNo) {
const newSeqNo = await this.ton.getSeqNo();
if (newSeqNo !== seqNo) {
throw new Error('Invalid message Seqno is expired');
}
this.currentSeqNo = newSeqNo;
async sendMsg(msg) {
try {

@@ -81,3 +70,3 @@ await this.ton.sendTx(msg);

}
async waitNewSeqNo(seqNo, delay = 5000, maxTryes = 20) {
async waitNewSeqNo(seqNo, delay = 2000, maxTryes = 16) {
while (maxTryes) {

@@ -84,0 +73,0 @@ (0, common_helpers_1.wait)(delay);

{
"name": "ton-watcher",
"version": "1.3.1",
"version": "1.3.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -14,3 +14,2 @@ import { Cell } from "@ton/core";

private logger: (msg: string) => void;
private currentSeqNo = -1;

@@ -42,12 +41,8 @@ constructor(ton: TonInteractionV4, logger?: (msg: string) => void) {

const bigIntAmount = strToBigInt(amount, 9);
if (this.currentSeqNo !== -1) {
await this.waitNewSeqNo(this.currentSeqNo);
}
const { message, messageHash, seqno } = await this.ton.transferTonMessage(address, bigIntAmount, msg, true);
this.logger(`TON transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.sendMsg(message, seqno);
await this.sendMsg(message);
this.logger(`TON transfer sent ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
// const data = await this.waitMsgHash(messageHash);
await this.waitNewSeqNo(seqno);
this.logger(`TON transfer done ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);

@@ -63,6 +58,2 @@ return { msgHash: messageHash, seqno };

if (this.currentSeqNo !== -1) {
await this.waitNewSeqNo(this.currentSeqNo);
}
const bigIntAmount = strToBigInt(amount, jettons[name].decimals);

@@ -77,18 +68,11 @@ const balance = await this.ton.fetchJettonWalletBalance(jettons[name].jettonMasterAddress.toRawString(), address);

this.logger(`Jetton ${name} transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.sendMsg(message, seqno);
await this.sendMsg(message);
this.logger(`Jetton ${name} transfer sent ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
// const data = await this.waitMsgHash(messageHash);
this.logger(`Jetton ${name} transfer done ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
await this.waitNewSeqNo(seqno);
return { msgHash: messageHash, seqno };
}
private async sendMsg(msg: Cell, seqNo: number) {
const newSeqNo = await this.ton.getSeqNo();
if (newSeqNo !== seqNo) {
throw new Error('Invalid message Seqno is expired');
}
this.currentSeqNo = newSeqNo;
private async sendMsg(msg: Cell) {
try {

@@ -101,3 +85,3 @@ await this.ton.sendTx(msg);

private async waitNewSeqNo(seqNo: number, delay = 5000, maxTryes = 20) {
private async waitNewSeqNo(seqNo: number, delay = 2000, maxTryes = 16) {
while(maxTryes) {

@@ -104,0 +88,0 @@ wait(delay);

@@ -113,3 +113,3 @@ {

},
"exclude": ["**/*.test.*", "./build/**/*"]
"exclude": ["**/*.test.*", "./build/**/*", "./src/test"]
}

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