@agoric/orchestration 0.1.1-dev-fac5579.0.fac5579 → 0.1.1-dev-82a1d65.0.82a1d65
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/package.json +17 -17
- package/src/stubs/viem-typedData.js +1 -0
- package/src/utils/abitype.d.ts +41 -16
- package/src/utils/abitype.d.ts.map +1 -1
- package/src/utils/abitype.js +66 -16
- package/src/utils/address.d.ts +1 -0
- package/src/utils/address.d.ts.map +1 -1
- package/src/utils/address.js +11 -0
- package/src/utils/eip712-message-handler.d.ts +15 -1
- package/src/utils/eip712-message-handler.d.ts.map +1 -1
- package/src/utils/eip712-message-handler.js +80 -16
- package/src/utils/eip712-messages.d.ts +5 -5
- package/src/utils/eip712-messages.d.ts.map +1 -1
- package/src/utils/eip712-messages.js +25 -8
- package/src/utils/permit2/signatureTransferHelpers.d.ts.map +1 -1
- package/src/utils/permit2/signatureTransferHelpers.js +4 -1
- package/src/utils/viem-utils/eip712-normalize.d.ts +77 -4
- package/src/utils/viem-utils/eip712-normalize.d.ts.map +1 -1
- package/src/utils/viem-utils/eip712-normalize.js +188 -42
- package/src/vendor/viem/{chunk-XNGNAKRR.js → chunk-7BNMBC44.js} +43 -42
- package/src/vendor/viem/viem-abi.js +1 -1
- package/src/vendor/viem/viem-address.js +1 -1
- package/src/vendor/viem/viem-typedData.d.ts +1 -1
- package/src/vendor/viem/viem-typedData.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-82a1d65.0.82a1d65",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@agoric/async-flow": "0.1.1-dev-
|
|
39
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
40
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
41
|
-
"@agoric/internal": "0.3.3-dev-
|
|
42
|
-
"@agoric/network": "0.1.1-dev-
|
|
43
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
44
|
-
"@agoric/store": "0.9.3-dev-
|
|
45
|
-
"@agoric/time": "0.3.3-dev-
|
|
46
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
47
|
-
"@agoric/vow": "0.1.1-dev-
|
|
48
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
49
|
-
"@agoric/zone": "0.2.3-dev-
|
|
38
|
+
"@agoric/async-flow": "0.1.1-dev-82a1d65.0.82a1d65",
|
|
39
|
+
"@agoric/cosmic-proto": "0.4.1-dev-82a1d65.0.82a1d65",
|
|
40
|
+
"@agoric/ertp": "0.16.3-dev-82a1d65.0.82a1d65",
|
|
41
|
+
"@agoric/internal": "0.3.3-dev-82a1d65.0.82a1d65",
|
|
42
|
+
"@agoric/network": "0.1.1-dev-82a1d65.0.82a1d65",
|
|
43
|
+
"@agoric/notifier": "0.6.3-dev-82a1d65.0.82a1d65",
|
|
44
|
+
"@agoric/store": "0.9.3-dev-82a1d65.0.82a1d65",
|
|
45
|
+
"@agoric/time": "0.3.3-dev-82a1d65.0.82a1d65",
|
|
46
|
+
"@agoric/vat-data": "0.5.3-dev-82a1d65.0.82a1d65",
|
|
47
|
+
"@agoric/vow": "0.1.1-dev-82a1d65.0.82a1d65",
|
|
48
|
+
"@agoric/zoe": "0.26.3-dev-82a1d65.0.82a1d65",
|
|
49
|
+
"@agoric/zone": "0.2.3-dev-82a1d65.0.82a1d65",
|
|
50
50
|
"@cosmjs/encoding": "^0.36.0",
|
|
51
51
|
"@endo/base64": "^1.1.1",
|
|
52
52
|
"@endo/common": "^1.4.0",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"bs58": "^6.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
65
|
-
"@agoric/vats": "0.15.2-dev-
|
|
66
|
-
"@agoric/xsnap": "0.14.3-dev-
|
|
64
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-82a1d65.0.82a1d65",
|
|
65
|
+
"@agoric/vats": "0.15.2-dev-82a1d65.0.82a1d65",
|
|
66
|
+
"@agoric/xsnap": "0.14.3-dev-82a1d65.0.82a1d65",
|
|
67
67
|
"@chain-registry/client": "^1.53.194",
|
|
68
68
|
"@cosmjs/amino": "^0.36.0",
|
|
69
69
|
"@cosmjs/proto-signing": "^0.36.0",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"typeCoverage": {
|
|
101
101
|
"atLeast": 96.68
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "82a1d65dcde4d1da305f8ce43539075c764bd510"
|
|
104
104
|
}
|
package/src/utils/abitype.d.ts
CHANGED
|
@@ -29,39 +29,64 @@ export type TypedDataParameter<TN extends string = string, TT extends string = T
|
|
|
29
29
|
* Unlike abitype's version, this has no self/circular-reference detection:
|
|
30
30
|
* none of this repo's type graphs are self-referencing, so it wasn't worth
|
|
31
31
|
* reproducing.
|
|
32
|
+
*
|
|
33
|
+
* `Kind` selects which values the type describes: `'output'` (the default)
|
|
34
|
+
* is the canonical form, e.g. as returned by `normalizeAndValidateEIP712Data`;
|
|
35
|
+
* `'input'` additionally allows the other encodings it accepts and
|
|
36
|
+
* normalizes (see {@link EIP712IntegerInput}).
|
|
37
|
+
*/
|
|
38
|
+
export type TypedDataToStructType<TD extends Record<string, readonly TypedDataParameter[]>, K extends keyof TD & string, Kind extends TypedDataValueKind = 'output'> = StructToType<TD, TD[K], Kind>;
|
|
39
|
+
export type TypedDataValueKind = 'input' | 'output';
|
|
40
|
+
/**
|
|
41
|
+
* The values `normalizeAndValidateEIP712Data` accepts (and normalizes to
|
|
42
|
+
* abitype's `number`/`bigint` output type) for a `uint<M>`/`int<M>` field. Range and exact string grammar
|
|
43
|
+
* (unsigned hex, or optionally signed decimal) are only checked at runtime.
|
|
32
44
|
*/
|
|
33
|
-
export type
|
|
34
|
-
type StructToType<TD extends Record<string, readonly TypedDataParameter[]>, Fields extends readonly TypedDataParameter[]> = Simplify<{
|
|
45
|
+
export type EIP712IntegerInput = bigint | number | `${bigint}` | `+${bigint}` | `0x${string}`;
|
|
46
|
+
type StructToType<TD extends Record<string, readonly TypedDataParameter[]>, Fields extends readonly TypedDataParameter[], Kind extends TypedDataValueKind> = Simplify<{
|
|
35
47
|
[F in Exclude<Fields[number], {
|
|
36
48
|
optional: true;
|
|
37
|
-
}> as F['name']]: FieldToType<TD, F['type']>;
|
|
49
|
+
}> as F['name']]: FieldToType<TD, F['type'], Kind>;
|
|
38
50
|
} & {
|
|
39
51
|
[F in Extract<Fields[number], {
|
|
40
52
|
optional: true;
|
|
41
|
-
}> as F['name']]?: FieldToType<TD, F['type']>;
|
|
53
|
+
}> as F['name']]?: FieldToType<TD, F['type'], Kind>;
|
|
42
54
|
}>;
|
|
43
55
|
/**
|
|
44
|
-
* `Foo[3]` / `Foo[]` -> `{elem: 'Foo';
|
|
45
|
-
* `
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
48
|
-
*
|
|
56
|
+
* `Foo[3]` / `Foo[]` / `Foo[2][]` -> `{elem: 'Foo'; dims: '[3]' | '[]' |
|
|
57
|
+
* '[2][]'}` (all dimensions, since an array of arrays is valid EIP-712);
|
|
58
|
+
* non-array -> `undefined`, NOT `never` -- `never` is a subtype of
|
|
59
|
+
* everything, so `ParseArrayType<T> extends {elem: ...; dims: ...}` would
|
|
60
|
+
* then vacuously match every non-array `T` too (mirrors abitype's own
|
|
61
|
+
* `undefined` fallback in `MaybeExtractArrayParameterType`, for the same
|
|
62
|
+
* reason).
|
|
49
63
|
*/
|
|
50
|
-
type ParseArrayType<T extends string> = T extends `${infer Elem}[${infer
|
|
64
|
+
type ParseArrayType<T extends string> = T extends `${infer Elem}[${infer Rest}` ? {
|
|
51
65
|
elem: Elem;
|
|
52
|
-
|
|
66
|
+
dims: `[${Rest}`;
|
|
53
67
|
} : undefined;
|
|
54
68
|
/** Mirrors abitype's own (unexported) `Tuple` helper. */
|
|
55
69
|
type FixedLengthTuple<T, N extends number, Acc extends unknown[] = []> = Acc['length'] extends N ? Acc : FixedLengthTuple<T, N, [T, ...Acc]>;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
/** `T[N]` / `T[]` for an array type's parsed `Size`. */
|
|
71
|
+
type ArrayOfSize<T, Size extends string> = Size extends `${infer N extends number}` ? FixedLengthTuple<T, N> : readonly T[];
|
|
72
|
+
/**
|
|
73
|
+
* Wraps `T` in an array per dimension of `Dims` (e.g. `'[2][]'`), leftmost
|
|
74
|
+
* (innermost) first: `T[2][]` is a dynamic-length array of `T[2]`.
|
|
75
|
+
*/
|
|
76
|
+
type ApplyArrayDims<T, Dims extends string> = Dims extends `[${infer Size}]${infer Rest}` ? ApplyArrayDims<ArrayOfSize<T, Size>, Rest> : T;
|
|
77
|
+
type PrimitiveToType<FieldType extends string, Kind extends TypedDataValueKind> = Kind extends 'input' ? FieldType extends `int${string}` | `uint${string}` ? EIP712IntegerInput : AbiParameterToPrimitiveType<{
|
|
60
78
|
name: string;
|
|
61
79
|
type: FieldType;
|
|
62
|
-
}> :
|
|
80
|
+
}> : AbiParameterToPrimitiveType<{
|
|
63
81
|
name: string;
|
|
64
82
|
type: FieldType;
|
|
65
83
|
}>;
|
|
84
|
+
type FieldToType<TD extends Record<string, readonly TypedDataParameter[]>, FieldType extends string, Kind extends TypedDataValueKind> = ParseArrayType<FieldType> extends {
|
|
85
|
+
elem: infer Elem extends string;
|
|
86
|
+
dims: infer Dims extends string;
|
|
87
|
+
} ? Elem extends keyof TD & string ? ApplyArrayDims<StructToType<TD, TD[Elem], Kind>, Dims> : Kind extends 'input' ? ApplyArrayDims<PrimitiveToType<Elem, Kind>, Dims> : AbiParameterToPrimitiveType<{
|
|
88
|
+
name: string;
|
|
89
|
+
type: FieldType;
|
|
90
|
+
}> : FieldType extends keyof TD & string ? StructToType<TD, TD[FieldType], Kind> : PrimitiveToType<FieldType, Kind>;
|
|
66
91
|
export {};
|
|
67
92
|
//# sourceMappingURL=abitype.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abitype.d.ts","sourceRoot":"","sources":["abitype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,aAAa,EACb,SAAS,EACV,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,MAAM,kBAAkB,CAC5B,EAAE,SAAS,MAAM,GAAG,MAAM,EAC1B,EAAE,SAAS,MAAM,GACb,aAAa,GACb,MAAM,SAAS,GACf,GAAG,MAAM,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,IACtC;IACF,IAAI,EAAE,EAAE,CAAC;IACT,IAAI,EAAE,EAAE,CAAC;IACT;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"abitype.d.ts","sourceRoot":"","sources":["abitype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,aAAa,EACb,SAAS,EACV,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,MAAM,kBAAkB,CAC5B,EAAE,SAAS,MAAM,GAAG,MAAM,EAC1B,EAAE,SAAS,MAAM,GACb,aAAa,GACb,MAAM,SAAS,GACf,GAAG,MAAM,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,IACtC;IACF,IAAI,EAAE,EAAE,CAAC;IACT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EnE,KAAK,WAAW,CACd,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC,EACxD,SAAS,SAAS,MAAM,EACxB,IAAI,SAAS,kBAAkB,IAE/B,cAAc,CAAC,SAAS,CAAC,SAAS;IAChC,IAAI,EAAE,MAAM,IAAI,SAAS,MAAM,CAAC;IAChC,IAAI,EAAE,MAAM,IAAI,SAAS,MAAM,CAAC;CACjC,GACG,IAAI,SAAS,MAAM,EAAE,GAAG,MAAM,GAC5B,cAAc,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,GACtD,IAAI,SAAS,OAAO,GAClB,cAAc,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,GACjD,2BAA2B,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,GAClE,SAAS,SAAS,MAAM,EAAE,GAAG,MAAM,GACjC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,GACrC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC"}
|
package/src/utils/abitype.js
CHANGED
|
@@ -42,38 +42,61 @@
|
|
|
42
42
|
* Unlike abitype's version, this has no self/circular-reference detection:
|
|
43
43
|
* none of this repo's type graphs are self-referencing, so it wasn't worth
|
|
44
44
|
* reproducing.
|
|
45
|
+
*
|
|
46
|
+
* `Kind` selects which values the type describes: `'output'` (the default)
|
|
47
|
+
* is the canonical form, e.g. as returned by `normalizeAndValidateEIP712Data`;
|
|
48
|
+
* `'input'` additionally allows the other encodings it accepts and
|
|
49
|
+
* normalizes (see {@link EIP712IntegerInput}).
|
|
45
50
|
*/
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The values `normalizeAndValidateEIP712Data` accepts (and normalizes to
|
|
61
|
+
* abitype's `number`/`bigint` output type) for a `uint<M>`/`int<M>` field. Range and exact string grammar
|
|
62
|
+
* (unsigned hex, or optionally signed decimal) are only checked at runtime.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
50
70
|
|
|
51
71
|
|
|
52
72
|
|
|
53
73
|
|
|
74
|
+
|
|
54
75
|
|
|
55
76
|
|
|
56
77
|
|
|
57
78
|
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
|
|
60
81
|
|
|
61
82
|
|
|
62
83
|
|
|
63
84
|
|
|
64
|
-
|
|
85
|
+
|
|
65
86
|
|
|
66
87
|
|
|
67
88
|
|
|
68
89
|
/**
|
|
69
|
-
* `Foo[3]` / `Foo[]` -> `{elem: 'Foo';
|
|
70
|
-
* `
|
|
71
|
-
* `
|
|
72
|
-
*
|
|
73
|
-
*
|
|
90
|
+
* `Foo[3]` / `Foo[]` / `Foo[2][]` -> `{elem: 'Foo'; dims: '[3]' | '[]' |
|
|
91
|
+
* '[2][]'}` (all dimensions, since an array of arrays is valid EIP-712);
|
|
92
|
+
* non-array -> `undefined`, NOT `never` -- `never` is a subtype of
|
|
93
|
+
* everything, so `ParseArrayType<T> extends {elem: ...; dims: ...}` would
|
|
94
|
+
* then vacuously match every non-array `T` too (mirrors abitype's own
|
|
95
|
+
* `undefined` fallback in `MaybeExtractArrayParameterType`, for the same
|
|
96
|
+
* reason).
|
|
74
97
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
98
|
+
|
|
99
|
+
|
|
77
100
|
|
|
78
101
|
|
|
79
102
|
/** Mirrors abitype's own (unexported) `Tuple` helper. */
|
|
@@ -83,19 +106,46 @@
|
|
|
83
106
|
|
|
84
107
|
|
|
85
108
|
|
|
109
|
+
/** `T[N]` / `T[]` for an array type's parsed `Size`. */
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Wraps `T` in an array per dimension of `Dims` (e.g. `'[2][]'`), leftmost
|
|
117
|
+
* (innermost) first: `T[2][]` is a dynamic-length array of `T[2]`.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
86
135
|
|
|
87
136
|
|
|
88
137
|
|
|
138
|
+
|
|
89
139
|
|
|
90
140
|
|
|
91
141
|
|
|
92
142
|
|
|
93
143
|
|
|
94
144
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
99
151
|
|
|
100
|
-
|
|
101
|
-
|
package/src/utils/address.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export function makeICQChannelAddress(controllerConnectionId: IBCConnectionID, v
|
|
|
12
12
|
export function findAddressField(remoteAddressString: RemoteIbcAddress): CosmosChainAddress["value"] | undefined;
|
|
13
13
|
export function getBech32Prefix(address: Bech32Address | string): string;
|
|
14
14
|
export function sameEvmAddress(a: EvmAddress, b: EvmAddress | undefined): boolean;
|
|
15
|
+
export function isEvmAddressShape(x: unknown): x is EvmAddress;
|
|
15
16
|
export function coerceAccountId(idArg: AccountIdArg): AccountId;
|
|
16
17
|
export function parseAccountIdArg(idArg: AccountIdArg): Caip10Record;
|
|
17
18
|
export function parseAccountId(accountId: AccountId): Caip10Record;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["address.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["address.js"],"names":[],"mappings":"AA4OA;;;;;;GAMG;AACH,6CAHW,MAAM,GACJ,QAAQ,OAAO,IAAI,aAAa,CAM5C;AA3NM,wDALI,eAAe,0BACf,eAAe,6CACf,qBAAqB,GACnB,gBAAgB,CA4B5B;AAGD,kCAAmC,OAAO,CAAC;AAOpC,8DAJI,eAAe,YACf,MAAM,GACJ,gBAAgB,CAa5B;AAaM,sDAJI,gBAAgB,GAEd,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS,CAYnD;AAaM,yCAHI,aAAa,GAAG,MAAM,GACpB,MAAM,CAQlB;AASM,kCAJI,UAAU,KACV,UAAU,GAAG,SAAS,GACpB,OAAO,CAEwD;AAUrE,qCAHI,OAAO,GACL,CAAC,IAAI,UAAU,CAG6B;AAYlD,uCAJI,YAAY,GAEV,SAAS,CAQrB;AAUM,yCAJI,YAAY,GAEV,YAAY,CAaxB;AASM,0CAHI,SAAS,GACP,YAAY,CAaxB;AAUM,6CAJI,YAAY,GAEV,WAAW,CAKvB;AASM,yCAJI,MAAM,GACJ,OAAO,CAkBnB;AAwBM,uDAFI,MAAM,+BAOhB;AAWM,8CAJI,SAAS,GACP,UAAU,CAatB;;;;;;;;;;;;;;;;;;;;;mCAnRgE,aAAa;qCAF1B,qBAAqB;sCAArB,qBAAqB;wCAER,aAAa;2CADtC,MAAM;kCAEU,yBAAyB;+BAAzB,yBAAyB;kCAAzB,yBAAyB;iCADhB,aAAa"}
|
package/src/utils/address.js
CHANGED
|
@@ -127,6 +127,17 @@ export const getBech32Prefix = address => {
|
|
|
127
127
|
export const sameEvmAddress = (a, b) => a.toLowerCase() === b?.toLowerCase();
|
|
128
128
|
harden(sameEvmAddress);
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Whether `x` has the shape of an EVM address: `0x` followed by 40 hex
|
|
132
|
+
* digits, in any casing (an EIP-55 checksum is not verified).
|
|
133
|
+
*
|
|
134
|
+
* @param {unknown} x
|
|
135
|
+
* @returns {x is EvmAddress}
|
|
136
|
+
*/
|
|
137
|
+
export const isEvmAddressShape = x =>
|
|
138
|
+
typeof x === 'string' && /^0x[0-9a-fA-F]{40}$/u.test(x);
|
|
139
|
+
harden(isEvmAddressShape);
|
|
140
|
+
|
|
130
141
|
/**
|
|
131
142
|
* Coerce an AccountIdArg into a plain AccountId. The latter is now preferred so
|
|
132
143
|
* this utility can be used to adapt legacy calls, in particular from vows
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* The viem runtime dependency is expected as a power to make this usable both
|
|
7
7
|
* on chain and in off-chain services.
|
|
8
8
|
*/
|
|
9
|
-
import type { Address } from 'abitype';
|
|
9
|
+
import type { Address, TypedDataDomain } from 'abitype';
|
|
10
10
|
import type { getTypesForEIP712Domain } from 'viem';
|
|
11
11
|
import type { hashStruct, isHex, recoverTypedDataAddress } from 'viem/utils';
|
|
12
|
+
import type { TypedDataParameter } from './abitype.js';
|
|
12
13
|
import type { encodeType, WithSignature } from './viem.js';
|
|
13
14
|
import { type Permit2Domain, type PermitWitnessTransferFromPayload } from './permit2.js';
|
|
14
15
|
import { type EIP712MessageSchema, type FullDomain, type OperationNames, type OperationType, type PermitWitnessTransferFromOperationData, type StandaloneOperationData } from './eip712-messages.js';
|
|
@@ -35,11 +36,24 @@ export type PermitDetails = {
|
|
|
35
36
|
spender: Address;
|
|
36
37
|
permit2Payload: Omit<PermitWitnessTransferFromPayload, 'transferDetails'>;
|
|
37
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* The normalized form of an EIP-712 message: what remains of it once
|
|
41
|
+
* validated, with its values in canonical form (e.g. integers as
|
|
42
|
+
* `bigint`/`number`). Hashes identically to the message as received.
|
|
43
|
+
*/
|
|
44
|
+
export type NormalizedTypedData = {
|
|
45
|
+
domain: TypedDataDomain;
|
|
46
|
+
types: Record<string, readonly TypedDataParameter[]>;
|
|
47
|
+
primaryType: string;
|
|
48
|
+
message: Record<string, unknown>;
|
|
49
|
+
};
|
|
38
50
|
export type FullMessageDetails<S extends EIP712MessageSchema, T extends OperationNames<S> = OperationNames<S>> = OperationDetails<S, T> & {
|
|
39
51
|
permitDetails?: PermitDetails;
|
|
40
52
|
evmWalletAddress: Address;
|
|
41
53
|
nonce: bigint;
|
|
42
54
|
deadline: bigint;
|
|
55
|
+
/** The normalized message the details were extracted from. */
|
|
56
|
+
normalizedData: NormalizedTypedData;
|
|
43
57
|
};
|
|
44
58
|
/**
|
|
45
59
|
* Valid contract addresses, keyed by chain ID.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip712-message-handler.d.ts","sourceRoot":"","sources":["eip712-message-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"eip712-message-handler.d.ts","sourceRoot":"","sources":["eip712-message-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAa,eAAe,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,KAAK,EACV,UAAU,EACV,KAAK,EACL,uBAAuB,EAExB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAML,KAAK,aAAa,EAIlB,KAAK,gCAAgC,EACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,sCAAsC,EAC3C,KAAK,uBAAuB,EAE7B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,mBAAmB,EAC7B,CAAC,SAAS,cAAc,CAAC,CAAC,CAA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CAAC,CAAC,EAAE,CAAC,CAAC;4CAiK0B,CAAC,4DACxC,aAAa,CAAC,4EAAiC,CAAC,GAAG;QAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,oCACiC,iBAAiB,KAClD,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CA0BrC,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,mBAAmB,IACjE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from './permit2.js';
|
|
34
34
|
import {
|
|
35
35
|
makeEIP712MessageKit,
|
|
36
|
+
StandaloneEnvelopeTypeParams,
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
|
|
@@ -71,6 +72,18 @@ import {
|
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
|
|
75
|
+
/**
|
|
76
|
+
* The normalized form of an EIP-712 message: what remains of it once
|
|
77
|
+
* validated, with its values in canonical form (e.g. integers as
|
|
78
|
+
* `bigint`/`number`). Hashes identically to the message as received.
|
|
79
|
+
*/
|
|
80
|
+
;
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
74
87
|
;
|
|
75
88
|
|
|
76
89
|
|
|
@@ -79,6 +92,8 @@ import {
|
|
|
79
92
|
|
|
80
93
|
|
|
81
94
|
|
|
95
|
+
|
|
96
|
+
|
|
82
97
|
|
|
83
98
|
|
|
84
99
|
/**
|
|
@@ -178,7 +193,11 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
178
193
|
* an attenuated grant into an unconstrained one. The returned `data` can
|
|
179
194
|
* therefore be a superset of the expected shape; it is guaranteed to
|
|
180
195
|
* satisfy the expected types (required fields present, values of the
|
|
181
|
-
* right shape/range
|
|
196
|
+
* right shape/range, and already in the canonical JS form for the
|
|
197
|
+
* expected type, e.g. a `bigint` for a `uint256`: a field the signed
|
|
198
|
+
* types declared differently, e.g. as `uint48` or `string`, is rejected
|
|
199
|
+
* rather than returned with an unexpected JS type), but consumers that
|
|
200
|
+
* must reject unrecognized fields
|
|
182
201
|
* (e.g. permission records) need to validate that themselves against a
|
|
183
202
|
* closed shape.
|
|
184
203
|
*
|
|
@@ -204,9 +223,18 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
204
223
|
|
|
205
224
|
messageKit.validateOperationTypeName (standaloneData.primaryType);
|
|
206
225
|
|
|
207
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
208
226
|
const { nonce, deadline, ...operationData } =
|
|
209
227
|
standaloneData.message ;
|
|
228
|
+
// The signed types of the envelope fields are otherwise not checked
|
|
229
|
+
// against the expected ones (unlike permit2's, see `extractPermitDetails`).
|
|
230
|
+
normalizeAndValidateEIP712Data(
|
|
231
|
+
{
|
|
232
|
+
message: { nonce, deadline },
|
|
233
|
+
types: { StandaloneEnvelope: StandaloneEnvelopeTypeParams },
|
|
234
|
+
primaryType: 'StandaloneEnvelope',
|
|
235
|
+
},
|
|
236
|
+
{ onExtraField: 'throw', onNonCanonicalValue: 'throw' },
|
|
237
|
+
);
|
|
210
238
|
const operation = standaloneData.primaryType;
|
|
211
239
|
const { message: normalizedData } = normalizeAndValidateEIP712Data(
|
|
212
240
|
{
|
|
@@ -214,7 +242,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
214
242
|
types: messageKit.getOperationTypes(operation),
|
|
215
243
|
primaryType: operation,
|
|
216
244
|
},
|
|
217
|
-
{ onExtraField: 'keep' },
|
|
245
|
+
{ onExtraField: 'keep', onNonCanonicalValue: 'throw' },
|
|
218
246
|
);
|
|
219
247
|
return {
|
|
220
248
|
operation,
|
|
@@ -274,7 +302,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
274
302
|
types: messageKit.getOperationTypes(operation),
|
|
275
303
|
primaryType: operation,
|
|
276
304
|
},
|
|
277
|
-
{ onExtraField: 'keep' },
|
|
305
|
+
{ onExtraField: 'keep', onNonCanonicalValue: 'throw' },
|
|
278
306
|
);
|
|
279
307
|
const spender = permitData.message.spender;
|
|
280
308
|
return {
|
|
@@ -423,7 +451,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
423
451
|
) => {
|
|
424
452
|
const {
|
|
425
453
|
address: tokenOwner,
|
|
426
|
-
domain,
|
|
454
|
+
domain: rawDomain,
|
|
427
455
|
...otherData
|
|
428
456
|
} = data
|
|
429
457
|
|
|
@@ -433,7 +461,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
433
461
|
|
|
434
462
|
;
|
|
435
463
|
|
|
436
|
-
if (!
|
|
464
|
+
if (!rawDomain) {
|
|
437
465
|
throw new Error(`Missing domain in typed data`);
|
|
438
466
|
}
|
|
439
467
|
|
|
@@ -452,21 +480,55 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
452
480
|
message: signedMessage,
|
|
453
481
|
types: signedTypes,
|
|
454
482
|
};
|
|
483
|
+
// Normalized per the signed types: checked to be the expected `uint256`
|
|
484
|
+
// (so `bigint`) by `extractPermitDetails` / the base permit2 types, or
|
|
485
|
+
// `extractOperationDetailsFromStandaloneData`.
|
|
455
486
|
const { nonce, deadline } = signedMessage
|
|
456
487
|
|
|
457
488
|
|
|
458
489
|
;
|
|
459
490
|
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
//
|
|
464
|
-
//
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
491
|
+
// Validate `domain` against the same types viem's signature recovery
|
|
492
|
+
// hashes it with: the message's own `types.EIP712Domain` if declared (as
|
|
493
|
+
// `eth_signTypedData_v4` payloads do), else derived from `domain`'s
|
|
494
|
+
// shape. Any present field those types leave out was not part of the
|
|
495
|
+
// signed domain hash, so reject rather than drop it -- notably a string
|
|
496
|
+
// `chainId` without declared types, which viem (unlike ethers.js) omits
|
|
497
|
+
// from the derived types. This also checks values (e.g. `chainId`
|
|
498
|
+
// range, `verifyingContract` shape) and normalizes them (e.g. a number
|
|
499
|
+
// or declared string `chainId` to a bigint).
|
|
500
|
+
// Domain-specific checks (name/version/contract match, field types)
|
|
501
|
+
// happen later, in `validateDomain`/`validatePermit2Domain`.
|
|
502
|
+
const domain = normalizeAndValidateEIP712Data(
|
|
503
|
+
{
|
|
504
|
+
message: rawDomain ,
|
|
505
|
+
types: {
|
|
506
|
+
EIP712Domain:
|
|
507
|
+
otherData.types.EIP712Domain ??
|
|
508
|
+
getTypesForEIP712Domain({ domain: rawDomain }),
|
|
509
|
+
},
|
|
510
|
+
primaryType: 'EIP712Domain',
|
|
511
|
+
},
|
|
512
|
+
{ onExtraField: 'throw' },
|
|
513
|
+
).message ;
|
|
514
|
+
const normalizedData = {
|
|
515
|
+
domain,
|
|
516
|
+
types: signedTypes,
|
|
517
|
+
primaryType: otherData.primaryType,
|
|
518
|
+
message: signedMessage,
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// The declared types used above may be non-standard (e.g. an `int256`
|
|
522
|
+
// `chainId`), so also check the now-normalized values against the
|
|
523
|
+
// standard domain types, as derived by viem from those values.
|
|
524
|
+
normalizeAndValidateEIP712Data(
|
|
525
|
+
{
|
|
526
|
+
message: domain ,
|
|
527
|
+
types: { EIP712Domain: getTypesForEIP712Domain({ domain }) },
|
|
528
|
+
primaryType: 'EIP712Domain',
|
|
529
|
+
},
|
|
530
|
+
{ onExtraField: 'throw', onNonCanonicalValue: 'throw' },
|
|
531
|
+
);
|
|
470
532
|
|
|
471
533
|
if (isPermit2MessageType(data.primaryType)) {
|
|
472
534
|
if (!messageKit.supportsPermit2Witness) {
|
|
@@ -508,6 +570,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
508
570
|
evmWalletAddress: tokenOwner,
|
|
509
571
|
nonce,
|
|
510
572
|
deadline,
|
|
573
|
+
normalizedData,
|
|
511
574
|
};
|
|
512
575
|
} else {
|
|
513
576
|
const standaloneData = signedData
|
|
@@ -527,6 +590,7 @@ export const makeEIP712MessageHandlerUtils = (
|
|
|
527
590
|
evmWalletAddress: tokenOwner,
|
|
528
591
|
nonce,
|
|
529
592
|
deadline,
|
|
593
|
+
normalizedData,
|
|
530
594
|
};
|
|
531
595
|
}
|
|
532
596
|
};
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { Address, TypedData, TypedDataDomain } from 'abitype';
|
|
24
24
|
import type { TypedDataDefinition } from 'viem';
|
|
25
|
-
import type { TypedDataParameter, TypedDataToStructType } from './abitype.js';
|
|
25
|
+
import type { TypedDataParameter, TypedDataToStructType, TypedDataValueKind } from './abitype.js';
|
|
26
26
|
import { type Witness, type getPermitWitnessTransferFromData, type getPermitBatchWitnessTransferFromData } from './permit2.js';
|
|
27
27
|
type TypedDataRecord = Record<string, readonly TypedDataParameter[]>;
|
|
28
28
|
/**
|
|
@@ -101,8 +101,8 @@ type StandaloneOperationTypes<S extends EIP712MessageSchema, T extends Operation
|
|
|
101
101
|
export type StandaloneTypes<S extends EIP712MessageSchema, T extends OperationNames<S> = OperationNames<S>> = StandaloneOperationTypes<S, T> & S['subTypes'] & {
|
|
102
102
|
EIP712Domain: typeof StandaloneDomainTypeParams;
|
|
103
103
|
};
|
|
104
|
-
export type WitnessData<S extends EIP712MessageSchema, T extends OperationNames<S
|
|
105
|
-
export type StandaloneData<S extends EIP712MessageSchema, T extends OperationNames<S
|
|
104
|
+
export type WitnessData<S extends EIP712MessageSchema, T extends OperationNames<S>, Kind extends TypedDataValueKind = 'output'> = TypedDataToStructType<WitnessTypes<S, T>, WitnessTypeParam<S, T>['type'], Kind>;
|
|
105
|
+
export type StandaloneData<S extends EIP712MessageSchema, T extends OperationNames<S>, Kind extends TypedDataValueKind = 'output'> = TypedDataToStructType<StandaloneTypes<S, T>, T, Kind>;
|
|
106
106
|
export type StandaloneOperationData<S extends EIP712MessageSchema, T extends OperationNames<S> = OperationNames<S>> = TypedDataDefinition<StandaloneTypes<S, T>, T, T> & {
|
|
107
107
|
domain: FullDomain<S>;
|
|
108
108
|
};
|
|
@@ -137,10 +137,10 @@ export interface EIP712MessageKit<S extends EIP712MessageSchema> {
|
|
|
137
137
|
[K in T]: S['operationTypes'][K];
|
|
138
138
|
} & S['subTypes'];
|
|
139
139
|
/** Make the witness of an operation for a permit2 message. */
|
|
140
|
-
getWitness<T extends OperationNames<S>>(operation: T, data: NoInfer<WitnessData<S, T>>): OperationWitness<S, T>;
|
|
140
|
+
getWitness<T extends OperationNames<S>>(operation: T, data: NoInfer<WitnessData<S, T, 'input'>>): OperationWitness<S, T>;
|
|
141
141
|
getStandaloneDomain(chainId: bigint | number, verifyingContract: Address): FullDomain<S>;
|
|
142
142
|
/** Make the typed data of a standalone operation message. */
|
|
143
|
-
getStandaloneOperationData<T extends OperationNames<S>>(data: NoInfer<StandaloneData<S, T>>, operation: T, chainId: bigint | number, verifyingContract: Address): StandaloneOperationData<S, T>;
|
|
143
|
+
getStandaloneOperationData<T extends OperationNames<S>>(data: NoInfer<StandaloneData<S, T, 'input'>>, operation: T, chainId: bigint | number, verifyingContract: Address): StandaloneOperationData<S, T>;
|
|
144
144
|
/** Validate the name and version of a domain. */
|
|
145
145
|
validateDomainBase(domain: TypedDataDomain): asserts domain is DomainBase<S>;
|
|
146
146
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip712-messages.d.ts","sourceRoot":"","sources":["eip712-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"eip712-messages.d.ts","sourceRoot":"","sources":["eip712-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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