Skip to content

Commit

Permalink
chore(sdk): cleanup (stephenh#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Sep 1, 2022
1 parent 878cace commit bef8e97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
6 changes: 3 additions & 3 deletions protos/processor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package processor;

import "google/protobuf/empty.proto";

option go_package = "sentioxyz/sentio/processor";
option go_package = "sentioxyz/sentio/processor/protos";

service Processor {
// Start the processor, need to be called before any other RPC calls
Expand Down Expand Up @@ -47,13 +47,13 @@ message ProcessConfigResponse {

message ContractConfig {
ContractInfo contract = 1;
OldBlockHandlerConfig block_config = 2; // deprecate, TODO to be deleted
repeated BlockHandlerConfig block_configs = 7;
repeated LogHandlerConfig log_configs = 3;
uint64 start_block = 4;
uint64 end_block = 5;
// int32 chunk_size = 6;
InstructionHandlerConfig instruction_config = 6;

string processor_type = 8;
}

message ContractInfo {
Expand Down
39 changes: 14 additions & 25 deletions sdk/src/gen/processor/protos/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export interface ProcessConfigResponse {

export interface ContractConfig {
contract: ContractInfo | undefined;
blockConfig: OldBlockHandlerConfig | undefined;
blockConfigs: BlockHandlerConfig[];
logConfigs: LogHandlerConfig[];
startBlock: Long;
endBlock: Long;
instructionConfig: InstructionHandlerConfig | undefined;
processorType: string;
}

export interface ContractInfo {
Expand Down Expand Up @@ -451,12 +451,12 @@ export const ProcessConfigResponse = {
function createBaseContractConfig(): ContractConfig {
return {
contract: undefined,
blockConfig: undefined,
blockConfigs: [],
logConfigs: [],
startBlock: Long.UZERO,
endBlock: Long.UZERO,
instructionConfig: undefined,
processorType: "",
};
}

Expand All @@ -468,12 +468,6 @@ export const ContractConfig = {
if (message.contract !== undefined) {
ContractInfo.encode(message.contract, writer.uint32(10).fork()).ldelim();
}
if (message.blockConfig !== undefined) {
OldBlockHandlerConfig.encode(
message.blockConfig,
writer.uint32(18).fork()
).ldelim();
}
for (const v of message.blockConfigs) {
BlockHandlerConfig.encode(v!, writer.uint32(58).fork()).ldelim();
}
Expand All @@ -492,6 +486,9 @@ export const ContractConfig = {
writer.uint32(50).fork()
).ldelim();
}
if (message.processorType !== "") {
writer.uint32(66).string(message.processorType);
}
return writer;
},

Expand All @@ -505,12 +502,6 @@ export const ContractConfig = {
case 1:
message.contract = ContractInfo.decode(reader, reader.uint32());
break;
case 2:
message.blockConfig = OldBlockHandlerConfig.decode(
reader,
reader.uint32()
);
break;
case 7:
message.blockConfigs.push(
BlockHandlerConfig.decode(reader, reader.uint32())
Expand All @@ -533,6 +524,9 @@ export const ContractConfig = {
reader.uint32()
);
break;
case 8:
message.processorType = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
Expand All @@ -546,9 +540,6 @@ export const ContractConfig = {
contract: isSet(object.contract)
? ContractInfo.fromJSON(object.contract)
: undefined,
blockConfig: isSet(object.blockConfig)
? OldBlockHandlerConfig.fromJSON(object.blockConfig)
: undefined,
blockConfigs: Array.isArray(object?.blockConfigs)
? object.blockConfigs.map((e: any) => BlockHandlerConfig.fromJSON(e))
: [],
Expand All @@ -564,6 +555,9 @@ export const ContractConfig = {
instructionConfig: isSet(object.instructionConfig)
? InstructionHandlerConfig.fromJSON(object.instructionConfig)
: undefined,
processorType: isSet(object.processorType)
? String(object.processorType)
: "",
};
},

Expand All @@ -573,10 +567,6 @@ export const ContractConfig = {
(obj.contract = message.contract
? ContractInfo.toJSON(message.contract)
: undefined);
message.blockConfig !== undefined &&
(obj.blockConfig = message.blockConfig
? OldBlockHandlerConfig.toJSON(message.blockConfig)
: undefined);
if (message.blockConfigs) {
obj.blockConfigs = message.blockConfigs.map((e) =>
e ? BlockHandlerConfig.toJSON(e) : undefined
Expand All @@ -599,6 +589,8 @@ export const ContractConfig = {
(obj.instructionConfig = message.instructionConfig
? InstructionHandlerConfig.toJSON(message.instructionConfig)
: undefined);
message.processorType !== undefined &&
(obj.processorType = message.processorType);
return obj;
},

Expand All @@ -608,10 +600,6 @@ export const ContractConfig = {
object.contract !== undefined && object.contract !== null
? ContractInfo.fromPartial(object.contract)
: undefined;
message.blockConfig =
object.blockConfig !== undefined && object.blockConfig !== null
? OldBlockHandlerConfig.fromPartial(object.blockConfig)
: undefined;
message.blockConfigs =
object.blockConfigs?.map((e) => BlockHandlerConfig.fromPartial(e)) || [];
message.logConfigs =
Expand All @@ -629,6 +617,7 @@ export const ContractConfig = {
object.instructionConfig !== null
? InstructionHandlerConfig.fromPartial(object.instructionConfig)
: undefined;
message.processorType = object.processorType ?? "";
return message;
},
};
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,13 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
this.processorsByChainId.set(chainId, processor)

const contractConfig: ContractConfig = {
processorType: 'user_processor',
contract: {
name: processor.config.name,
chainId: chainId,
address: processor.config.address,
abi: '',
},
blockConfig: {
// TODO remove this field
numHandlers: processor.blockHandlers.length,
},
blockConfigs: [],
logConfigs: [],
startBlock: processor.config.startBlock,
Expand Down Expand Up @@ -144,13 +141,13 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
// Part 2, prepare solana constractors
for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {
const contractConfig: ContractConfig = {
processorType: 'user_processor',
contract: {
name: solanaProcessor.contractName,
chainId: 'SOL:mainnet', // TODO set in processor
address: solanaProcessor.address,
abi: '',
},
blockConfig: undefined,
blockConfigs: [],
logConfigs: [],
startBlock: solanaProcessor.config.startSlot,
Expand Down

0 comments on commit bef8e97

Please sign in to comment.