openapi: 3.0.3
info:
  title: load simulation - OpenAPI 3.0
  description: |-
    describe list of requests
  version: 1.0.0
tags:
  - name: contract calls
  - name: contractCalls

paths:
  /request:
    put:
      tags:
        - trigger calls
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Request'
        required: true
      responses:
        '200':
          description: Successful operation


components:
  schemas:
    Request:
      type: object
      required:
        - context
      properties:
        id:
          type: integer
          format: int32
          example: 10
        name:
          type: string
          example: "test"
        context:
          $ref: '#/components/schemas/Context'
        calls:
          type: array
          items:
            $ref: '#/components/schemas/ScenarioDefinition'

    ScenarioDefinition:
      type: object
      properties:
        nbOfExecution:
          type: integer
          format: int32
          default: 1
          description: "Number of time the set of call described in this ScenarioDefinition object will be executed. Set to 0 to disable this ScenarioDefinition."
        scenario:
          $ref: "#/components/schemas/Scenario"

    Scenario:
      required:
        - scenarioType
      type: object
      properties:
        scenarioType:
          type: string
      discriminator:
        propertyName: scenarioType
        mapping:
          RoundRobinMoneyTransfer: '#/components/schemas/RoundRobinMoneyTransfer'
          SelfTransactionWithPayload: '#/components/schemas/SelfTransactionWithPayload'
          SelfTransactionWithRandomPayload: '#/components/schemas/SelfTransactionWithRandomPayload'
          ContractCall: '#/components/schemas/ContractCall'

    RoundRobinMoneyTransfer:
      allOf:
        - $ref: "#/components/schemas/Scenario"
      description: "The test will create nbWallets new wallets and make each of them send nbTransfers requests to each other in a round robin fashion."
      properties:
        nbTransfers:
          type: integer
          format: int32
          default: 1
        nbWallets:
          type: integer
          format: int32
          default: 1

    SelfTransactionWithPayload:
      allOf:
        - $ref: "#/components/schemas/Scenario"
      description: "The test will create nbTransfers new wallets and make each of them send one request to itself. A new wallet is created for each transaction as it's likely the tx will remain in pending state."
      properties:
        wallet:
          type: string
          default: "new"
          example: "source, new"
          description: "new means a new wallet is going to be created by the test framework to make the calls, source means the test will use the sourceWallet whose pk is passed as parameter."
        nbTransfers:
          type: integer
          format: int32
          default: 1
        nbWallets:
          type: integer
          format: int32
          default: 1
        payload:
          type: string
        price:
          type: integer
          format: int32
          default: 27000

    SelfTransactionWithRandomPayload:
      allOf:
        - $ref: "#/components/schemas/Scenario"
      description: "The test will create nbTransfers new wallets and make each of them send one request to itself. A new wallet is created for each transaction as it's likely the tx will remain in pending state."
      properties:
        wallet:
          type: string
          default: "new"
          example: "source, new"
          description: "new means a new wallet is going to be created by the test framework to make the calls, source means the test will use the sourceWallet whose pk is passed as parameter."
        nbWallets:
          type: integer
          format: int32
          default: 1
        nbTransfers:
          type: integer
          format: int32
          default: 1
        payloadSize:
          type: integer
          format: int32
          default: 50000
        price:
          type: integer
          format: int32
          default: 27000

    UnderPricedTransaction:
      allOf:
        - $ref: "#/components/schemas/Scenario"
      description: "The test will create nbWallets new wallets and make each of them send one request to itself. A new wallet is created for each transaction as the tx will remain in pending state."
      properties:
        nbWallets:
          type: integer
          format: int32
          default: 1

    ContractCall:
      allOf:
        - $ref: "#/components/schemas/Scenario"
      properties:
        wallet:
          type: string
          default: "source"
          example: "source, new"
          description: "new means a new wallet is going to be created by the test framework to make the calls, source means the test will use the sourceWallet whose pk is passed as parameter."
        contract:
          $ref: '#/components/schemas/Contract'

    Contract:
      required:
        - contractCallType
      type: object
      properties:
        contractCallType:
          type: string
      discriminator:
        propertyName: contractCallType
        mapping:
          CreateContract: '#/components/schemas/CreateContract'
          CallExistingContract: '#/components/schemas/CallExistingContract'
          CallContractReference: '#/components/schemas/CallContractReference'

    CreateContract:
      allOf:
        - $ref: "#/components/schemas/Contract"
      type: object
      properties:
        byteCode:
          type: string
        name:
          type: string

    CallExistingContract:
      allOf:
        - $ref: "#/components/schemas/Contract"
      type: object
      properties:
        contractAddress:
          type: string
        methodAndParameters:
          type: object
          $ref: '#/components/schemas/MethodAndParameter'

    CallContractReference:
      allOf:
        - $ref: "#/components/schemas/Contract"
      type: object
      properties:
        contractName:
          type: string
        methodAndParameters:
          type: object
          $ref: '#/components/schemas/MethodAndParameter'


    MethodAndParameter:
      required:
        - type
        - numberOfTimes
      type: object
      properties:
        type:
          type: string
        numberOfTimes:
          type: integer
          format: int32
          default: 1
          example: 10
      discriminator:
        propertyName: type
        mapping:
          BatchMint: '#/components/schemas/BatchMint'
          Mint: '#/components/schemas/Mint'
          TransferOwnership: '#/components/schemas/TransferOwnership'

    GenericCall:
      allOf:
        - $ref: "#/components/schemas/MethodAndParameter"
      type: object
      properties:
        methodName:
          type: string
        price:
          type: integer
          format: int64
        parameters:
          type: array
          items:
            $ref: "#/components/schemas/Parameter"

    Parameter:
      required:
        - type
      type: object
      properties:
        type:
          type: string
      discriminator:
        propertyName: type
        mapping:
          SimpleParameter: '#/components/schemas/SimpleParameter'
          ArrayParameter: '#/components/schemas/ArrayParameter'

    SimpleParameter:
      allOf:
        - $ref: "#/components/schemas/Parameter"
      type: object
      properties:
        value:
          type: string
        solidityType:
          type: string

    ArrayParameter:
      allOf:
        - $ref: "#/components/schemas/Parameter"
      type: object
      properties:
        values:
          type: array
          items:
            $ref: "#/components/schemas/Parameter"

    BatchMint:
      allOf:
        - $ref: "#/components/schemas/MethodAndParameter"
      type: object
      properties:
        address:
          type: array
          items:
            type: string
        amount:
          type: integer
          format: int32

    Mint:
      allOf:
        - $ref: "#/components/schemas/MethodAndParameter"
      properties:
        address:
          type: string
        amount:
          type: integer
          format: int32

    TransferOwnership:
      allOf:
        - $ref: "#/components/schemas/MethodAndParameter"
      properties:
        destinationAddress:
          type: string

    Context:
      type: object
      required:
        - chainId
      properties:
        url:
          type: string
          default: "http://localhost:8545"
        nbOfExecutions:
          type: integer
          format: int32
          default: 1
        chainId:
          type: integer
          format: int32
          example: 59140
        contracts:
          type: array
          items:
            $ref: '#/components/schemas/CreateContract'
