From 1f96fa774d2e25f988f695d8dc76c318390ba384 Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Wed, 3 Dec 2025 10:40:24 -0500 Subject: [PATCH] Cleanup unused code --- go.mod | 2 +- netutil/domain.go | 24 ------ netutil/url.go | 76 ------------------- solana/vm/virtual_instructions_airdrop.go | 28 ------- ...rtual_instructions_conditional_transfer.go | 25 ------ 5 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 netutil/domain.go delete mode 100644 netutil/url.go delete mode 100644 solana/vm/virtual_instructions_airdrop.go delete mode 100644 solana/vm/virtual_instructions_conditional_transfer.go diff --git a/go.mod b/go.mod index 5564c00..e83e024 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,6 @@ require ( github.com/stretchr/testify v1.8.4 github.com/ybbus/jsonrpc v2.1.2+incompatible go.uber.org/zap v1.27.1 - golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 google.golang.org/grpc v1.77.0 google.golang.org/protobuf v1.36.10 ) @@ -80,6 +79,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/crypto v0.43.0 // indirect + golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 // indirect golang.org/x/sys v0.37.0 // indirect golang.org/x/text v0.30.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect diff --git a/netutil/domain.go b/netutil/domain.go deleted file mode 100644 index d686b67..0000000 --- a/netutil/domain.go +++ /dev/null @@ -1,24 +0,0 @@ -package netutil - -import ( - "github.com/pkg/errors" - "golang.org/x/net/idna" -) - -const ( - maxDomainNameSize = 253 -) - -// ValidateDomainName validates the string value as a domain name -func ValidateDomainName(value string) error { - if len(value) == 0 { - return errors.New("domain name is empty") - } - if len(value) > maxDomainNameSize { - return errors.New("domain name length exceeds limit") - } - if _, err := idna.Registration.ToASCII(value); err != nil { - return errors.Wrap(err, "domain name is invalid") - } - return nil -} diff --git a/netutil/url.go b/netutil/url.go deleted file mode 100644 index e280169..0000000 --- a/netutil/url.go +++ /dev/null @@ -1,76 +0,0 @@ -package netutil - -import ( - "net" - "net/http" - "net/url" - "time" - - "github.com/pkg/errors" - - "github.com/code-payments/ocp-server/retry" - "github.com/code-payments/ocp-server/retry/backoff" -) - -// ValidateHttpUrl validates a URL for an HTTP scheme -func ValidateHttpUrl( - value string, - requireSecureConnection bool, - fetchContent bool, -) error { - parsed, err := url.Parse(value) - if err != nil { - return err - } - - if len(parsed.Scheme) == 0 { - // Add a HTTP scheme by default - value = "http://" + value - parsed, err = url.Parse(value) - if err != nil { - return err - } - } - - if requireSecureConnection && parsed.Scheme != "https" { - return errors.New("url scheme must be https") - } - - if parsed.Scheme != "http" && parsed.Scheme != "https" { - return errors.New("url scheme must be http or https") - } - - if len(parsed.Host) == 0 { - return errors.New("host component missing") - } else if err := ValidateDomainName(parsed.Host); err != nil { - return errors.Wrap(err, "host is not a valid domain name") - } - - if fetchContent { - // Best-effort attempt to fetch the content - var resp *http.Response - _, err = retry.Retry( - func() error { - resp, err = http.Get(value) - return err - }, - retry.Limit(5), - retry.Backoff(backoff.BinaryExponential(100*time.Millisecond), time.Second), - ) - if err != nil { - return err - } - - if resp.StatusCode != http.StatusOK { - return errors.Errorf("%d status code fetching content", resp.StatusCode) - } - } else { - // If not fetching content, then ensure the hostname is valid - _, err := net.LookupIP(parsed.Hostname()) - if err != nil { - return errors.Wrap(err, "error resolving hostname") - } - } - - return nil -} diff --git a/solana/vm/virtual_instructions_airdrop.go b/solana/vm/virtual_instructions_airdrop.go deleted file mode 100644 index 6ec7fad..0000000 --- a/solana/vm/virtual_instructions_airdrop.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -const ( - AirdropVirtrualInstructionDataSize = (SignatureSize + // signature - 8 + // amount - 1) // count -) - -type AirdropVirtualInstructionArgs struct { - Amount uint64 - Count uint8 - Signature Signature -} - -func NewAirdropVirtualInstruction( - args *AirdropVirtualInstructionArgs, -) VirtualInstruction { - var offset int - data := make([]byte, AirdropVirtrualInstructionDataSize) - putSignature(data, args.Signature, &offset) - putUint64(data, args.Amount, &offset) - putUint8(data, args.Count, &offset) - - return VirtualInstruction{ - Opcode: OpcodeAirdrop, - Data: data, - } -} diff --git a/solana/vm/virtual_instructions_conditional_transfer.go b/solana/vm/virtual_instructions_conditional_transfer.go deleted file mode 100644 index 4be8c65..0000000 --- a/solana/vm/virtual_instructions_conditional_transfer.go +++ /dev/null @@ -1,25 +0,0 @@ -package vm - -const ( - ConditionalTransferVirtrualInstructionDataSize = (SignatureSize + // signature - 8) // amount -) - -type ConditionalTransferVirtualInstructionArgs struct { - Amount uint64 - Signature Signature -} - -func NewConditionalTransferVirtualInstruction( - args *ConditionalTransferVirtualInstructionArgs, -) VirtualInstruction { - var offset int - data := make([]byte, ConditionalTransferVirtrualInstructionDataSize) - putSignature(data, args.Signature, &offset) - putUint64(data, args.Amount, &offset) - - return VirtualInstruction{ - Opcode: OpcodeConditionalTransfer, - Data: data, - } -}