Skip to content

Commit

Permalink
wormchain: change ioutil to io and os (wormhole-foundation#3970)
Browse files Browse the repository at this point in the history
* ioutil to io and os

* io to os
  • Loading branch information
charltonliv committed Jul 30, 2024
1 parent b90ea59 commit 1018463
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
14 changes: 8 additions & 6 deletions near/test/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ package main
import (
"bytes"
"fmt"

"github.com/tidwall/gjson"

// "encoding/base64"
"io/ioutil"
"io"
"net/http"
"strings"
"time"
Expand All @@ -27,7 +29,7 @@ func getTxStatus(tx string, src string) ([]byte, error) {
}

defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

func getBlock(block uint64) ([]byte, error) {
Expand All @@ -39,7 +41,7 @@ func getBlock(block uint64) ([]byte, error) {
}

defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

func getFinalBlock() ([]byte, error) {
Expand All @@ -51,7 +53,7 @@ func getFinalBlock() ([]byte, error) {
}

defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

func getChunk(chunk string) ([]byte, error) {
Expand All @@ -64,7 +66,7 @@ func getChunk(chunk string) ([]byte, error) {
}

defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

func inspectBody(block uint64, body gjson.Result) error {
Expand Down Expand Up @@ -121,7 +123,7 @@ func inspectBody(block uint64, body gjson.Result) error {
if !strings.HasPrefix(event, "EVENT_JSON:") {
continue
}
// event_json := gjson.ParseBytes(event[11:])
//event_json := gjson.ParseBytes(event[11:])
fmt.Printf("log: %s\n", event[11:])
}
}
Expand Down
7 changes: 2 additions & 5 deletions wormchain/testutil/keeper/wormhole.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"io/ioutil"
"os"
"testing"
"time"

Expand Down Expand Up @@ -97,10 +97,7 @@ func WormholeKeeperAndWasmd(t testing.TB) (*keeper.Keeper, wasmkeeper.Keeper, *w
appapp.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
scopedWasmKeeper := appapp.CapabilityKeeper.ScopeToModule(wasm.ModuleName)

wasmDir, err := ioutil.TempDir("", "")
if err != nil {
panic(err)
}
wasmDir := os.TempDir()
wasmKeeper := wasm.NewKeeper(
appCodec,
keys[wasmtypes.StoreKey],
Expand Down
9 changes: 4 additions & 5 deletions wormchain/x/wormhole/client/cli/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"io/ioutil"
"math/big"
"os"
"strings"
Expand Down Expand Up @@ -79,11 +78,11 @@ func CmdGenerateTestGuardianKey() *cobra.Command {
private_key := [32]byte{}
key.D.FillBytes(private_key[:])

err = ioutil.WriteFile(outPrivatePath, []byte(hex.EncodeToString(private_key[:])), 0644)
err = os.WriteFile(outPrivatePath, []byte(hex.EncodeToString(private_key[:])), 0644)
if err != nil {
return err
}
ioutil.WriteFile(outPublicPath, []byte(hex.EncodeToString(addr.Bytes())), 0644)
os.WriteFile(outPublicPath, []byte(hex.EncodeToString(addr.Bytes())), 0644)
if err != nil {
return err
}
Expand Down Expand Up @@ -131,15 +130,15 @@ func CmdDecodeAddress() *cobra.Command {

func ImportKeyFromFile(filePath string) (*ecdsa.PrivateKey, error) {
priv := ecdsa.PrivateKey{}
bz, err := ioutil.ReadFile(filePath)
bz, err := os.ReadFile(filePath)
if err != nil {
return &priv, err
}
return ImportKeyFromHex(string(bz))
}

func ImportPublicKeyFromFile(filePath string) ([]byte, error) {
hexBz, err := ioutil.ReadFile(filePath)
hexBz, err := os.ReadFile(filePath)
if err != nil {
return []byte{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions wormchain/x/wormhole/client/cli/tx_wasmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

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

"encoding/hex"
Expand All @@ -22,7 +22,7 @@ import (
var _ = strconv.Itoa(0)

func parseStoreCodeArgs(file string, sender sdk.AccAddress, vaa []byte) (types.MsgStoreCode, error) {
wasm, err := ioutil.ReadFile(file)
wasm, err := os.ReadFile(file)
if err != nil {
return types.MsgStoreCode{}, err
}
Expand Down

0 comments on commit 1018463

Please sign in to comment.