diff --git a/pkg/repository/asset.go b/pkg/repository/asset.go index e34e10ef..d0f984e1 100644 --- a/pkg/repository/asset.go +++ b/pkg/repository/asset.go @@ -13,7 +13,7 @@ type Asset interface { Transactable Create(model.Asset) (model.Asset, error) GetById(id string) (model.Asset, error) - GetName(name string) (model.Asset, error) + GetByName(name string) (model.Asset, error) Update(ID string, updates any) error } @@ -41,7 +41,7 @@ func (a asset[T]) Create(insert model.Asset) (model.Asset, error) { return m, err } -func (a asset[T]) GetName(name string) (model.Asset, error) { +func (a asset[T]) GetByName(name string) (model.Asset, error) { m := model.Asset{} err := a.store.Get(&m, fmt.Sprintf("SELECT * FROM %s WHERE name = $1", a.table), name) if err != nil && err == sql.ErrNoRows { diff --git a/pkg/repository/network.go b/pkg/repository/network.go index d41faaca..c387c19c 100644 --- a/pkg/repository/network.go +++ b/pkg/repository/network.go @@ -13,7 +13,7 @@ type Network interface { Transactable Create(model.Network) (model.Network, error) GetById(id string) (model.Network, error) - GetChainID(chainId uint64) (model.Network, error) + GetByChainId(chainId uint64) (model.Network, error) Update(ID string, updates any) error } @@ -47,7 +47,7 @@ func (n network[T]) Create(insert model.Network) (model.Network, error) { return m, nil } -func (n network[T]) GetChainID(chainId uint64) (model.Network, error) { +func (n network[T]) GetByChainId(chainId uint64) (model.Network, error) { m := model.Network{} err := n.store.Get(&m, fmt.Sprintf("SELECT * FROM %s WHERE chain_id = $1", n.table), chainId) if err != nil && err == sql.ErrNoRows { diff --git a/pkg/service/chain.go b/pkg/service/chain.go index 4e1fd2df..fd252a6a 100644 --- a/pkg/service/chain.go +++ b/pkg/service/chain.go @@ -24,7 +24,7 @@ func stringFee(chainId uint64) (float64, error) { } func ChainInfo(chainId uint64, networkRepo repository.Network, assetRepo repository.Asset) (Chain, error) { - network, err := networkRepo.GetChainID(chainId) + network, err := networkRepo.GetByChainId(chainId) if err != nil { return Chain{}, common.StringError(err) } diff --git a/pkg/service/executor.go b/pkg/service/executor.go index 51d9b0b5..cbc5ea6d 100644 --- a/pkg/service/executor.go +++ b/pkg/service/executor.go @@ -39,7 +39,7 @@ type Executor interface { Estimate(call ContractCall) (CallEstimate, error) TxWait(txID string) (uint64, error) Close() error - GetChainID() (uint64, error) + GetByChainId() (uint64, error) GetBalance() (float64, error) } @@ -245,7 +245,7 @@ func (e executor) TxWait(txID string) (uint64, error) { return receipt.GasUsed, nil } -func (e executor) GetChainID() (uint64, error) { +func (e executor) GetByChainId() (uint64, error) { // Get ChainID from state var chainId64 uint64 err := e.client.Call(eth.ChainID().Returns(&chainId64)) diff --git a/pkg/service/transaction.go b/pkg/service/transaction.go index 936fe7fa..59fe6a28 100644 --- a/pkg/service/transaction.go +++ b/pkg/service/transaction.go @@ -370,7 +370,7 @@ func (t transaction) populateInitialTxModelData(e model.ExecutionRequest, m *mod contractFunc := e.CxFunc + e.CxReturn m.ContractFunc = &contractFunc - asset, err := t.repos.Asset.GetName("USD") + asset, err := t.repos.Asset.GetByName("USD") if err != nil { return model.Asset{}, common.StringError(err) } @@ -401,7 +401,7 @@ func (t transaction) testTransaction(executor Executor, request model.Transactio wei := gas.Add(&estimateEVM.Value, gas) eth := common.WeiToEther(wei) - chainID, err := executor.GetChainID() + chainID, err := executor.GetByChainId() if err != nil { return res, eth, common.StringError(err) } @@ -644,7 +644,7 @@ func (t transaction) tenderTransaction(p transactionProcessingData) (float64, er profit := p.executionRequest.Quote.TotalUSD - trueUSD // Create Receive Tx leg - asset, err := t.repos.Asset.GetName("ETH") + asset, err := t.repos.Asset.GetById(p.chain.GasTokenID) if err != nil { return profit, common.StringError(err) } diff --git a/pkg/test/stubs/repository.go b/pkg/test/stubs/repository.go index a132be47..2dad2992 100644 --- a/pkg/test/stubs/repository.go +++ b/pkg/test/stubs/repository.go @@ -49,7 +49,7 @@ import ( // return model.Asset{}, nil // } -// func (Asset) GetName(name string) (model.Asset, error) { +// func (Asset) GetByName(name string) (model.Asset, error) { // if name == "AVAX" { // return avax, nil // }