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

feat: integrate finance widget #609

Merged
merged 12 commits into from
Nov 27, 2023
4 changes: 4 additions & 0 deletions packages/core-sdk/src/core-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export class CoreSDK extends BaseCoreSDK {
return this._getTxExplorerUrl;
}

public get web3Lib() {
return this._web3Lib;
}

public checkMetaTxConfigSet(
args: {
contractAddress?: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/react-kit/src/components/cta/common/CtaButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from "react";
import { providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { useSignerAddress } from "../../../hooks/useSignerAddress";
import { useCtaClickHandler, Action } from "../../../hooks/useCtaClickHandler";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type Props<T> = CtaButtonProps<T> & {
defaultLabel?: string;
Expand All @@ -35,8 +35,8 @@ export function CtaButton<T>({
coreSdkConfig,
...rest
}: Props<T>) {
const coreSdk = useCoreSdk(coreSdkConfig);
const signerAddress = useSignerAddress(coreSdkConfig.web3Provider);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const signerAddress = useSignerAddress(coreSdk.web3Lib);

const { clickHandler, isLoading } = useCtaClickHandler<T>({
waitBlocks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useState } from "react";
import { BigNumberish, providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { CreateSellerArgs, TransactionResponse } from "@bosonprotocol/common";
import { DisputeResolutionFee } from "@bosonprotocol/core-sdk/dist/cjs/accounts";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";
export type IAddFeesDisputeResolverButton = {
exchangeId: BigNumberish;
createSellerArgs: CreateSellerArgs;
Expand Down Expand Up @@ -39,7 +39,7 @@ export const AddFeesDisputeResolverButton = ({
coreSdkConfig,
...rest
}: IAddFeesDisputeResolverButton) => {
const coreSdk = useCoreSdk(coreSdkConfig);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const [isLoading, setIsLoading] = useState<boolean>(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useState } from "react";
import { BigNumberish, providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { CreateSellerArgs, TransactionResponse } from "@bosonprotocol/common";
import { DisputeResolutionFee } from "@bosonprotocol/core-sdk/dist/cjs/accounts";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";
export type IAddSellerToDisputeResolver = {
exchangeId: BigNumberish;
createSellerArgs: CreateSellerArgs;
Expand Down Expand Up @@ -41,7 +41,7 @@ export const AddSellerToDisputeResolver = ({
coreSdkConfig,
...rest
}: IAddSellerToDisputeResolver) => {
const coreSdk = useCoreSdk(coreSdkConfig);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const [isLoading, setIsLoading] = useState<boolean>(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useState } from "react";
import { BigNumberish, providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { TransactionResponse } from "@bosonprotocol/common";
import { accounts } from "@bosonprotocol/core-sdk";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";
export type ICreateDisputeResolverButton = {
exchangeId: BigNumberish;
disputeResolverToCreate: accounts.CreateDisputeResolverArgs;
Expand All @@ -33,7 +33,7 @@ export const CreateDisputeResolverButton = ({
coreSdkConfig,
...rest
}: ICreateDisputeResolverButton) => {
const coreSdk = useCoreSdk(coreSdkConfig);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const [isLoading, setIsLoading] = useState<boolean>(false);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -23,7 +23,9 @@ export const DecideDisputeButton = ({
variant = "primaryFill",
...restProps
}: IDecideDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});
const actions = [
{
writeContractFn: () => coreSdk.decideDispute(exchangeId, buyerPercent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const EscalateDisputeButton = ({
exchangeId,
...restProps
}: IEscalateDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const ExpireDisputeButton = ({
exchangeId,
...restProps
}: IExpireDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const ExpireEscalationDisputeButton = ({
variant = "secondaryFill",
...restProps
}: IExpireEscalationDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});
const actions = [
{
writeContractFn: () => coreSdk.expireEscalatedDispute(exchangeId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -23,7 +23,9 @@ export const ExtendDisputeTimeoutButton = ({
newDisputeTimeout,
...restProps
}: IExtendDisputeTimeoutButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const RaiseDisputeButton = ({
exchangeId,
...restProps
}: IRaiseDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const RefuseDisputeButton = ({
variant = "secondaryFill",
...restProps
}: IRefuseDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});
const actions = [
{
writeContractFn: () => coreSdk.refuseEscalatedDispute(exchangeId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useState } from "react";
import { BigNumberish, providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { CreateSellerArgs, TransactionResponse } from "@bosonprotocol/common";
import { DisputeResolutionFee } from "@bosonprotocol/core-sdk/dist/cjs/accounts";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";
export type IRemoveSellerFromDisputeResolverButton = {
exchangeId: BigNumberish;
createSellerArgs: CreateSellerArgs;
Expand Down Expand Up @@ -41,7 +41,7 @@ export const RemoveSellerFromDisputeResolverButton = ({
coreSdkConfig,
...rest
}: IRemoveSellerFromDisputeResolverButton) => {
const coreSdk = useCoreSdk(coreSdkConfig);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const [isLoading, setIsLoading] = useState<boolean>(false);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish, utils } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -27,7 +27,9 @@ export const ResolveDisputeButton = ({
variant = "primaryFill",
...restProps
}: IResolveDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});
const signature = utils.splitSignature(proposal.signature);

const actions = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -21,7 +21,9 @@ export const RetractDisputeButton = ({
variant = "primaryFill",
...restProps
}: IRetractDisputeButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useState } from "react";
import { BigNumberish, providers } from "ethers";

import { Button } from "../../buttons/Button";
import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
import { CtaButtonProps } from "../common/types";
import { Loading } from "../../Loading";
import { CreateSellerArgs, TransactionResponse } from "@bosonprotocol/common";
import { accounts } from "@bosonprotocol/core-sdk";
import { ButtonSize } from "../../ui/buttonSize";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";
export type IUpdateDisputeResolverButton = {
exchangeId: BigNumberish;
disputeResolverId: BigNumberish;
Expand Down Expand Up @@ -37,7 +37,7 @@ export const UpdateDisputeResolverButton = ({
coreSdkConfig,
...rest
}: IUpdateDisputeResolverButton) => {
const coreSdk = useCoreSdk(coreSdkConfig);
const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
const [isLoading, setIsLoading] = useState<boolean>(false);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
/**
Expand All @@ -23,7 +23,9 @@ export const BatchCompleteButton = ({
variant = "primaryFill",
...restProps
}: Props) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { BigNumberish } from "ethers";

import { useCoreSdk } from "../../../hooks/useCoreSdk";
import { CtaButtonProps } from "../common/types";
import { CtaButton } from "../common/CtaButton";
import { useCoreSdkOverrides } from "../../../hooks/useCoreSdkOverrides";

type AdditionalProps = {
exchangeId: BigNumberish;
Expand All @@ -20,7 +20,9 @@ export const CancelButton = ({
exchangeId,
...restProps
}: ICancelButton) => {
const coreSdk = useCoreSdk(restProps.coreSdkConfig);
const coreSdk = useCoreSdkOverrides({
coreSdkConfig: restProps.coreSdkConfig
});

const actions = [
{
Expand Down
Loading
Loading