= ({ tx }) => {
title="Blocknumber"
>
- {tx.tx.blockNumber}
+ {tx.block}
{tx.length > 0 && (
@@ -53,7 +53,7 @@ export const TransactionEntry: FC<{ tx: AllMultiReturnTypes }> = ({ tx }) => {
{formatThousands(
- BigInt(tx.tx.gasUsed) / BigInt(tx.length)
+ BigInt(tx.gas_used) / BigInt(tx.length)
)}
Per Name
@@ -62,7 +62,7 @@ export const TransactionEntry: FC<{ tx: AllMultiReturnTypes }> = ({ tx }) => {
-
{formatThousands(BigInt(tx.tx.gasUsed))}
+
{formatThousands(BigInt(tx.gas_used))}
{ethUsd.data ? (
@@ -70,8 +70,8 @@ export const TransactionEntry: FC<{ tx: AllMultiReturnTypes }> = ({ tx }) => {
Number(
(ethUsd.data *
Number(
- (BigInt(tx.tx.gasUsed) *
- BigInt(tx.tx.gasPrice)) /
+ (BigInt(tx.gas_used) *
+ BigInt(tx.gas_price)) /
1_000_000_000_000_000n
)) /
1_000_000
@@ -81,31 +81,24 @@ export const TransactionEntry: FC<{ tx: AllMultiReturnTypes }> = ({ tx }) => {
) : undefined}
-
-
- {(Number(BigInt(tx.tx.gasPrice) / 100_000_000n) / 10)
- .toPrecision(2)
- .toString()}
-
- {['renewAll', 'multiRegister'].includes(tx.functionName) && (
+ {['renewAll', 'multiRegister'].includes(tx.method) && (
Names
- {tx.args[0].map((name, _index) => (
+ {(
+ tx.decoded_input.parameters[0]
+ .value as string[]
+ ).map((name, _index) => (
-
= ({ tx }) => {
)}
- {tx.functionName === 'multiCommit' && (
+ {tx.method === 'multiCommit' && (
Commitments
-
- {tx.args[0].map((commitment, _index) => (
- - {commitment}
+
+ {(
+ tx.decoded_input.parameters[0]
+ .value as string[]
+ ).map((commitment, _index) => (
+ -
+ {formatAddress(commitment)}
+
))}
)}
-
diff --git a/web/src/txHistory/TransactionHistory.tsx b/web/src/txHistory/TransactionHistory.tsx
index a2d0caa..e98bda4 100644
--- a/web/src/txHistory/TransactionHistory.tsx
+++ b/web/src/txHistory/TransactionHistory.tsx
@@ -36,7 +36,7 @@ export const TransactionHistory: FC<{
{txs.length > 0 && (
{txs.filter(Boolean).map((tx) => (
-
+
))}
)}
diff --git a/web/src/utils/aggregateTotals.ts b/web/src/utils/aggregateTotals.ts
index fc004bd..a670368 100644
--- a/web/src/utils/aggregateTotals.ts
+++ b/web/src/utils/aggregateTotals.ts
@@ -3,37 +3,51 @@ import { AllMultiReturnTypes } from './decodeTransaction';
export const aggregateTotals = (txs: AllMultiReturnTypes[]) => {
const aggregates = txs.reduce(
(aggregate, current) => {
- if (current?.functionName == 'renewAll') {
+ if (current.revert_reason != undefined) return aggregate;
+
+ if (current?.method == 'renewAll') {
aggregate.renewCount += BigInt(current.length);
- aggregate.renewTotal += BigInt(current.tx.gasUsed);
+ aggregate.renewTotal += BigInt(current.gas_used);
+ aggregate.renewGasPriceCount += BigInt(current.gas_price);
}
- if (current?.functionName == 'multiCommit') {
+ if (current?.method == 'multiCommit') {
aggregate.commitCount += BigInt(current.length);
- aggregate.commitTotal += BigInt(current.tx.gasUsed);
+ aggregate.commitTotal += BigInt(current.gas_used);
+ aggregate.commitGasPriceCount += BigInt(current.gas_price);
}
- if (current?.functionName == 'multiRegister') {
+ if (current?.method == 'multiRegister') {
aggregate.registerCount += BigInt(current.length);
- aggregate.registerTotal += BigInt(current.tx.gasUsed);
+ aggregate.registerTotal += BigInt(current.gas_used);
+ aggregate.registerGasPriceCount += BigInt(current.gas_price);
}
return aggregate;
},
{
commitTotal: 0n,
+ commitGasPriceCount: 0n,
commitCount: 0n,
renewTotal: 0n,
+ renewGasPriceCount: 0n,
renewCount: 0n,
registerTotal: 0n,
+ registerGasPriceCount: 0n,
registerCount: 0n,
}
);
return {
commitAverage: aggregates.commitTotal / aggregates.commitCount,
+ commitGasPriceAverage:
+ aggregates.commitGasPriceCount / aggregates.commitCount,
registerAverage: aggregates.registerTotal / aggregates.registerCount,
+ registerGasPriceAverage:
+ aggregates.registerGasPriceCount / aggregates.registerCount,
renewAverage: aggregates.renewTotal / aggregates?.renewCount,
+ renewGasPriceAverage:
+ aggregates.renewGasPriceCount / aggregates?.renewCount,
...aggregates,
};
};
diff --git a/web/src/utils/decodeTransaction.ts b/web/src/utils/decodeTransaction.ts
index c679f22..969b15f 100644
--- a/web/src/utils/decodeTransaction.ts
+++ b/web/src/utils/decodeTransaction.ts
@@ -1,20 +1,8 @@
-import { decodeFunctionData } from 'viem';
+import { BlockscoutTx } from '../etherscan/getTransactions';
-import { ultraBulkAbi } from '../abi';
-import { EtherscanTx } from '../etherscan/getTransactions';
-
-type DecodedFunction
= {
- functionName: K;
- args: V;
- length: number;
- tx: EtherscanTx;
-};
-type MultiRegisterType = DecodedFunction<
- 'multiRegister',
- [string[], string[], bigint, string, string]
->;
-type MultiCommitType = DecodedFunction<'multiCommit', [string[]]>;
-type MultiRenewType = DecodedFunction<'renewAll', [string[], bigint, bigint]>;
+type MultiRegisterType = BlockscoutTx<'multiRegister'> & { length: number };
+type MultiCommitType = BlockscoutTx<'multiCommit'> & { length: number };
+type MultiRenewType = BlockscoutTx<'renewAll'> & { length: number };
export type AllMultiReturnTypes =
| MultiRegisterType
@@ -22,50 +10,75 @@ export type AllMultiReturnTypes =
| MultiRenewType;
export const decodeTransaction = (
- tx: EtherscanTx
+ tx: BlockscoutTx
): AllMultiReturnTypes | undefined => {
- // If contract Create
- if (tx.to == '') {
+ // If contract Create skip
+ if (!tx.to) {
return;
}
- try {
- const { args, functionName } = decodeFunctionData({
- abi: ultraBulkAbi,
- data: tx.input as '0x{string}',
- });
-
- const length = getNameLength(functionName, args as any);
-
- if (functionName == 'multiRegister' && args) {
- return {
- functionName,
- args,
- length,
- tx,
- } as MultiRegisterType;
- }
-
- if (functionName == 'multiCommit' && args) {
- return {
- functionName,
- args,
- length,
- tx,
- } as MultiCommitType;
- }
-
- if (functionName == 'renewAll' && args) {
- return {
- functionName,
- args,
- length,
- tx,
- } as MultiRenewType;
- }
- } catch (error) {
- console.error({ e: error });
+ if (
+ tx.method == 'multiRegister' &&
+ Array.isArray(tx.decoded_input.parameters[0].value)
+ ) {
+ return {
+ ...tx,
+ length: tx.decoded_input.parameters[0].value.length,
+ } as MultiRegisterType;
+ }
+
+ if (tx.method == 'multiCommit') {
+ return {
+ ...tx,
+ length: tx.decoded_input.parameters[0].value.length,
+ } as MultiCommitType;
}
+
+ if (tx.method == 'renewAll') {
+ return {
+ ...tx,
+ length: tx.decoded_input.parameters[0].value.length,
+ } as MultiRenewType;
+ }
+
+ // try {
+ // const { args, functionName } = decodeFunctionData({
+ // abi: ultraBulkAbi,
+ // data: tx.input as '0x{string}',
+ // });
+
+ // const length = getNameLength(functionName, args as any);
+
+ // if (functionName == 'multiRegister' && args) {
+ // return {
+ // functionName,
+ // args,
+ // length,
+ // tx,
+ // } as MultiRegisterType;
+ // }
+
+ // if (functionName == 'multiCommit' && args) {
+ // return {
+ // functionName,
+ // args,
+ // length,
+ // tx,
+ // } as MultiCommitType;
+ // }
+
+ // if (functionName == 'renewAll' && args) {
+ // return {
+ // functionName,
+ // args,
+ // length,
+ // tx,
+ // } as MultiRenewType;
+ // }
+ // } catch (error) {
+ // console.error({ e: error });
+ // }
+ return tx;
};
export const deriveLabelFromFunctionName = (
diff --git a/web/src/utils/formatGas.ts b/web/src/utils/formatGas.ts
new file mode 100644
index 0000000..e0bf24c
--- /dev/null
+++ b/web/src/utils/formatGas.ts
@@ -0,0 +1,4 @@
+// Divide by 10e8 to get gwei but keep 2 decimals of precision so 1.23 return as string
+export const formatGas = (gas: BigInt): string => {
+ return (Number(BigInt(gas.toString()) / BigInt(10e6)) / 10).toString();
+};
diff --git a/web/src/utils/gasMagic.ts b/web/src/utils/gasMagic.ts
index 1574cd4..36a5eb8 100644
--- a/web/src/utils/gasMagic.ts
+++ b/web/src/utils/gasMagic.ts
@@ -5,7 +5,7 @@ export const gasPriceMagic = (
) => {
return (
Number(
- BigInt(Math.round(Number(gas * gasPrice * 1000n) * ethUSDC)) /
+ BigInt(Math.round(Number((gas * gasPrice) / 10_000n) * ethUSDC)) /
1_000_000n
) / 1_000_000_000
).toPrecision(3);