-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Skyway CW bindings (#1325)
# Related Github tickets - VolumeFi#2442 - VolumeFi#2468 # Background This change refactors a large amount of the existing CW integration, fixes a bug introduced with the last update & introduces bindings for the Skyway module. # Testing completed - [x] test coverage exists or has been added/updated - [x] tested in a private testnet # Breaking changes - [x] I have checked my code for breaking changes - [x] If there are breaking changes, there is a supporting migration.
- Loading branch information
1 parent
65d95c2
commit 017da08
Showing
31 changed files
with
1,398 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 0 additions & 133 deletions
133
tests/integration/scheduler/keeper/wasm_handler_test.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package libeth | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
// Validates the input string as an Ethereum Address | ||
// Addresses must not be empty, have 42 character length, start with 0x and have 40 remaining characters in [0-9a-fA-F] | ||
func ValidateEthAddress(address string) error { | ||
if address == "" { | ||
return fmt.Errorf("empty") | ||
} | ||
|
||
if has0xPrefix(address) { | ||
address = address[2:] | ||
} | ||
|
||
if _, err := hex.DecodeString(address); err != nil { | ||
return fmt.Errorf("invalid hex with error: %s", err) | ||
} | ||
|
||
if !common.IsHexAddress(address) { | ||
return fmt.Errorf("address(%s) doesn't pass format validation", address) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func has0xPrefix(str string) bool { | ||
return len(str) >= 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package libeth | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestValidateEthAddress(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
address string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Valid address with 0x prefix", | ||
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Valid address without 0x prefix", | ||
address: "742d35Cc6634C0532925a3b844Bc454e4438f44e", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Empty address", | ||
address: "", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Invalid hex characters", | ||
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44g", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Too short address", | ||
address: "0x742d35", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Too long address", | ||
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e11", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Invalid prefix", | ||
address: "1x742d35Cc6634C0532925a3b844Bc454e4438f44e", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Only 0x prefix", | ||
address: "0x", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Case-insensitive 0X prefix", | ||
address: "0X742d35Cc6634C0532925a3b844Bc454e4438f44e", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Mixed case address", | ||
address: "0x1DeaDbeeF634C0532925a3b844Bc454e4438f44e", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "All lowercase address", | ||
address: "0x1deadbeef634c0532925a3b844bc454e4438f44e", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "All uppercase address", | ||
address: "0x1DEADBEEF634C0532925A3B844BC454E4438F44E", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Special characters in address", | ||
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f4$e", | ||
wantErr: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := ValidateEthAddress(tt.address) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("ValidateEthAddress() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.