-
Notifications
You must be signed in to change notification settings - Fork 16
/
client_util.go
65 lines (59 loc) · 1.65 KB
/
client_util.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
61
62
63
64
65
package aptos
import (
"fmt"
"net/url"
"runtime/debug"
)
// ClientHeader is the header key for the SDK version
const ClientHeader = "x-aptos-client"
// ClientHeaderValue is the header value for the SDK version
var ClientHeaderValue = "aptos-go-sdk/unk"
// Sets up the ClientHeaderValue with the SDK version
func init() {
vcsRevision := "unk"
vcsMod := ""
goArch := ""
goOs := ""
buildInfo, ok := debug.ReadBuildInfo()
if ok {
for _, setting := range buildInfo.Settings {
switch setting.Key {
case "vcs.revision":
vcsRevision = setting.Value
case "vcs.modified":
vcsMod = setting.Value
case "GOARCH":
goArch = setting.Value
case "GOOS":
goOs = setting.Value
default:
}
}
}
params := url.Values{}
if vcsMod == "true" {
params.Set("m", "t")
}
params.Set("go", buildInfo.GoVersion)
if goArch != "" {
params.Set("a", goArch)
}
if goOs != "" {
params.Set("os", goOs)
}
ClientHeaderValue = fmt.Sprintf("aptos-go-sdk/%s;%s", vcsRevision, params.Encode())
}
// APTTransferTransaction Move some APT from sender to dest, only for single signer
// Amount in Octas (10^-8 APT)
//
// options may be: MaxGasAmount, GasUnitPrice, ExpirationSeconds, ValidUntil, SequenceNumber, ChainIdOption
// deprecated, please use the EntryFunction APIs
func APTTransferTransaction(client *Client, sender TransactionSigner, dest AccountAddress, amount uint64, options ...any) (rawTxn *RawTransaction, err error) {
entryFunction, err := CoinTransferPayload(nil, dest, amount)
if err != nil {
return nil, err
}
rawTxn, err = client.BuildTransaction(sender.AccountAddress(),
TransactionPayload{Payload: entryFunction}, options...)
return
}