wasm

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 14 Imported by: 0

README

Wasm module

Usage

(Tx) Store code
// can instantiate only store msg sender
storeMsg := types.StoreMsg {
    FilePath: "./wasmcontract.wasm",
    InstantiatePermission: "instantiate-only-sender" //optional. if method is empty string, everybody
}

// can instantiate address
// method and address must be seperated by "."
storeMsg := types.StoreMsg {
    FilePath: "./wasmcontract.wasm",
    InstantiatePermission: "instantiate-only-address.xpla19w2r47nczglwlpfynqe5769cwkwq5fvmzu5pu7" 
}

txbytes, err := xplac.StoreCode(storeMsg).CreateAndSignTx()
res, _ := xplac.Broadcast(txbytes)
(Tx) Instantiate contract
instantiateMsg := types.InstantiateMsg {
    CodeId: "1",
    Amount: "10",
    Label: "Contract instant",
    InitMsg: `{"owner":"xpla19w2r47nczglwlpfynqe5769cwkwq5fvmzu5pu7"}`,
}
txbytes, err := xplac.InstantiateContract(instantiateMsg).CreateAndSignTx()
res, _ := xplac.Broadcast(txbytes)
(Tx) Execute contract
executeMsg := types.ExecuteMsg {
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
    Amount: "0",
    ExecMsg: `{"execute_method":{"execute_key":"execute_test","execute_value":"xpla19w2r47nczglwlpfynqe5769cwkwq5fvmzu5pu7"}}`,
}
txbytes, err := xplac.ExecuteContract(executeMsg).CreateAndSignTx()
res, _ := xplac.Broadcast(txbytes)
(Tx) Clear contract admin
clearContractAdminMsg := types.ClearContractAdminMsg{
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
}
txbytes, err := xplac.ClearContractAdmin(clearContractAdminMsg).CreateAndSignTx()
res, _ := xplac.Broadcast(txbytes)
(Tx) Set contract admin
setContractAdminMsg := types.SetContractAdminMsg{
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
    NewAdmin: "xpla19w2r47nczglwlpfynqe5769cwkwq5fvmzu5pu7",
}

txbytes, err := xplac.SetContractAdmin(setContractAdminMsg).CreateAndSignTx()
res, _ := xplac.Broadcast(txbytes)
(Tx) Migrate
migrateMsg := types.MigrateMsg{
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
    CodeId: "123",
    MigrateMsg: "json encoded migrate msg",
}

txbytes, err := xplac.Migrate(migrateMsg).CreateAndSignTx()
(Query) contract
queryMsg := types.QueryMsg {
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
    QueryMsg: `{"query_method":{"query":"query_test"}}`,
}

response, _ := xplac.QueryContract(queryMsg).Query()
(Query) list code
response, _ := xplac.ListCode().Query()
(Query) list contract by code
listContractByCodeMsg := types.ListContractByCodeMsg {
    CodeId: "1",
}

response, err := xplac.ListContractByCode(listContractByCodeMsg).Query()
(Query) Download contract wasm file
downloadMsg := types.DownloadMsg{
    CodeId: "1",
    DownloadFileName: "test",
}

response, err := xplac.Download(downloadMsg).Query()
(Query) code info
codeInfoMsg := types.CodeInfoMsg{
    CodeId: "1",
}

response, err := xplac.CodeInfo(codeInfoMsg).Query()
(Query) Contract info
contractInfoMsg := types.ContractInfoMsg {
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
}

response, err := xplac.ContractInfo(contractInfoMsg).Query()
(Query) all contract state
contractStateAllMsg := types.ContractStateAllMsg{
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
}

response, err := xplac.ContractStateAll(contractStateAllMsg).Query()
(Query) contract history
contractHistoryMsg := types.ContractHistoryMsg {
    ContractAddress: "xpla14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s525s0h",
}

response, err := xplac.ContractHistory(contractHistoryMsg).Query()
(Query) pinned
response, err := xplac.Pinned().Query()
(Query) Lib wasmvm version
response, err := xplac.LibwasmvmVersion().Query()

Documentation

Index

Constants

View Source
const (
	WasmModule                    = "wasm"
	WasmStoreMsgType              = "store-code"
	WasmInstantiateMsgType        = "instantiate-contract"
	WasmExecuteMsgType            = "execute-contract"
	WasmClearContractAdminMsgType = "clear-contract-admin"
	WasmSetContractAdminMsgType   = "set-contract-admin"
	WasmMigrateMsgType            = "migrate"
	WasmQueryContractMsgType      = "query-contract"
	WasmListCodeMsgType           = "list-code"
	WasmListContractByCodeMsgType = "list-contract-by-code"
	WasmDownloadMsgType           = "download"
	WasmCodeInfoMsgType           = "code-info"
	WasmContractInfoMsgType       = "contract-info"
	WasmContractStateAllMsgType   = "contract-state-all"
	WasmContractHistoryMsgType    = "contract-history"
	WasmPinnedMsgType             = "pinned"
	WasmLibwasmvmVersionMsgType   = "libwasmvm-version"
)

Variables

This section is empty.

Functions

func AsciiDecodeString

func AsciiDecodeString(s string) ([]byte, error)

func MakeClearContractAdminMsg

func MakeClearContractAdminMsg(clearContractAdminMsg types.ClearContractAdminMsg, privKey key.PrivateKey) (wasmtypes.MsgClearAdmin, error)

(Tx) make msg - clear contract admin

func MakeCodeInfoMsg

func MakeCodeInfoMsg(codeInfoMsg types.CodeInfoMsg) (wasmtypes.QueryCodeRequest, error)

(Query) make msg - code info

func MakeContractHistoryMsg

func MakeContractHistoryMsg(contractHistoryMsg types.ContractHistoryMsg) (wasmtypes.QueryContractHistoryRequest, error)

(Query) make msg - history

func MakeContractInfoMsg

func MakeContractInfoMsg(contractInfoMsg types.ContractInfoMsg) (wasmtypes.QueryContractInfoRequest, error)

(Query) make msg - contract info

func MakeContractStateAllMsg

func MakeContractStateAllMsg(contractStateAllMsg types.ContractStateAllMsg) (wasmtypes.QueryAllContractStateRequest, error)

(Query) make msg - contract state all

func MakeDownloadMsg

func MakeDownloadMsg(downloadMsg types.DownloadMsg) ([]interface{}, error)

(Query) make msg - download

func MakeExecuteMsg

func MakeExecuteMsg(executeMsg types.ExecuteMsg, addr sdk.AccAddress) (wasmtypes.MsgExecuteContract, error)

(Tx) make msg - execute

func MakeInstantiateMsg

func MakeInstantiateMsg(instantiateMsg types.InstantiateMsg, addr sdk.AccAddress) (wasmtypes.MsgInstantiateContract, error)

(Tx) make msg - instantiate

func MakeLibwasmvmVersionMsg

func MakeLibwasmvmVersionMsg() (string, error)

(Query) make msg - libwasmvm version

func MakeListContractByCodeMsg

func MakeListContractByCodeMsg(listContractByCodeMsg types.ListContractByCodeMsg) (wasmtypes.QueryContractsByCodeRequest, error)

(Query) make msg - list contract by code

func MakeListcodeMsg

func MakeListcodeMsg() (wasmtypes.QueryCodesRequest, error)

(Query) make msg - list code

func MakeMigrateMsg

func MakeMigrateMsg(migrateMsg types.MigrateMsg, privKey key.PrivateKey) (wasmtypes.MsgMigrateContract, error)

(Tx) make msg - migrate

func MakePinnedMsg

func MakePinnedMsg() (wasmtypes.QueryPinnedCodesRequest, error)

(Query) make msg - pinned

func MakeQueryMsg

(Query) make msg - query contract

func MakeSetContractAdmintMsg

func MakeSetContractAdmintMsg(setContractAdminMsg types.SetContractAdminMsg, privKey key.PrivateKey) (wasmtypes.MsgUpdateAdmin, error)

(Tx) make msg - set contract admin

func MakeStoreCodeMsg

func MakeStoreCodeMsg(storeMsg types.StoreMsg, addr sdk.AccAddress) (wasmtypes.MsgStoreCode, error)

(Tx) make msg - store code

Types

type ArgumentDecoder

type ArgumentDecoder struct {
	// contains filtered or unexported fields
}

func NewArgDecoder

func NewArgDecoder(def func(string) ([]byte, error)) *ArgumentDecoder

Make new query decoder.

func (*ArgumentDecoder) DecodeString

func (a *ArgumentDecoder) DecodeString(s string) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL