Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solana: porting over contracts #366

Merged
merged 13 commits into from
Dec 17, 2024
Prev Previous commit
Next Next commit
fix lint
  • Loading branch information
aalu1418 committed Dec 13, 2024
commit 31f3cdd1d42f9a42afd911bfca1ac6a05488b033
4 changes: 2 additions & 2 deletions chains/solana/contracts/tests/timelock.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func (r RoleMultisigs) GetAnyMultisig() mcmsUtils.Multisig {
if len(r.Multisigs) == 0 {
panic("no multisigs to pick from")
}
max := big.NewInt(int64(len(r.Multisigs)))
n, err := crypto_rand.Int(crypto_rand.Reader, max)
maxN := big.NewInt(int64(len(r.Multisigs)))
n, err := crypto_rand.Int(crypto_rand.Reader, maxN)
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions chains/solana/contracts/tests/utils/anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func IsEvent(event string, data []byte) bool {
return bytes.Equal(d, data[:8])
}

func ParseEvent(logs []string, event string, obj interface{}, print ...bool) error {
func ParseEvent(logs []string, event string, obj interface{}, shouldPrint ...bool) error {
for _, v := range logs {
if strings.Contains(v, "Program data:") {
encodedData := strings.TrimSpace(strings.TrimPrefix(v, "Program data:"))
Expand All @@ -141,7 +141,7 @@ func ParseEvent(logs []string, event string, obj interface{}, print ...bool) err
return err
}

if len(print) > 0 && print[0] {
if len(shouldPrint) > 0 && shouldPrint[0] {
fmt.Printf("%s: %+v\n", event, obj)
}
return nil
Expand All @@ -151,7 +151,7 @@ func ParseEvent(logs []string, event string, obj interface{}, print ...bool) err
return fmt.Errorf("%s: event not found", event)
}

func ParseMultipleEvents[T any](logs []string, event string, print bool) ([]T, error) {
func ParseMultipleEvents[T any](logs []string, event string, shouldPrint bool) ([]T, error) {
var results []T
for _, v := range logs {
if strings.Contains(v, "Program data:") {
Expand All @@ -166,7 +166,7 @@ func ParseMultipleEvents[T any](logs []string, event string, print bool) ([]T, e
return nil, err
}

if print {
if shouldPrint {
fmt.Printf("%s: %+v\n", event, obj)
}

Expand Down
4 changes: 2 additions & 2 deletions chains/solana/contracts/tests/utils/mcms/timelock.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (r RoleAccounts) RandomPick() solana.PrivateKey {
panic("no accounts to pick from")
}

max := big.NewInt(int64(len(r.Accounts)))
n, err := crypto_rand.Int(crypto_rand.Reader, max)
maxN := big.NewInt(int64(len(r.Accounts)))
n, err := crypto_rand.Int(crypto_rand.Reader, maxN)
if err != nil {
panic(err)
}
Expand Down
Loading