Generate watcher with deployed DelegatedSending contract (#15)
This commit is contained in:
parent
787965737d
commit
0bce143a00
@ -1,16 +1,6 @@
|
|||||||
# delegated-sending-watcher
|
# delegated-sending-watcher
|
||||||
|
|
||||||
## Currently unsupported queries
|
This watcher has been generated based on the `DelegatedSending` contract deployed at [0xf6b461fe1ad4bd2ce25b23fe0aff2ac19b3dfa76](https://etherscan.io/address/0xf6b461fe1ad4bd2ce25b23fe0aff2ac19b3dfa76#code#L1)
|
||||||
|
|
||||||
The watcher was generated in `eth_call` mode and does not support the following queries in its current state:
|
|
||||||
|
|
||||||
* `getPoolStars(uint32 _who) returns (uint16[] stars)`
|
|
||||||
|
|
||||||
* `getInviters() returns (uint32[] invs)`
|
|
||||||
|
|
||||||
* `getInvited(uint32 _who) returns (uint32[] invd)`
|
|
||||||
|
|
||||||
* `getPool(uint32 _point) returns (uint32 pool)`
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
@ -1,101 +1,17 @@
|
|||||||
{
|
{
|
||||||
"abi": [
|
"abi": [
|
||||||
{
|
{
|
||||||
"constant": true,
|
"constant": false,
|
||||||
"inputs": [],
|
|
||||||
"name": "getInviters",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "invs",
|
|
||||||
"type": "uint32[]"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "_for",
|
||||||
"type": "uint32"
|
"type": "uint32"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "isInviter",
|
"name": "resetPool",
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
"payable": false,
|
||||||
"stateMutability": "view",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "poolStarsRegistered",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "invitedBy",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "pools",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -132,7 +48,7 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "uint32"
|
"type": "uint64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"payable": false,
|
"payable": false,
|
||||||
@ -167,33 +83,10 @@
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "uint256"
|
"type": "uint64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "inviters",
|
"name": "pools",
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "poolStars",
|
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
@ -228,60 +121,36 @@
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "uint32"
|
"type": "uint16"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "limits",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint16"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_prefix",
|
||||||
|
"type": "uint16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "_limit",
|
||||||
"type": "uint256"
|
"type": "uint16"
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "invited",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"name": "configureLimit",
|
||||||
|
"outputs": [],
|
||||||
"payable": false,
|
"payable": false,
|
||||||
"stateMutability": "view",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_point",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "getPool",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "pool",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_who",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "getPoolStars",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stars",
|
|
||||||
"type": "uint16[]"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -298,47 +167,6 @@
|
|||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_who",
|
|
||||||
"type": "uint32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "getInvited",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "invd",
|
|
||||||
"type": "uint32[]"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_as",
|
|
||||||
"type": "uint16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_for",
|
|
||||||
"type": "uint32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_size",
|
|
||||||
"type": "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "setPoolSize",
|
|
||||||
"outputs": [],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -350,28 +178,6 @@
|
|||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "constructor"
|
"type": "constructor"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "prefix",
|
|
||||||
"type": "uint16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "who",
|
|
||||||
"type": "uint32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "size",
|
|
||||||
"type": "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Pool",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"anonymous": false,
|
"anonymous": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
@ -383,7 +189,7 @@
|
|||||||
{
|
{
|
||||||
"indexed": true,
|
"indexed": true,
|
||||||
"name": "fromPool",
|
"name": "fromPool",
|
||||||
"type": "uint32"
|
"type": "uint64"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"indexed": false,
|
"indexed": false,
|
||||||
|
@ -26,15 +26,6 @@ export class Client {
|
|||||||
return canSend;
|
return canSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGetPool (blockHash: string, contractAddress: string, _point: bigint): Promise<any> {
|
|
||||||
const { getPool } = await this._client.query(
|
|
||||||
gql(queries.getPool),
|
|
||||||
{ blockHash, contractAddress, _point }
|
|
||||||
);
|
|
||||||
|
|
||||||
return getPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getCanReceive (blockHash: string, contractAddress: string, _recipient: string): Promise<any> {
|
async getCanReceive (blockHash: string, contractAddress: string, _recipient: string): Promise<any> {
|
||||||
const { canReceive } = await this._client.query(
|
const { canReceive } = await this._client.query(
|
||||||
gql(queries.canReceive),
|
gql(queries.canReceive),
|
||||||
|
@ -21,10 +21,9 @@ import { StateSyncStatus } from './entity/StateSyncStatus';
|
|||||||
import { BlockProgress } from './entity/BlockProgress';
|
import { BlockProgress } from './entity/BlockProgress';
|
||||||
import { State } from './entity/State';
|
import { State } from './entity/State';
|
||||||
import { CanSend } from './entity/CanSend';
|
import { CanSend } from './entity/CanSend';
|
||||||
import { GetPool } from './entity/GetPool';
|
|
||||||
import { CanReceive } from './entity/CanReceive';
|
import { CanReceive } from './entity/CanReceive';
|
||||||
|
|
||||||
export const ENTITIES = [CanSend, GetPool, CanReceive];
|
export const ENTITIES = [CanSend, CanReceive];
|
||||||
|
|
||||||
export class Database implements DatabaseInterface {
|
export class Database implements DatabaseInterface {
|
||||||
_config: ConnectionOptions;
|
_config: ConnectionOptions;
|
||||||
@ -67,15 +66,6 @@ export class Database implements DatabaseInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGetPool ({ blockHash, contractAddress, _point }: { blockHash: string, contractAddress: string, _point: bigint }): Promise<GetPool | undefined> {
|
|
||||||
return this._conn.getRepository(GetPool)
|
|
||||||
.findOne({
|
|
||||||
blockHash,
|
|
||||||
contractAddress,
|
|
||||||
_point
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getCanReceive ({ blockHash, contractAddress, _recipient }: { blockHash: string, contractAddress: string, _recipient: string }): Promise<CanReceive | undefined> {
|
async getCanReceive ({ blockHash, contractAddress, _recipient }: { blockHash: string, contractAddress: string, _recipient: string }): Promise<CanReceive | undefined> {
|
||||||
return this._conn.getRepository(CanReceive)
|
return this._conn.getRepository(CanReceive)
|
||||||
.findOne({
|
.findOne({
|
||||||
@ -91,12 +81,6 @@ export class Database implements DatabaseInterface {
|
|||||||
return repo.save(entity);
|
return repo.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveGetPool ({ blockHash, blockNumber, contractAddress, _point, value, proof }: DeepPartial<GetPool>): Promise<GetPool> {
|
|
||||||
const repo = this._conn.getRepository(GetPool);
|
|
||||||
const entity = repo.create({ blockHash, blockNumber, contractAddress, _point, value, proof });
|
|
||||||
return repo.save(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
async saveCanReceive ({ blockHash, blockNumber, contractAddress, _recipient, value, proof }: DeepPartial<CanReceive>): Promise<CanReceive> {
|
async saveCanReceive ({ blockHash, blockNumber, contractAddress, _recipient, value, proof }: DeepPartial<CanReceive>): Promise<CanReceive> {
|
||||||
const repo = this._conn.getRepository(CanReceive);
|
const repo = this._conn.getRepository(CanReceive);
|
||||||
const entity = repo.create({ blockHash, blockNumber, contractAddress, _recipient, value, proof });
|
const entity = repo.create({ blockHash, blockNumber, contractAddress, _recipient, value, proof });
|
||||||
@ -309,7 +293,6 @@ export class Database implements DatabaseInterface {
|
|||||||
|
|
||||||
_setPropColMaps (): void {
|
_setPropColMaps (): void {
|
||||||
this._propColMaps.CanSend = this._getPropertyColumnMapForEntity('CanSend');
|
this._propColMaps.CanSend = this._getPropertyColumnMapForEntity('CanSend');
|
||||||
this._propColMaps.GetPool = this._getPropertyColumnMapForEntity('GetPool');
|
|
||||||
this._propColMaps.CanReceive = this._getPropertyColumnMapForEntity('CanReceive');
|
this._propColMaps.CanReceive = this._getPropertyColumnMapForEntity('CanReceive');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,6 @@ query events($blockHash: String!, $contractAddress: String!, $name: String){
|
|||||||
contract
|
contract
|
||||||
eventIndex
|
eventIndex
|
||||||
event{
|
event{
|
||||||
... on PoolEvent {
|
|
||||||
prefix
|
|
||||||
who
|
|
||||||
size
|
|
||||||
}
|
|
||||||
... on SentEvent {
|
... on SentEvent {
|
||||||
prefix
|
prefix
|
||||||
fromPool
|
fromPool
|
||||||
|
@ -16,11 +16,6 @@ query eventsInRange($fromBlockNumber: Int!, $toBlockNumber: Int!){
|
|||||||
contract
|
contract
|
||||||
eventIndex
|
eventIndex
|
||||||
event{
|
event{
|
||||||
... on PoolEvent {
|
|
||||||
prefix
|
|
||||||
who
|
|
||||||
size
|
|
||||||
}
|
|
||||||
... on SentEvent {
|
... on SentEvent {
|
||||||
prefix
|
prefix
|
||||||
fromPool
|
fromPool
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
query getInvited($blockHash: String!, $contractAddress: String!, $_who: BigInt!){
|
|
||||||
getInvited(blockHash: $blockHash, contractAddress: $contractAddress, _who: $_who){
|
|
||||||
value
|
|
||||||
proof{
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
query getInviters($blockHash: String!, $contractAddress: String!){
|
|
||||||
getInviters(blockHash: $blockHash, contractAddress: $contractAddress){
|
|
||||||
value
|
|
||||||
proof{
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
query getPool($blockHash: String!, $contractAddress: String!, $_point: BigInt!){
|
|
||||||
getPool(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point){
|
|
||||||
value
|
|
||||||
proof{
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
query getPoolStars($blockHash: String!, $contractAddress: String!, $_who: BigInt!){
|
|
||||||
getPoolStars(blockHash: $blockHash, contractAddress: $contractAddress, _who: $_who){
|
|
||||||
value
|
|
||||||
proof{
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,11 +4,7 @@ import path from 'path';
|
|||||||
export const events = fs.readFileSync(path.join(__dirname, 'events.gql'), 'utf8');
|
export const events = fs.readFileSync(path.join(__dirname, 'events.gql'), 'utf8');
|
||||||
export const eventsInRange = fs.readFileSync(path.join(__dirname, 'eventsInRange.gql'), 'utf8');
|
export const eventsInRange = fs.readFileSync(path.join(__dirname, 'eventsInRange.gql'), 'utf8');
|
||||||
export const canSend = fs.readFileSync(path.join(__dirname, 'canSend.gql'), 'utf8');
|
export const canSend = fs.readFileSync(path.join(__dirname, 'canSend.gql'), 'utf8');
|
||||||
export const getPool = fs.readFileSync(path.join(__dirname, 'getPool.gql'), 'utf8');
|
|
||||||
export const canReceive = fs.readFileSync(path.join(__dirname, 'canReceive.gql'), 'utf8');
|
export const canReceive = fs.readFileSync(path.join(__dirname, 'canReceive.gql'), 'utf8');
|
||||||
export const getPoolStars = fs.readFileSync(path.join(__dirname, 'getPoolStars.gql'), 'utf8');
|
|
||||||
export const getInviters = fs.readFileSync(path.join(__dirname, 'getInviters.gql'), 'utf8');
|
|
||||||
export const getInvited = fs.readFileSync(path.join(__dirname, 'getInvited.gql'), 'utf8');
|
|
||||||
export const getSyncStatus = fs.readFileSync(path.join(__dirname, 'getSyncStatus.gql'), 'utf8');
|
export const getSyncStatus = fs.readFileSync(path.join(__dirname, 'getSyncStatus.gql'), 'utf8');
|
||||||
export const getStateByCID = fs.readFileSync(path.join(__dirname, 'getStateByCID.gql'), 'utf8');
|
export const getStateByCID = fs.readFileSync(path.join(__dirname, 'getStateByCID.gql'), 'utf8');
|
||||||
export const getState = fs.readFileSync(path.join(__dirname, 'getState.gql'), 'utf8');
|
export const getState = fs.readFileSync(path.join(__dirname, 'getState.gql'), 'utf8');
|
||||||
|
@ -16,11 +16,6 @@ subscription onEvent{
|
|||||||
contract
|
contract
|
||||||
eventIndex
|
eventIndex
|
||||||
event{
|
event{
|
||||||
... on PoolEvent {
|
|
||||||
prefix
|
|
||||||
who
|
|
||||||
size
|
|
||||||
}
|
|
||||||
... on SentEvent {
|
... on SentEvent {
|
||||||
prefix
|
prefix
|
||||||
fromPool
|
fromPool
|
||||||
|
@ -123,37 +123,6 @@ export class Indexer implements IndexerInterface {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPool (blockHash: string, contractAddress: string, _point: bigint): Promise<ValueResult> {
|
|
||||||
const entity = await this._db.getGetPool({ blockHash, contractAddress, _point });
|
|
||||||
if (entity) {
|
|
||||||
log('getPool: db hit.');
|
|
||||||
|
|
||||||
return {
|
|
||||||
value: entity.value,
|
|
||||||
proof: JSON.parse(entity.proof)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const { block: { number } } = await this._ethClient.getBlockByHash(blockHash);
|
|
||||||
const blockNumber = ethers.BigNumber.from(number).toNumber();
|
|
||||||
|
|
||||||
log('getPool: db miss, fetching from upstream server');
|
|
||||||
|
|
||||||
const abi = this._abiMap.get(KIND_DELEGATEDSENDING);
|
|
||||||
assert(abi);
|
|
||||||
|
|
||||||
const contract = new ethers.Contract(contractAddress, abi, this._ethProvider);
|
|
||||||
const contractResult = await contract.getPool(_point, { blockTag: blockHash });
|
|
||||||
|
|
||||||
const value = ethers.BigNumber.from(contractResult).toBigInt();
|
|
||||||
|
|
||||||
const result: ValueResult = { value };
|
|
||||||
|
|
||||||
await this._db.saveGetPool({ blockHash, blockNumber, contractAddress, _point, value: result.value, proof: JSONbigNative.stringify(result.proof) });
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
async canReceive (blockHash: string, contractAddress: string, _recipient: string): Promise<ValueResult> {
|
async canReceive (blockHash: string, contractAddress: string, _recipient: string): Promise<ValueResult> {
|
||||||
const entity = await this._db.getCanReceive({ blockHash, contractAddress, _recipient });
|
const entity = await this._db.getCanReceive({ blockHash, contractAddress, _recipient });
|
||||||
if (entity) {
|
if (entity) {
|
||||||
@ -184,51 +153,6 @@ export class Indexer implements IndexerInterface {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPoolStars (blockHash: string, contractAddress: string, _who: bigint): Promise<ValueResult> {
|
|
||||||
log('getPoolStars: db miss, fetching from upstream server');
|
|
||||||
|
|
||||||
const abi = this._abiMap.get(KIND_DELEGATEDSENDING);
|
|
||||||
assert(abi);
|
|
||||||
|
|
||||||
const contract = new ethers.Contract(contractAddress, abi, this._ethProvider);
|
|
||||||
const contractResult = await contract.getPoolStars(_who, { blockTag: blockHash });
|
|
||||||
|
|
||||||
const value = contractResult;
|
|
||||||
const result: ValueResult = { value };
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getInviters (blockHash: string, contractAddress: string): Promise<ValueResult> {
|
|
||||||
log('getInviters: db miss, fetching from upstream server');
|
|
||||||
|
|
||||||
const abi = this._abiMap.get(KIND_DELEGATEDSENDING);
|
|
||||||
assert(abi);
|
|
||||||
|
|
||||||
const contract = new ethers.Contract(contractAddress, abi, this._ethProvider);
|
|
||||||
const contractResult = await contract.getInviters({ blockTag: blockHash });
|
|
||||||
|
|
||||||
const value = contractResult.map((val: ethers.BigNumber | number) => ethers.BigNumber.from(val).toBigInt());
|
|
||||||
const result: ValueResult = { value };
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getInvited (blockHash: string, contractAddress: string, _who: bigint): Promise<ValueResult> {
|
|
||||||
log('getInvited: db miss, fetching from upstream server');
|
|
||||||
|
|
||||||
const abi = this._abiMap.get(KIND_DELEGATEDSENDING);
|
|
||||||
assert(abi);
|
|
||||||
|
|
||||||
const contract = new ethers.Contract(contractAddress, abi, this._ethProvider);
|
|
||||||
const contractResult = await contract.getInvited(_who, { blockTag: blockHash });
|
|
||||||
|
|
||||||
const value = contractResult.map((val: ethers.BigNumber | number) => ethers.BigNumber.from(val).toBigInt());
|
|
||||||
const result: ValueResult = { value };
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getStorageValue (storageLayout: StorageLayout, blockHash: string, contractAddress: string, variable: string, ...mappingKeys: MappingKey[]): Promise<ValueResult> {
|
async getStorageValue (storageLayout: StorageLayout, blockHash: string, contractAddress: string, variable: string, ...mappingKeys: MappingKey[]): Promise<ValueResult> {
|
||||||
return this._baseIndexer.getStorageValue(
|
return this._baseIndexer.getStorageValue(
|
||||||
storageLayout,
|
storageLayout,
|
||||||
|
@ -90,24 +90,6 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
|||||||
return indexer.canSend(blockHash, contractAddress, _as, _point);
|
return indexer.canSend(blockHash, contractAddress, _as, _point);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPool: (
|
|
||||||
_: any,
|
|
||||||
{ blockHash, contractAddress, _point }: { blockHash: string, contractAddress: string, _point: bigint },
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
__: any,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
info: GraphQLResolveInfo
|
|
||||||
): Promise<ValueResult> => {
|
|
||||||
log('getPool', blockHash, contractAddress, _point);
|
|
||||||
gqlTotalQueryCount.inc(1);
|
|
||||||
gqlQueryCount.labels('getPool').inc(1);
|
|
||||||
|
|
||||||
// Set cache-control hints
|
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
|
||||||
|
|
||||||
return indexer.getPool(blockHash, contractAddress, _point);
|
|
||||||
},
|
|
||||||
|
|
||||||
canReceive: (
|
canReceive: (
|
||||||
_: any,
|
_: any,
|
||||||
{ blockHash, contractAddress, _recipient }: { blockHash: string, contractAddress: string, _recipient: string },
|
{ blockHash, contractAddress, _recipient }: { blockHash: string, contractAddress: string, _recipient: string },
|
||||||
@ -126,60 +108,6 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
|||||||
return indexer.canReceive(blockHash, contractAddress, _recipient);
|
return indexer.canReceive(blockHash, contractAddress, _recipient);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPoolStars: (
|
|
||||||
_: any,
|
|
||||||
{ blockHash, contractAddress, _who }: { blockHash: string, contractAddress: string, _who: bigint },
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
__: any,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
info: GraphQLResolveInfo
|
|
||||||
): Promise<ValueResult> => {
|
|
||||||
log('getPoolStars', blockHash, contractAddress, _who);
|
|
||||||
gqlTotalQueryCount.inc(1);
|
|
||||||
gqlQueryCount.labels('getPoolStars').inc(1);
|
|
||||||
|
|
||||||
// Set cache-control hints
|
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
|
||||||
|
|
||||||
return indexer.getPoolStars(blockHash, contractAddress, _who);
|
|
||||||
},
|
|
||||||
|
|
||||||
getInviters: (
|
|
||||||
_: any,
|
|
||||||
{ blockHash, contractAddress }: { blockHash: string, contractAddress: string },
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
__: any,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
info: GraphQLResolveInfo
|
|
||||||
): Promise<ValueResult> => {
|
|
||||||
log('getInviters', blockHash, contractAddress);
|
|
||||||
gqlTotalQueryCount.inc(1);
|
|
||||||
gqlQueryCount.labels('getInviters').inc(1);
|
|
||||||
|
|
||||||
// Set cache-control hints
|
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
|
||||||
|
|
||||||
return indexer.getInviters(blockHash, contractAddress);
|
|
||||||
},
|
|
||||||
|
|
||||||
getInvited: (
|
|
||||||
_: any,
|
|
||||||
{ blockHash, contractAddress, _who }: { blockHash: string, contractAddress: string, _who: bigint },
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
__: any,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
info: GraphQLResolveInfo
|
|
||||||
): Promise<ValueResult> => {
|
|
||||||
log('getInvited', blockHash, contractAddress, _who);
|
|
||||||
gqlTotalQueryCount.inc(1);
|
|
||||||
gqlQueryCount.labels('getInvited').inc(1);
|
|
||||||
|
|
||||||
// Set cache-control hints
|
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
|
||||||
|
|
||||||
return indexer.getInvited(blockHash, contractAddress, _who);
|
|
||||||
},
|
|
||||||
|
|
||||||
events: async (_: any, { blockHash, contractAddress, name }: { blockHash: string, contractAddress: string, name?: string }) => {
|
events: async (_: any, { blockHash, contractAddress, name }: { blockHash: string, contractAddress: string, name?: string }) => {
|
||||||
log('events', blockHash, contractAddress, name);
|
log('events', blockHash, contractAddress, name);
|
||||||
gqlTotalQueryCount.inc(1);
|
gqlTotalQueryCount.inc(1);
|
||||||
|
@ -39,13 +39,7 @@ type ResultEvent {
|
|||||||
proof: Proof
|
proof: Proof
|
||||||
}
|
}
|
||||||
|
|
||||||
union Event = PoolEvent | SentEvent
|
union Event = SentEvent
|
||||||
|
|
||||||
type PoolEvent {
|
|
||||||
prefix: Int!
|
|
||||||
who: BigInt!
|
|
||||||
size: Int!
|
|
||||||
}
|
|
||||||
|
|
||||||
type SentEvent {
|
type SentEvent {
|
||||||
prefix: Int!
|
prefix: Int!
|
||||||
@ -60,21 +54,6 @@ type ResultBoolean {
|
|||||||
proof: Proof
|
proof: Proof
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResultBigInt {
|
|
||||||
value: BigInt!
|
|
||||||
proof: Proof
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResultIntArray {
|
|
||||||
value: [Int!]!
|
|
||||||
proof: Proof
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResultBigIntArray {
|
|
||||||
value: [BigInt!]!
|
|
||||||
proof: Proof
|
|
||||||
}
|
|
||||||
|
|
||||||
type SyncStatus {
|
type SyncStatus {
|
||||||
latestIndexedBlockHash: String!
|
latestIndexedBlockHash: String!
|
||||||
latestIndexedBlockNumber: Int!
|
latestIndexedBlockNumber: Int!
|
||||||
@ -94,11 +73,7 @@ type Query {
|
|||||||
events(blockHash: String!, contractAddress: String!, name: String): [ResultEvent!]
|
events(blockHash: String!, contractAddress: String!, name: String): [ResultEvent!]
|
||||||
eventsInRange(fromBlockNumber: Int!, toBlockNumber: Int!): [ResultEvent!]
|
eventsInRange(fromBlockNumber: Int!, toBlockNumber: Int!): [ResultEvent!]
|
||||||
canSend(blockHash: String!, contractAddress: String!, _as: BigInt!, _point: BigInt!): ResultBoolean!
|
canSend(blockHash: String!, contractAddress: String!, _as: BigInt!, _point: BigInt!): ResultBoolean!
|
||||||
getPool(blockHash: String!, contractAddress: String!, _point: BigInt!): ResultBigInt!
|
|
||||||
canReceive(blockHash: String!, contractAddress: String!, _recipient: String!): ResultBoolean!
|
canReceive(blockHash: String!, contractAddress: String!, _recipient: String!): ResultBoolean!
|
||||||
getPoolStars(blockHash: String!, contractAddress: String!, _who: BigInt!): ResultIntArray!
|
|
||||||
getInviters(blockHash: String!, contractAddress: String!): ResultBigIntArray!
|
|
||||||
getInvited(blockHash: String!, contractAddress: String!, _who: BigInt!): ResultBigIntArray!
|
|
||||||
getSyncStatus: SyncStatus
|
getSyncStatus: SyncStatus
|
||||||
getStateByCID(cid: String!): ResultState
|
getStateByCID(cid: String!): ResultState
|
||||||
getState(blockHash: String!, contractAddress: String!, kind: String): ResultState
|
getState(blockHash: String!, contractAddress: String!, kind: String): ResultState
|
||||||
|
Loading…
Reference in New Issue
Block a user