devnet_setup.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/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. # Constants
  12. cli_address=6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J
  13. bridge_address=Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
  14. initial_guardian=befa429d57cd18b7f8a4d91a2da9ab4af05d0fbe
  15. recipient_address=90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
  16. chain_id_ethereum=2
  17. retry () {
  18. while ! $@; do
  19. sleep 1
  20. done
  21. }
  22. # Fund our account (as seen in id.json).
  23. retry cli airdrop 127.0.0.1:9900
  24. # Create the bridge contract at a known address
  25. # OK to fail on subsequent attempts (already created).
  26. retry cli create-bridge "$bridge_address" "$initial_guardian"
  27. # Create a new SPL token (at a random address)
  28. token=$(cli create-token --seed=29934 | grep 'Creating token' | awk '{ print $3 }')
  29. echo "Created token $token"
  30. # Create token account
  31. account=$(cli create-account --seed=38489 "$token" | grep 'Creating account' | awk '{ print $3 }')
  32. echo "Created token account $account"
  33. # Mint new tokens owned by our CLI account
  34. cli mint "$token" 10000000000 "$account"
  35. # Create wrapped asset for the token we mint in send-lockups.js (2 = Ethereum, 9 decimals)
  36. wrapped_token=$(cli create-wrapped "$bridge_address" 2 9 000000000000000000000000CfEB869F69431e42cdB54A4F4f105C19C080A601 | grep 'Wrapped Mint address' | awk '{ print $4 }')
  37. echo "Created wrapped token $token"
  38. # Create token account to receive wrapped assets from send-lockups.js
  39. wrapped_account=$(cli create-account --seed=934893 "$wrapped_token" | grep 'Creating account' | awk '{ print $3 }')
  40. echo "Created wrapped token account $wrapped_account"
  41. # Let k8s startup probe succeed
  42. nc -l -p 2000
  43. # Keep the container alive for interactive CLI usage
  44. sleep infinity