Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
moritamori committed May 1, 2021
1 parent 9a475a9 commit b55de9a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
20 changes: 14 additions & 6 deletions examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ var (
conf config
)

type key struct {
Type string `json:"type"`
Index int `json:"index"`
Context struct {
PrivateKey string `json:"privateKey"`
}
SignatureAlgorithm string `json:"signatureAlgorithm"`
HashAlgorithm string `json:"hashAlgorithm"`
}

type config struct {
Accounts struct {
Service struct {
Address string `json:"address"`
PrivateKey string `json:"privateKey"`
SigAlgo string `json:"sigAlgorithm"`
HashAlgo string `json:"hashAlgorithm"`
Address string `json:"address"`
Keys []key
}
}
Contracts map[string]string `json:"contracts"`
Expand Down Expand Up @@ -86,8 +94,8 @@ func init() {
}

func ServiceAccount(flowClient *client.Client) (flow.Address, *flow.AccountKey, crypto.Signer) {
sigAlgo := crypto.StringToSignatureAlgorithm(conf.Accounts.Service.SigAlgo)
privateKey, err := crypto.DecodePrivateKeyHex(sigAlgo, conf.Accounts.Service.PrivateKey)
sigAlgo := crypto.StringToSignatureAlgorithm(conf.Accounts.Service.Keys[0].SignatureAlgorithm)
privateKey, err := crypto.DecodePrivateKeyHex(sigAlgo, conf.Accounts.Service.Keys[0].Context.PrivateKey)
Handle(err)

addr := flow.HexToAddress(conf.Accounts.Service.Address)
Expand Down
19 changes: 16 additions & 3 deletions examples/flow.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
{
"emulators": {
"default": {
"serviceAccount": "service"
}
},
"accounts": {
"service": {
"address": "f8d6e0586b0a20c7",
"privateKey": "68ee617d9bf67a4677af80aaca5a090fcda80ff2f4dbc340e0e36201fa1f1d8c",
"sigAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "68ee617d9bf67a4677af80aaca5a090fcda80ff2f4dbc340e0e36201fa1f1d8c"
}
}
]
}
},
"contracts": {
Expand Down

0 comments on commit b55de9a

Please sign in to comment.