1.1.1 • Published 3 months ago

@wharfkit/transact-plugin-resource-provider v1.1.1

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
3 months ago

@wharfkit/transact-plugin-resource-provider

A transactPlugin for use with the @wharfkit/session library that provides resources to perform transactions.

Caveats

  • Resource Provider API endpoint must conform to the Resource Provider API specification.
  • To allow fees from the Resource Provider, the allowFees parameter must be specified and set to true.
  • Any fees must be paid in the networks system token, deployed on the eosio.token account using the standard token contract.

Installation

The @wharfkit/transact-plugin-resource-provider package is distributed as a module on npm.

yarn add @wharfkit/transact-plugin-resource-provider
# or
npm install --save @wharfkit/transact-plugin-resource-provider

Usage

Include when configuring the Session Kit:

import {TransactPluginResourceProvider} from '@wharfkit/transact-plugin-resource-provider'

const kit = new SessionKit(
    {
        // ... your session kit args
    },
    {
        // ... your other options
        transactPlugins: [new TransactPluginResourceProvider()],
    }
)

Or when you are manually configuring a Session:

import {TransactPluginResourceProvider} from '@wharfkit/transact-plugin-resource-provider'

const session = new Session(
    {
        // ... your session kit args
    },
    {
        // ... your other options
        transactPlugins: [new TransactPluginResourceProvider()],
    }
)

The plugin is also capable of utilizing any API that conforms to the Resource Provider API specification. To change the default endpoints, specify them in the constructor as a key/value pair using the chainId and URL.

import {TransactPluginResourceProvider} from '@wharfkit/transact-plugin-resource-provider'

const session = new Session(
    {
        // ... your session kit args
    },
    {
        // ... your other session kit options
        transactPlugins: [
            new TransactPluginResourceProvider({
                endpoints: {
                    '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d':
                        'https://jungle4.greymass.com',
                },
            }),
        ],
    }
)

The full list of options that can be passed in during instantiation are defined in the ResourceProviderOptions:

interface ResourceProviderOptions {
    // Defaults to true, determines whether or not the user will be prompted with fees.
    allowFees?: boolean
    // The API endpoints to request resources from.
    endpoints?: Record<string, string>
    // The maximum allowed fee, if a fee exists. Provides a sanity check against the API.
    maxFee?: AssetType
}

Developing

You need Make, node.js and yarn installed.

Clone the repository and run make to checkout all dependencies and build the project. See the Makefile for other useful targets. Before submitting a pull request make sure to run make lint.


Made with ☕️ & ❤️ by Greymass, if you find this useful please consider supporting us.

1.1.1

3 months ago

1.0.2

6 months ago

1.1.0

6 months ago

1.0.1

8 months ago

1.0.0

9 months ago

1.0.0-beta1

10 months ago

0.5.0

11 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.3.0

1 year ago

0.3.0-ui-16

1 year ago

0.3.0-ui-14

1 year ago

0.3.0-ui-5

1 year ago