Skip to content

Commit 3abb3d0

Browse files
committed
chore(SOLNENG-27): clearer comments
1 parent e622e9b commit 3abb3d0

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sequenceDiagram
77
autonumber
88
participant StakeClient as Sample stake<br> client application
99
participant StakeAPI as Stake Intent API
10-
participant Blockchain as Blockchain
10+
participant Blockchain as Blockchain RPC API
1111
box Builder Vault
1212
participant TSM1 as MPC Wallet <br>(private key share 1)
1313
participant TSM2 as MPC Wallet <br>(private key share 2)
@@ -31,7 +31,7 @@ sequenceDiagram
3131
3232
# Get Plans
3333
http -b GET https://svc.blockdaemon.com/boss/v1/plans \
34-
X-API-KEY:$STAKE_API_KEY \
34+
X-API-KEY:$STAKE_API_KEY
3535
3636
# Post Intent
3737
http -b POST https://svc.blockdaemon.com/boss/v1/ethereum/holesky/stake-intents \

main.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"context"
6+
"encoding/hex"
67
"encoding/json"
78
"fmt"
89
"log"
@@ -50,13 +51,13 @@ type Response struct {
5051
func createStakeIntent(stakeApiKey string, stakeRequest *Request) (string, string, *big.Int) {
5152
requestJson, _ := json.Marshal(stakeRequest)
5253

53-
fmt.Println("\nStake request:\n", structs.Map(stakeRequest))
54+
fmt.Println("\nStake API request:\n", structs.Map(stakeRequest))
5455

5556
req, _ := http.NewRequest("POST", "https://svc.blockdaemon.com/boss/v1/ethereum/holesky/stake-intents", bytes.NewBuffer(requestJson))
5657
req.Header.Set("Content-Type", "application/json")
5758
req.Header.Set("Accept", "application/json")
5859
req.Header.Set("X-API-Key", stakeApiKey)
59-
//req.Header.Set("Idempotency-Key", "E96E9CE5-A81E-4178-AAA7-4BDC7ED1BCC2")
60+
//req.Header.Set("Idempotency-Key", "7515F6E2-7A57-4BA5-9CFA-FA7F4ECD41CF")
6061

6162
client := &http.Client{}
6263
resp, err := client.Do(req)
@@ -79,7 +80,7 @@ func createStakeIntent(stakeApiKey string, stakeRequest *Request) (string, strin
7980
amount = amount.Mul(amount, new(big.Int).SetInt64(1000000000))
8081
totalAmount.Add(totalAmount, amount)
8182
}
82-
fmt.Println("\nStake response:\n", structs.Map(stakeResponse))
83+
fmt.Println("\nStake API response:\n", structs.Map(stakeResponse))
8384

8485
return stakeResponse.Ethereum.UnsignedTransaction, stakeResponse.Ethereum.ContractAddress, totalAmount
8586
}
@@ -182,13 +183,13 @@ func signTx(unsignedTxHash []byte) []byte {
182183
panic(err)
183184
}
184185

185-
// Construct Ethereum V R S signature format
186+
// Construct Ethereum R S V signature format
186187

187188
sigBytes := make([]byte, 2*32+1)
188189
copy(sigBytes[0:32], signature.R())
189190
copy(sigBytes[32:64], signature.S())
190191
sigBytes[64] = byte(signature.RecoveryID())
191-
fmt.Println("\nTransaction signature:\n", sigBytes)
192+
fmt.Println("\nTransaction signature:\n", hex.EncodeToString(sigBytes))
192193

193194
return sigBytes
194195
}
@@ -200,7 +201,7 @@ func sendTx(client *ethclient.Client, chainID *big.Int, unsignedTx *types.Transa
200201
if err != nil {
201202
panic(err)
202203
}
203-
fmt.Println("\nSigned raw transaction:\n", signedTx.Data())
204+
fmt.Println("\nSigned raw transaction:\n", hex.EncodeToString(signedTx.Data()))
204205

205206
err = client.SendTransaction(context.Background(), signedTx)
206207
if err != nil {
@@ -214,7 +215,7 @@ func main() {
214215
stakeApiKey := os.Getenv("STAKE_API_KEY")
215216
rpcApiKey := os.Getenv("RPC_API_KEY")
216217

217-
// Define stake intent parameters
218+
// ! Define stake intent parameters
218219
ethereumSenderAddress := "0xE8fE1C1058b34d5152f2B23908dD8c65715F2D3A"
219220
stakeWithdrawalAddress := "0xE8fE1C1058b34d5152f2B23908dD8c65715F2D3A"
220221
stakeFeeRecipientAddress := "0xE8fE1C1058b34d5152f2B23908dD8c65715F2D3A"
@@ -245,16 +246,16 @@ func main() {
245246
}
246247
fmt.Println("Balance at account:", ethereumSenderAddress, "=", (balance), "wei")
247248

248-
// Create stake intent nd receive transaction data
249+
// ! Create stake intent and receive transaction data
249250
txData, contractAddress, totalAmount := createStakeIntent(stakeApiKey, stakeRequest)
250251

251-
// Craft transaction with stake intent unsigned tx data and blockchain inputs
252+
// ! Craft transaction with stake intent unsigned tx data and blockchain inputs
252253
unsignedTx, unsignedTxHash, chainID := craftTx(client, ethereumSenderAddress, contractAddress, totalAmount, txData)
253254

254-
// Sign the transaction with MPC wallet private key shares
255+
// ! Sign the transaction with MPC wallet private key shares
255256
signature := signTx(unsignedTxHash)
256257

257-
// Broadcast the transaction to the blockchain
258+
// ! Broadcast the transaction to the blockchain
258259
txHash := sendTx(client, chainID, unsignedTx, signature)
259260
fmt.Println("\nTransaction hash:", txHash)
260261
}

0 commit comments

Comments
 (0)