Skip to content

Commit

Permalink
feat: a basic level guide for using pylon sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 3, 2024
1 parent 7118910 commit c3737b4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
3 changes: 3 additions & 0 deletions game_guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ you need a public wallet address to run the methods


for using Int64 use this import 'package:fixnum/fixnum.dart';

for more details please read through this
https://github.com/Pylons-tech/pylons/tree/main/dart_sdk/doc/spec
6 changes: 3 additions & 3 deletions game_guide/lib/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class StartPage extends Component {
borderColor: const Color(0xffedffab),
),
_button2 = RoundedButton(
text: 'Create Recipe',
text: 'Create Free Recipe',
action: () {
final game = parent as FlameGame;
final context = game.buildContext;
Expand All @@ -50,11 +50,11 @@ class StartPage extends Component {
borderColor: const Color(0xfffff4c7),
),
_button3 = RoundedButton(
text: 'Create Transactions',
text: 'Create Paid Recipe',
action: () {
final game = parent as FlameGame;
final context = game.buildContext;
context!.read<SdkProvider>().createTransaction();
context!.read<SdkProvider>().createPaidRecipe();
},
color: const Color(0xffadde6c),
borderColor: const Color(0xfffff4c7),
Expand Down
34 changes: 27 additions & 7 deletions game_guide/lib/sdk_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class SdkProvider with ChangeNotifier, DiagnosticableTreeMixin {
void createCookBook() async {
///* wallet address
var cookBook = Cookbook(
creator: cookBookId,
id: "demoGameCookbook",
creator: "pylo1ztzpj4v72d5gszpgendqa82erq7msaxc2hdqes",
id: cookBookId, //"demoGameCookbook",
name: "demo game cook book guide",
description: "this is guide purpose demo game guide for the developer",
developer: "Ahsan Ali",
Expand All @@ -37,7 +37,7 @@ class SdkProvider with ChangeNotifier, DiagnosticableTreeMixin {
}

///* method for creating recipe
void createRecipe() async{
void createRecipe() async {
var recipe = Recipe(
cookbookId: cookBookId,
id: "recipeId",
Expand All @@ -59,12 +59,32 @@ class SdkProvider with ChangeNotifier, DiagnosticableTreeMixin {

var response = await PylonsWallet.instance.txCreateRecipe(recipe);

print(response);

}

///* method for creating transaction
void createTransaction() {
print("createTransaction");
///* method for creating createPaidRecipe
void createPaidRecipe() async {
var recipe = Recipe(
cookbookId: cookBookId,
id: "recipeId_paid_2",
nodeVersion: Int64(),
name: "Paid recipe",
description: "this is free receipe",
version: "v0.1.3",
coinInputs: [
CoinInput(coins: [Coin(amount: "10", denom: "upylon")]),
],
itemInputs: [],
costPerBlock: Coin(denom: "upylon", amount: "0"),
entries: EntriesList(),
outputs: [],
blockInterval: Int64(0),
enabled: false,
extraInfo: "extraInfo",
);

var response = await PylonsWallet.instance.txCreateRecipe(recipe);

}

/// Makes `Counter` readable inside the devtools by listing all of its properties
Expand Down

0 comments on commit c3737b4

Please sign in to comment.