@ckb-lumos/ckb-indexer
Advanced tools
Comparing version 0.0.0-canary-ad483d9-20240125131247 to 0.0.0-canary-ae45845-20240806053619
@@ -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) { |
@@ -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; | ||
@@ -174,3 +110,5 @@ this.options = options; | ||
cycles: tx.cycles, | ||
timeAddedToPool: tx.timeAddedToPool | ||
timeAddedToPool: tx.timeAddedToPool, | ||
minReplaceFee: tx.minReplaceFee, | ||
fee: tx.fee | ||
})); | ||
@@ -256,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() { | ||
@@ -258,0 +258,0 @@ let lastCursor = undefined; |
{ | ||
"name": "@ckb-lumos/ckb-indexer", | ||
"version": "0.0.0-canary-ad483d9-20240125131247", | ||
"version": "0.0.0-canary-ae45845-20240806053619", | ||
"description": "CKB Indexer", | ||
@@ -22,7 +22,7 @@ "author": "Xuejie Xiao <xxuejie@gmail.com>", | ||
"dependencies": { | ||
"@ckb-lumos/base": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/bi": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/codec": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/rpc": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/base": "0.0.0-canary-ae45845-20240806053619", | ||
"@ckb-lumos/bi": "0.0.0-canary-ae45845-20240806053619", | ||
"@ckb-lumos/codec": "0.0.0-canary-ae45845-20240806053619", | ||
"@ckb-lumos/rpc": "0.0.0-canary-ae45845-20240806053619", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-ae45845-20240806053619", | ||
"cross-fetch": "^3.1.5", | ||
@@ -32,3 +32,4 @@ "events": "^3.3.0" | ||
"devDependencies": { | ||
"@ckb-lumos/testkit": "0.0.0-canary-ad483d9-20240125131247", | ||
"@ckb-lumos/crypto": "0.0.0-canary-ae45845-20240806053619", | ||
"@ckb-lumos/testkit": "0.0.0-canary-ae45845-20240806053619", | ||
"@types/lodash.uniqby": "^4.7.7", | ||
@@ -35,0 +36,0 @@ "@types/request": "^2.48.8", |
@@ -182,2 +182,4 @@ import { | ||
timeAddedToPool: tx.timeAddedToPool, | ||
minReplaceFee: tx.minReplaceFee, | ||
fee: tx.fee, | ||
}) | ||
@@ -184,0 +186,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
286995
9
3834
+ Added@ckb-lumos/base@0.0.0-canary-ae45845-20240806053619(transitive)
+ Added@ckb-lumos/bi@0.0.0-canary-ae45845-20240806053619(transitive)
+ Added@ckb-lumos/codec@0.0.0-canary-ae45845-20240806053619(transitive)
+ Added@ckb-lumos/rpc@0.0.0-canary-ae45845-20240806053619(transitive)
+ Added@ckb-lumos/toolkit@0.0.0-canary-ae45845-20240806053619(transitive)
- Removed@ckb-lumos/base@0.0.0-canary-ad483d9-20240125131247(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-ad483d9-20240125131247(transitive)
- Removed@ckb-lumos/codec@0.0.0-canary-ad483d9-20240125131247(transitive)
- Removed@ckb-lumos/rpc@0.0.0-canary-ad483d9-20240125131247(transitive)
- Removed@ckb-lumos/toolkit@0.0.0-canary-ad483d9-20240125131247(transitive)
- Removedlodash.isequal@4.5.0(transitive)
Updated@ckb-lumos/toolkit@0.0.0-canary-ae45845-20240806053619