SNS testflight error

Hi everyone. You can use these instructions to deploy a testflight to a local replica:

First you need to get the right version of the sns binary, which this command will download to ./sns:

GIT_HASH="f72ad66cc01b5441da26a596abaa2117c023844d"
PLATFORM=$(uname | tr '[[:upper:]]' '[[:lower:]]')
DOWNLOAD_NAME="sns"
DEST=./sns
curl "https://download.dfinity.systems/ic/${GIT_HASH}/binaries/x86_64-${PLATFORM}/${DOWNLOAD_NAME}.gz" | zcat >"$DEST" && chmod +x "$DEST"

Once we have that, we can deploy the testflight like this:

# Requires a modern DFX
dfx --version 
# should say: dfx 0.16.1 or similar
# add the sns canisters to your DFX environment
dfx extension install sns --version 0.3.1
export DFX_IC_COMMIT=f72ad66cc01b5441da26a596abaa2117c023844d
dfx sns import
dfx sns download
# start the local replica (in a new terminal)
dfx start --clean
# (you may need to run `dfx stop`)
# deploy a testflight
rm ./sns_canister_ids # ok if this fails
./sns deploy-testflight --verbose --init-config-file=$(pwd)/sns_init.yaml
# you need a canister to give to the SNS, I'll create one but you can deploy it to the local replica any way you like, just set the CID variable to the canister's principal ID
TMP=$(mktemp -d) && (cd $TMP && echo '{"canisters": { "x": {} }}' >dfx.json && dfx canister create --no-wallet  x ; rm -rf .dfx ; rm dfx.json ) ; rmdir $TMP
CID="bnz7o-iuaaa-aaaaa-qaaaa-cai" # replace with your canister ID
# create the proposal to register the dapp canister
NETWORK="local"
SNS_GOVRENANCE_CANISTER=$(jq -r '.governance_canister_id' ./sns_canister_ids.json) 
CANDID_PATH="candid/sns_governance.did"
PRINCIPAL="$(dfx identity get-principal)"
NEURON_ID=$(dfx canister \
   --network "${NETWORK}" \
   call "${SNS_GOVRENANCE_CANISTER}" \
   --candid ${CANDID_PATH} \
   list_neurons "(record {of_principal = opt principal\"${PRINCIPAL}\"; limit = 1})" | sed -n 's/.*id = blob "\([^"]*\).*/\1/p')
dfx canister \
   --network "${NETWORK}" \
   call "${SNS_GOVRENANCE_CANISTER}" \
   --candid ${CANDID_PATH} \
   manage_neuron "(record { subaccount = blob \"${NEURON_ID}\"; command = opt variant {MakeProposal = record { title=\"Register dapp's canisters with SNS.\"; url=\"https://example.com/\"; summary=\"This proposal registers dapp's canisters with SNS.\"; action=opt variant {RegisterDappCanisters = record {canister_ids=vec {principal\"${CID}\"}}}}} })"

Edit: replaced with instructions that are tested to work on mainnet. In particular, the steps where we download the sns-cli and add the sns canisters to your dfx environment have been changed. If you followed the previous version of the instructions, run rm ./sns-* && rm ./ic-icrc1-* before re-adding the sns canisters to your environment

2 Likes