Skip to content

Update engine API #7427

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

Merged
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
5 changes: 5 additions & 0 deletions .changeset/heavy-banks-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/engine": minor
---

New engine v3 APIs - see changelog for breaking changes
5 changes: 5 additions & 0 deletions .changeset/lovely-brooms-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Support latest engine API
2 changes: 1 addition & 1 deletion apps/dashboard/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"extends": "//"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ type ExecutionResult4337Serialized =
}
| {
status: "FAILED";
error: string;
error: {
stage: string;
message: string;
errorCode: string;
inner_error: object;
nonce_used: string;
account_address: string;
};
}
| {
status: "SUBMITTED";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { format, formatDistanceToNowStrict } from "date-fns";
import { ExternalLinkIcon, InfoIcon } from "lucide-react";
import Link from "next/link";
import { type ThirdwebClient, toEther } from "thirdweb";
import { hexToNumber, isHex, type ThirdwebClient, toEther } from "thirdweb";
import type { Project } from "@/api/projects";
import { WalletAddress } from "@/components/blocks/wallet-address";
import { Badge } from "@/components/ui/badge";
Expand Down Expand Up @@ -43,10 +43,14 @@ export function TransactionDetailsUI({
const status = executionResult?.status as keyof typeof statusDetails;
const errorMessage =
executionResult && "error" in executionResult
? executionResult.error
? executionResult.error.message
: executionResult && "revertData" in executionResult
? executionResult.revertData?.revertReason
: null;
const errorDetails =
executionResult && "error" in executionResult
? executionResult.error
: undefined;

const chain = chainId ? idToChain.get(Number.parseInt(chainId)) : undefined;
const explorer = chain?.explorers?.[0];
Expand All @@ -64,7 +68,7 @@ export function TransactionDetailsUI({
// Gas information
const gasUsed =
executionResult && "actualGasUsed" in executionResult
? `${executionResult.actualGasUsed}`
? `${isHex(executionResult.actualGasUsed) ? hexToNumber(executionResult.actualGasUsed) : executionResult.actualGasUsed}`
: "N/A";

const gasCost =
Expand Down Expand Up @@ -244,9 +248,16 @@ export function TransactionDetailsUI({
</CardTitle>
</CardHeader>
<CardContent>
<div className="rounded-md bg-destructive/10 p-4 text-destructive">
{errorMessage}
</div>
{errorDetails ? (
<CodeClient
code={JSON.stringify(errorDetails, null, 2)}
lang="json"
/>
) : (
<div className="rounded-md bg-destructive/10 p-4 text-destructive">
{errorMessage}
</div>
)}
</CardContent>
</Card>
)}
Expand Down Expand Up @@ -328,7 +339,9 @@ export function TransactionDetailsUI({
Block Number
</div>
<div className="text-sm md:w-2/3">
{transaction.confirmedAtBlockNumber}
{isHex(transaction.confirmedAtBlockNumber)
? hexToNumber(transaction.confirmedAtBlockNumber)
: transaction.confirmedAtBlockNumber}
</div>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/nebula/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"extends": "//"
}
2 changes: 1 addition & 1 deletion apps/playground-web/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"extends": "//"
}
2 changes: 1 addition & 1 deletion apps/portal/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"extends": "//"
}
2 changes: 1 addition & 1 deletion apps/wallet-ui/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"extends": "//"
}
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"assist": {
"actions": {
"source": {
Expand Down
17 changes: 15 additions & 2 deletions packages/engine/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"extends": "//"
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
"linter": {
"rules": {
"correctness": {
"useImportExtensions": {
"fix": "safe",
"level": "error",
"options": {
"forceJsExtensions": true
}
}
}
}
},
"root": true
}
1 change: 0 additions & 1 deletion packages/engine/openapi-ts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ import { defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({
input: "https://engine.thirdweb.com/openapi",
output: { format: "biome", lint: "biome", path: "src/client" },
plugins: ["@hey-api/client-fetch"],
});
25 changes: 14 additions & 11 deletions packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
"type": "git",
"url": "git+https://github.com/thirdweb-dev/js.git#main"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/thirdweb-dev/js/issues"
},
"author": "thirdweb eng <[email protected]>",
"type": "module",
"main": "./dist/cjs/exports/thirdweb.js",
"module": "./dist/esm/exports/thirdweb.js",
"types": "./dist/types/exports/thirdweb.d.ts",
"typings": "./dist/types/exports/thirdweb.d.ts",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/thirdweb-dev/js/issues"
},
"dependencies": {
"@hey-api/client-fetch": "0.10.0"
},
"engines": {
"node": ">=18"
},
"exports": {
".": {
"types": "./dist/types/exports/thirdweb.d.ts",
Expand Down Expand Up @@ -42,17 +48,14 @@
}
},
"scripts": {
"format": "biome format ./src --write",
"lint": "biome check ./src",
"fix": "biome check ./src --fix",
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm && pnpm build:types",
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
"build:esm": "tsc --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json",
"build:generate": "openapi-ts && pnpm format && pnpm fix",
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rimraf dist",
"build:generate": "openapi-ts && pnpm format"
},
"engines": {
"node": ">=18"
"fix": "biome check --write ./src",
"format": "biome format --write ./src",
"lint": "biome check ./src"
}
}
20 changes: 10 additions & 10 deletions packages/engine/src/client/client.gen.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This file is auto-generated by @hey-api/openapi-ts

import {
type Config,
createClient,
createConfig,
type ClientOptions as DefaultClientOptions,
type Config,
createClient,
createConfig,
type ClientOptions as DefaultClientOptions,
} from "./client/index.js";
import type { ClientOptions } from "./types.gen.js";

Expand All @@ -17,12 +17,12 @@ import type { ClientOptions } from "./types.gen.js";
* to ensure your client always has the correct values.
*/
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =
(
override?: Config<DefaultClientOptions & T>,
) => Config<Required<DefaultClientOptions> & T>;
(
override?: Config<DefaultClientOptions & T>,
) => Config<Required<DefaultClientOptions> & T>;

export const client = createClient(
createConfig<ClientOptions>({
baseUrl: "https://engine.thirdweb.com",
}),
createConfig<ClientOptions>({
baseUrl: "https://engine.thirdweb.com",
}),
);
Loading
Loading