-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (38 loc) · 851 Bytes
/
main.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
package main
import (
"log"
"net/url"
"github.com/aws/aws-lambda-go/lambda"
"github.com/caarlos0/env/v6"
"github.com/icon-project/steller-sponsored-account/soroban"
"github.com/stellar/go/keypair"
)
type config struct {
Soroban url.URL `env:"SOROBAN_RPC_URL,notEmpty"`
Seed string `env:"KEY_SEED,notEmpty"`
}
var (
cfg config
sorobanClient *soroban.Client
key *keypair.Full
networkPassphrase string
)
func init() {
if err := env.Parse(&cfg); err != nil {
log.Fatal(err)
}
client, err := soroban.New(cfg.Soroban.String())
if err != nil {
log.Fatal(err)
}
networkInfo, err := client.GetNetworkInfo()
if err != nil {
log.Fatal(err)
}
networkPassphrase = networkInfo.Passphrase
sorobanClient = client
key = client.LoadKeystore(cfg.Seed)
}
func main() {
lambda.Start(handleRequest)
}