-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
swagger.yaml
519 lines (504 loc) · 14.1 KB
/
swagger.yaml
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
openapi: 3.0.3
info:
title: Tokens
version: "1.0"
description: |-
Issue, hold, transfer and redeem tokens. Backed by a distributed ledger,
preserving privacy using Zero Knowledge Proofs. This API definition fronts 4 different services, which each play a different
role in the ecosystem.
To try it out, let the Issuer issue some funds to one of the users. Watch the balances
get updated and see the transaction history. Transfer it to another account, or redeem
the tokens to destroy them.
servers:
- url: http://localhost:9000/api/v1/
description: auditor
- url: http://localhost:9100/api/v1/
description: issuer
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
paths:
# Auditor
/auditor/accounts/{id}:
servers:
- url: http://localhost:9000/api/v1/
description: auditor
get:
tags:
- auditor
parameters:
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/code"
required: true
responses:
"200":
$ref: "#/components/responses/AccountSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
operationId: auditorAccount
summary: Get an account and their balance of a certain type
/auditor/accounts/{id}/transactions:
servers:
- url: http://localhost:9000/api/v1/
description: auditor
get:
tags:
- auditor
parameters:
- $ref: "#/components/parameters/id"
operationId: auditorTransactions
summary: Get all transactions for an account
responses:
"200":
$ref: "#/components/responses/TransactionsSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
# Issuer
/issuer/issue:
servers:
- url: http://localhost:9100/api/v1/
description: issuer
summary: Issue tokens to an account
post:
tags:
- issuer
responses:
"200":
$ref: "#/components/responses/IssueSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
requestBody:
description: Instructions to issue funds to an account
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TransferRequest"
operationId: issue
summary: Issue tokens of any kind to an account
# Owner
/owner/accounts:
servers:
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
get:
tags:
- owner
responses:
"200":
$ref: "#/components/responses/AccountsSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
operationId: ownerAccounts
summary: Get all accounts on this node and their balances of each type
/owner/accounts/{id}:
servers:
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
get:
tags:
- owner
parameters:
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/code"
responses:
"200":
$ref: "#/components/responses/AccountSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
operationId: ownerAccount
summary: Get an account and its balances of each token type
/owner/accounts/{id}/transactions:
servers:
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
get:
tags:
- owner
parameters:
- $ref: "#/components/parameters/id"
operationId: ownerTransactions
summary: Get all transactions for an account
description: |
Note that the system uses Unspent Transaction Outputs (UTXO).
For a transfer, you'll often see two transactions with the same id. The user specified amount goes
to the counterparty, and some other amount (the remaining part of the input token) goes back to the
sender!
This could be confusing for a user. A simple solution is to filter out the transactions with the same
sender and recipient.
responses:
"200":
$ref: "#/components/responses/TransactionsSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
/owner/accounts/{id}/transfer:
servers:
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
summary: Transfer tokens to another account
post:
tags:
- owner
parameters:
- $ref: "#/components/parameters/id"
name: id
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TransferRequest"
responses:
"200":
$ref: "#/components/responses/TransferSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
operationId: transfer
summary: Transfer tokens to another account
/owner/accounts/{id}/redeem:
servers:
- url: http://localhost:9200/api/v1/
description: alice and bob
- url: http://localhost:9300/api/v1/
description: carlos and dan
summary: Redeem (burn) tokens
post:
tags:
- owner
parameters:
- $ref: "#/components/parameters/id"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/RedeemRequest"
operationId: redeem
summary: Redeem (burn) tokens
responses:
"200":
$ref: "#/components/responses/RedeemSuccess"
default:
$ref: "#/components/responses/ErrorResponse"
# Operations
/healthz:
get:
tags:
- operations
operationId: healthz
summary: Returns 200 if the service is healthy
responses:
"200":
$ref: "#/components/responses/HealthSuccess"
"503":
$ref: "#/components/responses/ErrorResponse"
/readyz:
get:
tags:
- operations
operationId: readyz
summary: Returns 200 if the service is ready to accept calls
responses:
"200":
$ref: "#/components/responses/HealthSuccess"
"503":
$ref: "#/components/responses/ErrorResponse"
components:
responses:
AccountSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
payload:
$ref: "#/components/schemas/Account"
AccountsSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
payload:
type: array
items:
$ref: "#/components/schemas/Account"
TransactionsSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
example: "transactions retrieved"
payload:
type: array
items:
$ref: "#/components/schemas/TransactionRecord"
TransferSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
payload:
type: string
description: Transaction id
example:
message: transferred tokens
payload: 7c26ed6e5e05f7de81a82691b66b1069d1507d9edf3c7b78ea1fa98557ee57b4
RedeemSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
example: tokens redeemed
payload:
type: string
description: Transaction id
example: 7c26ed6e5e05f7de81a82691b66b1069d1507d9edf3c7b78ea1fa98557ee57b4
IssueSuccess:
description: Success or error response
content:
application/json:
schema:
type: object
required:
- message
- payload
properties:
message:
type: string
payload:
type: string
description: Transaction id
HealthSuccess:
description: Success response
content:
application/json:
schema:
type: object
required:
- message
properties:
message:
type: string
description: ok
example:
message: ok
ErrorResponse:
description: Error response
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
schemas:
# Common
Amount:
description: The amount to issue, transfer or redeem.
type: object
required:
- code
- value
properties:
code:
description: the code of the token
default: EURX
type: string
value:
description: value in base units (usually cents)
type: integer
format: int64
minimum: 0
example:
code: EURX
value: 100
Account:
type: object
description: Information about an account and its balance
required:
- id
- balance
properties:
id:
type: string
description: account id as registered at the Certificate Authority
example: alice
balance:
type: array
description: balance in base units for each currency
items:
$ref: "#/components/schemas/Amount"
example:
id: alice
balance:
- code: EURX
value: 10000
- code: USDX
value: 200
Counterparty:
description: The counterparty in a Transfer or Issuance transaction.
required:
- node
- account
type: object
properties:
node:
description: The node that holds the recipient account
type: string
account:
type: string
example:
node: owner1
account: alice
TransactionRecord:
type: object
description: A transaction
required:
- id
- sender
- recipient
- amount
- timestamp
- status
- message
properties:
id:
type: string
description: transaction id
sender:
type: string
description: the sender of the transaction
recipient:
type: string
description: the recipient of the transaction
amount:
$ref: "#/components/schemas/Amount"
timestamp:
type: string
format: date-time
description: 'timestamp in the format: "2018-03-20T09:12:28Z"'
status:
type: string
description: Unknown | Pending | Confirmed | Deleted
message:
type: string
description: user provided message
example:
id: 123
sender: alice
recipient: bob
amount:
code: EURX
value: 100
timestamp: "2018-03-20T09:12:28Z"
status: Confirmed
message: ""
# Owner
TransferRequest:
description: Instructions to issue or transfer tokens to an account
required:
- counterparty
- amount
type: object
properties:
amount:
$ref: "#/components/schemas/Amount"
counterparty:
$ref: "#/components/schemas/Counterparty"
message:
description: optional message that will be sent and stored with the transfer transaction
type: string
RedeemRequest:
description: Instructions to redeem tokens from an account
required:
- amount
type: object
properties:
amount:
$ref: "#/components/schemas/Amount"
message:
description: optional message that will be visible to the auditor
type: string
Error:
required:
- message
- payload
type: object
properties:
message:
description: High level error message
type: string
payload:
description: Details about the error
type: string
example:
message: error message
payload: ""
parameters:
id:
name: id
schema:
example: alice
description: account id as registered at the Certificate Authority
type: string
in: path
required: true
code:
name: code
in: query
schema:
example: EURX
description: The token code to filter on
type: string
securitySchemes: {}
headers: {}
tags:
- name: issuer
description: can create tokens of any kind, and send them to owner accounts
- name: owner
description: is the service that hosts the keys and accounts of end users
- name: auditor
description: gets to see every transaction in the clear, and keeps a history
- name: operations
description: Service health and readiness
security: []