Skip to content
Merged
Show file tree
Hide file tree
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
Binary file modified dist/javy-chainlink-sdk.plugin.wasm
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't include this in the repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is temporary until the npm package is published.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have no idea why mine is so much smaller. I ran bun build:all. I wonder if there had been a debug build checked in by mistake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in npm package I believe javy plugin needs to be included, dist is used by npm a lot to distribute artifacts, not sure what would be the alternative ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so the dist folder would be published in the npm package but not checked into this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffrifwaldsmartcontract or @ernest-nowacki, anything blocking this PR? I want to build on it to clean up the runtime more :)

Binary file not shown.
1,014 changes: 519 additions & 495 deletions src/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,115 +1,128 @@
import { fromBinary, toBinary, fromJson, create } from '@bufbuild/protobuf'
import { Mode, type CapabilityResponse } from '@cre/generated/sdk/v1alpha/sdk_pb'
import { callCapability } from '@cre/sdk/utils/capabilities/call-capability'
import { CapabilityError } from '@cre/sdk/utils/capabilities/capability-error'
import { type Trigger } from '@cre/sdk/utils/triggers/trigger-interface'
import { type Any, AnySchema } from '@bufbuild/protobuf/wkt'
import { getTypeUrl } from '@cre/sdk/utils/typeurl'
import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf";
import {
ConfigSchema,
InputSchema,
OutputSchema,
TriggerEventSchema,
type ConfigJson,
type InputJson,
type Output,
type TriggerEvent,
} from '@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb'
Mode,
type CapabilityResponse,
} from "@cre/generated/sdk/v1alpha/sdk_pb";
import { callCapability } from "@cre/sdk/utils/capabilities/call-capability";
import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error";
import { type Trigger } from "@cre/sdk/utils/triggers/trigger-interface";
import { type Any, AnySchema } from "@bufbuild/protobuf/wkt";
import { getTypeUrl } from "@cre/sdk/utils/typeurl";
import {
ConfigSchema,
InputSchema,
OutputSchema,
TriggerEventSchema,
type Config,
type ConfigJson,
type Input,
type InputJson,
type Output,
type TriggerEvent,
} from "@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb";

/**
* Basic Capability
*
*
* Capability ID: basic-test-action-trigger@1.0.0
* Default Mode: Mode.DON
* Capability Name: basic-test-action-trigger
* Capability Version: 1.0.0
*/
export class BasicCapability {
/** The capability ID for this service */
static readonly CAPABILITY_ID = 'basic-test-action-trigger@1.0.0'

/** The default execution mode for this capability */
static readonly DEFAULT_MODE = Mode.DON
/** The capability ID for this service */
static readonly CAPABILITY_ID = "basic-test-action-trigger@1.0.0";
/** The default execution mode for this capability */
static readonly DEFAULT_MODE = Mode.DON;

static readonly CAPABILITY_NAME = 'basic-test-action-trigger'
static readonly CAPABILITY_VERSION = '1.0.0'
static readonly CAPABILITY_NAME = "basic-test-action-trigger";
static readonly CAPABILITY_VERSION = "1.0.0";

constructor(private readonly mode: Mode = BasicCapability.DEFAULT_MODE) {}

async action(input: InputJson): Promise<Output> {
const payload = {
typeUrl: getTypeUrl(InputSchema),
value: toBinary(InputSchema, fromJson(InputSchema, input)),
}
const capabilityId = BasicCapability.CAPABILITY_ID
constructor(
private readonly mode: Mode = BasicCapability.DEFAULT_MODE
) {}

return callCapability({
capabilityId,
method: 'Action',
mode: this.mode,
payload,
}).then((capabilityResponse: CapabilityResponse) => {
if (capabilityResponse.response.case === 'error') {
throw new CapabilityError(capabilityResponse.response.value, {
capabilityId,
method: 'Action',
mode: this.mode,
})
}
async action(input: Input | InputJson): Promise<Output> {
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
const value = (input as any).$typeName ? input as Input : fromJson(InputSchema, input as InputJson)
const payload = {
typeUrl: getTypeUrl(InputSchema),
value: toBinary(InputSchema, value),
};
const capabilityId = BasicCapability.CAPABILITY_ID;

return callCapability({
capabilityId,
method: "Action",
mode: this.mode,
payload,
}).then((capabilityResponse: CapabilityResponse) => {
if (capabilityResponse.response.case === "error") {
throw new CapabilityError(capabilityResponse.response.value, {
capabilityId,
method: "Action",
mode: this.mode,
});
}

if (capabilityResponse.response.case !== 'payload') {
throw new CapabilityError('No payload in response', {
capabilityId,
method: 'Action',
mode: this.mode,
})
}
if (capabilityResponse.response.case !== "payload") {
throw new CapabilityError("No payload in response", {
capabilityId,
method: "Action",
mode: this.mode,
});
}

return fromBinary(OutputSchema, capabilityResponse.response.value.value)
})
}
return fromBinary(OutputSchema, capabilityResponse.response.value.value);
});
}

trigger(config: ConfigJson): BasicTrigger {
return new BasicTrigger(this.mode, config, BasicCapability.CAPABILITY_ID, 'Trigger')
}
trigger(config: ConfigJson): BasicTrigger {
return new BasicTrigger(this.mode, config, BasicCapability.CAPABILITY_ID, "Trigger");
}
}

/**
* Trigger implementation for Trigger
*/
class BasicTrigger implements Trigger<TriggerEvent, TriggerEvent> {
constructor(
public readonly mode: Mode,
public readonly config: ConfigJson,
private readonly _capabilityId: string,
private readonly _method: string,
) {}
public readonly config: Config
constructor(
public readonly mode: Mode,
config: Config | ConfigJson,
private readonly _capabilityId: string,
private readonly _method: string
) {
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
this.config = (config as any).$typeName ? config as Config : fromJson(ConfigSchema, config as ConfigJson)
}

capabilityId(): string {
return this._capabilityId
}
capabilityId(): string {
return this._capabilityId;
}

method(): string {
return this._method
}
method(): string {
return this._method;
}

outputSchema() {
return TriggerEventSchema
}
outputSchema() {
return TriggerEventSchema;
}

configAsAny(): Any {
const configMessage = fromJson(ConfigSchema, this.config)
return create(AnySchema, {
typeUrl: getTypeUrl(ConfigSchema),
value: toBinary(ConfigSchema, configMessage),
})
}
configAsAny(): Any {
return create(AnySchema, {
typeUrl: getTypeUrl(ConfigSchema),
value: toBinary(ConfigSchema, this.config),
});
}

/**
* Transform the raw trigger output - override this method if needed
* Default implementation returns the raw output unchanged
*/
adapt(rawOutput: TriggerEvent): TriggerEvent {
return rawOutput
}
}
/**
* Transform the raw trigger output - override this method if needed
* Default implementation returns the raw output unchanged
*/
adapt(rawOutput: TriggerEvent): TriggerEvent {
return rawOutput;
}
}
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
import { fromBinary, toBinary, fromJson, create } from '@bufbuild/protobuf'
import { Mode, type CapabilityResponse } from '@cre/generated/sdk/v1alpha/sdk_pb'
import { callCapability } from '@cre/sdk/utils/capabilities/call-capability'
import { CapabilityError } from '@cre/sdk/utils/capabilities/capability-error'
import { getTypeUrl } from '@cre/sdk/utils/typeurl'
import { fromBinary, toBinary, fromJson } from "@bufbuild/protobuf";
import {
InputsSchema,
OutputsSchema,
type InputsJson,
type Outputs,
} from '@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb'
Mode,
type CapabilityResponse,
} from "@cre/generated/sdk/v1alpha/sdk_pb";
import { callCapability } from "@cre/sdk/utils/capabilities/call-capability";
import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error";
import { getTypeUrl } from "@cre/sdk/utils/typeurl";
import {
InputsSchema,
OutputsSchema,
type Inputs,
type InputsJson,
type Outputs,
} from "@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb";

/**
* BasicAction Capability
*
*
* Capability ID: basic-test-action@1.0.0
* Default Mode: Mode.DON
* Capability Name: basic-test-action
* Capability Version: 1.0.0
*/
export class BasicActionCapability {
/** The capability ID for this service */
static readonly CAPABILITY_ID = 'basic-test-action@1.0.0'

/** The default execution mode for this capability */
static readonly DEFAULT_MODE = Mode.DON
/** The capability ID for this service */
static readonly CAPABILITY_ID = "basic-test-action@1.0.0";
/** The default execution mode for this capability */
static readonly DEFAULT_MODE = Mode.DON;

static readonly CAPABILITY_NAME = 'basic-test-action'
static readonly CAPABILITY_VERSION = '1.0.0'
static readonly CAPABILITY_NAME = "basic-test-action";
static readonly CAPABILITY_VERSION = "1.0.0";

constructor(private readonly mode: Mode = BasicActionCapability.DEFAULT_MODE) {}

async performAction(input: InputsJson): Promise<Outputs> {
const payload = {
typeUrl: getTypeUrl(InputsSchema),
value: toBinary(InputsSchema, fromJson(InputsSchema, input)),
}
const capabilityId = BasicActionCapability.CAPABILITY_ID
constructor(
private readonly mode: Mode = BasicActionCapability.DEFAULT_MODE
) {}

return callCapability({
capabilityId,
method: 'PerformAction',
mode: this.mode,
payload,
}).then((capabilityResponse: CapabilityResponse) => {
if (capabilityResponse.response.case === 'error') {
throw new CapabilityError(capabilityResponse.response.value, {
capabilityId,
method: 'PerformAction',
mode: this.mode,
})
}
async performAction(input: Inputs | InputsJson): Promise<Outputs> {
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
const value = (input as any).$typeName ? input as Inputs : fromJson(InputsSchema, input as InputsJson)
const payload = {
typeUrl: getTypeUrl(InputsSchema),
value: toBinary(InputsSchema, value),
};
const capabilityId = BasicActionCapability.CAPABILITY_ID;

return callCapability({
capabilityId,
method: "PerformAction",
mode: this.mode,
payload,
}).then((capabilityResponse: CapabilityResponse) => {
if (capabilityResponse.response.case === "error") {
throw new CapabilityError(capabilityResponse.response.value, {
capabilityId,
method: "PerformAction",
mode: this.mode,
});
}

if (capabilityResponse.response.case !== 'payload') {
throw new CapabilityError('No payload in response', {
capabilityId,
method: 'PerformAction',
mode: this.mode,
})
}
if (capabilityResponse.response.case !== "payload") {
throw new CapabilityError("No payload in response", {
capabilityId,
method: "PerformAction",
mode: this.mode,
});
}

return fromBinary(OutputsSchema, capabilityResponse.response.value.value)
})
}
return fromBinary(OutputsSchema, capabilityResponse.response.value.value);
});
}
}
Loading
Loading