From 5bd8e956d10735953d788a5f36388bdf0e15f70e Mon Sep 17 00:00:00 2001 From: Ali Mahdiyar Date: Thu, 23 Nov 2023 20:42:38 +0330 Subject: [PATCH 1/2] fix: ConditionContext import error --- demos/taco-demo/webpack.config.js | 2 +- demos/taco-nft-demo/webpack.config.js | 2 +- packages/taco/src/conditions/base/shared.ts | 2 +- packages/taco/src/conditions/const.ts | 2 ++ packages/taco/src/conditions/context/context.ts | 9 ++++++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/demos/taco-demo/webpack.config.js b/demos/taco-demo/webpack.config.js index 60d709f95..11c98381e 100644 --- a/demos/taco-demo/webpack.config.js +++ b/demos/taco-demo/webpack.config.js @@ -11,7 +11,7 @@ module.exports = { entry: './src', devtool: isDevelopment ? 'eval-source-map' : 'source-map', plugins: [ - // isDevelopment && new ReactRefreshWebpackPlugin(), // TODO: Investigate why ConditionContext can't be loaded here + isDevelopment && new ReactRefreshWebpackPlugin(), new HtmlWebpackPlugin({ template: './src/index.html', }), diff --git a/demos/taco-nft-demo/webpack.config.js b/demos/taco-nft-demo/webpack.config.js index 60d709f95..11c98381e 100644 --- a/demos/taco-nft-demo/webpack.config.js +++ b/demos/taco-nft-demo/webpack.config.js @@ -11,7 +11,7 @@ module.exports = { entry: './src', devtool: isDevelopment ? 'eval-source-map' : 'source-map', plugins: [ - // isDevelopment && new ReactRefreshWebpackPlugin(), // TODO: Investigate why ConditionContext can't be loaded here + isDevelopment && new ReactRefreshWebpackPlugin(), new HtmlWebpackPlugin({ template: './src/index.html', }), diff --git a/packages/taco/src/conditions/base/shared.ts b/packages/taco/src/conditions/base/shared.ts index 8da43d203..325abda27 100644 --- a/packages/taco/src/conditions/base/shared.ts +++ b/packages/taco/src/conditions/base/shared.ts @@ -1,11 +1,11 @@ import { z } from 'zod'; import { + CONTEXT_PARAM_PREFIX, CONTEXT_PARAM_REGEXP, ETH_ADDRESS_REGEXP, USER_ADDRESS_PARAM, } from '../const'; -import { CONTEXT_PARAM_PREFIX } from '../context/context'; export const contextParamSchema = z.string().regex(CONTEXT_PARAM_REGEXP); // We want to discriminate between ContextParams and plain strings diff --git a/packages/taco/src/conditions/const.ts b/packages/taco/src/conditions/const.ts index 971c0839b..c7f80d5f0 100644 --- a/packages/taco/src/conditions/const.ts +++ b/packages/taco/src/conditions/const.ts @@ -7,6 +7,8 @@ export const ETH_ADDRESS_REGEXP = new RegExp('^0x[a-fA-F0-9]{40}$'); // Only allow alphanumeric characters and underscores export const CONTEXT_PARAM_REGEXP = new RegExp('^:[a-zA-Z_][a-zA-Z0-9_]*$'); +export const CONTEXT_PARAM_PREFIX = ':'; + export const SUPPORTED_CHAIN_IDS = [ ChainId.POLYGON, ChainId.MUMBAI, diff --git a/packages/taco/src/conditions/context/context.ts b/packages/taco/src/conditions/context/context.ts index 312fa085c..f4ea81103 100644 --- a/packages/taco/src/conditions/context/context.ts +++ b/packages/taco/src/conditions/context/context.ts @@ -1,11 +1,15 @@ -import { Context, Conditions as WASMConditions } from '@nucypher/nucypher-core'; +import { Conditions as WASMConditions, Context } from '@nucypher/nucypher-core'; import { fromJSON, toJSON } from '@nucypher/shared'; import { ethers } from 'ethers'; import { CompoundConditionType } from '../compound-condition'; import { Condition, ConditionProps } from '../condition'; import { ConditionExpression } from '../condition-expr'; -import { CONTEXT_PARAM_REGEXP, USER_ADDRESS_PARAM } from '../const'; +import { + CONTEXT_PARAM_PREFIX, + CONTEXT_PARAM_REGEXP, + USER_ADDRESS_PARAM, +} from '../const'; import { TypedSignature, WalletAuthenticationProvider } from './providers'; @@ -13,7 +17,6 @@ export type CustomContextParam = string | number | boolean; export type ContextParam = CustomContextParam | TypedSignature; export const RESERVED_CONTEXT_PARAMS = [USER_ADDRESS_PARAM]; -export const CONTEXT_PARAM_PREFIX = ':'; const ERR_RESERVED_PARAM = (key: string) => `Cannot use reserved parameter name ${key} as custom parameter`; From 493fbcac1510a10f9677335718d2ea32c99d3b82 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 24 Nov 2023 10:38:32 +0100 Subject: [PATCH 2/2] chore(linter): fix linter --- examples/taco/nodejs/src/index.ts | 1 + packages/taco/src/conditions/context/context.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts index 0d624c7b7..e9595823d 100644 --- a/examples/taco/nodejs/src/index.ts +++ b/examples/taco/nodejs/src/index.ts @@ -78,6 +78,7 @@ const decryptFromBytes = async (encryptedBytes: Uint8Array) => { "\nConsumer signer's address:", await consumerSigner.getAddress(), ); + const messageKit = ThresholdMessageKit.fromBytes(encryptedBytes); console.log('Decrypting message ...'); return decrypt( diff --git a/packages/taco/src/conditions/context/context.ts b/packages/taco/src/conditions/context/context.ts index f4ea81103..7b528f70e 100644 --- a/packages/taco/src/conditions/context/context.ts +++ b/packages/taco/src/conditions/context/context.ts @@ -1,4 +1,4 @@ -import { Conditions as WASMConditions, Context } from '@nucypher/nucypher-core'; +import { Context, Conditions as WASMConditions } from '@nucypher/nucypher-core'; import { fromJSON, toJSON } from '@nucypher/shared'; import { ethers } from 'ethers';