Skip to content

Commit

Permalink
Init sh/update-program-id.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
s-damian committed Aug 25, 2024
1 parent 0281162 commit 2e91824
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,16 @@ anchor deploy

### Change Program ID

1/2. Find your program ID in `target/idl/nft_ticketing.json`.

2/2. Update the program ID in:
- `Anchor.toml`
- `programs/nft-ticketing/src/lib.rs`
```bash
npm run update-program-id
```

### IDL Setup

Copy the IDL (Interface Definition Language) file into the Next.js App:

```bash
./sh/copy-idl.sh
npm run copy-idl
```

### Run Front-End (Next.js App)
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"scripts": {
"lint:fix": "prettier */*.js \"*/**/*.{js,jsx,ts,tsx}\" -w",
"lint": "prettier */*.js \"*/**/*.{js,jsx,ts,tsx}\" --check",
"build": "anchor build && ./sh/copy-idl.sh",
"build": "anchor build && npm run copy-idl",
"lint-all": "cargo fmt && npm run lint:fix",
"deploy": "anchor build && anchor deploy && ./sh/copy-idl.sh",
"deploy": "anchor build && anchor deploy && npm run copy-idl",
"ledger": "./sh/test-ledger.sh",
"ledger-b": "./sh/test-ledger-b.sh",
"test": "anchor test --skip-local-validator"
"test": "anchor test --skip-local-validator",
"copy-idl": "./sh/copy-idl.sh",
"update-program-id": "./sh/update-program-id.sh"
},
"dependencies": {
"@coral-xyz/anchor": "0.30.1",
Expand Down
14 changes: 14 additions & 0 deletions sh/update-program-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Assurez-vous que le script est exécutable avec : chmod +x update_program_id.sh

# Obtenez le nouveau Program ID
PROGRAM_ID=$(solana address -k target/deploy/nft_ticketing-keypair.json)

# Mise à jour de Anchor.toml
sed -i "s/nft_ticketing = \"[^\"]*\"/nft_ticketing = \"$PROGRAM_ID\"/" Anchor.toml

# Mise à jour de lib.rs
sed -i "s/declare_id!(\"[^\"]*\")/declare_id!(\"$PROGRAM_ID\")/" programs/nft-ticketing/src/lib.rs

echo "Program ID updated to $PROGRAM_ID in Anchor.toml and lib.rs."

0 comments on commit 2e91824

Please sign in to comment.