-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnative_contract.go
60 lines (53 loc) · 1.63 KB
/
native_contract.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
package chain
import (
"time"
"github.com/saveio/themis-go-sdk/auth"
"github.com/saveio/themis-go-sdk/channel"
"github.com/saveio/themis-go-sdk/client"
"github.com/saveio/themis-go-sdk/dns"
"github.com/saveio/themis-go-sdk/fs"
cgp "github.com/saveio/themis-go-sdk/globalparam"
"github.com/saveio/themis-go-sdk/governance"
"github.com/saveio/themis-go-sdk/ontid"
"github.com/saveio/themis-go-sdk/usdt"
"github.com/saveio/themis/account"
)
const DEFAULT_POLL_FOR_CONFIRM_DURATION = time.Duration(10) * time.Second
type ContractType int
type NativeContract struct {
Usdt *usdt.Usdt
OntId *ontid.OntId
GlobalParams *cgp.GlobalParam
Auth *auth.Auth
Dns *dns.Dns
Fs *fs.Fs
Channel *channel.Channel
Governance *governance.Governance
}
func newNativeContract(client *client.ClientMgr) *NativeContract {
native := &NativeContract{}
native.Usdt = &usdt.Usdt{Client: client}
native.OntId = &ontid.OntId{Client: client}
native.GlobalParams = &cgp.GlobalParam{Client: client}
native.Auth = &auth.Auth{Client: client}
native.Dns = &dns.Dns{}
native.Dns.NewClient(&dns.Native{
Client: client,
DefAcc: nil,
})
native.Fs = &fs.Fs{}
native.Fs.NewClient(&fs.Native{
Client: client,
DefAcc: nil,
PollForTxDuration: DEFAULT_POLL_FOR_CONFIRM_DURATION,
})
native.Channel = &channel.Channel{Client: client}
native.Governance = &governance.Governance{Client: client}
return native
}
func (this *NativeContract) SetDefaultAccount(acc *account.Account) {
this.Channel.DefAcc = acc
this.Fs.SetDefaultAccount(acc)
this.Dns.SetDefaultAccount(acc)
this.Governance.DefAcc = acc
}