@bloks/utils
Advanced tools
Comparing version 27.6.0 to 27.7.0
@@ -0,1 +1,3 @@ | ||
import { ApiInterfaces, RpcInterfaces } from '@proton/js'; | ||
declare function cloneDeepArrayOfObj(array: Array<object>): {}[]; | ||
@@ -256,2 +258,39 @@ | ||
declare type ActionTraceWithReceivers = ApiInterfaces.ActionTrace & { | ||
receivers: string[]; | ||
}; | ||
declare type MinimalTrace = { | ||
act: RpcInterfaces.ProcessedAction; | ||
account_ram_deltas: ApiInterfaces.AccountDelta[]; | ||
receivers: string[]; | ||
act_digest: string; | ||
traces: MinimalTrace[]; | ||
}; | ||
interface TransformedTransaction { | ||
status: string; | ||
cpu_usage: number; | ||
net_usage: number; | ||
id: string; | ||
block_time: Date; | ||
block_num: number; | ||
transaction_extensions: any[]; | ||
delay_sec: string | number; | ||
expiration: string | Date; | ||
actions: ApiInterfaces.ActionTrace[]; | ||
traces: MinimalTrace[]; | ||
context_free_actions?: RpcInterfaces.ProcessedAction[]; | ||
context_free_data?: Uint8Array[]; | ||
max_cpu_usage_ms?: number; | ||
max_net_usage_words?: number; | ||
ref_block_num?: number; | ||
ref_block_prefix?: number; | ||
signatures: string[]; | ||
cpu_usage_us: number; | ||
net_usage_words: number; | ||
trx: [number, RpcInterfaces.PackedTrx]; | ||
head_block_num: number; | ||
irreversible: boolean; | ||
last_irreversible_block: number; | ||
transaction_num: number; | ||
} | ||
declare function nativeTransformGetActions(result: GetActionsNativeResult, constants: any): GetActionsNativeResult; | ||
@@ -370,11 +409,5 @@ declare function hyperionTransformGetActions({ query_time, lib, actions, total: { relation, value }, }: GetActionsHyperionResult): { | ||
}; | ||
declare function historyTransformRecursiveTrace(action: any): { | ||
act: any; | ||
account_ram_deltas: any; | ||
receivers: any[]; | ||
act_digest: any; | ||
traces: never[]; | ||
}; | ||
declare function historyTransformFlatTraces(traces: any): any[]; | ||
declare function historyTransformTransaction(transaction: any): any; | ||
declare function historyTransformRecursiveTrace(action: ApiInterfaces.ActionTrace): MinimalTrace; | ||
declare function historyTransformFlatTraces(traces: ApiInterfaces.ActionTrace[]): ActionTraceWithReceivers[]; | ||
declare function historyTransformTransaction(transaction: RpcInterfaces.NativeTransaction): TransformedTransaction; | ||
@@ -523,2 +556,2 @@ declare function hexToUint8Array(hex: string): Uint8Array; | ||
export { AccountRAMDelta, Act, Action, ActionData, ActionElement, ActionTrace, AtomicAsset, AtomicAssetsAccountResponse, AtomicAssetsIdResponse, Authorization, Dbop, DbopOp, DfuseAction, ExecutionBlockHeader, ExecutionTrace, ExecutionTraceReceipt, GetActionsDfuseResult, GetActionsHyperionResult, GetActionsNativeResult, Lifecycle, LifecycleTransaction, New, Nft, NftInterface, PurpleData, Ramop, Receipt, SimpleAsset, SimpleAssetsAccountResponse, Tableop, Total, TransactionElement, bytesToString, charidx, cloneDeepArrayOfObj, copy, decodeName, dfuseDepthFirstExtract, dfuseTransformDeferredAction, dfuseTransformDeferredTransaction, dfuseTransformGetActions, dfuseTransformTrace, dfuseTransformTransaction, dfuseTransformTransactionResult, encodeName, fioKeyToActor, hexToUint8Array, historyTransformDeferredAction, historyTransformDeferredTransaction, historyTransformFlatTraces, historyTransformRecursiveTrace, historyTransformTransaction, hyperionTransformFlatTraces, hyperionTransformGetActions, hyperionTransformTransaction, isString, nativeTransformGetActions, parseAaNft, parseSaNft, sha, string_to_uint128_hash, urlBuilder, wait }; | ||
export { AccountRAMDelta, Act, Action, ActionData, ActionElement, ActionTrace, AtomicAsset, AtomicAssetsAccountResponse, AtomicAssetsIdResponse, Authorization, Dbop, DbopOp, DfuseAction, ExecutionBlockHeader, ExecutionTrace, ExecutionTraceReceipt, GetActionsDfuseResult, GetActionsHyperionResult, GetActionsNativeResult, Lifecycle, LifecycleTransaction, New, Nft, NftInterface, PurpleData, Ramop, Receipt, SimpleAsset, SimpleAssetsAccountResponse, Tableop, Total, TransactionElement, TransformedTransaction, bytesToString, charidx, cloneDeepArrayOfObj, copy, decodeName, dfuseDepthFirstExtract, dfuseTransformDeferredAction, dfuseTransformDeferredTransaction, dfuseTransformGetActions, dfuseTransformTrace, dfuseTransformTransaction, dfuseTransformTransactionResult, encodeName, fioKeyToActor, hexToUint8Array, historyTransformDeferredAction, historyTransformDeferredTransaction, historyTransformFlatTraces, historyTransformRecursiveTrace, historyTransformTransaction, hyperionTransformFlatTraces, hyperionTransformGetActions, hyperionTransformTransaction, isString, nativeTransformGetActions, parseAaNft, parseSaNft, sha, string_to_uint128_hash, urlBuilder, wait }; |
@@ -597,5 +597,4 @@ "use strict"; | ||
}, {}); | ||
for (const trace of traces.sort( | ||
(a, b) => b.action_ordinal - a.action_ordinal | ||
)) { | ||
const sortedTraces = traces.sort((a, b) => b.action_ordinal - a.action_ordinal); | ||
for (const trace of sortedTraces) { | ||
if (trace.creator_action_ordinal === 0) { | ||
@@ -610,16 +609,6 @@ continue; | ||
...trace, | ||
receivers: [trace.receipt.receiver], | ||
act_digest: trace.receipt.act_digest | ||
receivers: [trace.receipt.receiver] | ||
})); | ||
return result; | ||
} | ||
function findIfSameTx(inline_traces, act) { | ||
let match = false; | ||
for (const trace of inline_traces) { | ||
if (trace.act.hex_data === act.hex_data && trace.act.name === act.name && trace.act.account === act.account || findIfSameTx(trace.inline_traces, act)) { | ||
return true; | ||
} | ||
} | ||
return match; | ||
} | ||
function inlineTraceCountHelper(traces) { | ||
@@ -631,98 +620,29 @@ return traces.reduce((acc, trace) => { | ||
function historyTransformTransaction(transaction) { | ||
if (transaction.trx) { | ||
let actions = []; | ||
let delay_sec; | ||
let expiration; | ||
let traces; | ||
if (transaction.traces && transaction.traces.length && "creator_action_ordinal" in transaction.traces[0]) { | ||
traces = historyTransformFlatTraces(transaction.traces).map( | ||
historyTransformRecursiveTrace | ||
); | ||
actions = transaction.traces.filter( | ||
(trace) => trace.creator_action_ordinal === 0 | ||
); | ||
} else { | ||
for (const [i, action] of transaction.traces.entries()) { | ||
const tempTraces = transaction.traces.slice(); | ||
tempTraces.splice(i, i + 1); | ||
const foundSameHex = tempTraces.find( | ||
(trace) => findIfSameTx(trace.inline_traces.slice(), action.act) | ||
); | ||
if (!foundSameHex) { | ||
actions.push(action); | ||
} | ||
} | ||
traces = actions.map((action) => historyTransformRecursiveTrace(action)); | ||
if (transaction.traces.length > 0 && actions.length === 0) { | ||
actions = []; | ||
let counter = 0; | ||
let i = 0; | ||
for (const tx2 of transaction.traces) { | ||
if (i >= counter) { | ||
actions.push(tx2); | ||
} | ||
counter += inlineTraceCountHelper(tx2.inline_traces); | ||
i++; | ||
} | ||
traces = actions.map( | ||
(action) => historyTransformRecursiveTrace(action) | ||
); | ||
} | ||
if (transaction.traces.length === 0 && actions.length === 0 && transaction.trx.trx && transaction.trx.trx.actions && transaction.trx.trx.actions.length) { | ||
traces = transaction.trx.trx.actions.map((action) => ({ | ||
act: action, | ||
account_ram_deltas: [], | ||
receivers: action.authorization.map((auth) => auth.actor), | ||
act_digest: "", | ||
traces: [] | ||
})); | ||
actions = traces; | ||
} | ||
} | ||
if (transaction.trx.trx) { | ||
delay_sec = transaction.trx.trx.delay_sec; | ||
expiration = transaction.trx.trx.expiration; | ||
} else { | ||
delay_sec = "N/A"; | ||
expiration = "N/A"; | ||
} | ||
const extraFields = { | ||
...transaction, | ||
...transaction.trx.receipt, | ||
...transaction.trx.trx || {} | ||
}; | ||
let tx = { | ||
...extraFields, | ||
status: transaction.trx.receipt.status, | ||
cpu_usage: transaction.trx.receipt.cpu_usage_us, | ||
net_usage: transaction.trx.receipt.net_usage_words * 8, | ||
id: transaction.id, | ||
block_time: transaction.block_time, | ||
block_num: transaction.block_num, | ||
transaction_extensions: [], | ||
delay_sec, | ||
expiration, | ||
actions, | ||
traces | ||
}; | ||
return tx; | ||
} else if (transaction.action_traces) { | ||
return dfuseTransformTransaction(transaction); | ||
} else { | ||
let traces = transaction.traces.map( | ||
(trace) => historyTransformRecursiveTrace(trace) | ||
); | ||
return { | ||
status: "executed", | ||
cpu_usage: 0, | ||
net_usage: 0, | ||
id: transaction.id, | ||
block_time: transaction.block_time, | ||
block_num: transaction.block_num, | ||
delay_sec: 0, | ||
expiration: 0, | ||
actions: traces, | ||
traces | ||
}; | ||
} | ||
var _a, _b, _c, _d; | ||
const flatTraces = historyTransformFlatTraces(transaction.traces); | ||
const traces = flatTraces.map(historyTransformRecursiveTrace); | ||
const actions = transaction.traces.filter((trace) => trace.creator_action_ordinal === 0); | ||
const delay_sec = ((_b = (_a = transaction.trx) == null ? void 0 : _a.trx) == null ? void 0 : _b.delay_sec) || "N/A"; | ||
const expiration = ((_d = (_c = transaction.trx) == null ? void 0 : _c.trx) == null ? void 0 : _d.expiration) || "N/A"; | ||
const extraFields = { | ||
...transaction, | ||
...transaction.trx.receipt, | ||
...transaction.trx.trx || {} | ||
}; | ||
const tx = { | ||
...extraFields, | ||
status: transaction.trx.receipt.status, | ||
cpu_usage: transaction.trx.receipt.cpu_usage_us, | ||
net_usage: transaction.trx.receipt.net_usage_words * 8, | ||
id: transaction.id, | ||
block_time: transaction.block_time, | ||
block_num: transaction.block_num, | ||
transaction_extensions: [], | ||
signatures: transaction.trx.receipt.trx[1].signatures, | ||
delay_sec, | ||
expiration, | ||
actions, | ||
traces | ||
}; | ||
return tx; | ||
} | ||
@@ -729,0 +649,0 @@ |
{ | ||
"name": "@bloks/utils", | ||
"version": "27.6.0", | ||
"version": "27.7.0", | ||
"author": "Metallicus", | ||
@@ -16,2 +16,3 @@ "module": "dist/index.mjs", | ||
"dependencies": { | ||
"@proton/js": "^27.10.0", | ||
"fast-text-encoding": "^1.0.3", | ||
@@ -22,6 +23,6 @@ "long": "^4.0.0", | ||
"devDependencies": { | ||
"@proton/tsconfig": "1.5.0", | ||
"@types/jest": "^24.9.0", | ||
"@types/long": "^4.0.1", | ||
"@types/qs": "^6.9.0", | ||
"@proton/tsconfig": "1.5.0", | ||
"tslib": "^1.10.0", | ||
@@ -28,0 +29,0 @@ "tsup": "^6.3.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69734
4
2231
+ Added@proton/js@^27.10.0
+ Added@bloks/constants@28.11.0(transitive)
+ Added@peculiar/asn1-schema@2.3.13(transitive)
+ Added@peculiar/json-schema@1.1.12(transitive)
+ Added@peculiar/webcrypto@1.5.0(transitive)
+ Added@proton/js@27.13.0(transitive)
+ Added@types/bn.js@4.11.6(transitive)
+ Added@types/node@22.10.0(transitive)
+ Added@types/pbkdf2@3.1.2(transitive)
+ Added@types/secp256k1@4.0.6(transitive)
+ Addedabortcontroller-polyfill@1.7.6(transitive)
+ Addedasn1js@3.0.5(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbase64url@3.0.1(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedbn.js@4.12.15.2.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addedeth-sig-util@3.0.1(transitive)
+ Addedethereum-cryptography@0.1.3(transitive)
+ Addedethereumjs-abi@0.6.8(transitive)
+ Addedethereumjs-util@5.2.16.2.1(transitive)
+ Addedethjs-util@0.1.6(transitive)
+ Addedevent-target-shim@6.0.2(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-hex-prefixed@1.0.0(transitive)
+ Addedkeccak@3.0.4(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednode-addon-api@2.0.25.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
+ Addedpako@2.0.3(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedpvtsutils@1.3.6(transitive)
+ Addedpvutils@1.1.3(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd-ts@0.0.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedrlp@2.2.7(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedscrypt-js@3.0.1(transitive)
+ Addedsecp256k1@4.0.4(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-hex-prefix@1.0.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtweetnacl@1.0.3(transitive)
+ Addedtweetnacl-util@0.15.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwebcrypto-core@1.8.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)