@integraledger/lcp-binding-evm-escrow 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 +116 -0
- package/dist/adapter.d.ts +82 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +152 -0
- package/dist/adapter.js.map +1 -0
- package/dist/calls.d.ts +30 -0
- package/dist/calls.d.ts.map +1 -0
- package/dist/calls.js +67 -0
- package/dist/calls.js.map +1 -0
- package/dist/collectors.d.ts +42 -0
- package/dist/collectors.d.ts.map +1 -0
- package/dist/collectors.js +59 -0
- package/dist/collectors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +34 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +28 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/manifest.d.ts +52 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +82 -0
- package/dist/manifest.js.map +1 -0
- package/package.json +64 -0
- package/src/adapter.ts +255 -0
- package/src/calls.ts +99 -0
- package/src/collectors.ts +96 -0
- package/src/index.ts +33 -0
- package/src/lifecycle.ts +53 -0
- package/src/manifest.ts +83 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-evm-escrow
|
|
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,116 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-evm-escrow
|
|
2
|
+
|
|
3
|
+
Welds an ATR hash into an authorize-and-capture escrow settlement on EVM chains.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @integraledger/lcp-binding-evm-escrow
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| | |
|
|
10
|
+
|---|---|
|
|
11
|
+
| **Chain** | EVM |
|
|
12
|
+
| **Pattern** | `native-field` |
|
|
13
|
+
| **Carrier** | `PaymentInfo.salt` |
|
|
14
|
+
| **Surface** | `createEscrowAdapter` returning [`@integraledger/lcp-binding-core`](../binding-core#readme)'s `WeldAdapter` over a `ChainReader` |
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Built on [`@integraledger/lcp-binding-core`](../binding-core#readme)'s `WeldAdapter` and
|
|
18
|
+
[`@integraledger/lcp-binding-evm-common`](../binding-evm-common#readme). Installing this package installs
|
|
19
|
+
**viem**.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { atrHashFromSalt, createEscrowAdapter } from "@integraledger/lcp-binding-evm-escrow";
|
|
23
|
+
import type { VerifierPorts } from "@integraledger/lcp-binding-core";
|
|
24
|
+
|
|
25
|
+
declare const atrHash: `0x${string}`;
|
|
26
|
+
declare const ctx: Omit<
|
|
27
|
+
import("@integraledger/lcp-binding-evm-escrow").PaymentInfo,
|
|
28
|
+
"salt"
|
|
29
|
+
>;
|
|
30
|
+
declare const ports: VerifierPorts; // your viem-backed ChainReader + ArtifactResolver
|
|
31
|
+
declare const txHash: `0x${string}`;
|
|
32
|
+
|
|
33
|
+
const adapter = createEscrowAdapter({ chainId: 84532 });
|
|
34
|
+
|
|
35
|
+
// SERVICE OPERATOR — the PaymentInfo to submit, with `salt` filled from the atrHash.
|
|
36
|
+
const proposed = await adapter.propose(atrHash, ctx);
|
|
37
|
+
|
|
38
|
+
// VERIFIER — the atrHash back out of the settlement's PaymentAuthorized/PaymentCharged event.
|
|
39
|
+
const recovered = await adapter.recover({ chainId: 84532, txHash }, ports);
|
|
40
|
+
if (!("refused" in recovered)) console.log(recovered.value); // "0x…"
|
|
41
|
+
// Narrow with `"refused" in x` — `Refusal` has no `ok`, so the union cannot discriminate on one.
|
|
42
|
+
|
|
43
|
+
atrHashFromSalt(0n); // the inverse, for a salt you already hold
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## The carrier
|
|
47
|
+
|
|
48
|
+
The ATR hash rides `PaymentInfo.salt` — an existing field the service already controls. No derivation,
|
|
49
|
+
no overlay contract.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { EVENT_TO_STATE } from "@integraledger/lcp-binding-evm-escrow";
|
|
53
|
+
|
|
54
|
+
EVENT_TO_STATE.PaymentCharged; // "charged"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What it refuses rather than guesses
|
|
58
|
+
|
|
59
|
+
One escrow transaction can authorize or charge several independent payments, each with its own
|
|
60
|
+
`PaymentInfo` and therefore its own ATR hash. `recover` will not choose between them:
|
|
61
|
+
|
|
62
|
+
| Refusal | When |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `escrow/ambiguous-settlement` | The transaction carries salt-bearing events with *different* salts and the `SettlementRef` pins no `logIndex`. Pin one. The same payment seen through both `PaymentAuthorized` and `PaymentCharged` carries one salt and resolves normally. |
|
|
65
|
+
| `escrow/log-index-not-found` | A pinned `logIndex` matches no salt-bearing event — a failure, never a fall-through to the first one. |
|
|
66
|
+
| `escrow/no-recoverable-event` | No `PaymentAuthorized`/`PaymentCharged` with a cleartext `PaymentInfo` in the settlement. |
|
|
67
|
+
|
|
68
|
+
Recovery is an **event-data scan**, not a topic filter: `paymentInfoHash` is the only indexed key and it
|
|
69
|
+
is not derivable from an ATR hash alone, so `enumerate` fetches the salt-bearing events over a range and
|
|
70
|
+
filters client-side. The manifest declares `forwardIndexable: false` for exactly that reason.
|
|
71
|
+
|
|
72
|
+
## Escrow is a mechanism, not our product
|
|
73
|
+
|
|
74
|
+
This package encodes calls to Coinbase's MIT-licensed `AuthCaptureEscrow` and collects its events. It
|
|
75
|
+
does not supply, operate, or price an escrow. What it contributes is the **record weld across authorize
|
|
76
|
+
and capture** — so that a payment authorized under one set of terms and captured later can still be shown
|
|
77
|
+
to correspond to those terms.
|
|
78
|
+
|
|
79
|
+
Lifecycle states are a discriminated union rather than a string enum, so an illegal state is not
|
|
80
|
+
constructible instead of being rejected at runtime.
|
|
81
|
+
|
|
82
|
+
## The drift guard
|
|
83
|
+
|
|
84
|
+
The constants this package ships — `PAYMENT_INFO_TYPEHASH`, and the `getHashOffchain` / `saltFromAtrHash`
|
|
85
|
+
derivations — are re-derived **weekly against the deployed `AuthCaptureEscrow`** on live Base mainnet and
|
|
86
|
+
Sepolia, in a lane held outside the default test run (per-mutant RPC storms are the reason). So a green
|
|
87
|
+
unit-test run says nothing about contract drift, and the weekly lane is what does.
|
|
88
|
+
|
|
89
|
+
That matters to you as a consumer because these are values you cannot check by reading: a typehash that
|
|
90
|
+
drifted from the deployed contract produces a well-formed hash that matches nothing on chain. The guard is
|
|
91
|
+
in the source repository rather than in this tarball, which is why the property is stated here rather than
|
|
92
|
+
the file path — you receive the constants and the fact that they are checked, not the checker.
|
|
93
|
+
|
|
94
|
+
## Requirement ids
|
|
95
|
+
|
|
96
|
+
This package's source and its messages cite short ids — `ATA-3`, `RCS-5`, `CMP-6` and their kin.
|
|
97
|
+
**They are not LCP clause numbers.** LCP is cited by section (`§8.3.1`, `§C.2`); anything shaped `XXX-n`
|
|
98
|
+
comes from Integra's functional specification of what a complete agent transaction requires, the fourteen
|
|
99
|
+
families below. Nothing in this package's behaviour depends on them, and where an id and an LCP section
|
|
100
|
+
disagree the section governs.
|
|
101
|
+
|
|
102
|
+
| | | | |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| `IDN` identity | `ASP` authority to spend | `ATA` authority to accept terms | `TRM` the terms record |
|
|
105
|
+
| `RCS` recourse | `PAY` payment and settlement | `WLD` the transactional weld | `OFR` offer integrity |
|
|
106
|
+
| `FRC` fraud, risk, and compliance | `OPS` commercial operations | `DSC` discovery and reputation | `ORC` orchestration |
|
|
107
|
+
| `CMP` composition | `PRS` persistence and verification infrastructure | | |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
**Requires Node >= 24.** Part of the
|
|
112
|
+
[Legal Context Protocol open layer](https://github.com/IntegraLedger/integra-protocol) — see the
|
|
113
|
+
[documentation](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/index.md)
|
|
114
|
+
and the
|
|
115
|
+
[package index](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/reference.md).
|
|
116
|
+
Apache-2.0.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Commerce Payments escrow WeldAdapter: the atrHash rides `PaymentInfo.salt`
|
|
3
|
+
* (`salt = uint256(atrHash)`), proven on-chain. `recover`/`enumerate`
|
|
4
|
+
* decode the cleartext `PaymentInfo` in `PaymentAuthorized`/`PaymentCharged` event data (the WLD-3
|
|
5
|
+
* event-data scan — `paymentInfoHash` is the indexed topic, `salt` is not). viem lives here.
|
|
6
|
+
*/
|
|
7
|
+
import type { WeldAdapter } from "@integraledger/lcp-binding-core";
|
|
8
|
+
import { type Abi, type Log } from "viem";
|
|
9
|
+
import { type EscrowEventName } from "./lifecycle.js";
|
|
10
|
+
/** The six escrow lifecycle events. `PaymentAuthorized`/`PaymentCharged` carry the cleartext `PaymentInfo`
|
|
11
|
+
* (→ salt → atrHash); the rest join on the indexed `paymentInfoHash`. */
|
|
12
|
+
export declare const ESCROW_EVENTS_ABI: Abi;
|
|
13
|
+
/** `AuthCaptureEscrow.PaymentInfo` — the pre-settlement artifact. `salt` carries the atrHash. */
|
|
14
|
+
export interface PaymentInfo {
|
|
15
|
+
operator: `0x${string}`;
|
|
16
|
+
payer: `0x${string}`;
|
|
17
|
+
receiver: `0x${string}`;
|
|
18
|
+
token: `0x${string}`;
|
|
19
|
+
maxAmount: bigint;
|
|
20
|
+
preApprovalExpiry: number;
|
|
21
|
+
authorizationExpiry: number;
|
|
22
|
+
refundExpiry: number;
|
|
23
|
+
minFeeBps: number;
|
|
24
|
+
maxFeeBps: number;
|
|
25
|
+
feeReceiver: `0x${string}`;
|
|
26
|
+
salt: bigint;
|
|
27
|
+
}
|
|
28
|
+
/** `salt = uint256(atrHash)` — the 32-byte atrHash reinterpreted as a uint256. */
|
|
29
|
+
export declare function saltFromAtrHash(atrHash: `0x${string}`): bigint;
|
|
30
|
+
/** Recover the atrHash from a `PaymentInfo.salt` — the reverse (lowercase 0x, 32 bytes). */
|
|
31
|
+
export declare function atrHashFromSalt(salt: bigint): `0x${string}`;
|
|
32
|
+
/** The per-payment proposal inputs (everything but `salt`, which the adapter fills from the atrHash). */
|
|
33
|
+
export type EscrowProposalContext = Omit<PaymentInfo, "salt">;
|
|
34
|
+
/** What `propose` returns: the `PaymentInfo` to submit, with `salt` already set from the atrHash. A
|
|
35
|
+
* single-field object rather than a bare `PaymentInfo` so the return can gain siblings without breaking
|
|
36
|
+
* callers. This package proposes and reads — it never operates the escrow. */
|
|
37
|
+
export interface EscrowProposal {
|
|
38
|
+
paymentInfo: PaymentInfo;
|
|
39
|
+
}
|
|
40
|
+
/** How to point the adapter at a deployment. `chainId` is required; the other two default — `escrow` to
|
|
41
|
+
* the canonical deterministic `AuthCaptureEscrow`, `fromBlock` to the full history. Widen `fromBlock`
|
|
42
|
+
* knowingly: enumeration from `earliest` is a full-history scan on a busy chain. */
|
|
43
|
+
export interface EscrowAdapterConfig {
|
|
44
|
+
chainId: number;
|
|
45
|
+
/** The `AuthCaptureEscrow` address; defaults to the canonical deterministic deployment. */
|
|
46
|
+
escrow?: `0x${string}`;
|
|
47
|
+
/** Enumeration lower bound; defaults to the full history (`earliest`). */
|
|
48
|
+
fromBlock?: bigint;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One decoded escrow lifecycle event, INCLUDING the asset the payment moved.
|
|
52
|
+
*
|
|
53
|
+
* The asset fields are carried rather than dropped, and that is what makes `assetBinding: "carried"` a
|
|
54
|
+
* true claim: the axis asks whether a CONSUMER can reach the asset the weld is attached to, not merely
|
|
55
|
+
* whether the chain recorded it. Decoding `salt` and `amount` while discarding the rest of `PaymentInfo`
|
|
56
|
+
* would leave the manifest declaring an asset binding nobody could check.
|
|
57
|
+
*/
|
|
58
|
+
export interface DecodedEscrowLog {
|
|
59
|
+
name: EscrowEventName;
|
|
60
|
+
/** The atrHash weld, as the raw `PaymentInfo.salt` uint256. Absent on events carrying no `PaymentInfo`. */
|
|
61
|
+
salt?: bigint;
|
|
62
|
+
amount: bigint;
|
|
63
|
+
/** ERC-20 the payment moved. Absent on events carrying no `PaymentInfo`. */
|
|
64
|
+
token?: `0x${string}`;
|
|
65
|
+
/** The paying account. Absent on events carrying no `PaymentInfo`. */
|
|
66
|
+
payer?: `0x${string}`;
|
|
67
|
+
/** The receiving account. Absent on events carrying no `PaymentInfo`. */
|
|
68
|
+
receiver?: `0x${string}`;
|
|
69
|
+
logIndex: number | null;
|
|
70
|
+
txHash: `0x${string}` | null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Decode every escrow lifecycle event in a log set (ignoring anything that is not one).
|
|
74
|
+
*
|
|
75
|
+
* Exported because it is the only way a consumer reaches the asset behind the weld: `observe` returns
|
|
76
|
+
* `LifecycleTransition[]`, a shape fixed by `binding-core` that has no room for `token`/`payer`/`receiver`.
|
|
77
|
+
* A caller checking that a settlement moved the asset its record names calls this directly.
|
|
78
|
+
*/
|
|
79
|
+
export declare function decodeEscrowLogs(logs: readonly Log[], escrow: string): DecodedEscrowLog[];
|
|
80
|
+
/** Construct the escrow WeldAdapter for one chain. */
|
|
81
|
+
export declare function createEscrowAdapter(config: EscrowAdapterConfig): WeldAdapter;
|
|
82
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAKV,WAAW,EACZ,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,GAAG,EAAkB,KAAK,GAAG,EAAY,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB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AM,CAAC;IACf,4EAA4E;IAC5E,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,sEAAsE;IACtE,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,MAAM,EAAE,MAAM,GACb,gBAAgB,EAAE,CAuCpB;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,WAAW,CAqG5E"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { refOf } from "@integraledger/lcp-binding-evm-common";
|
|
2
|
+
import { decodeEventLog, parseAbi } from "viem";
|
|
3
|
+
import { AUTH_CAPTURE_ESCROW } from "./collectors.js";
|
|
4
|
+
import { EVENT_TO_STATE } from "./lifecycle.js";
|
|
5
|
+
import { ESCROW_MANIFEST } from "./manifest.js";
|
|
6
|
+
const PI_TUPLE = "(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt)";
|
|
7
|
+
/** The six escrow lifecycle events. `PaymentAuthorized`/`PaymentCharged` carry the cleartext `PaymentInfo`
|
|
8
|
+
* (→ salt → atrHash); the rest join on the indexed `paymentInfoHash`. */
|
|
9
|
+
export const ESCROW_EVENTS_ABI = parseAbi([
|
|
10
|
+
`event PaymentAuthorized(bytes32 indexed paymentInfoHash, ${PI_TUPLE} paymentInfo, uint256 amount, address tokenCollector)`,
|
|
11
|
+
`event PaymentCharged(bytes32 indexed paymentInfoHash, ${PI_TUPLE} paymentInfo, uint256 amount, address tokenCollector, uint16 feeBps, address feeReceiver)`,
|
|
12
|
+
"event PaymentCaptured(bytes32 indexed paymentInfoHash, uint256 amount, uint16 feeBps, address feeReceiver)",
|
|
13
|
+
"event PaymentVoided(bytes32 indexed paymentInfoHash, uint256 amount)",
|
|
14
|
+
"event PaymentReclaimed(bytes32 indexed paymentInfoHash, uint256 amount)",
|
|
15
|
+
"event PaymentRefunded(bytes32 indexed paymentInfoHash, uint256 amount, address tokenCollector)",
|
|
16
|
+
]);
|
|
17
|
+
/** `salt = uint256(atrHash)` — the 32-byte atrHash reinterpreted as a uint256. */
|
|
18
|
+
export function saltFromAtrHash(atrHash) {
|
|
19
|
+
return BigInt(atrHash);
|
|
20
|
+
}
|
|
21
|
+
/** Recover the atrHash from a `PaymentInfo.salt` — the reverse (lowercase 0x, 32 bytes). */
|
|
22
|
+
export function atrHashFromSalt(salt) {
|
|
23
|
+
return `0x${salt.toString(16).padStart(64, "0")}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decode every escrow lifecycle event in a log set (ignoring anything that is not one).
|
|
27
|
+
*
|
|
28
|
+
* Exported because it is the only way a consumer reaches the asset behind the weld: `observe` returns
|
|
29
|
+
* `LifecycleTransition[]`, a shape fixed by `binding-core` that has no room for `token`/`payer`/`receiver`.
|
|
30
|
+
* A caller checking that a settlement moved the asset its record names calls this directly.
|
|
31
|
+
*/
|
|
32
|
+
export function decodeEscrowLogs(logs, escrow) {
|
|
33
|
+
const want = escrow.toLowerCase();
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const log of logs) {
|
|
36
|
+
if (log.address.toLowerCase() !== want)
|
|
37
|
+
continue;
|
|
38
|
+
try {
|
|
39
|
+
const decoded = decodeEventLog({
|
|
40
|
+
abi: ESCROW_EVENTS_ABI,
|
|
41
|
+
data: log.data,
|
|
42
|
+
topics: log.topics,
|
|
43
|
+
});
|
|
44
|
+
const args = decoded.args;
|
|
45
|
+
out.push({
|
|
46
|
+
name: decoded.eventName,
|
|
47
|
+
...(args.paymentInfo !== undefined
|
|
48
|
+
? {
|
|
49
|
+
salt: args.paymentInfo.salt,
|
|
50
|
+
token: args.paymentInfo.token,
|
|
51
|
+
payer: args.paymentInfo.payer,
|
|
52
|
+
receiver: args.paymentInfo.receiver,
|
|
53
|
+
}
|
|
54
|
+
: {}),
|
|
55
|
+
amount: args.amount,
|
|
56
|
+
logIndex: log.logIndex,
|
|
57
|
+
txHash: log.transactionHash,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// not an escrow lifecycle event — ignore
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/** Construct the escrow WeldAdapter for one chain. */
|
|
67
|
+
export function createEscrowAdapter(config) {
|
|
68
|
+
const escrow = config.escrow ?? AUTH_CAPTURE_ESCROW;
|
|
69
|
+
return {
|
|
70
|
+
manifest: ESCROW_MANIFEST,
|
|
71
|
+
async propose(atrHash, ctx) {
|
|
72
|
+
const c = ctx;
|
|
73
|
+
// The salt is filled from the atrHash — never re-derived. No value-level Refusal
|
|
74
|
+
// on this path; a malformed atrHash is a programming error surfaced by BigInt() (fail-fast).
|
|
75
|
+
const paymentInfo = { ...c, salt: saltFromAtrHash(atrHash) };
|
|
76
|
+
return { ok: true, value: { paymentInfo } };
|
|
77
|
+
},
|
|
78
|
+
async recover(ref, ports) {
|
|
79
|
+
const logs = (await ports.chain.getTransactionLogs(ref));
|
|
80
|
+
// Only PaymentAuthorized/PaymentCharged carry the cleartext PaymentInfo (→ salt → atrHash).
|
|
81
|
+
const salted = decodeEscrowLogs(logs, escrow).filter((e) => e.salt !== undefined);
|
|
82
|
+
if (salted.length === 0)
|
|
83
|
+
return {
|
|
84
|
+
refused: true,
|
|
85
|
+
haltClass: "verification-failure",
|
|
86
|
+
code: "escrow/no-recoverable-event",
|
|
87
|
+
detail: `no PaymentAuthorized/PaymentCharged with a cleartext PaymentInfo in this settlement`,
|
|
88
|
+
};
|
|
89
|
+
// Disambiguate by logIndex when the ref pins one — and a pinned index matching NO salt-bearing event
|
|
90
|
+
// is a failure, never a fall-through to the first. One escrow transaction can authorize or charge
|
|
91
|
+
// several independent payments, each with its own salt.
|
|
92
|
+
if (ref.logIndex !== undefined) {
|
|
93
|
+
const match = salted.find((e) => e.logIndex === ref.logIndex);
|
|
94
|
+
if (match === undefined)
|
|
95
|
+
return {
|
|
96
|
+
refused: true,
|
|
97
|
+
haltClass: "verification-failure",
|
|
98
|
+
code: "escrow/log-index-not-found",
|
|
99
|
+
detail: `no salt-bearing escrow event at logIndex ${ref.logIndex} in settlement ${ref.txHash}`,
|
|
100
|
+
};
|
|
101
|
+
return { ok: true, value: atrHashFromSalt(match.salt) };
|
|
102
|
+
}
|
|
103
|
+
// Unpinned. This used to take the FIRST salt-bearing event, which silently answered one payment's
|
|
104
|
+
// atrHash for a transaction that welded several — the same first-wins defect x402's `recover` carried,
|
|
105
|
+
// and the one tempo-mpp refuses by name. Distinctness is the test: the same payment observed through
|
|
106
|
+
// both PaymentAuthorized and PaymentCharged carries one salt and is not ambiguous.
|
|
107
|
+
const distinct = new Set(salted.map((e) => e.salt));
|
|
108
|
+
if (distinct.size > 1)
|
|
109
|
+
return {
|
|
110
|
+
refused: true,
|
|
111
|
+
haltClass: "verification-failure",
|
|
112
|
+
code: "escrow/ambiguous-settlement",
|
|
113
|
+
detail: `settlement ${ref.txHash} carries ${distinct.size} payments with different salts — pin one with ref.logIndex rather than choosing for the caller`,
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
ok: true,
|
|
117
|
+
value: atrHashFromSalt(salted[0].salt),
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
async observe(ref, ports) {
|
|
121
|
+
const logs = (await ports.chain.getTransactionLogs(ref));
|
|
122
|
+
const events = decodeEscrowLogs(logs, escrow);
|
|
123
|
+
if (events.length === 0)
|
|
124
|
+
return { ok: true, value: [] };
|
|
125
|
+
const at = await ports.chain.blockTime(ref);
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
value: events.map((e) => ({
|
|
129
|
+
state: EVENT_TO_STATE[e.name],
|
|
130
|
+
at,
|
|
131
|
+
ref: refOf(ref.chainId, ref.txHash, e.logIndex),
|
|
132
|
+
})),
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
async enumerate(atrHash, ports) {
|
|
136
|
+
// Event-data scan (salt is NOT an indexed topic): fetch the salt-bearing events over the range and
|
|
137
|
+
// filter by decoded salt == uint256(atrHash). paymentInfoHash is the only indexed key, so there is
|
|
138
|
+
// no topic filter for salt — this is the manifest's declared "event-data-scan:paymentInfoHash".
|
|
139
|
+
const want = saltFromAtrHash(atrHash);
|
|
140
|
+
const logs = (await ports.chain.getLogs({
|
|
141
|
+
address: escrow,
|
|
142
|
+
events: [ESCROW_EVENTS_ABI[0], ESCROW_EVENTS_ABI[1]], // PaymentAuthorized, PaymentCharged
|
|
143
|
+
fromBlock: config.fromBlock ?? "earliest",
|
|
144
|
+
toBlock: "latest",
|
|
145
|
+
}));
|
|
146
|
+
return decodeEscrowLogs(logs, escrow)
|
|
147
|
+
.filter((e) => e.salt === want)
|
|
148
|
+
.map((e) => refOf(config.chainId, e.txHash ?? undefined, e.logIndex));
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAC9D,OAAO,EAAY,cAAc,EAAY,QAAQ,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAwB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,e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AClB,CAAC,CAAU,CAAC;YACb,OAAO,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC;iBAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;iBAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/calls.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PaymentInfo } from "./adapter.js";
|
|
2
|
+
/** keccak256 of the PaymentInfo typehash STRING (== the deployed PAYMENT_INFO_TYPEHASH, 0xae68…6591). */
|
|
3
|
+
export declare const PAYMENT_INFO_TYPEHASH: `0x${string}`;
|
|
4
|
+
/**
|
|
5
|
+
* The off-chain `getHash(paymentInfo)` — `keccak256(abi.encode(chainId, escrow, keccak256(abi.encode(
|
|
6
|
+
* TYPEHASH, paymentInfo))))`. Equals the event's indexed `paymentInfoHash` (the deployed `authorize`/
|
|
7
|
+
* `charge` emit `getHash(paymentInfo)` as that topic) and the settlement key. This matches
|
|
8
|
+
* the on-chain view byte-for-byte (incl. the fee-bearing case).
|
|
9
|
+
*/
|
|
10
|
+
export declare function getHashOffchain(params: {
|
|
11
|
+
chainId: number;
|
|
12
|
+
escrow?: `0x${string}`;
|
|
13
|
+
paymentInfo: PaymentInfo;
|
|
14
|
+
}): `0x${string}`;
|
|
15
|
+
/** The settlement key / event `paymentInfoHash` for a PaymentInfo (alias of `getHashOffchain`). */
|
|
16
|
+
export declare function paymentInfoHash(params: {
|
|
17
|
+
chainId: number;
|
|
18
|
+
escrow?: `0x${string}`;
|
|
19
|
+
paymentInfo: PaymentInfo;
|
|
20
|
+
}): `0x${string}`;
|
|
21
|
+
/**
|
|
22
|
+
* The ERC-3009 `ReceiveWithAuthorization` nonce the buyer signs — `getHash(paymentInfo with payer = 0)`
|
|
23
|
+
* (the "payer-agnostic" hash; the collector fills the real payer from the recovered signature).
|
|
24
|
+
*/
|
|
25
|
+
export declare function payerAgnosticNonce(params: {
|
|
26
|
+
chainId: number;
|
|
27
|
+
escrow?: `0x${string}`;
|
|
28
|
+
paymentInfo: PaymentInfo;
|
|
29
|
+
}): `0x${string}`;
|
|
30
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../src/calls.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsBhD,yGAAyG;AACzG,eAAO,MAAM,qBAAqB,EAAE,KAAK,MAAM,EAI9C,CAAC;AAIF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,KAAK,MAAM,EAAE,CAchB;AAED,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,KAAK,MAAM,EAAE,CAEhB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,KAAK,MAAM,EAAE,CAKhB"}
|