Skip to content

Commit

Permalink
fix: ConditionContext import error (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Nov 24, 2023
2 parents 59d8877 + 493fbca commit 111897a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/taco-demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand Down
2 changes: 1 addition & 1 deletion demos/taco-nft-demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand Down
1 change: 1 addition & 0 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/taco/src/conditions/base/shared.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/taco/src/conditions/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions packages/taco/src/conditions/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ 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';

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`;
Expand Down

0 comments on commit 111897a

Please sign in to comment.