Skip to content

Commit

Permalink
Merge branch 'main' into feature/681-keychain-sdk-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
artur-abliazimov authored Sep 29, 2024
2 parents 99e2f73 + 0bb0e6a commit 09acfbe
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ To learn more, see the following:

## x/oracle

The `x/oracle` module is a Cosmos SDK module by **Skip Protocol** that enables storing prices on-chain in **Slinky** (an oracle service).
The `x/oracle` module is a Cosmos SDK module by **Skip Protocol** that enables storing prices on-chain in **Skip:Connect** (an oracle service).

To learn more, see the following:

- [Slinky documentation](https://docs.skip.money/slinky/overview)
- [Connect documentation](https://docs.skip.build/connect/introduction)
- [`x/oracle` on GitHub](https://github.com/skip-mev/slinky/tree/main/x/oracle)
- [Warden docs: Oracle services](/learn/oracle-services)

Expand Down
6 changes: 3 additions & 3 deletions docs/developer-docs/docs/operate-a-node/run-a-local-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ In the previous steps, you configured your node with the minimum settings requir
#### Create a Keychain
1. While the node is running, execute the command below in a separate terminal window. Specify a custom keychain description, your key name, and the chain ID:
1. While the node is running, execute the command below in a separate terminal window. Specify a custom keychain description, your key name and the chain ID:
```bash
wardend tx warden new-keychain \
Expand Down Expand Up @@ -279,7 +279,7 @@ In the previous steps, you configured your node with the minimum settings requir
#### Create a Space
1. To create a Space, run the following command. Specify your key name, and the chain ID:
1. To create a Space, run the following command. Specify your key name and the chain ID:
```bash
wardend tx warden new-space \
Expand All @@ -295,7 +295,7 @@ In the previous steps, you configured your node with the minimum settings requir
wardend query warden spaces
```
The output should look like this::
The output should look like this:
```bash
pagination:
Expand Down
82 changes: 58 additions & 24 deletions spaceward/src/features/actions/StatusSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from "clsx";
import { useContext, useEffect, useRef, useState } from "react";
import { isDeliverTxSuccess } from "@cosmjs/stargate";
import { DeliverTxResponse, isDeliverTxSuccess } from "@cosmjs/stargate";
import { useChain, walletContext } from "@cosmos-kit/react-lite";
import { cosmos, warden } from "@wardenprotocol/wardenjs";
import { Action, ActionStatus } from "@wardenprotocol/wardenjs/codegen/warden/act/v1beta1/action";
Expand Down Expand Up @@ -45,6 +45,21 @@ const waitForVisibility = () => {
});
};

class DetailedError<T> extends Error {
constructor(message: string, public detail: T) {
super(message);
}
}

function isDetailedError<T>(e?: unknown): e is DetailedError<T> {
if (!e) {
return false;
}

return "detail" in (e as {});
}


function ActionItem({ single, ...item }: ItemProps) {
const queryClient = useQueryClient();
const { walletManager } = useContext(walletContext);
Expand Down Expand Up @@ -88,32 +103,51 @@ function ActionItem({ single, ...item }: ItemProps) {
const signer = getOfflineSigner();
const client = await getSigningClient(signer);
const txRaw = cosmos.tx.v1beta1.TxRaw.encode(item.txRaw);
const res = await client.broadcastTx(Uint8Array.from(txRaw.finish()));
try {
const res = await client.broadcastTx(Uint8Array.from(txRaw.finish()));

if (isDeliverTxSuccess(res)) {
setData({
[item.id]: {
...item,
status: QueuedActionStatus.Broadcast,
response: res,
},
});
} else {
console.error("Failed to broadcast", res);
if (isDeliverTxSuccess(res)) {
setData({
[item.id]: {
...item,
status: QueuedActionStatus.Broadcast,
response: res,
},
});
} else {
console.error("Failed to broadcast", res);
throw new DetailedError("Could not broadcast transaction", res);

toast({
title: "Failed",
description: "Could not broadcast transaction",
duration: 10000,
});
}
} catch (e) {
if (isDetailedError<DeliverTxResponse>(e)) {
toast({
title: "Failed",
description: "Could not broadcast transaction",
duration: 10000,
});

setData({
[item.id]: {
...item,
status: QueuedActionStatus.Failed,
response: res,
},
});
setData({
[item.id]: {
...item,
status: QueuedActionStatus.Failed,
response: e.detail,
},
});
} else {
toast({
title: "Failed",
description: (e as Error)?.message ?? "Unexpected error",
duration: 10000,
});

setData({
[item.id]: {
...item,
status: QueuedActionStatus.Failed,
},
});
}
}

break;
Expand Down
13 changes: 8 additions & 5 deletions spaceward/src/lib/datetime.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Timestamp } from '@wardenprotocol/wardenjs/codegen/google/protobuf/timestamp';
import dayjs from 'dayjs';
import { Timestamp } from "@wardenprotocol/wardenjs/codegen/google/protobuf/timestamp";
import dayjs from "dayjs";

export const formatDateTime = (date: Timestamp) => {
return dayjs(timestampToDate(date)).format('DD/MM/YYYY HH:mm:ss');
}
return dayjs(timestampToDate(date)).format("DD/MM/YYYY HH:mm:ss");
};

export function timestampToDate(timestamp: Timestamp): Date {
return new Date(Number(timestamp.seconds) * 1000 + Number(timestamp.nanos) / 1000);
return new Date(
Number(timestamp.seconds) * 1000 +
Math.floor(Number(timestamp.nanos) / 1e6),
);
}

0 comments on commit 09acfbe

Please sign in to comment.