-
Notifications
You must be signed in to change notification settings - Fork 5
/
client.go
55 lines (45 loc) · 1.3 KB
/
client.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
package bif_core_sdk_go
import (
"errors"
"github.com/caict-4iot-dev/BIF-Core-SDK-Go/module/account"
"github.com/caict-4iot-dev/BIF-Core-SDK-Go/module/blockchain"
"github.com/caict-4iot-dev/BIF-Core-SDK-Go/module/contract"
)
// BIFSDK bif sdk interface
type BIFSDK interface {
// GetBIFAccountService ...
GetBIFAccountService() account.BIFAccountService
// GetBlockService ...
GetBlockService() blockchain.BIFBlockService
// GetTransactionService ...
GetTransactionService() blockchain.BIFTransactionService
// GetContractService ...
GetContractService() contract.BIFContractService
}
// SDK ...
type SDK struct {
url string
chainID int
}
// GetInstance initialize the SDK instance
func GetInstance(url string) (*SDK, error) {
if url == "" {
return nil, errors.New("url is empty")
}
sdk := &SDK{
url: url,
}
return sdk, nil
}
func (sdk *SDK) GetBIFAccountService() account.BIFAccountService {
return account.GetAccountInstance(sdk.url)
}
func (sdk *SDK) GetBlockService() blockchain.BIFBlockService {
return blockchain.GetBlockInstance(sdk.url)
}
func (sdk *SDK) GetTransactionService() blockchain.BIFTransactionService {
return blockchain.GetTransactionInstance(sdk.url)
}
func (sdk *SDK) GetContractService() contract.BIFContractService {
return contract.GetContractInstance(sdk.url)
}