Skip to content

Commit

Permalink
Updated repo urls and fixed deploy command
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCipherCoder committed Sep 15, 2024
1 parent 23bdce9 commit d615a19
Showing 1 changed file with 54 additions and 12 deletions.
66 changes: 54 additions & 12 deletions content/courses/program-optimization/program-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ feature flags.
### 1. Starter

Download the starter code from
the [`starter` branch of this repository](https://github.com/Unboxed-Software/solana-admin-instructions/tree/starter).
the [`starter` branch of this repository](https://github.com/solana-developers/admin-instructions/tree/starter).
The code contains a program with a single instruction handler and a single test
in the `tests` directory.

Expand Down Expand Up @@ -565,21 +565,43 @@ the deploy command for the program with an upgradeable loader. To use it, run
run the deploy command after the test validator has started.

```typescript
import { execSync } from "child_process"
import { execSync } from "child_process";
import path from "path";

...

const deploy = () => {
const deployCmd = `solana program deploy --url localhost -v --program-id $(pwd)/target/deploy/config-keypair.json $(pwd)/target/deploy/config.so`
execSync(deployCmd)
}
const workingDirectory = process.cwd();
const programKeypairPath = path.join(
workingDirectory,
"target",
"deploy",
"config-keypair.json",
);
const programBinaryPath = path.join(
workingDirectory,
"target",
"deploy",
"config.so",
);

const deploy_command = `solana program deploy --url localhost -v --program-id "${programKeypairPath}" "${programBinaryPath}"`;

try {
execSync(deploy_command, { stdio: "inherit" });
console.log("Program deployed successfully");
} catch (error) {
console.error("Error deploying program:", error.message);
throw error;
}
};

...

before(async () => {
deploy()
deploy();
...
})
});
```

For example, the command to run the test with features would look like this:
Expand All @@ -596,8 +618,29 @@ the file name with the one generated in the previous step.
let tokenMint: PublicKey;

const deploy = () => {
const deployCmd = `solana program deploy --url localhost -v --program-id $(pwd)/target/deploy/config-keypair.json $(pwd)/target/deploy/config.so`;
execSync(deployCmd);
const workingDirectory = process.cwd();
const programKeypairPath = path.join(
workingDirectory,
"target",
"deploy",
"config-keypair.json",
);
const programBinaryPath = path.join(
workingDirectory,
"target",
"deploy",
"config.so",
);

const deploy_command = `solana program deploy --url localhost -v --program-id "${programKeypairPath}" "${programBinaryPath}"`;

try {
execSync(deploy_command, { stdio: "inherit" });
console.log("Program deployed successfully");
} catch (error) {
console.error("Error deploying program:", error.message);
throw error;
}
};

before(async () => {
Expand Down Expand Up @@ -1091,7 +1134,7 @@ Catch the `SendTransactionError` and call `getLogs()` on it for full details.
And that's it! You've made the program a lot easier to work with moving forward.
If you want to take a look at the final solution code you can find it on
the [`solution` branch of the same](https://github.com/Unboxed-Software/solana-admin-instructions/tree/solution).
the [`solution` branch of the same](https://github.com/solana-developers/admin-instructions/tree/solution).
## Challenge
Expand All @@ -1101,8 +1144,7 @@ the lab's `initialize_program_config` so that only the upgrade authority can
call it rather than having a hardcoded `ADMIN`.
Try doing this on your own, but if you get stuck, feel free to reference the
`challenge` branch of
[the same repository](https://github.com/Unboxed-Software/solana-admin-instructions/tree/challenge)
[`challenge` branch of the same repository](https://github.com/solana-developers/admin-instructions/tree/challenge)
to see one possible solution.
<Callout type="success" title="Completed the lab?">
Expand Down

0 comments on commit d615a19

Please sign in to comment.