From edce49f848e9aa8d16aa2e60356b83620fea6dfd Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 29 Nov 2022 10:40:20 +0100 Subject: [PATCH 1/4] Remove default chain and fix tests --- src/policies/conditions.ts | 1 - test/integration/enrico.test.ts | 2 ++ test/integration/pre.test.ts | 2 ++ test/unit/strategy.test.ts | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/policies/conditions.ts b/src/policies/conditions.ts index 0c9430a98..e5f341ad6 100644 --- a/src/policies/conditions.ts +++ b/src/policies/conditions.ts @@ -299,7 +299,6 @@ class EvmCondition extends Condition { class ERC721Ownership extends EvmCondition { readonly defaults = { - chain: 5, // TODO: make this value configurable method: 'ownerOf', parameters: [], standardContractType: 'ERC721', diff --git a/test/integration/enrico.test.ts b/test/integration/enrico.test.ts index bc509cd0c..f3281b0ad 100644 --- a/test/integration/enrico.test.ts +++ b/test/integration/enrico.test.ts @@ -116,11 +116,13 @@ describe('enrico', () => { const ownsBufficornNFT = new Conditions.ERC721Ownership({ contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77', + chain: 5, parameters: [3591], }); const ownsNonsenseNFT = new Conditions.ERC721Ownership({ contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77', + chain: 5, parameters: [6969], }); diff --git a/test/integration/pre.test.ts b/test/integration/pre.test.ts index ee808b6fa..c896c7b6c 100644 --- a/test/integration/pre.test.ts +++ b/test/integration/pre.test.ts @@ -87,9 +87,11 @@ describe('proxy reencryption', () => { const genuineUndead = new Conditions.ERC721Ownership({ contractAddress: '0x209e639a0EC166Ac7a1A4bA41968fa967dB30221', + chain: 1, }); const gnomePals = new Conditions.ERC721Ownership({ contractAddress: '0x5dB11d7356aa4C0E85Aa5b255eC2B5F81De6d4dA', + chain: 1, }); const conditions = new ConditionSet([ genuineUndead, diff --git a/test/unit/strategy.test.ts b/test/unit/strategy.test.ts index b0fd3b0da..9dbc01687 100644 --- a/test/unit/strategy.test.ts +++ b/test/unit/strategy.test.ts @@ -197,6 +197,7 @@ describe('Deployed Strategy', () => { const ownsNFT = new Conditions.ERC721Ownership({ contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77', parameters: [3591], + chain: 5, }); const plaintext = 'this is a secret'; From ebe9e62912b50672657382b5c5c97b2704e76ca6 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 29 Nov 2022 10:41:37 +0100 Subject: [PATCH 2/4] Add test for validation of chain in conditions --- test/integration/conditions.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/integration/conditions.test.ts b/test/integration/conditions.test.ts index bc633a618..433937da8 100644 --- a/test/integration/conditions.test.ts +++ b/test/integration/conditions.test.ts @@ -37,6 +37,11 @@ describe('conditions schema', () => { expect(result.error).toEqual(undefined); expect(result.value.chain).toEqual(5); }); + + it('should validate chain id', async () => { + result = condition.validate({ chain: 10 }); + expect(result.error?.message).toEqual("\"chain\" must be one of [1, 5, 137, 80001]"); + }); }); describe('condition set', () => { From a6bb035b6f0ce5e3c85e1d0eb1884720d0b1bc46 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 29 Nov 2022 11:10:19 +0100 Subject: [PATCH 3/4] Change ibex references to tapir --- examples/react-craco/src/App.js | 2 +- examples/react-webpack-5-experiments/src/App.tsx | 2 +- examples/webpack-5-experiments/index.js | 2 +- examples/webpack-bundler/index.js | 2 +- src/config.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/react-craco/src/App.js b/examples/react-craco/src/App.js index 1fd205371..72aa3ffe2 100644 --- a/examples/react-craco/src/App.js +++ b/examples/react-craco/src/App.js @@ -38,7 +38,7 @@ function App() { const config = { // Public Porter endpoint on Ibex network - porterUri: 'https://porter-ibex.nucypher.community', + porterUri: 'https://porter-tapir.nucypher.community', }; const makeAlice = () => { diff --git a/examples/react-webpack-5-experiments/src/App.tsx b/examples/react-webpack-5-experiments/src/App.tsx index e97d4a884..aca13ec4d 100644 --- a/examples/react-webpack-5-experiments/src/App.tsx +++ b/examples/react-webpack-5-experiments/src/App.tsx @@ -34,7 +34,7 @@ export function App() { const config = { // Public Porter endpoint on Ibex network - porterUri: 'https://porter-ibex.nucypher.community', + porterUri: 'https://porter-tapir.nucypher.community', } const makeAlice = () => { diff --git a/examples/webpack-5-experiments/index.js b/examples/webpack-5-experiments/index.js index e2421e44e..1c86b90bb 100644 --- a/examples/webpack-5-experiments/index.js +++ b/examples/webpack-5-experiments/index.js @@ -5,7 +5,7 @@ const txtEncoder = new TextEncoder(); const config = { // Public Porter endpoint on Ibex network - porterUri: 'https://porter-ibex.nucypher.community', + porterUri: 'https://porter-tapir.nucypher.community', } const makeAlice = (provider) => { diff --git a/examples/webpack-bundler/index.js b/examples/webpack-bundler/index.js index 301011329..d93ed5178 100644 --- a/examples/webpack-bundler/index.js +++ b/examples/webpack-bundler/index.js @@ -3,7 +3,7 @@ import { ethers } from 'ethers'; const config = { // Public Porter endpoint on Ibex network - porterUri: 'https://porter-ibex.nucypher.community', + porterUri: 'https://porter-tapir.nucypher.community', } const makeAlice = (provider) => { diff --git a/src/config.ts b/src/config.ts index 1584bb519..32b969429 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,7 +9,7 @@ const CONFIGS: { readonly [key in ChainId]: Configuration } = { porterUri: 'https://porter.nucypher.community', }, [ChainId.MUMBAI]: { - porterUri: 'https://porter-ibex.nucypher.community', + porterUri: 'https://porter-tapir.nucypher.community', }, }; From ae6cd07cb1fe55057dcca56815a025f51b54411a Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 29 Nov 2022 11:12:47 +0100 Subject: [PATCH 4/4] Run prettier --- src/policies/conditions.ts | 1 - test/integration/conditions.test.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/policies/conditions.ts b/src/policies/conditions.ts index e5f341ad6..6b16e8268 100644 --- a/src/policies/conditions.ts +++ b/src/policies/conditions.ts @@ -311,7 +311,6 @@ class ERC721Ownership extends EvmCondition { class ERC721Balance extends EvmCondition { readonly defaults = { - chain: 5, // TODO: make this value configurable method: 'balanceOf', parameters: [':userAddress'], standardContractType: 'ERC721', diff --git a/test/integration/conditions.test.ts b/test/integration/conditions.test.ts index 433937da8..1c2f2c726 100644 --- a/test/integration/conditions.test.ts +++ b/test/integration/conditions.test.ts @@ -40,7 +40,9 @@ describe('conditions schema', () => { it('should validate chain id', async () => { result = condition.validate({ chain: 10 }); - expect(result.error?.message).toEqual("\"chain\" must be one of [1, 5, 137, 80001]"); + expect(result.error?.message).toEqual( + '"chain" must be one of [1, 5, 137, 80001]' + ); }); });