Skip to content

Commit

Permalink
feat(sdk/aptos): resource filter for aptos, upgrade aptos sdk (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Sep 26, 2023
1 parent f6be34e commit a0ca535
Show file tree
Hide file tree
Showing 6 changed files with 1,008 additions and 750 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
"superstruct": "^1.0.3"
},
"devDependencies": {
"@jest/globals": "^29.6.4",
"@jest/globals": "^29.7.0",
"@jest/types": "^29.6.3",
"@ls-lint/ls-lint": "^2.0.1",
"@types/chai": "^4.3.5",
"@types/jest": "^29.5.4",
"@types/node": "^18.17.12",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"@ls-lint/ls-lint": "^2.1.0",
"@types/chai": "^4.3.6",
"@types/jest": "^29.5.5",
"@types/node": "^18.18.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"chai": "^4.3.8",
"conventional-changelog-conventionalcommits": "^7.0.1",
"eslint": "^8.48.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-unused-imports": "^3.0.0",
"jest": "^29.6.4",
"jest": "^29.7.0",
"json": "^11.0.0",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/protos/processor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,14 @@ message InstructionHandlerConfig {
bool raw_data_instruction = 3;
}

message ResourceConfig {
string move_type_prefix = 1;
}

message MoveFetchConfig {
bool resource_changes = 1;
bool all_events = 2;
optional ResourceConfig resource_config = 3;
}

message MoveAccountFetchConfig {
Expand Down
70 changes: 69 additions & 1 deletion packages/protos/src/processor/protos/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,14 @@ export interface InstructionHandlerConfig {
rawDataInstruction: boolean;
}

export interface ResourceConfig {
moveTypePrefix: string;
}

export interface MoveFetchConfig {
resourceChanges: boolean;
allEvents: boolean;
resourceConfig?: ResourceConfig | undefined;
}

export interface MoveAccountFetchConfig {
Expand Down Expand Up @@ -2910,8 +2915,59 @@ export const InstructionHandlerConfig = {
},
};

function createBaseResourceConfig(): ResourceConfig {
return { moveTypePrefix: "" };
}

export const ResourceConfig = {
encode(message: ResourceConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.moveTypePrefix !== "") {
writer.uint32(10).string(message.moveTypePrefix);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): ResourceConfig {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseResourceConfig();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.moveTypePrefix = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): ResourceConfig {
return { moveTypePrefix: isSet(object.moveTypePrefix) ? String(object.moveTypePrefix) : "" };
},

toJSON(message: ResourceConfig): unknown {
const obj: any = {};
message.moveTypePrefix !== undefined && (obj.moveTypePrefix = message.moveTypePrefix);
return obj;
},

create(base?: DeepPartial<ResourceConfig>): ResourceConfig {
return ResourceConfig.fromPartial(base ?? {});
},

fromPartial(object: DeepPartial<ResourceConfig>): ResourceConfig {
const message = createBaseResourceConfig();
message.moveTypePrefix = object.moveTypePrefix ?? "";
return message;
},
};

function createBaseMoveFetchConfig(): MoveFetchConfig {
return { resourceChanges: false, allEvents: false };
return { resourceChanges: false, allEvents: false, resourceConfig: undefined };
}

export const MoveFetchConfig = {
Expand All @@ -2922,6 +2978,9 @@ export const MoveFetchConfig = {
if (message.allEvents === true) {
writer.uint32(16).bool(message.allEvents);
}
if (message.resourceConfig !== undefined) {
ResourceConfig.encode(message.resourceConfig, writer.uint32(26).fork()).ldelim();
}
return writer;
},

Expand All @@ -2938,6 +2997,9 @@ export const MoveFetchConfig = {
case 2:
message.allEvents = reader.bool();
break;
case 3:
message.resourceConfig = ResourceConfig.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
Expand All @@ -2950,13 +3012,16 @@ export const MoveFetchConfig = {
return {
resourceChanges: isSet(object.resourceChanges) ? Boolean(object.resourceChanges) : false,
allEvents: isSet(object.allEvents) ? Boolean(object.allEvents) : false,
resourceConfig: isSet(object.resourceConfig) ? ResourceConfig.fromJSON(object.resourceConfig) : undefined,
};
},

toJSON(message: MoveFetchConfig): unknown {
const obj: any = {};
message.resourceChanges !== undefined && (obj.resourceChanges = message.resourceChanges);
message.allEvents !== undefined && (obj.allEvents = message.allEvents);
message.resourceConfig !== undefined &&
(obj.resourceConfig = message.resourceConfig ? ResourceConfig.toJSON(message.resourceConfig) : undefined);
return obj;
},

Expand All @@ -2968,6 +3033,9 @@ export const MoveFetchConfig = {
const message = createBaseMoveFetchConfig();
message.resourceChanges = object.resourceChanges ?? false;
message.allEvents = object.allEvents ?? false;
message.resourceConfig = (object.resourceConfig !== undefined && object.resourceConfig !== null)
? ResourceConfig.fromPartial(object.resourceConfig)
: undefined;
return message;
},
};
Expand Down
70 changes: 69 additions & 1 deletion packages/runtime/src/gen/processor/protos/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,14 @@ export interface InstructionHandlerConfig {
rawDataInstruction: boolean;
}

export interface ResourceConfig {
moveTypePrefix: string;
}

export interface MoveFetchConfig {
resourceChanges: boolean;
allEvents: boolean;
resourceConfig?: ResourceConfig | undefined;
}

export interface MoveAccountFetchConfig {
Expand Down Expand Up @@ -2949,8 +2954,59 @@ export const InstructionHandlerConfig = {
},
};

function createBaseResourceConfig(): ResourceConfig {
return { moveTypePrefix: "" };
}

export const ResourceConfig = {
encode(message: ResourceConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.moveTypePrefix !== "") {
writer.uint32(10).string(message.moveTypePrefix);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): ResourceConfig {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseResourceConfig();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.moveTypePrefix = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): ResourceConfig {
return { moveTypePrefix: isSet(object.moveTypePrefix) ? String(object.moveTypePrefix) : "" };
},

toJSON(message: ResourceConfig): unknown {
const obj: any = {};
message.moveTypePrefix !== undefined && (obj.moveTypePrefix = message.moveTypePrefix);
return obj;
},

create(base?: DeepPartial<ResourceConfig>): ResourceConfig {
return ResourceConfig.fromPartial(base ?? {});
},

fromPartial(object: DeepPartial<ResourceConfig>): ResourceConfig {
const message = createBaseResourceConfig();
message.moveTypePrefix = object.moveTypePrefix ?? "";
return message;
},
};

function createBaseMoveFetchConfig(): MoveFetchConfig {
return { resourceChanges: false, allEvents: false };
return { resourceChanges: false, allEvents: false, resourceConfig: undefined };
}

export const MoveFetchConfig = {
Expand All @@ -2961,6 +3017,9 @@ export const MoveFetchConfig = {
if (message.allEvents === true) {
writer.uint32(16).bool(message.allEvents);
}
if (message.resourceConfig !== undefined) {
ResourceConfig.encode(message.resourceConfig, writer.uint32(26).fork()).ldelim();
}
return writer;
},

Expand All @@ -2977,6 +3036,9 @@ export const MoveFetchConfig = {
case 2:
message.allEvents = reader.bool();
break;
case 3:
message.resourceConfig = ResourceConfig.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
Expand All @@ -2989,13 +3051,16 @@ export const MoveFetchConfig = {
return {
resourceChanges: isSet(object.resourceChanges) ? Boolean(object.resourceChanges) : false,
allEvents: isSet(object.allEvents) ? Boolean(object.allEvents) : false,
resourceConfig: isSet(object.resourceConfig) ? ResourceConfig.fromJSON(object.resourceConfig) : undefined,
};
},

toJSON(message: MoveFetchConfig): unknown {
const obj: any = {};
message.resourceChanges !== undefined && (obj.resourceChanges = message.resourceChanges);
message.allEvents !== undefined && (obj.allEvents = message.allEvents);
message.resourceConfig !== undefined &&
(obj.resourceConfig = message.resourceConfig ? ResourceConfig.toJSON(message.resourceConfig) : undefined);
return obj;
},

Expand All @@ -3007,6 +3072,9 @@ export const MoveFetchConfig = {
const message = createBaseMoveFetchConfig();
message.resourceChanges = object.resourceChanges ?? false;
message.allEvents = object.allEvents ?? false;
message.resourceConfig = (object.resourceConfig !== undefined && object.resourceConfig !== null)
? ResourceConfig.fromPartial(object.resourceConfig)
: undefined;
return message;
},
};
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
"@sentio/protos": "workspace:*",
"@sentio/runtime": "workspace:^",
"@solana/web3.js": "^1.78.3",
"@typemove/aptos": "~1.2.1",
"@typemove/move": "~1.2.1",
"@typemove/sui": "~1.2.1",
"aptos": "~1.19.0",
"aptos-sdk": "npm:aptos@^1.19.0",
"@typemove/aptos": "~1.2.2",
"@typemove/move": "~1.2.2",
"@typemove/sui": "~1.2.2",
"aptos": "~1.20.0",
"aptos-sdk": "npm:aptos@^1.20.0",
"bs58": "^5.0.0",
"chalk": "^5.2.0",
"csv-parse": "^5.3.0",
Expand Down
Loading

0 comments on commit a0ca535

Please sign in to comment.