kopia lustrzana https://github.com/bugout-dev/moonstream
rodzic
9e6fa856bb
commit
8ed8719a51
|
@ -10,6 +10,8 @@ from . import data
|
|||
from .routes.subscriptions import app as subscriptions_api
|
||||
from .routes.users import app as users_api
|
||||
from .routes.txinfo import app as txinfo_api
|
||||
from .routes.streams import app as streams_api
|
||||
|
||||
from .settings import ORIGINS
|
||||
from .version import MOONSTREAM_VERSION
|
||||
|
||||
|
@ -39,4 +41,4 @@ async def version_handler() -> data.VersionResponse:
|
|||
|
||||
app.mount("/subscriptions", subscriptions_api)
|
||||
app.mount("/users", users_api)
|
||||
app.mount("/txinfo", txinfo_api)
|
||||
app.mount("/streams", streams_api)
|
||||
|
|
|
@ -70,7 +70,7 @@ class SubscriptionResponse(BaseModel):
|
|||
|
||||
|
||||
class SubscriptionsListResponse(BaseModel):
|
||||
subscriptions: List[SubscriptionResponse] = Field(default_factory=list)
|
||||
subscriptions: List[SubscriptionResourceData] = Field(default_factory=list)
|
||||
|
||||
|
||||
class EVMFunctionSignature(BaseModel):
|
||||
|
@ -100,6 +100,22 @@ class EthereumTransaction(BaseModel):
|
|||
input: Optional[str] = None
|
||||
|
||||
|
||||
class EthereumTransactionItem(BaseModel):
|
||||
from_label: Optional[str] = "from_label"
|
||||
to_label: Optional[str] = "to_label"
|
||||
gas: int
|
||||
gasPrice: int
|
||||
value: int
|
||||
from_address: Optional[str] # = Field(alias="from")
|
||||
to_address: Optional[str] # = Field(default=None, alias="to")
|
||||
hash: Optional[str] = None
|
||||
input: Optional[str] = None
|
||||
|
||||
|
||||
class EthereumTransactionResponse(BaseModel):
|
||||
stream: List[EthereumTransactionItem]
|
||||
|
||||
|
||||
class TxinfoEthereumBlockchainRequest(BaseModel):
|
||||
tx: EthereumTransaction
|
||||
|
||||
|
@ -108,4 +124,3 @@ class TxinfoEthereumBlockchainResponse(BaseModel):
|
|||
tx: EthereumTransaction
|
||||
abi: Optional[ContractABI] = None
|
||||
errors: List[str] = Field(default_factory=list)
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ const FILTER_TYPES = {
|
|||
HASH: 4,
|
||||
DISABLED: 99,
|
||||
};
|
||||
const DIRECTIONS = { SOURCE: 0, DESTINATION: 1 };
|
||||
const DIRECTIONS = { SOURCE: "from", DESTINATION: "to" };
|
||||
const CONDITION = {
|
||||
EQUAL: 0,
|
||||
CONTAINS: 1,
|
||||
|
@ -68,10 +68,11 @@ const EntriesNavigation = () => {
|
|||
const [filterState, setFilterState] = useState([]);
|
||||
|
||||
const setNewFilterState = (props) => {
|
||||
console.log(subscriptionsCache.data.subscriptions);
|
||||
console.log(
|
||||
"setNewFilterState",
|
||||
props,
|
||||
subscriptionsCache.data.subscriptions[0].id
|
||||
subscriptionsCache.data.subscriptions[0].address
|
||||
);
|
||||
_setNewFilterState(props);
|
||||
};
|
||||
|
@ -126,20 +127,44 @@ const EntriesNavigation = () => {
|
|||
const canDelete = false;
|
||||
|
||||
const dropNewFilterArrayItem = (idx) => {
|
||||
const newArray = [...newFilterState];
|
||||
delete newArray[idx];
|
||||
const oldArray = [...newFilterState];
|
||||
|
||||
const newArray = oldArray.filter(function (ele) {
|
||||
return ele != oldArray[idx];
|
||||
});
|
||||
console.log(newFilterState);
|
||||
console.log(newArray);
|
||||
setNewFilterState(newArray);
|
||||
};
|
||||
|
||||
const dropFilterArrayItem = (idx) => {
|
||||
console.log("dropFilterArrayItem", idx, filterState);
|
||||
const newArray = [...filterState];
|
||||
newArray[idx].type = FILTER_TYPES.DISABLED;
|
||||
const oldArray = [...filterState];
|
||||
//newArray[idx].type = FILTER_TYPES.DISABLED;
|
||||
const newArray = oldArray.filter(function (ele) {
|
||||
return ele != oldArray[idx];
|
||||
});
|
||||
|
||||
setFilterState(newArray);
|
||||
setNewFilterState(newArray);
|
||||
ui.setSearchTerm(
|
||||
newArray
|
||||
.map((filter) => {
|
||||
return filter.direction + ":" + filter.value;
|
||||
})
|
||||
.join("+")
|
||||
);
|
||||
};
|
||||
|
||||
const handleFilterSubmit = () => {
|
||||
setFilterState(newFilterState);
|
||||
ui.setSearchTerm(
|
||||
newFilterState
|
||||
.map((filter) => {
|
||||
return filter.direction + ":" + filter.value;
|
||||
})
|
||||
.join("+")
|
||||
);
|
||||
onClose();
|
||||
};
|
||||
|
||||
|
@ -159,7 +184,7 @@ const EntriesNavigation = () => {
|
|||
setFilterState(newFilterState);
|
||||
};
|
||||
if (subscriptionsCache.isLoading) return "";
|
||||
console.log("filterstate test", filterState);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
id="JournalNavigation"
|
||||
|
@ -181,6 +206,7 @@ const EntriesNavigation = () => {
|
|||
Source:
|
||||
</Text>
|
||||
{newFilterState.map((filter, idx) => {
|
||||
console.log("197", newFilterState);
|
||||
if (filter.type === FILTER_TYPES.DISABLED) return "";
|
||||
return (
|
||||
<Flex
|
||||
|
@ -242,15 +268,33 @@ const EntriesNavigation = () => {
|
|||
</Select>
|
||||
)}
|
||||
{filter.direction === DIRECTIONS.DESTINATION && (
|
||||
<Input
|
||||
type="text"
|
||||
onChange={(e) =>
|
||||
setFilterProps(idx, {
|
||||
value: e.target.value,
|
||||
})
|
||||
<Select
|
||||
variant="solid"
|
||||
colorScheme="primary"
|
||||
name="address"
|
||||
onChange={handleAddressChange(idx)}
|
||||
>
|
||||
{!subscriptionsCache.isLoading &&
|
||||
subscriptionsCache.data.subscriptions.map(
|
||||
(subscription, idx) => {
|
||||
return (
|
||||
<option
|
||||
value={subscription.address}
|
||||
key={`subscription-filter-item-${idx}`}
|
||||
>
|
||||
{`${
|
||||
subscription.label
|
||||
} - ${subscription.address.slice(
|
||||
0,
|
||||
5
|
||||
)}...${subscription.address.slice(
|
||||
-3
|
||||
)}`}
|
||||
</option>
|
||||
);
|
||||
}
|
||||
placeholder="Type in address"
|
||||
/>
|
||||
)}
|
||||
</Select>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
@ -284,7 +328,8 @@ const EntriesNavigation = () => {
|
|||
type: FILTER_TYPES.ADDRESS,
|
||||
direction: DIRECTIONS.SOURCE,
|
||||
condition: CONDITION.EQUAL,
|
||||
value: subscriptionsCache.data.subscriptions[0].id,
|
||||
value:
|
||||
subscriptionsCache.data.subscriptions[0].address,
|
||||
},
|
||||
])
|
||||
}
|
||||
|
@ -299,7 +344,8 @@ const EntriesNavigation = () => {
|
|||
type: FILTER_TYPES.ADDRESS,
|
||||
direction: DIRECTIONS.DESTINATION,
|
||||
condition: CONDITION.EQUAL,
|
||||
value: null,
|
||||
value:
|
||||
subscriptionsCache.data.subscriptions[0].address,
|
||||
},
|
||||
])
|
||||
}
|
||||
|
|
|
@ -48,16 +48,13 @@ const StreamEntry = ({ entry, filterCallback, filterConstants }) => {
|
|||
filterCallback({
|
||||
direction: filterConstants.DIRECTIONS.SOURCE,
|
||||
type: filterConstants.FILTER_TYPES.ADDRESS,
|
||||
value: entry.from,
|
||||
value: entry.from_address,
|
||||
conditon: filterConstants.CONDITION.EQUAL,
|
||||
})
|
||||
}
|
||||
>
|
||||
{"From:"}
|
||||
{`${entry.from_label} - ${entry.from.slice(
|
||||
0,
|
||||
5
|
||||
)}...${entry.from.slice(-3, -1)}`}
|
||||
{`${entry.from_label} - ${entry.from_address}`}
|
||||
</Tag>{" "}
|
||||
<Tag
|
||||
alignSelf="center"
|
||||
|
@ -67,16 +64,13 @@ const StreamEntry = ({ entry, filterCallback, filterConstants }) => {
|
|||
filterCallback({
|
||||
direction: filterConstants.DIRECTIONS.DESTINATION,
|
||||
type: filterConstants.FILTER_TYPES.ADDRESS,
|
||||
value: entry.to,
|
||||
value: entry.to_address,
|
||||
conditon: filterConstants.CONDITION.EQUAL,
|
||||
})
|
||||
}
|
||||
>
|
||||
{"To:"}
|
||||
{`${entry.to_label} - ${entry.to.slice(0, 5)}...${entry.to.slice(
|
||||
-3,
|
||||
-1
|
||||
)}`}
|
||||
{`${entry.to_label} - ${entry.to_address}`}
|
||||
</Tag>{" "}
|
||||
<Tag alignSelf="center" colorScheme="secondary" variant="subtle">
|
||||
Gas Price: {entry.gasPrice}
|
||||
|
|
|
@ -6,7 +6,7 @@ const API = process.env.NEXT_PUBLIC_MOONSTREAM_API_URL;
|
|||
export const getStream = ({ searchTerm, limit, offset, isContent }) =>
|
||||
http({
|
||||
method: "GET",
|
||||
url: `${API}/stream`,
|
||||
url: `${API}/streams/`,
|
||||
params: {
|
||||
q: searchTerm,
|
||||
limit: encodeURIComponent(limit),
|
||||
|
|
Ładowanie…
Reference in New Issue