@thirdweb-dev/service-utils 0.4.1-nightly-4b0e63dc-20230807165538 → 0.4.2-nightly-205018f6-20230807235029

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ function getAws(options) {
19
19
  /**
20
20
  * Types
21
21
  */
22
- zod.z.object({
22
+ const usageEventSchema = zod.z.object({
23
23
  source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
24
24
  action: zod.z.string(),
25
25
  accountId: zod.z.string(),
@@ -35,7 +35,8 @@ zod.z.object({
35
35
  fileCid: zod.z.string().optional(),
36
36
  transactionHash: zod.z.string().optional(),
37
37
  gasLimit: zod.z.number().nonnegative().optional(),
38
- gasPricePerUnit: zod.z.string().optional()
38
+ gasPricePerUnit: zod.z.string().optional(),
39
+ userOpHash: zod.z.string().optional()
39
40
  });
40
41
  /**
41
42
  * Publish usage events. Provide the relevant fields for your application.
@@ -58,10 +59,14 @@ async function publishUsageEvents(usageEvents, config) {
58
59
  secretAccessKey,
59
60
  region = "us-west-2"
60
61
  } = config;
61
- const entries = usageEvents.map(event => ({
62
- Id: crypto.randomUUID(),
63
- MessageBody: JSON.stringify(event)
64
- }));
62
+ const entries = usageEvents.map(event => {
63
+ // Enforce schema of usage event.
64
+ const parsed = usageEventSchema.parse(event);
65
+ return {
66
+ Id: crypto.randomUUID(),
67
+ MessageBody: JSON.stringify(parsed)
68
+ };
69
+ });
65
70
  const aws = getAws({
66
71
  accessKeyId,
67
72
  secretAccessKey,
@@ -19,7 +19,7 @@ function getAws(options) {
19
19
  /**
20
20
  * Types
21
21
  */
22
- zod.z.object({
22
+ const usageEventSchema = zod.z.object({
23
23
  source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
24
24
  action: zod.z.string(),
25
25
  accountId: zod.z.string(),
@@ -35,7 +35,8 @@ zod.z.object({
35
35
  fileCid: zod.z.string().optional(),
36
36
  transactionHash: zod.z.string().optional(),
37
37
  gasLimit: zod.z.number().nonnegative().optional(),
38
- gasPricePerUnit: zod.z.string().optional()
38
+ gasPricePerUnit: zod.z.string().optional(),
39
+ userOpHash: zod.z.string().optional()
39
40
  });
40
41
  /**
41
42
  * Publish usage events. Provide the relevant fields for your application.
@@ -58,10 +59,14 @@ async function publishUsageEvents(usageEvents, config) {
58
59
  secretAccessKey,
59
60
  region = "us-west-2"
60
61
  } = config;
61
- const entries = usageEvents.map(event => ({
62
- Id: crypto.randomUUID(),
63
- MessageBody: JSON.stringify(event)
64
- }));
62
+ const entries = usageEvents.map(event => {
63
+ // Enforce schema of usage event.
64
+ const parsed = usageEventSchema.parse(event);
65
+ return {
66
+ Id: crypto.randomUUID(),
67
+ MessageBody: JSON.stringify(parsed)
68
+ };
69
+ });
65
70
  const aws = getAws({
66
71
  accessKeyId,
67
72
  secretAccessKey,
@@ -15,7 +15,7 @@ function getAws(options) {
15
15
  /**
16
16
  * Types
17
17
  */
18
- z.object({
18
+ const usageEventSchema = z.object({
19
19
  source: z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
20
20
  action: z.string(),
21
21
  accountId: z.string(),
@@ -31,7 +31,8 @@ z.object({
31
31
  fileCid: z.string().optional(),
32
32
  transactionHash: z.string().optional(),
33
33
  gasLimit: z.number().nonnegative().optional(),
34
- gasPricePerUnit: z.string().optional()
34
+ gasPricePerUnit: z.string().optional(),
35
+ userOpHash: z.string().optional()
35
36
  });
36
37
  /**
37
38
  * Publish usage events. Provide the relevant fields for your application.
@@ -54,10 +55,14 @@ async function publishUsageEvents(usageEvents, config) {
54
55
  secretAccessKey,
55
56
  region = "us-west-2"
56
57
  } = config;
57
- const entries = usageEvents.map(event => ({
58
- Id: crypto.randomUUID(),
59
- MessageBody: JSON.stringify(event)
60
- }));
58
+ const entries = usageEvents.map(event => {
59
+ // Enforce schema of usage event.
60
+ const parsed = usageEventSchema.parse(event);
61
+ return {
62
+ Id: crypto.randomUUID(),
63
+ MessageBody: JSON.stringify(parsed)
64
+ };
65
+ });
61
66
  const aws = getAws({
62
67
  accessKeyId,
63
68
  secretAccessKey,
@@ -18,6 +18,7 @@ declare const usageEventSchema: z.ZodObject<{
18
18
  transactionHash: z.ZodOptional<z.ZodString>;
19
19
  gasLimit: z.ZodOptional<z.ZodNumber>;
20
20
  gasPricePerUnit: z.ZodOptional<z.ZodString>;
21
+ userOpHash: z.ZodOptional<z.ZodString>;
21
22
  }, "strip", z.ZodTypeAny, {
22
23
  source: "storage" | "rpc" | "bundler" | "relayer" | "wallet" | "paymaster";
23
24
  action: string;
@@ -34,6 +35,7 @@ declare const usageEventSchema: z.ZodObject<{
34
35
  transactionHash?: string | undefined;
35
36
  gasLimit?: number | undefined;
36
37
  gasPricePerUnit?: string | undefined;
38
+ userOpHash?: string | undefined;
37
39
  }, {
38
40
  source: "storage" | "rpc" | "bundler" | "relayer" | "wallet" | "paymaster";
39
41
  action: string;
@@ -50,6 +52,7 @@ declare const usageEventSchema: z.ZodObject<{
50
52
  transactionHash?: string | undefined;
51
53
  gasLimit?: number | undefined;
52
54
  gasPricePerUnit?: string | undefined;
55
+ userOpHash?: string | undefined;
53
56
  }>;
54
57
  export type UsageEvent = z.infer<typeof usageEventSchema>;
55
58
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBpB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BpB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,MAAM,CAAC,CAkCjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdweb-dev/service-utils",
3
- "version": "0.4.1-nightly-4b0e63dc-20230807165538",
3
+ "version": "0.4.2-nightly-205018f6-20230807235029",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {