Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use approveAndCall in staking txs #687

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
1875971
chore: Add .env to .gitignore and add example env
theref Sep 1, 2023
929ec5e
Add Dockerfile
theref Jul 19, 2023
566be2e
Switch to debian image to avoid memory issues
theref Jul 20, 2023
9edac59
docs: Update local docker development instruction in README
theref Aug 24, 2023
aa7bf07
Converts docker usage into docker compose and use a bind mount to ref…
KPrasch Sep 18, 2023
7f698cd
automated linting
KPrasch Sep 18, 2023
f596d72
chore: update readme from docker to docker-compose command
theref Oct 5, 2023
02d20fc
chore: update docker-compose command
theref Oct 11, 2023
3f32799
Update README.md
theref Oct 11, 2023
beb0306
Add Dockerfile
theref Jul 19, 2023
2a93943
Switch to debian image to avoid memory issues
theref Jul 20, 2023
ae4fd31
docs: Update local docker development instruction in README
theref Aug 24, 2023
2e43c61
Converts docker usage into docker compose and use a bind mount to ref…
KPrasch Sep 18, 2023
be319e8
Update README with new package versions for local dev
theref Oct 17, 2023
06482cc
Replace pre with taco on varioius pages
theref Sep 1, 2023
a11a817
Continue replacing PRE with TACo
theref Sep 5, 2023
2372f6b
Update staking application authorization form
theref Sep 11, 2023
abe86d5
Apply wording change
theref Sep 14, 2023
2072a01
Apply review wording change
theref Sep 14, 2023
1de5b5d
Update documentation urls
theref Sep 14, 2023
afa5fca
automated linting
KPrasch Sep 18, 2023
98b1fe5
feat(store): add taco to operator info
theref Sep 18, 2023
20c6bb9
feat: Update labels and add TACo app mapping
theref Sep 18, 2023
e7d80ed
refactor: Rename variable TACoApp to tacoApp
theref Sep 18, 2023
a8f0921
feat: Add support for authorizing Taco app
theref Sep 18, 2023
66242ca
feat: Add mapping of operator address to TACo app
theref Sep 19, 2023
8195276
feat: Add Taco Application abi and goerli address
theref Sep 19, 2023
36de012
Add some todos and export the Taco contract const
theref Sep 19, 2023
b870d74
Use the Taco Contract within MultiAppStaking
theref Sep 19, 2023
0e3c153
linting fixes, fix small typo.
KPrasch Sep 19, 2023
7c24748
Use a static deployment artifact registry for TacoApplication.
KPrasch Sep 19, 2023
98a2514
Use nucypher-contracts package for TACo abi and address
theref Oct 9, 2023
3af1d38
feat(utils): add taco mapping for address and app label after rebase
theref Oct 10, 2023
2ed7dbe
Update yarn.lock after adding @nucypher/nucypher-contracts dependency
cygnusv Oct 11, 2023
6f1a787
Update src/components/Modal/MapOperatorToStakingProviderConfirmationM…
theref Oct 11, 2023
3e1d01f
chore: Add dashboard network to .env files
theref Oct 11, 2023
66a4731
style: fix typo in TACo node and TACo app names
theref Oct 12, 2023
1ae8674
fix(mas): update environment variable name
theref Oct 12, 2023
5aca550
Add TACo app to testing
theref Oct 12, 2023
3abad9e
Bump version of @nucypher/nucypher-contracts
theref Oct 17, 2023
8a1a1dc
Update docs links for TACo node setup and staking providers
theref Oct 19, 2023
311f7e8
Remove reference to PRE in bonus eligibility
theref Oct 19, 2023
fb32b23
Remove remaining references to PRE
theref Oct 19, 2023
50642be
Fix bug with taco min auth amount
theref Oct 23, 2023
0dbd12d
Update Operator-StakingProvider mapping function for TACo app contract
theref Oct 23, 2023
b1c9f9e
Upgrade node to 18 within the dockerfile
theref Oct 31, 2023
b67a4a4
Update nucypher-contracts version and add bondOperator to interface
theref Nov 21, 2023
0377ec2
Fix Dockerfile after rebase
theref Nov 27, 2023
01f1202
Update Dockerfile, nucypher-contracts version, and TACo domain to sup…
theref Nov 27, 2023
49d96a8
More sepolia Taco improvements
theref Nov 28, 2023
27d1049
Include TACo in NewAppsToAuthorizeModal
theref Nov 29, 2023
7cdbfd2
Add optional _minimumAuthorization for AuthorizationParameters
theref Dec 4, 2023
d00b240
Initial Taco commitment work
theref Dec 4, 2023
df98dbc
Fix file type
theref Dec 4, 2023
71a95c5
Add basics of button and new card
theref Dec 4, 2023
ae23663
Update images used for TACo increase/decrease authorizations.
derekpierre Dec 4, 2023
dcbde5f
Update images used for showing Authorized Apps.
derekpierre Dec 4, 2023
5bdd437
Update StakingApp illustrations to include TACo instead of PRE.
derekpierre Dec 4, 2023
ebb783c
Update increase/decrease auth images text to use Inter.
derekpierre Dec 4, 2023
6f48c4f
Add table of choices to Commitment modal
theref Dec 4, 2023
61ce4cf
chore: remove redundant image from docker-compose file
piotr-roslaniec Dec 5, 2023
518229d
add links to staking apps docs
piotr-roslaniec Dec 5, 2023
50c7d3c
update lockfile
piotr-roslaniec Dec 5, 2023
3190b11
Send commitment tx successfully!
theref Dec 5, 2023
6b43793
Merge pull request #682 from threshold-network/commit
theref Dec 5, 2023
783d51a
Update yarn.lock.
derekpierre Dec 5, 2023
201a561
Merge pull request #686 from threshold-network/taco-image
theref Dec 5, 2023
a323875
Update TACo commitment modal wording
theref Dec 5, 2023
324ad95
Catch isOperatorInPool error for TACo application
theref Dec 5, 2023
6e437dd
Add extra commitment options
theref Dec 5, 2023
7607e39
Clarify deauthorization cooldown periods
cygnusv Dec 5, 2023
8d3c7c5
Reorder app cards
cygnusv Dec 5, 2023
fff60ed
Pin react-icons to v4.4.0
cygnusv Dec 5, 2023
41751b0
Merge pull request #690 from threshold-network/react-icons
theref Dec 6, 2023
69432ce
Merge pull request #689 from threshold-network/taco-cards
theref Dec 6, 2023
10dbe8f
Merge pull request #685 from threshold-network/staking-links
piotr-roslaniec Dec 6, 2023
41cf676
Remove trailing whitespace
cygnusv Dec 6, 2023
31474cf
update dockerfile
piotr-roslaniec Dec 6, 2023
4ccdefd
Restore react-icons to ^4.3.1 in package.json
cygnusv Dec 6, 2023
463081b
update .dockerignore
piotr-roslaniec Dec 6, 2023
227ef21
Add card to Operator Mapping modal
theref Dec 6, 2023
036cf18
Use refs to handle multiple form submits for Operator Mapping
theref Dec 6, 2023
75b39f5
Merge pull request #691 from threshold-network/taco-cards
theref Dec 6, 2023
c7ac849
wip
piotr-roslaniec Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copied from .gitignore

# Local
.DS_Store
.idea
.eslintcache

# IDEs
.vscode/
.idea/

# Generated
build/
dist/
external/

# Storybook
storybook-static
build-storybook.log
cypress/fixtures
cypress/plugins

# Yarn
node_modules/
yarn-error.log
.env
.cosine/
2 changes: 2 additions & 0 deletions .env → .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ REACT_APP_ELECTRUM_PORT=$ELECTRUM_PORT
REACT_APP_MOCK_BITCOIN_CLIENT=true

REACT_APP_WALLET_CONNECT_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID

REACT_APP_TACO_DOMAIN=dashboard
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ REACT_APP_ELECTRUM_PORT=$ELECTRUM_PORT
REACT_APP_MOCK_BITCOIN_CLIENT=false

REACT_APP_WALLET_CONNECT_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID
REACT_APP_TACO_DOMAIN=mainnet
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
REACT_APP_SUPPORTED_CHAIN_ID=1337
REACT_APP_MULTICALL_ADDRESS=0x086813525A7dC7dafFf015Cdf03896Fd276eab60
REACT_APP_TACO_DOMAIN=dashboard
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ cypress/plugins
# Yarn
node_modules/
yarn-error.log
.env
.cosine/
33 changes: 33 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Use the specified image
FROM node:18-buster-slim

# Set the working directory
WORKDIR /app

# Install dependencies
RUN apt-get update && apt-get install -y python3 make g++ git openssh-client ca-certificates && \
git config --global url."https://".insteadOf git:// && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

# Set the environment variables
ENV PYTHON=/usr/bin/python3
ENV NODE_OPTIONS=--max_old_space_size=3072

# Copy package files and install node modules
COPY package*.json ./
RUN npm install -g node-gyp
RUN yarn install --ignore-scripts --frozen-lockfile
RUN yarn upgrade @keep-network/coverage-pools@sepolia \
@keep-network/ecdsa@sepolia \
@keep-network/keep-core@sepolia \
@keep-network/keep-ecdsa@sepolia \
@keep-network/random-beacon@sepolia \
@keep-network/tbtc@sepolia \
@keep-network/tbtc-v2@sepolia \
@threshold-network/coverage-pools@npm:@keep-network/coverage-pools@sepolia \
@threshold-network/solidity-contracts@sepolia
RUN yarn run postinstall

# Expose port 3000
EXPOSE 3000
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,37 @@ The following procedure allows to deploy T token dashboard to production:
approval of someone else from the development team.
5. Once the release action is approved, the new version is automatically
deployed to `dashboard.threshold.network`.

## Local Development

Update `.env` to contain:

```
REACT_APP_SUPPORTED_CHAIN_ID=11155111
REACT_APP_ETH_HOSTNAME_HTTP=https://sepolia.infura.io/v3/<your API key here>
REACT_APP_ETH_HOSTNAME_WS=wss://sepolia.infura.io/v3/<your API key here>
REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS

REACT_APP_FEATURE_FLAG_TBTC_V2=true
REACT_APP_FEATURE_FLAG_TBTC_V2_REDEMPTION=true
REACT_APP_FEATURE_FLAG_MULTI_APP_STAKING=true
REACT_APP_FEATURE_FLAG_FEEDBACK_MODULE=false
REACT_APP_FEATURE_FLAG_POSTHOG=false
REACT_APP_FEATURE_FLAG_SENTRY=$SENTRY_SUPPORT
REACT_APP_SENTRY_DSN=$SENTRY_DSN

REACT_APP_ELECTRUM_PROTOCOL=wss
REACT_APP_ELECTRUM_HOST=electrumx-server.test.tbtc.network
REACT_APP_ELECTRUM_PORT=8443
REACT_APP_MOCK_BITCOIN_CLIENT=false

REACT_APP_WALLET_CONNECT_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID

REACT_APP_TACO_DOMAIN=dashboard
```

Then build the docker container and run the dashboard:

```bash
docker-compose up --build
```
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.8"

services:
threshold-dashboard:
container_name: threshold-dashboard
working_dir: /app
environment:
- PYTHON=/usr/bin/python3
- NODE_OPTIONS=--max_old_space_size=3072
ports:
- "3000:3000"
volumes:
- .:/app # Bind mount the current directory to /app in the container
command: bash -c "yarn format:fix && yarn start"
build:
context: .
dockerfile: Dockerfile.dev
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@ledgerhq/connect-kit-loader": "^1.1.2",
"@reduxjs/toolkit": "^1.6.1",
"@rehooks/local-storage": "^2.4.4",
"@nucypher/nucypher-contracts": "0.13.0",
"@sentry/react": "^7.33.0",
"@sentry/tracing": "^7.33.0",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ const MapOperatorToStakingProviderConfirmationModal: FC<
operator: string
isOperatorMappedOnlyInTbtc: boolean
isOperatorMappedOnlyInRandomBeacon: boolean
isOperatorMappedOnlyInTaco: boolean
}
> = ({
operator,
isOperatorMappedOnlyInTbtc,
isOperatorMappedOnlyInRandomBeacon,
isOperatorMappedOnlyInTaco,
closeModal,
}) => {
const { account } = useWeb3React()
Expand Down Expand Up @@ -135,9 +137,11 @@ const MapOperatorToStakingProviderConfirmationModal: FC<
</H5>
<BodyLg mt="4">
This will require{" "}
{isOperatorMappedOnlyInRandomBeacon || isOperatorMappedOnlyInTbtc
? "1 transaction"
: "2 transactions"}
{isOperatorMappedOnlyInRandomBeacon ||
isOperatorMappedOnlyInTbtc ||
isOperatorMappedOnlyInTaco
? "2 transactions"
: "3 transactions"}
. Each mapping is one transaction
</BodyLg>
</InfoBox>
Expand All @@ -155,6 +159,13 @@ const MapOperatorToStakingProviderConfirmationModal: FC<
stakingProvider={account ? account : AddressZero}
/>
)}
{!isOperatorMappedOnlyInTaco && (
<OperatorMappingConfirmation
appName="taco"
operator={operator}
stakingProvider={account ? account : AddressZero}
/>
)}
</ModalBody>
<ModalFooter>
<Button onClick={closeModal} variant="outline" mr={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ const validateInputtedOperatorAddress = async (

type MapOperatorToStakingProviderFormProps = {
initialAddress: string
mappedOperatorTbtc: string
mappedOperatorRandomBeacon: string
mappedOperatorTbtc?: string
mappedOperatorRandomBeacon?: string
mappedOperatorTaco?: string
innerRef: Ref<FormikProps<MapOperatorToStakingProviderFormValues>>
checkIfOperatorIsMappedToAnotherStakingProvider: (
operator: string
Expand All @@ -96,19 +97,47 @@ const MapOperatorToStakingProviderForm = withFormik<
const {
mappedOperatorTbtc,
mappedOperatorRandomBeacon,
mappedOperatorTaco,
checkIfOperatorIsMappedToAnotherStakingProvider,
} = props
const errors: FormikErrors<MapOperatorToStakingProviderFormValues> = {}

console.log("tbtc", mappedOperatorTbtc)
console.log("random beacon", mappedOperatorRandomBeacon)
console.log("taco", mappedOperatorTaco)

errors.operator = validateETHAddress(values.operator)
if (!errors.operator) {
if (
!errors.operator &&
mappedOperatorTbtc !== undefined &&
mappedOperatorRandomBeacon !== undefined
) {
errors.operator = await validateInputtedOperatorAddress(
values.operator,
checkIfOperatorIsMappedToAnotherStakingProvider,
mappedOperatorTbtc,
mappedOperatorRandomBeacon
)
}
if (!errors.operator && mappedOperatorTaco !== undefined) {
let validationMsg: string | undefined = ""
try {
const isOperatorMappedToAnotherStakingProvider =
await checkIfOperatorIsMappedToAnotherStakingProvider(values.operator)
validationMsg = undefined
if (isOperatorMappedToAnotherStakingProvider) {
validationMsg =
"Operator is already mapped to another staking provider."
}
} catch (error) {
console.error(
"`MapOperatorToStakingProviderForm` validation error.",
error
)
validationMsg = (error as Error)?.message
}
errors.operator = validationMsg
}

return getErrorsObj(errors)
},
Expand Down
51 changes: 45 additions & 6 deletions src/components/Modal/MapOperatorToStakingProviderModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,27 @@ import ModalCloseButton from "../ModalCloseButton"
export interface MapOperatorToStakingProviderModalProps {
mappedOperatorTbtc: string
mappedOperatorRandomBeacon: string
mappedOperatorTaco: string
}

const MapOperatorToStakingProviderModal: FC<
BaseModalProps & MapOperatorToStakingProviderModalProps
> = () => {
const { account } = useWeb3React()
const formRef =
const formRefTbtc =
useRef<FormikProps<MapOperatorToStakingProviderFormValues>>(null)
const formRefTaco =
useRef<FormikProps<MapOperatorToStakingProviderFormValues>>(null)
const { closeModal, openModal } = useModal()
const threshold = useThreshold()

const {
mappedOperatorTbtc,
mappedOperatorRandomBeacon,
mappedOperatorTaco,
isOperatorMappedOnlyInRandomBeacon,
isOperatorMappedOnlyInTbtc,
isOperatorMappedOnlyInTaco,
} = useAppSelector(selectMappedOperators)

const onSubmit = async ({
Expand All @@ -62,6 +67,7 @@ const MapOperatorToStakingProviderModal: FC<
operator,
isOperatorMappedOnlyInTbtc,
isOperatorMappedOnlyInRandomBeacon,
isOperatorMappedOnlyInTaco,
})
}
}
Expand All @@ -84,13 +90,25 @@ const MapOperatorToStakingProviderModal: FC<
)
}

const handleSubmit = async () => {
if (formRefTbtc.current) {
await formRefTbtc.current.handleSubmit()
}

if (formRefTaco.current) {
await formRefTaco.current.handleSubmit()
}
}

return (
<>
<ModalHeader>Operator Address Mapping</ModalHeader>
<ModalCloseButton />
<ModalBody>
<InfoBox variant="modal">
{isOperatorMappedOnlyInRandomBeacon || isOperatorMappedOnlyInTbtc ? (
{isOperatorMappedOnlyInRandomBeacon ||
isOperatorMappedOnlyInTbtc ||
isOperatorMappedOnlyInTaco ? (
<H5>
We noticed you've only mapped 1 application's Operator Address.
</H5>
Expand Down Expand Up @@ -122,12 +140,12 @@ const MapOperatorToStakingProviderModal: FC<
) : isOperatorMappedOnlyInTbtc ? (
<LabelSm>random beacon app</LabelSm>
) : (
<LabelSm>tBTC + Random Beacon apps (requires 2txs)</LabelSm>
<LabelSm>tBTC + Random Beacon (requires 2txs)</LabelSm>
)}
<StakeAddressInfo stakingProvider={account ? account : AddressZero} />
<MapOperatorToStakingProviderForm
innerRef={formRef}
formId="map-operator-to-staking-provider-form"
innerRef={formRefTbtc}
formId="map-operator-to-staking-provider-form-tbtc"
initialAddress={
isOperatorMappedOnlyInRandomBeacon
? mappedOperatorRandomBeacon
Expand Down Expand Up @@ -155,12 +173,33 @@ const MapOperatorToStakingProviderModal: FC<
transactions, one transaction per application.
</BodyXs>
</AlertBox>
<Box
p={"24px"}
border={"1px solid"}
borderColor={"gray.100"}
borderRadius={"12px"}
mt={"5"}
mb={"5"}
>
<LabelSm>Taco (requires 1tx)</LabelSm>
<StakeAddressInfo stakingProvider={account ? account : AddressZero} />
<MapOperatorToStakingProviderForm
innerRef={formRefTaco}
formId="map-operator-to-staking-provider-form-taco"
initialAddress={""}
onSubmitForm={onSubmit}
checkIfOperatorIsMappedToAnotherStakingProvider={
checkIfOperatorIsMappedToAnotherStakingProvider
}
mappedOperatorTaco={mappedOperatorTaco}
/>
</Box>
</ModalBody>
<ModalFooter>
<Button onClick={closeModal} variant="outline" mr={2}>
Dismiss
</Button>
<Button type="submit" form="map-operator-to-staking-provider-form">
<Button type="submit" onClick={handleSubmit}>
Map Address
</Button>
</ModalFooter>
Expand Down
Loading
Loading