Skip to content

Commit ac68b9d

Browse files
committed
preliminary algod box access API
1 parent a42709a commit ac68b9d

File tree

12 files changed

+693
-355
lines changed

12 files changed

+693
-355
lines changed

config/consensus.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ type ConsensusParams struct {
332332
// []byte values stored in LocalState or GlobalState key/value stores
333333
SchemaBytesMinBalance uint64
334334

335+
// Maximum length of a box (does not include name length)
336+
MaxBoxSize uint64
337+
335338
// MBR per box created
336339
BoxFlatMinBalance uint64
337340

@@ -1160,6 +1163,7 @@ func initConsensusProtocols() {
11601163
vFuture.EnableSHA256TxnCommitmentHeader = true
11611164

11621165
// Boxes (unlimited global storage)
1166+
vFuture.MaxBoxSize = 8096
11631167
vFuture.BoxFlatMinBalance = 2500
11641168
vFuture.BoxByteMinBalance = 400
11651169
vFuture.MaxAppBoxReferences = 8

daemon/algod/api/algod.oas2.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,82 @@
13091309
}
13101310
]
13111311
},
1312+
"/v2/applications/{application-id}/boxes/{box-name}": {
1313+
"get": {
1314+
"description": "Given an application ID and box name, it returns box information including box name and base64 encoded content.",
1315+
"produces": [
1316+
"application/json"
1317+
],
1318+
"schemes": [
1319+
"http"
1320+
],
1321+
"summary": "Get box information for a given application.",
1322+
"operationId": "GetApplicationBoxByName",
1323+
"parameters": [
1324+
{
1325+
"type": "integer",
1326+
"description": "An application identifier",
1327+
"name": "application-id",
1328+
"in": "path",
1329+
"required": true
1330+
},
1331+
{
1332+
"type": "string",
1333+
"description": "A box name",
1334+
"name": "box-name",
1335+
"in": "path",
1336+
"required": true
1337+
}
1338+
],
1339+
"responses": {
1340+
"200": {
1341+
"description": "OK",
1342+
"$ref": "#/responses/BoxResponse"
1343+
},
1344+
"400": {
1345+
"description": "Bad Request",
1346+
"schema": {
1347+
"$ref": "#/definitions/ErrorResponse"
1348+
}
1349+
},
1350+
"401": {
1351+
"description": "Invalid API Token",
1352+
"schema": {
1353+
"$ref": "#/definitions/ErrorResponse"
1354+
}
1355+
},
1356+
"404": {
1357+
"description": "Box Not Found",
1358+
"schema": {
1359+
"$ref": "#/definitions/ErrorResponse"
1360+
}
1361+
},
1362+
"500": {
1363+
"description": "Internal Error",
1364+
"schema": {
1365+
"$ref": "#/definitions/ErrorResponse"
1366+
}
1367+
},
1368+
"default": {
1369+
"description": "Unknown Error"
1370+
}
1371+
}
1372+
},
1373+
"parameters": [
1374+
{
1375+
"type": "integer",
1376+
"name": "application-id",
1377+
"in": "path",
1378+
"required": true
1379+
},
1380+
{
1381+
"type": "string",
1382+
"name": "box-name",
1383+
"in": "path",
1384+
"required": true
1385+
}
1386+
]
1387+
},
13121388
"/v2/assets/{asset-id}": {
13131389
"get": {
13141390
"description": "Given a asset ID, it returns asset information including creator, name, total supply and special addresses.",
@@ -2398,6 +2474,26 @@
23982474
}
23992475
}
24002476
},
2477+
"Box": {
2478+
"description": "Box name and its content.",
2479+
"type": "object",
2480+
"required": [
2481+
"name",
2482+
"value"
2483+
],
2484+
"properties": {
2485+
"name": {
2486+
"description": "\\[name\\] box name, base64 encoded",
2487+
"type": "string",
2488+
"format": "byte"
2489+
},
2490+
"value": {
2491+
"description": "\\[value\\] box value, base64 encoded.",
2492+
"type": "string",
2493+
"format": "byte"
2494+
}
2495+
}
2496+
},
24012497
"Version": {
24022498
"description": "algod version information.",
24032499
"type": "object",
@@ -3089,6 +3185,12 @@
30893185
"$ref": "#/definitions/Application"
30903186
}
30913187
},
3188+
"BoxResponse": {
3189+
"description": "Box information",
3190+
"schema": {
3191+
"$ref": "#/definitions/Box"
3192+
}
3193+
},
30923194
"AssetResponse": {
30933195
"description": "Asset information",
30943196
"schema": {

daemon/algod/api/algod.oas3.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@
330330
},
331331
"description": "Encoded block object."
332332
},
333+
"BoxResponse": {
334+
"content": {
335+
"application/json": {
336+
"schema": {
337+
"$ref": "#/components/schemas/Box"
338+
}
339+
}
340+
},
341+
"description": "Box information"
342+
},
333343
"CatchpointAbortResponse": {
334344
"content": {
335345
"application/json": {
@@ -1161,6 +1171,28 @@
11611171
],
11621172
"type": "object"
11631173
},
1174+
"Box": {
1175+
"description": "Box name and its content.",
1176+
"properties": {
1177+
"name": {
1178+
"description": "\\[name\\] box name, base64 encoded",
1179+
"format": "byte",
1180+
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
1181+
"type": "string"
1182+
},
1183+
"value": {
1184+
"description": "\\[value\\] box value, base64 encoded.",
1185+
"format": "byte",
1186+
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
1187+
"type": "string"
1188+
}
1189+
},
1190+
"required": [
1191+
"name",
1192+
"value"
1193+
],
1194+
"type": "object"
1195+
},
11641196
"BuildVersion": {
11651197
"properties": {
11661198
"branch": {
@@ -2369,6 +2401,89 @@
23692401
"summary": "Get application information."
23702402
}
23712403
},
2404+
"/v2/applications/{application-id}/boxes/{box-name}": {
2405+
"get": {
2406+
"description": "Given an application ID and box name, it returns box information including box name and base64 encoded content.",
2407+
"operationId": "GetApplicationBoxByName",
2408+
"parameters": [
2409+
{
2410+
"description": "An application identifier",
2411+
"in": "path",
2412+
"name": "application-id",
2413+
"required": true,
2414+
"schema": {
2415+
"type": "integer"
2416+
}
2417+
},
2418+
{
2419+
"description": "A box name",
2420+
"in": "path",
2421+
"name": "box-name",
2422+
"required": true,
2423+
"schema": {
2424+
"type": "string"
2425+
}
2426+
}
2427+
],
2428+
"responses": {
2429+
"200": {
2430+
"content": {
2431+
"application/json": {
2432+
"schema": {
2433+
"$ref": "#/components/schemas/Box"
2434+
}
2435+
}
2436+
},
2437+
"description": "Box information"
2438+
},
2439+
"400": {
2440+
"content": {
2441+
"application/json": {
2442+
"schema": {
2443+
"$ref": "#/components/schemas/ErrorResponse"
2444+
}
2445+
}
2446+
},
2447+
"description": "Bad Request"
2448+
},
2449+
"401": {
2450+
"content": {
2451+
"application/json": {
2452+
"schema": {
2453+
"$ref": "#/components/schemas/ErrorResponse"
2454+
}
2455+
}
2456+
},
2457+
"description": "Invalid API Token"
2458+
},
2459+
"404": {
2460+
"content": {
2461+
"application/json": {
2462+
"schema": {
2463+
"$ref": "#/components/schemas/ErrorResponse"
2464+
}
2465+
}
2466+
},
2467+
"description": "Box Not Found"
2468+
},
2469+
"500": {
2470+
"content": {
2471+
"application/json": {
2472+
"schema": {
2473+
"$ref": "#/components/schemas/ErrorResponse"
2474+
}
2475+
}
2476+
},
2477+
"description": "Internal Error"
2478+
},
2479+
"default": {
2480+
"content": {},
2481+
"description": "Unknown Error"
2482+
}
2483+
},
2484+
"summary": "Get box information for a given application."
2485+
}
2486+
},
23722487
"/v2/assets/{asset-id}": {
23732488
"get": {
23742489
"description": "Given a asset ID, it returns asset information including creator, name, total supply and special addresses.",

daemon/algod/api/server/v2/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
errAssetDoesNotExist = "asset does not exist"
2222
errAccountAppDoesNotExist = "account application info not found"
2323
errAccountAssetDoesNotExist = "account asset info not found"
24+
errBoxDoesNotExist = "box not found"
2425
errFailedLookingUpLedger = "failed to retrieve information from the ledger"
2526
errFailedLookingUpTransactionPool = "failed to retrieve information from the transaction pool"
2627
errFailedRetrievingNodeStatus = "failed retrieving node status"

0 commit comments

Comments
 (0)