@hashgraphonline/standards-sdk 0.1.190 → 0.1.191
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/dist/browser/hcs-25/adapters/ans-trust-discovery.d.ts +22 -0
- package/dist/browser/hcs-25/adapters/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser/hcs-25/adapters/index.d.ts +1 -0
- package/dist/browser/hcs-25/adapters/index.d.ts.map +1 -1
- package/dist/browser/hcs-25/collectors/ans-trust-discovery.d.ts +32 -0
- package/dist/browser/hcs-25/collectors/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser/hcs-25/collectors/catalog.d.ts +9 -2
- package/dist/browser/hcs-25/collectors/catalog.d.ts.map +1 -1
- package/dist/browser/hcs-25/collectors/index.d.ts +1 -0
- package/dist/browser/hcs-25/collectors/index.d.ts.map +1 -1
- package/dist/browser/hcs-25/signals/ans-trust-discovery.d.ts +50 -0
- package/dist/browser/hcs-25/signals/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser/hcs-25/signals/index.d.ts +1 -0
- package/dist/browser/hcs-25/signals/index.d.ts.map +1 -1
- package/dist/browser-root/hcs-25/adapters/ans-trust-discovery.d.ts +22 -0
- package/dist/browser-root/hcs-25/adapters/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser-root/hcs-25/adapters/index.d.ts +1 -0
- package/dist/browser-root/hcs-25/adapters/index.d.ts.map +1 -1
- package/dist/browser-root/hcs-25/collectors/ans-trust-discovery.d.ts +32 -0
- package/dist/browser-root/hcs-25/collectors/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser-root/hcs-25/collectors/catalog.d.ts +9 -2
- package/dist/browser-root/hcs-25/collectors/catalog.d.ts.map +1 -1
- package/dist/browser-root/hcs-25/collectors/index.d.ts +1 -0
- package/dist/browser-root/hcs-25/collectors/index.d.ts.map +1 -1
- package/dist/browser-root/hcs-25/signals/ans-trust-discovery.d.ts +50 -0
- package/dist/browser-root/hcs-25/signals/ans-trust-discovery.d.ts.map +1 -0
- package/dist/browser-root/hcs-25/signals/index.d.ts +1 -0
- package/dist/browser-root/hcs-25/signals/index.d.ts.map +1 -1
- package/dist/cjs/hcs-25/adapters/ans-trust-discovery.d.ts +22 -0
- package/dist/cjs/hcs-25/adapters/ans-trust-discovery.d.ts.map +1 -0
- package/dist/cjs/hcs-25/adapters/index.d.ts +1 -0
- package/dist/cjs/hcs-25/adapters/index.d.ts.map +1 -1
- package/dist/cjs/hcs-25/collectors/ans-trust-discovery.d.ts +32 -0
- package/dist/cjs/hcs-25/collectors/ans-trust-discovery.d.ts.map +1 -0
- package/dist/cjs/hcs-25/collectors/catalog.d.ts +9 -2
- package/dist/cjs/hcs-25/collectors/catalog.d.ts.map +1 -1
- package/dist/cjs/hcs-25/collectors/index.d.ts +1 -0
- package/dist/cjs/hcs-25/collectors/index.d.ts.map +1 -1
- package/dist/cjs/hcs-25/signals/ans-trust-discovery.d.ts +50 -0
- package/dist/cjs/hcs-25/signals/ans-trust-discovery.d.ts.map +1 -0
- package/dist/cjs/hcs-25/signals/index.d.ts +1 -0
- package/dist/cjs/hcs-25/signals/index.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-25/adapters/ans-trust-discovery.d.ts +22 -0
- package/dist/es/hcs-25/adapters/ans-trust-discovery.d.ts.map +1 -0
- package/dist/es/hcs-25/adapters/index.d.ts +1 -0
- package/dist/es/hcs-25/adapters/index.d.ts.map +1 -1
- package/dist/es/hcs-25/collectors/ans-trust-discovery.d.ts +32 -0
- package/dist/es/hcs-25/collectors/ans-trust-discovery.d.ts.map +1 -0
- package/dist/es/hcs-25/collectors/catalog.d.ts +9 -2
- package/dist/es/hcs-25/collectors/catalog.d.ts.map +1 -1
- package/dist/es/hcs-25/collectors/index.d.ts +1 -0
- package/dist/es/hcs-25/collectors/index.d.ts.map +1 -1
- package/dist/es/hcs-25/signals/ans-trust-discovery.d.ts +50 -0
- package/dist/es/hcs-25/signals/ans-trust-discovery.d.ts.map +1 -0
- package/dist/es/hcs-25/signals/index.d.ts +1 -0
- package/dist/es/hcs-25/signals/index.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +78 -71
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +2 -2
- package/dist/es/standards-sdk.es103.js +2 -2
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +2 -2
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +2 -2
- package/dist/es/standards-sdk.es115.js +3 -3
- package/dist/es/standards-sdk.es116.js +4 -4
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +22 -4
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +15 -12
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +6 -5
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +6 -5
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +6 -5
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +110 -136
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +133 -141
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +135 -345
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +332 -344
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +338 -178
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +200 -196
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +216 -364
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +358 -100
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +91 -220
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +173 -1250
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +1295 -98
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +109 -246
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +1 -1
- package/dist/es/standards-sdk.es140.js +263 -97
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +107 -248
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +246 -472
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +458 -85
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +96 -151
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +155 -29
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +26 -4
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +10 -180
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +179 -26
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +27 -20
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es150.js +18 -156
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +148 -190
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +159 -747
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +786 -9
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +13 -567
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +541 -600
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +625 -12
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +13 -2
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +2 -87
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +84 -37
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +6 -6
- package/dist/es/standards-sdk.es160.js +40 -2
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +2 -235
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +204 -1109
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +1059 -225
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +303 -419
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +418 -351
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +347 -1114
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +1094 -180
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +153 -1512
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +1457 -1056
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +1163 -14
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +15 -449
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +440 -248
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +259 -4
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +4 -81
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +71 -77
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +80 -53
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +59 -2546
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +2547 -159
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +159 -7
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +13 -13
- package/dist/es/standards-sdk.es180.js +7 -86
- package/dist/es/standards-sdk.es180.js.map +1 -1
- package/dist/es/standards-sdk.es181.js +65 -44
- package/dist/es/standards-sdk.es181.js.map +1 -1
- package/dist/es/standards-sdk.es182.js +57 -188
- package/dist/es/standards-sdk.es182.js.map +1 -1
- package/dist/es/standards-sdk.es183.js +27 -26
- package/dist/es/standards-sdk.es183.js.map +1 -1
- package/dist/es/standards-sdk.es184.js +191 -53
- package/dist/es/standards-sdk.es184.js.map +1 -1
- package/dist/es/standards-sdk.es185.js +21 -109
- package/dist/es/standards-sdk.es185.js.map +1 -1
- package/dist/es/standards-sdk.es186.js +49 -47
- package/dist/es/standards-sdk.es186.js.map +1 -1
- package/dist/es/standards-sdk.es187.js +89 -205
- package/dist/es/standards-sdk.es187.js.map +1 -1
- package/dist/es/standards-sdk.es188.js +35 -58
- package/dist/es/standards-sdk.es188.js.map +1 -1
- package/dist/es/standards-sdk.es189.js +48 -39
- package/dist/es/standards-sdk.es189.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +10 -10
- package/dist/es/standards-sdk.es190.js +218 -48
- package/dist/es/standards-sdk.es190.js.map +1 -1
- package/dist/es/standards-sdk.es191.js +66 -42
- package/dist/es/standards-sdk.es191.js.map +1 -1
- package/dist/es/standards-sdk.es192.js +33 -105
- package/dist/es/standards-sdk.es192.js.map +1 -1
- package/dist/es/standards-sdk.es193.js +49 -43
- package/dist/es/standards-sdk.es193.js.map +1 -1
- package/dist/es/standards-sdk.es194.js +33 -42
- package/dist/es/standards-sdk.es194.js.map +1 -1
- package/dist/es/standards-sdk.es195.js +123 -72
- package/dist/es/standards-sdk.es195.js.map +1 -1
- package/dist/es/standards-sdk.es196.js +58 -75
- package/dist/es/standards-sdk.es196.js.map +1 -1
- package/dist/es/standards-sdk.es197.js +60 -44
- package/dist/es/standards-sdk.es197.js.map +1 -1
- package/dist/es/standards-sdk.es198.js +72 -36
- package/dist/es/standards-sdk.es198.js.map +1 -1
- package/dist/es/standards-sdk.es199.js +75 -30
- package/dist/es/standards-sdk.es199.js.map +1 -1
- package/dist/es/standards-sdk.es2.js +2 -2
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es200.js +44 -34
- package/dist/es/standards-sdk.es200.js.map +1 -1
- package/dist/es/standards-sdk.es201.js +36 -48
- package/dist/es/standards-sdk.es201.js.map +1 -1
- package/dist/es/standards-sdk.es202.js +30 -138
- package/dist/es/standards-sdk.es202.js.map +1 -1
- package/dist/es/standards-sdk.es203.js +34 -42
- package/dist/es/standards-sdk.es203.js.map +1 -1
- package/dist/es/standards-sdk.es204.js +48 -12482
- package/dist/es/standards-sdk.es204.js.map +1 -1
- package/dist/es/standards-sdk.es205.js +134 -13
- package/dist/es/standards-sdk.es205.js.map +1 -1
- package/dist/es/standards-sdk.es206.js +36 -50
- package/dist/es/standards-sdk.es206.js.map +1 -1
- package/dist/es/standards-sdk.es207.js +12449 -78
- package/dist/es/standards-sdk.es207.js.map +1 -1
- package/dist/es/standards-sdk.es208.js +15 -79
- package/dist/es/standards-sdk.es208.js.map +1 -1
- package/dist/es/standards-sdk.es209.js +48 -192
- package/dist/es/standards-sdk.es209.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es210.js +90 -651
- package/dist/es/standards-sdk.es210.js.map +1 -1
- package/dist/es/standards-sdk.es211.js +71 -63
- package/dist/es/standards-sdk.es211.js.map +1 -1
- package/dist/es/standards-sdk.es212.js +188 -160
- package/dist/es/standards-sdk.es212.js.map +1 -1
- package/dist/es/standards-sdk.es213.js +65 -314
- package/dist/es/standards-sdk.es213.js.map +1 -1
- package/dist/es/standards-sdk.es214.js +661 -335
- package/dist/es/standards-sdk.es214.js.map +1 -1
- package/dist/es/standards-sdk.es215.js +129 -410
- package/dist/es/standards-sdk.es215.js.map +1 -1
- package/dist/es/standards-sdk.es216.js +200 -209
- package/dist/es/standards-sdk.es216.js.map +1 -1
- package/dist/es/standards-sdk.es217.js +334 -64
- package/dist/es/standards-sdk.es217.js.map +1 -1
- package/dist/es/standards-sdk.es218.js +438 -124
- package/dist/es/standards-sdk.es218.js.map +1 -1
- package/dist/es/standards-sdk.es219.js +310 -496
- package/dist/es/standards-sdk.es219.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es220.js +60 -243
- package/dist/es/standards-sdk.es220.js.map +1 -1
- package/dist/es/standards-sdk.es221.js +118 -175
- package/dist/es/standards-sdk.es221.js.map +1 -1
- package/dist/es/standards-sdk.es222.js +465 -67
- package/dist/es/standards-sdk.es222.js.map +1 -1
- package/dist/es/standards-sdk.es223.js +250 -143
- package/dist/es/standards-sdk.es223.js.map +1 -1
- package/dist/es/standards-sdk.es224.js +172 -160
- package/dist/es/standards-sdk.es224.js.map +1 -1
- package/dist/es/standards-sdk.es225.js +65 -630
- package/dist/es/standards-sdk.es225.js.map +1 -1
- package/dist/es/standards-sdk.es226.js +128 -161
- package/dist/es/standards-sdk.es226.js.map +1 -1
- package/dist/es/standards-sdk.es227.js +144 -195
- package/dist/es/standards-sdk.es227.js.map +1 -1
- package/dist/es/standards-sdk.es228.js +668 -223
- package/dist/es/standards-sdk.es228.js.map +1 -1
- package/dist/es/standards-sdk.es229.js +188 -0
- package/dist/es/standards-sdk.es229.js.map +1 -0
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es230.js +238 -0
- package/dist/es/standards-sdk.es230.js.map +1 -0
- package/dist/es/standards-sdk.es231.js +242 -0
- package/dist/es/standards-sdk.es231.js.map +1 -0
- package/dist/es/standards-sdk.es24.js +1 -1
- package/dist/es/standards-sdk.es25.js +1 -1
- package/dist/es/standards-sdk.es26.js +1 -1
- package/dist/es/standards-sdk.es27.js +13 -13
- package/dist/es/standards-sdk.es30.js +2 -2
- package/dist/es/standards-sdk.es31.js +4 -4
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es35.js +7 -7
- package/dist/es/standards-sdk.es36.js +4 -4
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +1 -1
- package/dist/es/standards-sdk.es4.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +2 -2
- package/dist/es/standards-sdk.es46.js +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +2 -2
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es6.js +2 -2
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es67.js +8 -8
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +3 -3
- package/dist/es/standards-sdk.es75.js +5 -5
- package/dist/es/standards-sdk.es76.js +3 -3
- package/dist/es/standards-sdk.es77.js +2 -2
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es81.js +2 -2
- package/dist/es/standards-sdk.es83.js +2 -2
- package/dist/es/standards-sdk.es84.js +5 -5
- package/dist/es/standards-sdk.es85.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es89.js +2 -2
- package/dist/es/standards-sdk.es9.js +2 -2
- package/dist/es/standards-sdk.es90.js +4 -4
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es96.js +2 -2
- package/dist/es/standards-sdk.es98.js +1 -1
- package/dist/es/standards-sdk.es99.js +3 -3
- package/package.json +1 -1
|
@@ -1,1169 +1,1570 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { DEFAULT_BASE_URL, normaliseBaseUrl, normaliseHeaderName, isBrowserRuntime, DEFAULT_USER_AGENT, JSON_CONTENT_TYPE, serialiseAgentRegistrationRequest, MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS, createAbortError, isJsonObject, DEFAULT_HISTORY_TOP_UP_HBAR } from "./standards-sdk.es228.js";
|
|
19
|
-
import { RegistryBrokerError, RegistryBrokerParseError } from "./standards-sdk.es170.js";
|
|
20
|
-
import { optionalImportSync } from "./standards-sdk.es207.js";
|
|
21
|
-
class RegistryBrokerClient {
|
|
22
|
-
constructor(options = {}) {
|
|
23
|
-
this.encryptionBootstrapPromise = null;
|
|
24
|
-
this.chatApi = null;
|
|
25
|
-
this.agentNetworkApi = null;
|
|
26
|
-
this.encryptedChatManager = null;
|
|
27
|
-
this.encryptionApi = null;
|
|
28
|
-
this.conversationContexts = /* @__PURE__ */ new Map();
|
|
29
|
-
const {
|
|
30
|
-
baseUrl = DEFAULT_BASE_URL,
|
|
31
|
-
fetchImplementation,
|
|
32
|
-
defaultHeaders,
|
|
33
|
-
apiKey,
|
|
34
|
-
accountId,
|
|
35
|
-
ledgerApiKey,
|
|
36
|
-
registrationAutoTopUp,
|
|
37
|
-
historyAutoTopUp,
|
|
38
|
-
encryption
|
|
39
|
-
} = options;
|
|
40
|
-
this.baseUrl = normaliseBaseUrl(baseUrl);
|
|
41
|
-
const resolvedFetch = fetchImplementation ?? (typeof globalThis.fetch === "function" ? globalThis.fetch : null);
|
|
42
|
-
if (!resolvedFetch) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
"A fetch implementation is required for RegistryBrokerClient"
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
this.fetchImpl = resolvedFetch;
|
|
48
|
-
this.defaultHeaders = {
|
|
49
|
-
...defaultHeaders ?? {}
|
|
50
|
-
};
|
|
51
|
-
Object.entries(this.defaultHeaders).forEach(([key, value]) => {
|
|
52
|
-
const headerName = normaliseHeaderName(key);
|
|
53
|
-
if (headerName !== key) {
|
|
54
|
-
delete this.defaultHeaders[key];
|
|
55
|
-
this.defaultHeaders[headerName] = value;
|
|
56
|
-
}
|
|
1
|
+
import { PublicKey, Timestamp, AccountId } from "@hashgraph/sdk";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { Logger } from "./standards-sdk.es148.js";
|
|
4
|
+
import { proto } from "@hashgraph/proto";
|
|
5
|
+
class HederaMirrorNode {
|
|
6
|
+
constructor(network, logger, config) {
|
|
7
|
+
this.maxRetries = 5;
|
|
8
|
+
this.initialDelayMs = 2e3;
|
|
9
|
+
this.maxDelayMs = 3e4;
|
|
10
|
+
this.backoffFactor = 2;
|
|
11
|
+
this.network = network;
|
|
12
|
+
this.apiKey = config?.apiKey;
|
|
13
|
+
this.customHeaders = config?.headers || {};
|
|
14
|
+
this.baseUrl = config?.customUrl || this.getMirrorNodeUrl();
|
|
15
|
+
this.logger = logger || new Logger({
|
|
16
|
+
level: "debug",
|
|
17
|
+
module: "MirrorNode"
|
|
57
18
|
});
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
this.
|
|
61
|
-
}
|
|
62
|
-
if (apiKey) {
|
|
63
|
-
this.
|
|
19
|
+
this.isServerEnvironment = typeof window === "undefined";
|
|
20
|
+
if (config?.customUrl) {
|
|
21
|
+
this.logger.info(`Using custom mirror node URL: ${config.customUrl}`);
|
|
22
|
+
}
|
|
23
|
+
if (config?.apiKey) {
|
|
24
|
+
this.logger.info("Using API key for mirror node requests");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configures the retry mechanism for API requests.
|
|
29
|
+
* @param config The retry configuration.
|
|
30
|
+
*/
|
|
31
|
+
configureRetry(config) {
|
|
32
|
+
this.maxRetries = config.maxRetries ?? this.maxRetries;
|
|
33
|
+
this.initialDelayMs = config.initialDelayMs ?? this.initialDelayMs;
|
|
34
|
+
this.maxDelayMs = config.maxDelayMs ?? this.maxDelayMs;
|
|
35
|
+
this.backoffFactor = config.backoffFactor ?? this.backoffFactor;
|
|
36
|
+
this.logger.info(
|
|
37
|
+
`Retry configuration updated: maxRetries=${this.maxRetries}, initialDelayMs=${this.initialDelayMs}, maxDelayMs=${this.maxDelayMs}, backoffFactor=${this.backoffFactor}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Updates the mirror node configuration.
|
|
42
|
+
* @param config The new mirror node configuration.
|
|
43
|
+
*/
|
|
44
|
+
configureMirrorNode(config) {
|
|
45
|
+
if (config.customUrl) {
|
|
46
|
+
this.baseUrl = config.customUrl;
|
|
47
|
+
this.logger.info(`Updated mirror node URL: ${config.customUrl}`);
|
|
64
48
|
}
|
|
65
|
-
if (
|
|
66
|
-
this.
|
|
49
|
+
if (config.apiKey) {
|
|
50
|
+
this.apiKey = config.apiKey;
|
|
51
|
+
this.logger.info("Updated API key for mirror node requests");
|
|
67
52
|
}
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
if (config.headers) {
|
|
54
|
+
this.customHeaders = { ...this.customHeaders, ...config.headers };
|
|
55
|
+
this.logger.info("Updated custom headers for mirror node requests");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Constructs a full URL for API requests, handling custom providers with API keys in the path.
|
|
60
|
+
* @param endpoint The API endpoint (e.g., '/api/v1/accounts/0.0.123')
|
|
61
|
+
* @returns The full URL for the request
|
|
62
|
+
*/
|
|
63
|
+
constructUrl(endpoint) {
|
|
64
|
+
if (this.baseUrl.includes("<API-KEY>") && this.apiKey) {
|
|
65
|
+
const baseUrlWithKey = this.baseUrl.replace("<API-KEY>", this.apiKey);
|
|
66
|
+
return endpoint.startsWith("/") ? `${baseUrlWithKey}${endpoint}` : `${baseUrlWithKey}/${endpoint}`;
|
|
67
|
+
}
|
|
68
|
+
return endpoint.startsWith("/") ? `${this.baseUrl}${endpoint}` : `${this.baseUrl}/${endpoint}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the base URL for the Hedera mirror node based on the network type
|
|
72
|
+
* @returns The mirror node base URL
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
getMirrorNodeUrl() {
|
|
76
|
+
return this.network === "mainnet" ? "https://mainnet-public.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
|
|
77
|
+
}
|
|
78
|
+
getBaseUrl() {
|
|
79
|
+
return this.baseUrl;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves the public key for a given account ID from the mirror node.
|
|
83
|
+
* @param accountId The ID of the account to retrieve the public key for.
|
|
84
|
+
* @returns A promise that resolves to the public key for the given account.
|
|
85
|
+
* @throws An error if the account ID is invalid or the public key cannot be retrieved.
|
|
86
|
+
*/
|
|
87
|
+
async getPublicKey(accountId) {
|
|
88
|
+
this.logger.debug(`Getting public key for account ${accountId}`);
|
|
89
|
+
const accountInfo = await this.requestAccount(accountId);
|
|
90
|
+
try {
|
|
91
|
+
if (!accountInfo || !accountInfo.key) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Failed to retrieve public key for account ID: ${accountId}`
|
|
94
|
+
);
|
|
71
95
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
return PublicKey.fromString(accountInfo.key.key);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
const error = e;
|
|
99
|
+
const logMessage = `Error fetching public key from Mirror Node: ${error.message}`;
|
|
100
|
+
this.logger.error(logMessage);
|
|
101
|
+
throw new Error(logMessage);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves the memo for a given account ID from the mirror node.
|
|
106
|
+
* @param accountId The ID of the account to retrieve the memo for.
|
|
107
|
+
* @returns A promise that resolves to the memo for the given account.
|
|
108
|
+
* @throws An error if the account ID is invalid or the memo cannot be retrieved.
|
|
109
|
+
*/
|
|
110
|
+
async getAccountMemo(accountId) {
|
|
111
|
+
this.logger.debug(`Getting account memo for account ID: ${accountId}`);
|
|
112
|
+
try {
|
|
113
|
+
const accountInfo = await this._requestWithRetry(
|
|
114
|
+
`/api/v1/accounts/${accountId}`
|
|
79
115
|
);
|
|
116
|
+
if (accountInfo?.memo) {
|
|
117
|
+
return accountInfo.memo;
|
|
118
|
+
}
|
|
119
|
+
this.logger.warn(`No memo found for account ${accountId}`);
|
|
120
|
+
return null;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
const error = e;
|
|
123
|
+
this.logger.error(
|
|
124
|
+
`Failed to get account memo for ${accountId} after retries: ${error.message}`
|
|
125
|
+
);
|
|
126
|
+
return null;
|
|
80
127
|
}
|
|
81
128
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves topic information for a given topic ID from the mirror node.
|
|
131
|
+
* @param topicId The ID of the topic to retrieve information for.
|
|
132
|
+
* @returns A promise that resolves to the topic information.
|
|
133
|
+
* @throws An error if the topic ID is invalid or the information cannot be retrieved.
|
|
134
|
+
*/
|
|
135
|
+
async getTopicInfo(topicId) {
|
|
136
|
+
try {
|
|
137
|
+
this.logger.debug(`Fetching topic info for ${topicId}`);
|
|
138
|
+
const data = await this._requestWithRetry(
|
|
139
|
+
`/api/v1/topics/${topicId}`
|
|
140
|
+
);
|
|
141
|
+
return data;
|
|
142
|
+
} catch (e) {
|
|
143
|
+
const error = e;
|
|
144
|
+
const logMessage = `Error retrieving topic information for ${topicId} after retries: ${error.message}`;
|
|
145
|
+
this.logger.error(logMessage);
|
|
146
|
+
throw new Error(logMessage);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves custom fees for a given topic ID from the mirror node.
|
|
151
|
+
* @param topicId The ID of the topic to retrieve custom fees for.
|
|
152
|
+
* @returns A promise that resolves to the custom fees for the given topic.
|
|
153
|
+
* @throws An error if the topic ID is invalid or the custom fees cannot be retrieved.
|
|
154
|
+
*/
|
|
155
|
+
async getTopicFees(topicId) {
|
|
156
|
+
try {
|
|
157
|
+
const topicInfo = await this.getTopicInfo(topicId);
|
|
158
|
+
return topicInfo.custom_fees;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
const error = e;
|
|
161
|
+
const logMessage = `Error retrieving topic fees: ${error.message}`;
|
|
162
|
+
this.logger.error(logMessage);
|
|
163
|
+
return null;
|
|
113
164
|
}
|
|
114
|
-
const api = createEncryptionApi(this);
|
|
115
|
-
this.encryptionApi = api;
|
|
116
|
-
return api;
|
|
117
165
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return;
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves the current HBAR price from the mirror node.
|
|
168
|
+
* @param date The date to retrieve the HBAR price for.
|
|
169
|
+
* @returns A promise that resolves to the HBAR price for the given date.
|
|
170
|
+
* @throws An error if the date is invalid or the price cannot be retrieved.
|
|
171
|
+
*/
|
|
172
|
+
async getHBARPrice(date) {
|
|
173
|
+
try {
|
|
174
|
+
const timestamp = Timestamp.fromDate(date).toString();
|
|
175
|
+
this.logger.debug(`Fetching HBAR price for timestamp ${timestamp}`);
|
|
176
|
+
const response = await this._requestWithRetry(
|
|
177
|
+
`/api/v1/network/exchangerate?timestamp=${timestamp}`
|
|
178
|
+
);
|
|
179
|
+
const usdPrice = Number(response?.current_rate?.cent_equivalent) / Number(response?.current_rate?.hbar_equivalent) / 100;
|
|
180
|
+
return usdPrice;
|
|
181
|
+
} catch (e) {
|
|
182
|
+
const error = e;
|
|
183
|
+
const logMessage = `Error retrieving HBAR price: ${error.message}`;
|
|
184
|
+
this.logger.error(logMessage);
|
|
185
|
+
return null;
|
|
133
186
|
}
|
|
134
|
-
this.defaultHeaders[headerName] = value.trim();
|
|
135
187
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves token information for a given token ID from the mirror node.
|
|
190
|
+
* @param tokenId The ID of the token to retrieve information for.
|
|
191
|
+
* @returns A promise that resolves to the token information.
|
|
192
|
+
* @throws An error if the token ID is invalid or the information cannot be retrieved.
|
|
193
|
+
*/
|
|
194
|
+
async getTokenInfo(tokenId) {
|
|
195
|
+
this.logger.debug(`Fetching token info for ${tokenId}`);
|
|
196
|
+
try {
|
|
197
|
+
const data = await this._requestWithRetry(
|
|
198
|
+
`/api/v1/tokens/${tokenId}`
|
|
199
|
+
);
|
|
200
|
+
if (data) {
|
|
201
|
+
this.logger.trace(`Token info found for ${tokenId}:`, data);
|
|
202
|
+
return data;
|
|
203
|
+
}
|
|
204
|
+
this.logger.warn(`No token info found for ${tokenId}`);
|
|
205
|
+
return null;
|
|
206
|
+
} catch (e) {
|
|
207
|
+
const error = e;
|
|
208
|
+
const logMessage = `Error fetching token info for ${tokenId}: ${error.message}`;
|
|
209
|
+
this.logger.error(logMessage);
|
|
210
|
+
return null;
|
|
142
211
|
}
|
|
143
|
-
await this.encryptionBootstrapPromise;
|
|
144
212
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Retrieves messages for a given topic ID from the mirror node. Supports filtering by sequence number
|
|
215
|
+
* based on the OpenAPI specification.
|
|
216
|
+
* @param topicId The ID of the topic to retrieve messages for.
|
|
217
|
+
* @param options Optional filtering parameters.
|
|
218
|
+
* @returns A promise that resolves to the messages for the given topic.
|
|
219
|
+
*/
|
|
220
|
+
async getTopicMessages(topicId, options) {
|
|
221
|
+
this.logger.trace(
|
|
222
|
+
`Querying messages for topic ${topicId}${options ? " with filters" : ""}`
|
|
223
|
+
);
|
|
224
|
+
let endpoint = `/api/v1/topics/${topicId}/messages`;
|
|
225
|
+
const params = new URLSearchParams();
|
|
226
|
+
if (options) {
|
|
227
|
+
if (options.sequenceNumber !== void 0) {
|
|
228
|
+
const seqNum = typeof options.sequenceNumber === "number" ? options.sequenceNumber.toString() : options.sequenceNumber;
|
|
229
|
+
if (!seqNum.match(/^(gt|gte|lt|lte|eq|ne):/)) {
|
|
230
|
+
params.append("sequencenumber", `gt:${seqNum}`);
|
|
231
|
+
} else {
|
|
232
|
+
params.append("sequencenumber", seqNum);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (options.limit) {
|
|
236
|
+
params.append("limit", options.limit.toString());
|
|
237
|
+
}
|
|
238
|
+
if (options.order) {
|
|
239
|
+
params.append("order", options.order);
|
|
240
|
+
}
|
|
161
241
|
}
|
|
162
|
-
|
|
163
|
-
|
|
242
|
+
const queryString = params.toString();
|
|
243
|
+
if (queryString) {
|
|
244
|
+
endpoint += `?${queryString}`;
|
|
164
245
|
}
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
246
|
+
const messages = [];
|
|
247
|
+
let nextEndpoint = endpoint;
|
|
248
|
+
while (nextEndpoint) {
|
|
249
|
+
try {
|
|
250
|
+
const data = await this._requestWithRetry(nextEndpoint);
|
|
251
|
+
if (data.messages && data.messages.length > 0) {
|
|
252
|
+
for (const message of data.messages) {
|
|
253
|
+
try {
|
|
254
|
+
if (!message.message) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
let messageContent;
|
|
258
|
+
try {
|
|
259
|
+
if (this.isServerEnvironment) {
|
|
260
|
+
messageContent = Buffer.from(
|
|
261
|
+
message.message,
|
|
262
|
+
"base64"
|
|
263
|
+
).toString("utf-8");
|
|
264
|
+
} else {
|
|
265
|
+
messageContent = new TextDecoder().decode(
|
|
266
|
+
Uint8Array.from(
|
|
267
|
+
atob(message.message),
|
|
268
|
+
(c) => c.charCodeAt(0)
|
|
269
|
+
)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
const logMessage = `Error decoding message: ${error}`;
|
|
274
|
+
this.logger.error(logMessage);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
let messageJson;
|
|
278
|
+
try {
|
|
279
|
+
messageJson = JSON.parse(messageContent);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
const logMessage = `Invalid JSON message content: ${messageContent}`;
|
|
282
|
+
this.logger.error(logMessage);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
messageJson.sequence_number = message.sequence_number;
|
|
286
|
+
messages.push({
|
|
287
|
+
...messageJson,
|
|
288
|
+
consensus_timestamp: message.consensus_timestamp,
|
|
289
|
+
sequence_number: message.sequence_number,
|
|
290
|
+
running_hash: message.running_hash,
|
|
291
|
+
running_hash_version: message.running_hash_version,
|
|
292
|
+
topic_id: message.topic_id,
|
|
293
|
+
payer: message.payer_account_id,
|
|
294
|
+
created: new Date(Number(message.consensus_timestamp) * 1e3)
|
|
295
|
+
});
|
|
296
|
+
} catch (error) {
|
|
297
|
+
const logMessage = `Error processing message: ${error.message}`;
|
|
298
|
+
this.logger.error(logMessage);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
nextEndpoint = data.links?.next || "";
|
|
303
|
+
} catch (e) {
|
|
304
|
+
const error = e;
|
|
305
|
+
const logMessage = `Error querying topic messages for topic ${topicId} (endpoint: ${nextEndpoint}) after retries: ${error.message}`;
|
|
306
|
+
this.logger.error(logMessage);
|
|
307
|
+
throw new Error(logMessage);
|
|
173
308
|
}
|
|
174
309
|
}
|
|
175
|
-
return
|
|
310
|
+
return messages;
|
|
176
311
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Requests account information for a given account ID from the mirror node.
|
|
314
|
+
* @param accountId The ID of the account to retrieve information for.
|
|
315
|
+
* @returns A promise that resolves to the account information.
|
|
316
|
+
* @throws An error if the account ID is invalid or the information cannot be retrieved.
|
|
317
|
+
*/
|
|
318
|
+
async requestAccount(accountId) {
|
|
319
|
+
try {
|
|
320
|
+
this.logger.debug(`Requesting account info for ${accountId}`);
|
|
321
|
+
const data = await this._requestWithRetry(
|
|
322
|
+
`/api/v1/accounts/${accountId}`
|
|
323
|
+
);
|
|
324
|
+
if (!data) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`No data received from mirror node for account: ${accountId}`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return data;
|
|
330
|
+
} catch (e) {
|
|
331
|
+
const error = e;
|
|
332
|
+
const logMessage = `Failed to fetch account ${accountId} after retries: ${error.message}`;
|
|
333
|
+
this.logger.error(logMessage);
|
|
334
|
+
throw new Error(logMessage);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Checks if a user has access to a given key list.
|
|
339
|
+
* @param keyBytes The key list to check access for.
|
|
340
|
+
* @param userPublicKey The public key of the user to check access for.
|
|
341
|
+
* @returns A promise that resolves to true if the user has access, false otherwise.
|
|
342
|
+
*/
|
|
343
|
+
async checkKeyListAccess(keyBytes, userPublicKey) {
|
|
344
|
+
try {
|
|
345
|
+
const key = proto.Key.decode(keyBytes);
|
|
346
|
+
return this.evaluateKeyAccess(key, userPublicKey);
|
|
347
|
+
} catch (e) {
|
|
348
|
+
const error = e;
|
|
349
|
+
const logMessage = `Error decoding protobuf key: ${error.message}`;
|
|
350
|
+
this.logger.error(logMessage);
|
|
351
|
+
throw new Error(logMessage);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Evaluates the access of a given key to a user's public key.
|
|
356
|
+
* @param key The key to evaluate access for.
|
|
357
|
+
* @param userPublicKey The public key of the user to evaluate access for.
|
|
358
|
+
* @returns A promise that resolves to true if the key has access, false otherwise.
|
|
359
|
+
*/
|
|
360
|
+
async evaluateKeyAccess(key, userPublicKey) {
|
|
361
|
+
if (key.ed25519) {
|
|
362
|
+
return this.compareEd25519Key(key.ed25519, userPublicKey);
|
|
363
|
+
}
|
|
364
|
+
if (key.keyList) {
|
|
365
|
+
return this.evaluateKeyList(key.keyList, userPublicKey);
|
|
366
|
+
}
|
|
367
|
+
if (key.thresholdKey && key.thresholdKey.keys) {
|
|
368
|
+
return this.evaluateKeyList(key.thresholdKey.keys, userPublicKey);
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Evaluates the access of a given key list to a user's public key.
|
|
374
|
+
* @param keyList The key list to evaluate access for.
|
|
375
|
+
* @param userPublicKey The public key of the user to evaluate access for.
|
|
376
|
+
* @returns A promise that resolves to true if the key list has access, false otherwise.
|
|
377
|
+
*/
|
|
378
|
+
async evaluateKeyList(keyList, userPublicKey) {
|
|
379
|
+
const keys = keyList.keys || [];
|
|
380
|
+
for (const listKey of keys) {
|
|
381
|
+
if (!listKey) continue;
|
|
382
|
+
if (listKey.ed25519) {
|
|
383
|
+
if (this.compareEd25519Key(listKey.ed25519, userPublicKey)) {
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
} else if (listKey.keyList || listKey.thresholdKey) {
|
|
387
|
+
try {
|
|
388
|
+
const nestedKeyBytes = proto.Key.encode({
|
|
389
|
+
...listKey.keyList ? { keyList: listKey.keyList } : {},
|
|
390
|
+
...listKey.thresholdKey ? { thresholdKey: listKey.thresholdKey } : {}
|
|
391
|
+
}).finish();
|
|
392
|
+
const hasNestedAccess = await this.checkKeyListAccess(
|
|
393
|
+
Buffer.from(nestedKeyBytes),
|
|
394
|
+
userPublicKey
|
|
395
|
+
);
|
|
396
|
+
if (hasNestedAccess) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
} catch (e) {
|
|
400
|
+
const error = e;
|
|
401
|
+
const logMessage = `Error in nested key: ${error.message}`;
|
|
402
|
+
this.logger.debug(logMessage);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
182
405
|
}
|
|
183
|
-
|
|
184
|
-
throw new RegistryBrokerError("Registry broker request failed", {
|
|
185
|
-
status: response.status,
|
|
186
|
-
statusText: response.statusText,
|
|
187
|
-
body: errorBody
|
|
188
|
-
});
|
|
406
|
+
return false;
|
|
189
407
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Compares an Ed25519 key with a user's public key.
|
|
410
|
+
* @param keyData The Ed25519 key data to compare.
|
|
411
|
+
* @param userPublicKey The public key of the user to compare with.
|
|
412
|
+
* @returns A boolean indicating whether the key matches the user's public key.
|
|
413
|
+
*/
|
|
414
|
+
compareEd25519Key(keyData, userPublicKey) {
|
|
415
|
+
try {
|
|
416
|
+
const decodedKey = PublicKey.fromBytes(Buffer.from(keyData));
|
|
417
|
+
return decodedKey.toString() === userPublicKey.toString();
|
|
418
|
+
} catch (e) {
|
|
419
|
+
const error = e;
|
|
420
|
+
const logMessage = `Error comparing Ed25519 key: ${error.message}`;
|
|
421
|
+
this.logger.debug(logMessage);
|
|
422
|
+
return false;
|
|
195
423
|
}
|
|
196
|
-
const errorBody = await this.extractErrorBody(response);
|
|
197
|
-
throw new RegistryBrokerError("Registry broker request failed", {
|
|
198
|
-
status: response.status,
|
|
199
|
-
statusText: response.statusText,
|
|
200
|
-
body: errorBody
|
|
201
|
-
});
|
|
202
424
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
425
|
+
/**
|
|
426
|
+
* Retrieves information about a scheduled transaction
|
|
427
|
+
* @param scheduleId The ID of the scheduled transaction
|
|
428
|
+
* @returns A promise that resolves to the scheduled transaction information
|
|
429
|
+
*/
|
|
430
|
+
async getScheduleInfo(scheduleId) {
|
|
431
|
+
try {
|
|
432
|
+
this.logger.info(
|
|
433
|
+
`Getting information for scheduled transaction ${scheduleId}`
|
|
211
434
|
);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
435
|
+
const data = await this._requestWithRetry(
|
|
436
|
+
`/api/v1/schedules/${scheduleId}`
|
|
437
|
+
);
|
|
438
|
+
if (data) {
|
|
439
|
+
return data;
|
|
440
|
+
}
|
|
441
|
+
this.logger.warn(
|
|
442
|
+
`No schedule info found for ${scheduleId} after retries.`
|
|
443
|
+
);
|
|
444
|
+
return null;
|
|
445
|
+
} catch (error) {
|
|
446
|
+
this.logger.error(
|
|
447
|
+
`Error fetching schedule info for ${scheduleId} after retries: ${error.message}`
|
|
223
448
|
);
|
|
449
|
+
return null;
|
|
224
450
|
}
|
|
225
|
-
return await response.json();
|
|
226
451
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Checks the status of a scheduled transaction
|
|
454
|
+
* @param scheduleId The schedule ID to check
|
|
455
|
+
* @returns Status of the scheduled transaction
|
|
456
|
+
*/
|
|
457
|
+
async getScheduledTransactionStatus(scheduleId) {
|
|
458
|
+
try {
|
|
459
|
+
this.logger.info(
|
|
460
|
+
`Checking status of scheduled transaction ${scheduleId}`
|
|
461
|
+
);
|
|
462
|
+
const scheduleInfo = await this.getScheduleInfo(scheduleId);
|
|
463
|
+
if (!scheduleInfo) {
|
|
464
|
+
throw new Error(`Schedule ${scheduleId} not found`);
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
executed: Boolean(scheduleInfo.executed_timestamp),
|
|
468
|
+
executedDate: scheduleInfo.executed_timestamp ? new Date(Number(scheduleInfo.executed_timestamp) * 1e3) : void 0,
|
|
469
|
+
deleted: scheduleInfo.deleted || false
|
|
470
|
+
};
|
|
471
|
+
} catch (error) {
|
|
472
|
+
this.logger.error(
|
|
473
|
+
`Error checking scheduled transaction status: ${error}`
|
|
474
|
+
);
|
|
475
|
+
throw error;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Retrieves details for a given transaction ID or hash from the mirror node.
|
|
480
|
+
* @param transactionIdOrHash The ID or hash of the transaction.
|
|
481
|
+
* @returns A promise that resolves to the transaction details.
|
|
482
|
+
* @throws An error if the transaction ID/hash is invalid or details cannot be retrieved.
|
|
483
|
+
*/
|
|
484
|
+
async getTransaction(transactionIdOrHash) {
|
|
485
|
+
this.logger.info(
|
|
486
|
+
`Getting transaction details for ID/hash: ${transactionIdOrHash}`
|
|
241
487
|
);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
488
|
+
try {
|
|
489
|
+
const response = await this._requestWithRetry(`/api/v1/transactions/${transactionIdOrHash}`);
|
|
490
|
+
if (response?.transactions?.length > 0) {
|
|
491
|
+
this.logger.trace(
|
|
492
|
+
`Transaction details found for ${transactionIdOrHash}:`,
|
|
493
|
+
response.transactions[0]
|
|
494
|
+
);
|
|
495
|
+
return response.transactions[0];
|
|
496
|
+
}
|
|
497
|
+
this.logger.warn(
|
|
498
|
+
`No transaction details found for ${transactionIdOrHash} or unexpected response structure.`
|
|
499
|
+
);
|
|
500
|
+
return null;
|
|
501
|
+
} catch (e) {
|
|
502
|
+
const error = e;
|
|
503
|
+
this.logger.error(
|
|
504
|
+
`Failed to get transaction details for ${transactionIdOrHash} after retries: ${error.message}`
|
|
505
|
+
);
|
|
506
|
+
return null;
|
|
253
507
|
}
|
|
254
|
-
const suffix = params.size > 0 ? `?${params.toString()}` : "";
|
|
255
|
-
const raw = await this.requestJson(`/agents/feedback${suffix}`, {
|
|
256
|
-
method: "GET"
|
|
257
|
-
});
|
|
258
|
-
return this.parseWithSchema(
|
|
259
|
-
raw,
|
|
260
|
-
agentFeedbackIndexResponseSchema,
|
|
261
|
-
"agent feedback index response"
|
|
262
|
-
);
|
|
263
508
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
509
|
+
/**
|
|
510
|
+
* Private helper to make GET requests with retry logic using Axios.
|
|
511
|
+
*/
|
|
512
|
+
async _requestWithRetry(endpoint, axiosConfig) {
|
|
513
|
+
let attempt = 0;
|
|
514
|
+
let delay = this.initialDelayMs;
|
|
515
|
+
const url = this.constructUrl(endpoint);
|
|
516
|
+
const config = {
|
|
517
|
+
...axiosConfig,
|
|
518
|
+
headers: {
|
|
519
|
+
...this.customHeaders,
|
|
520
|
+
...axiosConfig?.headers
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
if (this.apiKey) {
|
|
524
|
+
config.headers = {
|
|
525
|
+
...config.headers,
|
|
526
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
527
|
+
"X-API-Key": this.apiKey
|
|
528
|
+
};
|
|
271
529
|
}
|
|
272
|
-
|
|
273
|
-
|
|
530
|
+
while (attempt < this.maxRetries) {
|
|
531
|
+
try {
|
|
532
|
+
const response = await axios.get(url, config);
|
|
533
|
+
return response.data;
|
|
534
|
+
} catch (error) {
|
|
535
|
+
attempt++;
|
|
536
|
+
const isLastAttempt = attempt >= this.maxRetries;
|
|
537
|
+
const statusCode = error.response?.status;
|
|
538
|
+
if (statusCode && statusCode > 404 && statusCode < 500 && statusCode !== 429) {
|
|
539
|
+
this.logger.error(
|
|
540
|
+
`Client error for ${url} (status ${statusCode}): ${error.message}. Not retrying.`
|
|
541
|
+
);
|
|
542
|
+
throw error;
|
|
543
|
+
}
|
|
544
|
+
if (isLastAttempt) {
|
|
545
|
+
this.logger.error(
|
|
546
|
+
`Max retries (${this.maxRetries}) reached for ${url}. Last error: ${error.message}`
|
|
547
|
+
);
|
|
548
|
+
throw error;
|
|
549
|
+
}
|
|
550
|
+
this.logger.warn(
|
|
551
|
+
`Attempt ${attempt}/${this.maxRetries} failed for ${url}: ${error.message}. Retrying in ${delay}ms...`
|
|
552
|
+
);
|
|
553
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
554
|
+
delay = Math.min(delay * this.backoffFactor, this.maxDelayMs);
|
|
555
|
+
}
|
|
274
556
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
`/agents/feedback/entries${suffix}`,
|
|
278
|
-
{ method: "GET" }
|
|
279
|
-
);
|
|
280
|
-
return this.parseWithSchema(
|
|
281
|
-
raw,
|
|
282
|
-
agentFeedbackEntriesIndexResponseSchema,
|
|
283
|
-
"agent feedback entries index response"
|
|
557
|
+
throw new Error(
|
|
558
|
+
`Failed to fetch data from ${url} after ${this.maxRetries} attempts.`
|
|
284
559
|
);
|
|
285
560
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
561
|
+
/**
|
|
562
|
+
* Private helper to make fetch requests with retry logic.
|
|
563
|
+
*/
|
|
564
|
+
async _fetchWithRetry(url, fetchOptions) {
|
|
565
|
+
let attempt = 0;
|
|
566
|
+
let delay = this.initialDelayMs;
|
|
567
|
+
const headers = {
|
|
568
|
+
...this.customHeaders
|
|
569
|
+
};
|
|
570
|
+
if (fetchOptions?.headers) {
|
|
571
|
+
if (fetchOptions.headers instanceof Headers) {
|
|
572
|
+
fetchOptions.headers.forEach((value, key) => {
|
|
573
|
+
headers[key] = value;
|
|
574
|
+
});
|
|
575
|
+
} else if (Array.isArray(fetchOptions.headers)) {
|
|
576
|
+
fetchOptions.headers.forEach(([key, value]) => {
|
|
577
|
+
headers[key] = value;
|
|
578
|
+
});
|
|
579
|
+
} else {
|
|
580
|
+
Object.assign(headers, fetchOptions.headers);
|
|
297
581
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
582
|
+
}
|
|
583
|
+
if (this.apiKey) {
|
|
584
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
585
|
+
headers["X-API-Key"] = this.apiKey;
|
|
586
|
+
}
|
|
587
|
+
const options = {
|
|
588
|
+
...fetchOptions,
|
|
589
|
+
headers
|
|
590
|
+
};
|
|
591
|
+
while (attempt < this.maxRetries) {
|
|
592
|
+
try {
|
|
593
|
+
const request = await fetch(url, options);
|
|
594
|
+
if (!request.ok) {
|
|
595
|
+
if (request.status >= 400 && request.status < 500 && request.status !== 429) {
|
|
596
|
+
this.logger.error(
|
|
597
|
+
`Client error for ${url} (status ${request.status}): ${request.statusText}. Not retrying.`
|
|
598
|
+
);
|
|
599
|
+
throw new Error(
|
|
600
|
+
`Fetch failed with status ${request.status}: ${request.statusText} for URL: ${url}`
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
throw new Error(
|
|
604
|
+
`Fetch failed with status ${request.status}: ${request.statusText} for URL: ${url}`
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
const response = await request.json();
|
|
608
|
+
return response;
|
|
609
|
+
} catch (error) {
|
|
610
|
+
attempt++;
|
|
611
|
+
if (attempt >= this.maxRetries) {
|
|
612
|
+
this.logger.error(
|
|
613
|
+
`Max retries (${this.maxRetries}) reached for ${url}. Last error: ${error.message}`
|
|
614
|
+
);
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
this.logger.warn(
|
|
618
|
+
`Attempt ${attempt}/${this.maxRetries} failed for ${url}: ${error.message}. Retrying in ${delay}ms...`
|
|
619
|
+
);
|
|
620
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
621
|
+
delay = Math.min(delay * this.backoffFactor, this.maxDelayMs);
|
|
316
622
|
}
|
|
623
|
+
}
|
|
624
|
+
throw new Error(
|
|
625
|
+
`Failed to fetch data from ${url} after ${this.maxRetries} attempts.`
|
|
317
626
|
);
|
|
318
|
-
return this.parseWithSchema(
|
|
319
|
-
raw,
|
|
320
|
-
agentFeedbackSubmissionResponseSchema,
|
|
321
|
-
"agent feedback submission response"
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
async search(params = {}) {
|
|
325
|
-
return search(this, params);
|
|
326
627
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
const nativeId = `${chainId}:${agentId}`;
|
|
341
|
-
return search(this, {
|
|
342
|
-
registries: ["erc-8004"],
|
|
343
|
-
limit: params.limit ?? 1,
|
|
344
|
-
...typeof params.page === "number" ? { page: params.page } : {},
|
|
345
|
-
...typeof params.sortBy === "string" ? { sortBy: params.sortBy } : {},
|
|
346
|
-
...typeof params.sortOrder === "string" ? { sortOrder: params.sortOrder } : {},
|
|
347
|
-
metadata: {
|
|
348
|
-
nativeId: [nativeId],
|
|
349
|
-
networkKey: [`eip155:${chainId}`]
|
|
628
|
+
/**
|
|
629
|
+
* Retrieves the numerical balance (in HBAR) for a given account ID.
|
|
630
|
+
* @param accountId The ID of the account.
|
|
631
|
+
* @returns A promise that resolves to the HBAR balance or null if an error occurs.
|
|
632
|
+
*/
|
|
633
|
+
async getAccountBalance(accountId) {
|
|
634
|
+
this.logger.info(`Getting balance for account ${accountId}`);
|
|
635
|
+
try {
|
|
636
|
+
const accountInfo = await this.requestAccount(accountId);
|
|
637
|
+
if (accountInfo && accountInfo.balance) {
|
|
638
|
+
const hbarBalance = accountInfo.balance.balance / 1e8;
|
|
639
|
+
return hbarBalance;
|
|
350
640
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
async popularSearches() {
|
|
363
|
-
return popularSearches(this);
|
|
364
|
-
}
|
|
365
|
-
async listProtocols() {
|
|
366
|
-
return listProtocols(this);
|
|
367
|
-
}
|
|
368
|
-
async detectProtocol(message) {
|
|
369
|
-
return detectProtocol(this, message);
|
|
370
|
-
}
|
|
371
|
-
async registrySearchByNamespace(registry, query) {
|
|
372
|
-
return registrySearchByNamespace(this, registry, query);
|
|
373
|
-
}
|
|
374
|
-
async vectorSearch(request) {
|
|
375
|
-
return vectorSearch(this, request);
|
|
376
|
-
}
|
|
377
|
-
async searchStatus() {
|
|
378
|
-
return searchStatus(this);
|
|
379
|
-
}
|
|
380
|
-
async websocketStats() {
|
|
381
|
-
return websocketStats(this);
|
|
382
|
-
}
|
|
383
|
-
async metricsSummary() {
|
|
384
|
-
return metricsSummary(this);
|
|
385
|
-
}
|
|
386
|
-
async facets(adapter) {
|
|
387
|
-
return facets(this, adapter);
|
|
388
|
-
}
|
|
389
|
-
async adapters() {
|
|
390
|
-
return adapters(this);
|
|
391
|
-
}
|
|
392
|
-
async skillsConfig() {
|
|
393
|
-
return skillsConfig(this);
|
|
394
|
-
}
|
|
395
|
-
async listSkills(options) {
|
|
396
|
-
return listSkills(this, options);
|
|
397
|
-
}
|
|
398
|
-
async getSkillsCatalog(options) {
|
|
399
|
-
return getSkillsCatalog(this, options);
|
|
400
|
-
}
|
|
401
|
-
async listSkillVersions(params) {
|
|
402
|
-
return listSkillVersions(this, params);
|
|
403
|
-
}
|
|
404
|
-
async listMySkills(params) {
|
|
405
|
-
return listMySkills(this, params);
|
|
406
|
-
}
|
|
407
|
-
async getMySkillsList(params) {
|
|
408
|
-
return getMySkillsList(this, params);
|
|
409
|
-
}
|
|
410
|
-
async quoteSkillPublish(payload) {
|
|
411
|
-
return quoteSkillPublish(this, payload);
|
|
412
|
-
}
|
|
413
|
-
async quoteSkillPublishPreview(payload) {
|
|
414
|
-
return quoteSkillPublishPreview(this, payload);
|
|
415
|
-
}
|
|
416
|
-
async publishSkill(payload) {
|
|
417
|
-
return publishSkill(this, payload);
|
|
418
|
-
}
|
|
419
|
-
async getSkillPublishJob(jobId, params) {
|
|
420
|
-
return getSkillPublishJob(this, jobId, params);
|
|
421
|
-
}
|
|
422
|
-
async getSkillOwnership(params) {
|
|
423
|
-
return getSkillOwnership(this, params);
|
|
424
|
-
}
|
|
425
|
-
async getRecommendedSkillVersion(params) {
|
|
426
|
-
return getRecommendedSkillVersion(this, params);
|
|
427
|
-
}
|
|
428
|
-
async setRecommendedSkillVersion(payload) {
|
|
429
|
-
return setRecommendedSkillVersion(this, payload);
|
|
430
|
-
}
|
|
431
|
-
async getSkillDeprecations(params) {
|
|
432
|
-
return getSkillDeprecations(this, params);
|
|
433
|
-
}
|
|
434
|
-
async setSkillDeprecation(payload) {
|
|
435
|
-
return setSkillDeprecation(this, payload);
|
|
436
|
-
}
|
|
437
|
-
async getSkillBadge(params) {
|
|
438
|
-
return getSkillBadge(this, params);
|
|
439
|
-
}
|
|
440
|
-
async getSkillStatus(params) {
|
|
441
|
-
return getSkillStatus(this, params);
|
|
442
|
-
}
|
|
443
|
-
async getSkillSecurityBreakdown(params) {
|
|
444
|
-
return getSkillSecurityBreakdown(this, params);
|
|
445
|
-
}
|
|
446
|
-
async getSkillStatusByRepo(params) {
|
|
447
|
-
return getSkillStatusByRepo(this, params);
|
|
448
|
-
}
|
|
449
|
-
async getSkillConversionSignalsByRepo(params) {
|
|
450
|
-
return getSkillConversionSignalsByRepo(this, params);
|
|
451
|
-
}
|
|
452
|
-
async uploadSkillPreviewFromGithubOidc(payload) {
|
|
453
|
-
return uploadSkillPreviewFromGithubOidc(this, payload);
|
|
454
|
-
}
|
|
455
|
-
async getSkillPreview(params) {
|
|
456
|
-
return getSkillPreview(this, params);
|
|
457
|
-
}
|
|
458
|
-
async getSkillPreviewByRepo(params) {
|
|
459
|
-
return getSkillPreviewByRepo(this, params);
|
|
460
|
-
}
|
|
461
|
-
async getSkillPreviewById(previewId) {
|
|
462
|
-
return getSkillPreviewById(this, previewId);
|
|
463
|
-
}
|
|
464
|
-
async getSkillInstall(skillRef) {
|
|
465
|
-
return getSkillInstall(this, skillRef);
|
|
466
|
-
}
|
|
467
|
-
async recordSkillInstallCopy(skillRef, payload) {
|
|
468
|
-
return recordSkillInstallCopy(this, skillRef, payload);
|
|
469
|
-
}
|
|
470
|
-
async listSkillTags() {
|
|
471
|
-
return listSkillTags(this);
|
|
472
|
-
}
|
|
473
|
-
async listSkillCategories() {
|
|
474
|
-
return listSkillCategories(this);
|
|
475
|
-
}
|
|
476
|
-
async resolveSkillMarkdown(skillRef) {
|
|
477
|
-
return resolveSkillMarkdown(this, skillRef);
|
|
478
|
-
}
|
|
479
|
-
async resolveSkillManifest(skillRef) {
|
|
480
|
-
return resolveSkillManifest(this, skillRef);
|
|
481
|
-
}
|
|
482
|
-
async getSkillVoteStatus(params) {
|
|
483
|
-
return getSkillVoteStatus(this, params);
|
|
484
|
-
}
|
|
485
|
-
async setSkillVote(payload) {
|
|
486
|
-
return setSkillVote(this, payload);
|
|
487
|
-
}
|
|
488
|
-
async requestSkillVerification(payload) {
|
|
489
|
-
return requestSkillVerification(this, payload);
|
|
490
|
-
}
|
|
491
|
-
async getSkillVerificationStatus(params) {
|
|
492
|
-
return getSkillVerificationStatus(this, params);
|
|
493
|
-
}
|
|
494
|
-
async createSkillDomainProofChallenge(payload) {
|
|
495
|
-
return createSkillDomainProofChallenge(this, payload);
|
|
496
|
-
}
|
|
497
|
-
async verifySkillDomainProof(payload) {
|
|
498
|
-
return verifySkillDomainProof(this, payload);
|
|
499
|
-
}
|
|
500
|
-
async adaptersDetailed() {
|
|
501
|
-
return adaptersDetailed(this);
|
|
502
|
-
}
|
|
503
|
-
async adapterRegistryCategories() {
|
|
504
|
-
return adapterRegistryCategories(this);
|
|
505
|
-
}
|
|
506
|
-
async adapterRegistryAdapters(filters) {
|
|
507
|
-
return adapterRegistryAdapters(this, filters);
|
|
508
|
-
}
|
|
509
|
-
async createAdapterRegistryCategory(payload) {
|
|
510
|
-
return createAdapterRegistryCategory(this, payload);
|
|
511
|
-
}
|
|
512
|
-
async submitAdapterRegistryAdapter(payload) {
|
|
513
|
-
return submitAdapterRegistryAdapter(this, payload);
|
|
514
|
-
}
|
|
515
|
-
async adapterRegistrySubmissionStatus(submissionId) {
|
|
516
|
-
return adapterRegistrySubmissionStatus(this, submissionId);
|
|
517
|
-
}
|
|
518
|
-
async resolveUaid(uaid) {
|
|
519
|
-
return resolveUaid(this, uaid);
|
|
641
|
+
this.logger.warn(
|
|
642
|
+
`Could not retrieve balance for account ${accountId} from account info.`
|
|
643
|
+
);
|
|
644
|
+
return null;
|
|
645
|
+
} catch (error) {
|
|
646
|
+
this.logger.error(
|
|
647
|
+
`Error fetching numerical balance for account ${accountId}: ${error.message}`
|
|
648
|
+
);
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
520
651
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
652
|
+
/**
|
|
653
|
+
* Retrieves messages for a given topic ID with optional filters.
|
|
654
|
+
* @param topicId The ID of the topic.
|
|
655
|
+
* @param sequenceNumber Filter by sequence number (e.g., "gt:10", "lte:20").
|
|
656
|
+
* @param startTime Filter by consensus timestamp (e.g., "gt:1629400000.000000000").
|
|
657
|
+
* @param endTime Filter by consensus timestamp (e.g., "lt:1629500000.000000000").
|
|
658
|
+
* @param limit The maximum number of messages to return.
|
|
659
|
+
* @returns A promise that resolves to an array of HCSMessages or null.
|
|
660
|
+
*/
|
|
661
|
+
async getTopicMessagesByFilter(topicId, options) {
|
|
662
|
+
this.logger.trace(
|
|
663
|
+
`Querying messages for topic ${topicId} with filters: ${JSON.stringify(
|
|
664
|
+
options
|
|
665
|
+
)}`
|
|
531
666
|
);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
|
|
667
|
+
let nextUrl = `/api/v1/topics/${topicId}/messages`;
|
|
668
|
+
const params = new URLSearchParams();
|
|
669
|
+
if (options?.limit) {
|
|
670
|
+
params.append("limit", options.limit.toString());
|
|
536
671
|
}
|
|
537
|
-
if (
|
|
538
|
-
|
|
672
|
+
if (options?.sequenceNumber) {
|
|
673
|
+
params.append("sequencenumber", options.sequenceNumber);
|
|
539
674
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return tinybars / 1e8;
|
|
543
|
-
}
|
|
544
|
-
resolveCreditsToPurchase(shortfallCredits) {
|
|
545
|
-
if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {
|
|
546
|
-
return 0;
|
|
675
|
+
if (options?.startTime) {
|
|
676
|
+
params.append("timestamp", `gte:${options.startTime}`);
|
|
547
677
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
)
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
678
|
+
if (options?.endTime) {
|
|
679
|
+
params.append("timestamp", `lt:${options.endTime}`);
|
|
680
|
+
}
|
|
681
|
+
if (options?.order) {
|
|
682
|
+
params.append("order", options.order);
|
|
683
|
+
}
|
|
684
|
+
const queryString = params.toString();
|
|
685
|
+
if (queryString) {
|
|
686
|
+
nextUrl += `?${queryString}`;
|
|
687
|
+
}
|
|
688
|
+
const messages = [];
|
|
689
|
+
let pagesFetched = 0;
|
|
690
|
+
const maxPages = 10;
|
|
691
|
+
try {
|
|
692
|
+
while (nextUrl && pagesFetched < maxPages) {
|
|
693
|
+
pagesFetched++;
|
|
694
|
+
const data = await this._requestWithRetry(nextUrl);
|
|
695
|
+
if (data.messages && data.messages.length > 0) {
|
|
696
|
+
for (const message of data.messages) {
|
|
697
|
+
try {
|
|
698
|
+
if (!message.message) {
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
let messageContent;
|
|
702
|
+
if (this.isServerEnvironment) {
|
|
703
|
+
messageContent = Buffer.from(
|
|
704
|
+
message.message,
|
|
705
|
+
"base64"
|
|
706
|
+
).toString("utf-8");
|
|
707
|
+
} else {
|
|
708
|
+
messageContent = new TextDecoder().decode(
|
|
709
|
+
Uint8Array.from(atob(message.message), (c) => c.charCodeAt(0))
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
let messageJson = {};
|
|
713
|
+
try {
|
|
714
|
+
messageJson = JSON.parse(messageContent);
|
|
715
|
+
} catch (parseError) {
|
|
716
|
+
this.logger.debug(
|
|
717
|
+
`Message content is not valid JSON, using raw: ${messageContent}`
|
|
718
|
+
);
|
|
719
|
+
messageJson = { raw_content: messageContent };
|
|
720
|
+
}
|
|
721
|
+
const parsedContent = messageJson;
|
|
722
|
+
const hcsMsg = {
|
|
723
|
+
...parsedContent,
|
|
724
|
+
consensus_timestamp: message.consensus_timestamp,
|
|
725
|
+
sequence_number: message.sequence_number,
|
|
726
|
+
payer_account_id: message.payer_account_id,
|
|
727
|
+
topic_id: message.topic_id,
|
|
728
|
+
running_hash: message.running_hash,
|
|
729
|
+
running_hash_version: message.running_hash_version,
|
|
730
|
+
chunk_info: message.chunk_info,
|
|
731
|
+
created: new Date(
|
|
732
|
+
Number(message.consensus_timestamp.split(".")[0]) * 1e3 + Number(message.consensus_timestamp.split(".")[1] || 0) / 1e6
|
|
733
|
+
),
|
|
734
|
+
payer: message.payer_account_id
|
|
735
|
+
};
|
|
736
|
+
messages.push(hcsMsg);
|
|
737
|
+
} catch (error) {
|
|
738
|
+
this.logger.error(
|
|
739
|
+
`Error processing individual message: ${error.message}`
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (options?.limit && messages.length >= options.limit) break;
|
|
745
|
+
nextUrl = data.links?.next ? `${data.links.next}` : "";
|
|
577
746
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
747
|
+
return messages;
|
|
748
|
+
} catch (e) {
|
|
749
|
+
const error = e;
|
|
750
|
+
this.logger.error(
|
|
751
|
+
`Error querying filtered topic messages for ${topicId}: ${error.message}`
|
|
581
752
|
);
|
|
582
|
-
|
|
583
|
-
accountId: details.accountId.trim(),
|
|
584
|
-
privateKey: details.privateKey.trim(),
|
|
585
|
-
hbarAmount,
|
|
586
|
-
memo: details.memo ?? "Registry Broker auto top-up",
|
|
587
|
-
metadata: {
|
|
588
|
-
shortfallCredits: shortfall,
|
|
589
|
-
requiredCredits: quote.requiredCredits,
|
|
590
|
-
purchasedCredits: creditsToPurchase
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
const finalQuote = await this.getRegistrationQuote(payload);
|
|
595
|
-
if ((finalQuote.shortfallCredits ?? 0) > 0) {
|
|
596
|
-
throw new Error("Unable to purchase sufficient credits for registration");
|
|
753
|
+
return null;
|
|
597
754
|
}
|
|
598
755
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
756
|
+
/**
|
|
757
|
+
* Retrieves token balances for a given account ID.
|
|
758
|
+
* @param accountId The ID of the account.
|
|
759
|
+
* @param limit The maximum number of tokens to return.
|
|
760
|
+
* @returns A promise that resolves to an array of AccountTokenBalance or null.
|
|
761
|
+
*/
|
|
762
|
+
async getAccountTokens(accountId, limit = 100) {
|
|
763
|
+
this.logger.info(`Getting tokens for account ${accountId}`);
|
|
764
|
+
let allTokens = [];
|
|
765
|
+
let endpoint = `/api/v1/accounts/${accountId}/tokens?limit=${limit}`;
|
|
766
|
+
try {
|
|
767
|
+
for (let i = 0; i < 10 && endpoint; i++) {
|
|
768
|
+
const response = await this._requestWithRetry(endpoint);
|
|
769
|
+
if (response && response.tokens) {
|
|
770
|
+
allTokens = allTokens.concat(response.tokens);
|
|
771
|
+
}
|
|
772
|
+
endpoint = response.links?.next || "";
|
|
773
|
+
if (!endpoint || limit && allTokens.length >= limit) {
|
|
774
|
+
if (limit && allTokens.length > limit) {
|
|
775
|
+
allTokens = allTokens.slice(0, limit);
|
|
776
|
+
}
|
|
777
|
+
break;
|
|
615
778
|
}
|
|
616
|
-
throw error;
|
|
617
779
|
}
|
|
780
|
+
return allTokens;
|
|
781
|
+
} catch (error) {
|
|
782
|
+
this.logger.error(
|
|
783
|
+
`Error fetching tokens for account ${accountId}: ${error.message}`
|
|
784
|
+
);
|
|
785
|
+
return null;
|
|
618
786
|
}
|
|
619
787
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
async
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
async dashboardStats() {
|
|
648
|
-
return dashboardStats(this);
|
|
649
|
-
}
|
|
650
|
-
async getCreditsBalance(params = {}) {
|
|
651
|
-
return getCreditsBalance(this, params);
|
|
652
|
-
}
|
|
653
|
-
async getCreditProviders() {
|
|
654
|
-
return getCreditProviders(this);
|
|
655
|
-
}
|
|
656
|
-
async getGuardSession() {
|
|
657
|
-
return getGuardSession(this);
|
|
658
|
-
}
|
|
659
|
-
async getGuardEntitlements() {
|
|
660
|
-
return getGuardEntitlements(this);
|
|
661
|
-
}
|
|
662
|
-
async getGuardBillingBalance() {
|
|
663
|
-
return getGuardBillingBalance(this);
|
|
664
|
-
}
|
|
665
|
-
async getGuardFeed(limit) {
|
|
666
|
-
return getGuardFeed(this, limit);
|
|
667
|
-
}
|
|
668
|
-
async getGuardOverview() {
|
|
669
|
-
return getGuardOverview(this);
|
|
670
|
-
}
|
|
671
|
-
async getGuardTrustByHash(sha256) {
|
|
672
|
-
return getGuardTrustByHash(this, sha256);
|
|
673
|
-
}
|
|
674
|
-
async resolveGuardTrust(query) {
|
|
675
|
-
return resolveGuardTrust(this, query);
|
|
676
|
-
}
|
|
677
|
-
async getGuardRevocations() {
|
|
678
|
-
return getGuardRevocations(this);
|
|
679
|
-
}
|
|
680
|
-
async fetchGuardAdvisories() {
|
|
681
|
-
return fetchGuardAdvisories(this);
|
|
682
|
-
}
|
|
683
|
-
async fetchGuardPolicy() {
|
|
684
|
-
return fetchGuardPolicy(this);
|
|
685
|
-
}
|
|
686
|
-
async getGuardInventory() {
|
|
687
|
-
return getGuardInventory(this);
|
|
688
|
-
}
|
|
689
|
-
async getGuardReceiptHistory() {
|
|
690
|
-
return getGuardReceiptHistory(this);
|
|
691
|
-
}
|
|
692
|
-
async getGuardArtifactTimeline(artifactId) {
|
|
693
|
-
return getGuardArtifactTimeline(this, artifactId);
|
|
694
|
-
}
|
|
695
|
-
async getGuardInventoryDiff() {
|
|
696
|
-
return getGuardInventoryDiff(this);
|
|
697
|
-
}
|
|
698
|
-
async exportGuardAbom() {
|
|
699
|
-
return exportGuardAbom(this);
|
|
700
|
-
}
|
|
701
|
-
async exportGuardArtifactAbom(artifactId) {
|
|
702
|
-
return exportGuardArtifactAbom(this, artifactId);
|
|
703
|
-
}
|
|
704
|
-
async exportGuardReceipts() {
|
|
705
|
-
return exportGuardReceipts(this);
|
|
706
|
-
}
|
|
707
|
-
async getGuardDevices() {
|
|
708
|
-
return getGuardDevices(this);
|
|
709
|
-
}
|
|
710
|
-
async getGuardAlertPreferences() {
|
|
711
|
-
return getGuardAlertPreferences(this);
|
|
712
|
-
}
|
|
713
|
-
async updateGuardAlertPreferences(payload) {
|
|
714
|
-
return updateGuardAlertPreferences(this, payload);
|
|
715
|
-
}
|
|
716
|
-
async getGuardExceptions() {
|
|
717
|
-
return getGuardExceptions(this);
|
|
718
|
-
}
|
|
719
|
-
async getGuardWatchlist() {
|
|
720
|
-
return getGuardWatchlist(this);
|
|
721
|
-
}
|
|
722
|
-
async lookupGuardWatchlist(payload) {
|
|
723
|
-
return lookupGuardWatchlist(this, payload);
|
|
724
|
-
}
|
|
725
|
-
async getGuardPainSignals() {
|
|
726
|
-
return getGuardPainSignals(this);
|
|
727
|
-
}
|
|
728
|
-
async getGuardAggregatedPainSignals() {
|
|
729
|
-
return getGuardAggregatedPainSignals(this);
|
|
730
|
-
}
|
|
731
|
-
async getGuardPreInstallVerdict(payload) {
|
|
732
|
-
return getGuardPreInstallVerdict(this, payload);
|
|
733
|
-
}
|
|
734
|
-
async getGuardPreExecutionVerdict(payload) {
|
|
735
|
-
return getGuardPreExecutionVerdict(this, payload);
|
|
736
|
-
}
|
|
737
|
-
async addGuardWatchlistItem(payload) {
|
|
738
|
-
return addGuardWatchlistItem(this, payload);
|
|
739
|
-
}
|
|
740
|
-
async removeGuardWatchlistItem(artifactId) {
|
|
741
|
-
return removeGuardWatchlistItem(this, artifactId);
|
|
742
|
-
}
|
|
743
|
-
async addGuardException(payload) {
|
|
744
|
-
return addGuardException(this, payload);
|
|
745
|
-
}
|
|
746
|
-
async requestGuardException(payload) {
|
|
747
|
-
return requestGuardException(this, payload);
|
|
748
|
-
}
|
|
749
|
-
async removeGuardException(exceptionId) {
|
|
750
|
-
return removeGuardException(this, exceptionId);
|
|
751
|
-
}
|
|
752
|
-
async ingestGuardPainSignals(items) {
|
|
753
|
-
return ingestGuardPainSignals(this, items);
|
|
754
|
-
}
|
|
755
|
-
async syncGuardReceipts(payload) {
|
|
756
|
-
return syncGuardReceipts(this, payload);
|
|
757
|
-
}
|
|
758
|
-
async syncGuardInventory(payload) {
|
|
759
|
-
return syncGuardInventory(this, payload);
|
|
760
|
-
}
|
|
761
|
-
async submitGuardReceipts(payload) {
|
|
762
|
-
return submitGuardReceipts(this, payload);
|
|
763
|
-
}
|
|
764
|
-
async getGuardTeamPolicyPack() {
|
|
765
|
-
return getGuardTeamPolicyPack(this);
|
|
766
|
-
}
|
|
767
|
-
async updateGuardTeamPolicyPack(payload) {
|
|
768
|
-
return updateGuardTeamPolicyPack(this, payload);
|
|
769
|
-
}
|
|
770
|
-
async createHbarPurchaseIntent(payload) {
|
|
771
|
-
return createHbarPurchaseIntent(this, payload);
|
|
772
|
-
}
|
|
773
|
-
async purchaseCreditsWithHbar(params) {
|
|
774
|
-
return purchaseCreditsWithHbar(this, params);
|
|
775
|
-
}
|
|
776
|
-
async getX402Minimums() {
|
|
777
|
-
return getX402Minimums(this);
|
|
778
|
-
}
|
|
779
|
-
async purchaseCreditsWithX402(params) {
|
|
780
|
-
return purchaseCreditsWithX402(this, params);
|
|
781
|
-
}
|
|
782
|
-
async buyCreditsWithX402(params) {
|
|
783
|
-
return buyCreditsWithX402(this, params);
|
|
784
|
-
}
|
|
785
|
-
async generateEncryptionKeyPair(options = {}) {
|
|
786
|
-
return generateEncryptionKeyPair(this, options);
|
|
787
|
-
}
|
|
788
|
-
async createLedgerChallenge(payload) {
|
|
789
|
-
return createLedgerChallenge(this, payload);
|
|
790
|
-
}
|
|
791
|
-
async verifyLedgerChallenge(payload) {
|
|
792
|
-
return verifyLedgerChallenge(this, payload);
|
|
793
|
-
}
|
|
794
|
-
async authenticateWithLedger(options) {
|
|
795
|
-
return authenticateWithLedger(this, options);
|
|
796
|
-
}
|
|
797
|
-
async authenticateWithLedgerCredentials(options) {
|
|
798
|
-
return authenticateWithLedgerCredentials(this, options);
|
|
799
|
-
}
|
|
800
|
-
async getVerificationStatus(uaid) {
|
|
801
|
-
return getVerificationStatus(this, uaid);
|
|
802
|
-
}
|
|
803
|
-
async createVerificationChallenge(uaid) {
|
|
804
|
-
return createVerificationChallenge(this, uaid);
|
|
805
|
-
}
|
|
806
|
-
async getVerificationChallenge(challengeId) {
|
|
807
|
-
return getVerificationChallenge(this, challengeId);
|
|
808
|
-
}
|
|
809
|
-
async verifyVerificationChallenge(params) {
|
|
810
|
-
return verifyVerificationChallenge(this, params);
|
|
811
|
-
}
|
|
812
|
-
async getVerificationOwnership(uaid) {
|
|
813
|
-
return getVerificationOwnership(this, uaid);
|
|
814
|
-
}
|
|
815
|
-
async verifySenderOwnership(uaid) {
|
|
816
|
-
return verifySenderOwnership(this, uaid);
|
|
817
|
-
}
|
|
818
|
-
async verifyUaidDnsTxt(payload) {
|
|
819
|
-
return verifyUaidDnsTxt(this, payload);
|
|
820
|
-
}
|
|
821
|
-
async getVerificationDnsStatus(uaid, query) {
|
|
822
|
-
return getVerificationDnsStatus(this, uaid, query);
|
|
823
|
-
}
|
|
824
|
-
async fetchHistorySnapshot(sessionId, options) {
|
|
825
|
-
return fetchHistorySnapshot(
|
|
826
|
-
this.conversationContexts,
|
|
827
|
-
this,
|
|
828
|
-
sessionId,
|
|
829
|
-
options
|
|
788
|
+
/**
|
|
789
|
+
* Retrieves transaction details by consensus timestamp.
|
|
790
|
+
* @param timestamp The consensus timestamp of the transaction (e.g., "1629400000.000000000").
|
|
791
|
+
* @returns A promise that resolves to the transaction details or null.
|
|
792
|
+
*/
|
|
793
|
+
async getTransactionByTimestamp(timestamp) {
|
|
794
|
+
this.logger.info(`Getting transaction by timestamp: ${timestamp}`);
|
|
795
|
+
try {
|
|
796
|
+
const response = await this._requestWithRetry(`/api/v1/transactions?timestamp=${timestamp}&limit=1`);
|
|
797
|
+
return response.transactions;
|
|
798
|
+
} catch (error) {
|
|
799
|
+
this.logger.error(
|
|
800
|
+
`Error fetching transaction by timestamp ${timestamp}: ${error}`
|
|
801
|
+
);
|
|
802
|
+
return [];
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Retrieves NFTs for a given account ID, optionally filtered by token ID.
|
|
807
|
+
* @param accountId The ID of the account.
|
|
808
|
+
* @param tokenId Optional ID of the token to filter NFTs by.
|
|
809
|
+
* @param limit The maximum number of NFTs to return per page (API has its own max).
|
|
810
|
+
* @returns A promise that resolves to an array of NftDetail or null.
|
|
811
|
+
*/
|
|
812
|
+
async getAccountNfts(accountId, tokenId, limit = 100) {
|
|
813
|
+
this.logger.info(
|
|
814
|
+
`Getting NFTs for account ${accountId}${tokenId ? ` for token ${tokenId}` : ""}`
|
|
830
815
|
);
|
|
816
|
+
let allNfts = [];
|
|
817
|
+
let endpoint = `/api/v1/accounts/${accountId}/nfts?limit=${limit}`;
|
|
818
|
+
if (tokenId) {
|
|
819
|
+
endpoint += `&token.id=${tokenId}`;
|
|
820
|
+
}
|
|
821
|
+
try {
|
|
822
|
+
for (let i = 0; i < 10 && endpoint; i++) {
|
|
823
|
+
const response = await this._requestWithRetry(endpoint);
|
|
824
|
+
if (response && response.nfts) {
|
|
825
|
+
const nftsWithUri = response.nfts.map((nft) => {
|
|
826
|
+
let tokenUri = void 0;
|
|
827
|
+
if (nft.metadata) {
|
|
828
|
+
try {
|
|
829
|
+
if (this.isServerEnvironment) {
|
|
830
|
+
tokenUri = Buffer.from(nft.metadata, "base64").toString(
|
|
831
|
+
"utf-8"
|
|
832
|
+
);
|
|
833
|
+
} else {
|
|
834
|
+
tokenUri = new TextDecoder().decode(
|
|
835
|
+
Uint8Array.from(atob(nft.metadata), (c) => c.charCodeAt(0))
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
} catch (e) {
|
|
839
|
+
this.logger.warn(
|
|
840
|
+
`Failed to decode metadata for NFT ${nft.token_id} SN ${nft.serial_number}: ${e.message}`
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return { ...nft, token_uri: tokenUri };
|
|
845
|
+
});
|
|
846
|
+
allNfts = allNfts.concat(nftsWithUri);
|
|
847
|
+
}
|
|
848
|
+
endpoint = response.links?.next || "";
|
|
849
|
+
if (!endpoint) break;
|
|
850
|
+
}
|
|
851
|
+
return allNfts;
|
|
852
|
+
} catch (error) {
|
|
853
|
+
this.logger.error(
|
|
854
|
+
`Error fetching NFTs for account ${accountId}: ${error.message}`
|
|
855
|
+
);
|
|
856
|
+
return null;
|
|
857
|
+
}
|
|
831
858
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Validates NFT ownership by checking if a specific serial number of a token ID exists for an account.
|
|
861
|
+
* @param accountId The ID of the account.
|
|
862
|
+
* @param tokenId The ID of the NFT's token.
|
|
863
|
+
* @param serialNumber The serial number of the NFT.
|
|
864
|
+
* @returns A promise that resolves to the NftDetail if owned, or null otherwise.
|
|
865
|
+
*/
|
|
866
|
+
async validateNFTOwnership(accountId, tokenId, serialNumber) {
|
|
867
|
+
this.logger.info(
|
|
868
|
+
`Validating ownership of NFT ${tokenId} SN ${serialNumber} for account ${accountId}`
|
|
839
869
|
);
|
|
870
|
+
try {
|
|
871
|
+
const nfts = await this.getAccountNfts(accountId, tokenId);
|
|
872
|
+
if (nfts) {
|
|
873
|
+
const foundNft = nfts.find(
|
|
874
|
+
(nft) => nft.token_id === tokenId && nft.serial_number === serialNumber
|
|
875
|
+
);
|
|
876
|
+
return foundNft || null;
|
|
877
|
+
}
|
|
878
|
+
return null;
|
|
879
|
+
} catch (error) {
|
|
880
|
+
this.logger.error(`Error validating NFT ownership: ${error.message}`);
|
|
881
|
+
return null;
|
|
882
|
+
}
|
|
840
883
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
884
|
+
/**
|
|
885
|
+
* Performs a read-only query against a smart contract (eth_call like).
|
|
886
|
+
* @param contractIdOrAddress The contract ID (e.g., "0.0.123") or EVM address (e.g., "0x...").
|
|
887
|
+
* @param functionSelector The function selector and encoded parameters (e.g., "0xabcdef12...").
|
|
888
|
+
* @param payerAccountId The account ID of the payer (not strictly payer for read-only, but often required as 'from').
|
|
889
|
+
* @param estimate Whether this is an estimate call. Mirror node might not support this directly in /contracts/call for true estimation.
|
|
890
|
+
* @param block Block parameter, e.g., "latest", "pending", or block number.
|
|
891
|
+
* @param value The value in tinybars to send with the call (for payable view/pure functions, usually 0).
|
|
892
|
+
* @returns A promise that resolves to the contract call query response or null.
|
|
893
|
+
*/
|
|
894
|
+
async readSmartContractQuery(contractIdOrAddress, functionSelector, payerAccountId, options) {
|
|
895
|
+
this.logger.info(
|
|
896
|
+
`Reading smart contract ${contractIdOrAddress} with selector ${functionSelector}`
|
|
845
897
|
);
|
|
898
|
+
const toAddress = contractIdOrAddress.startsWith("0x") ? contractIdOrAddress : `0x${AccountId.fromString(contractIdOrAddress).toSolidityAddress()}`;
|
|
899
|
+
const fromAddress = payerAccountId.startsWith("0x") ? payerAccountId : `0x${AccountId.fromString(payerAccountId).toSolidityAddress()}`;
|
|
900
|
+
const body = {
|
|
901
|
+
block: options?.block || "latest",
|
|
902
|
+
data: functionSelector,
|
|
903
|
+
estimate: options?.estimate || false,
|
|
904
|
+
from: fromAddress,
|
|
905
|
+
to: toAddress,
|
|
906
|
+
gas: options?.gas,
|
|
907
|
+
gasPrice: options?.gasPrice,
|
|
908
|
+
value: options?.value || 0
|
|
909
|
+
};
|
|
910
|
+
Object.keys(body).forEach((key) => {
|
|
911
|
+
const K = key;
|
|
912
|
+
if (body[K] === void 0) {
|
|
913
|
+
delete body[K];
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
try {
|
|
917
|
+
const url = this.constructUrl("/api/v1/contracts/call");
|
|
918
|
+
const response = await this._fetchWithRetry(
|
|
919
|
+
url,
|
|
920
|
+
{
|
|
921
|
+
method: "POST",
|
|
922
|
+
body: JSON.stringify(body),
|
|
923
|
+
headers: {
|
|
924
|
+
"Content-Type": "application/json"
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
);
|
|
928
|
+
return response;
|
|
929
|
+
} catch (error) {
|
|
930
|
+
this.logger.error(
|
|
931
|
+
`Error reading smart contract ${contractIdOrAddress}: ${error.message}`
|
|
932
|
+
);
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
846
935
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
936
|
+
/**
|
|
937
|
+
* Retrieves outstanding token airdrops sent by an account.
|
|
938
|
+
* @param accountId The ID of the account that sent the airdrops.
|
|
939
|
+
* @param options Optional parameters for filtering airdrops.
|
|
940
|
+
* @returns A promise that resolves to an array of TokenAirdrop or null.
|
|
941
|
+
*/
|
|
942
|
+
async getOutstandingTokenAirdrops(accountId, options) {
|
|
943
|
+
this.logger.info(
|
|
944
|
+
`Getting outstanding token airdrops sent by account ${accountId}`
|
|
853
945
|
);
|
|
946
|
+
let endpoint = `/api/v1/accounts/${accountId}/airdrops/outstanding`;
|
|
947
|
+
const params = new URLSearchParams();
|
|
948
|
+
if (options?.limit) {
|
|
949
|
+
params.append("limit", options.limit.toString());
|
|
950
|
+
}
|
|
951
|
+
if (options?.order) {
|
|
952
|
+
params.append("order", options.order);
|
|
953
|
+
}
|
|
954
|
+
if (options?.receiverId) {
|
|
955
|
+
params.append("receiver.id", options.receiverId);
|
|
956
|
+
}
|
|
957
|
+
if (options?.serialNumber) {
|
|
958
|
+
params.append("serialnumber", options.serialNumber);
|
|
959
|
+
}
|
|
960
|
+
if (options?.tokenId) {
|
|
961
|
+
params.append("token.id", options.tokenId);
|
|
962
|
+
}
|
|
963
|
+
const queryString = params.toString();
|
|
964
|
+
if (queryString) {
|
|
965
|
+
endpoint += `?${queryString}`;
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
const response = await this._requestWithRetry(endpoint);
|
|
969
|
+
return response.airdrops || [];
|
|
970
|
+
} catch (error) {
|
|
971
|
+
this.logger.error(
|
|
972
|
+
`Error fetching outstanding token airdrops for account ${accountId}: ${error.message}`
|
|
973
|
+
);
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
854
976
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
async
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
async checkChatReadiness(payload) {
|
|
865
|
-
return checkChatReadiness(this, payload);
|
|
866
|
-
}
|
|
867
|
-
async startChat(options) {
|
|
868
|
-
return startChat(this, this.getEncryptedChatManager(), options);
|
|
869
|
-
}
|
|
870
|
-
async startConversation(options) {
|
|
871
|
-
return startConversation(this, this.getEncryptedChatManager(), options);
|
|
872
|
-
}
|
|
873
|
-
async acceptConversation(options) {
|
|
874
|
-
return acceptConversation(
|
|
875
|
-
this,
|
|
876
|
-
this.getEncryptedChatManager(),
|
|
877
|
-
options
|
|
977
|
+
/**
|
|
978
|
+
* Retrieves pending token airdrops received by an account.
|
|
979
|
+
* @param accountId The ID of the account that received the airdrops.
|
|
980
|
+
* @param options Optional parameters for filtering airdrops.
|
|
981
|
+
* @returns A promise that resolves to an array of TokenAirdrop or null.
|
|
982
|
+
*/
|
|
983
|
+
async getPendingTokenAirdrops(accountId, options) {
|
|
984
|
+
this.logger.info(
|
|
985
|
+
`Getting pending token airdrops received by account ${accountId}`
|
|
878
986
|
);
|
|
987
|
+
let endpoint = `/api/v1/accounts/${accountId}/airdrops/pending`;
|
|
988
|
+
const params = new URLSearchParams();
|
|
989
|
+
if (options?.limit) {
|
|
990
|
+
params.append("limit", options.limit.toString());
|
|
991
|
+
}
|
|
992
|
+
if (options?.order) {
|
|
993
|
+
params.append("order", options.order);
|
|
994
|
+
}
|
|
995
|
+
if (options?.senderId) {
|
|
996
|
+
params.append("sender.id", options.senderId);
|
|
997
|
+
}
|
|
998
|
+
if (options?.serialNumber) {
|
|
999
|
+
params.append("serialnumber", options.serialNumber);
|
|
1000
|
+
}
|
|
1001
|
+
if (options?.tokenId) {
|
|
1002
|
+
params.append("token.id", options.tokenId);
|
|
1003
|
+
}
|
|
1004
|
+
const queryString = params.toString();
|
|
1005
|
+
if (queryString) {
|
|
1006
|
+
endpoint += `?${queryString}`;
|
|
1007
|
+
}
|
|
1008
|
+
try {
|
|
1009
|
+
const response = await this._requestWithRetry(endpoint);
|
|
1010
|
+
return response.airdrops || [];
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
this.logger.error(
|
|
1013
|
+
`Error fetching pending token airdrops for account ${accountId}: ${error.message}`
|
|
1014
|
+
);
|
|
1015
|
+
return null;
|
|
1016
|
+
}
|
|
879
1017
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1018
|
+
/**
|
|
1019
|
+
* Retrieves blocks from the network.
|
|
1020
|
+
* @param options Optional parameters for filtering blocks.
|
|
1021
|
+
* @returns A promise that resolves to an array of Block or null.
|
|
1022
|
+
*/
|
|
1023
|
+
async getBlocks(options) {
|
|
1024
|
+
this.logger.info("Getting blocks from the network");
|
|
1025
|
+
let endpoint = `/api/v1/blocks`;
|
|
1026
|
+
const params = new URLSearchParams();
|
|
1027
|
+
if (options?.limit) {
|
|
1028
|
+
params.append("limit", options.limit.toString());
|
|
1029
|
+
}
|
|
1030
|
+
if (options?.order) {
|
|
1031
|
+
params.append("order", options.order);
|
|
1032
|
+
}
|
|
1033
|
+
if (options?.timestamp) {
|
|
1034
|
+
params.append("timestamp", options.timestamp);
|
|
1035
|
+
}
|
|
1036
|
+
if (options?.blockNumber) {
|
|
1037
|
+
params.append("block.number", options.blockNumber);
|
|
1038
|
+
}
|
|
1039
|
+
const queryString = params.toString();
|
|
1040
|
+
if (queryString) {
|
|
1041
|
+
endpoint += `?${queryString}`;
|
|
1042
|
+
}
|
|
1043
|
+
try {
|
|
1044
|
+
const response = await this._requestWithRetry(endpoint);
|
|
1045
|
+
return response.blocks || [];
|
|
1046
|
+
} catch (error) {
|
|
1047
|
+
this.logger.error(`Error fetching blocks: ${error.message}`);
|
|
1048
|
+
return null;
|
|
1049
|
+
}
|
|
885
1050
|
}
|
|
886
|
-
|
|
887
|
-
|
|
1051
|
+
/**
|
|
1052
|
+
* Retrieves a specific block by number or hash.
|
|
1053
|
+
* @param blockNumberOrHash The block number or hash.
|
|
1054
|
+
* @returns A promise that resolves to a Block or null.
|
|
1055
|
+
*/
|
|
1056
|
+
async getBlock(blockNumberOrHash) {
|
|
1057
|
+
this.logger.info(`Getting block ${blockNumberOrHash}`);
|
|
1058
|
+
try {
|
|
1059
|
+
const response = await this._requestWithRetry(
|
|
1060
|
+
`/api/v1/blocks/${blockNumberOrHash}`
|
|
1061
|
+
);
|
|
1062
|
+
return response;
|
|
1063
|
+
} catch (error) {
|
|
1064
|
+
this.logger.error(
|
|
1065
|
+
`Error fetching block ${blockNumberOrHash}: ${error.message}`
|
|
1066
|
+
);
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
888
1069
|
}
|
|
889
|
-
|
|
890
|
-
|
|
1070
|
+
/**
|
|
1071
|
+
* Retrieves contract entities from the network.
|
|
1072
|
+
* @param options Optional parameters for filtering contracts.
|
|
1073
|
+
* @returns A promise that resolves to an array of ContractEntity or null.
|
|
1074
|
+
*/
|
|
1075
|
+
async getContracts(options) {
|
|
1076
|
+
this.logger.info("Getting contracts from the network");
|
|
1077
|
+
let url = `/api/v1/contracts`;
|
|
1078
|
+
const params = new URLSearchParams();
|
|
1079
|
+
if (options?.contractId) {
|
|
1080
|
+
params.append("contract.id", options.contractId);
|
|
1081
|
+
}
|
|
1082
|
+
if (options?.limit) {
|
|
1083
|
+
params.append("limit", options.limit.toString());
|
|
1084
|
+
}
|
|
1085
|
+
if (options?.order) {
|
|
1086
|
+
params.append("order", options.order);
|
|
1087
|
+
}
|
|
1088
|
+
const queryString = params.toString();
|
|
1089
|
+
if (queryString) {
|
|
1090
|
+
url += `?${queryString}`;
|
|
1091
|
+
}
|
|
1092
|
+
try {
|
|
1093
|
+
const response = await this._requestWithRetry(url);
|
|
1094
|
+
return response.contracts || [];
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
this.logger.error(`Error fetching contracts: ${error.message}`);
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
891
1099
|
}
|
|
892
|
-
|
|
893
|
-
|
|
1100
|
+
/**
|
|
1101
|
+
* Retrieves a specific contract by ID or address.
|
|
1102
|
+
* @param contractIdOrAddress The contract ID or EVM address.
|
|
1103
|
+
* @param timestamp Optional timestamp for historical data.
|
|
1104
|
+
* @returns A promise that resolves to a ContractEntity or null.
|
|
1105
|
+
*/
|
|
1106
|
+
async getContract(contractIdOrAddress, timestamp) {
|
|
1107
|
+
this.logger.info(`Getting contract ${contractIdOrAddress}`);
|
|
1108
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}`;
|
|
1109
|
+
if (timestamp) {
|
|
1110
|
+
url += `?timestamp=${timestamp}`;
|
|
1111
|
+
}
|
|
1112
|
+
try {
|
|
1113
|
+
const response = await this._requestWithRetry(url);
|
|
1114
|
+
return response;
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
this.logger.error(
|
|
1117
|
+
`Error fetching contract ${contractIdOrAddress}: ${error.message}`
|
|
1118
|
+
);
|
|
1119
|
+
return null;
|
|
1120
|
+
}
|
|
894
1121
|
}
|
|
895
|
-
|
|
896
|
-
|
|
1122
|
+
/**
|
|
1123
|
+
* Retrieves contract results from the network.
|
|
1124
|
+
* @param options Optional parameters for filtering contract results.
|
|
1125
|
+
* @returns A promise that resolves to an array of ContractResult or null.
|
|
1126
|
+
*/
|
|
1127
|
+
async getContractResults(options) {
|
|
1128
|
+
this.logger.info("Getting contract results from the network");
|
|
1129
|
+
let url = `/api/v1/contracts/results`;
|
|
1130
|
+
const params = new URLSearchParams();
|
|
1131
|
+
if (options?.from) {
|
|
1132
|
+
params.append("from", options.from);
|
|
1133
|
+
}
|
|
1134
|
+
if (options?.blockHash) {
|
|
1135
|
+
params.append("block.hash", options.blockHash);
|
|
1136
|
+
}
|
|
1137
|
+
if (options?.blockNumber) {
|
|
1138
|
+
params.append("block.number", options.blockNumber);
|
|
1139
|
+
}
|
|
1140
|
+
if (options?.internal !== void 0) {
|
|
1141
|
+
params.append("internal", options.internal.toString());
|
|
1142
|
+
}
|
|
1143
|
+
if (options?.limit) {
|
|
1144
|
+
params.append("limit", options.limit.toString());
|
|
1145
|
+
}
|
|
1146
|
+
if (options?.order) {
|
|
1147
|
+
params.append("order", options.order);
|
|
1148
|
+
}
|
|
1149
|
+
if (options?.timestamp) {
|
|
1150
|
+
params.append("timestamp", options.timestamp);
|
|
1151
|
+
}
|
|
1152
|
+
if (options?.transactionIndex) {
|
|
1153
|
+
params.append("transaction.index", options.transactionIndex.toString());
|
|
1154
|
+
}
|
|
1155
|
+
const queryString = params.toString();
|
|
1156
|
+
if (queryString) {
|
|
1157
|
+
url += `?${queryString}`;
|
|
1158
|
+
}
|
|
1159
|
+
try {
|
|
1160
|
+
const response = await this._requestWithRetry(url);
|
|
1161
|
+
return response.results || [];
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
this.logger.error(`Error fetching contract results: ${error.message}`);
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
897
1166
|
}
|
|
898
|
-
|
|
899
|
-
|
|
1167
|
+
/**
|
|
1168
|
+
* Retrieves a specific contract result by transaction ID or hash.
|
|
1169
|
+
* @param transactionIdOrHash The transaction ID or hash.
|
|
1170
|
+
* @param nonce Optional nonce filter.
|
|
1171
|
+
* @returns A promise that resolves to a ContractResult or null.
|
|
1172
|
+
*/
|
|
1173
|
+
async getContractResult(transactionIdOrHash, nonce) {
|
|
1174
|
+
this.logger.info(`Getting contract result for ${transactionIdOrHash}`);
|
|
1175
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}`;
|
|
1176
|
+
if (nonce !== void 0) {
|
|
1177
|
+
url += `?nonce=${nonce}`;
|
|
1178
|
+
}
|
|
1179
|
+
try {
|
|
1180
|
+
const response = await this._requestWithRetry(url);
|
|
1181
|
+
return response;
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
this.logger.error(
|
|
1184
|
+
`Error fetching contract result for ${transactionIdOrHash}: ${error.message}`
|
|
1185
|
+
);
|
|
1186
|
+
return null;
|
|
1187
|
+
}
|
|
900
1188
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1189
|
+
/**
|
|
1190
|
+
* Retrieves contract results for a specific contract.
|
|
1191
|
+
* @param contractIdOrAddress The contract ID or EVM address.
|
|
1192
|
+
* @param options Optional parameters for filtering.
|
|
1193
|
+
* @returns A promise that resolves to an array of ContractResult or null.
|
|
1194
|
+
*/
|
|
1195
|
+
async getContractResultsByContract(contractIdOrAddress, options) {
|
|
1196
|
+
this.logger.info(
|
|
1197
|
+
`Getting contract results for contract ${contractIdOrAddress}`
|
|
908
1198
|
);
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
if (
|
|
912
|
-
|
|
1199
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/results`;
|
|
1200
|
+
const params = new URLSearchParams();
|
|
1201
|
+
if (options?.blockHash) {
|
|
1202
|
+
params.append("block.hash", options.blockHash);
|
|
913
1203
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
if (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1204
|
+
if (options?.blockNumber) {
|
|
1205
|
+
params.append("block.number", options.blockNumber);
|
|
1206
|
+
}
|
|
1207
|
+
if (options?.from) {
|
|
1208
|
+
params.append("from", options.from);
|
|
1209
|
+
}
|
|
1210
|
+
if (options?.internal !== void 0) {
|
|
1211
|
+
params.append("internal", options.internal.toString());
|
|
1212
|
+
}
|
|
1213
|
+
if (options?.limit) {
|
|
1214
|
+
params.append("limit", options.limit.toString());
|
|
1215
|
+
}
|
|
1216
|
+
if (options?.order) {
|
|
1217
|
+
params.append("order", options.order);
|
|
1218
|
+
}
|
|
1219
|
+
if (options?.timestamp) {
|
|
1220
|
+
params.append("timestamp", options.timestamp);
|
|
1221
|
+
}
|
|
1222
|
+
if (options?.transactionIndex) {
|
|
1223
|
+
params.append("transaction.index", options.transactionIndex.toString());
|
|
1224
|
+
}
|
|
1225
|
+
const queryString = params.toString();
|
|
1226
|
+
if (queryString) {
|
|
1227
|
+
url += `?${queryString}`;
|
|
926
1228
|
}
|
|
927
1229
|
try {
|
|
928
|
-
|
|
1230
|
+
const response = await this._requestWithRetry(url);
|
|
1231
|
+
return response.results || [];
|
|
929
1232
|
} catch (error) {
|
|
930
|
-
|
|
1233
|
+
this.logger.error(
|
|
1234
|
+
`Error fetching contract results for ${contractIdOrAddress}: ${error.message}`
|
|
1235
|
+
);
|
|
1236
|
+
return null;
|
|
931
1237
|
}
|
|
932
1238
|
}
|
|
933
|
-
|
|
1239
|
+
/**
|
|
1240
|
+
* Retrieves contract state for a specific contract.
|
|
1241
|
+
* @param contractIdOrAddress The contract ID or EVM address.
|
|
1242
|
+
* @param options Optional parameters for filtering.
|
|
1243
|
+
* @returns A promise that resolves to an array of ContractState or null.
|
|
1244
|
+
*/
|
|
1245
|
+
async getContractState(contractIdOrAddress, options) {
|
|
1246
|
+
this.logger.info(`Getting contract state for ${contractIdOrAddress}`);
|
|
1247
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/state`;
|
|
1248
|
+
const params = new URLSearchParams();
|
|
1249
|
+
if (options?.limit) {
|
|
1250
|
+
params.append("limit", options.limit.toString());
|
|
1251
|
+
}
|
|
1252
|
+
if (options?.order) {
|
|
1253
|
+
params.append("order", options.order);
|
|
1254
|
+
}
|
|
1255
|
+
if (options?.slot) {
|
|
1256
|
+
params.append("slot", options.slot);
|
|
1257
|
+
}
|
|
1258
|
+
if (options?.timestamp) {
|
|
1259
|
+
params.append("timestamp", options.timestamp);
|
|
1260
|
+
}
|
|
1261
|
+
const queryString = params.toString();
|
|
1262
|
+
if (queryString) {
|
|
1263
|
+
url += `?${queryString}`;
|
|
1264
|
+
}
|
|
934
1265
|
try {
|
|
935
|
-
|
|
1266
|
+
const response = await this._requestWithRetry(url);
|
|
1267
|
+
return response.state || [];
|
|
936
1268
|
} catch (error) {
|
|
937
|
-
|
|
938
|
-
`
|
|
939
|
-
error instanceof ZodError || error instanceof Error ? error : String(error),
|
|
940
|
-
value
|
|
1269
|
+
this.logger.error(
|
|
1270
|
+
`Error fetching contract state for ${contractIdOrAddress}: ${error.message}`
|
|
941
1271
|
);
|
|
1272
|
+
return null;
|
|
942
1273
|
}
|
|
943
1274
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Retrieves contract actions for a specific transaction.
|
|
1277
|
+
* @param transactionIdOrHash The transaction ID or hash.
|
|
1278
|
+
* @param options Optional parameters for filtering.
|
|
1279
|
+
* @returns A promise that resolves to an array of ContractAction or null.
|
|
1280
|
+
*/
|
|
1281
|
+
async getContractActions(transactionIdOrHash, options) {
|
|
1282
|
+
this.logger.info(`Getting contract actions for ${transactionIdOrHash}`);
|
|
1283
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}/actions`;
|
|
1284
|
+
const params = new URLSearchParams();
|
|
1285
|
+
if (options?.index) {
|
|
1286
|
+
params.append("index", options.index);
|
|
950
1287
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
if (signal) {
|
|
954
|
-
signal.removeEventListener("abort", onAbort);
|
|
955
|
-
}
|
|
956
|
-
resolve();
|
|
957
|
-
}, ms);
|
|
958
|
-
const onAbort = () => {
|
|
959
|
-
clearTimeout(timer);
|
|
960
|
-
signal?.removeEventListener("abort", onAbort);
|
|
961
|
-
reject(createAbortError());
|
|
962
|
-
};
|
|
963
|
-
if (signal) {
|
|
964
|
-
if (signal.aborted) {
|
|
965
|
-
clearTimeout(timer);
|
|
966
|
-
reject(createAbortError());
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
970
|
-
}
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
assertNodeRuntime(feature) {
|
|
974
|
-
if (typeof process === "undefined" || !process.versions?.node) {
|
|
975
|
-
throw new Error(`${feature} is only available in Node.js environments`);
|
|
1288
|
+
if (options?.limit) {
|
|
1289
|
+
params.append("limit", options.limit.toString());
|
|
976
1290
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
if (
|
|
982
|
-
|
|
1291
|
+
if (options?.order) {
|
|
1292
|
+
params.append("order", options.order);
|
|
1293
|
+
}
|
|
1294
|
+
const queryString = params.toString();
|
|
1295
|
+
if (queryString) {
|
|
1296
|
+
url += `?${queryString}`;
|
|
1297
|
+
}
|
|
1298
|
+
try {
|
|
1299
|
+
const response = await this._requestWithRetry(url);
|
|
1300
|
+
return response.actions || [];
|
|
1301
|
+
} catch (error) {
|
|
1302
|
+
this.logger.error(
|
|
1303
|
+
`Error fetching contract actions for ${transactionIdOrHash}: ${error.message}`
|
|
1304
|
+
);
|
|
1305
|
+
return null;
|
|
983
1306
|
}
|
|
984
|
-
return nodeCrypto;
|
|
985
|
-
}
|
|
986
|
-
getSecureRandomBytes(size, feature) {
|
|
987
|
-
const webCrypto = globalThis.crypto;
|
|
988
|
-
if (webCrypto && typeof webCrypto.getRandomValues === "function") {
|
|
989
|
-
const bytes = new Uint8Array(size);
|
|
990
|
-
webCrypto.getRandomValues(bytes);
|
|
991
|
-
return bytes;
|
|
992
|
-
}
|
|
993
|
-
return this.getNodeCrypto(feature).randomBytes(size);
|
|
994
|
-
}
|
|
995
|
-
createEphemeralKeyPair() {
|
|
996
|
-
const privateKeyBytes = this.getSecureRandomBytes(
|
|
997
|
-
32,
|
|
998
|
-
"generateEphemeralKeyPair"
|
|
999
|
-
);
|
|
1000
|
-
const publicKey = secp256k1.getPublicKey(privateKeyBytes, true);
|
|
1001
|
-
return {
|
|
1002
|
-
privateKey: Buffer.from(privateKeyBytes).toString("hex"),
|
|
1003
|
-
publicKey: Buffer.from(publicKey).toString("hex")
|
|
1004
|
-
};
|
|
1005
1307
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1308
|
+
/**
|
|
1309
|
+
* Retrieves contract logs from the network.
|
|
1310
|
+
* @param options Optional parameters for filtering logs.
|
|
1311
|
+
* @returns A promise that resolves to an array of ContractLog or null.
|
|
1312
|
+
*/
|
|
1313
|
+
async getContractLogs(options) {
|
|
1314
|
+
this.logger.info("Getting contract logs from the network");
|
|
1315
|
+
let url = `/api/v1/contracts/results/logs`;
|
|
1316
|
+
const params = new URLSearchParams();
|
|
1317
|
+
if (options?.index) {
|
|
1318
|
+
params.append("index", options.index);
|
|
1319
|
+
}
|
|
1320
|
+
if (options?.limit) {
|
|
1321
|
+
params.append("limit", options.limit.toString());
|
|
1322
|
+
}
|
|
1323
|
+
if (options?.order) {
|
|
1324
|
+
params.append("order", options.order);
|
|
1325
|
+
}
|
|
1326
|
+
if (options?.timestamp) {
|
|
1327
|
+
params.append("timestamp", options.timestamp);
|
|
1328
|
+
}
|
|
1329
|
+
if (options?.topic0) {
|
|
1330
|
+
params.append("topic0", options.topic0);
|
|
1331
|
+
}
|
|
1332
|
+
if (options?.topic1) {
|
|
1333
|
+
params.append("topic1", options.topic1);
|
|
1334
|
+
}
|
|
1335
|
+
if (options?.topic2) {
|
|
1336
|
+
params.append("topic2", options.topic2);
|
|
1337
|
+
}
|
|
1338
|
+
if (options?.topic3) {
|
|
1339
|
+
params.append("topic3", options.topic3);
|
|
1340
|
+
}
|
|
1341
|
+
if (options?.transactionHash) {
|
|
1342
|
+
params.append("transaction.hash", options.transactionHash);
|
|
1343
|
+
}
|
|
1344
|
+
const queryString = params.toString();
|
|
1345
|
+
if (queryString) {
|
|
1346
|
+
url += `?${queryString}`;
|
|
1347
|
+
}
|
|
1348
|
+
try {
|
|
1349
|
+
const response = await this._requestWithRetry(url);
|
|
1350
|
+
return response.logs || [];
|
|
1351
|
+
} catch (error) {
|
|
1352
|
+
this.logger.error(`Error fetching contract logs: ${error.message}`);
|
|
1353
|
+
return null;
|
|
1354
|
+
}
|
|
1012
1355
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1356
|
+
/**
|
|
1357
|
+
* Retrieves contract logs for a specific contract.
|
|
1358
|
+
* @param contractIdOrAddress The contract ID or EVM address.
|
|
1359
|
+
* @param options Optional parameters for filtering logs.
|
|
1360
|
+
* @returns A promise that resolves to an array of ContractLog or null.
|
|
1361
|
+
*/
|
|
1362
|
+
async getContractLogsByContract(contractIdOrAddress, options) {
|
|
1363
|
+
this.logger.info(
|
|
1364
|
+
`Getting contract logs for contract ${contractIdOrAddress}`
|
|
1016
1365
|
);
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
const associatedDataEncoded = aadSource ? Buffer.from(aadSource, "utf8").toString("base64") : void 0;
|
|
1022
|
-
if (aadSource) {
|
|
1023
|
-
cipher.setAAD(Buffer.from(aadSource, "utf8"));
|
|
1024
|
-
}
|
|
1025
|
-
const ciphertext = Buffer.concat([
|
|
1026
|
-
cipher.update(Buffer.from(options.plaintext, "utf8")),
|
|
1027
|
-
cipher.final()
|
|
1028
|
-
]);
|
|
1029
|
-
const tag = cipher.getAuthTag();
|
|
1030
|
-
const payload = Buffer.concat([ciphertext, tag]);
|
|
1031
|
-
return {
|
|
1032
|
-
algorithm: "aes-256-gcm",
|
|
1033
|
-
ciphertext: payload.toString("base64"),
|
|
1034
|
-
nonce: iv.toString("base64"),
|
|
1035
|
-
associatedData: associatedDataEncoded,
|
|
1036
|
-
keyLocator: {
|
|
1037
|
-
sessionId: options.sessionId,
|
|
1038
|
-
revision: options.revision ?? 1
|
|
1039
|
-
},
|
|
1040
|
-
recipients: options.recipients.map((recipient) => ({
|
|
1041
|
-
...recipient,
|
|
1042
|
-
encryptedShare: ""
|
|
1043
|
-
}))
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
openCipherEnvelope(options) {
|
|
1047
|
-
const { createDecipheriv } = this.getNodeCrypto("decryptCipherEnvelope");
|
|
1048
|
-
const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
|
|
1049
|
-
const payload = Buffer.from(options.envelope.ciphertext, "base64");
|
|
1050
|
-
const nonce = Buffer.from(options.envelope.nonce, "base64");
|
|
1051
|
-
const ciphertext = payload.slice(0, payload.length - 16);
|
|
1052
|
-
const tag = payload.slice(payload.length - 16);
|
|
1053
|
-
const decipher = createDecipheriv("aes-256-gcm", sharedSecret, nonce);
|
|
1054
|
-
if (options.envelope.associatedData) {
|
|
1055
|
-
decipher.setAAD(Buffer.from(options.envelope.associatedData, "base64"));
|
|
1056
|
-
}
|
|
1057
|
-
decipher.setAuthTag(tag);
|
|
1058
|
-
const plaintext = Buffer.concat([
|
|
1059
|
-
decipher.update(ciphertext),
|
|
1060
|
-
decipher.final()
|
|
1061
|
-
]);
|
|
1062
|
-
return plaintext.toString(options.encoding ?? "utf8");
|
|
1063
|
-
}
|
|
1064
|
-
normalizeSharedSecret(input) {
|
|
1065
|
-
if (Buffer.isBuffer(input)) {
|
|
1066
|
-
return Buffer.from(input);
|
|
1366
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/results/logs`;
|
|
1367
|
+
const params = new URLSearchParams();
|
|
1368
|
+
if (options?.index) {
|
|
1369
|
+
params.append("index", options.index);
|
|
1067
1370
|
}
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1371
|
+
if (options?.limit) {
|
|
1372
|
+
params.append("limit", options.limit.toString());
|
|
1070
1373
|
}
|
|
1071
|
-
if (
|
|
1072
|
-
|
|
1374
|
+
if (options?.order) {
|
|
1375
|
+
params.append("order", options.order);
|
|
1073
1376
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1377
|
+
if (options?.timestamp) {
|
|
1378
|
+
params.append("timestamp", options.timestamp);
|
|
1379
|
+
}
|
|
1380
|
+
if (options?.topic0) {
|
|
1381
|
+
params.append("topic0", options.topic0);
|
|
1382
|
+
}
|
|
1383
|
+
if (options?.topic1) {
|
|
1384
|
+
params.append("topic1", options.topic1);
|
|
1080
1385
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1386
|
+
if (options?.topic2) {
|
|
1387
|
+
params.append("topic2", options.topic2);
|
|
1388
|
+
}
|
|
1389
|
+
if (options?.topic3) {
|
|
1390
|
+
params.append("topic3", options.topic3);
|
|
1391
|
+
}
|
|
1392
|
+
const queryString = params.toString();
|
|
1393
|
+
if (queryString) {
|
|
1394
|
+
url += `?${queryString}`;
|
|
1395
|
+
}
|
|
1396
|
+
try {
|
|
1397
|
+
const response = await this._requestWithRetry(url);
|
|
1398
|
+
return response.logs || [];
|
|
1399
|
+
} catch (error) {
|
|
1400
|
+
this.logger.error(
|
|
1401
|
+
`Error fetching contract logs for ${contractIdOrAddress}: ${error.message}`
|
|
1402
|
+
);
|
|
1403
|
+
return null;
|
|
1084
1404
|
}
|
|
1085
|
-
return Buffer.from(trimmed, "base64");
|
|
1086
1405
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1406
|
+
/**
|
|
1407
|
+
* Retrieves NFT information by token ID and serial number.
|
|
1408
|
+
* @param tokenId The token ID.
|
|
1409
|
+
* @param serialNumber The serial number of the NFT.
|
|
1410
|
+
* @returns A promise that resolves to an NftInfo or null.
|
|
1411
|
+
*/
|
|
1412
|
+
async getNftInfo(tokenId, serialNumber) {
|
|
1413
|
+
this.logger.info(`Getting NFT info for ${tokenId}/${serialNumber}`);
|
|
1414
|
+
const url = `/api/v1/tokens/${tokenId}/nfts/${serialNumber}`;
|
|
1415
|
+
try {
|
|
1416
|
+
const response = await this._requestWithRetry(url);
|
|
1417
|
+
return response;
|
|
1418
|
+
} catch (error) {
|
|
1419
|
+
this.logger.error(
|
|
1420
|
+
`Error fetching NFT info for ${tokenId}/${serialNumber}: ${error.message}`
|
|
1421
|
+
);
|
|
1422
|
+
return null;
|
|
1091
1423
|
}
|
|
1092
|
-
return Buffer.from(normalized, "hex");
|
|
1093
1424
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1425
|
+
/**
|
|
1426
|
+
* Retrieves NFTs for a specific token.
|
|
1427
|
+
* @param tokenId The token ID.
|
|
1428
|
+
* @param options Optional parameters for filtering NFTs.
|
|
1429
|
+
* @returns A promise that resolves to an array of NftInfo or null.
|
|
1430
|
+
*/
|
|
1431
|
+
async getNftsByToken(tokenId, options) {
|
|
1432
|
+
this.logger.info(`Getting NFTs for token ${tokenId}`);
|
|
1433
|
+
let url = `/api/v1/tokens/${tokenId}/nfts`;
|
|
1434
|
+
const params = new URLSearchParams();
|
|
1435
|
+
if (options?.accountId) {
|
|
1436
|
+
params.append("account.id", options.accountId);
|
|
1437
|
+
}
|
|
1438
|
+
if (options?.limit) {
|
|
1439
|
+
params.append("limit", options.limit.toString());
|
|
1440
|
+
}
|
|
1441
|
+
if (options?.order) {
|
|
1442
|
+
params.append("order", options.order);
|
|
1443
|
+
}
|
|
1444
|
+
if (options?.serialNumber) {
|
|
1445
|
+
params.append("serialnumber", options.serialNumber);
|
|
1446
|
+
}
|
|
1447
|
+
const queryString = params.toString();
|
|
1448
|
+
if (queryString) {
|
|
1449
|
+
url += `?${queryString}`;
|
|
1450
|
+
}
|
|
1451
|
+
try {
|
|
1452
|
+
const response = await this._requestWithRetry(url);
|
|
1453
|
+
return response.nfts || [];
|
|
1454
|
+
} catch (error) {
|
|
1455
|
+
this.logger.error(
|
|
1456
|
+
`Error fetching NFTs for token ${tokenId}: ${error.message}`
|
|
1457
|
+
);
|
|
1096
1458
|
return null;
|
|
1097
1459
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Retrieves network information.
|
|
1463
|
+
* @returns A promise that resolves to NetworkInfo or null.
|
|
1464
|
+
*/
|
|
1465
|
+
async getNetworkInfo() {
|
|
1466
|
+
this.logger.info("Getting network information");
|
|
1467
|
+
const url = `/api/v1/network/nodes`;
|
|
1468
|
+
try {
|
|
1469
|
+
const response = await this._requestWithRetry(url);
|
|
1470
|
+
return response;
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
this.logger.error(`Error fetching network info: ${error.message}`);
|
|
1100
1473
|
return null;
|
|
1101
1474
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Retrieves network fees.
|
|
1478
|
+
* @param timestamp Optional timestamp for historical fees.
|
|
1479
|
+
* @returns A promise that resolves to NetworkFees or null.
|
|
1480
|
+
*/
|
|
1481
|
+
async getNetworkFees(timestamp) {
|
|
1482
|
+
this.logger.info("Getting network fees");
|
|
1483
|
+
let url = `/api/v1/network/fees`;
|
|
1484
|
+
if (timestamp) {
|
|
1485
|
+
url += `?timestamp=${timestamp}`;
|
|
1486
|
+
}
|
|
1487
|
+
try {
|
|
1488
|
+
const response = await this._requestWithRetry(url);
|
|
1489
|
+
return response;
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
this.logger.error(`Error fetching network fees: ${error.message}`);
|
|
1104
1492
|
return null;
|
|
1105
1493
|
}
|
|
1106
|
-
return { shortfallCredits: maybeShortfall };
|
|
1107
1494
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1495
|
+
/**
|
|
1496
|
+
* Retrieves network supply information.
|
|
1497
|
+
* @param timestamp Optional timestamp for historical supply data.
|
|
1498
|
+
* @returns A promise that resolves to NetworkSupply or null.
|
|
1499
|
+
*/
|
|
1500
|
+
async getNetworkSupply(timestamp) {
|
|
1501
|
+
this.logger.info("Getting network supply");
|
|
1502
|
+
let url = `/api/v1/network/supply`;
|
|
1503
|
+
if (timestamp) {
|
|
1504
|
+
url += `?timestamp=${timestamp}`;
|
|
1505
|
+
}
|
|
1506
|
+
try {
|
|
1507
|
+
const response = await this._requestWithRetry(url);
|
|
1508
|
+
return response;
|
|
1509
|
+
} catch (error) {
|
|
1510
|
+
this.logger.error(`Error fetching network supply: ${error.message}`);
|
|
1511
|
+
return null;
|
|
1111
1512
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Retrieves network stake information.
|
|
1516
|
+
* @param timestamp Optional timestamp for historical stake data.
|
|
1517
|
+
* @returns A promise that resolves to NetworkStake or null.
|
|
1518
|
+
*/
|
|
1519
|
+
async getNetworkStake(timestamp) {
|
|
1520
|
+
this.logger.info("Getting network stake");
|
|
1521
|
+
let url = `/api/v1/network/stake`;
|
|
1522
|
+
if (timestamp) {
|
|
1523
|
+
url += `?timestamp=${timestamp}`;
|
|
1114
1524
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1525
|
+
try {
|
|
1526
|
+
const response = await this._requestWithRetry(url);
|
|
1527
|
+
return response;
|
|
1528
|
+
} catch (error) {
|
|
1529
|
+
this.logger.error(`Error fetching network stake: ${error.message}`);
|
|
1530
|
+
return null;
|
|
1117
1531
|
}
|
|
1118
|
-
return void 0;
|
|
1119
1532
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1533
|
+
/**
|
|
1534
|
+
* Retrieves opcode traces for a specific transaction.
|
|
1535
|
+
* @param transactionIdOrHash The transaction ID or hash.
|
|
1536
|
+
* @param options Optional parameters for trace details.
|
|
1537
|
+
* @returns A promise that resolves to an OpcodesResponse or null.
|
|
1538
|
+
*/
|
|
1539
|
+
async getOpcodeTraces(transactionIdOrHash, options) {
|
|
1540
|
+
this.logger.info(`Getting opcode traces for ${transactionIdOrHash}`);
|
|
1541
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}/opcodes`;
|
|
1542
|
+
const params = new URLSearchParams();
|
|
1543
|
+
if (options?.stack !== void 0) {
|
|
1544
|
+
params.append("stack", options.stack.toString());
|
|
1123
1545
|
}
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1546
|
+
if (options?.memory !== void 0) {
|
|
1547
|
+
params.append("memory", options.memory.toString());
|
|
1126
1548
|
}
|
|
1127
|
-
if (
|
|
1128
|
-
|
|
1549
|
+
if (options?.storage !== void 0) {
|
|
1550
|
+
params.append("storage", options.storage.toString());
|
|
1129
1551
|
}
|
|
1130
|
-
const
|
|
1131
|
-
if (
|
|
1132
|
-
|
|
1552
|
+
const queryString = params.toString();
|
|
1553
|
+
if (queryString) {
|
|
1554
|
+
url += `?${queryString}`;
|
|
1555
|
+
}
|
|
1556
|
+
try {
|
|
1557
|
+
const response = await this._requestWithRetry(url);
|
|
1558
|
+
return response;
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
this.logger.error(
|
|
1561
|
+
`Error fetching opcode traces for ${transactionIdOrHash}: ${error.message}`
|
|
1562
|
+
);
|
|
1563
|
+
return null;
|
|
1133
1564
|
}
|
|
1134
|
-
const normalised = message.toLowerCase();
|
|
1135
|
-
return normalised.includes("history") || normalised.includes("chat history");
|
|
1136
|
-
}
|
|
1137
|
-
async executeHistoryAutoTopUp(reason) {
|
|
1138
|
-
if (!this.historyAutoTopUp) {
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
const hbarAmount = this.historyAutoTopUp.hbarAmount && this.historyAutoTopUp.hbarAmount > 0 ? this.historyAutoTopUp.hbarAmount : DEFAULT_HISTORY_TOP_UP_HBAR;
|
|
1142
|
-
await this.purchaseCreditsWithHbar({
|
|
1143
|
-
accountId: this.historyAutoTopUp.accountId,
|
|
1144
|
-
privateKey: this.historyAutoTopUp.privateKey,
|
|
1145
|
-
hbarAmount,
|
|
1146
|
-
memo: this.historyAutoTopUp.memo ?? "registry-broker-client:chat-history-topup",
|
|
1147
|
-
metadata: {
|
|
1148
|
-
purpose: "chat-history",
|
|
1149
|
-
reason
|
|
1150
|
-
}
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
initializeEncryptionBootstrap(options) {
|
|
1154
|
-
return this.bootstrapEncryptionOptions(options).then(() => void 0);
|
|
1155
|
-
}
|
|
1156
|
-
bootstrapEncryptionOptions(options) {
|
|
1157
|
-
return bootstrapEncryptionOptions(this, options);
|
|
1158
1565
|
}
|
|
1159
1566
|
}
|
|
1160
|
-
const isPendingRegisterAgentResponse = (response) => response.status === "pending";
|
|
1161
|
-
const isPartialRegisterAgentResponse = (response) => response.status === "partial" && response.success === false;
|
|
1162
|
-
const isSuccessRegisterAgentResponse = (response) => response.success === true && response.status !== "pending";
|
|
1163
1567
|
export {
|
|
1164
|
-
|
|
1165
|
-
isPartialRegisterAgentResponse,
|
|
1166
|
-
isPendingRegisterAgentResponse,
|
|
1167
|
-
isSuccessRegisterAgentResponse
|
|
1568
|
+
HederaMirrorNode
|
|
1168
1569
|
};
|
|
1169
1570
|
//# sourceMappingURL=standards-sdk.es169.js.map
|