From 36a69495029a6e90b38157fa050de5f1b788f7d9 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Tue, 16 Jul 2019 17:53:23 -0400 Subject: [PATCH] fix: end of life native loader (#404) --- bin/localnet.sh | 26 +----------------------- module.flow.js | 10 ---------- src/index.js | 1 - src/native-loader.js | 41 -------------------------------------- test/native-loader.test.js | 37 ---------------------------------- 5 files changed, 1 insertion(+), 114 deletions(-) delete mode 100644 src/native-loader.js delete mode 100644 test/native-loader.test.js diff --git a/bin/localnet.sh b/bin/localnet.sh index 53b5cf8f1931c7..64e95827356b82 100755 --- a/bin/localnet.sh +++ b/bin/localnet.sh @@ -21,7 +21,7 @@ usage() { echo "Error: $*" fi cat <; } - // === src/native-loader.js === - declare export class NativeLoader { - static programId: PublicKey; - static load( - connection: Connection, - payer: Account, - programName: string, - ): Promise; - } - // === src/util/send-and-confirm-transaction.js === declare export function sendAndConfirmTransaction( connection: Connection, diff --git a/src/index.js b/src/index.js index 379a7031eb7630..0dcc62cc27a867 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,6 @@ export {BpfLoader} from './bpf-loader'; export {BudgetProgram} from './budget-program'; export {Connection} from './connection'; export {Loader} from './loader'; -export {NativeLoader} from './native-loader'; export {PublicKey} from './publickey'; export {SystemProgram} from './system-program'; export {Token, TokenAmount} from './token-program'; diff --git a/src/native-loader.js b/src/native-loader.js deleted file mode 100644 index 794de73e2c6a30..00000000000000 --- a/src/native-loader.js +++ /dev/null @@ -1,41 +0,0 @@ -// @flow - -import {Account} from './account'; -import {PublicKey} from './publickey'; -import {Loader} from './loader'; -import type {Connection} from './connection'; - -/** - * Factory class for transactions to interact with a program loader - */ -export class NativeLoader { - /** - * Public key that identifies the NativeLoader - */ - static get programId(): PublicKey { - return new PublicKey('NativeLoader1111111111111111111111111111111'); - } - - /** - * Loads a native program - * - * @param connection The connection to use - * @param payer System account that pays to load the program - * @param programName Name of the native program - */ - static load( - connection: Connection, - payer: Account, - programName: string, - ): Promise { - const bytes = [...Buffer.from(programName)]; - const program = new Account(); - return Loader.load( - connection, - payer, - program, - NativeLoader.programId, - bytes, - ); - } -} diff --git a/test/native-loader.test.js b/test/native-loader.test.js deleted file mode 100644 index b8fb5362e6b174..00000000000000 --- a/test/native-loader.test.js +++ /dev/null @@ -1,37 +0,0 @@ -// @flow - -import { - Connection, - NativeLoader, - Transaction, - sendAndConfirmTransaction, -} from '../src'; -import {mockRpcEnabled} from './__mocks__/node-fetch'; -import {url} from './url'; -import {newAccountWithLamports} from './new-account-with-lamports'; - -if (!mockRpcEnabled) { - // The default of 5 seconds is too slow for live testing sometimes - jest.setTimeout(15000); -} - -test('load native program', async () => { - if (mockRpcEnabled) { - console.log('non-live test skipped'); - return; - } - - const connection = new Connection(url); - const from = await newAccountWithLamports(connection, 1024); - const programId = await NativeLoader.load( - connection, - from, - 'solana_noop_program', - ); - const transaction = new Transaction().add({ - keys: [{pubkey: from.publicKey, isSigner: true, isDebitable: true}], - programId, - }); - - await sendAndConfirmTransaction(connection, transaction, from); -});