revelrylabs / elixir-stellar-client

Elixir Client for Stellar
MIT License
20 stars 8 forks source link

Protocol 14 support #81

Open abuiles opened 3 years ago

abuiles commented 3 years ago

This issue lists the changes to the Horizon API introduced by CAP-23 and CAP-33. These two CAPs comprise the public-facing changes in Stellar Protocol 14. The first Horizon version with the updated API is Horizon 1.9.0-RC, to be released 2020-09-21 (monorepo release page).

This protocol upgrade is purely additive. We expect a protocol 14 compliant SDK to be able to run successfully against a protocol 13 network.

We are aiming for the following timeline:

In what follows, "canonical form" means code:address or native (for the XLM asset).

New objects

Modified objects

New endpoints

Modified endpoints

New operations

New effects

predicate field

predicate field is a JSON representation of xdr.ClaimPredicate as defined in CAP-23 and is a requirement that needs to be satisfied to claim the balance. It is a recursive structure that can be represented in JSON using for example the following Golang struct:

type claimPredicateJSON struct {
    And           *[]claimPredicateJSON `json:"and,omitempty"`
    Or            *[]claimPredicateJSON `json:"or,omitempty"`
    Not           *claimPredicateJSON   `json:"not,omitempty"`
    Unconditional bool                  `json:"unconditional,omitempty"`
    AbsBefore     *time.Time            `json:"absBefore,omitempty"`
    RelBefore     *int64                `json:"relBefore,omitempty"`
}

Please refer to the Golang implementation for details.

The following issue shows how the Golang SDK will handle predicate creation: https://github.com/stellar/go/issues/3000

RevokeSponsorshipOp

The RevokeSponsorshipOp requires users to build LedgerKey or a struct for signers sponsorship. Ideally SDKs should expose helpers that build a valid operation for users without require them to pass an XDR LedgerKey. See the following issue for more information https://github.com/stellar/go/issues/3001 .

abuiles commented 3 years ago

Hi! We just made available a Horizon standalone network running protocol 14 which you can use to test your changes.

To get test lumens, generate a new keypair here

And then replace the account query parameter in the following URL https://friend14.herokuapp.com/?account=G... with the public account ID generated in the laboratory.

The protocol 14 standalone test network will be available until 9/30/2020 and then it will go offline.

abuiles commented 3 years ago

We noticed some effects were missing and should be incorporated (they are not included in the 1.19.0 Horizon release candidate). You can find extra context at https://github.com/stellar/go/pull/3060

Extra new effects in protocol 14

Pre-existing effects (before protocol 14) which were already being emitted by Horizon but may not be covered by the SDKs (and should be)

Updates to future friend-bot

We added a new end-point to the future friend-bot which returns a sponsored account and a sponsored data entry in that account: https://friend14.herokuapp.com/new-account

abuiles commented 3 years ago

Hi there!

Just a quick heads up that we'll be changing the keys on the JSON response for claim predicates in the next release.

We introduced a couple of keys with camelCase, but we use snake_case in Horizon.

For consistency we decided to add this change in the next release and although it is a "breaking change", we'll be doing a patch release (1.10.0) - mostly because:

  1. Testnet will be reset soon, so old data won't be relevant.
  2. There is no production data with this format since it is only generated with Protocol 14 operations.

The change renames the field absBefore to abs_before and relBefore to relBefore.

Something like this:

{
  "predicate": {
    "and": [
      {
        "not": {
          "absBefore": "100"
        }
      },
      {
        "or": [
          {
            "relBefore": "1000"
          },
          {
            "not": {
              "relBefore": "108000"
            }
          }
        ]
      }
    ]
  }
}

Will become

{
  "predicate": {
    "and": [
      {
        "not": {
          "abs_before": "100"
        }
      },
      {
        "or": [
          {
            "rel_before": "1000"
          },
          {
            "not": {
              "rel_before": "108000"
            }
          }
        ]
      }
    ]
  }
}

The following PR implements the changes listed above in the JS-SDK https://github.com/stellar/js-stellar-sdk/pull/575