From 647663e422363b4ae08706357f520b271e6c4132 Mon Sep 17 00:00:00 2001 From: bl0up Date: Tue, 30 Apr 2024 15:38:10 +0200 Subject: [PATCH] tested make file --- Makefile | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 09fba52..f999550 100644 --- a/Makefile +++ b/Makefile @@ -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 ""; \ @@ -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