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

Feature: wallet connection modal and different providers support #166

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"@stacks/auth": "6.9.0",
"@stacks/blockchain-api-client": "7.3.2",
"@stacks/common": "6.8.1",
"@stacks/connect": "7.4.1",
"@stacks/connect-react": "22.2.1",
"@stacks/connect": "7.7.0",
"@stacks/connect-react": "22.4.0",
"@stacks/network": "6.8.1",
"@stacks/stacking": "6.9.0",
"@stacks/transactions": "6.9.0",
Expand Down
43 changes: 31 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/components/auth-provider/auth-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactNode, createContext, useContext, useState } from 'react';

import { UserData } from '@stacks/auth';
import { AppConfig, UserSession, showConnect } from '@stacks/connect';
import { AppConfig, UserSession, disconnect, showConnect } from '@stacks/connect';
import { validateStacksAddress as isValidStacksAddress } from '@stacks/transactions';
import { APP_DETAILS } from 'src/constants';

Expand Down Expand Up @@ -72,6 +72,7 @@ export function AuthProvider({ children }: Props) {

function signOut() {
userSession.signUserOut();
disconnect();
setIsSignedIn(false);
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/stacking/pool-admin/delegate-stack-extend/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';

import { ContractCallRegularOptions, FinishedTxData, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, FinishedTxData, showContractCall } from '@stacks/connect';
import { StacksNetwork, StacksNetworkName } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import * as yup from 'yup';
Expand Down Expand Up @@ -61,11 +61,11 @@ export function createHandleSubmit({

console.log(delegateStackExtendOptions);

openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dispatch, SetStateAction } from 'react';

import { intToBigInt } from '@stacks/common';
import { ContractCallRegularOptions, FinishedTxData, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, FinishedTxData, showContractCall } from '@stacks/connect';
import { StacksNetwork, StacksNetworkName } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import BigNumber from 'bignumber.js';
Expand Down Expand Up @@ -79,11 +79,11 @@ export function createHandleSubmit({
poxAddress: values.poxAddress,
});

openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
8 changes: 4 additions & 4 deletions src/pages/stacking/pool-admin/delegate-stack-stx/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';

import { ContractCallRegularOptions, FinishedTxData, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, FinishedTxData, showContractCall } from '@stacks/connect';
import { StacksNetwork } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import * as yup from 'yup';
Expand Down Expand Up @@ -80,11 +80,11 @@ export function createHandleSubmit({
burnBlockHeight: values.startBurnHt,
});

openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';

import { ContractCallRegularOptions, FinishedTxData, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, FinishedTxData, showContractCall } from '@stacks/connect';
import { StackingClient } from '@stacks/stacking';
import * as yup from 'yup';

Expand Down Expand Up @@ -42,11 +42,11 @@ export function createHandleSubmit({
rewardCycle: values.rewardCycleId,
});

openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StackingClient } from '@stacks/stacking';
import { Box, Flex, Text } from '@stacks/ui';

Expand Down Expand Up @@ -100,11 +100,11 @@ function PooledStackingInfoLayout({ client }: CardLayoutProps) {
const stackingContract = await client.getStackingContract();
const revokeDelegationOptions = client.getRevokeDelegateStxOptions(stackingContract);
setIsContractCallExtensionPageOpen(true);
openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
4 changes: 2 additions & 2 deletions src/pages/stacking/self-service-extend/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StacksNetwork, StacksNetworkName } from '@stacks/network';
import { PoxInfo } from '@stacks/stacking';
import { principalCV } from '@stacks/transactions';
Expand Down Expand Up @@ -45,7 +45,7 @@ export function createHandleSubmit({
network,
};
setIsContractCallExtensionPageOpen(true);
openContractCall({
showContractCall({
...delegateStackStxOptions,
onCancel() {
setIsContractCallExtensionPageOpen(false);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/stacking/stack-extend/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StackingClient } from '@stacks/stacking';
import * as yup from 'yup';

Expand Down Expand Up @@ -49,11 +49,11 @@ export function createHandleSubmit({
poxAddress,
});
setIsContractCallExtensionPageOpen(true);
openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
8 changes: 4 additions & 4 deletions src/pages/stacking/stack-increase/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { AccountExtendedBalances, StackingClient } from '@stacks/stacking';
import BigNumber from 'bignumber.js';
import * as yup from 'yup';
Expand Down Expand Up @@ -73,11 +73,11 @@ export function createHandleSubmit({
increaseBy: stxToMicroStx(increaseBy).toString(),
});
setIsContractCallExtensionPageOpen(true);
openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
8 changes: 4 additions & 4 deletions src/pages/stacking/start-direct-stacking/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dispatch, SetStateAction } from 'react';
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StackingClient } from '@stacks/stacking';
import BigNumber from 'bignumber.js';
import * as yup from 'yup';
Expand Down Expand Up @@ -103,11 +103,11 @@ export function createHandleSubmit({
burnBlockHeight: coreInfo.burn_block_height,
});

openContractCall({
showContractCall({
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StacksNetwork } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import { noneCV, principalCV } from '@stacks/transactions';
Expand Down Expand Up @@ -46,7 +46,7 @@ export function createHandleSubmit({

const allowContractCallerOptions = getOptions(poxWrapperContract, stackingContract, network);

openContractCall({
showContractCall({
...allowContractCallerOptions,
onFinish() {
setIsContractCallExtensionPageOpen(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dispatch, SetStateAction } from 'react';
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StacksNetwork, StacksNetworkName } from '@stacks/network';
import { PoxInfo, StackingClient, poxAddressToTuple } from '@stacks/stacking';
import { noneCV, someCV, uintCV } from '@stacks/transactions';
Expand Down Expand Up @@ -107,9 +107,9 @@ function getOptions(
untilBurnBlockHeight,
}
// Type coercion necessary because the `network` property returned by
// `client.getStackingContract()` has a wider type than allowed by `openContractCall`. Despite
// `client.getStackingContract()` has a wider type than allowed by `showContractCall`. Despite
// the wider type, the actual value of `network` is always of the type `StacksNetwork`
// expected by `openContractCall`.
// expected by `showContractCall`.
//
// See
// https://github.com/hirosystems/stacks.js/blob/0e1f9f19dfa45788236c9e481f9a476d9948d86d/packages/stacking/src/index.ts#L1054
Expand Down Expand Up @@ -162,7 +162,7 @@ export function createHandleSubmit({

const delegateStxOptions = getOptions(values, poxInfo, stackingContract, client, network);

openContractCall({
showContractCall({
...delegateStxOptions,
onFinish() {
setIsContractCallExtensionPageOpen(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { ContractCallRegularOptions, showContractCall } from '@stacks/connect';
import { StacksNetwork } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import { principalCV } from '@stacks/transactions';
Expand Down Expand Up @@ -39,7 +39,7 @@ export function createHandleSubmit({

const disAllowContracCallerOptions = getOptions(poxWrapperContract, stackingContract, network);

openContractCall({
showContractCall({
...disAllowContracCallerOptions,
onFinish() {
setIsContractCallExtensionPageOpen(false);
Expand Down
Loading