token-js: Update instruction enum for UiAmountToAmount / AmountToUiAmount (#2949)

* token-js: Unflake create native test

* Add UiAmountToAmount and AmountToUiAmount to enum
This commit is contained in:
Jon Cinque 2022-02-24 15:17:32 -05:00 committed by GitHub
parent 7f3cad3d11
commit 5229a21c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 14 deletions

View File

@ -23,11 +23,13 @@ export enum TokenInstruction {
InitializeMint2 = 20,
GetAccountDataSize = 21,
InitializeImmutableOwner = 22,
InitializeMintCloseAuthority = 23,
TransferFeeExtension = 24,
ConfidentialTransferExtension = 25,
DefaultAccountStateExtension = 26,
Reallocate = 27,
MemoTransferExtension = 28,
CreateNativeMint = 29,
AmountToUiAmount = 23,
UiAmountToAmount = 24,
InitializeMintCloseAuthority = 25,
TransferFeeExtension = 26,
ConfidentialTransferExtension = 27,
DefaultAccountStateExtension = 28,
Reallocate = 29,
MemoTransferExtension = 30,
CreateNativeMint = 31,
}

View File

@ -1,5 +1,5 @@
import { PublicKey, Keypair, Connection, Signer } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID, NATIVE_MINT, NATIVE_MINT_2022 } from '../../src';
import { TOKEN_PROGRAM_ID } from '../../src';
export async function newAccountWithLamports(connection: Connection, lamports = 1000000): Promise<Signer> {
const account = Keypair.generate();
@ -18,5 +18,3 @@ export async function getConnection(): Promise<Connection> {
export const TEST_PROGRAM_ID = process.env.TEST_PROGRAM_ID
? new PublicKey(process.env.TEST_PROGRAM_ID)
: TOKEN_PROGRAM_ID;
export const TEST_NATIVE_MINT = TEST_PROGRAM_ID === TOKEN_PROGRAM_ID ? NATIVE_MINT : NATIVE_MINT_2022;

View File

@ -13,13 +13,15 @@ import {
} from '@solana/web3.js';
import {
NATIVE_MINT,
NATIVE_MINT_2022,
TOKEN_PROGRAM_ID,
closeAccount,
getAccount,
createNativeMint,
createWrappedNativeAccount,
syncNative,
} from '../../src';
import { TEST_PROGRAM_ID, TEST_NATIVE_MINT, newAccountWithLamports, getConnection } from './common';
import { TEST_PROGRAM_ID, newAccountWithLamports, getConnection } from './common';
describe('native', () => {
let connection: Connection;
@ -27,12 +29,16 @@ describe('native', () => {
let owner: Keypair;
let account: PublicKey;
let amount: number;
let nativeMint: PublicKey;
before(async () => {
amount = 1_000_000_000;
connection = await getConnection();
payer = await newAccountWithLamports(connection, 100_000_000_000);
if (TEST_NATIVE_MINT !== NATIVE_MINT) {
await createNativeMint(connection, payer, undefined, TEST_PROGRAM_ID, TEST_NATIVE_MINT);
if (TEST_PROGRAM_ID == TOKEN_PROGRAM_ID) {
nativeMint = NATIVE_MINT;
} else {
nativeMint = NATIVE_MINT_2022;
await createNativeMint(connection, payer, undefined, TEST_PROGRAM_ID, nativeMint);
}
});
beforeEach(async () => {
@ -45,7 +51,7 @@ describe('native', () => {
undefined,
undefined,
TEST_PROGRAM_ID,
TEST_NATIVE_MINT
nativeMint
);
});
it('works', async () => {