Skip to content

Commit

Permalink
Merge pull request #1066 from scrtlabs/deprecate-ioutil
Browse files Browse the repository at this point in the history
stop using ioutil
  • Loading branch information
assafmo authored Aug 24, 2022
2 parents edefe41 + 5677467 commit cb95587
Show file tree
Hide file tree
Showing 33 changed files with 141 additions and 31,870 deletions.
4 changes: 2 additions & 2 deletions app/legacy/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package legacy
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"time"

"github.com/cosmos/cosmos-sdk/x/authz"
Expand Down Expand Up @@ -53,7 +53,7 @@ $ secretd migrate /path/to/genesis.json --chain-id=secret-4 --genesis-time=2019-

importGenesis := args[0]

jsonBlob, err := ioutil.ReadFile(importGenesis)
jsonBlob, err := os.ReadFile(importGenesis)
if err != nil {
return errors.Wrap(err, "failed to read provided genesis file")
}
Expand Down
22 changes: 11 additions & 11 deletions cmd/secretd/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ blockchain. Writes the certificate in DER format to ~/attestation_cert
// Load consensus_seed_exchange_pubkey
cert := []byte(nil)
if len(args) >= 1 {
cert, err = ioutil.ReadFile(args[0])
cert, err = os.ReadFile(args[0])
if err != nil {
return err
}
} else {
cert, err = ioutil.ReadFile(filepath.Join(userHome, reg.NodeExchMasterCertPath))
cert, err = os.ReadFile(filepath.Join(userHome, reg.NodeExchMasterCertPath))
if err != nil {
return err
}
Expand All @@ -187,12 +187,12 @@ blockchain. Writes the certificate in DER format to ~/attestation_cert

// Load consensus_io_exchange_pubkey
if len(args) == 2 {
cert, err = ioutil.ReadFile(args[1])
cert, err = os.ReadFile(args[1])
if err != nil {
return err
}
} else {
cert, err = ioutil.ReadFile(filepath.Join(userHome, reg.IoExchMasterCertPath))
cert, err = os.ReadFile(filepath.Join(userHome, reg.IoExchMasterCertPath))
if err != nil {
return err
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func ParseCert() *cobra.Command {
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// parse coins trying to be sent
cert, err := ioutil.ReadFile(args[0])
cert, err := os.ReadFile(args[0])
if err != nil {
return err
}
Expand All @@ -254,7 +254,7 @@ func ConfigureSecret() *cobra.Command {
"seed that was written on-chain",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
cert, err := ioutil.ReadFile(args[0])
cert, err := os.ReadFile(args[0])
if err != nil {
return err
}
Expand Down Expand Up @@ -289,7 +289,7 @@ func ConfigureSecret() *cobra.Command {

seedFilePath := filepath.Join(nodeDir, reg.SecretNodeSeedConfig)

err = ioutil.WriteFile(seedFilePath, cfgBytes, 0o664)
err = os.WriteFile(seedFilePath, cfgBytes, 0o664)
if err != nil {
return err
}
Expand Down Expand Up @@ -449,7 +449,7 @@ Please report any issues with this command
}

// read the attestation certificate that we just created
cert, err := ioutil.ReadFile(sgxAttestationCert)
cert, err := os.ReadFile(sgxAttestationCert)
if err != nil {
_ = os.Remove(sgxAttestationCert)
return err
Expand Down Expand Up @@ -494,7 +494,7 @@ Please report any issues with this command
resp, err := http.Post(fmt.Sprintf(`%s`, regUrl), "application/json", bytes.NewBuffer(data))
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
Expand Down Expand Up @@ -559,7 +559,7 @@ Please report any issues with this command
// write seed to file - if file doesn't exist, write it. If it does, delete the existing one and create this
_, err = os.Stat(seedCfgFile)
if os.IsNotExist(err) {
err = ioutil.WriteFile(seedCfgFile, cfgBytes, 0o644)
err = os.WriteFile(seedCfgFile, cfgBytes, 0o644)
if err != nil {
return err
}
Expand All @@ -569,7 +569,7 @@ Please report any issues with this command
return fmt.Errorf("failed to modify file '%s': %w", seedCfgFile, err)
}

err = ioutil.WriteFile(seedCfgFile, cfgBytes, 0o644)
err = os.WriteFile(seedCfgFile, cfgBytes, 0o644)
if err != nil {
return fmt.Errorf("failed to create file '%s': %w", seedCfgFile, err)
}
Expand Down
3 changes: 1 addition & 2 deletions go-cosmwasm/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"

wasm "github.com/enigmampc/SecretNetwork/go-cosmwasm"
Expand All @@ -12,7 +11,7 @@ import (
func main() {
file := os.Args[1]
fmt.Printf("Running %s...\n", file)
bz, err := ioutil.ReadFile(file)
bz, err := os.ReadFile(file)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit cb95587

Please sign in to comment.