@ledgerhq/evm-tools
Advanced tools
Comparing version
# @ledgerhq/evm-tools | ||
## 1.5.0-next.2 | ||
### Minor Changes | ||
- [#9158](https://github.com/LedgerHQ/ledger-live/pull/9158) [`7931e5f`](https://github.com/LedgerHQ/ledger-live/commit/7931e5f6bf379eee7b80f5a95f13b6e96140ac5a) Thanks [@Canestin](https://github.com/Canestin)! - change uniswap signmessage modal | ||
### Patch Changes | ||
- Updated dependencies [[`1461449`](https://github.com/LedgerHQ/ledger-live/commit/146144941c13e60182da8d79592f706d12a6f00e), [`bdfa413`](https://github.com/LedgerHQ/ledger-live/commit/bdfa4139fcbceabfd05a57e69b05e9ccf10efbe1)]: | ||
- @ledgerhq/live-env@2.6.0-next.2 | ||
- @ledgerhq/cryptoassets-evm-signatures@13.5.4-next.2 | ||
## 1.5.0-nightly.1 | ||
### Minor Changes | ||
- [#9158](https://github.com/LedgerHQ/ledger-live/pull/9158) [`7931e5f`](https://github.com/LedgerHQ/ledger-live/commit/7931e5f6bf379eee7b80f5a95f13b6e96140ac5a) Thanks [@Canestin](https://github.com/Canestin)! - change uniswap signmessage modal | ||
### Patch Changes | ||
- Updated dependencies [[`bdfa413`](https://github.com/LedgerHQ/ledger-live/commit/bdfa4139fcbceabfd05a57e69b05e9ccf10efbe1)]: | ||
- @ledgerhq/live-env@2.6.0-nightly.1 | ||
- @ledgerhq/cryptoassets-evm-signatures@13.5.4-nightly.1 | ||
## 1.4.1-nightly.0 | ||
@@ -4,0 +28,0 @@ |
@@ -116,2 +116,21 @@ import axios from "axios"; | ||
}; | ||
function formatDate(timestamp) { | ||
const date = new Date(Number(timestamp) * 1000); | ||
if (isNaN(date.getTime())) { | ||
return timestamp; | ||
} | ||
const formatter = new Intl.DateTimeFormat("en-GB", { | ||
year: "numeric", | ||
month: "2-digit", | ||
day: "2-digit", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit", | ||
timeZone: "UTC", | ||
hour12: false, | ||
}); | ||
const parts = formatter.formatToParts(date); | ||
const p = (type) => parts.find(p => p.type === type)?.value || "00"; | ||
return `${p("year")}-${p("month")}-${p("day")} ${p("hour")}:${p("minute")}:${p("second")} UTC`; | ||
} | ||
/** | ||
@@ -173,10 +192,34 @@ * Gets the fields visible on the nano for a specific EIP712 message | ||
} | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
if (messageData.primaryType === "PermitSingle") { | ||
for (const field of fields) { | ||
if (field.path.includes("token")) { | ||
displayedInfos.push({ | ||
label: "Token", | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} | ||
else if (field.path.includes("amount")) { | ||
displayedInfos.push({ | ||
label: "Amount", | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} | ||
else if (field.path.includes("expiration")) { | ||
displayedInfos.push({ | ||
label: "Approval expires", | ||
value: formatDate(getValueFromPath(field.path, messageData)), | ||
}); | ||
} | ||
} | ||
} | ||
else { | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} | ||
} | ||
return displayedInfos; | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -127,2 +127,21 @@ "use strict"; | ||
exports.getValueFromPath = getValueFromPath; | ||
function formatDate(timestamp) { | ||
const date = new Date(Number(timestamp) * 1000); | ||
if (isNaN(date.getTime())) { | ||
return timestamp; | ||
} | ||
const formatter = new Intl.DateTimeFormat("en-GB", { | ||
year: "numeric", | ||
month: "2-digit", | ||
day: "2-digit", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit", | ||
timeZone: "UTC", | ||
hour12: false, | ||
}); | ||
const parts = formatter.formatToParts(date); | ||
const p = (type) => parts.find(p => p.type === type)?.value || "00"; | ||
return `${p("year")}-${p("month")}-${p("day")} ${p("hour")}:${p("minute")}:${p("second")} UTC`; | ||
} | ||
/** | ||
@@ -184,8 +203,32 @@ * Gets the fields visible on the nano for a specific EIP712 message | ||
} | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: (0, exports.getValueFromPath)(field.path, messageData), | ||
}); | ||
if (messageData.primaryType === "PermitSingle") { | ||
for (const field of fields) { | ||
if (field.path.includes("token")) { | ||
displayedInfos.push({ | ||
label: "Token", | ||
value: (0, exports.getValueFromPath)(field.path, messageData), | ||
}); | ||
} | ||
else if (field.path.includes("amount")) { | ||
displayedInfos.push({ | ||
label: "Amount", | ||
value: (0, exports.getValueFromPath)(field.path, messageData), | ||
}); | ||
} | ||
else if (field.path.includes("expiration")) { | ||
displayedInfos.push({ | ||
label: "Approval expires", | ||
value: formatDate((0, exports.getValueFromPath)(field.path, messageData)), | ||
}); | ||
} | ||
} | ||
} | ||
else { | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: (0, exports.getValueFromPath)(field.path, messageData), | ||
}); | ||
} | ||
} | ||
return displayedInfos; | ||
@@ -192,0 +235,0 @@ }; |
{ | ||
"name": "@ledgerhq/evm-tools", | ||
"version": "1.4.1-nightly.0", | ||
"version": "1.5.0-next.2", | ||
"description": "EVM tooling used for coin integrations & app bindings", | ||
@@ -52,4 +52,4 @@ "main": "./index.ts", | ||
"crypto-js": "4.2.0", | ||
"@ledgerhq/cryptoassets-evm-signatures": "^13.5.4-nightly.0", | ||
"@ledgerhq/live-env": "^2.6.0-nightly.0" | ||
"@ledgerhq/cryptoassets-evm-signatures": "^13.5.4-next.2", | ||
"@ledgerhq/live-env": "^2.6.0-next.2" | ||
}, | ||
@@ -63,3 +63,3 @@ "devDependencies": { | ||
"ts-jest": "^29.1.1", | ||
"@ledgerhq/types-live": "^6.60.0" | ||
"@ledgerhq/types-live": "^6.61.0-next.1" | ||
}, | ||
@@ -66,0 +66,0 @@ "scripts": { |
@@ -151,2 +151,26 @@ import axios from "axios"; | ||
function formatDate(timestamp: string) { | ||
const date = new Date(Number(timestamp) * 1000); | ||
if (isNaN(date.getTime())) { | ||
return timestamp; | ||
} | ||
const formatter = new Intl.DateTimeFormat("en-GB", { | ||
year: "numeric", | ||
month: "2-digit", | ||
day: "2-digit", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit", | ||
timeZone: "UTC", | ||
hour12: false, | ||
}); | ||
const parts = formatter.formatToParts(date); | ||
const p = (type: string) => parts.find(p => p.type === type)?.value || "00"; | ||
return `${p("year")}-${p("month")}-${p("day")} ${p("hour")}:${p("minute")}:${p("second")} UTC`; | ||
} | ||
/** | ||
@@ -162,3 +186,2 @@ * Gets the fields visible on the nano for a specific EIP712 message | ||
} | ||
const { EIP712Domain, ...otherTypes } = messageData.types; | ||
@@ -223,7 +246,28 @@ const displayedInfos: { label: string; value: string | string[] }[] = []; | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
if (messageData.primaryType === "PermitSingle") { | ||
for (const field of fields) { | ||
if (field.path.includes("token")) { | ||
displayedInfos.push({ | ||
label: "Token", | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} else if (field.path.includes("amount")) { | ||
displayedInfos.push({ | ||
label: "Amount", | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} else if (field.path.includes("expiration")) { | ||
displayedInfos.push({ | ||
label: "Approval expires", | ||
value: formatDate(getValueFromPath(field.path, messageData) as string), | ||
}); | ||
} | ||
} | ||
} else { | ||
for (const field of fields) { | ||
displayedInfos.push({ | ||
label: field.label, | ||
value: getValueFromPath(field.path, messageData), | ||
}); | ||
} | ||
} | ||
@@ -230,0 +274,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
147152
6.21%2200
6.08%