text: import * as sdk from "@onflow/sdk"
  import * as t from "@onflow/types"
  import {config} from "@onflow/config"
  
  const Deps = {
      LOCKEDTOKENADDRESS: "0xLOCKEDTOKENADDRESS",
  }
  
  const Env = {
      local: {
          [Deps.LOCKEDTOKENADDRESS]: "0x0",
      },
      testnet: {
          [Deps.LOCKEDTOKENADDRESS]: "0xbe9b485f7d5e7787",
      },
      mainnet: {
          [Deps.LOCKEDTOKENADDRESS]: "0x31aed847945124fd",
      }
  }
  
  export const TITLE = "Redelegate Rewarded Flow"
  export const DESCRIPTION = "Redelegates rewarded Flow for an account."
  export const VERSION = "0.0.1"
  export const HASH = "864edbff384335ef21c26b3bcf17d36b2b1d894afbe2b203f58099cc457971e4"
  export const CODE = 
  `import LockedTokens from 0xLOCKEDTOKENADDRESS
  
  transaction(amount: UFix64) {
      let nodeDelegatorProxy: LockedTokens.LockedNodeDelegatorProxy
  
      prepare(acct: AuthAccount) {
          let holderRef = acct.borrow<&LockedTokens.TokenHolder>(from: LockedTokens.TokenHolderStoragePath) 
              ?? panic("TokenHolder is not saved at specified path")
          
          self.nodeDelegatorProxy = holderRef.borrowDelegator()
      }
  
      execute {
          self.nodeDelegatorProxy.delegateRewardedTokens(amount: amount)
      }
  }`
  
  export const template = async ({ proposer, authorization, payer, amount = ""}) => {
      const env = await config().get("env", "mainnet")
      let code = CODE.replace(Deps.LOCKEDTOKENADDRESS, Env[env][Deps.LOCKEDTOKENADDRESS])
  
      return sdk.pipe([
          sdk.transaction(code),
          sdk.args([sdk.arg(amount, t.UFix64)]),
          sdk.proposer(proposer),
          sdk.authorizations([authorization]),
          sdk.payer(payer),
          sdk.validator((ix, {Ok, Bad}) => {
              if (ix.authorizations.length > 1) return Bad(ix, "template only requires one authorization.")
              return Ok(ix)
          })
      ])
  }
  