Skip to content

Commit

Permalink
Handle near-primitives type mismatch, provide type for FunctionCall w…
Browse files Browse the repository at this point in the history
…ith decoded args.
  • Loading branch information
gabehamilton committed Nov 10, 2023
1 parent e5d00dc commit 0f1ccfb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion runner/src/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ interface Dependencies {
parser: Parser
};

// '@near-lake/primitives/receipt' FunctionCall but with base64 decoded args
declare class DecodedFunctionCall {
readonly methodName: string;
readonly args: string;
readonly gas: number;
readonly deposit: string;
constructor (methodName: string, args: string, gas: number, deposit: string);
}

interface Context {
graphql: (operation: string, variables?: Record<string, any>) => Promise<any>
set: (key: string, value: any) => Promise<any>
Expand All @@ -24,7 +33,7 @@ interface Context {
block: Block,
contract: string,
method: string,
) => Array<{ Operation, args: string }>
) => DecodedFunctionCall[]
getSocialOperations: (block: Block, operation: string) => Array<Record<string, unknown>>
}

Expand Down Expand Up @@ -157,6 +166,7 @@ export default class Indexer {
.filter((action) => action.receiverId === contract)
.flatMap((action) =>
action.operations
// @ts-expect-error block data is an object keyed by type
.map(({ FunctionCall }) => FunctionCall)
.filter((operation) => operation?.methodName === method)
.map((functionCallOperation) => ({
Expand Down

0 comments on commit 0f1ccfb

Please sign in to comment.