Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@nftx/subgraph
Advanced tools
This library contains a few helpers for querying and fetching from the subgraph
Our subgraph urls can be found at @nftx/constants
(s: string) => string;
"Processes" a graphql string. Under the hood this function does nothing :D but most IDEs and editors like VSCode recognize and provide syntax highlighting when they see gql
calls.
const query = gql`
{
vaults {
id
vaultId
}
}
`;
<T>({
url: string,
query: string,
variables?: object
}): Promise<T>
Sends a graphql request to the subgraph.
This uses the global fetch api under the hood so if you're running in a non-browser environment (or aupporting older browsers), you'll need to polyfill fetch
When writing queries for querySubgraph
you can pass variables in by prefixing a name with $
.
For example:
const query = gql`{
vaults(
first: ${LIMIT}
where: {
createdAt_gt: $timestamp
}
) {
id
}
}`;
For this string, LIMIT
is inserted immediately, like a regular string interpoaltion. However $timestamp
will later be passed in as a variable into querySubgraph
:
querySubgraph({
url,
query,
variables: { timestamp },
});
Variables are all stringified so if you pass in a string, you don't need to wrap it in quotes:
const query = gql`
{
vault(id: $id) {
id
}
}
`;
querySubgraph({ url, query, variables: { id: '0x' } });
This would send a request with this query:
{
vault(id: "0x") {
id
}
}
(obj: object) => string;
This helper function lets you build a where clause string. Where a value is null, it filters it out.
const query = gql`{
vault(where: ${buildWhere({
id: idOrNull,
vaultId: vaultIdOrNull,
})}) {
id
}
}`;
0.1.1 (2022-12-16)
Note: Version bump only for package nftxjs
FAQs
This package contains utilities for interacting with subgraphs, built on top of `@nftx/query`
The npm package @nftx/subgraph receives a total of 5 weekly downloads. As such, @nftx/subgraph popularity was classified as not popular.
We found that @nftx/subgraph demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.