-
Notifications
You must be signed in to change notification settings - Fork 39
/
bootstrapper.go
33 lines (27 loc) · 1013 Bytes
/
bootstrapper.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
package v2
import (
"github.com/centrifuge/go-centrifuge/bootstrap"
"github.com/centrifuge/go-centrifuge/documents"
"github.com/centrifuge/go-centrifuge/errors"
"github.com/centrifuge/go-centrifuge/pending"
)
// BootstrappedService key maps to the Service implementation in Bootstrap context.
const BootstrappedService = "V2 Service"
// Bootstrapper implements bootstrap.Bootstrapper.
type Bootstrapper struct{}
// Bootstrap adds transaction.Repository into context.
func (b Bootstrapper) Bootstrap(ctx map[string]interface{}) error {
pendingDocSrv, ok := ctx[pending.BootstrappedPendingDocumentService].(pending.Service)
if !ok {
return errors.New("failed to get %s", pending.BootstrappedPendingDocumentService)
}
nftSrv, ok := ctx[bootstrap.BootstrappedInvoiceUnpaid].(documents.TokenRegistry)
if !ok {
return errors.New("failed to get %s", bootstrap.BootstrappedInvoiceUnpaid)
}
ctx[BootstrappedService] = Service{
pendingDocSrv: pendingDocSrv,
tokenRegistry: nftSrv,
}
return nil
}