-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from hyperweb-io/authz
authz code
- Loading branch information
Showing
640 changed files
with
163,099 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
/main | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# 1.1.0 (2024-10-08) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* deps ([b2aa70b](https://github.com/hyperweb-io/create-cosmos-app/commit/b2aa70ba9ef34fd96954c033220ff160d2c8ece7)) | ||
* old ci job yarn4 issues ([#182](https://github.com/hyperweb-io/create-cosmos-app/issues/182)) ([2bb19f7](https://github.com/hyperweb-io/create-cosmos-app/commit/2bb19f75fcc6ffaa4bcb63ecf071009d2f9d7e76)) | ||
* rename telescope-authz to authz ([9ba95fd](https://github.com/hyperweb-io/create-cosmos-app/commit/9ba95fd9d2e23620b1997e87f780460602507d60)) | ||
* try locks update script ([000aa5f](https://github.com/hyperweb-io/create-cosmos-app/commit/000aa5fc73faa0182a23f50a6402e8b2351a587c)) | ||
* upgrade deps and fix multi chain dropdown ([eecbcaa](https://github.com/hyperweb-io/create-cosmos-app/commit/eecbcaad5e7729f00f9121250c04eb40d201ed80)) | ||
|
||
|
||
|
||
|
||
|
||
# 1.0.0 (2024-04-06) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* rename telescope-authz to authz ([e30689d](https://github.com/hyperweb-io/create-cosmos-app/commit/e30689d1ff5f5c42a1c962aecc8b568511e0d0c2)) | ||
|
||
|
||
|
||
|
||
|
||
## [0.0.4](https://github.com/hyperweb-io/create-cosmos-app/compare/@cosmology/[email protected]...@cosmology/[email protected]) (2024-01-20) | ||
|
||
**Note:** Version bump only for package @cosmology/telescope-authz-example | ||
|
||
|
||
|
||
|
||
|
||
## [0.0.3](https://github.com/hyperweb-io/create-cosmos-app/compare/@cosmology/[email protected]...@cosmology/[email protected]) (2024-01-20) | ||
|
||
**Note:** Version bump only for package @cosmology/telescope-authz-example | ||
|
||
|
||
|
||
|
||
|
||
## 0.0.2 (2024-01-19) | ||
|
||
**Note:** Version bump only for package @cosmology/telescope-authz-example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
This is a Cosmos App project bootstrapped with [`create-cosmos-app`](https://github.com/hyperweb-io/create-cosmos-app). | ||
|
||
## Getting Started | ||
|
||
First, install the packages and run the development server: | ||
|
||
```bash | ||
yarn && yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. | ||
|
||
## Learn More | ||
|
||
### Chain Registry | ||
|
||
The npm package for the Official Cosmos chain registry. Get chain and token data for you application. | ||
|
||
* https://github.com/hyperweb-io/chain-registry | ||
|
||
### Cosmology Videos | ||
|
||
Checkout more videos for how to use various frontend tooling in the Cosmos! | ||
|
||
* https://cosmology.zone/learn | ||
|
||
### Interchain Kit | ||
|
||
A wallet connector for the Cosmos ⚛️ | ||
|
||
* https://github.com/hyperweb-io/interchain-kit | ||
|
||
### Telescope | ||
|
||
A "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. Telescope is used to generate libraries for Cosmos blockchains. Simply point to your protobuffer files and create developer-friendly Typescript libraries for teams to build on your blockchain. | ||
|
||
* https://github.com/hyperweb-io/telescope | ||
|
||
🎥 [Checkout the Telescope video playlist](https://www.youtube.com/watch?v=n82MsLe82mk&list=PL-lMkVv7GZwyQaK6bp6kMdOS5mzosxytC) to learn how to use `telescope`! | ||
|
||
### CosmWasm TS Codegen | ||
|
||
The quickest and easiest way to interact with CosmWasm Contracts. @cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code. | ||
|
||
* https://github.com/CosmWasm/ts-codegen | ||
|
||
🎥 [Checkout the CosmWasm/ts-codegen video playlist](https://www.youtube.com/watch?v=D_A5V2PfNLA&list=PL-lMkVv7GZwz1KO3jANwr5W4MoziruXwK) to learn how to use `ts-codegen`! | ||
|
||
|
||
## Learn More about Next.js | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. | ||
|
||
## Related | ||
|
||
Checkout these related projects: | ||
|
||
* [@cosmology/telescope](https://github.com/hyperweb-io/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules. | ||
* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes. | ||
* [chain-registry](https://github.com/hyperweb-io/chain-registry) Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application. | ||
* [interchain-kit](https://github.com/hyperweb-io/interchain-kit) Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface. | ||
* [create-cosmos-app](https://github.com/hyperweb-io/create-cosmos-app) Set up a modern Cosmos app by running one command. | ||
* [interchain-ui](https://github.com/hyperweb-io/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit. | ||
* [starship](https://github.com/hyperweb-io/starship) Unified Testing and Development for the Interchain. | ||
|
||
## Credits | ||
|
||
🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator) | ||
|
||
|
||
## Disclaimer | ||
|
||
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. | ||
|
||
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// TODO fix type issues | ||
// @ts-nocheck | ||
|
||
import { useState } from 'react'; | ||
import { useChain } from '@interchain-kit/react'; | ||
import { Box, Button, Tabs, Text } from '@interchain-ui/react'; | ||
|
||
import { Grants } from './Grants'; | ||
import { GrantModal } from './GrantModal'; | ||
|
||
export const AuthzSection = ({ chainName }: { chainName: string }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [activeTab, setActiveTab] = useState(0); | ||
const { address } = useChain(chainName); | ||
|
||
if (!address) { | ||
return ( | ||
<Text | ||
fontWeight="$semibold" | ||
fontSize="$lg" | ||
textAlign="center" | ||
color="$textSecondary" | ||
attributes={{ my: '$24' }} | ||
> | ||
Please connect your wallet to view and create grants | ||
</Text> | ||
); | ||
} | ||
|
||
return ( | ||
<Box mb="$18" minHeight="500px" display="flex" flexDirection="column"> | ||
<Box | ||
display="flex" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
mb="$16" | ||
> | ||
<Tabs | ||
tabs={[ | ||
{ | ||
label: 'Grants to me', | ||
content: null, | ||
}, | ||
{ | ||
label: 'Grants by me', | ||
content: null, | ||
}, | ||
]} | ||
activeTab={activeTab} | ||
onActiveTabChange={(tabId) => setActiveTab(tabId)} | ||
attributes={{ width: '$min' }} | ||
/> | ||
<Button intent="tertiary" onClick={() => setIsOpen(true)}> | ||
Create Grant | ||
</Button> | ||
</Box> | ||
|
||
<Grants | ||
chainName={chainName} | ||
role={activeTab === 0 ? 'grantee' : 'granter'} | ||
/> | ||
|
||
<GrantModal | ||
isOpen={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
chainName={chainName} | ||
/> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// TODO fix type issues | ||
// @ts-nocheck | ||
|
||
import { Dispatch, SetStateAction, useState } from 'react'; | ||
import { Box, NumberField, SelectButton, Text } from '@interchain-ui/react'; | ||
|
||
import { useValidators } from '@/hooks'; | ||
import { Permission, PermissionId } from '@/configs'; | ||
import { SelectValidatorsModal } from './SelectValidatorsModal'; | ||
import { AccessList } from './GrantModal'; | ||
|
||
// ============================================== | ||
|
||
type SendCustomizationProps = { | ||
value: number | undefined; | ||
onChange: (value: string) => void; | ||
}; | ||
|
||
const SendCustomization = ({ value, onChange }: SendCustomizationProps) => { | ||
return ( | ||
<NumberField | ||
placeholder="Spend Limit (Optional)" | ||
value={value} | ||
onInput={(e) => { | ||
// @ts-ignore | ||
onChange(e.target.value); | ||
}} | ||
formatOptions={{ | ||
maximumFractionDigits: 6, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
// ============================================== | ||
|
||
type DelegateCustomizationProps = { | ||
value: number | undefined; | ||
onChange: (value: string) => void; | ||
chainName: string; | ||
accessList: AccessList; | ||
setAccessList: Dispatch<SetStateAction<AccessList>>; | ||
}; | ||
|
||
const DelegateCustomization = ({ | ||
value, | ||
onChange, | ||
chainName, | ||
accessList, | ||
setAccessList, | ||
}: DelegateCustomizationProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const { data } = useValidators(chainName); | ||
|
||
const validatorNames = data | ||
? accessList.addresses.map( | ||
(address) => data.find((v) => v.address === address)!.name | ||
) | ||
: []; | ||
|
||
return ( | ||
<> | ||
<NumberField | ||
placeholder="Max Tokens (Optional)" | ||
value={value} | ||
onInput={(e) => { | ||
// @ts-ignore | ||
onChange(e.target.value); | ||
}} | ||
formatOptions={{ | ||
maximumFractionDigits: 6, | ||
}} | ||
/> | ||
<SelectButton | ||
placeholder="Select Validators (Optional)" | ||
onClick={() => setIsOpen(true)} | ||
/> | ||
<Box | ||
display={validatorNames.length > 0 ? 'block' : 'none'} | ||
mt="$2" | ||
px="$2" | ||
> | ||
<Text> | ||
<Text | ||
as="span" | ||
fontWeight="$semibold" | ||
color={ | ||
accessList.type === 'allowList' ? '$textSuccess' : '$textDanger' | ||
} | ||
> | ||
{accessList.type === 'allowList' ? 'Allow List' : 'Deny List'} | ||
: | ||
</Text> | ||
{validatorNames.join(', ')} | ||
</Text> | ||
</Box> | ||
<SelectValidatorsModal | ||
chainName={chainName} | ||
accessList={accessList} | ||
setAccessList={setAccessList} | ||
isOpen={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
// ============================================== | ||
|
||
type CustomizationFieldProps = | ||
| ({ | ||
permissionType: typeof Permission['Send']; | ||
} & SendCustomizationProps) | ||
| ({ | ||
permissionType: typeof Permission['Delegate']; | ||
} & DelegateCustomizationProps); | ||
|
||
export const CustomizationField = ({ | ||
permissionType, | ||
...rest | ||
}: CustomizationFieldProps): JSX.Element | null => { | ||
const fields: Partial<Record<PermissionId, JSX.Element | null>> = { | ||
send: | ||
permissionType === 'send' ? ( | ||
<SendCustomization {...(rest as SendCustomizationProps)} /> | ||
) : null, | ||
delegate: | ||
permissionType === 'delegate' ? ( | ||
<DelegateCustomization {...(rest as DelegateCustomizationProps)} /> | ||
) : null, | ||
}; | ||
|
||
return fields[permissionType] ?? null; | ||
}; |
Oops, something went wrong.