mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-12-06 17:27:57 +00:00
chore(code-samples): remove all emojis
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Peersyst/xrpl-go/examples/clients"
|
||||
"github.com/Peersyst/xrpl-go/pkg/crypto"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
|
||||
rippletime "github.com/Peersyst/xrpl-go/xrpl/time"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/transaction"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/wallet"
|
||||
"github.com/Peersyst/xrpl-go/examples/clients"
|
||||
"github.com/Peersyst/xrpl-go/pkg/crypto"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
|
||||
rippletime "github.com/Peersyst/xrpl-go/xrpl/time"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/transaction"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/wallet"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println("⏳ Setting up client...")
|
||||
fmt.Println("Setting up client...")
|
||||
|
||||
client := clients.GetDevnetWebsocketClient()
|
||||
fmt.Println("Connecting to server...")
|
||||
@@ -26,7 +26,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("✅ Client configured!")
|
||||
fmt.Println("Client configured!")
|
||||
fmt.Println()
|
||||
|
||||
fmt.Printf("Connection: %t", client.IsConnected())
|
||||
@@ -35,41 +35,41 @@ func main() {
|
||||
// Configure wallets
|
||||
|
||||
// Issuer
|
||||
fmt.Println("⏳ Setting up credential issuer wallet...")
|
||||
fmt.Println("Setting up credential issuer wallet...")
|
||||
issuer, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error creating credential issuer wallet: %s\n", err)
|
||||
fmt.Printf("Error creating credential issuer wallet: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = client.FundWallet(&issuer)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error funding credential issuer wallet: %s\n", err)
|
||||
fmt.Printf("Error funding credential issuer wallet: %s\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("✅ Credential issuer wallet funded: %s\n", issuer.ClassicAddress)
|
||||
fmt.Printf("Credential issuer wallet funded: %s\n", issuer.ClassicAddress)
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Holder 1
|
||||
fmt.Println("⏳ Setting up holder 1 wallet...")
|
||||
fmt.Println("Setting up holder 1 wallet...")
|
||||
holderWallet1, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error creating holder 1 wallet: %s\n", err)
|
||||
fmt.Printf("Error creating holder 1 wallet: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = client.FundWallet(&holderWallet1)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error funding holder 1 wallet: %s\n", err)
|
||||
fmt.Printf("Error funding holder 1 wallet: %s\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("✅ Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress)
|
||||
fmt.Printf("Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress)
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Enabling DepositAuth on the issuer account with an AccountSet transaction
|
||||
fmt.Println("⏳ Enabling DepositAuth on the issuer account...")
|
||||
fmt.Println("Enabling DepositAuth on the issuer account...")
|
||||
accountSetTx := &transaction.AccountSet{
|
||||
BaseTx: transaction.BaseTx{
|
||||
Account: issuer.ClassicAddress,
|
||||
@@ -83,11 +83,11 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Creating the CredentialCreate transaction
|
||||
fmt.Println("⏳ Creating the CredentialCreate transaction...")
|
||||
fmt.Println("Creating the CredentialCreate transaction...")
|
||||
|
||||
expiration, err := rippletime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339))
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error converting expiration to ripple time: %s\n", err)
|
||||
fmt.Printf("Error converting expiration to ripple time: %s\n", err)
|
||||
return
|
||||
}
|
||||
credentialType := types.CredentialType("6D795F63726564656E7469616C") // my_credential
|
||||
@@ -108,7 +108,7 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Creating the CredentialAccept transaction
|
||||
fmt.Println("⏳ Creating the CredentialAccept transaction...")
|
||||
fmt.Println("Creating the CredentialAccept transaction...")
|
||||
|
||||
credentialAcceptTx := &transaction.CredentialAccept{
|
||||
BaseTx: transaction.BaseTx{
|
||||
@@ -124,7 +124,7 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Creating the DepositPreauth transaction
|
||||
fmt.Println("⏳ Creating the DepositPreauth transaction using AuthorizeCredentials...")
|
||||
fmt.Println("Creating the DepositPreauth transaction using AuthorizeCredentials...")
|
||||
|
||||
depositPreauthTx := &transaction.DepositPreauth{
|
||||
BaseTx: transaction.BaseTx{
|
||||
@@ -146,7 +146,7 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Get the credential ID
|
||||
fmt.Println("⏳ Getting the credential ID from the holder 1 account...")
|
||||
fmt.Println("Getting the credential ID from the holder 1 account...")
|
||||
|
||||
objectsRequest := &account.ObjectsRequest{
|
||||
Account: holderWallet1.ClassicAddress,
|
||||
@@ -156,30 +156,30 @@ func main() {
|
||||
|
||||
objectsResponse, err := client.GetAccountObjects(objectsRequest)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error getting the credential ID: %s\n", err)
|
||||
fmt.Printf("Error getting the credential ID: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if we have any credential objects
|
||||
if len(objectsResponse.AccountObjects) == 0 {
|
||||
fmt.Println("❌ No credential objects found")
|
||||
fmt.Println("No credential objects found")
|
||||
return
|
||||
}
|
||||
|
||||
// Extract the credential ID
|
||||
credentialID, ok := objectsResponse.AccountObjects[0]["index"].(string)
|
||||
if !ok {
|
||||
fmt.Println("❌ Could not extract credential ID from response")
|
||||
fmt.Println("Could not extract credential ID from response")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("✅ Credential ID: %s\n", credentialID)
|
||||
fmt.Printf("Credential ID: %s\n", credentialID)
|
||||
fmt.Println()
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Sending XRP to the holder 1 account
|
||||
fmt.Println("⏳ Sending XRP to the issuer account, should succeed...")
|
||||
fmt.Println("Sending XRP to the issuer account, should succeed...")
|
||||
|
||||
sendTx := &transaction.Payment{
|
||||
BaseTx: transaction.BaseTx{
|
||||
@@ -196,7 +196,7 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Unauthorize the holder 1 account
|
||||
fmt.Println("⏳ Unauthorize the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...")
|
||||
fmt.Println("Unauthorize the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...")
|
||||
|
||||
unauthorizeTx := &transaction.DepositPreauth{
|
||||
BaseTx: transaction.BaseTx{
|
||||
@@ -218,7 +218,7 @@ func main() {
|
||||
// -----------------------------------------------------
|
||||
|
||||
// Sending XRP to the holder 1 account again (which should fail)
|
||||
fmt.Println("⏳ Sending XRP to the issuer account again (which should fail)...")
|
||||
fmt.Println("Sending XRP to the issuer account again (which should fail)...")
|
||||
|
||||
sendTx2 := &transaction.Payment{
|
||||
BaseTx: transaction.BaseTx{
|
||||
|
||||
Reference in New Issue
Block a user