diff --git a/src/components/transfer_graphs/HbarTransferGraphC.vue b/src/components/transfer_graphs/HbarTransferGraphC.vue
index 7075c487d..a4b88d9dd 100644
--- a/src/components/transfer_graphs/HbarTransferGraphC.vue
+++ b/src/components/transfer_graphs/HbarTransferGraphC.vue
@@ -48,7 +48,7 @@
+ v-bind:amount="hbarTransferLayout.destinationAmount"/>
diff --git a/src/components/transfer_graphs/layout/HbarTransferLayout.ts b/src/components/transfer_graphs/layout/HbarTransferLayout.ts
index eff86b4ff..9fd97a2a3 100644
--- a/src/components/transfer_graphs/layout/HbarTransferLayout.ts
+++ b/src/components/transfer_graphs/layout/HbarTransferLayout.ts
@@ -19,14 +19,14 @@
*/
import {compareTransferByAccount, NetworkNode, Transaction, Transfer} from "@/schemas/HederaSchemas";
+import {isFeeTransfer, makeOperatorDescription} from "@/schemas/HederaUtils";
import {computeNetAmount} from "@/utils/TransactionTools";
-import {makeOperatorDescription} from "@/schemas/HederaUtils";
export class HbarTransferLayout {
public readonly transaction: Transaction|undefined
public readonly nodes: NetworkNode[]
- public readonly netAmount: number
+ public readonly destinationAmount: number
public readonly sources = Array()
public readonly destinations = Array()
public readonly rowCount: number
@@ -39,7 +39,6 @@ export class HbarTransferLayout {
this.transaction = transaction
this.nodes = nodes
- this.netAmount = transaction ? computeNetAmount(transaction) : 0
if (this.transaction?.transfers) {
const negativeTransfers = new Array()
@@ -55,18 +54,18 @@ export class HbarTransferLayout {
positiveTransfers.sort(compareTransferByAccount)
for (const t of negativeTransfers) {
- const payload = t.account === null || makeOperatorDescription(t.account, this.nodes) === null
- this.sources.push(new HbarTransferRow(t, null, payload))
+ const isFee = isFeeTransfer(t, this.nodes)
+ this.sources.push(new HbarTransferRow(t, null, !isFee))
}
for (const t of positiveTransfers) {
- const operator = t.account !== null ? makeOperatorDescription(t.account, this.nodes) : null
- const payload = t.account === null || operator === null
- this.destinations.push(new HbarTransferRow(t, operator ?? "Transfer", payload))
+ const isFee = isFeeTransfer(t, this.nodes)
+ const operator = t.account ? makeOperatorDescription(t.account, this.nodes) : null
+ this.destinations.push(new HbarTransferRow(t, operator ?? "Transfer", !isFee))
}
}
// Makes sure net amount is distributed across payload transfers
- let remaining = this.netAmount
+ let remaining = this.transaction ? computeNetAmount(this.transaction) : 0
// First we remove amount from payload transfers
for (const r of this.destinations) {
if (r.payload) {
@@ -112,10 +111,14 @@ export class HbarTransferLayout {
}
}
+ this.destinationAmount = 0
+ for (const r of this.destinations) {
+ this.destinationAmount += r.transfer.amount
+ }
+
this.rowCount = Math.max(this.sources.length, this.destinations.length)
}
-
//
// Private
//
diff --git a/src/schemas/HederaUtils.ts b/src/schemas/HederaUtils.ts
index 09651d6c1..407c01648 100644
--- a/src/schemas/HederaUtils.ts
+++ b/src/schemas/HederaUtils.ts
@@ -18,7 +18,7 @@
*
*/
-import {AccountInfo, KeyType, NetworkNode, TokenInfo} from "@/schemas/HederaSchemas";
+import {AccountInfo, KeyType, NetworkNode, TokenInfo, Transfer} from "@/schemas/HederaSchemas";
import {EntityID} from "@/utils/EntityID";
import {ethers} from "ethers";
@@ -112,6 +112,12 @@ export function makeOperatorDescription(accountId: string, nodes: NetworkNode[])
return result
}
+export function isFeeTransfer(t: Transfer, nodes: NetworkNode[]): boolean {
+ return t.account !== null
+ && t.amount > 0
+ && makeOperatorDescription(t.account, nodes) !== null
+}
+
const errorStringSelector = '0x08c379a0'
const panicUint256Selector = '0x4e487b71'
diff --git a/tests/unit/transfer_graphs/layout/HbarTransferLayout.spec.ts b/tests/unit/transfer_graphs/layout/HbarTransferLayout.spec.ts
index 32157b7d4..bf7209cc6 100644
--- a/tests/unit/transfer_graphs/layout/HbarTransferLayout.spec.ts
+++ b/tests/unit/transfer_graphs/layout/HbarTransferLayout.spec.ts
@@ -55,7 +55,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(0)
+ expect(fullLayout.destinationAmount).toBe(10)
expect(fullLayout.rowCount).toBe(2)
expect(fullLayout.sources.length).toBe(1)
expect(fullLayout.destinations.length).toBe(2)
@@ -85,7 +85,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(0)
+ expect(compactLayout.destinationAmount).toBe(0)
expect(compactLayout.rowCount).toBe(0)
expect(compactLayout.sources.length).toBe(0)
expect(compactLayout.destinations.length).toBe(0)
@@ -111,7 +111,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(90)
+ expect(fullLayout.destinationAmount).toBe(100)
expect(fullLayout.rowCount).toBe(3)
expect(fullLayout.sources.length).toBe(1)
expect(fullLayout.destinations.length).toBe(3)
@@ -147,7 +147,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(90)
+ expect(compactLayout.destinationAmount).toBe(90)
expect(compactLayout.rowCount).toBe(1)
expect(compactLayout.sources.length).toBe(1)
expect(compactLayout.destinations.length).toBe(1)
@@ -185,7 +185,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(90)
+ expect(fullLayout.destinationAmount).toBe(100)
expect(fullLayout.rowCount).toBe(4)
expect(fullLayout.sources.length).toBe(1)
expect(fullLayout.destinations.length).toBe(4)
@@ -227,7 +227,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(90)
+ expect(compactLayout.destinationAmount).toBe(90)
expect(compactLayout.rowCount).toBe(2)
expect(compactLayout.sources.length).toBe(1)
expect(compactLayout.destinations.length).toBe(2)
@@ -275,7 +275,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(0)
+ expect(fullLayout.destinationAmount).toBe(10)
expect(fullLayout.rowCount).toBe(2)
expect(fullLayout.sources.length).toBe(2)
expect(fullLayout.destinations.length).toBe(2)
@@ -312,7 +312,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(0)
+ expect(compactLayout.destinationAmount).toBe(0)
expect(compactLayout.rowCount).toBe(0)
expect(compactLayout.sources.length).toBe(0)
expect(compactLayout.destinations.length).toBe(0)
@@ -339,7 +339,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(90)
+ expect(fullLayout.destinationAmount).toBe(100)
expect(fullLayout.rowCount).toBe(3)
expect(fullLayout.sources.length).toBe(2)
expect(fullLayout.destinations.length).toBe(3)
@@ -381,7 +381,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(90)
+ expect(compactLayout.destinationAmount).toBe(90)
expect(compactLayout.rowCount).toBe(2)
expect(compactLayout.sources.length).toBe(2)
expect(compactLayout.destinations.length).toBe(1)
@@ -426,7 +426,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(90)
+ expect(fullLayout.destinationAmount).toBe(100)
expect(fullLayout.rowCount).toBe(4)
expect(fullLayout.sources.length).toBe(2)
expect(fullLayout.destinations.length).toBe(4)
@@ -475,7 +475,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(90)
+ expect(compactLayout.destinationAmount).toBe(90)
expect(compactLayout.rowCount).toBe(2)
expect(compactLayout.sources.length).toBe(2)
expect(compactLayout.destinations.length).toBe(2)
@@ -527,7 +527,7 @@ describe("HbarTransferLayout.vue", () => {
const fullLayout = new HbarTransferLayout(transaction, NETWORK_NODES)
expect(fullLayout.transaction).toBe(transaction)
- expect(fullLayout.netAmount).toBe(2)
+ expect(fullLayout.destinationAmount).toBe(10)
expect(fullLayout.rowCount).toBe(3)
expect(fullLayout.sources.length).toBe(1)
expect(fullLayout.destinations.length).toBe(3)
@@ -563,7 +563,7 @@ describe("HbarTransferLayout.vue", () => {
const compactLayout = new HbarTransferLayout(transaction, NETWORK_NODES, false)
expect(compactLayout.transaction).toBe(transaction)
- expect(compactLayout.netAmount).toBe(2)
+ expect(compactLayout.destinationAmount).toBe(2)
expect(compactLayout.rowCount).toBe(1)
expect(compactLayout.sources.length).toBe(1)
expect(compactLayout.destinations.length).toBe(1)