@wuwei-labs/srsly 2.0.0-beta.14 → 2.0.0-beta.16

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.
Files changed (495) hide show
  1. package/README.md +117 -712
  2. package/dist/cjs/codama/accounts/config.js +88 -0
  3. package/dist/cjs/codama/accounts/config.js.map +1 -0
  4. package/dist/cjs/codama/accounts/contractState.js.map +1 -0
  5. package/dist/cjs/codama/accounts/fleet.js.map +1 -0
  6. package/dist/cjs/codama/{atlasnet/accounts → accounts}/index.js +1 -0
  7. package/dist/cjs/codama/accounts/index.js.map +1 -0
  8. package/dist/cjs/codama/accounts/rentalState.js.map +1 -0
  9. package/dist/cjs/codama/accounts/thread.js.map +1 -0
  10. package/dist/cjs/codama/errors/index.js.map +1 -0
  11. package/dist/cjs/codama/{mainnet/errors → errors}/srsly.js +15 -3
  12. package/dist/cjs/codama/errors/srsly.js.map +1 -0
  13. package/dist/cjs/codama/index.js.map +1 -0
  14. package/dist/cjs/codama/{atlasnet/instructions → instructions}/acceptRental.js +14 -9
  15. package/dist/cjs/codama/instructions/acceptRental.js.map +1 -0
  16. package/dist/cjs/codama/{mainnet/instructions → instructions}/cancelRental.js +10 -33
  17. package/dist/cjs/codama/instructions/cancelRental.js.map +1 -0
  18. package/dist/cjs/codama/{mainnet/instructions → instructions}/closeContract.js +10 -37
  19. package/dist/cjs/codama/instructions/closeContract.js.map +1 -0
  20. package/dist/cjs/codama/{mainnet/instructions → instructions}/closeRental.js +14 -41
  21. package/dist/cjs/codama/instructions/closeRental.js.map +1 -0
  22. package/dist/cjs/codama/{atlasnet/instructions → instructions}/createContract.js +14 -9
  23. package/dist/cjs/codama/instructions/createContract.js.map +1 -0
  24. package/dist/cjs/codama/{mainnet/instructions → instructions}/index.js +2 -0
  25. package/dist/cjs/codama/instructions/index.js.map +1 -0
  26. package/dist/cjs/codama/instructions/initializeConfig.js +131 -0
  27. package/dist/cjs/codama/instructions/initializeConfig.js.map +1 -0
  28. package/dist/cjs/codama/{mainnet/instructions → instructions}/payRental.js +10 -37
  29. package/dist/cjs/codama/instructions/payRental.js.map +1 -0
  30. package/dist/cjs/codama/instructions/resetRental.js.map +1 -0
  31. package/dist/cjs/codama/instructions/updateConfig.js +145 -0
  32. package/dist/cjs/codama/instructions/updateConfig.js.map +1 -0
  33. package/dist/cjs/codama/programs/index.js.map +1 -0
  34. package/dist/cjs/codama/{atlasnet/programs → programs}/srsly.js +18 -6
  35. package/dist/cjs/codama/programs/srsly.js.map +1 -0
  36. package/dist/cjs/codama/shared/index.js.map +1 -0
  37. package/dist/cjs/codama/types/clockData.js.map +1 -0
  38. package/dist/cjs/codama/types/equality.js.map +1 -0
  39. package/dist/cjs/codama/types/execContext.js.map +1 -0
  40. package/dist/cjs/codama/{atlasnet/types → types}/index.js +1 -0
  41. package/dist/cjs/codama/types/index.js.map +1 -0
  42. package/dist/cjs/codama/types/paymentFrequency.js +34 -0
  43. package/dist/cjs/codama/types/paymentFrequency.js.map +1 -0
  44. package/dist/cjs/codama/types/serializableAccount.js.map +1 -0
  45. package/dist/cjs/codama/types/serializableInstruction.js.map +1 -0
  46. package/dist/cjs/codama/types/threadResponse.js.map +1 -0
  47. package/dist/cjs/codama/types/trigger.js.map +1 -0
  48. package/dist/cjs/codama/types/triggerContext.js.map +1 -0
  49. package/dist/cjs/contract/close.js +3 -3
  50. package/dist/cjs/contract/close.js.map +1 -1
  51. package/dist/cjs/contract/create.js +4 -4
  52. package/dist/cjs/contract/create.js.map +1 -1
  53. package/dist/cjs/package.json +5 -9
  54. package/dist/cjs/rental/accept.js +3 -3
  55. package/dist/cjs/rental/accept.js.map +1 -1
  56. package/dist/cjs/rental/cancel.js +3 -3
  57. package/dist/cjs/rental/cancel.js.map +1 -1
  58. package/dist/cjs/rental/close.js +3 -3
  59. package/dist/cjs/rental/close.js.map +1 -1
  60. package/dist/cjs/rental/reset.js +3 -3
  61. package/dist/cjs/rental/reset.js.map +1 -1
  62. package/dist/cjs/utils/config.js +27 -49
  63. package/dist/cjs/utils/config.js.map +1 -1
  64. package/dist/cjs/utils/constants.js +1 -0
  65. package/dist/cjs/utils/constants.js.map +1 -1
  66. package/dist/esm/codama/accounts/config.js +76 -0
  67. package/dist/esm/codama/accounts/config.js.map +1 -0
  68. package/dist/esm/codama/accounts/contractState.js.map +1 -0
  69. package/dist/esm/codama/accounts/fleet.js.map +1 -0
  70. package/dist/esm/codama/{atlasnet/accounts → accounts}/index.js +1 -0
  71. package/dist/esm/codama/accounts/index.js.map +1 -0
  72. package/dist/esm/codama/accounts/rentalState.js.map +1 -0
  73. package/dist/esm/codama/accounts/thread.js.map +1 -0
  74. package/dist/esm/codama/errors/index.js.map +1 -0
  75. package/dist/esm/codama/{atlasnet/errors → errors}/srsly.js +14 -2
  76. package/dist/esm/codama/errors/srsly.js.map +1 -0
  77. package/dist/esm/codama/index.js.map +1 -0
  78. package/dist/esm/codama/{atlasnet/instructions → instructions}/acceptRental.js +14 -9
  79. package/dist/esm/codama/instructions/acceptRental.js.map +1 -0
  80. package/dist/esm/codama/{mainnet/instructions → instructions}/cancelRental.js +10 -33
  81. package/dist/esm/codama/instructions/cancelRental.js.map +1 -0
  82. package/dist/esm/codama/{mainnet/instructions → instructions}/closeContract.js +12 -39
  83. package/dist/esm/codama/instructions/closeContract.js.map +1 -0
  84. package/dist/esm/codama/{mainnet/instructions → instructions}/closeRental.js +14 -41
  85. package/dist/esm/codama/instructions/closeRental.js.map +1 -0
  86. package/dist/esm/codama/{mainnet/instructions → instructions}/createContract.js +14 -9
  87. package/dist/esm/codama/instructions/createContract.js.map +1 -0
  88. package/dist/esm/codama/{mainnet/instructions → instructions}/index.js +2 -0
  89. package/dist/esm/codama/instructions/index.js.map +1 -0
  90. package/dist/esm/codama/instructions/initializeConfig.js +121 -0
  91. package/dist/esm/codama/instructions/initializeConfig.js.map +1 -0
  92. package/dist/esm/codama/{mainnet/instructions → instructions}/payRental.js +12 -39
  93. package/dist/esm/codama/instructions/payRental.js.map +1 -0
  94. package/dist/esm/codama/instructions/resetRental.js.map +1 -0
  95. package/dist/esm/codama/instructions/updateConfig.js +135 -0
  96. package/dist/esm/codama/instructions/updateConfig.js.map +1 -0
  97. package/dist/esm/codama/programs/index.js.map +1 -0
  98. package/dist/esm/codama/{atlasnet/programs → programs}/srsly.js +18 -6
  99. package/dist/esm/codama/programs/srsly.js.map +1 -0
  100. package/dist/esm/codama/shared/index.js.map +1 -0
  101. package/dist/esm/codama/types/clockData.js.map +1 -0
  102. package/dist/esm/codama/types/equality.js.map +1 -0
  103. package/dist/esm/codama/types/execContext.js.map +1 -0
  104. package/dist/esm/codama/{atlasnet/types → types}/index.js +1 -0
  105. package/dist/esm/codama/types/index.js.map +1 -0
  106. package/dist/esm/codama/types/paymentFrequency.js +28 -0
  107. package/dist/esm/codama/types/paymentFrequency.js.map +1 -0
  108. package/dist/esm/codama/types/serializableAccount.js.map +1 -0
  109. package/dist/esm/codama/types/serializableInstruction.js.map +1 -0
  110. package/dist/esm/codama/types/threadResponse.js.map +1 -0
  111. package/dist/esm/codama/types/trigger.js.map +1 -0
  112. package/dist/esm/codama/types/triggerContext.js.map +1 -0
  113. package/dist/esm/contract/close.js +4 -4
  114. package/dist/esm/contract/close.js.map +1 -1
  115. package/dist/esm/contract/create.js +5 -5
  116. package/dist/esm/contract/create.js.map +1 -1
  117. package/dist/esm/package.json +5 -9
  118. package/dist/esm/rental/accept.js +4 -4
  119. package/dist/esm/rental/accept.js.map +1 -1
  120. package/dist/esm/rental/cancel.js +4 -4
  121. package/dist/esm/rental/cancel.js.map +1 -1
  122. package/dist/esm/rental/close.js +4 -4
  123. package/dist/esm/rental/close.js.map +1 -1
  124. package/dist/esm/rental/reset.js +4 -4
  125. package/dist/esm/rental/reset.js.map +1 -1
  126. package/dist/esm/utils/config.js +26 -48
  127. package/dist/esm/utils/config.js.map +1 -1
  128. package/dist/esm/utils/constants.js +1 -0
  129. package/dist/esm/utils/constants.js.map +1 -1
  130. package/dist/types/codama/accounts/config.d.ts +52 -0
  131. package/dist/types/codama/accounts/config.d.ts.map +1 -0
  132. package/dist/types/codama/accounts/contractState.d.ts.map +1 -0
  133. package/dist/types/codama/accounts/fleet.d.ts.map +1 -0
  134. package/dist/types/codama/{atlasnet/accounts → accounts}/index.d.ts +1 -0
  135. package/dist/types/codama/accounts/index.d.ts.map +1 -0
  136. package/dist/types/codama/accounts/rentalState.d.ts.map +1 -0
  137. package/dist/types/codama/accounts/thread.d.ts.map +1 -0
  138. package/dist/types/codama/errors/index.d.ts.map +1 -0
  139. package/dist/types/codama/{atlasnet/errors → errors}/srsly.d.ts +10 -2
  140. package/dist/types/codama/errors/srsly.d.ts.map +1 -0
  141. package/dist/types/codama/index.d.ts.map +1 -0
  142. package/dist/types/codama/{atlasnet/instructions → instructions}/acceptRental.d.ts +18 -14
  143. package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -0
  144. package/dist/types/codama/{mainnet/instructions → instructions}/cancelRental.d.ts +14 -10
  145. package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -0
  146. package/dist/types/codama/{atlasnet/instructions → instructions}/closeContract.d.ts +14 -10
  147. package/dist/types/codama/instructions/closeContract.d.ts.map +1 -0
  148. package/dist/types/codama/{mainnet/instructions → instructions}/closeRental.d.ts +16 -12
  149. package/dist/types/codama/instructions/closeRental.d.ts.map +1 -0
  150. package/dist/types/codama/{atlasnet/instructions → instructions}/createContract.d.ts +17 -13
  151. package/dist/types/codama/instructions/createContract.d.ts.map +1 -0
  152. package/dist/types/codama/{atlasnet/instructions → instructions}/index.d.ts +2 -0
  153. package/dist/types/codama/instructions/index.d.ts.map +1 -0
  154. package/dist/types/codama/instructions/initializeConfig.d.ts +60 -0
  155. package/dist/types/codama/instructions/initializeConfig.d.ts.map +1 -0
  156. package/dist/types/codama/{atlasnet/instructions → instructions}/payRental.d.ts +16 -12
  157. package/dist/types/codama/instructions/payRental.d.ts.map +1 -0
  158. package/dist/types/codama/instructions/resetRental.d.ts.map +1 -0
  159. package/dist/types/codama/instructions/updateConfig.d.ts +93 -0
  160. package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -0
  161. package/dist/types/codama/programs/index.d.ts.map +1 -0
  162. package/dist/types/codama/{mainnet/programs → programs}/srsly.d.ts +15 -8
  163. package/dist/types/codama/programs/srsly.d.ts.map +1 -0
  164. package/dist/types/codama/shared/index.d.ts.map +1 -0
  165. package/dist/types/codama/types/clockData.d.ts.map +1 -0
  166. package/dist/types/codama/types/equality.d.ts.map +1 -0
  167. package/dist/types/codama/types/execContext.d.ts.map +1 -0
  168. package/dist/types/codama/{atlasnet/types → types}/index.d.ts +1 -0
  169. package/dist/types/codama/types/index.d.ts.map +1 -0
  170. package/dist/types/codama/types/paymentFrequency.d.ts +22 -0
  171. package/dist/types/codama/types/paymentFrequency.d.ts.map +1 -0
  172. package/dist/types/codama/types/serializableAccount.d.ts.map +1 -0
  173. package/dist/types/codama/types/serializableInstruction.d.ts.map +1 -0
  174. package/dist/types/codama/types/threadResponse.d.ts.map +1 -0
  175. package/dist/types/codama/types/trigger.d.ts.map +1 -0
  176. package/dist/types/codama/types/triggerContext.d.ts.map +1 -0
  177. package/dist/types/contract/close.d.ts.map +1 -1
  178. package/dist/types/contract/create.d.ts.map +1 -1
  179. package/dist/types/index.d.ts +1 -1
  180. package/dist/types/index.d.ts.map +1 -1
  181. package/dist/types/rental/accept.d.ts.map +1 -1
  182. package/dist/types/rental/cancel.d.ts.map +1 -1
  183. package/dist/types/rental/close.d.ts.map +1 -1
  184. package/dist/types/rental/reset.d.ts.map +1 -1
  185. package/dist/types/utils/config.d.ts +16 -31
  186. package/dist/types/utils/config.d.ts.map +1 -1
  187. package/dist/types/utils/constants.d.ts.map +1 -1
  188. package/package.json +19 -13
  189. package/target/idl/{srsly-mainnet.json → srsly.json} +479 -428
  190. package/dist/cjs/codama/atlasnet/accounts/contractState.js.map +0 -1
  191. package/dist/cjs/codama/atlasnet/accounts/fleet.js.map +0 -1
  192. package/dist/cjs/codama/atlasnet/accounts/index.js.map +0 -1
  193. package/dist/cjs/codama/atlasnet/accounts/rentalState.js.map +0 -1
  194. package/dist/cjs/codama/atlasnet/accounts/thread.js.map +0 -1
  195. package/dist/cjs/codama/atlasnet/errors/index.js.map +0 -1
  196. package/dist/cjs/codama/atlasnet/errors/srsly.js +0 -74
  197. package/dist/cjs/codama/atlasnet/errors/srsly.js.map +0 -1
  198. package/dist/cjs/codama/atlasnet/index.js.map +0 -1
  199. package/dist/cjs/codama/atlasnet/instructions/acceptRental.js.map +0 -1
  200. package/dist/cjs/codama/atlasnet/instructions/cancelRental.js +0 -225
  201. package/dist/cjs/codama/atlasnet/instructions/cancelRental.js.map +0 -1
  202. package/dist/cjs/codama/atlasnet/instructions/closeContract.js +0 -238
  203. package/dist/cjs/codama/atlasnet/instructions/closeContract.js.map +0 -1
  204. package/dist/cjs/codama/atlasnet/instructions/closeRental.js +0 -260
  205. package/dist/cjs/codama/atlasnet/instructions/closeRental.js.map +0 -1
  206. package/dist/cjs/codama/atlasnet/instructions/createContract.js.map +0 -1
  207. package/dist/cjs/codama/atlasnet/instructions/index.js +0 -31
  208. package/dist/cjs/codama/atlasnet/instructions/index.js.map +0 -1
  209. package/dist/cjs/codama/atlasnet/instructions/payRental.js +0 -272
  210. package/dist/cjs/codama/atlasnet/instructions/payRental.js.map +0 -1
  211. package/dist/cjs/codama/atlasnet/instructions/resetRental.js.map +0 -1
  212. package/dist/cjs/codama/atlasnet/programs/index.js.map +0 -1
  213. package/dist/cjs/codama/atlasnet/programs/srsly.js.map +0 -1
  214. package/dist/cjs/codama/atlasnet/shared/index.js.map +0 -1
  215. package/dist/cjs/codama/atlasnet/types/clockData.js.map +0 -1
  216. package/dist/cjs/codama/atlasnet/types/equality.js.map +0 -1
  217. package/dist/cjs/codama/atlasnet/types/execContext.js.map +0 -1
  218. package/dist/cjs/codama/atlasnet/types/index.js.map +0 -1
  219. package/dist/cjs/codama/atlasnet/types/serializableAccount.js.map +0 -1
  220. package/dist/cjs/codama/atlasnet/types/serializableInstruction.js.map +0 -1
  221. package/dist/cjs/codama/atlasnet/types/threadResponse.js.map +0 -1
  222. package/dist/cjs/codama/atlasnet/types/trigger.js.map +0 -1
  223. package/dist/cjs/codama/atlasnet/types/triggerContext.js.map +0 -1
  224. package/dist/cjs/codama/mainnet/accounts/contractState.js +0 -87
  225. package/dist/cjs/codama/mainnet/accounts/contractState.js.map +0 -1
  226. package/dist/cjs/codama/mainnet/accounts/fleet.js +0 -77
  227. package/dist/cjs/codama/mainnet/accounts/fleet.js.map +0 -1
  228. package/dist/cjs/codama/mainnet/accounts/index.js +0 -28
  229. package/dist/cjs/codama/mainnet/accounts/index.js.map +0 -1
  230. package/dist/cjs/codama/mainnet/accounts/rentalState.js +0 -87
  231. package/dist/cjs/codama/mainnet/accounts/rentalState.js.map +0 -1
  232. package/dist/cjs/codama/mainnet/accounts/thread.js +0 -89
  233. package/dist/cjs/codama/mainnet/accounts/thread.js.map +0 -1
  234. package/dist/cjs/codama/mainnet/errors/index.js +0 -25
  235. package/dist/cjs/codama/mainnet/errors/index.js.map +0 -1
  236. package/dist/cjs/codama/mainnet/errors/srsly.js.map +0 -1
  237. package/dist/cjs/codama/mainnet/index.js +0 -29
  238. package/dist/cjs/codama/mainnet/index.js.map +0 -1
  239. package/dist/cjs/codama/mainnet/instructions/acceptRental.js +0 -349
  240. package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +0 -1
  241. package/dist/cjs/codama/mainnet/instructions/cancelRental.js.map +0 -1
  242. package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +0 -1
  243. package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +0 -1
  244. package/dist/cjs/codama/mainnet/instructions/createContract.js +0 -253
  245. package/dist/cjs/codama/mainnet/instructions/createContract.js.map +0 -1
  246. package/dist/cjs/codama/mainnet/instructions/index.js.map +0 -1
  247. package/dist/cjs/codama/mainnet/instructions/payRental.js.map +0 -1
  248. package/dist/cjs/codama/mainnet/instructions/resetRental.js +0 -146
  249. package/dist/cjs/codama/mainnet/instructions/resetRental.js.map +0 -1
  250. package/dist/cjs/codama/mainnet/programs/index.js +0 -25
  251. package/dist/cjs/codama/mainnet/programs/index.js.map +0 -1
  252. package/dist/cjs/codama/mainnet/programs/srsly.js +0 -73
  253. package/dist/cjs/codama/mainnet/programs/srsly.js.map +0 -1
  254. package/dist/cjs/codama/mainnet/shared/index.js +0 -95
  255. package/dist/cjs/codama/mainnet/shared/index.js.map +0 -1
  256. package/dist/cjs/codama/mainnet/types/clockData.js +0 -31
  257. package/dist/cjs/codama/mainnet/types/clockData.js.map +0 -1
  258. package/dist/cjs/codama/mainnet/types/equality.js +0 -30
  259. package/dist/cjs/codama/mainnet/types/equality.js.map +0 -1
  260. package/dist/cjs/codama/mainnet/types/execContext.js +0 -38
  261. package/dist/cjs/codama/mainnet/types/execContext.js.map +0 -1
  262. package/dist/cjs/codama/mainnet/types/index.js +0 -32
  263. package/dist/cjs/codama/mainnet/types/index.js.map +0 -1
  264. package/dist/cjs/codama/mainnet/types/serializableAccount.js +0 -31
  265. package/dist/cjs/codama/mainnet/types/serializableAccount.js.map +0 -1
  266. package/dist/cjs/codama/mainnet/types/serializableInstruction.js +0 -32
  267. package/dist/cjs/codama/mainnet/types/serializableInstruction.js.map +0 -1
  268. package/dist/cjs/codama/mainnet/types/threadResponse.js +0 -38
  269. package/dist/cjs/codama/mainnet/types/threadResponse.js.map +0 -1
  270. package/dist/cjs/codama/mainnet/types/trigger.js +0 -90
  271. package/dist/cjs/codama/mainnet/types/trigger.js.map +0 -1
  272. package/dist/cjs/codama/mainnet/types/triggerContext.js +0 -49
  273. package/dist/cjs/codama/mainnet/types/triggerContext.js.map +0 -1
  274. package/dist/esm/codama/atlasnet/accounts/contractState.js.map +0 -1
  275. package/dist/esm/codama/atlasnet/accounts/fleet.js.map +0 -1
  276. package/dist/esm/codama/atlasnet/accounts/index.js.map +0 -1
  277. package/dist/esm/codama/atlasnet/accounts/rentalState.js.map +0 -1
  278. package/dist/esm/codama/atlasnet/accounts/thread.js.map +0 -1
  279. package/dist/esm/codama/atlasnet/errors/index.js.map +0 -1
  280. package/dist/esm/codama/atlasnet/errors/srsly.js.map +0 -1
  281. package/dist/esm/codama/atlasnet/index.js.map +0 -1
  282. package/dist/esm/codama/atlasnet/instructions/acceptRental.js.map +0 -1
  283. package/dist/esm/codama/atlasnet/instructions/cancelRental.js +0 -215
  284. package/dist/esm/codama/atlasnet/instructions/cancelRental.js.map +0 -1
  285. package/dist/esm/codama/atlasnet/instructions/closeContract.js +0 -228
  286. package/dist/esm/codama/atlasnet/instructions/closeContract.js.map +0 -1
  287. package/dist/esm/codama/atlasnet/instructions/closeRental.js +0 -250
  288. package/dist/esm/codama/atlasnet/instructions/closeRental.js.map +0 -1
  289. package/dist/esm/codama/atlasnet/instructions/createContract.js +0 -243
  290. package/dist/esm/codama/atlasnet/instructions/createContract.js.map +0 -1
  291. package/dist/esm/codama/atlasnet/instructions/index.js +0 -15
  292. package/dist/esm/codama/atlasnet/instructions/index.js.map +0 -1
  293. package/dist/esm/codama/atlasnet/instructions/payRental.js +0 -262
  294. package/dist/esm/codama/atlasnet/instructions/payRental.js.map +0 -1
  295. package/dist/esm/codama/atlasnet/instructions/resetRental.js.map +0 -1
  296. package/dist/esm/codama/atlasnet/programs/index.js.map +0 -1
  297. package/dist/esm/codama/atlasnet/programs/srsly.js.map +0 -1
  298. package/dist/esm/codama/atlasnet/shared/index.js.map +0 -1
  299. package/dist/esm/codama/atlasnet/types/clockData.js.map +0 -1
  300. package/dist/esm/codama/atlasnet/types/equality.js.map +0 -1
  301. package/dist/esm/codama/atlasnet/types/execContext.js.map +0 -1
  302. package/dist/esm/codama/atlasnet/types/index.js.map +0 -1
  303. package/dist/esm/codama/atlasnet/types/serializableAccount.js.map +0 -1
  304. package/dist/esm/codama/atlasnet/types/serializableInstruction.js.map +0 -1
  305. package/dist/esm/codama/atlasnet/types/threadResponse.js.map +0 -1
  306. package/dist/esm/codama/atlasnet/types/trigger.js.map +0 -1
  307. package/dist/esm/codama/atlasnet/types/triggerContext.js.map +0 -1
  308. package/dist/esm/codama/mainnet/accounts/contractState.js +0 -75
  309. package/dist/esm/codama/mainnet/accounts/contractState.js.map +0 -1
  310. package/dist/esm/codama/mainnet/accounts/fleet.js +0 -64
  311. package/dist/esm/codama/mainnet/accounts/fleet.js.map +0 -1
  312. package/dist/esm/codama/mainnet/accounts/index.js +0 -12
  313. package/dist/esm/codama/mainnet/accounts/index.js.map +0 -1
  314. package/dist/esm/codama/mainnet/accounts/rentalState.js +0 -74
  315. package/dist/esm/codama/mainnet/accounts/rentalState.js.map +0 -1
  316. package/dist/esm/codama/mainnet/accounts/thread.js +0 -77
  317. package/dist/esm/codama/mainnet/accounts/thread.js.map +0 -1
  318. package/dist/esm/codama/mainnet/errors/index.js +0 -9
  319. package/dist/esm/codama/mainnet/errors/index.js.map +0 -1
  320. package/dist/esm/codama/mainnet/errors/srsly.js +0 -69
  321. package/dist/esm/codama/mainnet/errors/srsly.js.map +0 -1
  322. package/dist/esm/codama/mainnet/index.js +0 -13
  323. package/dist/esm/codama/mainnet/index.js.map +0 -1
  324. package/dist/esm/codama/mainnet/instructions/acceptRental.js +0 -339
  325. package/dist/esm/codama/mainnet/instructions/acceptRental.js.map +0 -1
  326. package/dist/esm/codama/mainnet/instructions/cancelRental.js.map +0 -1
  327. package/dist/esm/codama/mainnet/instructions/closeContract.js.map +0 -1
  328. package/dist/esm/codama/mainnet/instructions/closeRental.js.map +0 -1
  329. package/dist/esm/codama/mainnet/instructions/createContract.js.map +0 -1
  330. package/dist/esm/codama/mainnet/instructions/index.js.map +0 -1
  331. package/dist/esm/codama/mainnet/instructions/payRental.js.map +0 -1
  332. package/dist/esm/codama/mainnet/instructions/resetRental.js +0 -136
  333. package/dist/esm/codama/mainnet/instructions/resetRental.js.map +0 -1
  334. package/dist/esm/codama/mainnet/programs/index.js +0 -9
  335. package/dist/esm/codama/mainnet/programs/index.js.map +0 -1
  336. package/dist/esm/codama/mainnet/programs/srsly.js +0 -68
  337. package/dist/esm/codama/mainnet/programs/srsly.js.map +0 -1
  338. package/dist/esm/codama/mainnet/shared/index.js +0 -87
  339. package/dist/esm/codama/mainnet/shared/index.js.map +0 -1
  340. package/dist/esm/codama/mainnet/types/clockData.js +0 -26
  341. package/dist/esm/codama/mainnet/types/clockData.js.map +0 -1
  342. package/dist/esm/codama/mainnet/types/equality.js +0 -24
  343. package/dist/esm/codama/mainnet/types/equality.js.map +0 -1
  344. package/dist/esm/codama/mainnet/types/execContext.js +0 -33
  345. package/dist/esm/codama/mainnet/types/execContext.js.map +0 -1
  346. package/dist/esm/codama/mainnet/types/index.js +0 -16
  347. package/dist/esm/codama/mainnet/types/index.js.map +0 -1
  348. package/dist/esm/codama/mainnet/types/serializableAccount.js +0 -26
  349. package/dist/esm/codama/mainnet/types/serializableAccount.js.map +0 -1
  350. package/dist/esm/codama/mainnet/types/serializableInstruction.js +0 -27
  351. package/dist/esm/codama/mainnet/types/serializableInstruction.js.map +0 -1
  352. package/dist/esm/codama/mainnet/types/threadResponse.js +0 -33
  353. package/dist/esm/codama/mainnet/types/threadResponse.js.map +0 -1
  354. package/dist/esm/codama/mainnet/types/trigger.js +0 -83
  355. package/dist/esm/codama/mainnet/types/trigger.js.map +0 -1
  356. package/dist/esm/codama/mainnet/types/triggerContext.js +0 -42
  357. package/dist/esm/codama/mainnet/types/triggerContext.js.map +0 -1
  358. package/dist/types/codama/atlasnet/accounts/contractState.d.ts.map +0 -1
  359. package/dist/types/codama/atlasnet/accounts/fleet.d.ts.map +0 -1
  360. package/dist/types/codama/atlasnet/accounts/index.d.ts.map +0 -1
  361. package/dist/types/codama/atlasnet/accounts/rentalState.d.ts.map +0 -1
  362. package/dist/types/codama/atlasnet/accounts/thread.d.ts.map +0 -1
  363. package/dist/types/codama/atlasnet/errors/index.d.ts.map +0 -1
  364. package/dist/types/codama/atlasnet/errors/srsly.d.ts.map +0 -1
  365. package/dist/types/codama/atlasnet/index.d.ts.map +0 -1
  366. package/dist/types/codama/atlasnet/instructions/acceptRental.d.ts.map +0 -1
  367. package/dist/types/codama/atlasnet/instructions/cancelRental.d.ts +0 -71
  368. package/dist/types/codama/atlasnet/instructions/cancelRental.d.ts.map +0 -1
  369. package/dist/types/codama/atlasnet/instructions/closeContract.d.ts.map +0 -1
  370. package/dist/types/codama/atlasnet/instructions/closeRental.d.ts +0 -83
  371. package/dist/types/codama/atlasnet/instructions/closeRental.d.ts.map +0 -1
  372. package/dist/types/codama/atlasnet/instructions/createContract.d.ts.map +0 -1
  373. package/dist/types/codama/atlasnet/instructions/index.d.ts.map +0 -1
  374. package/dist/types/codama/atlasnet/instructions/payRental.d.ts.map +0 -1
  375. package/dist/types/codama/atlasnet/instructions/resetRental.d.ts.map +0 -1
  376. package/dist/types/codama/atlasnet/programs/index.d.ts.map +0 -1
  377. package/dist/types/codama/atlasnet/programs/srsly.d.ts +0 -47
  378. package/dist/types/codama/atlasnet/programs/srsly.d.ts.map +0 -1
  379. package/dist/types/codama/atlasnet/shared/index.d.ts.map +0 -1
  380. package/dist/types/codama/atlasnet/types/clockData.d.ts.map +0 -1
  381. package/dist/types/codama/atlasnet/types/equality.d.ts.map +0 -1
  382. package/dist/types/codama/atlasnet/types/execContext.d.ts.map +0 -1
  383. package/dist/types/codama/atlasnet/types/index.d.ts.map +0 -1
  384. package/dist/types/codama/atlasnet/types/serializableAccount.d.ts.map +0 -1
  385. package/dist/types/codama/atlasnet/types/serializableInstruction.d.ts.map +0 -1
  386. package/dist/types/codama/atlasnet/types/threadResponse.d.ts.map +0 -1
  387. package/dist/types/codama/atlasnet/types/trigger.d.ts.map +0 -1
  388. package/dist/types/codama/atlasnet/types/triggerContext.d.ts.map +0 -1
  389. package/dist/types/codama/mainnet/accounts/contractState.d.ts +0 -51
  390. package/dist/types/codama/mainnet/accounts/contractState.d.ts.map +0 -1
  391. package/dist/types/codama/mainnet/accounts/fleet.d.ts +0 -38
  392. package/dist/types/codama/mainnet/accounts/fleet.d.ts.map +0 -1
  393. package/dist/types/codama/mainnet/accounts/index.d.ts +0 -12
  394. package/dist/types/codama/mainnet/accounts/index.d.ts.map +0 -1
  395. package/dist/types/codama/mainnet/accounts/rentalState.d.ts +0 -48
  396. package/dist/types/codama/mainnet/accounts/rentalState.d.ts.map +0 -1
  397. package/dist/types/codama/mainnet/accounts/thread.d.ts +0 -74
  398. package/dist/types/codama/mainnet/accounts/thread.d.ts.map +0 -1
  399. package/dist/types/codama/mainnet/errors/index.d.ts +0 -9
  400. package/dist/types/codama/mainnet/errors/index.d.ts.map +0 -1
  401. package/dist/types/codama/mainnet/errors/srsly.d.ts +0 -50
  402. package/dist/types/codama/mainnet/errors/srsly.d.ts.map +0 -1
  403. package/dist/types/codama/mainnet/index.d.ts +0 -13
  404. package/dist/types/codama/mainnet/index.d.ts.map +0 -1
  405. package/dist/types/codama/mainnet/instructions/acceptRental.d.ts +0 -131
  406. package/dist/types/codama/mainnet/instructions/acceptRental.d.ts.map +0 -1
  407. package/dist/types/codama/mainnet/instructions/cancelRental.d.ts.map +0 -1
  408. package/dist/types/codama/mainnet/instructions/closeContract.d.ts +0 -100
  409. package/dist/types/codama/mainnet/instructions/closeContract.d.ts.map +0 -1
  410. package/dist/types/codama/mainnet/instructions/closeRental.d.ts.map +0 -1
  411. package/dist/types/codama/mainnet/instructions/createContract.d.ts +0 -108
  412. package/dist/types/codama/mainnet/instructions/createContract.d.ts.map +0 -1
  413. package/dist/types/codama/mainnet/instructions/index.d.ts +0 -15
  414. package/dist/types/codama/mainnet/instructions/index.d.ts.map +0 -1
  415. package/dist/types/codama/mainnet/instructions/payRental.d.ts +0 -110
  416. package/dist/types/codama/mainnet/instructions/payRental.d.ts.map +0 -1
  417. package/dist/types/codama/mainnet/instructions/resetRental.d.ts +0 -71
  418. package/dist/types/codama/mainnet/instructions/resetRental.d.ts.map +0 -1
  419. package/dist/types/codama/mainnet/programs/index.d.ts +0 -9
  420. package/dist/types/codama/mainnet/programs/index.d.ts.map +0 -1
  421. package/dist/types/codama/mainnet/programs/srsly.d.ts.map +0 -1
  422. package/dist/types/codama/mainnet/shared/index.d.ts +0 -50
  423. package/dist/types/codama/mainnet/shared/index.d.ts.map +0 -1
  424. package/dist/types/codama/mainnet/types/clockData.d.ts +0 -29
  425. package/dist/types/codama/mainnet/types/clockData.d.ts.map +0 -1
  426. package/dist/types/codama/mainnet/types/equality.d.ts +0 -18
  427. package/dist/types/codama/mainnet/types/equality.d.ts.map +0 -1
  428. package/dist/types/codama/mainnet/types/execContext.d.ts +0 -48
  429. package/dist/types/codama/mainnet/types/execContext.d.ts.map +0 -1
  430. package/dist/types/codama/mainnet/types/index.d.ts +0 -16
  431. package/dist/types/codama/mainnet/types/index.d.ts.map +0 -1
  432. package/dist/types/codama/mainnet/types/serializableAccount.d.ts +0 -22
  433. package/dist/types/codama/mainnet/types/serializableAccount.d.ts.map +0 -1
  434. package/dist/types/codama/mainnet/types/serializableInstruction.d.ts +0 -30
  435. package/dist/types/codama/mainnet/types/serializableInstruction.d.ts.map +0 -1
  436. package/dist/types/codama/mainnet/types/threadResponse.d.ts +0 -42
  437. package/dist/types/codama/mainnet/types/threadResponse.d.ts.map +0 -1
  438. package/dist/types/codama/mainnet/types/trigger.d.ts +0 -98
  439. package/dist/types/codama/mainnet/types/trigger.d.ts.map +0 -1
  440. package/dist/types/codama/mainnet/types/triggerContext.d.ts +0 -75
  441. package/dist/types/codama/mainnet/types/triggerContext.d.ts.map +0 -1
  442. package/target/idl/srsly-atlasnet.json +0 -3270
  443. package/target/types/srsly-mainnet.ts +0 -1
  444. /package/dist/cjs/codama/{atlasnet/accounts → accounts}/contractState.js +0 -0
  445. /package/dist/cjs/codama/{atlasnet/accounts → accounts}/fleet.js +0 -0
  446. /package/dist/cjs/codama/{atlasnet/accounts → accounts}/rentalState.js +0 -0
  447. /package/dist/cjs/codama/{atlasnet/accounts → accounts}/thread.js +0 -0
  448. /package/dist/cjs/codama/{atlasnet/errors → errors}/index.js +0 -0
  449. /package/dist/cjs/codama/{atlasnet/index.js → index.js} +0 -0
  450. /package/dist/cjs/codama/{atlasnet/instructions → instructions}/resetRental.js +0 -0
  451. /package/dist/cjs/codama/{atlasnet/programs → programs}/index.js +0 -0
  452. /package/dist/cjs/codama/{atlasnet/shared → shared}/index.js +0 -0
  453. /package/dist/cjs/codama/{atlasnet/types → types}/clockData.js +0 -0
  454. /package/dist/cjs/codama/{atlasnet/types → types}/equality.js +0 -0
  455. /package/dist/cjs/codama/{atlasnet/types → types}/execContext.js +0 -0
  456. /package/dist/cjs/codama/{atlasnet/types → types}/serializableAccount.js +0 -0
  457. /package/dist/cjs/codama/{atlasnet/types → types}/serializableInstruction.js +0 -0
  458. /package/dist/cjs/codama/{atlasnet/types → types}/threadResponse.js +0 -0
  459. /package/dist/cjs/codama/{atlasnet/types → types}/trigger.js +0 -0
  460. /package/dist/cjs/codama/{atlasnet/types → types}/triggerContext.js +0 -0
  461. /package/dist/esm/codama/{atlasnet/accounts → accounts}/contractState.js +0 -0
  462. /package/dist/esm/codama/{atlasnet/accounts → accounts}/fleet.js +0 -0
  463. /package/dist/esm/codama/{atlasnet/accounts → accounts}/rentalState.js +0 -0
  464. /package/dist/esm/codama/{atlasnet/accounts → accounts}/thread.js +0 -0
  465. /package/dist/esm/codama/{atlasnet/errors → errors}/index.js +0 -0
  466. /package/dist/esm/codama/{atlasnet/index.js → index.js} +0 -0
  467. /package/dist/esm/codama/{atlasnet/instructions → instructions}/resetRental.js +0 -0
  468. /package/dist/esm/codama/{atlasnet/programs → programs}/index.js +0 -0
  469. /package/dist/esm/codama/{atlasnet/shared → shared}/index.js +0 -0
  470. /package/dist/esm/codama/{atlasnet/types → types}/clockData.js +0 -0
  471. /package/dist/esm/codama/{atlasnet/types → types}/equality.js +0 -0
  472. /package/dist/esm/codama/{atlasnet/types → types}/execContext.js +0 -0
  473. /package/dist/esm/codama/{atlasnet/types → types}/serializableAccount.js +0 -0
  474. /package/dist/esm/codama/{atlasnet/types → types}/serializableInstruction.js +0 -0
  475. /package/dist/esm/codama/{atlasnet/types → types}/threadResponse.js +0 -0
  476. /package/dist/esm/codama/{atlasnet/types → types}/trigger.js +0 -0
  477. /package/dist/esm/codama/{atlasnet/types → types}/triggerContext.js +0 -0
  478. /package/dist/types/codama/{atlasnet/accounts → accounts}/contractState.d.ts +0 -0
  479. /package/dist/types/codama/{atlasnet/accounts → accounts}/fleet.d.ts +0 -0
  480. /package/dist/types/codama/{atlasnet/accounts → accounts}/rentalState.d.ts +0 -0
  481. /package/dist/types/codama/{atlasnet/accounts → accounts}/thread.d.ts +0 -0
  482. /package/dist/types/codama/{atlasnet/errors → errors}/index.d.ts +0 -0
  483. /package/dist/types/codama/{atlasnet/index.d.ts → index.d.ts} +0 -0
  484. /package/dist/types/codama/{atlasnet/instructions → instructions}/resetRental.d.ts +0 -0
  485. /package/dist/types/codama/{atlasnet/programs → programs}/index.d.ts +0 -0
  486. /package/dist/types/codama/{atlasnet/shared → shared}/index.d.ts +0 -0
  487. /package/dist/types/codama/{atlasnet/types → types}/clockData.d.ts +0 -0
  488. /package/dist/types/codama/{atlasnet/types → types}/equality.d.ts +0 -0
  489. /package/dist/types/codama/{atlasnet/types → types}/execContext.d.ts +0 -0
  490. /package/dist/types/codama/{atlasnet/types → types}/serializableAccount.d.ts +0 -0
  491. /package/dist/types/codama/{atlasnet/types → types}/serializableInstruction.d.ts +0 -0
  492. /package/dist/types/codama/{atlasnet/types → types}/threadResponse.d.ts +0 -0
  493. /package/dist/types/codama/{atlasnet/types → types}/trigger.d.ts +0 -0
  494. /package/dist/types/codama/{atlasnet/types → types}/triggerContext.d.ts +0 -0
  495. /package/target/types/{srsly-atlasnet.ts → srsly.ts} +0 -0
package/README.md CHANGED
@@ -8,842 +8,247 @@ A TypeScript SDK for building Solana instructions to interact with the SRSLY (Sp
8
8
 
9
9
  ## What This SDK Does
10
10
 
11
- The SRSLY SDK is an **instruction builder** that helps you create properly formatted Solana instructions for the SRSLY rental program. It handles:
11
+ The SRSLY SDK is an **instruction builder** that helps you create properly formatted Solana instructions for fleet rentals. It handles:
12
12
 
13
- - ✅ Network-specific program addresses and configurations
14
- - ✅ Account derivation and validation
13
+ - ✅ Account derivation and validation
15
14
  - ✅ Instruction data encoding
16
15
  - ✅ Type-safe parameter handling
17
16
 
18
- ## What You Need to Provide
19
-
20
- The SDK **does not** handle transaction creation, signing, or submission. You'll need to:
21
-
22
- - 🔧 Choose a transaction library (`@solana/web3.js` or `@solana/kit`)
23
- - 🔧 Connect to a Solana RPC endpoint
24
- - 🔧 Handle wallet integration (Phantom, Solflare, etc.)
25
- - 🔧 Build, sign, and send transactions
17
+ **What you provide**: RPC connection, wallet integration, transaction handling.
26
18
 
27
19
  ## Installation
28
20
 
29
- ### NPM
30
-
31
21
  ```bash
32
22
  npm install @wuwei-labs/srsly
33
- ```
34
-
35
- ### PNPM
36
-
37
- ```bash
23
+ # or
38
24
  pnpm add @wuwei-labs/srsly
39
- ```
40
-
41
- ### Yarn
42
-
43
- ```bash
25
+ # or
44
26
  yarn add @wuwei-labs/srsly
45
27
  ```
46
28
 
47
29
  ## Quick Start
48
30
 
49
31
  ```typescript
50
- import {
51
- createContract,
52
- setConfig
53
- } from '@wuwei-labs/srsly';
54
-
55
- import {
56
- createDefaultSolanaRpc,
57
- createTransaction,
58
- appendInstructions,
59
- signAndSendTransaction,
60
- pipe
61
- } from '@solana/kit';
62
-
63
- // Step 1: Set up RPC connection
64
- const rpc = createDefaultSolanaRpc('https://api.atlasnet.solana.com');
65
-
66
- // Step 2: Get wallet from browser extension (Phantom, Solflare, etc.)
67
- // Assumes you've already connected to the user's wallet
68
- const wallet = window.solana; // or your wallet adapter
32
+ import { createContract, setConfig } from '@wuwei-labs/srsly';
33
+ import { Connection, Transaction } from '@solana/web3.js';
69
34
 
70
- // Step 3: Configure SDK to use atlasnet program addresses
71
- setConfig({ network: 'atlasnet' });
35
+ // 1. Configure SDK for your network
36
+ setConfig({ programs: 'atlasnet' });
72
37
 
73
- // Step 4: Build the instruction using SRSLY SDK
74
- const contractInstruction = await createContract({
75
- owner: wallet.publicKey, // Wallet's public key
38
+ // 2. Build instruction
39
+ const instruction = await createContract({
40
+ owner: walletPublicKey,
76
41
  fleet: fleetAddress,
77
42
  ownerProfile: profileAddress,
78
- rate: 1000000, // Rate in ATLAS tokens
79
- durationMin: 86400, // 1 day in seconds
80
- durationMax: 604800, // 1 week in seconds
81
- paymentsFreq: 'daily',
82
- ownerKeyIndex: 0
43
+ rate: 1000000, // ATLAS tokens
44
+ durationMin: 86400, // 1 day
45
+ durationMax: 604800, // 1 week
46
+ paymentsFreq: 'daily'
83
47
  });
84
48
 
85
- // Step 5: Build transaction and send (using your preferred method)
86
- const transaction = pipe(
87
- createTransaction({ version: 0 }),
88
- tx => appendInstructions([contractInstruction], tx)
89
- );
90
-
91
- // Sign and send using wallet extension
92
- const signature = await signAndSendTransaction(rpc, transaction, wallet);
93
- console.log('Transaction signature:', signature);
94
- ```
95
-
96
- **Alternative with @solana/web3.js:**
97
-
98
- ```typescript
99
- import { Connection, Transaction } from '@solana/web3.js';
100
-
49
+ // 3. Build and send transaction
101
50
  const connection = new Connection('https://api.atlasnet.solana.com');
102
- const transaction = new Transaction().add(contractInstruction);
103
-
104
- // Sign and send with wallet extension
105
- const signature = await window.solana.signAndSendTransaction(transaction);
51
+ const transaction = new Transaction().add(instruction);
52
+ const signature = await wallet.signAndSendTransaction(transaction);
106
53
  ```
107
54
 
108
- > **Note**: The SRSLY SDK only creates instructions. You're responsible for:
109
- > - Setting up RPC connections
110
- > - Managing wallet connections (Phantom, Solflare, etc.)
111
- > - Building, signing, and sending transactions
112
- > - Handling transaction confirmation and errors
113
-
114
- ---
115
-
116
- ## SDK Features
117
-
118
- The following examples show how to use the SRSLY SDK to build instructions. Add these instructions to transactions using your preferred Solana library (`@solana/web3.js` or `@solana/kit`).
55
+ ## Core Features
119
56
 
120
57
  ### Contract Management
121
58
 
122
- Create and manage rental contracts for Star Atlas fleets:
123
-
124
59
  ```typescript
125
60
  import { createContract, closeContract } from '@wuwei-labs/srsly';
126
61
 
127
- // Create a new rental contract with network configuration
62
+ // Create rental contract
128
63
  const createIx = await createContract({
129
64
  owner: wallet,
130
65
  fleet: fleetAddress,
131
66
  ownerProfile: profileAddress,
132
- rate: 5000000, // Rate in ATLAS tokens
133
- durationMin: 86400, // Minimum 1 day
134
- durationMax: 2592000, // Maximum 30 days
135
- paymentsFreq: 'daily',
136
- ownerKeyIndex: 0
137
- }).set({ network: 'mainnet' }); // Use mainnet configuration
138
-
139
- // Close an existing contract using atlasnet programs (direct await)
67
+ rate: 5000000,
68
+ durationMin: 86400,
69
+ durationMax: 2592000,
70
+ paymentsFreq: 'daily'
71
+ });
72
+
73
+ // Close contract
140
74
  const closeIx = await closeContract({
141
75
  owner: wallet,
142
76
  fleet: fleetAddress,
143
- contract: contractAddress,
144
- faction: 'mud' // or faction number: 1, 2, 3
77
+ contract: contractAddress
145
78
  });
146
79
  ```
147
80
 
148
81
  ### Rental Operations
149
82
 
150
- Handle rental lifecycle operations with automatic token conversion:
151
-
152
83
  ```typescript
153
- import {
154
- acceptRental,
155
- cancelRental,
156
- closeRental,
157
- resetRental,
158
- ATLAS_TO_STARDUST
159
- } from '@wuwei-labs/srsly';
84
+ import { acceptRental, cancelRental, closeRental } from '@wuwei-labs/srsly';
160
85
 
161
- // Accept a rental offer on atlasnet (rate-based with automatic conversion)
86
+ // Accept rental offer
162
87
  const acceptIx = await acceptRental({
163
88
  borrower: borrowerWallet,
164
89
  borrowerProfile: borrowerProfileAddress,
165
- borrowerFaction: 'oni', // or faction number: 1=mud, 2=oni, 3=ustur
90
+ borrowerFaction: 'mud', // or 1, 2, 3
166
91
  fleet: fleetAddress,
167
92
  contract: contractAddress,
168
- rate: 100, // ATLAS tokens (not per second, just ATLAS)
93
+ rate: 100, // ATLAS per day
169
94
  duration: 86400 // 1 day in seconds
170
- // amount = rate * duration * ATLAS_TO_STARDUST automatically calculated
171
- }).set({ network: 'atlasnet' });
95
+ });
172
96
 
173
- // Cancel an active rental using atlasnet programs (direct await)
97
+ // Cancel active rental
174
98
  const cancelIx = await cancelRental({
175
99
  borrower: borrowerWallet,
176
100
  contract: contractAddress,
177
101
  rentalState: rentalStateAddress
178
102
  });
179
103
 
180
- // Close a completed rental on mainnet
104
+ // Close completed rental
181
105
  const closeIx = await closeRental({
182
106
  borrower: borrowerWallet,
183
107
  contract: contractAddress,
184
108
  rentalState: rentalStateAddress,
185
109
  ownerTokenAccount: ownerTokenAccountAddress
186
- }).set({ network: 'mainnet' });
187
-
188
- // Reset rental state with custom configuration
189
- const resetIx = await resetRental({
190
- fleet: fleetAddress,
191
- contract: contractAddress,
192
- rentalState: rentalStateAddress,
193
- faction: 'mud',
194
- ownerProfile: ownerProfileAddress
195
- }).set({
196
- network: 'mainnet',
197
- sageProgramAddress: 'custom...',
198
- gameId: 'custom...'
199
- });
200
- ```
201
-
202
- ### Account State Management
203
-
204
- Fetch and decode account states using network-specific functions:
205
-
206
- ```typescript
207
- import { getCachedNetworkModule } from '@wuwei-labs/srsly';
208
-
209
- // Get network-specific account functions (programs to atlasnet)
210
- const accountsModule = await getCachedNetworkModule('accounts');
211
- const { fetchContractState, fetchRentalState } = accountsModule;
212
-
213
- // Or specify network explicitly
214
- const mainnetAccountsModule = await getCachedNetworkModule('accounts', 'mainnet');
215
-
216
- // Fetch contract state
217
- const contractState = await fetchContractState(rpc, contractPublicKey);
218
- console.log('Contract rate:', contractState.rate.toString());
219
- console.log('Duration range:', contractState.durationMin.toString(), '-', contractState.durationMax.toString());
220
-
221
- // Fetch rental state
222
- const rentalState = await fetchRentalState(rpc, rentalPublicKey);
223
- console.log('Rental status:', rentalState.status);
224
- console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
225
- ```
226
-
227
- ### Error Handling
228
-
229
- The SDK provides custom error types for better debugging:
230
-
231
- ```typescript
232
- import { SrslyError } from '@wuwei-labs/srsly';
233
-
234
- try {
235
- const instruction = await createContract(params);
236
- // Add to transaction and send...
237
- } catch (error) {
238
- if (error instanceof SrslyError) {
239
- console.error('SRSLY SDK Error:', error.message, error.code);
240
- } else {
241
- console.error('Other Error:', error);
242
- }
243
- }
244
- ```
245
-
246
- ### Token Conversion
247
-
248
- The SDK includes automatic ATLAS to stardust conversion for rental operations:
249
-
250
- ```typescript
251
- import { ATLAS_TO_STARDUST } from '@wuwei-labs/srsly';
252
-
253
- // ATLAS_TO_STARDUST = 100_000_000 (1 ATLAS = 100 million stardust)
254
- console.log('Conversion rate:', ATLAS_TO_STARDUST);
255
-
256
- // When using acceptRental with rate and duration:
257
- // Final amount = rate * duration * ATLAS_TO_STARDUST
258
- // Example: 100 ATLAS * 86400 seconds * 100_000_000 = 864,000,000,000,000 stardust
259
- ```
260
-
261
- ## Program Information
262
-
263
- - **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
264
- - **Network**: Solana Mainnet or Atlasnet
265
- - **Built with**: Anchor Framework
266
-
267
- ## Payment Structure
268
-
269
- The SRSLY program implements a comprehensive payment system with escrow deposits, periodic payments, fees, and refunds. Understanding this structure is crucial for integrating rental functionality.
270
-
271
- ### Overview
272
-
273
- ```text
274
- Rental Lifecycle:
275
- 1. Escrow Deposit (Full Payment Upfront)
276
- 2. Periodic Payments (Based on Payment Frequency)
277
- 3. Fee Collection (Platform + Referral Fees)
278
- 4. Owner Payments (After Fee Deduction)
279
- 5. Refunds (For Early Cancellation)
280
- ```
281
-
282
- ### 1. Escrow Deposit
283
-
284
- When a borrower accepts a rental, they deposit the **full rental amount upfront** into an escrow account:
285
-
286
- ```typescript
287
- // Example: 1000 ATLAS for 10 days = 10,000 ATLAS total
288
- const acceptIx = await acceptRental({
289
- borrower: wallet,
290
- borrowerProfile: profileAddress,
291
- borrowerFaction: 'mud',
292
- fleet: fleetAddress,
293
- contract: contractAddress,
294
- rate: 1000, // ATLAS tokens per day
295
- duration: 864000, // 10 days in seconds
296
- referralTokenAccount: referrerAddress // Optional referral
297
- });
298
- // Total escrowed: 1000 * 10 * 100,000,000 = 1,000,000,000,000 stardust
299
- ```
300
-
301
- **Key Points:**
302
-
303
- - Full payment calculated as: `rate × duration × ATLAS_TO_STARDUST`
304
- - Funds are held in a rental-specific escrow account
305
- - Escrow is controlled by the rental state PDA
306
- - No payments to owner until periodic execution
307
- - **Minimum enforcement**: 24 hours from start time (if no payments) or last payment time
308
-
309
- ### 2. Periodic Payments
310
-
311
- The system creates an automated thread that executes payments based on the contract's payment frequency:
312
-
313
- ```typescript
314
- // Contract with daily payments
315
- const contractIx = await createContract({
316
- owner: wallet,
317
- fleet: fleetAddress,
318
- ownerProfile: profileAddress,
319
- rate: 1000,
320
- durationMin: 86400, // 1 day minimum
321
- durationMax: 2592000, // 30 days maximum
322
- paymentsFreq: 'daily' // Payments every 24 hours
323
- });
324
- ```
325
-
326
- **Payment Schedule:**
327
-
328
- - **Daily**: Payments execute daily at 00:00 UTC (not every 24 hours from creation)
329
- - **Weekly**: Payments execute weekly at specific day/time
330
- - **Monthly**: Payments execute monthly at specific day/time
331
-
332
- **Pro-rata Calculation:**
333
-
334
- Each payment is calculated based on elapsed time since the last payment:
335
-
336
- ```text
337
- payment_amount = (elapsed_time / frequency_seconds) × rate × ATLAS_TO_STARDUST
338
- ```
339
-
340
- ### 3. Fee Structure
341
-
342
- Each payment is subject to a **10% platform fee** with optional **10% referral sharing**:
343
-
344
- ```typescript
345
- // Constants from the program
346
- const SERVICE_FEE_BPS = 1000; // 10% platform fee
347
- const REFERRAL_BPS = 1000; // 10% of total fee to referral
348
- const BASE_BPS = 10000; // 100% in basis points
349
- ```
350
-
351
- **Fee Calculation:**
352
-
353
- ```typescript
354
- // For each payment amount
355
- const totalFee = paymentAmount * SERVICE_FEE_BPS / BASE_BPS; // 10% of payment
356
- const referralFee = totalFee * REFERRAL_BPS / BASE_BPS; // 10% of total fee
357
- const platformFee = totalFee - referralFee; // 90% of total fee
358
- const ownerPayment = paymentAmount - totalFee; // 90% of payment
359
- ```
360
-
361
- **Example Payment Breakdown:**
362
-
363
- ```text
364
- Payment Amount: 1000 ATLAS
365
- ├── Total Fee (10%): 100 ATLAS
366
- │ ├── Referral Fee (10% of total fee): 10 ATLAS → Referrer
367
- │ └── Platform Fee (90% of total fee): 90 ATLAS → Platform
368
- └── Owner Payment (90%): 900 ATLAS → Fleet Owner
369
- ```
370
-
371
- ### 4. Payment Distribution
372
-
373
- Each periodic payment is distributed in this order:
374
-
375
- 1. **Referral Payment** (if referrer exists and ≠ system_program::ID)
376
- - Amount: `total_fee × REFERRAL_BPS ÷ BASE_BPS`
377
- - Destination: Referrer's token account
378
-
379
- 2. **Platform Fee Payment**
380
- - Amount: `total_fee - referral_payment`
381
- - Destination: Platform fee account
382
-
383
- 3. **Owner Payment**
384
- - Amount: `payment_amount - total_fee`
385
- - Destination: Fleet owner's token account
386
-
387
- **Code Example:**
388
-
389
- ```typescript
390
- // Accept rental with referral
391
- const acceptIx = await acceptRental({
392
- borrower: wallet,
393
- borrowerProfile: profileAddress,
394
- borrowerFaction: 'mud',
395
- fleet: fleetAddress,
396
- contract: contractAddress,
397
- rate: 1000,
398
- duration: 86400,
399
- referralTokenAccount: referrerTokenAccount // 10% of fees
400
- });
401
- ```
402
-
403
- ### 5. Refund Mechanism
404
-
405
- Refunds occur when rentals are cancelled early or when contracts are closed. **Important: All rentals enforce a minimum 24-hour active period from either the start time (if no payments made) or the last payment time.**
406
-
407
- **Early Cancellation:**
408
-
409
- ```typescript
410
- const cancelIx = await cancelRental({
411
- borrower: wallet,
412
- contract: contractAddress,
413
- rentalState: rentalStateAddress
414
110
  });
415
111
  ```
416
112
 
417
- **Refund Scenarios:**
418
-
419
- - **Before First Payment**: Rental remains active for 24 hours from start time, pro-rata refund for remaining time
420
- - **After Payment(s) Made**: Rental remains active for 24 hours from last payment time, pro-rata refund for remaining time
421
- - **Contract Closure**: Any remaining escrow returned to borrower
422
-
423
- ### 6. Payment Timeline Example
424
-
425
- **Scenario**: 10-day rental with daily payments, 1000 ATLAS/day rate
426
-
427
- ```text
428
- Day 0: Rental Accepted
429
- ├── Escrow: 10,000 ATLAS deposited
430
- ├── Thread: Created for daily execution at 00:00 UTC
431
- ├── Fleet: Transferred to borrower
432
- └── Minimum 24-hour commitment begins (from start time)
433
-
434
- 00:00 UTC Next Day: First Payment
435
- ├── Amount: 1,000 ATLAS from escrow
436
- ├── Total Fee (10%): 100 ATLAS
437
- │ ├── Referrer: 10 ATLAS (10% of total fee)
438
- │ └── Platform: 90 ATLAS (90% of total fee)
439
- ├── Owner: 900 ATLAS (90% of payment)
440
- ├── Escrow: 9,000 ATLAS remaining
441
- └── New 24-hour minimum period begins (from payment time)
442
-
443
- Daily at 00:00 UTC: Subsequent Payments
444
- ├── Same distribution pattern
445
- ├── Escrow decreases by 1,000 ATLAS each day
446
- └── Each payment resets 24-hour minimum period
447
-
448
- Final Day at 00:00 UTC: Final Payment & Cleanup
449
- ├── Final payment processed
450
- ├── Thread: Automatically closed
451
- ├── Rental State: Closed, lamports to borrower
452
- └── Fleet: Returned to owner or contract
453
-
454
- Early Cancellation Examples:
455
-
456
- Scenario A - Cancel before first payment (Day 0 at 6 PM):
457
- ├── Cancelled 6 hours after start
458
- ├── Rental extends until 24 hours from start time (Day 1 at start time)
459
- ├── Pro-rata refund calculated from Day 1 extended end onwards
460
- └── Borrower receives refund for Days 1-10
461
-
462
- Scenario B - Cancel after payments made (Day 3 at 6 PM):
463
- ├── Cancelled 18 hours after Day 3 payment (00:00 UTC)
464
- ├── Rental extends until 24 hours from last payment (Day 4 at 00:00 UTC)
465
- ├── Pro-rata refund calculated from Day 4 onwards
466
- └── Borrower receives refund for Days 4-10
467
- ```
468
-
469
- ### 7. Edge Cases
470
-
471
- **Insufficient Escrow Balance:**
472
-
473
- - Payment amount is limited to available escrow balance
474
- - Remaining balance distributed proportionally
475
-
476
- **Early Termination:**
477
-
478
- - **Cancellation Notice**: Must have more than one payment period remaining to cancel
479
- - **Minimum Period Enforcement**:
480
- - Before first payment: Active for 24 hours from start time
481
- - After payment(s): Active for 24 hours from last payment time
482
- - **Pro-rata Refund**: Refund calculated from the enforced minimum end time
483
- - Fleet returned to owner when minimum period expires
484
- - Payment thread continues until minimum period ends
485
-
486
- **Contract Closure:**
487
-
488
- - Final payment processed if rental active
489
- - All remaining resources cleaned up
490
- - Fleet rental capability removed
491
-
492
- ## Payment Frequencies
493
-
494
- The SDK supports multiple payment frequencies:
495
-
496
- - `daily` - Daily payments at 00:00 UTC
497
- - `weekly` - Weekly payments at specific day/time
498
- - `monthly` - Monthly payments at specific day/time
499
-
500
-
501
113
  ## Network Configuration
502
114
 
503
- The SDK supports both Solana mainnet and atlasnet with different IDL artifacts and default program addresses for each network. The configuration system has two main purposes:
504
-
505
- ### What `setConfig` Does:
506
-
507
- **1. Network Selection (IDL/Module Loading):**
508
- - ✅ Selects which IDL artifacts to use (`mainnet` vs `atlasnet`)
509
- - ✅ Loads appropriate codama-generated instruction builders
510
- - ✅ Determines default program addresses for the network
511
-
512
- **2. Program Address Selection:**
513
- - ✅ Select predefined program address sets (mainnet, atlasnet, holosim)
514
- - ✅ Override specific program addresses (SRSLY, SAGE, Profile Faction)
515
- - ✅ Override game IDs and other network constants
516
- - ✅ Mix and match programs across networks if needed
517
-
518
- **What it does NOT do:**
519
- - ❌ Configure RPC endpoints
520
- - ❌ Handle wallet connections
521
- - ❌ Manage transactions
522
-
523
- ### Global Configuration (Recommended)
115
+ The SDK supports multiple network configurations:
524
116
 
525
- Set default configuration once for all SDK operations:
117
+ ### Global Configuration
526
118
 
527
119
  ```typescript
528
- import { setConfig, getConfig, createContract } from '@wuwei-labs/srsly';
120
+ import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
529
121
 
530
- // Example 1: Use mainnet IDL with default mainnet program addresses
531
- setConfig({
532
- network: 'mainnet'
533
- });
534
-
535
- // Example 2: Use atlasnet IDL with default atlasnet program addresses
536
- setConfig({
537
- network: 'atlasnet'
538
- });
539
-
540
- // Example 3: Use atlasnet IDL with holosim program addresses
541
- setConfig({
542
- network: 'atlasnet',
543
- programs: 'holosim'
544
- });
122
+ // Use mainnet programs
123
+ setConfig({ programs: 'mainnet' });
545
124
 
546
- // Example 4: Use atlasnet IDL with holosim programs but custom SAGE
547
- setConfig({
548
- network: 'atlasnet',
549
- programs: 'holosim',
550
- sageProgramAddress: 'custom-sage-program-id...'
551
- });
125
+ // Use atlasnet programs (default)
126
+ setConfig({ programs: 'atlasnet' });
552
127
 
553
- // Example 5: Use mainnet IDL with atlasnet program addresses
554
- setConfig({
555
- network: 'mainnet',
556
- programs: 'atlasnet'
557
- });
128
+ // Use holosim test programs
129
+ setConfig({ programs: 'holosim' });
558
130
 
559
- // Example 6: Custom overrides only
131
+ // Custom configuration
560
132
  setConfig({
561
- network: 'atlasnet',
562
- srslyProgramAddress: 'custom-srsly-program-id...',
563
- sageProgramAddress: 'custom-sage-program-id...',
133
+ programs: 'mainnet',
134
+ sageProgramAddress: 'custom-sage-program...',
564
135
  gameId: 'custom-game-id...'
565
136
  });
566
137
 
567
- // Check current configuration
138
+ // Check current config
568
139
  console.log(getConfig());
569
140
 
570
- // All operations now use configured settings
571
- const ix1 = await createContract(params); // Uses configured SRSLY program
572
- const ix2 = await acceptRental(params); // Uses configured SAGE program
141
+ // Reset to defaults
142
+ clearConfig();
573
143
  ```
574
144
 
575
145
  ### Per-Instruction Configuration
576
146
 
577
- Override global program address configuration for specific instructions using the fluent `.set()` interface:
578
-
579
147
  ```typescript
580
- import { createContract, acceptRental } from '@wuwei-labs/srsly';
581
-
582
- // Assume global config is set to mainnet program addresses
583
- setConfig({ network: 'mainnet' });
584
-
585
- // Use global mainnet program addresses
586
- const mainnetIx = await createContract(params);
587
-
588
- // Override to use atlasnet program addresses for this specific instruction
589
- const atlasnetIx = await createContract(params).set({ network: 'atlasnet' });
148
+ // Override global config for specific instructions
149
+ const ix = await createContract(params).set({ programs: 'mainnet' });
590
150
 
591
- // Override specific program addresses while keeping global network
592
- const customIx = await createContract(params).set({
593
- sageProgramAddress: 'custom-sage-program-id...',
594
- gameId: 'custom-game-id...'
595
- // network: 'mainnet' inherited from global config
596
- });
597
- ```
598
-
599
- ### Configuration Options
600
-
601
- All SDK functions support these usage patterns:
602
-
603
- **Direct await (uses global config or atlasnet fallback):**
604
-
605
- ```typescript
606
- // Uses global program addresses if set, otherwise atlasnet programs
607
- await createContract(params);
608
- await acceptRental(params);
151
+ // Chain multiple configurations
152
+ const ix2 = await acceptRental(params)
153
+ .set({ programs: 'holosim' })
154
+ .set({ gameId: 'custom-game-id...' });
609
155
  ```
610
156
 
611
- **Global configuration functions:**
157
+ ## Payment System
612
158
 
613
- - `setConfig({ network: 'mainnet', gameId: '...' })` - Set global program addresses
614
- - `getConfig()` - Get current global configuration
615
- - `clearConfig()` - Reset to atlasnet programs
159
+ SRSLY implements an escrow-based payment system:
616
160
 
617
- **Per-instruction overrides with `.set()` method:**
618
-
619
- - `.set({ network: 'mainnet' })` - Override to mainnet program addresses
620
- - `.set({ sageProgramAddress: '...' })` - Override specific program address only
621
- - `.set({ network: 'mainnet', sageProgramAddress: '...' })` - Multiple overrides
622
-
623
- **Chainable configurations:**
624
-
625
- ```typescript
626
- // Chain multiple configurations (later ones override earlier ones)
627
- await createContract(params)
628
- .set({ network: 'atlasnet' })
629
- .set({ sageProgramAddress: 'override...' });
630
-
631
- // Examples with global config
632
- setConfig({ network: 'mainnet' });
633
- await createContract(params); // Uses mainnet program addresses
634
- await acceptRental(params).set({ network: 'atlasnet' }); // Override to atlasnet programs
635
- await closeContract(params).set({ gameId: 'custom...' }); // Custom gameId, mainnet programs
636
- ```
637
-
638
- ### Available Configuration Options
161
+ 1. **Escrow**: Borrower deposits full rental amount upfront
162
+ 2. **Periodic Payments**: Automated payments based on frequency (daily/weekly/monthly)
163
+ 3. **Fees**: 10% platform fee, optional 10% referral sharing
164
+ 4. **Refunds**: Pro-rata refunds for early cancellation (24-hour minimum)
639
165
 
640
166
  ```typescript
641
- interface ConfigOptions {
642
- network?: 'mainnet' | 'atlasnet'; // Which IDL artifacts to use
643
- programs?: 'mainnet' | 'atlasnet' | 'holosim'; // Which program address set to use
644
- srslyProgramAddress?: string; // Override SRSLY program address
645
- sageProgramAddress?: string; // Override SAGE program address
646
- profileFactionProgramAddress?: string; // Override Profile Faction program address
647
- gameId?: string; // Override SAGE game ID
648
- }
167
+ // Payment calculation
168
+ const rate = 1000; // ATLAS per day
169
+ const duration = 86400; // 1 day in seconds
170
+ const totalAmount = rate * duration * ATLAS_TO_STARDUST; // in stardust
649
171
  ```
650
172
 
651
- **Available Program Address Sets:**
173
+ ## Available Networks
652
174
 
653
175
  ```typescript
654
- // mainnet
655
- {
656
- srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
657
- sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
658
- profileFactionProgram: 'pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq',
659
- gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr'
660
- }
661
-
662
- // atlasnet (default) - values currently empty, to be filled
663
- {
664
- srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
665
- sageProgram: '',
666
- profileFactionProgram: '',
667
- gameId: ''
668
- }
669
-
670
- // holosim
671
- {
672
- srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
673
- sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
674
- profileFactionProgram: 'PprofUW1pURCnMW2si88GWPXEEK3Bvh9Tksy8WtnoYJ',
675
- gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
676
- }
677
- ```
678
-
679
- **Priority Order:**
680
- 1. Individual overrides (highest priority)
681
- 2. programs configuration
682
- 3. Network default (if programs not specified)
683
-
684
- **Key Concepts:**
685
-
686
- - **Network** = Which IDL/codama artifacts to load (affects instruction structure)
687
- - **programs** = Which predefined program address set to use (mainnet, atlasnet, holosim)
688
- - **Program Overrides** = Override individual program addresses (highest priority)
689
- - **Default Behavior** = If programs not specified, uses network's program addresses
690
- - **Flexibility** = Mix any IDL with any program set, plus individual overrides
691
-
692
- ### Network-Specific Constants
693
-
694
- The SDK automatically resolves network-specific constants:
695
-
696
- ```typescript
697
- import {
698
- getSageProgramAddress,
699
- getProfileFactionProgramAddress,
700
- getSageGameId
701
- } from '@wuwei-labs/srsly';
702
-
703
- // Get constants for atlasnet (default)
704
- const sageProgram = await getSageProgramAddress();
705
- const gameId = await getSageGameId();
706
-
707
- // Get constants for specific network
708
- const mainnetSageProgram = await getSageProgramAddress({ network: 'mainnet' });
709
- const mainnetGameId = await getSageGameId({ network: 'mainnet' });
710
- ```
711
-
712
- ## IDL and Types
713
-
714
- ### Network-Specific IDLs
715
-
716
- The SDK provides network-specific IDLs since program configurations differ between networks:
717
-
718
- ```typescript
719
- // Mainnet IDL
720
- import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
721
-
722
- // Devnet IDL
723
- import atlasnetIdl from '@wuwei-labs/srsly/idl/atlasnet';
724
-
725
- // Use with Anchor
726
- import { Program } from '@coral-xyz/anchor';
727
- const program = new Program(mainnetIdl, provider);
176
+ // Program address sets
177
+ const networks = {
178
+ mainnet: {
179
+ sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
180
+ gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr'
181
+ },
182
+ atlasnet: {
183
+ sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
184
+ gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
185
+ },
186
+ holosim: {
187
+ sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
188
+ gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
189
+ }
190
+ };
728
191
  ```
729
192
 
730
- ### Network-Specific Types
731
-
732
- Import TypeScript types that match your target network:
193
+ ## Types and Constants
733
194
 
734
195
  ```typescript
735
196
  import type {
736
- ContractState,
737
- RentalState,
738
- PaymentFrequency,
739
- ClockData,
740
- ThreadResponse,
741
- ConfigOptions
197
+ ContractState,
198
+ RentalState,
199
+ ConfigOptions,
200
+ PaymentFrequency
742
201
  } from '@wuwei-labs/srsly';
743
202
 
744
- // Import network-specific Anchor types
745
- import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
746
- import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/atlasnet';
747
- ```
748
-
749
- ## Constants and Utilities
750
-
751
- ### Available Constants
752
-
753
- ```typescript
754
203
  import {
755
204
  ATLAS_TO_STARDUST,
756
- STARBASE_SEED,
757
- STARBASE_PLAYER_SEED,
758
- SAGE_PLAYER_PROFILE_SEED,
759
- PROFILE_FACTION_SEED,
760
- FACTION_MAPPING,
761
- FACTION_SPECIFIC_CSS
205
+ FACTION_MAPPING
762
206
  } from '@wuwei-labs/srsly';
763
207
 
764
- // Token conversion
208
+ // Conversion rate: 1 ATLAS = 100,000,000 stardust
765
209
  console.log(ATLAS_TO_STARDUST); // 100_000_000
766
210
 
767
211
  // Faction mappings
768
212
  console.log(FACTION_MAPPING[1]); // 'mud'
769
- console.log(FACTION_MAPPING[2]); // 'oni'
213
+ console.log(FACTION_MAPPING[2]); // 'oni'
770
214
  console.log(FACTION_MAPPING[3]); // 'ustur'
771
215
  ```
772
216
 
773
- ### Profile Derivation
217
+ ## IDL and Program Information
774
218
 
775
219
  ```typescript
776
- import {
777
- deriveProfileFaction,
778
- deriveSagePlayerProfile,
779
- deriveStarbase,
780
- deriveStarbasePlayer,
781
- deriveGameAccounts
782
- } from '@wuwei-labs/srsly';
783
-
784
- // Derive individual accounts with network configuration
785
- const profileFaction = await deriveProfileFaction(profile, { network: 'mainnet' });
786
- const starbase = await deriveStarbase('mud', gameId, { network: 'mainnet' });
787
-
788
- // Derive all game accounts at once
789
- const gameAccounts = await deriveGameAccounts(
790
- profile,
791
- 'mud',
792
- gameId,
793
- 0, // starbaseSeqId
794
- { network: 'mainnet' }
795
- );
220
+ // Access program IDLs
221
+ import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
222
+ import atlasnetIdl from '@wuwei-labs/srsly/idl/atlasnet';
796
223
  ```
797
224
 
798
- ## Webpack Compatibility
799
-
800
- The SRSLY SDK is fully compatible with webpack bundlers. The package includes both CommonJS and ESM builds:
801
-
802
- - **CommonJS**: `./dist/cjs/index.cjs` (default for Node.js and webpack)
803
- - **ESM**: `./dist/esm/index.js` (for modern ES modules)
804
- - **Types**: `./dist/types/index.d.ts` (TypeScript definitions)
805
-
806
- ### Webpack Configuration
807
-
808
- For optimal webpack compatibility, the SDK includes:
809
-
810
- - `sideEffects: false` for better tree-shaking
811
- - Proper CommonJS exports with `.cjs` extensions for webpack bundling
812
- - ES module interoperability
813
- - Correct module resolution for mixed ESM/CommonJS environments
814
-
815
- No special webpack configuration is required. The SDK will work out-of-the-box with most webpack setups.
816
-
817
- **Note**: As of version 2.0.0-beta.9, the CommonJS build uses `.cjs` file extensions to ensure proper module resolution in environments where the package.json contains `"type": "module"`.
818
-
819
- ### Testing Webpack Compatibility
820
-
821
- ```bash
822
- # Test local CommonJS exports (fast)
823
- npm run test:webpack
225
+ ## Error Handling
824
226
 
825
- # Test actual npm package installation (comprehensive)
826
- npm run test:npm-install
827
-
828
- # Test actual pnpm package installation with webpack bundling
829
- npm run test:pnpm-install
227
+ ```typescript
228
+ import { SrslyError } from '@wuwei-labs/srsly';
830
229
 
831
- # Test both package managers
832
- npm run test:package-managers
230
+ try {
231
+ const instruction = await createContract(params);
232
+ // Add to transaction and send...
233
+ } catch (error) {
234
+ if (error instanceof SrslyError) {
235
+ console.error('SRSLY SDK Error:', error.message, error.code);
236
+ } else {
237
+ console.error('Other Error:', error);
238
+ }
239
+ }
833
240
  ```
834
241
 
835
- These commands test different aspects:
836
- - `test:webpack`: Tests local CommonJS exports that webpack uses
837
- - `test:npm-install`: Installs the actual published package via npm and tests functionality
838
- - `test:pnpm-install`: Installs via pnpm and includes a real webpack bundling test
839
- - `test:package-managers`: Runs both npm and pnpm tests
242
+ ## Package Structure
840
243
 
841
- ## Documentation
244
+ The SDK provides optimized builds for different environments:
842
245
 
843
- - **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
246
+ - **CommonJS**: `./dist/cjs/` (Node.js, webpack)
247
+ - **ESM**: `./dist/esm/` (Modern ES modules)
248
+ - **Types**: `./dist/types/` (TypeScript definitions)
249
+ - **Shared**: `./dist/shared/codama/` (Optimized codama exports)
844
250
 
845
- ## Related Projects
251
+ ## Links
846
252
 
847
- - **Star Atlas**: The metaverse gaming ecosystem
848
- - **Solana**: The blockchain platform powering SRSLY
849
- - **Anchor**: The framework used to build the SRSLY program
253
+ - **NPM Package**: [@wuwei-labs/srsly](https://www.npmjs.com/package/@wuwei-labs/srsly)
254
+ - **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)