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

@ckb-lumos/ckb-indexer

Package Overview
Dependencies
Maintainers
3
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckb-lumos/ckb-indexer - npm Package Compare versions

Comparing version 0.0.0-canary-54f8aff-20230815035108 to 0.0.0-canary-58ff5e4-20240712061301

11

lib/indexer.js

@@ -17,5 +17,2 @@ "use strict";

var _ckbIndexerFilter = require("./ckbIndexerFilter");
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
const DefaultTerminator = () => {

@@ -33,6 +30,7 @@ return {

class CkbIndexer {
static version = "0.4.1";
medianTimeEmitters = [];
emitters = [];
isSubscribeRunning = false;
constructor(ckbIndexerUrl, ckbRpcUrl) {
_defineProperty(this, "medianTimeEmitters", []);
_defineProperty(this, "emitters", []);
_defineProperty(this, "isSubscribeRunning", false);
this.ckbIndexerUrl = ckbIndexerUrl;

@@ -270,3 +268,2 @@ this.ckbRpcUrl = ckbRpcUrl;

exports.CkbIndexer = CkbIndexer;
_defineProperty(CkbIndexer, "version", "0.4.1");
class TerminableCellAdapter {

@@ -273,0 +270,0 @@ constructor(getCellsableRpc) {

@@ -1,2 +0,2 @@

import { HexString, HexNumber, Hash, Hexadecimal } from "@ckb-lumos/base";
import { HexString, HexNumber, Hash, Hexadecimal, HashType } from "@ckb-lumos/base";
export type Tip = {

@@ -8,3 +8,3 @@ block_hash: HexNumber;

code_hash: HexString;
hash_type: "type" | "data" | "data1";
hash_type: HashType;
args: HexString;

@@ -11,0 +11,0 @@ };

@@ -10,73 +10,9 @@ "use strict";

var services = _interopRequireWildcard(require("./services"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
class CKBIndexerTransactionCollector extends _base.indexer.TransactionCollector {
constructor(indexer, _queries, CKBRpcUrl, options) {
super(indexer, _queries, options);
_defineProperty(this, "getTransactionListFromRpc", async indexerTransactionList => {
const getDetailRequestData = indexerTransactionList.objects.map(hashItem => {
return hashItem.txHash;
});
const transactionList = await services.requestBatchTransactionWithStatus(this.CKBRpcUrl, getDetailRequestData).then(response => {
return response.map((item, index) => {
if (!this.filterOptions.skipMissing && !item.transaction) {
throw new Error(`Transaction ${indexerTransactionList.objects[index].txHash} is missing!`);
}
return item;
});
});
return transactionList;
});
_defineProperty(this, "isLockArgsLenMatched", (args, argsLen) => {
if (!argsLen) return true;
if (argsLen === "any") return true;
if (argsLen === -1) return true;
return services.getHexStringBytes(args) === argsLen;
});
// only valid after pass flow three validate
_defineProperty(this, "isCellScriptArgsValid", targetCell => {
if (this.queries.lock) {
const lockArgsLen = (0, _ckbIndexerFilter.instanceOfScriptWrapper)(this.queries.lock) ? this.queries.lock.argsLen : this.queries.argsLen;
if (!this.isLockArgsLenMatched(targetCell.lock.args, lockArgsLen)) {
return false;
}
}
if (this.queries.type && this.queries.type !== "empty") {
var _targetCell$type;
const typeArgsLen = (0, _ckbIndexerFilter.instanceOfScriptWrapper)(this.queries.type) ? this.queries.type.argsLen : this.queries.argsLen;
if (!this.isLockArgsLenMatched((_targetCell$type = targetCell.type) === null || _targetCell$type === void 0 ? void 0 : _targetCell$type.args, typeArgsLen)) {
return false;
}
}
if (this.queries.type && this.queries.type === "empty") {
if (targetCell.type) {
return false;
}
}
return true;
});
_defineProperty(this, "filterByIoType", (inputResult, ioType) => {
if (ioType === "both") {
return inputResult;
}
if (ioType === "input" || ioType === "output") {
return inputResult.filter(item => item.ioType === ioType || item.ioType === "both");
}
return inputResult;
});
_defineProperty(this, "filterByTypeIoTypeAndLockIoType", (inputResult, queries) => {
let result = inputResult;
if ((0, _ckbIndexerFilter.instanceOfScriptWrapper)(queries.lock) && queries.lock.ioType) {
result = this.filterByIoType(result, queries.lock.ioType);
}
if ((0, _ckbIndexerFilter.instanceOfScriptWrapper)(queries.type) && queries.type.ioType) {
result = this.filterByIoType(result, queries.type.ioType);
}
return result;
});
constructor(indexer, queries, CKBRpcUrl, options) {
super(indexer, queries, options);
this.indexer = indexer;
this.queries = _queries;
this.queries = queries;
this.CKBRpcUrl = CKBRpcUrl;

@@ -172,3 +108,7 @@ this.options = options;

transaction: tx.transaction,
txStatus: tx.txStatus
txStatus: tx.txStatus,
cycles: tx.cycles,
timeAddedToPool: tx.timeAddedToPool,
minReplaceFee: tx.minReplaceFee,
fee: tx.fee
}));

@@ -254,2 +194,64 @@ return objects;

}
getTransactionListFromRpc = async indexerTransactionList => {
const getDetailRequestData = indexerTransactionList.objects.map(hashItem => {
return hashItem.txHash;
});
const transactionList = await services.requestBatchTransactionWithStatus(this.CKBRpcUrl, getDetailRequestData).then(response => {
return response.map((item, index) => {
if (!this.filterOptions.skipMissing && !item.transaction) {
throw new Error(`Transaction ${indexerTransactionList.objects[index].txHash} is missing!`);
}
return item;
});
});
return transactionList;
};
isLockArgsLenMatched = (args, argsLen) => {
if (!argsLen) return true;
if (argsLen === "any") return true;
if (argsLen === -1) return true;
return services.getHexStringBytes(args) === argsLen;
};
// only valid after pass flow three validate
isCellScriptArgsValid = targetCell => {
if (this.queries.lock) {
const lockArgsLen = (0, _ckbIndexerFilter.instanceOfScriptWrapper)(this.queries.lock) ? this.queries.lock.argsLen : this.queries.argsLen;
if (!this.isLockArgsLenMatched(targetCell.lock.args, lockArgsLen)) {
return false;
}
}
if (this.queries.type && this.queries.type !== "empty") {
var _targetCell$type;
const typeArgsLen = (0, _ckbIndexerFilter.instanceOfScriptWrapper)(this.queries.type) ? this.queries.type.argsLen : this.queries.argsLen;
if (!this.isLockArgsLenMatched((_targetCell$type = targetCell.type) === null || _targetCell$type === void 0 ? void 0 : _targetCell$type.args, typeArgsLen)) {
return false;
}
}
if (this.queries.type && this.queries.type === "empty") {
if (targetCell.type) {
return false;
}
}
return true;
};
filterByIoType = (inputResult, ioType) => {
if (ioType === "both") {
return inputResult;
}
if (ioType === "input" || ioType === "output") {
return inputResult.filter(item => item.ioType === ioType || item.ioType === "both");
}
return inputResult;
};
filterByTypeIoTypeAndLockIoType = (inputResult, queries) => {
let result = inputResult;
if ((0, _ckbIndexerFilter.instanceOfScriptWrapper)(queries.lock) && queries.lock.ioType) {
result = this.filterByIoType(result, queries.lock.ioType);
}
if ((0, _ckbIndexerFilter.instanceOfScriptWrapper)(queries.type) && queries.type.ioType) {
result = this.filterByIoType(result, queries.type.ioType);
}
return result;
};
async count() {

@@ -256,0 +258,0 @@ let lastCursor = undefined;

{
"name": "@ckb-lumos/ckb-indexer",
"version": "0.0.0-canary-54f8aff-20230815035108",
"version": "0.0.0-canary-58ff5e4-20240712061301",
"description": "CKB Indexer",

@@ -22,7 +22,7 @@ "author": "Xuejie Xiao <xxuejie@gmail.com>",

"dependencies": {
"@ckb-lumos/base": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/bi": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/codec": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/rpc": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/toolkit": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/base": "0.0.0-canary-58ff5e4-20240712061301",
"@ckb-lumos/bi": "0.0.0-canary-58ff5e4-20240712061301",
"@ckb-lumos/codec": "0.0.0-canary-58ff5e4-20240712061301",
"@ckb-lumos/rpc": "0.0.0-canary-58ff5e4-20240712061301",
"@ckb-lumos/toolkit": "0.0.0-canary-58ff5e4-20240712061301",
"cross-fetch": "^3.1.5",

@@ -32,3 +32,4 @@ "events": "^3.3.0"

"devDependencies": {
"@ckb-lumos/testkit": "0.0.0-canary-54f8aff-20230815035108",
"@ckb-lumos/crypto": "0.0.0-canary-58ff5e4-20240712061301",
"@ckb-lumos/testkit": "0.0.0-canary-58ff5e4-20240712061301",
"@types/lodash.uniqby": "^4.7.7",

@@ -35,0 +36,0 @@ "@types/request": "^2.48.8",

@@ -1,2 +0,8 @@

import { HexString, HexNumber, Hash, Hexadecimal } from "@ckb-lumos/base";
import {
HexString,
HexNumber,
Hash,
Hexadecimal,
HashType,
} from "@ckb-lumos/base";

@@ -9,3 +15,3 @@ export type Tip = {

code_hash: HexString;
hash_type: "type" | "data" | "data1";
hash_type: HashType;
args: HexString;

@@ -12,0 +18,0 @@ };

@@ -176,6 +176,12 @@ import {

);
const objects = filteredTransactionList.map((tx) => ({
transaction: tx.transaction,
txStatus: tx.txStatus,
}));
const objects = filteredTransactionList.map<TransactionWithStatus>(
(tx) => ({
transaction: tx.transaction,
txStatus: tx.txStatus,
cycles: tx.cycles,
timeAddedToPool: tx.timeAddedToPool,
minReplaceFee: tx.minReplaceFee,
fee: tx.fee,
})
);
return objects;

@@ -182,0 +188,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

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

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

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