|
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
import 'zx/globals';
|
|
|
import {
|
|
|
getCargo,
|
|
|
+ getExternalAccountAddresses,
|
|
|
getExternalProgramAddresses,
|
|
|
getExternalProgramOutputDir,
|
|
|
getProgramFolders,
|
|
|
@@ -21,10 +22,18 @@ if (!restart && isValidatorRunning) {
|
|
|
|
|
|
// Initial message.
|
|
|
const verb = isValidatorRunning ? 'Restarting' : 'Starting';
|
|
|
+
|
|
|
+// Get programs and accounts.
|
|
|
const programs = [...getPrograms(), ...getExternalPrograms()];
|
|
|
const programPluralized = programs.length === 1 ? 'program' : 'programs';
|
|
|
+const accounts = [...getExternalAccounts()];
|
|
|
+const accountsPluralized = accounts.length === 1 ? 'account' : 'accounts';
|
|
|
+
|
|
|
echo(
|
|
|
- `${verb} local validator with ${programs.length} custom ${programPluralized}...`
|
|
|
+ `${verb} local validator with ${programs.length} custom ${programPluralized}` +
|
|
|
+ (accounts.length > 0
|
|
|
+ ? ` and ${accounts.length} external ${accountsPluralized}...`
|
|
|
+ : `...`)
|
|
|
);
|
|
|
|
|
|
// Kill the validator if it's already running.
|
|
|
@@ -41,6 +50,11 @@ programs.forEach(({ programId, deployPath }) => {
|
|
|
args.push(/* Load BPF program */ '--bpf-program', programId, deployPath);
|
|
|
});
|
|
|
|
|
|
+// Load accounts.
|
|
|
+accounts.forEach(({ account, deployPath }) => {
|
|
|
+ args.push(/* Load account */ '--account', account, deployPath);
|
|
|
+});
|
|
|
+
|
|
|
// Start the validator in detached mode.
|
|
|
const cliLogs = path.join(os.tmpdir(), 'validator-cli.log');
|
|
|
fs.writeFileSync(cliLogs, '', () => {});
|
|
|
@@ -98,3 +112,11 @@ function getExternalPrograms() {
|
|
|
deployPath: path.join(binaryDir, `${address}.so`),
|
|
|
}));
|
|
|
}
|
|
|
+
|
|
|
+function getExternalAccounts() {
|
|
|
+ const binaryDir = getExternalProgramOutputDir();
|
|
|
+ return getExternalAccountAddresses().map((address) => ({
|
|
|
+ account: address,
|
|
|
+ deployPath: path.join(binaryDir, `${address}.json`),
|
|
|
+ }));
|
|
|
+}
|