-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·35 lines (26 loc) · 899 Bytes
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# gen new program id
anchor keys list
PROGRAM_ID=$(solana address -k target/deploy/vault_pool-keypair.json)
# Set the file path
FILE_PATH="programs/vault_pool/src/lib.rs"
# Make sure the file exists
if [ ! -f "$FILE_PATH" ]; then
echo "Error: File not found: $FILE_PATH"
exit 1
fi
# Replace the existing declare_id! line with the new PROGRAM_ID
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
sed -i "" "s/declare_id!(\"[^\"]*\")/declare_id!(\"$PROGRAM_ID\")/g" "$FILE_PATH"
else
# Linux and others
sed -i "s/declare_id!(\"[^\"]*\")/declare_id!(\"$PROGRAM_ID\")/g" "$FILE_PATH"
fi
# Build the program
anchor build
# Copy the artifacts into the sdk
cp target/types/vault_pool.ts sdk/idl
FILE=sdk/idl/vault_pool.ts
sed -i "" "s/export type VaultPool/export type VaultPool/g" "$FILE"
sed -i "" "s/export const IDL: VaultPool/export const IDL: VaultPool/g" "$FILE"