-
Notifications
You must be signed in to change notification settings - Fork 1
Starting to move the API endpoints over from the openAPI repository #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ElliotFriend
wants to merge
5
commits into
script3:main
Choose a base branch
from
ElliotFriend:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
972129a
Beginning to copy API docs from existing documentation
ElliotFriend 1756bbd
Starting on the `/` endpoint. Trying to check the markdown syntax
ElliotFriend 685b4e6
Figuring out the GFM table syntax.
ElliotFriend 6a852f6
Fleshing out the first two api endpoints
ElliotFriend b763d66
Starting on the `tx-functions` api endpoints
ElliotFriend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Authentication | ||
|
|
||
| ## XdrToken | ||
|
|
||
| The Turret XDR Token is a signed transaction envelope XDR that is signed by the | ||
| account seeking authentication's public key. The signed XDR, or XDR Token, is | ||
| provided as a Authorization Bearer token to the Turret. | ||
|
|
||
| ### XdrToken Structure | ||
|
|
||
| The Xdr Token Transaction is a Stellar transaction that authenticates public key | ||
| ownership against a Turret. It MUST have a Sequence Number of 0 to ensure the | ||
| transaction is not malicious and is unable to be submitted. The following | ||
| information will be pulled from the Xdr Token Transaction: | ||
|
|
||
| * Sequence Number | ||
| * Verify the sequence number is 0 - if not, reject the token. | ||
| * Source account | ||
| * The account that is paying fees in to the turret through the claimable balance | ||
| * Timebounds | ||
| * The max time of the timebounds will be the absolute UNIX expiration time of the token. | ||
| * Operations | ||
| * ClaimClaimableBalance | ||
| * The Balance Id of the Claimable Fee Balance (of the structure show below) of the fee payment to the turret. | ||
| * ManageData | ||
| * Used to pass token parameters into the turret | ||
| * Valid parameters | ||
| * Entry name = "txFunction" (If no txFunctions parameters are passed in, the turret does not limit any txFunctions to run) | ||
| * Value = the hash of the txFunction that the user is allowing the turret to run | ||
| * Signature | ||
| * The Fee Transaction is signed by the account that is the source account of the transaction | ||
|
|
||
| ### Example | ||
|
|
||
| This [RunKit Example](https://runkit.com/mootz12/60d1f69582e0580013bb591e) | ||
| showcases how to generate a XDR Token. It creates, signs, and generates a valid | ||
| Authorization token. | ||
|
|
||
| | | | | ||
| | --- | --- | | ||
| | **Security Scheme Type** | HTTP | | ||
| | **HTTP Authorization Scheme** | bearer | | ||
| | **Bearer Format** | "XDR" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Turret | ||
|
|
||
| View information about a Turret | ||
|
|
||
| ## Get Turret Information | ||
|
|
||
| Returns basic information about the turret | ||
|
|
||
| ### Request | ||
|
|
||
| ``` | ||
| GET / | ||
| ``` | ||
|
|
||
| ### Responses | ||
|
|
||
| <details><summary>200 Success</summary> | ||
|
|
||
| | key | value | | ||
| | --- | --- | | ||
| | `turret` | `string` The public key of the turret owner | | ||
| | `network` | `string` The Stellar Network the turret is on. `TESTNET` or `PUBLIC` | | ||
| | `horizon` | `string` The Horizon API the turret uses | | ||
| | `version` | `string` The repository version and last commit | | ||
| | `fee` | `object (schemas)` | | ||
| | `divisor` | `object (schemas)` | | ||
|
|
||
| </details> | ||
|
|
||
| ### Response Sample | ||
|
|
||
| ```json | ||
| { | ||
| "turret": "GB4OYM7TQTJSROWXHOJLKAX2IJ2QN4I6S6GCJH4MGWVTAO5Q5DPNADXX", | ||
| "network": "TESTNET", | ||
| "horizon": "https://horizon-testnet.stellar.org", | ||
| "version": "v0.0.0-ff9e9750369cc8aed29af9f08ae34634594cbe41", | ||
| "fee": { | ||
| "min": 1, | ||
| "max": 10, | ||
| "days": 180 | ||
| }, | ||
| "divisor": { | ||
| "upload": 1000, | ||
| "run": 100000 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Get the Turret's TOML file | ||
|
|
||
| Returns the `stellar.toml` file associated with the turret | ||
|
|
||
| ### Request | ||
|
|
||
| ``` | ||
| GET /.well-known/stellar.toml | ||
| ``` | ||
|
|
||
| ### Responses | ||
|
|
||
| <details><summary>200</summary> | ||
|
|
||
| A [Stellar TOML](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md) file | ||
|
|
||
| </details> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # txFunctions | ||
|
|
||
| Manage and run txFunctions on the Turret. A txFuntion is a JavaScript file that | ||
| outputs a valid Transaction Envelope XDR. The txFunction will be executed in a | ||
| node environment with the following default node_module packages: | ||
|
|
||
| * bignumber.js | ||
| * node-fetch | ||
| * stellar-sdk | ||
|
|
||
| ## Upload a txFunction | ||
|
|
||
| Uploads a txFunction to the turret | ||
|
|
||
| ### Request | ||
|
|
||
| ``` | ||
| POST /tx-functions | ||
| ``` | ||
|
|
||
| REQUEST BODY SCHEMA: multipart/form-data | ||
|
|
||
| | key | value | | ||
| | --- | --- | | ||
| | `txFunction` | `string` The source code to be uploaded | | ||
| | `txFunctionFields` | `string` A Base64 encoded array of json object of the input fields for the contract | | ||
| | `txFunctionFee` | `string` A signed, non-submitted transaction envelope XDR for a fee payment to the `TURRET_ADDRESS` that is greater than or equal to the byte length of the contract divided by the `UPLOAD_DIVISOR` set by the turret | | ||
|
|
||
| ### Request Sample | ||
|
|
||
| ```json | ||
| { | ||
| "txFunction": "/some/path/txFunction.js", | ||
| "txFunctionFields": "W3sibmFtZSI6ImRlc3RpbmF0aW9uIiwidHlwZSI6InN0cmluZyIsImRlc2NyaXB0aW9uIjoiU3RlbGxhciBwdWJsaWMga2V5IHlvdSdkIGxpa2UgdG8gcGF5IiwicnVsZSI6Ik11c3QgYmUgYSB2YWxpZCBhbmQgZnVuZGVkIFN0ZWxsYXIgcHVibGljIGtleSJ9XQ", | ||
| "txFunctionFee": "AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAB47DPzhNMoutc7krUC+kJ1BvEel4wkn4w1qzA7sOje0AAAAAAAAAAAAJiWgAAAAAAAAAAB0jMiGwAAAEAZjWTnxXY2lxVt0VSos6/Uvpoo3pXo6l+0Xk/P+sE5KDPwhAYkVQyXEBb8prEYprzp3aSlLF4TKcw3m/RM5IMK" | ||
| } | ||
| ``` | ||
|
|
||
| ### Responses | ||
|
|
||
| <details><summary>200 txFunction uploaded</summary> | ||
|
|
||
| RESPONSE SCHEMA: application/json | ||
|
|
||
| | key | value | | ||
| | --- | --- | | ||
| | `hash` | `string` The SHA256 hash value of the contract | | ||
| | `signer` | `string` The public key of the signer the turret will use to sign the uploaded contract | | ||
|
|
||
| </details> | ||
|
|
||
| <details><summary>402 payment required</summary> | ||
|
|
||
| RESPONSE SCHEMA: application/json | ||
|
|
||
| | key | value | | ||
| | --- | --- | | ||
| | `message` | `string` Description of what failed | | ||
| | `turret` | `string` The public key of the turret requiring payment | | ||
| | `cost` | `string` The cost of the operation in lumens | | ||
|
|
||
| </details> | ||
|
|
||
| ### Response Samples | ||
|
|
||
| #### 200 txFunction Uploaded | ||
|
|
||
| ``` | ||
| { | ||
| "hash": "78565516a844fd4dfc5a7fc7da822028b04ee0aeaf981a4a914d4510906a7a32", | ||
| "signer": "GB6VNMGXKHS4UTIXW7U23ZQFWD7UJIWCJNQZR7ISNKBTYNULCFQKKPIK" | ||
| } | ||
| ``` | ||
|
|
||
| #### 402 payment required | ||
|
|
||
| ``` | ||
| { | ||
| "message": "Failed to process txFunctionFee", | ||
| "turret": "GB4OYM7TQTJSROWXHOJLKAX2IJ2QN4I6S6GCJH4MGWVTAO5Q5DPNADXX", | ||
| "cost": "0.2740000" | ||
| } | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm undecided if this should be the new home to the API docs.
Do others have thoughts and opinions?
If we do decide to port the API docs over, I think it would be better if it lived in a subpage.
IE
Our YBX docs have an example of how this would be structured https://github.com/script3/yieldblox-docs/tree/master/technical-docs/protocol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think I can just import the generated openApi file into the gitbook ui. This might be an easy add to get all the api docs in for me. I'll investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with you about the subpage!
I think I may have misunderstood the purpose of this repo. On the notion brainstorm page, I read "Create a documentation 'hub' for all things Turrets" and thought it was a turrets-documentation-centric thing. Is it intended to be more related to the DocSprint, rather than long-term Turrets documentation?