chore(samples): replace tab for 4 spaces

This commit is contained in:
banasa44
2025-07-23 10:51:03 +02:00
committed by akcodez
parent 2abda7d682
commit 43630fbdca
44 changed files with 5891 additions and 5891 deletions

View File

@@ -1,26 +1,26 @@
package main
import (
"github.com/Peersyst/xrpl-go/xrpl/queries/utility"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
"github.com/Peersyst/xrpl-go/xrpl/queries/utility"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
)
func main() {
// Define the network client configuration
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
if err != nil {
panic(err)
}
// Define the network client configuration
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
if err != nil {
panic(err)
}
// Initiate the network client
client := rpc.NewClient(cfg)
// Initiate the network client
client := rpc.NewClient(cfg)
// Ping the network (used to avoid Go unused variable error, but useful to check connectivity)
_, err = client.Ping(&utility.PingRequest{})
if err != nil {
panic(err)
}
// Ping the network (used to avoid Go unused variable error, but useful to check connectivity)
_, err = client.Ping(&utility.PingRequest{})
if err != nil {
panic(err)
}
// ... custom code goes here
// ... custom code goes here
}

View File

@@ -1,25 +1,25 @@
package main
import (
"fmt"
"fmt"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)
func main() {
// Define the network client
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"))
// Define the network client
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"))
// Disconnect the client when done. (Defer executes at the end of the function)
defer client.Disconnect()
// Disconnect the client when done. (Defer executes at the end of the function)
defer client.Disconnect()
// Connect to the network
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
// Connect to the network
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
// ... custom code goes here
// ... custom code goes here
}

View File

@@ -1,59 +1,59 @@
package main
import (
"fmt"
"fmt"
"github.com/Peersyst/xrpl-go/pkg/crypto"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/ledger"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
"github.com/Peersyst/xrpl-go/pkg/crypto"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/ledger"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
)
func main() {
// Define the network client with a faucet provider
cfg, err := rpc.NewClientConfig(
"https://s.altnet.rippletest.net:51234/",
rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
if err != nil {
panic(err)
}
client := rpc.NewClient(cfg)
// Define the network client with a faucet provider
cfg, err := rpc.NewClientConfig(
"https://s.altnet.rippletest.net:51234/",
rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
if err != nil {
panic(err)
}
client := rpc.NewClient(cfg)
// Create a new wallet
w, err := wallet.New(crypto.ED25519())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("New wallet created:")
fmt.Println("Address:", w.ClassicAddress)
// Create a new wallet
w, err := wallet.New(crypto.ED25519())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("New wallet created:")
fmt.Println("Address:", w.ClassicAddress)
// Fund the wallet with testnet XRP
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
// Fund the wallet with testnet XRP
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
// Get info from the ledger about the address we just funded
acc_info, err := client.GetAccountInfo(&account.InfoRequest{
Account: w.GetAddress(),
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
// Get info from the ledger about the address we just funded
acc_info, err := client.GetAccountInfo(&account.InfoRequest{
Account: w.GetAddress(),
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
// Get info about the ledger
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
// Get info about the ledger
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
}

View File

@@ -1,74 +1,74 @@
package main
import (
"fmt"
"fmt"
"github.com/Peersyst/xrpl-go/pkg/crypto"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/ledger"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
"github.com/Peersyst/xrpl-go/pkg/crypto"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/ledger"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)
func main() {
// Define the network client with a faucet provider
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
// Define the network client with a faucet provider
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
// Disconnect the client when done. (Defer executes at the end of the function)
defer client.Disconnect()
// Disconnect the client when done. (Defer executes at the end of the function)
defer client.Disconnect()
// Connect to the network
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
// Connect to the network
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
if !client.IsConnected() {
fmt.Println("❌ Failed to connect to testnet")
return
}
if !client.IsConnected() {
fmt.Println("❌ Failed to connect to testnet")
return
}
fmt.Println("✅ Connected to testnet")
fmt.Println()
fmt.Println("✅ Connected to testnet")
fmt.Println()
// Create a new wallet
w, err := wallet.New(crypto.ED25519())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("New wallet created:")
fmt.Println("Address:", w.ClassicAddress)
// Create a new wallet
w, err := wallet.New(crypto.ED25519())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("New wallet created:")
fmt.Println("Address:", w.ClassicAddress)
// Fund the wallet with testnet XRP
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
// Fund the wallet with testnet XRP
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
// Get info from the ledger about the address we just funded
acc_info, err := client.GetAccountInfo(&account.InfoRequest{
Account: w.GetAddress(),
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
// Get info from the ledger about the address we just funded
acc_info, err := client.GetAccountInfo(&account.InfoRequest{
Account: w.GetAddress(),
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
// Get info about the ledger
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
// Get info about the ledger
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
}