From 1ffb6a1727b7c1e10e8470e54bc779c9a0af2fdd Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Fri, 16 Jun 2023 11:16:43 -0400 Subject: [PATCH 01/12] feat: add flipper ui example --- .gitignore | 6 + .vscode/extensions.json | 4 + .vscode/settings.json | 13 + README.md | 11 + flipper/frontend/.gitignore | 21 ++ flipper/frontend/README.md | 4 + flipper/frontend/index.html | 13 + flipper/frontend/package.json | 30 ++ flipper/frontend/postcss.config.js | 6 + flipper/frontend/public/logo.svg | 1 + flipper/frontend/src/App.tsx | 49 +++ flipper/frontend/src/Global.css | 3 + flipper/frontend/src/assets/flipper.json | 396 +++++++++++++++++++++++ flipper/frontend/src/constants.ts | 2 + flipper/frontend/src/main.tsx | 27 ++ flipper/frontend/src/vite-env.d.ts | 1 + flipper/frontend/tailwind.config.js | 2 + flipper/frontend/tsconfig.json | 25 ++ flipper/frontend/tsconfig.node.json | 10 + flipper/frontend/vite.config.ts | 7 + package.json | 33 ++ pnpm-workspace.yaml | 3 + rome.json | 34 ++ ui/README.md | 4 + ui/package.json | 51 +++ ui/postcss.config | 6 + ui/src/Accounts/Accounts.tsx | 107 ++++++ ui/src/Accounts/index.ts | 1 + ui/src/Button/Button.tsx | 33 ++ ui/src/Button/index.ts | 1 + ui/src/Card/Card.tsx | 12 + ui/src/Card/index.ts | 1 + ui/src/ConnectButton/ConnectButton.tsx | 20 ++ ui/src/ConnectButton/index.ts | 1 + ui/src/ConnectWallet/ConnectWallet.tsx | 74 +++++ ui/src/ConnectWallet/index.ts | 1 + ui/src/InkLayout/InkLayout.tsx | 54 ++++ ui/src/InkLayout/index.ts | 1 + ui/src/Logo/Logo.tsx | 77 +++++ ui/src/Logo/index.ts | 1 + ui/src/LottieEntity/LottieEntity.tsx | 15 + ui/src/LottieEntity/index.ts | 1 + ui/src/Modal/Modal.tsx | 58 ++++ ui/src/Modal/index.ts | 1 + ui/src/Navbar/Navbar.tsx | 26 ++ ui/src/Navbar/index.ts | 1 + ui/src/Notifications/Notifications.tsx | 24 ++ ui/src/Notifications/index.ts | 1 + ui/src/NumberInput/NumberInput.tsx | 80 +++++ ui/src/NumberInput/index.ts | 1 + ui/src/Snackbar/Snackbar.tsx | 42 +++ ui/src/Snackbar/index.ts | 1 + ui/src/assets/react.svg | 1 + ui/src/contexts/UIContext.tsx | 21 ++ ui/src/contexts/index.ts | 1 + ui/src/hooks/index.ts | 1 + ui/src/hooks/useUI.ts | 4 + ui/src/index.css | 7 + ui/src/index.ts | 16 + ui/src/types/common.ts | 7 + ui/src/types/index.ts | 1 + ui/src/vite-env.d.ts | 1 + ui/tailwind.config.js | 53 +++ ui/tsconfig.json | 25 ++ ui/tsconfig.node.json | 10 + ui/vite.config.ts | 43 +++ 66 files changed, 1588 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 flipper/frontend/.gitignore create mode 100644 flipper/frontend/README.md create mode 100644 flipper/frontend/index.html create mode 100644 flipper/frontend/package.json create mode 100644 flipper/frontend/postcss.config.js create mode 100644 flipper/frontend/public/logo.svg create mode 100644 flipper/frontend/src/App.tsx create mode 100644 flipper/frontend/src/Global.css create mode 100644 flipper/frontend/src/assets/flipper.json create mode 100644 flipper/frontend/src/constants.ts create mode 100644 flipper/frontend/src/main.tsx create mode 100644 flipper/frontend/src/vite-env.d.ts create mode 100644 flipper/frontend/tailwind.config.js create mode 100644 flipper/frontend/tsconfig.json create mode 100644 flipper/frontend/tsconfig.node.json create mode 100644 flipper/frontend/vite.config.ts create mode 100644 package.json create mode 100644 pnpm-workspace.yaml create mode 100644 rome.json create mode 100644 ui/README.md create mode 100644 ui/package.json create mode 100644 ui/postcss.config create mode 100644 ui/src/Accounts/Accounts.tsx create mode 100644 ui/src/Accounts/index.ts create mode 100644 ui/src/Button/Button.tsx create mode 100644 ui/src/Button/index.ts create mode 100644 ui/src/Card/Card.tsx create mode 100644 ui/src/Card/index.ts create mode 100644 ui/src/ConnectButton/ConnectButton.tsx create mode 100644 ui/src/ConnectButton/index.ts create mode 100644 ui/src/ConnectWallet/ConnectWallet.tsx create mode 100644 ui/src/ConnectWallet/index.ts create mode 100644 ui/src/InkLayout/InkLayout.tsx create mode 100644 ui/src/InkLayout/index.ts create mode 100644 ui/src/Logo/Logo.tsx create mode 100644 ui/src/Logo/index.ts create mode 100644 ui/src/LottieEntity/LottieEntity.tsx create mode 100644 ui/src/LottieEntity/index.ts create mode 100644 ui/src/Modal/Modal.tsx create mode 100644 ui/src/Modal/index.ts create mode 100644 ui/src/Navbar/Navbar.tsx create mode 100644 ui/src/Navbar/index.ts create mode 100644 ui/src/Notifications/Notifications.tsx create mode 100644 ui/src/Notifications/index.ts create mode 100644 ui/src/NumberInput/NumberInput.tsx create mode 100644 ui/src/NumberInput/index.ts create mode 100644 ui/src/Snackbar/Snackbar.tsx create mode 100644 ui/src/Snackbar/index.ts create mode 100644 ui/src/assets/react.svg create mode 100644 ui/src/contexts/UIContext.tsx create mode 100644 ui/src/contexts/index.ts create mode 100644 ui/src/hooks/index.ts create mode 100644 ui/src/hooks/useUI.ts create mode 100644 ui/src/index.css create mode 100644 ui/src/index.ts create mode 100644 ui/src/types/common.ts create mode 100644 ui/src/types/index.ts create mode 100644 ui/src/vite-env.d.ts create mode 100644 ui/tailwind.config.js create mode 100644 ui/tsconfig.json create mode 100644 ui/tsconfig.node.json create mode 100644 ui/vite.config.ts diff --git a/.gitignore b/.gitignore index a0a88aaf..79f7022a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,13 @@ /**/target/ /design/ .idea/ +.vite/ +node_modules/ +/**/dist/ +pnpm-lock.yaml + +vite.config.ts.timestamp* # Ignore backup files creates by cargo fmt. **/*.rs.bk diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..c3153a4a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["rome.rome"], + "unwantedRecommendations": [] + } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..ad41dc44 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "editor.codeActionsOnSave": { + "source.organizeImports.rome": true + }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "rome.rome", + "[typescript]": { + "editor.defaultFormatter": "rome.rome" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "rome.rome" + } + } \ No newline at end of file diff --git a/README.md b/README.md index b732be1a..a189131a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,17 @@ To build a single example and generate the contracts Wasm file, navigate to the You should now have an optimized `.wasm` file, a `metadata.json` file and a `.contract` file in the `target` folder of your contract. The `.contract` file combines the Wasm and metadata into one file and can be used for instantiation. + +## Running front end dApp examples + +1. Install [nodejs](https://nodejs.org/en/) and then install [pnpm](https://pnpm.io/) `npm install -g pnpm` +2. Install dependencies `pnpm i` +3. Build the UI package `pnpm build:ui` (You only need to do this once) +4. Run each example with `pnpm `. e.g. `pnpm flipper` +5. Visit [http://localhost:5173](http://localhost:5173) in your browser. + +All examples are built with [useink](https://use.ink/frontend/overview), a React hooks library built by the ink! team. + ## License The examples in this folder are released into the public domain. diff --git a/flipper/frontend/.gitignore b/flipper/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/flipper/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/flipper/frontend/README.md b/flipper/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/flipper/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/flipper/frontend/index.html b/flipper/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/flipper/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/flipper/frontend/package.json b/flipper/frontend/package.json new file mode 100644 index 00000000..ecba45fa --- /dev/null +++ b/flipper/frontend/package.json @@ -0,0 +1,30 @@ +{ + "name": "flipper", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.0", + "@typescript-eslint/parser": "^5.59.0", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/flipper/frontend/postcss.config.js b/flipper/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/flipper/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/flipper/frontend/public/logo.svg b/flipper/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/flipper/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/flipper/frontend/src/App.tsx b/flipper/frontend/src/App.tsx new file mode 100644 index 00000000..4403d237 --- /dev/null +++ b/flipper/frontend/src/App.tsx @@ -0,0 +1,49 @@ +import metadata from './assets/flipper.json'; +import { CONTRACT_ROCOCO_ADDRESS } from './constants'; +import { Button, Card, ConnectButton, InkLayout } from 'ui'; +import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { pickDecoded, shouldDisable } from 'useink/utils'; + +function App() { + const { account } = useWallet(); + const contract = useContract(CONTRACT_ROCOCO_ADDRESS, metadata); + const getSub = useCallSubscription(contract, 'get', [], { + defaultCaller: true, + }); + + const flip = useTx(contract, 'flip'); + useTxNotifications(flip); + + return ( + + +

+ {metadata.contract.name.toUpperCase()} +

+ +

+ Flipped:{' '} + {pickDecoded(getSub.result)?.toString()} +

+ + {account ? ( + + ) : ( + + )} +
+
+ ); +} + +export default App; diff --git a/flipper/frontend/src/Global.css b/flipper/frontend/src/Global.css new file mode 100644 index 00000000..bd6213e1 --- /dev/null +++ b/flipper/frontend/src/Global.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/flipper/frontend/src/assets/flipper.json b/flipper/frontend/src/assets/flipper.json new file mode 100644 index 00000000..fe0d2253 --- /dev/null +++ b/flipper/frontend/src/assets/flipper.json @@ -0,0 +1,396 @@ +{ + "source": { + "hash": "0x0f466d0c332258ce41c0b4aaaba4f1708671da275c8fbe395dc81b1fdfedc662", + "language": "ink! 4.2.0", + "compiler": "rustc 1.69.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "flipper", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "init_value", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + "Creates a new flipper smart contract initialized with the given value." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + }, + { + "args": [], + "default": false, + "docs": [ + "Creates a new flipper smart contract initialized to `false`." + ], + "label": "new_default", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x61ef7e3e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 5 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 8 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 11 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 12 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 9 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 10 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 3 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [ + " Flips the current value of the Flipper's boolean." + ], + "label": "flip", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 1 + }, + "selector": "0x633aa551" + }, + { + "args": [], + "default": false, + "docs": [ + " Returns the current value of the Flipper's boolean." + ], + "label": "get", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x2f865bd9" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "value" + } + ], + "name": "Flipper" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 3, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "array": { + "len": 32, + "type": 7 + } + } + } + }, + { + "id": 7, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 9, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 12, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/flipper/frontend/src/constants.ts b/flipper/frontend/src/constants.ts new file mode 100644 index 00000000..549db8ba --- /dev/null +++ b/flipper/frontend/src/constants.ts @@ -0,0 +1,2 @@ +export const CONTRACT_ROCOCO_ADDRESS = + '5Fsk6oqWHJzMAQmkBTVzxxqZPPngLbHG48Tro3i53LC3quao'; diff --git a/flipper/frontend/src/main.tsx b/flipper/frontend/src/main.tsx new file mode 100644 index 00000000..bc773936 --- /dev/null +++ b/flipper/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import App from './App.tsx'; +import './Global.css'; +import metadata from './assets/flipper.json'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/flipper/frontend/src/vite-env.d.ts b/flipper/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/flipper/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/flipper/frontend/tailwind.config.js b/flipper/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/flipper/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/flipper/frontend/tsconfig.json b/flipper/frontend/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/flipper/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/flipper/frontend/tsconfig.node.json b/flipper/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/flipper/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/flipper/frontend/vite.config.ts b/flipper/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/flipper/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/package.json b/package.json new file mode 100644 index 00000000..1a30146f --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "ink-examples", + "version": "1.0.0", + "description": "Example dApps for ink! contracts.", + "main": "index.js", + "keywords": [], + "author": "Sam Ruberti ", + "license": "Apache 2.0", + "scripts": { + "format": "rome format . --write", + "lint": "rome check ./*", + "lint:fix": "pnpm lint --apply-unsafe", + "build:ui": "pnpm --filter ui build", + "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev" + }, + "packages": [ + "ui", + "*/frontend/*" + ], + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0", + "useink": "^1.5.1" + }, + "devDependencies": { + "tailwindcss": "^3.3.2", + "classnames": "^2.3.2", + "autoprefixer": "^10.4.14", + "postcss": "^8.4.24", + "rome": "12.1.3" + }, + "packageManager": "pnpm@8.4.0" +} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 00000000..83157c55 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - "ui" + - "*/frontend" \ No newline at end of file diff --git a/rome.json b/rome.json new file mode 100644 index 00000000..811fc28a --- /dev/null +++ b/rome.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json", + "files": { + "ignore": [ + "**/node_modules", ".next", "public", "dist", "**/*.json", "*.yaml", ".vscode" + ] + }, + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "formatWithErrors": false, + "indentStyle": "space", + "indentSize": 2, + "lineWidth": 80 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "error" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "trailingComma": "all", + "semicolons": "always" + } + } +} diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 00000000..977e9cd9 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,4 @@ +# useink UI + +This is a UI library for demonstrating [useink](https://use.ink/frontend/overview/) integrations, and is the UI library for +[ink-examples](github.com/paritytech/ink-examples/). \ No newline at end of file diff --git a/ui/package.json b/ui/package.json new file mode 100644 index 00000000..717cfbbc --- /dev/null +++ b/ui/package.json @@ -0,0 +1,51 @@ +{ + "name": "ui", + "version": "0.1.0", + "type": "module", + "license": "Apache 2.0", + "scripts": { + "build": "tsc && vite build && pnpm run build-tailwind", + "dev": "vite build --watch && pnpm run build-tailwind", + "build-tailwind": "NODE_ENV=production npx tailwindcss -o ./dist/style.css -m", + "lint": "rome check ./*", + "lint:fix": "pnpm lint --apply-unsafe" + }, + "sideEffects": false, + "peerDependencies": { + "useink": "^1.5.1", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "dependencies": { + "@headlessui/react": "^1.7.14", + "@heroicons/react": "^2.0.18", + "@lottiefiles/react-lottie-player": "^3.5.3" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.8", + "@typescript-eslint/parser": "^5.59.8", + "@vitejs/plugin-react": "^4.0.0", + "typescript": "^5.0.2", + "vite": "^4.3.9", + "vite-plugin-dts": "^2.3.0" + }, + "files": [ + "dist", + "./src/index.css" + ], + "exports": { + ".": { + "import": { + "default": "./dist/ui.es.js", + "types": "./dist/index.d.ts" + }, + "require": { + "default": "./dist/ui.umd.js", + "types": "./dist/index.d.ts" + } + }, + "./style.css": "./src/index.css" + } +} diff --git a/ui/postcss.config b/ui/postcss.config new file mode 100644 index 00000000..e2dc4780 --- /dev/null +++ b/ui/postcss.config @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + } +} \ No newline at end of file diff --git a/ui/src/Accounts/Accounts.tsx b/ui/src/Accounts/Accounts.tsx new file mode 100644 index 00000000..8c9fd4e8 --- /dev/null +++ b/ui/src/Accounts/Accounts.tsx @@ -0,0 +1,107 @@ +import { ClassNameable } from '../types'; +import { Listbox, Transition } from '@headlessui/react'; +import { + CheckIcon, + ChevronUpDownIcon, + XCircleIcon, +} from '@heroicons/react/24/solid'; +import classNames from 'classnames'; +import React, { Fragment } from 'react'; +import { useWallet } from 'useink'; + +export const Accounts: React.FC = ({ className }) => { + const { setAccount, account, accounts, disconnect } = useWallet(); + + return ( +
+ { + setAccount(a); + }} + > +
+ + + {account?.name || account?.address} + + + + + + + {accounts?.map((acc) => ( + + classNames( + 'relative cursor-default select-none py-2 pl-10 pr-4 hover:cursor-pointer', + active ? 'bg-violet-800 text-gray-300' : 'text-gray-300', + ) + } + value={acc} + > + {() => { + const selected = + account && account.address === acc?.address; + return ( + <> + + {acc.name || acc.address} + + + {selected && ( + + + )} + + ); + }} + + ))} + + +
+
+ +
+ ); +}; diff --git a/ui/src/Accounts/index.ts b/ui/src/Accounts/index.ts new file mode 100644 index 00000000..99ab81bf --- /dev/null +++ b/ui/src/Accounts/index.ts @@ -0,0 +1 @@ +export * from './Accounts'; diff --git a/ui/src/Button/Button.tsx b/ui/src/Button/Button.tsx new file mode 100644 index 00000000..901dd818 --- /dev/null +++ b/ui/src/Button/Button.tsx @@ -0,0 +1,33 @@ +import classNames from 'classnames'; +import React, { + ButtonHTMLAttributes, + DetailedHTMLProps, + PropsWithChildren, +} from 'react'; + +type ButtomHTMLProps = DetailedHTMLProps< + ButtonHTMLAttributes, + HTMLButtonElement +>; + +export type ButtonProps = PropsWithChildren; + +export const Button: React.FC = ({ + children, + className, + onClick, + ...rest +}) => { + const classes = classNames( + 'bg-brand-900 hover:opacity-80 transition ease-in-out px-6 py-2 border-none disabled:text-opacity-70', + 'text-base tracking-wide font-semibold rounded-full disabled:opacity-50 disabled:hover:bg-opacity-50', + 'focus:ring-none disabled:cursor-not-allowed focus:outline-none focus:ring-0 focus:ring-offset-0 text-white', + className, + ); + + return ( + + ); +}; diff --git a/ui/src/Button/index.ts b/ui/src/Button/index.ts new file mode 100644 index 00000000..8b166a86 --- /dev/null +++ b/ui/src/Button/index.ts @@ -0,0 +1 @@ +export * from './Button'; diff --git a/ui/src/Card/Card.tsx b/ui/src/Card/Card.tsx new file mode 100644 index 00000000..12103b11 --- /dev/null +++ b/ui/src/Card/Card.tsx @@ -0,0 +1,12 @@ +import { InkComponent } from '../types'; +import classNames from 'classnames'; +import React from 'react'; + +export const Card: React.FC = ({ children, className }) => { + const classes = classNames( + 'bg-brand-500 text-white/90 rounded-xl max-w-3xl', + className, + ); + + return
{children}
; +}; diff --git a/ui/src/Card/index.ts b/ui/src/Card/index.ts new file mode 100644 index 00000000..ca0b0604 --- /dev/null +++ b/ui/src/Card/index.ts @@ -0,0 +1 @@ +export * from './Card'; diff --git a/ui/src/ConnectButton/ConnectButton.tsx b/ui/src/ConnectButton/ConnectButton.tsx new file mode 100644 index 00000000..8b71c84d --- /dev/null +++ b/ui/src/ConnectButton/ConnectButton.tsx @@ -0,0 +1,20 @@ +import { Button, ButtonProps, useUI } from '..'; +import React from 'react'; + +export const ConnectButton: React.FC> = ({ + className, + children = 'Connect Wallet', + ...rest +}) => { + const { setShowConnectWallet } = useUI(); + + return ( + + ); +}; diff --git a/ui/src/ConnectButton/index.ts b/ui/src/ConnectButton/index.ts new file mode 100644 index 00000000..916bf3f7 --- /dev/null +++ b/ui/src/ConnectButton/index.ts @@ -0,0 +1 @@ +export * from './ConnectButton'; diff --git a/ui/src/ConnectWallet/ConnectWallet.tsx b/ui/src/ConnectWallet/ConnectWallet.tsx new file mode 100644 index 00000000..e151396c --- /dev/null +++ b/ui/src/ConnectWallet/ConnectWallet.tsx @@ -0,0 +1,74 @@ +import { Button } from '../Button'; +import { Modal } from '../Modal'; +import React, { useEffect } from 'react'; +import { useInstalledWallets, useUninstalledWallets, useWallet } from 'useink'; + +type Props = { + show: boolean; + onClose: () => void; +}; + +export const ConnectWallet: React.FC = ({ show, onClose }) => { + const { account, connect } = useWallet(); + const installed = useInstalledWallets(); + const uninstalled = useUninstalledWallets(); + + useEffect(() => { + account && onClose(); + }, [account, onClose]); + + return ( + +

Connect Wallet

+ + {!account && installed.length > 0 && ( +
    + {installed.map((w) => ( +
  • + +
  • + ))} +
+ )} + + {!account && uninstalled.length && installed.length === 0 && ( + <> +

+ Please install one of these supported wallets. +

+ +
    + {uninstalled.map((w) => ( +
  • + +
  • + ))} +
+ + )} + + +
+ ); +}; diff --git a/ui/src/ConnectWallet/index.ts b/ui/src/ConnectWallet/index.ts new file mode 100644 index 00000000..59af7d91 --- /dev/null +++ b/ui/src/ConnectWallet/index.ts @@ -0,0 +1 @@ +export * from './ConnectWallet'; diff --git a/ui/src/InkLayout/InkLayout.tsx b/ui/src/InkLayout/InkLayout.tsx new file mode 100644 index 00000000..c86d5923 --- /dev/null +++ b/ui/src/InkLayout/InkLayout.tsx @@ -0,0 +1,54 @@ +import { InkComponent, Notifications, useUI } from '..'; +import { ConnectWallet } from '../ConnectWallet'; +import { LottieEntity } from '../LottieEntity'; +import { Navbar } from '../Navbar'; +import { UIProvider } from '../contexts'; +import classNames from 'classnames'; +import React from 'react'; + +type Props = InkComponent & { + animationSrc?: string; + withNotifications?: boolean; + withNavbar?: boolean; +}; + +const InkLayoutInner: React.FC = ({ + children, + animationSrc, + className, + withNotifications = true, + withNavbar = true, +}) => { + const { showConnectWallet, setShowConnectWallet } = useUI(); + + return ( +
+ {animationSrc && ( + + )} + {withNavbar && } + {withNotifications && } + setShowConnectWallet(false)} + /> + +
{children}
+
+ ); +}; + +export const InkLayout: React.FC = (props) => { + return ( + + + + ); +}; diff --git a/ui/src/InkLayout/index.ts b/ui/src/InkLayout/index.ts new file mode 100644 index 00000000..02bd33ff --- /dev/null +++ b/ui/src/InkLayout/index.ts @@ -0,0 +1 @@ +export * from './InkLayout'; diff --git a/ui/src/Logo/Logo.tsx b/ui/src/Logo/Logo.tsx new file mode 100644 index 00000000..b6d42eac --- /dev/null +++ b/ui/src/Logo/Logo.tsx @@ -0,0 +1,77 @@ +import { ClassNameable } from '../types'; +import React from 'react'; + +export const Logo: React.FC = ({ className }) => ( + + Squink + + + + + + + + + + + + + + + + + + + + + + + +); diff --git a/ui/src/Logo/index.ts b/ui/src/Logo/index.ts new file mode 100644 index 00000000..d97c6951 --- /dev/null +++ b/ui/src/Logo/index.ts @@ -0,0 +1 @@ +export * from './Logo'; diff --git a/ui/src/LottieEntity/LottieEntity.tsx b/ui/src/LottieEntity/LottieEntity.tsx new file mode 100644 index 00000000..92b8177b --- /dev/null +++ b/ui/src/LottieEntity/LottieEntity.tsx @@ -0,0 +1,15 @@ +import { ClassNameable } from '..'; +import { Player } from '@lottiefiles/react-lottie-player'; +import React from 'react'; + +type Props = { + src: string; +} & ClassNameable; + +export const LottieEntity: React.FC = ({ src, className }) => { + return ( +
+ +
+ ); +}; diff --git a/ui/src/LottieEntity/index.ts b/ui/src/LottieEntity/index.ts new file mode 100644 index 00000000..023cb2d4 --- /dev/null +++ b/ui/src/LottieEntity/index.ts @@ -0,0 +1 @@ +export * from './LottieEntity'; diff --git a/ui/src/Modal/Modal.tsx b/ui/src/Modal/Modal.tsx new file mode 100644 index 00000000..716a6f54 --- /dev/null +++ b/ui/src/Modal/Modal.tsx @@ -0,0 +1,58 @@ +import { Dialog, Transition } from '@headlessui/react'; +import classNames from 'classnames'; +import React, { Fragment, PropsWithChildren } from 'react'; + +type Props = { + open: boolean; + handleClose?: () => void; + className?: string; +}; + +export const Modal: React.FC> = ({ + open, + handleClose, + children, + className, +}) => { + const containerClasses = classNames( + 'inline-block bg-brand-800 border border-white/10 rounded-2xl overflow-scroll shadow-xl transform transition-all w-full max-w-3xl', + className, + ); + + return ( + + handleClose?.()} + > +
+ + + + +
{children}
+
+
+
+
+ ); +}; diff --git a/ui/src/Modal/index.ts b/ui/src/Modal/index.ts new file mode 100644 index 00000000..cb89ee17 --- /dev/null +++ b/ui/src/Modal/index.ts @@ -0,0 +1 @@ +export * from './Modal'; diff --git a/ui/src/Navbar/Navbar.tsx b/ui/src/Navbar/Navbar.tsx new file mode 100644 index 00000000..ca32fa56 --- /dev/null +++ b/ui/src/Navbar/Navbar.tsx @@ -0,0 +1,26 @@ +import { Accounts, Button, useUI } from '..'; +import { Logo } from '../Logo'; +import React from 'react'; +import { useWallet } from 'useink'; + +export const Navbar: React.FC = () => { + const { setShowConnectWallet } = useUI(); + const { account } = useWallet(); + + return ( + + ); +}; diff --git a/ui/src/Navbar/index.ts b/ui/src/Navbar/index.ts new file mode 100644 index 00000000..e8a65623 --- /dev/null +++ b/ui/src/Navbar/index.ts @@ -0,0 +1 @@ +export * from './Navbar'; diff --git a/ui/src/Notifications/Notifications.tsx b/ui/src/Notifications/Notifications.tsx new file mode 100644 index 00000000..af1d08d9 --- /dev/null +++ b/ui/src/Notifications/Notifications.tsx @@ -0,0 +1,24 @@ +import { Snackbar } from '../Snackbar'; +import React from 'react'; +// eslint-disable-next-line import/no-unresolved +import { toNotificationLevel, useNotifications } from 'useink/notifications'; + +export const Notifications: React.FC = () => { + const { notifications } = useNotifications(); + + if (!notifications.length) return null; + + return ( +
    + {notifications.map((n) => ( +
  • + +
  • + ))} +
+ ); +}; diff --git a/ui/src/Notifications/index.ts b/ui/src/Notifications/index.ts new file mode 100644 index 00000000..e7825351 --- /dev/null +++ b/ui/src/Notifications/index.ts @@ -0,0 +1 @@ +export * from './Notifications'; diff --git a/ui/src/NumberInput/NumberInput.tsx b/ui/src/NumberInput/NumberInput.tsx new file mode 100644 index 00000000..f3ae7cfd --- /dev/null +++ b/ui/src/NumberInput/NumberInput.tsx @@ -0,0 +1,80 @@ +import { ClassNameable } from '..'; +import { MinusIcon, PlusIcon } from '@heroicons/react/24/solid'; +import classnames from 'classnames'; +import React from 'react'; + +type Props = ClassNameable & { + onChange: (v: number) => void; + value: number; + placeholder?: string; + disabled?: boolean; + max: number; + min?: number; +}; + +const COMMON_CLASSES = [ + 'bg-brand-500 text-white border-none focuse:outline-none focus-visible:outline-none', + 'focus:outline-none disabled:text-white/80 py-4 flex items-center justify-center', +].join(' '); + +const BUTTON_CLASSES = + 'hover:bg-brand-800 disabled:bg-brand-450 disabled:cursor-not-allowed'; + +export const NumberInput: React.FC = ({ + value, + disabled, + onChange, + placeholder, + max, + min = 0, +}) => { + const handleChange = (v: number) => { + const val = v || min; + if (val < min) return; + if (val > max) return; + onChange(val); + }; + + return ( + + + { + handleChange(parseInt(e.target.value) || 0); + }} + /> + + + ); +}; diff --git a/ui/src/NumberInput/index.ts b/ui/src/NumberInput/index.ts new file mode 100644 index 00000000..6433506a --- /dev/null +++ b/ui/src/NumberInput/index.ts @@ -0,0 +1 @@ +export * from './NumberInput'; diff --git a/ui/src/Snackbar/Snackbar.tsx b/ui/src/Snackbar/Snackbar.tsx new file mode 100644 index 00000000..45218c13 --- /dev/null +++ b/ui/src/Snackbar/Snackbar.tsx @@ -0,0 +1,42 @@ +import { Transition } from '@headlessui/react'; +import classNames from 'classnames'; +import React, { Fragment } from 'react'; + +type NotificationLevel = 'error' | 'info' | 'success' | 'warning'; + +type Props = { + className?: string; + message: string; + show: boolean; + type: NotificationLevel; +}; + +const BG_COLORS: Record = { + error: 'bg-error-500', + info: 'bg-info-500', + success: 'bg-success-500', + warning: 'bg-warning-500', +}; + +export const Snackbar: React.FC = ({ show, message, type }) => ( + +
+
+ + {message} + +
+
+
+); diff --git a/ui/src/Snackbar/index.ts b/ui/src/Snackbar/index.ts new file mode 100644 index 00000000..834dd92a --- /dev/null +++ b/ui/src/Snackbar/index.ts @@ -0,0 +1 @@ +export * from './Snackbar'; diff --git a/ui/src/assets/react.svg b/ui/src/assets/react.svg new file mode 100644 index 00000000..6c87de9b --- /dev/null +++ b/ui/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/src/contexts/UIContext.tsx b/ui/src/contexts/UIContext.tsx new file mode 100644 index 00000000..7f7bba10 --- /dev/null +++ b/ui/src/contexts/UIContext.tsx @@ -0,0 +1,21 @@ +import React, { PropsWithChildren, createContext, useState } from 'react'; + +export interface UIState { + showConnectWallet: boolean; + setShowConnectWallet: (show: boolean) => void; +} + +export const UIContext = createContext({ + showConnectWallet: false, + setShowConnectWallet: () => null, +}); + +export const UIProvider: React.FC = ({ children }) => { + const [showConnectWallet, setShowConnectWallet] = useState(false); + + return ( + + {children} + + ); +}; diff --git a/ui/src/contexts/index.ts b/ui/src/contexts/index.ts new file mode 100644 index 00000000..40b50346 --- /dev/null +++ b/ui/src/contexts/index.ts @@ -0,0 +1 @@ +export * from './UIContext'; diff --git a/ui/src/hooks/index.ts b/ui/src/hooks/index.ts new file mode 100644 index 00000000..c248da8b --- /dev/null +++ b/ui/src/hooks/index.ts @@ -0,0 +1 @@ +export * from './useUI'; diff --git a/ui/src/hooks/useUI.ts b/ui/src/hooks/useUI.ts new file mode 100644 index 00000000..a9b83fcf --- /dev/null +++ b/ui/src/hooks/useUI.ts @@ -0,0 +1,4 @@ +import { UIContext, UIState } from '..'; +import { useContext } from 'react'; + +export const useUI = (): UIState => useContext(UIContext); diff --git a/ui/src/index.css b/ui/src/index.css new file mode 100644 index 00000000..c2f5c12e --- /dev/null +++ b/ui/src/index.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: #1A1452; +} \ No newline at end of file diff --git a/ui/src/index.ts b/ui/src/index.ts new file mode 100644 index 00000000..f42dbffd --- /dev/null +++ b/ui/src/index.ts @@ -0,0 +1,16 @@ +export * from './Accounts'; +export * from './Button'; +export * from './Card'; +export * from './ConnectButton'; +export * from './ConnectWallet'; +export * from './InkLayout'; +export * from './LottieEntity'; +export * from './Modal'; +export * from './Navbar'; +export * from './Notifications'; +export * from './NumberInput'; +export * from './Snackbar'; + +export * from './contexts'; +export * from './hooks'; +export * from './types'; diff --git a/ui/src/types/common.ts b/ui/src/types/common.ts new file mode 100644 index 00000000..38aca385 --- /dev/null +++ b/ui/src/types/common.ts @@ -0,0 +1,7 @@ +import { PropsWithChildren } from 'react'; + +export interface ClassNameable { + className?: string; +} + +export type InkComponent = PropsWithChildren; diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts new file mode 100644 index 00000000..d0b93236 --- /dev/null +++ b/ui/src/types/index.ts @@ -0,0 +1 @@ +export * from './common'; diff --git a/ui/src/vite-env.d.ts b/ui/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/ui/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/ui/tailwind.config.js b/ui/tailwind.config.js new file mode 100644 index 00000000..a239636a --- /dev/null +++ b/ui/tailwind.config.js @@ -0,0 +1,53 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./src/**/*.{js,ts,tsx}', '../../ui/**/*.{js,ts,tsx}'], + theme: { + extend: { + fontFamily: { + montserrat: ['Montserrat'], + }, + colors: { + brand: { + 300: '#E2DCFE', + 450: '#D9B7FF', + 500: '#BD83FD', + 550: '#AD63FF', + 600: '#7967EB', + 800: '#5a007e', + 900: '#4030a3', + }, + background: { + 100: '#F2F2F3', + 300: '#D6D8DC', + 700: '#444950', + 800: '#242526', + 850: '#1b1b1d', + 900: '#090909', + }, + success: { + 500: '#00c900', + }, + warning: { + 500: '#ffbe54', + }, + error: { + 500: '#d6502b', + }, + info: { + 500: '#bc83fb', + }, + }, + maxWidth: { + biggest: '1440px', + }, + backgroundImage: { + 'brand-gradient': + 'linear-gradient(244.1deg, #9C45FC 12.55%, #A95DFC 32.31%, #BD83FD 86.37%)', + 'gradient-1': 'linear-gradient(180deg, #FFFFFF 0%, #EFEFEF 100%);', + 'gradient-1-dark': 'linear-gradient(180deg, #1B1B1D 0%, #242526 100%);', + }, + }, + }, + plugins: [], +}; + diff --git a/ui/tsconfig.json b/ui/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/ui/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/ui/tsconfig.node.json b/ui/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/ui/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/ui/vite.config.ts b/ui/vite.config.ts new file mode 100644 index 00000000..bcf5f85a --- /dev/null +++ b/ui/vite.config.ts @@ -0,0 +1,43 @@ +import react from '@vitejs/plugin-react'; +import path from 'node:path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + react(), + dts({ + insertTypesEntry: true, + }), + ], + build: { + sourcemap: true, + lib: { + entry: path.resolve(__dirname, 'src/index.ts'), + name: 'ui', + formats: ['es', 'umd'], + fileName: (format) => `ui.${format}.js`, + }, + rollupOptions: { + external: [ + 'react', + 'react-dom', + 'useink', + 'useink/core', + 'useink/notifications', + 'useink/utils', + ], + output: { + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + useink: 'useink', + 'useink/core': 'useink/core', + 'useink/notifications': 'useink/notifications', + 'useink/utils': 'useink/utils', + }, + }, + }, + }, +}); From 68ca7d832e7605dd38259938360699d6768a13d2 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Fri, 16 Jun 2023 11:31:11 -0400 Subject: [PATCH 02/12] feat: add incrementer ui --- incrementer/frontend/.gitignore | 21 + incrementer/frontend/README.md | 4 + incrementer/frontend/index.html | 13 + incrementer/frontend/package.json | 30 ++ incrementer/frontend/postcss.config.js | 6 + incrementer/frontend/public/logo.svg | 1 + incrementer/frontend/src/App.tsx | 60 +++ incrementer/frontend/src/Global.css | 3 + .../frontend/src/assets/incrementer.json | 398 ++++++++++++++++++ incrementer/frontend/src/constants.ts | 2 + incrementer/frontend/src/main.tsx | 27 ++ incrementer/frontend/src/vite-env.d.ts | 1 + incrementer/frontend/tailwind.config.js | 2 + incrementer/frontend/tsconfig.json | 25 ++ incrementer/frontend/tsconfig.node.json | 10 + incrementer/frontend/vite.config.ts | 7 + package.json | 3 +- 17 files changed, 612 insertions(+), 1 deletion(-) create mode 100644 incrementer/frontend/.gitignore create mode 100644 incrementer/frontend/README.md create mode 100644 incrementer/frontend/index.html create mode 100644 incrementer/frontend/package.json create mode 100644 incrementer/frontend/postcss.config.js create mode 100644 incrementer/frontend/public/logo.svg create mode 100644 incrementer/frontend/src/App.tsx create mode 100644 incrementer/frontend/src/Global.css create mode 100644 incrementer/frontend/src/assets/incrementer.json create mode 100644 incrementer/frontend/src/constants.ts create mode 100644 incrementer/frontend/src/main.tsx create mode 100644 incrementer/frontend/src/vite-env.d.ts create mode 100644 incrementer/frontend/tailwind.config.js create mode 100644 incrementer/frontend/tsconfig.json create mode 100644 incrementer/frontend/tsconfig.node.json create mode 100644 incrementer/frontend/vite.config.ts diff --git a/incrementer/frontend/.gitignore b/incrementer/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/incrementer/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/incrementer/frontend/README.md b/incrementer/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/incrementer/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/incrementer/frontend/index.html b/incrementer/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/incrementer/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/incrementer/frontend/package.json b/incrementer/frontend/package.json new file mode 100644 index 00000000..d3d31477 --- /dev/null +++ b/incrementer/frontend/package.json @@ -0,0 +1,30 @@ +{ + "name": "incrementer", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.0", + "@typescript-eslint/parser": "^5.59.0", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/incrementer/frontend/postcss.config.js b/incrementer/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/incrementer/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/incrementer/frontend/public/logo.svg b/incrementer/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/incrementer/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/incrementer/frontend/src/App.tsx b/incrementer/frontend/src/App.tsx new file mode 100644 index 00000000..b11908a5 --- /dev/null +++ b/incrementer/frontend/src/App.tsx @@ -0,0 +1,60 @@ +import metadata from './assets/incrementer.json'; +import { CONTRACT_ROCOCO_ADDRESS } from './constants'; +import { useState } from 'react'; +import { Button, Card, ConnectButton, InkLayout, NumberInput } from 'ui'; +import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { pickDecoded, shouldDisable } from 'useink/utils'; + +function App() { + const { account } = useWallet(); + const contract = useContract(CONTRACT_ROCOCO_ADDRESS, metadata); + const getSub = useCallSubscription(contract, 'get', [], { + defaultCaller: true, + }); + const [incAmount, setIncAmount] = useState(1); + const inc = useTx(contract, 'inc'); + useTxNotifications(inc); + + return ( + + +

+ {metadata.contract.name.toUpperCase()} +

+ +

+ Current Number:{' '} + {pickDecoded(getSub.result)} +

+ + setIncAmount(v)} + value={incAmount} + min={1} + max={100} + /> + + {account ? ( + + ) : ( + + )} +
+
+ ); +} + +export default App; diff --git a/incrementer/frontend/src/Global.css b/incrementer/frontend/src/Global.css new file mode 100644 index 00000000..bd6213e1 --- /dev/null +++ b/incrementer/frontend/src/Global.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/incrementer/frontend/src/assets/incrementer.json b/incrementer/frontend/src/assets/incrementer.json new file mode 100644 index 00000000..264ffe71 --- /dev/null +++ b/incrementer/frontend/src/assets/incrementer.json @@ -0,0 +1,398 @@ +{ + "source": { + "hash": "0xd03eed0bc4ad710b89b43a76efa9790b909220047e6a3b4d886f1428fcff349f", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "incrementer", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "init_value", + "type": { + "displayName": [ + "i32" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + }, + { + "args": [], + "default": false, + "docs": [], + "label": "new_default", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x61ef7e3e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 5 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 8 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 11 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 12 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 9 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 10 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 3 + }, + "messages": [ + { + "args": [ + { + "label": "by", + "type": { + "displayName": [ + "i32" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [], + "label": "inc", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 1 + }, + "selector": "0x1d32619f" + }, + { + "args": [], + "default": false, + "docs": [], + "label": "get", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x2f865bd9" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "value" + } + ], + "name": "Incrementer" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "i32" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 3, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "array": { + "len": 32, + "type": 7 + } + } + } + }, + { + "id": 7, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 9, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 12, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/incrementer/frontend/src/constants.ts b/incrementer/frontend/src/constants.ts new file mode 100644 index 00000000..ec2b8808 --- /dev/null +++ b/incrementer/frontend/src/constants.ts @@ -0,0 +1,2 @@ +export const CONTRACT_ROCOCO_ADDRESS = + '5GPBKgHopZS3tniuTMfPccr4QARh4uso2ej933Sx7RZrRbMH'; diff --git a/incrementer/frontend/src/main.tsx b/incrementer/frontend/src/main.tsx new file mode 100644 index 00000000..84ac05f0 --- /dev/null +++ b/incrementer/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import App from './App.tsx'; +import './Global.css'; +import metadata from './assets/incrementer.json'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/incrementer/frontend/src/vite-env.d.ts b/incrementer/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/incrementer/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/incrementer/frontend/tailwind.config.js b/incrementer/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/incrementer/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/incrementer/frontend/tsconfig.json b/incrementer/frontend/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/incrementer/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/incrementer/frontend/tsconfig.node.json b/incrementer/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/incrementer/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/incrementer/frontend/vite.config.ts b/incrementer/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/incrementer/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/package.json b/package.json index 1a30146f..18650445 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "lint": "rome check ./*", "lint:fix": "pnpm lint --apply-unsafe", "build:ui": "pnpm --filter ui build", - "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev" + "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", + "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev" }, "packages": [ "ui", From 86d868543b751e980dd0fe56a9d59f1209796802 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Fri, 16 Jun 2023 11:57:41 -0400 Subject: [PATCH 03/12] feat: add basic_contract_caller ui --- README.md | 6 + basic_contract_caller/frontend/.gitignore | 21 + basic_contract_caller/frontend/README.md | 4 + basic_contract_caller/frontend/index.html | 13 + basic_contract_caller/frontend/package.json | 30 ++ .../frontend/postcss.config.js | 6 + .../frontend/public/logo.svg | 1 + basic_contract_caller/frontend/src/App.tsx | 61 +++ basic_contract_caller/frontend/src/Global.css | 7 + basic_contract_caller/frontend/src/Other.tsx | 30 ++ .../src/assets/basic_contract_caller.json | 446 ++++++++++++++++++ .../frontend/src/assets/other_contract.json | 431 +++++++++++++++++ .../frontend/src/constants.ts | 2 + basic_contract_caller/frontend/src/main.tsx | 27 ++ .../frontend/src/vite-env.d.ts | 1 + .../frontend/tailwind.config.js | 2 + basic_contract_caller/frontend/tsconfig.json | 25 + .../frontend/tsconfig.node.json | 10 + basic_contract_caller/frontend/vite.config.ts | 7 + basic_contract_caller/lib.rs | 7 + .../other_contract/Cargo.toml | 2 +- basic_contract_caller/other_contract/lib.rs | 5 + package.json | 5 +- ui/src/Accounts/Accounts.tsx | 4 +- ui/src/Button/Button.tsx | 4 +- ui/src/Link/Link.tsx | 26 + ui/src/Link/index.ts | 1 + ui/src/NumberInput/NumberInput.tsx | 9 +- ui/src/index.ts | 1 + 29 files changed, 1182 insertions(+), 12 deletions(-) create mode 100644 basic_contract_caller/frontend/.gitignore create mode 100644 basic_contract_caller/frontend/README.md create mode 100644 basic_contract_caller/frontend/index.html create mode 100644 basic_contract_caller/frontend/package.json create mode 100644 basic_contract_caller/frontend/postcss.config.js create mode 100644 basic_contract_caller/frontend/public/logo.svg create mode 100644 basic_contract_caller/frontend/src/App.tsx create mode 100644 basic_contract_caller/frontend/src/Global.css create mode 100644 basic_contract_caller/frontend/src/Other.tsx create mode 100644 basic_contract_caller/frontend/src/assets/basic_contract_caller.json create mode 100644 basic_contract_caller/frontend/src/assets/other_contract.json create mode 100644 basic_contract_caller/frontend/src/constants.ts create mode 100644 basic_contract_caller/frontend/src/main.tsx create mode 100644 basic_contract_caller/frontend/src/vite-env.d.ts create mode 100644 basic_contract_caller/frontend/tailwind.config.js create mode 100644 basic_contract_caller/frontend/tsconfig.json create mode 100644 basic_contract_caller/frontend/tsconfig.node.json create mode 100644 basic_contract_caller/frontend/vite.config.ts create mode 100644 ui/src/Link/Link.tsx create mode 100644 ui/src/Link/index.ts diff --git a/README.md b/README.md index a189131a..d61b79d1 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ The `.contract` file combines the Wasm and metadata into one file and can be use 4. Run each example with `pnpm `. e.g. `pnpm flipper` 5. Visit [http://localhost:5173](http://localhost:5173) in your browser. +### Commands + +* `pnpm flipper` +* `pnpm incrementer` +* `pnpm contract_transfer` + All examples are built with [useink](https://use.ink/frontend/overview), a React hooks library built by the ink! team. ## License diff --git a/basic_contract_caller/frontend/.gitignore b/basic_contract_caller/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/basic_contract_caller/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/basic_contract_caller/frontend/README.md b/basic_contract_caller/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/basic_contract_caller/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/basic_contract_caller/frontend/index.html b/basic_contract_caller/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/basic_contract_caller/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/basic_contract_caller/frontend/package.json b/basic_contract_caller/frontend/package.json new file mode 100644 index 00000000..a50868f9 --- /dev/null +++ b/basic_contract_caller/frontend/package.json @@ -0,0 +1,30 @@ +{ + "name": "basic_contract_caller", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.0", + "@typescript-eslint/parser": "^5.59.0", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/basic_contract_caller/frontend/postcss.config.js b/basic_contract_caller/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/basic_contract_caller/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/basic_contract_caller/frontend/public/logo.svg b/basic_contract_caller/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/basic_contract_caller/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/App.tsx b/basic_contract_caller/frontend/src/App.tsx new file mode 100644 index 00000000..20b39b67 --- /dev/null +++ b/basic_contract_caller/frontend/src/App.tsx @@ -0,0 +1,61 @@ +import { Other } from './Other'; +import basicContractMetadata from './assets/basic_contract_caller.json'; +import { BASIC_CONTRACT_ROCOCO_ADDRESS } from './constants'; +import { useEffect } from 'react'; +import { Button, Card, ConnectButton, InkLayout } from 'ui'; +import { useCall, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { isPendingSignature, pickDecoded, shouldDisable } from 'useink/utils'; + +function App() { + const { account } = useWallet(); + const basicContract = useContract( + BASIC_CONTRACT_ROCOCO_ADDRESS, + basicContractMetadata, + ); + const flipAndGet = useTx(basicContract, 'flipAndGet'); + useTxNotifications(flipAndGet); + + const other = useCall(basicContract, 'other'); + + useEffect(() => { + other?.send([], { defaultCaller: true }); + }, [other.send]); + + const otherAddress = pickDecoded(other.result); + + return ( + +
+ +

+ {basicContractMetadata.contract.name.toUpperCase()} +

+ + {account ? ( + + ) : ( + + )} +
+ + {otherAddress && } +
+
+ ); +} + +export default App; diff --git a/basic_contract_caller/frontend/src/Global.css b/basic_contract_caller/frontend/src/Global.css new file mode 100644 index 00000000..c2f5c12e --- /dev/null +++ b/basic_contract_caller/frontend/src/Global.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: #1A1452; +} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/Other.tsx b/basic_contract_caller/frontend/src/Other.tsx new file mode 100644 index 00000000..84f93b69 --- /dev/null +++ b/basic_contract_caller/frontend/src/Other.tsx @@ -0,0 +1,30 @@ +import otherContractMetadata from './assets/other_contract.json'; +import { Card } from 'ui'; +import { useCallSubscription, useContract } from 'useink'; +import { pickDecoded } from 'useink/utils'; + +interface Props { + address: string; +} + +export const Other: React.FC = ({ address }) => { + const otherContract = useContract(address, otherContractMetadata); + const getOtherSub = useCallSubscription(otherContract, 'get', [], { + defaultCaller: true, + }); + + return ( + +

+ {otherContractMetadata.contract.name.toUpperCase()} +

+ +

+ Flipped:{' '} + + {pickDecoded(getOtherSub.result)?.toString()} + +

+
+ ); +}; diff --git a/basic_contract_caller/frontend/src/assets/basic_contract_caller.json b/basic_contract_caller/frontend/src/assets/basic_contract_caller.json new file mode 100644 index 00000000..ca8feda4 --- /dev/null +++ b/basic_contract_caller/frontend/src/assets/basic_contract_caller.json @@ -0,0 +1,446 @@ +{ + "source": { + "hash": "0x116670008181c58c5b65ea9c97a22b2a5eb205372a9428c6ee4560787edd1dbd", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "basic_contract_caller", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "other_contract_code_hash", + "type": { + "displayName": [ + "Hash" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "In order to use the `OtherContract` we first need to **instantiate** it.", + "", + "To do this we will use the uploaded `code_hash` of `OtherContract`." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 4 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 0 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 10 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 12 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 13 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 3 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 11 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 6 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [ + " Using the `ContractRef` we can call all the messages of the `OtherContract` as", + " if they were normal Rust methods (because at the end of the day, they", + " are!)." + ], + "label": "flip_and_get", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 7 + }, + "selector": "0x2e233661" + }, + { + "args": [], + "default": false, + "docs": [ + " Get the address of the other contract after it has been instantiated. We can", + " use this so we can call the other contract on the frontend." + ], + "label": "other", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 9 + }, + "selector": "0x96396e0f" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "account_id" + } + ], + "name": "CallBuilder" + } + }, + "name": "inner" + } + ], + "name": "OtherContractRef" + } + }, + "name": "other_contract" + } + ], + "name": "BasicContractCaller" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 1, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 1, + "type": { + "def": { + "array": { + "len": 32, + "type": 2 + } + } + } + }, + { + "id": 2, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 3, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 1, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 5 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 5 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 6, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 7, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 8 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 8 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 9, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 12, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 13, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/assets/other_contract.json b/basic_contract_caller/frontend/src/assets/other_contract.json new file mode 100644 index 00000000..3c05b931 --- /dev/null +++ b/basic_contract_caller/frontend/src/assets/other_contract.json @@ -0,0 +1,431 @@ +{ + "source": { + "hash": "0x8b9fdab59f82fc96ba8f8bba270e706a3900ec4fe9c92a249263f3fb63f8cb58", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "other_contract", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "init_value", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 6 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 9 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 12 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 13 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 10 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 11 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 3 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [], + "label": "flip", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 1 + }, + "selector": "0x633aa551" + }, + { + "args": [], + "default": false, + "docs": [], + "label": "get", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x2f865bd9" + }, + { + "args": [], + "default": false, + "docs": [], + "label": "account_id", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 5 + }, + "selector": "0x2be79821" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "value" + } + ], + "name": "OtherContract" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 3, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 6 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 6 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 7, + "type": { + "def": { + "array": { + "len": 32, + "type": 8 + } + } + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 9, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 10, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 12, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 13, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/constants.ts b/basic_contract_caller/frontend/src/constants.ts new file mode 100644 index 00000000..54cc8400 --- /dev/null +++ b/basic_contract_caller/frontend/src/constants.ts @@ -0,0 +1,2 @@ +export const BASIC_CONTRACT_ROCOCO_ADDRESS = + '5EnufwqqxnkWT6hc1LgjYWQGUsqQCtcr5192K2HuQJtRJgCi'; diff --git a/basic_contract_caller/frontend/src/main.tsx b/basic_contract_caller/frontend/src/main.tsx new file mode 100644 index 00000000..2ce2c515 --- /dev/null +++ b/basic_contract_caller/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import App from './App.tsx'; +import './Global.css'; +import metadata from './assets/basic_contract_caller.json'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/basic_contract_caller/frontend/src/vite-env.d.ts b/basic_contract_caller/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/basic_contract_caller/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/basic_contract_caller/frontend/tailwind.config.js b/basic_contract_caller/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/basic_contract_caller/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/basic_contract_caller/frontend/tsconfig.json b/basic_contract_caller/frontend/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/basic_contract_caller/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/basic_contract_caller/frontend/tsconfig.node.json b/basic_contract_caller/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/basic_contract_caller/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/basic_contract_caller/frontend/vite.config.ts b/basic_contract_caller/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/basic_contract_caller/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/basic_contract_caller/lib.rs b/basic_contract_caller/lib.rs index f988caab..14df01c2 100755 --- a/basic_contract_caller/lib.rs +++ b/basic_contract_caller/lib.rs @@ -37,5 +37,12 @@ mod basic_contract_caller { self.other_contract.flip(); self.other_contract.get() } + + /// Get the address of the other contract after it has been instantiated. We can + /// use this so we can call the other contract on the frontend. + #[ink(message)] + pub fn other(&mut self) -> AccountId { + self.other_contract.account_id() + } } } diff --git a/basic_contract_caller/other_contract/Cargo.toml b/basic_contract_caller/other_contract/Cargo.toml index 70a068ed..ed9500f7 100755 --- a/basic_contract_caller/other_contract/Cargo.toml +++ b/basic_contract_caller/other_contract/Cargo.toml @@ -12,7 +12,7 @@ scale = { package = "parity-scale-codec", version = "3", default-features = fals scale-info = { version = "2.5", default-features = false, features = ["derive"], optional = true } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { version = "4.2" } [lib] path = "lib.rs" diff --git a/basic_contract_caller/other_contract/lib.rs b/basic_contract_caller/other_contract/lib.rs index 53e51019..00eabdb4 100755 --- a/basic_contract_caller/other_contract/lib.rs +++ b/basic_contract_caller/other_contract/lib.rs @@ -29,5 +29,10 @@ mod other_contract { pub fn get(&self) -> bool { self.value } + + #[ink(message)] + pub fn account_id(&self) -> AccountId { + self.env().account_id() + } } } diff --git a/package.json b/package.json index 18650445..955eda91 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "lint:fix": "pnpm lint --apply-unsafe", "build:ui": "pnpm --filter ui build", "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", - "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev" + "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev", + "basic_contract_caller": "pnpm --filter ui dev & pnpm --filter basic_contract_caller dev" }, "packages": [ "ui", @@ -21,7 +22,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "useink": "^1.5.1" + "useink": "^1.7.5" }, "devDependencies": { "tailwindcss": "^3.3.2", diff --git a/ui/src/Accounts/Accounts.tsx b/ui/src/Accounts/Accounts.tsx index 8c9fd4e8..183c686b 100644 --- a/ui/src/Accounts/Accounts.tsx +++ b/ui/src/Accounts/Accounts.tsx @@ -15,7 +15,7 @@ export const Accounts: React.FC = ({ className }) => { return (
@@ -28,7 +28,7 @@ export const Accounts: React.FC = ({ className }) => {
= ({ ...rest }) => { const classes = classNames( - 'bg-brand-900 hover:opacity-80 transition ease-in-out px-6 py-2 border-none disabled:text-opacity-70', - 'text-base tracking-wide font-semibold rounded-full disabled:opacity-50 disabled:hover:bg-opacity-50', + 'bg-brand-900 hover:bg-brand-800 transition ease-in-out px-6 py-2 border-none', + 'text-base tracking-wide font-semibold rounded-full disabled:bg-brand-450', 'focus:ring-none disabled:cursor-not-allowed focus:outline-none focus:ring-0 focus:ring-offset-0 text-white', className, ); diff --git a/ui/src/Link/Link.tsx b/ui/src/Link/Link.tsx new file mode 100644 index 00000000..347d5cb9 --- /dev/null +++ b/ui/src/Link/Link.tsx @@ -0,0 +1,26 @@ +import classNames from 'classnames'; +import React, { + AnchorHTMLAttributes, + DetailedHTMLProps, + PropsWithChildren, +} from 'react'; + +type LinkHTMLProps = DetailedHTMLProps< + AnchorHTMLAttributes, + HTMLAnchorElement +>; + +type LinkProps = PropsWithChildren; + +export const Link: React.FC = ({ children, className, ...rest }) => { + const classes = classNames( + 'underline text-sm text-brand-300 font-semibold transition duration-25 hover:text-brand-450', + className, + ); + + return ( + + {children} + + ); +}; diff --git a/ui/src/Link/index.ts b/ui/src/Link/index.ts new file mode 100644 index 00000000..3db78f51 --- /dev/null +++ b/ui/src/Link/index.ts @@ -0,0 +1 @@ +export * from './Link'; diff --git a/ui/src/NumberInput/NumberInput.tsx b/ui/src/NumberInput/NumberInput.tsx index f3ae7cfd..535f104d 100644 --- a/ui/src/NumberInput/NumberInput.tsx +++ b/ui/src/NumberInput/NumberInput.tsx @@ -13,12 +13,11 @@ type Props = ClassNameable & { }; const COMMON_CLASSES = [ - 'bg-brand-500 text-white border-none focuse:outline-none focus-visible:outline-none', - 'focus:outline-none disabled:text-white/80 py-4 flex items-center justify-center', + 'bg-brand-500 disabled:bg-brand-450 text-white border-none focuse:outline-none focus-visible:outline-none', + 'focus:outline-none disabled:text-white/80 py-4 flex items-center justify-center disabled:cursor-not-allowed', ].join(' '); -const BUTTON_CLASSES = - 'hover:bg-brand-800 disabled:bg-brand-450 disabled:cursor-not-allowed'; +const BUTTON_CLASSES = 'hover:bg-brand-900'; export const NumberInput: React.FC = ({ value, @@ -52,7 +51,7 @@ export const NumberInput: React.FC = ({ Date: Fri, 16 Jun 2023 12:07:20 -0400 Subject: [PATCH 04/12] feat: add contract_transfer example --- README.md | 3 +- contract-transfer/codegen.rs | 2775 ----------------- contract-transfer/foo | 12 - contract-transfer/foo.rs | 306 -- .../.gitignore | 0 .../Cargo.toml | 0 contract_transfer/frontend/.gitignore | 21 + contract_transfer/frontend/README.md | 4 + contract_transfer/frontend/index.html | 13 + contract_transfer/frontend/package.json | 30 + contract_transfer/frontend/postcss.config.js | 6 + contract_transfer/frontend/public/logo.svg | 1 + contract_transfer/frontend/src/App.tsx | 120 + contract_transfer/frontend/src/Global.css | 3 + .../src/assets/contract_transfer.json | 333 ++ contract_transfer/frontend/src/constants.ts | 2 + contract_transfer/frontend/src/main.tsx | 27 + contract_transfer/frontend/src/vite-env.d.ts | 1 + contract_transfer/frontend/tailwind.config.js | 2 + contract_transfer/frontend/tsconfig.json | 25 + contract_transfer/frontend/tsconfig.node.json | 10 + contract_transfer/frontend/vite.config.ts | 7 + .../lib.rs | 0 package.json | 5 +- 24 files changed, 610 insertions(+), 3096 deletions(-) delete mode 100644 contract-transfer/codegen.rs delete mode 100644 contract-transfer/foo delete mode 100644 contract-transfer/foo.rs rename {contract-transfer => contract_transfer}/.gitignore (100%) rename {contract-transfer => contract_transfer}/Cargo.toml (100%) create mode 100644 contract_transfer/frontend/.gitignore create mode 100644 contract_transfer/frontend/README.md create mode 100644 contract_transfer/frontend/index.html create mode 100644 contract_transfer/frontend/package.json create mode 100644 contract_transfer/frontend/postcss.config.js create mode 100644 contract_transfer/frontend/public/logo.svg create mode 100644 contract_transfer/frontend/src/App.tsx create mode 100644 contract_transfer/frontend/src/Global.css create mode 100644 contract_transfer/frontend/src/assets/contract_transfer.json create mode 100644 contract_transfer/frontend/src/constants.ts create mode 100644 contract_transfer/frontend/src/main.tsx create mode 100644 contract_transfer/frontend/src/vite-env.d.ts create mode 100644 contract_transfer/frontend/tailwind.config.js create mode 100644 contract_transfer/frontend/tsconfig.json create mode 100644 contract_transfer/frontend/tsconfig.node.json create mode 100644 contract_transfer/frontend/vite.config.ts rename {contract-transfer => contract_transfer}/lib.rs (100%) diff --git a/README.md b/README.md index d61b79d1..42b612b3 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,10 @@ The `.contract` file combines the Wasm and metadata into one file and can be use ### Commands +* `pnpm basic_contract_caller` +* `pnpm contract_transfer` * `pnpm flipper` * `pnpm incrementer` -* `pnpm contract_transfer` All examples are built with [useink](https://use.ink/frontend/overview), a React hooks library built by the ink! team. diff --git a/contract-transfer/codegen.rs b/contract-transfer/codegen.rs deleted file mode 100644 index 484940f0..00000000 --- a/contract-transfer/codegen.rs +++ /dev/null @@ -1,2775 +0,0 @@ -#[allow(dead_code, unused_imports, non_camel_case_types)] -pub mod api { - use super::api as root_mod; - - pub static PALLETS: [&str; 8usize] = ["System", "RandomnessCollectiveFlip", "Timestamp", "Balances", "Authorship", "TransactionPayment", "Sudo", "Contracts", ]; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Event { #[codec(index = 0)] System(system::Event), #[codec(index = 3)] Balances(balances::Event), #[codec(index = 5)] TransactionPayment(transaction_payment::Event), #[codec(index = 6)] Sudo(sudo::Event), #[codec(index = 7)] Contracts(contracts::Event) } - - pub mod system { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct FillBlock { - pub ratio: runtime_types::sp_arithmetic::per_things::Perbill, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Remark { - pub remark: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::CompactAs, ::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetHeapPages { - pub pages: ::core::primitive::u64, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetCode { - pub code: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetCodeWithoutChecks { - pub code: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetStorage { - pub items: ::std::vec::Vec<(::std::vec::Vec<::core::primitive::u8>, ::std::vec::Vec<::core::primitive::u8>, )>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct KillStorage { - pub keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct KillPrefix { - pub prefix: ::std::vec::Vec<::core::primitive::u8>, - pub subkeys: ::core::primitive::u32, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct RemarkWithEvent { - pub remark: ::std::vec::Vec<::core::primitive::u8>, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "A dispatch that will fill the block weight up to the given ratio."] - pub fn fill_block(&self, ratio: runtime_types::sp_arithmetic::per_things::Perbill) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "fill_block", FillBlock { ratio }, [48u8, 18u8, 205u8, 90u8, 222u8, 4u8, 20u8, 251u8, 173u8, 76u8, 167u8, 4u8, 83u8, 203u8, 160u8, 89u8, 132u8, 218u8, 191u8, 145u8, 130u8, 245u8, 177u8, 201u8, 169u8, 129u8, 173u8, 105u8, 88u8, 45u8, 136u8, 191u8, ]) } - #[doc = "Make some on-chain remark."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(1)`"] - #[doc = "# "] - pub fn remark(&self, remark: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "remark", Remark { remark }, [101u8, 80u8, 195u8, 226u8, 224u8, 247u8, 60u8, 128u8, 3u8, 101u8, 51u8, 147u8, 96u8, 126u8, 76u8, 230u8, 194u8, 227u8, 191u8, 73u8, 160u8, 146u8, 87u8, 147u8, 243u8, 28u8, 228u8, 116u8, 224u8, 181u8, 129u8, 160u8, ]) } - #[doc = "Set the number of pages in the WebAssembly environment's heap."] - pub fn set_heap_pages(&self, pages: ::core::primitive::u64) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "set_heap_pages", SetHeapPages { pages }, [43u8, 103u8, 128u8, 49u8, 156u8, 136u8, 11u8, 204u8, 80u8, 6u8, 244u8, 86u8, 171u8, 44u8, 140u8, 225u8, 142u8, 198u8, 43u8, 87u8, 26u8, 45u8, 125u8, 222u8, 165u8, 254u8, 172u8, 158u8, 39u8, 178u8, 86u8, 87u8, ]) } - #[doc = "Set the new runtime code."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(C + S)` where `C` length of `code` and `S` complexity of `can_set_code`"] - #[doc = "- 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is"] - #[doc = " expensive)."] - #[doc = "- 1 storage write (codec `O(C)`)."] - #[doc = "- 1 digest item."] - #[doc = "- 1 event."] - #[doc = "The weight of this function is dependent on the runtime, but generally this is very"] - #[doc = "expensive. We will treat this as a full block."] - #[doc = "# "] - pub fn set_code(&self, code: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "set_code", SetCode { code }, [27u8, 104u8, 244u8, 205u8, 188u8, 254u8, 121u8, 13u8, 106u8, 120u8, 244u8, 108u8, 97u8, 84u8, 100u8, 68u8, 26u8, 69u8, 93u8, 128u8, 107u8, 4u8, 3u8, 142u8, 13u8, 134u8, 196u8, 62u8, 113u8, 181u8, 14u8, 40u8, ]) } - #[doc = "Set the new runtime code without doing any checks of the given `code`."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(C)` where `C` length of `code`"] - #[doc = "- 1 storage write (codec `O(C)`)."] - #[doc = "- 1 digest item."] - #[doc = "- 1 event."] - #[doc = "The weight of this function is dependent on the runtime. We will treat this as a full"] - #[doc = "block. # "] - pub fn set_code_without_checks(&self, code: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "set_code_without_checks", SetCodeWithoutChecks { code }, [102u8, 160u8, 125u8, 235u8, 30u8, 23u8, 45u8, 239u8, 112u8, 148u8, 159u8, 158u8, 42u8, 93u8, 206u8, 94u8, 80u8, 250u8, 66u8, 195u8, 60u8, 40u8, 142u8, 169u8, 183u8, 80u8, 80u8, 96u8, 3u8, 231u8, 99u8, 216u8, ]) } - #[doc = "Set some items of storage."] - pub fn set_storage(&self, items: ::std::vec::Vec<(::std::vec::Vec<::core::primitive::u8>, ::std::vec::Vec<::core::primitive::u8>, )>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "set_storage", SetStorage { items }, [74u8, 43u8, 106u8, 255u8, 50u8, 151u8, 192u8, 155u8, 14u8, 90u8, 19u8, 45u8, 165u8, 16u8, 235u8, 242u8, 21u8, 131u8, 33u8, 172u8, 119u8, 78u8, 140u8, 10u8, 107u8, 202u8, 122u8, 235u8, 181u8, 191u8, 22u8, 116u8, ]) } - #[doc = "Kill some items from storage."] - pub fn kill_storage(&self, keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "kill_storage", KillStorage { keys }, [174u8, 174u8, 13u8, 174u8, 75u8, 138u8, 128u8, 235u8, 222u8, 216u8, 85u8, 18u8, 198u8, 1u8, 138u8, 70u8, 19u8, 108u8, 209u8, 41u8, 228u8, 67u8, 130u8, 230u8, 160u8, 207u8, 11u8, 180u8, 139u8, 242u8, 41u8, 15u8, ]) } - #[doc = "Kill all storage items with a key that starts with the given prefix."] - #[doc = ""] - #[doc = "**NOTE:** We rely on the Root origin to provide us the number of subkeys under"] - #[doc = "the prefix we are removing to accurately calculate the weight of this function."] - pub fn kill_prefix(&self, prefix: ::std::vec::Vec<::core::primitive::u8>, subkeys: ::core::primitive::u32) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "kill_prefix", KillPrefix { prefix, subkeys }, [203u8, 116u8, 217u8, 42u8, 154u8, 215u8, 77u8, 217u8, 13u8, 22u8, 193u8, 2u8, 128u8, 115u8, 179u8, 115u8, 187u8, 218u8, 129u8, 34u8, 80u8, 4u8, 173u8, 120u8, 92u8, 35u8, 237u8, 112u8, 201u8, 207u8, 200u8, 48u8, ]) } - #[doc = "Make some on-chain remark and emit event."] - pub fn remark_with_event(&self, remark: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("System", "remark_with_event", RemarkWithEvent { remark }, [123u8, 225u8, 180u8, 179u8, 144u8, 74u8, 27u8, 85u8, 101u8, 75u8, 134u8, 44u8, 181u8, 25u8, 183u8, 158u8, 14u8, 213u8, 56u8, 225u8, 136u8, 88u8, 26u8, 114u8, 178u8, 43u8, 176u8, 43u8, 240u8, 84u8, 116u8, 46u8, ]) } - } - } - - #[doc = "Event for the System pallet."] - pub type Event = runtime_types::frame_system::pallet::Event; - - pub mod events { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "An extrinsic completed successfully."] - pub struct ExtrinsicSuccess { - pub dispatch_info: runtime_types::frame_support::weights::DispatchInfo, - } - - impl ::subxt::events::StaticEvent for ExtrinsicSuccess { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicSuccess"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "An extrinsic failed."] - pub struct ExtrinsicFailed { - pub dispatch_error: runtime_types::sp_runtime::DispatchError, - pub dispatch_info: runtime_types::frame_support::weights::DispatchInfo, - } - - impl ::subxt::events::StaticEvent for ExtrinsicFailed { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicFailed"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "`:code` was updated."] - pub struct CodeUpdated; - - impl ::subxt::events::StaticEvent for CodeUpdated { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "CodeUpdated"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A new account was created."] - pub struct NewAccount { - pub account: ::subxt::ext::sp_core::crypto::AccountId32, - } - - impl ::subxt::events::StaticEvent for NewAccount { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "NewAccount"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "An account was reaped."] - pub struct KilledAccount { - pub account: ::subxt::ext::sp_core::crypto::AccountId32, - } - - impl ::subxt::events::StaticEvent for KilledAccount { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "KilledAccount"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "On on-chain remark happened."] - pub struct Remarked { - pub sender: ::subxt::ext::sp_core::crypto::AccountId32, - pub hash: ::subxt::ext::sp_core::H256, - } - - impl ::subxt::events::StaticEvent for Remarked { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "Remarked"; - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " The full account information for a particular account ID."] - pub fn account(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::crypto::AccountId32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "Account", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Blake2_128Concat)], [176u8, 187u8, 21u8, 220u8, 159u8, 204u8, 127u8, 14u8, 21u8, 69u8, 77u8, 114u8, 230u8, 141u8, 107u8, 79u8, 23u8, 16u8, 174u8, 243u8, 252u8, 42u8, 65u8, 120u8, 229u8, 38u8, 210u8, 255u8, 22u8, 40u8, 109u8, 223u8, ]) } - #[doc = " The full account information for a particular account ID."] - pub fn account_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "Account", Vec::new(), [176u8, 187u8, 21u8, 220u8, 159u8, 204u8, 127u8, 14u8, 21u8, 69u8, 77u8, 114u8, 230u8, 141u8, 107u8, 79u8, 23u8, 16u8, 174u8, 243u8, 252u8, 42u8, 65u8, 120u8, 229u8, 38u8, 210u8, 255u8, 22u8, 40u8, 109u8, 223u8, ]) } - #[doc = " Total extrinsics count for the current block."] - pub fn extrinsic_count(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u32>, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "ExtrinsicCount", vec![], [223u8, 60u8, 201u8, 120u8, 36u8, 44u8, 180u8, 210u8, 242u8, 53u8, 222u8, 154u8, 123u8, 176u8, 249u8, 8u8, 225u8, 28u8, 232u8, 4u8, 136u8, 41u8, 151u8, 82u8, 189u8, 149u8, 49u8, 166u8, 139u8, 9u8, 163u8, 231u8, ]) } - #[doc = " The current weight for the block."] - pub fn block_weight(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "BlockWeight", vec![], [91u8, 211u8, 177u8, 36u8, 147u8, 249u8, 55u8, 164u8, 48u8, 49u8, 55u8, 11u8, 121u8, 193u8, 103u8, 69u8, 38u8, 142u8, 148u8, 36u8, 137u8, 41u8, 115u8, 195u8, 31u8, 174u8, 163u8, 125u8, 69u8, 5u8, 94u8, 79u8, ]) } - #[doc = " Total length (in bytes) for all extrinsics put together, for the current block."] - pub fn all_extrinsics_len(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u32>, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "AllExtrinsicsLen", vec![], [202u8, 145u8, 209u8, 225u8, 40u8, 220u8, 174u8, 74u8, 93u8, 164u8, 254u8, 248u8, 254u8, 192u8, 32u8, 117u8, 96u8, 149u8, 53u8, 145u8, 219u8, 64u8, 234u8, 18u8, 217u8, 200u8, 203u8, 141u8, 145u8, 28u8, 134u8, 60u8, ]) } - #[doc = " Map of block numbers to block hashes."] - pub fn block_hash(&self, _0: impl ::std::borrow::Borrow<::core::primitive::u32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::subxt::ext::sp_core::H256>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "BlockHash", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Twox64Concat)], [50u8, 112u8, 176u8, 239u8, 175u8, 18u8, 205u8, 20u8, 241u8, 195u8, 21u8, 228u8, 186u8, 57u8, 200u8, 25u8, 38u8, 44u8, 106u8, 20u8, 168u8, 80u8, 76u8, 235u8, 12u8, 51u8, 137u8, 149u8, 200u8, 4u8, 220u8, 237u8, ]) } - #[doc = " Map of block numbers to block hashes."] - pub fn block_hash_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::subxt::ext::sp_core::H256>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "BlockHash", Vec::new(), [50u8, 112u8, 176u8, 239u8, 175u8, 18u8, 205u8, 20u8, 241u8, 195u8, 21u8, 228u8, 186u8, 57u8, 200u8, 25u8, 38u8, 44u8, 106u8, 20u8, 168u8, 80u8, 76u8, 235u8, 12u8, 51u8, 137u8, 149u8, 200u8, 4u8, 220u8, 237u8, ]) } - #[doc = " Extrinsics data for the current block (maps an extrinsic's index to its data)."] - pub fn extrinsic_data(&self, _0: impl ::std::borrow::Borrow<::core::primitive::u32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::std::vec::Vec<::core::primitive::u8>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "ExtrinsicData", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Twox64Concat)], [210u8, 224u8, 211u8, 186u8, 118u8, 210u8, 185u8, 194u8, 238u8, 211u8, 254u8, 73u8, 67u8, 184u8, 31u8, 229u8, 168u8, 125u8, 98u8, 23u8, 241u8, 59u8, 49u8, 86u8, 126u8, 9u8, 114u8, 163u8, 160u8, 62u8, 50u8, 67u8, ]) } - #[doc = " Extrinsics data for the current block (maps an extrinsic's index to its data)."] - pub fn extrinsic_data_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::std::vec::Vec<::core::primitive::u8>>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "ExtrinsicData", Vec::new(), [210u8, 224u8, 211u8, 186u8, 118u8, 210u8, 185u8, 194u8, 238u8, 211u8, 254u8, 73u8, 67u8, 184u8, 31u8, 229u8, 168u8, 125u8, 98u8, 23u8, 241u8, 59u8, 49u8, 86u8, 126u8, 9u8, 114u8, 163u8, 160u8, 62u8, 50u8, 67u8, ]) } - #[doc = " The current block number being processed. Set by `execute_block`."] - pub fn number(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u32>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "Number", vec![], [228u8, 96u8, 102u8, 190u8, 252u8, 130u8, 239u8, 172u8, 126u8, 235u8, 246u8, 139u8, 208u8, 15u8, 88u8, 245u8, 141u8, 232u8, 43u8, 204u8, 36u8, 87u8, 211u8, 141u8, 187u8, 68u8, 236u8, 70u8, 193u8, 235u8, 164u8, 191u8, ]) } - #[doc = " Hash of the previous block."] - pub fn parent_hash(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::subxt::ext::sp_core::H256>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "ParentHash", vec![], [232u8, 206u8, 177u8, 119u8, 38u8, 57u8, 233u8, 50u8, 225u8, 49u8, 169u8, 176u8, 210u8, 51u8, 231u8, 176u8, 234u8, 186u8, 188u8, 112u8, 15u8, 152u8, 195u8, 232u8, 201u8, 97u8, 208u8, 249u8, 9u8, 163u8, 69u8, 36u8, ]) } - #[doc = " Digest of the current block, also part of the block header."] - pub fn digest(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "Digest", vec![], [83u8, 141u8, 200u8, 132u8, 182u8, 55u8, 197u8, 122u8, 13u8, 159u8, 31u8, 42u8, 60u8, 191u8, 89u8, 221u8, 242u8, 47u8, 199u8, 213u8, 48u8, 216u8, 131u8, 168u8, 245u8, 82u8, 56u8, 190u8, 62u8, 69u8, 96u8, 37u8, ]) } - #[doc = " Events deposited for the current block."] - #[doc = ""] - #[doc = " NOTE: The item is unbound and should therefore never be read on chain."] - #[doc = " It could otherwise inflate the PoV size of a block."] - #[doc = ""] - #[doc = " Events have a large in-memory size. Box the events to not go out-of-memory"] - #[doc = " just in case someone still reads them from within the runtime."] - pub fn events(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::std::vec::Vec>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "Events", vec![], [155u8, 23u8, 131u8, 160u8, 247u8, 184u8, 188u8, 91u8, 5u8, 245u8, 50u8, 182u8, 148u8, 189u8, 4u8, 241u8, 226u8, 55u8, 40u8, 150u8, 106u8, 102u8, 39u8, 77u8, 73u8, 128u8, 24u8, 217u8, 199u8, 22u8, 147u8, 233u8, ]) } - #[doc = " The number of events in the `Events` list."] - pub fn event_count(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u32>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "EventCount", vec![], [236u8, 93u8, 90u8, 177u8, 250u8, 211u8, 138u8, 187u8, 26u8, 208u8, 203u8, 113u8, 221u8, 233u8, 227u8, 9u8, 249u8, 25u8, 202u8, 185u8, 161u8, 144u8, 167u8, 104u8, 127u8, 187u8, 38u8, 18u8, 52u8, 61u8, 66u8, 112u8, ]) } - #[doc = " Mapping between a topic (represented by T::Hash) and a vector of indexes"] - #[doc = " of events in the `>` list."] - #[doc = ""] - #[doc = " All topic vectors have deterministic storage locations depending on the topic. This"] - #[doc = " allows light-clients to leverage the changes trie storage tracking mechanism and"] - #[doc = " in case of changes fetch the list of events of interest."] - #[doc = ""] - #[doc = " The value has the type `(T::BlockNumber, EventIndex)` because if we used only just"] - #[doc = " the `EventIndex` then in case if the topic has the same contents on the next block"] - #[doc = " no notification will be triggered thus the event might be lost."] - pub fn event_topics(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::H256>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::std::vec::Vec<(::core::primitive::u32, ::core::primitive::u32, )>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "EventTopics", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Blake2_128Concat)], [205u8, 90u8, 142u8, 190u8, 176u8, 37u8, 94u8, 82u8, 98u8, 1u8, 129u8, 63u8, 246u8, 101u8, 130u8, 58u8, 216u8, 16u8, 139u8, 196u8, 154u8, 111u8, 110u8, 178u8, 24u8, 44u8, 183u8, 176u8, 232u8, 82u8, 223u8, 38u8, ]) } - #[doc = " Mapping between a topic (represented by T::Hash) and a vector of indexes"] - #[doc = " of events in the `>` list."] - #[doc = ""] - #[doc = " All topic vectors have deterministic storage locations depending on the topic. This"] - #[doc = " allows light-clients to leverage the changes trie storage tracking mechanism and"] - #[doc = " in case of changes fetch the list of events of interest."] - #[doc = ""] - #[doc = " The value has the type `(T::BlockNumber, EventIndex)` because if we used only just"] - #[doc = " the `EventIndex` then in case if the topic has the same contents on the next block"] - #[doc = " no notification will be triggered thus the event might be lost."] - pub fn event_topics_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::std::vec::Vec<(::core::primitive::u32, ::core::primitive::u32, )>>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("System", "EventTopics", Vec::new(), [205u8, 90u8, 142u8, 190u8, 176u8, 37u8, 94u8, 82u8, 98u8, 1u8, 129u8, 63u8, 246u8, 101u8, 130u8, 58u8, 216u8, 16u8, 139u8, 196u8, 154u8, 111u8, 110u8, 178u8, 24u8, 44u8, 183u8, 176u8, 232u8, 82u8, 223u8, 38u8, ]) } - #[doc = " Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened."] - pub fn last_runtime_upgrade(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "LastRuntimeUpgrade", vec![], [52u8, 37u8, 117u8, 111u8, 57u8, 130u8, 196u8, 14u8, 99u8, 77u8, 91u8, 126u8, 178u8, 249u8, 78u8, 34u8, 9u8, 194u8, 92u8, 105u8, 113u8, 81u8, 185u8, 127u8, 245u8, 184u8, 60u8, 29u8, 234u8, 182u8, 96u8, 196u8, ]) } - #[doc = " True if we have upgraded so that `type RefCount` is `u32`. False (default) if not."] - pub fn upgraded_to_u32_ref_count(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::bool>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "UpgradedToU32RefCount", vec![], [171u8, 88u8, 244u8, 92u8, 122u8, 67u8, 27u8, 18u8, 59u8, 175u8, 175u8, 178u8, 20u8, 150u8, 213u8, 59u8, 222u8, 141u8, 32u8, 107u8, 3u8, 114u8, 83u8, 250u8, 180u8, 233u8, 152u8, 54u8, 187u8, 99u8, 131u8, 204u8, ]) } - #[doc = " True if we have upgraded so that AccountInfo contains three types of `RefCount`. False"] - #[doc = " (default) if not."] - pub fn upgraded_to_triple_ref_count(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::bool>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "UpgradedToTripleRefCount", vec![], [90u8, 33u8, 56u8, 86u8, 90u8, 101u8, 89u8, 133u8, 203u8, 56u8, 201u8, 210u8, 244u8, 232u8, 150u8, 18u8, 51u8, 105u8, 14u8, 230u8, 103u8, 155u8, 246u8, 99u8, 53u8, 207u8, 225u8, 128u8, 186u8, 76u8, 40u8, 185u8, ]) } - #[doc = " The execution phase of the block."] - pub fn execution_phase(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("System", "ExecutionPhase", vec![], [230u8, 183u8, 221u8, 135u8, 226u8, 223u8, 55u8, 104u8, 138u8, 224u8, 103u8, 156u8, 222u8, 99u8, 203u8, 199u8, 164u8, 168u8, 193u8, 133u8, 201u8, 155u8, 63u8, 95u8, 17u8, 206u8, 165u8, 123u8, 161u8, 33u8, 172u8, 93u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " Block & extrinsics weights: base values and limits."] - pub fn block_weights(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType> { ::subxt::constants::StaticConstantAddress::new("System", "BlockWeights", [153u8, 164u8, 86u8, 79u8, 97u8, 114u8, 248u8, 181u8, 179u8, 186u8, 214u8, 124u8, 215u8, 96u8, 116u8, 109u8, 215u8, 182u8, 61u8, 10u8, 77u8, 74u8, 29u8, 125u8, 131u8, 111u8, 249u8, 208u8, 233u8, 170u8, 11u8, 14u8, ]) } - #[doc = " The maximum length of a block (in bytes)."] - pub fn block_length(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType> { ::subxt::constants::StaticConstantAddress::new("System", "BlockLength", [116u8, 184u8, 225u8, 228u8, 207u8, 203u8, 4u8, 220u8, 234u8, 198u8, 150u8, 108u8, 205u8, 87u8, 194u8, 131u8, 229u8, 51u8, 140u8, 4u8, 47u8, 12u8, 200u8, 144u8, 153u8, 62u8, 51u8, 39u8, 138u8, 205u8, 203u8, 236u8, ]) } - #[doc = " Maximum number of block number to block hash mappings to keep (oldest pruned first)."] - pub fn block_hash_count(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u32>> { ::subxt::constants::StaticConstantAddress::new("System", "BlockHashCount", [98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, 203u8, 100u8, 41u8, 145u8, ]) } - #[doc = " The weight of runtime database operations the runtime can invoke."] - pub fn db_weight(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType> { ::subxt::constants::StaticConstantAddress::new("System", "DbWeight", [124u8, 162u8, 190u8, 149u8, 49u8, 177u8, 162u8, 231u8, 62u8, 167u8, 199u8, 181u8, 43u8, 232u8, 185u8, 116u8, 195u8, 51u8, 233u8, 223u8, 20u8, 129u8, 246u8, 13u8, 65u8, 180u8, 64u8, 9u8, 157u8, 59u8, 245u8, 118u8, ]) } - #[doc = " Get the chain's current version."] - pub fn version(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType> { ::subxt::constants::StaticConstantAddress::new("System", "Version", [93u8, 98u8, 57u8, 243u8, 229u8, 8u8, 234u8, 231u8, 72u8, 230u8, 139u8, 47u8, 63u8, 181u8, 17u8, 2u8, 220u8, 231u8, 104u8, 237u8, 185u8, 143u8, 165u8, 253u8, 188u8, 76u8, 147u8, 12u8, 170u8, 26u8, 74u8, 200u8, ]) } - #[doc = " The designated SS85 prefix of this chain."] - #[doc = ""] - #[doc = " This replaces the \"ss58Format\" property declared in the chain spec. Reason is"] - #[doc = " that the runtime should know about the prefix in order to make use of it as"] - #[doc = " an identifier of the chain."] - pub fn ss58_prefix(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u16>> { ::subxt::constants::StaticConstantAddress::new("System", "SS58Prefix", [116u8, 33u8, 2u8, 170u8, 181u8, 147u8, 171u8, 169u8, 167u8, 227u8, 41u8, 144u8, 11u8, 236u8, 82u8, 100u8, 74u8, 60u8, 184u8, 72u8, 169u8, 90u8, 208u8, 135u8, 15u8, 117u8, 10u8, 123u8, 128u8, 193u8, 29u8, 70u8, ]) } - } - } - } - - pub mod randomness_collective_flip { - use super::root_mod; - use super::runtime_types; - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " Series of block headers from the last 81 blocks that acts as random seed material. This"] - #[doc = " is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of"] - #[doc = " the oldest hash."] - pub fn random_material(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("RandomnessCollectiveFlip", "RandomMaterial", vec![], [152u8, 126u8, 73u8, 88u8, 54u8, 147u8, 6u8, 19u8, 214u8, 40u8, 159u8, 30u8, 236u8, 61u8, 240u8, 65u8, 178u8, 94u8, 146u8, 152u8, 135u8, 252u8, 160u8, 86u8, 123u8, 114u8, 251u8, 140u8, 98u8, 143u8, 217u8, 242u8, ]) } - } - } - } - - pub mod timestamp { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Set { - #[codec(compact)] pub now: ::core::primitive::u64, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "Set the current time."] - #[doc = ""] - #[doc = "This call should be invoked exactly once per block. It will panic at the finalization"] - #[doc = "phase, if this call hasn't been invoked by that time."] - #[doc = ""] - #[doc = "The timestamp should be greater than the previous one by the amount specified by"] - #[doc = "`MinimumPeriod`."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be `Inherent`."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)"] - #[doc = "- 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in"] - #[doc = " `on_finalize`)"] - #[doc = "- 1 event handler `on_timestamp_set`. Must be `O(1)`."] - #[doc = "# "] - pub fn set(&self, now: ::core::primitive::u64) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Timestamp", "set", Set { now }, [6u8, 97u8, 172u8, 236u8, 118u8, 238u8, 228u8, 114u8, 15u8, 115u8, 102u8, 85u8, 66u8, 151u8, 16u8, 33u8, 187u8, 17u8, 166u8, 88u8, 127u8, 214u8, 182u8, 51u8, 168u8, 88u8, 43u8, 101u8, 185u8, 8u8, 1u8, 28u8, ]) } - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " Current time for the current block."] - pub fn now(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u64>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Timestamp", "Now", vec![], [148u8, 53u8, 50u8, 54u8, 13u8, 161u8, 57u8, 150u8, 16u8, 83u8, 144u8, 221u8, 59u8, 75u8, 158u8, 130u8, 39u8, 123u8, 106u8, 134u8, 202u8, 185u8, 83u8, 85u8, 60u8, 41u8, 120u8, 96u8, 210u8, 34u8, 2u8, 250u8, ]) } - #[doc = " Did the timestamp get updated in this block?"] - pub fn did_update(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::bool>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Timestamp", "DidUpdate", vec![], [70u8, 13u8, 92u8, 186u8, 80u8, 151u8, 167u8, 90u8, 158u8, 232u8, 175u8, 13u8, 103u8, 135u8, 2u8, 78u8, 16u8, 6u8, 39u8, 158u8, 167u8, 85u8, 27u8, 47u8, 122u8, 73u8, 127u8, 26u8, 35u8, 168u8, 72u8, 204u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " The minimum period between blocks. Beware that this is different to the *expected*"] - #[doc = " period that the block production apparatus provides. Your chosen consensus system will"] - #[doc = " generally work with this to determine a sensible block time. e.g. For Aura, it will be"] - #[doc = " double this period on default settings."] - pub fn minimum_period(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u64>> { ::subxt::constants::StaticConstantAddress::new("Timestamp", "MinimumPeriod", [128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, 42u8, 184u8, 239u8, 42u8, 246u8, ]) } - } - } - } - - pub mod balances { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Transfer { - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] pub value: ::core::primitive::u128, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetBalance { - pub who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] pub new_free: ::core::primitive::u128, - #[codec(compact)] pub new_reserved: ::core::primitive::u128, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct ForceTransfer { - pub source: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] pub value: ::core::primitive::u128, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct TransferKeepAlive { - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] pub value: ::core::primitive::u128, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct TransferAll { - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - pub keep_alive: ::core::primitive::bool, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct ForceUnreserve { - pub who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - pub amount: ::core::primitive::u128, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "Transfer some liquid free balance to another account."] - #[doc = ""] - #[doc = "`transfer` will set the `FreeBalance` of the sender and receiver."] - #[doc = "If the sender's account is below the existential deposit as a result"] - #[doc = "of the transfer, the account will be reaped."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be `Signed` by the transactor."] - #[doc = ""] - #[doc = "# "] - #[doc = "- Dependent on arguments but not critical, given proper implementations for input config"] - #[doc = " types. See related functions below."] - #[doc = "- It contains a limited number of reads and writes internally and no complex"] - #[doc = " computation."] - #[doc = ""] - #[doc = "Related functions:"] - #[doc = ""] - #[doc = " - `ensure_can_withdraw` is always called internally but has a bounded complexity."] - #[doc = " - Transferring balances to accounts that did not exist before will cause"] - #[doc = " `T::OnNewAccount::on_new_account` to be called."] - #[doc = " - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`."] - #[doc = " - `transfer_keep_alive` works the same way as `transfer`, but has an additional check"] - #[doc = " that the transfer will not kill the origin account."] - #[doc = "---------------------------------"] - #[doc = "- Origin account is already in memory, so no DB operations for them."] - #[doc = "# "] - pub fn transfer(&self, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, value: ::core::primitive::u128) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "transfer", Transfer { dest, value }, [111u8, 222u8, 32u8, 56u8, 171u8, 77u8, 252u8, 29u8, 194u8, 155u8, 200u8, 192u8, 198u8, 81u8, 23u8, 115u8, 236u8, 91u8, 218u8, 114u8, 107u8, 141u8, 138u8, 100u8, 237u8, 21u8, 58u8, 172u8, 3u8, 20u8, 216u8, 38u8, ]) } - #[doc = "Set the balances of a given account."] - #[doc = ""] - #[doc = "This will alter `FreeBalance` and `ReservedBalance` in storage. it will"] - #[doc = "also alter the total issuance of the system (`TotalIssuance`) appropriately."] - #[doc = "If the new free or reserved balance is below the existential deposit,"] - #[doc = "it will reset the account nonce (`frame_system::AccountNonce`)."] - #[doc = ""] - #[doc = "The dispatch origin for this call is `root`."] - pub fn set_balance(&self, who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, new_free: ::core::primitive::u128, new_reserved: ::core::primitive::u128) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "set_balance", SetBalance { who, new_free, new_reserved }, [234u8, 215u8, 97u8, 98u8, 243u8, 199u8, 57u8, 76u8, 59u8, 161u8, 118u8, 207u8, 34u8, 197u8, 198u8, 61u8, 231u8, 210u8, 169u8, 235u8, 150u8, 137u8, 173u8, 49u8, 28u8, 77u8, 84u8, 149u8, 143u8, 210u8, 139u8, 193u8, ]) } - #[doc = "Exactly as `transfer`, except the origin must be root and the source account may be"] - #[doc = "specified."] - #[doc = "# "] - #[doc = "- Same as transfer, but additional read and write because the source account is not"] - #[doc = " assumed to be in the overlay."] - #[doc = "# "] - pub fn force_transfer(&self, source: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, value: ::core::primitive::u128) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "force_transfer", ForceTransfer { source, dest, value }, [79u8, 174u8, 212u8, 108u8, 184u8, 33u8, 170u8, 29u8, 232u8, 254u8, 195u8, 218u8, 221u8, 134u8, 57u8, 99u8, 6u8, 70u8, 181u8, 227u8, 56u8, 239u8, 243u8, 158u8, 157u8, 245u8, 36u8, 162u8, 11u8, 237u8, 147u8, 15u8, ]) } - #[doc = "Same as the [`transfer`] call, but with a check that the transfer will not kill the"] - #[doc = "origin account."] - #[doc = ""] - #[doc = "99% of the time you want [`transfer`] instead."] - #[doc = ""] - #[doc = "[`transfer`]: struct.Pallet.html#method.transfer"] - pub fn transfer_keep_alive(&self, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, value: ::core::primitive::u128) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "transfer_keep_alive", TransferKeepAlive { dest, value }, [112u8, 179u8, 75u8, 168u8, 193u8, 221u8, 9u8, 82u8, 190u8, 113u8, 253u8, 13u8, 130u8, 134u8, 170u8, 216u8, 136u8, 111u8, 242u8, 220u8, 202u8, 112u8, 47u8, 79u8, 73u8, 244u8, 226u8, 59u8, 240u8, 188u8, 210u8, 208u8, ]) } - #[doc = "Transfer the entire transferable balance from the caller account."] - #[doc = ""] - #[doc = "NOTE: This function only attempts to transfer _transferable_ balances. This means that"] - #[doc = "any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be"] - #[doc = "transferred by this function. To ensure that this function results in a killed account,"] - #[doc = "you might need to prepare the account by removing any reference counters, storage"] - #[doc = "deposits, etc..."] - #[doc = ""] - #[doc = "The dispatch origin of this call must be Signed."] - #[doc = ""] - #[doc = "- `dest`: The recipient of the transfer."] - #[doc = "- `keep_alive`: A boolean to determine if the `transfer_all` operation should send all"] - #[doc = " of the funds the account has, causing the sender account to be killed (false), or"] - #[doc = " transfer everything except at least the existential deposit, which will guarantee to"] - #[doc = " keep the sender account alive (true). # "] - #[doc = "- O(1). Just like transfer, but reading the user's transferable balance first."] - #[doc = " #"] - pub fn transfer_all(&self, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, keep_alive: ::core::primitive::bool) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "transfer_all", TransferAll { dest, keep_alive }, [46u8, 129u8, 29u8, 177u8, 221u8, 107u8, 245u8, 69u8, 238u8, 126u8, 145u8, 26u8, 219u8, 208u8, 14u8, 80u8, 149u8, 1u8, 214u8, 63u8, 67u8, 201u8, 144u8, 45u8, 129u8, 145u8, 174u8, 71u8, 238u8, 113u8, 208u8, 34u8, ]) } - #[doc = "Unreserve some balance from a user by force."] - #[doc = ""] - #[doc = "Can only be called by ROOT."] - pub fn force_unreserve(&self, who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, amount: ::core::primitive::u128) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Balances", "force_unreserve", ForceUnreserve { who, amount }, [160u8, 146u8, 137u8, 76u8, 157u8, 187u8, 66u8, 148u8, 207u8, 76u8, 32u8, 254u8, 82u8, 215u8, 35u8, 161u8, 213u8, 52u8, 32u8, 98u8, 102u8, 106u8, 234u8, 123u8, 6u8, 175u8, 184u8, 188u8, 174u8, 106u8, 176u8, 78u8, ]) } - } - } - - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub type Event = runtime_types::pallet_balances::pallet::Event; - - pub mod events { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "An account was created with some free balance."] - pub struct Endowed { - pub account: ::subxt::ext::sp_core::crypto::AccountId32, - pub free_balance: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Endowed { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Endowed"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "An account was removed whose balance was non-zero but below ExistentialDeposit,"] - #[doc = "resulting in an outright loss."] - pub struct DustLost { - pub account: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for DustLost { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "DustLost"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Transfer succeeded."] - pub struct Transfer { - pub from: ::subxt::ext::sp_core::crypto::AccountId32, - pub to: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Transfer { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Transfer"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A balance was set by root."] - pub struct BalanceSet { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub free: ::core::primitive::u128, - pub reserved: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for BalanceSet { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "BalanceSet"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some balance was reserved (moved from free to reserved)."] - pub struct Reserved { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Reserved { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Reserved"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some balance was unreserved (moved from reserved to free)."] - pub struct Unreserved { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Unreserved { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Unreserved"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some balance was moved from the reserve of the first account to the second account."] - #[doc = "Final argument indicates the destination balance type."] - pub struct ReserveRepatriated { - pub from: ::subxt::ext::sp_core::crypto::AccountId32, - pub to: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - pub destination_status: runtime_types::frame_support::traits::tokens::misc::BalanceStatus, - } - - impl ::subxt::events::StaticEvent for ReserveRepatriated { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "ReserveRepatriated"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some amount was deposited (e.g. for transaction fees)."] - pub struct Deposit { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Deposit { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Deposit"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some amount was withdrawn from the account (e.g. for transaction fees)."] - pub struct Withdraw { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Withdraw { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Withdraw"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Some amount was removed from the account (e.g. for misbehavior)."] - pub struct Slashed { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub amount: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for Slashed { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Slashed"; - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " The total units issued in the system."] - pub fn total_issuance(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u128>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "TotalIssuance", vec![], [1u8, 206u8, 252u8, 237u8, 6u8, 30u8, 20u8, 232u8, 164u8, 115u8, 51u8, 156u8, 156u8, 206u8, 241u8, 187u8, 44u8, 84u8, 25u8, 164u8, 235u8, 20u8, 86u8, 242u8, 124u8, 23u8, 28u8, 140u8, 26u8, 73u8, 231u8, 51u8, ]) } - #[doc = " The Balances pallet example of storing the balance of an account."] - #[doc = ""] - #[doc = " # Example"] - #[doc = ""] - #[doc = " ```nocompile"] - #[doc = " impl pallet_balances::Config for Runtime {"] - #[doc = " type AccountStore = StorageMapShim, frame_system::Provider, AccountId, Self::AccountData>"] - #[doc = " }"] - #[doc = " ```"] - #[doc = ""] - #[doc = " You can also store the balance of an account in the `System` pallet."] - #[doc = ""] - #[doc = " # Example"] - #[doc = ""] - #[doc = " ```nocompile"] - #[doc = " impl pallet_balances::Config for Runtime {"] - #[doc = " type AccountStore = System"] - #[doc = " }"] - #[doc = " ```"] - #[doc = ""] - #[doc = " But this comes with tradeoffs, storing account balances in the system pallet stores"] - #[doc = " `frame_system` data alongside the account data contrary to storing account balances in the"] - #[doc = " `Balances` pallet, which uses a `StorageMap` to store balances data only."] - #[doc = " NOTE: This is only used in the case that this pallet is used to store balances."] - pub fn account(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::crypto::AccountId32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Account", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Blake2_128Concat)], [246u8, 154u8, 253u8, 71u8, 192u8, 192u8, 192u8, 236u8, 128u8, 80u8, 40u8, 252u8, 201u8, 43u8, 3u8, 131u8, 19u8, 49u8, 141u8, 240u8, 172u8, 217u8, 215u8, 109u8, 87u8, 135u8, 248u8, 57u8, 98u8, 185u8, 22u8, 4u8, ]) } - #[doc = " The Balances pallet example of storing the balance of an account."] - #[doc = ""] - #[doc = " # Example"] - #[doc = ""] - #[doc = " ```nocompile"] - #[doc = " impl pallet_balances::Config for Runtime {"] - #[doc = " type AccountStore = StorageMapShim, frame_system::Provider, AccountId, Self::AccountData>"] - #[doc = " }"] - #[doc = " ```"] - #[doc = ""] - #[doc = " You can also store the balance of an account in the `System` pallet."] - #[doc = ""] - #[doc = " # Example"] - #[doc = ""] - #[doc = " ```nocompile"] - #[doc = " impl pallet_balances::Config for Runtime {"] - #[doc = " type AccountStore = System"] - #[doc = " }"] - #[doc = " ```"] - #[doc = ""] - #[doc = " But this comes with tradeoffs, storing account balances in the system pallet stores"] - #[doc = " `frame_system` data alongside the account data contrary to storing account balances in the"] - #[doc = " `Balances` pallet, which uses a `StorageMap` to store balances data only."] - #[doc = " NOTE: This is only used in the case that this pallet is used to store balances."] - pub fn account_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Account", Vec::new(), [246u8, 154u8, 253u8, 71u8, 192u8, 192u8, 192u8, 236u8, 128u8, 80u8, 40u8, 252u8, 201u8, 43u8, 3u8, 131u8, 19u8, 49u8, 141u8, 240u8, 172u8, 217u8, 215u8, 109u8, 87u8, 135u8, 248u8, 57u8, 98u8, 185u8, 22u8, 4u8, ]) } - #[doc = " Any liquidity locks on some account balances."] - #[doc = " NOTE: Should only be accessed when setting, changing and freeing a lock."] - pub fn locks(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::crypto::AccountId32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Locks", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Blake2_128Concat)], [216u8, 253u8, 87u8, 73u8, 24u8, 218u8, 35u8, 0u8, 244u8, 134u8, 195u8, 58u8, 255u8, 64u8, 153u8, 212u8, 210u8, 232u8, 4u8, 122u8, 90u8, 212u8, 136u8, 14u8, 127u8, 232u8, 8u8, 192u8, 40u8, 233u8, 18u8, 250u8, ]) } - #[doc = " Any liquidity locks on some account balances."] - #[doc = " NOTE: Should only be accessed when setting, changing and freeing a lock."] - pub fn locks_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Locks", Vec::new(), [216u8, 253u8, 87u8, 73u8, 24u8, 218u8, 35u8, 0u8, 244u8, 134u8, 195u8, 58u8, 255u8, 64u8, 153u8, 212u8, 210u8, 232u8, 4u8, 122u8, 90u8, 212u8, 136u8, 14u8, 127u8, 232u8, 8u8, 192u8, 40u8, 233u8, 18u8, 250u8, ]) } - #[doc = " Named reserves on some account balances."] - pub fn reserves(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::crypto::AccountId32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Reserves", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Blake2_128Concat)], [17u8, 32u8, 191u8, 46u8, 76u8, 220u8, 101u8, 100u8, 42u8, 250u8, 128u8, 167u8, 117u8, 44u8, 85u8, 96u8, 105u8, 216u8, 16u8, 147u8, 74u8, 55u8, 183u8, 94u8, 160u8, 177u8, 26u8, 187u8, 71u8, 197u8, 187u8, 163u8, ]) } - #[doc = " Named reserves on some account balances."] - pub fn reserves_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, (), ::subxt::storage::address::Yes, ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "Reserves", Vec::new(), [17u8, 32u8, 191u8, 46u8, 76u8, 220u8, 101u8, 100u8, 42u8, 250u8, 128u8, 167u8, 117u8, 44u8, 85u8, 96u8, 105u8, 216u8, 16u8, 147u8, 74u8, 55u8, 183u8, 94u8, 160u8, 177u8, 26u8, 187u8, 71u8, 197u8, 187u8, 163u8, ]) } - #[doc = " Storage version of the pallet."] - #[doc = ""] - #[doc = " This is set to v2.0.0 for new networks."] - pub fn storage_version(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Balances", "StorageVersion", vec![], [135u8, 96u8, 28u8, 234u8, 124u8, 212u8, 56u8, 140u8, 40u8, 101u8, 235u8, 128u8, 136u8, 221u8, 182u8, 81u8, 17u8, 9u8, 184u8, 228u8, 174u8, 165u8, 200u8, 162u8, 214u8, 178u8, 227u8, 72u8, 34u8, 5u8, 173u8, 96u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " The minimum amount required to keep an account open."] - pub fn existential_deposit(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u128>> { ::subxt::constants::StaticConstantAddress::new("Balances", "ExistentialDeposit", [84u8, 157u8, 140u8, 4u8, 93u8, 57u8, 29u8, 133u8, 105u8, 200u8, 214u8, 27u8, 144u8, 208u8, 218u8, 160u8, 130u8, 109u8, 101u8, 54u8, 210u8, 136u8, 71u8, 63u8, 49u8, 237u8, 234u8, 15u8, 178u8, 98u8, 148u8, 156u8, ]) } - #[doc = " The maximum number of locks that should exist on an account."] - #[doc = " Not strictly enforced, but used for weight estimation."] - pub fn max_locks(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u32>> { ::subxt::constants::StaticConstantAddress::new("Balances", "MaxLocks", [98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, 203u8, 100u8, 41u8, 145u8, ]) } - #[doc = " The maximum number of named reserves that can exist on an account."] - pub fn max_reserves(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u32>> { ::subxt::constants::StaticConstantAddress::new("Balances", "MaxReserves", [98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, 203u8, 100u8, 41u8, 145u8, ]) } - } - } - } - - pub mod authorship { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetUncles { - pub new_uncles: ::std::vec::Vec>, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "Provide a set of uncles."] - pub fn set_uncles(&self, new_uncles: ::std::vec::Vec>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Authorship", "set_uncles", SetUncles { new_uncles }, [181u8, 70u8, 222u8, 83u8, 154u8, 215u8, 200u8, 64u8, 154u8, 228u8, 115u8, 247u8, 117u8, 89u8, 229u8, 102u8, 128u8, 189u8, 90u8, 60u8, 223u8, 19u8, 111u8, 172u8, 5u8, 223u8, 132u8, 37u8, 235u8, 119u8, 42u8, 64u8, ]) } - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " Uncles"] - pub fn uncles(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Authorship", "Uncles", vec![], [193u8, 226u8, 196u8, 151u8, 233u8, 82u8, 60u8, 164u8, 27u8, 156u8, 231u8, 51u8, 79u8, 134u8, 170u8, 166u8, 71u8, 120u8, 250u8, 255u8, 52u8, 168u8, 74u8, 199u8, 122u8, 253u8, 248u8, 178u8, 39u8, 233u8, 132u8, 67u8, ]) } - #[doc = " Author of current block."] - pub fn author(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::subxt::ext::sp_core::crypto::AccountId32>, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("Authorship", "Author", vec![], [149u8, 42u8, 33u8, 147u8, 190u8, 207u8, 174u8, 227u8, 190u8, 110u8, 25u8, 131u8, 5u8, 167u8, 237u8, 188u8, 188u8, 33u8, 177u8, 126u8, 181u8, 49u8, 126u8, 118u8, 46u8, 128u8, 154u8, 95u8, 15u8, 91u8, 103u8, 113u8, ]) } - #[doc = " Whether uncles were already set in this block."] - pub fn did_set_uncles(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::bool>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Authorship", "DidSetUncles", vec![], [64u8, 3u8, 208u8, 187u8, 50u8, 45u8, 37u8, 88u8, 163u8, 226u8, 37u8, 126u8, 232u8, 107u8, 156u8, 187u8, 29u8, 15u8, 53u8, 46u8, 28u8, 73u8, 83u8, 123u8, 14u8, 244u8, 243u8, 43u8, 245u8, 143u8, 15u8, 115u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " The number of blocks back we should accept uncles."] - #[doc = " This means that we will deal with uncle-parents that are"] - #[doc = " `UncleGenerations + 1` before `now`."] - pub fn uncle_generations(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u32>> { ::subxt::constants::StaticConstantAddress::new("Authorship", "UncleGenerations", [98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, 203u8, 100u8, 41u8, 145u8, ]) } - } - } - } - - pub mod transaction_payment { - use super::root_mod; - use super::runtime_types; - - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub type Event = runtime_types::pallet_transaction_payment::pallet::Event; - - pub mod events { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,"] - #[doc = "has been paid by `who`."] - pub struct TransactionFeePaid { - pub who: ::subxt::ext::sp_core::crypto::AccountId32, - pub actual_fee: ::core::primitive::u128, - pub tip: ::core::primitive::u128, - } - - impl ::subxt::events::StaticEvent for TransactionFeePaid { - const PALLET: &'static str = "TransactionPayment"; - const EVENT: &'static str = "TransactionFeePaid"; - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - pub fn next_fee_multiplier(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("TransactionPayment", "NextFeeMultiplier", vec![], [210u8, 0u8, 206u8, 165u8, 183u8, 10u8, 206u8, 52u8, 14u8, 90u8, 218u8, 197u8, 189u8, 125u8, 113u8, 216u8, 52u8, 161u8, 45u8, 24u8, 245u8, 237u8, 121u8, 41u8, 106u8, 29u8, 45u8, 129u8, 250u8, 203u8, 206u8, 180u8, ]) } - pub fn storage_version(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("TransactionPayment", "StorageVersion", vec![], [219u8, 243u8, 82u8, 176u8, 65u8, 5u8, 132u8, 114u8, 8u8, 82u8, 176u8, 200u8, 97u8, 150u8, 177u8, 164u8, 166u8, 11u8, 34u8, 12u8, 12u8, 198u8, 58u8, 191u8, 186u8, 221u8, 221u8, 119u8, 181u8, 253u8, 154u8, 228u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " A fee mulitplier for `Operational` extrinsics to compute \"virtual tip\" to boost their"] - #[doc = " `priority`"] - #[doc = ""] - #[doc = " This value is multipled by the `final_fee` to obtain a \"virtual tip\" that is later"] - #[doc = " added to a tip component in regular `priority` calculations."] - #[doc = " It means that a `Normal` transaction can front-run a similarly-sized `Operational`"] - #[doc = " extrinsic (with no tip), by including a tip value greater than the virtual tip."] - #[doc = ""] - #[doc = " ```rust,ignore"] - #[doc = " // For `Normal`"] - #[doc = " let priority = priority_calc(tip);"] - #[doc = ""] - #[doc = " // For `Operational`"] - #[doc = " let virtual_tip = (inclusion_fee + tip) * OperationalFeeMultiplier;"] - #[doc = " let priority = priority_calc(tip + virtual_tip);"] - #[doc = " ```"] - #[doc = ""] - #[doc = " Note that since we use `final_fee` the multiplier applies also to the regular `tip`"] - #[doc = " sent with the transaction. So, not only does the transaction get a priority bump based"] - #[doc = " on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational`"] - #[doc = " transactions."] - pub fn operational_fee_multiplier(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u8>> { ::subxt::constants::StaticConstantAddress::new("TransactionPayment", "OperationalFeeMultiplier", [141u8, 130u8, 11u8, 35u8, 226u8, 114u8, 92u8, 179u8, 168u8, 110u8, 28u8, 91u8, 221u8, 64u8, 4u8, 148u8, 201u8, 193u8, 185u8, 66u8, 226u8, 114u8, 97u8, 79u8, 62u8, 212u8, 202u8, 114u8, 237u8, 228u8, 183u8, 165u8, ]) } - } - } - } - - pub mod sudo { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Sudo { - pub call: ::std::boxed::Box, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SudoUncheckedWeight { - pub call: ::std::boxed::Box, - pub weight: ::core::primitive::u64, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetKey { - pub new: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SudoAs { - pub who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - pub call: ::std::boxed::Box, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "Authenticates the sudo key and dispatches a function call with `Root` origin."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB write (event)."] - #[doc = "- Weight of derivative `call` execution + 10,000."] - #[doc = "# "] - pub fn sudo(&self, call: runtime_types::contracts_node_runtime::Call) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Sudo", "sudo", Sudo { call: ::std::boxed::Box::new(call) }, [140u8, 190u8, 95u8, 189u8, 152u8, 74u8, 211u8, 245u8, 255u8, 121u8, 217u8, 88u8, 217u8, 69u8, 210u8, 41u8, 140u8, 118u8, 39u8, 200u8, 60u8, 163u8, 228u8, 16u8, 106u8, 173u8, 217u8, 53u8, 218u8, 32u8, 243u8, 53u8, ]) } - #[doc = "Authenticates the sudo key and dispatches a function call with `Root` origin."] - #[doc = "This function does not check the weight of the call, and instead allows the"] - #[doc = "Sudo user to specify the weight of the call."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- The weight of this call is defined by the caller."] - #[doc = "# "] - pub fn sudo_unchecked_weight(&self, call: runtime_types::contracts_node_runtime::Call, weight: ::core::primitive::u64) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Sudo", "sudo_unchecked_weight", SudoUncheckedWeight { call: ::std::boxed::Box::new(call), weight }, [122u8, 45u8, 179u8, 118u8, 60u8, 6u8, 139u8, 190u8, 92u8, 219u8, 178u8, 5u8, 2u8, 182u8, 246u8, 117u8, 222u8, 56u8, 120u8, 74u8, 163u8, 230u8, 114u8, 33u8, 233u8, 96u8, 250u8, 106u8, 94u8, 108u8, 247u8, 60u8, ]) } - #[doc = "Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo"] - #[doc = "key."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB change."] - #[doc = "# "] - pub fn set_key(&self, new: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Sudo", "set_key", SetKey { new }, [23u8, 224u8, 218u8, 169u8, 8u8, 28u8, 111u8, 199u8, 26u8, 88u8, 225u8, 105u8, 17u8, 19u8, 87u8, 156u8, 97u8, 67u8, 89u8, 173u8, 70u8, 0u8, 5u8, 246u8, 198u8, 135u8, 182u8, 180u8, 44u8, 9u8, 212u8, 95u8, ]) } - #[doc = "Authenticates the sudo key and dispatches a function call with `Signed` origin from"] - #[doc = "a given account."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB write (event)."] - #[doc = "- Weight of derivative `call` execution + 10,000."] - #[doc = "# "] - pub fn sudo_as(&self, who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, call: runtime_types::contracts_node_runtime::Call) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Sudo", "sudo_as", SudoAs { who, call: ::std::boxed::Box::new(call) }, [47u8, 65u8, 47u8, 89u8, 53u8, 63u8, 102u8, 10u8, 76u8, 42u8, 188u8, 100u8, 163u8, 254u8, 9u8, 86u8, 162u8, 52u8, 248u8, 230u8, 53u8, 79u8, 251u8, 230u8, 72u8, 250u8, 49u8, 117u8, 194u8, 205u8, 254u8, 25u8, ]) } - } - } - - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub type Event = runtime_types::pallet_sudo::pallet::Event; - - pub mod events { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A sudo just took place. \\[result\\]"] - pub struct Sudid { - pub sudo_result: ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, - } - - impl ::subxt::events::StaticEvent for Sudid { - const PALLET: &'static str = "Sudo"; - const EVENT: &'static str = "Sudid"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "The \\[sudoer\\] just switched identity; the old key is supplied if one existed."] - pub struct KeyChanged { - pub old_sudoer: ::core::option::Option<::subxt::ext::sp_core::crypto::AccountId32>, - } - - impl ::subxt::events::StaticEvent for KeyChanged { - const PALLET: &'static str = "Sudo"; - const EVENT: &'static str = "KeyChanged"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A sudo just took place. \\[result\\]"] - pub struct SudoAsDone { - pub sudo_result: ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, - } - - impl ::subxt::events::StaticEvent for SudoAsDone { - const PALLET: &'static str = "Sudo"; - const EVENT: &'static str = "SudoAsDone"; - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " The `AccountId` of the sudo key."] - pub fn key(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::subxt::ext::sp_core::crypto::AccountId32>, ::subxt::storage::address::Yes, (), ()> { ::subxt::storage::address::StaticStorageAddress::new("Sudo", "Key", vec![], [244u8, 73u8, 188u8, 136u8, 218u8, 163u8, 68u8, 179u8, 122u8, 173u8, 34u8, 108u8, 137u8, 28u8, 182u8, 16u8, 196u8, 92u8, 138u8, 34u8, 102u8, 80u8, 199u8, 88u8, 107u8, 207u8, 36u8, 22u8, 168u8, 167u8, 20u8, 142u8, ]) } - } - } - } - - pub mod contracts { - use super::root_mod; - use super::runtime_types; - - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub mod calls { - use super::root_mod; - use super::runtime_types; - - type DispatchError = runtime_types::sp_runtime::DispatchError; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Call { - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] pub value: ::core::primitive::u128, - #[codec(compact)] pub gas_limit: ::core::primitive::u64, - pub storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, - pub data: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct InstantiateWithCode { - #[codec(compact)] pub value: ::core::primitive::u128, - #[codec(compact)] pub gas_limit: ::core::primitive::u64, - pub storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, - pub code: ::std::vec::Vec<::core::primitive::u8>, - pub data: ::std::vec::Vec<::core::primitive::u8>, - pub salt: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Instantiate { - #[codec(compact)] pub value: ::core::primitive::u128, - #[codec(compact)] pub gas_limit: ::core::primitive::u64, - pub storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, - pub code_hash: ::subxt::ext::sp_core::H256, - pub data: ::std::vec::Vec<::core::primitive::u8>, - pub salt: ::std::vec::Vec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct UploadCode { - pub code: ::std::vec::Vec<::core::primitive::u8>, - pub storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct RemoveCode { - pub code_hash: ::subxt::ext::sp_core::H256, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct SetCode { - pub dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, - pub code_hash: ::subxt::ext::sp_core::H256, - } - - pub struct TransactionApi; - - impl TransactionApi { - #[doc = "Makes a call to an account, optionally transferring some balance."] - #[doc = ""] - #[doc = "# Parameters"] - #[doc = ""] - #[doc = "* `dest`: Address of the contract to call."] - #[doc = "* `value`: The balance to transfer from the `origin` to `dest`."] - #[doc = "* `gas_limit`: The gas limit enforced when executing the constructor."] - #[doc = "* `storage_deposit_limit`: The maximum amount of balance that can be charged from the"] - #[doc = " caller to pay for the storage consumed."] - #[doc = "* `data`: The input data to pass to the contract."] - #[doc = ""] - #[doc = "* If the account is a smart-contract account, the associated code will be"] - #[doc = "executed and any value will be transferred."] - #[doc = "* If the account is a regular account, any value will be transferred."] - #[doc = "* If no account exists and the call value is not less than `existential_deposit`,"] - #[doc = "a regular account will be created and any value will be transferred."] - pub fn call(&self, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, value: ::core::primitive::u128, gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, data: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "call", Call { dest, value, gas_limit, storage_deposit_limit, data }, [22u8, 148u8, 225u8, 3u8, 113u8, 132u8, 125u8, 117u8, 187u8, 51u8, 32u8, 8u8, 2u8, 125u8, 76u8, 14u8, 227u8, 139u8, 67u8, 136u8, 55u8, 98u8, 181u8, 163u8, 105u8, 175u8, 43u8, 125u8, 17u8, 123u8, 191u8, 228u8, ]) } - #[doc = "Instantiates a new contract from the supplied `code` optionally transferring"] - #[doc = "some balance."] - #[doc = ""] - #[doc = "This dispatchable has the same effect as calling [`Self::upload_code`] +"] - #[doc = "[`Self::instantiate`]. Bundling them together provides efficiency gains. Please"] - #[doc = "also check the documentation of [`Self::upload_code`]."] - #[doc = ""] - #[doc = "# Parameters"] - #[doc = ""] - #[doc = "* `value`: The balance to transfer from the `origin` to the newly created contract."] - #[doc = "* `gas_limit`: The gas limit enforced when executing the constructor."] - #[doc = "* `storage_deposit_limit`: The maximum amount of balance that can be charged/reserved"] - #[doc = " from the caller to pay for the storage consumed."] - #[doc = "* `code`: The contract code to deploy in raw bytes."] - #[doc = "* `data`: The input data to pass to the contract constructor."] - #[doc = "* `salt`: Used for the address derivation. See [`Pallet::contract_address`]."] - #[doc = ""] - #[doc = "Instantiation is executed as follows:"] - #[doc = ""] - #[doc = "- The supplied `code` is instrumented, deployed, and a `code_hash` is created for that"] - #[doc = " code."] - #[doc = "- If the `code_hash` already exists on the chain the underlying `code` will be shared."] - #[doc = "- The destination address is computed based on the sender, code_hash and the salt."] - #[doc = "- The smart-contract account is created at the computed address."] - #[doc = "- The `value` is transferred to the new account."] - #[doc = "- The `deploy` function is executed in the context of the newly-created account."] - pub fn instantiate_with_code(&self, value: ::core::primitive::u128, gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, code: ::std::vec::Vec<::core::primitive::u8>, data: ::std::vec::Vec<::core::primitive::u8>, salt: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "instantiate_with_code", InstantiateWithCode { value, gas_limit, storage_deposit_limit, code, data, salt }, [232u8, 229u8, 46u8, 91u8, 11u8, 117u8, 3u8, 81u8, 213u8, 34u8, 184u8, 125u8, 77u8, 214u8, 71u8, 103u8, 244u8, 131u8, 1u8, 211u8, 191u8, 153u8, 1u8, 80u8, 177u8, 177u8, 205u8, 126u8, 194u8, 166u8, 136u8, 191u8, ]) } - #[doc = "Instantiates a contract from a previously deployed wasm binary."] - #[doc = ""] - #[doc = "This function is identical to [`Self::instantiate_with_code`] but without the"] - #[doc = "code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary"] - #[doc = "must be supplied."] - pub fn instantiate(&self, value: ::core::primitive::u128, gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, code_hash: ::subxt::ext::sp_core::H256, data: ::std::vec::Vec<::core::primitive::u8>, salt: ::std::vec::Vec<::core::primitive::u8>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "instantiate", Instantiate { value, gas_limit, storage_deposit_limit, code_hash, data, salt }, [69u8, 161u8, 178u8, 243u8, 14u8, 29u8, 15u8, 210u8, 29u8, 106u8, 129u8, 211u8, 90u8, 73u8, 66u8, 177u8, 245u8, 1u8, 232u8, 117u8, 119u8, 216u8, 84u8, 160u8, 207u8, 7u8, 237u8, 88u8, 25u8, 85u8, 213u8, 235u8, ]) } - #[doc = "Upload new `code` without instantiating a contract from it."] - #[doc = ""] - #[doc = "If the code does not already exist a deposit is reserved from the caller"] - #[doc = "and unreserved only when [`Self::remove_code`] is called. The size of the reserve"] - #[doc = "depends on the instrumented size of the the supplied `code`."] - #[doc = ""] - #[doc = "If the code already exists in storage it will still return `Ok` and upgrades"] - #[doc = "the in storage version to the current"] - #[doc = "[`InstructionWeights::version`](InstructionWeights)."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "Anyone can instantiate a contract from any uploaded code and thus prevent its removal."] - #[doc = "To avoid this situation a constructor could employ access control so that it can"] - #[doc = "only be instantiated by permissioned entities. The same is true when uploading"] - #[doc = "through [`Self::instantiate_with_code`]."] - pub fn upload_code(&self, code: ::std::vec::Vec<::core::primitive::u8>, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "upload_code", UploadCode { code, storage_deposit_limit }, [8u8, 32u8, 174u8, 226u8, 212u8, 86u8, 47u8, 247u8, 123u8, 155u8, 40u8, 192u8, 184u8, 216u8, 61u8, 57u8, 94u8, 23u8, 76u8, 59u8, 4u8, 124u8, 252u8, 248u8, 87u8, 233u8, 13u8, 184u8, 133u8, 236u8, 174u8, 85u8, ]) } - #[doc = "Remove the code stored under `code_hash` and refund the deposit to its owner."] - #[doc = ""] - #[doc = "A code can only be removed by its original uploader (its owner) and only if it is"] - #[doc = "not used by any contract."] - pub fn remove_code(&self, code_hash: ::subxt::ext::sp_core::H256) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "remove_code", RemoveCode { code_hash }, [43u8, 192u8, 198u8, 182u8, 108u8, 76u8, 21u8, 42u8, 169u8, 41u8, 195u8, 73u8, 31u8, 179u8, 162u8, 56u8, 91u8, 5u8, 64u8, 7u8, 252u8, 194u8, 255u8, 170u8, 67u8, 137u8, 143u8, 192u8, 2u8, 149u8, 38u8, 180u8, ]) } - #[doc = "Privileged function that changes the code of an existing contract."] - #[doc = ""] - #[doc = "This takes care of updating refcounts and all other necessary operations. Returns"] - #[doc = "an error if either the `code_hash` or `dest` do not exist."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "This does **not** change the address of the contract in question. This means"] - #[doc = "that the contract address is no longer derived from its code hash after calling"] - #[doc = "this dispatchable."] - pub fn set_code(&self, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, code_hash: ::subxt::ext::sp_core::H256) -> ::subxt::tx::StaticTxPayload { ::subxt::tx::StaticTxPayload::new("Contracts", "set_code", SetCode { dest, code_hash }, [106u8, 141u8, 239u8, 113u8, 99u8, 74u8, 14u8, 171u8, 80u8, 115u8, 214u8, 203u8, 232u8, 142u8, 48u8, 207u8, 214u8, 59u8, 204u8, 157u8, 101u8, 142u8, 12u8, 69u8, 230u8, 188u8, 60u8, 197u8, 238u8, 146u8, 17u8, 190u8, ]) } - } - } - - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub type Event = runtime_types::pallet_contracts::pallet::Event; - - pub mod events { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contract deployed by address at the specified address."] - pub struct Instantiated { - pub deployer: ::subxt::ext::sp_core::crypto::AccountId32, - pub contract: ::subxt::ext::sp_core::crypto::AccountId32, - } - - impl ::subxt::events::StaticEvent for Instantiated { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "Instantiated"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contract has been removed."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "The only way for a contract to be removed and emitting this event is by calling"] - #[doc = "`seal_terminate`."] - pub struct Terminated { - pub contract: ::subxt::ext::sp_core::crypto::AccountId32, - pub beneficiary: ::subxt::ext::sp_core::crypto::AccountId32, - } - - impl ::subxt::events::StaticEvent for Terminated { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "Terminated"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Code with the specified hash has been stored."] - pub struct CodeStored { - pub code_hash: ::subxt::ext::sp_core::H256, - } - - impl ::subxt::events::StaticEvent for CodeStored { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "CodeStored"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A custom event emitted by the contract."] - pub struct ContractEmitted { - pub contract: ::subxt::ext::sp_core::crypto::AccountId32, - pub data: ::std::vec::Vec<::core::primitive::u8>, - } - - impl ::subxt::events::StaticEvent for ContractEmitted { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "ContractEmitted"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A code with the specified hash was removed."] - pub struct CodeRemoved { - pub code_hash: ::subxt::ext::sp_core::H256, - } - - impl ::subxt::events::StaticEvent for CodeRemoved { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "CodeRemoved"; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "A contract's code was updated."] - pub struct ContractCodeUpdated { - pub contract: ::subxt::ext::sp_core::crypto::AccountId32, - pub new_code_hash: ::subxt::ext::sp_core::H256, - pub old_code_hash: ::subxt::ext::sp_core::H256, - } - - impl ::subxt::events::StaticEvent for ContractCodeUpdated { - const PALLET: &'static str = "Contracts"; - const EVENT: &'static str = "ContractCodeUpdated"; - } - } - - pub mod storage { - use super::runtime_types; - - pub struct StorageApi; - - impl StorageApi { - #[doc = " A mapping from an original code hash to the original code, untouched by instrumentation."] - pub fn pristine_code(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::H256>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "PristineCode", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Identity)], [244u8, 169u8, 220u8, 235u8, 62u8, 153u8, 226u8, 187u8, 220u8, 141u8, 149u8, 75u8, 224u8, 117u8, 181u8, 147u8, 140u8, 84u8, 9u8, 109u8, 230u8, 25u8, 186u8, 26u8, 171u8, 147u8, 19u8, 78u8, 62u8, 170u8, 27u8, 105u8, ]) } - #[doc = " A mapping from an original code hash to the original code, untouched by instrumentation."] - pub fn pristine_code_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, (), (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "PristineCode", Vec::new(), [244u8, 169u8, 220u8, 235u8, 62u8, 153u8, 226u8, 187u8, 220u8, 141u8, 149u8, 75u8, 224u8, 117u8, 181u8, 147u8, 140u8, 84u8, 9u8, 109u8, 230u8, 25u8, 186u8, 26u8, 171u8, 147u8, 19u8, 78u8, 62u8, 170u8, 27u8, 105u8, ]) } - #[doc = " A mapping between an original code hash and instrumented wasm code, ready for execution."] - pub fn code_storage(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::H256>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "CodeStorage", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Identity)], [167u8, 247u8, 131u8, 220u8, 90u8, 100u8, 172u8, 16u8, 129u8, 235u8, 119u8, 88u8, 60u8, 196u8, 74u8, 173u8, 192u8, 110u8, 106u8, 187u8, 111u8, 255u8, 114u8, 39u8, 76u8, 52u8, 245u8, 79u8, 132u8, 108u8, 141u8, 176u8, ]) } - #[doc = " A mapping between an original code hash and instrumented wasm code, ready for execution."] - pub fn code_storage_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, (), (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "CodeStorage", Vec::new(), [167u8, 247u8, 131u8, 220u8, 90u8, 100u8, 172u8, 16u8, 129u8, 235u8, 119u8, 88u8, 60u8, 196u8, 74u8, 173u8, 192u8, 110u8, 106u8, 187u8, 111u8, 255u8, 114u8, 39u8, 76u8, 52u8, 245u8, 79u8, 132u8, 108u8, 141u8, 176u8, ]) } - #[doc = " A mapping between an original code hash and its owner information."] - pub fn owner_info_of(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::H256>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, ::subxt::storage::address::Yes, (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "OwnerInfoOf", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Identity)], [147u8, 6u8, 225u8, 62u8, 211u8, 236u8, 61u8, 116u8, 152u8, 219u8, 220u8, 17u8, 82u8, 221u8, 156u8, 88u8, 63u8, 204u8, 16u8, 11u8, 184u8, 236u8, 181u8, 189u8, 170u8, 160u8, 60u8, 64u8, 71u8, 250u8, 202u8, 186u8, ]) } - #[doc = " A mapping between an original code hash and its owner information."] - pub fn owner_info_of_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType, (), (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "OwnerInfoOf", Vec::new(), [147u8, 6u8, 225u8, 62u8, 211u8, 236u8, 61u8, 116u8, 152u8, 219u8, 220u8, 17u8, 82u8, 221u8, 156u8, 88u8, 63u8, 204u8, 16u8, 11u8, 184u8, 236u8, 181u8, 189u8, 170u8, 160u8, 60u8, 64u8, 71u8, 250u8, 202u8, 186u8, ]) } - #[doc = " This is a **monotonic** counter incremented on contract instantiation."] - #[doc = ""] - #[doc = " This is used in order to generate unique trie ids for contracts."] - #[doc = " The trie id of a new contract is calculated from hash(account_id, nonce)."] - #[doc = " The nonce is required because otherwise the following sequence would lead to"] - #[doc = " a possible collision of storage:"] - #[doc = ""] - #[doc = " 1. Create a new contract."] - #[doc = " 2. Terminate the contract."] - #[doc = " 3. Immediately recreate the contract with the same account_id."] - #[doc = ""] - #[doc = " This is bad because the contents of a trie are deleted lazily and there might be"] - #[doc = " storage of the old instantiation still in it when the new contract is created. Please"] - #[doc = " note that we can't replace the counter by the block number because the sequence above"] - #[doc = " can happen in the same block. We also can't keep the account counter in memory only"] - #[doc = " because storage is the only way to communicate across different extrinsics in the"] - #[doc = " same block."] - #[doc = ""] - #[doc = " # Note"] - #[doc = ""] - #[doc = " Do not use it to determine the number of contracts. It won't be decremented if"] - #[doc = " a contract is destroyed."] - pub fn nonce(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType<::core::primitive::u64>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "Nonce", vec![], [122u8, 169u8, 95u8, 131u8, 85u8, 32u8, 154u8, 114u8, 143u8, 56u8, 12u8, 182u8, 64u8, 150u8, 241u8, 249u8, 254u8, 251u8, 160u8, 235u8, 192u8, 41u8, 101u8, 232u8, 186u8, 108u8, 187u8, 149u8, 210u8, 91u8, 179u8, 98u8, ]) } - #[doc = " The code associated with a given account."] - #[doc = ""] - #[doc = " TWOX-NOTE: SAFE since `AccountId` is a secure hash."] - pub fn contract_info_of(&self, _0: impl ::std::borrow::Borrow<::subxt::ext::sp_core::crypto::AccountId32>) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "ContractInfoOf", vec![::subxt::storage::address::StorageMapKey::new(_0.borrow(), ::subxt::storage::address::StorageHasher::Twox64Concat)], [249u8, 249u8, 163u8, 158u8, 30u8, 66u8, 127u8, 176u8, 156u8, 185u8, 75u8, 198u8, 120u8, 208u8, 233u8, 131u8, 161u8, 49u8, 45u8, 175u8, 242u8, 171u8, 63u8, 39u8, 76u8, 31u8, 167u8, 140u8, 210u8, 235u8, 185u8, 240u8, ]) } - #[doc = " The code associated with a given account."] - #[doc = ""] - #[doc = " TWOX-NOTE: SAFE since `AccountId` is a secure hash."] - pub fn contract_info_of_root(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, (), (), ::subxt::storage::address::Yes> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "ContractInfoOf", Vec::new(), [249u8, 249u8, 163u8, 158u8, 30u8, 66u8, 127u8, 176u8, 156u8, 185u8, 75u8, 198u8, 120u8, 208u8, 233u8, 131u8, 161u8, 49u8, 45u8, 175u8, 242u8, 171u8, 63u8, 39u8, 76u8, 31u8, 167u8, 140u8, 210u8, 235u8, 185u8, 240u8, ]) } - #[doc = " Evicted contracts that await child trie deletion."] - #[doc = ""] - #[doc = " Child trie deletion is a heavy operation depending on the amount of storage items"] - #[doc = " stored in said trie. Therefore this operation is performed lazily in `on_initialize`."] - pub fn deletion_queue(&self) -> ::subxt::storage::address::StaticStorageAddress::<::subxt::metadata::DecodeStaticType>, ::subxt::storage::address::Yes, ::subxt::storage::address::Yes, ()> { ::subxt::storage::address::StaticStorageAddress::new("Contracts", "DeletionQueue", vec![], [119u8, 169u8, 146u8, 210u8, 21u8, 216u8, 51u8, 225u8, 107u8, 61u8, 42u8, 155u8, 169u8, 127u8, 140u8, 106u8, 255u8, 137u8, 163u8, 199u8, 91u8, 137u8, 73u8, 61u8, 9u8, 167u8, 16u8, 157u8, 183u8, 212u8, 35u8, 88u8, ]) } - } - } - - pub mod constants { - use super::runtime_types; - - pub struct ConstantsApi; - - impl ConstantsApi { - #[doc = " Cost schedule and limits."] - pub fn schedule(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType> { ::subxt::constants::StaticConstantAddress::new("Contracts", "Schedule", [106u8, 133u8, 138u8, 78u8, 95u8, 52u8, 197u8, 85u8, 4u8, 33u8, 173u8, 239u8, 169u8, 196u8, 91u8, 38u8, 210u8, 50u8, 62u8, 67u8, 180u8, 184u8, 32u8, 190u8, 106u8, 252u8, 104u8, 173u8, 5u8, 140u8, 244u8, 249u8, ]) } - #[doc = " The maximum number of contracts that can be pending for deletion."] - #[doc = ""] - #[doc = " When a contract is deleted by calling `seal_terminate` it becomes inaccessible"] - #[doc = " immediately, but the deletion of the storage items it has accumulated is performed"] - #[doc = " later. The contract is put into the deletion queue. This defines how many"] - #[doc = " contracts can be queued up at the same time. If that limit is reached `seal_terminate`"] - #[doc = " will fail. The action must be retried in a later block in that case."] - #[doc = ""] - #[doc = " The reasons for limiting the queue depth are:"] - #[doc = ""] - #[doc = " 1. The queue is in storage in order to be persistent between blocks. We want to limit"] - #[doc = " \tthe amount of storage that can be consumed."] - #[doc = " 2. The queue is stored in a vector and needs to be decoded as a whole when reading"] - #[doc = "\t\tit at the end of each block. Longer queues take more weight to decode and hence"] - #[doc = "\t\tlimit the amount of items that can be deleted per block."] - pub fn deletion_queue_depth(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u32>> { ::subxt::constants::StaticConstantAddress::new("Contracts", "DeletionQueueDepth", [98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, 203u8, 100u8, 41u8, 145u8, ]) } - #[doc = " The maximum amount of weight that can be consumed per block for lazy trie removal."] - #[doc = ""] - #[doc = " The amount of weight that is dedicated per block to work on the deletion queue. Larger"] - #[doc = " values allow more trie keys to be deleted in each block but reduce the amount of"] - #[doc = " weight that is left for transactions. See [`Self::DeletionQueueDepth`] for more"] - #[doc = " information about the deletion queue."] - pub fn deletion_weight_limit(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u64>> { ::subxt::constants::StaticConstantAddress::new("Contracts", "DeletionWeightLimit", [128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, 42u8, 184u8, 239u8, 42u8, 246u8, ]) } - #[doc = " The amount of balance a caller has to pay for each byte of storage."] - #[doc = ""] - #[doc = " # Note"] - #[doc = ""] - #[doc = " Changing this value for an existing chain might need a storage migration."] - pub fn deposit_per_byte(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u128>> { ::subxt::constants::StaticConstantAddress::new("Contracts", "DepositPerByte", [84u8, 157u8, 140u8, 4u8, 93u8, 57u8, 29u8, 133u8, 105u8, 200u8, 214u8, 27u8, 144u8, 208u8, 218u8, 160u8, 130u8, 109u8, 101u8, 54u8, 210u8, 136u8, 71u8, 63u8, 49u8, 237u8, 234u8, 15u8, 178u8, 98u8, 148u8, 156u8, ]) } - #[doc = " The weight per byte of code that is charged when loading a contract from storage."] - #[doc = ""] - #[doc = " Currently, FRAME only charges fees for computation incurred but not for PoV"] - #[doc = " consumption caused for storage access. This is usually not exploitable because"] - #[doc = " accessing storage carries some substantial weight costs, too. However in case"] - #[doc = " of contract code very much PoV consumption can be caused while consuming very little"] - #[doc = " computation. This could be used to keep the chain busy without paying the"] - #[doc = " proper fee for it. Until this is resolved we charge from the weight meter for"] - #[doc = " contract access."] - #[doc = ""] - #[doc = " For more information check out: "] - #[doc = ""] - #[doc = " [`DefaultContractAccessWeight`] is a safe default to be used for Polkadot or Kusama"] - #[doc = " parachains."] - #[doc = ""] - #[doc = " # Note"] - #[doc = ""] - #[doc = " This is only relevant for parachains. Set to zero in case of a standalone chain."] - pub fn contract_access_weight(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u64>> { ::subxt::constants::StaticConstantAddress::new("Contracts", "ContractAccessWeight", [128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, 42u8, 184u8, 239u8, 42u8, 246u8, ]) } - #[doc = " The amount of balance a caller has to pay for each storage item."] - #[doc = ""] - #[doc = " # Note"] - #[doc = ""] - #[doc = " Changing this value for an existing chain might need a storage migration."] - pub fn deposit_per_item(&self) -> ::subxt::constants::StaticConstantAddress<::subxt::metadata::DecodeStaticType<::core::primitive::u128>> { ::subxt::constants::StaticConstantAddress::new("Contracts", "DepositPerItem", [84u8, 157u8, 140u8, 4u8, 93u8, 57u8, 29u8, 133u8, 105u8, 200u8, 214u8, 27u8, 144u8, 208u8, 218u8, 160u8, 130u8, 109u8, 101u8, 54u8, 210u8, 136u8, 71u8, 63u8, 49u8, 237u8, 234u8, 15u8, 178u8, 98u8, 148u8, 156u8, ]) } - } - } - } - - pub mod runtime_types { - use super::runtime_types; - - pub mod contracts_node_runtime { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Call { #[codec(index = 0)] System(runtime_types::frame_system::pallet::Call), #[codec(index = 2)] Timestamp(runtime_types::pallet_timestamp::pallet::Call), #[codec(index = 3)] Balances(runtime_types::pallet_balances::pallet::Call), #[codec(index = 4)] Authorship(runtime_types::pallet_authorship::pallet::Call), #[codec(index = 6)] Sudo(runtime_types::pallet_sudo::pallet::Call), #[codec(index = 7)] Contracts(runtime_types::pallet_contracts::pallet::Call) } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Event { #[codec(index = 0)] System(runtime_types::frame_system::pallet::Event), #[codec(index = 3)] Balances(runtime_types::pallet_balances::pallet::Event), #[codec(index = 5)] TransactionPayment(runtime_types::pallet_transaction_payment::pallet::Event), #[codec(index = 6)] Sudo(runtime_types::pallet_sudo::pallet::Event), #[codec(index = 7)] Contracts(runtime_types::pallet_contracts::pallet::Event) } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Runtime; - } - - pub mod frame_support { - use super::runtime_types; - - pub mod traits { - use super::runtime_types; - - pub mod tokens { - use super::runtime_types; - - pub mod misc { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum BalanceStatus { #[codec(index = 0)] Free, #[codec(index = 1)] Reserved } - } - } - } - - pub mod weights { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum DispatchClass { #[codec(index = 0)] Normal, #[codec(index = 1)] Operational, #[codec(index = 2)] Mandatory } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct DispatchInfo { - pub weight: ::core::primitive::u64, - pub class: runtime_types::frame_support::weights::DispatchClass, - pub pays_fee: runtime_types::frame_support::weights::Pays, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Pays { #[codec(index = 0)] Yes, #[codec(index = 1)] No } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct PerDispatchClass<_0> { - pub normal: _0, - pub operational: _0, - pub mandatory: _0, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct RuntimeDbWeight { - pub read: ::core::primitive::u64, - pub write: ::core::primitive::u64, - } - } - } - - pub mod frame_system { - use super::runtime_types; - - pub mod extensions { - use super::runtime_types; - - pub mod check_genesis { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckGenesis; - } - - pub mod check_mortality { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckMortality(pub runtime_types::sp_runtime::generic::era::Era); - } - - pub mod check_non_zero_sender { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckNonZeroSender; - } - - pub mod check_nonce { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckNonce(#[codec(compact)] pub ::core::primitive::u32); - } - - pub mod check_spec_version { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckSpecVersion; - } - - pub mod check_tx_version { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckTxVersion; - } - - pub mod check_weight { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct CheckWeight; - } - } - - pub mod limits { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct BlockLength { - pub max: runtime_types::frame_support::weights::PerDispatchClass<::core::primitive::u32>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct BlockWeights { - pub base_block: ::core::primitive::u64, - pub max_block: ::core::primitive::u64, - pub per_class: runtime_types::frame_support::weights::PerDispatchClass, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct WeightsPerClass { - pub base_extrinsic: ::core::primitive::u64, - pub max_extrinsic: ::core::option::Option<::core::primitive::u64>, - pub max_total: ::core::option::Option<::core::primitive::u64>, - pub reserved: ::core::option::Option<::core::primitive::u64>, - } - } - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "A dispatch that will fill the block weight up to the given ratio."] fill_block { ratio: runtime_types::sp_arithmetic::per_things::Perbill }, - #[codec(index = 1)] - #[doc = "Make some on-chain remark."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(1)`"] - #[doc = "# "] remark { remark: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 2)] - #[doc = "Set the number of pages in the WebAssembly environment's heap."] set_heap_pages { pages: ::core::primitive::u64 }, - #[codec(index = 3)] - #[doc = "Set the new runtime code."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(C + S)` where `C` length of `code` and `S` complexity of `can_set_code`"] - #[doc = "- 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is"] - #[doc = " expensive)."] - #[doc = "- 1 storage write (codec `O(C)`)."] - #[doc = "- 1 digest item."] - #[doc = "- 1 event."] - #[doc = "The weight of this function is dependent on the runtime, but generally this is very"] - #[doc = "expensive. We will treat this as a full block."] - #[doc = "# "] set_code { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 4)] - #[doc = "Set the new runtime code without doing any checks of the given `code`."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(C)` where `C` length of `code`"] - #[doc = "- 1 storage write (codec `O(C)`)."] - #[doc = "- 1 digest item."] - #[doc = "- 1 event."] - #[doc = "The weight of this function is dependent on the runtime. We will treat this as a full"] - #[doc = "block. # "] set_code_without_checks { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 5)] - #[doc = "Set some items of storage."] set_storage { items: ::std::vec::Vec<(::std::vec::Vec<::core::primitive::u8>, ::std::vec::Vec<::core::primitive::u8>, )> }, - #[codec(index = 6)] - #[doc = "Kill some items from storage."] kill_storage { keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>> }, - #[codec(index = 7)] - #[doc = "Kill all storage items with a key that starts with the given prefix."] - #[doc = ""] - #[doc = "**NOTE:** We rely on the Root origin to provide us the number of subkeys under"] - #[doc = "the prefix we are removing to accurately calculate the weight of this function."] kill_prefix { prefix: ::std::vec::Vec<::core::primitive::u8>, subkeys: ::core::primitive::u32 }, - #[codec(index = 8)] - #[doc = "Make some on-chain remark and emit event."] remark_with_event { remark: ::std::vec::Vec<::core::primitive::u8> }, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Error for the System pallet"] - pub enum Error { - #[codec(index = 0)] - #[doc = "The name of specification does not match between the current runtime"] - #[doc = "and the new runtime."] InvalidSpecName, - #[codec(index = 1)] - #[doc = "The specification version is not allowed to decrease between the current runtime"] - #[doc = "and the new runtime."] SpecVersionNeedsToIncrease, - #[codec(index = 2)] - #[doc = "Failed to extract the runtime version from the new runtime."] - #[doc = ""] - #[doc = "Either calling `Core_version` or decoding `RuntimeVersion` failed."] FailedToExtractRuntimeVersion, - #[codec(index = 3)] - #[doc = "Suicide called when the account has non-default composite data."] NonDefaultComposite, - #[codec(index = 4)] - #[doc = "There is a non-zero reference count preventing the account from being purged."] NonZeroRefCount, - #[codec(index = 5)] - #[doc = "The origin filter prevent the call to be dispatched."] CallFiltered, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Event for the System pallet."] - pub enum Event { - #[codec(index = 0)] - #[doc = "An extrinsic completed successfully."] ExtrinsicSuccess { dispatch_info: runtime_types::frame_support::weights::DispatchInfo }, - #[codec(index = 1)] - #[doc = "An extrinsic failed."] ExtrinsicFailed { dispatch_error: runtime_types::sp_runtime::DispatchError, dispatch_info: runtime_types::frame_support::weights::DispatchInfo }, - #[codec(index = 2)] - #[doc = "`:code` was updated."] CodeUpdated, - #[codec(index = 3)] - #[doc = "A new account was created."] NewAccount { account: ::subxt::ext::sp_core::crypto::AccountId32 }, - #[codec(index = 4)] - #[doc = "An account was reaped."] KilledAccount { account: ::subxt::ext::sp_core::crypto::AccountId32 }, - #[codec(index = 5)] - #[doc = "On on-chain remark happened."] Remarked { sender: ::subxt::ext::sp_core::crypto::AccountId32, hash: ::subxt::ext::sp_core::H256 }, - } - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct AccountInfo<_0, _1> { - pub nonce: _0, - pub consumers: _0, - pub providers: _0, - pub sufficients: _0, - pub data: _1, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct EventRecord<_0, _1> { - pub phase: runtime_types::frame_system::Phase, - pub event: _0, - pub topics: ::std::vec::Vec<_1>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct LastRuntimeUpgradeInfo { - #[codec(compact)] pub spec_version: ::core::primitive::u32, - pub spec_name: ::std::string::String, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Phase { #[codec(index = 0)] ApplyExtrinsic(::core::primitive::u32), #[codec(index = 1)] Finalization, #[codec(index = 2)] Initialization } - } - - pub mod pallet_authorship { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "Provide a set of uncles."] set_uncles { new_uncles: ::std::vec::Vec> }, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] - pub enum Error { - #[codec(index = 0)] - #[doc = "The uncle parent not in the chain."] InvalidUncleParent, - #[codec(index = 1)] - #[doc = "Uncles already set in the block."] UnclesAlreadySet, - #[codec(index = 2)] - #[doc = "Too many uncles."] TooManyUncles, - #[codec(index = 3)] - #[doc = "The uncle is genesis."] GenesisUncle, - #[codec(index = 4)] - #[doc = "The uncle is too high in chain."] TooHighUncle, - #[codec(index = 5)] - #[doc = "The uncle is already included."] UncleAlreadyIncluded, - #[codec(index = 6)] - #[doc = "The uncle isn't recent enough to be included."] OldUncle, - } - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum UncleEntryItem<_0, _1, _2> { #[codec(index = 0)] InclusionHeight(_0), #[codec(index = 1)] Uncle(_1, ::core::option::Option<_2>) } - } - - pub mod pallet_balances { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "Transfer some liquid free balance to another account."] - #[doc = ""] - #[doc = "`transfer` will set the `FreeBalance` of the sender and receiver."] - #[doc = "If the sender's account is below the existential deposit as a result"] - #[doc = "of the transfer, the account will be reaped."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be `Signed` by the transactor."] - #[doc = ""] - #[doc = "# "] - #[doc = "- Dependent on arguments but not critical, given proper implementations for input config"] - #[doc = " types. See related functions below."] - #[doc = "- It contains a limited number of reads and writes internally and no complex"] - #[doc = " computation."] - #[doc = ""] - #[doc = "Related functions:"] - #[doc = ""] - #[doc = " - `ensure_can_withdraw` is always called internally but has a bounded complexity."] - #[doc = " - Transferring balances to accounts that did not exist before will cause"] - #[doc = " `T::OnNewAccount::on_new_account` to be called."] - #[doc = " - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`."] - #[doc = " - `transfer_keep_alive` works the same way as `transfer`, but has an additional check"] - #[doc = " that the transfer will not kill the origin account."] - #[doc = "---------------------------------"] - #[doc = "- Origin account is already in memory, so no DB operations for them."] - #[doc = "# "] transfer { dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, #[codec(compact)] value: ::core::primitive::u128 }, - #[codec(index = 1)] - #[doc = "Set the balances of a given account."] - #[doc = ""] - #[doc = "This will alter `FreeBalance` and `ReservedBalance` in storage. it will"] - #[doc = "also alter the total issuance of the system (`TotalIssuance`) appropriately."] - #[doc = "If the new free or reserved balance is below the existential deposit,"] - #[doc = "it will reset the account nonce (`frame_system::AccountNonce`)."] - #[doc = ""] - #[doc = "The dispatch origin for this call is `root`."] set_balance { who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, #[codec(compact)] new_free: ::core::primitive::u128, #[codec(compact)] new_reserved: ::core::primitive::u128 }, - #[codec(index = 2)] - #[doc = "Exactly as `transfer`, except the origin must be root and the source account may be"] - #[doc = "specified."] - #[doc = "# "] - #[doc = "- Same as transfer, but additional read and write because the source account is not"] - #[doc = " assumed to be in the overlay."] - #[doc = "# "] force_transfer { source: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, #[codec(compact)] value: ::core::primitive::u128 }, - #[codec(index = 3)] - #[doc = "Same as the [`transfer`] call, but with a check that the transfer will not kill the"] - #[doc = "origin account."] - #[doc = ""] - #[doc = "99% of the time you want [`transfer`] instead."] - #[doc = ""] - #[doc = "[`transfer`]: struct.Pallet.html#method.transfer"] transfer_keep_alive { dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, #[codec(compact)] value: ::core::primitive::u128 }, - #[codec(index = 4)] - #[doc = "Transfer the entire transferable balance from the caller account."] - #[doc = ""] - #[doc = "NOTE: This function only attempts to transfer _transferable_ balances. This means that"] - #[doc = "any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be"] - #[doc = "transferred by this function. To ensure that this function results in a killed account,"] - #[doc = "you might need to prepare the account by removing any reference counters, storage"] - #[doc = "deposits, etc..."] - #[doc = ""] - #[doc = "The dispatch origin of this call must be Signed."] - #[doc = ""] - #[doc = "- `dest`: The recipient of the transfer."] - #[doc = "- `keep_alive`: A boolean to determine if the `transfer_all` operation should send all"] - #[doc = " of the funds the account has, causing the sender account to be killed (false), or"] - #[doc = " transfer everything except at least the existential deposit, which will guarantee to"] - #[doc = " keep the sender account alive (true). # "] - #[doc = "- O(1). Just like transfer, but reading the user's transferable balance first."] - #[doc = " #"] transfer_all { dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, keep_alive: ::core::primitive::bool }, - #[codec(index = 5)] - #[doc = "Unreserve some balance from a user by force."] - #[doc = ""] - #[doc = "Can only be called by ROOT."] force_unreserve { who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, amount: ::core::primitive::u128 }, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] - pub enum Error { - #[codec(index = 0)] - #[doc = "Vesting balance too high to send value"] VestingBalance, - #[codec(index = 1)] - #[doc = "Account liquidity restrictions prevent withdrawal"] LiquidityRestrictions, - #[codec(index = 2)] - #[doc = "Balance too low to send value"] InsufficientBalance, - #[codec(index = 3)] - #[doc = "Value too low to create account due to existential deposit"] ExistentialDeposit, - #[codec(index = 4)] - #[doc = "Transfer/payment would kill account"] KeepAlive, - #[codec(index = 5)] - #[doc = "A vesting schedule already exists for this account"] ExistingVestingSchedule, - #[codec(index = 6)] - #[doc = "Beneficiary account must pre-exist"] DeadAccount, - #[codec(index = 7)] - #[doc = "Number of named reserves exceed MaxReserves"] TooManyReserves, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub enum Event { - #[codec(index = 0)] - #[doc = "An account was created with some free balance."] Endowed { account: ::subxt::ext::sp_core::crypto::AccountId32, free_balance: ::core::primitive::u128 }, - #[codec(index = 1)] - #[doc = "An account was removed whose balance was non-zero but below ExistentialDeposit,"] - #[doc = "resulting in an outright loss."] DustLost { account: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 2)] - #[doc = "Transfer succeeded."] Transfer { from: ::subxt::ext::sp_core::crypto::AccountId32, to: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 3)] - #[doc = "A balance was set by root."] BalanceSet { who: ::subxt::ext::sp_core::crypto::AccountId32, free: ::core::primitive::u128, reserved: ::core::primitive::u128 }, - #[codec(index = 4)] - #[doc = "Some balance was reserved (moved from free to reserved)."] Reserved { who: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 5)] - #[doc = "Some balance was unreserved (moved from reserved to free)."] Unreserved { who: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 6)] - #[doc = "Some balance was moved from the reserve of the first account to the second account."] - #[doc = "Final argument indicates the destination balance type."] ReserveRepatriated { from: ::subxt::ext::sp_core::crypto::AccountId32, to: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128, destination_status: runtime_types::frame_support::traits::tokens::misc::BalanceStatus }, - #[codec(index = 7)] - #[doc = "Some amount was deposited (e.g. for transaction fees)."] Deposit { who: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 8)] - #[doc = "Some amount was withdrawn from the account (e.g. for transaction fees)."] Withdraw { who: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 9)] - #[doc = "Some amount was removed from the account (e.g. for misbehavior)."] Slashed { who: ::subxt::ext::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - } - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct AccountData<_0> { - pub free: _0, - pub reserved: _0, - pub misc_frozen: _0, - pub fee_frozen: _0, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct BalanceLock<_0> { - pub id: [::core::primitive::u8; 8usize], - pub amount: _0, - pub reasons: runtime_types::pallet_balances::Reasons, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Reasons { #[codec(index = 0)] Fee, #[codec(index = 1)] Misc, #[codec(index = 2)] All } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Releases { #[codec(index = 0)] V1_0_0, #[codec(index = 1)] V2_0_0 } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct ReserveData<_0, _1> { - pub id: _0, - pub amount: _1, - } - } - - pub mod pallet_contracts { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "Makes a call to an account, optionally transferring some balance."] - #[doc = ""] - #[doc = "# Parameters"] - #[doc = ""] - #[doc = "* `dest`: Address of the contract to call."] - #[doc = "* `value`: The balance to transfer from the `origin` to `dest`."] - #[doc = "* `gas_limit`: The gas limit enforced when executing the constructor."] - #[doc = "* `storage_deposit_limit`: The maximum amount of balance that can be charged from the"] - #[doc = " caller to pay for the storage consumed."] - #[doc = "* `data`: The input data to pass to the contract."] - #[doc = ""] - #[doc = "* If the account is a smart-contract account, the associated code will be"] - #[doc = "executed and any value will be transferred."] - #[doc = "* If the account is a regular account, any value will be transferred."] - #[doc = "* If no account exists and the call value is not less than `existential_deposit`,"] - #[doc = "a regular account will be created and any value will be transferred."] call { dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, #[codec(compact)] value: ::core::primitive::u128, #[codec(compact)] gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, data: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 1)] - #[doc = "Instantiates a new contract from the supplied `code` optionally transferring"] - #[doc = "some balance."] - #[doc = ""] - #[doc = "This dispatchable has the same effect as calling [`Self::upload_code`] +"] - #[doc = "[`Self::instantiate`]. Bundling them together provides efficiency gains. Please"] - #[doc = "also check the documentation of [`Self::upload_code`]."] - #[doc = ""] - #[doc = "# Parameters"] - #[doc = ""] - #[doc = "* `value`: The balance to transfer from the `origin` to the newly created contract."] - #[doc = "* `gas_limit`: The gas limit enforced when executing the constructor."] - #[doc = "* `storage_deposit_limit`: The maximum amount of balance that can be charged/reserved"] - #[doc = " from the caller to pay for the storage consumed."] - #[doc = "* `code`: The contract code to deploy in raw bytes."] - #[doc = "* `data`: The input data to pass to the contract constructor."] - #[doc = "* `salt`: Used for the address derivation. See [`Pallet::contract_address`]."] - #[doc = ""] - #[doc = "Instantiation is executed as follows:"] - #[doc = ""] - #[doc = "- The supplied `code` is instrumented, deployed, and a `code_hash` is created for that"] - #[doc = " code."] - #[doc = "- If the `code_hash` already exists on the chain the underlying `code` will be shared."] - #[doc = "- The destination address is computed based on the sender, code_hash and the salt."] - #[doc = "- The smart-contract account is created at the computed address."] - #[doc = "- The `value` is transferred to the new account."] - #[doc = "- The `deploy` function is executed in the context of the newly-created account."] instantiate_with_code { #[codec(compact)] value: ::core::primitive::u128, #[codec(compact)] gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, code: ::std::vec::Vec<::core::primitive::u8>, data: ::std::vec::Vec<::core::primitive::u8>, salt: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 2)] - #[doc = "Instantiates a contract from a previously deployed wasm binary."] - #[doc = ""] - #[doc = "This function is identical to [`Self::instantiate_with_code`] but without the"] - #[doc = "code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary"] - #[doc = "must be supplied."] instantiate { #[codec(compact)] value: ::core::primitive::u128, #[codec(compact)] gas_limit: ::core::primitive::u64, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>>, code_hash: ::subxt::ext::sp_core::H256, data: ::std::vec::Vec<::core::primitive::u8>, salt: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 3)] - #[doc = "Upload new `code` without instantiating a contract from it."] - #[doc = ""] - #[doc = "If the code does not already exist a deposit is reserved from the caller"] - #[doc = "and unreserved only when [`Self::remove_code`] is called. The size of the reserve"] - #[doc = "depends on the instrumented size of the the supplied `code`."] - #[doc = ""] - #[doc = "If the code already exists in storage it will still return `Ok` and upgrades"] - #[doc = "the in storage version to the current"] - #[doc = "[`InstructionWeights::version`](InstructionWeights)."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "Anyone can instantiate a contract from any uploaded code and thus prevent its removal."] - #[doc = "To avoid this situation a constructor could employ access control so that it can"] - #[doc = "only be instantiated by permissioned entities. The same is true when uploading"] - #[doc = "through [`Self::instantiate_with_code`]."] upload_code { code: ::std::vec::Vec<::core::primitive::u8>, storage_deposit_limit: ::core::option::Option<::subxt::ext::codec::Compact<::core::primitive::u128>> }, - #[codec(index = 4)] - #[doc = "Remove the code stored under `code_hash` and refund the deposit to its owner."] - #[doc = ""] - #[doc = "A code can only be removed by its original uploader (its owner) and only if it is"] - #[doc = "not used by any contract."] remove_code { code_hash: ::subxt::ext::sp_core::H256 }, - #[codec(index = 5)] - #[doc = "Privileged function that changes the code of an existing contract."] - #[doc = ""] - #[doc = "This takes care of updating refcounts and all other necessary operations. Returns"] - #[doc = "an error if either the `code_hash` or `dest` do not exist."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "This does **not** change the address of the contract in question. This means"] - #[doc = "that the contract address is no longer derived from its code hash after calling"] - #[doc = "this dispatchable."] set_code { dest: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, code_hash: ::subxt::ext::sp_core::H256 }, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] - pub enum Error { - #[codec(index = 0)] - #[doc = "A new schedule must have a greater version than the current one."] InvalidScheduleVersion, - #[codec(index = 1)] - #[doc = "Invalid combination of flags supplied to `seal_call` or `seal_delegate_call`."] InvalidCallFlags, - #[codec(index = 2)] - #[doc = "The executed contract exhausted its gas limit."] OutOfGas, - #[codec(index = 3)] - #[doc = "The output buffer supplied to a contract API call was too small."] OutputBufferTooSmall, - #[codec(index = 4)] - #[doc = "Performing the requested transfer failed. Probably because there isn't enough"] - #[doc = "free balance in the sender's account."] TransferFailed, - #[codec(index = 5)] - #[doc = "Performing a call was denied because the calling depth reached the limit"] - #[doc = "of what is specified in the schedule."] MaxCallDepthReached, - #[codec(index = 6)] - #[doc = "No contract was found at the specified address."] ContractNotFound, - #[codec(index = 7)] - #[doc = "The code supplied to `instantiate_with_code` exceeds the limit specified in the"] - #[doc = "current schedule."] CodeTooLarge, - #[codec(index = 8)] - #[doc = "No code could be found at the supplied code hash."] CodeNotFound, - #[codec(index = 9)] - #[doc = "A buffer outside of sandbox memory was passed to a contract API function."] OutOfBounds, - #[codec(index = 10)] - #[doc = "Input passed to a contract API function failed to decode as expected type."] DecodingFailed, - #[codec(index = 11)] - #[doc = "Contract trapped during execution."] ContractTrapped, - #[codec(index = 12)] - #[doc = "The size defined in `T::MaxValueSize` was exceeded."] ValueTooLarge, - #[codec(index = 13)] - #[doc = "Termination of a contract is not allowed while the contract is already"] - #[doc = "on the call stack. Can be triggered by `seal_terminate`."] TerminatedWhileReentrant, - #[codec(index = 14)] - #[doc = "`seal_call` forwarded this contracts input. It therefore is no longer available."] InputForwarded, - #[codec(index = 15)] - #[doc = "The subject passed to `seal_random` exceeds the limit."] RandomSubjectTooLong, - #[codec(index = 16)] - #[doc = "The amount of topics passed to `seal_deposit_events` exceeds the limit."] TooManyTopics, - #[codec(index = 17)] - #[doc = "The topics passed to `seal_deposit_events` contains at least one duplicate."] DuplicateTopics, - #[codec(index = 18)] - #[doc = "The chain does not provide a chain extension. Calling the chain extension results"] - #[doc = "in this error. Note that this usually shouldn't happen as deploying such contracts"] - #[doc = "is rejected."] NoChainExtension, - #[codec(index = 19)] - #[doc = "Removal of a contract failed because the deletion queue is full."] - #[doc = ""] - #[doc = "This can happen when calling `seal_terminate`."] - #[doc = "The queue is filled by deleting contracts and emptied by a fixed amount each block."] - #[doc = "Trying again during another block is the only way to resolve this issue."] DeletionQueueFull, - #[codec(index = 20)] - #[doc = "A contract with the same AccountId already exists."] DuplicateContract, - #[codec(index = 21)] - #[doc = "A contract self destructed in its constructor."] - #[doc = ""] - #[doc = "This can be triggered by a call to `seal_terminate`."] TerminatedInConstructor, - #[codec(index = 22)] - #[doc = "The debug message specified to `seal_debug_message` does contain invalid UTF-8."] DebugMessageInvalidUTF8, - #[codec(index = 23)] - #[doc = "A call tried to invoke a contract that is flagged as non-reentrant."] ReentranceDenied, - #[codec(index = 24)] - #[doc = "Origin doesn't have enough balance to pay the required storage deposits."] StorageDepositNotEnoughFunds, - #[codec(index = 25)] - #[doc = "More storage was created than allowed by the storage deposit limit."] StorageDepositLimitExhausted, - #[codec(index = 26)] - #[doc = "Code removal was denied because the code is still in use by at least one contract."] CodeInUse, - #[codec(index = 27)] - #[doc = "The contract ran to completion but decided to revert its storage changes."] - #[doc = "Please note that this error is only returned from extrinsics. When called directly"] - #[doc = "or via RPC an `Ok` will be returned. In this case the caller needs to inspect the flags"] - #[doc = "to determine whether a reversion has taken place."] ContractReverted, - #[codec(index = 28)] - #[doc = "The contract's code was found to be invalid during validation or instrumentation."] - #[doc = "A more detailed error can be found on the node console if debug messages are enabled"] - #[doc = "or in the debug buffer which is returned to RPC clients."] CodeRejected, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub enum Event { - #[codec(index = 0)] - #[doc = "Contract deployed by address at the specified address."] Instantiated { deployer: ::subxt::ext::sp_core::crypto::AccountId32, contract: ::subxt::ext::sp_core::crypto::AccountId32 }, - #[codec(index = 1)] - #[doc = "Contract has been removed."] - #[doc = ""] - #[doc = "# Note"] - #[doc = ""] - #[doc = "The only way for a contract to be removed and emitting this event is by calling"] - #[doc = "`seal_terminate`."] Terminated { contract: ::subxt::ext::sp_core::crypto::AccountId32, beneficiary: ::subxt::ext::sp_core::crypto::AccountId32 }, - #[codec(index = 2)] - #[doc = "Code with the specified hash has been stored."] CodeStored { code_hash: ::subxt::ext::sp_core::H256 }, - #[codec(index = 3)] - #[doc = "A custom event emitted by the contract."] ContractEmitted { contract: ::subxt::ext::sp_core::crypto::AccountId32, data: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 4)] - #[doc = "A code with the specified hash was removed."] CodeRemoved { code_hash: ::subxt::ext::sp_core::H256 }, - #[codec(index = 5)] - #[doc = "A contract's code was updated."] ContractCodeUpdated { contract: ::subxt::ext::sp_core::crypto::AccountId32, new_code_hash: ::subxt::ext::sp_core::H256, old_code_hash: ::subxt::ext::sp_core::H256 }, - } - } - - pub mod schedule { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct HostFnWeights { - pub caller: ::core::primitive::u64, - pub is_contract: ::core::primitive::u64, - pub code_hash: ::core::primitive::u64, - pub own_code_hash: ::core::primitive::u64, - pub caller_is_origin: ::core::primitive::u64, - pub address: ::core::primitive::u64, - pub gas_left: ::core::primitive::u64, - pub balance: ::core::primitive::u64, - pub value_transferred: ::core::primitive::u64, - pub minimum_balance: ::core::primitive::u64, - pub block_number: ::core::primitive::u64, - pub now: ::core::primitive::u64, - pub weight_to_fee: ::core::primitive::u64, - pub gas: ::core::primitive::u64, - pub input: ::core::primitive::u64, - pub input_per_byte: ::core::primitive::u64, - pub r#return: ::core::primitive::u64, - pub return_per_byte: ::core::primitive::u64, - pub terminate: ::core::primitive::u64, - pub random: ::core::primitive::u64, - pub deposit_event: ::core::primitive::u64, - pub deposit_event_per_topic: ::core::primitive::u64, - pub deposit_event_per_byte: ::core::primitive::u64, - pub debug_message: ::core::primitive::u64, - pub set_storage: ::core::primitive::u64, - pub set_storage_per_new_byte: ::core::primitive::u64, - pub set_storage_per_old_byte: ::core::primitive::u64, - pub set_code_hash: ::core::primitive::u64, - pub clear_storage: ::core::primitive::u64, - pub clear_storage_per_byte: ::core::primitive::u64, - pub contains_storage: ::core::primitive::u64, - pub contains_storage_per_byte: ::core::primitive::u64, - pub get_storage: ::core::primitive::u64, - pub get_storage_per_byte: ::core::primitive::u64, - pub take_storage: ::core::primitive::u64, - pub take_storage_per_byte: ::core::primitive::u64, - pub transfer: ::core::primitive::u64, - pub call: ::core::primitive::u64, - pub delegate_call: ::core::primitive::u64, - pub call_transfer_surcharge: ::core::primitive::u64, - pub call_per_cloned_byte: ::core::primitive::u64, - pub instantiate: ::core::primitive::u64, - pub instantiate_transfer_surcharge: ::core::primitive::u64, - pub instantiate_per_salt_byte: ::core::primitive::u64, - pub hash_sha2_256: ::core::primitive::u64, - pub hash_sha2_256_per_byte: ::core::primitive::u64, - pub hash_keccak_256: ::core::primitive::u64, - pub hash_keccak_256_per_byte: ::core::primitive::u64, - pub hash_blake2_256: ::core::primitive::u64, - pub hash_blake2_256_per_byte: ::core::primitive::u64, - pub hash_blake2_128: ::core::primitive::u64, - pub hash_blake2_128_per_byte: ::core::primitive::u64, - pub ecdsa_recover: ::core::primitive::u64, - pub ecdsa_to_eth_address: ::core::primitive::u64, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct InstructionWeights { - pub version: ::core::primitive::u32, - pub i64const: ::core::primitive::u32, - pub i64load: ::core::primitive::u32, - pub i64store: ::core::primitive::u32, - pub select: ::core::primitive::u32, - pub r#if: ::core::primitive::u32, - pub br: ::core::primitive::u32, - pub br_if: ::core::primitive::u32, - pub br_table: ::core::primitive::u32, - pub br_table_per_entry: ::core::primitive::u32, - pub call: ::core::primitive::u32, - pub call_indirect: ::core::primitive::u32, - pub call_indirect_per_param: ::core::primitive::u32, - pub local_get: ::core::primitive::u32, - pub local_set: ::core::primitive::u32, - pub local_tee: ::core::primitive::u32, - pub global_get: ::core::primitive::u32, - pub global_set: ::core::primitive::u32, - pub memory_current: ::core::primitive::u32, - pub memory_grow: ::core::primitive::u32, - pub i64clz: ::core::primitive::u32, - pub i64ctz: ::core::primitive::u32, - pub i64popcnt: ::core::primitive::u32, - pub i64eqz: ::core::primitive::u32, - pub i64extendsi32: ::core::primitive::u32, - pub i64extendui32: ::core::primitive::u32, - pub i32wrapi64: ::core::primitive::u32, - pub i64eq: ::core::primitive::u32, - pub i64ne: ::core::primitive::u32, - pub i64lts: ::core::primitive::u32, - pub i64ltu: ::core::primitive::u32, - pub i64gts: ::core::primitive::u32, - pub i64gtu: ::core::primitive::u32, - pub i64les: ::core::primitive::u32, - pub i64leu: ::core::primitive::u32, - pub i64ges: ::core::primitive::u32, - pub i64geu: ::core::primitive::u32, - pub i64add: ::core::primitive::u32, - pub i64sub: ::core::primitive::u32, - pub i64mul: ::core::primitive::u32, - pub i64divs: ::core::primitive::u32, - pub i64divu: ::core::primitive::u32, - pub i64rems: ::core::primitive::u32, - pub i64remu: ::core::primitive::u32, - pub i64and: ::core::primitive::u32, - pub i64or: ::core::primitive::u32, - pub i64xor: ::core::primitive::u32, - pub i64shl: ::core::primitive::u32, - pub i64shrs: ::core::primitive::u32, - pub i64shru: ::core::primitive::u32, - pub i64rotl: ::core::primitive::u32, - pub i64rotr: ::core::primitive::u32, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Limits { - pub event_topics: ::core::primitive::u32, - pub stack_height: ::core::option::Option<::core::primitive::u32>, - pub globals: ::core::primitive::u32, - pub parameters: ::core::primitive::u32, - pub memory_pages: ::core::primitive::u32, - pub table_size: ::core::primitive::u32, - pub br_table_size: ::core::primitive::u32, - pub subject_len: ::core::primitive::u32, - pub call_depth: ::core::primitive::u32, - pub payload_len: ::core::primitive::u32, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Schedule { - pub limits: runtime_types::pallet_contracts::schedule::Limits, - pub instruction_weights: runtime_types::pallet_contracts::schedule::InstructionWeights, - pub host_fn_weights: runtime_types::pallet_contracts::schedule::HostFnWeights, - } - } - - pub mod storage { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct DeletedContract { - pub trie_id: runtime_types::sp_runtime::bounded::bounded_vec::BoundedVec<::core::primitive::u8>, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct RawContractInfo<_0, _1> { - pub trie_id: runtime_types::sp_runtime::bounded::bounded_vec::BoundedVec<::core::primitive::u8>, - pub code_hash: _0, - pub storage_deposit: _1, - } - } - - pub mod wasm { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct OwnerInfo { - pub owner: ::subxt::ext::sp_core::crypto::AccountId32, - #[codec(compact)] pub deposit: ::core::primitive::u128, - #[codec(compact)] pub refcount: ::core::primitive::u64, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct PrefabWasmModule { - #[codec(compact)] pub instruction_weights_version: ::core::primitive::u32, - #[codec(compact)] pub initial: ::core::primitive::u32, - #[codec(compact)] pub maximum: ::core::primitive::u32, - pub code: runtime_types::sp_runtime::bounded::bounded_vec::BoundedVec<::core::primitive::u8>, - } - } - } - - pub mod pallet_sudo { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "Authenticates the sudo key and dispatches a function call with `Root` origin."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB write (event)."] - #[doc = "- Weight of derivative `call` execution + 10,000."] - #[doc = "# "] sudo { call: ::std::boxed::Box }, - #[codec(index = 1)] - #[doc = "Authenticates the sudo key and dispatches a function call with `Root` origin."] - #[doc = "This function does not check the weight of the call, and instead allows the"] - #[doc = "Sudo user to specify the weight of the call."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- The weight of this call is defined by the caller."] - #[doc = "# "] sudo_unchecked_weight { call: ::std::boxed::Box, weight: ::core::primitive::u64 }, - #[codec(index = 2)] - #[doc = "Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo"] - #[doc = "key."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB change."] - #[doc = "# "] set_key { new: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()> }, - #[codec(index = 3)] - #[doc = "Authenticates the sudo key and dispatches a function call with `Signed` origin from"] - #[doc = "a given account."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be _Signed_."] - #[doc = ""] - #[doc = "# "] - #[doc = "- O(1)."] - #[doc = "- Limited storage reads."] - #[doc = "- One DB write (event)."] - #[doc = "- Weight of derivative `call` execution + 10,000."] - #[doc = "# "] sudo_as { who: ::subxt::ext::sp_runtime::MultiAddress<::subxt::ext::sp_core::crypto::AccountId32, ()>, call: ::std::boxed::Box }, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Error for the Sudo pallet"] - pub enum Error { - #[codec(index = 0)] - #[doc = "Sender must be the Sudo account"] RequireSudo, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub enum Event { - #[codec(index = 0)] - #[doc = "A sudo just took place. \\[result\\]"] Sudid { sudo_result: ::core::result::Result<(), runtime_types::sp_runtime::DispatchError> }, - #[codec(index = 1)] - #[doc = "The \\[sudoer\\] just switched identity; the old key is supplied if one existed."] KeyChanged { old_sudoer: ::core::option::Option<::subxt::ext::sp_core::crypto::AccountId32> }, - #[codec(index = 2)] - #[doc = "A sudo just took place. \\[result\\]"] SudoAsDone { sudo_result: ::core::result::Result<(), runtime_types::sp_runtime::DispatchError> }, - } - } - } - - pub mod pallet_timestamp { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] - pub enum Call { - #[codec(index = 0)] - #[doc = "Set the current time."] - #[doc = ""] - #[doc = "This call should be invoked exactly once per block. It will panic at the finalization"] - #[doc = "phase, if this call hasn't been invoked by that time."] - #[doc = ""] - #[doc = "The timestamp should be greater than the previous one by the amount specified by"] - #[doc = "`MinimumPeriod`."] - #[doc = ""] - #[doc = "The dispatch origin for this call must be `Inherent`."] - #[doc = ""] - #[doc = "# "] - #[doc = "- `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)"] - #[doc = "- 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in"] - #[doc = " `on_finalize`)"] - #[doc = "- 1 event handler `on_timestamp_set`. Must be `O(1)`."] - #[doc = "# "] set { #[codec(compact)] now: ::core::primitive::u64 }, - } - } - } - - pub mod pallet_transaction_payment { - use super::runtime_types; - - pub mod pallet { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - #[doc = "\n\t\t\tThe [event](https://docs.substrate.io/main-docs/build/events-errors/) emitted\n\t\t\tby this pallet.\n\t\t\t"] - pub enum Event { - #[codec(index = 0)] - #[doc = "A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,"] - #[doc = "has been paid by `who`."] TransactionFeePaid { who: ::subxt::ext::sp_core::crypto::AccountId32, actual_fee: ::core::primitive::u128, tip: ::core::primitive::u128 }, - } - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct ChargeTransactionPayment(#[codec(compact)] pub ::core::primitive::u128); - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Releases { #[codec(index = 0)] V1Ancient, #[codec(index = 1)] V2 } - } - - pub mod primitive_types { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct H256(pub [::core::primitive::u8; 32usize]); - } - - pub mod sp_arithmetic { - use super::runtime_types; - - pub mod fixed_point { - use super::runtime_types; - - #[derive(::subxt::ext::codec::CompactAs, ::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct FixedU128(pub ::core::primitive::u128); - } - - pub mod per_things { - use super::runtime_types; - - #[derive(::subxt::ext::codec::CompactAs, ::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Perbill(pub ::core::primitive::u32); - } - } - - pub mod sp_core { - use super::runtime_types; - - pub mod crypto { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct AccountId32(pub [::core::primitive::u8; 32usize]); - } - - pub mod ecdsa { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Signature(pub [::core::primitive::u8; 65usize]); - } - - pub mod ed25519 { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - - pub mod sr25519 { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - } - - pub mod sp_runtime { - use super::runtime_types; - - pub mod bounded { - use super::runtime_types; - - pub mod bounded_vec { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct BoundedVec<_0> (pub ::std::vec::Vec<_0>); - } - - pub mod weak_bounded_vec { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct WeakBoundedVec<_0> (pub ::std::vec::Vec<_0>); - } - } - - pub mod generic { - use super::runtime_types; - - pub mod digest { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Digest { - pub logs: ::std::vec::Vec, - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum DigestItem { #[codec(index = 6)] PreRuntime([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), #[codec(index = 4)] Consensus([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), #[codec(index = 5)] Seal([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), #[codec(index = 0)] Other(::std::vec::Vec<::core::primitive::u8>), #[codec(index = 8)] RuntimeEnvironmentUpdated } - } - - pub mod era { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum Era { - #[codec(index = 0)] Immortal, - #[codec(index = 1)] Mortal1(::core::primitive::u8), - #[codec(index = 2)] Mortal2(::core::primitive::u8), - #[codec(index = 3)] Mortal3(::core::primitive::u8), - #[codec(index = 4)] Mortal4(::core::primitive::u8), - #[codec(index = 5)] Mortal5(::core::primitive::u8), - #[codec(index = 6)] Mortal6(::core::primitive::u8), - #[codec(index = 7)] Mortal7(::core::primitive::u8), - #[codec(index = 8)] Mortal8(::core::primitive::u8), - #[codec(index = 9)] Mortal9(::core::primitive::u8), - #[codec(index = 10)] Mortal10(::core::primitive::u8), - #[codec(index = 11)] Mortal11(::core::primitive::u8), - #[codec(index = 12)] Mortal12(::core::primitive::u8), - #[codec(index = 13)] Mortal13(::core::primitive::u8), - #[codec(index = 14)] Mortal14(::core::primitive::u8), - #[codec(index = 15)] Mortal15(::core::primitive::u8), - #[codec(index = 16)] Mortal16(::core::primitive::u8), - #[codec(index = 17)] Mortal17(::core::primitive::u8), - #[codec(index = 18)] Mortal18(::core::primitive::u8), - #[codec(index = 19)] Mortal19(::core::primitive::u8), - #[codec(index = 20)] Mortal20(::core::primitive::u8), - #[codec(index = 21)] Mortal21(::core::primitive::u8), - #[codec(index = 22)] Mortal22(::core::primitive::u8), - #[codec(index = 23)] Mortal23(::core::primitive::u8), - #[codec(index = 24)] Mortal24(::core::primitive::u8), - #[codec(index = 25)] Mortal25(::core::primitive::u8), - #[codec(index = 26)] Mortal26(::core::primitive::u8), - #[codec(index = 27)] Mortal27(::core::primitive::u8), - #[codec(index = 28)] Mortal28(::core::primitive::u8), - #[codec(index = 29)] Mortal29(::core::primitive::u8), - #[codec(index = 30)] Mortal30(::core::primitive::u8), - #[codec(index = 31)] Mortal31(::core::primitive::u8), - #[codec(index = 32)] Mortal32(::core::primitive::u8), - #[codec(index = 33)] Mortal33(::core::primitive::u8), - #[codec(index = 34)] Mortal34(::core::primitive::u8), - #[codec(index = 35)] Mortal35(::core::primitive::u8), - #[codec(index = 36)] Mortal36(::core::primitive::u8), - #[codec(index = 37)] Mortal37(::core::primitive::u8), - #[codec(index = 38)] Mortal38(::core::primitive::u8), - #[codec(index = 39)] Mortal39(::core::primitive::u8), - #[codec(index = 40)] Mortal40(::core::primitive::u8), - #[codec(index = 41)] Mortal41(::core::primitive::u8), - #[codec(index = 42)] Mortal42(::core::primitive::u8), - #[codec(index = 43)] Mortal43(::core::primitive::u8), - #[codec(index = 44)] Mortal44(::core::primitive::u8), - #[codec(index = 45)] Mortal45(::core::primitive::u8), - #[codec(index = 46)] Mortal46(::core::primitive::u8), - #[codec(index = 47)] Mortal47(::core::primitive::u8), - #[codec(index = 48)] Mortal48(::core::primitive::u8), - #[codec(index = 49)] Mortal49(::core::primitive::u8), - #[codec(index = 50)] Mortal50(::core::primitive::u8), - #[codec(index = 51)] Mortal51(::core::primitive::u8), - #[codec(index = 52)] Mortal52(::core::primitive::u8), - #[codec(index = 53)] Mortal53(::core::primitive::u8), - #[codec(index = 54)] Mortal54(::core::primitive::u8), - #[codec(index = 55)] Mortal55(::core::primitive::u8), - #[codec(index = 56)] Mortal56(::core::primitive::u8), - #[codec(index = 57)] Mortal57(::core::primitive::u8), - #[codec(index = 58)] Mortal58(::core::primitive::u8), - #[codec(index = 59)] Mortal59(::core::primitive::u8), - #[codec(index = 60)] Mortal60(::core::primitive::u8), - #[codec(index = 61)] Mortal61(::core::primitive::u8), - #[codec(index = 62)] Mortal62(::core::primitive::u8), - #[codec(index = 63)] Mortal63(::core::primitive::u8), - #[codec(index = 64)] Mortal64(::core::primitive::u8), - #[codec(index = 65)] Mortal65(::core::primitive::u8), - #[codec(index = 66)] Mortal66(::core::primitive::u8), - #[codec(index = 67)] Mortal67(::core::primitive::u8), - #[codec(index = 68)] Mortal68(::core::primitive::u8), - #[codec(index = 69)] Mortal69(::core::primitive::u8), - #[codec(index = 70)] Mortal70(::core::primitive::u8), - #[codec(index = 71)] Mortal71(::core::primitive::u8), - #[codec(index = 72)] Mortal72(::core::primitive::u8), - #[codec(index = 73)] Mortal73(::core::primitive::u8), - #[codec(index = 74)] Mortal74(::core::primitive::u8), - #[codec(index = 75)] Mortal75(::core::primitive::u8), - #[codec(index = 76)] Mortal76(::core::primitive::u8), - #[codec(index = 77)] Mortal77(::core::primitive::u8), - #[codec(index = 78)] Mortal78(::core::primitive::u8), - #[codec(index = 79)] Mortal79(::core::primitive::u8), - #[codec(index = 80)] Mortal80(::core::primitive::u8), - #[codec(index = 81)] Mortal81(::core::primitive::u8), - #[codec(index = 82)] Mortal82(::core::primitive::u8), - #[codec(index = 83)] Mortal83(::core::primitive::u8), - #[codec(index = 84)] Mortal84(::core::primitive::u8), - #[codec(index = 85)] Mortal85(::core::primitive::u8), - #[codec(index = 86)] Mortal86(::core::primitive::u8), - #[codec(index = 87)] Mortal87(::core::primitive::u8), - #[codec(index = 88)] Mortal88(::core::primitive::u8), - #[codec(index = 89)] Mortal89(::core::primitive::u8), - #[codec(index = 90)] Mortal90(::core::primitive::u8), - #[codec(index = 91)] Mortal91(::core::primitive::u8), - #[codec(index = 92)] Mortal92(::core::primitive::u8), - #[codec(index = 93)] Mortal93(::core::primitive::u8), - #[codec(index = 94)] Mortal94(::core::primitive::u8), - #[codec(index = 95)] Mortal95(::core::primitive::u8), - #[codec(index = 96)] Mortal96(::core::primitive::u8), - #[codec(index = 97)] Mortal97(::core::primitive::u8), - #[codec(index = 98)] Mortal98(::core::primitive::u8), - #[codec(index = 99)] Mortal99(::core::primitive::u8), - #[codec(index = 100)] Mortal100(::core::primitive::u8), - #[codec(index = 101)] Mortal101(::core::primitive::u8), - #[codec(index = 102)] Mortal102(::core::primitive::u8), - #[codec(index = 103)] Mortal103(::core::primitive::u8), - #[codec(index = 104)] Mortal104(::core::primitive::u8), - #[codec(index = 105)] Mortal105(::core::primitive::u8), - #[codec(index = 106)] Mortal106(::core::primitive::u8), - #[codec(index = 107)] Mortal107(::core::primitive::u8), - #[codec(index = 108)] Mortal108(::core::primitive::u8), - #[codec(index = 109)] Mortal109(::core::primitive::u8), - #[codec(index = 110)] Mortal110(::core::primitive::u8), - #[codec(index = 111)] Mortal111(::core::primitive::u8), - #[codec(index = 112)] Mortal112(::core::primitive::u8), - #[codec(index = 113)] Mortal113(::core::primitive::u8), - #[codec(index = 114)] Mortal114(::core::primitive::u8), - #[codec(index = 115)] Mortal115(::core::primitive::u8), - #[codec(index = 116)] Mortal116(::core::primitive::u8), - #[codec(index = 117)] Mortal117(::core::primitive::u8), - #[codec(index = 118)] Mortal118(::core::primitive::u8), - #[codec(index = 119)] Mortal119(::core::primitive::u8), - #[codec(index = 120)] Mortal120(::core::primitive::u8), - #[codec(index = 121)] Mortal121(::core::primitive::u8), - #[codec(index = 122)] Mortal122(::core::primitive::u8), - #[codec(index = 123)] Mortal123(::core::primitive::u8), - #[codec(index = 124)] Mortal124(::core::primitive::u8), - #[codec(index = 125)] Mortal125(::core::primitive::u8), - #[codec(index = 126)] Mortal126(::core::primitive::u8), - #[codec(index = 127)] Mortal127(::core::primitive::u8), - #[codec(index = 128)] Mortal128(::core::primitive::u8), - #[codec(index = 129)] Mortal129(::core::primitive::u8), - #[codec(index = 130)] Mortal130(::core::primitive::u8), - #[codec(index = 131)] Mortal131(::core::primitive::u8), - #[codec(index = 132)] Mortal132(::core::primitive::u8), - #[codec(index = 133)] Mortal133(::core::primitive::u8), - #[codec(index = 134)] Mortal134(::core::primitive::u8), - #[codec(index = 135)] Mortal135(::core::primitive::u8), - #[codec(index = 136)] Mortal136(::core::primitive::u8), - #[codec(index = 137)] Mortal137(::core::primitive::u8), - #[codec(index = 138)] Mortal138(::core::primitive::u8), - #[codec(index = 139)] Mortal139(::core::primitive::u8), - #[codec(index = 140)] Mortal140(::core::primitive::u8), - #[codec(index = 141)] Mortal141(::core::primitive::u8), - #[codec(index = 142)] Mortal142(::core::primitive::u8), - #[codec(index = 143)] Mortal143(::core::primitive::u8), - #[codec(index = 144)] Mortal144(::core::primitive::u8), - #[codec(index = 145)] Mortal145(::core::primitive::u8), - #[codec(index = 146)] Mortal146(::core::primitive::u8), - #[codec(index = 147)] Mortal147(::core::primitive::u8), - #[codec(index = 148)] Mortal148(::core::primitive::u8), - #[codec(index = 149)] Mortal149(::core::primitive::u8), - #[codec(index = 150)] Mortal150(::core::primitive::u8), - #[codec(index = 151)] Mortal151(::core::primitive::u8), - #[codec(index = 152)] Mortal152(::core::primitive::u8), - #[codec(index = 153)] Mortal153(::core::primitive::u8), - #[codec(index = 154)] Mortal154(::core::primitive::u8), - #[codec(index = 155)] Mortal155(::core::primitive::u8), - #[codec(index = 156)] Mortal156(::core::primitive::u8), - #[codec(index = 157)] Mortal157(::core::primitive::u8), - #[codec(index = 158)] Mortal158(::core::primitive::u8), - #[codec(index = 159)] Mortal159(::core::primitive::u8), - #[codec(index = 160)] Mortal160(::core::primitive::u8), - #[codec(index = 161)] Mortal161(::core::primitive::u8), - #[codec(index = 162)] Mortal162(::core::primitive::u8), - #[codec(index = 163)] Mortal163(::core::primitive::u8), - #[codec(index = 164)] Mortal164(::core::primitive::u8), - #[codec(index = 165)] Mortal165(::core::primitive::u8), - #[codec(index = 166)] Mortal166(::core::primitive::u8), - #[codec(index = 167)] Mortal167(::core::primitive::u8), - #[codec(index = 168)] Mortal168(::core::primitive::u8), - #[codec(index = 169)] Mortal169(::core::primitive::u8), - #[codec(index = 170)] Mortal170(::core::primitive::u8), - #[codec(index = 171)] Mortal171(::core::primitive::u8), - #[codec(index = 172)] Mortal172(::core::primitive::u8), - #[codec(index = 173)] Mortal173(::core::primitive::u8), - #[codec(index = 174)] Mortal174(::core::primitive::u8), - #[codec(index = 175)] Mortal175(::core::primitive::u8), - #[codec(index = 176)] Mortal176(::core::primitive::u8), - #[codec(index = 177)] Mortal177(::core::primitive::u8), - #[codec(index = 178)] Mortal178(::core::primitive::u8), - #[codec(index = 179)] Mortal179(::core::primitive::u8), - #[codec(index = 180)] Mortal180(::core::primitive::u8), - #[codec(index = 181)] Mortal181(::core::primitive::u8), - #[codec(index = 182)] Mortal182(::core::primitive::u8), - #[codec(index = 183)] Mortal183(::core::primitive::u8), - #[codec(index = 184)] Mortal184(::core::primitive::u8), - #[codec(index = 185)] Mortal185(::core::primitive::u8), - #[codec(index = 186)] Mortal186(::core::primitive::u8), - #[codec(index = 187)] Mortal187(::core::primitive::u8), - #[codec(index = 188)] Mortal188(::core::primitive::u8), - #[codec(index = 189)] Mortal189(::core::primitive::u8), - #[codec(index = 190)] Mortal190(::core::primitive::u8), - #[codec(index = 191)] Mortal191(::core::primitive::u8), - #[codec(index = 192)] Mortal192(::core::primitive::u8), - #[codec(index = 193)] Mortal193(::core::primitive::u8), - #[codec(index = 194)] Mortal194(::core::primitive::u8), - #[codec(index = 195)] Mortal195(::core::primitive::u8), - #[codec(index = 196)] Mortal196(::core::primitive::u8), - #[codec(index = 197)] Mortal197(::core::primitive::u8), - #[codec(index = 198)] Mortal198(::core::primitive::u8), - #[codec(index = 199)] Mortal199(::core::primitive::u8), - #[codec(index = 200)] Mortal200(::core::primitive::u8), - #[codec(index = 201)] Mortal201(::core::primitive::u8), - #[codec(index = 202)] Mortal202(::core::primitive::u8), - #[codec(index = 203)] Mortal203(::core::primitive::u8), - #[codec(index = 204)] Mortal204(::core::primitive::u8), - #[codec(index = 205)] Mortal205(::core::primitive::u8), - #[codec(index = 206)] Mortal206(::core::primitive::u8), - #[codec(index = 207)] Mortal207(::core::primitive::u8), - #[codec(index = 208)] Mortal208(::core::primitive::u8), - #[codec(index = 209)] Mortal209(::core::primitive::u8), - #[codec(index = 210)] Mortal210(::core::primitive::u8), - #[codec(index = 211)] Mortal211(::core::primitive::u8), - #[codec(index = 212)] Mortal212(::core::primitive::u8), - #[codec(index = 213)] Mortal213(::core::primitive::u8), - #[codec(index = 214)] Mortal214(::core::primitive::u8), - #[codec(index = 215)] Mortal215(::core::primitive::u8), - #[codec(index = 216)] Mortal216(::core::primitive::u8), - #[codec(index = 217)] Mortal217(::core::primitive::u8), - #[codec(index = 218)] Mortal218(::core::primitive::u8), - #[codec(index = 219)] Mortal219(::core::primitive::u8), - #[codec(index = 220)] Mortal220(::core::primitive::u8), - #[codec(index = 221)] Mortal221(::core::primitive::u8), - #[codec(index = 222)] Mortal222(::core::primitive::u8), - #[codec(index = 223)] Mortal223(::core::primitive::u8), - #[codec(index = 224)] Mortal224(::core::primitive::u8), - #[codec(index = 225)] Mortal225(::core::primitive::u8), - #[codec(index = 226)] Mortal226(::core::primitive::u8), - #[codec(index = 227)] Mortal227(::core::primitive::u8), - #[codec(index = 228)] Mortal228(::core::primitive::u8), - #[codec(index = 229)] Mortal229(::core::primitive::u8), - #[codec(index = 230)] Mortal230(::core::primitive::u8), - #[codec(index = 231)] Mortal231(::core::primitive::u8), - #[codec(index = 232)] Mortal232(::core::primitive::u8), - #[codec(index = 233)] Mortal233(::core::primitive::u8), - #[codec(index = 234)] Mortal234(::core::primitive::u8), - #[codec(index = 235)] Mortal235(::core::primitive::u8), - #[codec(index = 236)] Mortal236(::core::primitive::u8), - #[codec(index = 237)] Mortal237(::core::primitive::u8), - #[codec(index = 238)] Mortal238(::core::primitive::u8), - #[codec(index = 239)] Mortal239(::core::primitive::u8), - #[codec(index = 240)] Mortal240(::core::primitive::u8), - #[codec(index = 241)] Mortal241(::core::primitive::u8), - #[codec(index = 242)] Mortal242(::core::primitive::u8), - #[codec(index = 243)] Mortal243(::core::primitive::u8), - #[codec(index = 244)] Mortal244(::core::primitive::u8), - #[codec(index = 245)] Mortal245(::core::primitive::u8), - #[codec(index = 246)] Mortal246(::core::primitive::u8), - #[codec(index = 247)] Mortal247(::core::primitive::u8), - #[codec(index = 248)] Mortal248(::core::primitive::u8), - #[codec(index = 249)] Mortal249(::core::primitive::u8), - #[codec(index = 250)] Mortal250(::core::primitive::u8), - #[codec(index = 251)] Mortal251(::core::primitive::u8), - #[codec(index = 252)] Mortal252(::core::primitive::u8), - #[codec(index = 253)] Mortal253(::core::primitive::u8), - #[codec(index = 254)] Mortal254(::core::primitive::u8), - #[codec(index = 255)] Mortal255(::core::primitive::u8), - } - } - - pub mod header { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct Header<_0, _1> { - pub parent_hash: ::subxt::ext::sp_core::H256, - #[codec(compact)] pub number: _0, - pub state_root: ::subxt::ext::sp_core::H256, - pub extrinsics_root: ::subxt::ext::sp_core::H256, - pub digest: runtime_types::sp_runtime::generic::digest::Digest, - #[codec(skip)] pub __subxt_unused_type_params: ::core::marker::PhantomData<_1>, - } - } - - pub mod unchecked_extrinsic { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct UncheckedExtrinsic<_0, _1, _2, _3> (pub ::std::vec::Vec<::core::primitive::u8>, #[codec(skip)] pub ::core::marker::PhantomData<(_0, _1, _2, _3)>); - } - } - - pub mod multiaddress { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum MultiAddress<_0, _1> { #[codec(index = 0)] Id(_0), #[codec(index = 1)] Index(#[codec(compact)] _1), #[codec(index = 2)] Raw(::std::vec::Vec<::core::primitive::u8>), #[codec(index = 3)] Address32([::core::primitive::u8; 32usize]), #[codec(index = 4)] Address20([::core::primitive::u8; 20usize]) } - } - - pub mod traits { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct BlakeTwo256; - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum ArithmeticError { #[codec(index = 0)] Underflow, #[codec(index = 1)] Overflow, #[codec(index = 2)] DivisionByZero } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum DispatchError { #[codec(index = 0)] Other, #[codec(index = 1)] CannotLookup, #[codec(index = 2)] BadOrigin, #[codec(index = 3)] Module(runtime_types::sp_runtime::ModuleError), #[codec(index = 4)] ConsumerRemaining, #[codec(index = 5)] NoProviders, #[codec(index = 6)] TooManyConsumers, #[codec(index = 7)] Token(runtime_types::sp_runtime::TokenError), #[codec(index = 8)] Arithmetic(runtime_types::sp_runtime::ArithmeticError), #[codec(index = 9)] Transactional(runtime_types::sp_runtime::TransactionalError) } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct ModuleError { - pub index: ::core::primitive::u8, - pub error: [::core::primitive::u8; 4usize], - } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum MultiSignature { #[codec(index = 0)] Ed25519(runtime_types::sp_core::ed25519::Signature), #[codec(index = 1)] Sr25519(runtime_types::sp_core::sr25519::Signature), #[codec(index = 2)] Ecdsa(runtime_types::sp_core::ecdsa::Signature) } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum TokenError { #[codec(index = 0)] NoFunds, #[codec(index = 1)] WouldDie, #[codec(index = 2)] BelowMinimum, #[codec(index = 3)] CannotCreate, #[codec(index = 4)] UnknownAsset, #[codec(index = 5)] Frozen, #[codec(index = 6)] Unsupported } - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub enum TransactionalError { #[codec(index = 0)] LimitReached, #[codec(index = 1)] NoLayer } - } - - pub mod sp_version { - use super::runtime_types; - - #[derive(::subxt::ext::codec::Decode, ::subxt::ext::codec::Encode, Debug)] - pub struct RuntimeVersion { - pub spec_name: ::std::string::String, - pub impl_name: ::std::string::String, - pub authoring_version: ::core::primitive::u32, - pub spec_version: ::core::primitive::u32, - pub impl_version: ::core::primitive::u32, - pub apis: ::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32, )>, - pub transaction_version: ::core::primitive::u32, - pub state_version: ::core::primitive::u8, - } - } - } - - #[doc = r" The default error type returned when there is a runtime issue,"] - #[doc = r" exposed here for ease of use."] - pub type DispatchError = runtime_types::sp_runtime::DispatchError; - - pub fn constants() -> ConstantsApi { ConstantsApi } - - pub fn storage() -> StorageApi { StorageApi } - - pub fn tx() -> TransactionApi { TransactionApi } - - pub struct ConstantsApi; - - impl ConstantsApi { - pub fn system(&self) -> system::constants::ConstantsApi { system::constants::ConstantsApi } - pub fn timestamp(&self) -> timestamp::constants::ConstantsApi { timestamp::constants::ConstantsApi } - pub fn balances(&self) -> balances::constants::ConstantsApi { balances::constants::ConstantsApi } - pub fn authorship(&self) -> authorship::constants::ConstantsApi { authorship::constants::ConstantsApi } - pub fn transaction_payment(&self) -> transaction_payment::constants::ConstantsApi { transaction_payment::constants::ConstantsApi } - pub fn contracts(&self) -> contracts::constants::ConstantsApi { contracts::constants::ConstantsApi } - } - - pub struct StorageApi; - - impl StorageApi { - pub fn system(&self) -> system::storage::StorageApi { system::storage::StorageApi } - pub fn randomness_collective_flip(&self) -> randomness_collective_flip::storage::StorageApi { randomness_collective_flip::storage::StorageApi } - pub fn timestamp(&self) -> timestamp::storage::StorageApi { timestamp::storage::StorageApi } - pub fn balances(&self) -> balances::storage::StorageApi { balances::storage::StorageApi } - pub fn authorship(&self) -> authorship::storage::StorageApi { authorship::storage::StorageApi } - pub fn transaction_payment(&self) -> transaction_payment::storage::StorageApi { transaction_payment::storage::StorageApi } - pub fn sudo(&self) -> sudo::storage::StorageApi { sudo::storage::StorageApi } - pub fn contracts(&self) -> contracts::storage::StorageApi { contracts::storage::StorageApi } - } - - pub struct TransactionApi; - - impl TransactionApi { - pub fn system(&self) -> system::calls::TransactionApi { system::calls::TransactionApi } - pub fn timestamp(&self) -> timestamp::calls::TransactionApi { timestamp::calls::TransactionApi } - pub fn balances(&self) -> balances::calls::TransactionApi { balances::calls::TransactionApi } - pub fn authorship(&self) -> authorship::calls::TransactionApi { authorship::calls::TransactionApi } - pub fn sudo(&self) -> sudo::calls::TransactionApi { sudo::calls::TransactionApi } - pub fn contracts(&self) -> contracts::calls::TransactionApi { contracts::calls::TransactionApi } - } - - #[doc = r" check whether the Client you are using is aligned with the statically generated codegen."] - pub fn validate_codegen>(client: &C) -> Result<(), ::subxt::error::MetadataError> { - let runtime_metadata_hash = client.metadata().metadata_hash(&PALLETS); - if runtime_metadata_hash != [107u8, 60u8, 54u8, 83u8, 46u8, 188u8, 187u8, 179u8, 90u8, 168u8, 77u8, 163u8, 181u8, 134u8, 68u8, 181u8, 100u8, 67u8, 26u8, 120u8, 88u8, 254u8, 191u8, 177u8, 189u8, 239u8, 116u8, 99u8, 12u8, 153u8, 208u8, 133u8, ] { Err(::subxt::error::MetadataError::IncompatibleMetadata) } else { Ok(()) } - } -} diff --git a/contract-transfer/foo b/contract-transfer/foo deleted file mode 100644 index 5d010f67..00000000 --- a/contract-transfer/foo +++ /dev/null @@ -1,12 +0,0 @@ -ContractResult { - gas_consumed: 5501174466, - gas_required: 74999922688, - storage_deposit: StorageDeposit::Charge(0), - debug_message: [], - result: Ok( - ExecReturnValue { - flags: (empty), - data: Bytes([0, 57, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) - } - ) -} diff --git a/contract-transfer/foo.rs b/contract-transfer/foo.rs deleted file mode 100644 index 57635433..00000000 --- a/contract-transfer/foo.rs +++ /dev/null @@ -1,306 +0,0 @@ -pub mod subber -{ - use super::*; - - pub const CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/subber/subber.contract" - ; - - pub mod constructors - { - use super::*; - - #[derive(::scale::Encode)] - pub struct New - { - accumulator: super::accumulator::accumulator::AccumulatorRef, - } - - impl ::ink_e2e::InkConstructor for New - { - type ReturnType = Self; - const SELECTOR: [u8; 4] = - [0x9B_u8, 0xAE_u8, 0x9D_u8, 0x5E_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/subber/subber.contract" - ; - } - - pub fn - new(accumulator: super::accumulator::accumulator::AccumulatorRef) -> New { New { accumulator } } - } - - pub mod messages - { - use super::*; - - #[derive(::scale::Encode)] - pub struct Dec - { - by: ::core::primitive::i32, - } - - impl ::ink_e2e::InkMessage for - Dec - { - type ReturnType = (); - const SELECTOR: [u8; 4] = - [0xB5_u8, 0xD7_u8, 0xB4_u8, 0xF0_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/subber/subber.contract" - ; - } - - pub fn dec(by: ::core::primitive::i32) -> Dec { Dec { by } } - } -} - -pub mod accumulator -{ - use super::*; - - pub const CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/accumulator/accumulator.contract" - ; - - pub mod constructors - { - use super::*; - - #[derive(::scale::Encode)] - pub struct New - { - init_value: ::core::primitive::i32, - } - - impl ::ink_e2e:: - InkConstructor for New - { - type ReturnType = Self; - const SELECTOR: [u8; 4] = - [0x9B_u8, 0xAE_u8, 0x9D_u8, 0x5E_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/accumulator/accumulator.contract" - ; - } - - pub fn new(init_value: ::core::primitive::i32) -> New - { New { init_value } } - } - - pub mod messages - { - use super::*; - - #[derive(::scale::Encode)] - pub struct Inc - { - by: ::core::primitive::i32, - } - - impl ::ink_e2e::InkMessage for - Inc - { - type ReturnType = (); - const SELECTOR: [u8; 4] = - [0x1D_u8, 0x32_u8, 0x61_u8, 0x9F_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/accumulator/accumulator.contract" - ; - } - - pub fn inc(by: ::core::primitive::i32) -> Inc { Inc { by } } - - #[derive(::scale::Encode)] - pub struct Get {} - - impl ::ink_e2e:: - InkMessage for Get - { - type ReturnType = ::core::primitive::i32; - const SELECTOR: - [u8; 4] = [0x2F_u8, 0x86_u8, 0x5B_u8, 0xD9_u8]; - const - CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/accumulator/accumulator.contract" - ; - } - - pub fn get() -> Get { Get {} } - } -} - -pub mod adder -{ - use super::*; - - pub const CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/adder/adder.contract" - ; - - pub mod constructors - { - use super::*; - - #[derive(::scale::Encode)] - pub struct New - { - accumulator: super::accumulator::accumulator::AccumulatorRef, - } - - impl ::ink_e2e::InkConstructor for New - { - type ReturnType = Self; - const SELECTOR: [u8; 4] = - [0x9B_u8, 0xAE_u8, 0x9D_u8, 0x5E_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/adder/adder.contract" - ; - } - - pub fn - new(accumulator: super::accumulator::accumulator::AccumulatorRef) -> New { New { accumulator } } - } - - pub mod messages - { - use super::*; - - #[derive(::scale::Encode)] - pub struct Inc - { - by: ::core::primitive::i32, - } - - impl ::ink_e2e::InkMessage for - Inc - { - type ReturnType = (); - const SELECTOR: [u8; 4] = - [0x1D_u8, 0x32_u8, 0x61_u8, 0x9F_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/adder/adder.contract" - ; - } - - pub fn inc(by: ::core::primitive::i32) -> Inc { Inc { by } } - } -} - -pub mod delegator -{ - use super::*; - - pub const CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/delegator.contract" - ; - - pub mod constructors - { - use super::*; - - #[derive(::scale::Encode)] - pub struct New - { - init_value: ::core::primitive::i32, - version: ::core:: - primitive::u32, - accumulator_code_hash: ::ink::primitives:: - Hash, - adder_code_hash: ::ink::primitives::Hash, - subber_code_hash: ::ink::primitives::Hash, - } - - impl ::ink_e2e::InkConstructor for New - { - type ReturnType = Self; - const SELECTOR: [u8; 4] = - [0x9B_u8, 0xAE_u8, 0x9D_u8, 0x5E_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/delegator.contract" - ; - } - - pub fn - new(init_value: ::core::primitive::i32, version: ::core:: - primitive::u32, accumulator_code_hash: ::ink::primitives:: - Hash, adder_code_hash: ::ink::primitives::Hash, subber_code_hash - : ::ink::primitives::Hash) -> New - { - New - { - init_value, - version, - accumulator_code_hash, - adder_code_hash, - subber_code_hash, - } - } - } - - pub mod messages - { - use super::*; - - #[derive(::scale::Encode)] - pub struct Get {} - - impl - ::ink_e2e::InkMessage for Get - { - type ReturnType = ::core::primitive::i32; - const SELECTOR: - [u8; 4] = [0x2F_u8, 0x86_u8, 0x5B_u8, 0xD9_u8]; - const - CONTRACT_PATH: &'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/delegator.contract" - ; - } - - pub fn get() -> Get { Get {} } - - #[derive(::scale::Encode)] - pub - struct Change { - by: ::core::primitive::i32, - } - - impl ::ink_e2e:: - InkMessage for Change - { - type ReturnType = (); - const SELECTOR: [u8; 4] = - [0xBF_u8, 0x90_u8, 0xA6_u8, 0x40_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/delegator.contract" - ; - } - - pub fn change(by: ::core::primitive::i32) -> Change - { Change { by } } - - #[derive(::scale::Encode)] - pub struct Switch {} - - impl ::ink_e2e::InkMessage for Switch - { - type ReturnType = (); - const SELECTOR: [u8; 4] = - [0x1F_u8, 0x28_u8, 0xC9_u8, 0xDB_u8]; - const CONTRACT_PATH: & - 'static str = - "/Users/michi/projects/ink/examples/delegator/target/ink/delegator.contract" - ; - } - - pub fn switch() -> Switch { Switch {} } - } -} diff --git a/contract-transfer/.gitignore b/contract_transfer/.gitignore similarity index 100% rename from contract-transfer/.gitignore rename to contract_transfer/.gitignore diff --git a/contract-transfer/Cargo.toml b/contract_transfer/Cargo.toml similarity index 100% rename from contract-transfer/Cargo.toml rename to contract_transfer/Cargo.toml diff --git a/contract_transfer/frontend/.gitignore b/contract_transfer/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/contract_transfer/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/contract_transfer/frontend/README.md b/contract_transfer/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/contract_transfer/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/contract_transfer/frontend/index.html b/contract_transfer/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/contract_transfer/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/contract_transfer/frontend/package.json b/contract_transfer/frontend/package.json new file mode 100644 index 00000000..38b5f89b --- /dev/null +++ b/contract_transfer/frontend/package.json @@ -0,0 +1,30 @@ +{ + "name": "contract_transfer", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.0", + "@typescript-eslint/parser": "^5.59.0", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/contract_transfer/frontend/postcss.config.js b/contract_transfer/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/contract_transfer/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/contract_transfer/frontend/public/logo.svg b/contract_transfer/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/contract_transfer/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/contract_transfer/frontend/src/App.tsx b/contract_transfer/frontend/src/App.tsx new file mode 100644 index 00000000..d5b4e3e0 --- /dev/null +++ b/contract_transfer/frontend/src/App.tsx @@ -0,0 +1,120 @@ +import metadata from './assets/contract_transfer.json'; +import { CONTRACT_ROCOCO_ADDRESS } from './constants'; +import { useMemo, useState } from 'react'; +import { Button, Card, ConnectButton, InkLayout, Link, NumberInput } from 'ui'; +import { useBalance, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { + BN, + decimalToPlanck, + isPendingSignature, + planckToDecimal, + planckToDecimalFormatted, + shouldDisable, +} from 'useink/utils'; + +function App() { + const { account } = useWallet(); + const chainContract = useContract(CONTRACT_ROCOCO_ADDRESS, metadata); + const contractBalance = useBalance({ address: CONTRACT_ROCOCO_ADDRESS }); + const userBalance = useBalance(account); + const [amount, setAmount] = useState(1); + const giveMe = useTx(chainContract, 'giveMe'); + useTxNotifications(giveMe); + + const planckAmount = useMemo( + () => decimalToPlanck(amount, chainContract?.contract?.api) || 0, + [chainContract?.contract.api, amount], + ); + + const needsMoreFunds = useMemo( + () => + contractBalance?.freeBalance.lt(new BN(planckAmount?.toString() || '0')), + [contractBalance?.freeBalance, planckAmount], + ); + + return ( + + +

+ {metadata.contract.name.toUpperCase()} +

+ +
+

+ Contract Balance:{' '} + + {contractBalance + ? planckToDecimalFormatted( + contractBalance?.freeBalance, + chainContract?.contract.api, + { decimals: 4 }, + ) + : '--'} + +

+ +

+ Your Balance:{' '} + + {userBalance + ? planckToDecimalFormatted( + userBalance?.freeBalance, + chainContract?.contract.api, + { decimals: 4 }, + ) + : '--'} + +

+
+ + setAmount(v)} + value={amount} + min={1} + max={Math.floor( + planckToDecimal( + contractBalance?.freeBalance, + chainContract?.contract.api, + ) || 0, + )} + /> + + {account ? ( + + ) : ( + + )} + +
+ {needsMoreFunds && ( +

There are not enough funds.

+ )} + + + Add ROC to contract with faucet + +
+
+
+ ); +} + +export default App; diff --git a/contract_transfer/frontend/src/Global.css b/contract_transfer/frontend/src/Global.css new file mode 100644 index 00000000..bd6213e1 --- /dev/null +++ b/contract_transfer/frontend/src/Global.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/contract_transfer/frontend/src/assets/contract_transfer.json b/contract_transfer/frontend/src/assets/contract_transfer.json new file mode 100644 index 00000000..fdc46a25 --- /dev/null +++ b/contract_transfer/frontend/src/assets/contract_transfer.json @@ -0,0 +1,333 @@ +{ + "source": { + "hash": "0x3431764079ef7dacc018ed5bfee19e333caf631c92ab621e73d7ed21bed1bc93", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "contract_transfer", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [], + "default": false, + "docs": [ + "Creates a new instance of this contract." + ], + "label": "new", + "payable": true, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 0 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 4 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 3 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 9 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 10 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 7 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 8 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 2 + }, + "messages": [ + { + "args": [ + { + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Transfers `value` amount of tokens to the caller.", + "", + " # Errors", + "", + " - Panics in case the requested transfer exceeds the contract balance.", + " - Panics in case the requested transfer would have brought this contract's", + " balance below the minimum balance (i.e. the chain's existential deposit).", + " - Panics in case the transfer failed for another reason." + ], + "label": "give_me", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 0 + }, + "selector": "0x499bb739" + }, + { + "args": [], + "default": false, + "docs": [ + " Asserts that the token amount sent as payment with this call", + " is exactly `10`. This method will fail otherwise, and the", + " transaction would then be reverted.", + "", + " # Note", + "", + " The method needs to be annotated with `payable`; only then it is", + " allowed to receive value as part of the call." + ], + "label": "was_it_ten", + "mutates": false, + "payable": true, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 0 + }, + "selector": "0xcafebabe" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [], + "name": "GiveMe" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 1 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 2 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 1 + }, + { + "name": "E", + "type": 2 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 1, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 2, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 3, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 4, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 5, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "array": { + "len": 32, + "type": 6 + } + } + } + }, + { + "id": 6, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 7, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 5, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 9, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 10, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/contract_transfer/frontend/src/constants.ts b/contract_transfer/frontend/src/constants.ts new file mode 100644 index 00000000..ecbbe570 --- /dev/null +++ b/contract_transfer/frontend/src/constants.ts @@ -0,0 +1,2 @@ +export const CONTRACT_ROCOCO_ADDRESS = + '5E6iJxxnf2v8p1mfc9UV8ojBYAQbJQyd5H1gQwvpxESZYEja'; diff --git a/contract_transfer/frontend/src/main.tsx b/contract_transfer/frontend/src/main.tsx new file mode 100644 index 00000000..52664eea --- /dev/null +++ b/contract_transfer/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import App from './App.tsx'; +import './Global.css'; +import metadata from './assets/contract_transfer.json'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/contract_transfer/frontend/src/vite-env.d.ts b/contract_transfer/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/contract_transfer/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/contract_transfer/frontend/tailwind.config.js b/contract_transfer/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/contract_transfer/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/contract_transfer/frontend/tsconfig.json b/contract_transfer/frontend/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/contract_transfer/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/contract_transfer/frontend/tsconfig.node.json b/contract_transfer/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/contract_transfer/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/contract_transfer/frontend/vite.config.ts b/contract_transfer/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/contract_transfer/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/contract-transfer/lib.rs b/contract_transfer/lib.rs similarity index 100% rename from contract-transfer/lib.rs rename to contract_transfer/lib.rs diff --git a/package.json b/package.json index 955eda91..623037a0 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "build:ui": "pnpm --filter ui build", "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev", - "basic_contract_caller": "pnpm --filter ui dev & pnpm --filter basic_contract_caller dev" + "basic_contract_caller": "pnpm --filter ui dev & pnpm --filter basic_contract_caller dev", + "contract_transfer": "pnpm --filter ui dev & pnpm --filter contract_transfer dev" }, "packages": [ "ui", @@ -22,7 +23,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "useink": "^1.7.5" + "useink": "^1.9.1" }, "devDependencies": { "tailwindcss": "^3.3.2", From 6effa91088e32be1c20added125d0ea858a3f4fe Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Thu, 29 Jun 2023 12:50:20 -0400 Subject: [PATCH 05/12] chore: remove unused js packages --- basic_contract_caller/frontend/package.json | 4 ---- contract_transfer/frontend/package.json | 4 ---- flipper/frontend/package.json | 5 ----- 3 files changed, 13 deletions(-) diff --git a/basic_contract_caller/frontend/package.json b/basic_contract_caller/frontend/package.json index a50868f9..688fbe33 100644 --- a/basic_contract_caller/frontend/package.json +++ b/basic_contract_caller/frontend/package.json @@ -15,13 +15,9 @@ "devDependencies": { "@types/react": "^18.0.37", "@types/react-dom": "^18.0.11", - "@typescript-eslint/eslint-plugin": "^5.59.0", - "@typescript-eslint/parser": "^5.59.0", "@vitejs/plugin-react": "^4.0.0", "autoprefixer": "^10.4.14", "eslint": "^8.38.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.3.4", "postcss": "^8.4.24", "tailwindcss": "^3.3.2", "typescript": "^5.0.2", diff --git a/contract_transfer/frontend/package.json b/contract_transfer/frontend/package.json index 38b5f89b..36cbf1ab 100644 --- a/contract_transfer/frontend/package.json +++ b/contract_transfer/frontend/package.json @@ -15,13 +15,9 @@ "devDependencies": { "@types/react": "^18.0.37", "@types/react-dom": "^18.0.11", - "@typescript-eslint/eslint-plugin": "^5.59.0", - "@typescript-eslint/parser": "^5.59.0", "@vitejs/plugin-react": "^4.0.0", "autoprefixer": "^10.4.14", "eslint": "^8.38.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.3.4", "postcss": "^8.4.24", "tailwindcss": "^3.3.2", "typescript": "^5.0.2", diff --git a/flipper/frontend/package.json b/flipper/frontend/package.json index ecba45fa..fa9d0bef 100644 --- a/flipper/frontend/package.json +++ b/flipper/frontend/package.json @@ -15,13 +15,8 @@ "devDependencies": { "@types/react": "^18.0.37", "@types/react-dom": "^18.0.11", - "@typescript-eslint/eslint-plugin": "^5.59.0", - "@typescript-eslint/parser": "^5.59.0", "@vitejs/plugin-react": "^4.0.0", "autoprefixer": "^10.4.14", - "eslint": "^8.38.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.3.4", "postcss": "^8.4.24", "tailwindcss": "^3.3.2", "typescript": "^5.0.2", From e7e07da2815e0aa93bff3e72f7a162f1e06a9efd Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Thu, 29 Jun 2023 12:51:33 -0400 Subject: [PATCH 06/12] chore: rename contract-terminate -> contract_terminate --- {contract-terminate => contract_terminate}/.gitignore | 0 {contract-terminate => contract_terminate}/Cargo.toml | 0 {contract-terminate => contract_terminate}/lib.rs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {contract-terminate => contract_terminate}/.gitignore (100%) rename {contract-terminate => contract_terminate}/Cargo.toml (100%) rename {contract-terminate => contract_terminate}/lib.rs (100%) diff --git a/contract-terminate/.gitignore b/contract_terminate/.gitignore similarity index 100% rename from contract-terminate/.gitignore rename to contract_terminate/.gitignore diff --git a/contract-terminate/Cargo.toml b/contract_terminate/Cargo.toml similarity index 100% rename from contract-terminate/Cargo.toml rename to contract_terminate/Cargo.toml diff --git a/contract-terminate/lib.rs b/contract_terminate/lib.rs similarity index 100% rename from contract-terminate/lib.rs rename to contract_terminate/lib.rs From 39f058739b66b3d13bead055a821597ad04e9032 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Thu, 29 Jun 2023 13:08:07 -0400 Subject: [PATCH 07/12] feat: format contract names for examples --- basic_contract_caller/frontend/src/App.tsx | 11 ++++------- contract_transfer/frontend/src/App.tsx | 12 ++++++++++-- flipper/frontend/src/App.tsx | 4 ++-- incrementer/frontend/src/App.tsx | 11 +++++++++-- ui/src/index.ts | 1 + ui/src/utils/formatContractName.ts | 6 ++++++ ui/src/utils/index.ts | 1 + 7 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 ui/src/utils/formatContractName.ts create mode 100644 ui/src/utils/index.ts diff --git a/basic_contract_caller/frontend/src/App.tsx b/basic_contract_caller/frontend/src/App.tsx index 20b39b67..49aed813 100644 --- a/basic_contract_caller/frontend/src/App.tsx +++ b/basic_contract_caller/frontend/src/App.tsx @@ -1,18 +1,15 @@ import { Other } from './Other'; -import basicContractMetadata from './assets/basic_contract_caller.json'; +import metadata from './assets/basic_contract_caller.json'; import { BASIC_CONTRACT_ROCOCO_ADDRESS } from './constants'; import { useEffect } from 'react'; -import { Button, Card, ConnectButton, InkLayout } from 'ui'; +import { Button, Card, ConnectButton, InkLayout, formatContractName } from 'ui'; import { useCall, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { isPendingSignature, pickDecoded, shouldDisable } from 'useink/utils'; function App() { const { account } = useWallet(); - const basicContract = useContract( - BASIC_CONTRACT_ROCOCO_ADDRESS, - basicContractMetadata, - ); + const basicContract = useContract(BASIC_CONTRACT_ROCOCO_ADDRESS, metadata); const flipAndGet = useTx(basicContract, 'flipAndGet'); useTxNotifications(flipAndGet); @@ -32,7 +29,7 @@ function App() {

- {basicContractMetadata.contract.name.toUpperCase()} + {formatContractName(metadata.contract.name)}

{account ? ( diff --git a/contract_transfer/frontend/src/App.tsx b/contract_transfer/frontend/src/App.tsx index d5b4e3e0..6bb9f43a 100644 --- a/contract_transfer/frontend/src/App.tsx +++ b/contract_transfer/frontend/src/App.tsx @@ -1,7 +1,15 @@ import metadata from './assets/contract_transfer.json'; import { CONTRACT_ROCOCO_ADDRESS } from './constants'; import { useMemo, useState } from 'react'; -import { Button, Card, ConnectButton, InkLayout, Link, NumberInput } from 'ui'; +import { + Button, + Card, + ConnectButton, + InkLayout, + Link, + NumberInput, + formatContractName, +} from 'ui'; import { useBalance, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { @@ -40,7 +48,7 @@ function App() { >

- {metadata.contract.name.toUpperCase()} + {formatContractName(metadata.contract.name)}

diff --git a/flipper/frontend/src/App.tsx b/flipper/frontend/src/App.tsx index 4403d237..91704fb4 100644 --- a/flipper/frontend/src/App.tsx +++ b/flipper/frontend/src/App.tsx @@ -1,6 +1,6 @@ import metadata from './assets/flipper.json'; import { CONTRACT_ROCOCO_ADDRESS } from './constants'; -import { Button, Card, ConnectButton, InkLayout } from 'ui'; +import { Button, Card, ConnectButton, InkLayout, formatContractName } from 'ui'; import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { pickDecoded, shouldDisable } from 'useink/utils'; @@ -22,7 +22,7 @@ function App() { >

- {metadata.contract.name.toUpperCase()} + {formatContractName(metadata.contract.name)}

diff --git a/incrementer/frontend/src/App.tsx b/incrementer/frontend/src/App.tsx index b11908a5..7a6dec2e 100644 --- a/incrementer/frontend/src/App.tsx +++ b/incrementer/frontend/src/App.tsx @@ -1,7 +1,14 @@ import metadata from './assets/incrementer.json'; import { CONTRACT_ROCOCO_ADDRESS } from './constants'; import { useState } from 'react'; -import { Button, Card, ConnectButton, InkLayout, NumberInput } from 'ui'; +import { + Button, + Card, + ConnectButton, + InkLayout, + NumberInput, + formatContractName, +} from 'ui'; import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { pickDecoded, shouldDisable } from 'useink/utils'; @@ -23,7 +30,7 @@ function App() { >

- {metadata.contract.name.toUpperCase()} + {formatContractName(metadata.contract.name)}

diff --git a/ui/src/index.ts b/ui/src/index.ts index 29a45d37..6eff785f 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -15,3 +15,4 @@ export * from './Snackbar'; export * from './contexts'; export * from './hooks'; export * from './types'; +export * from './utils'; diff --git a/ui/src/utils/formatContractName.ts b/ui/src/utils/formatContractName.ts new file mode 100644 index 00000000..e0c3365a --- /dev/null +++ b/ui/src/utils/formatContractName.ts @@ -0,0 +1,6 @@ +export const formatContractName = (name: string): string => + name + .toLowerCase() + .split('_') + .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) + .join(' '); diff --git a/ui/src/utils/index.ts b/ui/src/utils/index.ts new file mode 100644 index 00000000..6190abdc --- /dev/null +++ b/ui/src/utils/index.ts @@ -0,0 +1 @@ +export * from './formatContractName'; From 5beaa5f123de0132579217084454d6403520aba1 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Thu, 29 Jun 2023 13:08:30 -0400 Subject: [PATCH 08/12] feat: add contract_terminate example --- contract_terminate/frontend/.gitignore | 21 ++ contract_terminate/frontend/README.md | 4 + contract_terminate/frontend/index.html | 13 + contract_terminate/frontend/package.json | 25 ++ contract_terminate/frontend/postcss.config.js | 6 + contract_terminate/frontend/public/logo.svg | 1 + contract_terminate/frontend/src/App.tsx | 191 ++++++++++++ contract_terminate/frontend/src/Global.css | 3 + .../src/assets/contract_terminate.json | 291 ++++++++++++++++++ contract_terminate/frontend/src/constants.ts | 2 + contract_terminate/frontend/src/main.tsx | 27 ++ contract_terminate/frontend/src/vite-env.d.ts | 1 + .../frontend/tailwind.config.js | 2 + contract_terminate/frontend/tsconfig.json | 25 ++ .../frontend/tsconfig.node.json | 10 + contract_terminate/frontend/vite.config.ts | 7 + package.json | 9 +- ui/package.json | 5 - ui/src/Events/Events.tsx | 47 +++ ui/src/Events/index.ts | 1 + ui/src/index.ts | 1 + 21 files changed, 683 insertions(+), 9 deletions(-) create mode 100644 contract_terminate/frontend/.gitignore create mode 100644 contract_terminate/frontend/README.md create mode 100644 contract_terminate/frontend/index.html create mode 100644 contract_terminate/frontend/package.json create mode 100644 contract_terminate/frontend/postcss.config.js create mode 100644 contract_terminate/frontend/public/logo.svg create mode 100644 contract_terminate/frontend/src/App.tsx create mode 100644 contract_terminate/frontend/src/Global.css create mode 100644 contract_terminate/frontend/src/assets/contract_terminate.json create mode 100644 contract_terminate/frontend/src/constants.ts create mode 100644 contract_terminate/frontend/src/main.tsx create mode 100644 contract_terminate/frontend/src/vite-env.d.ts create mode 100644 contract_terminate/frontend/tailwind.config.js create mode 100644 contract_terminate/frontend/tsconfig.json create mode 100644 contract_terminate/frontend/tsconfig.node.json create mode 100644 contract_terminate/frontend/vite.config.ts create mode 100644 ui/src/Events/Events.tsx create mode 100644 ui/src/Events/index.ts diff --git a/contract_terminate/frontend/.gitignore b/contract_terminate/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/contract_terminate/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/contract_terminate/frontend/README.md b/contract_terminate/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/contract_terminate/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/contract_terminate/frontend/index.html b/contract_terminate/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/contract_terminate/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +

+ + + diff --git a/contract_terminate/frontend/package.json b/contract_terminate/frontend/package.json new file mode 100644 index 00000000..b60f441b --- /dev/null +++ b/contract_terminate/frontend/package.json @@ -0,0 +1,25 @@ +{ + "name": "contract_terminate", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/contract_terminate/frontend/postcss.config.js b/contract_terminate/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/contract_terminate/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/contract_terminate/frontend/public/logo.svg b/contract_terminate/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/contract_terminate/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/contract_terminate/frontend/src/App.tsx b/contract_terminate/frontend/src/App.tsx new file mode 100644 index 00000000..5ec2273c --- /dev/null +++ b/contract_terminate/frontend/src/App.tsx @@ -0,0 +1,191 @@ +import metadata from './assets/contract_terminate.json'; +import { useEffect, useMemo } from 'react'; +import { + Button, + Card, + ConnectButton, + Events, + InkLayout, + formatContractName, +} from 'ui'; +import { useApi, useBalance, useDeployer, useMetadata } from 'useink'; +import { useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { + formatEventName, + isPendingSignature, + planckToDecimalFormatted, + shouldDisable, +} from 'useink/utils'; + +// We already deployed the contract Wasm blob on chain. We use this code hash to +// re-deploy; +const codeHash = + '0xf667f6dbcc27e4b0f2e23c2af12d6e5dee358910753b02910a6aebd3768dd618'; + +function App() { + const { account } = useWallet(); + const chainApi = useApi(); + + const M = useMetadata({ requireWasm: false }, metadata); + const balance = useBalance(account); + + const D = useDeployer(); + useTxNotifications(D); + + const contract = useContract(D.contractAddress || '', metadata); + const terminate = useTx(contract, 'terminateMe'); + useTxNotifications(terminate); + + useEffect(() => { + chainApi?.api && M.abi && D.dryRun(M.abi, 'new', undefined, { codeHash }); + }, [M.abi, chainApi?.api]); + + const wasTerminated = useMemo(() => { + return Boolean( + terminate.events.find( + (event) => formatEventName(event) === 'contracts:Terminated', + ), + ); + }, [terminate.events]); + + return ( + + +

+ {formatContractName(metadata.contract.name)} +

+ +

+ Your Balance:{' '} + {planckToDecimalFormatted(balance?.freeBalance, chainApi?.api)} +

+ + {D.storageDeposit && ( +
+

Dry Run Results

+ + {D.contractAddress && ( +
+

Contract Address

+

{D.contractAddress}

+
+ )} + + {D.gasConsumed && ( +
+

Gas Consumed

+
    +
  • refTime: {D.gasConsumed.refTime.toString()}
  • +
  • proof size: {D.gasConsumed.proofSize.toString()}
  • +
+
+ )} + + {D.gasRequired && ( +
+

Gas Required

+
    +
  • refTime: {D.gasRequired.refTime.toString()}
  • +
  • proof size: {D.gasRequired.proofSize.toString()}
  • +
+
+ )} + + {D.storageDeposit && ( +
+

+ Storage Deposit:{' '} + {planckToDecimalFormatted( + D.storageDeposit.asCharge, + chainApi?.api, + )} +

+
+ )} +
+ )} + + {M.error && ( +

+ Metadata: + {M.error} +

+ )} + + {D.error &&

{D.error}

} + + {!D.wasDeployed ? ( +
+

+ {D.storageDeposit + ? "Let's first deploy the contract!" + : 'Loading...'} +

+ + {account ? ( + + ) : ( + + )} +
+ ) : ( +
+

+ {wasTerminated + ? 'Your contract was terminated!' + : 'Your contract has been deployed!'} +

+ {account ? ( + wasTerminated ? ( + + ) : ( + + ) + ) : ( + + )} +
+ )} + + +
+
+ ); +} + +export default App; diff --git a/contract_terminate/frontend/src/Global.css b/contract_terminate/frontend/src/Global.css new file mode 100644 index 00000000..bd6213e1 --- /dev/null +++ b/contract_terminate/frontend/src/Global.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/contract_terminate/frontend/src/assets/contract_terminate.json b/contract_terminate/frontend/src/assets/contract_terminate.json new file mode 100644 index 00000000..c348271c --- /dev/null +++ b/contract_terminate/frontend/src/assets/contract_terminate.json @@ -0,0 +1,291 @@ +{ + "source": { + "hash": "0xf667f6dbcc27e4b0f2e23c2af12d6e5dee358910753b02910a6aebd3768dd618", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "contract_terminate", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [], + "default": false, + "docs": [ + "Creates a new instance of this contract." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 0 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 3 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 6 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 9 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 10 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 7 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 8 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 2 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [ + " Terminates with the caller as beneficiary." + ], + "label": "terminate_me", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 0 + }, + "selector": "0x17feb370" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [], + "name": "JustTerminate" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 1 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 2 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 1 + }, + { + "name": "E", + "type": 2 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 1, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 2, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 3, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 4, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "array": { + "len": 32, + "type": 5 + } + } + } + }, + { + "id": 5, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 6, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 7, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 4, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 9, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 10, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/contract_terminate/frontend/src/constants.ts b/contract_terminate/frontend/src/constants.ts new file mode 100644 index 00000000..549db8ba --- /dev/null +++ b/contract_terminate/frontend/src/constants.ts @@ -0,0 +1,2 @@ +export const CONTRACT_ROCOCO_ADDRESS = + '5Fsk6oqWHJzMAQmkBTVzxxqZPPngLbHG48Tro3i53LC3quao'; diff --git a/contract_terminate/frontend/src/main.tsx b/contract_terminate/frontend/src/main.tsx new file mode 100644 index 00000000..1af718b8 --- /dev/null +++ b/contract_terminate/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import App from './App.tsx'; +import './Global.css'; +import metadata from './assets/contract_terminate.json'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/contract_terminate/frontend/src/vite-env.d.ts b/contract_terminate/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/contract_terminate/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/contract_terminate/frontend/tailwind.config.js b/contract_terminate/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/contract_terminate/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/contract_terminate/frontend/tsconfig.json b/contract_terminate/frontend/tsconfig.json new file mode 100644 index 00000000..a7fc6fbf --- /dev/null +++ b/contract_terminate/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/contract_terminate/frontend/tsconfig.node.json b/contract_terminate/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/contract_terminate/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/contract_terminate/frontend/vite.config.ts b/contract_terminate/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/contract_terminate/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/package.json b/package.json index 623037a0..4753798c 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "lint": "rome check ./*", "lint:fix": "pnpm lint --apply-unsafe", "build:ui": "pnpm --filter ui build", - "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", - "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev", "basic_contract_caller": "pnpm --filter ui dev & pnpm --filter basic_contract_caller dev", - "contract_transfer": "pnpm --filter ui dev & pnpm --filter contract_transfer dev" + "contract_terminate": "pnpm --filter ui dev & pnpm --filter contract_terminate dev", + "contract_transfer": "pnpm --filter ui dev & pnpm --filter contract_transfer dev", + "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", + "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev" }, "packages": [ "ui", @@ -23,7 +24,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "useink": "^1.9.1" + "useink": "^1.10.3" }, "devDependencies": { "tailwindcss": "^3.3.2", diff --git a/ui/package.json b/ui/package.json index 717cfbbc..bd80fd8b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -11,11 +11,6 @@ "lint:fix": "pnpm lint --apply-unsafe" }, "sideEffects": false, - "peerDependencies": { - "useink": "^1.5.1", - "react": "^18.2.0", - "react-dom": "^18.2.0" - }, "dependencies": { "@headlessui/react": "^1.7.14", "@heroicons/react": "^2.0.18", diff --git a/ui/src/Events/Events.tsx b/ui/src/Events/Events.tsx new file mode 100644 index 00000000..da1ddaa3 --- /dev/null +++ b/ui/src/Events/Events.tsx @@ -0,0 +1,47 @@ +import { ClassNameable } from '..'; +import classNames from 'classnames'; +import React from 'react'; +import { EventRecord } from 'useink/core'; +import { + asContractInstantiatedEvent, + formatEventName, + isContractInstantiatedEvent, + isExtrinsicFailedEvent, +} from 'useink/utils'; + +export interface Props extends ClassNameable { + events?: EventRecord[]; +} + +export const Events: React.FC = ({ events, className }) => { + if (!events || events.length === 0) return null; + + return ( +
    + {events.map((event) => ( +
  • + {isContractInstantiatedEvent(event) ? ( +
    +

    {formatEventName(event)}

    +

    Deployer: {asContractInstantiatedEvent(event)?.deployer}

    + +

    + Contract Address:{' '} + {asContractInstantiatedEvent(event)?.contractAddress} +

    +
    + ) : ( + formatEventName(event) + )} +
  • + ))} +
+ ); +}; diff --git a/ui/src/Events/index.ts b/ui/src/Events/index.ts new file mode 100644 index 00000000..e162ea91 --- /dev/null +++ b/ui/src/Events/index.ts @@ -0,0 +1 @@ +export * from './Events'; diff --git a/ui/src/index.ts b/ui/src/index.ts index 6eff785f..e301a1c1 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -3,6 +3,7 @@ export * from './Button'; export * from './Card'; export * from './ConnectButton'; export * from './ConnectWallet'; +export * from './Events'; export * from './InkLayout'; export * from './Link'; export * from './LottieEntity'; From 8a17be16fbaac31ec4a884a3c712f4f1872e6b1e Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Thu, 6 Jul 2023 11:02:20 -0400 Subject: [PATCH 09/12] feat: add erc20 frontend --- README.md | 3 +- contract_transfer/frontend/src/App.tsx | 18 +- erc20/frontend/.gitignore | 21 + erc20/frontend/README.md | 4 + erc20/frontend/assets/erc20.json | 821 ++++++++++++++++++ erc20/frontend/index.html | 13 + erc20/frontend/package.json | 26 + erc20/frontend/postcss.config.js | 6 + erc20/frontend/public/logo.svg | 1 + erc20/frontend/src/App.tsx | 28 + erc20/frontend/src/Global.css | 7 + erc20/frontend/src/Other.tsx | 30 + erc20/frontend/src/components/Erc20/Erc20.tsx | 78 ++ erc20/frontend/src/components/Erc20/index.ts | 1 + .../src/components/ReadView/ReadView.tsx | 122 +++ .../frontend/src/components/ReadView/index.ts | 1 + .../src/components/WriteView/WriteView.tsx | 175 ++++ .../src/components/WriteView/index.ts | 1 + erc20/frontend/src/components/index.ts | 1 + erc20/frontend/src/main.tsx | 27 + erc20/frontend/src/vite-env.d.ts | 1 + erc20/frontend/tailwind.config.js | 2 + erc20/frontend/tsconfig.json | 25 + erc20/frontend/tsconfig.node.json | 10 + erc20/frontend/vite.config.ts | 7 + flipper/frontend/package.json | 5 + flipper/frontend/src/App.tsx | 4 +- package.json | 3 +- ui/src/BigIntInputField/BigIntInputField.tsx | 29 + ui/src/BigIntInputField/index.ts | 1 + ui/src/Button/Button.tsx | 2 +- ui/src/InputField/InputField.tsx | 32 + ui/src/InputField/index.ts | 1 + ui/src/Label/Label.tsx | 15 + ui/src/Label/index.ts | 1 + ui/src/NumberInput/NumberInput.tsx | 24 +- ui/src/RunResults/RunResults.tsx | 73 ++ ui/src/RunResults/index.ts | 1 + ui/src/Tabs/Tabs.tsx | 47 + ui/src/Tabs/index.ts | 1 + .../DeployerContext/DeployerContext.tsx | 161 ++++ ui/src/contexts/DeployerContext/index.ts | 1 + ui/src/contexts/{ => UIContext}/UIContext.tsx | 0 ui/src/contexts/UIContext/index.ts | 1 + ui/src/contexts/index.ts | 1 + ui/src/index.ts | 5 + 46 files changed, 1813 insertions(+), 24 deletions(-) create mode 100644 erc20/frontend/.gitignore create mode 100644 erc20/frontend/README.md create mode 100644 erc20/frontend/assets/erc20.json create mode 100644 erc20/frontend/index.html create mode 100644 erc20/frontend/package.json create mode 100644 erc20/frontend/postcss.config.js create mode 100644 erc20/frontend/public/logo.svg create mode 100644 erc20/frontend/src/App.tsx create mode 100644 erc20/frontend/src/Global.css create mode 100644 erc20/frontend/src/Other.tsx create mode 100644 erc20/frontend/src/components/Erc20/Erc20.tsx create mode 100644 erc20/frontend/src/components/Erc20/index.ts create mode 100644 erc20/frontend/src/components/ReadView/ReadView.tsx create mode 100644 erc20/frontend/src/components/ReadView/index.ts create mode 100644 erc20/frontend/src/components/WriteView/WriteView.tsx create mode 100644 erc20/frontend/src/components/WriteView/index.ts create mode 100644 erc20/frontend/src/components/index.ts create mode 100644 erc20/frontend/src/main.tsx create mode 100644 erc20/frontend/src/vite-env.d.ts create mode 100644 erc20/frontend/tailwind.config.js create mode 100644 erc20/frontend/tsconfig.json create mode 100644 erc20/frontend/tsconfig.node.json create mode 100644 erc20/frontend/vite.config.ts create mode 100644 ui/src/BigIntInputField/BigIntInputField.tsx create mode 100644 ui/src/BigIntInputField/index.ts create mode 100644 ui/src/InputField/InputField.tsx create mode 100644 ui/src/InputField/index.ts create mode 100644 ui/src/Label/Label.tsx create mode 100644 ui/src/Label/index.ts create mode 100644 ui/src/RunResults/RunResults.tsx create mode 100644 ui/src/RunResults/index.ts create mode 100644 ui/src/Tabs/Tabs.tsx create mode 100644 ui/src/Tabs/index.ts create mode 100644 ui/src/contexts/DeployerContext/DeployerContext.tsx create mode 100644 ui/src/contexts/DeployerContext/index.ts rename ui/src/contexts/{ => UIContext}/UIContext.tsx (100%) create mode 100644 ui/src/contexts/UIContext/index.ts diff --git a/README.md b/README.md index 42b612b3..2d9a9052 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ To build a single example and generate the contracts Wasm file, navigate to the You should now have an optimized `.wasm` file, a `metadata.json` file and a `.contract` file in the `target` folder of your contract. The `.contract` file combines the Wasm and metadata into one file and can be used for instantiation. - ## Running front end dApp examples 1. Install [nodejs](https://nodejs.org/en/) and then install [pnpm](https://pnpm.io/) `npm install -g pnpm` @@ -42,7 +41,9 @@ The `.contract` file combines the Wasm and metadata into one file and can be use ### Commands * `pnpm basic_contract_caller` +* `pnpm contract_terminate` * `pnpm contract_transfer` +* `pnpm erc20` * `pnpm flipper` * `pnpm incrementer` diff --git a/contract_transfer/frontend/src/App.tsx b/contract_transfer/frontend/src/App.tsx index 6bb9f43a..7809bff5 100644 --- a/contract_transfer/frontend/src/App.tsx +++ b/contract_transfer/frontend/src/App.tsx @@ -56,11 +56,10 @@ function App() { Contract Balance:{' '} {contractBalance - ? planckToDecimalFormatted( - contractBalance?.freeBalance, - chainContract?.contract.api, - { decimals: 4 }, - ) + ? planckToDecimalFormatted(contractBalance?.freeBalance, { + api: chainContract?.contract.api, + significantFigures: 4, + }) : '--'} @@ -69,11 +68,10 @@ function App() { Your Balance:{' '} {userBalance - ? planckToDecimalFormatted( - userBalance?.freeBalance, - chainContract?.contract.api, - { decimals: 4 }, - ) + ? planckToDecimalFormatted(userBalance?.freeBalance, { + api: chainContract?.contract.api, + significantFigures: 4, + }) : '--'} diff --git a/erc20/frontend/.gitignore b/erc20/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/erc20/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/erc20/frontend/README.md b/erc20/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/erc20/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/erc20/frontend/assets/erc20.json b/erc20/frontend/assets/erc20.json new file mode 100644 index 00000000..532fa52a --- /dev/null +++ b/erc20/frontend/assets/erc20.json @@ -0,0 +1,821 @@ +{ + "source": { + "hash": "0x2f88d986a619d7a1b81a3f6f886977fb3d56a2455b0368142fd4bf2e9d76d39e", + "language": "ink! 4.2.0", + "compiler": "rustc 1.70.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "erc20", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "total_supply", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + "Creates a new ERC-20 contract with the specified initial supply." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 5 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 0 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 14 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 15 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 12 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 13 + } + }, + "events": [ + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "from", + "type": { + "displayName": [ + "Option" + ], + "type": 11 + } + }, + { + "docs": [], + "indexed": true, + "label": "to", + "type": { + "displayName": [ + "Option" + ], + "type": 11 + } + }, + { + "docs": [], + "indexed": false, + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "docs": [ + "Event emitted when a token transfer occurs." + ], + "label": "Transfer" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "docs": [], + "indexed": true, + "label": "spender", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "docs": [], + "indexed": false, + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "docs": [ + "Event emitted when an approval occurs that `spender` is allowed to withdraw", + "up to the amount of `value` tokens from `owner`." + ], + "label": "Approval" + } + ], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 3 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [ + " Returns the total token supply." + ], + "label": "total_supply", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0xdb6375a8" + }, + { + "args": [ + { + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + } + ], + "default": false, + "docs": [ + " Returns the account balance for the specified `owner`.", + "", + " Returns `0` if the account is non-existent." + ], + "label": "balance_of", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x0f755a56" + }, + { + "args": [ + { + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "label": "spender", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + } + ], + "default": false, + "docs": [ + " Returns the amount which `spender` is still allowed to withdraw from `owner`.", + "", + " Returns `0` if no allowance has been set." + ], + "label": "allowance", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x6a00165e" + }, + { + "args": [ + { + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + " Transfers `value` amount of tokens from the caller's account to account `to`.", + "", + " On success a `Transfer` event is emitted.", + "", + " # Errors", + "", + " Returns `InsufficientBalance` error if there are not enough tokens on", + " the caller's account balance." + ], + "label": "transfer", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 8 + }, + "selector": "0x84a15da1" + }, + { + "args": [ + { + "label": "spender", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + " Allows `spender` to withdraw from the caller's account multiple times, up to", + " the `value` amount.", + "", + " If this function is called again it overwrites the current allowance with", + " `value`.", + "", + " An `Approval` event is emitted." + ], + "label": "approve", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 8 + }, + "selector": "0x681266a0" + }, + { + "args": [ + { + "label": "from", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 5 + } + }, + { + "label": "value", + "type": { + "displayName": [ + "Balance" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + " Transfers `value` tokens on the behalf of `from` to the account `to`.", + "", + " This can be used to allow a contract to transfer tokens on ones behalf and/or", + " to charge fees in sub-currencies, for example.", + "", + " On success a `Transfer` event is emitted.", + "", + " # Errors", + "", + " Returns `InsufficientAllowance` error if there are not enough tokens allowed", + " for the caller to withdraw from `from`.", + "", + " Returns `InsufficientBalance` error if there are not enough tokens on", + " the account balance of `from`." + ], + "label": "transfer_from", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 8 + }, + "selector": "0x0b396f18" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "total_supply" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x2623dce7", + "ty": 0 + } + }, + "root_key": "0x2623dce7" + } + }, + "name": "balances" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0xeca021b7", + "ty": 0 + } + }, + "root_key": "0xeca021b7" + } + }, + "name": "allowances" + } + ], + "name": "Erc20" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 3, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "array": { + "len": 32, + "type": 7 + } + } + } + }, + { + "id": 7, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 8, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 9 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 9 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 9, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 10 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 10 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "InsufficientBalance" + }, + { + "index": 1, + "name": "InsufficientAllowance" + } + ] + } + }, + "path": [ + "erc20", + "erc20", + "Error" + ] + } + }, + { + "id": 11, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "None" + }, + { + "fields": [ + { + "type": 5 + } + ], + "index": 1, + "name": "Some" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 5 + } + ], + "path": [ + "Option" + ] + } + }, + { + "id": 12, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 13, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 14, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 15, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/erc20/frontend/index.html b/erc20/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/erc20/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/erc20/frontend/package.json b/erc20/frontend/package.json new file mode 100644 index 00000000..16b2477f --- /dev/null +++ b/erc20/frontend/package.json @@ -0,0 +1,26 @@ +{ + "name": "erc20", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/erc20/frontend/postcss.config.js b/erc20/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/erc20/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/erc20/frontend/public/logo.svg b/erc20/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/erc20/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/erc20/frontend/src/App.tsx b/erc20/frontend/src/App.tsx new file mode 100644 index 00000000..bbc2d37c --- /dev/null +++ b/erc20/frontend/src/App.tsx @@ -0,0 +1,28 @@ +import metadata from '../assets/erc20.json'; +import { Erc20 } from './components'; +import { DeployerProvider, InkLayout } from 'ui'; + +const ONE_BILLION_TOKENS = '1000000000000000000000'; + +function App() { + return ( + + + + + + ); +} + +export default App; diff --git a/erc20/frontend/src/Global.css b/erc20/frontend/src/Global.css new file mode 100644 index 00000000..c2f5c12e --- /dev/null +++ b/erc20/frontend/src/Global.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: #1A1452; +} \ No newline at end of file diff --git a/erc20/frontend/src/Other.tsx b/erc20/frontend/src/Other.tsx new file mode 100644 index 00000000..84f93b69 --- /dev/null +++ b/erc20/frontend/src/Other.tsx @@ -0,0 +1,30 @@ +import otherContractMetadata from './assets/other_contract.json'; +import { Card } from 'ui'; +import { useCallSubscription, useContract } from 'useink'; +import { pickDecoded } from 'useink/utils'; + +interface Props { + address: string; +} + +export const Other: React.FC = ({ address }) => { + const otherContract = useContract(address, otherContractMetadata); + const getOtherSub = useCallSubscription(otherContract, 'get', [], { + defaultCaller: true, + }); + + return ( + +

+ {otherContractMetadata.contract.name.toUpperCase()} +

+ +

+ Flipped:{' '} + + {pickDecoded(getOtherSub.result)?.toString()} + +

+
+ ); +}; diff --git a/erc20/frontend/src/components/Erc20/Erc20.tsx b/erc20/frontend/src/components/Erc20/Erc20.tsx new file mode 100644 index 00000000..7137a03f --- /dev/null +++ b/erc20/frontend/src/components/Erc20/Erc20.tsx @@ -0,0 +1,78 @@ +import metadata from '../../../assets/erc20.json'; +import { ReadView } from '../ReadView'; +import { WriteView } from '../WriteView'; +import { useMemo, useState } from 'react'; +import { Card, Tab, Tabs, formatContractName, useDeployerState } from 'ui'; +import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { + pickDecoded, + planckToDecimalFormatted, + stringNumberToBN, +} from 'useink/utils'; + +export const Erc20: React.FC = () => { + const { contractAddress } = useDeployerState(); + const erc20 = useContract(contractAddress || '', metadata); + const [view, setView] = useState<'read' | 'write'>('read'); + + const approve = useTx(erc20, 'approve'); + useTxNotifications(approve); + + const { account } = useWallet(); + const balanceOf = useCallSubscription(erc20, 'balanceOf', [ + account?.address || '', + ]); + const yourBalance = useMemo(() => { + const stringWithCommas = pickDecoded(balanceOf.result) || '0'; + return stringNumberToBN(stringWithCommas); + }, [balanceOf.result]); + + return ( +
+ +
+

+ {formatContractName(metadata.contract.name)} +

+ + {erc20 && account && ( +
+

Your Balance

+

+ {yourBalance + ? planckToDecimalFormatted(yourBalance, { + api: erc20?.contract.api, + symbol: 'CLAMS', + }) + : '--'} +

+
+ )} +
+ + {erc20 && ( + <> + + setView('read')} isSelected={view === 'read'}> + Read + + setView('write')} + isSelected={view === 'write'} + > + Write + + + + {'read' === view ? ( + + ) : ( + + )} + + )} +
+
+ ); +}; diff --git a/erc20/frontend/src/components/Erc20/index.ts b/erc20/frontend/src/components/Erc20/index.ts new file mode 100644 index 00000000..ed779d7a --- /dev/null +++ b/erc20/frontend/src/components/Erc20/index.ts @@ -0,0 +1 @@ +export * from './Erc20'; diff --git a/erc20/frontend/src/components/ReadView/ReadView.tsx b/erc20/frontend/src/components/ReadView/ReadView.tsx new file mode 100644 index 00000000..65118d88 --- /dev/null +++ b/erc20/frontend/src/components/ReadView/ReadView.tsx @@ -0,0 +1,122 @@ +import { useMemo, useState } from 'react'; +import { Button, InputField } from 'ui'; +import { ChainContract, useCall, useCallSubscription } from 'useink'; +import { + pickDecoded, + planckToDecimalFormatted, + stringNumberToBN, +} from 'useink/utils'; + +const symbol = 'CLAMS'; + +interface Props { + erc20: ChainContract; +} + +export const ReadView: React.FC = ({ erc20 }) => { + const balanceOf = useCall(erc20, 'balanceOf'); + const [balanceOfOwner, setBalOfOwner] = useState(''); + const balanceResult = useMemo(() => { + // Convert string to BN. e.g. `1,000,000,000` -> BN + const stringWithCommas = pickDecoded(balanceOf.result); + if (!stringWithCommas) return; + return stringNumberToBN(stringWithCommas); + }, [balanceOf.result]); + + const allowance = useCall(erc20, 'allowance'); + const [allowanceOwner, setAllowanceOwner] = useState(''); + const [allowanceSpender, setAllowanceSpender] = useState(''); + const allowanceResult = useMemo(() => { + const stringWithCommas = pickDecoded(allowance.result); + if (!stringWithCommas) return; + return stringNumberToBN(stringWithCommas); + }, [allowance.result]); + + const totalSupply = useCallSubscription(erc20, 'totalSupply'); + const totalSupplyResult = useMemo(() => { + if (!totalSupply || !totalSupply?.result) return; + const stringWithCommas = pickDecoded(totalSupply.result) || '0'; + return stringNumberToBN(stringWithCommas); + }, [totalSupply.result]); + + return ( +
+

+ Total Supply:{' '} + {totalSupplyResult + ? planckToDecimalFormatted(totalSupplyResult, { + api: erc20?.contract.api, + symbol, + }) + : '--'} +

+ +
+ + setBalOfOwner(e.target.value)} + placeholder='Enter an Address...' + disabled={balanceOf.isSubmitting} + /> + + + {balanceResult && ( +

+ {planckToDecimalFormatted(balanceResult, { + api: erc20?.contract.api, + symbol: 'CLAMS', + })} +

+ )} +
+ +
+ + setAllowanceOwner(e.target.value)} + disabled={allowance.isSubmitting} + placeholder='Enter an Address...' + /> + + setAllowanceSpender(e.target.value)} + disabled={allowance.isSubmitting} + placeholder='Enter an Address...' + /> + + + {allowanceResult && ( +

+ {planckToDecimalFormatted(allowanceResult, { + api: erc20?.contract.api, + symbol: 'CLAMS', + })} +

+ )} +
+
+ ); +}; diff --git a/erc20/frontend/src/components/ReadView/index.ts b/erc20/frontend/src/components/ReadView/index.ts new file mode 100644 index 00000000..c4729ab7 --- /dev/null +++ b/erc20/frontend/src/components/ReadView/index.ts @@ -0,0 +1 @@ +export * from './ReadView'; diff --git a/erc20/frontend/src/components/WriteView/WriteView.tsx b/erc20/frontend/src/components/WriteView/WriteView.tsx new file mode 100644 index 00000000..a4872f99 --- /dev/null +++ b/erc20/frontend/src/components/WriteView/WriteView.tsx @@ -0,0 +1,175 @@ +import { useState } from 'react'; +import { BigIntInputField, Button, ConnectButton, InputField, Label } from 'ui'; +import { ChainContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { + isPendingSignature, + planckToDecimalFormatted, + shouldDisable, +} from 'useink/utils'; + +interface Props { + erc20: ChainContract; +} + +export const WriteView: React.FC = ({ erc20 }) => { + const { account } = useWallet(); + + const [transferAmount, setTransferAmount] = useState(0n); + const [transferToAddress, setTransferToAddress] = useState(''); + const transfer = useTx(erc20, 'transfer'); + useTxNotifications(transfer); + + const [approveAmount, setApproveAmount] = useState(0n); + const [approveSpender, setApproveSpender] = useState(''); + const approve = useTx(erc20, 'approve'); + useTxNotifications(approve); + + const [transferFromAmount, setTransferFromAmount] = useState(0n); + const [transferFromAddress, setTransferFromAddress] = useState(''); + const [transferFromToAddress, setTransferFromToAddress] = useState(''); + const transferFrom = useTx(erc20, 'transferFrom'); + useTxNotifications(transferFrom); + + if (!account) return ; + + return ( +
+
+ + setTransferToAddress(e.target.value)} + placeholder='To address...' + disabled={shouldDisable(transfer)} + /> + + + {transferAmount !== undefined && ( +

+ {planckToDecimalFormatted(transferAmount, { + api: erc20.contract.api, + symbol: 'CLAMS', + })} +

+ )} +
+ + +
+ +
+ + setApproveSpender(e.target.value)} + placeholder='Spender address...' + disabled={shouldDisable(approve)} + /> + + + {transferAmount !== undefined && ( +

+ {planckToDecimalFormatted(approveAmount, { + api: erc20.contract.api, + symbol: 'CLAMS', + })} +

+ )} +
+ + +
+ +
+ + setTransferFromAddress(e.target.value)} + placeholder='From address...' + disabled={shouldDisable(transferFrom)} + /> + + setTransferFromToAddress(e.target.value)} + placeholder='To address...' + disabled={shouldDisable(transferFrom)} + /> + + + {transferAmount !== undefined && ( +

+ {planckToDecimalFormatted(transferFromAmount, { + api: erc20.contract.api, + symbol: 'CLAMS', + })} +

+ )} +
+ + +
+
+ ); +}; diff --git a/erc20/frontend/src/components/WriteView/index.ts b/erc20/frontend/src/components/WriteView/index.ts new file mode 100644 index 00000000..98738aa5 --- /dev/null +++ b/erc20/frontend/src/components/WriteView/index.ts @@ -0,0 +1 @@ +export * from './WriteView'; diff --git a/erc20/frontend/src/components/index.ts b/erc20/frontend/src/components/index.ts new file mode 100644 index 00000000..ed779d7a --- /dev/null +++ b/erc20/frontend/src/components/index.ts @@ -0,0 +1 @@ +export * from './Erc20'; diff --git a/erc20/frontend/src/main.tsx b/erc20/frontend/src/main.tsx new file mode 100644 index 00000000..ce55e51e --- /dev/null +++ b/erc20/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import metadata from '../assets/erc20.json'; +import App from './App.tsx'; +import './Global.css'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/erc20/frontend/src/vite-env.d.ts b/erc20/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/erc20/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/erc20/frontend/tailwind.config.js b/erc20/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/erc20/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/erc20/frontend/tsconfig.json b/erc20/frontend/tsconfig.json new file mode 100644 index 00000000..5178ef59 --- /dev/null +++ b/erc20/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src", "../../ui/src/contexts/DeployerContext"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/erc20/frontend/tsconfig.node.json b/erc20/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/erc20/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/erc20/frontend/vite.config.ts b/erc20/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/erc20/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/flipper/frontend/package.json b/flipper/frontend/package.json index fa9d0bef..ecba45fa 100644 --- a/flipper/frontend/package.json +++ b/flipper/frontend/package.json @@ -15,8 +15,13 @@ "devDependencies": { "@types/react": "^18.0.37", "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.59.0", + "@typescript-eslint/parser": "^5.59.0", "@vitejs/plugin-react": "^4.0.0", "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", "postcss": "^8.4.24", "tailwindcss": "^3.3.2", "typescript": "^5.0.2", diff --git a/flipper/frontend/src/App.tsx b/flipper/frontend/src/App.tsx index 91704fb4..4403d237 100644 --- a/flipper/frontend/src/App.tsx +++ b/flipper/frontend/src/App.tsx @@ -1,6 +1,6 @@ import metadata from './assets/flipper.json'; import { CONTRACT_ROCOCO_ADDRESS } from './constants'; -import { Button, Card, ConnectButton, InkLayout, formatContractName } from 'ui'; +import { Button, Card, ConnectButton, InkLayout } from 'ui'; import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { pickDecoded, shouldDisable } from 'useink/utils'; @@ -22,7 +22,7 @@ function App() { >

- {formatContractName(metadata.contract.name)} + {metadata.contract.name.toUpperCase()}

diff --git a/package.json b/package.json index 4753798c..0c0859a9 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "basic_contract_caller": "pnpm --filter ui dev & pnpm --filter basic_contract_caller dev", "contract_terminate": "pnpm --filter ui dev & pnpm --filter contract_terminate dev", "contract_transfer": "pnpm --filter ui dev & pnpm --filter contract_transfer dev", + "erc20": "pnpm --filter ui dev & pnpm --filter erc20 dev", "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev" }, @@ -24,7 +25,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "useink": "^1.10.3" + "useink": "^1.13.0" }, "devDependencies": { "tailwindcss": "^3.3.2", diff --git a/ui/src/BigIntInputField/BigIntInputField.tsx b/ui/src/BigIntInputField/BigIntInputField.tsx new file mode 100644 index 00000000..a1cb13b4 --- /dev/null +++ b/ui/src/BigIntInputField/BigIntInputField.tsx @@ -0,0 +1,29 @@ +import { InputField } from '..'; +import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react'; + +interface Props + extends DetailedHTMLProps< + InputHTMLAttributes, + HTMLInputElement + > { + value: string; + onDigitChange: (digits: bigint) => void; +} + +export const BigIntInputField: React.FC = ({ + className, + onDigitChange, + ...props +}) => { + const handleChange = (val: string) => { + if (/^\d*$/.test(val)) onDigitChange(BigInt(val)); + }; + + return ( + handleChange(e.target.value)} + /> + ); +}; diff --git a/ui/src/BigIntInputField/index.ts b/ui/src/BigIntInputField/index.ts new file mode 100644 index 00000000..9f60a5ea --- /dev/null +++ b/ui/src/BigIntInputField/index.ts @@ -0,0 +1 @@ +export * from './BigIntInputField'; diff --git a/ui/src/Button/Button.tsx b/ui/src/Button/Button.tsx index fe3a7073..ef86c043 100644 --- a/ui/src/Button/Button.tsx +++ b/ui/src/Button/Button.tsx @@ -21,7 +21,7 @@ export const Button: React.FC = ({ const classes = classNames( 'bg-brand-900 hover:bg-brand-800 transition ease-in-out px-6 py-2 border-none', 'text-base tracking-wide font-semibold rounded-full disabled:bg-brand-450', - 'focus:ring-none disabled:cursor-not-allowed focus:outline-none focus:ring-0 focus:ring-offset-0 text-white', + 'focus:ring-4 ring-white/60 disabled:cursor-not-allowed focus:outline-none focus:ring-offset-0 text-white', className, ); diff --git a/ui/src/InputField/InputField.tsx b/ui/src/InputField/InputField.tsx new file mode 100644 index 00000000..b541c349 --- /dev/null +++ b/ui/src/InputField/InputField.tsx @@ -0,0 +1,32 @@ +import classnames from 'classnames'; +import React, { + ChangeEventHandler, + DetailedHTMLProps, + InputHTMLAttributes, +} from 'react'; + +interface Props + extends DetailedHTMLProps< + InputHTMLAttributes, + HTMLInputElement + > { + onChange: ChangeEventHandler; + value: string; + placeholder?: string; + disabled?: boolean; +} + +export const InputField: React.FC = ({ className, ...props }) => { + return ( + + ); +}; diff --git a/ui/src/InputField/index.ts b/ui/src/InputField/index.ts new file mode 100644 index 00000000..9cd70224 --- /dev/null +++ b/ui/src/InputField/index.ts @@ -0,0 +1 @@ +export * from './InputField'; diff --git a/ui/src/Label/Label.tsx b/ui/src/Label/Label.tsx new file mode 100644 index 00000000..ee376216 --- /dev/null +++ b/ui/src/Label/Label.tsx @@ -0,0 +1,15 @@ +import classNames from 'classnames'; +import React, { PropsWithChildren } from 'react'; + +interface Props { + className?: string; +} + +export const Label: React.FC> = ({ + children, + className, +}) => ( + +); diff --git a/ui/src/Label/index.ts b/ui/src/Label/index.ts new file mode 100644 index 00000000..ca58c61a --- /dev/null +++ b/ui/src/Label/index.ts @@ -0,0 +1 @@ +export * from './Label'; diff --git a/ui/src/NumberInput/NumberInput.tsx b/ui/src/NumberInput/NumberInput.tsx index 535f104d..3f15f31d 100644 --- a/ui/src/NumberInput/NumberInput.tsx +++ b/ui/src/NumberInput/NumberInput.tsx @@ -1,6 +1,6 @@ import { ClassNameable } from '..'; import { MinusIcon, PlusIcon } from '@heroicons/react/24/solid'; -import classnames from 'classnames'; +import classNames from 'classnames'; import React from 'react'; type Props = ClassNameable & { @@ -14,10 +14,10 @@ type Props = ClassNameable & { const COMMON_CLASSES = [ 'bg-brand-500 disabled:bg-brand-450 text-white border-none focuse:outline-none focus-visible:outline-none', - 'focus:outline-none disabled:text-white/80 py-4 flex items-center justify-center disabled:cursor-not-allowed', + 'focus:outline-none disabled:text-white/80 py-2 flex items-center justify-center disabled:cursor-not-allowed', ].join(' '); -const BUTTON_CLASSES = 'hover:bg-brand-900'; +const BUTTON_CLASSES = 'hover:bg-brand-900/50'; export const NumberInput: React.FC = ({ value, @@ -26,6 +26,7 @@ export const NumberInput: React.FC = ({ placeholder, max, min = 0, + className, }) => { const handleChange = (v: number) => { const val = v || min; @@ -35,21 +36,26 @@ export const NumberInput: React.FC = ({ }; return ( - + = ({ type='button' disabled={value >= max || disabled} onClick={() => handleChange(value + 1)} - className={classnames( + className={classNames( COMMON_CLASSES, BUTTON_CLASSES, - 'rounded-r-full pr-8 pl-4', + 'rounded-r-full pr-4 pl-2', )} > diff --git a/ui/src/RunResults/RunResults.tsx b/ui/src/RunResults/RunResults.tsx new file mode 100644 index 00000000..4fc0ccc3 --- /dev/null +++ b/ui/src/RunResults/RunResults.tsx @@ -0,0 +1,73 @@ +import classNames from 'classnames'; +import React from 'react'; +import { IApiProvider } from 'useink'; +import { StorageDeposit, WeightV2 } from 'useink/core'; +import { planckToDecimalFormatted } from 'useink/utils'; + +export interface RunResultsProps { + title?: string; + className?: string; + contractAddress?: string; + storageDeposit?: StorageDeposit; + gasConsumed?: WeightV2; + gasRequired?: WeightV2; + chainApi: IApiProvider | undefined; +} + +export const RunResults: React.FC = ({ + title, + className, + storageDeposit, + contractAddress, + gasConsumed, + gasRequired, + chainApi, +}) => { + return ( +

+ {storageDeposit && ( +
+ {title &&

{title}

} + + {contractAddress && ( +
+

Contract Address

+

{contractAddress}

+
+ )} + + {gasConsumed && ( +
+

Gas Consumed

+
    +
  • refTime: {gasConsumed.refTime.toString()}
  • +
  • proof size: {gasConsumed.proofSize.toString()}
  • +
+
+ )} + + {gasRequired && ( +
+

Gas Required

+
    +
  • refTime: {gasRequired.refTime.toString()}
  • +
  • proof size: {gasRequired.proofSize.toString()}
  • +
+
+ )} + + {storageDeposit && ( +
+

+ Storage Deposit:{' '} + {planckToDecimalFormatted(storageDeposit.asCharge, { + api: chainApi?.api, + })} +

+
+ )} +
+ )} +
+ ); +}; diff --git a/ui/src/RunResults/index.ts b/ui/src/RunResults/index.ts new file mode 100644 index 00000000..492fdc79 --- /dev/null +++ b/ui/src/RunResults/index.ts @@ -0,0 +1 @@ +export * from './RunResults'; diff --git a/ui/src/Tabs/Tabs.tsx b/ui/src/Tabs/Tabs.tsx new file mode 100644 index 00000000..9eb90662 --- /dev/null +++ b/ui/src/Tabs/Tabs.tsx @@ -0,0 +1,47 @@ +import classNames from 'classnames'; +import React, { PropsWithChildren } from 'react'; + +interface Props { + className?: string; +} + +export const Tabs: React.FC> = ({ + children, + className, +}) => ( +
+ {children} +
+); + +interface TabProps { + className?: string; + isSelected: boolean; + onClick: () => void; +} + +export const Tab: React.FC> = ({ + children, + className, + isSelected, + onClick, +}) => ( + +); diff --git a/ui/src/Tabs/index.ts b/ui/src/Tabs/index.ts new file mode 100644 index 00000000..856dbbb3 --- /dev/null +++ b/ui/src/Tabs/index.ts @@ -0,0 +1 @@ +export * from './Tabs'; diff --git a/ui/src/contexts/DeployerContext/DeployerContext.tsx b/ui/src/contexts/DeployerContext/DeployerContext.tsx new file mode 100644 index 00000000..7df9e35b --- /dev/null +++ b/ui/src/contexts/DeployerContext/DeployerContext.tsx @@ -0,0 +1,161 @@ +import { RunResults } from '../..'; +import { Button } from '../../Button'; +import { Card } from '../../Card'; +import { ConnectButton } from '../../ConnectButton'; +import { formatContractName } from '../../utils'; +import React, { + PropsWithChildren, + createContext, + useCallback, + useContext, + useEffect, + useMemo, +} from 'react'; +import { useApi, useDeployer, useMetadata, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { + isFinalized, + isPendingSignature, + shouldDisableStrict, +} from 'useink/utils'; + +export interface DeployerContextProps { + metadata: Record; + constructorArgs: Record | undefined; + constructorName: string; + codeHash: string; +} + +export interface DeployerState { + contractAddress?: string; + clearContract: () => void; +} + +const DeployerContext = createContext({ + clearContract: () => null, +}); + +function getContractAddress(key: string): string | null { + return localStorage.getItem(key); +} + +function setContractAddress(key: string, address: string) { + localStorage.setItem(key, address); +} + +function removeContractAddress(key: string) { + if (getContractAddress(key)) localStorage.removeItem(key); +} + +export const DeployerProvider: React.FC< + PropsWithChildren +> = ({ children, metadata, constructorArgs, constructorName, codeHash }) => { + const chainApi = useApi(); + const { account } = useWallet(); + const M = useMetadata({ requireWasm: false }, metadata); + const D = useDeployer(); + useTxNotifications(D); + + const name = useMemo( + () => (metadata?.contract as { name?: string })?.name || '', + [metadata], + ); + const storageKey = name ? `${name}-address` : ''; + + const savedAddress = useMemo(() => getContractAddress(storageKey), [name]); + const clearContract = useCallback(() => { + removeContractAddress(storageKey); + }, [name]); + + const signAndSend = useCallback(() => { + D.signAndSend(M.abi, constructorName, constructorArgs, { codeHash }); + }, [M.abi]); + + useEffect(() => { + chainApi?.api && + M.abi && + D.dryRun(M.abi, constructorName, constructorArgs, { + codeHash, + defaultCaller: true, + }); + }, [M.abi, chainApi?.api]); + + useEffect(() => { + if (D.contractAddress && D.wasDeployed && isFinalized(D)) { + setContractAddress(storageKey, D.contractAddress); + } + }, [D.status]); + + return ( + + {savedAddress || (D.wasDeployed && isFinalized(D)) ? ( + children + ) : ( +
+ +
+
+

+ {formatContractName(name)} +

+

+ {D.storageDeposit + ? "Let's first deploy the contract!" + : 'Loading...'} +

+
+ + {D.storageDeposit && ( + + )} + + {M.error && ( +

+ Metadata: + {M.error} +

+ )} + + {D.error && ( +

+ Deployer: + {D.error} +

+ )} + + {account ? ( + + ) : ( + + )} +
+
+
+ )} +
+ ); +}; + +export const useDeployerState = () => useContext(DeployerContext); diff --git a/ui/src/contexts/DeployerContext/index.ts b/ui/src/contexts/DeployerContext/index.ts new file mode 100644 index 00000000..f7417ca4 --- /dev/null +++ b/ui/src/contexts/DeployerContext/index.ts @@ -0,0 +1 @@ +export * from './DeployerContext'; diff --git a/ui/src/contexts/UIContext.tsx b/ui/src/contexts/UIContext/UIContext.tsx similarity index 100% rename from ui/src/contexts/UIContext.tsx rename to ui/src/contexts/UIContext/UIContext.tsx diff --git a/ui/src/contexts/UIContext/index.ts b/ui/src/contexts/UIContext/index.ts new file mode 100644 index 00000000..40b50346 --- /dev/null +++ b/ui/src/contexts/UIContext/index.ts @@ -0,0 +1 @@ +export * from './UIContext'; diff --git a/ui/src/contexts/index.ts b/ui/src/contexts/index.ts index 40b50346..4a673612 100644 --- a/ui/src/contexts/index.ts +++ b/ui/src/contexts/index.ts @@ -1 +1,2 @@ +export * from './DeployerContext'; export * from './UIContext'; diff --git a/ui/src/index.ts b/ui/src/index.ts index e301a1c1..681c9450 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -1,17 +1,22 @@ export * from './Accounts'; +export * from './BigIntInputField'; export * from './Button'; export * from './Card'; export * from './ConnectButton'; export * from './ConnectWallet'; export * from './Events'; export * from './InkLayout'; +export * from './InputField'; +export * from './Label'; export * from './Link'; export * from './LottieEntity'; export * from './Modal'; export * from './Navbar'; export * from './Notifications'; export * from './NumberInput'; +export * from './RunResults'; export * from './Snackbar'; +export * from './Tabs'; export * from './contexts'; export * from './hooks'; From 1fbe676bf0e8a5e888c327db75a74acf24685b42 Mon Sep 17 00:00:00 2001 From: Sam Ruberti Date: Wed, 19 Jul 2023 16:11:50 -0400 Subject: [PATCH 10/12] feat: add erc721 frontend --- README.md | 1 + erc20/frontend/src/Other.tsx | 30 - erc721/frontend/.gitignore | 21 + erc721/frontend/README.md | 4 + erc721/frontend/assets/erc721.json | 1086 +++++++++++++++++ erc721/frontend/index.html | 13 + erc721/frontend/package.json | 26 + erc721/frontend/postcss.config.js | 6 + erc721/frontend/public/logo.svg | 1 + erc721/frontend/src/App.tsx | 26 + erc721/frontend/src/Global.css | 7 + .../frontend/src/components/Erc721/Erc721.tsx | 65 + .../frontend/src/components/Erc721/index.ts | 1 + .../src/components/ReadView/ReadView.tsx | 161 +++ .../frontend/src/components/ReadView/index.ts | 1 + .../src/components/WriteView/WriteView.tsx | 252 ++++ .../src/components/WriteView/index.ts | 1 + erc721/frontend/src/components/index.ts | 1 + erc721/frontend/src/main.tsx | 27 + erc721/frontend/src/vite-env.d.ts | 1 + erc721/frontend/tailwind.config.js | 2 + erc721/frontend/tsconfig.json | 25 + erc721/frontend/tsconfig.node.json | 10 + erc721/frontend/vite.config.ts | 7 + package.json | 1 + ui/src/ToggleSwitch/ToggleSwitch.tsx | 40 + ui/src/ToggleSwitch/index.ts | 1 + ui/src/index.ts | 1 + 28 files changed, 1788 insertions(+), 30 deletions(-) delete mode 100644 erc20/frontend/src/Other.tsx create mode 100644 erc721/frontend/.gitignore create mode 100644 erc721/frontend/README.md create mode 100644 erc721/frontend/assets/erc721.json create mode 100644 erc721/frontend/index.html create mode 100644 erc721/frontend/package.json create mode 100644 erc721/frontend/postcss.config.js create mode 100644 erc721/frontend/public/logo.svg create mode 100644 erc721/frontend/src/App.tsx create mode 100644 erc721/frontend/src/Global.css create mode 100644 erc721/frontend/src/components/Erc721/Erc721.tsx create mode 100644 erc721/frontend/src/components/Erc721/index.ts create mode 100644 erc721/frontend/src/components/ReadView/ReadView.tsx create mode 100644 erc721/frontend/src/components/ReadView/index.ts create mode 100644 erc721/frontend/src/components/WriteView/WriteView.tsx create mode 100644 erc721/frontend/src/components/WriteView/index.ts create mode 100644 erc721/frontend/src/components/index.ts create mode 100644 erc721/frontend/src/main.tsx create mode 100644 erc721/frontend/src/vite-env.d.ts create mode 100644 erc721/frontend/tailwind.config.js create mode 100644 erc721/frontend/tsconfig.json create mode 100644 erc721/frontend/tsconfig.node.json create mode 100644 erc721/frontend/vite.config.ts create mode 100644 ui/src/ToggleSwitch/ToggleSwitch.tsx create mode 100644 ui/src/ToggleSwitch/index.ts diff --git a/README.md b/README.md index 2d9a9052..670dd042 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ The `.contract` file combines the Wasm and metadata into one file and can be use * `pnpm contract_terminate` * `pnpm contract_transfer` * `pnpm erc20` +* `pnpm erc721` * `pnpm flipper` * `pnpm incrementer` diff --git a/erc20/frontend/src/Other.tsx b/erc20/frontend/src/Other.tsx deleted file mode 100644 index 84f93b69..00000000 --- a/erc20/frontend/src/Other.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import otherContractMetadata from './assets/other_contract.json'; -import { Card } from 'ui'; -import { useCallSubscription, useContract } from 'useink'; -import { pickDecoded } from 'useink/utils'; - -interface Props { - address: string; -} - -export const Other: React.FC = ({ address }) => { - const otherContract = useContract(address, otherContractMetadata); - const getOtherSub = useCallSubscription(otherContract, 'get', [], { - defaultCaller: true, - }); - - return ( - -

- {otherContractMetadata.contract.name.toUpperCase()} -

- -

- Flipped:{' '} - - {pickDecoded(getOtherSub.result)?.toString()} - -

-
- ); -}; diff --git a/erc721/frontend/.gitignore b/erc721/frontend/.gitignore new file mode 100644 index 00000000..c13f37b6 --- /dev/null +++ b/erc721/frontend/.gitignore @@ -0,0 +1,21 @@ +# Logs +logs +*.log +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/erc721/frontend/README.md b/erc721/frontend/README.md new file mode 100644 index 00000000..ad88c572 --- /dev/null +++ b/erc721/frontend/README.md @@ -0,0 +1,4 @@ +# Have Questions? + +For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). + diff --git a/erc721/frontend/assets/erc721.json b/erc721/frontend/assets/erc721.json new file mode 100644 index 00000000..caf458b2 --- /dev/null +++ b/erc721/frontend/assets/erc721.json @@ -0,0 +1,1086 @@ +{ + "source": { + "hash": "0xe27214c33419121ce913d12859f57807fcee75a5ca53c32e7c97dd5d48181507", + "language": "ink! 4.2.0", + "compiler": "rustc 1.71.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "stable-x86_64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "erc721", + "version": "4.2.0", + "authors": [ + "Parity Technologies " + ] + }, + "spec": { + "constructors": [ + { + "args": [], + "default": false, + "docs": [ + "Creates a new ERC-721 token contract." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 5 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 0 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 15 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 3 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 18 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 16 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 17 + } + }, + "events": [ + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "from", + "type": { + "displayName": [ + "Option" + ], + "type": 9 + } + }, + { + "docs": [], + "indexed": true, + "label": "to", + "type": { + "displayName": [ + "Option" + ], + "type": 9 + } + }, + { + "docs": [], + "indexed": true, + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "docs": [ + "Event emitted when a token transfer occurs." + ], + "label": "Transfer" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "from", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "docs": [], + "indexed": true, + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "docs": [], + "indexed": true, + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "docs": [ + "Event emitted when a token approve occurs." + ], + "label": "Approval" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "docs": [], + "indexed": true, + "label": "operator", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "docs": [], + "indexed": false, + "label": "approved", + "type": { + "displayName": [ + "bool" + ], + "type": 11 + } + } + ], + "docs": [ + "Event emitted when an operator is enabled or disabled for an owner.", + "The operator can manage all NFTs of the owner." + ], + "label": "ApprovalForAll" + } + ], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 6 + }, + "messages": [ + { + "args": [ + { + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + " Returns the balance of the owner.", + "", + " This represents the amount of unique tokens the owner has." + ], + "label": "balance_of", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 7 + }, + "selector": "0x0f755a56" + }, + { + "args": [ + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Returns the owner of the token." + ], + "label": "owner_of", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 8 + }, + "selector": "0x99720c1e" + }, + { + "args": [ + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Returns the approved account ID for this token if any." + ], + "label": "get_approved", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 8 + }, + "selector": "0x27592dea" + }, + { + "args": [ + { + "label": "owner", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "operator", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + " Returns `true` if the operator is approved by the owner." + ], + "label": "is_approved_for_all", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 10 + }, + "selector": "0x0f5922e9" + }, + { + "args": [ + { + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "approved", + "type": { + "displayName": [ + "bool" + ], + "type": 11 + } + } + ], + "default": false, + "docs": [ + " Approves or disapproves the operator for all tokens of the caller." + ], + "label": "set_approval_for_all", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0xcfd0c27b" + }, + { + "args": [ + { + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Approves the account to transfer the specified token on behalf of the caller." + ], + "label": "approve", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0x681266a0" + }, + { + "args": [ + { + "label": "destination", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Transfers the token from the caller to the given destination." + ], + "label": "transfer", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0x84a15da1" + }, + { + "args": [ + { + "label": "from", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "to", + "type": { + "displayName": [ + "AccountId" + ], + "type": 0 + } + }, + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Transfer approved or owned token." + ], + "label": "transfer_from", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0x0b396f18" + }, + { + "args": [ + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Creates a new token." + ], + "label": "mint", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0xcfdd9aa2" + }, + { + "args": [ + { + "label": "id", + "type": { + "displayName": [ + "TokenId" + ], + "type": 3 + } + } + ], + "default": false, + "docs": [ + " Deletes an existing token. Only the owner can burn the token." + ], + "label": "burn", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 12 + }, + "selector": "0xb1efc17b" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0xed16db9e", + "ty": 0 + } + }, + "root_key": "0xed16db9e" + } + }, + "name": "token_owner" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x4d897660", + "ty": 0 + } + }, + "root_key": "0x4d897660" + } + }, + "name": "token_approvals" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0xb5379df2", + "ty": 3 + } + }, + "root_key": "0xb5379df2" + } + }, + "name": "owned_tokens_count" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0xad984333", + "ty": 4 + } + }, + "root_key": "0xad984333" + } + }, + "name": "operator_approvals" + } + ], + "name": "Erc721" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 1, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 1, + "type": { + "def": { + "array": { + "len": 32, + "type": 2 + } + } + } + }, + { + "id": 2, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 3, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 4, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 5, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 4 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 4 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 7, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 3 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 3 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 8, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 9 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 9 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 9, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "None" + }, + { + "fields": [ + { + "type": 0 + } + ], + "index": 1, + "name": "Some" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + } + ], + "path": [ + "Option" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 11 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 11 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 12, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 13 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 6 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 13 + }, + { + "name": "E", + "type": 6 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 13, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 4 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 14 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 4 + }, + { + "name": "E", + "type": 14 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 14, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "NotOwner" + }, + { + "index": 1, + "name": "NotApproved" + }, + { + "index": 2, + "name": "TokenExists" + }, + { + "index": 3, + "name": "TokenNotFound" + }, + { + "index": 4, + "name": "CannotInsert" + }, + { + "index": 5, + "name": "CannotFetchValue" + }, + { + "index": 6, + "name": "NotAllowed" + } + ] + } + }, + "path": [ + "erc721", + "erc721", + "Error" + ] + } + }, + { + "id": 15, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 16, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 1, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 17, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 18, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/erc721/frontend/index.html b/erc721/frontend/index.html new file mode 100644 index 00000000..e4d2ac59 --- /dev/null +++ b/erc721/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + ink! Examples + + +
+ + + diff --git a/erc721/frontend/package.json b/erc721/frontend/package.json new file mode 100644 index 00000000..91571bde --- /dev/null +++ b/erc721/frontend/package.json @@ -0,0 +1,26 @@ +{ + "name": "erc721", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "ui": "workspace:ui@*" + }, + "devDependencies": { + "@types/react": "^18.0.37", + "@types/react-dom": "^18.0.11", + "@vitejs/plugin-react": "^4.0.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.38.0", + "postcss": "^8.4.24", + "tailwindcss": "^3.3.2", + "typescript": "^5.0.2", + "vite": "^4.3.9" + } +} diff --git a/erc721/frontend/postcss.config.js b/erc721/frontend/postcss.config.js new file mode 100644 index 00000000..2aa7205d --- /dev/null +++ b/erc721/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/erc721/frontend/public/logo.svg b/erc721/frontend/public/logo.svg new file mode 100644 index 00000000..c31ded82 --- /dev/null +++ b/erc721/frontend/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/erc721/frontend/src/App.tsx b/erc721/frontend/src/App.tsx new file mode 100644 index 00000000..a8bb2954 --- /dev/null +++ b/erc721/frontend/src/App.tsx @@ -0,0 +1,26 @@ +import metadata from '../assets/erc721.json'; +import { Erc721 } from './components'; +import { DeployerProvider, InkLayout } from 'ui'; + +function App() { + return ( + + + + + + ); +} + +export default App; diff --git a/erc721/frontend/src/Global.css b/erc721/frontend/src/Global.css new file mode 100644 index 00000000..c2f5c12e --- /dev/null +++ b/erc721/frontend/src/Global.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: #1A1452; +} \ No newline at end of file diff --git a/erc721/frontend/src/components/Erc721/Erc721.tsx b/erc721/frontend/src/components/Erc721/Erc721.tsx new file mode 100644 index 00000000..b96c9329 --- /dev/null +++ b/erc721/frontend/src/components/Erc721/Erc721.tsx @@ -0,0 +1,65 @@ +import metadata from '../../../assets/erc721.json'; +import { ReadView } from '../ReadView'; +import { WriteView } from '../WriteView'; +import { useState } from 'react'; +import { Card, Tab, Tabs, formatContractName, useDeployerState } from 'ui'; +import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { pickDecoded } from 'useink/utils'; + +export const Erc721: React.FC = () => { + const { contractAddress } = useDeployerState(); + const erc721 = useContract(contractAddress || '', metadata); + const [view, setView] = useState<'read' | 'write'>('read'); + + const approve = useTx(erc721, 'approve'); + useTxNotifications(approve); + + const { account } = useWallet(); + const balanceOf = useCallSubscription(erc721, 'balanceOf', [ + account?.address || '', + ]); + + return ( +
+ +
+

+ {formatContractName(metadata.contract.name)} +

+ + {erc721 && account && ( +
+

Your Balance

+

+ {pickDecoded(balanceOf.result) || '--'} +

+
+ )} +
+ + {erc721 && ( + <> + + setView('read')} isSelected={view === 'read'}> + Read + + setView('write')} + isSelected={view === 'write'} + > + Write + + + + {'read' === view ? ( + + ) : ( + + )} + + )} +
+
+ ); +}; diff --git a/erc721/frontend/src/components/Erc721/index.ts b/erc721/frontend/src/components/Erc721/index.ts new file mode 100644 index 00000000..c87713b7 --- /dev/null +++ b/erc721/frontend/src/components/Erc721/index.ts @@ -0,0 +1 @@ +export * from './Erc721'; diff --git a/erc721/frontend/src/components/ReadView/ReadView.tsx b/erc721/frontend/src/components/ReadView/ReadView.tsx new file mode 100644 index 00000000..a4aefd29 --- /dev/null +++ b/erc721/frontend/src/components/ReadView/ReadView.tsx @@ -0,0 +1,161 @@ +import { useState } from 'react'; +import { Button, InputField, NumberInput } from 'ui'; +import { ChainContract, useCall } from 'useink'; +import { pickDecoded, pickError } from 'useink/utils'; + +interface Props { + erc721: ChainContract; +} + +export const ReadView: React.FC = ({ erc721 }) => { + const ownerOf = useCall(erc721, 'ownerOf'); + const [ownerOfId, setOwnerOfId] = useState(1); + + const balanceOf = useCall(erc721, 'balanceOf'); + const [balanceOfOwner, setBalOfOwner] = useState(''); + + const getApproved = useCall(erc721, 'getApproved'); + const [approvedTokenId, setApprovedTokenId] = useState(1); + + const isApprovedForAll = useCall(erc721, 'isApprovedForAll'); + const [approvedForAllOwner, setApprovedForAllOwner] = useState(''); + const [approvedForAllOperator, setApprovedForAllOperator] = useState(''); + + return ( +
+
+ + + + + {pickDecoded(ownerOf.result) && ( +

+ {pickDecoded(ownerOf.result)} +

+ )} + + {pickError(ownerOf.result) && ( +

+ {pickError(ownerOf.result)} +

+ )} +
+ +
+ + setBalOfOwner(e.target.value)} + placeholder='Enter an Address...' + disabled={balanceOf.isSubmitting} + /> + + + {balanceOf !== undefined && ( +

+ {pickDecoded(balanceOf.result)} +

+ )} +
+ +
+ + + + + {pickDecoded(getApproved.result) && ( +

+ {pickDecoded(getApproved.result)} +

+ )} + + {pickError(getApproved.result) && ( +

+ {pickError(getApproved.result)} +

+ )} +
+ +
+ + setApprovedForAllOwner(e.target.value)} + placeholder='Enter the owner...' + disabled={isApprovedForAll.isSubmitting} + /> + + setApprovedForAllOperator(e.target.value)} + placeholder='Enter the operator...' + disabled={isApprovedForAll.isSubmitting} + /> + + + {pickDecoded(isApprovedForAll.result) !== undefined && ( +

+ {`${pickDecoded(isApprovedForAll.result)}`} +

+ )} + + {pickError(isApprovedForAll.result) && ( +

+ {pickError(isApprovedForAll.result)} +

+ )} +
+
+ ); +}; diff --git a/erc721/frontend/src/components/ReadView/index.ts b/erc721/frontend/src/components/ReadView/index.ts new file mode 100644 index 00000000..c4729ab7 --- /dev/null +++ b/erc721/frontend/src/components/ReadView/index.ts @@ -0,0 +1 @@ +export * from './ReadView'; diff --git a/erc721/frontend/src/components/WriteView/WriteView.tsx b/erc721/frontend/src/components/WriteView/WriteView.tsx new file mode 100644 index 00000000..48b7d400 --- /dev/null +++ b/erc721/frontend/src/components/WriteView/WriteView.tsx @@ -0,0 +1,252 @@ +import { useState } from 'react'; +import { + Button, + ConnectButton, + InputField, + NumberInput, + ToggleSwitch, +} from 'ui'; +import { ChainContract, useTx, useWallet } from 'useink'; +import { useTxNotifications } from 'useink/notifications'; +import { isPendingSignature, shouldDisable } from 'useink/utils'; + +interface Props { + erc721: ChainContract; +} + +export const WriteView: React.FC = ({ erc721 }) => { + const { account } = useWallet(); + + const [mintTokenId, setMintTokenId] = useState(1); + const mint = useTx(erc721, 'mint'); + useTxNotifications(mint); + + const [burnTokenId, setBurnTokenId] = useState(1); + const burn = useTx(erc721, 'burn'); + useTxNotifications(burn); + + const [isApprovedForAll, setIsApprovedForAll] = useState(true); + const [approvalForAllAccount, setApprovalForAllAccount] = useState(''); + const setApprovalForAll = useTx(erc721, 'setApprovalForAll'); + useTxNotifications(setApprovalForAll); + + const [approveTokenId, setApproveTokenId] = useState(1); + const [approvalForTokenAccount, setApprovalForTokenAccount] = useState(''); + const approve = useTx(erc721, 'approve'); + useTxNotifications(approve); + + const [transferTokenId, setTransferTokenId] = useState(1); + const [transferToAccount, setTransferToAccount] = useState(''); + const transfer = useTx(erc721, 'transfer'); + useTxNotifications(transfer); + + const [transferFromTokenId, setTransferFromTokenId] = useState(1); + const [transferFromOwnerAccount, setTransferFromOwnerAccount] = useState(''); + const [transferFromToAccount, setTransferFromToAccount] = useState(''); + const transferFrom = useTx(erc721, 'transferFrom'); + useTxNotifications(transferFrom); + + if (!account) return ; + + return ( +
+
+ + + +
+ +
+ + + +
+ +
+ + setIsApprovedForAll(!isApprovedForAll)} + /> + + + setApprovalForAllAccount(e.target.value)} + placeholder='Enter an Address...' + disabled={shouldDisable(setApprovalForAll)} + /> + +
+ +
+ + + + + setApprovalForTokenAccount(e.target.value)} + placeholder='Enter an Address...' + disabled={shouldDisable(approve)} + /> + +
+ +
+ + + + + setTransferToAccount(e.target.value)} + placeholder='Enter an Address...' + disabled={shouldDisable(transfer)} + /> + +
+ +
+ + + + + setTransferFromOwnerAccount(e.target.value)} + placeholder='Enter an Address...' + disabled={shouldDisable(transferFrom)} + /> + + + setTransferFromToAccount(e.target.value)} + placeholder='Enter an Address...' + disabled={shouldDisable(transferFrom)} + /> + +
+
+ ); +}; diff --git a/erc721/frontend/src/components/WriteView/index.ts b/erc721/frontend/src/components/WriteView/index.ts new file mode 100644 index 00000000..98738aa5 --- /dev/null +++ b/erc721/frontend/src/components/WriteView/index.ts @@ -0,0 +1 @@ +export * from './WriteView'; diff --git a/erc721/frontend/src/components/index.ts b/erc721/frontend/src/components/index.ts new file mode 100644 index 00000000..c87713b7 --- /dev/null +++ b/erc721/frontend/src/components/index.ts @@ -0,0 +1 @@ +export * from './Erc721'; diff --git a/erc721/frontend/src/main.tsx b/erc721/frontend/src/main.tsx new file mode 100644 index 00000000..1f69b1a2 --- /dev/null +++ b/erc721/frontend/src/main.tsx @@ -0,0 +1,27 @@ +import metadata from '../assets/erc721.json'; +import App from './App.tsx'; +import './Global.css'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import 'ui/style.css'; +import { UseInkProvider } from 'useink'; +import { RococoContractsTestnet } from 'useink/chains'; +import { NotificationsProvider } from 'useink/notifications'; + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + + + + + , +); diff --git a/erc721/frontend/src/vite-env.d.ts b/erc721/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/erc721/frontend/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/erc721/frontend/tailwind.config.js b/erc721/frontend/tailwind.config.js new file mode 100644 index 00000000..c120a39a --- /dev/null +++ b/erc721/frontend/tailwind.config.js @@ -0,0 +1,2 @@ +import config from '../../ui/tailwind.config'; +export default config; \ No newline at end of file diff --git a/erc721/frontend/tsconfig.json b/erc721/frontend/tsconfig.json new file mode 100644 index 00000000..5178ef59 --- /dev/null +++ b/erc721/frontend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src", "../../ui/src/contexts/DeployerContext"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/erc721/frontend/tsconfig.node.json b/erc721/frontend/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/erc721/frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/erc721/frontend/vite.config.ts b/erc721/frontend/vite.config.ts new file mode 100644 index 00000000..4e7004eb --- /dev/null +++ b/erc721/frontend/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/package.json b/package.json index 0c0859a9..78d7b276 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "contract_terminate": "pnpm --filter ui dev & pnpm --filter contract_terminate dev", "contract_transfer": "pnpm --filter ui dev & pnpm --filter contract_transfer dev", "erc20": "pnpm --filter ui dev & pnpm --filter erc20 dev", + "erc721": "pnpm --filter ui dev & pnpm --filter erc721 dev", "flipper": "pnpm --filter ui dev & pnpm --filter flipper dev", "incrementer": "pnpm --filter ui dev & pnpm --filter incrementer dev" }, diff --git a/ui/src/ToggleSwitch/ToggleSwitch.tsx b/ui/src/ToggleSwitch/ToggleSwitch.tsx new file mode 100644 index 00000000..cc613fcb --- /dev/null +++ b/ui/src/ToggleSwitch/ToggleSwitch.tsx @@ -0,0 +1,40 @@ +import { Switch } from '@headlessui/react'; +import classNames from 'classnames'; +import React from 'react'; + +interface Props { + enabled: boolean; + handleClick: () => void; + screenReader?: string; +} + +export const ToggleSwitch: React.FC = ({ + enabled, + handleClick: handleClose, + screenReader, +}) => ( +
+ + {screenReader && {screenReader}} + +
+); diff --git a/ui/src/ToggleSwitch/index.ts b/ui/src/ToggleSwitch/index.ts new file mode 100644 index 00000000..abd33f3c --- /dev/null +++ b/ui/src/ToggleSwitch/index.ts @@ -0,0 +1 @@ +export * from './ToggleSwitch'; diff --git a/ui/src/index.ts b/ui/src/index.ts index 681c9450..c5bce20a 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -17,6 +17,7 @@ export * from './NumberInput'; export * from './RunResults'; export * from './Snackbar'; export * from './Tabs'; +export * from './ToggleSwitch'; export * from './contexts'; export * from './hooks'; From ccbb6abd69c074322f7765ac260566fd0477cd4d Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Fri, 10 Nov 2023 14:07:06 +0100 Subject: [PATCH 11/12] removes outdated code from previous folder names --- basic_contract_caller/frontend/.gitignore | 21 - basic_contract_caller/frontend/README.md | 4 - basic_contract_caller/frontend/index.html | 13 - basic_contract_caller/frontend/package.json | 26 - .../frontend/postcss.config.js | 6 - .../frontend/public/logo.svg | 1 - basic_contract_caller/frontend/src/App.tsx | 58 --- basic_contract_caller/frontend/src/Global.css | 7 - basic_contract_caller/frontend/src/Other.tsx | 30 -- .../src/assets/basic_contract_caller.json | 446 ------------------ .../frontend/src/assets/other_contract.json | 431 ----------------- .../frontend/src/constants.ts | 2 - basic_contract_caller/frontend/src/main.tsx | 27 -- .../frontend/src/vite-env.d.ts | 1 - .../frontend/tailwind.config.js | 2 - basic_contract_caller/frontend/tsconfig.json | 25 - .../frontend/tsconfig.node.json | 10 - basic_contract_caller/frontend/vite.config.ts | 7 - .../.gitignore | 0 .../Cargo.toml | 0 .../lib.rs | 0 .../.gitignore | 0 .../Cargo.toml | 0 .../lib.rs | 0 contract_terminate/frontend/.gitignore | 21 - contract_terminate/frontend/README.md | 4 - contract_terminate/frontend/index.html | 13 - contract_terminate/frontend/package.json | 25 - contract_terminate/frontend/postcss.config.js | 6 - contract_terminate/frontend/public/logo.svg | 1 - contract_terminate/frontend/src/App.tsx | 191 -------- contract_terminate/frontend/src/Global.css | 3 - .../src/assets/contract_terminate.json | 291 ------------ contract_terminate/frontend/src/constants.ts | 2 - contract_terminate/frontend/src/main.tsx | 27 -- contract_terminate/frontend/src/vite-env.d.ts | 1 - .../frontend/tailwind.config.js | 2 - contract_terminate/frontend/tsconfig.json | 25 - .../frontend/tsconfig.node.json | 10 - contract_terminate/frontend/vite.config.ts | 7 - contract_transfer/frontend/.gitignore | 21 - contract_transfer/frontend/README.md | 4 - contract_transfer/frontend/index.html | 13 - contract_transfer/frontend/package.json | 26 - contract_transfer/frontend/postcss.config.js | 6 - contract_transfer/frontend/public/logo.svg | 1 - contract_transfer/frontend/src/App.tsx | 126 ----- contract_transfer/frontend/src/Global.css | 3 - .../src/assets/contract_transfer.json | 333 ------------- contract_transfer/frontend/src/constants.ts | 2 - contract_transfer/frontend/src/main.tsx | 27 -- contract_transfer/frontend/src/vite-env.d.ts | 1 - contract_transfer/frontend/tailwind.config.js | 2 - contract_transfer/frontend/tsconfig.json | 25 - contract_transfer/frontend/tsconfig.node.json | 10 - contract_transfer/frontend/vite.config.ts | 7 - 56 files changed, 2353 deletions(-) delete mode 100644 basic_contract_caller/frontend/.gitignore delete mode 100644 basic_contract_caller/frontend/README.md delete mode 100644 basic_contract_caller/frontend/index.html delete mode 100644 basic_contract_caller/frontend/package.json delete mode 100644 basic_contract_caller/frontend/postcss.config.js delete mode 100644 basic_contract_caller/frontend/public/logo.svg delete mode 100644 basic_contract_caller/frontend/src/App.tsx delete mode 100644 basic_contract_caller/frontend/src/Global.css delete mode 100644 basic_contract_caller/frontend/src/Other.tsx delete mode 100644 basic_contract_caller/frontend/src/assets/basic_contract_caller.json delete mode 100644 basic_contract_caller/frontend/src/assets/other_contract.json delete mode 100644 basic_contract_caller/frontend/src/constants.ts delete mode 100644 basic_contract_caller/frontend/src/main.tsx delete mode 100644 basic_contract_caller/frontend/src/vite-env.d.ts delete mode 100644 basic_contract_caller/frontend/tailwind.config.js delete mode 100644 basic_contract_caller/frontend/tsconfig.json delete mode 100644 basic_contract_caller/frontend/tsconfig.node.json delete mode 100644 basic_contract_caller/frontend/vite.config.ts rename {contract_terminate => contract-terminate}/.gitignore (100%) rename {contract_terminate => contract-terminate}/Cargo.toml (100%) rename {contract_terminate => contract-terminate}/lib.rs (100%) rename {contract_transfer => contract-transfer}/.gitignore (100%) rename {contract_transfer => contract-transfer}/Cargo.toml (100%) rename {contract_transfer => contract-transfer}/lib.rs (100%) delete mode 100644 contract_terminate/frontend/.gitignore delete mode 100644 contract_terminate/frontend/README.md delete mode 100644 contract_terminate/frontend/index.html delete mode 100644 contract_terminate/frontend/package.json delete mode 100644 contract_terminate/frontend/postcss.config.js delete mode 100644 contract_terminate/frontend/public/logo.svg delete mode 100644 contract_terminate/frontend/src/App.tsx delete mode 100644 contract_terminate/frontend/src/Global.css delete mode 100644 contract_terminate/frontend/src/assets/contract_terminate.json delete mode 100644 contract_terminate/frontend/src/constants.ts delete mode 100644 contract_terminate/frontend/src/main.tsx delete mode 100644 contract_terminate/frontend/src/vite-env.d.ts delete mode 100644 contract_terminate/frontend/tailwind.config.js delete mode 100644 contract_terminate/frontend/tsconfig.json delete mode 100644 contract_terminate/frontend/tsconfig.node.json delete mode 100644 contract_terminate/frontend/vite.config.ts delete mode 100644 contract_transfer/frontend/.gitignore delete mode 100644 contract_transfer/frontend/README.md delete mode 100644 contract_transfer/frontend/index.html delete mode 100644 contract_transfer/frontend/package.json delete mode 100644 contract_transfer/frontend/postcss.config.js delete mode 100644 contract_transfer/frontend/public/logo.svg delete mode 100644 contract_transfer/frontend/src/App.tsx delete mode 100644 contract_transfer/frontend/src/Global.css delete mode 100644 contract_transfer/frontend/src/assets/contract_transfer.json delete mode 100644 contract_transfer/frontend/src/constants.ts delete mode 100644 contract_transfer/frontend/src/main.tsx delete mode 100644 contract_transfer/frontend/src/vite-env.d.ts delete mode 100644 contract_transfer/frontend/tailwind.config.js delete mode 100644 contract_transfer/frontend/tsconfig.json delete mode 100644 contract_transfer/frontend/tsconfig.node.json delete mode 100644 contract_transfer/frontend/vite.config.ts diff --git a/basic_contract_caller/frontend/.gitignore b/basic_contract_caller/frontend/.gitignore deleted file mode 100644 index c13f37b6..00000000 --- a/basic_contract_caller/frontend/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Logs -logs -*.log -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/basic_contract_caller/frontend/README.md b/basic_contract_caller/frontend/README.md deleted file mode 100644 index ad88c572..00000000 --- a/basic_contract_caller/frontend/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Have Questions? - -For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). - diff --git a/basic_contract_caller/frontend/index.html b/basic_contract_caller/frontend/index.html deleted file mode 100644 index e4d2ac59..00000000 --- a/basic_contract_caller/frontend/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - ink! Examples - - -
- - - diff --git a/basic_contract_caller/frontend/package.json b/basic_contract_caller/frontend/package.json deleted file mode 100644 index 688fbe33..00000000 --- a/basic_contract_caller/frontend/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "basic_contract_caller", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc && vite build", - "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" - }, - "dependencies": { - "ui": "workspace:ui@*" - }, - "devDependencies": { - "@types/react": "^18.0.37", - "@types/react-dom": "^18.0.11", - "@vitejs/plugin-react": "^4.0.0", - "autoprefixer": "^10.4.14", - "eslint": "^8.38.0", - "postcss": "^8.4.24", - "tailwindcss": "^3.3.2", - "typescript": "^5.0.2", - "vite": "^4.3.9" - } -} diff --git a/basic_contract_caller/frontend/postcss.config.js b/basic_contract_caller/frontend/postcss.config.js deleted file mode 100644 index 2aa7205d..00000000 --- a/basic_contract_caller/frontend/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/basic_contract_caller/frontend/public/logo.svg b/basic_contract_caller/frontend/public/logo.svg deleted file mode 100644 index c31ded82..00000000 --- a/basic_contract_caller/frontend/public/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/App.tsx b/basic_contract_caller/frontend/src/App.tsx deleted file mode 100644 index 49aed813..00000000 --- a/basic_contract_caller/frontend/src/App.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { Other } from './Other'; -import metadata from './assets/basic_contract_caller.json'; -import { BASIC_CONTRACT_ROCOCO_ADDRESS } from './constants'; -import { useEffect } from 'react'; -import { Button, Card, ConnectButton, InkLayout, formatContractName } from 'ui'; -import { useCall, useContract, useTx, useWallet } from 'useink'; -import { useTxNotifications } from 'useink/notifications'; -import { isPendingSignature, pickDecoded, shouldDisable } from 'useink/utils'; - -function App() { - const { account } = useWallet(); - const basicContract = useContract(BASIC_CONTRACT_ROCOCO_ADDRESS, metadata); - const flipAndGet = useTx(basicContract, 'flipAndGet'); - useTxNotifications(flipAndGet); - - const other = useCall(basicContract, 'other'); - - useEffect(() => { - other?.send([], { defaultCaller: true }); - }, [other.send]); - - const otherAddress = pickDecoded(other.result); - - return ( - -
- -

- {formatContractName(metadata.contract.name)} -

- - {account ? ( - - ) : ( - - )} -
- - {otherAddress && } -
-
- ); -} - -export default App; diff --git a/basic_contract_caller/frontend/src/Global.css b/basic_contract_caller/frontend/src/Global.css deleted file mode 100644 index c2f5c12e..00000000 --- a/basic_contract_caller/frontend/src/Global.css +++ /dev/null @@ -1,7 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -body { - background-color: #1A1452; -} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/Other.tsx b/basic_contract_caller/frontend/src/Other.tsx deleted file mode 100644 index 84f93b69..00000000 --- a/basic_contract_caller/frontend/src/Other.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import otherContractMetadata from './assets/other_contract.json'; -import { Card } from 'ui'; -import { useCallSubscription, useContract } from 'useink'; -import { pickDecoded } from 'useink/utils'; - -interface Props { - address: string; -} - -export const Other: React.FC = ({ address }) => { - const otherContract = useContract(address, otherContractMetadata); - const getOtherSub = useCallSubscription(otherContract, 'get', [], { - defaultCaller: true, - }); - - return ( - -

- {otherContractMetadata.contract.name.toUpperCase()} -

- -

- Flipped:{' '} - - {pickDecoded(getOtherSub.result)?.toString()} - -

-
- ); -}; diff --git a/basic_contract_caller/frontend/src/assets/basic_contract_caller.json b/basic_contract_caller/frontend/src/assets/basic_contract_caller.json deleted file mode 100644 index ca8feda4..00000000 --- a/basic_contract_caller/frontend/src/assets/basic_contract_caller.json +++ /dev/null @@ -1,446 +0,0 @@ -{ - "source": { - "hash": "0x116670008181c58c5b65ea9c97a22b2a5eb205372a9428c6ee4560787edd1dbd", - "language": "ink! 4.2.0", - "compiler": "rustc 1.70.0", - "build_info": { - "build_mode": "Release", - "cargo_contract_version": "2.2.1", - "rust_toolchain": "stable-x86_64-apple-darwin", - "wasm_opt_settings": { - "keep_debug_symbols": false, - "optimization_passes": "Z" - } - } - }, - "contract": { - "name": "basic_contract_caller", - "version": "4.2.0", - "authors": [ - "Parity Technologies " - ] - }, - "spec": { - "constructors": [ - { - "args": [ - { - "label": "other_contract_code_hash", - "type": { - "displayName": [ - "Hash" - ], - "type": 3 - } - } - ], - "default": false, - "docs": [ - "In order to use the `OtherContract` we first need to **instantiate** it.", - "", - "To do this we will use the uploaded `code_hash` of `OtherContract`." - ], - "label": "new", - "payable": false, - "returnType": { - "displayName": [ - "ink_primitives", - "ConstructorResult" - ], - "type": 4 - }, - "selector": "0x9bae9d5e" - } - ], - "docs": [], - "environment": { - "accountId": { - "displayName": [ - "AccountId" - ], - "type": 0 - }, - "balance": { - "displayName": [ - "Balance" - ], - "type": 10 - }, - "blockNumber": { - "displayName": [ - "BlockNumber" - ], - "type": 12 - }, - "chainExtension": { - "displayName": [ - "ChainExtension" - ], - "type": 13 - }, - "hash": { - "displayName": [ - "Hash" - ], - "type": 3 - }, - "maxEventTopics": 4, - "timestamp": { - "displayName": [ - "Timestamp" - ], - "type": 11 - } - }, - "events": [], - "lang_error": { - "displayName": [ - "ink", - "LangError" - ], - "type": 6 - }, - "messages": [ - { - "args": [], - "default": false, - "docs": [ - " Using the `ContractRef` we can call all the messages of the `OtherContract` as", - " if they were normal Rust methods (because at the end of the day, they", - " are!)." - ], - "label": "flip_and_get", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 7 - }, - "selector": "0x2e233661" - }, - { - "args": [], - "default": false, - "docs": [ - " Get the address of the other contract after it has been instantiated. We can", - " use this so we can call the other contract on the frontend." - ], - "label": "other", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 9 - }, - "selector": "0x96396e0f" - } - ] - }, - "storage": { - "root": { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "leaf": { - "key": "0x00000000", - "ty": 0 - } - }, - "name": "account_id" - } - ], - "name": "CallBuilder" - } - }, - "name": "inner" - } - ], - "name": "OtherContractRef" - } - }, - "name": "other_contract" - } - ], - "name": "BasicContractCaller" - } - }, - "root_key": "0x00000000" - } - }, - "types": [ - { - "id": 0, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 1, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "AccountId" - ] - } - }, - { - "id": 1, - "type": { - "def": { - "array": { - "len": 32, - "type": 2 - } - } - } - }, - { - "id": 2, - "type": { - "def": { - "primitive": "u8" - } - } - }, - { - "id": 3, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 1, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "Hash" - ] - } - }, - { - "id": 4, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 5 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 6 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 5 - }, - { - "name": "E", - "type": 6 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 5, - "type": { - "def": { - "tuple": [] - } - } - }, - { - "id": 6, - "type": { - "def": { - "variant": { - "variants": [ - { - "index": 1, - "name": "CouldNotReadInput" - } - ] - } - }, - "path": [ - "ink_primitives", - "LangError" - ] - } - }, - { - "id": 7, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 8 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 6 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 8 - }, - { - "name": "E", - "type": 6 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 8, - "type": { - "def": { - "primitive": "bool" - } - } - }, - { - "id": 9, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 0 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 6 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 0 - }, - { - "name": "E", - "type": 6 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 10, - "type": { - "def": { - "primitive": "u128" - } - } - }, - { - "id": 11, - "type": { - "def": { - "primitive": "u64" - } - } - }, - { - "id": 12, - "type": { - "def": { - "primitive": "u32" - } - } - }, - { - "id": 13, - "type": { - "def": { - "variant": {} - }, - "path": [ - "ink_env", - "types", - "NoChainExtension" - ] - } - } - ], - "version": "4" -} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/assets/other_contract.json b/basic_contract_caller/frontend/src/assets/other_contract.json deleted file mode 100644 index 3c05b931..00000000 --- a/basic_contract_caller/frontend/src/assets/other_contract.json +++ /dev/null @@ -1,431 +0,0 @@ -{ - "source": { - "hash": "0x8b9fdab59f82fc96ba8f8bba270e706a3900ec4fe9c92a249263f3fb63f8cb58", - "language": "ink! 4.2.0", - "compiler": "rustc 1.70.0", - "build_info": { - "build_mode": "Release", - "cargo_contract_version": "2.2.1", - "rust_toolchain": "stable-x86_64-apple-darwin", - "wasm_opt_settings": { - "keep_debug_symbols": false, - "optimization_passes": "Z" - } - } - }, - "contract": { - "name": "other_contract", - "version": "4.2.0", - "authors": [ - "Parity Technologies " - ] - }, - "spec": { - "constructors": [ - { - "args": [ - { - "label": "init_value", - "type": { - "displayName": [ - "bool" - ], - "type": 0 - } - } - ], - "default": false, - "docs": [], - "label": "new", - "payable": false, - "returnType": { - "displayName": [ - "ink_primitives", - "ConstructorResult" - ], - "type": 1 - }, - "selector": "0x9bae9d5e" - } - ], - "docs": [], - "environment": { - "accountId": { - "displayName": [ - "AccountId" - ], - "type": 6 - }, - "balance": { - "displayName": [ - "Balance" - ], - "type": 9 - }, - "blockNumber": { - "displayName": [ - "BlockNumber" - ], - "type": 12 - }, - "chainExtension": { - "displayName": [ - "ChainExtension" - ], - "type": 13 - }, - "hash": { - "displayName": [ - "Hash" - ], - "type": 10 - }, - "maxEventTopics": 4, - "timestamp": { - "displayName": [ - "Timestamp" - ], - "type": 11 - } - }, - "events": [], - "lang_error": { - "displayName": [ - "ink", - "LangError" - ], - "type": 3 - }, - "messages": [ - { - "args": [], - "default": false, - "docs": [], - "label": "flip", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 1 - }, - "selector": "0x633aa551" - }, - { - "args": [], - "default": false, - "docs": [], - "label": "get", - "mutates": false, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 4 - }, - "selector": "0x2f865bd9" - }, - { - "args": [], - "default": false, - "docs": [], - "label": "account_id", - "mutates": false, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 5 - }, - "selector": "0x2be79821" - } - ] - }, - "storage": { - "root": { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "leaf": { - "key": "0x00000000", - "ty": 0 - } - }, - "name": "value" - } - ], - "name": "OtherContract" - } - }, - "root_key": "0x00000000" - } - }, - "types": [ - { - "id": 0, - "type": { - "def": { - "primitive": "bool" - } - } - }, - { - "id": 1, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 2 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 3 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 2 - }, - { - "name": "E", - "type": 3 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 2, - "type": { - "def": { - "tuple": [] - } - } - }, - { - "id": 3, - "type": { - "def": { - "variant": { - "variants": [ - { - "index": 1, - "name": "CouldNotReadInput" - } - ] - } - }, - "path": [ - "ink_primitives", - "LangError" - ] - } - }, - { - "id": 4, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 0 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 3 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 0 - }, - { - "name": "E", - "type": 3 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 5, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 6 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 3 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 6 - }, - { - "name": "E", - "type": 3 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 6, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 7, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "AccountId" - ] - } - }, - { - "id": 7, - "type": { - "def": { - "array": { - "len": 32, - "type": 8 - } - } - } - }, - { - "id": 8, - "type": { - "def": { - "primitive": "u8" - } - } - }, - { - "id": 9, - "type": { - "def": { - "primitive": "u128" - } - } - }, - { - "id": 10, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 7, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "Hash" - ] - } - }, - { - "id": 11, - "type": { - "def": { - "primitive": "u64" - } - } - }, - { - "id": 12, - "type": { - "def": { - "primitive": "u32" - } - } - }, - { - "id": 13, - "type": { - "def": { - "variant": {} - }, - "path": [ - "ink_env", - "types", - "NoChainExtension" - ] - } - } - ], - "version": "4" -} \ No newline at end of file diff --git a/basic_contract_caller/frontend/src/constants.ts b/basic_contract_caller/frontend/src/constants.ts deleted file mode 100644 index 54cc8400..00000000 --- a/basic_contract_caller/frontend/src/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const BASIC_CONTRACT_ROCOCO_ADDRESS = - '5EnufwqqxnkWT6hc1LgjYWQGUsqQCtcr5192K2HuQJtRJgCi'; diff --git a/basic_contract_caller/frontend/src/main.tsx b/basic_contract_caller/frontend/src/main.tsx deleted file mode 100644 index 2ce2c515..00000000 --- a/basic_contract_caller/frontend/src/main.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import App from './App.tsx'; -import './Global.css'; -import metadata from './assets/basic_contract_caller.json'; -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import 'ui/style.css'; -import { UseInkProvider } from 'useink'; -import { RococoContractsTestnet } from 'useink/chains'; -import { NotificationsProvider } from 'useink/notifications'; - -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - , -); diff --git a/basic_contract_caller/frontend/src/vite-env.d.ts b/basic_contract_caller/frontend/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2..00000000 --- a/basic_contract_caller/frontend/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/basic_contract_caller/frontend/tailwind.config.js b/basic_contract_caller/frontend/tailwind.config.js deleted file mode 100644 index c120a39a..00000000 --- a/basic_contract_caller/frontend/tailwind.config.js +++ /dev/null @@ -1,2 +0,0 @@ -import config from '../../ui/tailwind.config'; -export default config; \ No newline at end of file diff --git a/basic_contract_caller/frontend/tsconfig.json b/basic_contract_caller/frontend/tsconfig.json deleted file mode 100644 index a7fc6fbf..00000000 --- a/basic_contract_caller/frontend/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/basic_contract_caller/frontend/tsconfig.node.json b/basic_contract_caller/frontend/tsconfig.node.json deleted file mode 100644 index 42872c59..00000000 --- a/basic_contract_caller/frontend/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/basic_contract_caller/frontend/vite.config.ts b/basic_contract_caller/frontend/vite.config.ts deleted file mode 100644 index 4e7004eb..00000000 --- a/basic_contract_caller/frontend/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import react from '@vitejs/plugin-react'; -import { defineConfig } from 'vite'; - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], -}); diff --git a/contract_terminate/.gitignore b/contract-terminate/.gitignore similarity index 100% rename from contract_terminate/.gitignore rename to contract-terminate/.gitignore diff --git a/contract_terminate/Cargo.toml b/contract-terminate/Cargo.toml similarity index 100% rename from contract_terminate/Cargo.toml rename to contract-terminate/Cargo.toml diff --git a/contract_terminate/lib.rs b/contract-terminate/lib.rs similarity index 100% rename from contract_terminate/lib.rs rename to contract-terminate/lib.rs diff --git a/contract_transfer/.gitignore b/contract-transfer/.gitignore similarity index 100% rename from contract_transfer/.gitignore rename to contract-transfer/.gitignore diff --git a/contract_transfer/Cargo.toml b/contract-transfer/Cargo.toml similarity index 100% rename from contract_transfer/Cargo.toml rename to contract-transfer/Cargo.toml diff --git a/contract_transfer/lib.rs b/contract-transfer/lib.rs similarity index 100% rename from contract_transfer/lib.rs rename to contract-transfer/lib.rs diff --git a/contract_terminate/frontend/.gitignore b/contract_terminate/frontend/.gitignore deleted file mode 100644 index c13f37b6..00000000 --- a/contract_terminate/frontend/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Logs -logs -*.log -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/contract_terminate/frontend/README.md b/contract_terminate/frontend/README.md deleted file mode 100644 index ad88c572..00000000 --- a/contract_terminate/frontend/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Have Questions? - -For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). - diff --git a/contract_terminate/frontend/index.html b/contract_terminate/frontend/index.html deleted file mode 100644 index e4d2ac59..00000000 --- a/contract_terminate/frontend/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - ink! Examples - - -
- - - diff --git a/contract_terminate/frontend/package.json b/contract_terminate/frontend/package.json deleted file mode 100644 index b60f441b..00000000 --- a/contract_terminate/frontend/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "contract_terminate", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc && vite build", - "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" - }, - "dependencies": { - "ui": "workspace:ui@*" - }, - "devDependencies": { - "@types/react": "^18.0.37", - "@types/react-dom": "^18.0.11", - "@vitejs/plugin-react": "^4.0.0", - "autoprefixer": "^10.4.14", - "postcss": "^8.4.24", - "tailwindcss": "^3.3.2", - "typescript": "^5.0.2", - "vite": "^4.3.9" - } -} diff --git a/contract_terminate/frontend/postcss.config.js b/contract_terminate/frontend/postcss.config.js deleted file mode 100644 index 2aa7205d..00000000 --- a/contract_terminate/frontend/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/contract_terminate/frontend/public/logo.svg b/contract_terminate/frontend/public/logo.svg deleted file mode 100644 index c31ded82..00000000 --- a/contract_terminate/frontend/public/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/contract_terminate/frontend/src/App.tsx b/contract_terminate/frontend/src/App.tsx deleted file mode 100644 index 5ec2273c..00000000 --- a/contract_terminate/frontend/src/App.tsx +++ /dev/null @@ -1,191 +0,0 @@ -import metadata from './assets/contract_terminate.json'; -import { useEffect, useMemo } from 'react'; -import { - Button, - Card, - ConnectButton, - Events, - InkLayout, - formatContractName, -} from 'ui'; -import { useApi, useBalance, useDeployer, useMetadata } from 'useink'; -import { useContract, useTx, useWallet } from 'useink'; -import { useTxNotifications } from 'useink/notifications'; -import { - formatEventName, - isPendingSignature, - planckToDecimalFormatted, - shouldDisable, -} from 'useink/utils'; - -// We already deployed the contract Wasm blob on chain. We use this code hash to -// re-deploy; -const codeHash = - '0xf667f6dbcc27e4b0f2e23c2af12d6e5dee358910753b02910a6aebd3768dd618'; - -function App() { - const { account } = useWallet(); - const chainApi = useApi(); - - const M = useMetadata({ requireWasm: false }, metadata); - const balance = useBalance(account); - - const D = useDeployer(); - useTxNotifications(D); - - const contract = useContract(D.contractAddress || '', metadata); - const terminate = useTx(contract, 'terminateMe'); - useTxNotifications(terminate); - - useEffect(() => { - chainApi?.api && M.abi && D.dryRun(M.abi, 'new', undefined, { codeHash }); - }, [M.abi, chainApi?.api]); - - const wasTerminated = useMemo(() => { - return Boolean( - terminate.events.find( - (event) => formatEventName(event) === 'contracts:Terminated', - ), - ); - }, [terminate.events]); - - return ( - - -

- {formatContractName(metadata.contract.name)} -

- -

- Your Balance:{' '} - {planckToDecimalFormatted(balance?.freeBalance, chainApi?.api)} -

- - {D.storageDeposit && ( -
-

Dry Run Results

- - {D.contractAddress && ( -
-

Contract Address

-

{D.contractAddress}

-
- )} - - {D.gasConsumed && ( -
-

Gas Consumed

-
    -
  • refTime: {D.gasConsumed.refTime.toString()}
  • -
  • proof size: {D.gasConsumed.proofSize.toString()}
  • -
-
- )} - - {D.gasRequired && ( -
-

Gas Required

-
    -
  • refTime: {D.gasRequired.refTime.toString()}
  • -
  • proof size: {D.gasRequired.proofSize.toString()}
  • -
-
- )} - - {D.storageDeposit && ( -
-

- Storage Deposit:{' '} - {planckToDecimalFormatted( - D.storageDeposit.asCharge, - chainApi?.api, - )} -

-
- )} -
- )} - - {M.error && ( -

- Metadata: - {M.error} -

- )} - - {D.error &&

{D.error}

} - - {!D.wasDeployed ? ( -
-

- {D.storageDeposit - ? "Let's first deploy the contract!" - : 'Loading...'} -

- - {account ? ( - - ) : ( - - )} -
- ) : ( -
-

- {wasTerminated - ? 'Your contract was terminated!' - : 'Your contract has been deployed!'} -

- {account ? ( - wasTerminated ? ( - - ) : ( - - ) - ) : ( - - )} -
- )} - - -
-
- ); -} - -export default App; diff --git a/contract_terminate/frontend/src/Global.css b/contract_terminate/frontend/src/Global.css deleted file mode 100644 index bd6213e1..00000000 --- a/contract_terminate/frontend/src/Global.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file diff --git a/contract_terminate/frontend/src/assets/contract_terminate.json b/contract_terminate/frontend/src/assets/contract_terminate.json deleted file mode 100644 index c348271c..00000000 --- a/contract_terminate/frontend/src/assets/contract_terminate.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "source": { - "hash": "0xf667f6dbcc27e4b0f2e23c2af12d6e5dee358910753b02910a6aebd3768dd618", - "language": "ink! 4.2.0", - "compiler": "rustc 1.70.0", - "build_info": { - "build_mode": "Release", - "cargo_contract_version": "2.2.1", - "rust_toolchain": "stable-x86_64-apple-darwin", - "wasm_opt_settings": { - "keep_debug_symbols": false, - "optimization_passes": "Z" - } - } - }, - "contract": { - "name": "contract_terminate", - "version": "4.2.0", - "authors": [ - "Parity Technologies " - ] - }, - "spec": { - "constructors": [ - { - "args": [], - "default": false, - "docs": [ - "Creates a new instance of this contract." - ], - "label": "new", - "payable": false, - "returnType": { - "displayName": [ - "ink_primitives", - "ConstructorResult" - ], - "type": 0 - }, - "selector": "0x9bae9d5e" - } - ], - "docs": [], - "environment": { - "accountId": { - "displayName": [ - "AccountId" - ], - "type": 3 - }, - "balance": { - "displayName": [ - "Balance" - ], - "type": 6 - }, - "blockNumber": { - "displayName": [ - "BlockNumber" - ], - "type": 9 - }, - "chainExtension": { - "displayName": [ - "ChainExtension" - ], - "type": 10 - }, - "hash": { - "displayName": [ - "Hash" - ], - "type": 7 - }, - "maxEventTopics": 4, - "timestamp": { - "displayName": [ - "Timestamp" - ], - "type": 8 - } - }, - "events": [], - "lang_error": { - "displayName": [ - "ink", - "LangError" - ], - "type": 2 - }, - "messages": [ - { - "args": [], - "default": false, - "docs": [ - " Terminates with the caller as beneficiary." - ], - "label": "terminate_me", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 0 - }, - "selector": "0x17feb370" - } - ] - }, - "storage": { - "root": { - "layout": { - "struct": { - "fields": [], - "name": "JustTerminate" - } - }, - "root_key": "0x00000000" - } - }, - "types": [ - { - "id": 0, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 1 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 2 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 1 - }, - { - "name": "E", - "type": 2 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 1, - "type": { - "def": { - "tuple": [] - } - } - }, - { - "id": 2, - "type": { - "def": { - "variant": { - "variants": [ - { - "index": 1, - "name": "CouldNotReadInput" - } - ] - } - }, - "path": [ - "ink_primitives", - "LangError" - ] - } - }, - { - "id": 3, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 4, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "AccountId" - ] - } - }, - { - "id": 4, - "type": { - "def": { - "array": { - "len": 32, - "type": 5 - } - } - } - }, - { - "id": 5, - "type": { - "def": { - "primitive": "u8" - } - } - }, - { - "id": 6, - "type": { - "def": { - "primitive": "u128" - } - } - }, - { - "id": 7, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 4, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "Hash" - ] - } - }, - { - "id": 8, - "type": { - "def": { - "primitive": "u64" - } - } - }, - { - "id": 9, - "type": { - "def": { - "primitive": "u32" - } - } - }, - { - "id": 10, - "type": { - "def": { - "variant": {} - }, - "path": [ - "ink_env", - "types", - "NoChainExtension" - ] - } - } - ], - "version": "4" -} \ No newline at end of file diff --git a/contract_terminate/frontend/src/constants.ts b/contract_terminate/frontend/src/constants.ts deleted file mode 100644 index 549db8ba..00000000 --- a/contract_terminate/frontend/src/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const CONTRACT_ROCOCO_ADDRESS = - '5Fsk6oqWHJzMAQmkBTVzxxqZPPngLbHG48Tro3i53LC3quao'; diff --git a/contract_terminate/frontend/src/main.tsx b/contract_terminate/frontend/src/main.tsx deleted file mode 100644 index 1af718b8..00000000 --- a/contract_terminate/frontend/src/main.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import App from './App.tsx'; -import './Global.css'; -import metadata from './assets/contract_terminate.json'; -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import 'ui/style.css'; -import { UseInkProvider } from 'useink'; -import { RococoContractsTestnet } from 'useink/chains'; -import { NotificationsProvider } from 'useink/notifications'; - -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - , -); diff --git a/contract_terminate/frontend/src/vite-env.d.ts b/contract_terminate/frontend/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2..00000000 --- a/contract_terminate/frontend/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/contract_terminate/frontend/tailwind.config.js b/contract_terminate/frontend/tailwind.config.js deleted file mode 100644 index c120a39a..00000000 --- a/contract_terminate/frontend/tailwind.config.js +++ /dev/null @@ -1,2 +0,0 @@ -import config from '../../ui/tailwind.config'; -export default config; \ No newline at end of file diff --git a/contract_terminate/frontend/tsconfig.json b/contract_terminate/frontend/tsconfig.json deleted file mode 100644 index a7fc6fbf..00000000 --- a/contract_terminate/frontend/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/contract_terminate/frontend/tsconfig.node.json b/contract_terminate/frontend/tsconfig.node.json deleted file mode 100644 index 42872c59..00000000 --- a/contract_terminate/frontend/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/contract_terminate/frontend/vite.config.ts b/contract_terminate/frontend/vite.config.ts deleted file mode 100644 index 4e7004eb..00000000 --- a/contract_terminate/frontend/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import react from '@vitejs/plugin-react'; -import { defineConfig } from 'vite'; - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], -}); diff --git a/contract_transfer/frontend/.gitignore b/contract_transfer/frontend/.gitignore deleted file mode 100644 index c13f37b6..00000000 --- a/contract_transfer/frontend/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Logs -logs -*.log -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/contract_transfer/frontend/README.md b/contract_transfer/frontend/README.md deleted file mode 100644 index ad88c572..00000000 --- a/contract_transfer/frontend/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Have Questions? - -For any questions about building front end applications with [useink](https://use.ink/frontend/overview/), join the [Element chat](https://matrix.to/#/%23useink:parity.io). - diff --git a/contract_transfer/frontend/index.html b/contract_transfer/frontend/index.html deleted file mode 100644 index e4d2ac59..00000000 --- a/contract_transfer/frontend/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - ink! Examples - - -
- - - diff --git a/contract_transfer/frontend/package.json b/contract_transfer/frontend/package.json deleted file mode 100644 index 36cbf1ab..00000000 --- a/contract_transfer/frontend/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "contract_transfer", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc && vite build", - "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" - }, - "dependencies": { - "ui": "workspace:ui@*" - }, - "devDependencies": { - "@types/react": "^18.0.37", - "@types/react-dom": "^18.0.11", - "@vitejs/plugin-react": "^4.0.0", - "autoprefixer": "^10.4.14", - "eslint": "^8.38.0", - "postcss": "^8.4.24", - "tailwindcss": "^3.3.2", - "typescript": "^5.0.2", - "vite": "^4.3.9" - } -} diff --git a/contract_transfer/frontend/postcss.config.js b/contract_transfer/frontend/postcss.config.js deleted file mode 100644 index 2aa7205d..00000000 --- a/contract_transfer/frontend/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/contract_transfer/frontend/public/logo.svg b/contract_transfer/frontend/public/logo.svg deleted file mode 100644 index c31ded82..00000000 --- a/contract_transfer/frontend/public/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/contract_transfer/frontend/src/App.tsx b/contract_transfer/frontend/src/App.tsx deleted file mode 100644 index 7809bff5..00000000 --- a/contract_transfer/frontend/src/App.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import metadata from './assets/contract_transfer.json'; -import { CONTRACT_ROCOCO_ADDRESS } from './constants'; -import { useMemo, useState } from 'react'; -import { - Button, - Card, - ConnectButton, - InkLayout, - Link, - NumberInput, - formatContractName, -} from 'ui'; -import { useBalance, useContract, useTx, useWallet } from 'useink'; -import { useTxNotifications } from 'useink/notifications'; -import { - BN, - decimalToPlanck, - isPendingSignature, - planckToDecimal, - planckToDecimalFormatted, - shouldDisable, -} from 'useink/utils'; - -function App() { - const { account } = useWallet(); - const chainContract = useContract(CONTRACT_ROCOCO_ADDRESS, metadata); - const contractBalance = useBalance({ address: CONTRACT_ROCOCO_ADDRESS }); - const userBalance = useBalance(account); - const [amount, setAmount] = useState(1); - const giveMe = useTx(chainContract, 'giveMe'); - useTxNotifications(giveMe); - - const planckAmount = useMemo( - () => decimalToPlanck(amount, chainContract?.contract?.api) || 0, - [chainContract?.contract.api, amount], - ); - - const needsMoreFunds = useMemo( - () => - contractBalance?.freeBalance.lt(new BN(planckAmount?.toString() || '0')), - [contractBalance?.freeBalance, planckAmount], - ); - - return ( - - -

- {formatContractName(metadata.contract.name)} -

- -
-

- Contract Balance:{' '} - - {contractBalance - ? planckToDecimalFormatted(contractBalance?.freeBalance, { - api: chainContract?.contract.api, - significantFigures: 4, - }) - : '--'} - -

- -

- Your Balance:{' '} - - {userBalance - ? planckToDecimalFormatted(userBalance?.freeBalance, { - api: chainContract?.contract.api, - significantFigures: 4, - }) - : '--'} - -

-
- - setAmount(v)} - value={amount} - min={1} - max={Math.floor( - planckToDecimal( - contractBalance?.freeBalance, - chainContract?.contract.api, - ) || 0, - )} - /> - - {account ? ( - - ) : ( - - )} - -
- {needsMoreFunds && ( -

There are not enough funds.

- )} - - - Add ROC to contract with faucet - -
-
-
- ); -} - -export default App; diff --git a/contract_transfer/frontend/src/Global.css b/contract_transfer/frontend/src/Global.css deleted file mode 100644 index bd6213e1..00000000 --- a/contract_transfer/frontend/src/Global.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file diff --git a/contract_transfer/frontend/src/assets/contract_transfer.json b/contract_transfer/frontend/src/assets/contract_transfer.json deleted file mode 100644 index fdc46a25..00000000 --- a/contract_transfer/frontend/src/assets/contract_transfer.json +++ /dev/null @@ -1,333 +0,0 @@ -{ - "source": { - "hash": "0x3431764079ef7dacc018ed5bfee19e333caf631c92ab621e73d7ed21bed1bc93", - "language": "ink! 4.2.0", - "compiler": "rustc 1.70.0", - "build_info": { - "build_mode": "Release", - "cargo_contract_version": "2.2.1", - "rust_toolchain": "stable-x86_64-apple-darwin", - "wasm_opt_settings": { - "keep_debug_symbols": false, - "optimization_passes": "Z" - } - } - }, - "contract": { - "name": "contract_transfer", - "version": "4.2.0", - "authors": [ - "Parity Technologies " - ] - }, - "spec": { - "constructors": [ - { - "args": [], - "default": false, - "docs": [ - "Creates a new instance of this contract." - ], - "label": "new", - "payable": true, - "returnType": { - "displayName": [ - "ink_primitives", - "ConstructorResult" - ], - "type": 0 - }, - "selector": "0x9bae9d5e" - } - ], - "docs": [], - "environment": { - "accountId": { - "displayName": [ - "AccountId" - ], - "type": 4 - }, - "balance": { - "displayName": [ - "Balance" - ], - "type": 3 - }, - "blockNumber": { - "displayName": [ - "BlockNumber" - ], - "type": 9 - }, - "chainExtension": { - "displayName": [ - "ChainExtension" - ], - "type": 10 - }, - "hash": { - "displayName": [ - "Hash" - ], - "type": 7 - }, - "maxEventTopics": 4, - "timestamp": { - "displayName": [ - "Timestamp" - ], - "type": 8 - } - }, - "events": [], - "lang_error": { - "displayName": [ - "ink", - "LangError" - ], - "type": 2 - }, - "messages": [ - { - "args": [ - { - "label": "value", - "type": { - "displayName": [ - "Balance" - ], - "type": 3 - } - } - ], - "default": false, - "docs": [ - " Transfers `value` amount of tokens to the caller.", - "", - " # Errors", - "", - " - Panics in case the requested transfer exceeds the contract balance.", - " - Panics in case the requested transfer would have brought this contract's", - " balance below the minimum balance (i.e. the chain's existential deposit).", - " - Panics in case the transfer failed for another reason." - ], - "label": "give_me", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 0 - }, - "selector": "0x499bb739" - }, - { - "args": [], - "default": false, - "docs": [ - " Asserts that the token amount sent as payment with this call", - " is exactly `10`. This method will fail otherwise, and the", - " transaction would then be reverted.", - "", - " # Note", - "", - " The method needs to be annotated with `payable`; only then it is", - " allowed to receive value as part of the call." - ], - "label": "was_it_ten", - "mutates": false, - "payable": true, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 0 - }, - "selector": "0xcafebabe" - } - ] - }, - "storage": { - "root": { - "layout": { - "struct": { - "fields": [], - "name": "GiveMe" - } - }, - "root_key": "0x00000000" - } - }, - "types": [ - { - "id": 0, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 1 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 2 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 1 - }, - { - "name": "E", - "type": 2 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 1, - "type": { - "def": { - "tuple": [] - } - } - }, - { - "id": 2, - "type": { - "def": { - "variant": { - "variants": [ - { - "index": 1, - "name": "CouldNotReadInput" - } - ] - } - }, - "path": [ - "ink_primitives", - "LangError" - ] - } - }, - { - "id": 3, - "type": { - "def": { - "primitive": "u128" - } - } - }, - { - "id": 4, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 5, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "AccountId" - ] - } - }, - { - "id": 5, - "type": { - "def": { - "array": { - "len": 32, - "type": 6 - } - } - } - }, - { - "id": 6, - "type": { - "def": { - "primitive": "u8" - } - } - }, - { - "id": 7, - "type": { - "def": { - "composite": { - "fields": [ - { - "type": 5, - "typeName": "[u8; 32]" - } - ] - } - }, - "path": [ - "ink_primitives", - "types", - "Hash" - ] - } - }, - { - "id": 8, - "type": { - "def": { - "primitive": "u64" - } - } - }, - { - "id": 9, - "type": { - "def": { - "primitive": "u32" - } - } - }, - { - "id": 10, - "type": { - "def": { - "variant": {} - }, - "path": [ - "ink_env", - "types", - "NoChainExtension" - ] - } - } - ], - "version": "4" -} \ No newline at end of file diff --git a/contract_transfer/frontend/src/constants.ts b/contract_transfer/frontend/src/constants.ts deleted file mode 100644 index ecbbe570..00000000 --- a/contract_transfer/frontend/src/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const CONTRACT_ROCOCO_ADDRESS = - '5E6iJxxnf2v8p1mfc9UV8ojBYAQbJQyd5H1gQwvpxESZYEja'; diff --git a/contract_transfer/frontend/src/main.tsx b/contract_transfer/frontend/src/main.tsx deleted file mode 100644 index 52664eea..00000000 --- a/contract_transfer/frontend/src/main.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import App from './App.tsx'; -import './Global.css'; -import metadata from './assets/contract_transfer.json'; -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import 'ui/style.css'; -import { UseInkProvider } from 'useink'; -import { RococoContractsTestnet } from 'useink/chains'; -import { NotificationsProvider } from 'useink/notifications'; - -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - , -); diff --git a/contract_transfer/frontend/src/vite-env.d.ts b/contract_transfer/frontend/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2..00000000 --- a/contract_transfer/frontend/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/contract_transfer/frontend/tailwind.config.js b/contract_transfer/frontend/tailwind.config.js deleted file mode 100644 index c120a39a..00000000 --- a/contract_transfer/frontend/tailwind.config.js +++ /dev/null @@ -1,2 +0,0 @@ -import config from '../../ui/tailwind.config'; -export default config; \ No newline at end of file diff --git a/contract_transfer/frontend/tsconfig.json b/contract_transfer/frontend/tsconfig.json deleted file mode 100644 index a7fc6fbf..00000000 --- a/contract_transfer/frontend/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/contract_transfer/frontend/tsconfig.node.json b/contract_transfer/frontend/tsconfig.node.json deleted file mode 100644 index 42872c59..00000000 --- a/contract_transfer/frontend/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/contract_transfer/frontend/vite.config.ts b/contract_transfer/frontend/vite.config.ts deleted file mode 100644 index 4e7004eb..00000000 --- a/contract_transfer/frontend/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import react from '@vitejs/plugin-react'; -import { defineConfig } from 'vite'; - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], -}); From 1339431ac8305744a1e4a99d06e5d5395ff799d4 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Fri, 10 Nov 2023 14:17:02 +0100 Subject: [PATCH 12/12] revert merge changes --- flipper/frontend/src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flipper/frontend/src/App.tsx b/flipper/frontend/src/App.tsx index 4403d237..91704fb4 100644 --- a/flipper/frontend/src/App.tsx +++ b/flipper/frontend/src/App.tsx @@ -1,6 +1,6 @@ import metadata from './assets/flipper.json'; import { CONTRACT_ROCOCO_ADDRESS } from './constants'; -import { Button, Card, ConnectButton, InkLayout } from 'ui'; +import { Button, Card, ConnectButton, InkLayout, formatContractName } from 'ui'; import { useCallSubscription, useContract, useTx, useWallet } from 'useink'; import { useTxNotifications } from 'useink/notifications'; import { pickDecoded, shouldDisable } from 'useink/utils'; @@ -22,7 +22,7 @@ function App() { >

- {metadata.contract.name.toUpperCase()} + {formatContractName(metadata.contract.name)}