@hashgraphonline/standards-sdk 0.1.167 → 0.1.169
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/README.md +21 -7
- package/dist/browser/hcs-10/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-10/types.d.ts +3 -1
- package/dist/browser/hcs-10/types.d.ts.map +1 -1
- package/dist/browser/hcs-11/client.d.ts.map +1 -1
- package/dist/browser/hcs-11/types.d.ts +2 -1
- package/dist/browser/hcs-11/types.d.ts.map +1 -1
- package/dist/browser/hcs-12/sdk.d.ts +2 -0
- package/dist/browser/hcs-12/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-15/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-15/types.d.ts +2 -1
- package/dist/browser/hcs-15/types.d.ts.map +1 -1
- package/dist/browser/hcs-16/sdk.d.ts +2 -1
- package/dist/browser/hcs-16/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-17/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-17/types.d.ts +2 -1
- package/dist/browser/hcs-17/types.d.ts.map +1 -1
- package/dist/browser/hcs-18/sdk.d.ts +2 -1
- package/dist/browser/hcs-18/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-2/client.d.ts +2 -1
- package/dist/browser/hcs-2/client.d.ts.map +1 -1
- package/dist/browser/hcs-20/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-20/types.d.ts +2 -1
- package/dist/browser/hcs-20/types.d.ts.map +1 -1
- package/dist/browser/hcs-21/sdk.d.ts +2 -1
- package/dist/browser/hcs-21/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-27/base-client.d.ts +41 -0
- package/dist/browser/hcs-27/base-client.d.ts.map +1 -0
- package/dist/browser/hcs-27/index.d.ts +6 -0
- package/dist/browser/hcs-27/index.d.ts.map +1 -0
- package/dist/browser/hcs-27/memos.d.ts +5 -0
- package/dist/browser/hcs-27/memos.d.ts.map +1 -0
- package/dist/browser/hcs-27/merkle.d.ts +23 -0
- package/dist/browser/hcs-27/merkle.d.ts.map +1 -0
- package/dist/browser/hcs-27/sdk.d.ts +23 -0
- package/dist/browser/hcs-27/sdk.d.ts.map +1 -0
- package/dist/browser/hcs-27/types.d.ts +1611 -0
- package/dist/browser/hcs-27/types.d.ts.map +1 -0
- package/dist/browser/hcs-5/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-5/types.d.ts +2 -1
- package/dist/browser/hcs-5/types.d.ts.map +1 -1
- package/dist/browser/hcs-6/sdk.d.ts +2 -1
- package/dist/browser/hcs-6/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-7/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-7/types.d.ts +2 -1
- package/dist/browser/hcs-7/types.d.ts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +33 -8
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser/utils/key-type-detector.d.ts.map +1 -1
- package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-10/types.d.ts +3 -1
- package/dist/cjs/hcs-10/types.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +2 -1
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-12/sdk.d.ts +2 -0
- package/dist/cjs/hcs-12/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-15/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-15/types.d.ts +2 -1
- package/dist/cjs/hcs-15/types.d.ts.map +1 -1
- package/dist/cjs/hcs-16/sdk.d.ts +2 -1
- package/dist/cjs/hcs-16/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-17/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-17/types.d.ts +2 -1
- package/dist/cjs/hcs-17/types.d.ts.map +1 -1
- package/dist/cjs/hcs-18/sdk.d.ts +2 -1
- package/dist/cjs/hcs-18/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-2/client.d.ts +2 -1
- package/dist/cjs/hcs-2/client.d.ts.map +1 -1
- package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-20/types.d.ts +2 -1
- package/dist/cjs/hcs-20/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts +2 -1
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-27/base-client.d.ts +41 -0
- package/dist/cjs/hcs-27/base-client.d.ts.map +1 -0
- package/dist/cjs/hcs-27/index.d.ts +6 -0
- package/dist/cjs/hcs-27/index.d.ts.map +1 -0
- package/dist/cjs/hcs-27/memos.d.ts +5 -0
- package/dist/cjs/hcs-27/memos.d.ts.map +1 -0
- package/dist/cjs/hcs-27/merkle.d.ts +23 -0
- package/dist/cjs/hcs-27/merkle.d.ts.map +1 -0
- package/dist/cjs/hcs-27/sdk.d.ts +23 -0
- package/dist/cjs/hcs-27/sdk.d.ts.map +1 -0
- package/dist/cjs/hcs-27/types.d.ts +1611 -0
- package/dist/cjs/hcs-27/types.d.ts.map +1 -0
- package/dist/cjs/hcs-5/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-5/types.d.ts +2 -1
- package/dist/cjs/hcs-5/types.d.ts.map +1 -1
- package/dist/cjs/hcs-6/sdk.d.ts +2 -1
- package/dist/cjs/hcs-6/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-7/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-7/types.d.ts +2 -1
- package/dist/cjs/hcs-7/types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/cjs/utils/key-type-detector.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-10/types.d.ts +3 -1
- package/dist/es/hcs-10/types.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +2 -1
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-12/sdk.d.ts +2 -0
- package/dist/es/hcs-12/sdk.d.ts.map +1 -1
- package/dist/es/hcs-15/sdk.d.ts.map +1 -1
- package/dist/es/hcs-15/types.d.ts +2 -1
- package/dist/es/hcs-15/types.d.ts.map +1 -1
- package/dist/es/hcs-16/sdk.d.ts +2 -1
- package/dist/es/hcs-16/sdk.d.ts.map +1 -1
- package/dist/es/hcs-17/sdk.d.ts.map +1 -1
- package/dist/es/hcs-17/types.d.ts +2 -1
- package/dist/es/hcs-17/types.d.ts.map +1 -1
- package/dist/es/hcs-18/sdk.d.ts +2 -1
- package/dist/es/hcs-18/sdk.d.ts.map +1 -1
- package/dist/es/hcs-2/client.d.ts +2 -1
- package/dist/es/hcs-2/client.d.ts.map +1 -1
- package/dist/es/hcs-20/sdk.d.ts.map +1 -1
- package/dist/es/hcs-20/types.d.ts +2 -1
- package/dist/es/hcs-20/types.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts +2 -1
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-27/base-client.d.ts +41 -0
- package/dist/es/hcs-27/base-client.d.ts.map +1 -0
- package/dist/es/hcs-27/index.d.ts +6 -0
- package/dist/es/hcs-27/index.d.ts.map +1 -0
- package/dist/es/hcs-27/memos.d.ts +5 -0
- package/dist/es/hcs-27/memos.d.ts.map +1 -0
- package/dist/es/hcs-27/merkle.d.ts +23 -0
- package/dist/es/hcs-27/merkle.d.ts.map +1 -0
- package/dist/es/hcs-27/sdk.d.ts +23 -0
- package/dist/es/hcs-27/sdk.d.ts.map +1 -0
- package/dist/es/hcs-27/types.d.ts +1611 -0
- package/dist/es/hcs-27/types.d.ts.map +1 -0
- package/dist/es/hcs-5/sdk.d.ts.map +1 -1
- package/dist/es/hcs-5/types.d.ts +2 -1
- package/dist/es/hcs-5/types.d.ts.map +1 -1
- package/dist/es/hcs-6/sdk.d.ts +2 -1
- package/dist/es/hcs-6/sdk.d.ts.map +1 -1
- package/dist/es/hcs-7/sdk.d.ts.map +1 -1
- package/dist/es/hcs-7/types.d.ts +2 -1
- package/dist/es/hcs-7/types.d.ts.map +1 -1
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +67 -38
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +2 -2
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +2 -2
- package/dist/es/standards-sdk.es104.js +2 -2
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +3 -3
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es11.js +3 -2
- package/dist/es/standards-sdk.es11.js.map +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.es112.js +151 -234
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +20 -471
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +263 -104
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +167 -138
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +315 -29
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +250 -10
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +448 -152
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +101 -25
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +155 -17
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +29 -155
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +9 -200
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +146 -754
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +27 -11
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +19 -564
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +140 -582
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +202 -12
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +790 -2
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +10 -84
- 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 +567 -40
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +626 -2
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +12 -234
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +2 -1140
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +73 -292
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +36 -418
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +2 -355
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +198 -1079
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +1107 -175
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +218 -1479
- 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 +422 -1500
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +351 -13
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +1102 -73
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +203 -76
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +1459 -830
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +1499 -59
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +14 -156
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +87 -7
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +74 -79
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +934 -61
- 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 +60 -30
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +159 -34
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +7 -48
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +70 -122
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +58 -35
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +30 -12482
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +34 -56
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +48 -84
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +128 -71
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +33 -191
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +5 -5
- package/dist/es/standards-sdk.es160.js +12477 -12
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +15 -548
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +51 -167
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +70 -308
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +71 -336
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +186 -439
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +537 -318
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +63 -66
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +165 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +310 -160
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +336 -212
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +437 -223
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +324 -112
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +65 -115
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +151 -140
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +193 -156
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +221 -121
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +81 -293
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +114 -247
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +119 -110
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +15 -14
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es180.js +188 -0
- package/dist/es/standards-sdk.es180.js.map +1 -0
- package/dist/es/standards-sdk.es181.js +142 -0
- package/dist/es/standards-sdk.es181.js.map +1 -0
- package/dist/es/standards-sdk.es182.js +334 -0
- package/dist/es/standards-sdk.es182.js.map +1 -0
- package/dist/es/standards-sdk.es183.js +262 -0
- package/dist/es/standards-sdk.es183.js.map +1 -0
- package/dist/es/standards-sdk.es184.js +155 -0
- package/dist/es/standards-sdk.es184.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +9 -9
- package/dist/es/standards-sdk.es2.js +2 -2
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- 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.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js.map +1 -1
- 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 +6 -6
- package/dist/es/standards-sdk.es36.js +5 -5
- package/dist/es/standards-sdk.es36.js.map +1 -1
- 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 +3 -3
- package/dist/es/standards-sdk.es4.js.map +1 -1
- 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 +7 -7
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +5 -4
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +6 -6
- package/dist/es/standards-sdk.es75.js.map +1 -1
- 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.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +2 -2
- package/dist/es/standards-sdk.es83.js +7 -5
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +4 -4
- 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 +5 -5
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +4 -4
- package/dist/es/standards-sdk.es94.js.map +1 -1
- 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 +4 -4
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/key-type-detector.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,90 +1,1119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"avalanche-fuji": 43113,
|
|
19
|
-
iotex: 4689,
|
|
20
|
-
sei: 1329,
|
|
21
|
-
"sei-testnet": 1328,
|
|
22
|
-
polygon: 137,
|
|
23
|
-
"polygon-amoy": 80002,
|
|
24
|
-
peaq: 3338
|
|
1
|
+
import { InscriptionSDK } from "./standards-sdk.es160.js";
|
|
2
|
+
import { Logger } from "./standards-sdk.es123.js";
|
|
3
|
+
import { ProgressReporter } from "./standards-sdk.es126.js";
|
|
4
|
+
import { TransactionParser } from "./standards-sdk.es128.js";
|
|
5
|
+
import { isBrowser } from "./standards-sdk.es136.js";
|
|
6
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
7
|
+
import { validateQuoteParameters, getCachedQuote, getOrCreateSDK, cacheQuote } from "./standards-sdk.es143.js";
|
|
8
|
+
import { HederaMirrorNode } from "./standards-sdk.es144.js";
|
|
9
|
+
import { sleep } from "./standards-sdk.es133.js";
|
|
10
|
+
import { computeInscriptionCostSummary } from "./standards-sdk.es167.js";
|
|
11
|
+
let nodeModules = {};
|
|
12
|
+
const normalizeTransactionId = (txId) => {
|
|
13
|
+
if (!txId.includes("@")) {
|
|
14
|
+
return txId;
|
|
15
|
+
}
|
|
16
|
+
const txParts = txId?.split("@");
|
|
17
|
+
return `${txParts[0]}-${txParts[1].replace(".", "-")}`;
|
|
25
18
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const parseChainId = (value) => {
|
|
30
|
-
if (/^eip155:\d+$/i.test(value)) {
|
|
31
|
-
return Number.parseInt(value.split(":")[1], 10);
|
|
19
|
+
async function loadNodeModules() {
|
|
20
|
+
if (isBrowser || nodeModules.readFileSync) {
|
|
21
|
+
return;
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
try {
|
|
24
|
+
const globalObj = typeof global !== "undefined" ? global : globalThis;
|
|
25
|
+
const req = globalObj.process?.mainModule?.require || globalObj.require;
|
|
26
|
+
if (typeof req === "function") {
|
|
27
|
+
const fs = req("fs");
|
|
28
|
+
const path = req("path");
|
|
29
|
+
nodeModules.readFileSync = fs.readFileSync;
|
|
30
|
+
nodeModules.basename = path.basename;
|
|
31
|
+
nodeModules.extname = path.extname;
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error("require function not available");
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.warn(
|
|
37
|
+
"Node.js modules not available, file path operations will be disabled"
|
|
38
|
+
);
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (chainId === void 0) {
|
|
43
|
-
const mapped = EVM_NETWORK_CHAIN_IDS[trimmed];
|
|
44
|
-
if (mapped !== void 0) {
|
|
45
|
-
chainId = mapped;
|
|
46
|
-
alias = trimmed;
|
|
47
|
-
}
|
|
48
|
-
} else if (CHAIN_ID_TO_ALIAS.has(chainId)) {
|
|
49
|
-
alias = CHAIN_ID_TO_ALIAS.get(chainId);
|
|
50
|
-
}
|
|
51
|
-
if (chainId === void 0) {
|
|
40
|
+
}
|
|
41
|
+
const COST_LOOKUP_ATTEMPTS = 3;
|
|
42
|
+
const COST_LOOKUP_DELAY_MS = 1e3;
|
|
43
|
+
const COST_LOGGER_MODULE = "InscriberCost";
|
|
44
|
+
async function convertFileToBase64(filePath) {
|
|
45
|
+
if (isBrowser) {
|
|
52
46
|
throw new Error(
|
|
53
|
-
|
|
47
|
+
"File path operations are not supported in browser environment. Use buffer input type instead."
|
|
54
48
|
);
|
|
55
49
|
}
|
|
50
|
+
await loadNodeModules();
|
|
51
|
+
if (!nodeModules.readFileSync || !nodeModules.basename || !nodeModules.extname) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Node.js file system modules are not available. Cannot read file from path."
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const buffer = nodeModules.readFileSync(filePath);
|
|
58
|
+
const base64 = buffer.toString("base64");
|
|
59
|
+
const fileName = nodeModules.basename(filePath);
|
|
60
|
+
let mimeType = "application/octet-stream";
|
|
61
|
+
try {
|
|
62
|
+
const fileTypeResult = await fileTypeFromBuffer(buffer);
|
|
63
|
+
if (fileTypeResult) {
|
|
64
|
+
mimeType = fileTypeResult.mime;
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const ext = nodeModules.extname(filePath).toLowerCase();
|
|
68
|
+
const mimeMap = {
|
|
69
|
+
".txt": "text/plain",
|
|
70
|
+
".json": "application/json",
|
|
71
|
+
".html": "text/html",
|
|
72
|
+
".css": "text/css",
|
|
73
|
+
".js": "application/javascript",
|
|
74
|
+
".png": "image/png",
|
|
75
|
+
".jpg": "image/jpeg",
|
|
76
|
+
".jpeg": "image/jpeg",
|
|
77
|
+
".gif": "image/gif",
|
|
78
|
+
".svg": "image/svg+xml",
|
|
79
|
+
".pdf": "application/pdf"
|
|
80
|
+
};
|
|
81
|
+
mimeType = mimeMap[ext] || "application/octet-stream";
|
|
82
|
+
}
|
|
83
|
+
return { base64, fileName, mimeType };
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Failed to read file ${filePath}: ${error.message}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function normalizeClientConfig(cfg) {
|
|
56
91
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
legacyName: alias
|
|
92
|
+
accountId: cfg.accountId,
|
|
93
|
+
privateKey: typeof cfg.privateKey === "string" ? cfg.privateKey : cfg.privateKey.toString(),
|
|
94
|
+
network: cfg.network
|
|
61
95
|
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
}
|
|
97
|
+
function resolveConnectionMode(options) {
|
|
98
|
+
if (options.connectionMode) {
|
|
99
|
+
return options.connectionMode;
|
|
100
|
+
}
|
|
101
|
+
if (typeof options.websocket === "boolean") {
|
|
102
|
+
return options.websocket ? "websocket" : "http";
|
|
103
|
+
}
|
|
104
|
+
return "websocket";
|
|
105
|
+
}
|
|
106
|
+
async function inscribe(input, clientConfig, options, existingSDK) {
|
|
107
|
+
const logger = Logger.getInstance({
|
|
108
|
+
module: "Inscriber",
|
|
109
|
+
...options.logging
|
|
110
|
+
});
|
|
111
|
+
const resolvedConnectionMode = resolveConnectionMode(options);
|
|
112
|
+
logger.info("Starting inscription process", {
|
|
113
|
+
type: input.type,
|
|
114
|
+
mode: options.mode || "file",
|
|
115
|
+
quoteOnly: options.quoteOnly || false,
|
|
116
|
+
...input.type === "url" ? { url: input.url } : {},
|
|
117
|
+
...input.type === "file" ? { path: input.path } : {},
|
|
118
|
+
...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
|
|
119
|
+
});
|
|
120
|
+
try {
|
|
121
|
+
if (options.quoteOnly) {
|
|
122
|
+
logger.debug("Quote-only mode requested, generating quote");
|
|
123
|
+
return await generateQuote(input, clientConfig, options, existingSDK);
|
|
124
|
+
}
|
|
125
|
+
if (options.mode === "hashinal" && options.metadata) {
|
|
126
|
+
validateHashinalMetadata(options.metadata, logger);
|
|
127
|
+
}
|
|
128
|
+
let sdk;
|
|
129
|
+
if (existingSDK) {
|
|
130
|
+
logger.debug("Using existing InscriptionSDK instance");
|
|
131
|
+
sdk = existingSDK;
|
|
132
|
+
} else if (options.apiKey) {
|
|
133
|
+
logger.debug("Initializing InscriptionSDK with API key");
|
|
134
|
+
sdk = new InscriptionSDK({
|
|
135
|
+
apiKey: options.apiKey,
|
|
136
|
+
network: clientConfig.network || "mainnet",
|
|
137
|
+
connectionMode: resolvedConnectionMode,
|
|
138
|
+
baseURL: options.baseURL
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
logger.debug("Initializing InscriptionSDK with server auth");
|
|
142
|
+
const normalized = normalizeClientConfig(clientConfig);
|
|
143
|
+
sdk = await InscriptionSDK.createWithAuth({
|
|
144
|
+
type: "server",
|
|
145
|
+
accountId: normalized.accountId,
|
|
146
|
+
privateKey: normalized.privateKey,
|
|
147
|
+
network: normalized.network || "mainnet",
|
|
148
|
+
connectionMode: resolvedConnectionMode,
|
|
149
|
+
baseUrl: options.baseURL
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const baseRequest = {
|
|
153
|
+
holderId: clientConfig.accountId,
|
|
154
|
+
metadata: options.metadata || {},
|
|
155
|
+
tags: options.tags || [],
|
|
156
|
+
mode: options.mode || "file",
|
|
157
|
+
fileStandard: options.fileStandard,
|
|
158
|
+
chunkSize: options.chunkSize
|
|
159
|
+
};
|
|
160
|
+
let request;
|
|
161
|
+
switch (input.type) {
|
|
162
|
+
case "url":
|
|
163
|
+
request = {
|
|
164
|
+
...baseRequest,
|
|
165
|
+
file: {
|
|
166
|
+
type: "url",
|
|
167
|
+
url: input.url
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
break;
|
|
171
|
+
case "file": {
|
|
172
|
+
const fileData = await convertFileToBase64(input.path);
|
|
173
|
+
request = {
|
|
174
|
+
...baseRequest,
|
|
175
|
+
file: {
|
|
176
|
+
type: "base64",
|
|
177
|
+
base64: fileData.base64,
|
|
178
|
+
fileName: fileData.fileName,
|
|
179
|
+
mimeType: fileData.mimeType
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case "buffer":
|
|
185
|
+
request = {
|
|
186
|
+
...baseRequest,
|
|
187
|
+
file: {
|
|
188
|
+
type: "base64",
|
|
189
|
+
base64: Buffer.from(
|
|
190
|
+
input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
|
|
191
|
+
).toString("base64"),
|
|
192
|
+
fileName: input.fileName,
|
|
193
|
+
mimeType: input.mimeType
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (options.mode === "hashinal") {
|
|
199
|
+
request.metadataObject = options.metadata;
|
|
200
|
+
request.creator = options.metadata?.creator || clientConfig.accountId;
|
|
201
|
+
request.description = options.metadata?.description;
|
|
202
|
+
if (options.jsonFileURL) {
|
|
203
|
+
request.jsonFileURL = options.jsonFileURL;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
logger.debug("Preparing to inscribe content", {
|
|
207
|
+
type: input.type,
|
|
208
|
+
mode: options.mode || "file",
|
|
209
|
+
holderId: clientConfig.accountId
|
|
210
|
+
});
|
|
211
|
+
const normalizedCfg = normalizeClientConfig(clientConfig);
|
|
212
|
+
const result = await sdk.inscribeAndExecute(
|
|
213
|
+
request,
|
|
214
|
+
normalizedCfg,
|
|
215
|
+
options.progressCallback
|
|
216
|
+
);
|
|
217
|
+
const rawJobId = result.jobId || result.tx_id || result.transactionId || "";
|
|
218
|
+
const rawTxId = result.transactionId || rawJobId || "";
|
|
219
|
+
const normalizedJobId = normalizeTransactionId(rawJobId);
|
|
220
|
+
const normalizedTxId = normalizeTransactionId(rawTxId);
|
|
221
|
+
const waitId = normalizeTransactionId(
|
|
222
|
+
normalizedJobId || normalizedTxId || rawJobId || result.jobId || ""
|
|
223
|
+
);
|
|
224
|
+
logger.info("Starting to inscribe.", {
|
|
225
|
+
type: input.type,
|
|
226
|
+
mode: options.mode || "file",
|
|
227
|
+
transactionId: result.jobId
|
|
228
|
+
});
|
|
229
|
+
if (options.waitForConfirmation) {
|
|
230
|
+
logger.debug("Waiting for inscription confirmation", {
|
|
231
|
+
transactionId: waitId,
|
|
232
|
+
maxAttempts: options.waitMaxAttempts,
|
|
233
|
+
intervalMs: options.waitIntervalMs
|
|
234
|
+
});
|
|
235
|
+
const inscription = await waitForInscriptionConfirmation(
|
|
236
|
+
sdk,
|
|
237
|
+
waitId,
|
|
238
|
+
options.waitMaxAttempts,
|
|
239
|
+
options.waitIntervalMs,
|
|
240
|
+
options.progressCallback
|
|
241
|
+
);
|
|
242
|
+
logger.info("Inscription confirmation received", {
|
|
243
|
+
transactionId: result.jobId
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
confirmed: true,
|
|
247
|
+
result: {
|
|
248
|
+
...result,
|
|
249
|
+
jobId: waitId,
|
|
250
|
+
transactionId: normalizedTxId
|
|
251
|
+
},
|
|
252
|
+
inscription,
|
|
253
|
+
sdk,
|
|
254
|
+
costSummary: await resolveInscriptionCost(
|
|
255
|
+
normalizedTxId,
|
|
256
|
+
clientConfig.network || "mainnet",
|
|
257
|
+
options.logging?.level
|
|
258
|
+
)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
confirmed: false,
|
|
263
|
+
result: {
|
|
264
|
+
...result,
|
|
265
|
+
jobId: waitId,
|
|
266
|
+
transactionId: normalizedTxId
|
|
267
|
+
},
|
|
268
|
+
sdk,
|
|
269
|
+
costSummary: await resolveInscriptionCost(
|
|
270
|
+
normalizedTxId,
|
|
271
|
+
clientConfig.network || "mainnet",
|
|
272
|
+
options.logging?.level
|
|
273
|
+
)
|
|
274
|
+
};
|
|
275
|
+
} catch (error) {
|
|
276
|
+
logger.error("Error during inscription process", error);
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async function resolveInscriptionCost(transactionId, network, level) {
|
|
281
|
+
const logger = Logger.getInstance({
|
|
282
|
+
module: COST_LOGGER_MODULE,
|
|
283
|
+
level: level ?? "info"
|
|
284
|
+
});
|
|
285
|
+
const mirrorNode = new HederaMirrorNode(network, logger);
|
|
286
|
+
const normalizedId = normalizeTransactionId(transactionId);
|
|
287
|
+
const payerAccountId = normalizedId.split("-")[0];
|
|
288
|
+
for (let attempt = 0; attempt < COST_LOOKUP_ATTEMPTS; attempt++) {
|
|
289
|
+
try {
|
|
290
|
+
const txn = await mirrorNode.getTransaction(normalizedId);
|
|
291
|
+
if (!txn) {
|
|
292
|
+
if (attempt < COST_LOOKUP_ATTEMPTS - 1) {
|
|
293
|
+
await sleep(COST_LOOKUP_DELAY_MS);
|
|
294
|
+
}
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const computed = computeInscriptionCostSummary({
|
|
298
|
+
txn,
|
|
299
|
+
payerAccountId
|
|
300
|
+
});
|
|
301
|
+
if (!computed) {
|
|
302
|
+
if (attempt < COST_LOOKUP_ATTEMPTS - 1) {
|
|
303
|
+
await sleep(COST_LOOKUP_DELAY_MS);
|
|
304
|
+
}
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
return computed.summary;
|
|
308
|
+
} catch (error) {
|
|
309
|
+
logger.warn("Unable to resolve inscription cost", {
|
|
310
|
+
transactionId: normalizedId,
|
|
311
|
+
attempt: attempt + 1,
|
|
312
|
+
error: error instanceof Error ? error.message : String(error)
|
|
313
|
+
});
|
|
314
|
+
if (attempt < COST_LOOKUP_ATTEMPTS - 1) {
|
|
315
|
+
await sleep(COST_LOOKUP_DELAY_MS);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return void 0;
|
|
320
|
+
}
|
|
321
|
+
async function inscribeWithSigner(input, signer, options, existingSDK) {
|
|
322
|
+
const logger = Logger.getInstance({
|
|
323
|
+
module: "Inscriber",
|
|
324
|
+
...options.logging
|
|
325
|
+
});
|
|
326
|
+
const resolvedConnectionMode = resolveConnectionMode(options);
|
|
327
|
+
logger.info("Starting inscription process with signer", {
|
|
328
|
+
type: input.type,
|
|
329
|
+
mode: options.mode || "file",
|
|
330
|
+
quoteOnly: options.quoteOnly || false,
|
|
331
|
+
...input.type === "url" ? { url: input.url } : {},
|
|
332
|
+
...input.type === "file" ? { path: input.path } : {},
|
|
333
|
+
...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
|
|
334
|
+
});
|
|
335
|
+
try {
|
|
336
|
+
if (options.quoteOnly) {
|
|
337
|
+
logger.debug("Quote-only mode requested with signer, generating quote");
|
|
338
|
+
const clientConfig = {
|
|
339
|
+
accountId: signer.getAccountId().toString(),
|
|
340
|
+
privateKey: "",
|
|
341
|
+
network: options.network || "mainnet"
|
|
342
|
+
};
|
|
343
|
+
return await generateQuote(input, clientConfig, options, existingSDK);
|
|
344
|
+
}
|
|
345
|
+
if (options.mode === "hashinal" && options.metadata) {
|
|
346
|
+
validateHashinalMetadata(options.metadata, logger);
|
|
347
|
+
}
|
|
348
|
+
const accountId = signer.getAccountId().toString();
|
|
349
|
+
logger.debug("Using account ID from signer", { accountId });
|
|
350
|
+
let sdk;
|
|
351
|
+
if (existingSDK) {
|
|
352
|
+
logger.debug("Using existing InscriptionSDK instance");
|
|
353
|
+
sdk = existingSDK;
|
|
354
|
+
} else if (options.apiKey) {
|
|
355
|
+
logger.debug("Initializing InscriptionSDK with API key");
|
|
356
|
+
sdk = new InscriptionSDK({
|
|
357
|
+
apiKey: options.apiKey,
|
|
358
|
+
network: options.network || "mainnet",
|
|
359
|
+
connectionMode: resolvedConnectionMode,
|
|
360
|
+
baseURL: options.baseURL
|
|
361
|
+
});
|
|
362
|
+
} else {
|
|
363
|
+
logger.debug("Initializing InscriptionSDK with client auth (websocket)");
|
|
364
|
+
sdk = await InscriptionSDK.createWithAuth({
|
|
365
|
+
type: "client",
|
|
366
|
+
accountId,
|
|
367
|
+
signer,
|
|
368
|
+
network: options.network || "mainnet",
|
|
369
|
+
connectionMode: resolvedConnectionMode,
|
|
370
|
+
baseUrl: options.baseURL
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const baseRequest = {
|
|
374
|
+
holderId: accountId,
|
|
375
|
+
metadata: options.metadata || {},
|
|
376
|
+
tags: options.tags || [],
|
|
377
|
+
mode: options.mode || "file",
|
|
378
|
+
fileStandard: options.fileStandard,
|
|
379
|
+
chunkSize: options.chunkSize
|
|
380
|
+
};
|
|
381
|
+
let request;
|
|
382
|
+
switch (input.type) {
|
|
383
|
+
case "url":
|
|
384
|
+
request = {
|
|
385
|
+
...baseRequest,
|
|
386
|
+
file: {
|
|
387
|
+
type: "url",
|
|
388
|
+
url: input.url
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
break;
|
|
392
|
+
case "file": {
|
|
393
|
+
const fileData = await convertFileToBase64(input.path);
|
|
394
|
+
request = {
|
|
395
|
+
...baseRequest,
|
|
396
|
+
file: {
|
|
397
|
+
type: "base64",
|
|
398
|
+
base64: fileData.base64,
|
|
399
|
+
fileName: fileData.fileName,
|
|
400
|
+
mimeType: fileData.mimeType
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case "buffer":
|
|
406
|
+
request = {
|
|
407
|
+
...baseRequest,
|
|
408
|
+
file: {
|
|
409
|
+
type: "base64",
|
|
410
|
+
base64: Buffer.from(
|
|
411
|
+
input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
|
|
412
|
+
).toString("base64"),
|
|
413
|
+
fileName: input.fileName,
|
|
414
|
+
mimeType: input.mimeType
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
if (options.mode === "hashinal") {
|
|
420
|
+
request.metadataObject = options.metadata;
|
|
421
|
+
request.creator = options.metadata?.creator || accountId;
|
|
422
|
+
request.description = options.metadata?.description;
|
|
423
|
+
if (options.jsonFileURL) {
|
|
424
|
+
request.jsonFileURL = options.jsonFileURL;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
logger.debug("Starting inscription via startInscription (websocket)", {
|
|
428
|
+
type: input.type,
|
|
429
|
+
mode: options.mode || "file",
|
|
430
|
+
holderId: accountId,
|
|
431
|
+
usesStartInscription: true
|
|
432
|
+
});
|
|
433
|
+
const startResult = await sdk.startInscription({
|
|
434
|
+
...request,
|
|
435
|
+
holderId: accountId,
|
|
436
|
+
network: options.network || "mainnet"
|
|
437
|
+
});
|
|
438
|
+
const startTransactionIdRaw = typeof startResult?.tx_id === "string" && startResult.tx_id.trim() || typeof startResult?.jobId === "string" && (startResult.jobId || "").trim() || typeof startResult?.id === "string" && (startResult.id || "").trim() || "";
|
|
439
|
+
const waitId = normalizeTransactionId(startTransactionIdRaw);
|
|
440
|
+
if (!waitId) {
|
|
441
|
+
throw new Error("startInscription did not return a transaction id");
|
|
442
|
+
}
|
|
443
|
+
logger.info("about to start inscription", {
|
|
444
|
+
type: input.type,
|
|
445
|
+
mode: options.mode || "file",
|
|
446
|
+
jobId: waitId,
|
|
447
|
+
...startResult
|
|
448
|
+
});
|
|
449
|
+
if (typeof startResult?.transactionBytes === "string") {
|
|
450
|
+
logger.debug("Executing inscription transaction with signer from bytes");
|
|
451
|
+
await sdk.executeTransactionWithSigner(
|
|
452
|
+
startResult.transactionBytes,
|
|
453
|
+
signer
|
|
454
|
+
);
|
|
455
|
+
} else if (startResult?.transactionBytes?.type === "Buffer") {
|
|
456
|
+
logger.debug("Executing inscription transaction with signer from buffer");
|
|
457
|
+
await sdk.executeTransactionWithSigner(
|
|
458
|
+
Buffer.from(startResult.transactionBytes.data).toString("base64"),
|
|
459
|
+
signer
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
if (options.waitForConfirmation) {
|
|
463
|
+
logger.debug("Waiting for inscription confirmation (websocket)", {
|
|
464
|
+
jobId: waitId,
|
|
465
|
+
maxAttempts: options.waitMaxAttempts,
|
|
466
|
+
intervalMs: options.waitIntervalMs
|
|
467
|
+
});
|
|
468
|
+
const inscription = await waitForInscriptionConfirmation(
|
|
469
|
+
sdk,
|
|
470
|
+
waitId,
|
|
471
|
+
options.waitMaxAttempts,
|
|
472
|
+
options.waitIntervalMs,
|
|
473
|
+
options.progressCallback
|
|
474
|
+
);
|
|
475
|
+
logger.info("Inscription confirmation received", {
|
|
476
|
+
jobId: waitId
|
|
477
|
+
});
|
|
478
|
+
return {
|
|
479
|
+
confirmed: true,
|
|
480
|
+
result: {
|
|
481
|
+
jobId: waitId,
|
|
482
|
+
transactionId: waitId,
|
|
483
|
+
topic_id: startResult.topic_id,
|
|
484
|
+
status: startResult.status,
|
|
485
|
+
completed: startResult.completed
|
|
486
|
+
},
|
|
487
|
+
inscription,
|
|
488
|
+
sdk,
|
|
489
|
+
costSummary: await resolveInscriptionCost(
|
|
490
|
+
waitId,
|
|
491
|
+
options.network || "mainnet",
|
|
492
|
+
options.logging?.level
|
|
493
|
+
)
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
confirmed: false,
|
|
498
|
+
result: {
|
|
499
|
+
jobId: waitId,
|
|
500
|
+
transactionId: waitId,
|
|
501
|
+
topic_id: startResult.topic_id,
|
|
502
|
+
status: startResult.status,
|
|
503
|
+
completed: startResult.completed
|
|
504
|
+
},
|
|
505
|
+
sdk,
|
|
506
|
+
costSummary: await resolveInscriptionCost(
|
|
507
|
+
waitId,
|
|
508
|
+
options.network || "mainnet",
|
|
509
|
+
options.logging?.level
|
|
510
|
+
)
|
|
511
|
+
};
|
|
512
|
+
} catch (error) {
|
|
513
|
+
logger.error("Error during inscription process", error);
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
async function retrieveInscription(transactionId, options) {
|
|
518
|
+
const logger = Logger.getInstance({
|
|
519
|
+
module: "Inscriber",
|
|
520
|
+
...options?.logging || {}
|
|
521
|
+
});
|
|
522
|
+
const formattedTransactionId = transactionId.includes("@") ? `${transactionId.split("@")[0]}-${transactionId.split("@")[1].replace(/\./g, "-")}` : transactionId;
|
|
523
|
+
logger.info("Retrieving inscription", {
|
|
524
|
+
originalTransactionId: transactionId,
|
|
525
|
+
formattedTransactionId
|
|
526
|
+
});
|
|
527
|
+
try {
|
|
528
|
+
let sdk;
|
|
529
|
+
if (options?.apiKey) {
|
|
530
|
+
logger.debug("Initializing InscriptionSDK with API key");
|
|
531
|
+
sdk = new InscriptionSDK({
|
|
532
|
+
apiKey: options.apiKey,
|
|
533
|
+
network: options.network || "mainnet",
|
|
534
|
+
baseURL: options.baseURL
|
|
535
|
+
});
|
|
536
|
+
} else if (options?.accountId && options?.privateKey) {
|
|
537
|
+
logger.debug("Initializing InscriptionSDK with server auth");
|
|
538
|
+
sdk = await InscriptionSDK.createWithAuth({
|
|
539
|
+
type: "server",
|
|
540
|
+
accountId: options.accountId,
|
|
541
|
+
privateKey: options.privateKey,
|
|
542
|
+
network: options.network || "mainnet",
|
|
543
|
+
baseUrl: options.baseURL
|
|
544
|
+
});
|
|
545
|
+
} else {
|
|
546
|
+
const error = new Error(
|
|
547
|
+
"Either API key or account ID and private key are required for retrieving inscriptions"
|
|
548
|
+
);
|
|
549
|
+
logger.error("Missing authentication credentials", {
|
|
550
|
+
hasApiKey: Boolean(options?.apiKey),
|
|
551
|
+
hasAccountId: Boolean(options?.accountId),
|
|
552
|
+
hasPrivateKey: Boolean(options?.privateKey)
|
|
553
|
+
});
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
556
|
+
logger.debug("Initialized SDK for inscription retrieval", {
|
|
557
|
+
formattedTransactionId,
|
|
558
|
+
network: options.network || "mainnet"
|
|
559
|
+
});
|
|
560
|
+
const result = await sdk.retrieveInscription(formattedTransactionId);
|
|
561
|
+
logger.info("Successfully retrieved inscription", {
|
|
562
|
+
formattedTransactionId
|
|
563
|
+
});
|
|
564
|
+
return result;
|
|
565
|
+
} catch (error) {
|
|
566
|
+
logger.error("Error retrieving inscription", {
|
|
567
|
+
formattedTransactionId,
|
|
568
|
+
error
|
|
569
|
+
});
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function validateHashinalMetadata(metadata, logger) {
|
|
574
|
+
const requiredFields = ["name", "creator", "description", "type"];
|
|
575
|
+
const missingFields = requiredFields.filter((field) => !metadata[field]);
|
|
576
|
+
if (missingFields.length > 0) {
|
|
577
|
+
const error = new Error(
|
|
578
|
+
`Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
|
|
579
|
+
);
|
|
580
|
+
logger.error("Hashinal metadata validation failed", { missingFields });
|
|
581
|
+
throw error;
|
|
582
|
+
}
|
|
583
|
+
logger.debug("Hashinal metadata validation passed", {
|
|
584
|
+
name: metadata.name,
|
|
585
|
+
creator: metadata.creator,
|
|
586
|
+
description: metadata.description,
|
|
587
|
+
type: metadata.type,
|
|
588
|
+
hasAttributes: !!metadata.attributes,
|
|
589
|
+
hasProperties: !!metadata.properties
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
async function generateQuote(input, clientConfig, options, existingSDK) {
|
|
593
|
+
const logger = Logger.getInstance({
|
|
594
|
+
module: "Inscriber",
|
|
595
|
+
...options.logging
|
|
596
|
+
});
|
|
597
|
+
logger.info("Generating inscription quote", {
|
|
598
|
+
type: input.type,
|
|
599
|
+
mode: options.mode || "file",
|
|
600
|
+
...input.type === "url" ? { url: input.url } : {},
|
|
601
|
+
...input.type === "file" ? { path: input.path } : {},
|
|
602
|
+
...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
|
|
603
|
+
});
|
|
604
|
+
try {
|
|
605
|
+
validateQuoteParameters(input, clientConfig, options);
|
|
606
|
+
const cachedQuote = getCachedQuote(input, clientConfig, options);
|
|
607
|
+
if (cachedQuote) {
|
|
608
|
+
logger.debug("Returning cached quote");
|
|
609
|
+
return {
|
|
610
|
+
confirmed: false,
|
|
611
|
+
quote: true,
|
|
612
|
+
result: cachedQuote
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
if (options.mode === "hashinal" && options.metadata) {
|
|
616
|
+
validateHashinalMetadata(options.metadata, logger);
|
|
617
|
+
}
|
|
618
|
+
const sdk = await getOrCreateSDK(clientConfig, options, existingSDK);
|
|
619
|
+
const baseRequest = {
|
|
620
|
+
holderId: clientConfig.accountId,
|
|
621
|
+
metadata: options.metadata || {},
|
|
622
|
+
tags: options.tags || [],
|
|
623
|
+
mode: options.mode || "file",
|
|
624
|
+
fileStandard: options.fileStandard,
|
|
625
|
+
chunkSize: options.chunkSize
|
|
626
|
+
};
|
|
627
|
+
let request;
|
|
628
|
+
switch (input.type) {
|
|
629
|
+
case "url":
|
|
630
|
+
request = {
|
|
631
|
+
...baseRequest,
|
|
632
|
+
file: {
|
|
633
|
+
type: "url",
|
|
634
|
+
url: input.url
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
break;
|
|
638
|
+
case "file": {
|
|
639
|
+
const fileData = await convertFileToBase64(input.path);
|
|
640
|
+
request = {
|
|
641
|
+
...baseRequest,
|
|
642
|
+
file: {
|
|
643
|
+
type: "base64",
|
|
644
|
+
base64: fileData.base64,
|
|
645
|
+
fileName: fileData.fileName,
|
|
646
|
+
mimeType: fileData.mimeType
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
case "buffer":
|
|
652
|
+
request = {
|
|
653
|
+
...baseRequest,
|
|
654
|
+
file: {
|
|
655
|
+
type: "base64",
|
|
656
|
+
base64: Buffer.from(
|
|
657
|
+
input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
|
|
658
|
+
).toString("base64"),
|
|
659
|
+
fileName: input.fileName,
|
|
660
|
+
mimeType: input.mimeType
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
if (options.mode === "hashinal") {
|
|
666
|
+
request.metadataObject = options.metadata;
|
|
667
|
+
request.creator = options.metadata?.creator || clientConfig.accountId;
|
|
668
|
+
request.description = options.metadata?.description;
|
|
669
|
+
if (options.jsonFileURL) {
|
|
670
|
+
request.jsonFileURL = options.jsonFileURL;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
logger.debug("Calling inscription SDK startInscription for quote", {
|
|
674
|
+
type: input.type,
|
|
675
|
+
mode: options.mode || "file",
|
|
676
|
+
holderId: clientConfig.accountId
|
|
677
|
+
});
|
|
678
|
+
const inscriptionResponse = await sdk.startInscription(request);
|
|
679
|
+
logger.debug("Received inscription response for quote parsing", {
|
|
680
|
+
hasTransactionBytes: !!inscriptionResponse.transactionBytes,
|
|
681
|
+
bytesLength: inscriptionResponse.transactionBytes?.length || 0,
|
|
682
|
+
transactionBytesType: typeof inscriptionResponse.transactionBytes,
|
|
683
|
+
totalCost: inscriptionResponse.totalCost
|
|
684
|
+
});
|
|
685
|
+
const quote = await parseTransactionForQuote(
|
|
686
|
+
inscriptionResponse,
|
|
687
|
+
logger
|
|
688
|
+
);
|
|
689
|
+
cacheQuote(input, clientConfig, options, quote);
|
|
690
|
+
logger.info("Successfully generated inscription quote", {
|
|
691
|
+
totalCostHbar: quote.totalCostHbar
|
|
692
|
+
});
|
|
693
|
+
return {
|
|
694
|
+
confirmed: false,
|
|
695
|
+
quote: true,
|
|
696
|
+
result: quote
|
|
697
|
+
};
|
|
698
|
+
} catch (error) {
|
|
699
|
+
logger.error("Error generating inscription quote", error);
|
|
700
|
+
throw error;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
async function parseTransactionForQuote(inscriptionResponse, logger) {
|
|
704
|
+
try {
|
|
705
|
+
let totalCostHbar = "0.001";
|
|
706
|
+
if (inscriptionResponse.totalCost && typeof inscriptionResponse.totalCost === "number") {
|
|
707
|
+
const hbarAmount = inscriptionResponse.totalCost / 1e8;
|
|
708
|
+
totalCostHbar = hbarAmount.toString();
|
|
709
|
+
logger.debug("Using totalCost from inscription response", {
|
|
710
|
+
totalCostTinybars: inscriptionResponse.totalCost,
|
|
711
|
+
totalCostHbar
|
|
712
|
+
});
|
|
713
|
+
} else if (inscriptionResponse.transactionBytes) {
|
|
714
|
+
logger.debug("Parsing transaction bytes for cost information");
|
|
715
|
+
try {
|
|
716
|
+
let transactionBytesString;
|
|
717
|
+
if (typeof inscriptionResponse.transactionBytes === "string") {
|
|
718
|
+
transactionBytesString = inscriptionResponse.transactionBytes;
|
|
719
|
+
} else if (inscriptionResponse.transactionBytes && typeof inscriptionResponse.transactionBytes === "object" && "data" in inscriptionResponse.transactionBytes) {
|
|
720
|
+
const buffer = Buffer.from(inscriptionResponse.transactionBytes.data);
|
|
721
|
+
transactionBytesString = buffer.toString("base64");
|
|
722
|
+
} else {
|
|
723
|
+
throw new Error("Invalid transactionBytes format");
|
|
724
|
+
}
|
|
725
|
+
logger.debug("About to parse transaction bytes", {
|
|
726
|
+
bytesLength: transactionBytesString.length,
|
|
727
|
+
bytesPreview: transactionBytesString.slice(0, 100)
|
|
728
|
+
});
|
|
729
|
+
const parsedTransaction = await TransactionParser.parseTransactionBytes(
|
|
730
|
+
transactionBytesString,
|
|
731
|
+
{ includeRaw: false }
|
|
732
|
+
);
|
|
733
|
+
logger.debug("Parsed transaction for quote", {
|
|
734
|
+
type: parsedTransaction.type,
|
|
735
|
+
hasTransfers: !!parsedTransaction.transfers,
|
|
736
|
+
transferCount: parsedTransaction.transfers?.length || 0,
|
|
737
|
+
transfers: parsedTransaction.transfers
|
|
738
|
+
});
|
|
739
|
+
let totalTransferAmount = 0;
|
|
740
|
+
if (parsedTransaction.transfers && parsedTransaction.transfers.length > 0) {
|
|
741
|
+
for (const transfer of parsedTransaction.transfers) {
|
|
742
|
+
const transferAmount = typeof transfer.amount === "string" ? parseFloat(transfer.amount) : transfer.amount;
|
|
743
|
+
if (transferAmount < 0) {
|
|
744
|
+
const amountHbar = Math.abs(transferAmount);
|
|
745
|
+
totalTransferAmount += amountHbar;
|
|
746
|
+
logger.debug("Found HBAR transfer", {
|
|
747
|
+
from: transfer.accountId,
|
|
748
|
+
to: "service",
|
|
749
|
+
amount: amountHbar
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
if (totalTransferAmount > 0) {
|
|
755
|
+
totalCostHbar = totalTransferAmount.toString();
|
|
756
|
+
logger.debug("Using parsed transaction transfer amount", {
|
|
757
|
+
totalTransferAmount,
|
|
758
|
+
totalCostHbar
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
} catch (parseError) {
|
|
762
|
+
logger.warn(
|
|
763
|
+
"Could not parse transaction bytes, using totalCost fallback",
|
|
764
|
+
{
|
|
765
|
+
error: parseError,
|
|
766
|
+
errorMessage: parseError instanceof Error ? parseError.message : String(parseError)
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
const transfers = [
|
|
772
|
+
{
|
|
773
|
+
to: "Inscription Service",
|
|
774
|
+
amount: totalCostHbar,
|
|
775
|
+
description: `Inscription fee (${totalCostHbar} HBAR)`
|
|
776
|
+
}
|
|
777
|
+
];
|
|
778
|
+
const validUntil = new Date(Date.now() + 15 * 60 * 1e3).toISOString();
|
|
779
|
+
const quote = {
|
|
780
|
+
totalCostHbar,
|
|
781
|
+
validUntil,
|
|
782
|
+
breakdown: {
|
|
783
|
+
transfers
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
logger.debug("Successfully parsed transaction for quote", {
|
|
787
|
+
totalCostHbar: quote.totalCostHbar,
|
|
788
|
+
transferCount: transfers.length,
|
|
789
|
+
hasTransactionBytes: !!inscriptionResponse.transactionBytes,
|
|
790
|
+
hasTotalCost: !!inscriptionResponse.totalCost
|
|
791
|
+
});
|
|
792
|
+
return quote;
|
|
793
|
+
} catch (error) {
|
|
794
|
+
logger.error("Error parsing transaction for quote", error);
|
|
795
|
+
throw error;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async function waitForInscriptionConfirmation(sdk, transactionId, maxAttempts = 450, intervalMs = 4e3, progressCallback) {
|
|
799
|
+
const logger = Logger.getInstance({ module: "Inscriber" });
|
|
800
|
+
const normalizedId = normalizeTransactionId(transactionId);
|
|
801
|
+
const progressReporter = new ProgressReporter({
|
|
802
|
+
module: "Inscriber",
|
|
803
|
+
logger,
|
|
804
|
+
callback: progressCallback
|
|
805
|
+
});
|
|
806
|
+
try {
|
|
807
|
+
logger.debug("Waiting for inscription confirmation", {
|
|
808
|
+
transactionId: normalizedId,
|
|
809
|
+
maxAttempts,
|
|
810
|
+
intervalMs
|
|
811
|
+
});
|
|
812
|
+
progressReporter.preparing("Preparing for inscription confirmation", 5, {
|
|
813
|
+
transactionId: normalizedId,
|
|
814
|
+
maxAttempts,
|
|
815
|
+
intervalMs
|
|
816
|
+
});
|
|
817
|
+
try {
|
|
818
|
+
const waitMethod = sdk.waitForInscription.bind(sdk);
|
|
819
|
+
const wrappedCallback = (data) => {
|
|
820
|
+
const stageRaw = data.stage || "confirming";
|
|
821
|
+
const allowedStages = [
|
|
822
|
+
"preparing",
|
|
823
|
+
"submitting",
|
|
824
|
+
"confirming",
|
|
825
|
+
"verifying",
|
|
826
|
+
"completed",
|
|
827
|
+
"failed"
|
|
828
|
+
];
|
|
829
|
+
const stage = allowedStages.includes(stageRaw) ? stageRaw : "confirming";
|
|
830
|
+
const message = data.message || "Processing inscription";
|
|
831
|
+
const percent = data.progressPercent || 50;
|
|
832
|
+
progressReporter.report({
|
|
833
|
+
stage,
|
|
834
|
+
message,
|
|
835
|
+
progressPercent: percent,
|
|
836
|
+
details: data.details
|
|
837
|
+
});
|
|
838
|
+
};
|
|
839
|
+
return await waitMethod(
|
|
840
|
+
normalizedId,
|
|
841
|
+
maxAttempts,
|
|
842
|
+
intervalMs,
|
|
843
|
+
true,
|
|
844
|
+
wrappedCallback
|
|
845
|
+
);
|
|
846
|
+
} catch (e) {
|
|
847
|
+
logger.debug("Falling back to standard waitForInscription method", {
|
|
848
|
+
error: e
|
|
849
|
+
});
|
|
850
|
+
progressReporter.verifying("Verifying inscription status", 50, {
|
|
851
|
+
error: e
|
|
852
|
+
});
|
|
853
|
+
return await sdk.waitForInscription(
|
|
854
|
+
normalizedId,
|
|
855
|
+
maxAttempts,
|
|
856
|
+
intervalMs,
|
|
857
|
+
true
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
} catch (error) {
|
|
861
|
+
logger.error("Error waiting for inscription confirmation", {
|
|
862
|
+
transactionId,
|
|
863
|
+
maxAttempts,
|
|
864
|
+
intervalMs,
|
|
865
|
+
error
|
|
866
|
+
});
|
|
867
|
+
progressReporter.failed("Inscription confirmation failed", {
|
|
868
|
+
transactionId,
|
|
869
|
+
error
|
|
870
|
+
});
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const DEFAULT_REGISTRY_BROKER_URL = "https://hol.org/registry/api/v1";
|
|
875
|
+
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
876
|
+
const DEFAULT_WAIT_TIMEOUT_MS = 12e4;
|
|
877
|
+
async function fetchRegistryBroker(url, options) {
|
|
878
|
+
const response = await fetch(url, options);
|
|
879
|
+
const body = await response.json().catch(() => ({}));
|
|
880
|
+
if (!response.ok) {
|
|
881
|
+
const errorMessage = typeof body === "object" && body && "error" in body ? String(body.error) : `HTTP ${response.status}`;
|
|
882
|
+
throw new Error(errorMessage);
|
|
883
|
+
}
|
|
884
|
+
return body;
|
|
885
|
+
}
|
|
886
|
+
async function inscribeViaRegistryBroker(input, options = {}) {
|
|
887
|
+
const logger = Logger.getInstance({
|
|
888
|
+
module: "InscribeViaBroker",
|
|
889
|
+
...options.logging
|
|
890
|
+
});
|
|
891
|
+
const baseUrl = options.baseUrl ?? DEFAULT_REGISTRY_BROKER_URL;
|
|
892
|
+
const waitForConfirmation = options.waitForConfirmation ?? true;
|
|
893
|
+
const waitTimeoutMs = options.waitTimeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
894
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
895
|
+
const headers = {
|
|
896
|
+
"Content-Type": "application/json",
|
|
897
|
+
Accept: "application/json"
|
|
898
|
+
};
|
|
899
|
+
if (options.ledgerApiKey) {
|
|
900
|
+
headers["x-api-key"] = options.ledgerApiKey;
|
|
901
|
+
} else if (options.apiKey) {
|
|
902
|
+
headers["x-api-key"] = options.apiKey;
|
|
903
|
+
} else {
|
|
67
904
|
throw new Error(
|
|
68
|
-
|
|
905
|
+
"Either ledgerApiKey or apiKey is required for Registry Broker inscription"
|
|
69
906
|
);
|
|
70
907
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
908
|
+
logger.info("Starting inscription via Registry Broker", {
|
|
909
|
+
baseUrl,
|
|
910
|
+
inputType: input.type,
|
|
911
|
+
mode: options.mode ?? "file"
|
|
912
|
+
});
|
|
913
|
+
let base64Content;
|
|
914
|
+
let fileName;
|
|
915
|
+
let mimeType;
|
|
916
|
+
switch (input.type) {
|
|
917
|
+
case "url":
|
|
918
|
+
logger.debug("Creating job with URL input");
|
|
919
|
+
break;
|
|
920
|
+
case "file": {
|
|
921
|
+
const fileData = await convertFileToBase64(input.path);
|
|
922
|
+
base64Content = fileData.base64;
|
|
923
|
+
fileName = fileData.fileName;
|
|
924
|
+
mimeType = fileData.mimeType;
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
case "buffer":
|
|
928
|
+
base64Content = Buffer.from(
|
|
929
|
+
input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
|
|
930
|
+
).toString("base64");
|
|
931
|
+
fileName = input.fileName;
|
|
932
|
+
mimeType = input.mimeType;
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
const requestBody = {
|
|
936
|
+
inputType: input.type === "url" ? "url" : "base64",
|
|
937
|
+
mode: options.mode ?? "file"
|
|
75
938
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
939
|
+
if (input.type === "url") {
|
|
940
|
+
requestBody.url = input.url;
|
|
941
|
+
} else {
|
|
942
|
+
requestBody.base64 = base64Content;
|
|
943
|
+
requestBody.fileName = fileName;
|
|
944
|
+
if (mimeType) {
|
|
945
|
+
requestBody.mimeType = mimeType;
|
|
946
|
+
}
|
|
80
947
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return normaliseHederaNetwork(trimmed);
|
|
948
|
+
if (options.metadata) {
|
|
949
|
+
requestBody.metadata = options.metadata;
|
|
84
950
|
}
|
|
85
|
-
|
|
86
|
-
|
|
951
|
+
if (options.tags) {
|
|
952
|
+
requestBody.tags = options.tags;
|
|
953
|
+
}
|
|
954
|
+
if (options.fileStandard) {
|
|
955
|
+
requestBody.fileStandard = options.fileStandard;
|
|
956
|
+
}
|
|
957
|
+
if (options.chunkSize) {
|
|
958
|
+
requestBody.chunkSize = options.chunkSize;
|
|
959
|
+
}
|
|
960
|
+
logger.debug("Creating inscription job");
|
|
961
|
+
const job = await fetchRegistryBroker(
|
|
962
|
+
`${baseUrl}/inscribe/content`,
|
|
963
|
+
{
|
|
964
|
+
method: "POST",
|
|
965
|
+
headers,
|
|
966
|
+
body: JSON.stringify(requestBody)
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
const jobId = job.jobId ?? job.id ?? "";
|
|
970
|
+
logger.info("Inscription job created", { jobId, status: job.status });
|
|
971
|
+
if (!waitForConfirmation) {
|
|
972
|
+
return {
|
|
973
|
+
confirmed: false,
|
|
974
|
+
jobId,
|
|
975
|
+
status: job.status,
|
|
976
|
+
credits: job.credits ?? job.quoteCredits,
|
|
977
|
+
usdCents: job.usdCents ?? job.quoteUsdCents,
|
|
978
|
+
sizeBytes: job.sizeBytes,
|
|
979
|
+
createdAt: job.createdAt,
|
|
980
|
+
updatedAt: job.updatedAt,
|
|
981
|
+
network: job.network
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
logger.debug("Polling for job completion", { jobId, waitTimeoutMs });
|
|
985
|
+
const startTime = Date.now();
|
|
986
|
+
let lastStatus = "";
|
|
987
|
+
while (Date.now() - startTime < waitTimeoutMs) {
|
|
988
|
+
const currentJob = await fetchRegistryBroker(
|
|
989
|
+
`${baseUrl}/inscribe/content/${jobId}`,
|
|
990
|
+
{ method: "GET", headers }
|
|
991
|
+
);
|
|
992
|
+
if (currentJob.status !== lastStatus) {
|
|
993
|
+
logger.debug("Job status update", { jobId, status: currentJob.status });
|
|
994
|
+
lastStatus = currentJob.status;
|
|
995
|
+
}
|
|
996
|
+
if (currentJob.status === "completed") {
|
|
997
|
+
logger.info("Inscription completed", {
|
|
998
|
+
jobId,
|
|
999
|
+
hrl: currentJob.hrl,
|
|
1000
|
+
topicId: currentJob.topicId
|
|
1001
|
+
});
|
|
1002
|
+
return {
|
|
1003
|
+
confirmed: true,
|
|
1004
|
+
jobId,
|
|
1005
|
+
status: currentJob.status,
|
|
1006
|
+
hrl: currentJob.hrl,
|
|
1007
|
+
topicId: currentJob.topicId,
|
|
1008
|
+
network: currentJob.network,
|
|
1009
|
+
credits: currentJob.credits ?? currentJob.quoteCredits,
|
|
1010
|
+
usdCents: currentJob.usdCents ?? currentJob.quoteUsdCents,
|
|
1011
|
+
sizeBytes: currentJob.sizeBytes,
|
|
1012
|
+
createdAt: currentJob.createdAt,
|
|
1013
|
+
updatedAt: currentJob.updatedAt
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
if (currentJob.status === "failed") {
|
|
1017
|
+
logger.error("Inscription failed", { jobId, error: currentJob.error });
|
|
1018
|
+
return {
|
|
1019
|
+
confirmed: false,
|
|
1020
|
+
jobId,
|
|
1021
|
+
status: currentJob.status,
|
|
1022
|
+
error: currentJob.error ?? "Inscription failed",
|
|
1023
|
+
credits: currentJob.credits ?? currentJob.quoteCredits,
|
|
1024
|
+
createdAt: currentJob.createdAt,
|
|
1025
|
+
updatedAt: currentJob.updatedAt
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
await sleep(pollIntervalMs);
|
|
1029
|
+
}
|
|
1030
|
+
throw new Error(
|
|
1031
|
+
`Inscription job ${jobId} did not complete within ${waitTimeoutMs}ms`
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
async function getRegistryBrokerQuote(input, options = {}) {
|
|
1035
|
+
const logger = Logger.getInstance({
|
|
1036
|
+
module: "InscribeViaBroker",
|
|
1037
|
+
...options.logging
|
|
1038
|
+
});
|
|
1039
|
+
const baseUrl = options.baseUrl ?? DEFAULT_REGISTRY_BROKER_URL;
|
|
1040
|
+
const headers = {
|
|
1041
|
+
"Content-Type": "application/json",
|
|
1042
|
+
Accept: "application/json"
|
|
1043
|
+
};
|
|
1044
|
+
if (options.ledgerApiKey) {
|
|
1045
|
+
headers["x-api-key"] = options.ledgerApiKey;
|
|
1046
|
+
} else if (options.apiKey) {
|
|
1047
|
+
headers["x-api-key"] = options.apiKey;
|
|
1048
|
+
} else {
|
|
1049
|
+
throw new Error(
|
|
1050
|
+
"Either ledgerApiKey or apiKey is required for Registry Broker quotes"
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
let base64Content;
|
|
1054
|
+
let fileName;
|
|
1055
|
+
let mimeType;
|
|
1056
|
+
switch (input.type) {
|
|
1057
|
+
case "url":
|
|
1058
|
+
break;
|
|
1059
|
+
case "file": {
|
|
1060
|
+
const fileData = await convertFileToBase64(input.path);
|
|
1061
|
+
base64Content = fileData.base64;
|
|
1062
|
+
fileName = fileData.fileName;
|
|
1063
|
+
mimeType = fileData.mimeType;
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
case "buffer":
|
|
1067
|
+
base64Content = Buffer.from(
|
|
1068
|
+
input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
|
|
1069
|
+
).toString("base64");
|
|
1070
|
+
fileName = input.fileName;
|
|
1071
|
+
mimeType = input.mimeType;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
const requestBody = {
|
|
1075
|
+
inputType: input.type === "url" ? "url" : "base64",
|
|
1076
|
+
mode: options.mode ?? "file"
|
|
1077
|
+
};
|
|
1078
|
+
if (input.type === "url") {
|
|
1079
|
+
requestBody.url = input.url;
|
|
1080
|
+
} else {
|
|
1081
|
+
requestBody.base64 = base64Content;
|
|
1082
|
+
requestBody.fileName = fileName;
|
|
1083
|
+
if (mimeType) {
|
|
1084
|
+
requestBody.mimeType = mimeType;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (options.metadata) {
|
|
1088
|
+
requestBody.metadata = options.metadata;
|
|
1089
|
+
}
|
|
1090
|
+
if (options.tags) {
|
|
1091
|
+
requestBody.tags = options.tags;
|
|
1092
|
+
}
|
|
1093
|
+
if (options.fileStandard) {
|
|
1094
|
+
requestBody.fileStandard = options.fileStandard;
|
|
1095
|
+
}
|
|
1096
|
+
if (options.chunkSize) {
|
|
1097
|
+
requestBody.chunkSize = options.chunkSize;
|
|
1098
|
+
}
|
|
1099
|
+
logger.debug("Getting inscription quote from Registry Broker");
|
|
1100
|
+
return fetchRegistryBroker(
|
|
1101
|
+
`${baseUrl}/inscribe/content/quote`,
|
|
1102
|
+
{
|
|
1103
|
+
method: "POST",
|
|
1104
|
+
headers,
|
|
1105
|
+
body: JSON.stringify(requestBody)
|
|
1106
|
+
}
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
87
1109
|
export {
|
|
88
|
-
|
|
1110
|
+
generateQuote,
|
|
1111
|
+
getRegistryBrokerQuote,
|
|
1112
|
+
inscribe,
|
|
1113
|
+
inscribeViaRegistryBroker,
|
|
1114
|
+
inscribeWithSigner,
|
|
1115
|
+
normalizeTransactionId,
|
|
1116
|
+
retrieveInscription,
|
|
1117
|
+
waitForInscriptionConfirmation
|
|
89
1118
|
};
|
|
90
1119
|
//# sourceMappingURL=standards-sdk.es142.js.map
|