The backend for the project formerly known as signet, now known as beignet.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/imosed/signet/client"
  5. "github.com/rs/zerolog/log"
  6. "github.com/stellar/go/clients/horizonclient"
  7. "github.com/stellar/go/keypair"
  8. "github.com/stellar/go/network"
  9. "github.com/stellar/go/protocols/horizon"
  10. "github.com/stellar/go/txnbuild"
  11. )
  12. func SendAsset(from *keypair.Full, memo txnbuild.Memo, operations []txnbuild.Operation) (bool, error) {
  13. var err error
  14. source := keypair.MustParseFull(from.Seed())
  15. sourceReq := horizonclient.AccountRequest{AccountID: source.Address()}
  16. var sourceAcct horizon.Account
  17. sourceAcct, err = client.SignetClient.AccountDetail(sourceReq)
  18. if err != nil {
  19. return false, err
  20. }
  21. tx, err := txnbuild.NewTransaction(
  22. txnbuild.TransactionParams{
  23. SourceAccount: &sourceAcct,
  24. IncrementSequenceNum: true,
  25. Operations: operations,
  26. BaseFee: txnbuild.MinBaseFee,
  27. Memo: memo,
  28. Preconditions: txnbuild.Preconditions{
  29. TimeBounds: txnbuild.NewTimeout(15),
  30. },
  31. })
  32. if err != nil {
  33. return false, err
  34. }
  35. tx, err = tx.Sign(network.TestNetworkPassphrase, source)
  36. if err != nil {
  37. return false, err
  38. }
  39. var response horizon.Transaction
  40. response, err = client.SignetClient.SubmitTransaction(tx)
  41. if err != nil {
  42. return false, err
  43. }
  44. log.Info().Msg(fmt.Sprintf("Successful Transaction: { Ledger: %d, Hash: %s }", response.Ledger, response.Hash))
  45. return true, nil
  46. }