Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfolch-redeemeum committed Nov 30, 2023
1 parent f652c7f commit a117876
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 30 deletions.
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 @@ -96,6 +96,10 @@ export class CoreSDK extends BaseCoreSDK {
return this._web3Lib;
}

public get uuid() {
return this._uuid;
}

public checkMetaTxConfigSet(
args: {
contractAddress?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/core-sdk/src/mixins/base-core-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class BaseCoreSDK {
protected _metaTxConfig?: Partial<MetaTxConfig>;
protected _lens?: Lens;
protected _contracts?: ContractAddresses;
protected _uuid: string;
protected _getTxExplorerUrl?: (
txHash?: string,
isAddress?: boolean
Expand Down Expand Up @@ -50,6 +51,7 @@ export class BaseCoreSDK {
this._metaTxConfig = opts.metaTx;
this._lens = opts.lens;
this._contracts = opts.contracts;
this._uuid = crypto.randomUUID();
this._getTxExplorerUrl = opts.getTxExplorerUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,18 @@ import { DetailDisputeResolver } from "../../common/detail/DetailDisputeResolver
import Grid from "../../../../ui/Grid";
import VariationSelects from "../../common/VariationSelects";
import { VariantV1 } from "../../../../../types/variants";
import { breakpoint } from "../../../../../lib/ui/breakpoint";
const colors = theme.colors.light;

const StyledPrice = styled(Price)`
h3 {
font-size: 2rem;
}
small {
font-size: 1rem;
}
`;

const CommitButtonWrapper = styled.div<{
$pointerEvents: string;
disabled: boolean;
Expand All @@ -78,15 +88,22 @@ const CommitButtonWrapper = styled.div<{
pointer-events: ${({ $pointerEvents }) => $pointerEvents};
}
`;

const StyledPrice = styled(Price)`
h3 {
font-size: 2rem;
const CommitWrapper = styled(Grid)`
flex-direction: column;
column-gap: 1rem;
align-items: flex-start;
${breakpoint.m} {
flex-direction: row;
}
small {
font-size: 1rem;
`;

const ResponsiveVariationSelects = styled(VariationSelects)`
flex-direction: column;
${breakpoint.m} {
flex-direction: row;
}
`;

type ActionName = "approveExchangeToken" | "depositFunds" | "commit";

const getOfferDetailData = ({
Expand Down Expand Up @@ -194,41 +211,41 @@ const getOfferDetailData = ({
<Typography tag="h6">
<b>Exchange policy</b>
</Typography>
<Typography tag="p">
<p>
The Exchange policy ensures that the terms of sale are set in a fair
way to protect both buyers and sellers.
</Typography>
</p>
</>
),
value: exchangePolicyCheckResult ? (
exchangePolicyCheckResult.isValid ? (
<Typography tag="p">
<p>
{exchangePolicyLabel + " "}
<ArrowSquareOut
size={20}
onClick={() => handleShowExchangePolicy()}
style={{ cursor: "pointer" }}
/>
</Typography>
</p>
) : (
<Typography tag="p" color={colors.orange}>
<p style={{ color: colors.orange }}>
<WarningCircle size={20}></WarningCircle> Non-standard{" "}
<ArrowSquareOut
size={20}
onClick={() => handleShowExchangePolicy()}
style={{ cursor: "pointer" }}
/>
</Typography>
</p>
)
) : (
<Typography tag="p" color="purple">
<p style={{ color: "purple" }}>
<CircleWavyQuestion size={20}></CircleWavyQuestion> Unknown{" "}
<ArrowSquareOut
size={20}
onClick={() => handleShowExchangePolicy()}
style={{ cursor: "pointer" }}
/>
</Typography>
</p>
)
},
{
Expand Down Expand Up @@ -558,7 +575,7 @@ const DetailView: React.FC<IDetailWidget> = ({
isBuyerInsufficientFunds ||
(offer.condition && !isConditionMet);
const hasVariations = !!selectedVariant.variations?.length;

console.log("allVariants", allVariants);
return (
<Widget>
<div>
Expand Down Expand Up @@ -592,7 +609,7 @@ const DetailView: React.FC<IDetailWidget> = ({
<div
style={{ width: "100%", marginTop: "0.5rem", marginBottom: "1rem" }}
>
<VariationSelects
<ResponsiveVariationSelects
selectedVariant={selectedVariant}
variants={allVariants}
disabled={allVariants.length < 2}
Expand Down Expand Up @@ -621,7 +638,7 @@ const DetailView: React.FC<IDetailWidget> = ({
/>
</div>
<Break />
<Grid gap="1rem" justifyContent="space-between" margin="1rem 0">
<CommitWrapper justifyContent="space-between" margin="1rem 0">
<CommitButtonWrapper
disabled={!!isCommitDisabled}
role="button"
Expand Down Expand Up @@ -685,7 +702,7 @@ const DetailView: React.FC<IDetailWidget> = ({
</span>
.
</Typography>
</Grid>
</CommitWrapper>
</Widget>
);
};
Expand Down
3 changes: 0 additions & 3 deletions packages/react-kit/src/hooks/core-sdk/types.ts

This file was deleted.

13 changes: 4 additions & 9 deletions packages/react-kit/src/hooks/core-sdk/useCoreSdkWithContext.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { providers } from "ethers";
import { getEnvConfigById, hooks } from "../..";
import { CoreSDK, getEnvConfigById, hooks } from "../..";
import { useEnvContext } from "../../components/environment/EnvironmentContext";
import { Token } from "../../components/widgets/finance/convertion-rate/ConvertionRateContext";
import { useSigner } from "../connection/connection";
import { useMemo } from "react";
import { useExternalSigner } from "../../components/signer/useExternalSigner";
import { ExtendedCoreSDK } from "./types";

export function useCoreSDKWithContext(): ExtendedCoreSDK {
export function useCoreSDKWithContext(): CoreSDK {
const { envName, configId, metaTx } = useEnvContext();
const externalSigner = useExternalSigner();
const signer = useSigner();
const defaultConfig = getEnvConfigById(envName, configId);
const overrides = useMemo(() => {
return externalSigner ? { web3Lib: externalSigner } : undefined;
}, [externalSigner]);
const coreSDK = hooks.useCoreSdk(
return hooks.useCoreSdk(
{
envName,
configId,
Expand All @@ -31,11 +30,7 @@ export function useCoreSDKWithContext(): ExtendedCoreSDK {
}
},
overrides
) as ExtendedCoreSDK;
if (!coreSDK.uuid) {
coreSDK.uuid = crypto.randomUUID();
}
return coreSDK;
);
}

function getMetaTxApiIds(
Expand Down

0 comments on commit a117876

Please sign in to comment.