Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split mapping main file #12

Closed
wants to merge 9 commits into from
Closed

Conversation

manumonti
Copy link
Member

Note: This PR must be merged after #11 .

Threshold Subgraph recieves events from several sources (contracts). So
a logical division of events handlers can be each contract.

To achieve this, the generic "mappings.ts" file have been splitted in
"pre-app.ts" and "staking.ts".

Also, TokenStaking entities list in subgraph manifest has been updated.

manumonti added 9 commits May 23, 2022 08:43
GraphQL schema changes:

- Epoch counter's unique entity ID ('Singleton') have been replaced by
  `epoch-counter` to have a more meaningful name.
- EpochStake entities only contains the fields `staking provider
  address` and `amount`. `participation` and `stakeData` fields have
  been removed to avoid redundant data.
- The timestamp field name of an epoch have been replaced by
  `timestamp`. The total amount of token staked in a epoch entity is
  saved in `totalStaked` field.
- Now, the first epoch (number 0) is the period between the token
  staking contract deployment and the first staking event.
- Comments format have been homogenized.

Src files changes:

- Added src/utils/epochs.ts code with some utilities related to the
  management of the epochs and its counter.
- Modified HandleStaked function in mapping.ts to follow the new schema
  (handleToppedUp and handleUnstaked are pending).
These modifications increase the processing time of subgraph.

A bug has been fixed also in Staked handle function: previous
epochStakes were not properly saved when a new Epoch is created.
To create a new Epoch, it's necessary to copy the last epoch stakes but
replacing the ID for a new one. This task is made in at least three
handlers (staked, toppedup and unstaked), so a new function has been
created in utils.

Also, a new constant variable for amount and staking provider has been
added to staked and unstaked handler functions.
These modifications increase the processing time of subgraph.
A stake can have different stake types at the same time (T, NuInTStake
and KeepInTStake), so the StakeType's field can be misleading.
This function from utils returns a string with the Epoch Stake's ID.
Now it accepts an epoch ID. If this is not passed, it takes the current
epoch count.

Also, the staking provider argument type have changed from String to
Address for simplicity.
- Entity name changed to PREOperator, which is more descriptive.
- Added OperatorBonded event handler, so PREOperator instance is
  created when a new operator is bonded.
- Added confirmationTimestamp field, which will store the time in which
  the operator is confirmed.
Threshold Subgraph recieves events from several sources (contracts). So
a logical division of events handlers can be each contract.

To achieve this, the generic "mappings.ts" file have been splitted in
"pre-app.ts" and "staking.ts".

Also, TokenStaking entities list in subgraph manifest has been updated.
@manumonti manumonti requested review from cygnusv and r-czajkowski May 27, 2022 12:59
@manumonti manumonti marked this pull request as draft June 7, 2022 16:41
@manumonti manumonti closed this Jun 8, 2022
@manumonti manumonti deleted the spliting-mappings branch June 8, 2022 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant