From 5d348de1bd34533e9ae1261b31bfaa955fc5041f Mon Sep 17 00:00:00 2001 From: Armani Ferrante Date: Wed, 27 Jan 2021 07:16:19 -0800 Subject: [PATCH] common: Add decimals arg to mint creation --- packages/common/src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 09826945..ab4ed1eb 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -29,6 +29,7 @@ export const SPL_SHARED_MEMORY_ID = new PublicKey( export async function createMint( provider: Provider, authority?: PublicKey, + decimals?: number, ): Promise { if (authority === undefined) { authority = provider.wallet.publicKey; @@ -38,6 +39,7 @@ export async function createMint( provider, authority, mint.publicKey, + decimals, ); const tx = new Transaction(); @@ -52,6 +54,7 @@ export async function createMintInstructions( provider: Provider, authority: PublicKey, mint: PublicKey, + decimals?: number, ): Promise { let instructions = [ SystemProgram.createAccount({ @@ -63,7 +66,7 @@ export async function createMintInstructions( }), TokenInstructions.initializeMint({ mint, - decimals: 0, + decimals: decimals ?? 0, mintAuthority: authority, }), ]; @@ -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; @@ -91,7 +95,7 @@ export async function createMintAndVault( }), TokenInstructions.initializeMint({ mint: mint.publicKey, - decimals: 0, + decimals: decimals ?? 0, mintAuthority: provider.wallet.publicKey, }), SystemProgram.createAccount({