Skip to content

Commit

Permalink
tested make file
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0up committed Apr 30, 2024
1 parent 1dc0e54 commit 647663e
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ deploy-anvil:

deploy-btp:
@eval $$(curl -H "x-auth-token: $${BTP_SERVICE_TOKEN}" -s $${BTP_CLUSTER_MANAGER_URL}/ide/foundry/$${BTP_SCS_ID}/env | sed 's/^/export /'); \
args="--broadcast"; \
args=""; \
if [ ! -z "$${BTP_FROM}" ]; then \
args="--unlocked --sender $${BTP_FROM}"; \
args="--unlocked --sender $${BTP_FROM} --broadcast"; \
else \
echo "\033[1;33mWARNING: No keys are activated on the node, falling back to interactive mode...\033[0m"; \
echo ""; \
Expand All @@ -43,23 +43,28 @@ deploy-btp:
if [ "$${BTP_EIP_1559_ENABLED}" = "false" ]; then \
args="$$args --legacy"; \
fi; \
forge script script/DeployDiamond.s.sol $${args} --rpc-url $${BTP_RPC_URL}
forge script script/DeployDiamond.s.sol $${args} --rpc-url $${BTP_RPC_URL} --json

subgraph:
@echo "Deploying the subgraph..."
@rm -Rf subgraph/subgraph.config.json
.PHONY: deploy-contracts
deploy-contracts:
@output=$$(jq '.transactions[] | select(.transactionType == "CREATE" and (.contractName == "GenericToken" or .contractName == "Diamond")) | if .contractName == "GenericToken" then {contractName: "GenericToken", contractAddress: .contractAddress, transactionHash: .hash} elif .contractName == "Diamond" then {contractName: "Diamond", contractAddress: .contractAddress, transactionHash: .hash} end' broadcast/DeployDiamond.s.sol/42541/run-latest.json); \
DEPLOYED_ERC20_ADDRESS=$$(echo $$output | jq -r 'select(.contractName == "GenericToken") | .contractAddress'); \
TRANSACTION_HASH_ERC20=$$(echo $$output | jq -r 'select(.contractName
@CHAIN_ID=$$(cast chain-id --rpc-url $$BTP_RPC_URL); \
output=$$(jq '.transactions[] | \
select(.transactionType == "CREATE" and \
(.contractName == "GenericToken" or .contractName == "Diamond")) | \
if .contractName == "GenericToken" then \
{contractName: "GenericToken", contractAddress: (.contractAddress // "not available"), transactionHash: (.hash // "not available")} \
elif .contractName == "Diamond" then \
{contractName: "Diamond", contractAddress: (.contractAddress // "not available"), transactionHash: (.hash // "not available")} \
else empty end' broadcast/DeployDiamond.s.sol/$$CHAIN_ID/run-latest.json); \
export DEPLOYED_ERC20_ADDRESS=$$(echo "$$output" | jq -r 'select(.contractName == "GenericToken") | .contractAddress'); \
export TRANSACTION_HASH_ERC20=$$(echo "$$output" | jq -r 'select(.contractName == "GenericToken") | .transactionHash'); \
export DEPLOYED_ADDRESS=$$(echo "$$output" | jq -r 'select(.contractName == "Diamond") | .contractAddress'); \
export TRANSACTION_HASH=$$(echo "$$output" | jq -r 'select(.contractName == "Diamond") | .transactionHash'); \
export BLOCK_NUMBER=$$(cast receipt --rpc-url $${BTP_RPC_URL} $${TRANSACTION_HASH} | grep "^blockNumber" | awk '{print $$2}'); \
export BLOCK_NUMBER_ERC20=$$(cast receipt --rpc-url $${BTP_RPC_URL} $${TRANSACTION_HASH_ERC20} | grep "^blockNumber" | awk '{print $$2}'); \
yq e -p=json -o=json '.datasources[0].address = strenv(DEPLOYED_ADDRESS) | .datasources[0].startBlock = strenv(BLOCK_NUMBER) | .datasources[1].address = strenv(DEPLOYED_ERC20_ADDRESS) | .datasources[1].startBlock = strenv(BLOCK_NUMBER_ERC20) | .chain = strenv(BTP_NODE_UNIQUE_NAME)' subgraph/subgraph.config.template.json > subgraph/subgraph.config.json; \

DEPLOYED_ERC20_ADDRESS=$(echo "$$output" | jq -r 'select(.contractName == "GenericToken") | .contractAddress'); \
TRANSACTION_HASH_ERC20=$(echo "$$output" | jq -r 'select(.contractName == "GenericToken") | .transactionHash');\
DEPLOYED_ADDRESS=$(echo "$$output" | jq -r 'select(.contractName == "Diamond") | .contractAddress'); \
TRANSACTION_HASH=$(echo "$$output" | jq -r 'select(.contractName == "Diamond") | .transactionHash'); \
BLOCK_NUMBER=$$(cast receipt --rpc-url btp $${TRANSACTION_HASH} | grep "blockNumber" | awk '{print $$2}' | sed '2d') BLOCK_NUMBER_ERC20=$$(cast receipt --rpc-url btp $${TRANSACTION_HASH_ERC20} | grep "blockNumber" | awk '{print $$2}' | sed '2d');\
yq e -p=json -o=json '.datasources[0].address = strenv(DEPLOYED_ADDRESS) | .datasources[0].startBlock = strenv(BLOCK_NUMBER) | .datasources[1].address = strenv(DEPLOYED_ADDRESS) | .datasources[1].startBlock = strenv(BLOCK_NUMBER_ERC20) | .chain = strenv(BTP_NODE_UNIQUE_NAME)' subgraph/subgraph.config.template.json > subgraph/subgraph.config.json;\
@cd subgraph && npx graph-compiler --config subgraph.config.json --include node_modules/@openzeppelin/subgraphs/src/datasources ./datasources --export-schema --export-subgraph
@cd subgraph && yq e '.specVersion = "0.0.4"' -i generated/solidity-diamond-bond.subgraph.yaml
@cd subgraph && yq e '.description = "Solidity Token diamond-bond"' -i generated/solidity-diamond-bond.subgraph.yaml
Expand Down

0 comments on commit 647663e

Please sign in to comment.