Skip to content

Commit

Permalink
Feature/add stake entities and params (#26)
Browse files Browse the repository at this point in the history
## Summary

- Added the following entities that can be staked and their related
messages/events:
  - Application
  - Supplier
  - Gateway.

- Added functionality to parse params from genesis and update the
parameters that came in an authz exec transaction.

- Added functionality to save the entities from the genesis.
  • Loading branch information
Alann27 authored Nov 19, 2024
1 parent bcf7244 commit 5ecfc6b
Show file tree
Hide file tree
Showing 28 changed files with 3,098 additions and 4,575 deletions.
31 changes: 20 additions & 11 deletions genesis/localnet.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"license": "MIT",
"devDependencies": {
"@cosmjs/stargate": "^0.28.9",
"@subql/cli": "5.1.1",
"@subql/cli": "^5.3.0",
"@subql/testing": "2.2.1",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
Expand All @@ -76,8 +76,8 @@
},
"dependencies": {
"@bufbuild/protobuf": "^2.2.0",
"@subql/node-cosmos": "^4.1.1",
"@subql/types-cosmos": "^3.5.2",
"@subql/node-cosmos": "^4.1.4",
"@subql/types-cosmos": "^4.0.0",
"@types/json-bigint": "^1.0.4",
"@types/node": "^22.0.0",
"dotenv": "latest",
Expand Down
170 changes: 162 additions & 8 deletions project.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
CosmosDatasourceKind,
CosmosHandlerKind,
CosmosProject,
} from "@subql/types-cosmos";
import { CosmosDatasourceKind, CosmosHandlerKind, CosmosProject } from "@subql/types-cosmos";

import * as dotenv from 'dotenv';
import path from 'path';
import * as dotenv from "dotenv";
import path from "path";

const mode = process.env.NODE_ENV || 'production';

Expand Down Expand Up @@ -80,9 +76,11 @@ const project: CosmosProject = {
{
file: "./proto/poktroll/application/tx.proto",
messages: [
"MsgUpdateParam",
"MsgUpdateParams",
"MsgStakeApplication",
"MsgUnstakeApplication",
"MsgTransferApplication",
"MsgDelegateToGateway",
"MsgUndelegateFromGateway",
],
Expand All @@ -93,7 +91,14 @@ const project: CosmosProject = {
{
file: "./proto/poktroll/application/event.proto",
messages: [
"EventRedelegation"
"EventRedelegation",
"EventTransferBegin",
"EventTransferEnd",
"EventTransferError",
"EventApplicationStaked",
"EventApplicationUnbondingEnd",
"EventApplicationUnbondingBegin",
"EventApplicationUnbondingCanceled",
],
},
],
Expand Down Expand Up @@ -320,6 +325,17 @@ const project: CosmosProject = {
],
},
],
[
"poktroll.supplier_events",
{
file: "./proto/poktroll/supplier/event.proto",
messages: [
"EventSupplierStaked",
"EventSupplierUnbondingBegin",
"EventSupplierUnbondingEnd",
],
},
],
[
"poktroll.supplier_params",
{
Expand Down Expand Up @@ -425,6 +441,144 @@ const project: CosmosProject = {
type: "coin_received",
}
},
// --- Applications
{
handler: "handleAppMsgStake",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.application.MsgStakeApplication",
}
},
{
handler: "handleDelegateToGatewayMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.application.MsgDelegateToGateway",
}
},
{
handler: "handleUndelegateFromGatewayMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.application.MsgUndelegateFromGateway",
}
},
{
handler: "handleUnstakeApplicationMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.application.MsgUnstakeApplication",
}
},
{
handler: "handleTransferApplicationMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.application.MsgTransferApplication",
}
},
{
handler: "handleTransferApplicationBeginEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.application.EventTransferBegin",
}
},
{
handler: "handleTransferApplicationEndEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.application.EventTransferEnd",
}
},
{
handler: "handleTransferApplicationErrorEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.application.EventTransferError",
}
},
{
handler: "handleApplicationUnbondingBeginEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.application.EventApplicationUnbondingBegin",
}
},
{
handler: "handleApplicationUnbondingEndEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.application.EventApplicationUnbondingEnd",
}
},
// --- Services
{
handler: "handleMsgAddService",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.service.MsgAddService",
}
},
// --- Suppliers
{
handler: "handleSupplierStakeMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.supplier.MsgStakeSupplier",
}
},
{
handler: "handleUnstakeSupplierMsg",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.supplier.MsgUnstakeSupplier",
}
},
{
handler: "handleSupplierUnbondingBeginEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.supplier.EventSupplierUnbondingBegin",
}
},
{
handler: "handleSupplierUnbondingEndEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.supplier.EventSupplierUnbondingEnd",
}
},
// --- Gateways
{
handler: "handleGatewayMsgStake",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.gateway.MsgStakeGateway",
}
},
{
handler: "handleGatewayMsgUnstake",
kind: CosmosHandlerKind.Message,
filter: {
type: "/poktroll.gateway.MsgUnstakeGateway",
}
},
{
handler: "handleGatewayUnstakeEvent",
kind: CosmosHandlerKind.Event,
filter: {
type: "poktroll.gateway.EventGatewayUnstaked",
}
},
// --- Authz
{
handler: "handleAuthzExec",
kind: CosmosHandlerKind.Message,
filter: {
type: "/cosmos.authz.v1beta1.MsgExec",
}
},
],
},
},
Expand Down
Loading

0 comments on commit 5ecfc6b

Please sign in to comment.