@agoric/orchestration 0.1.1-dev-827f812.0.827f812 → 0.1.1-dev-dbd6917.0.dbd6917
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/typeGuards.d.ts +29 -5
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +43 -5
- package/src/utils/viem-utils/eip712-normalize.d.ts +19 -1
- package/src/utils/viem-utils/eip712-normalize.d.ts.map +1 -1
- package/src/utils/viem-utils/eip712-normalize.js +23 -6
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-dbd6917.0.dbd6917",
|
|
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-dbd6917.0.dbd6917",
|
|
39
|
+
"@agoric/cosmic-proto": "0.4.1-dev-dbd6917.0.dbd6917",
|
|
40
|
+
"@agoric/ertp": "0.16.3-dev-dbd6917.0.dbd6917",
|
|
41
|
+
"@agoric/internal": "0.3.3-dev-dbd6917.0.dbd6917",
|
|
42
|
+
"@agoric/network": "0.1.1-dev-dbd6917.0.dbd6917",
|
|
43
|
+
"@agoric/notifier": "0.6.3-dev-dbd6917.0.dbd6917",
|
|
44
|
+
"@agoric/store": "0.9.3-dev-dbd6917.0.dbd6917",
|
|
45
|
+
"@agoric/time": "0.3.3-dev-dbd6917.0.dbd6917",
|
|
46
|
+
"@agoric/vat-data": "0.5.3-dev-dbd6917.0.dbd6917",
|
|
47
|
+
"@agoric/vow": "0.1.1-dev-dbd6917.0.dbd6917",
|
|
48
|
+
"@agoric/zoe": "0.26.3-dev-dbd6917.0.dbd6917",
|
|
49
|
+
"@agoric/zone": "0.2.3-dev-dbd6917.0.dbd6917",
|
|
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-dbd6917.0.dbd6917",
|
|
65
|
+
"@agoric/vats": "0.15.2-dev-dbd6917.0.dbd6917",
|
|
66
|
+
"@agoric/xsnap": "0.14.3-dev-dbd6917.0.dbd6917",
|
|
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": "dbd69178a10fc0c096d38f920c54bcf8e38d083c"
|
|
104
104
|
}
|
package/src/typeGuards.d.ts
CHANGED
|
@@ -224,12 +224,36 @@ export const ForwardOptsShape: CastedPattern<NonNullable<IBCMsgTransferOptions["
|
|
|
224
224
|
* @internal
|
|
225
225
|
*/
|
|
226
226
|
export const IBCTransferOptionsShape: CastedPattern<IBCMsgTransferOptions>;
|
|
227
|
+
export namespace EIP712TypeEntryShape {
|
|
228
|
+
let name: import("@endo/patterns").MatcherOf<"string", string>;
|
|
229
|
+
let type: import("@endo/patterns").MatcherOf<"string", string>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* EIP-712 struct type definitions, keyed by type name. The `EIP712Domain` type
|
|
233
|
+
* is not required; a consumer that requires it can combine this with e.g.
|
|
234
|
+
* `M.splitRecord({ EIP712Domain: M.any() }, {}, M.any())` using `M.and`.
|
|
235
|
+
*/
|
|
236
|
+
export const EIP712TypesShape: import("@endo/patterns").MatcherOf<"recordOf", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"arrayOf", {
|
|
237
|
+
name: import("@endo/patterns").MatcherOf<"string", string>;
|
|
238
|
+
type: import("@endo/patterns").MatcherOf<"string", string>;
|
|
239
|
+
}>]>;
|
|
240
|
+
/**
|
|
241
|
+
* An EIP-712 domain, with only standard fields, all optional. An integer
|
|
242
|
+
* `chainId` may be in any form accepted for EIP-712 integers.
|
|
243
|
+
*/
|
|
244
|
+
export const EIP712DomainShape: import("@endo/patterns").MatcherOf<"splitRecord", [{}, {
|
|
245
|
+
name: import("@endo/patterns").MatcherOf<"string", string>;
|
|
246
|
+
version: import("@endo/patterns").MatcherOf<"string", string>;
|
|
247
|
+
chainId: import("@endo/patterns").MatcherOf<"or", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"number", number>, import("@endo/patterns").MatcherOf<"bigint", bigint>]>;
|
|
248
|
+
verifyingContract: import("@endo/patterns").MatcherOf<"string", string>;
|
|
249
|
+
salt: import("@endo/patterns").MatcherOf<"string", string>;
|
|
250
|
+
}, {}]>;
|
|
227
251
|
export namespace SignedEIP712DataShape {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
let primaryType: import("@endo/patterns").MatcherOf<"string", string>;
|
|
231
|
-
let message: import("@endo/patterns").MatcherOf<"recordOf", any>;
|
|
232
|
-
let signature: import("@endo/patterns").MatcherOf<"or", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"recordOf", any>]>;
|
|
252
|
+
export { EIP712DomainShape as domain };
|
|
253
|
+
export { EIP712TypesShape as types };
|
|
254
|
+
export let primaryType: import("@endo/patterns").MatcherOf<"string", string>;
|
|
255
|
+
export let message: import("@endo/patterns").MatcherOf<"recordOf", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"any", any>]>;
|
|
256
|
+
export let signature: import("@endo/patterns").MatcherOf<"or", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"recordOf", any>]>;
|
|
233
257
|
}
|
|
234
258
|
import type { Caip10Record } from './types.js';
|
|
235
259
|
import type { CastedPattern } from '@endo/patterns';
|
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH;;;GAQE;;;;;;AAYF,0CAA0C;AAC1C,gCADW,cAAc,YAAY,CAAC,CAKpC;;AAMF;;;;GAIG;AACH,gCAFU,cAAc,YAAY,CAAC,CAEsC;AAE3E,uCAAuC;AACvC,0BADW,cAAc,SAAS,CAAC,CACmC;AAGtE,gBAAgB;AAChB,qFAA4C;AAE5C,gBAAgB;AAChB;;;;;;;;eAQG;AAEH,gBAAgB;AAChB,wFAA+C;AAE/C,gBA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C;;;;;AAUF;;;;GAIG;AACH;;;KAGE;AAGF;;;GAGG;AACH;;;;;;QAUE;;;;;;;;kCAlZ6C,YAAY;mCAN3B,gBAAgB;kCAMD,YAAY;sCACxB,6CAA6C;qCADjC,YAAY;mCAAZ,YAAY;qCAAZ,YAAY;+BAAZ,YAAY;0BAGpC,kDAAkD;+BAH1B,YAAY;iCAK7B,qBAAqB;iCALJ,YAAY;4BAMlC,cAAc;+BANQ,YAAY;4CAAZ,YAAY;+BAI/B,sBAAsB;0CAJH,YAAY;mCAAZ,YAAY;yCAAZ,YAAY;mDAAZ,YAAY;0CAAZ,YAAY;4BAElC,8CAA8C;yCAFxB,YAAY;iCAAZ,YAAY;2CAAZ,YAAY"}
|
package/src/typeGuards.js
CHANGED
|
@@ -379,10 +379,48 @@ export const IBCTransferOptionsShape = M.and(
|
|
|
379
379
|
CosmosActionOptionsShape,
|
|
380
380
|
);
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* An entry of an EIP-712 struct type definition: a field name and its type.
|
|
384
|
+
* Nothing else is allowed, notably not the repo-local `optional` marker, which
|
|
385
|
+
* belongs in schema definitions only, never in typed data.
|
|
386
|
+
*/
|
|
387
|
+
export const EIP712TypeEntryShape = { name: M.string(), type: M.string() };
|
|
388
|
+
harden(EIP712TypeEntryShape);
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* EIP-712 struct type definitions, keyed by type name. The `EIP712Domain` type
|
|
392
|
+
* is not required; a consumer that requires it can combine this with e.g.
|
|
393
|
+
* `M.splitRecord({ EIP712Domain: M.any() }, {}, M.any())` using `M.and`.
|
|
394
|
+
*/
|
|
395
|
+
export const EIP712TypesShape = M.recordOf(
|
|
396
|
+
M.string(),
|
|
397
|
+
M.arrayOf(EIP712TypeEntryShape),
|
|
398
|
+
);
|
|
399
|
+
harden(EIP712TypesShape);
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* An EIP-712 domain, with only standard fields, all optional. An integer
|
|
403
|
+
* `chainId` may be in any form accepted for EIP-712 integers.
|
|
404
|
+
*/
|
|
405
|
+
export const EIP712DomainShape = M.splitRecord(
|
|
406
|
+
{},
|
|
407
|
+
{
|
|
408
|
+
name: M.string(),
|
|
409
|
+
version: M.string(),
|
|
410
|
+
chainId: M.or(M.string(), M.number(), M.bigint()),
|
|
411
|
+
verifyingContract: M.string(),
|
|
412
|
+
salt: M.string(),
|
|
413
|
+
},
|
|
414
|
+
{},
|
|
415
|
+
);
|
|
416
|
+
harden(EIP712DomainShape);
|
|
417
|
+
|
|
382
418
|
/**
|
|
383
419
|
* The fields of signed EIP-712 typed data, e.g. as relayed on behalf of its
|
|
384
|
-
* signer. Only the
|
|
385
|
-
*
|
|
420
|
+
* signer. Only the structure is described: the values themselves (whose
|
|
421
|
+
* types depend on the typed data's `types`, and can't be described by a
|
|
422
|
+
* recursive pattern), identifiers, and the signature need to be validated
|
|
423
|
+
* separately, e.g. by `normalizeAndValidateEIP712Data`.
|
|
386
424
|
*
|
|
387
425
|
* The signature may be in any passable form accepted by viem (see
|
|
388
426
|
* `WithSignature`): hex encoded, or structured (`{ r, s, v }` or
|
|
@@ -391,10 +429,10 @@ export const IBCTransferOptionsShape = M.and(
|
|
|
391
429
|
* As a record of shapes, it can also be extended with other fields.
|
|
392
430
|
*/
|
|
393
431
|
export const SignedEIP712DataShape = {
|
|
394
|
-
domain:
|
|
395
|
-
types:
|
|
432
|
+
domain: EIP712DomainShape,
|
|
433
|
+
types: EIP712TypesShape,
|
|
396
434
|
primaryType: M.string(),
|
|
397
|
-
message: M.
|
|
435
|
+
message: M.recordOf(M.string(), M.any()),
|
|
398
436
|
signature: M.or(M.string(), M.record()),
|
|
399
437
|
};
|
|
400
438
|
harden(SignedEIP712DataShape);
|
|
@@ -87,11 +87,29 @@ export type NormalizeAndValidateEIP712DataResult = {
|
|
|
87
87
|
message: Record<string, unknown>;
|
|
88
88
|
types: TypesRecord;
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Make a `RegExp` of the grammar of string-encoded EIP-712 `(u)int<M>` values
|
|
92
|
+
* accepted by {@link parseEIP712Integer}: unsigned hex, or decimal with an
|
|
93
|
+
* optional sign. Such strings are also bounded in length by
|
|
94
|
+
* {@link EIP712_INTEGER_STRING_MAX_LENGTH}.
|
|
95
|
+
*
|
|
96
|
+
* For consumers that need to describe the grammar (e.g. in an API schema); to
|
|
97
|
+
* validate a value, prefer {@link parseEIP712Integer}. Each call returns a new
|
|
98
|
+
* instance, since a `RegExp` is mutable.
|
|
99
|
+
*/
|
|
100
|
+
export declare const makeEIP712IntegerStringRegExp: () => RegExp;
|
|
101
|
+
/**
|
|
102
|
+
* The maximum length of a string-encoded EIP-712 integer accepted by
|
|
103
|
+
* {@link parseEIP712Integer}. Bounds the work `BigInt` parsing of an
|
|
104
|
+
* untrusted string can do. Generous for any in-range 256-bit value (at most
|
|
105
|
+
* 78 decimal or 64 hex digits), leaving room for some leading zeros in hex.
|
|
106
|
+
*/
|
|
107
|
+
export declare const EIP712_INTEGER_STRING_MAX_LENGTH = 100;
|
|
90
108
|
/**
|
|
91
109
|
* Parses an integer given in one of the JS representations accepted for an
|
|
92
110
|
* EIP-712 `(u)int<M>` value: a `bigint`, a safe integer `number`, or a
|
|
93
111
|
* string of unsigned hex (`0x...`) or optionally signed decimal digits (see
|
|
94
|
-
*
|
|
112
|
+
* {@link makeEIP712IntegerStringRegExp}). Returns `undefined` for anything else, including
|
|
95
113
|
* non-integer and unsafe-integer numbers (which have likely already lost
|
|
96
114
|
* precision; ethers.js rejects them too). Does not check the value's range
|
|
97
115
|
* for any particular type: see {@link normalizeEIP712Primitive} for that.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip712-normalize.d.ts","sourceRoot":"","sources":["eip712-normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,OAAO,KAAK,EAAE,kB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AAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AA4CF;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,QAAO,MACf,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,MAAM,CAAC;AAwFpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAc5D,CAAC;AAeF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,MAAM,EACjB,OAAO,OAAO,KACb,OAgFF,CAAC;AAwLF,eAAO,MAAM,8BAA8B,GACzC,OAAO,mCAAmC,EAC1C,UAAS,qCAA0C,KAClD,oCA+EF,CAAC"}
|
|
@@ -133,10 +133,27 @@ const HEX_REGEX = /^0x[0-9a-fA-F]*$/u;
|
|
|
133
133
|
// which has no distinct meaning (`0` and `+0` are fine). Hex may have
|
|
134
134
|
// leading zeros, as fixed-width hex commonly does.
|
|
135
135
|
const INTEGER_STRING_REGEX = /^(?:\+?0|[-+]?[1-9][0-9]*|0x[0-9a-fA-F]+)$/u;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Make a `RegExp` of the grammar of string-encoded EIP-712 `(u)int<M>` values
|
|
139
|
+
* accepted by {@link parseEIP712Integer}: unsigned hex, or decimal with an
|
|
140
|
+
* optional sign. Such strings are also bounded in length by
|
|
141
|
+
* {@link EIP712_INTEGER_STRING_MAX_LENGTH}.
|
|
142
|
+
*
|
|
143
|
+
* For consumers that need to describe the grammar (e.g. in an API schema); to
|
|
144
|
+
* validate a value, prefer {@link parseEIP712Integer}. Each call returns a new
|
|
145
|
+
* instance, since a `RegExp` is mutable.
|
|
146
|
+
*/
|
|
147
|
+
export const makeEIP712IntegerStringRegExp = () =>
|
|
148
|
+
new RegExp(INTEGER_STRING_REGEX);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The maximum length of a string-encoded EIP-712 integer accepted by
|
|
152
|
+
* {@link parseEIP712Integer}. Bounds the work `BigInt` parsing of an
|
|
153
|
+
* untrusted string can do. Generous for any in-range 256-bit value (at most
|
|
154
|
+
* 78 decimal or 64 hex digits), leaving room for some leading zeros in hex.
|
|
155
|
+
*/
|
|
156
|
+
export const EIP712_INTEGER_STRING_MAX_LENGTH = 100;
|
|
140
157
|
// abitype types `(u)int<M>` values as `number` for `M <= 48`, else `bigint`.
|
|
141
158
|
const MAX_NUMBER_INTEGER_BITS = 48;
|
|
142
159
|
|
|
@@ -228,7 +245,7 @@ const describeValue = (value ) => {
|
|
|
228
245
|
* Parses an integer given in one of the JS representations accepted for an
|
|
229
246
|
* EIP-712 `(u)int<M>` value: a `bigint`, a safe integer `number`, or a
|
|
230
247
|
* string of unsigned hex (`0x...`) or optionally signed decimal digits (see
|
|
231
|
-
*
|
|
248
|
+
* {@link makeEIP712IntegerStringRegExp}). Returns `undefined` for anything else, including
|
|
232
249
|
* non-integer and unsafe-integer numbers (which have likely already lost
|
|
233
250
|
* precision; ethers.js rejects them too). Does not check the value's range
|
|
234
251
|
* for any particular type: see {@link normalizeEIP712Primitive} for that.
|
|
@@ -242,7 +259,7 @@ export const parseEIP712Integer = (value ) => {
|
|
|
242
259
|
}
|
|
243
260
|
if (
|
|
244
261
|
typeof value !== 'string' ||
|
|
245
|
-
value.length >
|
|
262
|
+
value.length > EIP712_INTEGER_STRING_MAX_LENGTH ||
|
|
246
263
|
!INTEGER_STRING_REGEX.test(value)
|
|
247
264
|
) {
|
|
248
265
|
return undefined;
|