Skip to content

Commit

Permalink
chore: moved new btc headers to str instead of json
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Jul 30, 2024
1 parent 34252d0 commit 3d58d6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
package signetlaunch

const NewBtcHeadersStr = `{
"btc_headers": [
{
"header": "0000002095156a30ef4e6c9764c0ce83fac51a37365b2092bd39bdbfd038f5b98f00000077f14ee2b34b7dcbb7e3fc624184b919b74cd047837728593140ee21e59cc5bee4c9a766644d011e4e202800",
Expand Down Expand Up @@ -85,4 +87,4 @@
"work": "180357618"
}
]
}
}`
16 changes: 7 additions & 9 deletions app/upgrades/signetlaunch/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
package signetlaunch

import (
"bytes"
"context"
"errors"
"fmt"
"os"
"path/filepath"
"sort"

store "cosmossdk.io/store/types"
Expand Down Expand Up @@ -61,18 +60,17 @@ func propLaunch(
return insertBtcHeaders(ctx, btcLigthK, newHeaders)
}

// LoadBTCHeadersFromData returns the BTC headers load from the data/btc_headers.json path.
// LoadBTCHeadersFromData returns the BTC headers load from the json string with the headers inside of it.
func LoadBTCHeadersFromData() ([]*btclighttypes.BTCHeaderInfo, error) {
pwd, err := os.Getwd()
if err != nil {
return nil, err
}
cdc := appparams.DefaultEncodingConfig().Codec
buff := bytes.NewBufferString(NewBtcHeadersStr)

btcHeadersFilePath := filepath.Join(pwd, "data/btc_headers.json")
gs, err := btclighttypes.LoadBtcLightGenStateFromFile(appparams.DefaultEncodingConfig().Codec, btcHeadersFilePath)
var gs btclighttypes.GenesisState
err := cdc.UnmarshalJSON(buff.Bytes(), &gs)
if err != nil {
return nil, err
}

return gs.BtcHeaders, nil
}

Expand Down

0 comments on commit 3d58d6d

Please sign in to comment.