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

activate signature function when login #24

Open
YouJun-IWON opened this issue Mar 8, 2023 · 2 comments
Open

activate signature function when login #24

YouJun-IWON opened this issue Mar 8, 2023 · 2 comments
Assignees
Milestone

Comments

@YouJun-IWON
Copy link
Collaborator

YouJun-IWON commented Mar 8, 2023

    try {
        const signature = await library.getSigner(account).signMessage('Hello');
        window.alert(`Success! ${signature}`);
    }catch(error) {
        console.error(error);
    }

위와 같은 구문을 통해 onclick 이벤트와 함께 login 버튼을 누를시 서명이 활성화될 수 있도록 하려 했지만 작동하지 않음

@YouJun-IWON YouJun-IWON self-assigned this Mar 8, 2023
@YouJun-IWON YouJun-IWON added this to the Lending Page milestone Mar 8, 2023
@YouJun-IWON
Copy link
Collaborator Author

const Activate = () => {
const context = useWeb3React();
const { activate, active } = context;
const [activating, setActivating] = useState(false);
const { account, library } = useWeb3React()

const handleActivate = (event) => {
    event.preventDefault(); 

    async function _activate() {
        try {
            const signature = await library.getSigner(account).signMessage('Hello');
            window.alert(`Success! ${signature}`);
        }catch(error) {
            console.error(error);
        }
        setActivating(true);
        await activate(injected);
        setActivating(false); 
    }
    _activate();
}

// web3 요소가 감지되면 자동실행
const eagerConnectionSuccessful = useWeb3Connect();
useInactiveListener(!eagerConnectionSuccessful);

return (
    <StyledActivateButton disabled = {active} 
    style={{
        borderColor: activating ? 'orange' : active? 'unset' : 'green'
    }}
    onClick = {handleActivate}>Connect</StyledActivateButton>
)

}

@YouJun-IWON
Copy link
Collaborator Author

구현되지 않음

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant