@thirdweb-dev/service-utils 0.4.1 → 0.4.2-nightly-7e483ec9-20230808002741
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.
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.dev.js +12 -8
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.prod.js +12 -8
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.esm.js +12 -8
- package/dist/declarations/src/cf-worker/usage.d.ts +4 -1
- package/dist/declarations/src/cf-worker/usage.d.ts.map +1 -1
- package/package.json +1 -1
@@ -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,16 +59,20 @@ async function publishUsageEvents(usageEvents, config) {
|
|
58
59
|
secretAccessKey,
|
59
60
|
region = "us-west-2"
|
60
61
|
} = config;
|
61
|
-
const entries = usageEvents.map(event =>
|
62
|
-
|
63
|
-
|
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,
|
68
73
|
region
|
69
74
|
});
|
70
|
-
|
75
|
+
await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
|
71
76
|
headers: {
|
72
77
|
"X-Amz-Target": "AmazonSQS.SendMessageBatch",
|
73
78
|
"X-Amz-Date": new Date().toISOString(),
|
@@ -78,7 +83,6 @@ async function publishUsageEvents(usageEvents, config) {
|
|
78
83
|
Entries: entries
|
79
84
|
})
|
80
85
|
});
|
81
|
-
return await res.text();
|
82
86
|
}
|
83
87
|
|
84
88
|
const DEFAULT_CACHE_TTL_SECONDS = 60;
|
@@ -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,16 +59,20 @@ async function publishUsageEvents(usageEvents, config) {
|
|
58
59
|
secretAccessKey,
|
59
60
|
region = "us-west-2"
|
60
61
|
} = config;
|
61
|
-
const entries = usageEvents.map(event =>
|
62
|
-
|
63
|
-
|
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,
|
68
73
|
region
|
69
74
|
});
|
70
|
-
|
75
|
+
await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
|
71
76
|
headers: {
|
72
77
|
"X-Amz-Target": "AmazonSQS.SendMessageBatch",
|
73
78
|
"X-Amz-Date": new Date().toISOString(),
|
@@ -78,7 +83,6 @@ async function publishUsageEvents(usageEvents, config) {
|
|
78
83
|
Entries: entries
|
79
84
|
})
|
80
85
|
});
|
81
|
-
return await res.text();
|
82
86
|
}
|
83
87
|
|
84
88
|
const DEFAULT_CACHE_TTL_SECONDS = 60;
|
@@ -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,16 +55,20 @@ async function publishUsageEvents(usageEvents, config) {
|
|
54
55
|
secretAccessKey,
|
55
56
|
region = "us-west-2"
|
56
57
|
} = config;
|
57
|
-
const entries = usageEvents.map(event =>
|
58
|
-
|
59
|
-
|
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,
|
64
69
|
region
|
65
70
|
});
|
66
|
-
|
71
|
+
await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
|
67
72
|
headers: {
|
68
73
|
"X-Amz-Target": "AmazonSQS.SendMessageBatch",
|
69
74
|
"X-Amz-Date": new Date().toISOString(),
|
@@ -74,7 +79,6 @@ async function publishUsageEvents(usageEvents, config) {
|
|
74
79
|
Entries: entries
|
75
80
|
})
|
76
81
|
});
|
77
|
-
return await res.text();
|
78
82
|
}
|
79
83
|
|
80
84
|
const DEFAULT_CACHE_TTL_SECONDS = 60;
|
@@ -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
|
/**
|
@@ -71,6 +74,6 @@ export declare function publishUsageEvents(usageEvents: UsageEvent[], config: {
|
|
71
74
|
accessKeyId: string;
|
72
75
|
secretAccessKey: string;
|
73
76
|
region?: string;
|
74
|
-
}): Promise<
|
77
|
+
}): Promise<void>;
|
75
78
|
export {};
|
76
79
|
//# sourceMappingURL=usage.d.ts.map
|
@@ -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
|
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,IAAI,CAAC,CAiCf"}
|
package/package.json
CHANGED