@wuwei-labs/srsly 2.0.0-beta.3 → 2.0.0-beta.31

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 (395) hide show
  1. package/README.md +322 -197
  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/{devnet/accounts → accounts}/contractState.js +2 -7
  5. package/dist/cjs/codama/accounts/contractState.js.map +1 -0
  6. package/dist/cjs/codama/{devnet/accounts → accounts}/index.js +1 -1
  7. package/dist/cjs/codama/accounts/index.js.map +1 -0
  8. package/dist/cjs/codama/{devnet/accounts → accounts}/rentalState.js +3 -1
  9. package/dist/cjs/codama/accounts/rentalState.js.map +1 -0
  10. package/dist/cjs/codama/accounts/thread.js.map +1 -0
  11. package/dist/cjs/codama/errors/index.js.map +1 -0
  12. package/dist/cjs/codama/{devnet/errors → errors}/srsly.js +30 -3
  13. package/dist/cjs/codama/errors/srsly.js.map +1 -0
  14. package/dist/cjs/codama/index.js.map +1 -0
  15. package/dist/cjs/codama/{devnet/instructions → instructions}/acceptRental.js +30 -39
  16. package/dist/cjs/codama/instructions/acceptRental.js.map +1 -0
  17. package/dist/cjs/codama/{devnet/instructions → instructions}/cancelRental.js +10 -33
  18. package/dist/cjs/codama/instructions/cancelRental.js.map +1 -0
  19. package/dist/cjs/codama/{devnet/instructions → instructions}/closeContract.js +15 -23
  20. package/dist/cjs/codama/instructions/closeContract.js.map +1 -0
  21. package/dist/cjs/codama/{devnet/instructions → instructions}/closeRental.js +19 -19
  22. package/dist/cjs/codama/instructions/closeRental.js.map +1 -0
  23. package/dist/cjs/codama/{devnet/instructions → instructions}/createContract.js +13 -16
  24. package/dist/cjs/codama/instructions/createContract.js.map +1 -0
  25. package/dist/cjs/codama/{devnet/instructions → instructions}/index.js +2 -1
  26. package/dist/cjs/codama/instructions/index.js.map +1 -0
  27. package/dist/cjs/codama/instructions/initializeConfig.js +131 -0
  28. package/dist/cjs/codama/instructions/initializeConfig.js.map +1 -0
  29. package/dist/cjs/codama/{devnet/instructions → instructions}/payRental.js +32 -23
  30. package/dist/cjs/codama/instructions/payRental.js.map +1 -0
  31. package/dist/cjs/codama/{devnet/instructions → instructions}/resetRental.js +0 -9
  32. package/dist/cjs/codama/instructions/resetRental.js.map +1 -0
  33. package/dist/cjs/codama/instructions/updateConfig.js +145 -0
  34. package/dist/cjs/codama/instructions/updateConfig.js.map +1 -0
  35. package/dist/cjs/codama/programs/index.js.map +1 -0
  36. package/dist/cjs/codama/{devnet/programs → programs}/srsly.js +12 -8
  37. package/dist/cjs/codama/programs/srsly.js.map +1 -0
  38. package/dist/cjs/codama/shared/index.js.map +1 -0
  39. package/dist/cjs/codama/types/clockData.js.map +1 -0
  40. package/dist/cjs/codama/types/equality.js.map +1 -0
  41. package/dist/cjs/codama/types/execContext.js.map +1 -0
  42. package/dist/cjs/codama/types/index.js.map +1 -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 +74 -31
  50. package/dist/cjs/contract/close.js.map +1 -1
  51. package/dist/cjs/contract/create.js +79 -35
  52. package/dist/cjs/contract/create.js.map +1 -1
  53. package/dist/cjs/index.js +25 -2
  54. package/dist/cjs/index.js.map +1 -1
  55. package/dist/cjs/package.json +53 -0
  56. package/dist/cjs/rental/accept.js +76 -42
  57. package/dist/cjs/rental/accept.js.map +1 -1
  58. package/dist/cjs/rental/cancel.js +40 -28
  59. package/dist/cjs/rental/cancel.js.map +1 -1
  60. package/dist/cjs/rental/close.js +42 -30
  61. package/dist/cjs/rental/close.js.map +1 -1
  62. package/dist/cjs/rental/reset.js +50 -43
  63. package/dist/cjs/rental/reset.js.map +1 -1
  64. package/dist/cjs/types/paymentFrequency.js +58 -0
  65. package/dist/cjs/types/paymentFrequency.js.map +1 -0
  66. package/dist/cjs/utils/config.js +216 -0
  67. package/dist/cjs/utils/config.js.map +1 -0
  68. package/dist/cjs/utils/constants.js +55 -27
  69. package/dist/cjs/utils/constants.js.map +1 -1
  70. package/dist/cjs/utils/duration.js +77 -0
  71. package/dist/cjs/utils/duration.js.map +1 -0
  72. package/dist/cjs/utils/index.js +4 -0
  73. package/dist/cjs/utils/index.js.map +1 -1
  74. package/dist/cjs/utils/instruction-converter.js +66 -0
  75. package/dist/cjs/utils/instruction-converter.js.map +1 -0
  76. package/dist/cjs/utils/paymentFrequency.js +60 -0
  77. package/dist/cjs/utils/paymentFrequency.js.map +1 -0
  78. package/dist/cjs/utils/profiles.js +38 -18
  79. package/dist/cjs/utils/profiles.js.map +1 -1
  80. package/dist/cjs/utils/types.js +6 -0
  81. package/dist/cjs/utils/types.js.map +1 -0
  82. package/dist/esm/codama/accounts/config.js +76 -0
  83. package/dist/esm/codama/accounts/config.js.map +1 -0
  84. package/dist/esm/codama/{devnet/accounts → accounts}/contractState.js +3 -7
  85. package/dist/esm/codama/accounts/contractState.js.map +1 -0
  86. package/dist/esm/codama/{devnet/accounts → accounts}/index.js +1 -1
  87. package/dist/esm/codama/accounts/index.js.map +1 -0
  88. package/dist/esm/codama/{devnet/accounts → accounts}/rentalState.js +3 -1
  89. package/dist/esm/codama/accounts/rentalState.js.map +1 -0
  90. package/dist/esm/codama/accounts/thread.js.map +1 -0
  91. package/dist/esm/codama/errors/index.js.map +1 -0
  92. package/dist/esm/codama/{devnet/errors → errors}/srsly.js +29 -2
  93. package/dist/esm/codama/errors/srsly.js.map +1 -0
  94. package/dist/esm/codama/index.js.map +1 -0
  95. package/dist/esm/codama/{devnet/instructions → instructions}/acceptRental.js +30 -39
  96. package/dist/esm/codama/instructions/acceptRental.js.map +1 -0
  97. package/dist/esm/codama/{devnet/instructions → instructions}/cancelRental.js +10 -33
  98. package/dist/esm/codama/instructions/cancelRental.js.map +1 -0
  99. package/dist/esm/codama/{devnet/instructions → instructions}/closeContract.js +17 -25
  100. package/dist/esm/codama/instructions/closeContract.js.map +1 -0
  101. package/dist/esm/codama/{devnet/instructions → instructions}/closeRental.js +19 -19
  102. package/dist/esm/codama/instructions/closeRental.js.map +1 -0
  103. package/dist/esm/codama/{devnet/instructions → instructions}/createContract.js +13 -16
  104. package/dist/esm/codama/instructions/createContract.js.map +1 -0
  105. package/dist/esm/codama/{devnet/instructions → instructions}/index.js +2 -1
  106. package/dist/esm/codama/instructions/index.js.map +1 -0
  107. package/dist/esm/codama/instructions/initializeConfig.js +121 -0
  108. package/dist/esm/codama/instructions/initializeConfig.js.map +1 -0
  109. package/dist/esm/codama/{devnet/instructions → instructions}/payRental.js +34 -25
  110. package/dist/esm/codama/instructions/payRental.js.map +1 -0
  111. package/dist/esm/codama/{devnet/instructions → instructions}/resetRental.js +0 -9
  112. package/dist/esm/codama/instructions/resetRental.js.map +1 -0
  113. package/dist/esm/codama/instructions/updateConfig.js +135 -0
  114. package/dist/esm/codama/instructions/updateConfig.js.map +1 -0
  115. package/dist/esm/codama/programs/index.js.map +1 -0
  116. package/dist/esm/codama/{devnet/programs → programs}/srsly.js +12 -8
  117. package/dist/esm/codama/programs/srsly.js.map +1 -0
  118. package/dist/esm/codama/shared/index.js.map +1 -0
  119. package/dist/esm/codama/types/clockData.js.map +1 -0
  120. package/dist/esm/codama/types/equality.js.map +1 -0
  121. package/dist/esm/codama/types/execContext.js.map +1 -0
  122. package/dist/esm/codama/types/index.js.map +1 -0
  123. package/dist/esm/codama/types/paymentFrequency.js.map +1 -0
  124. package/dist/esm/codama/types/serializableAccount.js.map +1 -0
  125. package/dist/esm/codama/types/serializableInstruction.js.map +1 -0
  126. package/dist/esm/codama/types/threadResponse.js.map +1 -0
  127. package/dist/esm/codama/types/trigger.js.map +1 -0
  128. package/dist/esm/codama/types/triggerContext.js.map +1 -0
  129. package/dist/esm/contract/close.js +75 -32
  130. package/dist/esm/contract/close.js.map +1 -1
  131. package/dist/esm/contract/create.js +79 -34
  132. package/dist/esm/contract/create.js.map +1 -1
  133. package/dist/esm/index.js +8 -2
  134. package/dist/esm/index.js.map +1 -1
  135. package/dist/esm/package.json +53 -0
  136. package/dist/esm/rental/accept.js +77 -43
  137. package/dist/esm/rental/accept.js.map +1 -1
  138. package/dist/esm/rental/cancel.js +40 -28
  139. package/dist/esm/rental/cancel.js.map +1 -1
  140. package/dist/esm/rental/close.js +42 -30
  141. package/dist/esm/rental/close.js.map +1 -1
  142. package/dist/esm/rental/reset.js +51 -44
  143. package/dist/esm/rental/reset.js.map +1 -1
  144. package/dist/esm/types/paymentFrequency.js +53 -0
  145. package/dist/esm/types/paymentFrequency.js.map +1 -0
  146. package/dist/esm/utils/config.js +173 -0
  147. package/dist/esm/utils/config.js.map +1 -0
  148. package/dist/esm/utils/constants.js +49 -24
  149. package/dist/esm/utils/constants.js.map +1 -1
  150. package/dist/esm/utils/duration.js +68 -0
  151. package/dist/esm/utils/duration.js.map +1 -0
  152. package/dist/esm/utils/index.js +4 -0
  153. package/dist/esm/utils/index.js.map +1 -1
  154. package/dist/esm/utils/instruction-converter.js +62 -0
  155. package/dist/esm/utils/instruction-converter.js.map +1 -0
  156. package/dist/esm/utils/paymentFrequency.js +55 -0
  157. package/dist/esm/utils/paymentFrequency.js.map +1 -0
  158. package/dist/esm/utils/profiles.js +39 -19
  159. package/dist/esm/utils/profiles.js.map +1 -1
  160. package/dist/esm/utils/types.js +5 -0
  161. package/dist/esm/utils/types.js.map +1 -0
  162. package/dist/types/codama/accounts/config.d.ts +52 -0
  163. package/dist/types/codama/accounts/config.d.ts.map +1 -0
  164. package/dist/types/codama/{devnet/accounts → accounts}/contractState.d.ts +2 -4
  165. package/dist/types/codama/accounts/contractState.d.ts.map +1 -0
  166. package/dist/types/codama/{devnet/accounts → accounts}/index.d.ts +1 -1
  167. package/dist/types/codama/accounts/index.d.ts.map +1 -0
  168. package/dist/types/codama/{devnet/accounts → accounts}/rentalState.d.ts +2 -0
  169. package/dist/types/codama/accounts/rentalState.d.ts.map +1 -0
  170. package/dist/types/codama/accounts/thread.d.ts.map +1 -0
  171. package/dist/types/codama/errors/index.d.ts.map +1 -0
  172. package/dist/types/codama/{devnet/errors → errors}/srsly.d.ts +20 -2
  173. package/dist/types/codama/errors/srsly.d.ts.map +1 -0
  174. package/dist/types/codama/index.d.ts.map +1 -0
  175. package/dist/types/codama/instructions/acceptRental.d.ts +135 -0
  176. package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -0
  177. package/dist/types/codama/{devnet/instructions → instructions}/cancelRental.d.ts +14 -10
  178. package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -0
  179. package/dist/types/codama/instructions/closeContract.d.ts +104 -0
  180. package/dist/types/codama/instructions/closeContract.d.ts.map +1 -0
  181. package/dist/types/codama/{devnet/instructions → instructions}/closeRental.d.ts +20 -12
  182. package/dist/types/codama/instructions/closeRental.d.ts.map +1 -0
  183. package/dist/types/codama/instructions/createContract.d.ts +112 -0
  184. package/dist/types/codama/instructions/createContract.d.ts.map +1 -0
  185. package/dist/types/codama/{devnet/instructions → instructions}/index.d.ts +2 -1
  186. package/dist/types/codama/instructions/index.d.ts.map +1 -0
  187. package/dist/types/codama/instructions/initializeConfig.d.ts +60 -0
  188. package/dist/types/codama/instructions/initializeConfig.d.ts.map +1 -0
  189. package/dist/types/codama/{devnet/instructions → instructions}/payRental.d.ts +28 -13
  190. package/dist/types/codama/instructions/payRental.d.ts.map +1 -0
  191. package/dist/types/codama/{devnet/instructions → instructions}/resetRental.d.ts +3 -3
  192. package/dist/types/codama/instructions/resetRental.d.ts.map +1 -0
  193. package/dist/types/codama/instructions/updateConfig.d.ts +93 -0
  194. package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -0
  195. package/dist/types/codama/programs/index.d.ts.map +1 -0
  196. package/dist/types/codama/{devnet/programs → programs}/srsly.d.ts +11 -8
  197. package/dist/types/codama/programs/srsly.d.ts.map +1 -0
  198. package/dist/types/codama/shared/index.d.ts.map +1 -0
  199. package/dist/types/codama/types/clockData.d.ts.map +1 -0
  200. package/dist/types/codama/types/equality.d.ts.map +1 -0
  201. package/dist/types/codama/types/execContext.d.ts.map +1 -0
  202. package/dist/types/codama/types/index.d.ts.map +1 -0
  203. package/dist/types/codama/types/paymentFrequency.d.ts.map +1 -0
  204. package/dist/types/codama/types/serializableAccount.d.ts.map +1 -0
  205. package/dist/types/codama/types/serializableInstruction.d.ts.map +1 -0
  206. package/dist/types/codama/types/threadResponse.d.ts.map +1 -0
  207. package/dist/types/codama/types/trigger.d.ts.map +1 -0
  208. package/dist/types/codama/types/triggerContext.d.ts.map +1 -0
  209. package/dist/types/contract/close.d.ts +29 -13
  210. package/dist/types/contract/close.d.ts.map +1 -1
  211. package/dist/types/contract/create.d.ts +55 -54
  212. package/dist/types/contract/create.d.ts.map +1 -1
  213. package/dist/types/index.d.ts +5 -2
  214. package/dist/types/index.d.ts.map +1 -1
  215. package/dist/types/rental/accept.d.ts +65 -15
  216. package/dist/types/rental/accept.d.ts.map +1 -1
  217. package/dist/types/rental/cancel.d.ts +36 -8
  218. package/dist/types/rental/cancel.d.ts.map +1 -1
  219. package/dist/types/rental/close.d.ts +36 -8
  220. package/dist/types/rental/close.d.ts.map +1 -1
  221. package/dist/types/rental/reset.d.ts +42 -11
  222. package/dist/types/rental/reset.d.ts.map +1 -1
  223. package/dist/types/types/paymentFrequency.d.ts +44 -0
  224. package/dist/types/types/paymentFrequency.d.ts.map +1 -0
  225. package/dist/types/utils/config.d.ts +110 -0
  226. package/dist/types/utils/config.d.ts.map +1 -0
  227. package/dist/types/utils/constants.d.ts +14 -11
  228. package/dist/types/utils/constants.d.ts.map +1 -1
  229. package/dist/types/utils/duration.d.ts +56 -0
  230. package/dist/types/utils/duration.d.ts.map +1 -0
  231. package/dist/types/utils/index.d.ts +4 -0
  232. package/dist/types/utils/index.d.ts.map +1 -1
  233. package/dist/types/utils/instruction-converter.d.ts +117 -0
  234. package/dist/types/utils/instruction-converter.d.ts.map +1 -0
  235. package/dist/types/utils/paymentFrequency.d.ts +18 -0
  236. package/dist/types/utils/paymentFrequency.d.ts.map +1 -0
  237. package/dist/types/utils/profiles.d.ts +14 -8
  238. package/dist/types/utils/profiles.d.ts.map +1 -1
  239. package/dist/types/utils/types.d.ts +6 -0
  240. package/dist/types/utils/types.d.ts.map +1 -0
  241. package/package.json +33 -25
  242. package/target/idl/{srsly-devnet.json → srsly.json} +795 -523
  243. package/dist/cjs/codama/devnet/accounts/contractState.js.map +0 -1
  244. package/dist/cjs/codama/devnet/accounts/fleet.js +0 -77
  245. package/dist/cjs/codama/devnet/accounts/fleet.js.map +0 -1
  246. package/dist/cjs/codama/devnet/accounts/index.js.map +0 -1
  247. package/dist/cjs/codama/devnet/accounts/rentalState.js.map +0 -1
  248. package/dist/cjs/codama/devnet/accounts/thread.js.map +0 -1
  249. package/dist/cjs/codama/devnet/errors/index.js.map +0 -1
  250. package/dist/cjs/codama/devnet/errors/srsly.js.map +0 -1
  251. package/dist/cjs/codama/devnet/index.js.map +0 -1
  252. package/dist/cjs/codama/devnet/instructions/acceptRental.js.map +0 -1
  253. package/dist/cjs/codama/devnet/instructions/cancelRental.js.map +0 -1
  254. package/dist/cjs/codama/devnet/instructions/closeContract.js.map +0 -1
  255. package/dist/cjs/codama/devnet/instructions/closeRental.js.map +0 -1
  256. package/dist/cjs/codama/devnet/instructions/createContract.js.map +0 -1
  257. package/dist/cjs/codama/devnet/instructions/index.js.map +0 -1
  258. package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js +0 -152
  259. package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
  260. package/dist/cjs/codama/devnet/instructions/payRental.js.map +0 -1
  261. package/dist/cjs/codama/devnet/instructions/resetRental.js.map +0 -1
  262. package/dist/cjs/codama/devnet/programs/index.js.map +0 -1
  263. package/dist/cjs/codama/devnet/programs/srsly.js.map +0 -1
  264. package/dist/cjs/codama/devnet/shared/index.js.map +0 -1
  265. package/dist/cjs/codama/devnet/types/clockData.js.map +0 -1
  266. package/dist/cjs/codama/devnet/types/equality.js.map +0 -1
  267. package/dist/cjs/codama/devnet/types/execContext.js.map +0 -1
  268. package/dist/cjs/codama/devnet/types/index.js.map +0 -1
  269. package/dist/cjs/codama/devnet/types/paymentFrequency.js.map +0 -1
  270. package/dist/cjs/codama/devnet/types/serializableAccount.js.map +0 -1
  271. package/dist/cjs/codama/devnet/types/serializableInstruction.js.map +0 -1
  272. package/dist/cjs/codama/devnet/types/threadResponse.js.map +0 -1
  273. package/dist/cjs/codama/devnet/types/trigger.js.map +0 -1
  274. package/dist/cjs/codama/devnet/types/triggerContext.js.map +0 -1
  275. package/dist/cjs/network.js +0 -107
  276. package/dist/cjs/network.js.map +0 -1
  277. package/dist/esm/codama/devnet/accounts/contractState.js.map +0 -1
  278. package/dist/esm/codama/devnet/accounts/fleet.js +0 -64
  279. package/dist/esm/codama/devnet/accounts/fleet.js.map +0 -1
  280. package/dist/esm/codama/devnet/accounts/index.js.map +0 -1
  281. package/dist/esm/codama/devnet/accounts/rentalState.js.map +0 -1
  282. package/dist/esm/codama/devnet/accounts/thread.js.map +0 -1
  283. package/dist/esm/codama/devnet/errors/index.js.map +0 -1
  284. package/dist/esm/codama/devnet/errors/srsly.js.map +0 -1
  285. package/dist/esm/codama/devnet/index.js.map +0 -1
  286. package/dist/esm/codama/devnet/instructions/acceptRental.js.map +0 -1
  287. package/dist/esm/codama/devnet/instructions/cancelRental.js.map +0 -1
  288. package/dist/esm/codama/devnet/instructions/closeContract.js.map +0 -1
  289. package/dist/esm/codama/devnet/instructions/closeRental.js.map +0 -1
  290. package/dist/esm/codama/devnet/instructions/createContract.js.map +0 -1
  291. package/dist/esm/codama/devnet/instructions/index.js.map +0 -1
  292. package/dist/esm/codama/devnet/instructions/normalizeAdmin.js +0 -142
  293. package/dist/esm/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
  294. package/dist/esm/codama/devnet/instructions/payRental.js.map +0 -1
  295. package/dist/esm/codama/devnet/instructions/resetRental.js.map +0 -1
  296. package/dist/esm/codama/devnet/programs/index.js.map +0 -1
  297. package/dist/esm/codama/devnet/programs/srsly.js.map +0 -1
  298. package/dist/esm/codama/devnet/shared/index.js.map +0 -1
  299. package/dist/esm/codama/devnet/types/clockData.js.map +0 -1
  300. package/dist/esm/codama/devnet/types/equality.js.map +0 -1
  301. package/dist/esm/codama/devnet/types/execContext.js.map +0 -1
  302. package/dist/esm/codama/devnet/types/index.js.map +0 -1
  303. package/dist/esm/codama/devnet/types/paymentFrequency.js.map +0 -1
  304. package/dist/esm/codama/devnet/types/serializableAccount.js.map +0 -1
  305. package/dist/esm/codama/devnet/types/serializableInstruction.js.map +0 -1
  306. package/dist/esm/codama/devnet/types/threadResponse.js.map +0 -1
  307. package/dist/esm/codama/devnet/types/trigger.js.map +0 -1
  308. package/dist/esm/codama/devnet/types/triggerContext.js.map +0 -1
  309. package/dist/esm/network.js +0 -67
  310. package/dist/esm/network.js.map +0 -1
  311. package/dist/types/codama/devnet/accounts/contractState.d.ts.map +0 -1
  312. package/dist/types/codama/devnet/accounts/fleet.d.ts +0 -38
  313. package/dist/types/codama/devnet/accounts/fleet.d.ts.map +0 -1
  314. package/dist/types/codama/devnet/accounts/index.d.ts.map +0 -1
  315. package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +0 -1
  316. package/dist/types/codama/devnet/accounts/thread.d.ts.map +0 -1
  317. package/dist/types/codama/devnet/errors/index.d.ts.map +0 -1
  318. package/dist/types/codama/devnet/errors/srsly.d.ts.map +0 -1
  319. package/dist/types/codama/devnet/index.d.ts.map +0 -1
  320. package/dist/types/codama/devnet/instructions/acceptRental.d.ts +0 -128
  321. package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +0 -1
  322. package/dist/types/codama/devnet/instructions/cancelRental.d.ts.map +0 -1
  323. package/dist/types/codama/devnet/instructions/closeContract.d.ts +0 -96
  324. package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +0 -1
  325. package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +0 -1
  326. package/dist/types/codama/devnet/instructions/createContract.d.ts +0 -108
  327. package/dist/types/codama/devnet/instructions/createContract.d.ts.map +0 -1
  328. package/dist/types/codama/devnet/instructions/index.d.ts.map +0 -1
  329. package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts +0 -67
  330. package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts.map +0 -1
  331. package/dist/types/codama/devnet/instructions/payRental.d.ts.map +0 -1
  332. package/dist/types/codama/devnet/instructions/resetRental.d.ts.map +0 -1
  333. package/dist/types/codama/devnet/programs/index.d.ts.map +0 -1
  334. package/dist/types/codama/devnet/programs/srsly.d.ts.map +0 -1
  335. package/dist/types/codama/devnet/shared/index.d.ts.map +0 -1
  336. package/dist/types/codama/devnet/types/clockData.d.ts.map +0 -1
  337. package/dist/types/codama/devnet/types/equality.d.ts.map +0 -1
  338. package/dist/types/codama/devnet/types/execContext.d.ts.map +0 -1
  339. package/dist/types/codama/devnet/types/index.d.ts.map +0 -1
  340. package/dist/types/codama/devnet/types/paymentFrequency.d.ts.map +0 -1
  341. package/dist/types/codama/devnet/types/serializableAccount.d.ts.map +0 -1
  342. package/dist/types/codama/devnet/types/serializableInstruction.d.ts.map +0 -1
  343. package/dist/types/codama/devnet/types/threadResponse.d.ts.map +0 -1
  344. package/dist/types/codama/devnet/types/trigger.d.ts.map +0 -1
  345. package/dist/types/codama/devnet/types/triggerContext.d.ts.map +0 -1
  346. package/dist/types/network.d.ts +0 -58
  347. package/dist/types/network.d.ts.map +0 -1
  348. package/target/idl/srsly-mainnet.json +0 -3011
  349. package/target/types/srsly-mainnet.ts +0 -1
  350. /package/dist/cjs/codama/{devnet/accounts → accounts}/thread.js +0 -0
  351. /package/dist/cjs/codama/{devnet/errors → errors}/index.js +0 -0
  352. /package/dist/cjs/codama/{devnet/index.js → index.js} +0 -0
  353. /package/dist/cjs/codama/{devnet/programs → programs}/index.js +0 -0
  354. /package/dist/cjs/codama/{devnet/shared → shared}/index.js +0 -0
  355. /package/dist/cjs/codama/{devnet/types → types}/clockData.js +0 -0
  356. /package/dist/cjs/codama/{devnet/types → types}/equality.js +0 -0
  357. /package/dist/cjs/codama/{devnet/types → types}/execContext.js +0 -0
  358. /package/dist/cjs/codama/{devnet/types → types}/index.js +0 -0
  359. /package/dist/cjs/codama/{devnet/types → types}/paymentFrequency.js +0 -0
  360. /package/dist/cjs/codama/{devnet/types → types}/serializableAccount.js +0 -0
  361. /package/dist/cjs/codama/{devnet/types → types}/serializableInstruction.js +0 -0
  362. /package/dist/cjs/codama/{devnet/types → types}/threadResponse.js +0 -0
  363. /package/dist/cjs/codama/{devnet/types → types}/trigger.js +0 -0
  364. /package/dist/cjs/codama/{devnet/types → types}/triggerContext.js +0 -0
  365. /package/dist/esm/codama/{devnet/accounts → accounts}/thread.js +0 -0
  366. /package/dist/esm/codama/{devnet/errors → errors}/index.js +0 -0
  367. /package/dist/esm/codama/{devnet/index.js → index.js} +0 -0
  368. /package/dist/esm/codama/{devnet/programs → programs}/index.js +0 -0
  369. /package/dist/esm/codama/{devnet/shared → shared}/index.js +0 -0
  370. /package/dist/esm/codama/{devnet/types → types}/clockData.js +0 -0
  371. /package/dist/esm/codama/{devnet/types → types}/equality.js +0 -0
  372. /package/dist/esm/codama/{devnet/types → types}/execContext.js +0 -0
  373. /package/dist/esm/codama/{devnet/types → types}/index.js +0 -0
  374. /package/dist/esm/codama/{devnet/types → types}/paymentFrequency.js +0 -0
  375. /package/dist/esm/codama/{devnet/types → types}/serializableAccount.js +0 -0
  376. /package/dist/esm/codama/{devnet/types → types}/serializableInstruction.js +0 -0
  377. /package/dist/esm/codama/{devnet/types → types}/threadResponse.js +0 -0
  378. /package/dist/esm/codama/{devnet/types → types}/trigger.js +0 -0
  379. /package/dist/esm/codama/{devnet/types → types}/triggerContext.js +0 -0
  380. /package/dist/types/codama/{devnet/accounts → accounts}/thread.d.ts +0 -0
  381. /package/dist/types/codama/{devnet/errors → errors}/index.d.ts +0 -0
  382. /package/dist/types/codama/{devnet/index.d.ts → index.d.ts} +0 -0
  383. /package/dist/types/codama/{devnet/programs → programs}/index.d.ts +0 -0
  384. /package/dist/types/codama/{devnet/shared → shared}/index.d.ts +0 -0
  385. /package/dist/types/codama/{devnet/types → types}/clockData.d.ts +0 -0
  386. /package/dist/types/codama/{devnet/types → types}/equality.d.ts +0 -0
  387. /package/dist/types/codama/{devnet/types → types}/execContext.d.ts +0 -0
  388. /package/dist/types/codama/{devnet/types → types}/index.d.ts +0 -0
  389. /package/dist/types/codama/{devnet/types → types}/paymentFrequency.d.ts +0 -0
  390. /package/dist/types/codama/{devnet/types → types}/serializableAccount.d.ts +0 -0
  391. /package/dist/types/codama/{devnet/types → types}/serializableInstruction.d.ts +0 -0
  392. /package/dist/types/codama/{devnet/types → types}/threadResponse.d.ts +0 -0
  393. /package/dist/types/codama/{devnet/types → types}/trigger.d.ts +0 -0
  394. /package/dist/types/codama/{devnet/types → types}/triggerContext.d.ts +0 -0
  395. /package/target/types/{srsly-devnet.ts → srsly.ts} +0 -0
package/README.md CHANGED
@@ -4,307 +4,432 @@
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
5
5
  [![Solana](https://img.shields.io/badge/Solana-000?style=flat&logo=solana&logoColor=9945FF)](https://solana.com/)
6
6
 
7
- A TypeScript SDK for interacting with the SRSLY (Space Rental from SLY) Solana program - a decentralized rental system for Star Atlas.
7
+ A TypeScript SDK for building Solana instructions to interact with the SRSLY (Space Rental from SLY) program - a decentralized rental system for Star Atlas fleets.
8
8
 
9
- ## Installation
9
+ ## What This SDK Does
10
+
11
+ The SRSLY SDK is a focused instruction builder that helps you create Solana instructions for fleet rentals. It provides:
12
+
13
+ - ✅ **Instruction Building** - Creates properly formatted Solana instructions using @solana/kit
14
+ - ✅ **Account derivation and validation** - Automatically derives required accounts
15
+ - ✅ **Instruction data encoding** - Handles all the complex encoding for you
16
+ - ✅ **Type-safe parameter handling** - Full TypeScript support with validation
17
+ - ✅ **Duration helper functions** - `days()`, `weeks()`, `months()` for time calculations
18
+ - ✅ **Default Star Atlas Programs** - Support for mainnet, atlasnet, and holosim
19
+
20
+ **Current Status**: Instruction-only SDK using @solana/kit. Users handle transaction assembly and sending.
10
21
 
11
- ### NPM
22
+ ## Installation
12
23
 
13
24
  ```bash
25
+ # Install the SDK (includes @solana/kit as a dependency)
14
26
  npm install @wuwei-labs/srsly
15
27
  ```
16
28
 
17
- ### PNPM
29
+ The SDK uses @solana/kit internally and provides seamless conversion to @solana/web3.js format for browser wallet compatibility.
18
30
 
19
- ```bash
20
- pnpm add @wuwei-labs/srsly
31
+ ## Quick Start
32
+
33
+ ### Using with @solana/kit (Default)
34
+
35
+ ```typescript
36
+ import { createContract, setConfig, days } from '@wuwei-labs/srsly';
37
+
38
+ // 1. Configure SDK for your network
39
+ setConfig({
40
+ programs: 'atlasnet' // or 'mainnet', 'holosim'
41
+ });
42
+
43
+ // 2. Create an instruction (returns @solana/kit format by default)
44
+ const instruction = await createContract({
45
+ owner: signer, // Can be a signer object or string address
46
+ fleet: "FleetAddress123...", // String address
47
+ ownerProfile: "ProfileAddr...", // String address
48
+ rate: 1000000, // ATLAS tokens per payment period
49
+ durationMax: days(7), // 7 days using helper function
50
+ paymentsFreq: 'daily' // Payment frequency
51
+ });
52
+
53
+ // 3. Add instruction to your transaction and send
54
+ // (Use your preferred transaction building and sending method)
21
55
  ```
22
56
 
23
- ### Yarn
57
+ ### Using with @solana/web3.js (wallet-adapter)
24
58
 
25
- ```bash
26
- yarn add @wuwei-labs/srsly
59
+ ```typescript
60
+ import { createContract, setConfig, days } from '@wuwei-labs/srsly';
61
+ import { Transaction, PublicKey } from '@solana/web3.js';
62
+
63
+ // 1. Configure SDK for your network
64
+ setConfig({ programs: 'atlasnet' });
65
+
66
+ // 2. Create and convert to web3.js format
67
+ const web3jsInstruction = await createContract({
68
+ owner: wallet.publicKey.toString(), // String address
69
+ fleet: "FleetAddress123...", // String address
70
+ ownerProfile: "ProfileAddr...", // String address
71
+ rate: 1000000,
72
+ durationMax: days(7),
73
+ paymentsFreq: 'daily'
74
+ }).web3js(PublicKey); // Convert to web3.js format with PublicKey instances
75
+
76
+ // 3. Add to transaction and send
77
+ const transaction = new Transaction().add(web3jsInstruction);
78
+ const signature = await wallet.sendTransaction(transaction, connection);
27
79
  ```
28
80
 
29
- ## Quick Start
81
+ ## Core Features
82
+
83
+ ### Instruction Building & Format Conversion
84
+
85
+ The SDK creates @solana/kit compatible instructions with seamless web3.js conversion:
86
+
87
+ - **📦 Instruction-Only**: Focus on instruction building, users handle transaction assembly/sending
88
+ - **🔄 Format Conversion**: Built-in `.web3js(PublicKey)` method for wallet compatibility
89
+ - **🎯 String Addresses**: Simple string-based addressing for all inputs
90
+ - **⚡ Lightweight**: Uses @solana/kit internally with optional web3.js conversion
91
+
92
+ ### Web3.js Format Conversion
93
+
94
+ The SDK accepts string addresses as input and provides seamless conversion to @solana/web3.js format for browser wallet compatibility:
30
95
 
31
96
  ```typescript
32
- import { Connection, PublicKey } from '@solana/web3.js';
33
- import {
34
- createContract,
35
- acceptRental,
36
- setNetwork,
37
- ContractState,
38
- RentalState
39
- } from '@wuwei-labs/srsly';
97
+ import { createContract } from '@wuwei-labs/srsly';
98
+ import { Transaction, PublicKey } from '@solana/web3.js';
99
+
100
+ // Web3.js format with PublicKey instances
101
+ const web3jsInstruction = await createContract({
102
+ owner: "OwnerAddress123...", // String address input
103
+ fleet: "FleetAddress123...", // String address input
104
+ ownerProfile: "ProfileAddr...", // String address input
105
+ rate: 1000000,
106
+ durationMax: days(7),
107
+ paymentsFreq: 'daily'
108
+ }).web3js(PublicKey);
109
+
110
+ // Chain configuration with conversion
111
+ const configuredInstruction = await createContract({
112
+ owner: "OwnerAddress123...",
113
+ fleet: "FleetAddress123...",
114
+ ownerProfile: "ProfileAddr...",
115
+ rate: 1000000,
116
+ durationMax: days(7),
117
+ paymentsFreq: 'daily'
118
+ }).set({ programs: 'mainnet' })
119
+ .web3js(PublicKey);
120
+
121
+ // Use in transactions
122
+ const transaction = new Transaction().add(web3jsInstruction);
123
+ ```
124
+
125
+ **Key points:**
40
126
 
41
- // Set global network (optional - defaults to devnet)
42
- setNetwork('mainnet');
127
+ - SDK inputs are always **string addresses**
128
+ - `.web3js(PublicKey)` converts output to web3.js format with PublicKey instances
129
+ - Use when working with browser wallets (Phantom, Solflare, etc.)
43
130
 
44
- // Create a rental contract using global network setting (direct await)
45
- const contractInstruction = await createContract({
131
+ ### Duration Helper Functions
132
+
133
+ The SDK provides convenient helper functions for converting time units to seconds:
134
+
135
+ ```typescript
136
+ import { days, weeks, months, hours, minutes, duration } from '@wuwei-labs/srsly';
137
+
138
+ // Individual helper functions
139
+ const sevenDays = days(7); // 604800 seconds
140
+ const twoWeeks = weeks(2); // 1209600 seconds
141
+ const oneMonth = months(1); // 2678400 seconds (31 days)
142
+ const sixHours = hours(6); // 21600 seconds
143
+ const thirtyMinutes = minutes(30); // 1800 seconds
144
+
145
+ // Using in contract creation
146
+ const contract = await createContract({
46
147
  owner: wallet,
47
148
  fleet: fleetAddress,
48
149
  ownerProfile: profileAddress,
49
- rate: 1000000, // Rate in lamports
50
- durationMin: 86400, // 1 day in seconds
51
- durationMax: 604800, // 1 week in seconds
52
- paymentsFreq: 'daily',
53
- ownerKeyIndex: 0
150
+ rate: 1000000,
151
+ durationMax: weeks(2), // 2 weeks maximum
152
+ paymentsFreq: 'daily'
54
153
  });
55
154
 
56
- // Or override network for specific instruction
57
- const mainnetInstruction = await createContract(params).mainnet();
58
- const devnetInstruction = await createContract(params).devnet();
59
- ```
155
+ // Alternative: use the duration object
156
+ const anotherContract = await createContract({
157
+ owner: wallet,
158
+ fleet: fleetAddress,
159
+ ownerProfile: profileAddress,
160
+ rate: 500000,
161
+ durationMax: duration.months(3), // 3 months maximum
162
+ paymentsFreq: 'weekly'
163
+ });
60
164
 
61
- ## Core Features
165
+ // You can still use raw seconds if preferred
166
+ const rawContract = await createContract({
167
+ owner: wallet,
168
+ fleet: fleetAddress,
169
+ ownerProfile: profileAddress,
170
+ rate: 750000,
171
+ durationMax: 86400, // Raw 86400 seconds (1 day)
172
+ paymentsFreq: 'daily'
173
+ });
174
+ ```
62
175
 
63
176
  ### Contract Management
64
177
 
65
- Create and manage rental contracts for Star Atlas:
66
-
67
178
  ```typescript
68
- import { createContract, closeContract } from '@wuwei-labs/srsly';
179
+ import { createContract, closeContract, days, months } from '@wuwei-labs/srsly';
69
180
 
70
- // Create a new rental contract with network selection
181
+ // Create rental contract instruction
71
182
  const createIx = await createContract({
72
183
  owner: wallet,
73
184
  fleet: fleetAddress,
74
185
  ownerProfile: profileAddress,
75
- rate: 5000000, // 0.005 SOL per day
76
- durationMin: 86400, // Minimum 1 day
77
- durationMax: 2592000, // Maximum 30 days
78
- paymentsFreq: 'daily',
79
- ownerKeyIndex: 0
80
- }).mainnet(); // Use mainnet for this instruction
81
-
82
- // Close an existing contract using global network setting (direct await)
186
+ rate: 5000000,
187
+ durationMax: months(1), // 30 days using helper function
188
+ paymentsFreq: 'daily'
189
+ });
190
+
191
+ // Close contract instruction
83
192
  const closeIx = await closeContract({
84
193
  owner: wallet,
85
194
  fleet: fleetAddress,
86
- contract: contractAddress,
87
- faction: 'mud',
88
- ownerProfile: profileAddress
195
+ contract: contractAddress
89
196
  });
90
197
  ```
91
198
 
92
199
  ### Rental Operations
93
200
 
94
- Handle rental lifecycle operations:
95
-
96
201
  ```typescript
97
- import {
98
- acceptRental,
99
- cancelRental,
100
- closeRental,
101
- resetRental
102
- } from '@wuwei-labs/srsly';
202
+ import { acceptRental, cancelRental, closeRental, resetRental } from '@wuwei-labs/srsly';
203
+ import { Transaction, PublicKey } from '@solana/web3.js';
103
204
 
104
- // Accept a rental offer on devnet
205
+ // Accept rental offer instruction (all addresses are strings)
105
206
  const acceptIx = await acceptRental({
106
- borrower: borrowerWallet,
107
- borrowerProfile: borrowerProfileAddress,
108
- contract: contractAddress,
109
- borrowerFaction: 'oni',
110
- duration: 86400,
111
- amount: 1000000
112
- }).devnet();
207
+ borrower: borrowerWallet, // signer object or string address
208
+ borrowerProfile: borrowerProfileAddress, // string address
209
+ borrowerFaction: 'mud', // or 1, 2, 3
210
+ fleet: fleetAddress, // string address
211
+ contract: contractAddress, // string address
212
+ rate: 100, // ATLAS per payment period (based on contract's payment frequency)
213
+ duration: 86400 // Duration in seconds (must be between contract's min/max)
214
+ });
113
215
 
114
- // Cancel an active rental using current network setting (direct await)
216
+ // Cancel active rental instruction
115
217
  const cancelIx = await cancelRental({
116
218
  borrower: borrowerWallet,
117
- rental: rentalAddress
219
+ contract: contractAddress,
220
+ rentalState: rentalStateAddress
118
221
  });
119
222
 
120
- // Close a completed rental on mainnet
223
+ // Close completed rental instruction
121
224
  const closeIx = await closeRental({
122
225
  borrower: borrowerWallet,
123
- rental: rentalAddress
124
- }).mainnet();
226
+ contract: contractAddress,
227
+ rentalState: rentalStateAddress,
228
+ ownerTokenAccount: ownerTokenAccountAddress
229
+ });
125
230
 
126
- // Reset rental state (admin only) with specific network
231
+ // Reset rental instruction
127
232
  const resetIx = await resetRental({
128
- fleet: fleetAddress,
233
+ borrower: borrowerWallet,
129
234
  contract: contractAddress,
130
- rentalState: rentalStateAddress,
131
- faction: 'mud',
132
- ownerProfile: ownerProfileAddress
133
- }).network('mainnet');
235
+ rentalState: rentalStateAddress
236
+ });
237
+
238
+ // Convert any instruction to web3.js format for wallet compatibility
239
+ const web3jsAcceptIx = await acceptRental(params).web3js(PublicKey);
240
+ const web3jsCancelIx = await cancelRental(params).web3js(PublicKey);
241
+
242
+ // Use in web3.js transactions
243
+ const transaction = new Transaction()
244
+ .add(web3jsAcceptIx)
245
+ .add(web3jsCancelIx);
134
246
  ```
135
247
 
136
- ### Account State Management
248
+ ## Configuration
137
249
 
138
- Fetch and decode account states:
250
+ The SDK provides simple configuration for different networks:
139
251
 
140
252
  ```typescript
141
- import { ContractState, RentalState } from '@wuwei-labs/srsly';
142
-
143
- // Fetch contract state
144
- const contractAccount = await connection.getAccountInfo(contractPublicKey);
145
- const contractState = ContractState.fromAccountInfo(contractAccount)[0];
253
+ import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
254
+
255
+ // Set network configuration
256
+ setConfig({
257
+ programs: 'atlasnet', // 'mainnet' | 'atlasnet' | 'holosim'
258
+ srslyProgramAddress: 'custom-program-address...', // Optional override
259
+ profileFactionProgramAddress: 'custom-profile-program...', // Optional override
260
+ gameId: 'custom-game-id...', // Optional override
261
+ atlasMint: 'custom-atlas-mint...' // Optional override
262
+ });
146
263
 
147
- console.log('Contract rate:', contractState.rate.toString());
148
- console.log('Duration range:', contractState.durationMin.toString(), '-', contractState.durationMax.toString());
264
+ // Simple network configurations
265
+ setConfig({ programs: 'mainnet' });
266
+ setConfig({ programs: 'atlasnet' });
267
+ setConfig({ programs: 'holosim' });
149
268
 
150
- // Fetch rental state
151
- const rentalAccount = await connection.getAccountInfo(rentalPublicKey);
152
- const rentalState = RentalState.fromAccountInfo(rentalAccount)[0];
269
+ // Check current configuration
270
+ console.log(getConfig());
153
271
 
154
- console.log('Rental status:', rentalState.status);
155
- console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
272
+ // Reset to defaults
273
+ clearConfig();
156
274
  ```
157
275
 
158
- ## Program Information
159
-
160
- - **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
161
- - **Network**: Solana Mainnet or Atlasnet
162
- - **Built with**: Anchor Framework
163
-
164
- ## Payment Frequencies
165
-
166
- The SDK supports multiple payment frequencies:
167
-
168
- - `daily` - Daily payments
169
- - `weekly` - Weekly payments
170
- - `monthly` - Monthly payments
276
+ ### Configuration Options
171
277
 
172
- ## Error Handling
278
+ | Option | Type | Description | Default |
279
+ |--------|------|-------------|---------|
280
+ | `programs` | `'mainnet' \| 'atlasnet' \| 'holosim'` | Predefined program address set | `'atlasnet'` |
281
+ | `srslyProgramAddress` | `string` | SRSLY program address override | From program set |
282
+ | `profileFactionProgramAddress` | `string` | Profile Faction program override | From program set |
283
+ | `gameId` | `string` | SAGE game ID override | From program set |
284
+ | `atlasMint` | `string` | ATLAS token mint override | From program set |
173
285
 
174
- The SDK includes comprehensive error types:
286
+ ## Duration and Payment Frequency
175
287
 
176
- ```typescript
177
- import { SrslyError } from '@wuwei-labs/srsly';
288
+ **Important**: All durations must be aligned with the payment frequency to ensure proper payment calculations.
178
289
 
179
- try {
180
- const instruction = await createContract({...});
181
- } catch (error) {
182
- if (error instanceof SrslyError) {
183
- console.error('SRSLY Error:', error.message);
184
- console.error('Error code:', error.code);
185
- }
186
- }
187
- ```
290
+ ### Duration Rules
188
291
 
189
- ## Network Configuration
292
+ 1. **Duration Units**: All durations are specified in seconds
293
+ 2. **Alignment Requirement**: Durations must be multiples of the payment frequency interval
294
+ 3. **Validation**: The SDK automatically validates duration alignment and throws an error if invalid
190
295
 
191
- The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can configure networks globally or per instruction.
296
+ ### Payment Frequency Intervals
192
297
 
193
- ### Global Network Configuration
298
+ | Frequency | Interval | Example Valid Durations |
299
+ |-----------|----------|------------------------|
300
+ | `hourly` | 3,600 seconds (1 hour) | 3,600 (1h), 7,200 (2h), 86,400 (24h) |
301
+ | `daily` | 86,400 seconds (1 day) | 86,400 (1d), 172,800 (2d), 604,800 (7d) |
302
+ | `weekly` | 604,800 seconds (1 week) | 604,800 (1w), 1,209,600 (2w), 2,419,200 (4w) |
303
+ | `monthly` | 2,678,400 seconds (31 days) | 2,678,400 (1m), 5,356,800 (2m) |
194
304
 
195
- Set the default network for all SDK operations:
305
+ ### Examples
196
306
 
197
307
  ```typescript
198
- import { setNetwork, getNetwork } from '@wuwei-labs/srsly';
199
-
200
- // Set global network (defaults to 'devnet')
201
- setNetwork('mainnet');
308
+ // Valid: 7 day max duration with daily payments
309
+ await createContract({
310
+ durationMax: 604800, // 7 days (604800 % 86400 = 0)
311
+ paymentsFreq: 'daily' // Min duration automatically set to 1 day
312
+ });
202
313
 
203
- // Check current network
204
- console.log(getNetwork()); // 'mainnet'
314
+ // Invalid: 3.5 day max duration with daily payments
315
+ await createContract({
316
+ durationMax: 302400, // 3.5 days (302400 % 86400 = 43200) ✗
317
+ paymentsFreq: 'daily'
318
+ });
319
+ // Error: Duration (302400 seconds) must be a multiple of daily frequency (86400 seconds)
205
320
 
206
- // All instructions will now use mainnet by default (direct await)
207
- const ix = await createContract(params);
321
+ // Valid: Hourly payments with hour-aligned max duration
322
+ await createContract({
323
+ durationMax: 172800, // 48 hours (172800 % 3600 = 0) ✓
324
+ paymentsFreq: 'hourly' // Min duration automatically set to 1 hour
325
+ });
208
326
  ```
209
327
 
210
- ### Per-Instruction Network Selection
211
-
212
- Override the network for specific instructions using the fluent interface:
328
+ ### Rate Calculation
213
329
 
214
- ```typescript
215
- import { createContract } from '@wuwei-labs/srsly';
330
+ The `rate` parameter in contracts represents ATLAS tokens per payment period:
331
+ - For `daily` frequency: rate is ATLAS per day
332
+ - For `weekly` frequency: rate is ATLAS per week
333
+ - For `hourly` frequency: rate is ATLAS per hour
216
334
 
217
- // Use mainnet for this specific instruction
218
- const mainnetIx = await createContract(params).mainnet();
335
+ ## Payment System
219
336
 
220
- // Use devnet for this specific instruction
221
- const devnetIx = await createContract(params).devnet();
337
+ SRSLY implements an escrow-based payment system:
222
338
 
223
- // Use a specific network
224
- const specificIx = await createContract(params).network('mainnet');
339
+ 1. **Escrow**: Borrower deposits full rental amount upfront
340
+ 2. **Periodic Payments**: Automated payments based on frequency (daily/weekly/monthly)
341
+ 3. **Fees**: 10% platform fee, optional 10% referral sharing
342
+ 4. **Refunds**: Pro-rata refunds for early cancellation (24-hour minimum)
225
343
 
226
- // Use global network setting (direct await - no .build() needed!)
227
- const globalIx = await createContract(params);
344
+ ```typescript
345
+ // Payment calculation example
346
+ const rate = 1000; // ATLAS per payment period
347
+ const paymentFrequency = 'daily'; // Payment every 86400 seconds
348
+ const duration = days(7); // 7 days using helper function
349
+ const paymentPeriods = duration / days(1); // 7 periods
350
+ const totalAmount = rate * paymentPeriods * ATLAS_TO_STARDUST; // Total in stardust
228
351
  ```
229
352
 
230
- ### Network Selection Methods
353
+ ## Program Sets Reference
231
354
 
232
- All SDK functions support these usage patterns:
355
+ The SDK includes predefined program address sets for different networks:
233
356
 
234
- **Direct await (uses global network):**
235
- ```typescript
236
- await createContract(params);
237
- await acceptRental(params);
238
- ```
357
+ | Network | SAGE Program | Game ID | ATLAS Mint |
358
+ |---------|--------------|---------|------------|
359
+ | `mainnet` | `SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE` | `GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr` | `ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx` |
360
+ | `atlasnet` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
361
+ | `holosim` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
239
362
 
240
- **Network-specific methods:**
241
- - `.mainnet()` - Build with mainnet configuration
242
- - `.devnet()` - Build with devnet configuration
243
- - `.network(network)` - Build with specified network
244
- - `.build()` - Build with current global network setting (explicit)
363
+ ## Types and Constants
245
364
 
246
365
  ```typescript
247
- // Examples across different functions
248
- await createContract(params).mainnet();
249
- await acceptRental(params).devnet();
250
- await closeContract(params).network('mainnet');
251
- await resetRental(params); // Direct await uses global network
252
- ```
366
+ import type {
367
+ ContractState,
368
+ RentalState,
369
+ ConfigOptions,
370
+ PaymentFrequency
371
+ } from '@wuwei-labs/srsly';
253
372
 
254
- ## IDL and Types
373
+ import {
374
+ ATLAS_TO_STARDUST,
375
+ FACTION_MAPPING,
376
+ days,
377
+ weeks,
378
+ months,
379
+ duration
380
+ } from '@wuwei-labs/srsly';
255
381
 
256
- ### Network-Specific IDLs
382
+ // Conversion rate: 1 ATLAS = 100,000,000 stardust
383
+ console.log(ATLAS_TO_STARDUST); // 100_000_000
257
384
 
258
- The SDK provides network-specific IDLs since program configurations differ between networks:
385
+ // Faction mappings
386
+ console.log(FACTION_MAPPING[1]); // 'mud'
387
+ console.log(FACTION_MAPPING[2]); // 'oni'
388
+ console.log(FACTION_MAPPING[3]); // 'ustur'
259
389
 
260
- ```typescript
261
- // Mainnet IDL
262
- import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
390
+ // Duration helper functions
391
+ console.log(days(7)); // 604800 (7 days in seconds)
392
+ console.log(weeks(2)); // 1209600 (2 weeks in seconds)
393
+ console.log(months(1)); // 2678400 (1 month in seconds)
394
+ console.log(duration.hours(12)); // 43200 (12 hours in seconds)
395
+ ```
263
396
 
264
- // Devnet IDL
265
- import devnetIdl from '@wuwei-labs/srsly/idl/devnet';
397
+ ## IDL and Program Information
266
398
 
267
- // Use with Anchor
268
- import { Program } from '@coral-xyz/anchor';
269
- const program = new Program(mainnetIdl, provider);
399
+ ```typescript
400
+ // Access program IDL
401
+ import idl from '@wuwei-labs/srsly/idl';
270
402
  ```
271
403
 
272
- ### Network-Specific Types
273
-
274
- Import TypeScript types that match your target network:
404
+ ## Error Handling
275
405
 
276
406
  ```typescript
277
- import type {
278
- ContractState,
279
- RentalState,
280
- PaymentFrequency,
281
- ClockData,
282
- ThreadResponse
283
- } from '@wuwei-labs/srsly';
407
+ import { SrslyError } from '@wuwei-labs/srsly';
284
408
 
285
- // Import network-specific Anchor types
286
- import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
287
- import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
409
+ try {
410
+ const instruction = await createContract(params);
411
+ // Add to transaction and send...
412
+ } catch (error) {
413
+ if (error instanceof SrslyError) {
414
+ console.error('SRSLY SDK Error:', error.message, error.code);
415
+ } else {
416
+ console.error('Other Error:', error);
417
+ }
418
+ }
288
419
  ```
289
420
 
290
- ### Building Network-Specific Assets
421
+ ## Package Structure
291
422
 
292
- To generate IDLs and types for different networks:
423
+ The SDK provides optimized builds for different environments:
293
424
 
294
- ```bash
295
- # Generate mainnet IDL and types
296
- pnpm run generate:mainnet
425
+ - **CommonJS**: `./dist/cjs/` (Node.js, webpack)
426
+ - **ESM**: `./dist/esm/` (Modern ES modules)
427
+ - **Types**: `./dist/types/` (TypeScript definitions)
428
+ - **Codama**: `./dist/*/codama/` (Generated Solana program interfaces)
429
+ - **IDL**: `./target/idl/srsly.json` (Anchor IDL)
430
+ - **Types**: `./target/types/srsly.ts` (Generated types)
297
431
 
298
- # Generate devnet IDL and types
299
- pnpm run generate:devnet
300
- ```
301
-
302
- ## Documentation
432
+ ## Links
303
433
 
434
+ - **NPM Package**: [@wuwei-labs/srsly](https://www.npmjs.com/package/@wuwei-labs/srsly)
304
435
  - **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
305
-
306
- ## Related Projects
307
-
308
- - **Star Atlas**: The metaverse gaming ecosystem
309
- - **Solana**: The blockchain platform powering SRSLY
310
- - **Anchor**: The framework used to build the SRSLY program