nirium-pollar-adapter 0.4.1 → 0.6.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/LICENSE +190 -0
- package/README.md +126 -34
- package/dist/index.d.ts +60 -0
- package/dist/index.js +98 -1
- package/examples/pay-with-keypair.mjs +9 -4
- package/examples/spike-19/anchor-on-success.mjs +168 -0
- package/examples/spike-19/browser-polyfill.mjs +46 -0
- package/examples/spike-19/spike.mjs +146 -0
- package/package.json +26 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Nirium Protocol Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# nirium-pollar-adapter
|
|
2
2
|
|
|
3
|
-
Nirium adapter for the [Pollar](https://pollar.xyz) SDK
|
|
3
|
+
Nirium adapter for the [Pollar](https://pollar.xyz) SDK. It lets the wallet a user onboarded through Pollar pay for APIs (x402) and anchor tamper-proof evidence to IPFS, without your app touching keys or learning the x402 protocol.
|
|
4
4
|
|
|
5
5
|
Both surfaces are **software-only and non-custodial**, and both are **live on Stellar mainnet**.
|
|
6
6
|
|
|
7
|
+
Wraps [`nirium`](https://github.com/nirium-protocol/nirium), the TypeScript/Python SDK this adapter signs for. See that repo for the full API this exposes through a Pollar wallet instead of a raw keypair.
|
|
8
|
+
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
npm install nirium-pollar-adapter
|
|
11
|
-
# optional peer, only for createPollarSigner: @pollar/core >= 0.
|
|
13
|
+
# optional peer, only for createPollarSigner: @pollar/core >=0.11.4 <0.13.0
|
|
12
14
|
```
|
|
13
15
|
|
|
14
16
|
## Quickstart
|
|
@@ -32,13 +34,13 @@ const res = await nirium.x402Fetch(
|
|
|
32
34
|
const data = await res.json();
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
The user pays **$0.05 USDC** and signs nothing else
|
|
37
|
+
The user pays **$0.05 USDC** and signs nothing else. The x402 facilitator sponsors the network fee, so the wallet does not need XLM for gas.
|
|
36
38
|
|
|
37
|
-
### Requires @pollar/core 0.11+
|
|
39
|
+
### Requires @pollar/core 0.11.4+
|
|
38
40
|
|
|
39
|
-
`createPollarSigner` calls `PollarClient.signAuthEntry`, available from `@pollar/core` 0.11. On older versions it throws an explanatory error, and you can still pass any other SEP-43 signer.
|
|
41
|
+
`createPollarSigner` calls `PollarClient.signAuthEntry`, available from `@pollar/core` 0.11. The peer range is `>=0.11.4 <0.13.0`; CI runs the contract test against 0.11.4; 0.12.0 was also run by hand on 2026-10-31. On older versions it throws an explanatory error, and you can still pass any other SEP-43 signer.
|
|
40
42
|
|
|
41
|
-
The two sides speak different dialects and the adapter translates between them: x402 expects SEP-43 (`signAuthEntry(xdr, { networkPassphrase, address }) → { signedAuthEntry }`), Pollar expects `signAuthEntry(xdr, { validUntilLedger }) → { status, … }`. The adapter reads the network's latest ledger, sets the expiry, and normalises the outcome
|
|
43
|
+
The two sides speak different dialects and the adapter translates between them: x402 expects SEP-43 (`signAuthEntry(xdr, { networkPassphrase, address }) → { signedAuthEntry }`), Pollar expects `signAuthEntry(xdr, { validUntilLedger }) → { status, … }`. The adapter reads the network's latest ledger, sets the expiry, and normalises the outcome. You do not deal with any of it.
|
|
42
44
|
|
|
43
45
|
```ts
|
|
44
46
|
const signer = createPollarSigner(pollar, {
|
|
@@ -51,17 +53,23 @@ Check at runtime before enabling a pay button:
|
|
|
51
53
|
|
|
52
54
|
```ts
|
|
53
55
|
import { canSignX402 } from "nirium-pollar-adapter";
|
|
54
|
-
<button disabled={!canSignX402(pollar)}>Pay $0.
|
|
56
|
+
<button disabled={!canSignX402(pollar)}>Pay $0.05</button>
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
## Verify it end-to-end today
|
|
58
60
|
|
|
59
|
-
The signer is pluggable, so you can prove the whole path works with a plain Stellar keypair
|
|
61
|
+
The signer is pluggable, so you can prove the whole path works with a plain Stellar keypair. No Pollar required - this defaults to testnet, no real money moves:
|
|
60
62
|
|
|
61
63
|
```bash
|
|
62
64
|
NIRIUM_DEMO_SECRET=S… node examples/pay-with-keypair.mjs
|
|
63
65
|
```
|
|
64
66
|
|
|
67
|
+
Against mainnet (spends real USDC, $0.05 per call), opt in explicitly:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
NIRIUM_DEMO_SECRET=S… NIRIUM_NETWORK=stellar:pubnet node examples/pay-with-keypair.mjs
|
|
71
|
+
```
|
|
72
|
+
|
|
65
73
|
Verified on mainnet (27 Jul 2026): payment [`25ebaf9a…`](https://stellar.expert/explorer/public/tx/25ebaf9aa7e72c1c3edcc43a1c18aaa102c12eee42c57e02fed4fda79af6605d) settled, evidence anchored at [`QmZiwxidm…`](https://gateway.pinata.cloud/ipfs/QmZiwxidm7pcTqNufxzFyUc7qJrCRN2TKRNwcXkg7vUUwR).
|
|
66
74
|
|
|
67
75
|
Swapping to a Pollar wallet is one line:
|
|
@@ -72,18 +80,57 @@ Swapping to a Pollar wallet is one line:
|
|
|
72
80
|
```
|
|
73
81
|
|
|
74
82
|
**Verified with a real Pollar social login (our own test account, 5 Aug
|
|
75
|
-
2026):** a user who signed in with Google paid $0.02 USDC on mainnet
|
|
76
|
-
[`e4fa3df9…`](https://stellar.expert/explorer/public/tx/e4fa3df9cb225a4d7f64dd0082eb38218ada4b4af3378f288989a5d4b1116ed9)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
source. The user never saw a key, a seed phrase or a gas prompt.
|
|
83
|
+
2026):** a user who signed in with Google paid $0.02 USDC on mainnet
|
|
84
|
+
([`e4fa3df9…`](https://stellar.expert/explorer/public/tx/e4fa3df9cb225a4d7f64dd0082eb38218ada4b4af3378f288989a5d4b1116ed9))
|
|
85
|
+
while holding **zero XLM** at every point. Pollar sponsors the account reserve
|
|
86
|
+
and the trustline. The x402 facilitator sponsors the network fee and is the
|
|
87
|
+
transaction source. The user never saw a key, a seed phrase or a gas prompt.
|
|
80
88
|
|
|
81
89
|
Both proofs above paid `/premium/signals` ($0.02). Since 6-Aug-2026 that
|
|
82
|
-
endpoint is **testnet only
|
|
90
|
+
endpoint is **testnet only**: the mainnet agent box runs no autonomous loop,
|
|
83
91
|
so a capability guard now returns 501 before any charge. The example above
|
|
84
92
|
pays `/premium/market` ($0.05) instead, which has no such guard and still
|
|
85
|
-
settles on mainnet today
|
|
86
|
-
just no longer reproducible
|
|
93
|
+
settles on mainnet today. The two linked transactions remain real; they are
|
|
94
|
+
just no longer reproducible word for word with the current example.
|
|
95
|
+
|
|
96
|
+
## Deferred funding (Pollar "Deferred mode")
|
|
97
|
+
|
|
98
|
+
If your Pollar app's **Dashboard → Treasury → Funding Mode** is set to
|
|
99
|
+
**Deferred**, Pollar does not create the account on-chain at login. Your
|
|
100
|
+
backend creates it by calling `POST /v3/wallets/fund`. Checked on testnet on
|
|
101
|
+
2026-10-31: for a wallet that did not exist yet (Horizon returned 404), the
|
|
102
|
+
call returned 200 with `startingBalance: "0"`, and Horizon then showed the
|
|
103
|
+
account with 0 XLM and its reserves sponsored by Pollar. So "funding" here
|
|
104
|
+
means creating the account with sponsored reserves, not sending XLM to it.
|
|
105
|
+
|
|
106
|
+
You often do not need it for x402. A wallet at 0 XLM can sign and settle a
|
|
107
|
+
real x402 payment (see the section above: Pollar sponsors the reserve and
|
|
108
|
+
the default trustline, and the facilitator sponsors the network fee). Call
|
|
109
|
+
`activateWallet()` when your app needs the account to exist on-chain before
|
|
110
|
+
that first payment, or to match what Pollar's dashboard considers
|
|
111
|
+
"activated."
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { activateWallet } from "nirium-pollar-adapter";
|
|
115
|
+
|
|
116
|
+
// Server-side only (Next.js API route, Express handler, webhook). Never
|
|
117
|
+
// call this from the browser: it requires the secret key.
|
|
118
|
+
const result = await activateWallet(wallet.address, {
|
|
119
|
+
secretKey: process.env.POLLAR_SECRET_KEY!, // sec_testnet_… / sec_mainnet_…
|
|
120
|
+
});
|
|
121
|
+
// { activated: true, amount: "0" } - funded now (amount = Pollar's startingBalance)
|
|
122
|
+
// { activated: false } - account already exists on-chain; safe, not an error
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Calling it twice on an already-funded wallet does not throw. Pollar's own
|
|
126
|
+
docs call HTTP 409 "safe to ignore, treat as success," and `activateWallet`
|
|
127
|
+
returns `{ activated: false }` rather than raising. Anything else throws
|
|
128
|
+
`PollarActivationError` with the real `code` and HTTP `status` Pollar sent,
|
|
129
|
+
rather than assuming a fixed meaning per status number. The two Pollar docs
|
|
130
|
+
pages that describe this endpoint disagree on what several of the non-200/409
|
|
131
|
+
codes mean (402 vs. 403, 503 vs. 502 for what reads like the same failure),
|
|
132
|
+
so this adapter passes on what the server actually said instead of picking
|
|
133
|
+
one doc to trust.
|
|
87
134
|
|
|
88
135
|
## API
|
|
89
136
|
|
|
@@ -91,7 +138,7 @@ just no longer reproducible verbatim with the current example.
|
|
|
91
138
|
|
|
92
139
|
| Option | Default | |
|
|
93
140
|
|---|---|---|
|
|
94
|
-
| `signer` |
|
|
141
|
+
| `signer` | - | SEP-43 signer. Only `address` and `signAuthEntry` are required |
|
|
95
142
|
| `network` | `stellar:testnet` | `stellar:testnet` or `stellar:pubnet` |
|
|
96
143
|
| `agentBaseUrl` | box for the network | Nirium agent base URL |
|
|
97
144
|
| `rpcUrl` | public RPC for the network | Soroban RPC |
|
|
@@ -99,11 +146,11 @@ just no longer reproducible verbatim with the current example.
|
|
|
99
146
|
|
|
100
147
|
Returns:
|
|
101
148
|
|
|
102
|
-
- **`x402Fetch(url, init?)
|
|
103
|
-
- **`getPremiumSignals()
|
|
104
|
-
- **`getPremiumMarket()
|
|
105
|
-
- **`anchorAuditRecord({ hash?, record?, txHash?, tag? })
|
|
106
|
-
- **`getCetesRate()
|
|
149
|
+
- **`x402Fetch(url, init?)`**: fetch that pays on `402` and retries. Passes through untouched on `200`.
|
|
150
|
+
- **`getPremiumSignals()`**: typed shortcut to the agent's paid signals endpoint. **Testnet only**: signals come from the autonomous loop, which does not run on the mainnet box; there the endpoint returns 501 without charging.
|
|
151
|
+
- **`getPremiumMarket()`**: typed shortcut to the agent's paid market-state endpoint ($0.05). Works and charges on **both** networks, with no dependency on the autonomous loop.
|
|
152
|
+
- **`anchorAuditRecord({ hash?, record?, txHash?, tag? })`**: anchors evidence to IPFS and returns the CID. No signature, no payment. Anchor **hashes, not personal data**: IPFS cannot be deleted.
|
|
153
|
+
- **`getCetesRate()`**: CETES rate as a number, no key required. It is **not a live reading**: today the agent serves a fixed value (5.57, read in June 2026 from app.etherfuse.com/b/cetes).
|
|
107
154
|
|
|
108
155
|
### `createPollarSigner(pollarClient, opts?)`
|
|
109
156
|
|
|
@@ -119,24 +166,55 @@ Wraps a Pollar client as a SEP-43 `ClientStellarSigner`.
|
|
|
119
166
|
**`signAuthEntry` means two different things, and this is what translates them.**
|
|
120
167
|
|
|
121
168
|
`stellar-sdk` (`AssembledTransaction.signAuthEntries` → `authorizeEntry`) hands
|
|
122
|
-
the signer a **`HashIdPreimage`**
|
|
169
|
+
the signer a **`HashIdPreimage`** (the thing about to be hashed) and expects
|
|
123
170
|
the **raw signature** back; it assembles the final entry itself. Pollar's
|
|
124
171
|
`POST /tx/sign-auth-entry` expects the full **`SorobanAuthorizationEntry`** and
|
|
125
|
-
returns the **signed entry**, because its backend
|
|
172
|
+
returns the **signed entry**, because its backend checks the invocation tree
|
|
126
173
|
against your Auth Policy allowlist before signing, and a hash would tell it
|
|
127
174
|
nothing. Both designs are right; they are just not the same one.
|
|
128
175
|
|
|
129
|
-
Without translation Pollar answers `SOROBAN_AUTH_ENTRY_INVALID
|
|
176
|
+
Without translation Pollar answers `SOROBAN_AUTH_ENTRY_INVALID - "entryXdr is
|
|
130
177
|
not a valid SorobanAuthorizationEntry"`, which reads like a corrupt XDR when the
|
|
131
|
-
XDR is fine and
|
|
178
|
+
XDR is fine and simply of another type.
|
|
132
179
|
|
|
133
|
-
The preimage carries nonce, expiry and invocation
|
|
134
|
-
|
|
135
|
-
|
|
180
|
+
The preimage carries nonce, expiry and invocation. The only extra thing the
|
|
181
|
+
entry needs is the signer address, which we have, so the rebuilt entry is exact
|
|
182
|
+
and the hash Pollar signs is byte-identical to the one the SDK expects.
|
|
136
183
|
The expiry is taken **from the preimage**, never from the clock: it lives inside
|
|
137
184
|
the signed hash, so asking Pollar for a different one would yield a signature
|
|
138
185
|
that does not validate.
|
|
139
186
|
|
|
187
|
+
### `activateWallet(publicKey, options)`
|
|
188
|
+
|
|
189
|
+
Creates a Pollar wallet's account on-chain with sponsored reserves, for apps in Deferred funding mode (`POST /v3/wallets/fund`). **Server-side only.**
|
|
190
|
+
|
|
191
|
+
| Option | Default | |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `secretKey` | - | `sec_testnet_…` / `sec_mainnet_…`. Never expose this client-side |
|
|
194
|
+
| `baseUrl` | `https://server.api.pollar.xyz` | Pollar Server base URL |
|
|
195
|
+
| `fetchImpl` | global `fetch` | for tests or runtimes without global fetch |
|
|
196
|
+
|
|
197
|
+
Returns `{ activated: boolean, amount?: string, queued?: boolean }`. `amount` is the `startingBalance` Pollar reports (`"0"` in the testnet run above). `queued` is `true` on HTTP 202, for co-signed or self-custody wallets, where the user approves the request in their next session. Throws `PollarActivationError` (`.code`, `.status`) for anything other than success (200) or already-funded (409). Also throws a plain `Error` synchronously, before any network call, if `publicKey` is not a valid Stellar `G...` address.
|
|
198
|
+
|
|
199
|
+
### `anchorOnTransactionSuccess(pollarClient, adapter, options?)`
|
|
200
|
+
|
|
201
|
+
Anchors an Audit Trail receipt each time a Pollar transaction reaches `success`. It listens to Pollar's `onTransactionStateChange`, which Pollar emits for custodial, external, passkey and co-signed wallets. It is **not** emitted for x402 payments, which this adapter anchors itself. Returns a function that stops listening.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import { createNiriumAdapter, anchorOnTransactionSuccess } from "nirium-pollar-adapter";
|
|
205
|
+
|
|
206
|
+
const adapter = createNiriumAdapter({ signer });
|
|
207
|
+
const stop = anchorOnTransactionSuccess(pollar, adapter, {
|
|
208
|
+
onError: (err, hash) => console.error("anchor failed", hash, err),
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The receipt carries only `chain`, `network`, `hash` and `observedAt` (no app id), because what goes into IPFS is not deleted. Pollar replays the current state when you subscribe, so the function deduplicates by hash inside the process. It does not deduplicate across restarts: the same hash can be anchored twice. A failed anchor goes to `onError` and never throws into Pollar's listener; the hash can be retried when Pollar sends it again. Options: `chain` (default `"stellar"`), `tag` (default `"pollar-tx"`), `onError`.
|
|
213
|
+
|
|
214
|
+
Checked against `@pollar/core` 0.11.4 and 0.12.0 in the test suite.
|
|
215
|
+
|
|
216
|
+
**Live check, 2026-11-01, testnet.** `examples/spike-19/anchor-on-success.mjs` logs in to a Pollar testnet app, sends 1 XLM through `pollar.sendPayment`, and anchors the receipt. Transaction [`95717202...b7b`](https://horizon-testnet.stellar.org/transactions/95717202be514ed0ae6d59d88c5950d79ff94b40dad709a430691ad6c4449b7b) (successful, ledger 5506358, 1 payment op) produced Audit Trail receipt [`QmboKKkuwck3zvRx2bqnzUdDFkrEtc1VUHo6rrzm9nyBtD`](https://gateway.pinata.cloud/ipfs/QmboKKkuwck3zvRx2bqnzUdDFkrEtc1VUHo6rrzm9nyBtD). The record holds only `chain`, `network`, `hash` and `observedAt`, and `content_sha256` equals the sha-256 of that record as sent. This is a Nirium self-test on testnet, not third-party use.
|
|
217
|
+
|
|
140
218
|
### Paying from a browser
|
|
141
219
|
|
|
142
220
|
Three server-side settings are not optional, and all three fail with messages
|
|
@@ -155,19 +233,33 @@ Pollar side: allowlist the USDC SAC with the `transfer` function under
|
|
|
155
233
|
**Treasury → Auth Policy**. Until a contract is listed, every custodial signing
|
|
156
234
|
request is rejected.
|
|
157
235
|
|
|
236
|
+
## How this relates to Pollar's `AdapterFn` pattern
|
|
237
|
+
|
|
238
|
+
Pollar's own adapters (for example the Trustless Work one in its demo) follow the `AdapterFn` pattern from `@pollar/core`: each function returns `{ unsignedTransaction }`, the functions are registered on `PollarProvider` through `adapters={{ ... }}`, and the hook made by `createPollarAdapterHook` signs that transaction with the user's wallet and submits it to the network (`signAndSubmitTx`).
|
|
239
|
+
|
|
240
|
+
This package does not follow that pattern, on purpose. An x402 payment is not a transaction that gets submitted. The user signs a Soroban authorization entry, it travels to the seller in a header, and the x402 facilitator settles it. If an adapter returned it as `unsignedTransaction`, the hook would submit it to the network by itself. So `createNiriumAdapter` runs the payment itself (it negotiates the 402, signs through `createPollarSigner` and retries), and anchoring is a plain HTTP call.
|
|
241
|
+
|
|
242
|
+
In practice:
|
|
243
|
+
|
|
244
|
+
- You use `createNiriumAdapter` directly. It is not registered under `PollarProvider adapters`, and there is no `createPollarAdapterHook` hook for it.
|
|
245
|
+
- Nirium operations that do return an unsigned transaction (treasury, payouts) are not exposed here as `AdapterFn`s. They are invite-only on mainnet and outside the scope of this package.
|
|
246
|
+
- A registry-pattern version of the payment flow is not shipped. Whether one is possible depends on how an adapter could hand back a signed authorization entry instead of a transaction. That is an open design question, not a plan.
|
|
247
|
+
|
|
248
|
+
Checked on 2026-10-12 against the published `@pollar/core` 0.11.4 and `@pollar/react` 0.11.4 packages, not their docs. CI runs a contract test against the real `@pollar/core` 0.11.4 (`test/pollar-contract.test.mjs` and a compile-time check in `test/pollar-contract.types.ts`), so a change in the shape this package relies on fails the build.
|
|
249
|
+
|
|
158
250
|
## Scope
|
|
159
251
|
|
|
160
252
|
| | |
|
|
161
253
|
|---|---|
|
|
162
254
|
| x402 Settlement | ✅ mainnet |
|
|
163
255
|
| Audit Trail (IPFS) | ✅ mainnet |
|
|
164
|
-
| Treasury vault (DeFindex, client-owned)
|
|
165
|
-
| Treasury vault
|
|
166
|
-
| Nirium's own NiriumVault | audit-gated
|
|
167
|
-
| MPP session channels | audit-gated
|
|
256
|
+
| Treasury vault (DeFindex, client-owned), Nirium signs and executes | ✅ mainnet, invite-only during legal review |
|
|
257
|
+
| Treasury vault, propose only, you sign | ✅ mainnet, public, no invite required (`POST /api/treasury/rebalance/propose`, not yet wrapped by this adapter) |
|
|
258
|
+
| Nirium's own NiriumVault | audit-gated, testnet only |
|
|
259
|
+
| MPP session channels | audit-gated, testnet only |
|
|
168
260
|
|
|
169
261
|
Nirium never holds customer funds. The user's signature is the authorization; regulated partners execute any financial settlement.
|
|
170
262
|
|
|
171
263
|
## License
|
|
172
264
|
|
|
173
|
-
|
|
265
|
+
Apache-2.0: see [LICENSE](./LICENSE).
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,47 @@ export interface PollarSignerOptions {
|
|
|
64
64
|
export declare function createPollarSigner(pollar: PollarLikeClient, opts?: PollarSignerOptions): ClientStellarSigner;
|
|
65
65
|
/** ¿Este signer ya puede pagar? Útil para deshabilitar el botón en la UI. */
|
|
66
66
|
export declare function canSignX402(pollar: PollarLikeClient): boolean;
|
|
67
|
+
export interface ActivateWalletOptions {
|
|
68
|
+
/** Secret key de Pollar (sec_testnet_… / sec_mainnet_…). SOLO backend — nunca la mandes al navegador. */
|
|
69
|
+
secretKey: string;
|
|
70
|
+
/** Base URL del servidor de Pollar. Default: https://server.api.pollar.xyz. */
|
|
71
|
+
baseUrl?: string;
|
|
72
|
+
/** fetch a envolver (para tests o runtimes sin fetch global). */
|
|
73
|
+
fetchImpl?: typeof fetch;
|
|
74
|
+
}
|
|
75
|
+
export interface ActivateWalletResult {
|
|
76
|
+
/** `true` si esta llamada fondeó la reserva; `false` si ya estaba fondeada (idempotente, HTTP 409). */
|
|
77
|
+
activated: boolean;
|
|
78
|
+
/** Reserva de XLM fondeada, tal como la reporta Pollar. Solo viene cuando `activated` es `true` en esta llamada. */
|
|
79
|
+
amount?: string;
|
|
80
|
+
/** `true` si Pollar encoló la petición (HTTP 202, wallet co-firmada o self-custody): el usuario la aprueba en su próxima sesión. */
|
|
81
|
+
queued?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** Pollar rechazó la activación con un código que no es "ya estaba activa". */
|
|
84
|
+
export declare class PollarActivationError extends Error {
|
|
85
|
+
/** El `code` que mandó Pollar (p.ej. "WALLET_NOT_FOUND", "FORBIDDEN"), o "UNKNOWN" si no vino. */
|
|
86
|
+
readonly code: string;
|
|
87
|
+
/** El status HTTP real de la respuesta. */
|
|
88
|
+
readonly status: number;
|
|
89
|
+
constructor(message: string,
|
|
90
|
+
/** El `code` que mandó Pollar (p.ej. "WALLET_NOT_FOUND", "FORBIDDEN"), o "UNKNOWN" si no vino. */
|
|
91
|
+
code: string,
|
|
92
|
+
/** El status HTTP real de la respuesta. */
|
|
93
|
+
status: number);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fondea la reserva de XLM on-chain de una wallet de Pollar en modo Deferred
|
|
97
|
+
* (`POST /v3/wallets/fund`). Llamar SOLO desde tu backend — la secret key
|
|
98
|
+
* nunca debe llegar al navegador.
|
|
99
|
+
*
|
|
100
|
+
* Cuándo llamarla: no hay un "evento de negocio" natural en un flujo x402 puro
|
|
101
|
+
* como si lo hay en KYC — el disparador razonable es justo después del login,
|
|
102
|
+
* antes de mostrar el botón de pago, para que la primera petición del usuario
|
|
103
|
+
* no se tope con una cuenta a medio activar. Si tu app ya cobra sin problema
|
|
104
|
+
* con la wallet a 0 XLM (el caso común, ver la nota arriba), puedes no
|
|
105
|
+
* llamarla nunca; queda disponible para cuando sí la necesites.
|
|
106
|
+
*/
|
|
107
|
+
export declare function activateWallet(publicKey: string, options: ActivateWalletOptions): Promise<ActivateWalletResult>;
|
|
67
108
|
export interface NiriumAdapterConfig {
|
|
68
109
|
/** Signer SEP-43 — normalmente createPollarSigner(pollarClient). */
|
|
69
110
|
signer: ClientStellarSigner;
|
|
@@ -97,3 +138,22 @@ export declare function createNiriumAdapter(config: NiriumAdapterConfig): {
|
|
|
97
138
|
getCetesRate: () => Promise<number | null>;
|
|
98
139
|
};
|
|
99
140
|
export type NiriumAdapter = ReturnType<typeof createNiriumAdapter>;
|
|
141
|
+
/** Lo unico que se necesita del cliente de Pollar. */
|
|
142
|
+
export interface PollarTransactionEvents {
|
|
143
|
+
onTransactionStateChange?: (cb: (state: any) => void) => () => void;
|
|
144
|
+
}
|
|
145
|
+
export interface AnchorOnSuccessOptions {
|
|
146
|
+
/** Cadena que se escribe en el recibo. Default: "stellar". */
|
|
147
|
+
chain?: string;
|
|
148
|
+
/** Etiqueta del recibo en Audit Trail. Default: "pollar-tx". */
|
|
149
|
+
tag?: string;
|
|
150
|
+
/** Reloj, para pruebas. Default: Date.now. */
|
|
151
|
+
now?: () => number;
|
|
152
|
+
/** Se llama si el anclaje falla. El listener de Pollar nunca lanza. */
|
|
153
|
+
onError?: (error: unknown, hash: string) => void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Ancla un recibo en Audit Trail cada vez que una transaccion de Pollar llega a
|
|
157
|
+
* `success`. Devuelve la funcion para dejar de escuchar.
|
|
158
|
+
*/
|
|
159
|
+
export declare function anchorOnTransactionSuccess(pollar: PollarTransactionEvents, adapter: Pick<NiriumAdapter, "anchorAuditRecord" | "network">, options?: AnchorOnSuccessOptions): () => void;
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// ───────────────────────────────────────────────────────────────────────────
|
|
31
31
|
import { x402Client as X402ClientClass, wrapFetchWithPayment } from "@x402/fetch";
|
|
32
32
|
import { ExactStellarScheme } from "@x402/stellar/exact/client";
|
|
33
|
-
import { Address, rpc, xdr } from "@stellar/stellar-sdk";
|
|
33
|
+
import { Address, StrKey, rpc, xdr } from "@stellar/stellar-sdk";
|
|
34
34
|
const DEFAULTS = {
|
|
35
35
|
network: "stellar:testnet",
|
|
36
36
|
testnetAgent: "https://nirium-agent.fly.dev",
|
|
@@ -209,6 +209,66 @@ export function createPollarSigner(pollar, opts = {}) {
|
|
|
209
209
|
export function canSignX402(pollar) {
|
|
210
210
|
return typeof pollar.signAuthEntry === "function";
|
|
211
211
|
}
|
|
212
|
+
/** Pollar rechazó la activación con un código que no es "ya estaba activa". */
|
|
213
|
+
export class PollarActivationError extends Error {
|
|
214
|
+
code;
|
|
215
|
+
status;
|
|
216
|
+
constructor(message,
|
|
217
|
+
/** El `code` que mandó Pollar (p.ej. "WALLET_NOT_FOUND", "FORBIDDEN"), o "UNKNOWN" si no vino. */
|
|
218
|
+
code,
|
|
219
|
+
/** El status HTTP real de la respuesta. */
|
|
220
|
+
status) {
|
|
221
|
+
super(message);
|
|
222
|
+
this.code = code;
|
|
223
|
+
this.status = status;
|
|
224
|
+
this.name = "PollarActivationError";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Fondea la reserva de XLM on-chain de una wallet de Pollar en modo Deferred
|
|
229
|
+
* (`POST /v3/wallets/fund`). Llamar SOLO desde tu backend — la secret key
|
|
230
|
+
* nunca debe llegar al navegador.
|
|
231
|
+
*
|
|
232
|
+
* Cuándo llamarla: no hay un "evento de negocio" natural en un flujo x402 puro
|
|
233
|
+
* como si lo hay en KYC — el disparador razonable es justo después del login,
|
|
234
|
+
* antes de mostrar el botón de pago, para que la primera petición del usuario
|
|
235
|
+
* no se tope con una cuenta a medio activar. Si tu app ya cobra sin problema
|
|
236
|
+
* con la wallet a 0 XLM (el caso común, ver la nota arriba), puedes no
|
|
237
|
+
* llamarla nunca; queda disponible para cuando sí la necesites.
|
|
238
|
+
*/
|
|
239
|
+
export async function activateWallet(publicKey, options) {
|
|
240
|
+
if (!StrKey.isValidEd25519PublicKey(publicKey)) {
|
|
241
|
+
throw new Error(`activateWallet: "${publicKey}" no es una dirección Stellar G... válida.`);
|
|
242
|
+
}
|
|
243
|
+
const baseUrl = (options.baseUrl ?? "https://server.api.pollar.xyz").replace(/\/+$/, "");
|
|
244
|
+
const doFetch = options.fetchImpl ?? fetch;
|
|
245
|
+
const res = await doFetch(`${baseUrl}/v3/wallets/fund`, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
headers: {
|
|
248
|
+
"content-type": "application/json",
|
|
249
|
+
"x-pollar-api-key": options.secretKey,
|
|
250
|
+
},
|
|
251
|
+
body: JSON.stringify({ publicKey }),
|
|
252
|
+
});
|
|
253
|
+
let body = {};
|
|
254
|
+
try {
|
|
255
|
+
body = await res.json();
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
// Cuerpo vacío o no-JSON — se maneja abajo con el status solo.
|
|
259
|
+
}
|
|
260
|
+
if (res.status === 200 && body?.success !== false) {
|
|
261
|
+
// Pollar v3 devuelve content.startingBalance (verificado en testnet 2026-10-31); `amount` era el nombre de v1.
|
|
262
|
+
return { activated: true, amount: body?.content?.startingBalance ?? body?.content?.amount };
|
|
263
|
+
}
|
|
264
|
+
if (res.status === 202) {
|
|
265
|
+
return { activated: false, queued: true };
|
|
266
|
+
}
|
|
267
|
+
if (res.status === 409) {
|
|
268
|
+
return { activated: false };
|
|
269
|
+
}
|
|
270
|
+
throw new PollarActivationError(`Pollar rechazó la activación de ${publicKey}: HTTP ${res.status} ${body?.code ?? "(sin código)"}`, body?.code ?? "UNKNOWN", res.status);
|
|
271
|
+
}
|
|
212
272
|
export function createNiriumAdapter(config) {
|
|
213
273
|
const network = config.network ?? DEFAULTS.network;
|
|
214
274
|
const agentBaseUrl = (config.agentBaseUrl ??
|
|
@@ -315,3 +375,40 @@ export function createNiriumAdapter(config) {
|
|
|
315
375
|
getCetesRate,
|
|
316
376
|
};
|
|
317
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Ancla un recibo en Audit Trail cada vez que una transaccion de Pollar llega a
|
|
380
|
+
* `success`. Devuelve la funcion para dejar de escuchar.
|
|
381
|
+
*/
|
|
382
|
+
export function anchorOnTransactionSuccess(pollar, adapter, options = {}) {
|
|
383
|
+
if (typeof pollar.onTransactionStateChange !== "function") {
|
|
384
|
+
throw new Error("anchorOnTransactionSuccess: este cliente de Pollar no tiene onTransactionStateChange.");
|
|
385
|
+
}
|
|
386
|
+
const seen = new Set();
|
|
387
|
+
const now = options.now ?? Date.now;
|
|
388
|
+
return pollar.onTransactionStateChange((state) => {
|
|
389
|
+
if (state?.step !== "success" || typeof state.hash !== "string" || !state.hash)
|
|
390
|
+
return;
|
|
391
|
+
const hash = state.hash;
|
|
392
|
+
if (seen.has(hash))
|
|
393
|
+
return;
|
|
394
|
+
seen.add(hash);
|
|
395
|
+
const record = {
|
|
396
|
+
chain: options.chain ?? "stellar",
|
|
397
|
+
network: isPubnet(adapter.network) ? "mainnet" : "testnet",
|
|
398
|
+
hash,
|
|
399
|
+
observedAt: new Date(now()).toISOString(),
|
|
400
|
+
};
|
|
401
|
+
Promise.resolve()
|
|
402
|
+
.then(() => adapter.anchorAuditRecord({ record, txHash: hash, tag: options.tag ?? "pollar-tx" }))
|
|
403
|
+
.catch((err) => {
|
|
404
|
+
// Si falla, se permite reintentar con el mismo hash cuando Pollar lo reenvie.
|
|
405
|
+
seen.delete(hash);
|
|
406
|
+
try {
|
|
407
|
+
options.onError?.(err, hash);
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
// un onError que lanza no debe romper el listener de Pollar
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}
|
|
@@ -8,11 +8,16 @@
|
|
|
8
8
|
// - const signer = createEd25519Signer(secret, network);
|
|
9
9
|
// + const signer = createPollarSigner(pollarClient);
|
|
10
10
|
//
|
|
11
|
-
// Uso:
|
|
11
|
+
// Uso (default = testnet, seguro, sin gasto real):
|
|
12
12
|
// NIRIUM_DEMO_SECRET=S... node examples/pay-with-keypair.mjs
|
|
13
|
-
// NIRIUM_DEMO_SECRET=S... NIRIUM_NETWORK=stellar:testnet node examples/pay-with-keypair.mjs
|
|
14
13
|
//
|
|
15
|
-
//
|
|
14
|
+
// Contra mainnet (gasta USDC REAL, 0.05 por llamada a market) — opt-in explícito:
|
|
15
|
+
// NIRIUM_DEMO_SECRET=S... NIRIUM_NETWORK=stellar:pubnet node examples/pay-with-keypair.mjs
|
|
16
|
+
//
|
|
17
|
+
// Update, 2026-10-24: el default de este archivo era "stellar:pubnet" —
|
|
18
|
+
// quien corriera el primer comando de uso tal cual, sin leer el resto del
|
|
19
|
+
// comentario, gastaba USDC real sin darse cuenta. El default ahora es
|
|
20
|
+
// testnet; pubnet pide la variable de entorno a propósito.
|
|
16
21
|
//
|
|
17
22
|
// Usa getPremiumMarket(), no getPremiumSignals(): desde el 6-ago-2026 el box
|
|
18
23
|
// de mainnet responde 501 a /premium/signals ANTES de cobrar (no hay loop
|
|
@@ -29,7 +34,7 @@ if (!secret) {
|
|
|
29
34
|
process.exit(1);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
const network = process.env.NIRIUM_NETWORK ?? "stellar:
|
|
37
|
+
const network = process.env.NIRIUM_NETWORK ?? "stellar:testnet";
|
|
33
38
|
const signer = createEd25519Signer(secret, network);
|
|
34
39
|
const nirium = createNiriumAdapter({ signer, network });
|
|
35
40
|
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Live check for anchorOnTransactionSuccess: one Pollar login, one real testnet
|
|
2
|
+
// payment, one Audit Trail receipt for it.
|
|
3
|
+
//
|
|
4
|
+
// What it does:
|
|
5
|
+
// 1. Logs in to a Pollar TESTNET app with an email code (you type the code).
|
|
6
|
+
// 2. Gives the Pollar wallet some testnet XLM from a throwaway key funded by
|
|
7
|
+
// friendbot (the throwaway key is never printed or saved).
|
|
8
|
+
// 3. Sends 1 XLM back through Pollar's own pipeline (pollar.sendPayment), which
|
|
9
|
+
// makes onTransactionStateChange report { step: "success", hash }.
|
|
10
|
+
// 4. anchorOnTransactionSuccess anchors { chain, network, hash, observedAt } in
|
|
11
|
+
// Audit Trail. The script prints the tx hash and the CID.
|
|
12
|
+
//
|
|
13
|
+
// Testnet only. The receipt is a Nirium self-test: never count it as third-party use.
|
|
14
|
+
//
|
|
15
|
+
// Env:
|
|
16
|
+
// POLLAR_PUBLISHABLE_KEY=pub_testnet_... (public key of a testnet Pollar app)
|
|
17
|
+
// POLLAR_LOGIN_EMAIL=you@example.com
|
|
18
|
+
// POLLAR_CODE_FILE=/path/to/file (optional; if unset, the code is asked in the terminal)
|
|
19
|
+
// POLLAR_ORIGIN=http://localhost:3000 (optional; must be an origin allowed in the Pollar
|
|
20
|
+
// app's settings, or session creation fails with ORIGIN_NOT_ALLOWED)
|
|
21
|
+
//
|
|
22
|
+
// Run from the repo root after `npm run build`:
|
|
23
|
+
// node examples/spike-19/anchor-on-success.mjs
|
|
24
|
+
|
|
25
|
+
import "./browser-polyfill.mjs";
|
|
26
|
+
|
|
27
|
+
import { PollarClient, createMemoryAdapter } from "@pollar/core";
|
|
28
|
+
import { Keypair, Horizon, TransactionBuilder, Operation, Asset, Networks, BASE_FEE } from "@stellar/stellar-sdk";
|
|
29
|
+
import { createPollarSigner, createNiriumAdapter, anchorOnTransactionSuccess } from "../../dist/index.js";
|
|
30
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
31
|
+
import { createInterface } from "node:readline/promises";
|
|
32
|
+
|
|
33
|
+
const HORIZON = "https://horizon-testnet.stellar.org";
|
|
34
|
+
|
|
35
|
+
function waitForAuthStep(pollar, targetStep) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const off = pollar.onAuthStateChange((state) => {
|
|
38
|
+
console.log("[auth]", state.step);
|
|
39
|
+
if (state.step === targetStep) {
|
|
40
|
+
off();
|
|
41
|
+
resolve(state);
|
|
42
|
+
} else if (state.step === "error") {
|
|
43
|
+
off();
|
|
44
|
+
reject(new Error(`Pollar auth error: ${state.message} [${state.errorCode}]`));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function readCode() {
|
|
51
|
+
const file = process.env.POLLAR_CODE_FILE;
|
|
52
|
+
if (file) {
|
|
53
|
+
console.log(`Waiting for the 6-digit code in ${file} ...`);
|
|
54
|
+
const deadline = Date.now() + 5 * 60 * 1000;
|
|
55
|
+
while (Date.now() < deadline) {
|
|
56
|
+
try {
|
|
57
|
+
const raw = (await readFile(file, "utf8")).trim();
|
|
58
|
+
if (raw) {
|
|
59
|
+
await unlink(file).catch(() => {});
|
|
60
|
+
return raw;
|
|
61
|
+
}
|
|
62
|
+
} catch {}
|
|
63
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Timed out waiting for the code file.");
|
|
66
|
+
}
|
|
67
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
68
|
+
const code = (await rl.question("6-digit code from your email: ")).trim();
|
|
69
|
+
rl.close();
|
|
70
|
+
return code;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function giveTestnetXlm(address) {
|
|
74
|
+
const funder = Keypair.random();
|
|
75
|
+
const fb = await fetch(`https://friendbot.stellar.org?addr=${funder.publicKey()}`);
|
|
76
|
+
if (!fb.ok) throw new Error(`friendbot HTTP ${fb.status}`);
|
|
77
|
+
const server = new Horizon.Server(HORIZON);
|
|
78
|
+
const account = await server.loadAccount(funder.publicKey());
|
|
79
|
+
const exists = (await fetch(`${HORIZON}/accounts/${address}`)).status === 200;
|
|
80
|
+
const op = exists
|
|
81
|
+
? Operation.payment({ destination: address, asset: Asset.native(), amount: "5" })
|
|
82
|
+
: Operation.createAccount({ destination: address, startingBalance: "5" });
|
|
83
|
+
const tx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.TESTNET })
|
|
84
|
+
.addOperation(op)
|
|
85
|
+
.setTimeout(60)
|
|
86
|
+
.build();
|
|
87
|
+
tx.sign(funder);
|
|
88
|
+
await server.submitTransaction(tx);
|
|
89
|
+
console.log(`Wallet ${exists ? "topped up with" : "created on-chain with"} 5 testnet XLM.`);
|
|
90
|
+
return funder.publicKey();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function main() {
|
|
94
|
+
const apiKey = process.env.POLLAR_PUBLISHABLE_KEY;
|
|
95
|
+
const email = process.env.POLLAR_LOGIN_EMAIL;
|
|
96
|
+
if (!apiKey?.startsWith("pub_testnet_") || !email) {
|
|
97
|
+
console.error("Set POLLAR_PUBLISHABLE_KEY (pub_testnet_...) and POLLAR_LOGIN_EMAIL first.");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const pollar = new PollarClient({ apiKey, stellarNetwork: "testnet", storage: createMemoryAdapter() });
|
|
102
|
+
await pollar.ready();
|
|
103
|
+
|
|
104
|
+
const enteringEmail = waitForAuthStep(pollar, "entering_email");
|
|
105
|
+
pollar.beginEmailLogin();
|
|
106
|
+
await enteringEmail;
|
|
107
|
+
const enteringCode = waitForAuthStep(pollar, "entering_code");
|
|
108
|
+
pollar.sendEmailCode(email);
|
|
109
|
+
await enteringCode;
|
|
110
|
+
const authenticated = waitForAuthStep(pollar, "authenticated");
|
|
111
|
+
pollar.verifyEmailCode(await readCode());
|
|
112
|
+
await authenticated;
|
|
113
|
+
|
|
114
|
+
const signer = createPollarSigner(pollar, { network: "stellar:testnet" });
|
|
115
|
+
console.log("Pollar wallet:", signer.address);
|
|
116
|
+
|
|
117
|
+
const nirium = createNiriumAdapter({
|
|
118
|
+
signer,
|
|
119
|
+
network: "stellar:testnet",
|
|
120
|
+
agentBaseUrl: "https://nirium-agent.fly.dev",
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Wrap the anchor call only to capture its result for this check.
|
|
124
|
+
let resolveAnchor;
|
|
125
|
+
let rejectAnchor;
|
|
126
|
+
const anchored = new Promise((res, rej) => {
|
|
127
|
+
resolveAnchor = res;
|
|
128
|
+
rejectAnchor = rej;
|
|
129
|
+
});
|
|
130
|
+
const watched = {
|
|
131
|
+
network: nirium.network,
|
|
132
|
+
anchorAuditRecord: async (input) => {
|
|
133
|
+
console.log("Anchoring:", JSON.stringify(input));
|
|
134
|
+
const out = await nirium.anchorAuditRecord(input);
|
|
135
|
+
resolveAnchor(out);
|
|
136
|
+
return out;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
const stop = anchorOnTransactionSuccess(pollar, watched, {
|
|
140
|
+
onError: (err, hash) => rejectAnchor(new Error(`anchor failed for ${hash}: ${err?.message ?? err}`)),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const funder = await giveTestnetXlm(signer.address);
|
|
144
|
+
|
|
145
|
+
console.log("Sending 1 XLM through Pollar ...");
|
|
146
|
+
const outcome = await pollar.sendPayment({
|
|
147
|
+
destination: funder,
|
|
148
|
+
amount: "1",
|
|
149
|
+
asset: { type: "native" },
|
|
150
|
+
});
|
|
151
|
+
console.log("sendPayment outcome:", outcome.status, outcome.hash ?? "");
|
|
152
|
+
|
|
153
|
+
const result = await Promise.race([
|
|
154
|
+
anchored,
|
|
155
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error("No anchor within 60 s.")), 60000)),
|
|
156
|
+
]);
|
|
157
|
+
stop();
|
|
158
|
+
|
|
159
|
+
console.log("\n=== RESULT ===");
|
|
160
|
+
console.log("tx hash:", outcome.hash);
|
|
161
|
+
console.log("check it:", `${HORIZON}/transactions/${outcome.hash}`);
|
|
162
|
+
console.log("anchor response:", JSON.stringify(result));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
main().catch((e) => {
|
|
166
|
+
console.error("FAILED:", e?.message ?? e);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Side-effect-only module. Must be the FIRST import in spike.mjs.
|
|
2
|
+
//
|
|
3
|
+
// @pollar/core computes `isBrowser = typeof window !== "undefined" && typeof
|
|
4
|
+
// localStorage !== "undefined"` as a module-level `var`, evaluated once when
|
|
5
|
+
// the module is first loaded — not re-checked per call. ES module `import`
|
|
6
|
+
// declarations are hoisted and all execute before the rest of a file's body,
|
|
7
|
+
// regardless of where `globalThis.window = ...` is textually written in that
|
|
8
|
+
// same file — so setting the globals inline above a static
|
|
9
|
+
// `import { PollarClient } from "@pollar/core"` has no effect: the import
|
|
10
|
+
// already ran first. A separate module, imported before @pollar/core (static
|
|
11
|
+
// imports run in the order they're written relative to each other), is what
|
|
12
|
+
// actually gets the globals in place before @pollar/core's module body runs.
|
|
13
|
+
// Pollar's publishable keys are domain-restricted: their backend checks the
|
|
14
|
+
// request's Origin header against an allowlist and returns 403
|
|
15
|
+
// ORIGIN_NOT_ALLOWED otherwise (confirmed against the real API below, not
|
|
16
|
+
// assumed). A real browser attaches Origin automatically on every
|
|
17
|
+
// cross-origin fetch; Node's fetch does not, and there's no PollarClient
|
|
18
|
+
// config knob to set it — so the fix has to be a global fetch monkey-patch
|
|
19
|
+
// that adds it only for calls to Pollar's own API host.
|
|
20
|
+
const ORIGIN = process.env.POLLAR_ORIGIN || "https://nirium.xyz";
|
|
21
|
+
const realFetch = globalThis.fetch;
|
|
22
|
+
globalThis.fetch = (input, init = {}) => {
|
|
23
|
+
const url = typeof input === "string" ? input : input?.url ?? String(input);
|
|
24
|
+
if (url.includes(".pollar.xyz")) {
|
|
25
|
+
const headers = new Headers(init.headers ?? (typeof input === "object" ? input.headers : undefined));
|
|
26
|
+
headers.set("Origin", ORIGIN);
|
|
27
|
+
init = { ...init, headers };
|
|
28
|
+
}
|
|
29
|
+
return realFetch(input, init);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
globalThis.window = globalThis.window ?? {
|
|
33
|
+
// Used for the visibilitychange-driven token-refresh scheduler. A no-op
|
|
34
|
+
// is fine here — this script is a single short-lived run, not a long-lived
|
|
35
|
+
// tab that needs to catch up on missed background refreshes.
|
|
36
|
+
addEventListener: () => {},
|
|
37
|
+
removeEventListener: () => {},
|
|
38
|
+
};
|
|
39
|
+
if (typeof globalThis.localStorage === "undefined") {
|
|
40
|
+
const backing = new Map();
|
|
41
|
+
globalThis.localStorage = {
|
|
42
|
+
getItem: (k) => backing.get(k) ?? null,
|
|
43
|
+
setItem: (k, v) => void backing.set(k, String(v)),
|
|
44
|
+
removeItem: (k) => void backing.delete(k),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Spike for pollar-apps#19 — "Nirium adapter: pay per API request with a
|
|
2
|
+
// Pollar account (x402) and ship demo.pollar.xyz/adapters/nirium".
|
|
3
|
+
//
|
|
4
|
+
// Blocking criterion from the issue: one Pollar social-login session,
|
|
5
|
+
// createPollarSigner() from nirium-pollar-adapter, one x402 request paid
|
|
6
|
+
// and settled against an x402-enabled endpoint, transaction hash captured.
|
|
7
|
+
//
|
|
8
|
+
// Rewritten against the REAL @pollar/core@0.11.2 API, verified against its
|
|
9
|
+
// .d.ts before writing a line of this: PollarClient's auth surface is
|
|
10
|
+
// event-driven (sendEmailCode/verifyEmailCode return void, not Promise) —
|
|
11
|
+
// state comes through onAuthStateChange(cb) as a discriminated union keyed
|
|
12
|
+
// by `step` (idle → sending_email → entering_code → verifying_email_code →
|
|
13
|
+
// authenticating → authenticated | error). The previous version of this
|
|
14
|
+
// script assumed a Promise-returning login()/verifyEmailCode() pair that
|
|
15
|
+
// does not exist in the installed SDK and would have hung or thrown.
|
|
16
|
+
//
|
|
17
|
+
// Still not fully scriptable: a human has to read the 6-digit code from
|
|
18
|
+
// their inbox. This version doesn't block on stdin (there's no live
|
|
19
|
+
// terminal attached when run in the background) — it polls a code file
|
|
20
|
+
// instead, so the OTP can be dropped in from a separate step once it
|
|
21
|
+
// arrives by email.
|
|
22
|
+
//
|
|
23
|
+
// Run with: node spike.mjs
|
|
24
|
+
//
|
|
25
|
+
// Env required (get PUB_KEY from https://dashboard.pollar.xyz → Build → API Keys):
|
|
26
|
+
// POLLAR_PUBLISHABLE_KEY=pub_testnet_...
|
|
27
|
+
// POLLAR_LOGIN_EMAIL=you@example.com
|
|
28
|
+
// POLLAR_CODE_FILE=/tmp/pollar-otp-code.txt (optional, this is the default)
|
|
29
|
+
|
|
30
|
+
// Must be the first import — see browser-polyfill.mjs for why this can't
|
|
31
|
+
// just be inline code above the @pollar/core import in this same file.
|
|
32
|
+
import "./browser-polyfill.mjs";
|
|
33
|
+
|
|
34
|
+
import { PollarClient, createMemoryAdapter } from "@pollar/core";
|
|
35
|
+
import { createPollarSigner, createNiriumAdapter } from "../../dist/index.js";
|
|
36
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
37
|
+
|
|
38
|
+
const CODE_FILE = process.env.POLLAR_CODE_FILE || "/tmp/pollar-otp-code.txt";
|
|
39
|
+
const CODE_POLL_TIMEOUT_MS = 5 * 60 * 1000; // 5 min to relay the OTP
|
|
40
|
+
const CODE_POLL_INTERVAL_MS = 2000;
|
|
41
|
+
|
|
42
|
+
/** Resolve once the auth state reaches `targetStep`, reject on `step: 'error'`. */
|
|
43
|
+
function waitForAuthStep(pollar, targetStep) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const unsubscribe = pollar.onAuthStateChange((state) => {
|
|
46
|
+
console.log("[auth state]", state.step);
|
|
47
|
+
if (state.step === targetStep) {
|
|
48
|
+
unsubscribe();
|
|
49
|
+
resolve(state);
|
|
50
|
+
} else if (state.step === "error") {
|
|
51
|
+
unsubscribe();
|
|
52
|
+
reject(new Error(`Pollar auth error (was expecting "${targetStep}"): ${state.message} [${state.errorCode}]`));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Poll CODE_FILE until it has content, then delete it so a stale code can't be reused. */
|
|
59
|
+
async function waitForCodeFile() {
|
|
60
|
+
console.log(`Waiting for the 6-digit code in ${CODE_FILE} (write it there once you have it)...`);
|
|
61
|
+
const deadline = Date.now() + CODE_POLL_TIMEOUT_MS;
|
|
62
|
+
while (Date.now() < deadline) {
|
|
63
|
+
try {
|
|
64
|
+
const raw = (await readFile(CODE_FILE, "utf8")).trim();
|
|
65
|
+
if (raw) {
|
|
66
|
+
await unlink(CODE_FILE).catch(() => {});
|
|
67
|
+
return raw;
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
// File doesn't exist yet — keep polling.
|
|
71
|
+
}
|
|
72
|
+
await new Promise((r) => setTimeout(r, CODE_POLL_INTERVAL_MS));
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`Timed out after ${CODE_POLL_TIMEOUT_MS}ms waiting for ${CODE_FILE}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function main() {
|
|
78
|
+
const apiKey = process.env.POLLAR_PUBLISHABLE_KEY;
|
|
79
|
+
const email = process.env.POLLAR_LOGIN_EMAIL;
|
|
80
|
+
if (!apiKey || !email) {
|
|
81
|
+
console.error("Set POLLAR_PUBLISHABLE_KEY and POLLAR_LOGIN_EMAIL first.");
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const pollar = new PollarClient({
|
|
86
|
+
apiKey,
|
|
87
|
+
stellarNetwork: "testnet",
|
|
88
|
+
storage: createMemoryAdapter(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await pollar.ready();
|
|
92
|
+
|
|
93
|
+
// sendEmailCode() throws PollarFlowError unless the current step is
|
|
94
|
+
// 'entering_email' — that step only exists after beginEmailLogin() runs
|
|
95
|
+
// (idle -> creating_session -> entering_email). Skipping straight to
|
|
96
|
+
// sendEmailCode() is the second bug the server-side no-op guard was
|
|
97
|
+
// masking in the previous version of this script.
|
|
98
|
+
console.log("Starting email login...");
|
|
99
|
+
const enteringEmail = waitForAuthStep(pollar, "entering_email");
|
|
100
|
+
pollar.beginEmailLogin();
|
|
101
|
+
await enteringEmail;
|
|
102
|
+
|
|
103
|
+
console.log(`Sending OTP to ${email}...`);
|
|
104
|
+
const enteringCode = waitForAuthStep(pollar, "entering_code");
|
|
105
|
+
pollar.sendEmailCode(email);
|
|
106
|
+
await enteringCode;
|
|
107
|
+
|
|
108
|
+
const code = await waitForCodeFile();
|
|
109
|
+
|
|
110
|
+
console.log("Verifying code...");
|
|
111
|
+
const authenticated = waitForAuthStep(pollar, "authenticated");
|
|
112
|
+
pollar.verifyEmailCode(code);
|
|
113
|
+
const authState = await authenticated;
|
|
114
|
+
console.log("Authenticated. verified:", authState.verified);
|
|
115
|
+
|
|
116
|
+
const signer = createPollarSigner(pollar, { network: "stellar:testnet" });
|
|
117
|
+
console.log("Signer address:", signer.address);
|
|
118
|
+
|
|
119
|
+
const nirium = createNiriumAdapter({
|
|
120
|
+
signer,
|
|
121
|
+
network: "stellar:testnet",
|
|
122
|
+
agentBaseUrl: "https://nirium-agent.fly.dev",
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
console.log("Requesting /api/v1/premium/signals (expect 402, then auto-pay + retry)...");
|
|
126
|
+
// Using x402Fetch directly (not the getPremiumSignals() shortcut) so we can
|
|
127
|
+
// inspect the raw response headers — the settlement tx hash comes from
|
|
128
|
+
// @x402/express's own machinery, not from Nirium's code, and the exact
|
|
129
|
+
// header name isn't pinned down anywhere in this repo. Log everything and
|
|
130
|
+
// find it empirically rather than guessing a header key.
|
|
131
|
+
const res = await nirium.x402Fetch(`${nirium.agentBaseUrl}/api/v1/premium/signals`);
|
|
132
|
+
console.log("Response status:", res.status);
|
|
133
|
+
console.log("Response headers:");
|
|
134
|
+
for (const [key, value] of res.headers.entries()) {
|
|
135
|
+
console.log(` ${key}: ${value}`);
|
|
136
|
+
}
|
|
137
|
+
const body = await res.json();
|
|
138
|
+
console.log("Body:", body);
|
|
139
|
+
|
|
140
|
+
console.log("Done. Find the settlement tx hash in the headers above, verify it resolves on stellar.expert before including it in the PR.");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
main().catch((err) => {
|
|
144
|
+
console.error("Spike failed:", err);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nirium-pollar-adapter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Nirium adapter for the Pollar SDK — x402 pay-per-request and IPFS audit anchoring using the wallet a user onboarded through Pollar. Signs SEP-43 auth entries; the facilitator sponsors network fees.",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Nirium adapter for the Pollar SDK — x402 pay-per-request and IPFS audit anchoring using the wallet a user onboarded through Pollar. Signs SEP-43 auth entries; the facilitator sponsors network fees. Includes Deferred-mode wallet activation (POST /v1/wallets/activate).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,24 +9,34 @@
|
|
|
9
9
|
"dist",
|
|
10
10
|
"examples"
|
|
11
11
|
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.12.0"
|
|
14
|
+
},
|
|
12
15
|
"scripts": {
|
|
13
16
|
"build": "tsc -p tsconfig.json",
|
|
14
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.contract.json",
|
|
18
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
15
20
|
},
|
|
16
21
|
"dependencies": {
|
|
17
|
-
"@stellar/stellar-sdk": "^
|
|
18
|
-
"@x402/core": "2.
|
|
19
|
-
"@x402/fetch": "2.
|
|
20
|
-
"@x402/stellar": "2.
|
|
22
|
+
"@stellar/stellar-sdk": "^16.4.1",
|
|
23
|
+
"@x402/core": "2.29.0",
|
|
24
|
+
"@x402/fetch": "2.29.0",
|
|
25
|
+
"@x402/stellar": "2.29.0"
|
|
21
26
|
},
|
|
22
27
|
"peerDependencies": {
|
|
23
|
-
"@pollar/core": ">=0.11.0"
|
|
28
|
+
"@pollar/core": ">=0.11.4 <0.13.0"
|
|
24
29
|
},
|
|
25
30
|
"peerDependenciesMeta": {
|
|
26
31
|
"@pollar/core": {
|
|
27
32
|
"optional": true
|
|
28
33
|
}
|
|
29
34
|
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@pollar/core": "0.11.4",
|
|
37
|
+
"@types/node": "^26.6.5",
|
|
38
|
+
"typescript": "^5.7.0"
|
|
39
|
+
},
|
|
30
40
|
"keywords": [
|
|
31
41
|
"nirium",
|
|
32
42
|
"pollar",
|
|
@@ -36,5 +46,12 @@
|
|
|
36
46
|
"adapter"
|
|
37
47
|
],
|
|
38
48
|
"homepage": "https://nirium.xyz",
|
|
39
|
-
"
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/nirium-protocol/nirium-pollar-adapter.git"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/nirium-protocol/nirium-pollar-adapter/issues"
|
|
55
|
+
},
|
|
56
|
+
"license": "Apache-2.0"
|
|
40
57
|
}
|