Skip to content

Commit

Permalink
Generate watcher with deployed DelegatedSending contract (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikugogoi committed Apr 27, 2023
1 parent 7879657 commit 0bce143
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 478 deletions.
12 changes: 1 addition & 11 deletions packages/delegated-sending-watcher/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
# delegated-sending-watcher

## Currently unsupported queries

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)`
This watcher has been generated based on the `DelegatedSending` contract deployed at [0xf6b461fe1ad4bd2ce25b23fe0aff2ac19b3dfa76](https://etherscan.io/address/0xf6b461fe1ad4bd2ce25b23fe0aff2ac19b3dfa76#code#L1)

## Setup

Expand Down
236 changes: 21 additions & 215 deletions packages/delegated-sending-watcher/src/artifacts/DelegatedSending.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,17 @@
{
"abi": [
{
"constant": true,
"inputs": [],
"name": "getInviters",
"outputs": [
{
"name": "invs",
"type": "uint32[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint32"
}
],
"name": "isInviter",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"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,
"constant": false,
"inputs": [
{
"name": "",
"name": "_for",
"type": "uint32"
},
{
"name": "",
"type": "uint16"
}
],
"name": "pools",
"outputs": [
{
"name": "",
"type": "uint16"
}
],
"name": "resetPool",
"outputs": [],
"payable": false,
"stateMutability": "view",
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand Down Expand Up @@ -132,7 +48,7 @@
"outputs": [
{
"name": "",
"type": "uint32"
"type": "uint64"
}
],
"payable": false,
Expand Down Expand Up @@ -167,33 +83,10 @@
"inputs": [
{
"name": "",
"type": "uint256"
"type": "uint64"
}
],
"name": "inviters",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint32"
},
{
"name": "",
"type": "uint256"
}
],
"name": "poolStars",
"name": "pools",
"outputs": [
{
"name": "",
Expand Down Expand Up @@ -228,60 +121,36 @@
"inputs": [
{
"name": "",
"type": "uint32"
},
{
"name": "",
"type": "uint256"
"type": "uint16"
}
],
"name": "invited",
"name": "limits",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_point",
"type": "uint32"
}
],
"name": "getPool",
"outputs": [
{
"name": "pool",
"type": "uint32"
"type": "uint16"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"constant": false,
"inputs": [
{
"name": "_who",
"type": "uint32"
}
],
"name": "getPoolStars",
"outputs": [
"name": "_prefix",
"type": "uint16"
},
{
"name": "stars",
"type": "uint16[]"
"name": "_limit",
"type": "uint16"
}
],
"name": "configureLimit",
"outputs": [],
"payable": false,
"stateMutability": "view",
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -298,47 +167,6 @@
"stateMutability": "view",
"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": [
{
Expand All @@ -350,28 +178,6 @@
"stateMutability": "nonpayable",
"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,
"inputs": [
Expand All @@ -383,7 +189,7 @@
{
"indexed": true,
"name": "fromPool",
"type": "uint32"
"type": "uint64"
},
{
"indexed": false,
Expand Down
9 changes: 0 additions & 9 deletions packages/delegated-sending-watcher/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ export class Client {
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> {
const { canReceive } = await this._client.query(
gql(queries.canReceive),
Expand Down
19 changes: 1 addition & 18 deletions packages/delegated-sending-watcher/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import { StateSyncStatus } from './entity/StateSyncStatus';
import { BlockProgress } from './entity/BlockProgress';
import { State } from './entity/State';
import { CanSend } from './entity/CanSend';
import { GetPool } from './entity/GetPool';
import { CanReceive } from './entity/CanReceive';

export const ENTITIES = [CanSend, GetPool, CanReceive];
export const ENTITIES = [CanSend, CanReceive];

export class Database implements DatabaseInterface {
_config: ConnectionOptions;
Expand Down Expand Up @@ -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> {
return this._conn.getRepository(CanReceive)
.findOne({
Expand All @@ -91,12 +81,6 @@ export class Database implements DatabaseInterface {
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> {
const repo = this._conn.getRepository(CanReceive);
const entity = repo.create({ blockHash, blockNumber, contractAddress, _recipient, value, proof });
Expand Down Expand Up @@ -309,7 +293,6 @@ export class Database implements DatabaseInterface {

_setPropColMaps (): void {
this._propColMaps.CanSend = this._getPropertyColumnMapForEntity('CanSend');
this._propColMaps.GetPool = this._getPropertyColumnMapForEntity('GetPool');
this._propColMaps.CanReceive = this._getPropertyColumnMapForEntity('CanReceive');
}
}
Loading

0 comments on commit 0bce143

Please sign in to comment.