Skip to content

Commit

Permalink
feat: Subscribe to events automatically when deploying smartdeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
asanson1404 committed Mar 27, 2024
1 parent be6746b commit dd81a61
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
4 changes: 0 additions & 4 deletions .env

This file was deleted.

6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SOROBAN_NETWORK=testnet
SOROBAN_ACCOUNT=default
CONFIG_DIR=.
SOROBAN_FEE=10000000
MERCURY_BACKEND_ENDPOINT=https://api.mercurydata.app:8443
MERCURY_JWT_TOKEN=request-access-to-mercury-team
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target/
.soroban

.env
2 changes: 2 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ if test "$ID" = ""; then
fi
echo $ID

./subscribe_events.sh $ID

# smartdeploy="soroban --quiet contract invoke --id $ID"

if test "$FILE_HASH" = ""; then
Expand Down
33 changes: 33 additions & 0 deletions subscribe_events.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Load the .env variables
if [ -f .env ]; then
source .env
else
echo "The file .env doesn't exist"
exit 1
fi

# Subscribe to the "Publish" event
# XDR built with JS: sorobanClient.xdr.ScVal.scvString("Publish").toXDR("base64")
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MERCURY_JWT_TOKEN" \
-d '{
"contract_id": "'"$1"'",
"topic1": "AAAADgAAAAdQdWJsaXNoAA=="
}' \
$MERCURY_BACKEND_ENDPOINT/event

# Subscribe to the "Deploy" event
# XDR built with JS: sorobanClient.xdr.ScVal.scvString("Deploy").toXDR("base64")
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MERCURY_JWT_TOKEN" \
-d '{
"contract_id": "'"$1"'",
"topic1": "AAAADgAAAAZEZXBsb3kAAA=="
}' \
$MERCURY_BACKEND_ENDPOINT/event

echo "\n\nSuccessfully subscribed to the events"

0 comments on commit dd81a61

Please sign in to comment.