| 
									
										
										
										
											2020-07-29 11:05:19 -07:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Fetches the latest SPL programs and produces the solana-genesis command-line | 
					
						
							|  |  |  | # arguments needed to install them | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fetch_program() { | 
					
						
							|  |  |  |   declare name=$1 | 
					
						
							|  |  |  |   declare version=$2 | 
					
						
							|  |  |  |   declare address=$3 | 
					
						
							| 
									
										
										
										
											2020-08-12 09:46:49 -07:00
										 |  |  |   declare loader=$4 | 
					
						
							| 
									
										
										
										
											2020-07-29 11:05:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   declare so=spl_$name-$version.so | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-12 09:46:49 -07:00
										 |  |  |   genesis_args+=(--bpf-program "$address" "$loader" "$so") | 
					
						
							| 
									
										
										
										
											2020-07-29 11:05:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if [[ -r $so ]]; then | 
					
						
							|  |  |  |     return | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -r ~/.cache/solana-spl/$so ]]; then | 
					
						
							|  |  |  |     cp ~/.cache/solana-spl/"$so" "$so" | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     echo "Downloading $name $version" | 
					
						
							|  |  |  |     ( | 
					
						
							|  |  |  |       set -x | 
					
						
							|  |  |  |       curl -L --retry 5 --retry-delay 2 --retry-connrefused \
 | 
					
						
							|  |  |  |         -o "$so" \
 | 
					
						
							|  |  |  |         "https://github.com/solana-labs/solana-program-library/releases/download/$name-v$version/spl_$name.so" | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     mkdir -p ~/.cache/solana-spl | 
					
						
							|  |  |  |     cp "$so" ~/.cache/solana-spl/"$so" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-29 09:23:20 -07:00
										 |  |  | fetch_program token 2.0.3 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader1111111111111111111111111111111111 | 
					
						
							| 
									
										
										
										
											2020-08-12 09:46:49 -07:00
										 |  |  | fetch_program memo  1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111 | 
					
						
							| 
									
										
										
										
											2020-07-29 11:05:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | echo "${genesis_args[@]}" > spl-genesis-args.sh | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo | 
					
						
							|  |  |  | echo "Available SPL programs:" | 
					
						
							|  |  |  | ls -l spl_*.so | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo | 
					
						
							|  |  |  | echo "solana-genesis command-line arguments (spl-genesis-args.sh):" | 
					
						
							|  |  |  | cat spl-genesis-args.sh |