This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
73 lines (61 loc) · 3.23 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tokens
import (
"context"
"github.com/hyperledger-labs/firefly/internal/config"
"github.com/hyperledger-labs/firefly/pkg/fftypes"
)
// Plugin is the interface implemented by each tokens plugin
type Plugin interface {
fftypes.Named
// InitPrefix initializes the set of configuration options that are valid, with defaults. Called on all plugins.
InitPrefix(prefix config.PrefixArray)
// Init initializes the plugin, with configuration
// Returns the supported featureset of the interface
Init(ctx context.Context, name string, prefix config.Prefix, callbacks Callbacks) error
// Blockchain interface must not deliver any events until start is called
Start() error
// Capabilities returns capabilities - not called until after Init
Capabilities() *Capabilities
// CreateTokenPool creates a new (fungible or non-fungible) pool of tokens
// The returned tracking ID will be used to correlate with any subsequent transaction tracking updates
CreateTokenPool(ctx context.Context, identity *fftypes.Identity, pool *fftypes.TokenPool) error
}
// Callbacks is the interface provided to the tokens plugin, to allow it to pass events back to firefly.
//
// Events must be delivered sequentially, such that event 2 is not delivered until the callback invoked for event 1
// has completed. However, it does not matter if these events are workload balance between the firefly core
// cluster instances of the node.
type Callbacks interface {
// TokensTxUpdate notifies firefly of an update to this plugin's operation within a transaction.
// Only success/failure and errorMessage (for errors) are modeled.
// opOutput can be used to add opaque protocol specific JSON from the plugin (protocol transaction ID etc.)
// Note this is an optional hook information, and stored separately to the confirmation of the actual event that was being submitted/sequenced.
// Only the party submitting the transaction will see this data.
//
// Error should will only be returned in shutdown scenarios
TokensTxUpdate(plugin Plugin, txTrackingID string, txState fftypes.OpStatus, errorMessage string, opOutput fftypes.JSONObject) error
// TokenPoolCreated notifies on the creation of a new token pool, which might have been
// submitted by us, or by any other authorized party in the network.
//
// Error should will only be returned in shutdown scenarios
TokenPoolCreated(plugin Plugin, pool *fftypes.TokenPool, signingIdentity string, protocolTxID string, additionalInfo fftypes.JSONObject) error
}
// Capabilities the supported featureset of the tokens
// interface implemented by the plugin, with the specified config
type Capabilities struct {
}