-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdist.yml
More file actions
555 lines (550 loc) · 19.8 KB
/
Copy pathdist.yml
File metadata and controls
555 lines (550 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
openapi: 3.0.3
info:
version: 0.1.1
title: Turing Signing Server Reference Documentation
contact:
url: "https://tss.stellar.org/"
license:
name: GPL-3.0 License
url: "https://www.gnu.org/licenses/gpl-3.0.en.html"
x-logo:
url: >-
https://raw.githubusercontent.com/tyvdh/stellar-turrets/master/assets/tss-logo.png
altText: Stellar Turrets Home Page
description: |
Stellar Turrets provide decentralizated contract creation on Stellar.
tags:
- name: Turret
description: View information about a Turret
- name: txFunctions
description: >
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
- name: Fees
description: >
Manage and view Fee Balances on the Turret. A Fee Balance is an XLM based
balance that the Turret will accrue fees against as txFunctions are run. A
Fee Balance is unique to a Stellar account Public Key.
- name: Control Accounts
description: Control Turret accounts.
paths:
/:
get:
tags:
- Turret
summary: Get turret information
operationId: getTurretInfo
description: |
Returns basic information about the turret
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/TurretInfo"
/.well-known/stellar.toml:
get:
tags:
- Turret
summary: Get the turrets toml file
operationId: getToml
description: |
Returns the stellar.toml file associated with the turret
responses:
"200":
description: >
A [Stellar
TOML](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md)
file
/tx-functions:
post:
tags:
- txFunctions
summary: Upload a txFunction
operationId: uploadTxFunction
description: Uploads a txFunction to the turret.
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/TxFuncUploadForm"
example:
txFunction: /some/path/txFunction.js
txFunctionFields: >-
W3sibmFtZSI6ImRlc3RpbmF0aW9uIiwidHlwZSI6InN0cmluZyIsImRlc2NyaXB0aW9uIjoiU3RlbGxhciBwdWJsaWMga2V5IHlvdSdkIGxpa2UgdG8gcGF5IiwicnVsZSI6Ik11c3QgYmUgYSB2YWxpZCBhbmQgZnVuZGVkIFN0ZWxsYXIgcHVibGljIGtleSJ9XQ
txFunctionFee: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAB47DPzhNMoutc7krUC+kJ1BvEel4wkn4w1qzA7sOje0AAAAAAAAAAAAJiWgAAAAAAAAAAB0jMiGwAAAEAZjWTnxXY2lxVt0VSos6/Uvpoo3pXo6l+0Xk/P+sE5KDPwhAYkVQyXEBb8prEYprzp3aSlLF4TKcw3m/RM5IMK
required: true
responses:
"200":
description: txFunction uploaded
content:
application/json:
schema:
$ref: "#/components/schemas/ContractUploadResponse"
"402":
description: payment required
content:
application/json:
schema:
$ref: "#/components/schemas/PaymentRequired"
"/tx-functions/{txFunctionHash}":
get:
tags:
- txFunctions
summary: Get txFunction information
operationId: getTxFunctionInfo
description: |
Returns information about an uploaded txFunction
parameters:
- name: txFunctionHash
in: path
required: true
description: The hash value of the txFunction
schema:
type: string
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/TxFunctionInfo"
"404":
description: Not Found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
message: Unable to find txFunction
status: 404
post:
tags:
- txFunctions
summary: Run a txFunction
operationId: executeTxFunction
description: Executes a txFunction on the turret
security:
- XdrToken: []
parameters:
- name: txFunctionHash
in: path
required: true
description: The hash value of the txFunction
schema:
type: string
requestBody:
description: The fields for the contract being run.
content:
application/json:
schema:
type: object
example:
txFunctionField: some input
anotherTxFunctionField: some other input
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/TxFunctionResult"
"404":
description: Not Found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
message: Unable to find txFunction
status: 404
/tx-fees:
get:
tags:
- Fees
summary: View the fee balance for a public key
operationId: getFees
description: >-
View the fee balance for a public key based on the authorized public
key.
security:
- XdrToken: []
responses:
"200":
description: Fee payment applied
content:
application/json:
schema:
$ref: "#/components/schemas/FeePaymentResponse"
"400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
message: Error message specific to failure
status: 404
"/tx-fees/{publicKey}":
post:
tags:
- Fees
summary: Send a fee payment to the turret
operationId: payFees
description: Sends a fee payment to the turret
parameters:
- name: publicKey
in: path
required: true
description: >-
The Stellar public address of the account to apply the fee payment
to
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/FeePaymentForm"
example:
txFunctionFee: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAB47DPzhNMoutc7krUC+kJ1BvEel4wkn4w1qzA7sOje0AAAAAAAAAAAAJiWgAAAAAAAAAAB0jMiGwAAAEAZjWTnxXY2lxVt0VSos6/Uvpoo3pXo6l+0Xk/P+sE5KDPwhAYkVQyXEBb8prEYprzp3aSlLF4TKcw3m/RM5IMK
required: true
responses:
"200":
description: Fee payment applied
content:
application/json:
schema:
$ref: "#/components/schemas/FeePaymentResponse"
"400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
message: Error message specific to failure
status: 404
/ctrl-accounts:
put:
tags:
- Control Accounts
summary: Manage turrets tied to txFunctions
operationId: updateCtrlAccounts
description: >-
Allows for healing a signer on a txFunction if the majority of trusted
turrets approve it.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CtrlAccounts"
required: true
responses:
"200":
description: txFunction uploaded
content:
application/json:
schema:
$ref: "#/components/schemas/CtrlAccountsResult"
components:
securitySchemes:
XdrToken:
name: Turret XDR Token
description: >
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.
### Xdr Token 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 <a href="https://runkit.com/mootz12/60d1f69582e0580013bb591e"
target="_blank">RunKit Example</a> showcases how to generate a XDR
Token. It creates, signs, and generates a valid Authorization token.
type: http
scheme: bearer
bearerFormat: XDR
x-examples:
header: test
schemas:
Fee:
type: object
properties:
min:
description: The minimum claimable fee balance allowed
type: string
example: 1
max:
description: The maximum claimable fee balance allowed
type: string
example: 10
days:
description: >-
The time allowed before the claimable fee balance is reclaimable by
the user
type: string
example: 180
Divisor:
type: object
properties:
upload:
description: The divisor used in fee calculations for uploading functions
type: string
example: 1000
run:
description: The divisor used in fee calculations for running functions
type: string
example: 100000
TurretInfo:
type: object
properties:
turret:
description: The public key of the turret owner
type: string
example: GB4OYM7TQTJSROWXHOJLKAX2IJ2QN4I6S6GCJH4MGWVTAO5Q5DPNADXX
network:
description: The Stellar Network the turret is on. TESTNET or PUBLIC
type: string
example: TESTNET
horizon:
description: The Horizon API the turret uses
type: string
example: "https://horizon-testnet.stellar.org"
version:
description: The repository version and last commit
type: string
example: v0.0.0-ff9e9750369cc8aed29af9f08ae34634594cbe41
fee:
$ref: "#/components/schemas/Fee"
divisor:
$ref: "#/components/schemas/Divisor"
TxFuncUploadForm:
type: object
properties:
txFunction:
description: The source code to be uploaded
type: string
example: /some/path/txFunction.js
txFunctionFields:
description: >
A Base64 encoded array of json object of the input fields for the
contract in this format: <pre>
<code>
[
{
"name": "paramName",
"type": "string",
"description": "This is a param",
"rule": "Required"
}
]
</code>
</pre> Valid `rules` are `Required` and `Optional`
type: string
example: >-
W3sibmFtZSI6ImRlc3RpbmF0aW9uIiwidHlwZSI6InN0cmluZyIsImRlc2NyaXB0aW9uIjoiU3RlbGxhciBwdWJsaWMga2V5IHlvdSdkIGxpa2UgdG8gcGF5IiwicnVsZSI6Ik11c3QgYmUgYSB2YWxpZCBhbmQgZnVuZGVkIFN0ZWxsYXIgcHVibGljIGtleSJ9XQ
txFunctionFee:
description: >-
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
type: string
example: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAB47DPzhNMoutc7krUC+kJ1BvEel4wkn4w1qzA7sOje0AAAAAAAAAAAAJiWgAAAAAAAAAAB0jMiGwAAAEAZjWTnxXY2lxVt0VSos6/Uvpoo3pXo6l+0Xk/P+sE5KDPwhAYkVQyXEBb8prEYprzp3aSlLF4TKcw3m/RM5IMK
ContractUploadResponse:
type: object
properties:
hash:
description: The SHA256 hash value of the contract
type: string
example: 78565516a844fd4dfc5a7fc7da822028b04ee0aeaf981a4a914d4510906a7a32
signer:
description: >-
The public key of the signer the turret will use to sign the
uploaded contract
type: string
example: GB6VNMGXKHS4UTIXW7U23ZQFWD7UJIWCJNQZR7ISNKBTYNULCFQKKPIK
PaymentRequired:
type: object
properties:
message:
description: Description of what failed
type: string
example: Failed to process txFunctionFee
turret:
description: The public key of the turret requiring payment
type: string
example: GB4OYM7TQTJSROWXHOJLKAX2IJ2QN4I6S6GCJH4MGWVTAO5Q5DPNADXX
cost:
description: The cost of the operation in lumens
type: string
example: "0.2740000"
TxFunctionInfo:
type: object
properties:
function:
description: The source code the function will execute
type: string
example: |-
(body) => {
return fetch('https://tss-contract-5wkzvvzhfmmp.runkit.sh', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then((res) => {
if (res.ok)
return res.text()
throw res
})
}
fields:
description: An array of input fields the turret accepts
type: array
example:
- name: destination
type: string
description: Stellar public key you'd like to pay
rule: Must be a valid and funded Stellar public key
signer:
description: The public key that signs for the contract
type: string
example: GB2BZXNG3JLUX4HYWRHREDMPJ4YINBLEHGZB4US2NJ2IPFNK65MCOOLG
Error:
type: object
properties:
message:
description: The error message
type: string
status:
description: The status code of the message
type: integer
TxFunctionResult:
type: object
properties:
xdr:
description: The transaction build by the txFunction in XDR form
type: string
example: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAArr/6wLdvAWAFR2sJFcN5Fy2xOkZ3C4Xrb54LTM9fAFgAAAAAAAAAAAJiWgAAAAAAAAAAA
signer:
description: >-
The public address of the account that generated the signature of
the XDR
type: string
example: GB2BZXNG3JLUX4HYWRHREDMPJ4YINBLEHGZB4US2NJ2IPFNK65MCOOLG
signature:
description: >-
The signature generated by the signer signing the xdr. NOTE - this
has not been applied to the transaction yet
type: string
example: >-
LsDA4lJN8V+4RuhPjV2xzDxnYXHtCD/y1IuXo5A5Q1aKJxz5O1v9GpmLWIZdZJrzAu/AWYvZQ1X+vmqXbcCZDw==
cost:
description: The cost in XLM for running the contract
type: string
example: "0.0119300"
FeePaymentResponse:
type: object
properties:
publicKey:
description: The public key of the Stellar account that owns the fees
type: string
example: GB6VNMGXKHS4UTIXW7U23ZQFWD7UJIWCJNQZR7ISNKBTYNULCFQKKPIK
lastModifiedTime:
description: >-
The epoch timestamp in milliseconds of the last time the fee balance
modified
type: number
example: 1631468533000
balance:
description: The current fee balance in XLM
type: string
example: 1.4234001
FeePaymentForm:
type: object
properties:
txFunctionFee:
description: >-
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
type: string
example: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAB47DPzhNMoutc7krUC+kJ1BvEel4wkn4w1qzA7sOje0AAAAAAAAAAAAJiWgAAAAAAAAAAB0jMiGwAAAEAZjWTnxXY2lxVt0VSos6/Uvpoo3pXo6l+0Xk/P+sE5KDPwhAYkVQyXEBb8prEYprzp3aSlLF4TKcw3m/RM5IMK
CtrlAccounts:
type: object
properties:
functionHash:
description: The hash of the txFunction to manage the turret access of
type: string
example: 78565516a844fd4dfc5a7fc7da822028b04ee0aeaf981a4a914d4510906a7a32
sourceAccount:
description: The source account to create the transaction to heal with
type: string
example: GB2BZXNG3JLUX4HYWRHREDMPJ4YINBLEHGZB4US2NJ2IPFNK65MCOOLG
removeTurret:
description: >-
The public address of a turret to remove signing power for a
txFunction
type: string
example: GDLXUEYABS4ZR7XA4YYY7VKVD6DHFP7TFF2N2OXGBL6JL73HCXUFVDKX
addTurret:
description: >-
The public address of a turret to add signing powers for a
txFunction
type: string
example: GB4OYM7TQTJSROWXHOJLKAX2IJ2QN4I6S6GCJH4MGWVTAO5Q5DPNADXX
CtrlAccountsResult:
type: object
properties:
xdr:
description: The transaction built to heal the account
type: string
example: >-
AAAAAgAAAABTqjFHz0quLSka8SOrkw7R07aqDNUHAe+Qm5PX0jMiGwAAAGQAHfBZAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAArr/6wLdvAWAFR2sJFcN5Fy2xOkZ3C4Xrb54LTM9fAFgAAAAAAAAAAAJiWgAAAAAAAAAAA
signer:
description: The signer for this turret
type: string
example: GB2BZXNG3JLUX4HYWRHREDMPJ4YINBLEHGZB4US2NJ2IPFNK65MCOOLG
signature:
description: >-
The signature generated by the signer signing the xdr. NOTE - this
has not been applied to the transaction yet
type: string
example: >-
LsDA4lJN8V+4RuhPjV2xzDxnYXHtCD/y1IuXo5A5Q1aKJxz5O1v9GpmLWIZdZJrzAu/AWYvZQ1X+vmqXbcCZDw==
servers:
- url: "http://valid-turret-address"