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.4.3 to 1.4.4

21

build/modules/txs/TransferQueu.js

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

const stringNumber_1 = require("../../utils/stringNumber");
const safeJson_1 = require("../../utils/safeJson");
class TransferQueue {

@@ -18,3 +19,5 @@ queue;

transfer(priority, address, amount, name, message) {
this.logger(`Add Transfer to queue ${address} ${amount} ${name} ${message}`);
return this.queue.add(async () => {
this.logger(`Exec Transfer ${address} ${amount} ${name} ${message}`);
return this._transfer(address, amount, name, message);

@@ -24,9 +27,15 @@ }, priority);

_transfer(address, amount, name, message) {
if (!this.ton.isValidAddress(address)) {
return Promise.reject(`Ton transfer Fail. Address ${address} is not valid`);
try {
if (!this.ton.isValidAddress(address)) {
return Promise.reject(`Ton transfer Fail. Address ${address} is not valid`);
}
if (name === 'TON') {
return this.transferTon(address, amount, message);
}
return this.transferJetton(address, amount, name, message);
}
if (name === 'TON') {
return this.transferTon(address, amount, message);
catch (e) {
this.logger(`Transfer error ${(0, safeJson_1.safeJSONStringify)(e)}`);
throw e;
}
return this.transferJetton(address, amount, name, message);
}

@@ -44,2 +53,3 @@ async transferTon(address, amount, msg = '') {

async transferJetton(address, amount, name, msg = '') {
this.logger(`Begin Transfer exec ${address} ${amount} ${name} ${msg}`);
const jettons = await this.ton.getJettonsInfo();

@@ -54,2 +64,3 @@ if (!jettons[name]) {

}
this.logger(`Try Transfer jetton ${address} ${bigIntAmount} ${jettons[name].jettonMasterAddress.toString()} ${msg}`);
const { message, messageHash, seqno } = await this.ton.transferJettonMessage(address, jettons[name].jettonMasterAddress.toRawString(), bigIntAmount, msg);

@@ -56,0 +67,0 @@ this.logger(`Jetton ${name} transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);

{
"name": "ton-watcher",
"version": "1.4.3",
"version": "1.4.4",
"description": "",

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

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

import { strToBigInt } from "../../utils/stringNumber";
import { safeJSONStringify } from "../../utils/safeJson";

@@ -23,3 +24,5 @@ export type txHash = string;

public transfer(priority: number, address: string, amount: string, name: Tokens, message?: string): Promise<{ msgHash: string, seqno: number }> {
this.logger(`Add Transfer to queue ${address} ${amount} ${name} ${message}`);
return this.queue.add(async () => {
this.logger(`Exec Transfer ${address} ${amount} ${name} ${message}`);
return this._transfer(address, amount, name, message);

@@ -30,10 +33,15 @@ }, priority);

private _transfer(address: string, amount: string, name: Tokens, message?: string): Promise<{ msgHash: string, seqno: number }> {
if (!this.ton.isValidAddress(address)) {
return Promise.reject(`Ton transfer Fail. Address ${address} is not valid`);
}
try {
if (!this.ton.isValidAddress(address)) {
return Promise.reject(`Ton transfer Fail. Address ${address} is not valid`);
}
if (name === 'TON') {
return this.transferTon(address, amount, message);
if (name === 'TON') {
return this.transferTon(address, amount, message);
}
return this.transferJetton(address, amount, name, message);
} catch(e) {
this.logger(`Transfer error ${safeJSONStringify(e)}`);
throw e;
}
return this.transferJetton(address, amount, name, message);
}

@@ -53,3 +61,5 @@

private async transferJetton(address: string, amount: string, name: string, msg: string = ''): Promise<{ msgHash: string, seqno: number }> {
this.logger(`Begin Transfer exec ${address} ${amount} ${name} ${msg}`);
const jettons = await this.ton.getJettonsInfo();
if (!jettons[name]) {

@@ -66,4 +76,7 @@ throw new Error(`Transfer jetton ${name} fail. Not found jetton`);

this.logger(`Try Transfer jetton ${address} ${bigIntAmount} ${jettons[name].jettonMasterAddress.toString()} ${msg}`);
const { message, messageHash, seqno } = await this.ton.transferJettonMessage(address, jettons[name].jettonMasterAddress.toRawString(), bigIntAmount, msg);
this.logger(`Jetton ${name} transfer ready to send ${amount} to ${address} seqno ${seqno} msghash ${messageHash}`);
try {

@@ -70,0 +83,0 @@ await this.sendMsg(message);

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