Skip to content

Commit

Permalink
feat(launch): use wasm binaries in embed fs instead of local one (#73)
Browse files Browse the repository at this point in the history
* use embed fs instead of local one

* remove unnecessary comments

* format
  • Loading branch information
Vritra4 authored Oct 28, 2024
1 parent 05d759a commit 00a3c03
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/minitiad/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ package main

import (
"encoding/json"
"os"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/initia-labs/OPinit/contrib/launchtools"
"github.com/initia-labs/OPinit/contrib/launchtools/steps"

"github.com/initia-labs/initia/app/params"
minitiaapp "github.com/initia-labs/miniwasm/app"

"github.com/initia-labs/miniwasm/contrib"

"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -69,13 +74,14 @@ func LaunchCommand(ac *appCreator, enc params.EncodingConfig, mbm module.BasicMa
func StoreAndInstantiateNFTContracts(input *launchtools.Config) launchtools.LauncherStepFunc {
return func(ctx launchtools.Launcher) error {
ctx.Logger().Info("Storing and instantiating cw721 and ics721 contracts")
fs := contrib.FS()

cw721, err := os.ReadFile("contrib/wasm/cw721_base.wasm")
cw721, err := fs.ReadFile("wasm/cw721_base.wasm")
if err != nil {
return errors.Wrapf(err, "failed to read cw721_base.wasm")
}

ics721, err := os.ReadFile("contrib/wasm/ics721_base.wasm")
ics721, err := fs.ReadFile("wasm/ics721_base.wasm")
if err != nil {
return errors.Wrapf(err, "failed to read ics721_base.wasm")
}
Expand Down
13 changes: 13 additions & 0 deletions contrib/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package contrib

import (
"embed"
)

//go:embed wasm/*
var fs embed.FS

// FS returns the embedded filesystem for the contrib package.
func FS() embed.FS {
return fs
}

0 comments on commit 00a3c03

Please sign in to comment.