Skip to content

Commit

Permalink
fixed orderSchema for protocolFee and jsonDisplayData for protocolFee
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestarrdev committed May 10, 2024
1 parent 5cb0f9e commit 668ec11
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function App() {
let senderWallet;
let senderToken;
let senderAmount;
let userProtocolFee;

const validSchema = schemaValidationResult.success;

Expand All @@ -97,6 +98,7 @@ function App() {
senderWallet = order?.senderWallet;
senderToken = order?.senderToken;
senderAmount = order?.senderAmount;
userProtocolFee = order?.protocolFee;
}

const handleTextChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
Expand Down Expand Up @@ -141,6 +143,7 @@ function App() {
protocolFeeFormatted={
Number(protocolFeeFromJson) || protocolFeeFormatted
}
userProtocolFee={userProtocolFee}
nonce={nonce}
expiry={expiry}
signerWallet={signerWallet}
Expand Down
10 changes: 10 additions & 0 deletions src/features/ui/jsonDataDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const JsonDataDisplay = ({
domainName,
domainVersion,
protocolFeeFormatted,
userProtocolFee,
nonce,
expiry,
signerWallet,
Expand All @@ -26,6 +27,7 @@ export const JsonDataDisplay = ({
domainName: string | undefined;
domainVersion: string | undefined;
protocolFeeFormatted: number | undefined;
userProtocolFee?: string | undefined;
nonce: number | undefined;
expiry: number | undefined;
signerWallet: string | undefined;
Expand Down Expand Up @@ -91,6 +93,14 @@ export const JsonDataDisplay = ({
</div>
<div className="text-textDark font-medium">signerAmount</div>
<div>{signerAmountFormatted}</div>

{userProtocolFee && (
<>
<div className="text-textDark font-medium">protocolFee</div>
<div>{userProtocolFee}</div>
</>
)}

<div className="text-textDark font-medium">senderWallet</div>
<div>
<ExplorerUrl jsonData={senderWallet} />
Expand Down
17 changes: 0 additions & 17 deletions src/hooks/useSetChainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ type Order =
[x: string]: any;
}
| undefined;
// | {
// nonce: number;
// signerWallet: string;
// senderWallet: string | null;
// expiry: number;
// signerToken: string;
// signerAmount: string;
// senderToken: string;
// senderAmount: string;
// v: number;
// r: string;
// s: string;
// chainId?: number | undefined;
// swapContract?: string | undefined;
// protocolFee?: number | undefined;
// }
// | undefined;

export const useSetChainId = ({
order,
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useValidateOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const useValidateOrder = ({
}
}

console.log(_order);
// Check if the parsed order is valid.
const schemaWithExpectedFee = signedOrderSchema(protocolFee);

Expand Down
3 changes: 2 additions & 1 deletion src/utils/orderSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const signedOrderSchema = (expectedProtocolFee?: number | undefined) => {
if (expectedProtocolFee) {
schemaConfig.protocolFee = z.coerce
.number()
.pipe(z.literal(expectedProtocolFee).optional());
.pipe(z.literal(expectedProtocolFee))
.optional();
}

return z.object(schemaConfig);
Expand Down

0 comments on commit 668ec11

Please sign in to comment.