forked from hiero-ledger/hiero-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exchange_rate.go
42 lines (35 loc) · 972 Bytes
/
exchange_rate.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
package hedera
import (
"github.com/hashgraph/hedera-sdk-go/v2/proto"
)
type ExchangeRate struct {
Hbars int32
cents int32
expirationTime *proto.TimestampSeconds
}
func newExchangeRate(hbars int32, cents int32, expirationTime int64) *ExchangeRate {
exchange := ExchangeRate{
Hbars: hbars,
cents: cents,
expirationTime: &proto.TimestampSeconds{Seconds: expirationTime},
}
return &exchange
}
func exchangeRateFromProtobuf(protoExchange *proto.ExchangeRate) ExchangeRate {
var expirationTime *proto.TimestampSeconds
if protoExchange.ExpirationTime != nil {
expirationTime = protoExchange.ExpirationTime
}
return ExchangeRate{
protoExchange.HbarEquiv,
protoExchange.CentEquiv,
expirationTime,
}
}
func (exchange *ExchangeRate) toProtobuf() *proto.ExchangeRate {
return &proto.ExchangeRate{
HbarEquiv: exchange.Hbars,
CentEquiv: exchange.cents,
ExpirationTime: exchange.expirationTime,
}
}