@integraledger/lcp-binding-stellar 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 +95 -0
- package/dist/adapter.d.ts +128 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +132 -0
- package/dist/adapter.js.map +1 -0
- package/dist/constants.d.ts +47 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +46 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +32 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +49 -0
- package/dist/manifest.js.map +1 -0
- package/dist/mux.d.ts +27 -0
- package/dist/mux.d.ts.map +1 -0
- package/dist/mux.js +70 -0
- package/dist/mux.js.map +1 -0
- package/package.json +62 -0
- package/src/adapter.ts +316 -0
- package/src/constants.ts +74 -0
- package/src/index.ts +31 -0
- package/src/manifest.ts +50 -0
- package/src/mux.ts +99 -0
- package/src/stellar-js-xdr.d.ts +31 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-stellar
|
|
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,95 @@
|
|
|
1
|
+
# @integraledger/lcp-binding-stellar
|
|
2
|
+
|
|
3
|
+
Welds an ATR hash into a Stellar payment.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @integraledger/lcp-binding-stellar
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| | |
|
|
10
|
+
|---|---|
|
|
11
|
+
| **Chain** | Stellar |
|
|
12
|
+
| **Pattern** | `native-field` |
|
|
13
|
+
| **Carrier** | the CAP-67 muxed-address `mux_id` |
|
|
14
|
+
| **Surface** | `createStellarAdapter` returning a rail-native adapter over a `StellarReader` port — **not** [`@integraledger/lcp-binding-core`](../binding-core#readme)'s `WeldAdapter`, whose shape is EVM's |
|
|
15
|
+
|
|
16
|
+
Installing this package installs **`@stellar/stellar-sdk`** — it is a direct dependency, used for XDR
|
|
17
|
+
envelope decoding. You supply the `StellarReader`; nothing here opens a connection.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import {
|
|
21
|
+
createStellarAdapter,
|
|
22
|
+
STELLAR_MANIFEST,
|
|
23
|
+
type StellarReader,
|
|
24
|
+
} from "@integraledger/lcp-binding-stellar";
|
|
25
|
+
|
|
26
|
+
declare const atrHash: string;
|
|
27
|
+
declare const baseGPubkey: string;
|
|
28
|
+
declare const reader: StellarReader; // your Horizon client
|
|
29
|
+
declare const txHash: string;
|
|
30
|
+
|
|
31
|
+
const adapter = createStellarAdapter(STELLAR_MANIFEST);
|
|
32
|
+
|
|
33
|
+
// SELLER — the muxed M-address to advertise as `payTo`. It welds atrHash[:8].
|
|
34
|
+
const payTo = adapter.propose(atrHash, baseGPubkey);
|
|
35
|
+
|
|
36
|
+
// VERIFIER — `verify`, not `recover`. You bring the atrHash; the chain confirms its first 8 bytes.
|
|
37
|
+
const confirmed = await adapter.verify(atrHash, { txHash }, reader);
|
|
38
|
+
if (!("refused" in confirmed)) console.log(confirmed.value.muxIdPrefix8Hex);
|
|
39
|
+
// Narrow with `"refused" in x` — `Refusal` has no `ok`, so the union cannot discriminate on one.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## The carrier
|
|
43
|
+
|
|
44
|
+
The binding rides `mux_id` inside a [CAP-67](https://stellar.org/protocol/cap-67) muxed M-address — an
|
|
45
|
+
existing Stellar account primitive, not an overlay contract. The muxed destination commits atomically with
|
|
46
|
+
the transfer.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import {
|
|
50
|
+
recoverMuxIdPrefix8,
|
|
51
|
+
verifyMuxedBinding,
|
|
52
|
+
} from "@integraledger/lcp-binding-stellar";
|
|
53
|
+
|
|
54
|
+
declare const atrHash: string;
|
|
55
|
+
declare const muxedM: string;
|
|
56
|
+
|
|
57
|
+
recoverMuxIdPrefix8(muxedM); // Uint8Array(8) | null — eight bytes, never a 64-hex lookalike
|
|
58
|
+
verifyMuxedBinding({ muxedM, atrHash }); // true iff the on-chain prefix matches the hash you hold
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Eight bytes, and the honesty that requires
|
|
62
|
+
|
|
63
|
+
`mux_id` is 64 bits, so it carries the **first 8 bytes** of the ATR hash, not the whole thing. The API
|
|
64
|
+
reflects that exactly:
|
|
65
|
+
|
|
66
|
+
- `recoverMuxIdPrefix8` returns raw 8 bytes — never a 64-hex value that would read as a full hash.
|
|
67
|
+
- `verifyMuxedBinding` **confirms** rather than recovers: an observer who already holds the ATR hash can
|
|
68
|
+
check that the on-chain destination binds to it.
|
|
69
|
+
|
|
70
|
+
Eight bytes is enough to confirm a hash you have and not enough to reconstruct one you do not, and the
|
|
71
|
+
surface is shaped so a caller cannot mistake the second for the first.
|
|
72
|
+
|
|
73
|
+
## Requirement ids
|
|
74
|
+
|
|
75
|
+
This package's source and its messages cite short ids — `ATA-3`, `RCS-5`, `CMP-6` and their kin.
|
|
76
|
+
**They are not LCP clause numbers.** LCP is cited by section (`§8.3.1`, `§C.2`); anything shaped `XXX-n`
|
|
77
|
+
comes from Integra's functional specification of what a complete agent transaction requires, the fourteen
|
|
78
|
+
families below. Nothing in this package's behaviour depends on them, and where an id and an LCP section
|
|
79
|
+
disagree the section governs.
|
|
80
|
+
|
|
81
|
+
| | | | |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `IDN` identity | `ASP` authority to spend | `ATA` authority to accept terms | `TRM` the terms record |
|
|
84
|
+
| `RCS` recourse | `PAY` payment and settlement | `WLD` the transactional weld | `OFR` offer integrity |
|
|
85
|
+
| `FRC` fraud, risk, and compliance | `OPS` commercial operations | `DSC` discovery and reputation | `ORC` orchestration |
|
|
86
|
+
| `CMP` composition | `PRS` persistence and verification infrastructure | | |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
**Requires Node >= 24.** Part of the
|
|
91
|
+
[Legal Context Protocol open layer](https://github.com/IntegraLedger/integra-protocol) — see the
|
|
92
|
+
[documentation](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/index.md)
|
|
93
|
+
and the
|
|
94
|
+
[package index](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/reference.md).
|
|
95
|
+
Apache-2.0.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Stellar CAP-67 muxed-address adapter — thin I/O with @stellar/stellar-sdk isolated here. Like
|
|
3
|
+
* binding-solana it intentionally does NOT implement binding-core's `WeldAdapter`: that port is EVM-shaped
|
|
4
|
+
* (`SettlementRef.txHash` is a `0x`-hex value, `ChainReader` speaks `eth_getLogs`), and Stellar speaks
|
|
5
|
+
* hex tx hashes over Horizon + CAP-67 M-address destinations. Rather than lie through those types, this
|
|
6
|
+
* exposes a Stellar-native surface (a tx-hash ref, a `StellarReader` port) alongside the shared,
|
|
7
|
+
* chain-agnostic `BindingManifest`. Unifying the port shape across EVM and non-EVM rails is future work;
|
|
8
|
+
* forcing it here would misrepresent the rail.
|
|
9
|
+
*
|
|
10
|
+
* ★ THE SURFACE IS CONFIRM-NOT-RECOVER, BY THE RAIL'S NATURE. Only `atrHash[:8]` rides in the CAP-67 mux
|
|
11
|
+
* id (8 bytes); the full 32-byte atrHash never touches the chain. So:
|
|
12
|
+
* - `propose(atrHash, basePubkey)` builds the muxed M-address destination the buyer transfers to.
|
|
13
|
+
* - `verify(atrHash, ref)` is the PRIMARY honest surface: it confirms the known atrHash's prefix-8 equals
|
|
14
|
+
* the settlement's on-chain mux id → `Outcome<{ confirmed: true; muxIdPrefix8Hex }>` or a
|
|
15
|
+
* `verification-failure` Refusal. (You bring the atrHash — from `extensions.legalContext.info` — the chain
|
|
16
|
+
* confirms the match.)
|
|
17
|
+
* - `recover(ref)` does NOT return a full atrHash (it cannot — the chain holds 8 bytes). It returns an
|
|
18
|
+
* explicitly-PARTIAL `{ muxIdPrefix8Hex }` documenting that only the prefix is on-chain, so a caller
|
|
19
|
+
* cannot mistake it for a recovered hash. If you want the atrHash, use `verify` with the off-chain hash.
|
|
20
|
+
* - `observe` reports the settled transition alongside the on-chain mux prefix.
|
|
21
|
+
* - `enumerate` is the best-effort account scan the manifest declares (`forwardIndexable: false`).
|
|
22
|
+
*
|
|
23
|
+
* ★ EVERY SURFACE GATES ON TRANSACTION SUCCESS FIRST (`StellarSettlementView.successful`). A failed
|
|
24
|
+
* Stellar transaction is still recorded in the ledger with its fee charged, and the operation's `to`
|
|
25
|
+
* destination lives in the transaction ENVELOPE — so the M-address stays readable on a `txFAILED` result.
|
|
26
|
+
* The confirm-not-recover posture does NOT mitigate that: it changes WHAT is proven (a prefix match rather
|
|
27
|
+
* than a recovered hash), never WHETHER settlement occurred. Without the gate, `verify` returns
|
|
28
|
+
* `confirmed: true` and `observe` returns `state: "settled"` for a transaction that moved nothing.
|
|
29
|
+
*/
|
|
30
|
+
import type { BindingManifest, Outcome } from "@integraledger/lcp-binding-core";
|
|
31
|
+
/** A Stellar settlement reference — a transaction hash (64-hex, as Horizon reports it). */
|
|
32
|
+
export interface StellarSettlementRef {
|
|
33
|
+
txHash: string;
|
|
34
|
+
}
|
|
35
|
+
/** The minimal on-chain view of a settlement this binding cares about: the CAP-67 M-address the SAC
|
|
36
|
+
* `transfer` paid to, plus whether the transaction actually succeeded. A reader implementation decodes the
|
|
37
|
+
* destination from the tx's single `transfer(from, to, amount)` op. `null` when the tx has no muxed
|
|
38
|
+
* destination. */
|
|
39
|
+
export interface StellarSettlementView {
|
|
40
|
+
/** The `to` destination of the SAC transfer, a CAP-67 M-address (starts with `M`), or null if none. */
|
|
41
|
+
muxedDestination: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Horizon's `successful` field for the transaction. ONLY `true` is a settlement: a Stellar transaction
|
|
44
|
+
* that fails is still recorded in the ledger with its fee charged, and the operation's `to` destination
|
|
45
|
+
* lives in the transaction ENVELOPE — so the M-address stays readable on a `txFAILED` result. Confirming
|
|
46
|
+
* it would mint a settlement record out of a failure. Fail-closed: `false` AND absent are both refused,
|
|
47
|
+
* because a reader that supplied no outcome gave no evidence of success (mirrors binding-solana's
|
|
48
|
+
* `err === null` gate and binding-xrpl's validated/tesSUCCESS gate). A faithful Horizon reader always
|
|
49
|
+
* supplies this field; note `/accounts/{id}/transactions` omits failed transactions unless
|
|
50
|
+
* `include_failed=true`, while `/transactions/{hash}` returns them either way.
|
|
51
|
+
*/
|
|
52
|
+
successful?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Did this transaction actually settle? Pure, fail-closed — only an explicit `true` counts. Every surface
|
|
56
|
+
* in this binding (`verify`, `recover`, `observe`, `enumerate`) gates on this before honouring a mux id:
|
|
57
|
+
* the confirm-not-recover posture changes WHAT is proven (a prefix match rather than a recovered hash),
|
|
58
|
+
* never WHETHER settlement occurred.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isSettledSuccessfully(view: StellarSettlementView): boolean;
|
|
61
|
+
/** Reads confirmed Stellar transactions — an injected port over Horizon / the SDK. */
|
|
62
|
+
export interface StellarReader {
|
|
63
|
+
settlementView(txHash: string): Promise<StellarSettlementView>;
|
|
64
|
+
/** Tx hashes touching an account's payment history (best-effort scan input for `enumerate`). */
|
|
65
|
+
transactionsFor(account: string, limit?: number): Promise<string[]>;
|
|
66
|
+
}
|
|
67
|
+
/** Build the CAP-67 muxed M-address destination carrying `atrHash[:8]` for a seller base G-pubkey. This is
|
|
68
|
+
* the `payTo` the buyer's SAC transfer targets; the buyer's signature over that transfer welds the mux id
|
|
69
|
+
* (signature-grade). Throws on a malformed atrHash / base pubkey (fail-fast). */
|
|
70
|
+
export declare function buildMuxedDestination(atrHash: string, baseGPubkey: string): string;
|
|
71
|
+
/** The result of `recover`: explicitly PARTIAL. `muxIdPrefix8Hex` is `0x` + 16 hex chars = `atrHash[:8]`,
|
|
72
|
+
* NOT a full atrHash. `note` states the truncation so no caller mistakes it for a recovered hash. */
|
|
73
|
+
export interface StellarMuxPrefixRecovery {
|
|
74
|
+
/** `0x`-prefixed hex of the 8 on-chain mux bytes (`atrHash[:8]`). NOT the full 32-byte atrHash. */
|
|
75
|
+
muxIdPrefix8Hex: string;
|
|
76
|
+
partial: true;
|
|
77
|
+
note: string;
|
|
78
|
+
}
|
|
79
|
+
/** The result of `verify`: a confirmed prefix-8 match against a KNOWN atrHash. */
|
|
80
|
+
export interface StellarMuxConfirmation {
|
|
81
|
+
confirmed: true;
|
|
82
|
+
/** `0x`-prefixed hex of the on-chain mux id that matched `atrHash[:8]`. */
|
|
83
|
+
muxIdPrefix8Hex: string;
|
|
84
|
+
}
|
|
85
|
+
/** The Stellar rail's surface, and the one whose shape differs most from the others — because only 8 bytes
|
|
86
|
+
* ride on-chain. A CAP-67 mux id is 8 bytes, so the full atrHash does not fit, and `recover` therefore
|
|
87
|
+
* answers a PREFIX, never a hash. {@link StellarAdapter.verify} is the primary method here: you bring the
|
|
88
|
+
* atrHash from off-chain and the chain confirms its first 8 bytes match. A caller reaching for `recover`
|
|
89
|
+
* expecting the other rails' behaviour is the mistake this rail is shaped to make impossible. */
|
|
90
|
+
export interface StellarAdapter {
|
|
91
|
+
manifest: BindingManifest;
|
|
92
|
+
/** Build the muxed M-address destination the buyer transfers to (welds `atrHash[:8]`). */
|
|
93
|
+
propose(atrHash: string, baseGPubkey: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* CONFIRM (primary): does the settlement's on-chain mux id equal the KNOWN atrHash's prefix-8? Returns a
|
|
96
|
+
* confirmation with the matched prefix, or a `verification-failure` Refusal on mismatch / no muxed
|
|
97
|
+
* destination. You supply the atrHash (from off-chain `extensions.legalContext.info`); the chain confirms it.
|
|
98
|
+
*/
|
|
99
|
+
verify(atrHash: string, ref: StellarSettlementRef, reader: StellarReader): Promise<Outcome<StellarMuxConfirmation>>;
|
|
100
|
+
/**
|
|
101
|
+
* RECOVER — explicitly PARTIAL. Returns only the 8-byte on-chain mux prefix (`atrHash[:8]`), never a full
|
|
102
|
+
* atrHash (the chain does not carry one). A `verification-failure` Refusal when the tx has no muxed
|
|
103
|
+
* destination. To obtain the atrHash, use `verify` with the off-chain hash.
|
|
104
|
+
*/
|
|
105
|
+
recover(ref: StellarSettlementRef, reader: StellarReader): Promise<Outcome<StellarMuxPrefixRecovery>>;
|
|
106
|
+
/** Report the settled transition (the tx is confirmed and its destination is a CAP-67 muxed M-address). */
|
|
107
|
+
observe(ref: StellarSettlementRef, reader: StellarReader): Promise<Outcome<{
|
|
108
|
+
state: "settled";
|
|
109
|
+
muxIdPrefix8Hex: string;
|
|
110
|
+
}>>;
|
|
111
|
+
/**
|
|
112
|
+
* Best-effort account scan for settlements whose mux id matches `atrHash[:8]` (NOT a native index — see
|
|
113
|
+
* the manifest's `forwardIndexable: false`). Confirms, per tx, against the known atrHash.
|
|
114
|
+
*/
|
|
115
|
+
enumerate(atrHash: string, account: string, reader: StellarReader, limit?: number): Promise<StellarSettlementRef[]>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The `note` every partial recovery carries, exported because callers receive it and matching on a string
|
|
119
|
+
* they cannot import is guesswork. It names the off-chain slot the x402 placement actually writes —
|
|
120
|
+
* `extensions.legalContext.info` — and `rail-invariants` asserts that against the placement's own manifest,
|
|
121
|
+
* because a reader who follows this instruction to a slot nothing writes concludes the reference is absent.
|
|
122
|
+
*/
|
|
123
|
+
export declare const STELLAR_PREFIX_NOTE = "PARTIAL: only atrHash[:8] rides in the CAP-67 mux id \u2014 this is the 8-byte on-chain prefix, NOT the full atrHash; obtain the full hash off-chain (extensions.legalContext.info) and use verify() to confirm the match";
|
|
124
|
+
/** Construct the Stellar adapter. **The manifest is injected, not baked in** — pass this package's own
|
|
125
|
+
* `STELLAR_MANIFEST`; a manifest whose `rail` is not `"stellar"` throws, because an adapter over another
|
|
126
|
+
* rail's manifest would publish that rail's claims as its own. This is the package's entry point. */
|
|
127
|
+
export declare function createStellarAdapter(manifest: BindingManifest): StellarAdapter;
|
|
128
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EAER,MAAM,iCAAiC,CAAC;AAQzC,2FAA2F;AAC3F,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;mBAGmB;AACnB,MAAM,WAAW,qBAAqB;IACpC,uGAAuG;IACvG,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAE1E;AAED,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC/D,gGAAgG;IAChG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACrE;AAED;;kFAEkF;AAClF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAQD;sGACsG;AACtG,MAAM,WAAW,wBAAwB;IACvC,mGAAmG;IACnG,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kFAAkF;AAClF,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,IAAI,CAAC;IAChB,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;kGAIkG;AAClG,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,0FAA0F;IAC1F,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IACtD;;;;OAIG;IACH,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,OAAO,CACL,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAC9C,2GAA2G;IAC3G,OAAO,CACL,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACnE;;;OAGG;IACH,SAAS,CACP,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CACpC;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,8NACwL,CAAC;AAEzN;;sGAEsG;AACtG,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,GACxB,cAAc,CA6IhB"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { deriveMuxId, encodeMuxedAddress, recoverMuxIdPrefix8, verifyMuxedBinding, } from "./mux.js";
|
|
2
|
+
/**
|
|
3
|
+
* Did this transaction actually settle? Pure, fail-closed — only an explicit `true` counts. Every surface
|
|
4
|
+
* in this binding (`verify`, `recover`, `observe`, `enumerate`) gates on this before honouring a mux id:
|
|
5
|
+
* the confirm-not-recover posture changes WHAT is proven (a prefix match rather than a recovered hash),
|
|
6
|
+
* never WHETHER settlement occurred.
|
|
7
|
+
*/
|
|
8
|
+
export function isSettledSuccessfully(view) {
|
|
9
|
+
return view.successful === true;
|
|
10
|
+
}
|
|
11
|
+
/** Build the CAP-67 muxed M-address destination carrying `atrHash[:8]` for a seller base G-pubkey. This is
|
|
12
|
+
* the `payTo` the buyer's SAC transfer targets; the buyer's signature over that transfer welds the mux id
|
|
13
|
+
* (signature-grade). Throws on a malformed atrHash / base pubkey (fail-fast). */
|
|
14
|
+
export function buildMuxedDestination(atrHash, baseGPubkey) {
|
|
15
|
+
return encodeMuxedAddress(baseGPubkey, deriveMuxId(atrHash));
|
|
16
|
+
}
|
|
17
|
+
function toHex(bytes) {
|
|
18
|
+
let out = "0x";
|
|
19
|
+
for (const b of bytes)
|
|
20
|
+
out += b.toString(16).padStart(2, "0");
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The `note` every partial recovery carries, exported because callers receive it and matching on a string
|
|
25
|
+
* they cannot import is guesswork. It names the off-chain slot the x402 placement actually writes —
|
|
26
|
+
* `extensions.legalContext.info` — and `rail-invariants` asserts that against the placement's own manifest,
|
|
27
|
+
* because a reader who follows this instruction to a slot nothing writes concludes the reference is absent.
|
|
28
|
+
*/
|
|
29
|
+
export const STELLAR_PREFIX_NOTE = "PARTIAL: only atrHash[:8] rides in the CAP-67 mux id — this is the 8-byte on-chain prefix, NOT the full atrHash; obtain the full hash off-chain (extensions.legalContext.info) and use verify() to confirm the match";
|
|
30
|
+
/** Construct the Stellar adapter. **The manifest is injected, not baked in** — pass this package's own
|
|
31
|
+
* `STELLAR_MANIFEST`; a manifest whose `rail` is not `"stellar"` throws, because an adapter over another
|
|
32
|
+
* rail's manifest would publish that rail's claims as its own. This is the package's entry point. */
|
|
33
|
+
export function createStellarAdapter(manifest) {
|
|
34
|
+
// Fail-fast: an adapter constructed over another rail's manifest would report that rail's claims as
|
|
35
|
+
// this one's. The EVM adapters bake their module const in; the injectable factories refuse instead.
|
|
36
|
+
// Stryker disable next-line all: the guard runs during test-module load (the repository's
|
|
37
|
+
// test suite constructs the adapter at describe scope), so its mutants are 'static' — outside the vitest
|
|
38
|
+
// runner's per-test attribution and unkillable by any test that in fact kills them behaviorally
|
|
39
|
+
// (each rail pins both arms: valid manifest constructs, wrong rail throws by message).
|
|
40
|
+
if (manifest.rail !== "stellar")
|
|
41
|
+
throw new Error(`createStellarAdapter: manifest.rail "${manifest.rail}" is not "stellar"`);
|
|
42
|
+
// Closure helpers (not `this`) so the returned methods stay destructure-safe.
|
|
43
|
+
/** Every refusal on this rail is a verification failure, namespaced `stellar/…` (mirrors placement.ts). */
|
|
44
|
+
const refuse = (code, detail) => ({
|
|
45
|
+
refused: true,
|
|
46
|
+
haltClass: "verification-failure",
|
|
47
|
+
code: `stellar/${code}`,
|
|
48
|
+
detail,
|
|
49
|
+
});
|
|
50
|
+
/** The refusal a transaction that did not succeed earns — never a mismatch, never a missing destination. */
|
|
51
|
+
const unsuccessful = (txHash) => refuse("unsuccessful-transaction", `transaction ${txHash} did not succeed (Horizon successful !== true) — its CAP-67 destination is not a settlement`);
|
|
52
|
+
const noMuxedDestination = (txHash) => refuse("no-muxed-destination", `no CAP-67 muxed destination in ${txHash}`);
|
|
53
|
+
/**
|
|
54
|
+
* The on-chain mux prefix of a SUCCESSFUL settlement. Returns the refusal reason as a discriminated
|
|
55
|
+
* value so `recover` and `observe` report WHY: a failed transaction is not "no destination".
|
|
56
|
+
*/
|
|
57
|
+
async function onChainPrefix(ref, reader) {
|
|
58
|
+
const view = await reader.settlementView(ref.txHash);
|
|
59
|
+
if (view.muxedDestination === null)
|
|
60
|
+
return { reason: "no-muxed-destination" };
|
|
61
|
+
if (!isSettledSuccessfully(view))
|
|
62
|
+
return { reason: "unsuccessful" };
|
|
63
|
+
// DECODE BEFORE COMPARING. A destination that is not a valid M-address (a plain G-address, a truncated
|
|
64
|
+
// StrKey) carries no mux id at all — that is "no muxed destination", never "the wrong atrHash". Every
|
|
65
|
+
// surface routes through here so the four of them cannot disagree about what a given view means.
|
|
66
|
+
const prefix = recoverMuxIdPrefix8(view.muxedDestination);
|
|
67
|
+
if (prefix === null)
|
|
68
|
+
return { reason: "no-muxed-destination" };
|
|
69
|
+
return { prefix, muxedDestination: view.muxedDestination };
|
|
70
|
+
}
|
|
71
|
+
/** The refusal for whichever reason `onChainPrefix` gave — shared by all four surfaces. */
|
|
72
|
+
const refusalFor = (reason, txHash) => reason === "unsuccessful"
|
|
73
|
+
? unsuccessful(txHash)
|
|
74
|
+
: noMuxedDestination(txHash);
|
|
75
|
+
return {
|
|
76
|
+
manifest,
|
|
77
|
+
propose(atrHash, baseGPubkey) {
|
|
78
|
+
return buildMuxedDestination(atrHash, baseGPubkey);
|
|
79
|
+
},
|
|
80
|
+
async verify(atrHash, ref, reader) {
|
|
81
|
+
// ★ The success gate and the decode both run BEFORE the prefix match: a failed transaction is not
|
|
82
|
+
// "the wrong ATR" (its envelope still carries the M-address), and an undecodable destination is not
|
|
83
|
+
// one either. `mux-prefix-mismatch` therefore means strictly: there WAS a mux id, and it was wrong.
|
|
84
|
+
const found = await onChainPrefix(ref, reader);
|
|
85
|
+
if ("reason" in found)
|
|
86
|
+
return refusalFor(found.reason, ref.txHash);
|
|
87
|
+
if (!verifyMuxedBinding({ muxedM: found.muxedDestination, atrHash }))
|
|
88
|
+
return refuse("mux-prefix-mismatch", `on-chain mux id != atrHash[:8] for ${ref.txHash}`);
|
|
89
|
+
return {
|
|
90
|
+
ok: true,
|
|
91
|
+
value: { confirmed: true, muxIdPrefix8Hex: toHex(found.prefix) },
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
async recover(ref, reader) {
|
|
95
|
+
const found = await onChainPrefix(ref, reader);
|
|
96
|
+
if ("reason" in found)
|
|
97
|
+
return refusalFor(found.reason, ref.txHash);
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
value: {
|
|
101
|
+
muxIdPrefix8Hex: toHex(found.prefix),
|
|
102
|
+
partial: true,
|
|
103
|
+
note: STELLAR_PREFIX_NOTE,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
async observe(ref, reader) {
|
|
108
|
+
const found = await onChainPrefix(ref, reader);
|
|
109
|
+
if ("reason" in found)
|
|
110
|
+
return refusalFor(found.reason, ref.txHash);
|
|
111
|
+
return {
|
|
112
|
+
ok: true,
|
|
113
|
+
value: { state: "settled", muxIdPrefix8Hex: toHex(found.prefix) },
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
async enumerate(atrHash, account, reader, limit) {
|
|
117
|
+
const hashes = await reader.transactionsFor(account, limit);
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const txHash of hashes) {
|
|
120
|
+
const view = await reader.settlementView(txHash);
|
|
121
|
+
// A failed transaction's envelope still carries the M-address — the scan must skip it, or a
|
|
122
|
+
// ledger full of failures enumerates as a ledger full of settlements.
|
|
123
|
+
if (view.muxedDestination !== null &&
|
|
124
|
+
isSettledSuccessfully(view) &&
|
|
125
|
+
verifyMuxedBinding({ muxedM: view.muxedDestination, atrHash }))
|
|
126
|
+
out.push({ txHash });
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AA2BlB;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA2B;IAC/D,OAAO,IAAI,CAAC,UAAU,KAAK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,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC5D,MAAM,GAAG,GAA2B,EAAE,CAAC;YACvC,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;gBAC5B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;gBACjD,4FAA4F;gBAC5F,sEAAsE;gBACtE,IACE,IAAI,CAAC,gBAAgB,KAAK,IAAI;oBAC9B,qBAAqB,CAAC,IAAI,CAAC;oBAC3B,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC;oBAE9D,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACzB,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar network constants for the LCP CAP-67 muxed-address binding. The binding rides
|
|
3
|
+
* `mux_id = atrHash[:8]` inside a CAP-67 muxed M-address that the seller advertises as `payTo`; the buyer
|
|
4
|
+
* signs a Soroban SAC `transfer(from, to, amount)` whose `to` is that M-address, so the buyer's signature
|
|
5
|
+
* commits the 8-byte prefix atomically with the transfer (canonical LCP §8.3.1 Native Field per the LCP
|
|
6
|
+
* per-chain binding table — the CAP-67 muxed id, not an overlay contract).
|
|
7
|
+
*
|
|
8
|
+
* ★ ONLY 8 bytes ride on-chain. A CAP-67 muxed id is exactly 8 bytes, so the FULL 32-byte atrHash does not
|
|
9
|
+
* fit — the on-chain artifact confirms `atrHash[:8]`, it does not recover the whole hash (that comes from
|
|
10
|
+
* off-chain `extensions.legalContext.info`). See `mux.ts` and the manifest for how the surface stays honest.
|
|
11
|
+
*/
|
|
12
|
+
/** The single canonical mux-id derivation scheme LCP-on-Stellar commits to: `mux_id = atrHash[:8]`. The
|
|
13
|
+
* prefix is deliberately public (project_stellar_mux_prefix8_audit) — any observer holding the atrHash can
|
|
14
|
+
* confirm the on-chain mux id matches, which IS the audit-trail property the protocol wants. No HMAC /
|
|
15
|
+
* per-seller-key variant is wired (that would trade auditability for unlinkability, which is not wanted). */
|
|
16
|
+
export declare const MUX_SCHEME: "atrHash-prefix-8";
|
|
17
|
+
/** The mux id is the first 8 bytes of the 32-byte atrHash. */
|
|
18
|
+
export declare const MUX_ID_BYTES = 8;
|
|
19
|
+
/** The two networks. Stellar's mainnet is `pubnet`, not `"mainnet"` — the SDK's own name, kept. */
|
|
20
|
+
export type StellarNetwork = "testnet" | "pubnet";
|
|
21
|
+
/** Per-network constants. Two endpoints, because the write and the read use different ones: the transfer
|
|
22
|
+
* is a Soroban SAC call (`sorobanRpcUrl`, for the caller that builds and submits it) while recovery reads
|
|
23
|
+
* the transaction envelope back through Horizon (`horizonUrl`). This package itself performs no HTTP —
|
|
24
|
+
* `sorobanRpcUrl` is carried for the caller's benefit and nothing here consumes it. */
|
|
25
|
+
export interface StellarNetworkConfig {
|
|
26
|
+
network: StellarNetwork;
|
|
27
|
+
/** Network passphrase used for tx signing / envelope decoding. */
|
|
28
|
+
networkPassphrase: string;
|
|
29
|
+
/** Horizon REST base URL. */
|
|
30
|
+
horizonUrl: string;
|
|
31
|
+
/** Soroban RPC URL. */
|
|
32
|
+
sorobanRpcUrl: string;
|
|
33
|
+
/** Circle-issued USDC Soroban Asset Contract id on this network. */
|
|
34
|
+
usdcSacContractId: string;
|
|
35
|
+
}
|
|
36
|
+
/** Stellar network passphrases (from the SDK's `Networks`; inlined here so constants stays SDK-free). */
|
|
37
|
+
export declare const TESTNET_PASSPHRASE = "Test SDF Network ; September 2015";
|
|
38
|
+
/** The pubnet passphrase. Note the spacing — ` ; ` with spaces either side is part of the string, and the
|
|
39
|
+
* passphrase is hashed into every signature, so a single wrong character produces a transaction that
|
|
40
|
+
* verifies against nothing. */
|
|
41
|
+
export declare const PUBNET_PASSPHRASE = "Public Global Stellar Network ; September 2015";
|
|
42
|
+
/** The constants for one network. Both are usable — the CAP-67 muxed id is a ledger primitive, so nothing
|
|
43
|
+
* has to be deployed first. */
|
|
44
|
+
export declare function getStellarConfig(network: StellarNetwork): StellarNetworkConfig;
|
|
45
|
+
/** USDC on Stellar has 7 decimals — 1 USDC = 10_000_000 base units. */
|
|
46
|
+
export declare const USDC_DECIMALS = 7;
|
|
47
|
+
//# sourceMappingURL=constants.d.ts.map
|