Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gauntlet token details #63

Merged
merged 4 commits into from
Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Result } from '@chainlink/gauntlet-core'
import { logger } from '@chainlink/gauntlet-core/dist/utils'
import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { SolanaCommand, TransactionResponse } from '@chainlink/gauntlet-solana'
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token'
import BN from 'bn.js'
Expand All @@ -19,29 +19,36 @@ export default class DeployToken extends SolanaCommand {

logger.loading('Creating token...')

const decimals = this.flags.decimals || 18
const decimals = this.flags.decimals || 9
const token = await Token.createMint(
this.provider.connection,
this.wallet.payer,
mintAuthority.publicKey,
null,
this.wallet.payer.publicKey, // Freeze authority
decimals,
TOKEN_PROGRAM_ID,
)

const tokenVault = await token.createAssociatedTokenAccount(this.wallet.publicKey)
const mintAmount = new BN(['1'].concat(new Array(decimals).fill('0')).join(''))
logger.log('Minting', mintAmount.toString())
const billion = new BN(Math.pow(10, 9))
const tokenVault = await token.createAssociatedTokenAccount(this.wallet.payer.publicKey)
const mintAmount = billion.mul(new BN(Math.pow(10, decimals)))

await prompt(
`Minting ${billion.toString()} token units, with ${decimals} decimals. Total ${mintAmount.toString()}. Continue?`,
)

await token.mintTo(tokenVault, this.wallet.payer, [], mintAmount)

// To disable minting https://github.com/solana-labs/solana-program-library/blob/36e886392b8c6619b275f6681aed6d8aae6e70f9/token/js/client/token.js#L985

logger.info(`
TOKEN:
- Address: ${token.publicKey}
VAULT:
- address: ${tokenVault.toString()}
STATE ACCOUNTS:
- Mint Authority: ${mintAuthority.publicKey}
- Freeze Authority: ${this.wallet.payer.publicKey}
`)

return {
Expand Down