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
1 change: 1 addition & 0 deletions packages/agent-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./evm";
export * from "./request";
export * from "./error";
export * from "./misc";
export * from "./openai";
3 changes: 3 additions & 0 deletions packages/agent-sdk/src/openai/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./params";
export * from "./response";
export * from "./schema";
35 changes: 35 additions & 0 deletions packages/agent-sdk/src/openai/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export const chainIdParam = {
name: "chainId",
in: "query",
required: true,
description: "EVM Network (aka chain ID)",
schema: { type: "number" },
example: 100,
};

export const addressParam = {
name: "address",
in: "query",
required: true,
description: "20 byte Ethereum address with 0x prefix",
schema: { type: "string" },
};

export const addressOrSymbolParam = {
name: "address",
in: "query",
required: true,
description:
"The ERC-20 token symbol or address to be sold, if provided with the symbol do not try to infer the address.",
schema: { type: "string" },
example: "0x6810e776880c02933d47db1b9fc05908e5386b96",
};

export const amountParam = {
name: "amount",
in: "query",
required: true,
description: "Amount in human-readable units (not wei)",
schema: { type: "number" },
example: 0.123,
};
19 changes: 19 additions & 0 deletions packages/agent-sdk/src/openai/response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const SignRequestResponse200 = {
description: "Successful signing request",
content: {
"application/json": {
schema: {
type: "object",
required: ["transaction"],
properties: {
transaction: { $ref: "#/components/schemas/SignRequest" },
meta: {
type: "object",
additionalProperties: true,
example: { message: "Submitted" },
},
},
},
},
},
};
58 changes: 58 additions & 0 deletions packages/agent-sdk/src/openai/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const AddressSchema = {
description: "20 byte Ethereum address encoded as a hex with `0x` prefix.",
type: "string",
example: "0x6810e776880c02933d47db1b9fc05908e5386b96",
};

export const MetaTransactionSchema = {
type: "object",
description: "Sufficient data representing an EVM transaction",
properties: {
to: { $ref: "#/components/schemas/Address" },
data: {
type: "string",
description: "Transaction calldata",
example: "0xd0e30db0",
},
value: {
type: "string",
description: "Transaction value",
example: "0x1b4fbd92b5f8000",
},
},
required: ["to", "data", "value"],
};

export const SignRequestSchema = {
type: "object",
required: ["method", "chainId", "params"],
properties: {
method: {
type: "string",
enum: [
"eth_sign",
"personal_sign",
"eth_sendTransaction",
"eth_signTypedData",
"eth_signTypedData_v4",
],
description: "The signing method to be used.",
},
chainId: {
type: "integer",
description: "The ID of the Ethereum chain.",
},
params: {
oneOf: [
{
type: "array",
items: { $ref: "#/components/schemas/MetaTransaction" },
},
{
type: "array",
items: { type: "string" },
},
],
},
},
};