-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a341b72
commit 8ec9151
Showing
19 changed files
with
226 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from 'zod'; | ||
|
||
import { ETH_ADDRESS_REGEXP, USER_ADDRESS_PARAM } from '../const'; | ||
|
||
export const returnValueTestSchema = z.object({ | ||
index: z.number().optional(), | ||
comparator: z.enum(['==', '>', '<', '>=', '<=', '!=']), | ||
value: z.unknown(), | ||
}); | ||
|
||
export type ReturnValueTestProps = z.infer<typeof returnValueTestSchema>; | ||
|
||
const EthAddressSchema = z.string().regex(ETH_ADDRESS_REGEXP); | ||
const UserAddressSchema = z.literal(USER_ADDRESS_PARAM); | ||
export const EthAddressOrUserAddressSchema = z.union([ | ||
EthAddressSchema, | ||
UserAddressSchema, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import { ChainId } from '../web3'; | ||
|
||
export const USER_ADDRESS_PARAM = ':userAddress'; | ||
|
||
export const ETH_ADDRESS_REGEXP = new RegExp('^0x[a-fA-F0-9]{40}$'); | ||
|
||
export const SUPPORTED_CHAIN_IDS = [ | ||
ChainId.POLYGON, | ||
ChainId.MUMBAI, | ||
ChainId.GOERLI, | ||
ChainId.MAINNET, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Primitive, z, ZodLiteral } from 'zod'; | ||
|
||
// Source: https://github.com/colinhacks/zod/issues/831#issuecomment-1063481764 | ||
const createUnion = < | ||
T extends Readonly<[Primitive, Primitive, ...Primitive[]]> | ||
>( | ||
values: T | ||
) => { | ||
const zodLiterals = values.map((value) => z.literal(value)) as unknown as [ | ||
ZodLiteral<Primitive>, | ||
ZodLiteral<Primitive>, | ||
...ZodLiteral<Primitive>[] | ||
]; | ||
return z.union(zodLiterals); | ||
}; | ||
|
||
function createUnionSchema<T extends readonly Primitive[]>(values: T) { | ||
if (values.length === 0) { | ||
return z.never(); | ||
} | ||
|
||
if (values.length === 1) { | ||
return z.literal(values[0]); | ||
} | ||
|
||
return createUnion( | ||
values as unknown as Readonly<[Primitive, Primitive, ...Primitive[]]> | ||
); | ||
} | ||
|
||
export default createUnionSchema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
export type ChecksumAddress = string; | ||
export type HexEncodedBytes = string; | ||
export type Base64EncodedBytes = string; | ||
|
||
export enum ChainId { | ||
POLYGON = 137, | ||
MUMBAI = 80001, | ||
GOERLI = 5, | ||
MAINNET = 1, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
8ec9151
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundled size for the package is listed below:
build/main/src/characters: 74.22 KB
build/main/src/kits: 19.53 KB
build/main/src/conditions/context: 42.97 KB
build/main/src/conditions/predefined: 19.53 KB
build/main/src/conditions/base: 54.69 KB
build/main/src/conditions: 175.78 KB
build/main/src/agents: 39.06 KB
build/main/src/sdk/strategy: 35.16 KB
build/main/src/sdk: 46.88 KB
build/main/src/policies: 19.53 KB
build/main/src: 453.13 KB
build/main/types/ethers-contracts/factories: 82.03 KB
build/main/types/ethers-contracts: 152.34 KB
build/main/types: 156.25 KB
build/main: 667.97 KB
build/module/src/characters: 78.13 KB
build/module/src/kits: 19.53 KB
build/module/src/conditions/context: 42.97 KB
build/module/src/conditions/predefined: 19.53 KB
build/module/src/conditions/base: 54.69 KB
build/module/src/conditions: 175.78 KB
build/module/src/agents: 39.06 KB
build/module/src/sdk/strategy: 31.25 KB
build/module/src/sdk: 42.97 KB
build/module/src/policies: 19.53 KB
build/module/src: 449.22 KB
build/module/types/ethers-contracts/factories: 82.03 KB
build/module/types/ethers-contracts: 152.34 KB
build/module/types: 156.25 KB
build/module: 664.06 KB
build: 1.30 MB