Skip to content

Commit

Permalink
chore(providers): improve tx types
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Oct 29, 2024
1 parent 8a4fc50 commit d51e6fb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"files": ["dist"],
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"test": "bun test",
"cleanup": "rimraf dist .turbo"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"files": ["dist"],
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"test": "bun test --rerun-each 3",
"cleanup": "rimraf dist .turbo"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/klesia-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"files": ["dist"],
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"test": "bun test --rerun-each 3",
"cleanup": "rimraf dist .turbo"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"files": ["dist"],
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"test": "bun test",
"cleanup": "rimraf dist .turbo"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"files": ["dist"],
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"test": "bun test",
"cleanup": "rimraf dist .turbo"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
TransactionBodySchema,
TransactionPayloadSchema,
TransactionReceiptSchema,
ZkAppCommandBodySchema,
ZkAppCommandPayload,
} from "./validation";

Expand All @@ -24,6 +25,7 @@ export type PrivateKey = z.infer<typeof PrivateKeySchema>;
export type TransactionBody = z.infer<typeof TransactionBodySchema>;
export type TransactionPayload = z.infer<typeof TransactionPayloadSchema>;
export type PartialTransaction = z.infer<typeof PartialTransactionSchema>;
export type ZkAppCommandBody = z.infer<typeof ZkAppCommandBodySchema>;
export type ZkAppCommandProperties = z.infer<typeof ZkAppCommandPayload>;

/**
Expand Down
12 changes: 9 additions & 3 deletions packages/utils/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,24 @@ export const TransactionPayloadSchema = z
})
.strict();

export const PartialTransactionSchema = TransactionPayloadSchema.extend({
export const PartialTransactionSchema = TransactionBodySchema.extend({
fee: z.coerce.string().optional(),
nonce: z.coerce.string().optional(),
});

export const ZkAppCommandPayload = z
export const ZkAppCommandBodySchema = z
.object({
zkappCommand: JsonSchema,
feePayer: FeePayerSchema,
})
.strict();

export const ZkAppCommandPayload = z
.object({
command: ZkAppCommandBodySchema,
})
.strict();

/**
* Return type schemas
*/
Expand Down Expand Up @@ -112,7 +118,7 @@ export const SignedTransactionSchema = z
.object({
signature: SignatureSchema,
publicKey: PublicKeySchema,
data: z.union([TransactionBodySchema, ZkAppCommandPayload]),
data: z.union([TransactionBodySchema, ZkAppCommandBodySchema]),
})
.strict();

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "@tsconfig/bun/tsconfig.json"
"extends": "@tsconfig/bun/tsconfig.json",
"exclude": ["apps"]
}

0 comments on commit d51e6fb

Please sign in to comment.