Skip to content

Commit

Permalink
Remove references to supported chainID (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre authored Dec 19, 2024
2 parents 529eee7 + ef55822 commit 6baef32
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 27 deletions.
8 changes: 0 additions & 8 deletions packages/taco/src/conditions/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChainId } from '@nucypher/shared';
import {
USER_ADDRESS_PARAM_DEFAULT,
USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
Expand All @@ -16,13 +15,6 @@ export const CONTEXT_PARAM_FULL_MATCH_REGEXP = new RegExp(

export const CONTEXT_PARAM_PREFIX = ':';

export const SUPPORTED_CHAIN_IDS = [
ChainId.POLYGON,
ChainId.AMOY,
ChainId.SEPOLIA,
ChainId.ETHEREUM_MAINNET,
];

export const USER_ADDRESS_PARAMS = [
USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
// Ordering matters, this should always be last
Expand Down
6 changes: 2 additions & 4 deletions packages/taco/src/conditions/schemas/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { BlockIdentifierSchema, EthAddressSchema } from '@nucypher/shared';
import { z } from 'zod';

import { SUPPORTED_CHAIN_IDS } from '../const';

import createUnionSchema, {
import {
baseConditionSchema,
UserAddressSchema,
} from './common';
Expand All @@ -27,7 +25,7 @@ const BlockOrContextParamSchema = z.union([
// - web3py: https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.get_balance
export const rpcConditionSchema = baseConditionSchema.extend({
conditionType: z.literal(RpcConditionType).default(RpcConditionType),
chain: createUnionSchema(SUPPORTED_CHAIN_IDS),
chain: z.number().int().nonnegative(),
method: z.enum(['eth_getBalance']),
parameters: z.union([
// Spec requires 2 parameters: an address and a block identifier
Expand Down
5 changes: 1 addition & 4 deletions packages/taco/test/conditions/base/condition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ describe('validation', () => {
expect(result.error?.format()).toMatchObject({
chain: {
_errors: [
'Invalid literal value, expected 137',
'Invalid literal value, expected 80002',
'Invalid literal value, expected 11155111',
'Invalid literal value, expected 1',
"Expected number, received string",
],
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/taco/test/conditions/compound-condition.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainId } from '@nucypher/shared';
import { describe, expect, it } from 'vitest';

import { ContractCondition } from '../../src/conditions/base/contract';
Expand All @@ -8,7 +9,6 @@ import {
compoundConditionSchema,
CompoundConditionType,
} from '../../src/conditions/compound-condition';
import { SUPPORTED_CHAIN_IDS } from '../../src/conditions/const';
import {
testContractConditionObj,
testRpcConditionObj,
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('validation', () => {
const multichainCondition: CompoundConditionProps = {
conditionType: CompoundConditionType,
operator: 'and',
operands: SUPPORTED_CHAIN_IDS.map((chain) => ({
operands: [ChainId.ETHEREUM_MAINNET, ChainId.POLYGON, ChainId.SEPOLIA, ChainId.AMOY].map((chain) => ({
...testRpcConditionObj,
chain,
})),
Expand Down
7 changes: 0 additions & 7 deletions packages/taco/test/conditions/conditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { beforeAll, describe, expect, it } from 'vitest';

import { initialize } from '../../src';
import { CompoundCondition } from '../../src/conditions/compound-condition';
import { SUPPORTED_CHAIN_IDS } from '../../src/conditions/const';
import { ConditionContext } from '../../src/conditions/context';

describe('conditions', () => {
Expand Down Expand Up @@ -53,10 +52,4 @@ describe('conditions', () => {
expect(asObj).toBeDefined();
expect(asObj[':time']).toBe(100);
});

it('has supported chains consistent with shared', async () => {
const chainIdsAndNames = Object.values(ChainId);
const chainIds = chainIdsAndNames.filter((id) => typeof id === 'number');
expect(SUPPORTED_CHAIN_IDS).toEqual(chainIds);
});
});
4 changes: 2 additions & 2 deletions packages/taco/test/conditions/sequential.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainId } from '@nucypher/shared';
import { describe, expect, it } from 'vitest';

import { CompoundConditionType } from '../../src/conditions/compound-condition';
import { SUPPORTED_CHAIN_IDS } from '../../src/conditions/const';
import {
ConditionVariableProps,
SequentialCondition,
Expand Down Expand Up @@ -223,7 +223,7 @@ describe('validation', () => {
it('accepts on a valid multichain condition schema', () => {
const multichainCondition: SequentialConditionProps = {
conditionType: SequentialConditionType,
conditionVariables: SUPPORTED_CHAIN_IDS.map((chain) => ({
conditionVariables: [ChainId.AMOY, ChainId.POLYGON, ChainId.ETHEREUM_MAINNET, ChainId.SEPOLIA].map((chain) => ({
varName: `chain_${chain}`,
condition: {
...testRpcConditionObj,
Expand Down

0 comments on commit 6baef32

Please sign in to comment.