Skip to content

Commit

Permalink
Refactorrrrrrrrrr
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Jan 19, 2024
1 parent 366a992 commit 6d7f649
Show file tree
Hide file tree
Showing 40 changed files with 1,231 additions and 1,283 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ localhost:8000/tx/<hash>?type=forward
### Generating Go ABI bindings

```shell
abigen --abi cmd/ethereum/abi/TokenMessenger.json --pkg cmd --type TokenMessenger --out cmd/TokenMessenger.go
abigen --abi cmd/ethereum/abi/TokenMessengerWithMetadata.json --pkg cmd --type TokenMessengerWithMetadata --out cmd/TokenMessengerWithMetadata.go
abigen --abi cmd/ethereum/abi/ERC20.json --pkg integration_testing --type ERC20 --out integration/ERC20.go
abigen --abi cmd/ethereum/abi/MessageTransmitter.json --pkg cmd --type MessageTransmitter --out cmd/MessageTransmitter.go
abigen --abi ethereum/abi/TokenMessenger.json --pkg contracts --type TokenMessenger --out ethereum/contracts/TokenMessenger.go
abigen --abi ethereum/abi/TokenMessengerWithMetadata.json --pkg contracts --type TokenMessengerWithMetadata --out ethereum/contracts/TokenMessengerWithMetadata.go
abigen --abi ethereum/abi/ERC20.json --pkg integration_testing --type ERC20 --out integration/ERC20.go
abigen --abi ethereum/abi/MessageTransmitter.json --pkg contracts- --type MessageTransmitter --out ethereum/contracts/MessageTransmitter.go
```

### Useful links
Expand Down
9 changes: 4 additions & 5 deletions cmd/circle/attestation.go → circle/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ import (
"time"

"cosmossdk.io/log"
"github.com/strangelove-ventures/noble-cctp-relayer/config"
"github.com/strangelove-ventures/noble-cctp-relayer/types"
)

// CheckAttestation checks the iris api for attestation status and returns true if attestation is complete
func CheckAttestation(cfg config.Config, logger log.Logger, irisLookupId string, txHash string, sourceDomain, destDomain types.Domain) *types.AttestationResponse {
logger.Debug(fmt.Sprintf("Checking attestation for %s%s%s for source tx %s from %d to %d", cfg.Circle.AttestationBaseUrl, "0x", irisLookupId, txHash, sourceDomain, destDomain))
func CheckAttestation(attestationURL string, logger log.Logger, irisLookupId string, txHash string, sourceDomain, destDomain types.Domain) *types.AttestationResponse {
logger.Debug(fmt.Sprintf("Checking attestation for %s%s%s for source tx %s from %d to %d", attestationURL, "0x", irisLookupId, txHash, sourceDomain, destDomain))

client := http.Client{Timeout: 2 * time.Second}

rawResponse, err := client.Get(cfg.Circle.AttestationBaseUrl + "0x" + irisLookupId)
rawResponse, err := client.Get(attestationURL + "0x" + irisLookupId)
if err != nil {
logger.Debug("error during request: " + err.Error())
return nil
Expand All @@ -39,7 +38,7 @@ func CheckAttestation(cfg config.Config, logger log.Logger, irisLookupId string,
logger.Debug("unable to unmarshal response")
return nil
}
logger.Info(fmt.Sprintf("Attestation found for %s%s%s", cfg.Circle.AttestationBaseUrl, "0x", irisLookupId))
logger.Info(fmt.Sprintf("Attestation found for %s%s%s", attestationURL, "0x", irisLookupId))

return &response
}
10 changes: 5 additions & 5 deletions cmd/circle/attestation_test.go → circle/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (

"cosmossdk.io/log"
"github.com/rs/zerolog"
"github.com/strangelove-ventures/noble-cctp-relayer/cmd/circle"
"github.com/strangelove-ventures/noble-cctp-relayer/config"
"github.com/strangelove-ventures/noble-cctp-relayer/circle"
"github.com/strangelove-ventures/noble-cctp-relayer/types"
"github.com/stretchr/testify/require"
)

var cfg config.Config
var cfg types.Config
var logger log.Logger

func init() {
Expand All @@ -20,12 +20,12 @@ func init() {
}

func TestAttestationIsReady(t *testing.T) {
resp := circle.CheckAttestation(cfg, logger, "85bbf7e65a5992e6317a61f005e06d9972a033d71b514be183b179e1b47723fe", "", 0, 4)
resp := circle.CheckAttestation(cfg.Circle.AttestationBaseUrl, logger, "85bbf7e65a5992e6317a61f005e06d9972a033d71b514be183b179e1b47723fe", "", 0, 4)
require.NotNil(t, resp)
require.Equal(t, "complete", resp.Status)
}

func TestAttestationNotFound(t *testing.T) {
resp := circle.CheckAttestation(cfg, logger, "not an attestation", "", 0, 4)
resp := circle.CheckAttestation(cfg.Circle.AttestationBaseUrl, logger, "not an attestation", "", 0, 4)
require.Nil(t, resp)
}
167 changes: 0 additions & 167 deletions cmd/ethereum/broadcast.go

This file was deleted.

114 changes: 0 additions & 114 deletions cmd/ethereum/listener.go

This file was deleted.

Loading

0 comments on commit 6d7f649

Please sign in to comment.