fix: end of life native loader (#404)
This commit is contained in:
committed by
Michael Vines
parent
6f05930076
commit
2e3c5e7820
@ -21,7 +21,7 @@ usage() {
|
|||||||
echo "Error: $*"
|
echo "Error: $*"
|
||||||
fi
|
fi
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: $0 [update|up|down|logs|deploy] [command-specific options]
|
usage: $0 [update|up|down|logs] [command-specific options]
|
||||||
|
|
||||||
Operate a local testnet
|
Operate a local testnet
|
||||||
|
|
||||||
@ -29,7 +29,6 @@ Operate a local testnet
|
|||||||
up - Start the cluster
|
up - Start the cluster
|
||||||
down - Stop the cluster
|
down - Stop the cluster
|
||||||
logs - Display cluster logging
|
logs - Display cluster logging
|
||||||
deploy - Deploy a native program.
|
|
||||||
|
|
||||||
|
|
||||||
logs-specific options:
|
logs-specific options:
|
||||||
@ -49,11 +48,6 @@ Operate a local testnet
|
|||||||
down-specific options:
|
down-specific options:
|
||||||
none
|
none
|
||||||
|
|
||||||
deploy-specific options:
|
|
||||||
program - The program to deploy.
|
|
||||||
|
|
||||||
Note that deployments are discarded on cluster stop
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
}
|
}
|
||||||
@ -154,24 +148,6 @@ logs)
|
|||||||
docker logs solana-localnet
|
docker logs solana-localnet
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
deploy)
|
|
||||||
program=$1
|
|
||||||
[[ -n $program ]] || usage
|
|
||||||
[[ -f $program ]] || usage "file does not exist: $program"
|
|
||||||
|
|
||||||
basename=$(basename "$program")
|
|
||||||
if docker exec solana-localnet test -f /usr/bin/"$basename"; then
|
|
||||||
echo "Error: $basename has already been deployed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
(
|
|
||||||
set -x
|
|
||||||
docker cp "$program" solana-localnet:/usr/bin/
|
|
||||||
)
|
|
||||||
docker exec solana-localnet ls -l /usr/bin/"$basename"
|
|
||||||
echo "$basename deployed successfully"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
usage "Unknown command: $cmd"
|
usage "Unknown command: $cmd"
|
||||||
esac
|
esac
|
||||||
|
@ -306,16 +306,6 @@ declare module '@solana/web3.js' {
|
|||||||
): Promise<PublicKey>;
|
): Promise<PublicKey>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === src/native-loader.js ===
|
|
||||||
declare export class NativeLoader {
|
|
||||||
static programId: PublicKey;
|
|
||||||
static load(
|
|
||||||
connection: Connection,
|
|
||||||
payer: Account,
|
|
||||||
programName: string,
|
|
||||||
): Promise<PublicKey>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// === src/util/send-and-confirm-transaction.js ===
|
// === src/util/send-and-confirm-transaction.js ===
|
||||||
declare export function sendAndConfirmTransaction(
|
declare export function sendAndConfirmTransaction(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
|
@ -4,7 +4,6 @@ export {BpfLoader} from './bpf-loader';
|
|||||||
export {BudgetProgram} from './budget-program';
|
export {BudgetProgram} from './budget-program';
|
||||||
export {Connection} from './connection';
|
export {Connection} from './connection';
|
||||||
export {Loader} from './loader';
|
export {Loader} from './loader';
|
||||||
export {NativeLoader} from './native-loader';
|
|
||||||
export {PublicKey} from './publickey';
|
export {PublicKey} from './publickey';
|
||||||
export {SystemProgram} from './system-program';
|
export {SystemProgram} from './system-program';
|
||||||
export {Token, TokenAmount} from './token-program';
|
export {Token, TokenAmount} from './token-program';
|
||||||
|
@ -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<PublicKey> {
|
|
||||||
const bytes = [...Buffer.from(programName)];
|
|
||||||
const program = new Account();
|
|
||||||
return Loader.load(
|
|
||||||
connection,
|
|
||||||
payer,
|
|
||||||
program,
|
|
||||||
NativeLoader.programId,
|
|
||||||
bytes,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
});
|
|
Reference in New Issue
Block a user