@integraledger/lcp-binding-evm-common 0.9.0
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/CHANGELOG.md +13 -0
- package/LICENSE +202 -0
- package/NOTICE +14 -0
- package/README.md +75 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +24 -0
- package/dist/client.js.map +1 -0
- package/dist/eas.d.ts +98 -0
- package/dist/eas.d.ts.map +1 -0
- package/dist/eas.js +70 -0
- package/dist/eas.js.map +1 -0
- package/dist/eip3009.d.ts +104 -0
- package/dist/eip3009.d.ts.map +1 -0
- package/dist/eip3009.js +73 -0
- package/dist/eip3009.js.map +1 -0
- package/dist/eip712.d.ts +8 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +10 -0
- package/dist/eip712.js.map +1 -0
- package/dist/erc1271.d.ts +147 -0
- package/dist/erc1271.d.ts.map +1 -0
- package/dist/erc1271.js +197 -0
- package/dist/erc1271.js.map +1 -0
- package/dist/erc20.d.ts +36 -0
- package/dist/erc20.d.ts.map +1 -0
- package/dist/erc20.js +20 -0
- package/dist/erc20.js.map +1 -0
- package/dist/events.d.ts +67 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +90 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
- package/src/client.ts +31 -0
- package/src/eas.ts +120 -0
- package/src/eip3009.ts +142 -0
- package/src/eip712.ts +11 -0
- package/src/erc1271.ts +321 -0
- package/src/erc20.ts +48 -0
- package/src/events.ts +126 -0
- package/src/index.ts +48 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-evm-common
|
|
2
|
+
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
First public release.
|
|
6
|
+
|
|
7
|
+
`0.9.0` is deliberate: this is a release candidate for 1.0, not a preview. The implementation is complete
|
|
8
|
+
against LCP v1.38 and certified by the conformance corpus, and the remaining distance to 1.0 is the
|
|
9
|
+
specification's own — the standard is still moving through its steering committee, and this package will not
|
|
10
|
+
claim a stability its protocol has not yet promised.
|
|
11
|
+
|
|
12
|
+
Development before this release happened in a private repository and is not reproduced here; no earlier
|
|
13
|
+
version was ever available to install.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Integra Protocol
|
|
2
|
+
Copyright 2026 Integra Ledger
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Integra Ledger (https://integraledger.com).
|
|
5
|
+
|
|
6
|
+
"Integra", "Integra Ledger", and the Integra logo are trademarks of Integra Ledger.
|
|
7
|
+
Trademark use is not granted by the Apache License 2.0 (see Section 6).
|
|
8
|
+
|
|
9
|
+
The Legal Context Protocol is co-stewarded by Integra Ledger and AAA-ICDR. This repository is a
|
|
10
|
+
reference implementation of the standard's open layer; the specification itself is published at
|
|
11
|
+
https://legalcontextprotocol.org/standard and is not part of this distribution.
|
|
12
|
+
|
|
13
|
+
The vendored submodule under lib/commerce-payments is Coinbase's AuthCaptureEscrow and carries its own
|
|
14
|
+
MIT licence at lib/commerce-payments/LICENSE.md. It is not covered by the Apache License above.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-evm-common
|
|
2
|
+
|
|
3
|
+
Shared EVM machinery for the rail bindings: typed-data construction, signature verification, and
|
|
4
|
+
event decoding. This is not itself a rail binding — it is what [`@integraledger/lcp-binding-evm-x402`](../binding-evm-x402#readme),
|
|
5
|
+
[`@integraledger/lcp-binding-evm-escrow`](../binding-evm-escrow#readme) and [`@integraledger/lcp-binding-evm-mpp`](../binding-evm-mpp#readme) are built from.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @integraledger/lcp-binding-evm-common
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Acceptance signatures
|
|
12
|
+
|
|
13
|
+
Implements the `SignatureVerifier` port that [`@integraledger/lcp-authority`](../authority#readme) declares, across four schemes:
|
|
14
|
+
|
|
15
|
+
| Scheme | How it verifies |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `eip191` | Recovered offline — no chain access |
|
|
18
|
+
| `eip712` | Recovered offline — no chain access |
|
|
19
|
+
| `erc1271` | On-chain, through an injected viem client |
|
|
20
|
+
| `erc6492` | On-chain — counterfactual accounts not yet deployed |
|
|
21
|
+
|
|
22
|
+
The EOA schemes need no network, which is what lets the deterministic conformance vectors cover them.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
type AcceptanceSignatureInput,
|
|
27
|
+
type AcceptanceVerifyOpts,
|
|
28
|
+
verifyAcceptanceSignature,
|
|
29
|
+
} from "@integraledger/lcp-binding-evm-common";
|
|
30
|
+
|
|
31
|
+
declare const acceptance: AcceptanceSignatureInput; // scheme: "eip191" | "eip712" | …
|
|
32
|
+
declare const smartAccountOpts: AcceptanceVerifyOpts; // { chainId, client } — a viem PublicClient
|
|
33
|
+
|
|
34
|
+
// EOA schemes need no network at all — no client, no chain id.
|
|
35
|
+
const ok = await verifyAcceptanceSignature(acceptance);
|
|
36
|
+
|
|
37
|
+
// The smart-account schemes do, and an absent client THROWS rather than answering `false`:
|
|
38
|
+
// "not verified" and "verified as forged" are different facts.
|
|
39
|
+
const onChain = await verifyAcceptanceSignature(acceptance, smartAccountOpts);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Three outcomes, kept distinct
|
|
43
|
+
|
|
44
|
+
A malformed **configuration** throws — an absent chain id or a missing client is an integration error the
|
|
45
|
+
caller must fix. A malformed **record** throws — an unparseable timestamp is a different fact from a
|
|
46
|
+
forged signature, and letting it hide behind a bad-signature verdict would lose that. A malformed
|
|
47
|
+
**signature** returns `false` — recovery over forged bytes fails deep in curve math, and a verifier that
|
|
48
|
+
crashes on a forgery cannot report the forgery.
|
|
49
|
+
|
|
50
|
+
Collapsing any two of those into one another is how a verifier ends up reporting the wrong thing about
|
|
51
|
+
the one case it exists for.
|
|
52
|
+
|
|
53
|
+
## Requirement ids
|
|
54
|
+
|
|
55
|
+
This package's source and its messages cite short ids — `ATA-3`, `RCS-5`, `CMP-6` and their kin.
|
|
56
|
+
**They are not LCP clause numbers.** LCP is cited by section (`§8.3.1`, `§C.2`); anything shaped `XXX-n`
|
|
57
|
+
comes from Integra's functional specification of what a complete agent transaction requires, the fourteen
|
|
58
|
+
families below. Nothing in this package's behaviour depends on them, and where an id and an LCP section
|
|
59
|
+
disagree the section governs.
|
|
60
|
+
|
|
61
|
+
| | | | |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| `IDN` identity | `ASP` authority to spend | `ATA` authority to accept terms | `TRM` the terms record |
|
|
64
|
+
| `RCS` recourse | `PAY` payment and settlement | `WLD` the transactional weld | `OFR` offer integrity |
|
|
65
|
+
| `FRC` fraud, risk, and compliance | `OPS` commercial operations | `DSC` discovery and reputation | `ORC` orchestration |
|
|
66
|
+
| `CMP` composition | `PRS` persistence and verification infrastructure | | |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
**Requires Node >= 24.** Part of the
|
|
71
|
+
[Legal Context Protocol open layer](https://github.com/IntegraLedger/integra-protocol) — see the
|
|
72
|
+
[documentation](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/index.md)
|
|
73
|
+
and the
|
|
74
|
+
[package index](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/reference.md).
|
|
75
|
+
Apache-2.0.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChainReader } from "@integraledger/lcp-binding-core";
|
|
2
|
+
import type { PublicClient } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Adapt a viem `PublicClient` into binding-core's `ChainReader` port (viem lives here and in the two
|
|
5
|
+
* EVM adapters, nowhere else). Imperative shell over viem — the pure verifier logic reads through the port.
|
|
6
|
+
*/
|
|
7
|
+
export declare function makeChainReader(client: PublicClient): ChainReader;
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAoBjE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapt a viem `PublicClient` into binding-core's `ChainReader` port (viem lives here and in the two
|
|
3
|
+
* EVM adapters, nowhere else). Imperative shell over viem — the pure verifier logic reads through the port.
|
|
4
|
+
*/
|
|
5
|
+
export function makeChainReader(client) {
|
|
6
|
+
return {
|
|
7
|
+
getLogs: (q) => client.getLogs(q),
|
|
8
|
+
getTransactionLogs: async (ref) => {
|
|
9
|
+
if (ref.txHash === undefined)
|
|
10
|
+
throw new Error("getTransactionLogs requires a txHash on the SettlementRef");
|
|
11
|
+
const receipt = await client.getTransactionReceipt({ hash: ref.txHash });
|
|
12
|
+
return [...receipt.logs];
|
|
13
|
+
},
|
|
14
|
+
readContract: (c) => client.readContract(c),
|
|
15
|
+
blockTime: async (ref) => {
|
|
16
|
+
if (ref.txHash === undefined)
|
|
17
|
+
throw new Error("blockTime requires a txHash on the SettlementRef");
|
|
18
|
+
const receipt = await client.getTransactionReceipt({ hash: ref.txHash });
|
|
19
|
+
const block = await client.getBlock({ blockNumber: receipt.blockNumber });
|
|
20
|
+
return block.timestamp;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAU,CAAC;QAC1C,kBAAkB,EAAE,KAAK,EAAE,GAAkB,EAAsB,EAAE;YACnE,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;gBAC1B,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACzE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAU,CAAC;QACpD,SAAS,EAAE,KAAK,EAAE,GAAkB,EAAmB,EAAE;YACvD,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;gBAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACtE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACzE,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;YAC1E,OAAO,KAAK,CAAC,SAAS,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/eas.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EAS (Ethereum Attestation Service) read — the EVM substrate adapter for a profiled attestation
|
|
3
|
+
* (`authority`'s attestation-profile.ts interprets attestations generically; the per-substrate on-chain
|
|
4
|
+
* read lives here, pure over the injected viem client). This reads `getAttestation(uid)` and
|
|
5
|
+
* normalizes the on-chain `Attestation` struct into a typed, as-of-checkable value. It verifies nothing
|
|
6
|
+
* cryptographically beyond the chain's own state — EAS attestations are on-chain records, so their
|
|
7
|
+
* validity is a state read (attester, expiration, revocation), evaluated AS OF a settlement time exactly
|
|
8
|
+
* like `authority`'s status-list discipline (never "is it valid now" — "was it valid at settlement").
|
|
9
|
+
*/
|
|
10
|
+
import type { Hex, PublicClient } from "viem";
|
|
11
|
+
/** EAS `getAttestation(bytes32) returns (Attestation)` — the canonical struct (EAS v0.26+ field order). */
|
|
12
|
+
export declare const EAS_GET_ATTESTATION_ABI: readonly [{
|
|
13
|
+
readonly type: "function";
|
|
14
|
+
readonly name: "getAttestation";
|
|
15
|
+
readonly stateMutability: "view";
|
|
16
|
+
readonly inputs: readonly [{
|
|
17
|
+
readonly name: "uid";
|
|
18
|
+
readonly type: "bytes32";
|
|
19
|
+
}];
|
|
20
|
+
readonly outputs: readonly [{
|
|
21
|
+
readonly type: "tuple";
|
|
22
|
+
readonly name: "";
|
|
23
|
+
readonly components: readonly [{
|
|
24
|
+
readonly name: "uid";
|
|
25
|
+
readonly type: "bytes32";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "schema";
|
|
28
|
+
readonly type: "bytes32";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "time";
|
|
31
|
+
readonly type: "uint64";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "expirationTime";
|
|
34
|
+
readonly type: "uint64";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "revocationTime";
|
|
37
|
+
readonly type: "uint64";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "refUID";
|
|
40
|
+
readonly type: "bytes32";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "recipient";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "attester";
|
|
46
|
+
readonly type: "address";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "revocable";
|
|
49
|
+
readonly type: "bool";
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: "data";
|
|
52
|
+
readonly type: "bytes";
|
|
53
|
+
}];
|
|
54
|
+
}];
|
|
55
|
+
}];
|
|
56
|
+
/** The raw shape viem decodes an EAS `Attestation` tuple into (named components → object). */
|
|
57
|
+
export interface RawEasAttestation {
|
|
58
|
+
uid: Hex;
|
|
59
|
+
schema: Hex;
|
|
60
|
+
time: bigint;
|
|
61
|
+
expirationTime: bigint;
|
|
62
|
+
revocationTime: bigint;
|
|
63
|
+
refUID: Hex;
|
|
64
|
+
recipient: Hex;
|
|
65
|
+
attester: Hex;
|
|
66
|
+
revocable: boolean;
|
|
67
|
+
data: Hex;
|
|
68
|
+
}
|
|
69
|
+
/** A normalized EAS attestation (addresses lowercased; times as bigints; `exists` = a non-zero uid). */
|
|
70
|
+
export interface EasAttestation {
|
|
71
|
+
uid: Hex;
|
|
72
|
+
schema: Hex;
|
|
73
|
+
time: bigint;
|
|
74
|
+
expirationTime: bigint;
|
|
75
|
+
revocationTime: bigint;
|
|
76
|
+
refUID: Hex;
|
|
77
|
+
recipient: Hex;
|
|
78
|
+
attester: Hex;
|
|
79
|
+
revocable: boolean;
|
|
80
|
+
data: Hex;
|
|
81
|
+
/** EAS returns a zero-filled struct for an unknown uid — this flags that non-existence explicitly. */
|
|
82
|
+
exists: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** Normalize viem's decoded tuple into an `EasAttestation` (idempotent field mapping; addresses lowercased). */
|
|
85
|
+
export declare function decodeEasAttestation(raw: RawEasAttestation): EasAttestation;
|
|
86
|
+
/**
|
|
87
|
+
* Was this attestation valid AS OF `asOfUnixSeconds`? — it must exist, not have been revoked at/before the
|
|
88
|
+
* as-of time (revocationTime 0 = never revoked), and not have expired by then (expirationTime 0 = no expiry).
|
|
89
|
+
* EAS has no historical query, so a live read yields today's revocationTime; a settlement-time snapshot of the
|
|
90
|
+
* uid is the authority (same as the Bitstring status-list as-of rule) — this predicate states the semantics.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isEasValidAsOf(att: EasAttestation, asOfUnixSeconds: bigint): boolean;
|
|
93
|
+
/** Read + normalize an EAS attestation by uid, over the injected viem client (imperative shell). */
|
|
94
|
+
export declare function readEasAttestation(client: PublicClient, params: {
|
|
95
|
+
eas: string;
|
|
96
|
+
uid: string;
|
|
97
|
+
}): Promise<EasAttestation>;
|
|
98
|
+
//# sourceMappingURL=eas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eas.d.ts","sourceRoot":"","sources":["../src/eas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9C,2GAA2G;AAC3G,eAAO,MAAM,uBAAuB;aAEhC,IAAI,EAAE,UAAU;aAChB,IAAI,EAAE,gBAAgB;aACtB,eAAe,EAAE,MAAM;aACvB,MAAM;iBAAK,IAAI,EAAE,KAAK;iBAAE,IAAI,EAAE,SAAS;;aACvC,OAAO;iBAEH,IAAI,EAAE,OAAO;iBACb,IAAI,EAAE,EAAE;iBACR,UAAU;qBACN,IAAI,EAAE,KAAK;qBAAE,IAAI,EAAE,SAAS;;qBAC5B,IAAI,EAAE,QAAQ;qBAAE,IAAI,EAAE,SAAS;;qBAC/B,IAAI,EAAE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3E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAOT;AAED,oGAAoG;AACpG,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACnC,OAAO,CAAC,cAAc,CAAC,CAQzB"}
|
package/dist/eas.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** EAS `getAttestation(bytes32) returns (Attestation)` — the canonical struct (EAS v0.26+ field order). */
|
|
2
|
+
export const EAS_GET_ATTESTATION_ABI = [
|
|
3
|
+
{
|
|
4
|
+
type: "function",
|
|
5
|
+
name: "getAttestation",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [{ name: "uid", type: "bytes32" }],
|
|
8
|
+
outputs: [
|
|
9
|
+
{
|
|
10
|
+
type: "tuple",
|
|
11
|
+
name: "",
|
|
12
|
+
components: [
|
|
13
|
+
{ name: "uid", type: "bytes32" },
|
|
14
|
+
{ name: "schema", type: "bytes32" },
|
|
15
|
+
{ name: "time", type: "uint64" },
|
|
16
|
+
{ name: "expirationTime", type: "uint64" },
|
|
17
|
+
{ name: "revocationTime", type: "uint64" },
|
|
18
|
+
{ name: "refUID", type: "bytes32" },
|
|
19
|
+
{ name: "recipient", type: "address" },
|
|
20
|
+
{ name: "attester", type: "address" },
|
|
21
|
+
{ name: "revocable", type: "bool" },
|
|
22
|
+
{ name: "data", type: "bytes" },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
const ZERO_UID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
29
|
+
/** Normalize viem's decoded tuple into an `EasAttestation` (idempotent field mapping; addresses lowercased). */
|
|
30
|
+
export function decodeEasAttestation(raw) {
|
|
31
|
+
return {
|
|
32
|
+
uid: raw.uid.toLowerCase(),
|
|
33
|
+
schema: raw.schema.toLowerCase(),
|
|
34
|
+
time: raw.time,
|
|
35
|
+
expirationTime: raw.expirationTime,
|
|
36
|
+
revocationTime: raw.revocationTime,
|
|
37
|
+
refUID: raw.refUID.toLowerCase(),
|
|
38
|
+
recipient: raw.recipient.toLowerCase(),
|
|
39
|
+
attester: raw.attester.toLowerCase(),
|
|
40
|
+
revocable: raw.revocable,
|
|
41
|
+
data: raw.data.toLowerCase(),
|
|
42
|
+
exists: raw.uid.toLowerCase() !== ZERO_UID,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Was this attestation valid AS OF `asOfUnixSeconds`? — it must exist, not have been revoked at/before the
|
|
47
|
+
* as-of time (revocationTime 0 = never revoked), and not have expired by then (expirationTime 0 = no expiry).
|
|
48
|
+
* EAS has no historical query, so a live read yields today's revocationTime; a settlement-time snapshot of the
|
|
49
|
+
* uid is the authority (same as the Bitstring status-list as-of rule) — this predicate states the semantics.
|
|
50
|
+
*/
|
|
51
|
+
export function isEasValidAsOf(att, asOfUnixSeconds) {
|
|
52
|
+
if (!att.exists)
|
|
53
|
+
return false;
|
|
54
|
+
if (att.revocationTime !== 0n && att.revocationTime <= asOfUnixSeconds)
|
|
55
|
+
return false;
|
|
56
|
+
if (att.expirationTime !== 0n && att.expirationTime <= asOfUnixSeconds)
|
|
57
|
+
return false;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/** Read + normalize an EAS attestation by uid, over the injected viem client (imperative shell). */
|
|
61
|
+
export async function readEasAttestation(client, params) {
|
|
62
|
+
const raw = (await client.readContract({
|
|
63
|
+
address: params.eas,
|
|
64
|
+
abi: EAS_GET_ATTESTATION_ABI,
|
|
65
|
+
functionName: "getAttestation",
|
|
66
|
+
args: [params.uid],
|
|
67
|
+
}));
|
|
68
|
+
return decodeEasAttestation(raw);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=eas.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CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The EIP-3009 `TransferWithAuthorization` typed-data machinery for the LCP canonical EVM binding
|
|
3
|
+
* `LCP-X402-EVM-NONCE-1`: the buyer signs an EIP-3009 authorization whose `nonce` field IS the
|
|
4
|
+
* `atrHash`, so the fingerprint is committed on-chain in the token's `AuthorizationUsed(authorizer,
|
|
5
|
+
* indexed nonce)` event — no overlay contract.
|
|
6
|
+
*
|
|
7
|
+
* The x402-client scheme class is deliberately NOT here; it lives in binding-evm-x402. This module is
|
|
8
|
+
* protocol-agnostic typed-data construction, viem-only.
|
|
9
|
+
*/
|
|
10
|
+
import { type Address, type Hex, type TypedDataDomain } from "viem";
|
|
11
|
+
/** EIP-3009 TransferWithAuthorization typed-data field layout (USDC FiatTokenV2). */
|
|
12
|
+
export declare const TRANSFER_WITH_AUTHORIZATION_TYPE: {
|
|
13
|
+
readonly TransferWithAuthorization: readonly [{
|
|
14
|
+
readonly name: "from";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "to";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "value";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "validAfter";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "validBefore";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "nonce";
|
|
30
|
+
readonly type: "bytes32";
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
/** Parse the EIP-155 chain id out of a CAIP-2 network string; throws on anything that is not
|
|
34
|
+
* `eip155:<digits>` (never defaults — the chain id binds the EIP-712 domain). */
|
|
35
|
+
export declare function eip155ChainId(network: string): number;
|
|
36
|
+
/** The atrHash rides the EIP-3009 nonce as a 0x-prefixed 32-byte value. Any-case digits accepted
|
|
37
|
+
* (ATR canon), then lowercased for the on-chain nonce (the nonce is matched lowercase on decode). */
|
|
38
|
+
export declare function assertBytes32(value: string): Hex;
|
|
39
|
+
/** The EIP-3009 authorization object (string-encoded uint fields, as the x402 wire expects). */
|
|
40
|
+
export interface Eip3009Authorization {
|
|
41
|
+
from: Address;
|
|
42
|
+
to: Address;
|
|
43
|
+
value: string;
|
|
44
|
+
validAfter: string;
|
|
45
|
+
validBefore: string;
|
|
46
|
+
nonce: Hex;
|
|
47
|
+
}
|
|
48
|
+
/** Everything needed to build an EIP-3009 authorization whose `nonce` IS the atrHash. Two fields are the
|
|
49
|
+
* usual mistake: `tokenName`/`tokenVersion` are the token's own EIP-712 domain and DIFFER between USDC
|
|
50
|
+
* deployments, so copying them from one chain to another yields a signature the token rejects. Amounts
|
|
51
|
+
* and times are strings here (base units, unix seconds) and become `bigint` in the typed data. */
|
|
52
|
+
export interface BuildEip3009Input {
|
|
53
|
+
/** The LCP carrier value — becomes the on-chain nonce. */
|
|
54
|
+
atrHash: string;
|
|
55
|
+
/** Payer address; checksummed via `getAddress`. */
|
|
56
|
+
from: string;
|
|
57
|
+
/** Recipient address; checksummed via `getAddress`. */
|
|
58
|
+
to: string;
|
|
59
|
+
/** Amount in token base units (string). */
|
|
60
|
+
value: string;
|
|
61
|
+
validAfter: string;
|
|
62
|
+
validBefore: string;
|
|
63
|
+
chainId: number;
|
|
64
|
+
/** EIP-712 domain `name`/`version` for the token (USDC). */
|
|
65
|
+
tokenName: string;
|
|
66
|
+
tokenVersion: string;
|
|
67
|
+
/** Token contract — the EIP-712 `verifyingContract`; checksummed via `getAddress`. */
|
|
68
|
+
verifyingContract: string;
|
|
69
|
+
}
|
|
70
|
+
/** The EIP-712 payload a payer signs for an EIP-3009 transfer. Distinct from the authorization: the
|
|
71
|
+
* authorization is what goes on the wire, this is what is signed, and their numeric fields differ in type
|
|
72
|
+
* (`bigint` here, decimal strings there) because that is what each side requires. */
|
|
73
|
+
export type Eip3009TypedData = {
|
|
74
|
+
domain: TypedDataDomain;
|
|
75
|
+
types: typeof TRANSFER_WITH_AUTHORIZATION_TYPE;
|
|
76
|
+
primaryType: "TransferWithAuthorization";
|
|
77
|
+
message: {
|
|
78
|
+
from: Address;
|
|
79
|
+
to: Address;
|
|
80
|
+
value: bigint;
|
|
81
|
+
validAfter: bigint;
|
|
82
|
+
validBefore: bigint;
|
|
83
|
+
nonce: Hex;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Build the EIP-3009 authorization + the EIP-712 typed-data to sign, with `nonce = atrHash`.
|
|
88
|
+
* `authorization` is the wire payload; `typedData` is what the signer signs.
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildEip3009TypedData(i: BuildEip3009Input): {
|
|
91
|
+
authorization: Eip3009Authorization;
|
|
92
|
+
typedData: Eip3009TypedData;
|
|
93
|
+
};
|
|
94
|
+
/** Minimal EVM signer — the structural subset a scheme needs (viem LocalAccount / CDP account / injected wallet). */
|
|
95
|
+
export interface LcpEvmSigner {
|
|
96
|
+
readonly address: Address;
|
|
97
|
+
signTypedData(message: {
|
|
98
|
+
domain: Record<string, unknown>;
|
|
99
|
+
types: Record<string, unknown>;
|
|
100
|
+
primaryType: string;
|
|
101
|
+
message: Record<string, unknown>;
|
|
102
|
+
}): Promise<Hex>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=eip3009.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip3009.d.ts","sourceRoot":"","sources":["../src/eip3009.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,KAAK,OAAO,EAAc,KAAK,GAAG,EAAE,KAAK,eAAe,EAAE,MAAM,MAAM,CAAC;AAEhF,qFAAqF;AACrF,eAAO,MAAM,gCAAgC;aAC3C,yBAAyB;iBACrB,IAAI,EAAE,MAAM;iBAAE,IAAI,EAAE,SAAS;;iBAC7B,IAAI,EAA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