Skip to content

Commit

Permalink
Update openrpc to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Sep 17, 2024
1 parent 6cbade5 commit d8d7a84
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 196 deletions.
143 changes: 77 additions & 66 deletions open_rpc/massa.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openrpc": "1.2.4",
"info": {
"title": "Massa OpenRPC Specification",
"version": "MAIN.2.1",
"version": "MAIN.2.2",
"description": "Massa OpenRPC Specification document. Find more information on https://docs.massa.net/docs/build/api/jsonrpc",
"termsOfService": "https://open-rpc.org",
"contact": {
Expand Down Expand Up @@ -148,8 +148,10 @@
"schema": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
"type": "array",
"items": {
"type": "number"
}
}
},
"name": "Addresses bytecode array"
Expand Down Expand Up @@ -1584,6 +1586,9 @@
},
"additionalProperties": false
},
"Amount": {
"type": "integer"
},
"ApiRequest": {
"title": "ApiRequest",
"description": "ApiRequest for apiV2",
Expand Down Expand Up @@ -1803,7 +1808,7 @@
"type": "number"
},
"end_timestamp": {
"description": "(Only in tesnets)\nTime in milliseconds when the blockclique started.",
"description": "(Only in testnets)\nTime in milliseconds when the blockclique started.",
"oneOf": [
{
"type": "null"
Expand Down Expand Up @@ -1975,24 +1980,28 @@
"title": "DatastoreEntryOutput",
"description": "Datastore entry",
"type": "object",
"required": [
"candidate_value",
"final_value"
],
"properties": {
"candidate_value": {
"description": "The candidate datastore entry value bytes",
"type": "array",
"items": {
"type": "integer"
}
"description": "",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"final_value": {
"description": "The final datastore entry value bytes",
"type": "array",
"items": {
"type": "integer"
}
"description": "",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -2114,7 +2123,7 @@
"type": "number"
},
"active_cursor": {
"descritpion": "active execution cursor slot",
"description": "active execution cursor slot",
"$ref": "#/components/schemas/Slot"
},
"final_cursor": {
Expand Down Expand Up @@ -2388,8 +2397,15 @@
"description": "When was it generated"
},
"block": {
"$ref": "#/components/schemas/BlockId",
"description": "Block Id"
"description": "Block Id",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/BlockId"
}
]
},
"read_only": {
"description": "Wether the event was generated during read only call",
Expand All @@ -2407,8 +2423,15 @@
"type": "number"
},
"origin_operation_id": {
"$ref": "#/components/schemas/OperationId",
"description": "Origin operation id"
"description": "Origin operation id",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/OperationId"
}
]
},
"is_final": {
"description": "Whether the event is final",
Expand Down Expand Up @@ -2607,34 +2630,6 @@
},
"additionalProperties": false
},
"LedgerInfo": {
"title": "SceLedgerInfo",
"required": [
"balance",
"datastore"
],
"type": "object",
"properties": {
"balance": {
"description": "Represent an amount",
"type": "string"
},
"module": {
"description": "Stored bytecode",
"type": "array",
"items": {
"type": "integer"
}
},
"datastore": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DataStore"
}
}
},
"additionalProperties": false
},
"NetworkStats": {
"title": "NetworkStats",
"description": "Network stats",
Expand Down Expand Up @@ -2682,7 +2677,6 @@
"current_cycle_time",
"next_cycle_time",
"network_stats",
"last_slot",
"next_slot",
"node_id",
"pool_stats",
Expand Down Expand Up @@ -2722,7 +2716,7 @@
},
"last_slot": {
"$ref": "#/components/schemas/Slot",
"description": "Latest slot, none if now is before genesis timestamp"
"description": "Latest slot"
},
"network_stats": {
"$ref": "#/components/schemas/NetworkStats",
Expand Down Expand Up @@ -2764,7 +2758,7 @@
"type": "number"
},
"minimal_fees": {
"description": "Minimal fee",
"description": "Minimal fees to include operation in a block",
"type": "string"
}
},
Expand Down Expand Up @@ -2897,7 +2891,7 @@
"$ref": "#/components/schemas/Transaction",
"description": "transfer coins from sender to recipient"
},
"ExecutSC": {
"ExecuteSC": {
"$ref": "#/components/schemas/ExecuteSC",
"description": "Execute a smart contract."
},
Expand Down Expand Up @@ -3067,10 +3061,7 @@
"max_gas",
"target_address",
"target_function",
"parameter",
"caller_address",
"coins",
"fee"
"parameter"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -3111,6 +3102,7 @@
"type": "null"
},
{
"description": "Amount in coins",
"type": "string"
}
]
Expand Down Expand Up @@ -3138,8 +3130,7 @@
"description": "Included in case of success. The result of the execution",
"type": "array",
"items": {
"format": "byte",
"type": "string"
"type": "number"
}
},
"Error": {
Expand Down Expand Up @@ -3319,6 +3310,7 @@
"required": [
"async_pool_changes",
"executed_ops_changes",
"deferred_call_changes",
"ledger_changes",
"pos_changes",
"executed_denunciations_changes",
Expand All @@ -3345,20 +3337,39 @@
"description": "executed operations changes",
"type": "object"
},
"deferred_call_changes": {
"description": "deferred call changes",
"type": "object"
},
"executed_denunciations_changes": {
"description": "executed denunciation changes",
"type": "object"
},
"execution_trail_hash_change": {
"description": "execution trail hash change",
"type": "string"
"oneOf": [
{
"type": "object",
"properties": {
"Set": {
"type": "string"
}
},
"required": [
"Set"
]
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"Transaction": {
"title": "Transaction",
"description": "Transation",
"description": "Transaction",
"required": [
"amount",
"recipient_address"
Expand Down Expand Up @@ -3400,14 +3411,14 @@
},
"amount": {
"description": "Amount transferred",
"type": "integer"
"type": "string"
},
"effective_amount_received": {
"description": "Amount received by the receiver",
"type": "integer"
"type": "string"
},
"context": {
"description": "Context of the transfer : operation or asyncronous execution",
"description": "Context of the transfer : operation or asynchronous execution",
"type": "object"
},
"succeed": {
Expand Down
1 change: 0 additions & 1 deletion open_rpc/openrpc.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"openrpcDocument": "open_rpc/massa.api.json",
"old": "https://raw.githubusercontent.com/massalabs/massa/a2dfcab8e19220e736d1351f49f54d03b7b23d7a/massa-node/base_config/openrpc.json",
"outDir": "tmp/",
"components": [
{
Expand Down
20 changes: 12 additions & 8 deletions src/client/publicAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class PublicAPI {
)
}

async getAddressesBytecode(addressFilter: AddressFilter): Promise<string> {
async getAddressesBytecode(addressFilter: AddressFilter): Promise<number[]> {

Check warning on line 158 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return withRetry(
() => this.connector.get_addresses_bytecode([addressFilter]),
this.options.retry!
Expand All @@ -164,7 +164,7 @@ export class PublicAPI {

async executeMultipleGetAddressesBytecode(
addressFilters: AddressFilter[]
): Promise<string[]> {
): Promise<number[][]> {
return withRetry(
() => this.connector.get_addresses_bytecode(addressFilters),
this.options.retry!
Expand Down Expand Up @@ -218,7 +218,7 @@ export class PublicAPI {
async getDatastoreEntries(
inputs: DatastoreEntry[],
final = true
): Promise<Uint8Array[]> {
): Promise<string[]> {
const entriesQuery = inputs.map((entry) => ({
key: Array.from(entry.key),
address: entry.address,
Expand All @@ -228,16 +228,20 @@ export class PublicAPI {
this.options.retry!
)

return res.map((r: DatastoreEntryOutput) =>
Uint8Array.from(final ? r.final_value : r.candidate_value)
)
return res.map((r: DatastoreEntryOutput) => {

Check warning on line 231 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
const result = final ? r.final_value : r.candidate_value

Check warning on line 232 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 232 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 232 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
if (!result) {
throw new Error('Datastore entry not found')

Check warning on line 234 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 235 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 235 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
return result

Check warning on line 236 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
})

Check warning on line 237 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

async getDatastoreEntry(
key: string | Uint8Array,
address: string,
final = true
): Promise<Uint8Array> {
): Promise<string[] | string> {
const byteKey: Uint8Array = typeof key === 'string' ? strToBytes(key) : key
return this.getDatastoreEntries([{ key: byteKey, address }], final).then(
(r) => r[0]
Expand Down Expand Up @@ -374,7 +378,7 @@ export class PublicAPI {
return status.last_slot.period
}

async getCurrentSlot(): Promise<Slot> {
async getCurrentSlot(): Promise<Slot | undefined> {

Check warning on line 381 in src/client/publicAPI.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
const { last_slot } = await this.status()
return last_slot
}
Expand Down
7 changes: 5 additions & 2 deletions src/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { EventExecutionContext } from '../generated/client'
import {
EventExecutionContext,
ObjectOfStringDoaGddGANwpLofVw,
} from '../generated/client'

export enum Transport {
WebSocket = 'websocket',
Expand Down Expand Up @@ -55,7 +58,7 @@ export type ReadOnlyCallResult = {
posChanges: Record<string, unknown>
executedOpsChanges: Record<string, unknown>
executedDenunciationsChanges: Record<string, unknown>
executionTrailHashChange: string
executionTrailHashChange: string | ObjectOfStringDoaGddGANwpLofVw
}
}
}
Expand Down
Loading

0 comments on commit d8d7a84

Please sign in to comment.