New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

banano-nft-crawler

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

banano-nft-crawler - npm Package Compare versions

Comparing version 1.1.10 to 1.1.11

2

dist/asset-crawler-states/asset/receivable.js

@@ -55,3 +55,3 @@ "use strict";

recipient = assetCrawler.frontier.owner;
return [4 /*yield*/, (0, find_receive_block_1.findReceiveBlock)(nanoNode, sender, sendBlockHash, recipient)];
return [4 /*yield*/, (0, find_receive_block_1.findReceiveBlock)(nanoNode, sender, sendBlockHash, recipient).catch(function (error) { throw (error); })];
case 1:

@@ -58,0 +58,0 @@ _a = _b.sent(), success = _a.success, block = _a.block;

@@ -53,5 +53,5 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var payingAccount, paymentHeight, _a, previousBlock, nextBlock, sendAtomicSwap, atomicSwapConditions, originalOwner, type;
return __generator(this, function (_b) {
switch (_b.label) {
var payingAccount, paymentHeight, prevAndNextBlock, previousBlock, nextBlock, sendAtomicSwap, atomicSwapConditions, originalOwner, type;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:

@@ -62,3 +62,9 @@ payingAccount = assetCrawler.frontier.account;

case 1:
_a = _b.sent(), previousBlock = _a[0], nextBlock = _a[1];
prevAndNextBlock = _a.sent();
// Guard. Should not happen since this point shouldn't be reached for unopened accounts given
// the users followed client protocol and checked that the account was opened before initiating a swap.
if (prevAndNextBlock == undefined) {
return [2 /*return*/, false];
}
previousBlock = prevAndNextBlock[0], nextBlock = prevAndNextBlock[1];
sendAtomicSwap = assetCrawler.findSendAtomicSwapBlock();

@@ -65,0 +71,0 @@ // guards

@@ -45,3 +45,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var sendAtomicSwap, sendAtomicSwapHash, representative, atomicSwapConditions, payerAccount, originalOwner, blocks, previousBlock, receiveBlock, isReceive, receivesAtomicSwap, hasCorrectHeight, representativeUnchanged;
var sendAtomicSwap, sendAtomicSwapHash, representative, atomicSwapConditions, payerAccount, originalOwner, prevAndNextBlock, previousBlock, receiveBlock, isReceive, receivesAtomicSwap, hasCorrectHeight, representativeUnchanged;
return __generator(this, function (_a) {

@@ -62,6 +62,10 @@ switch (_a.label) {

assetCrawler.traceLength += BigInt(1);
return [4 /*yield*/, (0, find_block_at_height_and_previous_block_1.findBlockAtHeightAndPreviousBlock)(nanoNode, payerAccount, atomicSwapConditions.receiveHeight)];
return [4 /*yield*/, (0, find_block_at_height_and_previous_block_1.findBlockAtHeightAndPreviousBlock)(nanoNode, payerAccount, atomicSwapConditions.receiveHeight).catch(function (error) { throw (error); })];
case 1:
blocks = _a.sent();
previousBlock = blocks[0], receiveBlock = blocks[1];
prevAndNextBlock = _a.sent();
// guard
if (prevAndNextBlock == undefined) {
return [2 /*return*/, false];
}
previousBlock = prevAndNextBlock[0], receiveBlock = prevAndNextBlock[1];
if (previousBlock === undefined) {

@@ -68,0 +72,0 @@ return [2 /*return*/, false];

@@ -51,22 +51,27 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var nanoBackwardIterable, previousHeight, previousBlock, block, nanoBackwardIterable_1, nanoBackwardIterable_1_1, _block, _height, e_1_1, error_1;
var previousHeight, previousBlock, block, nanoBackwardIterable, nanoBackwardIterable_1, nanoBackwardIterable_1_1, _block, _height, e_1_1, error_1, error_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 14, , 15]);
nanoBackwardIterable = new nano_account_backward_crawler_1.NanoAccountBackwardCrawler(nanoNode, account);
return [4 /*yield*/, nanoBackwardIterable.initialize()];
case 1:
_b.sent();
previousHeight = height - BigInt(1);
previousBlock = undefined;
block = undefined;
_b.label = 1;
case 1:
_b.trys.push([1, 18, , 19]);
nanoBackwardIterable = new nano_account_backward_crawler_1.NanoAccountBackwardCrawler(nanoNode, account);
_b.label = 2;
case 2:
_b.trys.push([2, 7, 8, 13]);
_b.trys.push([2, 16, , 17]);
return [4 /*yield*/, nanoBackwardIterable.initialize().catch(function (error) { throw (error); })];
case 3:
_b.sent();
_b.label = 4;
case 4:
_b.trys.push([4, 9, 10, 15]);
nanoBackwardIterable_1 = __asyncValues(nanoBackwardIterable);
_b.label = 3;
case 3: return [4 /*yield*/, nanoBackwardIterable_1.next()];
case 4:
if (!(nanoBackwardIterable_1_1 = _b.sent(), !nanoBackwardIterable_1_1.done)) return [3 /*break*/, 6];
_b.label = 5;
case 5: return [4 /*yield*/, nanoBackwardIterable_1.next()];
case 6:
if (!(nanoBackwardIterable_1_1 = _b.sent(), !nanoBackwardIterable_1_1.done)) return [3 /*break*/, 8];
_block = nanoBackwardIterable_1_1.value;

@@ -81,28 +86,38 @@ _height = BigInt(_block.height);

else if (_height < previousHeight) {
return [3 /*break*/, 6];
return [3 /*break*/, 8];
}
_b.label = 5;
case 5: return [3 /*break*/, 3];
case 6: return [3 /*break*/, 13];
case 7:
_b.label = 7;
case 7: return [3 /*break*/, 5];
case 8: return [3 /*break*/, 15];
case 9:
e_1_1 = _b.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 13];
case 8:
_b.trys.push([8, , 11, 12]);
if (!(nanoBackwardIterable_1_1 && !nanoBackwardIterable_1_1.done && (_a = nanoBackwardIterable_1.return))) return [3 /*break*/, 10];
return [3 /*break*/, 15];
case 10:
_b.trys.push([10, , 13, 14]);
if (!(nanoBackwardIterable_1_1 && !nanoBackwardIterable_1_1.done && (_a = nanoBackwardIterable_1.return))) return [3 /*break*/, 12];
return [4 /*yield*/, _a.call(nanoBackwardIterable_1)];
case 9:
case 11:
_b.sent();
_b.label = 10;
case 10: return [3 /*break*/, 12];
case 11:
_b.label = 12;
case 12: return [3 /*break*/, 14];
case 13:
if (e_1) throw e_1.error;
return [7 /*endfinally*/];
case 12: return [7 /*endfinally*/];
case 13: return [2 /*return*/, [previousBlock, block]];
case 14:
case 14: return [7 /*endfinally*/];
case 15: return [3 /*break*/, 17];
case 16:
error_1 = _b.sent();
throw (error_1);
case 15: return [2 /*return*/];
if (error_1.message.match(/^NanoNodeError:/)) {
return [2 /*return*/, undefined];
}
else {
throw (error_1);
}
return [3 /*break*/, 17];
case 17: return [2 /*return*/, [previousBlock, block]];
case 18:
error_2 = _b.sent();
throw (error_2);
case 19: return [2 /*return*/];
}

@@ -109,0 +124,0 @@ });

{
"name": "banano-nft-crawler",
"version": "1.1.10",
"version": "1.1.11",
"description": "Library for crawling across the Banano ledger to trace NFTs.",

@@ -14,3 +14,4 @@ "files": [

"testMintBlocksCrawler": "mocha --require ts-node/register ./test/mint-blocks-crawler.spec.ts",
"testAssetCrawler": "mocha --require ts-node/register ./test/asset-crawler.spec.ts"
"testAssetCrawler": "mocha --require ts-node/register ./test/asset-crawler.spec.ts",
"testFindReceiveBlock": "mocha --require ts-node/register ./test/find-receive-block.spec.ts"
},

@@ -17,0 +18,0 @@ "author": "Airtune",

@@ -18,3 +18,3 @@ import { findReceiveBlock } from "../../lib/find-receive-block";

const recipient = assetCrawler.frontier.owner;
const { success, block } = await findReceiveBlock(nanoNode, sender, sendBlockHash, recipient);
const { success, block } = await findReceiveBlock(nanoNode, sender, sendBlockHash, recipient).catch((error) => { throw(error); });
// guards

@@ -21,0 +21,0 @@ if (typeof block === 'undefined') { return false; }

@@ -27,3 +27,9 @@ import { INanoBlock, TAccount } from "nano-account-crawler/dist/nano-interfaces";

const paymentHeight = BigInt(assetCrawler.frontier.block_height) + BigInt(1);
const [previousBlock, nextBlock]: [INanoBlock, INanoBlock] = await findBlockAtHeightAndPreviousBlock(nanoNode, payingAccount, paymentHeight);
const prevAndNextBlock = await findBlockAtHeightAndPreviousBlock(nanoNode, payingAccount, paymentHeight);
// Guard. Should not happen since this point shouldn't be reached for unopened accounts given
// the users followed client protocol and checked that the account was opened before initiating a swap.
if (prevAndNextBlock == undefined) {
return false;
}
const [previousBlock, nextBlock]: [INanoBlock, INanoBlock] = prevAndNextBlock;
const sendAtomicSwap: IAssetBlock = assetCrawler.findSendAtomicSwapBlock();

@@ -30,0 +36,0 @@ // guards

@@ -25,4 +25,8 @@ import { AssetCrawler } from "../../asset-crawler";

assetCrawler.traceLength += BigInt(1);
const blocks = await findBlockAtHeightAndPreviousBlock(nanoNode, payerAccount, atomicSwapConditions.receiveHeight);
const [previousBlock, receiveBlock] = blocks;
const prevAndNextBlock = await findBlockAtHeightAndPreviousBlock(nanoNode, payerAccount, atomicSwapConditions.receiveHeight).catch((error) => { throw(error); });
// guard
if (prevAndNextBlock == undefined) {
return false;
}
const [previousBlock, receiveBlock] = prevAndNextBlock;

@@ -29,0 +33,0 @@ if (previousBlock === undefined) { return false; }

@@ -6,20 +6,27 @@ import { NanoAccountBackwardCrawler } from "nano-account-crawler/dist/nano-account-backward-crawler";

export async function findBlockAtHeightAndPreviousBlock(nanoNode: NanoNode, account: TAccount, height: bigint): Promise<([INanoBlock, INanoBlock]|undefined)> {
const previousHeight = height - BigInt(1)
let previousBlock: INanoBlock = undefined;
let block: INanoBlock = undefined;
try {
const nanoBackwardIterable = new NanoAccountBackwardCrawler(nanoNode, account);
await nanoBackwardIterable.initialize();
try {
await nanoBackwardIterable.initialize().catch((error) => { throw(error); });
const previousHeight = height - BigInt(1)
let previousBlock: INanoBlock = undefined;
let block: INanoBlock = undefined;
for await (const _block of nanoBackwardIterable) {
let _height = BigInt(_block.height);
if (_height === height) {
block = _block;
} else if (_height === previousHeight) {
previousBlock = _block;
} else if (_height < previousHeight) {
break;
for await (const _block of nanoBackwardIterable) {
let _height = BigInt(_block.height);
if (_height === height) {
block = _block;
} else if (_height === previousHeight) {
previousBlock = _block;
} else if (_height < previousHeight) {
break;
}
}
} catch (error) {
if (error.message.match(/^NanoNodeError:/)) {
return undefined;
} else {
throw(error);
}
}

@@ -26,0 +33,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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