Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUTOMATED] Update files from 0xsequence/sequence-sessions #606

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 90 additions & 19 deletions packages/sessions/src/trackers/remote/sessions.gen.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,70 @@
/* eslint-disable */
// sessions v0.0.1 67f782e8acfe452f905078a7423ed5d27c6639a8
// sessions v0.0.1 48681273e3b0249c5feb593b9af1b59dc6a14869
// --
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
// Code generated by webrpc-gen@v0.22.1 with typescript generator. DO NOT EDIT.
//
// webrpc-gen -schema=sessions.ridl -target=typescript -client -out=./clients/sessions.gen.ts

export const WebrpcHeader = 'Webrpc'

export const WebrpcHeaderValue = 'webrpc@v0.22.1;gen-typescript@v0.16.2;sessions@v0.0.1'

// WebRPC description and code-gen version
export const WebRPCVersion = 'v1'

// Schema version of your RIDL schema
export const WebRPCSchemaVersion = 'v0.0.1'

// Schema hash generated from your RIDL schema
export const WebRPCSchemaHash = '67f782e8acfe452f905078a7423ed5d27c6639a8'
export const WebRPCSchemaHash = '48681273e3b0249c5feb593b9af1b59dc6a14869'

type WebrpcGenVersions = {
webrpcGenVersion: string
codeGenName: string
codeGenVersion: string
schemaName: string
schemaVersion: string
}

export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
const headerValue = headers.get(WebrpcHeader)
if (!headerValue) {
return {
webrpcGenVersion: '',
codeGenName: '',
codeGenVersion: '',
schemaName: '',
schemaVersion: ''
}
}

return parseWebrpcGenVersions(headerValue)
}

function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
const versions = header.split(';')
if (versions.length < 3) {
return {
webrpcGenVersion: '',
codeGenName: '',
codeGenVersion: '',
schemaName: '',
schemaVersion: ''
}
}

const [_, webrpcGenVersion] = versions[0].split('@')
const [codeGenName, codeGenVersion] = versions[1].split('@')
const [schemaName, schemaVersion] = versions[2].split('@')

return {
webrpcGenVersion,
codeGenName,
codeGenVersion,
schemaName,
schemaVersion
}
}

//
// Types
Expand Down Expand Up @@ -127,9 +179,9 @@ export interface Signature {
}

export interface SignerSignature {
referenceChainID?: string
signer?: string
signature: string
referenceChainID?: string
}

export interface ConfigUpdate {
Expand Down Expand Up @@ -474,9 +526,12 @@ export class Sessions implements Sessions {
}

const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
reqHeaders[WebrpcHeader] = WebrpcHeaderValue

return {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
headers: reqHeaders,
body: JSON.stringify(body || {}),
signal
}
Expand Down Expand Up @@ -541,7 +596,7 @@ export class WebrpcEndpointError extends WebrpcError {
constructor(
name: string = 'WebrpcEndpoint',
code: number = 0,
message: string = 'endpoint error',
message: string = `endpoint error`,
status: number = 0,
cause?: string
) {
Expand All @@ -554,7 +609,7 @@ export class WebrpcRequestFailedError extends WebrpcError {
constructor(
name: string = 'WebrpcRequestFailed',
code: number = -1,
message: string = 'request failed',
message: string = `request failed`,
status: number = 0,
cause?: string
) {
Expand All @@ -567,7 +622,7 @@ export class WebrpcBadRouteError extends WebrpcError {
constructor(
name: string = 'WebrpcBadRoute',
code: number = -2,
message: string = 'bad route',
message: string = `bad route`,
status: number = 0,
cause?: string
) {
Expand All @@ -580,7 +635,7 @@ export class WebrpcBadMethodError extends WebrpcError {
constructor(
name: string = 'WebrpcBadMethod',
code: number = -3,
message: string = 'bad method',
message: string = `bad method`,
status: number = 0,
cause?: string
) {
Expand All @@ -593,7 +648,7 @@ export class WebrpcBadRequestError extends WebrpcError {
constructor(
name: string = 'WebrpcBadRequest',
code: number = -4,
message: string = 'bad request',
message: string = `bad request`,
status: number = 0,
cause?: string
) {
Expand All @@ -606,7 +661,7 @@ export class WebrpcBadResponseError extends WebrpcError {
constructor(
name: string = 'WebrpcBadResponse',
code: number = -5,
message: string = 'bad response',
message: string = `bad response`,
status: number = 0,
cause?: string
) {
Expand All @@ -619,7 +674,7 @@ export class WebrpcServerPanicError extends WebrpcError {
constructor(
name: string = 'WebrpcServerPanic',
code: number = -6,
message: string = 'server panic',
message: string = `server panic`,
status: number = 0,
cause?: string
) {
Expand All @@ -632,7 +687,7 @@ export class WebrpcInternalErrorError extends WebrpcError {
constructor(
name: string = 'WebrpcInternalError',
code: number = -7,
message: string = 'internal error',
message: string = `internal error`,
status: number = 0,
cause?: string
) {
Expand All @@ -645,7 +700,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError {
constructor(
name: string = 'WebrpcClientDisconnected',
code: number = -8,
message: string = 'client disconnected',
message: string = `client disconnected`,
status: number = 0,
cause?: string
) {
Expand All @@ -658,7 +713,7 @@ export class WebrpcStreamLostError extends WebrpcError {
constructor(
name: string = 'WebrpcStreamLost',
code: number = -9,
message: string = 'stream lost',
message: string = `stream lost`,
status: number = 0,
cause?: string
) {
Expand All @@ -671,7 +726,7 @@ export class WebrpcStreamFinishedError extends WebrpcError {
constructor(
name: string = 'WebrpcStreamFinished',
code: number = -10,
message: string = 'stream finished',
message: string = `stream finished`,
status: number = 0,
cause?: string
) {
Expand All @@ -686,7 +741,7 @@ export class InvalidArgumentError extends WebrpcError {
constructor(
name: string = 'InvalidArgument',
code: number = 1,
message: string = 'invalid argument',
message: string = `invalid argument`,
status: number = 0,
cause?: string
) {
Expand All @@ -696,7 +751,7 @@ export class InvalidArgumentError extends WebrpcError {
}

export class NotFoundError extends WebrpcError {
constructor(name: string = 'NotFound', code: number = 2, message: string = 'not found', status: number = 0, cause?: string) {
constructor(name: string = 'NotFound', code: number = 2, message: string = `not found`, status: number = 0, cause?: string) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, NotFoundError.prototype)
}
Expand All @@ -718,7 +773,23 @@ export enum errors {
NotFound = 'NotFound'
}

const webrpcErrorByCode: { [code: number]: any } = {
export enum WebrpcErrorCodes {
WebrpcEndpoint = 0,
WebrpcRequestFailed = -1,
WebrpcBadRoute = -2,
WebrpcBadMethod = -3,
WebrpcBadRequest = -4,
WebrpcBadResponse = -5,
WebrpcServerPanic = -6,
WebrpcInternalError = -7,
WebrpcClientDisconnected = -8,
WebrpcStreamLost = -9,
WebrpcStreamFinished = -10,
InvalidArgument = 1,
NotFound = 2
}

export const webrpcErrorByCode: { [code: number]: any } = {
[0]: WebrpcEndpointError,
[-1]: WebrpcRequestFailedError,
[-2]: WebrpcBadRouteError,
Expand Down