How to use the @celo/contractkit.CeloContract.StableToken function in @celo/contractkit

To help you get started, we’ve selected a few @celo/contractkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / celotool / src / lib / geth.ts View on Github external
while (true) {
    const sendTransactionTime = Date.now()

    // randomly choose which token to use
    const transferGold = Boolean(Math.round(Math.random()))
    const transferFn = transferGold ? transferCeloGold : transferCeloDollars
    baseLogMessage.tokenName = transferGold ? 'cGLD' : 'cUSD'

    // randomly choose which gas currency to use
    const feeCurrencyGold = Boolean(Math.round(Math.random()))

    let feeCurrency
    if (!feeCurrencyGold) {
      try {
        feeCurrency = await kit.registry.addressFor(CeloContract.StableToken)
      } catch (error) {
        tracerLog({
          tag: LOG_TAG_CONTRACT_ADDRESS_ERROR,
          error: error.toString(),
          ...baseLogMessage,
        })
      }
    }
    baseLogMessage.feeCurrency = feeCurrency || ''

    // We purposely do not use await syntax so we sleep after sending the transaction,
    // not after processing a transaction's result
    transferFn(kit, senderAddress, recipientAddress, LOAD_TEST_TRANSFER_WEI, {
      feeCurrency,
    })
      .then(async (txResult: TransactionResult) => {
github celo-org / celo-monorepo / packages / celotool / src / e2e-tests / transfer_tests.ts View on Github external
describe('gasCurrency = CeloGold >', () => {
            testTransferToken({
              expectedGas: 40456,
              transferToken: CeloContract.StableToken,
              feeToken: CeloContract.GoldToken,
              txOptions: {
                gasFeeRecipient: FeeRecipientAddress,
              },
            })
          })
        })
github celo-org / celo-monorepo / packages / celotool / src / e2e-tests / transfer_tests.ts View on Github external
before(async () => {
      const gasCurrency =
        feeToken === CeloContract.StableToken
          ? await kit.registry.addressFor(CeloContract.StableToken)
          : undefined

      const accounts = [FromAddress, ToAddress, validatorAddress, FeeRecipientAddress]
      balances = await newBalanceWatcher(kit, accounts)

      const transferFn =
        transferToken === CeloContract.StableToken ? transferCeloDollars : transferCeloGold
      const txResult = await transferFn(FromAddress, ToAddress, TransferAmount, {
        ...txOptions,
        gasCurrency,
      })

      txRes = await runTestTransaction(txResult, expectedGas, gasCurrency)

      await balances.update()
github celo-org / celo-monorepo / packages / celotool / src / e2e-tests / transfer_tests.ts View on Github external
before(async () => {
      const gasCurrency =
        feeToken === CeloContract.StableToken
          ? await kit.registry.addressFor(CeloContract.StableToken)
          : undefined

      const accounts = [FromAddress, ToAddress, validatorAddress, FeeRecipientAddress]
      balances = await newBalanceWatcher(kit, accounts)

      const transferFn =
        transferToken === CeloContract.StableToken ? transferCeloDollars : transferCeloGold
      const txResult = await transferFn(FromAddress, ToAddress, TransferAmount, {
        ...txOptions,
        gasCurrency,
      })

      txRes = await runTestTransaction(txResult, expectedGas, gasCurrency)

      await balances.update()
    })
github celo-org / celo-monorepo / packages / celotool / src / e2e-tests / transfer_tests.ts View on Github external
describe('when setting a gas amount less than the amount of gas necessary but more than the intrinsic gas amount', () => {
                const gas = intrinsicGas + 1000
                testTransferToken({
                  expectedGas: gas,
                  transferToken: CeloContract.GoldToken,
                  feeToken: CeloContract.StableToken,
                  expectSuccess: false,
                  txOptions: {
                    gas,
                    gasFeeRecipient: FeeRecipientAddress,
                  },
                })
              })
github celo-org / celo-monorepo / packages / notification-service / src / util / utils.ts View on Github external
export async function getTokenAddresses() {
  if (goldTokenAddress && stableTokenAddress) {
    return { goldTokenAddress, stableTokenAddress }
  } else {
    const kit = await getContractKit()
    goldTokenAddress = await kit.registry.addressFor(CeloContract.GoldToken)
    stableTokenAddress = await kit.registry.addressFor(CeloContract.StableToken)
    return { goldTokenAddress, stableTokenAddress }
  }
}
github celo-org / celo-monorepo / packages / dappkit / src / index.ts View on Github external
async function getFeeCurrencyContractAddress(
  kit: ContractKit,
  feeCurrency: FeeCurrency
): Promise {
  switch (feeCurrency) {
    case FeeCurrency.cUSD:
      return kit.registry.addressFor(CeloContract.StableToken)
    case FeeCurrency.cGLD:
      return kit.registry.addressFor(CeloContract.GoldToken)
    default:
      return kit.registry.addressFor(CeloContract.StableToken)
  }
}
github celo-org / celo-monorepo / packages / cli / src / commands / oracle / rates.ts View on Github external
import { BaseCommand } from '../../base'

export default class GetRates extends BaseCommand {
  static description = 'Get the current set oracle-reported rates for the given token'

  static flags = {
    ...BaseCommand.flags,
  }

  static args = [
    {
      name: 'token',
      required: true,
      description: 'Token to get the rates for',
      options: [CeloContract.StableToken],
      default: CeloContract.StableToken,
    },
  ]

  static example = ['rates StableToken', 'rates']

  async run() {
    const res = this.parse(GetRates)
    const sortedOracles = await this.kit.contracts.getSortedOracles()

    const rates = await sortedOracles.getRates(res.args.token)
    cli.table(
      rates,
      {
        address: {},
        rate: { get: (r) => r.rate.toNumber() },
      },
github celo-org / celo-monorepo / packages / cli / src / commands / oracle / rates.ts View on Github external
import { cli } from 'cli-ux'
import { BaseCommand } from '../../base'

export default class GetRates extends BaseCommand {
  static description = 'Get the current set oracle-reported rates for the given token'

  static flags = {
    ...BaseCommand.flags,
  }

  static args = [
    {
      name: 'token',
      required: true,
      description: 'Token to get the rates for',
      options: [CeloContract.StableToken],
      default: CeloContract.StableToken,
    },
  ]

  static example = ['rates StableToken', 'rates']

  async run() {
    const res = this.parse(GetRates)
    const sortedOracles = await this.kit.contracts.getSortedOracles()

    const rates = await sortedOracles.getRates(res.args.token)
    cli.table(
      rates,
      {
        address: {},
        rate: { get: (r) => r.rate.toNumber() },