-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* onboarding v6 * minor fixes
- Loading branch information
Showing
70 changed files
with
4,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/.vscode | ||
/.git | ||
/.gitignore | ||
/.prettier | ||
/.prettierignore | ||
|
||
.env | ||
|
||
/media | ||
node_modules | ||
!/node_modules/@eversdk/lib-web/eversdk.wasm | ||
!/node_modules/@eversdk/lib-web/index.js | ||
|
||
/tonos-cli.conf.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = false | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.ts] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[{*.json,*.jsonc}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[{*.yml,*.yaml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
indent_size = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.env | ||
.vscode | ||
node_modules | ||
|
||
/media | ||
/abi | ||
deno.lock | ||
|
||
/tonos-cli.conf.json | ||
/docker-compose.override.yaml | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
/build | ||
/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": false, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 90 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# syntax=docker/dockerfile:1.5.2 | ||
|
||
FROM denoland/deno:debian-1.34.3 as base_deno | ||
RUN apt update && apt install -y jq git wget libssl-dev libc6 curl | ||
|
||
FROM base_deno | ||
# TODO: will go away after ever sdk supports deno land | ||
WORKDIR /app/node_modules/@eversdk/lib-web | ||
COPY --link node_modules/@eversdk/lib-web/index.js ./ | ||
COPY --link node_modules/@eversdk/lib-web/eversdk.wasm ./ | ||
|
||
COPY --link --from=teamgosh/gosh-cli:0.2.0 /usr/local/bin/gosh-cli /usr/local/bin/gosh-cli | ||
|
||
WORKDIR /workdir | ||
ARG BRANCH=dev | ||
ENV BRANCH=${BRANCH} | ||
RUN <<EOF | ||
set -ex | ||
echo "$BRANCH" | ||
git clone --branch "$BRANCH" --depth 1 https://github.com/gosh-sh/gosh.git gosh | ||
cd gosh | ||
bash install.sh | ||
mv $HOME/.gosh/git-remote-gosh* /usr/local/bin/ | ||
cd .. | ||
rm -rf gosh | ||
EOF | ||
# WARNING: change workdir after | ||
|
||
WORKDIR /app/src | ||
COPY --link src/_deps.ts _deps.ts | ||
RUN deno cache _deps.ts | ||
|
||
WORKDIR /app | ||
COPY --link src src | ||
COPY --link bin bin | ||
COPY --link abi abi | ||
COPY --link emails emails | ||
|
||
ARG GOSH_ENDPOINTS | ||
ENV GOSH_ENDPOINTS=${GOSH_ENDPOINTS} | ||
ENV GOSHCLI_CONFIG=/gosh-cli.conf.json | ||
|
||
# TODO fix endpoints | ||
RUN <<EOF | ||
gosh-cli config --is_json true | ||
gosh-cli config -e ${GOSH_ENDPOINTS} | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# TODO refactor | ||
include .env | ||
|
||
BRANCH ?= dev | ||
|
||
.PHONY: docker | ||
docker: | ||
rm -rf abi | ||
mkdir -p abi | ||
cp ../v6_x/v6.1.0/contracts/gosh/*.abi.json abi | ||
cp ../v6_x/v6.1.0/contracts/*.abi.json abi | ||
npm i | ||
if [ -z "$(GOSH_ENDPOINTS)" ]; then echo GOSH_ENDPOINTS required; exit 1; fi | ||
docker buildx build \ | ||
--progress=plain \ | ||
-t gosh-onboarding-v6 \ | ||
--no-cache \ | ||
--build-arg GOSH_ENDPOINTS=$(GOSH_ENDPOINTS) \ | ||
--build-arg BRANCH=$(BRANCH) \ | ||
. | ||
|
||
.PHONY: fmt | ||
fmt: | ||
npx prettier -w . | ||
|
||
.PHONY: supabase_types | ||
supabase_types: | ||
echo $(SUPABASE_ADMIN_URI) | ||
if test -z "$(SUPABASE_ADMIN_URI)"; then echo set SUPABASE_ADMIN_URI ; exit 1; fi | ||
mkdir -p src/db | ||
npx supabase gen types typescript --db-url $(SUPABASE_ADMIN_URI) > src/db/types.ts | ||
npx prettier -w src/db/types.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
. "$(dirname "$0")/util.sh" | ||
. "$(dirname "$0")/gosh.sh" | ||
|
||
PROPOSAL_CODE_HASH=$1 | ||
REPO_NAME=$2 | ||
PROPOSAL_ABI=abi/SMVProposal.abi.json | ||
|
||
ensure_provided NETWORK | ||
ensure_provided PROPOSAL_CODE_HASH | ||
ensure_provided REPO_NAME | ||
ensure_abi_exists PROPOSAL_ABI | ||
|
||
accounts=$(curl -s "$NETWORK/graphql" \ | ||
-H 'Accept-Encoding: gzip, deflate, br' \ | ||
-H 'Content-Type: application/json' \ | ||
-H 'Accept: application/json' \ | ||
-H 'Connection: keep-alive' \ | ||
-H 'DNT: 1' \ | ||
-H "Origin: $NETWORK" \ | ||
--data-binary "{\"query\":\"query { accounts(filter: { code_hash: { eq: \\\"${PROPOSAL_CODE_HASH}\\\" } }) { id } }\"}" \ | ||
--compressed \ | ||
| jq -r '.data.accounts[] | .id?' | ||
) | ||
|
||
for account in $accounts; do | ||
status=$(get_proposal_deploy_repo_status $account) | ||
if [ -n "$status" ]; then | ||
name=$(get_proposal_deploy_repo_name $account) | ||
if [ $name == $REPO_NAME ]; then | ||
echo "${status}" | ||
exit | ||
fi | ||
else | ||
echo "" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
PROPOSAL_KIND_DEPLOY_REPO=0x000000000000000000000000000000000000000000000000000000000000000c | ||
|
||
function get_proposal_details { | ||
proposal_addr=$1 | ||
ensure_provided proposal_addr | ||
tonos-cli -j -u $NETWORK run $1 getDetails {} \ | ||
--abi ../v6_x/v6.1.0/contracts/gosh/smv/SMVProposal.abi.json | jq -r . | ||
} | ||
|
||
function get_proposal_deploy_repo_status { | ||
proposal_addr=$1 | ||
ensure_provided proposal_addr | ||
status=$(tonos-cli -j -u $NETWORK run $1 getDetails {} \ | ||
--abi ../v6_x/v6.1.0/contracts/gosh/smv/SMVProposal.abi.json \ | ||
| jq -r ". | select(.value0==\"$PROPOSAL_KIND_DEPLOY_REPO\") | .value1") | ||
echo -n $status | ||
} | ||
|
||
function get_proposal_deploy_repo_name { | ||
proposal_addr=$1 | ||
ensure_provided proposal_addr | ||
tonos-cli -j -u $NETWORK run $1 getGoshDeployRepoProposalParams {} \ | ||
--abi ../v6_x/v6.1.0/contracts/gosh/smv/SMVProposal.abi.json \ | ||
| jq -r ". | select(.proposalKind==\"$PROPOSAL_KIND_DEPLOY_REPO\") | .repoName" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
set -x | ||
. "$(dirname "$0")/util.sh" | ||
|
||
# | ||
# Assumptions check | ||
# | ||
ensure_provided WORKDIR | ||
ensure_provided GIT_REPO_URL | ||
ensure_provided GOSH_SYSTEM_CONTRACT_ADDR | ||
ensure_provided GOSH_DAO_NAME | ||
ensure_provided GOSH_DAO_ADDRESS | ||
ensure_provided GOSH_REPO_NAME | ||
ensure_provided GOSH_BOT_NAME | ||
ensure_provided GOSH_CONFIG_PATH | ||
|
||
LOG_DIR=/tmp/logs-git-remote-gosh | ||
mkdir -p $LOG_DIR | ||
LOG_FILE="$LOG_DIR"/"$GOSH_DAO_NAME"-"$GOSH_REPO_NAME".log | ||
touch "$LOG_FILE" | ||
|
||
# | ||
# Prepare constants for this run | ||
# | ||
BASE_REPO_DIRNAME="${WORKDIR}/${GIT_REPO_URL//[^a-zA-Z0-9]/}" | ||
# Check workdir existence | ||
set +e | ||
set +o pipefail | ||
LS=$(ls -dc $BASE_REPO_DIRNAME* 2>/dev/null) | ||
set -e | ||
set -o pipefail | ||
|
||
if [ -n "$LS" ]; then | ||
THIS_RUN_WORKDIR=$(printf '%s\n' $LS | head -n 1) | ||
else | ||
THIS_RUN_WORKDIR="${BASE_REPO_DIRNAME}-${BASHPID}-$(date +%s)" | ||
fi | ||
|
||
log "THIS_RUN_WORKDIR=${THIS_RUN_WORKDIR}" | ||
|
||
mkdir -p "$THIS_RUN_WORKDIR" | ||
cd "$THIS_RUN_WORKDIR" | ||
|
||
if [ ! -d "repo" ]; then | ||
# --------- | ||
log "Cloning github repo..." | ||
CLONE_START=$SECONDS | ||
git clone "$GIT_REPO_URL" "repo" | ||
CLONE_END=$SECONDS | ||
log "...clone complete. Cloned from github in $((CLONE_END - CLONE_START)) seconds." | ||
fi | ||
|
||
# --------- | ||
export GOSH_CONFIG_PATH | ||
log "Check if repo was already uploaded" | ||
git clone "gosh://$GOSH_SYSTEM_CONTRACT_ADDR/$GOSH_DAO_NAME/$GOSH_REPO_NAME" "repo_clone" || true | ||
log "Repo already exists on GOSH. Compare it with the original" | ||
if diff --brief --recursive "repo" "repo_clone" --exclude ".git" --no-dereference; then | ||
log "Repos are equal" | ||
exit 0 | ||
fi | ||
log "Repos are not equal. Trying to upload it again" | ||
rm -rf "repo_clone" | ||
|
||
# --------- | ||
log "Pushing github repo to gosh...\n________________" | ||
PUSH_START=$SECONDS | ||
cd ./repo | ||
git-remote-gosh_v6_1_0 --version | ||
git-remote-gosh dispatcher_ini | ||
REMOTE_GOSH_TRACKED=$(git remote | grep gosh || true) | ||
if [ -z "$REMOTE_GOSH_TRACKED" ]; then | ||
git remote add gosh "gosh://$GOSH_SYSTEM_CONTRACT_ADDR/$GOSH_DAO_NAME/$GOSH_REPO_NAME" | ||
fi | ||
export GOSH_TRACE=5 | ||
export GOSH_REMOTE_WAIT_TIMEOUT=600 | ||
export GOSH_REMOTE_WALLET_PARALLELISM=10 | ||
git push --all gosh &>>"$LOG_FILE" | ||
PUSH_END=$SECONDS | ||
PUSH_DURATION=$((PUSH_END - PUSH_START)) | ||
log "...complete. Push took $(convertsecs $PUSH_DURATION)." | ||
cd .. | ||
|
||
sleep 60 | ||
|
||
log "Cloning after push\n" | ||
git clone "gosh://$GOSH_SYSTEM_CONTRACT_ADDR/$GOSH_DAO_NAME/$GOSH_REPO_NAME" "repo_clone" | ||
|
||
log "***** comparing repositories *****" | ||
DIFF_STATUS=1 | ||
if diff --brief --recursive "repo" "repo_clone" --exclude ".git" --no-dereference; then | ||
DIFF_STATUS=0 | ||
fi | ||
log "Compare status: $DIFF_STATUS" | ||
|
||
if (( $DIFF_STATUS == 0 )); then | ||
cd /tmp | ||
rm $LOG_FILE | ||
rm -fr $THIS_RUN_WORKDIR | ||
fi | ||
|
||
exit $DIFF_STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
function ensure_provided { | ||
if [ -z "${!1}" ]; then | ||
echo "Assertion error. Variable ${1} was not passed" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
function optional { | ||
if [ -z "${!1}" ]; then | ||
echo "Optional variable ${1} was not passed" | ||
fi | ||
} | ||
|
||
function ensure_abi_exists { | ||
ensure_provided "$1" | ||
if [ ! -f "${!1}" ]; then | ||
echo "ABI file does not exist at the address provided: ${1} -> ${!1}" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
function log { | ||
echo "[$(date +%s)] $1" >>"$LOG_FILE" | ||
} | ||
|
||
convertsecs() { | ||
((h = ${1} / 3600)) | ||
((m = (${1} % 3600) / 60)) | ||
((s = ${1} % 60)) | ||
printf "%02d:%02d:%02d\n" $h $m $s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"fmt": { | ||
"files": { | ||
// disable deno fmt, use prettier for consistency | ||
"exclude": ["."] | ||
} | ||
}, | ||
"tasks": { | ||
"supabase_types": "mkdir -p src/db && npx supabase gen types typescript --db-url $SUPABASE_ADMIN_URI > src/db/types.ts && npx prettier -w src/db/types.ts" | ||
} | ||
} |
Oops, something went wrong.