Skip to content

Commit

Permalink
chore(All): Remove unnecessary logging.
Browse files Browse the repository at this point in the history
feat(funder): Add egoistic funding.
  • Loading branch information
sophia1ch committed Jul 17, 2024
1 parent a9bb3d1 commit 1d4a9f7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 24 deletions.
1 change: 0 additions & 1 deletion channel/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (b backend) CalcID(params *channel.Params) channel.ID {
return channel.ID{}
}
id := sha256.Sum256(bytes)
log.Println("CalcID called:", id)
return id
}

Expand Down
7 changes: 2 additions & 5 deletions channel/funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (f *Funder) fundParty(ctx context.Context, req pchannel.FundingReq) error {
log.Println("Balance A: ", bal0, bal1, " after funding amount: ", req.State.Balances, req.State.Assets)
continue
}
if req.Idx == pchannel.Index(1) && !chanState.Control.FundedB {
if req.Idx == pchannel.Index(1) && !chanState.Control.FundedB && chanState.Control.FundedA {
log.Println("Funding party B")
err := f.FundChannel(ctx, req.State, true)
if err != nil {
Expand Down Expand Up @@ -195,8 +195,7 @@ func (f *Funder) openChannel(ctx context.Context, req pchannel.FundingReq) error
log.Println(err)
return errors.New("error while opening channel in party A")
}
ch, err := f.cb.GetChannelInfo(ctx, f.perunAddr, req.State.ID)
log.Println("Channel: ", ch)
_, err = f.cb.GetChannelInfo(ctx, f.perunAddr, req.State.ID)
return nil
}

Expand All @@ -208,10 +207,8 @@ func (f *Funder) FundChannel(ctx context.Context, state *pchannel.State, funderI
}

if !containsAllAssets(balsStellar.Tokens, f.assetAddrs) {
log.Println(balsStellar.Tokens, f.assetAddrs)
return errors.New("asset address is not equal to the address stored in the state")
}
log.Println(f.perunAddr, state.ID, funderIdx)
return f.cb.Fund(ctx, f.perunAddr, state.ID, funderIdx)
}

Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (cb *ContractBackend) Withdraw(ctx context.Context, perunAddr xdr.ScAddress
log.Println("Error while getting balance: ", err)
}
tokenAddr1 := req.Tx.State.Assets[1].(*types.StellarAsset)
log.Println("Asset1: ", tokenAddr1, "Asset2: ", tokenAddr0)

cAdd1, err := types.MakeContractAddress(tokenAddr1.ContractID())
if err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions client/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/txnbuild"
"github.com/stellar/go/xdr"
"log"
"math/big"
"perun.network/perun-stellar-backend/wire"
"time"
Expand Down Expand Up @@ -128,7 +127,6 @@ func PreflightHostFunctionsResult(hzClient *horizonclient.Client,
if err != nil {
return wire.Channel{}, "", function, result.MinResourceFee, err
}
log.Println("RESULT: ", decodedXdr)
if chInfo {
decChanInfo := decodedXdr

Expand Down
16 changes: 1 addition & 15 deletions client/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/stellar/go/keypair"
"github.com/stellar/go/txnbuild"
"github.com/stellar/go/xdr"
"log"
)

func CreateSignedTransactionWithParams(signers []*keypair.Full, txParams txnbuild.TransactionParams,
Expand Down Expand Up @@ -35,13 +34,6 @@ func NewSender(kp *keypair.Full) Sender {
}

func (s *TxSender) SignSendTx(txUnsigned txnbuild.Transaction) (xdr.TransactionMeta, error) {
accReq := horizonclient.AccountRequest{AccountID: s.kp.Address()}
acc, err := s.hzClient.AccountDetail(accReq)
if err != nil {
return xdr.TransactionMeta{}, err
}
bals := acc.Balances
log.Println("Balances: ", bals)
tx, err := txUnsigned.Sign(NETWORK_PASSPHRASE, s.kp)
if err != nil {
return xdr.TransactionMeta{}, err
Expand All @@ -57,13 +49,7 @@ func (s *TxSender) SignSendTx(txUnsigned txnbuild.Transaction) (xdr.TransactionM
return xdr.TransactionMeta{}, ErrCouldNotDecodeTxMeta
}
_ = txMeta.V3.SorobanMeta.ReturnValue
accReq = horizonclient.AccountRequest{AccountID: s.kp.Address()}
acc, err = s.hzClient.AccountDetail(accReq)
if err != nil {
return xdr.TransactionMeta{}, err
}
bals = acc.Balances
log.Println("Balances: ", bals)

return txMeta, nil

}
Expand Down

0 comments on commit 1d4a9f7

Please sign in to comment.