Skip to content

Commit

Permalink
yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jul 29, 2022
1 parent e0687f7 commit 1ee34b5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export default class Fund extends SolanaCommand {
const from = await getAssociatedTokenAddress(linkPublicKey, this.wallet.publicKey)

logger.loading(`Transferring ${amount} tokens to ${state.toString()} token vault ${tokenVault.toString()}...`)
const tx = await transfer(this.provider.connection, this.wallet.payer, from, tokenVault, this.wallet.payer, amount.toNumber())
const tx = await transfer(
this.provider.connection,
this.wallet.payer,
from,
tokenVault,
this.wallet.payer,
amount.toNumber(),
)

return {
responses: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ export default class Initialize extends SolanaCommand {
const maxAnswer = new BN(input.maxAnswer)
const transmissions = new PublicKey(input.transmissions)

const tokenVault = (await getOrCreateAssociatedTokenAccount(
this.provider.connection,
this.wallet.payer,
linkPublicKey,
vaultAuthority,
true,
)).address
const tokenVault = (
await getOrCreateAssociatedTokenAccount(
this.provider.connection,
this.wallet.payer,
linkPublicKey,
vaultAuthority,
true,
)
).address

const tx = await program.methods
.initialize(minAnswer, maxAnswer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ export default class ProposePayees extends SolanaCommand {
const proposalInfo = (await this.program.account.proposal.fetch(proposal)) as any
const payees = proposalInfo.oracles.xs
.slice(0, proposalInfo.oracles.len)
.map(({ transmitter }) => ({ pubkey: this.contractInput.payeeByTransmitter[transmitter.toString()], isWritable: true, isSigner: false }));
.map(({ transmitter }) => ({
pubkey: this.contractInput.payeeByTransmitter[transmitter.toString()],
isWritable: true,
isSigner: false,
}))

const ix = await this.program.methods
.proposePayees(link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export default class CreateAccount extends SolanaCommand {
const tokenAddress = new PublicKey(this.args[0])

const newAccountBase = new PublicKey(this.flags.address)
const associatedAcc = await getAssociatedTokenAddress(
tokenAddress,
newAccountBase,
true,
)
const associatedAcc = await getAssociatedTokenAddress(tokenAddress, newAccountBase, true)

const accountExists = await isValidTokenAccount(this.provider.connection, tokenAddress, associatedAcc)
this.require(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export default class DeployToken extends SolanaCommand {
)

const billion = BigInt(Math.pow(10, 9))
const tokenVault = await createAssociatedTokenAccount(this.provider.connection, this.wallet.payer, token, this.wallet.payer.publicKey)
const tokenVault = await createAssociatedTokenAccount(
this.provider.connection,
this.wallet.payer,
token,
this.wallet.payer.publicKey,
)
const mintAmount = billion * BigInt(Math.pow(10, decimals))

await prompt(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Result } from '@chainlink/gauntlet-core'
import { logger, BN, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { SolanaCommand, TransactionResponse } from '@chainlink/gauntlet-solana'
import { ASSOCIATED_TOKEN_PROGRAM_ID, createTransferInstruction, getAssociatedTokenAddress, TOKEN_PROGRAM_ID } from '@solana/spl-token'
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
createTransferInstruction,
getAssociatedTokenAddress,
TOKEN_PROGRAM_ID,
} from '@solana/spl-token'
import { PublicKey, TransactionInstruction } from '@solana/web3.js'
import { TOKEN_DECIMALS } from '../../../lib/constants'
import { CONTRACT_LIST } from '../../../lib/contracts'
Expand All @@ -25,12 +30,12 @@ export default class TransferToken extends SolanaCommand {
makeRawTransaction = async (signer: PublicKey) => {
const address = this.args[0]

const token = new PublicKey(address);
const token = new PublicKey(address)

const from = await getAssociatedTokenAddress(token, signer, true)

const destination = new PublicKey(this.flags.to)
const amount = BigInt(this.flags.amount) * (BigInt(10) ** BigInt(TOKEN_DECIMALS))
const amount = BigInt(this.flags.amount) * BigInt(10) ** BigInt(TOKEN_DECIMALS)
this.require(
await isValidTokenAccount(this.provider.connection, token, destination),
`Destination ${destination.toString()} is not a valid token account`,
Expand All @@ -39,7 +44,7 @@ export default class TransferToken extends SolanaCommand {
logger.info(
`Preparing instruction to send ${amount.toString()} (${this.flags.amount}) Tokens to ${destination.toString()}`,
)

const ix = createTransferInstruction(from, destination, signer, amount)

return [
Expand Down

0 comments on commit 1ee34b5

Please sign in to comment.