Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ WAVS_CLI_LOG_LEVEL="info, wavs_cli=info"
WAVS_AGGREGATOR_DATA=~/wavs/aggregator
WAVS_AGGREGATOR_MNEMONIC="test test test test test test test test test test test junk"

# TODO: set if you want to upload to IPFS - https://app.pinata.cloud/developers/api-keys
PINATA_JWT=

# == Testnet ==
# Replace with your RPC URL
RPC_URL=https://holesky.drpc.org
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,47 @@ COMPONENT_FILENAME=eth_price_oracle.wasm AGGREGATOR_URL=http://127.0.0.1:8001 sh
SERVICE_CONFIG_FILE=.docker/service.json make deploy-service
```

## (optional) Upload to IPFS

```bash docci-ignore
# TODO: requires component upload to a registry (i.e. do this before the deploy)
# TODO: put this in the build service / deploy service to use instead?

source .env
if [ -z "${PINATA_JWT}" ]; then
echo "PINATA_JWT is not set. Please set it in .env"
exit 1
fi

# Upload the service JSON to IPFS
# {"data":{"id":"01965e4a-01e0-790e-8b40-756a7c889850","user_id":"b45a8a32-1fcf-4372-8cf5-ad4f0a02fbe7","name":"service-id-apr-22-12-13.json","network":"public","vectorized":false,"created_at":"2025-04-22T16:17:10.917Z","updated_at":"2025-04-22T16:17:10.917Z","accept_duplicates":false,"cid":"bafkreih7qefpplveuf3kqk7wedpo3vgwan7p65xof64cx5jjurnkgvgu7m","mime_type":"application/json","size":1319,"number_of_files":1}}
curl --request POST \
--url https://uploads.pinata.cloud/v3/files \
--header "Authorization: Bearer ${PINATA_JWT}" \
--header 'Content-Type: multipart/form-data' \
--form file=@.docker/service.json \
--form network=public \
--form name=service-id-apr-22-12-13.json

# Verify it is uploaded
CID=`curl --request GET --url https://api.pinata.cloud/v3/files/public/01965e4a-01e0-790e-8b40-756a7c889850 --header "Authorization: Bearer ${PINATA_JWT}" | jq -r .data.cid`
echo "CID: ${CID}"

# pin
curl --request POST \
--url https://api.pinata.cloud/pinning/pinByHash \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${PINATA_JWT}" \
--data "{
\"hashToPin\": \"${CID}\"
}"

# ipfs query cid
# Visit https://app.pinata.cloud/gateway

curl https://azure-internal-xerinae-429.mypinata.cloud/files/bafkreih7qefpplveuf3kqk7wedpo3vgwan7p65xof64cx5jjurnkgvgu7m
```

## Trigger the Service

Anyone can now call the [trigger contract](./src/contracts/WavsTrigger.sol) which emits the trigger event WAVS is watching for from the previous step. WAVS then calls the service and saves the result on-chain.
Expand Down
36 changes: 33 additions & 3 deletions script/build_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TRIGGER_EVENT=${TRIGGER_EVENT:-"NewTrigger(bytes)"}
TRIGGER_CHAIN=${TRIGGER_CHAIN:-"local"}
SUBMIT_CHAIN=${SUBMIT_CHAIN:-"local"}
AGGREGATOR_URL=${AGGREGATOR_URL:-""}
UPLOAD_REGISTRY_VERSION=${UPLOAD_REGISTRY_VERSION:-""}
export DOCKER_DEFAULT_PLATFORM=linux/amd64

BASE_CMD="docker run --rm --network host -w /data -v $(pwd):/data ghcr.io/lay3rlabs/wavs:reece_priv_key_signing_apr_10 wavs-cli service --json true --home /data --file /data/${FILE_LOCATION}"
Expand Down Expand Up @@ -56,7 +57,6 @@ TRIGGER_EVENT_HASH=`cast keccak ${TRIGGER_EVENT}`
SERVICE_ID=`$BASE_CMD init --name demo | jq -r .id`
echo "Service ID: ${SERVICE_ID}"


WORKFLOW_ID=`$BASE_CMD workflow add | jq -r '.workflows | keys | .[0]'`
echo "Workflow ID: ${WORKFLOW_ID}"

Expand All @@ -69,8 +69,38 @@ if [ -n "$AGGREGATOR_URL" ]; then
fi
$BASE_CMD workflow submit --id ${WORKFLOW_ID} ${SUB_CMD} --address ${SUBMIT_ADDRESS} --chain-name ${SUBMIT_CHAIN} --max-gas ${MAX_GAS} > /dev/null

COMPONENT_ID=`$BASE_CMD workflow component --id ${WORKFLOW_ID} set --digest ${WASM_DIGEST} | jq -r '.workflows | keys | .[0]'`
echo "Component ID: ${COMPONENT_ID}"
if [ -n "$UPLOAD_REGISTRY_VERSION" ]; then
echo "Uploading component to registry..."

# TODO: rm me (testing)
UPLOAD_REGISTRY_VERSION=0.0.3
WORKFLOW_ID=123
echo "REMOVE ME ABOVE (WORKFLOW AND UPLOAD REGISTRY VERSIONS)"

# replace any - or _ with no space
COMPONENT_FILENAME_NORMALIZED=`echo ${COMPONENT_FILENAME} | sed 's/_/-/g'`
# COMPONENT_FILENAME_NORMALIZED=`echo ${COMPONENT_FILENAME_NORMALIZED} | sed 's/-//g'`
COMPONENT_FILENAME_NORMALIZED=`echo ${COMPONENT_FILENAME_NORMALIZED} | sed 's/.wasm//g'`
if [[ ${UPLOAD_REGISTRY_VERSION} == v* ]]; then
UPLOAD_REGISTRY_VERSION=${UPLOAD_REGISTRY_VERSION:1}
fi


# TODO: change package name as well
BASE_PACKAGE=reecepbcups:${COMPONENT_FILENAME_NORMALIZED}; echo $BASE_PACKAGE
wkg publish --registry wa.dev --package ${BASE_PACKAGE}@${UPLOAD_REGISTRY_VERSION} ./compiled/${COMPONENT_FILENAME}

# TODO:
wavs-cli service workflow component --id ${WORKFLOW_ID} set-source-registry --package ${BASE_PACKAGE} --domain wa.dev --version ${UPLOAD_REGISTRY_VERSION}

echo "Component ID: ${COMPONENT_ID}"
else
echo "Using existing component digest: ${WASM_DIGEST}"
COMPONENT_ID=`$BASE_CMD workflow component --id ${WORKFLOW_ID} set --digest ${WASM_DIGEST} | jq -r '.workflows | keys | .[0]'`
echo "Component ID: ${COMPONENT_ID}"
fi



$BASE_CMD workflow component --id ${COMPONENT_ID} permissions --http-hosts '*' --file-system true > /dev/null
$BASE_CMD workflow component --id ${COMPONENT_ID} time-limit --seconds 30 > /dev/null
Expand Down
Loading