mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 14:45:50 +00:00
chore(sample-docs): unify error handling with panic(err).
This commit is contained in:
@@ -38,37 +38,31 @@ 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!")
|
||||
|
||||
customerOneWallet, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating token wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
err = client.FundWallet(&customerOneWallet)
|
||||
if err != nil {
|
||||
fmt.Printf("Error funding customer one wallet: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Customer one wallet funded!")
|
||||
fmt.Println()
|
||||
@@ -101,20 +95,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 {
|
||||
@@ -146,20 +137,17 @@ func main() {
|
||||
flattenedTx = hotWalletAccountSet.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 {
|
||||
@@ -191,20 +179,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 {
|
||||
@@ -236,20 +221,17 @@ func main() {
|
||||
flattenedTx = customerOneColdTrustSet.Flatten()
|
||||
err = client.Autofill(&flattenedTx)
|
||||
if err != nil {
|
||||
fmt.Printf("Error autofilling transaction: %s\n", err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txBlob, _, err = customerOneWallet.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 {
|
||||
@@ -283,20 +265,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 {
|
||||
@@ -329,20 +308,17 @@ func main() {
|
||||
flattenedTx = coldToCustomerOnePayment.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 {
|
||||
@@ -370,20 +346,17 @@ func main() {
|
||||
flattenedTx = freezeColdWallet.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 {
|
||||
@@ -416,14 +389,12 @@ func main() {
|
||||
flattenedTx = hotToCustomerOnePayment.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)
|
||||
}
|
||||
|
||||
_, err = client.SubmitTxBlobAndWait(txBlob, false)
|
||||
@@ -449,20 +420,17 @@ func main() {
|
||||
flattenedTx = unfreezeColdWallet.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 {
|
||||
@@ -495,20 +463,17 @@ func main() {
|
||||
flattenedTx = hotToCustomerOnePayment.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 {
|
||||
|
||||
Reference in New Issue
Block a user