Skip to content

Commit

Permalink
add indexergw package
Browse files Browse the repository at this point in the history
  • Loading branch information
xiam committed Dec 4, 2024
1 parent eefdc96 commit 70e0573
Show file tree
Hide file tree
Showing 5 changed files with 1,431 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/indexergw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @0xsequence/indexergw

## 1.0.0

### Initial Release

- Initial release of the Indexer Gateway
4 changes: 4 additions & 0 deletions packages/indexergw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@0xsequence/indexer
===================

See [0xsequence project page](https://github.com/0xsequence/sequence.js).
22 changes: 22 additions & 0 deletions packages/indexergw/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@0xsequence/indexergw",
"version": "2.1.6",
"description": "indexergw sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexergw",
"source": "src/index.ts",
"main": "dist/0xsequence-indexergw.cjs.js",
"module": "dist/0xsequence-indexergw.esm.js",
"author": "Horizon Blockchain Games",
"license": "Apache-2.0",
"scripts": {
"test": "echo",
"typecheck": "tsc --noEmit"
},
"dependencies": {},
"peerDependencies": {},
"devDependencies": {},
"files": [
"src",
"dist"
]
}
23 changes: 23 additions & 0 deletions packages/indexergw/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export * from './indexergw.gen'

import { IndexerGateway as IndexerGatewayRpc } from './indexergw.gen'

const fetch = globalThis.fetch

export class SequenceIndexerGateway extends IndexerGatewayRpc {
constructor(
hostname: string,
) {
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
this.fetch = this._fetch
}

_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
// no additional headers for now, but we might add some later
const headers: { [key: string]: any } = {}

init!.headers = { ...init!.headers, ...headers }

return fetch(input, init)
}
}
Loading

0 comments on commit 70e0573

Please sign in to comment.