npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blockrocket/drizzle-vue-plugin

v1.0.1

Published

A drizzle adaptor for Vue - Fetched from develop on 29/10/19

Downloads

1

Readme

Vue Plugin

Note: This is still a work in progres

$ npm install drizzle-vue-plugin

drizzle-vue-plugin adapts Drizzle for Vue development.

Getting Started

  1. Configure drizzle by defining a module. The following example lets drizzle know the web3 connection options, the contracts and contract events to monitor. It also specifies polling for account change every 15 seconds. This is useful to not be overwhelmed with polling messages while focusing on UI development.

    // drizzleOptions.js
    
    import SimpleStorage from './contracts/SimpleStorage.json'
    import ComplexStorage from './contracts/ComplexStorage.json'
    import TutorialToken from './contracts/TutorialToken.json'
    
    const options = {
      web3: {
        block: false,
        fallback: {
          type: 'ws',
          url: 'ws://127.0.0.1:9545'
        }
      },
    
      // The contracts to monitor
      contracts: [SimpleStorage, ComplexStorage, TutorialToken],
      events: {
        // monitor SimpleStorage.StorageSet events
        SimpleStorage: ['StorageSet']
      },
      polls: {
        // check accounts ever 15 seconds
        accounts: 15000
      }
    }
    
    export default options
  2. Register the drizzleVuePlugin with your Vuex Store and continue as normal with Vuex Store registration to main/root Vue instance.

    // main.js
    
    import Vue from 'vue'
    import App from './App.vue'
    import Vuex from 'vuex'
    
    import drizzleVuePlugin from 'TODO: TBD name of package'
    import drizzleOptions from './drizzleOptions'
    
    // Register Vuex
    Vue.use(Vuex)
    
    // Create and configure your Vuex Store
    const store = new Vuex.Store({ state: {} })
    
    // Register the drizzleVuePlugin
    Vue.use(drizzleVuePlugin, { store, drizzleOptions })
    
    // Register the store instance with the Root Vue instance
    new Vue({
     store,
     render: h => h(App)
    ).$mount('#app')
  3. The Vuex store will have access to 3 sub-branches of State that can be accessed with Vuex's mapGetters helper.

    • account - getAccount() - returns the current active web3 accounts.

    • contracts - getContractData({contract, method, toUtf8, toAscii}) - retrieve the smart contract state specified by contract.method and convert toUtf, or toAscii if specified.

    • drizzle - has 2 useful methods.

      1. isDrizzleInitialized() - true when drizzle is ready.
      2. drizzleInstance() - access the drizzleInstance, which may be necessary for interracting with drizzle directly, or even to access the web3 provider.
  4. You can now access 3 base components that you can use to build more sophisticated interfaces.

    • drizzle-account - render the current account and associated balance.
    • drizzle-contract - render a specific contract method.
    • drizzle-contract-form render an input for a specific contract method
  5. For more information take a look at the Test Vue Dapp

Events

The plugin adds an event bus to the root Vue instance of your application, which allows you to handle events emitted by your smart contracts. Use them in the mounted() hook of any component:

this.$drizzleEvents.$on('drizzle/contractEvent', payload => {
  // const { contractName, eventName, data } = payload
  // Do something with payload data
})

Component Props

// <drizzle-account />

props: {
  units: {
    type: String,
    default: 'Wei'
  },
  precision: {
    type: Number,
    default: 2
  }
}


// <drizzle-contract />

props: {
  contractName: {
    type: String,
    required: true
  },
  method: {
    type: String,
    required: true
  },
  label: {
    type: String,
    default: ''
  },
  toUtf8: {
    type: Boolean,
    default: false
  },
  toAscii: {
    type: Boolean,
    default: false
  },
  methodArgs: {
    type: Array,
    default: () => []
  }
}


// <drizzle-contract-form />

props: {
  contractName: {
    type: String,
    required: true
  },
  method: {
    type: String,
    required: true
  },
  methodArgs: {
    type: Array,
    default: () => []
  },

  placeholders: {
    type: Array,
    default: () => []
  }
}