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