From 37479a159dc12d7c0adfa12e8d7aadeef048d42c Mon Sep 17 00:00:00 2001 From: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com> Date: Wed, 14 Dec 2022 09:55:25 +0100 Subject: [PATCH] idl deploy workaround, reduce size by cutting largest fields i.e. docs (#334) * idl deploy workaround, reduce size by cutting largest fields i.e. docs Signed-off-by: microwavedcola1 * fixes from review Signed-off-by: microwavedcola1 * Fixes from review Signed-off-by: microwavedcola1 Signed-off-by: microwavedcola1 --- idl-fixup.sh | 13 +++++++++++++ release-to-devnet.sh | 2 +- release-to-mainnet.sh | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/idl-fixup.sh b/idl-fixup.sh index bc9275128..66c9e9089 100755 --- a/idl-fixup.sh +++ b/idl-fixup.sh @@ -19,3 +19,16 @@ done # errors on enums that have tuple variants. This hack drops these from the idl. perl -0777 -pi -e 's/ *{\s*"name": "NodeRef(?(?:[^{}[\]]+|\{(?&nested)\}|\[(?&nested)\])*)\},\n//g' \ target/idl/mango_v4.json target/types/mango_v4.ts; + +# Reduce size of idl to be uploaded to chain +cp target/idl/mango_v4.json target/idl/mango_v4_no_docs.json +jq 'del(.types[]?.docs)' target/idl/mango_v4_no_docs.json \ + > target/idl/mango_v4_no_docs.json.bak && mv target/idl/mango_v4_no_docs.json.bak target/idl/mango_v4_no_docs.json +jq 'del(.accounts[]?.type.fields[]?.docs)' target/idl/mango_v4_no_docs.json \ + > target/idl/mango_v4_no_docs.json.bak && mv target/idl/mango_v4_no_docs.json.bak target/idl/mango_v4_no_docs.json +jq 'del(.instructions[]?.docs)' target/idl/mango_v4_no_docs.json \ + > target/idl/mango_v4_no_docs.json.bak && mv target/idl/mango_v4_no_docs.json.bak target/idl/mango_v4_no_docs.json +jq 'del(.instructions[]?.accounts[]?.docs)' target/idl/mango_v4_no_docs.json \ + > target/idl/mango_v4_no_docs.json.bak && mv target/idl/mango_v4_no_docs.json.bak target/idl/mango_v4_no_docs.json +jq 'del(.types[]?.type.fields[]?.docs)' target/idl/mango_v4_no_docs.json \ + > target/idl/mango_v4_no_docs.json.bak && mv target/idl/mango_v4_no_docs.json.bak target/idl/mango_v4_no_docs.json diff --git a/release-to-devnet.sh b/release-to-devnet.sh index 07e6aa0f1..91f010fe1 100755 --- a/release-to-devnet.sh +++ b/release-to-devnet.sh @@ -22,7 +22,7 @@ solana --url https://mango.devnet.rpcpool.com program deploy --program-id $PROGR # # publish idl cargo run -p anchor-cli -- idl upgrade --provider.cluster https://mango.devnet.rpcpool.com --provider.wallet $WALLET_WITH_FUNDS \ - --filepath target/idl/mango_v4.json $PROGRAM_ID + --filepath target/idl/mango_v4_no_docs.json $PROGRAM_ID # build npm package diff --git a/release-to-mainnet.sh b/release-to-mainnet.sh index dc0ccfb6e..d75c80e57 100755 --- a/release-to-mainnet.sh +++ b/release-to-mainnet.sh @@ -22,7 +22,7 @@ solana --url $MB_CLUSTER_URL program deploy --program-id $PROGRAM_ID \ # publish idl cargo run -p anchor-cli -- idl upgrade --provider.cluster $MB_CLUSTER_URL --provider.wallet $WALLET_WITH_FUNDS \ - --filepath target/idl/mango_v4.json $PROGRAM_ID + --filepath target/idl/mango_v4_no_docs.json $PROGRAM_ID # build npm package