mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-27 23:25:51 +00:00
chore(sample-docs): unify error handling with panic(err).
This commit is contained in:
@@ -35,25 +35,21 @@ func main() {
|
||||
fmt.Println("Setting up wallets...")
|
||||
coldWallet, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating cold wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
err = client.FundWallet(&coldWallet)
|
||||
if err != nil {
|
||||
fmt.Printf("Error funding cold wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Cold wallet funded!")
|
||||
|
||||
hotWallet, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating hot wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
err = client.FundWallet(&hotWallet)
|
||||
if err != nil {
|
||||
fmt.Printf("Error funding hot wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Hot wallet funded!")
|
||||
fmt.Println()
|
||||
@@ -85,20 +81,17 @@ func main() {
|
||||
|
||||
err = client.Autofill(&flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error autofilling transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txBlob, _, err := coldWallet.Sign(flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error signing transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
response, err := client.SubmitTxBlobAndWait(txBlob, false)
|
||||
if err != nil {
|
||||
fmt.Printf("Error submitting transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !response.Validated {
|
||||
@@ -130,20 +123,17 @@ func main() {
|
||||
flattenedTx = hotColdTrustSet.Flatten()
|
||||
err = client.Autofill(&flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error autofilling transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txBlob, _, err = hotWallet.Sign(flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error signing transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
response, err = client.SubmitTxBlobAndWait(txBlob, false)
|
||||
if err != nil {
|
||||
fmt.Printf("Error submitting transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !response.Validated {
|
||||
@@ -177,20 +167,17 @@ func main() {
|
||||
flattenedTx = coldToHotPayment.Flatten()
|
||||
err = client.Autofill(&flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error autofilling transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txBlob, _, err = coldWallet.Sign(flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error signing transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
response, err = client.SubmitTxBlobAndWait(txBlob, false)
|
||||
if err != nil {
|
||||
fmt.Printf("Error submitting transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !response.Validated {
|
||||
@@ -223,20 +210,17 @@ func main() {
|
||||
flattenedTx = coldWalletClawback.Flatten()
|
||||
err = client.Autofill(&flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error autofilling transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txBlob, _, err = coldWallet.Sign(flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error signing transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
response, err = client.SubmitTxBlobAndWait(txBlob, false)
|
||||
if err != nil {
|
||||
fmt.Printf("Error submitting transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !response.Validated {
|
||||
|
||||
Reference in New Issue
Block a user