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

feat: save untrusted remote for completion and transparency #183

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion subgraphs/venus-governance/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ type RemoteProposal @entity {
proposalId: BigInt

"Remote ChainId where the proposal was sent"
trustedRemote: TrustedRemote
trustedRemote: TrustedRemote!

"Targets data for the change"
targets: [Bytes!]
Expand Down
15 changes: 12 additions & 3 deletions subgraphs/venus-governance/src/operations/createRemoteProposals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Address, BigInt, Bytes, ethereum } from '@graphprotocol/graph-ts';

import { ProposalCreated as ProposalCreatedV2 } from '../../generated/GovernorBravoDelegate2/GovernorBravoDelegate2';
import { RemoteProposal } from '../../generated/schema';
import { RemoteProposal, TrustedRemote } from '../../generated/schema';
import { DYNAMIC_TUPLE_BYTES_PREFIX } from '../constants';
import { nullAddress } from '../constants/addresses';

class RemoteCommandMap {
sourceProposalId: BigInt;
Expand Down Expand Up @@ -40,8 +41,16 @@ const createRemoteProposals = (event: ProposalCreatedV2): void => {
Bytes.fromByteArray(Bytes.fromBigInt(acc.sourceProposalId)),
);
const remoteProposal = new RemoteProposal(remoteProposalId);

remoteProposal.trustedRemote = Bytes.fromI32(layerZeroChainId); // default value replaced in event handler
const trustRemoteId = Bytes.fromI32(layerZeroChainId);
let trustedRemote = TrustedRemote.load(trustRemoteId);
if (!trustedRemote) {
trustedRemote = new TrustedRemote(trustRemoteId);
trustedRemote.layerZeroChainId = layerZeroChainId;
trustedRemote.address = nullAddress;
trustedRemote.active = false;
trustedRemote.save();
}
remoteProposal.trustedRemote = trustRemoteId;
remoteProposal.sourceProposal = acc.sourceProposalId.toString();
const targets = payloadDecoded[0]
.toAddressArray()
Expand Down
Loading