Skip to content

Commit 62d07b9

Browse files
authored
fix: use BTP_FROM instead of ETH_FROM (#4)
The interactive mode was being used even when an ETH_FROM was being returned from the cluster manager. This is because we have the if statement and exporting the envs in separate commands in the Makefile, which are executed in separate terminal subshells.
1 parent 18bcebb commit 62d07b9

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Makefile

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@ deploy-anvil:
2727
@forge create ./src/Counter.sol:Counter --rpc-url anvil --interactive | tee deployment-anvil.txt
2828

2929
deploy:
30-
@eval $$(curl -H "x-auth-token: $${BPT_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /')
31-
@if [ -z "${ETH_FROM}" ]; then \
32-
if [ -z "${BTP_GAS_PRICE}" ]; then \
33-
forge create ./src/Counter.sol:Counter ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --interactive | tee deployment.txt; \
30+
@eval $$(curl -H "x-auth-token: $${BTP_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /'); \
31+
if [ -z "$${BTP_FROM}" ]; then \
32+
echo "\033[1;33mWARNING: No keys are activated on the node, falling back to interactive mode...\033[0m"; \
33+
echo ""; \
34+
if [ -z "$${BTP_GAS_PRICE}" ]; then \
35+
forge create ./src/Counter.sol:Counter $${EXTRA_ARGS} --rpc-url $${BTP_RPC_URL} --interactive | tee deployment.txt; \
3436
else \
35-
forge create ./src/Counter.sol:Counter ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --interactive --gas-price ${BTP_GAS_PRICE} | tee deployment.txt; \
37+
forge create ./src/Counter.sol:Counter $${EXTRA_ARGS} --rpc-url $${BTP_RPC_URL} --interactive --gas-price $${BTP_GAS_PRICE} | tee deployment.txt; \
3638
fi; \
3739
else \
38-
if [ -z "${BTP_GAS_PRICE}" ]; then \
39-
forge create ./src/Counter.sol:Counter ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --unlocked | tee deployment.txt; \
40+
if [ -z "$${BTP_GAS_PRICE}" ]; then \
41+
forge create ./src/Counter.sol:Counter $${EXTRA_ARGS} --rpc-url $${BTP_RPC_URL} --unlocked --from $${BTP_FROM} | tee deployment.txt; \
4042
else \
41-
forge create ./src/Counter.sol:Counter ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --unlocked --gas-price ${BTP_GAS_PRICE} | tee deployment.txt; \
43+
forge create ./src/Counter.sol:Counter $${EXTRA_ARGS} --rpc-url $${BTP_RPC_URL} --unlocked --from $${BTP_FROM} --gas-price $${BTP_GAS_PRICE} | tee deployment.txt; \
4244
fi; \
4345
fi
4446

@@ -54,13 +56,13 @@ script:
5456
echo "\033[1;31mERROR: Contract was not deployed or the deployment-anvil.txt went missing.\033[0m"; \
5557
exit 1; \
5658
fi
57-
@eval $$(curl -H "x-auth-token: $${BPT_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /')
58-
@if [ -z "${ETH_FROM}" ]; then \
59+
@eval $$(curl -H "x-auth-token: $${BTP_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /'); \
60+
if [ -z "${BTP_FROM}" ]; then \
5961
echo "\033[1;33mWARNING: No keys are activated on the node, falling back to interactive mode...\033[0m"; \
6062
echo ""; \
6163
@DEPLOYED_ADDRESS=$$(grep "Deployed to:" deployment.txt | awk '{print $$3}') forge script script/Counter.s.sol:CounterScript ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} -i=1; \
6264
else \
63-
@DEPLOYED_ADDRESS=$$(grep "Deployed to:" deployment.txt | awk '{print $$3}') forge script script/Counter.s.sol:CounterScript ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --unlocked; \
65+
@DEPLOYED_ADDRESS=$$(grep "Deployed to:" deployment.txt | awk '{print $$3}') forge script script/Counter.s.sol:CounterScript ${EXTRA_ARGS} --rpc-url ${BTP_RPC_URL} --unlocked --froms ${BTP_FROM}; \
6466
fi
6567

6668
cast:
@@ -79,8 +81,8 @@ subgraph:
7981
@cd subgraph && yq e '.features = ["nonFatalErrors", "fullTextSearch", "ipfsOnEthereumContracts"]' -i generated/solidity-token-erc20.subgraph.yaml
8082
@cd subgraph && pnpm graph codegen generated/solidity-token-erc20.subgraph.yaml
8183
@cd subgraph && pnpm graph build generated/solidity-token-erc20.subgraph.yaml
82-
@eval $$(curl -H "x-auth-token: $${BPT_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /')
83-
@if [ "$${BTP_MIDDLEWARE}" == "" ]; then \
84+
@eval $$(curl -H "x-auth-token: $${BTP_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /'); \
85+
if [ "$${BTP_MIDDLEWARE}" == "" ]; then \
8486
echo "You have not launched a graph middleware for this smart contract set, aborting..."; \
8587
exit 1; \
8688
else \

0 commit comments

Comments
 (0)