@alchemy/wallet-apis 0.0.0-alpha.20 → 0.0.0-alpha.22
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/LICENSE +1 -1
- package/README.md +30 -0
- package/dist/esm/actions/formatSign.js +3 -4
- package/dist/esm/actions/formatSign.js.map +1 -1
- package/dist/esm/actions/grantPermissions.js +3 -4
- package/dist/esm/actions/grantPermissions.js.map +1 -1
- package/dist/esm/actions/listAccounts.js +3 -4
- package/dist/esm/actions/listAccounts.js.map +1 -1
- package/dist/esm/actions/prepareCalls.js +3 -4
- package/dist/esm/actions/prepareCalls.js.map +1 -1
- package/dist/esm/actions/prepareSign.js +3 -4
- package/dist/esm/actions/prepareSign.js.map +1 -1
- package/dist/esm/actions/requestAccount.js +3 -4
- package/dist/esm/actions/requestAccount.js.map +1 -1
- package/dist/esm/actions/sendPreparedCalls.js +3 -4
- package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signTypedData.d.ts +0 -1
- package/dist/esm/actions/signTypedData.js +0 -1
- package/dist/esm/actions/signTypedData.js.map +1 -1
- package/dist/esm/experimental/actions/requestQuoteV0.d.ts +16 -3
- package/dist/esm/experimental/actions/requestQuoteV0.js +19 -5
- package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
- package/dist/esm/utils/schema.d.ts +3 -1
- package/dist/esm/utils/schema.js +58 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/formatSign.d.ts.map +1 -1
- package/dist/types/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/actions/prepareSign.d.ts.map +1 -1
- package/dist/types/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/actions/signTypedData.d.ts +0 -1
- package/dist/types/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/experimental/actions/requestQuoteV0.d.ts +16 -3
- package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
- package/dist/types/utils/schema.d.ts +3 -1
- package/dist/types/utils/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/actions/formatSign.ts +5 -4
- package/src/actions/grantPermissions.ts +9 -11
- package/src/actions/listAccounts.ts +5 -7
- package/src/actions/prepareCalls.ts +5 -4
- package/src/actions/prepareSign.ts +5 -4
- package/src/actions/requestAccount.ts +8 -7
- package/src/actions/sendPreparedCalls.ts +4 -6
- package/src/actions/signTypedData.ts +0 -1
- package/src/experimental/actions/requestQuoteV0.ts +48 -6
- package/src/utils/schema.ts +79 -1
- package/src/version.ts +1 -1
package/dist/esm/utils/schema.js
CHANGED
|
@@ -1,7 +1,65 @@
|
|
|
1
|
+
import { Value, EncodeError, DecodeError, Pointer } from "typebox/value";
|
|
2
|
+
import { BaseError } from "@alchemy/common";
|
|
1
3
|
export function methodSchema(schema) {
|
|
2
4
|
return {
|
|
3
5
|
request: schema.properties.Request.properties.params.items[0],
|
|
4
6
|
response: schema.properties.ReturnType,
|
|
5
7
|
};
|
|
6
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Formats an {@link EncodeError} or {@link DecodeError} into a human-readable
|
|
11
|
+
* string describing what went wrong, including the JSON path and the schema's
|
|
12
|
+
* custom error message (if any).
|
|
13
|
+
*
|
|
14
|
+
* @param {TSchema} schema - The TypeBox schema that validation was run against.
|
|
15
|
+
* @param {EncodeError | DecodeError} error - The error thrown by {@link Value.Encode} or {@link Value.Decode}.
|
|
16
|
+
* @returns {string} A formatted error string prefixed with `"Invalid params"`.
|
|
17
|
+
*/
|
|
18
|
+
function formatCodecError(schema, error) {
|
|
19
|
+
// Use only the first error — it's the most specific. Subsequent errors are
|
|
20
|
+
// typically cascade noise from union/anyOf branches.
|
|
21
|
+
const causeError = error.cause.errors[0];
|
|
22
|
+
// errors is typed as an open array — guard against the (practically
|
|
23
|
+
// impossible) empty case.
|
|
24
|
+
if (!causeError)
|
|
25
|
+
return "Invalid params";
|
|
26
|
+
const path = causeError.instancePath || "(root)";
|
|
27
|
+
// Prefer the schema's custom errorMessage annotation over the generic locale message.
|
|
28
|
+
let message = causeError.message;
|
|
29
|
+
const schemaPointer = causeError.schemaPath.replace(/^#/, "");
|
|
30
|
+
if (schemaPointer) {
|
|
31
|
+
const schemaNode = Pointer.Get(schema, schemaPointer);
|
|
32
|
+
if (schemaNode &&
|
|
33
|
+
typeof schemaNode === "object" &&
|
|
34
|
+
"errorMessage" in schemaNode &&
|
|
35
|
+
typeof schemaNode.errorMessage === "string") {
|
|
36
|
+
message = schemaNode.errorMessage;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return `Invalid params: ${path}: ${message}`;
|
|
40
|
+
}
|
|
41
|
+
// Type-safe wrapper around `Value.Encode` with human-readable errors.
|
|
42
|
+
export function encode(schema, value) {
|
|
43
|
+
try {
|
|
44
|
+
return Value.Encode(schema, value);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof EncodeError) {
|
|
48
|
+
throw new BaseError(formatCodecError(schema, error), { cause: error });
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Type-safe wrapper around `Value.Decode` with human-readable errors.
|
|
54
|
+
export function decode(schema, value) {
|
|
55
|
+
try {
|
|
56
|
+
return Value.Decode(schema, value);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof DecodeError) {
|
|
60
|
+
throw new BaseError(formatCodecError(schema, error), { cause: error });
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
7
65
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,UAAU,YAAY,CAC1B,MAGE;IAEF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;KACvC,CAAC;AACJ,CAAC;AAYD;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CACvB,MAAe,EACf,KAAgC;IAEhC,2EAA2E;IAC3E,qDAAqD;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,oEAAoE;IACpE,0BAA0B;IAC1B,IAAI,CAAC,UAAU;QAAE,OAAO,gBAAgB,CAAC;IAEzC,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,IAAI,QAAQ,CAAC;IAEjD,sFAAsF;IACtF,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IACjC,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9D,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACtD,IACE,UAAU;YACV,OAAO,UAAU,KAAK,QAAQ;YAC9B,cAAc,IAAI,UAAU;YAC5B,OAAQ,UAAsC,CAAC,YAAY,KAAK,QAAQ,EACxE,CAAC;YACD,OAAO,GAAI,UAAsC,CAAC,YAAsB,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,IAAI,KAAK,OAAO,EAAE,CAAC;AAC/C,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,MAAM,CACpB,MAAS,EACT,KAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,MAAM,CACpB,MAAS,EACT,KAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type {\n TObject,\n TSchema,\n TTuple,\n StaticDecode,\n StaticEncode,\n} from \"typebox\";\nimport { Value, EncodeError, DecodeError, Pointer } from \"typebox/value\";\nimport { BaseError } from \"@alchemy/common\";\n\n/** Constraint for RPC method schemas from `@alchemy/wallet-api-types/rpc`. */\ntype RpcMethodSchema = TObject<{\n Request: TObject<{\n method: TSchema;\n params: TTuple<[TSchema, ...TSchema[]]>;\n }>;\n ReturnType: TSchema;\n}>;\n\nexport function methodSchema<TReq extends TSchema, TRes extends TSchema>(\n schema: TObject<{\n Request: TObject<{ method: TSchema; params: TTuple<[TReq, ...TSchema[]]> }>;\n ReturnType: TRes;\n }>,\n): { request: TReq; response: TRes } {\n return {\n request: schema.properties.Request.properties.params.items[0],\n response: schema.properties.ReturnType,\n };\n}\n\n/** Extracts the decoded params type from a method schema. */\nexport type MethodParams<T extends RpcMethodSchema> = StaticDecode<\n T[\"properties\"][\"Request\"][\"properties\"][\"params\"][\"items\"][0]\n>;\n\n/** Extracts the decoded response type from a method schema. */\nexport type MethodResponse<T extends RpcMethodSchema> = StaticDecode<\n T[\"properties\"][\"ReturnType\"]\n>;\n\n/**\n * Formats an {@link EncodeError} or {@link DecodeError} into a human-readable\n * string describing what went wrong, including the JSON path and the schema's\n * custom error message (if any).\n *\n * @param {TSchema} schema - The TypeBox schema that validation was run against.\n * @param {EncodeError | DecodeError} error - The error thrown by {@link Value.Encode} or {@link Value.Decode}.\n * @returns {string} A formatted error string prefixed with `\"Invalid params\"`.\n */\nfunction formatCodecError(\n schema: TSchema,\n error: EncodeError | DecodeError,\n): string {\n // Use only the first error — it's the most specific. Subsequent errors are\n // typically cascade noise from union/anyOf branches.\n const causeError = error.cause.errors[0];\n // errors is typed as an open array — guard against the (practically\n // impossible) empty case.\n if (!causeError) return \"Invalid params\";\n\n const path = causeError.instancePath || \"(root)\";\n\n // Prefer the schema's custom errorMessage annotation over the generic locale message.\n let message = causeError.message;\n const schemaPointer = causeError.schemaPath.replace(/^#/, \"\");\n if (schemaPointer) {\n const schemaNode = Pointer.Get(schema, schemaPointer);\n if (\n schemaNode &&\n typeof schemaNode === \"object\" &&\n \"errorMessage\" in schemaNode &&\n typeof (schemaNode as Record<string, unknown>).errorMessage === \"string\"\n ) {\n message = (schemaNode as Record<string, unknown>).errorMessage as string;\n }\n }\n\n return `Invalid params: ${path}: ${message}`;\n}\n\n// Type-safe wrapper around `Value.Encode` with human-readable errors.\nexport function encode<const T extends TSchema>(\n schema: T,\n value: StaticDecode<T>,\n): StaticEncode<T> {\n try {\n return Value.Encode(schema, value);\n } catch (error) {\n if (error instanceof EncodeError) {\n throw new BaseError(formatCodecError(schema, error), { cause: error });\n }\n throw error;\n }\n}\n\n// Type-safe wrapper around `Value.Decode` with human-readable errors.\nexport function decode<const T extends TSchema>(\n schema: T,\n value: StaticEncode<T>,\n): StaticDecode<T> {\n try {\n return Value.Decode(schema, value);\n } catch (error) {\n if (error instanceof DecodeError) {\n throw new BaseError(formatCodecError(schema, error), { cause: error });\n }\n throw error;\n }\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.0.0-alpha.21";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0-alpha.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0-alpha.21\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatSign.d.ts","sourceRoot":"","sources":["../../../src/actions/formatSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatSign.d.ts","sourceRoot":"","sources":["../../../src/actions/formatSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,oBAAoB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAC9D,KAAK,kBAAkB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAC3D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CACF,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.d.ts","sourceRoot":"","sources":["../../../src/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAa,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"grantPermissions.d.ts","sourceRoot":"","sources":["../../../src/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAa,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGrF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,uBAAuB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,gBAAgB,CAAC,uBAAuB,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IACjE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CACF,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,OAAO,EAAE,GAAG,CAAC;CACd,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAkCjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listAccounts.d.ts","sourceRoot":"","sources":["../../../src/actions/listAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"listAccounts.d.ts","sourceRoot":"","sources":["../../../src/actions/listAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,sBAAsB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAChE,KAAK,oBAAoB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CACvC,gBAAgB,CACd,sBAAsB,EACtB,eAAe,GAAG,iBAAiB,CACpC,GAAG;IACF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAuB7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,cAAc,CAAC,GAAG;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,wBAAwB,CAAC;CACzC,CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC,GAC3D,CAAC,IAAI,CACH,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC3D,iBAAiB,CAClB,GAAG;IACF,eAAe,EAAE,qBAAqB,CAAC;CACxC,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CA+C7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareSign.d.ts","sourceRoot":"","sources":["../../../src/actions/prepareSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareSign.d.ts","sourceRoot":"","sources":["../../../src/actions/prepareSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,qBAAqB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAC/D,KAAK,mBAAmB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAC9C,qBAAqB,EACrB,MAAM,GAAG,SAAS,CACnB,GAAG;IACF,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAqB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"requestAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,wBAAwB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,gBAAgB,CACd,OAAO,CAAC,wBAAwB,EAAE;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC,EAC7D,eAAe,GAAG,2BAA2B,CAC9C,GACC,CACI;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GACnD;IAAE,aAAa,CAAC,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,CACrD,CACJ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CA6D/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,2BAA2B,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AACrE,KAAK,yBAAyB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAErE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAC5C,gBAAgB,CACd,gBAAgB,CAAC,2BAA2B,EAAE,SAAS,CAAC,GAAG;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CACF,CACF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CA0BlC"}
|
|
@@ -10,7 +10,6 @@ export type SignTypedDataResult = Prettify<Hex>;
|
|
|
10
10
|
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
11
11
|
*
|
|
12
12
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
13
|
-
* @param {SignerClient} signerClient - The wallet client to use for signing
|
|
14
13
|
* @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
|
|
15
14
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
16
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,mBAAmB,GAAG;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,mBAAmB,GAAG;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,aAAa,CACjC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Prettify } from "viem";
|
|
1
|
+
import type { Address, Prettify } from "viem";
|
|
2
2
|
import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
|
|
3
|
-
import { type WithCapabilities } from "../../utils/capabilities.js";
|
|
3
|
+
import { type PrepareCallsCapabilities, type WithCapabilities } from "../../utils/capabilities.js";
|
|
4
4
|
import { type AccountParam } from "../../utils/resolve.js";
|
|
5
5
|
import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
6
|
import { type MethodParams, type MethodResponse } from "../../utils/schema.js";
|
|
@@ -10,7 +10,20 @@ export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<Ba
|
|
|
10
10
|
account?: AccountParam;
|
|
11
11
|
chainId?: number;
|
|
12
12
|
}>>;
|
|
13
|
-
|
|
13
|
+
/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
|
|
14
|
+
type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
|
|
15
|
+
type: "paymaster-permit";
|
|
16
|
+
}>["modifiedRequest"], "from" | "capabilities"> & {
|
|
17
|
+
account: Address;
|
|
18
|
+
capabilities?: PrepareCallsCapabilities;
|
|
19
|
+
}>;
|
|
20
|
+
export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
21
|
+
type: "paymaster-permit";
|
|
22
|
+
}> | (Omit<Extract<RequestQuoteV0Response, {
|
|
23
|
+
type: "paymaster-permit";
|
|
24
|
+
}>, "modifiedRequest"> & {
|
|
25
|
+
modifiedRequest: ClientModifiedRequest;
|
|
26
|
+
});
|
|
14
27
|
/**
|
|
15
28
|
* Requests a quote for a token swap, returning either prepared calls for smart wallets
|
|
16
29
|
* or raw calls for EOA wallets depending on the returnRawCalls parameter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestQuoteV0.d.ts","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"requestQuoteV0.d.ts","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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B,CAClB,GAAG;IACF,eAAe,EAAE,qBAAqB,CAAC;CACxC,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA6C/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TObject, TSchema, TTuple, StaticDecode } from "typebox";
|
|
1
|
+
import type { TObject, TSchema, TTuple, StaticDecode, StaticEncode } from "typebox";
|
|
2
2
|
/** Constraint for RPC method schemas from `@alchemy/wallet-api-types/rpc`. */
|
|
3
3
|
type RpcMethodSchema = TObject<{
|
|
4
4
|
Request: TObject<{
|
|
@@ -21,5 +21,7 @@ export declare function methodSchema<TReq extends TSchema, TRes extends TSchema>
|
|
|
21
21
|
export type MethodParams<T extends RpcMethodSchema> = StaticDecode<T["properties"]["Request"]["properties"]["params"]["items"][0]>;
|
|
22
22
|
/** Extracts the decoded response type from a method schema. */
|
|
23
23
|
export type MethodResponse<T extends RpcMethodSchema> = StaticDecode<T["properties"]["ReturnType"]>;
|
|
24
|
+
export declare function encode<const T extends TSchema>(schema: T, value: StaticDecode<T>): StaticEncode<T>;
|
|
25
|
+
export declare function decode<const T extends TSchema>(schema: T, value: StaticEncode<T>): StaticDecode<T>;
|
|
24
26
|
export {};
|
|
25
27
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAIjB,8EAA8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AAE,YAAY,CAAC,CAAC,CAAC,GACrB,YAAY,CAAC,CAAC,CAAC,CASjB"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.0.0-alpha.21";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy/wallet-apis",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.22",
|
|
4
4
|
"description": "Alchemy Wallet APIs",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"typescript-template": "*"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@alchemy/common": "^0.0.0-alpha.
|
|
56
|
+
"@alchemy/common": "^0.0.0-alpha.22",
|
|
57
57
|
"@alchemy/wallet-api-types": "0.1.0-alpha.25",
|
|
58
58
|
"deep-equal": "^2.2.3",
|
|
59
59
|
"ox": "^0.11.1",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
73
73
|
},
|
|
74
74
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "10e989504f15718c4c6b66e6856e509dfb3e6cfe"
|
|
76
76
|
}
|
|
@@ -3,9 +3,10 @@ import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
|
|
|
3
3
|
import { wallet_formatSign as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
4
4
|
import { LOGGER } from "../logger.js";
|
|
5
5
|
import { resolveAddress, type AccountParam } from "../utils/resolve.js";
|
|
6
|
-
import { Value } from "typebox/value";
|
|
7
6
|
import {
|
|
8
7
|
methodSchema,
|
|
8
|
+
encode,
|
|
9
|
+
decode,
|
|
9
10
|
type MethodParams,
|
|
10
11
|
type MethodResponse,
|
|
11
12
|
} from "../utils/schema.js";
|
|
@@ -53,11 +54,11 @@ export async function formatSign(
|
|
|
53
54
|
LOGGER.debug("formatSign:start");
|
|
54
55
|
|
|
55
56
|
const { account: _, chainId: __, ...rest } = params;
|
|
56
|
-
const rpcParams =
|
|
57
|
+
const rpcParams = encode(schema.request, {
|
|
57
58
|
...rest,
|
|
58
59
|
from,
|
|
59
60
|
chainId: params.chainId ?? client.chain.id,
|
|
60
|
-
}
|
|
61
|
+
});
|
|
61
62
|
|
|
62
63
|
const rpcResp = await client.request({
|
|
63
64
|
method: "wallet_formatSign",
|
|
@@ -65,5 +66,5 @@ export async function formatSign(
|
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
LOGGER.debug("formatSign:done");
|
|
68
|
-
return
|
|
69
|
+
return decode(schema.response, rpcResp);
|
|
69
70
|
}
|
|
@@ -3,9 +3,13 @@ import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
|
|
|
3
3
|
import { wallet_createSession as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
4
4
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
5
5
|
import { LOGGER } from "../logger.js";
|
|
6
|
-
import { Value } from "typebox/value";
|
|
7
6
|
import { resolveAddress, type AccountParam } from "../utils/resolve.js";
|
|
8
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
methodSchema,
|
|
9
|
+
encode,
|
|
10
|
+
decode,
|
|
11
|
+
type MethodParams,
|
|
12
|
+
} from "../utils/schema.js";
|
|
9
13
|
|
|
10
14
|
const schema = methodSchema(MethodSchema);
|
|
11
15
|
type BaseCreateSessionParams = MethodParams<typeof MethodSchema>;
|
|
@@ -88,24 +92,18 @@ export async function grantPermissions(
|
|
|
88
92
|
const chainId = params.chainId ?? client.chain.id;
|
|
89
93
|
|
|
90
94
|
const { account: _, chainId: __, ...rest } = params;
|
|
91
|
-
const rpcParams =
|
|
95
|
+
const rpcParams = encode(schema.request, {
|
|
92
96
|
...rest,
|
|
93
97
|
account,
|
|
94
98
|
chainId,
|
|
95
|
-
}
|
|
99
|
+
});
|
|
96
100
|
|
|
97
101
|
const rpcResp = await client.request({
|
|
98
102
|
method: "wallet_createSession",
|
|
99
103
|
params: [rpcParams],
|
|
100
104
|
});
|
|
101
105
|
|
|
102
|
-
const { sessionId, signatureRequest } =
|
|
103
|
-
schema.response,
|
|
104
|
-
rpcResp,
|
|
105
|
-
) satisfies {
|
|
106
|
-
sessionId: Hex;
|
|
107
|
-
signatureRequest: Parameters<typeof signSignatureRequest>[1];
|
|
108
|
-
};
|
|
106
|
+
const { sessionId, signatureRequest } = decode(schema.response, rpcResp);
|
|
109
107
|
|
|
110
108
|
const signature = await signSignatureRequest(client, signatureRequest);
|
|
111
109
|
|
|
@@ -3,9 +3,10 @@ import { LOGGER } from "../logger.js";
|
|
|
3
3
|
import type { Address, Prettify } from "viem";
|
|
4
4
|
import { wallet_listAccounts as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
5
5
|
import { isLocalAccount } from "../utils/assertions.js";
|
|
6
|
-
import { Value } from "typebox/value";
|
|
7
6
|
import {
|
|
8
7
|
methodSchema,
|
|
8
|
+
encode,
|
|
9
|
+
decode,
|
|
9
10
|
type MethodParams,
|
|
10
11
|
type MethodResponse,
|
|
11
12
|
} from "../utils/schema.js";
|
|
@@ -64,20 +65,17 @@ export async function listAccounts(
|
|
|
64
65
|
|
|
65
66
|
LOGGER.debug("listAccounts:start", { hasAfter: !!params.after });
|
|
66
67
|
|
|
67
|
-
const rpcParams =
|
|
68
|
+
const rpcParams = encode(schema.request, {
|
|
68
69
|
...params,
|
|
69
70
|
signerAddress,
|
|
70
|
-
}
|
|
71
|
+
});
|
|
71
72
|
|
|
72
73
|
const rpcResp = await client.request({
|
|
73
74
|
method: "wallet_listAccounts",
|
|
74
75
|
params: [rpcParams],
|
|
75
76
|
});
|
|
76
77
|
|
|
77
|
-
const res =
|
|
78
|
-
schema.response,
|
|
79
|
-
rpcResp,
|
|
80
|
-
) satisfies ListAccountsResult;
|
|
78
|
+
const res = decode(schema.response, rpcResp);
|
|
81
79
|
LOGGER.debug("listAccounts:done", { count: res.accounts.length });
|
|
82
80
|
|
|
83
81
|
return res;
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
} from "../utils/capabilities.js";
|
|
11
11
|
import { resolveAddress, type AccountParam } from "../utils/resolve.js";
|
|
12
12
|
import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
13
|
-
import { Value } from "typebox/value";
|
|
14
13
|
import {
|
|
15
14
|
methodSchema,
|
|
15
|
+
encode,
|
|
16
|
+
decode,
|
|
16
17
|
type MethodParams,
|
|
17
18
|
type MethodResponse,
|
|
18
19
|
} from "../utils/schema.js";
|
|
@@ -96,12 +97,12 @@ export async function prepareCalls(
|
|
|
96
97
|
});
|
|
97
98
|
|
|
98
99
|
const { account: _, chainId: __, ...rest } = params;
|
|
99
|
-
const rpcParams =
|
|
100
|
+
const rpcParams = encode(schema.request, {
|
|
100
101
|
...rest,
|
|
101
102
|
chainId,
|
|
102
103
|
from,
|
|
103
104
|
capabilities: toRpcCapabilities(capabilities),
|
|
104
|
-
}
|
|
105
|
+
});
|
|
105
106
|
|
|
106
107
|
const rpcResp = await client.request({
|
|
107
108
|
method: "wallet_prepareCalls",
|
|
@@ -109,7 +110,7 @@ export async function prepareCalls(
|
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
LOGGER.debug("prepareCalls:done");
|
|
112
|
-
const decoded =
|
|
113
|
+
const decoded = decode(schema.response, rpcResp);
|
|
113
114
|
|
|
114
115
|
// Transform paymaster-permit modifiedRequest from RPC format to client format:
|
|
115
116
|
// - `from` (RPC) → `account` (client)
|
|
@@ -2,9 +2,10 @@ import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
|
|
|
2
2
|
import { wallet_prepareSign as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
3
3
|
import { LOGGER } from "../logger.js";
|
|
4
4
|
import { resolveAddress, type AccountParam } from "../utils/resolve.js";
|
|
5
|
-
import { Value } from "typebox/value";
|
|
6
5
|
import {
|
|
7
6
|
methodSchema,
|
|
7
|
+
encode,
|
|
8
|
+
decode,
|
|
8
9
|
type MethodParams,
|
|
9
10
|
type MethodResponse,
|
|
10
11
|
} from "../utils/schema.js";
|
|
@@ -51,11 +52,11 @@ export async function prepareSign(
|
|
|
51
52
|
LOGGER.debug("prepareSign:start", { type: params.signatureRequest.type });
|
|
52
53
|
|
|
53
54
|
const { account: _, chainId: __, ...rest } = params;
|
|
54
|
-
const rpcParams =
|
|
55
|
+
const rpcParams = encode(schema.request, {
|
|
55
56
|
...rest,
|
|
56
57
|
from,
|
|
57
58
|
chainId: params.chainId ?? client.chain.id,
|
|
58
|
-
}
|
|
59
|
+
});
|
|
59
60
|
|
|
60
61
|
const rpcResp = await client.request({
|
|
61
62
|
method: "wallet_prepareSign",
|
|
@@ -63,5 +64,5 @@ export async function prepareSign(
|
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
LOGGER.debug("prepareSign:done");
|
|
66
|
-
return
|
|
67
|
+
return decode(schema.response, rpcResp);
|
|
67
68
|
}
|
|
@@ -5,8 +5,12 @@ import deepEqual from "deep-equal";
|
|
|
5
5
|
import type { DistributiveOmit, InnerWalletApiClient } from "../types";
|
|
6
6
|
import { LOGGER } from "../logger.js";
|
|
7
7
|
import { isLocalAccount } from "../utils/assertions.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
methodSchema,
|
|
10
|
+
encode,
|
|
11
|
+
decode,
|
|
12
|
+
type MethodParams,
|
|
13
|
+
} from "../utils/schema.js";
|
|
10
14
|
|
|
11
15
|
const schema = methodSchema(MethodSchema);
|
|
12
16
|
type BaseRequestAccountParams = MethodParams<typeof MethodSchema>;
|
|
@@ -90,17 +94,14 @@ export async function requestAccount(
|
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
const rpcParams =
|
|
94
|
-
schema.request,
|
|
95
|
-
args satisfies BaseRequestAccountParams,
|
|
96
|
-
);
|
|
97
|
+
const rpcParams = encode(schema.request, args);
|
|
97
98
|
|
|
98
99
|
const rpcResp = await client.request({
|
|
99
100
|
method: "wallet_requestAccount",
|
|
100
101
|
params: [rpcParams],
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
const resp =
|
|
104
|
+
const resp = decode(schema.response, rpcResp);
|
|
104
105
|
|
|
105
106
|
client.internal?.setAccount({
|
|
106
107
|
address: resp.accountAddress,
|
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
type WithCapabilities,
|
|
8
8
|
} from "../utils/capabilities.js";
|
|
9
9
|
import { wallet_sendPreparedCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
10
|
-
import { Value } from "typebox/value";
|
|
11
10
|
import {
|
|
12
11
|
methodSchema,
|
|
12
|
+
encode,
|
|
13
|
+
decode,
|
|
13
14
|
type MethodParams,
|
|
14
15
|
type MethodResponse,
|
|
15
16
|
} from "../utils/schema.js";
|
|
@@ -79,10 +80,7 @@ export async function sendPreparedCalls(
|
|
|
79
80
|
capabilities: toRpcCapabilities(capabilities),
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
const rpcParams =
|
|
83
|
-
schema.request,
|
|
84
|
-
fullParams satisfies BaseSendPreparedCallsParams,
|
|
85
|
-
);
|
|
83
|
+
const rpcParams = encode(schema.request, fullParams);
|
|
86
84
|
|
|
87
85
|
const rpcResp = await client.request({
|
|
88
86
|
method: "wallet_sendPreparedCalls",
|
|
@@ -90,5 +88,5 @@ export async function sendPreparedCalls(
|
|
|
90
88
|
});
|
|
91
89
|
|
|
92
90
|
LOGGER.debug("sendPreparedCalls:done");
|
|
93
|
-
return
|
|
91
|
+
return decode(schema.response, rpcResp);
|
|
94
92
|
}
|
|
@@ -20,7 +20,6 @@ export type SignTypedDataResult = Prettify<Hex>;
|
|
|
20
20
|
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
21
21
|
*
|
|
22
22
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
23
|
-
* @param {SignerClient} signerClient - The wallet client to use for signing
|
|
24
23
|
* @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
|
|
25
24
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
26
25
|
*
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { Prettify } from "viem";
|
|
1
|
+
import type { Address, Prettify } from "viem";
|
|
2
2
|
import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
|
|
3
3
|
import {
|
|
4
|
+
fromRpcCapabilities,
|
|
4
5
|
mergeClientCapabilities,
|
|
5
6
|
toRpcCapabilities,
|
|
7
|
+
type PrepareCallsCapabilities,
|
|
6
8
|
type WithCapabilities,
|
|
7
9
|
} from "../../utils/capabilities.js";
|
|
8
10
|
import { resolveAddress, type AccountParam } from "../../utils/resolve.js";
|
|
9
11
|
import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
10
|
-
import { Value } from "typebox/value";
|
|
11
12
|
import {
|
|
12
13
|
methodSchema,
|
|
14
|
+
encode,
|
|
15
|
+
decode,
|
|
13
16
|
type MethodParams,
|
|
14
17
|
type MethodResponse,
|
|
15
18
|
} from "../../utils/schema.js";
|
|
@@ -27,7 +30,28 @@ export type RequestQuoteV0Params = Prettify<
|
|
|
27
30
|
>
|
|
28
31
|
>;
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
|
|
34
|
+
type ClientModifiedRequest = Prettify<
|
|
35
|
+
Omit<
|
|
36
|
+
Extract<
|
|
37
|
+
RequestQuoteV0Response,
|
|
38
|
+
{ type: "paymaster-permit" }
|
|
39
|
+
>["modifiedRequest"],
|
|
40
|
+
"from" | "capabilities"
|
|
41
|
+
> & {
|
|
42
|
+
account: Address;
|
|
43
|
+
capabilities?: PrepareCallsCapabilities;
|
|
44
|
+
}
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
export type RequestQuoteV0Result =
|
|
48
|
+
| Exclude<RequestQuoteV0Response, { type: "paymaster-permit" }>
|
|
49
|
+
| (Omit<
|
|
50
|
+
Extract<RequestQuoteV0Response, { type: "paymaster-permit" }>,
|
|
51
|
+
"modifiedRequest"
|
|
52
|
+
> & {
|
|
53
|
+
modifiedRequest: ClientModifiedRequest;
|
|
54
|
+
});
|
|
31
55
|
|
|
32
56
|
/**
|
|
33
57
|
* Requests a quote for a token swap, returning either prepared calls for smart wallets
|
|
@@ -84,17 +108,35 @@ export async function requestQuoteV0(
|
|
|
84
108
|
);
|
|
85
109
|
|
|
86
110
|
const { account: _, chainId: __, ...rest } = params;
|
|
87
|
-
const rpcParams =
|
|
111
|
+
const rpcParams = encode(schema.request, {
|
|
88
112
|
...rest,
|
|
89
113
|
chainId: params.chainId ?? client.chain.id,
|
|
90
114
|
from,
|
|
91
115
|
...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),
|
|
92
|
-
}
|
|
116
|
+
});
|
|
93
117
|
|
|
94
118
|
const rpcResp = await client.request({
|
|
95
119
|
method: "wallet_requestQuote_v0",
|
|
96
120
|
params: [rpcParams],
|
|
97
121
|
});
|
|
98
122
|
|
|
99
|
-
|
|
123
|
+
const decoded = decode(schema.response, rpcResp);
|
|
124
|
+
|
|
125
|
+
// Transform paymaster-permit modifiedRequest from RPC format to client format:
|
|
126
|
+
// - `from` (RPC) → `account` (client)
|
|
127
|
+
// - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)
|
|
128
|
+
if ("type" in decoded && decoded.type === "paymaster-permit") {
|
|
129
|
+
const { from, capabilities, ...restModifiedRequest } =
|
|
130
|
+
decoded.modifiedRequest;
|
|
131
|
+
return {
|
|
132
|
+
...decoded,
|
|
133
|
+
modifiedRequest: {
|
|
134
|
+
...restModifiedRequest,
|
|
135
|
+
account: from,
|
|
136
|
+
capabilities: fromRpcCapabilities(capabilities),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return decoded;
|
|
100
142
|
}
|