Skip to main content
Version: Next

Plugin System

In order to provide better support and allow seamless integration to other libraries (i.e. FIND) we've added Plugin System.

There are two official @onflow/flow-cadut plugins currently: @onflow/flow-cadut-plugin-find and @onflow/flow-cadut-plugin-flowns

Currently, supported plugin types are:

  • arguments

Development

You can create your own plugins - in most simple case it's an object with id, type and resolver function, which transforms input and returns value in a specific format.

Below you can find specifications for different plugin types.

Argument Resolver

Argument Resolve plugin is an object with tree fields:

NameTypeDescription
idstringUnique id prefixed with cadut-
typestringPlugin type. Should be equal to "argument"
resolverfunctionFunction handling argument's transformation

📣 type field should take value from PLUGIN_TYPES enum for compatibility’s sake

resolver(type, value)

NameTypeDescription
typestringString representation of Cadence type
valueanyCorresponding value

Returns

resolver shall return an object with two fields:

NameTypeDescription
typestringString representation of Cadence type
valueanyCorresponding transformed value

📣 type could be changed during transformation 📣 value should remain unchanged if plugin can't transform the value (for exampl if it doesn't match specific validation criteria)

Example


_11
import { PLUGIN_TYPES } from "@onflow/flow-cadut";
_11
_11
const ArgumentLoggerPlugin = {
_11
id: "cadut-argument-logger",
_11
type: PLUGIN_TYPES.ARGUMENT,
_11
resolver: (type, value) => {
_11
// this plugin will output file type and it's value, then return them unchanged
_11
log(`${type} - ${JSON.stringify(value)}`);
_11
return { type, value };
_11
},
_11
};