Skip to content

Commit

Permalink
Add npm workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed May 4, 2022
1 parent 49f3218 commit c5077c1
Show file tree
Hide file tree
Showing 4 changed files with 3,823 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ vendor/
*.db
dipdup.yml

dist/
dist/
node_modules/
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,60 @@ Metadata indexer reuses `datasources`, `contracts`, `database`, `hasura` section

Read more [in the docs](https://docs.dipdup.net/plugins/metadata).

## GQL client

### Installation

```
npm i @dipdup/metadata
```

### Usage

First of all you need to create an instance of metadata client:
```js
import { createClient } from '@dipdup/metadata'

const client = createClient({
url: 'http://metadata.dipdup.net/v1/graphql',
subscription: {
url: "wss://metadata.dipdup.net/v1/graphql"
}
});
```

#### Query

```js
import { everything } from '@dipdup/metadata'

client.chain.query
.token_metadata({
where: {
contract: { _eq: 'KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton' },
token_id: { _eq: 100000 }
}
})
.get({ ...everything })
.then(res => console.log)
```

#### Subscription (live query)

```js
const { unsubscribe } = client.chain.subscription
.token_metadata({
where: {
contract: { _eq: 'KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton' },
created_at: { _gt: '2021-07-06T00:00:00' }
}
})
.get({ ...everything })
.subscribe({
next: res => console.log
})
```

## Maintenance

### Refetch recent metadata
Expand Down
Loading

0 comments on commit c5077c1

Please sign in to comment.