Skip to content

Commit

Permalink
Fix typo, PR feedback nit, unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
panieldark committed Nov 10, 2023
1 parent c4f60d3 commit 3b9a47d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Nocturne Snap",
"proposedName": "Nocturne Snap",
"source": {
"shasum": "Zw73RKC36CMTmgzSD5wWa0yxazNj1071ZA3KmG6I3EM=",
"shasum": "KmnIzT66SC5xSBAsy+khv0Arg0IZk7pEdhbt4mnHZZc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
28 changes: 9 additions & 19 deletions src/utils/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,13 @@ const makeFinalContent = (
items: { heading: string; messages: string[] }[]
): Panel => {
const formattedItems = items.flatMap((item, i) => {
if (i === 0) {
return [
heading(item.heading),
...item.messages.map((m) => {
const safeText = m.replace(NEWLINE_AND_CARRIAGE_RETURN_REGEX, ""); // Strip newlines and carriage returns to avoid injected malicious formatting
return text(safeText);
}),
];
}

return [
divider(),
...(i > 0 ? [divider()] : []),
heading(item.heading),
...item.messages.map((m) => {
const safeText = m.replace(NEWLINE_AND_CARRIAGE_RETURN_REGEX, ""); // Strip newlines and carriage returns to avoid injected malicious formatting
return text(safeText);
}),
})
];
});
return panel(formattedItems);
Expand All @@ -60,7 +50,7 @@ export const makeSignCanonAddrRegistryEntryContent = (
const messages = [
`Registering your canonical address gives your Ethereum account an address with which you
receive private payments.`,
`Your connected Ethereum address: **${entry.ethAddress}**`,
`Your connected Ethereum address: **${entry.ethAddress}**`
];

return makeFinalContent([{ heading, messages }]);
Expand All @@ -73,11 +63,11 @@ export const makeSignOperationContent = (
fee: bigint
): Panel => {
const headItem = {
heading: "Confirm transaction from our Nocturne account".replace(
heading: "Confirm transaction from your Nocturne account".replace(
NEWLINE_AND_CARRIAGE_RETURN_REGEX,
""
),
messages: [],
messages: []
};

const actionItems = opMetadata.items.map((item) => {
Expand All @@ -94,7 +84,7 @@ export const makeSignOperationContent = (
const {
amount: amountSmallestUnits,
recipientAddress,
erc20Address,
erc20Address
} = item;
const ticker = lookupTickerByAddress(erc20Address, erc20s);
const displayAmount = formatUnits(amountSmallestUnits);
Expand Down Expand Up @@ -127,7 +117,7 @@ export const makeSignOperationContent = (
tokenOut,
maxSlippageBps,
exactQuoteWei,
minimumAmountOutWei,
minimumAmountOutWei
} = item;
const tickerIn = lookupTickerByAddress(tokenIn, erc20s);
const tickerOut = lookupTickerByAddress(tokenOut, erc20s);
Expand Down Expand Up @@ -168,7 +158,7 @@ export const makeSignOperationContent = (
heading,
messages: messages.map(
(m) => m.replace(NEWLINE_AND_CARRIAGE_RETURN_REGEX, "") // Strip newlines and carriage returns
),
)
};
});

Expand Down Expand Up @@ -196,7 +186,7 @@ export const makeSignOperationContent = (
heading: gasItemHeader,
messages: gasItemMessages.map((m) =>
m.replace(NEWLINE_AND_CARRIAGE_RETURN_REGEX, "")
),
)
};

return makeFinalContent([headItem, ...actionItems, gasItem]);
Expand Down
3 changes: 2 additions & 1 deletion src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

export const UndefinedType = define(
"Undefined",
(value) => value === undefined
(value) => value === undefined,
);

const isDataHexString32 = (value: any) =>
Expand Down Expand Up @@ -182,6 +182,7 @@ const UniswapV3SwapActionMetadataType = object({
maxSlippageBps: number(),
exactQuoteWei: bigint(),
minimumAmountOutWei: bigint(),
gasFeeEstimate: bigint(),
});

const ActionMetadataType = union([
Expand Down
1 change: 1 addition & 0 deletions test/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ it("validates SignOperationParams", () => {
maxSlippageBps: 50,
exactQuoteWei: 1234n,
minimumAmountOutWei: 1234n,
gasFeeEstimate: 1n,
},
],
},
Expand Down

0 comments on commit 3b9a47d

Please sign in to comment.