devnet_setup.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. # This script configures the devnet for test transfers with hardcoded addresses.
  3. set -x
  4. # Configure CLI (works the same as upstream Solana CLI)
  5. mkdir -p ~/.config/solana/cli
  6. cat <<EOF > ~/.config/solana/cli/config.yml
  7. json_rpc_url: "http://127.0.0.1:8899"
  8. websocket_url: ""
  9. keypair_path: /usr/src/solana/id.json
  10. EOF
  11. # Static key for the mint so it always has the same address
  12. cat <<EOF > token.json
  13. [179,228,102,38,68,102,75,133,127,56,63,167,143,42,59,29,220,215,100,149,220,241,176,204,154,241,168,147,195,139,55,100,22,88,9,115,146,64,160,172,3,185,132,64,254,137,133,84,142,58,166,131,205,13,77,157,245,181,101,150,105,250,163,1]
  14. EOF
  15. # Constants
  16. cli_address=6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J
  17. bridge_address=Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
  18. initial_guardian=befa429d57cd18b7f8a4d91a2da9ab4af05d0fbe
  19. recipient_address=90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
  20. chain_id_ethereum=2
  21. retry () {
  22. while ! $@; do
  23. sleep 1
  24. done
  25. }
  26. # Fund our account (as seen in id.json).
  27. retry solana airdrop 1000 --faucet-port 9900 --faucet-host 127.0.0.1
  28. # Create a new SPL token
  29. token=$(spl-token create-token -- token.json | grep 'Creating token' | awk '{ print $3 }')
  30. echo "Created token $token"
  31. # Create token account
  32. account=$(spl-token create-account "$token" | grep 'Creating account' | awk '{ print $3 }')
  33. echo "Created token account $account"
  34. # Mint new tokens owned by our CLI account
  35. spl-token mint "$token" 10000000000 "$account"
  36. # Create the bridge contract at a known address
  37. # OK to fail on subsequent attempts (already created).
  38. retry client create-bridge "$bridge_address" "$initial_guardian" 86400 100 200
  39. # Let k8s startup probe succeed
  40. nc -l -p 2000
  41. # Keep the container alive for interactive CLI usage
  42. sleep infinity