Skip to content

Commit

Permalink
feat(sui): fix object id and add object version into object context
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 committed Dec 13, 2024
1 parent 9aaea7f commit 64238fe
Show file tree
Hide file tree
Showing 11 changed files with 422 additions and 18 deletions.
11 changes: 7 additions & 4 deletions packages/protos/processor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,13 @@ message Data {
uint64 slot = 3;
}
message SuiObject {
repeated google.protobuf.Struct objects = 1;
optional google.protobuf.Struct self = 4;
google.protobuf.Timestamp timestamp = 2;
uint64 slot = 3;
repeated google.protobuf.Struct objects = 1; // just details.content
optional google.protobuf.Struct self = 4; // just details.content
string object_id = 5; // self object property
uint64 object_version = 6; // self object property
string object_digest = 7; // self object property
google.protobuf.Timestamp timestamp = 2; // checkpoint timestamp
uint64 slot = 3; // checkpoint number
}
message SuiObjectChange {
repeated google.protobuf.Struct changes = 1;
Expand Down
61 changes: 60 additions & 1 deletion packages/protos/src/processor/protos/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@ export interface Data_SuiCall {
export interface Data_SuiObject {
objects: { [key: string]: any }[];
self?: { [key: string]: any } | undefined;
objectId: string;
objectVersion: bigint;
objectDigest: string;
timestamp: Date | undefined;
slot: bigint;
}
Expand Down Expand Up @@ -9755,7 +9758,15 @@ export const Data_SuiCall = {
};

function createBaseData_SuiObject(): Data_SuiObject {
return { objects: [], self: undefined, timestamp: undefined, slot: BigInt("0") };
return {
objects: [],
self: undefined,
objectId: "",
objectVersion: BigInt("0"),
objectDigest: "",
timestamp: undefined,
slot: BigInt("0"),
};
}

export const Data_SuiObject = {
Expand All @@ -9766,6 +9777,18 @@ export const Data_SuiObject = {
if (message.self !== undefined) {
Struct.encode(Struct.wrap(message.self), writer.uint32(34).fork()).ldelim();
}
if (message.objectId !== "") {
writer.uint32(42).string(message.objectId);
}
if (message.objectVersion !== BigInt("0")) {
if (BigInt.asUintN(64, message.objectVersion) !== message.objectVersion) {
throw new globalThis.Error("value provided for field message.objectVersion of type uint64 too large");
}
writer.uint32(48).uint64(message.objectVersion.toString());
}
if (message.objectDigest !== "") {
writer.uint32(58).string(message.objectDigest);
}
if (message.timestamp !== undefined) {
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(18).fork()).ldelim();
}
Expand Down Expand Up @@ -9799,6 +9822,27 @@ export const Data_SuiObject = {

message.self = Struct.unwrap(Struct.decode(reader, reader.uint32()));
continue;
case 5:
if (tag !== 42) {
break;
}

message.objectId = reader.string();
continue;
case 6:
if (tag !== 48) {
break;
}

message.objectVersion = longToBigint(reader.uint64() as Long);
continue;
case 7:
if (tag !== 58) {
break;
}

message.objectDigest = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
Expand Down Expand Up @@ -9826,6 +9870,9 @@ export const Data_SuiObject = {
return {
objects: globalThis.Array.isArray(object?.objects) ? [...object.objects] : [],
self: isObject(object.self) ? object.self : undefined,
objectId: isSet(object.objectId) ? globalThis.String(object.objectId) : "",
objectVersion: isSet(object.objectVersion) ? BigInt(object.objectVersion) : BigInt("0"),
objectDigest: isSet(object.objectDigest) ? globalThis.String(object.objectDigest) : "",
timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
slot: isSet(object.slot) ? BigInt(object.slot) : BigInt("0"),
};
Expand All @@ -9839,6 +9886,15 @@ export const Data_SuiObject = {
if (message.self !== undefined) {
obj.self = message.self;
}
if (message.objectId !== "") {
obj.objectId = message.objectId;
}
if (message.objectVersion !== BigInt("0")) {
obj.objectVersion = message.objectVersion.toString();
}
if (message.objectDigest !== "") {
obj.objectDigest = message.objectDigest;
}
if (message.timestamp !== undefined) {
obj.timestamp = message.timestamp.toISOString();
}
Expand All @@ -9855,6 +9911,9 @@ export const Data_SuiObject = {
const message = createBaseData_SuiObject();
message.objects = object.objects?.map((e) => e) || [];
message.self = object.self ?? undefined;
message.objectId = object.objectId ?? "";
message.objectVersion = object.objectVersion ?? BigInt("0");
message.objectDigest = object.objectDigest ?? "";
message.timestamp = object.timestamp ?? undefined;
message.slot = object.slot ?? BigInt("0");
return message;
Expand Down
44 changes: 44 additions & 0 deletions packages/protos/src/service/common/protos/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export interface Project {
enableDisk: boolean;
/** @deprecated */
enableMaterializedView: boolean;
defaultTimerange: TimeRangeLite | undefined;
}

export enum Project_Visibility {
Expand Down Expand Up @@ -480,6 +481,7 @@ export interface ProjectInfo {
enableDisk: boolean;
/** @deprecated */
enableMaterializedView: boolean;
defaultTimerange: TimeRangeLite | undefined;
}

export interface EventLogColumn {
Expand Down Expand Up @@ -1457,6 +1459,7 @@ export enum TabularData_ColumnType {
BOOLEAN = 2,
LIST = 3,
TIME = 4,
MAP = 5,
UNRECOGNIZED = -1,
}

Expand All @@ -1477,6 +1480,9 @@ export function tabularData_ColumnTypeFromJSON(object: any): TabularData_ColumnT
case 4:
case "TIME":
return TabularData_ColumnType.TIME;
case 5:
case "MAP":
return TabularData_ColumnType.MAP;
case -1:
case "UNRECOGNIZED":
default:
Expand All @@ -1496,6 +1502,8 @@ export function tabularData_ColumnTypeToJSON(object: TabularData_ColumnType): st
return "LIST";
case TabularData_ColumnType.TIME:
return "TIME";
case TabularData_ColumnType.MAP:
return "MAP";
case TabularData_ColumnType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
Expand Down Expand Up @@ -2739,6 +2747,7 @@ function createBaseProject(): Project {
superset: undefined,
enableDisk: false,
enableMaterializedView: false,
defaultTimerange: undefined,
};
}

Expand Down Expand Up @@ -2807,6 +2816,9 @@ export const Project = {
if (message.enableMaterializedView !== false) {
writer.uint32(160).bool(message.enableMaterializedView);
}
if (message.defaultTimerange !== undefined) {
TimeRangeLite.encode(message.defaultTimerange, writer.uint32(170).fork()).ldelim();
}
return writer;
},

Expand Down Expand Up @@ -2950,6 +2962,13 @@ export const Project = {

message.enableMaterializedView = reader.bool();
continue;
case 21:
if (tag !== 170) {
break;
}

message.defaultTimerange = TimeRangeLite.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
Expand Down Expand Up @@ -2986,6 +3005,7 @@ export const Project = {
enableMaterializedView: isSet(object.enableMaterializedView)
? globalThis.Boolean(object.enableMaterializedView)
: false,
defaultTimerange: isSet(object.defaultTimerange) ? TimeRangeLite.fromJSON(object.defaultTimerange) : undefined,
};
},

Expand Down Expand Up @@ -3048,6 +3068,9 @@ export const Project = {
if (message.enableMaterializedView !== false) {
obj.enableMaterializedView = message.enableMaterializedView;
}
if (message.defaultTimerange !== undefined) {
obj.defaultTimerange = TimeRangeLite.toJSON(message.defaultTimerange);
}
return obj;
},

Expand Down Expand Up @@ -3077,6 +3100,9 @@ export const Project = {
: undefined;
message.enableDisk = object.enableDisk ?? false;
message.enableMaterializedView = object.enableMaterializedView ?? false;
message.defaultTimerange = (object.defaultTimerange !== undefined && object.defaultTimerange !== null)
? TimeRangeLite.fromPartial(object.defaultTimerange)
: undefined;
return message;
},
};
Expand Down Expand Up @@ -3171,6 +3197,7 @@ function createBaseProjectInfo(): ProjectInfo {
superset: undefined,
enableDisk: false,
enableMaterializedView: false,
defaultTimerange: undefined,
};
}

Expand Down Expand Up @@ -3224,6 +3251,9 @@ export const ProjectInfo = {
if (message.enableMaterializedView !== false) {
writer.uint32(160).bool(message.enableMaterializedView);
}
if (message.defaultTimerange !== undefined) {
TimeRangeLite.encode(message.defaultTimerange, writer.uint32(170).fork()).ldelim();
}
return writer;
},

Expand Down Expand Up @@ -3332,6 +3362,13 @@ export const ProjectInfo = {

message.enableMaterializedView = reader.bool();
continue;
case 21:
if (tag !== 170) {
break;
}

message.defaultTimerange = TimeRangeLite.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
Expand Down Expand Up @@ -3359,6 +3396,7 @@ export const ProjectInfo = {
enableMaterializedView: isSet(object.enableMaterializedView)
? globalThis.Boolean(object.enableMaterializedView)
: false,
defaultTimerange: isSet(object.defaultTimerange) ? TimeRangeLite.fromJSON(object.defaultTimerange) : undefined,
};
},

Expand Down Expand Up @@ -3406,6 +3444,9 @@ export const ProjectInfo = {
if (message.enableMaterializedView !== false) {
obj.enableMaterializedView = message.enableMaterializedView;
}
if (message.defaultTimerange !== undefined) {
obj.defaultTimerange = TimeRangeLite.toJSON(message.defaultTimerange);
}
return obj;
},

Expand All @@ -3430,6 +3471,9 @@ export const ProjectInfo = {
: undefined;
message.enableDisk = object.enableDisk ?? false;
message.enableMaterializedView = object.enableMaterializedView ?? false;
message.defaultTimerange = (object.defaultTimerange !== undefined && object.defaultTimerange !== null)
? TimeRangeLite.fromPartial(object.defaultTimerange)
: undefined;
return message;
},
};
Expand Down
Loading

0 comments on commit 64238fe

Please sign in to comment.