Skip to content

Commit

Permalink
common: Add decimals arg to mint creation
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Jan 27, 2021
1 parent 90a00ec commit 5d348de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const SPL_SHARED_MEMORY_ID = new PublicKey(
export async function createMint(
provider: Provider,
authority?: PublicKey,
decimals?: number,
): Promise<PublicKey> {
if (authority === undefined) {
authority = provider.wallet.publicKey;
Expand All @@ -38,6 +39,7 @@ export async function createMint(
provider,
authority,
mint.publicKey,
decimals,
);

const tx = new Transaction();
Expand All @@ -52,6 +54,7 @@ export async function createMintInstructions(
provider: Provider,
authority: PublicKey,
mint: PublicKey,
decimals?: number,
): Promise<TransactionInstruction[]> {
let instructions = [
SystemProgram.createAccount({
Expand All @@ -63,7 +66,7 @@ export async function createMintInstructions(
}),
TokenInstructions.initializeMint({
mint,
decimals: 0,
decimals: decimals ?? 0,
mintAuthority: authority,
}),
];
Expand All @@ -74,6 +77,7 @@ export async function createMintAndVault(
provider: Provider,
amount: BN,
owner?: PublicKey,
decimals?: number,
): Promise<[PublicKey, PublicKey]> {
if (owner === undefined) {
owner = provider.wallet.publicKey;
Expand All @@ -91,7 +95,7 @@ export async function createMintAndVault(
}),
TokenInstructions.initializeMint({
mint: mint.publicKey,
decimals: 0,
decimals: decimals ?? 0,
mintAuthority: provider.wallet.publicKey,
}),
SystemProgram.createAccount({
Expand Down

0 comments on commit 5d348de

Please sign in to comment.