2021-07-01 11:12:37 +00:00
|
|
|
import assert from 'assert';
|
|
|
|
import BigInt from 'apollo-type-bigint';
|
|
|
|
import debug from 'debug';
|
|
|
|
|
2021-07-05 10:45:54 +00:00
|
|
|
import { Indexer } from './indexer';
|
2021-07-01 11:12:37 +00:00
|
|
|
|
|
|
|
const log = debug('vulcanize:resolver');
|
|
|
|
|
|
|
|
export const createResolvers = async (indexer: Indexer): Promise<any> => {
|
|
|
|
assert(indexer);
|
|
|
|
|
|
|
|
return {
|
|
|
|
BigInt: new BigInt('bigInt'),
|
|
|
|
|
|
|
|
ERC20Event: {
|
2021-07-05 10:45:54 +00:00
|
|
|
__resolveType () {
|
2021-07-01 11:12:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
FactoryEvent: {
|
2021-07-05 10:45:54 +00:00
|
|
|
__resolveType () {
|
2021-07-01 11:12:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
NonFungiblePositionManagerEvent: {
|
2021-07-05 10:45:54 +00:00
|
|
|
__resolveType () {
|
2021-07-01 11:12:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
PoolEvent: {
|
2021-07-05 10:45:54 +00:00
|
|
|
__resolveType () {
|
2021-07-01 11:12:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
Event: {
|
2021-07-05 10:45:54 +00:00
|
|
|
__resolveType: (obj: any) => {
|
|
|
|
assert(obj.__typename);
|
|
|
|
|
|
|
|
return obj.__typename;
|
2021-07-01 11:12:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
Subscription: {
|
|
|
|
onEvent: {
|
|
|
|
subscribe: () => indexer.getEventIterator()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
Query: {
|
|
|
|
|
2021-07-05 10:45:54 +00:00
|
|
|
events: async (_: any, { blockHash, contract, name }: { blockHash: string, contract: string, name: string }) => {
|
|
|
|
log('events', blockHash, contract, name || '');
|
|
|
|
return indexer.getEvents(blockHash, contract, name);
|
2021-07-01 11:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|