@agoric/orchestration 0.1.1-dev-3a9096a.0.3a9096a → 0.1.1-dev-fac5579.0.fac5579

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-3a9096a.0.3a9096a",
3
+ "version": "0.1.1-dev-fac5579.0.fac5579",
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-3a9096a.0.3a9096a",
39
- "@agoric/cosmic-proto": "0.4.1-dev-3a9096a.0.3a9096a",
40
- "@agoric/ertp": "0.16.3-dev-3a9096a.0.3a9096a",
41
- "@agoric/internal": "0.3.3-dev-3a9096a.0.3a9096a",
42
- "@agoric/network": "0.1.1-dev-3a9096a.0.3a9096a",
43
- "@agoric/notifier": "0.6.3-dev-3a9096a.0.3a9096a",
44
- "@agoric/store": "0.9.3-dev-3a9096a.0.3a9096a",
45
- "@agoric/time": "0.3.3-dev-3a9096a.0.3a9096a",
46
- "@agoric/vat-data": "0.5.3-dev-3a9096a.0.3a9096a",
47
- "@agoric/vow": "0.1.1-dev-3a9096a.0.3a9096a",
48
- "@agoric/zoe": "0.26.3-dev-3a9096a.0.3a9096a",
49
- "@agoric/zone": "0.2.3-dev-3a9096a.0.3a9096a",
38
+ "@agoric/async-flow": "0.1.1-dev-fac5579.0.fac5579",
39
+ "@agoric/cosmic-proto": "0.4.1-dev-fac5579.0.fac5579",
40
+ "@agoric/ertp": "0.16.3-dev-fac5579.0.fac5579",
41
+ "@agoric/internal": "0.3.3-dev-fac5579.0.fac5579",
42
+ "@agoric/network": "0.1.1-dev-fac5579.0.fac5579",
43
+ "@agoric/notifier": "0.6.3-dev-fac5579.0.fac5579",
44
+ "@agoric/store": "0.9.3-dev-fac5579.0.fac5579",
45
+ "@agoric/time": "0.3.3-dev-fac5579.0.fac5579",
46
+ "@agoric/vat-data": "0.5.3-dev-fac5579.0.fac5579",
47
+ "@agoric/vow": "0.1.1-dev-fac5579.0.fac5579",
48
+ "@agoric/zoe": "0.26.3-dev-fac5579.0.fac5579",
49
+ "@agoric/zone": "0.2.3-dev-fac5579.0.fac5579",
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-3a9096a.0.3a9096a",
65
- "@agoric/vats": "0.15.2-dev-3a9096a.0.3a9096a",
66
- "@agoric/xsnap": "0.14.3-dev-3a9096a.0.3a9096a",
64
+ "@agoric/swingset-liveslots": "0.10.3-dev-fac5579.0.fac5579",
65
+ "@agoric/vats": "0.15.2-dev-fac5579.0.fac5579",
66
+ "@agoric/xsnap": "0.14.3-dev-fac5579.0.fac5579",
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": "3a9096a59d398d357e4e849f1abada7b41a82a9c"
103
+ "gitHead": "fac5579a29a21343a945d8985a114fd595f41385"
104
104
  }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @file Helpers to handle EIP-712 messages described by an
3
+ * {@link EIP712MessageSchema}, extracting operation and deposit permit
4
+ * details, as well as verifying the signature.
5
+ *
6
+ * The viem runtime dependency is expected as a power to make this usable both
7
+ * on chain and in off-chain services.
8
+ */
9
+ import type { Address } from 'abitype';
10
+ import type { getTypesForEIP712Domain } from 'viem';
11
+ import type { hashStruct, isHex, recoverTypedDataAddress } from 'viem/utils';
12
+ import type { encodeType, WithSignature } from './viem.js';
13
+ import { type Permit2Domain, type PermitWitnessTransferFromPayload } from './permit2.js';
14
+ import { type EIP712MessageSchema, type FullDomain, type OperationNames, type OperationType, type PermitWitnessTransferFromOperationData, type StandaloneOperationData } from './eip712-messages.js';
15
+ export type OperationDetails<S extends EIP712MessageSchema, T extends OperationNames<S> = OperationNames<S>> = {
16
+ [P in T]: {
17
+ operation: P;
18
+ domain: FullDomain<S>;
19
+ /**
20
+ * A *lower bound* on the runtime shape, not an exact description: since
21
+ * `extractOperationDetailsFromStandaloneData` /
22
+ * `extractOperationDetailsFromPermit2WitnessData` keep (rather than
23
+ * drop) genuinely-signed fields this version doesn't recognize, `data`
24
+ * can carry extra properties beyond `OperationType<S, P>` at runtime.
25
+ * Consumers that must reject such fields (e.g. permission records)
26
+ * need to validate that themselves against a closed shape.
27
+ */
28
+ data: OperationType<S, P>;
29
+ };
30
+ }[T];
31
+ export type PermitDetails = {
32
+ chainId: bigint;
33
+ token: Address;
34
+ amount: bigint;
35
+ spender: Address;
36
+ permit2Payload: Omit<PermitWitnessTransferFromPayload, 'transferDetails'>;
37
+ };
38
+ export type FullMessageDetails<S extends EIP712MessageSchema, T extends OperationNames<S> = OperationNames<S>> = OperationDetails<S, T> & {
39
+ permitDetails?: PermitDetails;
40
+ evmWalletAddress: Address;
41
+ nonce: bigint;
42
+ deadline: bigint;
43
+ };
44
+ /**
45
+ * Valid contract addresses, keyed by chain ID.
46
+ */
47
+ export type ContractAddresses = Partial<Record<number | string, Address>>;
48
+ export type EIP712ViemUtils = {
49
+ isHex: typeof isHex;
50
+ hashStruct: typeof hashStruct;
51
+ recoverTypedDataAddress: typeof recoverTypedDataAddress;
52
+ encodeType: typeof encodeType;
53
+ getTypesForEIP712Domain: typeof getTypesForEIP712Domain;
54
+ };
55
+ /**
56
+ * EIP-712 message handler utils for messages described by `schema`. They
57
+ * depend on 'viem' utils for their implementation. Since on-chain we cannot
58
+ * directly import from 'viem', use a maker pattern to create these utils.
59
+ *
60
+ * @param viemUtils
61
+ * @param schema describes the domain and operations of accepted messages.
62
+ * Messages of any other domain or operation are rejected.
63
+ * @throws {Error} if a viem util is missing, or if the schema is invalid
64
+ * (see {@link makeEIP712MessageKit}).
65
+ */
66
+ export declare const makeEIP712MessageHandlerUtils: <const S extends EIP712MessageSchema>(viemUtils: EIP712ViemUtils, schema: S) => {
67
+ extractOperationDetailsFromStandaloneData: <T extends OperationNames<S>>(data: Omit<StandaloneOperationData<S, T>, "domain"> & {
68
+ domain: FullDomain<S>;
69
+ }, validContractAddresses?: undefined) => OperationDetails<S, T>;
70
+ extractOperationDetailsFromPermit2WitnessData: <T extends OperationNames<S>>(data: Omit<PermitWitnessTransferFromOperationData<S, T>, "domain"> & {
71
+ domain: Permit2Domain;
72
+ }) => OperationDetails<S, T>;
73
+ extractPermitDetails: {
74
+ <T extends OperationNames<S>>(data: Omit<PermitWitnessTransferFromOperationData<S, T>, "domain"> & {
75
+ domain: Permit2Domain;
76
+ address: Address;
77
+ signature: WithSignature<object>["signature"];
78
+ }): PermitDetails;
79
+ <T extends OperationNames<S>>(data: Omit<PermitWitnessTransferFromOperationData<S, T>, "domain"> & {
80
+ domain: Permit2Domain;
81
+ }, owner: Address, signature: WithSignature<object>["signature"]): PermitDetails;
82
+ };
83
+ extractOperationDetailsFromDataWithAddress: <T extends OperationNames<S> = OperationNames<S>>(data: (WithSignature<PermitWitnessTransferFromOperationData<S, T>> | StandaloneOperationData<S, T>) & {
84
+ address: Address;
85
+ }, contractAddresses?: {
86
+ permit2?: ContractAddresses;
87
+ verifyingContract?: ContractAddresses;
88
+ }) => FullMessageDetails<S, T>;
89
+ extractOperationDetailsFromSignedData: <T extends OperationNames<S> = OperationNames<S>>(signedData: WithSignature<PermitWitnessTransferFromOperationData<S, T> | StandaloneOperationData<S, T>> & {
90
+ address?: Address;
91
+ }, validVerifyingContractAddresses?: ContractAddresses) => Promise<FullMessageDetails<S, T>>;
92
+ };
93
+ export type EIP712MessageHandlerUtils<S extends EIP712MessageSchema> = ReturnType<typeof makeEIP712MessageHandlerUtils<S>>;
94
+ //# sourceMappingURL=eip712-message-handler.d.ts.map
@@ -0,0 +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,EAA8B,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;AAIpB,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAML,KAAK,aAAa,EAIlB,KAAK,gCAAgC,EACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,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,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAC7C;KACD,CAAC,IAAI,CAAC,GAAG;QACR,SAAS,EAAE,CAAC,CAAC;QACb,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB;;;;;;;;WAQG;QACH,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC3B;CACF,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC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