diff --git a/examples/candid-react/.gitignore b/examples/candid-react/.gitignore deleted file mode 100644 index 4d29575de8..0000000000 --- a/examples/candid-react/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/examples/candid-react/README.md b/examples/candid-react/README.md deleted file mode 100644 index b87cb00449..0000000000 --- a/examples/candid-react/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Getting Started with Create React App - -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/examples/candid-react/package.json b/examples/candid-react/package.json deleted file mode 100644 index 9ceee4f378..0000000000 --- a/examples/candid-react/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "candid-react", - "version": "0.1.0", - "private": true, - "dependencies": { - "@ic-reactor/react": "^*", - "@types/node": "^16.18.68", - "@types/react": "^18.2.45", - "@types/react-dom": "^18.2.18", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-hook-form": "^7.49.2", - "react-scripts": "5.0.1", - "typescript": "^4.9.5" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "devDependencies": { - "clsx": "^2.0.0", - "tailwind-merge": "^2.2.0", - "tailwindcss": "^3.4.0" - } -} diff --git a/examples/candid-react/public/favicon.ico b/examples/candid-react/public/favicon.ico deleted file mode 100644 index a11777cc47..0000000000 Binary files a/examples/candid-react/public/favicon.ico and /dev/null differ diff --git a/examples/candid-react/public/index.html b/examples/candid-react/public/index.html deleted file mode 100644 index 358b3a1e12..0000000000 --- a/examples/candid-react/public/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - Candid React Demo - - - - - -
- - - - \ No newline at end of file diff --git a/examples/candid-react/public/logo192.png b/examples/candid-react/public/logo192.png deleted file mode 100644 index fc44b0a379..0000000000 Binary files a/examples/candid-react/public/logo192.png and /dev/null differ diff --git a/examples/candid-react/public/logo512.png b/examples/candid-react/public/logo512.png deleted file mode 100644 index a4e47a6545..0000000000 Binary files a/examples/candid-react/public/logo512.png and /dev/null differ diff --git a/examples/candid-react/public/manifest.json b/examples/candid-react/public/manifest.json deleted file mode 100644 index 080d6c77ac..0000000000 --- a/examples/candid-react/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/candid-react/public/robots.txt b/examples/candid-react/public/robots.txt deleted file mode 100644 index e9e57dc4d4..0000000000 --- a/examples/candid-react/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/examples/candid-react/src/App.tsx b/examples/candid-react/src/App.tsx deleted file mode 100644 index 7fb641afe2..0000000000 --- a/examples/candid-react/src/App.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { ActorProvider, AgentProvider } from "@ic-reactor/react" -import DynamicCandid from "./components/DynamicCandid" -import { useRef, useState, useEffect } from "react" -import { Principal } from "@dfinity/principal" - -interface AppProps {} - -const App: React.FC = () => { - const inputRef = useRef(null) - const [canisterId, setCanisterId] = useState() - - useEffect(() => { - const dynamicCanisterId = localStorage.getItem("dynamicCanisterId") - if (dynamicCanisterId) { - setCanisterId(dynamicCanisterId) - } - }, []) - - const onSubmit = (event: React.FormEvent) => { - event.preventDefault() - try { - const principal = Principal.fromText(inputRef.current?.value || "") - - if (!principal) { - throw new Error("Invalid canister id") - } - - setCanisterId(principal.toText()) - localStorage.setItem("dynamicCanisterId", principal.toText()) - } catch (e) { - console.error(e) - } - } - - return ( - -
-

Dynamic Candid

-
- - -
- {canisterId && ( - - - - )} -
-
- ) -} - -export default App diff --git a/examples/candid-react/src/components/Button.tsx b/examples/candid-react/src/components/Button.tsx deleted file mode 100644 index 33d78e29dd..0000000000 --- a/examples/candid-react/src/components/Button.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from "react" -import { cn } from "../utils" - -interface ButtonProps { - onClick?: () => void - type?: "button" | "submit" | "reset" - className?: string - children?: React.ReactNode -} - -const Button: React.FC = ({ - onClick, - children, - type = "button", - className = "", -}) => { - return ( - - ) -} - -export default Button diff --git a/examples/candid-react/src/components/Candid/Inputs/Boolean.tsx b/examples/candid-react/src/components/Candid/Inputs/Boolean.tsx deleted file mode 100644 index b831e12ab4..0000000000 --- a/examples/candid-react/src/components/Candid/Inputs/Boolean.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Controller } from "react-hook-form" -import { RouteProps } from "../Routes" - -export interface BooleanProps extends RouteProps<"boolean"> {} - -const Boolean: React.FC = ({ - extractedField, - shouldUnregister, - registerName, -}) => { - return ( -
-
- -
- ( - - )} - /> -
- ) -} - -export default Boolean diff --git a/examples/candid-react/src/components/Candid/Inputs/Null.tsx b/examples/candid-react/src/components/Candid/Inputs/Null.tsx deleted file mode 100644 index 03c2b2ff12..0000000000 --- a/examples/candid-react/src/components/Candid/Inputs/Null.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Controller } from "react-hook-form" -import { RouteProps } from "../Routes" - -export interface NullProps extends RouteProps<"null"> {} - -const Null: React.FC = ({ registerName, shouldUnregister }) => { - return ( - null as never} - /> - ) -} - -export default Null diff --git a/examples/candid-react/src/components/Candid/Inputs/Number.tsx b/examples/candid-react/src/components/Candid/Inputs/Number.tsx deleted file mode 100644 index e0c99468b2..0000000000 --- a/examples/candid-react/src/components/Candid/Inputs/Number.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useFormContext } from "react-hook-form" -import { RouteProps } from "../Routes" -import { cn } from "../../../utils" - -export interface NumberProps extends RouteProps<"number"> {} - -const Number: React.FC = ({ - registerName, - errors, - extractedField, - shouldUnregister, -}) => { - const { register, resetField, trigger } = useFormContext() - - const resetHandler = () => { - resetField(registerName as never) - trigger(registerName as never, { shouldFocus: true }) - } - - const errorMessage = errors?.message?.toString() - - return ( -
-
- -
- {errorMessage && ( - ( {errorMessage} ) - )} -
- -
- × -
-
-
- ) -} - -export default Number diff --git a/examples/candid-react/src/components/Candid/Inputs/Principal.tsx b/examples/candid-react/src/components/Candid/Inputs/Principal.tsx deleted file mode 100644 index 1503995cce..0000000000 --- a/examples/candid-react/src/components/Candid/Inputs/Principal.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import { cn } from "../../../utils" -import { Principal as PrincipalId } from "@dfinity/principal" -import { useFormContext } from "react-hook-form" -import { RouteProps } from "../Routes" -import { Controller } from "react-hook-form" -import { useCallback } from "react" - -export interface PrincipalProps extends RouteProps<"principal"> {} - -const Principal: React.FC = ({ - registerName, - errors, - extractedField, - shouldUnregister, -}) => { - const { setValue, resetField, setError } = useFormContext() - - const validate = useCallback( - (x: any) => { - if (x._isPrincipal === true) { - return true - } - try { - if (x.length < 7) { - throw new Error("Principal is too short") - } - const principal = PrincipalId.fromText(x) - - let validate = extractedField.validate(principal) - - if (typeof validate === "string") { - throw new Error(validate) - } - return true - } catch (error) { - return (error as any).message - } - }, - [extractedField] - ) - - const blurHandler = useCallback( - (e: React.ChangeEvent) => { - if (e.target.value === "") { - setValue(registerName, "" as never) - return - } - const inputValue = e.target.value - resetField(registerName, { - defaultValue: inputValue as never, - }) - const isValid = validate(inputValue) - - if (isValid === true) { - const principal = PrincipalId.fromText(inputValue) - - setValue(registerName, principal as never) - } else { - setError(registerName, { - type: "manual", - message: isValid, - }) - } - }, - [registerName, resetField, setError, setValue, validate] - ) - - const errorMessage = errors?.message?.toString() - - return ( -
-
- -
- {errorMessage && ( - ( {errorMessage} ) - )} -
- ( - - )} - /> -
setValue(registerName, "" as never)} - > - × -
-
-
- ) -} - -export default Principal diff --git a/examples/candid-react/src/components/Candid/Inputs/Text.tsx b/examples/candid-react/src/components/Candid/Inputs/Text.tsx deleted file mode 100644 index 22e7a0ff96..0000000000 --- a/examples/candid-react/src/components/Candid/Inputs/Text.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { cn } from "../../../utils" -import { Controller, useFormContext } from "react-hook-form" -import { RouteProps } from "../Routes" - -export interface TextProps extends RouteProps {} - -const Text: React.FC = ({ - registerName, - errors, - extractedField, - shouldUnregister, -}) => { - const { resetField, trigger } = useFormContext() - - const resetHandler = () => { - resetField(registerName as never) - trigger(registerName as never, { shouldFocus: true }) - } - - const errorMessage = errors?.message?.toString() - - return ( -
-
- -
- {errorMessage && ( - ( {errorMessage} ) - )} -
- ( - - )} - /> -
- × -
-
-
- ) -} - -export default Text diff --git a/examples/candid-react/src/components/Candid/MethodCall.tsx b/examples/candid-react/src/components/Candid/MethodCall.tsx deleted file mode 100644 index 83634808a8..0000000000 --- a/examples/candid-react/src/components/Candid/MethodCall.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { FunctionName, FunctionType } from "@ic-reactor/core/dist/types" -import MethodForm from "./MethodForm" -import { useMethodCall } from "@ic-reactor/react" - -export interface FormFieldsProps { - functionName: FunctionName - type: FunctionType -} - -const MethodCall: React.FC = ({ functionName }) => { - const { call, data, loading, error, visit } = useMethodCall({ - functionName, - }) - - return ( -
- -
-
- - {loading ? "Loading" : error ? "Error" : "Results"} - -

- {loading - ? "Calling..." - : error - ? error.message - : JSON.stringify( - data, - (_, value) => - typeof value === "bigint" ? value.toString() : value, - 2 - )} -

-
-
-
- ) -} - -export default MethodCall diff --git a/examples/candid-react/src/components/Candid/MethodForm.tsx b/examples/candid-react/src/components/Candid/MethodForm.tsx deleted file mode 100644 index ecc9977be5..0000000000 --- a/examples/candid-react/src/components/Candid/MethodForm.tsx +++ /dev/null @@ -1,149 +0,0 @@ -import { useCallback, useState } from "react" -import Button from "../Button" -import Route from "./Routes" -import { FormProvider, useForm } from "react-hook-form" -import { - MethodFields, - ServiceDefaultValues, - extractAndSortArgs, -} from "@ic-reactor/core" - -interface FormProps extends MethodFields { - callHandler: (args: never) => Promise -} - -const MethodForm: React.FC = ({ - functionName, - defaultValues, - fields, - callHandler, -}) => { - const methods = useForm({ - mode: "onChange", - defaultValues, - }) - - const [argState, setArgState] = useState(null) - const [argErrorState, setArgErrorState] = useState(null) - - const onVerifyArgs = useCallback( - (data: ServiceDefaultValues) => { - const argsObject = data[functionName] - console.log("argsObject", argsObject) - - setArgState(null) - setArgErrorState(null) - - const args = extractAndSortArgs(argsObject) - console.log("args", args) - - let errorMessages = "" - const isInvalid = args.some((arg, i) => { - const validateArg = fields[i]?.validate(arg) - if (typeof validateArg === "string") { - errorMessages = validateArg - return false - } - return true - }) - - if (isInvalid === true) { - setArgState(args) - return args - } else { - setArgErrorState(errorMessages) - } - }, - [fields, functionName] - ) - - const onSubmitCall = useCallback( - async (data: ServiceDefaultValues) => { - const argsObject = data[functionName] - console.log("argsObject", argsObject) - - setArgState(null) - setArgErrorState(null) - - const args = extractAndSortArgs(argsObject) - console.log("args", args) - - setArgState(args) - - try { - const result = await callHandler(args as never) - console.log("result", result) - } catch (error) { - console.log("error", error) - } - }, - [callHandler, functionName] - ) - - const resetHandler = useCallback(() => { - setArgErrorState(null) - methods.reset(defaultValues) - setArgState(null) - }, [methods, defaultValues]) - - return ( - -
-
- - -
- {fields.map((field, index) => ( - - ))} - {argState && ( -
- Arguments - - ({" "} - {argState - .map((arg: any) => JSON.stringify(arg, null, 2)) - .join(", ")}{" "} - ) - -
- )} - {argErrorState && ( -
- Arguments Error - -
{argErrorState}
-
-
- )} -
- - -
- -
- ) -} - -export default MethodForm diff --git a/examples/candid-react/src/components/Candid/Routes/Optional.tsx b/examples/candid-react/src/components/Candid/Routes/Optional.tsx deleted file mode 100644 index ef1882064e..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Optional.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useFieldArray } from "react-hook-form" -import Route, { RouteProps } from "." -import { cn } from "../../../utils" - -export interface OptionalProps extends RouteProps<"optional"> {} - -const Optional: React.FC = ({ - extractedField, - registerName, - errors, - shouldUnregister, -}) => { - const { fields, insert, remove } = useFieldArray({ - name: registerName as never, - shouldUnregister, - }) - - return ( -
-
-
- -
-
- -
-
- {fields.map((field, index) => ( - - ))} -
- ) -} -export default Optional diff --git a/examples/candid-react/src/components/Candid/Routes/Record.tsx b/examples/candid-react/src/components/Candid/Routes/Record.tsx deleted file mode 100644 index 2c72f9a5bc..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Record.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import Route, { RouteProps } from "." - -export interface RecordProps extends RouteProps<"record"> {} - -const Record: React.FC = ({ - extractedField, - errors, - registerName, - shouldUnregister, -}) => { - return ( -
-
- -
-
- {extractedField.fields.map((field, index) => ( - - ))} -
-
- ) -} - -export default Record diff --git a/examples/candid-react/src/components/Candid/Routes/Recursive.tsx b/examples/candid-react/src/components/Candid/Routes/Recursive.tsx deleted file mode 100644 index 28b39e8dab..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Recursive.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { useMemo } from "react" -import Route, { RouteProps } from "." - -export interface RecursiveProps extends RouteProps<"recursive"> {} - -const Recursive: React.FC = ({ - extractedField: { extract }, - registerName, - errors, - ...rest -}) => { - const field = useMemo(() => extract(), [extract]) - - return field ? ( - - ) : ( -
Loading...
- ) -} - -export default Recursive diff --git a/examples/candid-react/src/components/Candid/Routes/Tuple.tsx b/examples/candid-react/src/components/Candid/Routes/Tuple.tsx deleted file mode 100644 index 08a21fa65a..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Tuple.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import Route, { RouteProps } from "." - -export interface TupleProps extends RouteProps<"tuple"> {} - -const Tuple: React.FC = ({ - extractedField, - registerName, - errors, - shouldUnregister, -}) => { - return ( -
-
- -
-
- {extractedField.fields.map((field, index) => ( - - ))} -
-
- ) -} - -export default Tuple diff --git a/examples/candid-react/src/components/Candid/Routes/Variant.tsx b/examples/candid-react/src/components/Candid/Routes/Variant.tsx deleted file mode 100644 index a4857f52c2..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Variant.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import React, { useId } from "react" -import { Controller, useWatch } from "react-hook-form" -import Route, { RouteProps } from "." - -export interface VariantProps extends RouteProps<"variant"> {} - -const Variant: React.FC = ({ - extractedField, - registerName, - errors, -}) => { - const selectRegisterName = useId() - - const selectedOption = useWatch({ - name: selectRegisterName, - defaultValue: extractedField.defaultValue, - }) - - return ( -
- ( - - )} - /> -
- {extractedField.fields.map( - (field, index) => - selectedOption === field.label && ( - - ) - )} -
-
- ) -} - -export default Variant diff --git a/examples/candid-react/src/components/Candid/Routes/Vector.tsx b/examples/candid-react/src/components/Candid/Routes/Vector.tsx deleted file mode 100644 index f6ad309bad..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/Vector.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React from "react" -import { useFieldArray } from "react-hook-form" -import Button from "../../Button" -import Route, { RouteProps } from "." - -export interface VectorProps extends RouteProps<"vector"> {} - -const Vector: React.FC = ({ - extractedField, - errors, - registerName, - shouldUnregister, -}) => { - const { fields, append, swap, remove } = useFieldArray({ - name: registerName as never, - shouldUnregister, - }) - - return ( -
-
-
- -
- -
- {fields.length > 0 &&
} - {fields.map((item, index) => ( -
-
- -
- {index + 1} -
- -
-
- -
-
remove(index)} - > - × -
-
- ))} -
- ) -} - -export default Vector diff --git a/examples/candid-react/src/components/Candid/Routes/index.tsx b/examples/candid-react/src/components/Candid/Routes/index.tsx deleted file mode 100644 index cc0ca74498..0000000000 --- a/examples/candid-react/src/components/Candid/Routes/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from "react" -import Tuple, { TupleProps } from "./Tuple" -import Vector, { VectorProps } from "./Vector" -import Record, { RecordProps } from "./Record" -import Variant, { VariantProps } from "./Variant" -import Optional, { OptionalProps } from "./Optional" -import Recursive, { RecursiveProps } from "./Recursive" -import { FieldError, FieldErrorsImpl, Merge } from "react-hook-form" -import { DynamicFieldType, FieldType } from "@ic-reactor/react" - -import Principal, { PrincipalProps } from "../Inputs/Principal" -import Boolean, { BooleanProps } from "../Inputs/Boolean" -import Number, { NumberProps } from "../Inputs/Number" -import NullINput, { NullProps } from "../Inputs/Null" -import Text, { TextProps } from "../Inputs/Text" - -export interface RouteProps { - extractedField: DynamicFieldType - registerName: string - shouldUnregister?: boolean - errors: FieldError | Merge> | undefined -} - -const Route: React.FC = (props) => { - switch (props.extractedField.type) { - case "vector": - return - case "optional": - return - case "record": - return - case "tuple": - return - case "variant": - return - case "recursive": - return - case "principal": - return - case "null": - return - case "boolean": - return - case "number": - return - default: - return - } -} - -export default Route diff --git a/examples/candid-react/src/components/CandidViewer.tsx b/examples/candid-react/src/components/CandidViewer.tsx deleted file mode 100644 index 3e85384962..0000000000 --- a/examples/candid-react/src/components/CandidViewer.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { AgentProvider, extractActorHooks, useActor } from "@ic-reactor/react" -import { createContext } from "react" -import type { ActorHooks } from "@ic-reactor/react/dist/types" -import type { Ledger } from "../declarations/ledger" - -const ActorContext = createContext | null>(null) - -export const { useQueryCall, useUpdateCall } = extractActorHooks(ActorContext) - -const Reactor = () => { - const { hooks, fetching, fetchError } = useActor({ - canisterId: "ryjl3-tyaaa-aaaaa-aaaba-cai", // ICP Ledger canister - }) - - return ( - -

IC Canister Interaction

- {fetching &&

Loading Candid interface...

} - {fetchError &&

Error: {fetchError}

} - {hooks && } -
- ) -} - -const CanisterName = () => { - const { data } = useQueryCall({ - functionName: "name", - }) - - return ( -
-

Query Call

-

Result: {JSON.stringify(data)}

-
- ) -} - -const App = () => ( - - - -) - -export default App diff --git a/examples/candid-react/src/components/DynamicCandid.tsx b/examples/candid-react/src/components/DynamicCandid.tsx deleted file mode 100644 index 64514fc661..0000000000 --- a/examples/candid-react/src/components/DynamicCandid.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useMethodFields } from "@ic-reactor/react" -import MethodCall from "./Candid/MethodCall" -interface DynamicCandidProps {} - -const DynamicCandid: React.FC = () => { - const methodDetails = useMethodFields() - - return ( -
- {methodDetails.map(({ functionName, functionType }) => ( - - ))} -
- ) -} - -export default DynamicCandid diff --git a/examples/candid-react/src/declarations/candid/candid.did b/examples/candid-react/src/declarations/candid/candid.did deleted file mode 100644 index df32d487d3..0000000000 --- a/examples/candid-react/src/declarations/candid/candid.did +++ /dev/null @@ -1,215 +0,0 @@ -type AppBug = record { - logs : vec text; - name : text; - canister_id : principal; - description : text; - version : text; -}; -type AppSystemError = variant { - InvalidSigner; - UserAlreadyExists; - WasmGetError : text; - CreateCanisterError : text; - UpdateCanisterControllersError : text; - HelperError : HelperError; - CanisterIdNotFound; - InvalidWalletCanister; - ValidateSignerError : text; - AppIdMismatch; - EncodeError : text; - InstallArgError : text; - AppAlreadyExists; - OwnerMismatch : record { owner : text; user : text }; - ReleaseNameNotFound; - InvalidAccountIdentifier; - AppNotFound; - WalletCanisterAlreadyInstalled; - WalletCanisterRateError : text; - WalletCanisterAlreadyExists : text; - AppIsDeprecated; - RateLimitExceeded; - UpdateControllersError : text; - WasmHashError : text; - ReleaseNotFound; - WasmNotFound; - WasmInstallError : text; - VersionError : text; - NoCanisterAvailable; - WalletCanisterDoesNotExist : text; - InstallCodeError : text; - WalletCanisterNotFound; - CanisterStatusError : text; - WasmAlreadyLoaded; - InvalidReleaseName : text; - ReleaseAlreadyExists; -}; -type AppView = record { - id : text; - updated_at : nat64; - metadata : vec record { text; Value }; - name : text; - description : text; - created_at : nat64; - created_by : text; - latest_release : opt ReleaseView; - install_count : nat64; -}; -type CanisterChange = record { - timestamp_nanos : nat64; - canister_version : nat64; - origin : CanisterChangeOrigin; - details : CanisterChangeDetails; -}; -type CanisterChangeDetails = variant { - creation : CreationRecord; - code_deployment : CodeDeploymentRecord; - controllers_change : CreationRecord; - code_uninstall; -}; -type CanisterChangeOrigin = variant { - from_user : FromUserRecord; - from_canister : FromCanisterRecord; -}; -type CanisterInfoResponse = record { - controllers : vec principal; - module_hash : opt vec nat8; - recent_changes : vec CanisterChange; - total_num_changes : nat64; -}; -type CanisterInstallMode = variant { reinstall; upgrade; install }; -type CanisterStatusResponse = record { - status : CanisterStatusType; - memory_size : nat; - cycles : nat; - settings : DefiniteCanisterSettings; - query_stats : QueryStats; - idle_cycles_burned_per_day : nat; - module_hash : opt vec nat8; -}; -type CanisterStatusType = variant { stopped; stopping; running }; -type CodeDeploymentRecord = record { - mode : CanisterInstallMode; - module_hash : vec nat8; -}; -type CreateAppArgs = record { - metadata : vec record { text; Value }; - name : text; - description : text; -}; -type CreateReleaseArgs = record { - id : text; - features : text; - size : nat64; - version : text; - wasm_hash : vec nat8; -}; -type CreationRecord = record { controllers : vec principal }; -type DefiniteCanisterSettings = record { - freezing_threshold : nat; - controllers : vec principal; - memory_allocation : nat; - compute_allocation : nat; -}; -type FromCanisterRecord = record { - canister_version : opt nat64; - canister_id : principal; -}; -type FromUserRecord = record { user_id : principal }; -type HelperError = variant { - CreateCanisterError : text; - UpdateCanisterControllersError : text; - ValidateSignerError : text; - HexStringToVecError : text; - InvalidHexString; - InvalidSubaccount : text; - EncodeError : text; - InvalidAccountIdentifier; - RateLimitExceeded; - WasmHashError : text; - HexStringToU64Error : text; - HexStringToNatError : text; - VersionError : text; - SignerNotAvailable; - HexStringToU128Error : text; - InstallCodeError : text; - CanisterStatusError : text; - InvalidReleaseName : text; -}; -type LoadRelease = record { total : nat64; chunks : nat64 }; -type QueryStats = record { - response_payload_bytes_total : nat; - num_instructions_total : nat; - num_calls_total : nat; - request_payload_bytes_total : nat; -}; -type ReleaseView = record { - features : text; - date : nat64; - name : text; - size : nat64; - version : text; - deprecated : bool; -}; -type Result = variant { Ok : UserView; Err : text }; -type Result_1 = variant { Ok : ReleaseView; Err : AppSystemError }; -type SystemCanisterStatus = record { - user_status : nat64; - status_at : nat64; - version : text; - canister_status : CanisterStatusResponse; -}; -type UserCanisterStatus = record { - version : text; - canister_status : CanisterStatusResponse; -}; -type UserStatus = variant { - Unregistered; - SingleCanister : principal; - MultipleCanister : vec principal; - Registered; -}; -type UserView = record { - updated_at : nat64; - metadata : vec record { text; Value }; - created_at : nat64; - canisters : vec principal; -}; -type Value = variant { - Int : int; - Map : vec record { text; Value }; - Nat : nat; - Nat64 : nat64; - Blob : vec nat8; - Text : text; - Array : vec Value; -}; -service : () -> { - add_release : (text, CreateReleaseArgs) -> (); - add_user_app : (principal, text) -> (); - clear_bugs : (principal) -> (); - create_app : (CreateAppArgs) -> (AppView); - create_app_canister : (text) -> (Result); - deprecate_release : (text, vec nat8) -> (ReleaseView); - get_app_version : (principal) -> (text) composite_query; - get_bugs : (principal) -> (vec AppBug) query; - get_canister_info : (principal) -> (CanisterInfoResponse); - get_canisters : () -> (vec principal) query; - get_create_canister_app_cycle : () -> (nat) query; - get_latest_release : (text) -> (Result_1) query; - get_release : (vec nat8) -> (ReleaseView) query; - get_states : () -> (UserView) query; - get_user_app_status : (principal) -> (UserCanisterStatus); - get_user_ids : () -> (vec vec nat8) query; - get_user_states : () -> (vec UserView) query; - get_user_status : () -> (UserStatus) query; - install_app : (principal, text) -> (Result); - load_wasm : (vec nat8, vec nat8) -> (LoadRelease); - releases : (text) -> (vec ReleaseView) query; - remove_release : (vec nat8) -> (); - remove_user : (principal) -> (); - remove_user_app : (principal) -> (); - report_bug : (AppBug) -> (); - status : () -> (SystemCanisterStatus); - update_app : (text, CreateAppArgs) -> (AppView); - version : () -> (text) query; -} diff --git a/examples/candid-react/src/declarations/candid/candid.did.d.ts b/examples/candid-react/src/declarations/candid/candid.did.d.ts deleted file mode 100644 index fa627865c1..0000000000 --- a/examples/candid-react/src/declarations/candid/candid.did.d.ts +++ /dev/null @@ -1,228 +0,0 @@ -import type { ActorMethod } from '@dfinity/agent'; -import type { Principal } from '@dfinity/principal'; - -export interface AppBug { - logs: Array; - name: string; - canister_id: Principal; - description: string; - version: string; -} -export type AppSystemError = - | { InvalidSigner: null } - | { UserAlreadyExists: null } - | { WasmGetError: string } - | { CreateCanisterError: string } - | { UpdateCanisterControllersError: string } - | { HelperError: HelperError } - | { CanisterIdNotFound: null } - | { InvalidWalletCanister: null } - | { ValidateSignerError: string } - | { AppIdMismatch: null } - | { EncodeError: string } - | { InstallArgError: string } - | { AppAlreadyExists: null } - | { OwnerMismatch: { owner: string; user: string } } - | { ReleaseNameNotFound: null } - | { InvalidAccountIdentifier: null } - | { AppNotFound: null } - | { WalletCanisterAlreadyInstalled: null } - | { WalletCanisterRateError: string } - | { WalletCanisterAlreadyExists: string } - | { AppIsDeprecated: null } - | { RateLimitExceeded: null } - | { UpdateControllersError: string } - | { WasmHashError: string } - | { ReleaseNotFound: null } - | { WasmNotFound: null } - | { WasmInstallError: string } - | { VersionError: string } - | { NoCanisterAvailable: null } - | { WalletCanisterDoesNotExist: string } - | { InstallCodeError: string } - | { WalletCanisterNotFound: null } - | { CanisterStatusError: string } - | { WasmAlreadyLoaded: null } - | { InvalidReleaseName: string } - | { ReleaseAlreadyExists: null }; -export interface AppView { - id: string; - updated_at: bigint; - metadata: Array<[string, Value]>; - name: string; - description: string; - created_at: bigint; - created_by: string; - latest_release: [] | [ReleaseView]; - install_count: bigint; -} -export interface CanisterChange { - timestamp_nanos: bigint; - canister_version: bigint; - origin: CanisterChangeOrigin; - details: CanisterChangeDetails; -} -export type CanisterChangeDetails = - | { creation: CreationRecord } - | { code_deployment: CodeDeploymentRecord } - | { controllers_change: CreationRecord } - | { code_uninstall: null }; -export type CanisterChangeOrigin = - | { from_user: FromUserRecord } - | { from_canister: FromCanisterRecord }; -export interface CanisterInfoResponse { - controllers: Array; - module_hash: [] | [Uint8Array | number[]]; - recent_changes: Array; - total_num_changes: bigint; -} -export type CanisterInstallMode = - | { reinstall: null } - | { upgrade: null } - | { install: null }; -export interface CanisterStatusResponse { - status: CanisterStatusType; - memory_size: bigint; - cycles: bigint; - settings: DefiniteCanisterSettings; - query_stats: QueryStats; - idle_cycles_burned_per_day: bigint; - module_hash: [] | [Uint8Array | number[]]; -} -export type CanisterStatusType = - | { stopped: null } - | { stopping: null } - | { running: null }; -export interface CodeDeploymentRecord { - mode: CanisterInstallMode; - module_hash: Uint8Array | number[]; -} -export interface CreateAppArgs { - metadata: Array<[string, Value]>; - name: string; - description: string; -} -export interface CreateReleaseArgs { - id: string; - features: string; - size: bigint; - version: string; - wasm_hash: Uint8Array | number[]; -} -export interface CreationRecord { - controllers: Array; -} -export interface DefiniteCanisterSettings { - freezing_threshold: bigint; - controllers: Array; - memory_allocation: bigint; - compute_allocation: bigint; -} -export interface FromCanisterRecord { - canister_version: [] | [bigint]; - canister_id: Principal; -} -export interface FromUserRecord { - user_id: Principal; -} -export type HelperError = - | { CreateCanisterError: string } - | { UpdateCanisterControllersError: string } - | { ValidateSignerError: string } - | { HexStringToVecError: string } - | { InvalidHexString: null } - | { InvalidSubaccount: string } - | { EncodeError: string } - | { InvalidAccountIdentifier: null } - | { RateLimitExceeded: null } - | { WasmHashError: string } - | { HexStringToU64Error: string } - | { HexStringToNatError: string } - | { VersionError: string } - | { SignerNotAvailable: null } - | { HexStringToU128Error: string } - | { InstallCodeError: string } - | { CanisterStatusError: string } - | { InvalidReleaseName: string }; -export interface LoadRelease { - total: bigint; - chunks: bigint; -} -export interface QueryStats { - response_payload_bytes_total: bigint; - num_instructions_total: bigint; - num_calls_total: bigint; - request_payload_bytes_total: bigint; -} -export interface ReleaseView { - features: string; - date: bigint; - name: string; - size: bigint; - version: string; - deprecated: boolean; -} -export type Result = { Ok: UserView } | { Err: string }; -export type Result_1 = { Ok: ReleaseView } | { Err: AppSystemError }; -export interface SystemCanisterStatus { - user_status: bigint; - status_at: bigint; - version: string; - canister_status: CanisterStatusResponse; -} -export interface UserCanisterStatus { - version: string; - canister_status: CanisterStatusResponse; -} -export type UserStatus = - | { Unregistered: null } - | { SingleCanister: Principal } - | { MultipleCanister: Array } - | { Registered: null }; -export interface UserView { - updated_at: bigint; - metadata: Array<[string, Value]>; - created_at: bigint; - canisters: Array; -} -export type Value = - | { Int: bigint } - | { Map: Array<[string, Value]> } - | { Nat: bigint } - | { Nat64: bigint } - | { Blob: Uint8Array | number[] } - | { Text: string } - | { Array: Array }; -export interface _SERVICE { - add_release: ActorMethod<[string, CreateReleaseArgs], undefined>; - add_user_app: ActorMethod<[Principal, string], undefined>; - clear_bugs: ActorMethod<[Principal], undefined>; - create_app: ActorMethod<[CreateAppArgs], AppView>; - create_app_canister: ActorMethod<[string], Result>; - deprecate_release: ActorMethod<[string, Uint8Array | number[]], ReleaseView>; - get_app_version: ActorMethod<[Principal], string>; - get_bugs: ActorMethod<[Principal], Array>; - get_canister_info: ActorMethod<[Principal], CanisterInfoResponse>; - get_canisters: ActorMethod<[], Array>; - get_create_canister_app_cycle: ActorMethod<[], bigint>; - get_latest_release: ActorMethod<[string], Result_1>; - get_release: ActorMethod<[Uint8Array | number[]], ReleaseView>; - get_states: ActorMethod<[], UserView>; - get_user_app_status: ActorMethod<[Principal], UserCanisterStatus>; - get_user_ids: ActorMethod<[], Array>; - get_user_states: ActorMethod<[], Array>; - get_user_status: ActorMethod<[], UserStatus>; - install_app: ActorMethod<[Principal, string], Result>; - load_wasm: ActorMethod< - [Uint8Array | number[], Uint8Array | number[]], - LoadRelease - >; - releases: ActorMethod<[string], Array>; - remove_release: ActorMethod<[Uint8Array | number[]], undefined>; - remove_user: ActorMethod<[Principal], undefined>; - remove_user_app: ActorMethod<[Principal], undefined>; - report_bug: ActorMethod<[AppBug], undefined>; - status: ActorMethod<[], SystemCanisterStatus>; - update_app: ActorMethod<[string, CreateAppArgs], AppView>; - version: ActorMethod<[], string>; -} diff --git a/examples/candid-react/src/declarations/candid/candid.did.js b/examples/candid-react/src/declarations/candid/candid.did.js deleted file mode 100644 index e19cfce2c0..0000000000 --- a/examples/candid-react/src/declarations/candid/candid.did.js +++ /dev/null @@ -1,167 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const Enum = IDL.Variant({ A: IDL.Null, B: IDL.Null, C: IDL.Null }) - const Value = IDL.Rec() - const Variant = IDL.Variant({ - Int: IDL.Int, - Map: IDL.Vec(IDL.Tuple(IDL.Text, Value)), - Nat: IDL.Nat, - Nat8: IDL.Opt(IDL.Nat8), - Nat64: IDL.Nat64, - Blob: IDL.Vec(IDL.Nat8), - Text: IDL.Text, - Array: IDL.Vec(Value), - }) - Value.fill(Variant) - const RecursiveRecord = IDL.Record({ - metadata: IDL.Vec(IDL.Tuple(IDL.Text, Value)), - name: IDL.Text, - description: IDL.Text, - }) - const SimpleRec = IDL.Rec() - SimpleRec.fill( - IDL.Variant({ A: IDL.Text, B: SimpleRec, C: IDL.Vec(SimpleRec) }) - ) - const ReleaseView = IDL.Record({ - features: IDL.Text, - date: IDL.Nat64, - name: IDL.Text, - size: IDL.Nat64, - version: IDL.Text, - deprecated: IDL.Bool, - }) - const AppView = IDL.Record({ - id: IDL.Text, - updated_at: IDL.Nat64, - metadata: IDL.Vec(IDL.Tuple(IDL.Text, Value)), - name: IDL.Text, - description: IDL.Text, - created_at: IDL.Nat64, - created_by: IDL.Text, - latest_release: IDL.Opt(ReleaseView), - install_count: IDL.Nat64, - }) - const AppArgs = IDL.Record({ - optional: IDL.Opt(ReleaseView), - metadata: IDL.Tuple(IDL.Text, IDL.Text), - name: IDL.Text, - description: IDL.Text, - }) - // Define some basic types - const BasicTypes = IDL.Record({ - IntVal: IDL.Int, - NatVal: IDL.Nat, - TextVal: IDL.Text, - BoolVal: IDL.Bool, - FloatVal: IDL.Float64, - PrincipalVal: IDL.Principal, - }) - - // Define a variant type (similar to an enum) - const Status = IDL.Variant({ - ok: IDL.Null, - err: IDL.Text, - }) - - // Define a complex nested record - const ComplexRecord = IDL.Record({ - basic: BasicTypes, - nestedRecord: IDL.Record({ - field1: IDL.Nat16, - field2: IDL.Text, - }), - optionalField: IDL.Opt(IDL.Bool), - }) - - return IDL.Service({ - principal: IDL.Func([IDL.Principal], [IDL.Text], ["query"]), - opt_principal: IDL.Func([IDL.Opt(IDL.Principal)], [IDL.Text], ["query"]), - vec_principal: IDL.Func([IDL.Vec(IDL.Principal)], [IDL.Text], ["query"]), - number: IDL.Func([IDL.Nat8], [IDL.Text], ["query"]), - number_and_text: IDL.Func([IDL.Nat8, IDL.Text], [IDL.Text], ["query"]), - name: IDL.Func([IDL.Text], [IDL.Text], ["query"]), - opt_text: IDL.Func([IDL.Opt(IDL.Text)], [IDL.Text], ["query"]), - vec_nat8: IDL.Func([IDL.Vec(IDL.Nat8)], [IDL.Text], ["query"]), - opt_number: IDL.Func([IDL.Opt(IDL.Nat16)], [IDL.Text], ["query"]), - opt_and_vec: IDL.Func( - [IDL.Opt(IDL.Nat16), IDL.Vec(IDL.Text)], - [IDL.Text], - ["query"] - ), - vec_in_opt: IDL.Func([IDL.Opt(IDL.Vec(IDL.Text))], [IDL.Text], ["query"]), - enum: IDL.Func([Enum], [IDL.Text], ["query"]), - number_vec: IDL.Func([IDL.Vec(IDL.Nat8)], [IDL.Text], ["query"]), - process_basic_types: IDL.Func([BasicTypes], [Status], ["query"]), - handle_complex_record: IDL.Func([ComplexRecord], [Status], ["query"]), - metadata: IDL.Func( - [IDL.Record({ newField: IDL.Nat8, otherField: IDL.Text })], - [IDL.Vec(IDL.Text)], - [] - ), - opt_metadata: IDL.Func( - [IDL.Opt(IDL.Record({ newField: IDL.Nat8, otherField: IDL.Text }))], - [IDL.Vec(IDL.Text)], - [] - ), - vec_metadata: IDL.Func( - [ - IDL.Opt( - IDL.Vec( - IDL.Record({ newField: IDL.Nat8, otherField: IDL.Opt(IDL.Text) }) - ) - ), - ], - [IDL.Vec(IDL.Text)], - [] - ), - variant: IDL.Func( - [ - IDL.Variant({ - Int: IDL.Int, - Int8: IDL.Int8, - Int16: IDL.Int16, - Int32: IDL.Int32, - Int64: IDL.Int64, - Text: IDL.Text, - Nat: IDL.Nat, - Nat8: IDL.Nat8, - Nat16: IDL.Nat16, - Nat32: IDL.Nat32, - Nat64: IDL.Nat64, - }), - ], - [IDL.Vec(IDL.Text)], - [] - ), - variant_in_record: IDL.Func( - [ - IDL.Record({ - New: IDL.Variant({ - Int: IDL.Int, - Int8: IDL.Int8, - Int16: IDL.Int16, - Int32: IDL.Int32, - Int64: IDL.Int64, - Text: IDL.Text, - Nat: IDL.Nat, - Nat8: IDL.Nat8, - Nat16: IDL.Nat16, - Nat32: IDL.Nat32, - Nat64: IDL.Nat64, - }), - }), - ], - [IDL.Vec(IDL.Text)], - [] - ), - tuple_text_nat8_int16: IDL.Func( - [IDL.Tuple(IDL.Text, IDL.Nat8, IDL.Int16)], - [IDL.Vec(IDL.Text)], - [] - ), - receive: IDL.Func([ReleaseView], [IDL.Text], []), - app: IDL.Func([AppArgs], [AppView], []), - simple_recursive: IDL.Func([SimpleRec], [IDL.Text], []), - complex_recursive: IDL.Func([RecursiveRecord], [AppView], []), - recursive_value: IDL.Func([Value], [], []), - }) -} diff --git a/examples/candid-react/src/declarations/candid/index.d.ts b/examples/candid-react/src/declarations/candid/index.d.ts deleted file mode 100644 index 0cb171dfc4..0000000000 --- a/examples/candid-react/src/declarations/candid/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorConfig, - ActorSubclass, - Agent, - HttpAgentOptions, -} from "@dfinity/agent" -import type { IDL } from "@dfinity/candid" -import type { Principal } from "@dfinity/principal" - -import { _SERVICE } from "./candid.did" - -export declare const idlFactory: IDL.InterfaceFactory -export declare const canisterId: string - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE> - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const candid: ActorSubclass<_SERVICE> diff --git a/examples/candid-react/src/declarations/candid/index.js b/examples/candid-react/src/declarations/candid/index.js deleted file mode 100644 index 5b04cb9547..0000000000 --- a/examples/candid-react/src/declarations/candid/index.js +++ /dev/null @@ -1,37 +0,0 @@ -import { Actor, HttpAgent } from '@dfinity/agent'; - -// Imports and re-exports candid interface -import { idlFactory } from './candid.did.js'; -export { idlFactory } from './candid.did.js'; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = process.env.CANISTER_ID_SIMPLE || process.env.SIMPLE_CANISTER_ID; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - 'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.', - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== 'ic') { - agent.fetchRootKey().catch(err => { - console.warn('Unable to fetch root key. Check to ensure that your local replica is running'); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; diff --git a/examples/candid-react/src/declarations/ledger.ts b/examples/candid-react/src/declarations/ledger.ts deleted file mode 100644 index db9826dd59..0000000000 --- a/examples/candid-react/src/declarations/ledger.ts +++ /dev/null @@ -1,293 +0,0 @@ -import type { Principal } from "@dfinity/principal" -import type { ActorMethod } from "@dfinity/agent" - -export interface Account { - owner: Principal - subaccount: [] | [Uint8Array | number[]] -} -export interface AccountBalanceArgs { - account: string -} -export interface Allowance { - allowance: bigint - expires_at: [] | [bigint] -} -export interface AllowanceArgs { - account: Account - spender: Account -} -export interface ApproveArgs { - fee: [] | [bigint] - memo: [] | [Uint8Array | number[]] - from_subaccount: [] | [Uint8Array | number[]] - created_at_time: [] | [bigint] - amount: bigint - expected_allowance: [] | [bigint] - expires_at: [] | [bigint] - spender: Account -} -export type ApproveError = - | { - GenericError: { message: string; error_code: bigint } - } - | { TemporarilyUnavailable: null } - | { Duplicate: { duplicate_of: bigint } } - | { BadFee: { expected_fee: bigint } } - | { AllowanceChanged: { current_allowance: bigint } } - | { CreatedInFuture: { ledger_time: bigint } } - | { TooOld: null } - | { Expired: { ledger_time: bigint } } - | { InsufficientFunds: { balance: bigint } } -export interface ArchiveInfo { - canister_id: Principal -} -export interface ArchiveOptions { - num_blocks_to_archive: bigint - max_transactions_per_response: [] | [bigint] - trigger_threshold: bigint - max_message_size_bytes: [] | [bigint] - cycles_for_archive_creation: [] | [bigint] - node_max_memory_size_bytes: [] | [bigint] - controller_id: Principal -} -export interface ArchivedBlocksRange { - callback: [Principal, string] - start: bigint - length: bigint -} -export interface ArchivedEncodedBlocksRange { - callback: [Principal, string] - start: bigint - length: bigint -} -export interface Archives { - archives: Array -} -export interface BinaryAccountBalanceArgs { - account: Uint8Array | number[] -} -export interface BlockRange { - blocks: Array -} -export interface CandidBlock { - transaction: CandidTransaction - timestamp: TimeStamp - parent_hash: [] | [Uint8Array | number[]] -} -export type CandidOperation = - | { - Approve: { - fee: Tokens - from: Uint8Array | number[] - allowance_e8s: bigint - allowance: Tokens - expected_allowance: [] | [Tokens] - expires_at: [] | [TimeStamp] - spender: Uint8Array | number[] - } - } - | { - Burn: { - from: Uint8Array | number[] - amount: Tokens - spender: [] | [Uint8Array | number[]] - } - } - | { Mint: { to: Uint8Array | number[]; amount: Tokens } } - | { - Transfer: { - to: Uint8Array | number[] - fee: Tokens - from: Uint8Array | number[] - amount: Tokens - spender: [] | [Uint8Array | number[]] - } - } -export interface CandidTransaction { - memo: bigint - icrc1_memo: [] | [Uint8Array | number[]] - operation: [] | [CandidOperation] - created_at_time: TimeStamp -} -export interface Decimals { - decimals: number -} -export interface Duration { - secs: bigint - nanos: number -} -export interface FeatureFlags { - icrc2: boolean -} -export interface GetBlocksArgs { - start: bigint - length: bigint -} -export type GetBlocksError = - | { - BadFirstBlockIndex: { - requested_index: bigint - first_valid_index: bigint - } - } - | { Other: { error_message: string; error_code: bigint } } -export interface InitArgs { - send_whitelist: Array - token_symbol: [] | [string] - transfer_fee: [] | [Tokens] - minting_account: string - maximum_number_of_accounts: [] | [bigint] - accounts_overflow_trim_quantity: [] | [bigint] - transaction_window: [] | [Duration] - max_message_size_bytes: [] | [bigint] - icrc1_minting_account: [] | [Account] - archive_options: [] | [ArchiveOptions] - initial_values: Array<[string, Tokens]> - token_name: [] | [string] - feature_flags: [] | [FeatureFlags] -} -export type LedgerCanisterPayload = - | { Upgrade: [] | [UpgradeArgs] } - | { Init: InitArgs } -export type MetadataValue = - | { Int: bigint } - | { Nat: bigint } - | { Blob: Uint8Array | number[] } - | { Text: string } -export interface Name { - name: string -} -export interface QueryBlocksResponse { - certificate: [] | [Uint8Array | number[]] - blocks: Array - chain_length: bigint - first_block_index: bigint - archived_blocks: Array -} -export interface QueryEncodedBlocksResponse { - certificate: [] | [Uint8Array | number[]] - blocks: Array - chain_length: bigint - first_block_index: bigint - archived_blocks: Array -} -export type Result = { Ok: bigint } | { Err: TransferError } -export type Result_1 = { Ok: bigint } | { Err: ApproveError } -export type Result_2 = { Ok: bigint } | { Err: TransferFromError } -export type Result_3 = { Ok: BlockRange } | { Err: GetBlocksError } -export type Result_4 = - | { Ok: Array } - | { Err: GetBlocksError } -export type Result_5 = { Ok: bigint } | { Err: TransferError_1 } -export interface SendArgs { - to: string - fee: Tokens - memo: bigint - from_subaccount: [] | [Uint8Array | number[]] - created_at_time: [] | [TimeStamp] - amount: Tokens -} -export interface StandardRecord { - url: string - name: string -} -export interface Symbol { - symbol: string -} -export interface TimeStamp { - timestamp_nanos: bigint -} -export interface Tokens { - e8s: bigint -} -export interface TransferArg { - to: Account - fee: [] | [bigint] - memo: [] | [Uint8Array | number[]] - from_subaccount: [] | [Uint8Array | number[]] - created_at_time: [] | [bigint] - amount: bigint -} -export interface TransferArgs { - to: Uint8Array | number[] - fee: Tokens - memo: bigint - from_subaccount: [] | [Uint8Array | number[]] - created_at_time: [] | [TimeStamp] - amount: Tokens -} -export type TransferError = - | { - GenericError: { message: string; error_code: bigint } - } - | { TemporarilyUnavailable: null } - | { BadBurn: { min_burn_amount: bigint } } - | { Duplicate: { duplicate_of: bigint } } - | { BadFee: { expected_fee: bigint } } - | { CreatedInFuture: { ledger_time: bigint } } - | { TooOld: null } - | { InsufficientFunds: { balance: bigint } } -export type TransferError_1 = - | { - TxTooOld: { allowed_window_nanos: bigint } - } - | { BadFee: { expected_fee: Tokens } } - | { TxDuplicate: { duplicate_of: bigint } } - | { TxCreatedInFuture: null } - | { InsufficientFunds: { balance: Tokens } } -export interface TransferFee { - transfer_fee: Tokens -} -export interface TransferFromArgs { - to: Account - fee: [] | [bigint] - spender_subaccount: [] | [Uint8Array | number[]] - from: Account - memo: [] | [Uint8Array | number[]] - created_at_time: [] | [bigint] - amount: bigint -} -export type TransferFromError = - | { - GenericError: { message: string; error_code: bigint } - } - | { TemporarilyUnavailable: null } - | { InsufficientAllowance: { allowance: bigint } } - | { BadBurn: { min_burn_amount: bigint } } - | { Duplicate: { duplicate_of: bigint } } - | { BadFee: { expected_fee: bigint } } - | { CreatedInFuture: { ledger_time: bigint } } - | { TooOld: null } - | { InsufficientFunds: { balance: bigint } } -export interface UpgradeArgs { - maximum_number_of_accounts: [] | [bigint] - icrc1_minting_account: [] | [Account] - feature_flags: [] | [FeatureFlags] -} -export interface Ledger { - account_balance: ActorMethod<[BinaryAccountBalanceArgs], Tokens> - account_balance_dfx: ActorMethod<[AccountBalanceArgs], Tokens> - account_identifier: ActorMethod<[Account], Uint8Array | number[]> - archives: ActorMethod<[], Archives> - decimals: ActorMethod<[], Decimals> - icrc1_balance_of: ActorMethod<[Account], bigint> - icrc1_decimals: ActorMethod<[], number> - icrc1_fee: ActorMethod<[], bigint> - icrc1_metadata: ActorMethod<[], Array<[string, MetadataValue]>> - icrc1_minting_account: ActorMethod<[], [] | [Account]> - icrc1_name: ActorMethod<[], string> - icrc1_supported_standards: ActorMethod<[], Array> - icrc1_symbol: ActorMethod<[], string> - icrc1_total_supply: ActorMethod<[], bigint> - icrc1_transfer: ActorMethod<[TransferArg], Result> - icrc2_allowance: ActorMethod<[AllowanceArgs], Allowance> - icrc2_approve: ActorMethod<[ApproveArgs], Result_1> - icrc2_transfer_from: ActorMethod<[TransferFromArgs], Result_2> - name: ActorMethod<[], Name> - query_blocks: ActorMethod<[GetBlocksArgs], QueryBlocksResponse> - query_encoded_blocks: ActorMethod<[GetBlocksArgs], QueryEncodedBlocksResponse> - send_dfx: ActorMethod<[SendArgs], bigint> - symbol: ActorMethod<[], Symbol> - transfer: ActorMethod<[TransferArgs], Result_5> - transfer_fee: ActorMethod<[{}], TransferFee> -} diff --git a/examples/candid-react/src/index.css b/examples/candid-react/src/index.css deleted file mode 100644 index 4bf1c5d353..0000000000 --- a/examples/candid-react/src/index.css +++ /dev/null @@ -1,17 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} \ No newline at end of file diff --git a/examples/candid-react/src/index.tsx b/examples/candid-react/src/index.tsx deleted file mode 100644 index 22c404664c..0000000000 --- a/examples/candid-react/src/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import ReactDOM from "react-dom/client" -import "./index.css" - -import App from "./components/CandidViewer" - -const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement) -root.render() diff --git a/examples/candid-react/src/react-app-env.d.ts b/examples/candid-react/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5fc6..0000000000 --- a/examples/candid-react/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/candid-react/src/utils.ts b/examples/candid-react/src/utils.ts deleted file mode 100644 index 2819a830d2..0000000000 --- a/examples/candid-react/src/utils.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { clsx, type ClassValue } from 'clsx'; -import { twMerge } from 'tailwind-merge'; - -export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); -} diff --git a/examples/candid-react/tailwind.config.js b/examples/candid-react/tailwind.config.js deleted file mode 100644 index 9b6645eb5d..0000000000 --- a/examples/candid-react/tailwind.config.js +++ /dev/null @@ -1,8 +0,0 @@ -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: ['./src/**/*.{js,jsx,ts,tsx}'], - theme: { - extend: {}, - }, - plugins: [], -}; diff --git a/examples/candid-react/tsconfig.json b/examples/candid-react/tsconfig.json deleted file mode 100644 index 9d379a3c4a..0000000000 --- a/examples/candid-react/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" - }, - "include": ["src"] -}