PHP WebShell

Текущая директория: /opt/BitGoJS/modules/sdk-coin-avaxc/src

Просмотр файла: avaxcToken.ts

/**
 * @prettier
 */
import { AvaxC } from './avaxc';
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
import { AvaxcTokenConfig, coins, tokens } from '@bitgo/statics';
import { TransactionPrebuild } from '@bitgo/sdk-coin-eth';

export { AvaxcTokenConfig };

export class AvaxCToken extends AvaxC {
  public readonly tokenConfig: AvaxcTokenConfig;

  constructor(bitgo: BitGoBase, tokenConfig: AvaxcTokenConfig) {
    const staticsCoin = tokenConfig.network === 'Mainnet' ? coins.get('avaxc') : coins.get('tavaxc');
    super(bitgo, staticsCoin);
    this.tokenConfig = tokenConfig;
  }

  static createTokenConstructor(config: AvaxcTokenConfig): CoinConstructor {
    return (bitgo: BitGoBase) => new AvaxCToken(bitgo, config);
  }

  static createTokenConstructors(
    tokenConfigs: AvaxcTokenConfig[] = [...tokens.bitcoin.avaxc.tokens, ...tokens.testnet.avaxc.tokens]
  ): NamedCoinConstructor[] {
    const tokensCtors: NamedCoinConstructor[] = [];
    for (const token of tokenConfigs) {
      const tokenConstructor = AvaxCToken.createTokenConstructor(token);
      tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
      tokensCtors.push({ name: token.tokenContractAddress, coinConstructor: tokenConstructor });
    }
    return tokensCtors;
  }

  get type(): string {
    return this.tokenConfig.type;
  }

  get name(): string {
    return this.tokenConfig.name;
  }

  get coin(): string {
    return this.tokenConfig.coin;
  }

  get network(): string {
    return this.tokenConfig.network;
  }

  get tokenContractAddress(): string {
    return this.tokenConfig.tokenContractAddress;
  }

  get decimalPlaces(): number {
    return this.tokenConfig.decimalPlaces;
  }

  getChain(): string {
    return this.tokenConfig.type;
  }

  getBaseChain() {
    return this.coin;
  }

  getFullName(): string {
    return 'Avaxc Token';
  }

  getBaseFactor(): number {
    return Math.pow(10, this.tokenConfig.decimalPlaces);
  }

  /**
   * Flag for sending value of 0
   * @returns {boolean} True if okay to send 0 value, false otherwise
   */
  valuelessTransferAllowed(): boolean {
    return false;
  }

  /**
   * Flag for sending data along with transactions
   * @returns {boolean} True if okay to send tx data (AVAXC), false otherwise
   */
  transactionDataAllowed(): boolean {
    return false;
  }

  isToken(): boolean {
    return true;
  }

  verifyCoin(txPrebuild: TransactionPrebuild): boolean {
    return txPrebuild.coin === this.tokenConfig.coin && txPrebuild.token === this.tokenConfig.type;
  }
}

Выполнить команду


Для локальной разработки. Не используйте в интернете!