Skip to content

Commit

Permalink
Fixes build
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Feb 16, 2025
1 parent 60656e9 commit 97971d4
Showing 1 changed file with 79 additions and 79 deletions.
158 changes: 79 additions & 79 deletions src/apps/chifra/pkg/ledger2/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,99 +148,99 @@ func guessAssetName(addr string) string {
func DeriveAssetTransfers(accountFor base.Address, tx *types.Transaction) []AssetTransfer {
var results []AssetTransfer

if false { // assetOfInterest(l.assetFilter, base.FAKE_ETH_ADDRESS) {
/*
// TODO: We ignore errors in the next few lines, but we should not
prevBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Prev())
if trans.BlockNumber == 0 {
prevBal = new(base.Wei)
}
begBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Cur()-1)
if trans.BlockNumber == 0 {
begBal = new(base.Wei)
}
endBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Cur())
ret := types.Statement{
AccountedFor: l.accountFor,
Sender: trans.From,
Recipient: trans.To,
BlockNumber: trans.BlockNumber,
TransactionIndex: trans.TransactionIndex,
TransactionHash: trans.Hash,
LogIndex: 0,
Timestamp: trans.Timestamp,
AssetAddr: base.FAKE_ETH_ADDRESS,
AssetSymbol: "WEI",
Decimals: 18,
SpotPrice: 0.0,
PriceSource: "not-priced",
PrevBal: *prevBal,
BegBal: *begBal,
EndBal: *endBal,
ReconType: ctx.Recon(),
}
if trans.To.IsZero() && trans.Receipt != nil && !trans.Receipt.ContractAddress.IsZero() {
ret.Recipient = trans.Receipt.ContractAddress
}
// if false { // assetOfInterest(l.assetFilter, base.FAKE_ETH_ADDRESS) {
/*
// TODO: We ignore errors in the next few lines, but we should not
prevBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Prev())
if trans.BlockNumber == 0 {
prevBal = new(base.Wei)
}
begBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Cur()-1)
if trans.BlockNumber == 0 {
begBal = new(base.Wei)
}
endBal, _ := l.connection.GetBalanceAt(l.accountFor, ctx.Cur())
ret := types.Statement{
AccountedFor: l.accountFor,
Sender: trans.From,
Recipient: trans.To,
BlockNumber: trans.BlockNumber,
TransactionIndex: trans.TransactionIndex,
TransactionHash: trans.Hash,
LogIndex: 0,
Timestamp: trans.Timestamp,
AssetAddr: base.FAKE_ETH_ADDRESS,
AssetSymbol: "WEI",
Decimals: 18,
SpotPrice: 0.0,
PriceSource: "not-priced",
PrevBal: *prevBal,
BegBal: *begBal,
EndBal: *endBal,
ReconType: ctx.Recon(),
}
// Do not collapse. A single transaction may have many movements of money
if l.accountFor == ret.Sender {
gasUsed := new(base.Wei)
if trans.Receipt != nil {
gasUsed.SetUint64(uint64(trans.Receipt.GasUsed))
}
gasPrice := new(base.Wei).SetUint64(uint64(trans.GasPrice))
gasOut := new(base.Wei).Mul(gasUsed, gasPrice)
if trans.To.IsZero() && trans.Receipt != nil && !trans.Receipt.ContractAddress.IsZero() {
ret.Recipient = trans.Receipt.ContractAddress
}
ret.AmountOut = trans.Value
ret.GasOut = *gasOut
// Do not collapse. A single transaction may have many movements of money
if l.accountFor == ret.Sender {
gasUsed := new(base.Wei)
if trans.Receipt != nil {
gasUsed.SetUint64(uint64(trans.Receipt.GasUsed))
}
gasPrice := new(base.Wei).SetUint64(uint64(trans.GasPrice))
gasOut := new(base.Wei).Mul(gasUsed, gasPrice)
// Do not collapse. A single transaction may have many movements of money
if l.accountFor == ret.Recipient {
if ret.BlockNumber == 0 {
ret.PrefundIn = trans.Value
ret.AmountOut = trans.Value
ret.GasOut = *gasOut
}
// Do not collapse. A single transaction may have many movements of money
if l.accountFor == ret.Recipient {
if ret.BlockNumber == 0 {
ret.PrefundIn = trans.Value
} else {
if trans.Rewards != nil {
ret.MinerBaseRewardIn = trans.Rewards.Block
ret.MinerNephewRewardIn = trans.Rewards.Nephew
ret.MinerTxFeeIn = trans.Rewards.TxFee
ret.MinerUncleRewardIn = trans.Rewards.Uncle
} else {
if trans.Rewards != nil {
ret.MinerBaseRewardIn = trans.Rewards.Block
ret.MinerNephewRewardIn = trans.Rewards.Nephew
ret.MinerTxFeeIn = trans.Rewards.TxFee
ret.MinerUncleRewardIn = trans.Rewards.Uncle
} else {
ret.AmountIn = trans.Value
}
// TODO: BOGUS PERF - WHAT ABOUT WITHDRAWALS?
ret.AmountIn = trans.Value
}
// TODO: BOGUS PERF - WHAT ABOUT WITHDRAWALS?
}
}
if l.asEther {
ret.AssetSymbol = "ETH"
}
if l.asEther {
ret.AssetSymbol = "ETH"
}
if !l.useTraces && l.trialBalance(types.TrialBalEth, &ret) {
if ret.IsMaterial() {
statements = append(statements, ret)
} else {
logger.TestLog(true, "Tx reconciled with a zero value net amount. It's okay.")
}
if !l.useTraces && l.trialBalance(types.TrialBalEth, &ret) {
if ret.IsMaterial() {
statements = append(statements, ret)
} else {
if !l.useTraces {
logger.TestLog(!l.useTraces, "Trial balance failed for ", ret.TransactionHash.Hex(), " need to decend into traces")
}
if traceStatements, err := l.getStatementsFromTraces(trans, &ret); err != nil {
if !utils.IsFuzzing() {
logger.Warn(colors.Yellow+"Statement at ", fmt.Sprintf("%d.%d", trans.BlockNumber, trans.TransactionIndex), " does not reconcile."+colors.Off)
}
} else {
statements = append(statements, traceStatements...)
logger.TestLog(true, "Tx reconciled with a zero value net amount. It's okay.")
}
} else {
if !l.useTraces {
logger.TestLog(!l.useTraces, "Trial balance failed for ", ret.TransactionHash.Hex(), " need to decend into traces")
}
if traceStatements, err := l.getStatementsFromTraces(trans, &ret); err != nil {
if !utils.IsFuzzing() {
logger.Warn(colors.Yellow+"Statement at ", fmt.Sprintf("%d.%d", trans.BlockNumber, trans.TransactionIndex), " does not reconcile."+colors.Off)
}
} else {
statements = append(statements, traceStatements...)
}
}
}
*/
}
*/
// }

// 1) Native transfer if tx.Value is non-zero.
if tx.Value.Cmp(base.NewWei(0)) != 0 {
Expand Down

0 comments on commit 97971d4

Please sign in to comment.