Skip to content

Commit

Permalink
feat: save untrusted remote for completion and transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 25, 2024
1 parent eee92b2 commit 96d3031
Showing 1 changed file with 12 additions and 3 deletions.
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

0 comments on commit 96d3031

Please sign in to comment.