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

@bloks/utils

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloks/utils - npm Package Compare versions

Comparing version 27.6.0 to 27.7.0

53

dist/index.d.ts

@@ -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 };

140

dist/index.js

@@ -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

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