#!/bin/bash
set -e

. "$(dirname "$0")/0_env.sh"

# Initialize the Dew Kernel contract
# Uses simple new(base_asset) constructor which auto-grants owner role to predecessor
echo "Initializing Dew Kernel at: $CONTRACT_ID"
echo "Signer (will receive owner role): $SIGNER_ID"

near call $CONTRACT_ID new "$KERNEL_CONFIG" \
  --accountId=$SIGNER_ID \
  --gas=300000000000000

echo "✅ Kernel initialization completed!"
echo "Owner role automatically granted to: $SIGNER_ID"