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

arweave-uploader

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arweave-uploader - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

ar-uploader.log

82

dist/uploader.js

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

var arweave_1 = __importDefault(require("arweave"));
var axios_1 = __importDefault(require("axios"));
var logger_1 = require("./utils/logger");

@@ -51,6 +52,22 @@ var utils_1 = require("./utils/utils");

});
var getFullStatus = function (txid) { return __awaiter(void 0, void 0, void 0, function () {
var _a, _b, e_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_c.trys.push([0, 2, , 3]);
_b = (_a = JSON).stringify;
return [4, axios_1.default.get("https://arweave.net/tx/" + txid + "/status")];
case 1: return [2, _b.apply(_a, [(_c.sent()).data])];
case 2:
e_1 = _c.sent();
return [2, JSON.stringify(e_1)];
case 3: return [2];
}
});
}); };
var upload = function (tx, wallet, userReference) { return __awaiter(void 0, void 0, void 0, function () {
var uRef, tStart, status, wait, err_1, fullStatus_1, _a, _b, now, err_2, tries, err_3, fullStatus, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
var uRef, tStart, status, wait, err_1, fullStatus_1, now, err_2, tries, err_3, fullStatus;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:

@@ -63,13 +80,13 @@ uRef = '';

case 1:
_e.sent();
_a.sent();
logger_1.logger(uRef, 'New txid', tx.id);
return [4, arweave.transactions.post(tx)];
case 2:
_e.sent();
_a.sent();
tStart = new Date().valueOf();
return [4, utils_1.getStatus(tx.id)];
case 3:
status = _e.sent();
status = _a.sent();
wait = 24;
_e.label = 4;
_a.label = 4;
case 4:

@@ -80,12 +97,12 @@ if (!((status === 404 || status === 410) && wait--)) return [3, 10];

case 5:
_e.sent();
_e.label = 6;
_a.sent();
_a.label = 6;
case 6:
_e.trys.push([6, 8, , 9]);
_a.trys.push([6, 8, , 9]);
return [4, utils_1.getStatus(tx.id)];
case 7:
status = _e.sent();
status = _a.sent();
return [3, 9];
case 8:
err_1 = _e.sent();
err_1 = _a.sent();
logger_1.logger(uRef, 'Network error getting status. Ignoring & waiting...', status);

@@ -98,7 +115,6 @@ wait++;

if (!(status === 400 || status === 404 || status === 410)) return [3, 12];
_b = (_a = JSON).stringify;
return [4, arweave.transactions.getStatus(tx.id)];
return [4, getFullStatus(tx.id)];
case 11:
fullStatus_1 = _b.apply(_a, [_e.sent()]);
logger_1.logger(uRef, 'Possible invalid transaction detected. Status ' + status, 'Throwing error');
fullStatus_1 = _a.sent();
logger_1.logger(uRef, 'Possible invalid transaction detected. Status ' + status, '\n' + fullStatus_1, '\nThrowing error');
throw new Error('Possible invalid transaction detected. Status '

@@ -113,12 +129,12 @@ + status + ':'

case 13:
_e.sent();
_e.label = 14;
_a.sent();
_a.label = 14;
case 14:
_e.trys.push([14, 16, , 17]);
_a.trys.push([14, 16, , 17]);
return [4, utils_1.getStatus(tx.id)];
case 15:
status = _e.sent();
status = _a.sent();
return [3, 17];
case 16:
err_2 = _e.sent();
err_2 = _a.sent();
logger_1.logger(uRef, 'Network error retrieving status.', status, 'Continuing...');

@@ -136,16 +152,16 @@ status = 202;

tries = 12;
_e.label = 19;
_a.label = 19;
case 19: return [4, utils_1.sleep(40000)];
case 20:
_e.sent();
_e.label = 21;
_a.sent();
_a.label = 21;
case 21:
_e.trys.push([21, 23, , 24]);
_a.trys.push([21, 23, , 24]);
return [4, utils_1.getStatus(tx.id)];
case 22:
status = _e.sent();
status = _a.sent();
logger_1.logger(uRef, 'tries', tries, 'status', status);
return [3, 24];
case 23:
err_3 = _e.sent();
err_3 = _a.sent();
logger_1.logger(uRef, 'Network error getting status. Ignoring & waiting...', status);

@@ -160,15 +176,13 @@ tries++;

}
_e.label = 25;
_a.label = 25;
case 25:
if (--tries) return [3, 19];
_e.label = 26;
case 26:
_d = (_c = JSON).stringify;
return [4, arweave.transactions.getStatus(tx.id)];
_a.label = 26;
case 26: return [4, getFullStatus(tx.id)];
case 27:
fullStatus = _d.apply(_c, [_e.sent()]);
fullStatus = _a.sent();
logger_1.logger(uRef, 'Possible failure. Status ', status, '. Retrying post tx. Full error:\n', fullStatus);
tx.addTag('Retry', (new Date().valueOf() / 1000).toString());
return [4, exports.upload(tx, wallet)];
case 28: return [2, _e.sent()];
case 28: return [2, _a.sent()];
}

@@ -175,0 +189,0 @@ });

export declare const setDebugMessagesOn: (b: boolean) => boolean;
export declare const useLogfile: (b: boolean) => boolean;
export declare const logger: (...args: any[]) => void;

@@ -13,7 +13,15 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = exports.setDebugMessagesOn = void 0;
exports.logger = exports.useLogfile = exports.setDebugMessagesOn = void 0;
var ansi_colors_1 = __importDefault(require("ansi-colors"));
var os_1 = require("os");
var appendFile;
if (typeof window === 'undefined') {
appendFile = require('fs').appendFile;
}
var DEBUG_MESSAGES = true;
var setDebugMessagesOn = function (b) { return DEBUG_MESSAGES = b; };
exports.setDebugMessagesOn = setDebugMessagesOn;
var LOGFILE = true;
var useLogfile = function (b) { return LOGFILE = b; };
exports.useLogfile = useLogfile;
var logger = function () {

@@ -32,4 +40,7 @@ var args = [];

}
if (LOGFILE && typeof window === 'undefined') {
appendFile('ar-uploader.log', '\"' + new Date().toUTCString() + '\",' + args.join(',') + os_1.EOL, function () { });
}
};
exports.logger = logger;
//# sourceMappingURL=logger.js.map
{
"name": "arweave-uploader",
"version": "1.1.6",
"version": "1.1.7",
"description": "",

@@ -34,4 +34,5 @@ "main": "dist/index.js",

"ansi-colors": "^4.1.1",
"arweave": "^1.10.13"
"arweave": "^1.10.13",
"axios": "^0.21.1"
}
}

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