Skip to content

Commit

Permalink
Merge pull request #8 from davisshaver/rpc
Browse files Browse the repository at this point in the history
feat: add onchain key validation
  • Loading branch information
davisshaver authored Dec 26, 2024
2 parents c68550f + 45cb9a6 commit f3bc0fe
Show file tree
Hide file tree
Showing 25 changed files with 4,413 additions and 330 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/generate-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
timeout-minutes: 70

steps:
- name: Checkout code
- name: Checkout Code
uses: actions/checkout@v4

- name: Build PHP
Expand All @@ -26,36 +26,36 @@ jobs:
with:
bun-version: latest

- name: Install packages w/ Bun
- name: Install Packages w/ Bun
run: bun install

- name: Build with Bun
run: bun run build

- name: Create release ZIP
- name: Create Release ZIP
uses: thedoctor0/zip-release@master
with:
type: 'zip'
filename: 'farcaster-wp.zip'
exclusions: '/*node_modules/* composer.* readme.md package.json .gitignore .eslintrc.js .nvmrc .stylelintrc.json phpcs.xml tsconfig.json bun.lockb .vscode/ .vscode/* .wordpress-org/ .wordpress-org/* src/ src/* src/components/ src/components/* src/hooks/ src/hooks/* src/utils/ src/utils/* /*.git/* /*.github/*'

- name: Upload artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: farcaster-wp
path: farcaster-wp.zip

- name: Upload to release
- name: Upload to Release
run: gh release upload ${{ github.event.release.tag_name }} farcaster-wp.zip
env:
GITHUB_TOKEN: ${{ github.TOKEN }}

- name: Unzip folder for WP.org
- name: Unzip Folder for WP.org
uses: montudor/action-zip@v1
with:
args: unzip -qq farcaster-wp.zip -d farcaster-wp

- name: Upload plugin to WP.org
- name: Upload Plugin to WP.org
id: deploy
uses: 10up/[email protected]
env:
Expand All @@ -64,7 +64,7 @@ jobs:
SLUG: farcaster-wp
BUILD_DIR: ./farcaster-wp

- name: Attest build provenance
- name: Attest Build Provenance
uses: johnbillion/[email protected]
with:
zip-path: ${{ steps.deploy.outputs.zip-path }}
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build PHP
Expand All @@ -17,7 +17,7 @@ jobs:
with:
bun-version: latest

- name: Install packages w/ Bun
- name: Install Packages w/ Bun
run: bun install

- name: Lint PHP
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Lint JS
run: bun run lint:js

- name: Validate types
- name: Validate Types
run: bun run lint:ts

- name: Lint CSS
Expand All @@ -35,5 +35,5 @@ jobs:
- name: Lint package.json
run: bun run lint:pkg-json

- name: Lint Markdown docs
- name: Lint Markdown Docs
run: bun run lint:md:docs
46 changes: 46 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PHPUnit Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:latest
ports:
- '3306:3306'
env:
MYSQL_ROOT_PASSWORD: wordpress
MARIADB_INITDB_SKIP_TZINFO: 1
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.2"

- name: Install PHP Dependencies
uses: ramsey/composer-install@v3

- name: Set Up WordPress and WordPress Test Library
uses: sjinks/setup-wordpress-test-library@master
with:
version: latest

- name: Verify MariaDB Connection
run: |
while ! mysqladmin ping -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} --silent; do
sleep 1
done
timeout-minutes: 1

- name: Run PHPUnit Tests
run: composer test
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ build
.Trashes
ehthumbs.db
Thumbs.db
.thumbsdb
.thumbsdb

# Internal notes
notes.md

# Frames.js debugger
notifications.db
155 changes: 155 additions & 0 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/usr/bin/env bash

if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
exit 1
fi

DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}

TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}

echo WP_CORE_DIR: $WP_CORE_DIR
echo WP_TESTS_DIR: $WP_TESTS_DIR

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}

if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
WP_TESTS_TAG="branches/$WP_VERSION"
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
WP_TESTS_TAG="tags/${WP_VERSION%??}"
else
WP_TESTS_TAG="tags/$WP_VERSION"
fi
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
else
# http serves a single offer, whereas https serves multiple. we only want one
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
if [[ -z "$LATEST_VERSION" ]]; then
echo "Latest WordPress version could not be found"
exit 1
fi
WP_TESTS_TAG="tags/$LATEST_VERSION"
fi

set -ex

install_wp() {

if [ -d $WP_CORE_DIR ]; then
return;
fi

mkdir -p $WP_CORE_DIR

if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p $TMPDIR/wordpress-nightly
download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
else
if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest'
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
# https serves multiple offers, whereas http serves single.
download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
LATEST_VERSION=${WP_VERSION%??}
else
# otherwise, scan the releases and get the most up to date minor version of the major release
local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
fi
if [[ -z "$LATEST_VERSION" ]]; then
local ARCHIVE_NAME="wordpress-$WP_VERSION"
else
local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
fi
else
local ARCHIVE_NAME="wordpress-$WP_VERSION"
fi
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
fi

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
}

install_test_suite() {
# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
local ioption='-i .bak'
else
local ioption='-i'
fi

# set up testing suite if it doesn't yet exist
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

if [ ! -f wp-tests-config.php ]; then
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
# remove all forward slashes in the end
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
fi

}

install_db() {

if [ ${SKIP_DB_CREATE} = "true" ]; then
return 0
fi

# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local DB_HOSTNAME=${PARTS[0]};
local DB_SOCK_OR_PORT=${PARTS[1]};
local EXTRA=""

if ! [ -z $DB_HOSTNAME ] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
elif ! [ -z $DB_HOSTNAME ] ; then
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
fi
fi

# create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

install_wp
install_test_suite
install_db
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"automattic/vipwpcs": "^3.0",
"wp-coding-standards/wpcs": "^3.0",
"dealerdirect/phpcodesniffer-composer-installer": "*",
"phpcompatibility/phpcompatibility-wp": "*"
"phpcompatibility/phpcompatibility-wp": "*",
"yoast/phpunit-polyfills": "^3.0",
"phpunit/phpunit": "^7.0 || ^9.5"
},
"autoload": {
"classmap": [
Expand All @@ -22,5 +24,12 @@
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"drlecks/simple-web3-php": "dev-master"
},
"scripts": {
"phpunit": "phpunit --config=phpunit.xml",
"test": "@phpunit"
}
}
Loading

0 comments on commit f3bc0fe

Please sign in to comment.