nxt.addons

## Class AbstractOperationContext

- java.lang.Object
- - nxt.addons.AbstractContractContext
  - - nxt.addons.AbstractOperationContext

- Direct Known Subclasses:
    TransactionContext, VoucherContext

      public abstract class AbstractOperationContext
      extends AbstractContractContext

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class nxt.addons.AbstractContractContext

      `AbstractContractContext.EventSource`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `blockId`
    `protected int` | `chain`
    `protected byte[]` | `fullHash`

    - ### Fields inherited from class nxt.addons.AbstractContractContext

      `chainById, chainByName, config, contractName, FEE_CANNOT_CALCULATE, FEE_EXCEEDS_AMOUNT, INTERNAL_ERROR_CODE_THRESHOLD, MESSAGE_TO_ENCRYPT_WITHOUT_SECRET_PHRASE, source, VALIDATE_SAME_ACCOUNT_CODE, VALIDATE_SAME_CHAIN, VALIDATE_SAME_TRANSACTION_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractOperationContext(byte[] fullHash, int chainId, long blockId, ContractRunnerConfig config, JO runtimeParams, java.lang.String contractName, java.lang.String seed)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getAmountNQT()` Returns the child chain amount of the trigger transaction
    `ChainWrapper` | `getChainOfTransaction()` Returns the chain object of the trigger transaction
    `protected JO` | `getPhasingAttachment()`
    `long` | `getRandomSeed()` Returns the random seed used by the contract to generate random numbers
    `long` | `getRecipientId()` Returns the numeric id of the recipient account
    `JO` | `getRuntimeParams()` Returns the parameters passed to this contract invocation
    `long` | `getSenderId()` Returns the numeric id of the sender account
    `abstract TransactionResponse` | `getTransaction()` Returns an object representing the trigger transaction data
    `protected abstract JO` | `getTransactionJson()` Returns the Json representation of the trigger transaction data
    `boolean` | `isSameChain(int chainId)` Returns true if the chain id is equal to the trigger transaction chain id
    `boolean` | `isSameRecipient()` Deprecated.
    `boolean` | `isSameSender()` Returns true if the trigger transaction sender is the same account as the contract runner account in other words, returns true if the trigger transaction was sent by this contract runner
    `boolean` | `notPaymentTransaction()` Returns true if the trigger transaction is not a send money transaction
    `boolean` | `notSameChain(int chainId)` Returns true if the chain id is not equal to the trigger transaction chain id
    `boolean` | `notSameRecipient()` Returns true if the trigger transaction recipient is not the same account as the contract runner account in other words, returns true if the trigger transaction specified a different recipient than this contract runner account
    `boolean` | `notSameSender()` Returns true if the trigger transaction sender is not the same account as the contract runner account in other words, returns true if the trigger transaction was submitted by a different sender than this contract runner account
    `boolean` | `validateSameAccount(java.lang.String attribute)` Returns true if the account id resolved from the attribute is the same account as the contract runner account

    - ### Methods inherited from class nxt.addons.AbstractContractContext

      `addTriggerData, createTransaction, createTransaction, fullHashToId, fullHashToId, generateErrorResponse, generateInfoResponse, generateInternalErrorResponse, generateResponse, getAccount, getAccountRs, getBlock, getBlockchainConstants, getBlockchainHeight, getChain, getChain, getConfig, getContext, getContractName, getContractRunnerConfigParams, getContractSetupParameters, getHash, getHash, getParams, getParentChain, getPublicKey, getPublicKey, getPublicKeyHexString, getRandomnessSource, getReferencedTransaction, getResponse, getSource, initRandom, isPermissionGranted, loadContract, logErrorMessage, logInfoMessage, parseAccountId, parseHexString, publicKeyToAccountId, publicKeyToAccountId, rsAccount, setContractSetupParameters, sign, toHexString, verify`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### fullHash

          protected final byte[] fullHash

    - #### chain

          protected final int chain

    - #### blockId

          protected final long blockId

  - ### Constructor Detail

    - #### AbstractOperationContext

          public AbstractOperationContext(byte[] fullHash,
                                          int chainId,
                                          long blockId,
                                          ContractRunnerConfig config,
                                          JO runtimeParams,
                                          java.lang.String contractName,
                                          java.lang.String seed)

  - ### Method Detail

    - #### getTransactionJson

          protected abstract JO getTransactionJson()

      Returns the Json representation of the trigger transaction data
      Returns:
        the Json representation of the trigger transaction data

    - #### getTransaction

          public abstract TransactionResponse getTransaction()

      Returns an object representing the trigger transaction data
      Returns:
        an object representing the trigger transaction data

    - #### getRuntimeParams

          public JO getRuntimeParams()

      Returns the parameters passed to this contract invocation
      Overrides:
        `getRuntimeParams` in class `AbstractContractContext`
      Returns:
        the parameters passed to this contract invocation

    - #### getAmountNQT

          public long getAmountNQT()

      Returns the child chain amount of the trigger transaction
      Returns:
        the amount in NQT

    - #### getSenderId

          public long getSenderId()

      Returns the numeric id of the sender account
      Returns:
        the numeric id of the sender account

    - #### getRecipientId

          public long getRecipientId()

      Returns the numeric id of the recipient account
      Returns:
        the numeric id of the recipient account

    - #### getChainOfTransaction

          public ChainWrapper getChainOfTransaction()

      Returns the chain object of the trigger transaction
      Returns:
        the chain object

    - #### isSameRecipient

          @Deprecated
          public boolean isSameRecipient()

      Deprecated.
      Returns true if the trigger transaction recipient is the same account as the contract runner account in other words, returns true if the trigger transaction was sent to this contract runner
      Returns:
        true if the same recipient, false otherwise

    - #### notSameRecipient

          public boolean notSameRecipient()

      Returns true if the trigger transaction recipient is not the same account as the contract runner account in other words, returns true if the trigger transaction specified a different recipient than this contract runner account
      Returns:
        true if not the same recipient, false otherwise

    - #### isSameSender

          public boolean isSameSender()

      Returns true if the trigger transaction sender is the same account as the contract runner account in other words, returns true if the trigger transaction was sent by this contract runner
      Returns:
        true if the same sender, false otherwise

    - #### notSameSender

          public boolean notSameSender()

      Returns true if the trigger transaction sender is not the same account as the contract runner account in other words, returns true if the trigger transaction was submitted by a different sender than this contract runner account
      Returns:
        true if not the same sender, false otherwise

    - #### validateSameAccount

          public boolean validateSameAccount(java.lang.String attribute)

      Returns true if the account id resolved from the attribute is the same account as the contract runner account
      Parameters:
        `attribute` - the key name whose value represents the account id
      Returns:
        true if the same account, false otherwise

    - #### notPaymentTransaction

          public boolean notPaymentTransaction()

      Returns true if the trigger transaction is not a send money transaction
      Returns:
        true if the trigger transaction is not a send money transaction, false otherwise

    - #### isSameChain

          public boolean isSameChain(int chainId)

      Returns true if the chain id is equal to the trigger transaction chain id
      Parameters:
        `chainId` - the chain id
      Returns:
        true if equal, false otherwise

    - #### notSameChain

          public boolean notSameChain(int chainId)

      Returns true if the chain id is not equal to the trigger transaction chain id
      Parameters:
        `chainId` - the chain id
      Returns:
        true if not equal, false otherwise

    - #### getRandomSeed

          public long getRandomSeed()

      Returns the random seed used by the contract to generate random numbers
      Returns:
        the random seed

    - #### getPhasingAttachment

          protected JO getPhasingAttachment()

      Overrides:
        `getPhasingAttachment` in class `AbstractContractContext`