-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloock.go
47 lines (40 loc) · 1.8 KB
/
bloock.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
// Package bloock provides a centralized configuration for the Bloock SDK library.
//
// For information about Bloock SDK in Go, see https://bloock.com.
package bloock
import (
"github.com/bloock/bloock-sdk-go/v2/entity/integrity"
"github.com/bloock/bloock-sdk-go/v2/internal/bridge/proto"
)
// ApiKey is a string variable representing the API key used for authentication with the Bloock SDK.
// Create one [here].
// [here]: https://dashboard.bloock.com/#
var ApiKey string
// ApiHost is a string variable representing the host URL used for API communication with the Bloock SDK.
var ApiHost string
// IdentityApiHost is a string variable representing the host URL used for Identity Managed API.
// Required to be set for identity-related features of the Bloock SDK.
var IdentityApiHost string = ""
// NetworkConfig is a map variable that holds network configurations associated
// with specific network IDs in the Bloock SDK.
var NetworkConfig map[int32]*proto.NetworkConfig = make(map[int32]*proto.NetworkConfig)
// SetProvider sets the HTTP provider for the specified network in the Bloock SDK configuration.
func SetProvider(network integrity.Network, provider string) {
if _, ok := NetworkConfig[int32(network)]; ok {
NetworkConfig[int32(network.Number())].HttpProvider = provider
} else {
NetworkConfig[int32(network.Number())] = &proto.NetworkConfig{
HttpProvider: provider,
}
}
}
// SetContractAddress sets the contract address for the specified network in the Bloock SDK configuration.
func SetContractAddress(network integrity.Network, contractAddress string) {
if _, ok := NetworkConfig[int32(network)]; ok {
NetworkConfig[int32(network.Number())].ContractAddress = contractAddress
} else {
NetworkConfig[int32(network.Number())] = &proto.NetworkConfig{
ContractAddress: contractAddress,
}
}
}