Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/storage/abi/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package abi
import (
"os"
"path/filepath"
"strings"
)

type Local struct {
Expand All @@ -26,12 +27,12 @@ func NewLocal(storePath string) (*Local, error) {

// Write writes the ABI data for a given contract ID.
func (l *Local) Write(id string, data string) error {
return os.WriteFile(filepath.Join(l.path, id), []byte(data), 0644)
return os.WriteFile(filepath.Join(l.path, strings.ToLower(id)), []byte(data), 0644)
}

// Read reads the ABI data for a given contract ID.
func (l *Local) Read(id string) (string, error) {
data, err := os.ReadFile(filepath.Join(l.path, id))
data, err := os.ReadFile(filepath.Join(l.path, strings.ToLower(id)))
if err != nil {
return "", err
}
Expand All @@ -40,10 +41,10 @@ func (l *Local) Read(id string) (string, error) {
}

func (l *Local) Delete(id string) error {
return os.Remove(filepath.Join(l.path, id))
return os.Remove(filepath.Join(l.path, strings.ToLower(id)))
}

// GetPath returns the file path of the ABI for a given contract ID.
func (l *Local) GetPath(id string) string {
return filepath.Join(l.path, id)
return filepath.Join(l.path, strings.ToLower(id))
}
5 changes: 5 additions & 0 deletions pkg/storage/contract/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"iter"
"os"
"path/filepath"
"strings"
)

var (
Expand Down Expand Up @@ -40,6 +41,7 @@ func NewLocal(storePath string) (*Local, error) {

// Add adds a contract
func (l *Local) Add(address string, meta []byte) error {
address = strings.ToLower(address)
c, err := l.getContracts()
if err != nil {
return fmt.Errorf("loading contracts: %w", err)
Expand All @@ -65,6 +67,7 @@ func (l *Local) Add(address string, meta []byte) error {

// Get returns a contract info
func (l *Local) Get(address string) ([]byte, error) {
address = strings.ToLower(address)
c, err := l.getContracts()
if err != nil {
return nil, fmt.Errorf("loading contracts: %w", err)
Expand All @@ -84,6 +87,7 @@ func (l *Local) Get(address string) ([]byte, error) {

// Update replaces the metadata for an existing contract.
func (l *Local) Update(address string, meta []byte) error {
address = strings.ToLower(address)
c, err := l.getContracts()
if err != nil {
return fmt.Errorf("loading contracts: %w", err)
Expand All @@ -109,6 +113,7 @@ func (l *Local) Update(address string, meta []byte) error {

// Delete deletes a contract
func (l *Local) Delete(address string) error {
address = strings.ToLower(address)
c, err := l.getContracts()
if err != nil {
return fmt.Errorf("loading contracts: %w", err)
Expand Down
Loading