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

@stardust-collective/dag4-xchain-ethereum

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stardust-collective/dag4-xchain-ethereum - npm Package Compare versions

Comparing version 0.1.12 to 0.1.13

58

cjs/account-tracker.js

@@ -6,4 +6,2 @@ "use strict";

const token_contract_service_1 = require("./token-contract-service");
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
class AccountTracker {

@@ -23,10 +21,5 @@ constructor({ infuraCreds }) {

this.debounceTimeSec = debounceTimeSec > 0.1 ? debounceTimeSec : 1;
//console.log('ethTracker.config: ', JSON.stringify(arguments));
if (accounts && accounts.length) {
if (this.isRunning) {
this.stop();
this.start();
}
else {
this.start();
}
this.start();
}

@@ -38,15 +31,20 @@ else if (this.isRunning) {

start() {
if (this.provider) {
this.subscription.unsubscribe();
if (this.isRunning) {
this.stop();
}
this.provider = new ethers_1.ethers.providers.InfuraProvider(this.chainId, this.infuraProjectId);
this.subscription = rxjs_1.fromEvent(this.provider, 'block')
.pipe(
// @ts-ignore
operators_1.debounceTime(this.debounceTimeSec * 1000), operators_1.distinctUntilChanged())
.subscribe(num => {
console.log('New Block: ' + num);
this.getTokenBalances();
});
this.getTokenBalances();
this.isRunning = true;
this.runInterval();
// this.subscription = fromEvent(this.provider, 'block')
// .pipe(
// // @ts-ignore
// debounceTime(this.debounceTimeSec * 1000),
// distinctUntilChanged()
// )
// .subscribe(num => {
// console.log('New Block: ' + num);
// this.getTokenBalances();
// });
//
// this.getTokenBalances();
// this.provider.on('block', blockNumber => {

@@ -57,8 +55,22 @@ // console.log('New Block: ' + blockNumber);

// });
this.isRunning = true;
}
async runInterval() {
try {
const block = await this.provider.getBlockNumber();
if (this.lastBlock !== block) {
await this.getTokenBalances();
this.lastBlock = block;
}
this.timeoutId = setTimeout(() => this.runInterval(), this.debounceTimeSec * 1000);
}
catch (e) {
//Wait 30 seconds
this.timeoutId = setTimeout(() => this.runInterval(), 30 * 1000);
}
}
stop() {
// this.provider.off('block');
this.subscription.unsubscribe();
this.subscription = null;
// this.subscription.unsubscribe();
// this.subscription = null;
clearTimeout(this.timeoutId);
this.isRunning = false;

@@ -65,0 +77,0 @@ this.provider = null;

import { ethers } from 'ethers';
import { tokenContractService } from './token-contract-service';
import { fromEvent } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
export class AccountTracker {

@@ -19,10 +17,5 @@ constructor({ infuraCreds }) {

this.debounceTimeSec = debounceTimeSec > 0.1 ? debounceTimeSec : 1;
//console.log('ethTracker.config: ', JSON.stringify(arguments));
if (accounts && accounts.length) {
if (this.isRunning) {
this.stop();
this.start();
}
else {
this.start();
}
this.start();
}

@@ -34,15 +27,20 @@ else if (this.isRunning) {

start() {
if (this.provider) {
this.subscription.unsubscribe();
if (this.isRunning) {
this.stop();
}
this.provider = new ethers.providers.InfuraProvider(this.chainId, this.infuraProjectId);
this.subscription = fromEvent(this.provider, 'block')
.pipe(
// @ts-ignore
debounceTime(this.debounceTimeSec * 1000), distinctUntilChanged())
.subscribe(num => {
console.log('New Block: ' + num);
this.getTokenBalances();
});
this.getTokenBalances();
this.isRunning = true;
this.runInterval();
// this.subscription = fromEvent(this.provider, 'block')
// .pipe(
// // @ts-ignore
// debounceTime(this.debounceTimeSec * 1000),
// distinctUntilChanged()
// )
// .subscribe(num => {
// console.log('New Block: ' + num);
// this.getTokenBalances();
// });
//
// this.getTokenBalances();
// this.provider.on('block', blockNumber => {

@@ -53,8 +51,22 @@ // console.log('New Block: ' + blockNumber);

// });
this.isRunning = true;
}
async runInterval() {
try {
const block = await this.provider.getBlockNumber();
if (this.lastBlock !== block) {
await this.getTokenBalances();
this.lastBlock = block;
}
this.timeoutId = setTimeout(() => this.runInterval(), this.debounceTimeSec * 1000);
}
catch (e) {
//Wait 30 seconds
this.timeoutId = setTimeout(() => this.runInterval(), 30 * 1000);
}
}
stop() {
// this.provider.off('block');
this.subscription.unsubscribe();
this.subscription = null;
// this.subscription.unsubscribe();
// this.subscription = null;
clearTimeout(this.timeoutId);
this.isRunning = false;

@@ -61,0 +73,0 @@ this.provider = null;

{
"name": "@stardust-collective/dag4-xchain-ethereum",
"version": "0.1.12",
"version": "0.1.13",
"description": "Cross chain communication with Ethereum",

@@ -5,0 +5,0 @@ "author": "Frank Fox",

@@ -10,3 +10,4 @@ export declare class AccountTracker {

private debounceTimeSec;
private subscription;
private timeoutId;
private lastBlock;
constructor({ infuraCreds }: {

@@ -17,2 +18,3 @@ infuraCreds: any;

private start;
private runInterval;
private stop;

@@ -19,0 +21,0 @@ private getTokenBalances;

Sorry, the diff of this file is not supported yet

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