-
Notifications
You must be signed in to change notification settings - Fork 14
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
4ebcb0f
commit a57763b
Showing
35 changed files
with
3,448 additions
and
182 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
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,93 @@ | ||
import { | ||
InvalidAddressOrEnsError, | ||
InvalidCidError, | ||
InvalidContractAbiError, | ||
InvalidParameter, | ||
InvalidSubdomainError, | ||
isEnsName, | ||
isIpfsUri, | ||
isSubdomain, | ||
} from "@aragon/sdk-common"; | ||
import { array, mixed, number, object, string } from "yup"; | ||
import { isAddress } from "@ethersproject/address"; | ||
|
||
export const BigintSchema = mixed().test( | ||
"isBigint", | ||
new InvalidParameter("bigint").message, | ||
(value) => typeof value === "bigint", | ||
); | ||
export const AddressOrEnsSchema = string().notRequired().test( | ||
"isAddressOrEns", | ||
new InvalidAddressOrEnsError().message, | ||
(value) => value ? isAddress(value) || isEnsName(value) : true, | ||
); | ||
export const VersionTagSchema = object({ | ||
build: number().moreThan(0).required(), | ||
release: number().moreThan(0).required(), | ||
}); | ||
export const AbiSchema = array().notRequired().test( | ||
"isValidAbi", | ||
new InvalidContractAbiError().message, | ||
// TODO: validate abi | ||
() => true, | ||
); | ||
export const Uint8ArraySchema = mixed().test( | ||
"isUint8Array", | ||
new InvalidParameter("Uint8Array").message, | ||
(value) => value ? value instanceof Uint8Array : true, | ||
); | ||
export const IpfsUriSchema = string().test( | ||
"isIpfsUri", | ||
new InvalidCidError().message, | ||
(value) => value ? isIpfsUri(value) : true, | ||
); | ||
export const SubdomainSchema = string().test( | ||
"isSubdomain", | ||
new InvalidSubdomainError().message, | ||
(value) => value ? isSubdomain(value) : true, | ||
); | ||
|
||
export const PaginationSchema = object({ | ||
skip: number().min(0).notRequired(), | ||
limit: number().min(1).notRequired(), | ||
direction: string().oneOf(["asc", "desc"]).notRequired(), | ||
}); | ||
|
||
export const PrepareUninstallationSchema = object({ | ||
daoAddressOrEns: AddressOrEnsSchema.required(), | ||
pluginAddress: AddressOrEnsSchema.required(), | ||
pluginInstallationIndex: number().notRequired().min(0), | ||
uninstallationParams: array().notRequired(), | ||
uninstallationAbi: AbiSchema.notRequired(), | ||
}); | ||
export const MultiTargetPermissionSchema = object({ | ||
operation: number().required().oneOf([0, 1, 2]), | ||
permissionId: string().required(), | ||
where: AddressOrEnsSchema.required(), | ||
who: AddressOrEnsSchema.required(), | ||
condition: string().notRequired(), | ||
}); | ||
|
||
export const PrepareInstallationSchema = object({ | ||
daoAddressOrEns: AddressOrEnsSchema.required(), | ||
pluginRepo: AddressOrEnsSchema.required(), | ||
version: VersionTagSchema.notRequired(), | ||
installationParams: array().notRequired(), | ||
installationAbi: AbiSchema.notRequired(), | ||
}); | ||
|
||
export const PluginInstallItemSchema = object({ | ||
id: AddressOrEnsSchema.required(), | ||
data: Uint8ArraySchema.required(), | ||
}); | ||
|
||
export const ApplyUninstallationSchema = object({ | ||
pluginAddress: AddressOrEnsSchema.required(), | ||
pluginRepo: AddressOrEnsSchema.required(), | ||
versionTag: VersionTagSchema.required(), | ||
permissions: array(MultiTargetPermissionSchema).required(), | ||
}); | ||
|
||
export const ApplyInstallationSchema = ApplyUninstallationSchema.concat(object({ | ||
helpers: array(AddressOrEnsSchema).required(), | ||
})); |
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.