tonkeeper / tonapi-js

MIT License
39 stars 11 forks source link

Add custom parsing logic for the Action component in the `client` package #12

Open mois-ilya opened 2 months ago

mois-ilya commented 2 months ago

Custom parsing logic needs to be added for the Action component from the Swagger schema. The Action component should be transformed into a structure that corresponds to the following schema:

Expected Structure (Example):

Action:
  type: object
  required:
    - type
    - status
    - simple_preview
    - base_transactions
  properties:
    type:
      type: string
      enum:
        - TonTransfer
        - JettonTransfer
        - JettonBurn
        - JettonMint
        - NftItemTransfer
        - ContractDeploy
        - Subscribe
        - UnSubscribe
        - AuctionBid
        - NftPurchase
        - DepositStake
        - WithdrawStake
        - WithdrawStakeRequest
        - JettonSwap
        - SmartContractExec
        - ElectionsRecoverStake
        - ElectionsDepositStake
        - DomainRenew
        - InscriptionTransfer
        - InscriptionMint
        - Unknown
    status:
      type: string
      enum: ["ok", "failed"]
    simple_preview:
      $ref: "#/components/schemas/ActionSimplePreview"
    base_transactions:
      type: array
      items:
        type: string
    action:
      type: object
      oneOf:
        - $ref: "#/components/schemas/TonTransferAction"
        - $ref: "#/components/schemas/ContractDeployAction"
        - $ref: "#/components/schemas/JettonTransferAction"
        - $ref: "#/components/schemas/JettonBurnAction"
        - $ref: "#/components/schemas/JettonMintAction"
        - $ref: "#/components/schemas/NftItemTransferAction"
        - $ref: "#/components/schemas/SubscriptionAction"
        - $ref: "#/components/schemas/UnSubscriptionAction"
        - $ref: "#/components/schemas/AuctionBidAction"
        - $ref: "#/components/schemas/NftPurchaseAction"
        - $ref: "#/components/schemas/DepositStakeAction"
        - $ref: "#/components/schemas/WithdrawStakeAction"
        - $ref: "#/components/schemas/WithdrawStakeRequestAction"
        - $ref: "#/components/schemas/ElectionsDepositStakeAction"
        - $ref: "#/components/schemas/ElectionsRecoverStakeAction"
        - $ref: "#/components/schemas/JettonSwapAction"
        - $ref: "#/components/schemas/SmartContractAction"
        - $ref: "#/components/schemas/DomainRenewAction"
        - $ref: "#/components/schemas/InscriptionTransferAction"
        - $ref: "#/components/schemas/InscriptionMintAction"

Requirements:

Acceptance Criteria: