Source

types/WithdrawType.ts

import { MetadataTypes, AssetType, AssetStatus, AnimationType } from "./AssetTypes";
import { TokenType } from "./CommonTypes";
import { SplitSignature } from "./OrderTypes";

/**
 * @description Withdraw off-chain params
 * @typedef {Object} WithdrawOffchainParams
 * @property {string} starkKey The identify stark key (L2-wallet address) for the wallet user
 * @property {string} ethAddress The ethereum address wallet of users (Metamask / Trust Wallet...)
 * @property {TokenType} tokenType The type of Token (ETH / ERC20 / ERC721 / MINTABLE_ERC20 / MINTABLE_ERC721)
 * @property {string?} quantum Default quantum number 10^10
 * @property {string} amount The wei amount of the withdrawal token
 * + quantizedAmount = (weiAmount) / 10^10 (quantizedAmount = weiAmount/quantum)
 * + weiAmount = quantizedAmount * 10^10 (weiAmount = quantizedAmount * quantum)
 * @property {string?} tokenAddress Token address with the pointed deployed smart contract address (ERC20 / ERC_721)
 * @property {string?} vaultId The unique vault ID to locate and identify the fund of users in the on-chain
 * @property {string?} tokenId The unique token ID to identify the NFTs (this param is only required for NFT assets)
 * @property {number?} nonce The unique nonce number to identify the unique on-chain transactions
 */
export interface WithdrawOffchainParams {
  starkKey: string;
  ethAddress: string;
  amount: string;
  tokenType: TokenType;
  quantum?:string;
  tokenAddress?: string;
  vaultId?: string;
  tokenId?: string;
  nonce?: number;
}
export interface UserWithdrawalHashType {
  vaultId: string;
  assetId: string;
  quantizedAmount: string;
  nonce: number;
  ethAddress: string;
}

export interface WithdrawOffchainPayloadV2 {
  senderVaultId: number;
  senderPublicKey: string;
  receiverVaultId: number;
  receiverPublicKey: string;
  nonce: number;
  expirationTimestamp: number;
  signature: SplitSignature;
  quantizedAmount: string;
  token: string;
}

/**
 * @description Withdraw offchain params V2 (latest function)
 * @typedef {Object} WithdrawOffchainParamsV2
 * @property {string} senderPublicKey The identical stark key of user (who directly make the withdrawal transactions)
 * @property {string} senderEthAddress The ethereum address wallet of users (Metamask / Trust Wallet...)
 * @property {string} receiverPublicKey The ethereum wallet address of users (The on-chain wallet address that user would receive the tokens)
 * @property {string} quantum Default quantum number 10^10 for some of tokens calculation amounts
 * @property {string} amount The wei amount of the withdrawal token
 * + quantizedAmount = (weiAmount) / 10^10 (quantizedAmount = weiAmount/quantum)
 * + weiAmount = quantizedAmount * 10^10 (weiAmount = quantizedAmount * quantum)
 * @property {string?} tokenAddress Token address with the pointed deployed smart contract address (ERC20 / ERC_721)
 * @property {TokenType} tokenType Type of token (ETH / ERC20 / MINTABLE_ERC20 / ERC721 / MINTABLE_ERC721)
 * @property {string?} tokenId The unique token ID to identify the NFTs (this param is only required for NFT assets)
 */
export interface WithdrawOffchainParamsV2 {
  senderPublicKey: string;
  senderEthAddress: string;
  receiverPublicKey: string;
  quantum: string;
  amount: string;
  tokenAddress?: string;
  tokenType: TokenType;
  tokenId?: string;
}
export interface WithdrawOffchainParamsV2RequestAPI {
  senderVaultId: number;
  senderPublicKey: string;
  senderEthAddress: string;
  receiverPublicKey: string;
  receiverVaultId: number;
  quantizedAmount: string;
  token: string;
  nonce: number;
  expirationTimestamp: number;
}

export interface WithdrawOffchainParamsV2Hash {
  senderVaultId: number;
  senderPublicKey: string;
  senderEthAddress: string;
  receiverPublicKey: string;
  receiverVaultId: number;
  quantizedAmount: string;
  token: string;
  nonce: number;
  expirationTimestamp: number;
}

export interface FullWithdrawalInput {
  vaultId: number;
  nonce: number;
  ethAddress: string;
  starkKey: string;
}

export interface FullWithdrawalPayload {
  vaultId: number;
  nonce: number;
  starkKey: string;
  signature: SplitSignature;
}

/**
 * @typedef {Object} WithdrawOnchainParams
 * @property {string} starkKey The stark public key of user
 * @property {string} assetType The hex string to identify the assets/tokens (computed with Starkware algorithm)
 */
export type WithdrawOnchainParams = {
  starkKey: string;
  assetType: string;
};

/**
 * @typedef {Object} WithdrawAndMintParams
 * @property {string} starkKey The stark public key of user
 * @property {string} walletAddress The eth wallet address that is to intend for withdrawAndMint
 * @property {string} assetType The hex string to identify the assets/tokens (computed with Starkware algorithm)
 * @property {string} mintingBlob The minting blob as the unique string and immutable data for the assets which is stored in the on-chain
 */
export type WithdrawAndMintParams = {
  starkKey: string;
  walletAddress: string;
  assetType: string;
  mintingBlob: string;
};

export type WithdrawERC721Params = {
  ownerKey: string;
  assetType: string;
  tokenId: string;
};

/**
 * @typedef {Object} WithdrawNftOffChainParams
 * @property {number} id The asset ID as identifier for the NFTs asset in Myria Marketplace System
 * @property {string} tokenId The token Id for the NFTs/assets
 * @property {string} tokenAddress The smart contract of NFTs/assets
 * @property {number} senderVaultId The vault ID of sender which stored token with specific asset type
 * @property {string} senderPublicKey The stark public key of Sender
 * @property {string} receiverPublicKey The wallet address of Receiver (Where it's store the received withdrawal token)
 * @property {string} assetId The minted asset ID which is as hex string to identify the unique asset
 * @property {string} quantizedAmount The quantized amount is 1 as always for the NFTs (ERC721)
 */
export interface WithdrawNftOffChainParams {
  id: number;
  tokenId: string;
  tokenAddress: string;
  senderVaultId: number;
  senderPublicKey: string;
  receiverPublicKey: string;
  assetId: string;
  quantizedAmount: string;
}

export interface WithdrawNftOffChainRequestAPI {
  id: number;
  senderVaultId: number;
  senderPublicKey: string;
  receiverVaultId: number;
  receiverPublicKey: string;
  token: string; // asset ID
  quantizedAmount: string;
  nonce: number;
  expirationTimestamp: number;
  signature: SplitSignature;
}

/**
 * @typedef {Object} WithdrawNftOffChainResponse
 * @property {number} id The unique asset ID of the NFTs
 * @property {string} createdAt The created time of withdraw nft transaction
 * @property {string} updatedAt The updated time of withdraw nft transaction
 * @property {string} starkKey The stark key of the owner for the assets/NFTs
 * @property {string} uri The uri of the NFTs to point and locate to the off-chain metadata
 * @property {AssetType} assetType The type of mintable token
 * @property {string} tokenId The unique token ID for the NFTs
 * @property {string} tokenAddress The smart contract address of the token/NFTs
 * @property {AssetStatus} status The status of the asset
 * @property {string=} name Name of the assets/NFTs
 * @property {string=} imageUrl The image URL to represent image for the NFTs
 * @property {string=} description The description about the assets
 * @property {number} collectionId The collection id contains the NFTs
 * @property {Object | any} metadata The metadata object of the NFTs/assets
 * @property {string} publicId  The public ID with uuid format for the assets/NFTs
 * @property {string=} assetMintId The hex string for the minted asset ID
 * @property {number} transactionId The transaction ID uniquely in Myria system for tracking status
 */
export interface WithdrawNftOffChainResponse {
  id: number;
  createdAt: string;
  updatedAt: string;
  starkKey: string;
  uri: string;
  assetType: AssetType;
  tokenId: string;
  tokenAddress: string;
  status: AssetStatus;
  name?: string;
  imageUrl?: string;
  description?: string;
  collectionId: number;
  metadata: Object | any;
  publicId: string;
  animationUrl?: string;
  animationUrlMimeType?: AnimationType;
  assetMintId?: string;
  transactionId: number;
}

/**
 * @typedef {Object} WithdrawNftCompleteParams
 * @property {string} assetId The asset ID (hex string) that's represent for the NFTs to be withdraw complete action
 * @property {string} starkKey The stark public key of the owner's NFT
 * @property {string} transactionHash The on-chain transaction hash to located the transaction on Etherscan once the NFTs has been completed withdraw
 */
export interface WithdrawNftCompleteParams {
  assetId: string;
  starkKey: string;
  transactionHash: string;
}

export interface WithdrawNftCompleteRequestAPI {
  starkKey: string;
  assetId: string;
  vaultId: number;
  transactionHash: string;
}

export interface WithdrawNftCompleteResponse {
  id: number;
  createdAt: string;
  updatedAt: string;
  starkKey: string;
  uri: string;
  assetType: AssetType;
  tokenId: string;
  tokenAddress: string;
  status: string;
  name: string;
  imageUrl: string;
  description: string;
  collectionId: number;
  metadata: MetadataTypes;
  publicId: string;
  animationUrl: string;
  animationUrlMimeType: string;
  assetMintId: string;
  transactionId: number;
}