Home Reference Source

src/services/deploys/nft/actions/nftCEP78Transfer.js

  1. import {
  2. CLKey, CLPublicKey, CLU64, RuntimeArgs,
  3. } from 'casper-js-sdk';
  4. import { NftTransferResult } from '../../../results';
  5. import AbstractSmartContractStoredByHashDeployParameters from '../../abstractSmartContractStoredByHashDeployParameters';
  6.  
  7. /**
  8. * @constant
  9. * @type {string}
  10. */
  11. const entrypoint = 'transfer';
  12.  
  13. /**
  14. * @constant
  15. * @type {number}
  16. */
  17. const fee = 6000000000;
  18.  
  19. /**
  20. * NftCEP78Transfer class
  21. * Class used to create DeployParameters for an NFT Transfer operation
  22. */
  23. export default class NftCEP78Transfer extends AbstractSmartContractStoredByHashDeployParameters {
  24. /**
  25. * Constructor
  26. *
  27. * @param {string} activeKey - Current active key in the public hex format
  28. * @param {number} tokenId - Token ID of the nft that will be transferred
  29. * @param {string} recipient - Public key hex of the recipient
  30. * @param {string} network - Current network to execute the deployment
  31. * @param {string} hash - Current hash of the stored SmartContract
  32. * @param {number} ttl - Deploy time to live in hours
  33. */
  34. constructor(activeKey, tokenId, recipient, network, hash, ttl = 1) {
  35. const args = RuntimeArgs.fromMap({
  36. source_key: new CLKey(CLPublicKey.fromHex(activeKey)),
  37. target_key: new CLKey(CLPublicKey.fromHex(recipient)),
  38. token_id: new CLU64(tokenId),
  39. });
  40. super(activeKey, network, hash, entrypoint, args, fee, ttl);
  41. }
  42.  
  43. /**
  44. * Get a DeployResult constructor
  45. *
  46. * @return {DeployResult.constructor} - Return the constructor of a given DeployResult
  47. */
  48. // eslint-disable-next-line class-methods-use-this
  49. get deployResult() {
  50. return NftTransferResult;
  51. }
  52. }