Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable anchor keys sync auto-replacement by removing program_id_from_env! #1282

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions examples/lzapp-migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,23 @@ pnpm compile
```bash
solana-keygen new -o target/deploy/endpoint-keypair.json --force
solana-keygen new -o target/deploy/oft-keypair.json --force
```

Run

```
anchor keys sync
anchor keys list
```

Copy the OFT's programId and go into [programs/oft202/lib.rs](./programs/oft202/src/lib.rs). Note the following snippet:
:information_source: `anchor keys sync` will replace the example programId value in `declare_id!()` and `Anchor.toml` to match the created keypair's.

```rust
declare_id!(Pubkey::new_from_array(program_id_from_env!(
"OFT_ID",
"3ThC8DDzimnnrt4mvJSKFpWQA3UvnbzKM3mT6SHoNQKu"
)));
```
:information_source: `anchor keys list` will output the generated programIds (public keys). It should look something like this:

Replace `3ThC8DDzimnnrt4mvJSKFpWQA3UvnbzKM3mT6SHoNQKu` with the programId that you have copied.
```
endpoint: <ENDPOINT_PROGRAM_ID>
oft: <OFT_PROGRAM_ID>
```

### Building and Deploying the Solana OFT Program

Expand Down
5 changes: 1 addition & 4 deletions examples/lzapp-migration/programs/oft202/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use oapp::{
use solana_helper::program_id_from_env;
use state::*;

declare_id!(Pubkey::new_from_array(program_id_from_env!(
"OFT_ID",
"3ThC8DDzimnnrt4mvJSKFpWQA3UvnbzKM3mT6SHoNQKu"
)));
declare_id!("3ThC8DDzimnnrt4mvJSKFpWQA3UvnbzKM3mT6SHoNQKu");

pub const OFT_SEED: &[u8] = b"OFT";
pub const PEER_SEED: &[u8] = b"Peer";
Expand Down
18 changes: 4 additions & 14 deletions examples/oft-solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,26 @@ Create `programId` keypair files by running:
```bash
solana-keygen new -o target/deploy/endpoint-keypair.json --force
solana-keygen new -o target/deploy/oft-keypair.json --force

anchor keys sync
```

:warning: `--force` flag overwrites the existing keys with the ones you generate.

Run

```
anchor keys sync
anchor keys list
```

to view the generated programIds (public keys). The output should look something like this:
:information_source: `anchor keys sync` will replace the example programId value in `declare_id!()` and `Anchor.toml` to match the created keypair's.

:information_source: `anchor keys list` will output the generated programIds (public keys). It should look something like this:

```
endpoint: <ENDPOINT_PROGRAM_ID>
oft: <OFT_PROGRAM_ID>
```

Copy the OFT's programId and go into [lib.rs](./programs/oft/src/lib.rs). Note the following snippet:

```
declare_id!(Pubkey::new_from_array(program_id_from_env!(
"OFT_ID",
"9UovNrJD8pQyBLheeHNayuG1wJSEAoxkmM14vw5gcsTT"
)));
```

Replace `9UovNrJD8pQyBLheeHNayuG1wJSEAoxkmM14vw5gcsTT` with the programId that you have copied.

### Building and Deploying the Solana OFT Program

Ensure you have Docker running before running the build command.
Expand Down
5 changes: 1 addition & 4 deletions examples/oft-solana/programs/oft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ use oapp::{
use solana_helper::program_id_from_env;
use state::*;

declare_id!(Pubkey::new_from_array(program_id_from_env!(
"OFT_ID",
"9UovNrJD8pQyBLheeHNayuG1wJSEAoxkmM14vw5gcsTT"
)));
declare_id!("9UovNrJD8pQyBLheeHNayuG1wJSEAoxkmM14vw5gcsTT");

pub const OFT_SEED: &[u8] = b"OFT";
pub const PEER_SEED: &[u8] = b"Peer";
Expand Down
Loading