Rocio  O'Keefe

Rocio O'Keefe

1660782480

Pylons_dart_sdk: Pylons Cross-platform Mobile Wallet

Pylons Dart SDK

A Flutter plugin project to connect any app with the Pylons blockchain.

Note: In order to be able to connect to the Pylons blockchain, you must already have a Pylons wallet installed on your mobile device. This package does not presently support desktop platforms.

Installation

Add the pylons_flutter dependency

Open your pubspec.yaml file within the app folder and add:

dependencies:
    pylons_sdk: ^0.0.8

Enable deep links

Permissions
Android and iOS must declare link permissions in a configuration file.

Feel free to examine the example app in the example directory for Deep Links (Android) and Custom URL schemes (iOS).

The following steps are platform-specific:

For Android:

You need to declare the following intent filters in android/app/src/main/AndroidManifest.xml:

<manifest ...>
    <!-- ... other tags -->
    <queries>
        <package android:name="tech.pylons.wallet" />
    </queries>

    <application ...>
        <activity ...>
        <!-- ... other tags -->

        <!-- Pylons Links -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
                <data
                    android:scheme="pylons"
                    android:host="[YOUR_HOST]" />
        </intent-filter>


        </activity>
    </application>
</manifest>

You are responsible for setting the value of the android:host attribute. Note that it should be as unique as possible.
 

For IOS:
You need to declare the following in ios/Runner/Info.plist:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>[Put your bundle id here]</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>pylons-[YOUR_HOST]</string>
            </array>
        </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>pylons-wallet</string>
    </array>

Note: Don't put any underscores in the host name, or the iOS system will not send a response from the wallet to your app.

Import the Pylons SDK and send a test request

In main.dart

Initialise the SDK before running the app:

void main(){
    WidgetsFlutterBinding.ensureInitialized();

    PylonsWallet.setup(mode: PylonsMode.prod, host: 'example');

    runApp(const MyApp());
}

Your host here should be as in the following files:

  • android/app/src/main/AndroidManifest.xml
  • ios/Runner/Info.plist

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add pylons_sdk

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  pylons_sdk: ^0.1.2

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:pylons_sdk/pylons_sdk.dart';

example/lib/main.dart

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:pylons_sdk/pylons_sdk.dart';
import 'package:fixnum/fixnum.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  PylonsWallet.setup(mode: PylonsMode.prod, host: 'example');

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    PylonsWallet.instance.exists().then((value) {
      log('WALLET Existence $value');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

  String cookBookId = "cookbook_cry_305";
  String recipeId = "recipe_1";
  String ownerId = "pylo1v97v5qj2kvph2d02fzxxlh44wzpfmuc63vpphj";
  String itemId = "8MrbcX2hkmm";
  String executionId = "exec1213";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffoldKey,
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            ElevatedButton(
              onPressed: () async {
                goToInstall();
              },
              child: const Text('Go to install Pylons'),
            ),
            ElevatedButton(
              onPressed: () async {
                goToLogin();
              },
              child: const Text('Go to log in Pylons'),
            ),
            ElevatedButton(
              onPressed: () async {
                createCookBook();
              },
              child: const Text('Cookbook'),
            ),
            ElevatedButton(
              onPressed: () async {
                updateCookBook();
              },
              child: const Text('Update Cookbook'),
            ),
            ElevatedButton(
              onPressed: () async {
                getCookbook();
              },
              child: const Text('Get Cookbook'),
            ),
            ElevatedButton(
              onPressed: () async {
                createRecipe();
              },
              child: const Text('Recipe'),
            ),
            ElevatedButton(
              onPressed: () async {
                executeRecipe();
              },
              child: const Text('Execute Recipe'),
            ),
            ElevatedButton(
              onPressed: () async {
                updateRecipe();
              },
              child: const Text('Update Recipe'),
            ),
            ElevatedButton(
              onPressed: () async {
                getProfile();
              },
              child: const Text('Get Profile'),
            ),
            ElevatedButton(
              onPressed: () async {
                getRecipes();
              },
              child: const Text('Get All recipes'),
            ),
            ElevatedButton(
              onPressed: () async {
                getRecipe();
              },
              child: const Text('Get recipe'),
            ),
            ElevatedButton(
              onPressed: () async {
                getExecutionListByRecipe();
              },
              child: const Text('Get execution list by recipe'),
            ),
            ElevatedButton(
              onPressed: () async {
                getItemListByOwner();
              },
              child: const Text('Get Items list by owner'),
            ),
            ElevatedButton(
              onPressed: () async {
                getItemById();
              },
              child: const Text('Get Item By Id'),
            ),
            ElevatedButton(
              onPressed: () async {
                getExecutionById();
              },
              child: const Text('Get Execution By Id'),
            ),
            ElevatedButton(
              onPressed: () async {
                getTrades();
              },
              child: const Text('Get Trades'),
            ),
            ElevatedButton(
              onPressed: () async {
                placeForSale();
              },
              child: const Text('Place for sale'),
            ),
            ElevatedButton(
              onPressed: () async {
                showStripe();
              },
              child: const Text('Show Stripe'),
            ),
          ],
        ),
      ),
    );
  }

  void createCookBook() async {
    var cookBook1 = Cookbook(
        creator: "pylo1v97v5qj2kvph2d02fzxxlh44wzpfmuc63vpphj",
        id: cookBookId,
        name: "Cry Cookbook for Test",
        description: "Cookbook for running pylons recreation of LOUD",
        developer: "Pylons Inc",
        version: "v0.0.1",
        supportEmail: "corey.williams@pylons.tech",
        enabled: true);

    var response = await PylonsWallet.instance.txCreateCookbook(cookBook1);

    log('From App $response', name: 'pylons_sdk');

    if (response.success) {
      ScaffoldMessenger.of(context)
          .showSnackBar(const SnackBar(content: Text("Cookbook created")));
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text("Cookbook error : ${response.error}")));
    }
  }

  void createRecipe() async {
    var recipe = Recipe(
        cookbookId: cookBookId,
        id: recipeId,
        nodeVersion: Int64(1),
        name: "LOUD's Wooden sword lv1 buy recipe",
        description: "this recipe is used to buy wooden sword lv1.",
        version: "v0.1.3",
        coinInputs: [],
        itemInputs: [],
        costPerBlock: Coin(denom: "upylon", amount: "1000000"),
        entries: EntriesList(coinOutputs: [], itemOutputs: [
          ItemOutput(
            id: "copper_sword_lv1",
            doubles: [],
            longs: [],
            strings: [],
            mutableStrings: [],
            transferFee: [],
            tradePercentage: DecString.decStringFromDouble(0.1),
            tradeable: true,
          ),
        ], itemModifyOutputs: []),
        outputs: [
          WeightedOutputs(entryIds: ["copper_sword_lv1"], weight: Int64(1))
        ],
        blockInterval: Int64(0),
        enabled: false,
        extraInfo: "extraInfo");

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

    log('From App $response', name: 'pylons_sdk');

    if (response.success) {
      ScaffoldMessenger.of(context)
          .showSnackBar(const SnackBar(content: Text("Recipe created")));
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text("Recipe error : ${response.error}")));
    }
  }

  void executeRecipe() async {
    var response = await PylonsWallet.instance.txExecuteRecipe(
        cookbookId: cookBookId,
        recipeName: recipeId,
        coinInputIndex: 0,
        itemIds: [],
        paymentInfo: []);

    log('From App $response', name: 'pylons_sdk');

    if (response.success) {
      ScaffoldMessenger.of(context)
          .showSnackBar(const SnackBar(content: Text("Recipe  executed")));
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text("Recipe  error : ${response.error}")));
    }
  }

  void updateRecipe() async {
    var recipe = Recipe(
        cookbookId: cookBookId,
        id: recipeId,
        nodeVersion: Int64(2),
        name: "LOUD's Wooden sword lv1 buy recipe",
        description: "this recipe is used to buy wooden sword lv1.",
        version: "v1.0.5",
        coinInputs: [],
        itemInputs: [],
        costPerBlock: Coin(denom: "upylon", amount: "1000000"),
        entries: EntriesList(coinOutputs: [], itemOutputs: [
          ItemOutput(
            id: "copper_sword_lv1",
            doubles: [],
            longs: [],
            strings: [],
            mutableStrings: [],
            transferFee: [],
            tradePercentage: DecString.decStringFromDouble(0.2),
            tradeable: true,
          ),
        ], itemModifyOutputs: []),
        outputs: [
          WeightedOutputs(entryIds: ["copper_sword_lv1"], weight: Int64(1))
        ],
        blockInterval: Int64(0),
        enabled: true,
        extraInfo: "extraInfo");

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

    log('From App $response', name: 'pylons_sdk');

    if (response.success) {
      ScaffoldMessenger.of(context)
          .showSnackBar(const SnackBar(content: Text("Recipe updated")));
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text("Recipe update error : ${response.error}")));
    }
  }

  void updateCookBook() async {
    var cookBook1 = Cookbook(
        creator: "",
        id: cookBookId,
        name: "Legend of the Undead Dianasour",
        description: "Cookbook for running pylons recreation of LOUD",
        developer: "Pylons Inc",
        version: "v0.0.2",
        supportEmail: "alex@shmeeload.xyz",
        enabled: true);

    var response = await PylonsWallet.instance.txUpdateCookbook(cookBook1);

    log('From App $response', name: 'pylons_sdk');

    if (response.success) {
      ScaffoldMessenger.of(context)
          .showSnackBar(const SnackBar(content: Text("Cookbook updated")));
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text("Cookbook update error: ${response.error}")));
    }
  }

  void getProfile() async {
    var sdkResponse = await PylonsWallet.instance.getProfile();

    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  Future getRecipes() async {
    var sdkResponse = await PylonsWallet.instance.getRecipes(cookBookId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getCookbook() async {
    var sdkResponse = await PylonsWallet.instance.getCookbook(cookBookId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getRecipe() async {
    var sdkResponse =
        await PylonsWallet.instance.getRecipe(cookBookId, recipeId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getExecutionListByRecipe() async {
    var sdkResponse = await PylonsWallet.instance
        .getExecutionBasedOnRecipe(cookbookId: cookBookId, recipeId: recipeId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getItemListByOwner() async {
    var sdkResponse =
        await PylonsWallet.instance.getItemListByOwner(owner: ownerId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getItemById() async {
    var sdkResponse = await PylonsWallet.instance
        .getItemById(cookbookId: cookBookId, itemId: itemId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void getExecutionById() async {
    var sdkResponse =
        await PylonsWallet.instance.getExecutionBasedOnId(id: executionId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  Future getTrades() async {
    var sdkResponse = await PylonsWallet.instance.getTrades(ownerId);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void placeForSale() async {
    var item = ItemRef(
      cookbookId: cookBookId,
      itemId: itemId,
    );
    var sdkResponse = await PylonsWallet.instance.txPlaceForSale(item, 100);
    log(sdkResponse.toString(), name: 'pylons_sdk');
  }

  void goToInstall() async {
    final isAlreadyInstalled = await PylonsWallet.instance.exists();
    if (isAlreadyInstalled) {
      log("Pylons Wallet already installed.", name: 'pylons_sdk');
    } else {
      PylonsWallet.instance.goToInstall();
    }
  }

  void goToLogin() async {
    PylonsWallet.instance.goToPylons();
  }

  void showStripe() {
    PylonsWallet.instance.showStripe();
  }
}

Download Details:

Author: Pylons-tech
Source Code: https://github.com/Pylons-tech/pylons_dart_sdk 
License: View license

#flutter #dart #sdk #blockchain 

What is GEEK

Buddha Community

Pylons_dart_sdk: Pylons Cross-platform Mobile Wallet

Best Cross-Platform Mobile App Development and Designing Company in USA

Are you looking for the best cross-platform mobile app development and designing company in USA? We at AppClues Infotech is one of the leading and most trusted cross-platform mobile app development services company that help to build custom mobile apps for your industry that will perfectly match with your specific business requirements.

If you have any app development project then just share your specific requirements with us and get the right solution for your business.

Our Cross-Platform App Development Services
• Custom Cross-Platform App Development
• Porting Cross-Platform Apps
• Cross-Platform App Migration
• Cross-Platform UI/UX Designing
• Cross-Platform Enterprise App Development

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#cross platform mobile app development company #best cross platform mobile app development #cross platform app development services #top cross platform app development company #custom cross-platform mobile app development company in usa #hire cross-platform mobile app developers in usa

Hire Top Cross-Platform Mobile App Developers in USA

Looking for dedicated & highly skilled Cross-Platform mobile app developers for your app development project? We at AppClues Infotech have the best team of Cross-Platform mobile app developers that help to designing & developing powerful cross-platform apps with the latest trends & features.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#cross platform mobile app development company #cross platform mobile app development company #cross platform mobile app development company #top cross platform app development company #top cross platform app development company #top cross platform app development company

Cross-Platform Mobile App Development Agency in the USA

Cross-Platform Mobile App Development Agency in the USA

The latest technology in mobile application development that could change the way how mobile apps are developed is cross-platform mobile app development. This technology helps you develop an Android and iOS app in one language so the overall development time reduces drastically.

Want to develop a cross-platform mobile app in the USA?

WebClues Infotech with a huge experience in flutter and many other cross-platform mobile app technology has all the skills required to develop a cross-platform app in the USA. With multiple offices in the USA, WebClues Infotech can become a company that provides quality work at a reasonable cost.

Want to know more about our cross-platform mobile app development services in the USA?

Visit: https://www.webcluesinfotech.com/cross-platform-app-development/

#cross-platform mobile app development agency in the usa #cross-platform mobile app development agency #cross-platform mobile app development #cross-platform mobile app #cross-platform

Cross Platform Mobile App Development Company in USA

AppClues Infotech is a top-notch cross platform mobile app development company in USA. With strong mobile app designers & developers team that help to create powerful cross-platform apps using the current market technologies & functionalities.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#cross platform mobile app development company #best cross platform mobile app development #cross platform app development services #top cross platform app development company #cross-platform app development usa #hire cross-platform app developer

Platform App Design | Cross-Platform Development Services

Cross-Platform Development Services

With the development in mobile app technology, a huge time saver as well as the quality maintainer technology is Cross-Platform App development. The development of an app that takes less time to develop as well as uses one technology to develop an app for both android and iOS is game-changing technology in mobile app development.

Want to develop or design a Cross-platform app?

With the successful delivery of more than 950 projects, WebClues Infotech has got the expertise as well as a huge experience of cross-platform app development and design. With global offices in 4 continents and a customer presence in most developed countries, WebClues Infotech has got a huge network around the world.

Want to know more about our cross-platform app designs?

Visit: https://www.webcluesinfotech.com/cross-platform-design/

Share your requirements https://www.webcluesinfotech.com/contact-us/

View Portfolio https://www.webcluesinfotech.com/portfolio/

#cross-platform development services #cross platform mobile app development services #cross-platform mobile app development services #cross platform app development services #hire cross platform app developer #hire cross-platform app developer india usa,