CronCats / treasury

Autonomous treasury for enabling DAOs or any type of near account to manage multiple funds to accrue interest across different vehicles
MIT License
4 stars 2 forks source link

E2E Testing: Actions (Timing, Budget, Transfer) #14

Open TrevorJTClarke opened 2 years ago

TrevorJTClarke commented 2 years ago

Unit Tests

Workspace Tests

Examples:


# add/remove permissions
near call $TREASURY_ACCOUNT_ID add_allowed_actions '{"actions": [{ "Transfer": { "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }}]}' --accountId $TREASURY_ACCOUNT_ID
near call $TREASURY_ACCOUNT_ID add_allowed_actions '{"actions": [{ "Budget": { "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }}]}' --accountId $TREASURY_ACCOUNT_ID
near call $TREASURY_ACCOUNT_ID remove_allowed_action '{"actions": [{ "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }]}' --accountId $TREASURY_ACCOUNT_ID
near view $TREASURY_ACCOUNT_ID get_approved_action_types
near view $TREASURY_ACCOUNT_ID is_allowed_action '{ "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }' --accountId $TREASURY_ACCOUNT_ID

# create actions
EPOCH=$(date +"%s")
ACTION_TIMEOUT_1min=$((($EPOCH * 1000 + 60000) * 1000000))
near call $TREASURY_ACCOUNT_ID create_actions '{"actions": [{"priority": 1, "timeout": "'$ACTION_TIMEOUT_1min'", "payload": { "Transfer": { "token_id": "wrap.testnet", "receiver_id": "you.testnet", "amount": "1000000000000000000000000", "msg": "transfer wrapped near"}}}]}' --accountId $TREASURY_ACCOUNT_ID --gas $MAX_GAS

# See everthing thats scheduled
#TBD

# Remove Actions
#TBD

# call cadence
near call $TREASURY_ACCOUNT_ID call_cadence_action '{"cadence": "0 3 * * * *"}' --accountId $CRONCAT_MANAGER_ID --gas $MAX_GAS

# call timeout
near call $TREASURY_ACCOUNT_ID call_timeout_actions --accountId $TREASURY_ACCOUNT_ID --gas $MAX_GAS