Categorygithub.com/Pylons-tech/pylons_sdk
module
0.0.6
Repository: https://github.com/pylons-tech/pylons_sdk.git
Documentation: pkg.go.dev

# README

pylons SDK

pylons SDK provides packages to build blockchain games on pylons eco system.

Setup development environment

git clone https://github.com/Pylons-tech/pylons_sdk
brew install pre-commit
brew install golangci/tap/golangci-lint
go get -u golang.org/x/lint/golint
pre-commit install

SDK publish preparation

Check fixture test works fine

make fixture_tests

All the features added should have fixture test and it should be well documented.

How to implement fixture test using fixture test SDK

As in cmd/fixture_test/fixture_test.go you can add single *_test.go file and add flag parser, register default action runners, custom action runners and run test scenarios.

package fixturetest

import (
	"flag"
	"strings"
	"testing"

	inttestSDK "github.com/Pylons-tech/pylons_sdk/cmd/test_utils"
	fixturetestSDK "github.com/Pylons-tech/pylons_sdk/cmd/fixture_utils"
)

var runSerialMode = false
var useRest = false
var useKnownCookbook = false
var verifyOnly = false
var scenarios = ""
var accounts = ""

func init() {
	flag.BoolVar(&runSerialMode, "runserial", false, "true/false value to check if test will be running in parallel")
	flag.BoolVar(&useRest, "userest", false, "use rest endpoint for Tx send")
	flag.BoolVar(&useKnownCookbook, "use-known-cookbook", false, "use existing cookbook or not")
	flag.BoolVar(&verifyOnly, "verify-only", false, "use this flag to only verify")
	flag.StringVar(&scenarios, "scenarios", "", "custom scenario file names")
	flag.StringVar(&accounts, "accounts", "", "custom account names")
}

func TestFixturesViaCLI(t *testing.T) {
	flag.Parse()
	fixturetestSDK.FixtureTestOpts.IsParallel = !runSerialMode
	fixturetestSDK.FixtureTestOpts.CreateNewCookbook = !useKnownCookbook
	fixturetestSDK.FixtureTestOpts.VerifyOnly = verifyOnly
	fixturetestSDK.FixtureTestOpts.BaseDirectory = "."
	if useRest {
		inttestSDK.CLIOpts.RestEndpoint = "http://localhost:1317"
	}
	inttestSDK.CLIOpts.MaxBroadcast = 50
	fixturetestSDK.RegisterDefaultActionRunners()
	// Register custom action runners
	// fixturetestSDK.RegisterActionRunner("custom_action", CustomActionRunner)
	scenarioFileNames := []string{}
	if len(scenarios) > 0 {
		scenarioFileNames = strings.Split(scenarios, ",")
	}
	fixturetestSDK.FixtureTestOpts.AccountNames = []string{}
	if len(accounts) > 0 {
		fixturetestSDK.FixtureTestOpts.AccountNames = strings.Split(accounts, ",")
	}
	fixturetestSDK.RunTestScenarios("scenarios", scenarioFileNames, t)
}

Packages

Fixture Test Package

github.com/Pylons-tech/pylons_sdk/cmd/fixtures_test

Integration Test Utils Package

github.com/Pylons-tech/pylons_sdk/cmd/test

NoTypeNameDescription
1ConfigCLIOptsCLIOpts is a variable to manage pylonsd options.CustomNode is for custom node tcp endpoint and RestEndpoint is for custom node http endpoint.
2FnCleanFileCleanFile is a function to remove file
3FnGenTxWithMsgGenTxWithMsg is a function to generate transaction from msg
4FnGetAccountAddrGetAccountAddr is a function to get account address from key
5FnGetAccountInfoFromNameGetAccountInfoFromName is a function to get account information from account key
6FnGetActionRunnerGetActionRunner get registered action runner function
7FnGetAminoCdcGetAminoCdc is a utility function to get amino codec
8FnGetDaemonStatusGetDaemonStatus is a function to get daemon status
9FnGetHumanReadableErrorFromTxHashGetHumanReadableErrorFromTxHash is a function to get human readable error from txhash
10FnGetItemByGUIDGetItemByGUID is to get Item from ID
11FnListItemsViaCLIListItemsViaCLI is a function to list items via cli
12FnReadFileReadFile is a utility function to read file
13FnRegisterActionRunnerRegisterActionRunner registers action runner function
14FnRegisterDefaultActionRunnersRegisterDefaultActionRunners register default test functions.
15FnRunActionRunnerRunActionRunner execute registered action runner function
16FnRunPylonsdRunPylonsd is a function to run pylonsd
17FnSendMultiMsgTxWithNonceSendMultiMsgTxWithNonce is an integration test utility to send multiple message transaction from a single sender, single signed transaction.
18FnTestTxWithMsgWithNonceTestTxWithMsgWithNonce is a function to send transaction with message and nonce
19FnWaitAndGetTxDataWaitAndGetTxData is a function to get transaction data after transaction is processed
20FnWaitAndGetTxDataWaitAndGetTxData is a function to get transaction data after transaction is processed
21FnWaitForNextBlockWaitForNextBlock is a function to wait until next block

Handlers struct package

github.com/Pylons-tech/pylons_sdk/x/pylons/handlers

Structs

NoTypeNameDescription
1StructCheckExecutionResponseCheckExecutionResponse is the response for checkExecution
2StructCreateCookbookResponseCreateCookbookResponse is a struct of create cookbook response
3StructCreateRecipeResponseCreateRecipeResponse is struct of create recipe response
4StructExecuteRecipeResponseExecuteRecipeResponse is the response for executeRecipe
5StructExecuteRecipeScheduleOutputExecuteRecipeScheduleOutput is a struct that shows how execute recipe schedule output works
6StructFiatItemResponseFiatItemResponse is a struct to control fiat item response
7StructFulfillTradeResponseFulfillTradeResponse is a struct to control fulfill trade response
8StructGetParamsForPopularRecipeGetParamsForPopularRecipe is a function to get popular recipe's attributes
9StructPopularRecipeTypePopularRecipeType is a type for popular recipes
10StructUpdateItemStringResponseUpdateItemStringResponse is a struct to control update item string response

Msg structs

NoTypeNameDescription
1StructMsgCheckExecutionMsgCheckExecution defines a CheckExecution message
2StructMsgCreateCookbookMsgCreateCookbook defines a CreateCookbook message
3StructMsgCreateRecipeNewMsgCreateRecipe a constructor for CreateRecipe msg
4StructMsgCreateTradeMsgCreateTrade defines a CreateTrade message
5StructMsgDisableRecipeMsgDisableRecipe defines a DisableRecipe message
6StructMsgDisableTradeMsgDisableTrade defines a DisableTrade message
7StructMsgEnableRecipeMsgEnableRecipe defines a EnableRecipe message
8StructMsgEnableTradeMsgEnableTrade defines a EnableTrade message
9StructMsgExecuteRecipeMsgExecuteRecipe defines a SetName message
10StructMsgFiatItemMsgFiatItem is a msg struct to be used to fiat item
11StructMsgFulfillTradeNewMsgFulfillTrade a constructor for FulfillTrade msg
12StructMsgGetPylonsMsgGetPylons defines a GetPylons message
13StructMsgSendCoinsMsgSendCoins defines a SendCoins message
14StructMsgUpdateCookbookMsgUpdateCookbook defines a UpdateCookbook message
15StructMsgUpdateItemStringMsgUpdateItemString defines a UpdateItemString message
16StructMsgUpdateRecipeMsgUpdateRecipe defines a UpdateRecipe message

Msg Utility functions

NoTypeNameDescription
1ConstantDefaultCostPerBlockDefaultCostPerBlock the amount of pylons to be charged by default
2FnNewMsgCheckExecutionNewMsgCheckExecution a constructor for CheckExecution msg
3FnNewMsgCreateCookbookNewMsgCreateCookbook a constructor for CreateCookbook msg
4FnNewMsgCreateRecipeNewMsgCreateRecipe a constructor for CreateRecipe msg
5FnNewMsgCreateTradeNewMsgCreateTrade a constructor for CreateTrade msg
6FnNewMsgDisableTradeNewMsgDisableTrade a constructor for DisableTrade msg
7FnNewMsgExecuteRecipeNewMsgExecuteRecipe a constructor for ExecuteCookbook msg
8FnNewMsgFiatItemNewMsgFiatItem a constructor for MsgFiatItem msg
9FnNewMsgFulfillTradeNewMsgFulfillTrade a constructor for FulfillTrade msg
10FnNewMsgGetPylonsNewMsgGetPylons is a function to get MsgGetPylons msg from required params
11FnNewMsgUpdateItemStringNewMsgUpdateItemString is a function to get MsgUpdateItemString msg from required params

Type structs

NoTypeNameDescription
1ConstantBasicTierBasicTier is the cookbook tier which doesn't allow paid receipes which means the developers cannot have receipes where they can actually carge a fee in pylons.
2StructCoinInputListCoinInputList is a list of Coin inputs
3StructCoinOutputCoinOutput is the game elements that are needs as output to a recipe
4StructCookbookCookbook is a struct that contains all the metadata of a cookbook
5StructDoubleInputParamDoubleInputParam describes the bounds on an item input/output parameter of type float64
6StructDoubleInputParamListDoubleInputParamList is a list of DoubleInputParam
7StructEntriesListEntriesList is a struct to keep list of items and coins
8StructExecutionExecution is a recipe execution used for tracking the execution #### specifically a scheduled execution
9StructFloatStringFloatString is a wrapper to resolve the amino issues
10StructItemItem is a tradable asset
11StructItemInputItemInput is a wrapper struct for Item for recipes
12StructItemInputListItemInputList is a list of ItemInputs for convinience
13StructItemListItemList is a list of items
14StructItemModifyParamsItemModifyParams describes the fields that needs to be modified
15StructLongInputParamLongInputParam describes the bounds on an item input/output parameter of type int64
16StructLongInputParamListLongInputParamList is a list of LongInputParam
17StructPremiumTierPremiumTier the cookbook tier which does allow paid receipes
18StructRecipeRecipe is a game state machine step abstracted out as a cooking terminology
19StructStringInputParamStringInputParam describes the bounds on an item input/output parameter of type string
20StructStringInputParamListStringInputParamList is a list of StringInputParam
21StructTradeTrade is a construct to perform exchange of items and coins between users. Initiated by the sender and completed by the FulFiller.
22StructTradeListTradeList is a list of trades
23StructWeightedOutputsListWeightedOutputsList is a struct to keep items which can be generated by weight

Type Utility functions

NoTypeNameDescription
1FnGenCoinInputListGenCoinInputList is a utility function to genearte coin input list
2FnGenEntriesGenEntries is a function to generate entries from coin name and item name
3FnGenEntriesItemNameUpgradeGenEntriesItemNameUpgrade is a function to generate entries that update first item's name
4FnGenItemInputListGenItemInputList is a utility function to genearte item input list
5FnGenItemOnlyEntryGenItemOnlyEntry is a utility function to generate item only entry
6FnGenOneOutputGenOneOutput is a function to generate output with one from entry list
7FnNewPylonNewPylon Returns pylon currency

App package

github.com/Pylons-tech/pylons_sdk/app

MakeCodec

MakeCodec make codec for message marshal/unmarshal

ExecResponse

ExecResponse is the response for ListExecutions

ItemResponse

ItemResponse is the response for Items

How to debug logs

To find the errors happened in that log, you need to search for warning, error, fatal, panic. Once that's found you can debug the debug and info logs near that log and it will make sense for you what happened.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author