Skip to content

Commit

Permalink
Add a tapir CI job (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Jan 8, 2024
2 parents 1a8c590 + 70b5794 commit 8333cc2
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 24 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/lynx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ on:
schedule:
- cron: "0 * * * *" # Every hour
pull_request:
# branches:
# - main
# - development
# - epic-*
workflow_dispatch:

env: # TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://polygon-mumbai.infura.io/v3/3747007a284045d483c342fb39889a30"
ENCRYPTOR_PRIVATE_KEY: "0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86"
CONSUMER_PRIVATE_KEY: "0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4"
RITUAL_ID: "0"

jobs:
build_project:
networks:
name: '🔎 Lynx Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'

runs-on: ${{ matrix.os }}
Expand All @@ -37,19 +35,20 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Lynx testnet node-js script installation
- name: Install dependencies
working-directory: ./examples/taco/nodejs
run: pnpm install

- name: Lynx testnet node-js script environment
- name: Setup environment
working-directory: ./examples/taco/nodejs
# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
run: |
echo RPC_PROVIDER_URL=$RPC_PROVIDER_URL > .env
echo ENCRYPTOR_PRIVATE_KEY=$ENCRYPTOR_PRIVATE_KEY >> .env
echo CONSUMER_PRIVATE_KEY=$CONSUMER_PRIVATE_KEY >> .env
echo RITUAL_ID=$RITUAL_ID >> .env
echo DOMAIN=lynx >> .env
- name: Lynx testnet node-js script execution
id: lynx_script
- name: Run taco/nodejs script
working-directory: ./examples/taco/nodejs
run: pnpm start
56 changes: 56 additions & 0 deletions .github/workflows/tapir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: '🔎 Tapir Testnet Example'

on:
schedule:
- cron: "0 * * * *" # Every hour
pull_request:
branches:
- main
workflow_dispatch:

# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://polygon-mumbai.infura.io/v3/3747007a284045d483c342fb39889a30"
ENCRYPTOR_PRIVATE_KEY: "0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86"
CONSUMER_PRIVATE_KEY: "0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4"
RITUAL_ID: "5"

jobs:
networks:
name: '🔎 Tapir Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '18.x' ]
os: [ ubuntu-latest ]

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 8.1

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
working-directory: ./examples/taco/nodejs
run: pnpm install

- name: Setup environment
working-directory: ./examples/taco/nodejs
# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
run: |
echo RPC_PROVIDER_URL=$RPC_PROVIDER_URL > .env
echo ENCRYPTOR_PRIVATE_KEY=$ENCRYPTOR_PRIVATE_KEY >> .env
echo CONSUMER_PRIVATE_KEY=$CONSUMER_PRIVATE_KEY >> .env
echo RITUAL_ID=$RITUAL_ID >> .env
echo DOMAIN=tapir >> .env
- name: Run taco/nodejs script
working-directory: ./examples/taco/nodejs
run: pnpm start
2 changes: 1 addition & 1 deletion demos/taco-demo/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const DEFAULT_RITUAL_ID =
(process.env.DEFAULT_RITUAL_ID && parseInt(process.env.DEFAULT_RITUAL_ID)) ||
24;

export const DEFAULT_DOMAIN = process.env.DEFAULT_DOMAIN || domains.DEV;
export const DEFAULT_DOMAIN = process.env.DEFAULT_DOMAIN || domains.DEVNET;
2 changes: 1 addition & 1 deletion demos/taco-nft-demo/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const DEFAULT_RITUAL_ID =
(process.env.DEFAULT_RITUAL_ID && parseInt(process.env.DEFAULT_RITUAL_ID)) ||
24;

export const DEFAULT_DOMAIN = process.env.DEFAULT_DOMAIN || domains.DEV;
export const DEFAULT_DOMAIN = process.env.DEFAULT_DOMAIN || domains.DEVNET;
2 changes: 2 additions & 0 deletions examples/taco/nodejs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ RPC_PROVIDER_URL=https://polygon-mumbai-bor.publicnode.com
# We provide here some defaults, but we encourage you to choose your own.
ENCRYPTOR_PRIVATE_KEY=0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86
CONSUMER_PRIVATE_KEY=0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4
RITUAL_ID=5
DOMAIN=tapir
7 changes: 5 additions & 2 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ if (!consumerPrivateKey) {
throw new Error('CONSUMER_PRIVATE_KEY is not set.');
}

const domain = domains.TESTNET;
const ritualId = 5; // Replace with your own ritual ID
const domain = process.env.DOMAIN || domains.TESTNET;
const ritualId = parseInt(process.env.RITUAL_ID || "5");
const provider = new ethers.providers.JsonRpcProvider(rpcProviderUrl);

console.log('Domain:', domain);
console.log('Ritual ID:', ritualId);

const encryptToBytes = async (messageString: string) => {
const encryptorSigner = new ethers.Wallet(encryptorPrivateKey);
console.log(
Expand Down
2 changes: 1 addition & 1 deletion packages/pre/test/acceptance/alice-grants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('story: alice shares message with bob through policy', () => {
policy = await alice.grant(
fakeProvider(),
fakeSigner(),
domains.DEV,
domains.DEVNET,
fakePorterUri,
policyParams,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/pre/test/acceptance/delay-enact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('story: alice creates a policy but someone else enacts it', () => {
const enacted = await preEnactedPolicy.enact(
provider,
fakeSigner(),
domains.DEV,
domains.DEVNET,
);
expect(enacted.txHash).toBeDefined();

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nucypher/nucypher-contracts": "^0.13.0",
"@nucypher/nucypher-contracts": "^0.15.0",
"@nucypher/nucypher-core": "*",
"axios": "^1.6.2",
"deep-equal": "^2.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/porter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const porterUri: Record<string, string> = {
export type Domain = keyof typeof porterUri;

export const domains: Record<string, Domain> = {
DEV: 'lynx',
DEVNET: 'lynx',
TESTNET: 'tapir',
MAINNET: 'mainnet',
};
Expand Down
4 changes: 2 additions & 2 deletions packages/taco/test/taco.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('taco', () => {

const messageKit = await taco.encrypt(
provider,
domains.DEV,
domains.DEVNET,
message,
ownsNFT,
mockedDkg.ritualId,
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('taco', () => {

const decryptedMessage = await taco.decrypt(
provider,
domains.DEV,
domains.DEVNET,
messageKit,
fakePorterUri,
signer,
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8333cc2

Please sign in to comment.