@render-foundation/utils 0.0.199 → 0.0.230
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/lib/cjs/assertSecrets.js +1 -2
- package/lib/cjs/assertSecrets.js.map +1 -1
- package/lib/cjs/backfiller.js +16 -16
- package/lib/cjs/backfiller.js.map +1 -1
- package/lib/cjs/burn/burnAnalysis.js +101 -0
- package/lib/cjs/burn/burnAnalysis.js.map +1 -0
- package/lib/cjs/burn/burnCalculations.js +140 -0
- package/lib/cjs/burn/burnCalculations.js.map +1 -0
- package/lib/cjs/client/onchain.js +3 -3
- package/lib/cjs/client/onchain.js.map +1 -1
- package/lib/cjs/client/pg/base.js +7 -7
- package/lib/cjs/client/pg/base.js.map +1 -1
- package/lib/cjs/client/pg/v1.js +31 -31
- package/lib/cjs/client/pg/v1.js.map +1 -1
- package/lib/cjs/client/pg/v2Client.js +244 -194
- package/lib/cjs/client/pg/v2Client.js.map +1 -1
- package/lib/cjs/client/pg/viewClient.js +6 -6
- package/lib/cjs/client/pg/viewClient.js.map +1 -1
- package/lib/cjs/client/price.js +3 -3
- package/lib/cjs/client/price.js.map +1 -1
- package/lib/cjs/client/render.js +10 -10
- package/lib/cjs/client/render.js.map +1 -1
- package/lib/cjs/client/squads.js +20 -10
- package/lib/cjs/client/squads.js.map +1 -1
- package/lib/cjs/client/trade.js +15 -12
- package/lib/cjs/client/trade.js.map +1 -1
- package/lib/cjs/client/wormhole.js +19 -9
- package/lib/cjs/client/wormhole.js.map +1 -1
- package/lib/cjs/errorReporter.js +1 -1
- package/lib/cjs/errorReporter.js.map +1 -1
- package/lib/cjs/index.js +19 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/src/assertSecrets.js.map +1 -1
- package/lib/esm/src/backfiller.js.map +1 -1
- package/lib/esm/src/burn/burnAnalysis.js +90 -0
- package/lib/esm/src/burn/burnAnalysis.js.map +1 -0
- package/lib/esm/src/burn/burnCalculations.js +124 -0
- package/lib/esm/src/burn/burnCalculations.js.map +1 -0
- package/lib/esm/src/client/onchain.js.map +1 -1
- package/lib/esm/src/client/pg/base.js.map +1 -1
- package/lib/esm/src/client/pg/v1.js.map +1 -1
- package/lib/esm/src/client/pg/v2Client.js +133 -91
- package/lib/esm/src/client/pg/v2Client.js.map +1 -1
- package/lib/esm/src/client/pg/viewClient.js.map +1 -1
- package/lib/esm/src/client/price.js.map +1 -1
- package/lib/esm/src/client/render.js.map +1 -1
- package/lib/esm/src/client/squads.js.map +1 -1
- package/lib/esm/src/client/trade.js +2 -2
- package/lib/esm/src/client/trade.js.map +1 -1
- package/lib/esm/src/client/wormhole.js.map +1 -1
- package/lib/esm/src/errorReporter.js.map +1 -1
- package/lib/esm/src/index.js +2 -5
- package/lib/esm/src/index.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/backfiller.d.ts.map +1 -1
- package/lib/types/src/burn/burnAnalysis.d.ts +51 -0
- package/lib/types/src/burn/burnAnalysis.d.ts.map +1 -0
- package/lib/types/src/burn/burnCalculations.d.ts +52 -0
- package/lib/types/src/burn/burnCalculations.d.ts.map +1 -0
- package/lib/types/src/client/onchain.d.ts +2 -1
- package/lib/types/src/client/onchain.d.ts.map +1 -1
- package/lib/types/src/client/pg/base.d.ts.map +1 -1
- package/lib/types/src/client/pg/v1.d.ts.map +1 -1
- package/lib/types/src/client/pg/v2Client.d.ts +23 -26
- package/lib/types/src/client/pg/v2Client.d.ts.map +1 -1
- package/lib/types/src/client/pg/viewClient.d.ts.map +1 -1
- package/lib/types/src/client/render.d.ts.map +1 -1
- package/lib/types/src/client/squads.d.ts.map +1 -1
- package/lib/types/src/client/trade.d.ts.map +1 -1
- package/lib/types/src/client/wormhole.d.ts +1 -1
- package/lib/types/src/client/wormhole.d.ts.map +1 -1
- package/lib/types/src/dbTypesV2.d.ts +13 -15
- package/lib/types/src/dbTypesV2.d.ts.map +1 -1
- package/lib/types/src/errorReporter.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +2 -2
- package/lib/types/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -310
- package/lib/cjs/client/dispersed.js +0 -123
- package/lib/cjs/client/dispersed.js.map +0 -1
- package/lib/esm/src/client/dispersed.js +0 -108
- package/lib/esm/src/client/dispersed.js.map +0 -1
- package/lib/types/src/client/dispersed.d.ts +0 -91
- package/lib/types/src/client/dispersed.d.ts.map +0 -1
package/CHANGELOG.md
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [3.10.2](https://github.com/StrataFoundation/strata/compare/v3.10.1...v3.10.2) (2022-08-10)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [3.10.0](https://github.com/StrataFoundation/strata/compare/v3.9.12...v3.10.0) (2022-08-04)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [3.9.5](https://github.com/StrataFoundation/strata/compare/v3.9.4...v3.9.5) (2022-07-26)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [3.9.3](https://github.com/StrataFoundation/strata/compare/v3.9.2...v3.9.3) (2022-07-25)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [3.9.0](https://github.com/StrataFoundation/strata/compare/v3.8.2...v3.9.0) (2022-07-11)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [3.8.2](https://github.com/StrataFoundation/strata/compare/v3.8.1...v3.8.2) (2022-06-19)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [3.8.1](https://github.com/StrataFoundation/strata/compare/v3.8.0...v3.8.1) (2022-06-18)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# [3.7.0](https://github.com/StrataFoundation/strata/compare/v3.5.5...v3.7.0) (2022-06-02)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Bug Fixes
|
|
66
|
-
|
|
67
|
-
* **transactions:** remove subscription if available ([#230](https://github.com/StrataFoundation/strata/issues/230)) ([e99f05c](https://github.com/StrataFoundation/strata/commit/e99f05c02dd1f0176c8303608ea4859c68774cf4))
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
## [3.6.1](https://github.com/StrataFoundation/strata/compare/v3.6.0...v3.6.1) (2022-05-21)
|
|
74
|
-
|
|
75
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## [3.5.7](https://github.com/StrataFoundation/strata/compare/v3.5.5...v3.5.7) (2022-05-07)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### Bug Fixes
|
|
85
|
-
|
|
86
|
-
* **transactions:** remove subscription if available ([#230](https://github.com/StrataFoundation/strata/issues/230)) ([e99f05c](https://github.com/StrataFoundation/strata/commit/e99f05c02dd1f0176c8303608ea4859c68774cf4))
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## [3.5.5](https://github.com/StrataFoundation/strata/compare/v3.5.4...v3.5.5) (2022-04-19)
|
|
93
|
-
|
|
94
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## [3.5.4](https://github.com/StrataFoundation/strata/compare/v3.5.2...v3.5.4) (2022-04-18)
|
|
101
|
-
|
|
102
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
## [3.5.3](https://github.com/StrataFoundation/strata/compare/v3.5.2...v3.5.3) (2022-04-18)
|
|
109
|
-
|
|
110
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
## [3.4.5](https://github.com/StrataFoundation/strata/compare/v3.4.1...v3.4.5) (2022-03-29)
|
|
117
|
-
|
|
118
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
## [3.4.3](https://github.com/StrataFoundation/strata/compare/v3.4.1...v3.4.3) (2022-03-26)
|
|
125
|
-
|
|
126
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## [3.4.2](https://github.com/StrataFoundation/strata/compare/v3.4.1...v3.4.2) (2022-03-26)
|
|
133
|
-
|
|
134
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
## [3.4.1](https://github.com/StrataFoundation/strata/compare/v3.4.0...v3.4.1) (2022-03-25)
|
|
141
|
-
|
|
142
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
# [3.4.0](https://github.com/StrataFoundation/strata/compare/v3.3.6...v3.4.0) (2022-03-25)
|
|
149
|
-
|
|
150
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
## [3.3.6](https://github.com/StrataFoundation/strata/compare/v3.3.4...v3.3.6) (2022-03-16)
|
|
157
|
-
|
|
158
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## [3.3.5](https://github.com/StrataFoundation/strata/compare/v3.3.4...v3.3.5) (2022-03-16)
|
|
165
|
-
|
|
166
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
## [3.3.4](https://github.com/StrataFoundation/strata/compare/v3.3.2...v3.3.4) (2022-03-16)
|
|
173
|
-
|
|
174
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
## [3.3.3](https://github.com/StrataFoundation/strata/compare/v3.3.2...v3.3.3) (2022-03-16)
|
|
181
|
-
|
|
182
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# [3.3.0](https://github.com/StrataFoundation/strata/compare/v3.2.6...v3.3.0) (2022-03-04)
|
|
189
|
-
|
|
190
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
## [3.2.6](https://github.com/StrataFoundation/strata/compare/v3.0.0...v3.2.6) (2022-03-03)
|
|
197
|
-
|
|
198
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
## [3.2.4](https://github.com/StrataFoundation/strata/compare/v3.2.4-alpha.5...v3.2.4) (2022-02-12)
|
|
205
|
-
|
|
206
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
## [3.2.3](https://github.com/StrataFoundation/strata/compare/v3.2.2...v3.2.3) (2022-02-09)
|
|
213
|
-
|
|
214
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
## [3.2.2](https://github.com/StrataFoundation/strata/compare/v3.2.1...v3.2.2) (2022-02-08)
|
|
221
|
-
|
|
222
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
## [3.2.1](https://github.com/StrataFoundation/strata/compare/v3.2.0...v3.2.1) (2022-02-08)
|
|
229
|
-
|
|
230
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
# [3.2.0](https://github.com/StrataFoundation/strata/compare/v3.1.0...v3.2.0) (2022-02-03)
|
|
237
|
-
|
|
238
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
# [3.1.0](https://github.com/StrataFoundation/strata/compare/v3.0.0...v3.1.0) (2022-01-29)
|
|
245
|
-
|
|
246
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
# [3.0.0](https://github.com/StrataFoundation/strata/compare/v2.2.0...v3.0.0) (2022-01-26)
|
|
253
|
-
|
|
254
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
# [2.2.0](https://github.com/StrataFoundation/strata/compare/v2.1.11...v2.2.0) (2022-01-25)
|
|
261
|
-
|
|
262
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
## [2.1.7](https://github.com/StrataFoundation/strata/compare/v2.1.6...v2.1.7) (2022-01-20)
|
|
269
|
-
|
|
270
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
## [2.1.2](https://github.com/StrataFoundation/strata/compare/v2.1.1...v2.1.2) (2022-01-17)
|
|
277
|
-
|
|
278
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
## [2.1.1](https://github.com/StrataFoundation/strata/compare/v2.1.0...v2.1.1) (2022-01-12)
|
|
285
|
-
|
|
286
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
# [2.1.0](https://github.com/StrataFoundation/strata/compare/v2.0.6...v2.1.0) (2022-01-11)
|
|
293
|
-
|
|
294
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
# [2.0.0](https://github.com/StrataFoundation/strata/compare/v1.3.2...v2.0.0) (2021-12-24)
|
|
301
|
-
|
|
302
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
## [1.3.2](https://github.com/StrataFoundation/strata/compare/v0.7.0...v1.3.2) (2021-12-15)
|
|
309
|
-
|
|
310
|
-
**Note:** Version bump only for package @strata-foundation/spl-utils
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.dispersedClient = exports.DispersedConflictError = void 0;
|
|
16
|
-
const logger_1 = require("../logger");
|
|
17
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
|
-
/**
|
|
19
|
-
* Dispersed Token Burn API client (M2M OAuth2 client_credentials).
|
|
20
|
-
*
|
|
21
|
-
* Thin transport only: it mints/caches the bearer token and posts the two burn
|
|
22
|
-
* endpoints (claim, settle). It does NOT price RENDER, sum obligations, or do
|
|
23
|
-
* any burn math — the consumer owns that (incl. the `settled_amount == Σ
|
|
24
|
-
* obligation amounts` invariant). Amounts are passed through as decimal strings.
|
|
25
|
-
*
|
|
26
|
-
* Contract: see docs/dispersed-burn.md. Authoritative spec at
|
|
27
|
-
* `{apiBaseUrl}/openapi.json` (tag "Burn Ledger").
|
|
28
|
-
*/
|
|
29
|
-
// Both scopes, space-delimited, requested on every token mint.
|
|
30
|
-
const SCOPES = 'burn_ledger_claims.create.all burn_ledger_settlements.create.all';
|
|
31
|
-
// Re-mint a little before the token actually expires.
|
|
32
|
-
const TOKEN_REFRESH_MARGIN_MS = 60000;
|
|
33
|
-
/**
|
|
34
|
-
* Thrown on a 409 from settle: the claim is missing/expired/released/already
|
|
35
|
-
* settled, an obligation mismatch, an amount mismatch, or a tx_signature reused
|
|
36
|
-
* with a different payload. Nothing was written. Do NOT re-burn — reconcile.
|
|
37
|
-
*/
|
|
38
|
-
class DispersedConflictError extends Error {
|
|
39
|
-
constructor(body) {
|
|
40
|
-
super(`dispersed 409 conflict: ${body}`);
|
|
41
|
-
this.body = body;
|
|
42
|
-
this.status = 409;
|
|
43
|
-
this.name = 'DispersedConflictError';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.DispersedConflictError = DispersedConflictError;
|
|
47
|
-
const dispersedClient = (cfg, fetchImpl = node_fetch_1.default) => {
|
|
48
|
-
let cached;
|
|
49
|
-
const mintToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const res = yield fetchImpl(`${cfg.authBaseUrl}/token`, {
|
|
51
|
-
method: 'POST',
|
|
52
|
-
headers: { 'Content-Type': 'application/json' },
|
|
53
|
-
body: JSON.stringify({
|
|
54
|
-
grant_type: 'client_credentials',
|
|
55
|
-
client_id: cfg.clientId,
|
|
56
|
-
client_secret: cfg.clientSecret,
|
|
57
|
-
scope: SCOPES,
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
if (res.status !== 200) {
|
|
61
|
-
throw new Error(`dispersed token mint failed. code: ${res.status} body: ${JSON.stringify(yield res.text())}`);
|
|
62
|
-
}
|
|
63
|
-
const json = (yield res.json());
|
|
64
|
-
cached = {
|
|
65
|
-
token: json.access_token,
|
|
66
|
-
expiresAt: Date.now() + json.expires_in * 1000,
|
|
67
|
-
};
|
|
68
|
-
return cached.token;
|
|
69
|
-
});
|
|
70
|
-
const getToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
if (cached && Date.now() < cached.expiresAt - TOKEN_REFRESH_MARGIN_MS) {
|
|
72
|
-
return cached.token;
|
|
73
|
-
}
|
|
74
|
-
return mintToken();
|
|
75
|
-
});
|
|
76
|
-
// POST with bearer; one transparent re-mint+retry on 401 (a dropped daily run
|
|
77
|
-
// is expensive, so it's worth recovering from a token that died mid-flight).
|
|
78
|
-
const authedPost = (path, body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
const doPost = (token) => fetchImpl(`${cfg.apiBaseUrl}${path}`, {
|
|
80
|
-
method: 'POST',
|
|
81
|
-
headers: {
|
|
82
|
-
'Content-Type': 'application/json',
|
|
83
|
-
Authorization: `Bearer ${token}`,
|
|
84
|
-
},
|
|
85
|
-
body: JSON.stringify(body),
|
|
86
|
-
});
|
|
87
|
-
let res = yield doPost(yield getToken());
|
|
88
|
-
if (res.status === 401) {
|
|
89
|
-
cached = undefined;
|
|
90
|
-
res = yield doPost(yield mintToken());
|
|
91
|
-
}
|
|
92
|
-
return res;
|
|
93
|
-
});
|
|
94
|
-
return {
|
|
95
|
-
claim({ from, to, limit }, log = logger_1.consoleLogger) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const res = yield authedPost('/v1/burn-ledger-claims', Object.assign({ executor_id: cfg.executorId, from: from.toISOString(), to: to.toISOString() }, (limit !== undefined ? { limit } : {})));
|
|
98
|
-
if (res.status !== 201) {
|
|
99
|
-
throw new Error(`dispersed claim failed. code: ${res.status} body: ${JSON.stringify(yield res.text())}`);
|
|
100
|
-
}
|
|
101
|
-
const result = (yield res.json());
|
|
102
|
-
log.info(`dispersed claim ${result.claim.uuid}: ${result.claimed_count} obligations, expires ${result.claim.claim_expires_at}`);
|
|
103
|
-
return result;
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
settle(req, log = logger_1.consoleLogger) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const res = yield authedPost('/v1/burn-ledger-settlements', req);
|
|
109
|
-
if (res.status === 409) {
|
|
110
|
-
throw new DispersedConflictError(yield res.text());
|
|
111
|
-
}
|
|
112
|
-
if (res.status !== 201 && res.status !== 200) {
|
|
113
|
-
throw new Error(`dispersed settle failed. code: ${res.status} body: ${JSON.stringify(yield res.text())}`);
|
|
114
|
-
}
|
|
115
|
-
const result = (yield res.json());
|
|
116
|
-
log.info(`dispersed settle ${result.settlement.uuid} for tx ${req.tx_signature} (replay=${result.idempotent_replay})`);
|
|
117
|
-
return result;
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
exports.dispersedClient = dispersedClient;
|
|
123
|
-
//# sourceMappingURL=dispersed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispersed.js","sourceRoot":"","sources":["../../../src/client/dispersed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAuD;AACvD,4DAA8B;AAE9B;;;;;;;;;;GAUG;AAEH,+DAA+D;AAC/D,MAAM,MAAM,GACV,kEAAkE,CAAA;AAEpE,sDAAsD;AACtD,MAAM,uBAAuB,GAAG,KAAM,CAAA;AA6EtC;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAE/C,YAA4B,IAAY;QACtC,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC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-
import fetch from 'node-fetch';
|
|
3
|
-
/**
|
|
4
|
-
* Dispersed Token Burn API client (M2M OAuth2 client_credentials).
|
|
5
|
-
*
|
|
6
|
-
* Thin transport only: it mints/caches the bearer token and posts the two burn
|
|
7
|
-
* endpoints (claim, settle). It does NOT price RENDER, sum obligations, or do
|
|
8
|
-
* any burn math — the consumer owns that (incl. the `settled_amount == Σ
|
|
9
|
-
* obligation amounts` invariant). Amounts are passed through as decimal strings.
|
|
10
|
-
*
|
|
11
|
-
* Contract: see docs/dispersed-burn.md. Authoritative spec at
|
|
12
|
-
* `{apiBaseUrl}/openapi.json` (tag "Burn Ledger").
|
|
13
|
-
*/
|
|
14
|
-
// Both scopes, space-delimited, requested on every token mint.
|
|
15
|
-
const SCOPES = 'burn_ledger_claims.create.all burn_ledger_settlements.create.all';
|
|
16
|
-
// Re-mint a little before the token actually expires.
|
|
17
|
-
const TOKEN_REFRESH_MARGIN_MS = 60_000;
|
|
18
|
-
/**
|
|
19
|
-
* Thrown on a 409 from settle: the claim is missing/expired/released/already
|
|
20
|
-
* settled, an obligation mismatch, an amount mismatch, or a tx_signature reused
|
|
21
|
-
* with a different payload. Nothing was written. Do NOT re-burn — reconcile.
|
|
22
|
-
*/
|
|
23
|
-
export class DispersedConflictError extends Error {
|
|
24
|
-
body;
|
|
25
|
-
status = 409;
|
|
26
|
-
constructor(body) {
|
|
27
|
-
super(`dispersed 409 conflict: ${body}`);
|
|
28
|
-
this.body = body;
|
|
29
|
-
this.name = 'DispersedConflictError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export const dispersedClient = (cfg, fetchImpl = fetch) => {
|
|
33
|
-
let cached;
|
|
34
|
-
const mintToken = async () => {
|
|
35
|
-
const res = await fetchImpl(`${cfg.authBaseUrl}/token`, {
|
|
36
|
-
method: 'POST',
|
|
37
|
-
headers: { 'Content-Type': 'application/json' },
|
|
38
|
-
body: JSON.stringify({
|
|
39
|
-
grant_type: 'client_credentials',
|
|
40
|
-
client_id: cfg.clientId,
|
|
41
|
-
client_secret: cfg.clientSecret,
|
|
42
|
-
scope: SCOPES,
|
|
43
|
-
}),
|
|
44
|
-
});
|
|
45
|
-
if (res.status !== 200) {
|
|
46
|
-
throw new Error(`dispersed token mint failed. code: ${res.status} body: ${JSON.stringify(await res.text())}`);
|
|
47
|
-
}
|
|
48
|
-
const json = (await res.json());
|
|
49
|
-
cached = {
|
|
50
|
-
token: json.access_token,
|
|
51
|
-
expiresAt: Date.now() + json.expires_in * 1000,
|
|
52
|
-
};
|
|
53
|
-
return cached.token;
|
|
54
|
-
};
|
|
55
|
-
const getToken = async () => {
|
|
56
|
-
if (cached && Date.now() < cached.expiresAt - TOKEN_REFRESH_MARGIN_MS) {
|
|
57
|
-
return cached.token;
|
|
58
|
-
}
|
|
59
|
-
return mintToken();
|
|
60
|
-
};
|
|
61
|
-
// POST with bearer; one transparent re-mint+retry on 401 (a dropped daily run
|
|
62
|
-
// is expensive, so it's worth recovering from a token that died mid-flight).
|
|
63
|
-
const authedPost = async (path, body) => {
|
|
64
|
-
const doPost = (token) => fetchImpl(`${cfg.apiBaseUrl}${path}`, {
|
|
65
|
-
method: 'POST',
|
|
66
|
-
headers: {
|
|
67
|
-
'Content-Type': 'application/json',
|
|
68
|
-
Authorization: `Bearer ${token}`,
|
|
69
|
-
},
|
|
70
|
-
body: JSON.stringify(body),
|
|
71
|
-
});
|
|
72
|
-
let res = await doPost(await getToken());
|
|
73
|
-
if (res.status === 401) {
|
|
74
|
-
cached = undefined;
|
|
75
|
-
res = await doPost(await mintToken());
|
|
76
|
-
}
|
|
77
|
-
return res;
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
async claim({ from, to, limit }, log = consoleLogger) {
|
|
81
|
-
const res = await authedPost('/v1/burn-ledger-claims', {
|
|
82
|
-
executor_id: cfg.executorId,
|
|
83
|
-
from: from.toISOString(),
|
|
84
|
-
to: to.toISOString(),
|
|
85
|
-
...(limit !== undefined ? { limit } : {}),
|
|
86
|
-
});
|
|
87
|
-
if (res.status !== 201) {
|
|
88
|
-
throw new Error(`dispersed claim failed. code: ${res.status} body: ${JSON.stringify(await res.text())}`);
|
|
89
|
-
}
|
|
90
|
-
const result = (await res.json());
|
|
91
|
-
log.info(`dispersed claim ${result.claim.uuid}: ${result.claimed_count} obligations, expires ${result.claim.claim_expires_at}`);
|
|
92
|
-
return result;
|
|
93
|
-
},
|
|
94
|
-
async settle(req, log = consoleLogger) {
|
|
95
|
-
const res = await authedPost('/v1/burn-ledger-settlements', req);
|
|
96
|
-
if (res.status === 409) {
|
|
97
|
-
throw new DispersedConflictError(await res.text());
|
|
98
|
-
}
|
|
99
|
-
if (res.status !== 201 && res.status !== 200) {
|
|
100
|
-
throw new Error(`dispersed settle failed. code: ${res.status} body: ${JSON.stringify(await res.text())}`);
|
|
101
|
-
}
|
|
102
|
-
const result = (await res.json());
|
|
103
|
-
log.info(`dispersed settle ${result.settlement.uuid} for tx ${req.tx_signature} (replay=${result.idempotent_replay})`);
|
|
104
|
-
return result;
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=dispersed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispersed.js","sourceRoot":"","sources":["../../../../src/client/dispersed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B;;;;;;;;;;GAUG;AAEH,+DAA+D;AAC/D,MAAM,MAAM,GACV,kEAAkE,CAAA;AAEpE,sDAAsD;AACtD,MAAM,uBAAuB,GAAG,MAAM,CAAA;AA6EtC;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAEnB;IADnB,MAAM,GAAG,GAAG,CAAA;IACrB,YAA4B,IAAY;QACtC,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAA;QADd,SAAI,GAAJ,IAAI,CAAQ;Q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|
|
6
|
-
clientSecret: string;
|
|
7
|
-
executorId: string;
|
|
8
|
-
};
|
|
9
|
-
export type FetchFn = (url: string, init?: {
|
|
10
|
-
method?: string;
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
body?: string;
|
|
13
|
-
}) => Promise<{
|
|
14
|
-
status: number;
|
|
15
|
-
json(): Promise<unknown>;
|
|
16
|
-
text(): Promise<string>;
|
|
17
|
-
}>;
|
|
18
|
-
export type EurAmount = {
|
|
19
|
-
amount: string;
|
|
20
|
-
currency: 'EUR';
|
|
21
|
-
};
|
|
22
|
-
export type RenderAmount = {
|
|
23
|
-
amount: string;
|
|
24
|
-
currency: 'RENDER';
|
|
25
|
-
};
|
|
26
|
-
export type DispersedObligation = {
|
|
27
|
-
uuid: string;
|
|
28
|
-
amount: string;
|
|
29
|
-
currency: 'EUR';
|
|
30
|
-
status: string;
|
|
31
|
-
};
|
|
32
|
-
export type DispersedClaim = {
|
|
33
|
-
uuid: string;
|
|
34
|
-
executor_id: string;
|
|
35
|
-
status: string;
|
|
36
|
-
claimed_at: string;
|
|
37
|
-
claim_expires_at: string;
|
|
38
|
-
};
|
|
39
|
-
export type ClaimResult = {
|
|
40
|
-
claim: DispersedClaim;
|
|
41
|
-
claimed_count: number;
|
|
42
|
-
effective_window: {
|
|
43
|
-
from: string;
|
|
44
|
-
requested_to: string;
|
|
45
|
-
to: string;
|
|
46
|
-
};
|
|
47
|
-
obligations: DispersedObligation[];
|
|
48
|
-
};
|
|
49
|
-
export type SettleRequest = {
|
|
50
|
-
burn_ledger_claim_uuid: string;
|
|
51
|
-
obligation_uuids: string[];
|
|
52
|
-
settled_amount: EurAmount;
|
|
53
|
-
burned_amount: RenderAmount;
|
|
54
|
-
executed_at: string;
|
|
55
|
-
tx_signature: string;
|
|
56
|
-
pricing_snapshot?: Record<string, unknown>;
|
|
57
|
-
executor_metadata?: Record<string, unknown>;
|
|
58
|
-
};
|
|
59
|
-
export type SettleResult = {
|
|
60
|
-
settlement: {
|
|
61
|
-
uuid: string;
|
|
62
|
-
burn_ledger_claim_uuid: string;
|
|
63
|
-
tx_signature: string;
|
|
64
|
-
executed_at: string;
|
|
65
|
-
settled_amount: string;
|
|
66
|
-
currency: 'EUR';
|
|
67
|
-
burned_amount: RenderAmount;
|
|
68
|
-
};
|
|
69
|
-
applications: unknown[];
|
|
70
|
-
idempotent_replay: boolean;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Thrown on a 409 from settle: the claim is missing/expired/released/already
|
|
74
|
-
* settled, an obligation mismatch, an amount mismatch, or a tx_signature reused
|
|
75
|
-
* with a different payload. Nothing was written. Do NOT re-burn — reconcile.
|
|
76
|
-
*/
|
|
77
|
-
export declare class DispersedConflictError extends Error {
|
|
78
|
-
readonly body: string;
|
|
79
|
-
readonly status = 409;
|
|
80
|
-
constructor(body: string);
|
|
81
|
-
}
|
|
82
|
-
export interface DispersedClient {
|
|
83
|
-
claim(args: {
|
|
84
|
-
from: Date;
|
|
85
|
-
to: Date;
|
|
86
|
-
limit?: number;
|
|
87
|
-
}, log?: RenderLogger): Promise<ClaimResult>;
|
|
88
|
-
settle(req: SettleRequest, log?: RenderLogger): Promise<SettleResult>;
|
|
89
|
-
}
|
|
90
|
-
export declare const dispersedClient: (cfg: DispersedConfig, fetchImpl?: FetchFn) => DispersedClient;
|
|
91
|
-
//# sourceMappingURL=dispersed.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispersed.d.ts","sourceRoot":"","sources":["../../../../src/client/dispersed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,MAAM,WAAW,CAAA;AAsBvD,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAID,MAAM,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