From 9d74701de7afc4260f01239a247cba6828cfd18d Mon Sep 17 00:00:00 2001 From: Elliot Voris Date: Tue, 19 Dec 2023 15:00:05 -0600 Subject: [PATCH] feat: add `resourceConfig` param to `simulateTransaction` method --- src/contentDescriptors/ResourceConfig.json | 11 +++++++++++ src/examplePairingObjects/SimulationPairs.json | 6 ++++-- src/examples/Simulations.json | 8 ++++++++ src/methods/simulateTransaction.json | 3 +++ src/schemas/ResourceConfig.json | 14 ++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/contentDescriptors/ResourceConfig.json create mode 100644 src/schemas/ResourceConfig.json diff --git a/src/contentDescriptors/ResourceConfig.json b/src/contentDescriptors/ResourceConfig.json new file mode 100644 index 0000000..85ff07d --- /dev/null +++ b/src/contentDescriptors/ResourceConfig.json @@ -0,0 +1,11 @@ +{ + "ResourceConfig": { + "name": "resourceConfig", + "summary": "configuration for how resources will be calculated", + "description": "Contains configuration for how resources will be calculated when simulating transactions.", + "required": false, + "schema": { + "$ref": "#/components/schemas/ResourceConfig" + } + } +} diff --git a/src/examplePairingObjects/SimulationPairs.json b/src/examplePairingObjects/SimulationPairs.json index e0438c0..3df5d03 100644 --- a/src/examplePairingObjects/SimulationPairs.json +++ b/src/examplePairingObjects/SimulationPairs.json @@ -3,7 +3,8 @@ "name": "Successful Transaction Simulation", "description": "Transaction simulation that succeeds and returns the necessary information to prepare and submit the transaction.", "params": [ - { "$ref": "#/components/examples/ValidContractTransaction" } + { "$ref": "#/components/examples/ValidContractTransaction" }, + { "$ref": "#/components/examples/DefaultResourceConfig" } ], "result": { "$ref": "#/components/examples/SuccessfulSimulationResult" @@ -13,7 +14,8 @@ "name": "Failed Transaction Simulation", "description": "Transaction simulation that fails due to the contract invocation being constructed with an improper number of arguments.", "params": [ - { "$ref": "#/components/examples/InvalidContractTransaction" } + { "$ref": "#/components/examples/InvalidContractTransaction" }, + { "$ref": "#/components/examples/DefaultResourceConfig" } ], "result": { "$ref": "#/components/examples/FailedSimulationResult" diff --git a/src/examples/Simulations.json b/src/examples/Simulations.json index 036bd92..522574c 100644 --- a/src/examples/Simulations.json +++ b/src/examples/Simulations.json @@ -47,5 +47,13 @@ }, "latestLedger": 2552013 } + }, + "DefaultResourceConfig": { + "name": "resourceConfig", + "summary": "the default resource configuration", + "description": "The default value for the (optional) resource configuration object for transaction simulation.", + "value": { + "instructionLeeway": 3000000 + } } } diff --git a/src/methods/simulateTransaction.json b/src/methods/simulateTransaction.json index 5182af3..b71cc58 100644 --- a/src/methods/simulateTransaction.json +++ b/src/methods/simulateTransaction.json @@ -9,6 +9,9 @@ "params": [ { "$ref": "#/components/contentDescriptors/UnsignedTransaction" + }, + { + "$ref": "#/components/contentDescriptors/ResourceConfig" } ], "result": { diff --git a/src/schemas/ResourceConfig.json b/src/schemas/ResourceConfig.json new file mode 100644 index 0000000..92cfd4b --- /dev/null +++ b/src/schemas/ResourceConfig.json @@ -0,0 +1,14 @@ +{ + "ResourceConfig": { + "title": "resourceConfig", + "description": "Configuration for how resources will be calculated.", + "type": "object", + "properties": { + "instructionLeeway": { + "title": "instructionLeeway", + "description": "Allow this many extra instructions when budgeting resources.", + "type": "number" + } + } + } +}