Adapt codebase to CosmJS/cosmjs-types changes
This commit is contained in:
@@ -9,7 +9,7 @@ interface TxMsgCreateVestingAccountDetailsProps {
|
||||
|
||||
const TxMsgCreateVestingAccountDetails = ({ msgValue }: TxMsgCreateVestingAccountDetailsProps) => {
|
||||
const { chain } = useChains();
|
||||
const endTimeDateObj = new Date(msgValue.endTime.multiply(1000).toNumber());
|
||||
const endTimeDateObj = new Date(Number(msgValue.endTime * 1000n));
|
||||
const endTimeDate = endTimeDateObj.toLocaleDateString();
|
||||
const endTimeHours = endTimeDateObj.toLocaleTimeString().slice(0, -3);
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ const TxMsgTransferDetails = ({ msgValue }: TxMsgTransferDetailsProps) => {
|
||||
msgValue.token,
|
||||
"Token must be set, same as https://github.com/osmosis-labs/telescope/issues/386",
|
||||
);
|
||||
const timeoutDateObj = new Date(msgValue.timeoutTimestamp.divide(1_000_000).toNumber());
|
||||
const timeoutMilis = Number(msgValue.timeoutTimestamp / 1_000_000n);
|
||||
const timeoutDateObj = new Date(timeoutMilis);
|
||||
const timeoutDate = timeoutDateObj.toLocaleDateString();
|
||||
const timeoutTime = timeoutDateObj.toLocaleTimeString();
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ const MsgCreateVestingAccountForm = ({
|
||||
return false;
|
||||
}
|
||||
|
||||
const timeoutDate = new Date(timestampFromDatetimeLocal(endTime).toNumber());
|
||||
const timeoutDate = new Date(Number(timestampFromDatetimeLocal(endTime, "ms")));
|
||||
if (timeoutDate <= new Date()) {
|
||||
setEndTimeError("End time must be a date in the future");
|
||||
return false;
|
||||
|
||||
@@ -149,7 +149,7 @@ const MsgInstantiateContract2Form = ({
|
||||
|
||||
const msgValue = MsgCodecs[MsgTypeUrls.Instantiate2].fromPartial({
|
||||
sender: fromAddress,
|
||||
codeId: codeId || 0,
|
||||
codeId: BigInt(codeId),
|
||||
label,
|
||||
admin: adminAddress,
|
||||
fixMsg: false,
|
||||
|
||||
@@ -127,7 +127,7 @@ const MsgInstantiateContractForm = ({
|
||||
|
||||
const msgValue = MsgCodecs[MsgTypeUrls.Instantiate].fromPartial({
|
||||
sender: fromAddress,
|
||||
codeId: codeId || 1,
|
||||
codeId: BigInt(codeId),
|
||||
label,
|
||||
admin: adminAddress,
|
||||
msg: msgContentUtf8Array,
|
||||
|
||||
@@ -72,7 +72,7 @@ const MsgMigrateContractForm = ({
|
||||
const msgValue = MsgCodecs[MsgTypeUrls.Migrate].fromPartial({
|
||||
sender: fromAddress,
|
||||
contract: contractAddress,
|
||||
codeId: codeId || 1,
|
||||
codeId: BigInt(codeId),
|
||||
msg: msgContentUtf8Array,
|
||||
});
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ const MsgTransferForm = ({ fromAddress, setMsgGetter, deleteMsg }: MsgTransferFo
|
||||
return false;
|
||||
}
|
||||
|
||||
const timeoutDate = new Date(timestampFromDatetimeLocal(timeout).toNumber());
|
||||
const timeoutDate = new Date(Number(timestampFromDatetimeLocal(timeout, "ms")));
|
||||
if (timeoutDate <= new Date()) {
|
||||
setTimeoutError("Timeout must be a date in the future");
|
||||
return false;
|
||||
|
||||
+8
-8
@@ -1,9 +1,7 @@
|
||||
import Long from "long";
|
||||
|
||||
export const timestampFromDatetimeLocal = (
|
||||
datetimeLocal: string,
|
||||
units?: "s" | "ms" | "ns",
|
||||
): Long => {
|
||||
units: "s" | "ms" | "ns",
|
||||
): bigint => {
|
||||
const [date, time] = datetimeLocal.split("T");
|
||||
const [year, month, day] = date.split("-");
|
||||
const [hours, minutes] = time.split(":");
|
||||
@@ -16,15 +14,17 @@ export const timestampFromDatetimeLocal = (
|
||||
Number(minutes),
|
||||
);
|
||||
|
||||
const timestampMillis = Long.fromNumber(dateObj.getTime());
|
||||
const timestampMillis = BigInt(dateObj.getTime());
|
||||
|
||||
switch (units) {
|
||||
case "s":
|
||||
return timestampMillis.divide(1000); // seconds
|
||||
return timestampMillis / 1000n; // seconds
|
||||
case "ns":
|
||||
return timestampMillis.multiply(1000_000); // nanoseconds
|
||||
default:
|
||||
return timestampMillis * 1000_000n; // nanoseconds
|
||||
case "ms":
|
||||
return timestampMillis; // milliseconds
|
||||
default:
|
||||
throw new Error("Unexpected unit value");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user