-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): split runtime out from sdk
- Loading branch information
Showing
45 changed files
with
332 additions
and
232 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
const { pathsToModuleNameMapper } = require('ts-jest'); | ||
const { compilerOptions } = require('./tsconfig'); | ||
|
||
// TODO seems not fully ignored | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
modulePathIgnorePatterns: ["<rootDir>/dist/", "<rootDir>/lib/", "<rootDir>/templates/"], | ||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src/' } ) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
packages/sdk/src/endpoints.ts → packages/runtime/src/endpoints.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { CallContext } from 'nice-grpc' | ||
|
||
// Different than the simple one which | ||
import { | ||
DataBinding, | ||
HandlerType, | ||
ProcessBindingsRequest, | ||
ProcessConfigRequest, | ||
ProcessorServiceImplementation, | ||
StartRequest, | ||
} from './gen/processor/protos/processor' | ||
|
||
import { Empty } from '@sentio/protos/lib/google/protobuf/empty' | ||
|
||
export class FullProcessorServiceImpl implements ProcessorServiceImplementation { | ||
constructor(instance: ProcessorServiceImplementation) { | ||
this.instance = instance | ||
} | ||
|
||
instance: ProcessorServiceImplementation | ||
|
||
async getConfig(request: ProcessConfigRequest, context: CallContext) { | ||
return this.instance.getConfig(request, context) | ||
} | ||
|
||
async start(request: StartRequest, context: CallContext) { | ||
return this.instance.start(request, context) | ||
} | ||
|
||
async stop(request: Empty, context: CallContext) { | ||
return this.instance.stop(request, context) | ||
} | ||
|
||
async processBindings(request: ProcessBindingsRequest, options: CallContext) { | ||
for (const binding of request.bindings) { | ||
this.adjustDataBinding(binding) | ||
} | ||
return this.instance.processBindings(request, options) | ||
} | ||
|
||
async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) { | ||
throw new Error('Not Implemented for streaming') | ||
// y this.instance.processBindingsStream(requests, context) | ||
} | ||
|
||
protected adjustDataBinding(dataBinding: DataBinding): void { | ||
switch (dataBinding.handlerType) { | ||
case HandlerType.UNKNOWN: | ||
if (dataBinding.data?.ethBlock) { | ||
if (dataBinding.data.raw.length === 0) { | ||
// This is actually not needed in current system, just as initla test propose, move to test only | ||
// when this is stable | ||
dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block)) | ||
} | ||
} | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
} |
85 changes: 45 additions & 40 deletions
85
.../src/gen/src/google/protobuf/timestamp.ts → ...time/src/gen/google/protobuf/timestamp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,91 @@ | ||
/* eslint-disable */ | ||
import Long from "long"; | ||
import _m0 from "protobufjs/minimal"; | ||
import Long from 'long' | ||
import _m0 from 'protobufjs/minimal' | ||
|
||
export interface Timestamp { | ||
seconds: bigint; | ||
nanos: number; | ||
seconds: bigint | ||
nanos: number | ||
} | ||
|
||
function createBaseTimestamp(): Timestamp { | ||
return { seconds: BigInt("0"), nanos: 0 }; | ||
return { seconds: BigInt('0'), nanos: 0 } | ||
} | ||
|
||
export const Timestamp = { | ||
encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
if (message.seconds !== BigInt("0")) { | ||
writer.uint32(8).int64(message.seconds.toString()); | ||
if (message.seconds !== BigInt('0')) { | ||
writer.uint32(8).int64(message.seconds.toString()) | ||
} | ||
if (message.nanos !== 0) { | ||
writer.uint32(16).int32(message.nanos); | ||
writer.uint32(16).int32(message.nanos) | ||
} | ||
return writer; | ||
return writer | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseTimestamp(); | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) | ||
let end = length === undefined ? reader.len : reader.pos + length | ||
const message = createBaseTimestamp() | ||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
const tag = reader.uint32() | ||
switch (tag >>> 3) { | ||
case 1: | ||
message.seconds = longToBigint(reader.int64() as Long); | ||
break; | ||
message.seconds = longToBigint(reader.int64() as Long) | ||
break | ||
case 2: | ||
message.nanos = reader.int32(); | ||
break; | ||
message.nanos = reader.int32() | ||
break | ||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
reader.skipType(tag & 7) | ||
break | ||
} | ||
} | ||
return message; | ||
return message | ||
}, | ||
|
||
fromJSON(object: any): Timestamp { | ||
return { | ||
seconds: isSet(object.seconds) ? BigInt(object.seconds) : BigInt("0"), | ||
seconds: isSet(object.seconds) ? BigInt(object.seconds) : BigInt('0'), | ||
nanos: isSet(object.nanos) ? Number(object.nanos) : 0, | ||
}; | ||
} | ||
}, | ||
|
||
toJSON(message: Timestamp): unknown { | ||
const obj: any = {}; | ||
message.seconds !== undefined && (obj.seconds = message.seconds.toString()); | ||
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); | ||
return obj; | ||
const obj: any = {} | ||
message.seconds !== undefined && (obj.seconds = message.seconds.toString()) | ||
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)) | ||
return obj | ||
}, | ||
|
||
fromPartial(object: DeepPartial<Timestamp>): Timestamp { | ||
const message = createBaseTimestamp(); | ||
message.seconds = object.seconds ?? BigInt("0"); | ||
message.nanos = object.nanos ?? 0; | ||
return message; | ||
const message = createBaseTimestamp() | ||
message.seconds = object.seconds ?? BigInt('0') | ||
message.nanos = object.nanos ?? 0 | ||
return message | ||
}, | ||
}; | ||
} | ||
|
||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; | ||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | ||
|
||
type DeepPartial<T> = T extends Builtin ? T | ||
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> | ||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } | ||
: Partial<T>; | ||
type DeepPartial<T> = T extends Builtin | ||
? T | ||
: T extends Array<infer U> | ||
? Array<DeepPartial<U>> | ||
: T extends ReadonlyArray<infer U> | ||
? ReadonlyArray<DeepPartial<U>> | ||
: T extends {} | ||
? { [K in keyof T]?: DeepPartial<T[K]> } | ||
: Partial<T> | ||
|
||
function longToBigint(long: Long) { | ||
return BigInt(long.toString()); | ||
return BigInt(long.toString()) | ||
} | ||
|
||
if (_m0.util.Long !== Long) { | ||
_m0.util.Long = Long as any; | ||
_m0.configure(); | ||
_m0.util.Long = Long as any | ||
_m0.configure() | ||
} | ||
|
||
function isSet(value: any): boolean { | ||
return value !== null && value !== undefined; | ||
return value !== null && value !== undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from './provider' | ||
export * from './plugin' | ||
export * from './state' | ||
export * from './utils' | ||
export * from './endpoints' | ||
export * from './chain-config' | ||
export * from './service' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.