@wuwei-labs/srsly 2.0.0-beta.4 → 2.0.0-beta.6

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 (372) hide show
  1. package/README.md +443 -73
  2. package/dist/cjs/codama/devnet/accounts/contractState.js +2 -7
  3. package/dist/cjs/codama/devnet/accounts/contractState.js.map +1 -1
  4. package/dist/cjs/codama/devnet/accounts/rentalState.js +3 -1
  5. package/dist/cjs/codama/devnet/accounts/rentalState.js.map +1 -1
  6. package/dist/cjs/codama/devnet/constants.js +32 -0
  7. package/dist/cjs/codama/devnet/constants.js.map +1 -0
  8. package/dist/cjs/codama/devnet/errors/srsly.js +4 -1
  9. package/dist/cjs/codama/devnet/errors/srsly.js.map +1 -1
  10. package/dist/cjs/codama/devnet/instructions/acceptRental.js +17 -23
  11. package/dist/cjs/codama/devnet/instructions/acceptRental.js.map +1 -1
  12. package/dist/cjs/codama/devnet/instructions/closeContract.js +28 -1
  13. package/dist/cjs/codama/devnet/instructions/closeContract.js.map +1 -1
  14. package/dist/cjs/codama/devnet/instructions/closeRental.js +28 -1
  15. package/dist/cjs/codama/devnet/instructions/closeRental.js.map +1 -1
  16. package/dist/cjs/codama/devnet/instructions/index.js +0 -1
  17. package/dist/cjs/codama/devnet/instructions/index.js.map +1 -1
  18. package/dist/cjs/codama/devnet/instructions/payRental.js +45 -1
  19. package/dist/cjs/codama/devnet/instructions/payRental.js.map +1 -1
  20. package/dist/cjs/codama/devnet/programs/srsly.js +2 -6
  21. package/dist/cjs/codama/devnet/programs/srsly.js.map +1 -1
  22. package/dist/cjs/codama/devnet/types/index.js +0 -1
  23. package/dist/cjs/codama/devnet/types/index.js.map +1 -1
  24. package/dist/cjs/codama/mainnet/accounts/contractState.js +2 -7
  25. package/dist/cjs/codama/mainnet/accounts/contractState.js.map +1 -1
  26. package/dist/cjs/codama/mainnet/accounts/rentalState.js +3 -1
  27. package/dist/cjs/codama/mainnet/accounts/rentalState.js.map +1 -1
  28. package/dist/cjs/codama/mainnet/constants.js +32 -0
  29. package/dist/cjs/codama/mainnet/constants.js.map +1 -0
  30. package/dist/cjs/codama/mainnet/errors/srsly.js +4 -1
  31. package/dist/cjs/codama/mainnet/errors/srsly.js.map +1 -1
  32. package/dist/cjs/codama/mainnet/instructions/acceptRental.js +17 -23
  33. package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +1 -1
  34. package/dist/cjs/codama/mainnet/instructions/closeContract.js +28 -1
  35. package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +1 -1
  36. package/dist/cjs/codama/mainnet/instructions/closeRental.js +28 -1
  37. package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +1 -1
  38. package/dist/cjs/codama/mainnet/instructions/index.js +0 -1
  39. package/dist/cjs/codama/mainnet/instructions/index.js.map +1 -1
  40. package/dist/cjs/codama/mainnet/instructions/payRental.js +45 -1
  41. package/dist/cjs/codama/mainnet/instructions/payRental.js.map +1 -1
  42. package/dist/cjs/codama/mainnet/programs/srsly.js +2 -6
  43. package/dist/cjs/codama/mainnet/programs/srsly.js.map +1 -1
  44. package/dist/cjs/codama/mainnet/types/index.js +0 -1
  45. package/dist/cjs/codama/mainnet/types/index.js.map +1 -1
  46. package/dist/cjs/contract/close.js +51 -19
  47. package/dist/cjs/contract/close.js.map +1 -1
  48. package/dist/cjs/contract/create.js +31 -19
  49. package/dist/cjs/contract/create.js.map +1 -1
  50. package/dist/cjs/index.js +4 -2
  51. package/dist/cjs/index.js.map +1 -1
  52. package/dist/cjs/rental/accept.js +59 -33
  53. package/dist/cjs/rental/accept.js.map +1 -1
  54. package/dist/cjs/rental/cancel.js +30 -24
  55. package/dist/cjs/rental/cancel.js.map +1 -1
  56. package/dist/cjs/rental/close.js +31 -25
  57. package/dist/cjs/rental/close.js.map +1 -1
  58. package/dist/cjs/rental/reset.js +40 -38
  59. package/dist/cjs/rental/reset.js.map +1 -1
  60. package/dist/cjs/utils/config.js +204 -0
  61. package/dist/cjs/utils/config.js.map +1 -0
  62. package/dist/cjs/utils/constants.js +78 -13
  63. package/dist/cjs/utils/constants.js.map +1 -1
  64. package/dist/cjs/utils/index.js +1 -0
  65. package/dist/cjs/utils/index.js.map +1 -1
  66. package/dist/cjs/utils/profiles.js +38 -18
  67. package/dist/cjs/utils/profiles.js.map +1 -1
  68. package/package.json +4 -2
  69. package/target/idl/srsly-devnet.json +649 -391
  70. package/target/idl/srsly-mainnet.json +493 -229
  71. package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js +0 -152
  72. package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
  73. package/dist/cjs/codama/devnet/types/paymentFrequency.js +0 -34
  74. package/dist/cjs/codama/devnet/types/paymentFrequency.js.map +0 -1
  75. package/dist/cjs/codama/mainnet/instructions/normalizeAdmin.js +0 -152
  76. package/dist/cjs/codama/mainnet/instructions/normalizeAdmin.js.map +0 -1
  77. package/dist/cjs/codama/mainnet/types/paymentFrequency.js +0 -32
  78. package/dist/cjs/codama/mainnet/types/paymentFrequency.js.map +0 -1
  79. package/dist/cjs/network.js +0 -107
  80. package/dist/cjs/network.js.map +0 -1
  81. package/dist/esm/codama/devnet/accounts/contractState.js +0 -79
  82. package/dist/esm/codama/devnet/accounts/contractState.js.map +0 -1
  83. package/dist/esm/codama/devnet/accounts/fleet.js +0 -64
  84. package/dist/esm/codama/devnet/accounts/fleet.js.map +0 -1
  85. package/dist/esm/codama/devnet/accounts/index.js +0 -12
  86. package/dist/esm/codama/devnet/accounts/index.js.map +0 -1
  87. package/dist/esm/codama/devnet/accounts/rentalState.js +0 -72
  88. package/dist/esm/codama/devnet/accounts/rentalState.js.map +0 -1
  89. package/dist/esm/codama/devnet/accounts/thread.js +0 -77
  90. package/dist/esm/codama/devnet/accounts/thread.js.map +0 -1
  91. package/dist/esm/codama/devnet/errors/index.js +0 -9
  92. package/dist/esm/codama/devnet/errors/index.js.map +0 -1
  93. package/dist/esm/codama/devnet/errors/srsly.js +0 -66
  94. package/dist/esm/codama/devnet/errors/srsly.js.map +0 -1
  95. package/dist/esm/codama/devnet/index.js +0 -13
  96. package/dist/esm/codama/devnet/index.js.map +0 -1
  97. package/dist/esm/codama/devnet/instructions/acceptRental.js +0 -353
  98. package/dist/esm/codama/devnet/instructions/acceptRental.js.map +0 -1
  99. package/dist/esm/codama/devnet/instructions/cancelRental.js +0 -215
  100. package/dist/esm/codama/devnet/instructions/cancelRental.js.map +0 -1
  101. package/dist/esm/codama/devnet/instructions/closeContract.js +0 -209
  102. package/dist/esm/codama/devnet/instructions/closeContract.js.map +0 -1
  103. package/dist/esm/codama/devnet/instructions/closeRental.js +0 -223
  104. package/dist/esm/codama/devnet/instructions/closeRental.js.map +0 -1
  105. package/dist/esm/codama/devnet/instructions/createContract.js +0 -251
  106. package/dist/esm/codama/devnet/instructions/createContract.js.map +0 -1
  107. package/dist/esm/codama/devnet/instructions/index.js +0 -16
  108. package/dist/esm/codama/devnet/instructions/index.js.map +0 -1
  109. package/dist/esm/codama/devnet/instructions/normalizeAdmin.js +0 -142
  110. package/dist/esm/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
  111. package/dist/esm/codama/devnet/instructions/payRental.js +0 -226
  112. package/dist/esm/codama/devnet/instructions/payRental.js.map +0 -1
  113. package/dist/esm/codama/devnet/instructions/resetRental.js +0 -145
  114. package/dist/esm/codama/devnet/instructions/resetRental.js.map +0 -1
  115. package/dist/esm/codama/devnet/programs/index.js +0 -9
  116. package/dist/esm/codama/devnet/programs/index.js.map +0 -1
  117. package/dist/esm/codama/devnet/programs/srsly.js +0 -72
  118. package/dist/esm/codama/devnet/programs/srsly.js.map +0 -1
  119. package/dist/esm/codama/devnet/shared/index.js +0 -87
  120. package/dist/esm/codama/devnet/shared/index.js.map +0 -1
  121. package/dist/esm/codama/devnet/types/clockData.js +0 -26
  122. package/dist/esm/codama/devnet/types/clockData.js.map +0 -1
  123. package/dist/esm/codama/devnet/types/equality.js +0 -24
  124. package/dist/esm/codama/devnet/types/equality.js.map +0 -1
  125. package/dist/esm/codama/devnet/types/execContext.js +0 -33
  126. package/dist/esm/codama/devnet/types/execContext.js.map +0 -1
  127. package/dist/esm/codama/devnet/types/index.js +0 -17
  128. package/dist/esm/codama/devnet/types/index.js.map +0 -1
  129. package/dist/esm/codama/devnet/types/paymentFrequency.js +0 -28
  130. package/dist/esm/codama/devnet/types/paymentFrequency.js.map +0 -1
  131. package/dist/esm/codama/devnet/types/serializableAccount.js +0 -26
  132. package/dist/esm/codama/devnet/types/serializableAccount.js.map +0 -1
  133. package/dist/esm/codama/devnet/types/serializableInstruction.js +0 -27
  134. package/dist/esm/codama/devnet/types/serializableInstruction.js.map +0 -1
  135. package/dist/esm/codama/devnet/types/threadResponse.js +0 -33
  136. package/dist/esm/codama/devnet/types/threadResponse.js.map +0 -1
  137. package/dist/esm/codama/devnet/types/trigger.js +0 -83
  138. package/dist/esm/codama/devnet/types/trigger.js.map +0 -1
  139. package/dist/esm/codama/devnet/types/triggerContext.js +0 -42
  140. package/dist/esm/codama/devnet/types/triggerContext.js.map +0 -1
  141. package/dist/esm/codama/mainnet/accounts/contractState.js +0 -79
  142. package/dist/esm/codama/mainnet/accounts/contractState.js.map +0 -1
  143. package/dist/esm/codama/mainnet/accounts/fleet.js +0 -64
  144. package/dist/esm/codama/mainnet/accounts/fleet.js.map +0 -1
  145. package/dist/esm/codama/mainnet/accounts/index.js +0 -12
  146. package/dist/esm/codama/mainnet/accounts/index.js.map +0 -1
  147. package/dist/esm/codama/mainnet/accounts/rentalState.js +0 -72
  148. package/dist/esm/codama/mainnet/accounts/rentalState.js.map +0 -1
  149. package/dist/esm/codama/mainnet/accounts/thread.js +0 -77
  150. package/dist/esm/codama/mainnet/accounts/thread.js.map +0 -1
  151. package/dist/esm/codama/mainnet/errors/index.js +0 -9
  152. package/dist/esm/codama/mainnet/errors/index.js.map +0 -1
  153. package/dist/esm/codama/mainnet/errors/srsly.js +0 -66
  154. package/dist/esm/codama/mainnet/errors/srsly.js.map +0 -1
  155. package/dist/esm/codama/mainnet/index.js +0 -13
  156. package/dist/esm/codama/mainnet/index.js.map +0 -1
  157. package/dist/esm/codama/mainnet/instructions/acceptRental.js +0 -353
  158. package/dist/esm/codama/mainnet/instructions/acceptRental.js.map +0 -1
  159. package/dist/esm/codama/mainnet/instructions/cancelRental.js +0 -215
  160. package/dist/esm/codama/mainnet/instructions/cancelRental.js.map +0 -1
  161. package/dist/esm/codama/mainnet/instructions/closeContract.js +0 -209
  162. package/dist/esm/codama/mainnet/instructions/closeContract.js.map +0 -1
  163. package/dist/esm/codama/mainnet/instructions/closeRental.js +0 -223
  164. package/dist/esm/codama/mainnet/instructions/closeRental.js.map +0 -1
  165. package/dist/esm/codama/mainnet/instructions/createContract.js +0 -251
  166. package/dist/esm/codama/mainnet/instructions/createContract.js.map +0 -1
  167. package/dist/esm/codama/mainnet/instructions/index.js +0 -16
  168. package/dist/esm/codama/mainnet/instructions/index.js.map +0 -1
  169. package/dist/esm/codama/mainnet/instructions/normalizeAdmin.js +0 -142
  170. package/dist/esm/codama/mainnet/instructions/normalizeAdmin.js.map +0 -1
  171. package/dist/esm/codama/mainnet/instructions/payRental.js +0 -226
  172. package/dist/esm/codama/mainnet/instructions/payRental.js.map +0 -1
  173. package/dist/esm/codama/mainnet/instructions/resetRental.js +0 -145
  174. package/dist/esm/codama/mainnet/instructions/resetRental.js.map +0 -1
  175. package/dist/esm/codama/mainnet/programs/index.js +0 -9
  176. package/dist/esm/codama/mainnet/programs/index.js.map +0 -1
  177. package/dist/esm/codama/mainnet/programs/srsly.js +0 -72
  178. package/dist/esm/codama/mainnet/programs/srsly.js.map +0 -1
  179. package/dist/esm/codama/mainnet/shared/index.js +0 -87
  180. package/dist/esm/codama/mainnet/shared/index.js.map +0 -1
  181. package/dist/esm/codama/mainnet/types/clockData.js +0 -26
  182. package/dist/esm/codama/mainnet/types/clockData.js.map +0 -1
  183. package/dist/esm/codama/mainnet/types/equality.js +0 -24
  184. package/dist/esm/codama/mainnet/types/equality.js.map +0 -1
  185. package/dist/esm/codama/mainnet/types/execContext.js +0 -33
  186. package/dist/esm/codama/mainnet/types/execContext.js.map +0 -1
  187. package/dist/esm/codama/mainnet/types/index.js +0 -17
  188. package/dist/esm/codama/mainnet/types/index.js.map +0 -1
  189. package/dist/esm/codama/mainnet/types/paymentFrequency.js +0 -26
  190. package/dist/esm/codama/mainnet/types/paymentFrequency.js.map +0 -1
  191. package/dist/esm/codama/mainnet/types/serializableAccount.js +0 -26
  192. package/dist/esm/codama/mainnet/types/serializableAccount.js.map +0 -1
  193. package/dist/esm/codama/mainnet/types/serializableInstruction.js +0 -27
  194. package/dist/esm/codama/mainnet/types/serializableInstruction.js.map +0 -1
  195. package/dist/esm/codama/mainnet/types/threadResponse.js +0 -33
  196. package/dist/esm/codama/mainnet/types/threadResponse.js.map +0 -1
  197. package/dist/esm/codama/mainnet/types/trigger.js +0 -83
  198. package/dist/esm/codama/mainnet/types/trigger.js.map +0 -1
  199. package/dist/esm/codama/mainnet/types/triggerContext.js +0 -42
  200. package/dist/esm/codama/mainnet/types/triggerContext.js.map +0 -1
  201. package/dist/esm/contract/close.js +0 -62
  202. package/dist/esm/contract/close.js.map +0 -1
  203. package/dist/esm/contract/create.js +0 -54
  204. package/dist/esm/contract/create.js.map +0 -1
  205. package/dist/esm/contract/index.js +0 -3
  206. package/dist/esm/contract/index.js.map +0 -1
  207. package/dist/esm/index.js +0 -7
  208. package/dist/esm/index.js.map +0 -1
  209. package/dist/esm/network.js +0 -67
  210. package/dist/esm/network.js.map +0 -1
  211. package/dist/esm/rental/accept.js +0 -60
  212. package/dist/esm/rental/accept.js.map +0 -1
  213. package/dist/esm/rental/cancel.js +0 -44
  214. package/dist/esm/rental/cancel.js.map +0 -1
  215. package/dist/esm/rental/close.js +0 -46
  216. package/dist/esm/rental/close.js.map +0 -1
  217. package/dist/esm/rental/index.js +0 -5
  218. package/dist/esm/rental/index.js.map +0 -1
  219. package/dist/esm/rental/reset.js +0 -63
  220. package/dist/esm/rental/reset.js.map +0 -1
  221. package/dist/esm/utils/constants.js +0 -42
  222. package/dist/esm/utils/constants.js.map +0 -1
  223. package/dist/esm/utils/index.js +0 -3
  224. package/dist/esm/utils/index.js.map +0 -1
  225. package/dist/esm/utils/profiles.js +0 -132
  226. package/dist/esm/utils/profiles.js.map +0 -1
  227. package/dist/types/codama/devnet/accounts/contractState.d.ts +0 -53
  228. package/dist/types/codama/devnet/accounts/contractState.d.ts.map +0 -1
  229. package/dist/types/codama/devnet/accounts/fleet.d.ts +0 -38
  230. package/dist/types/codama/devnet/accounts/fleet.d.ts.map +0 -1
  231. package/dist/types/codama/devnet/accounts/index.d.ts +0 -12
  232. package/dist/types/codama/devnet/accounts/index.d.ts.map +0 -1
  233. package/dist/types/codama/devnet/accounts/rentalState.d.ts +0 -46
  234. package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +0 -1
  235. package/dist/types/codama/devnet/accounts/thread.d.ts +0 -74
  236. package/dist/types/codama/devnet/accounts/thread.d.ts.map +0 -1
  237. package/dist/types/codama/devnet/errors/index.d.ts +0 -9
  238. package/dist/types/codama/devnet/errors/index.d.ts.map +0 -1
  239. package/dist/types/codama/devnet/errors/srsly.d.ts +0 -48
  240. package/dist/types/codama/devnet/errors/srsly.d.ts.map +0 -1
  241. package/dist/types/codama/devnet/index.d.ts +0 -13
  242. package/dist/types/codama/devnet/index.d.ts.map +0 -1
  243. package/dist/types/codama/devnet/instructions/acceptRental.d.ts +0 -128
  244. package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +0 -1
  245. package/dist/types/codama/devnet/instructions/cancelRental.d.ts +0 -71
  246. package/dist/types/codama/devnet/instructions/cancelRental.d.ts.map +0 -1
  247. package/dist/types/codama/devnet/instructions/closeContract.d.ts +0 -96
  248. package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +0 -1
  249. package/dist/types/codama/devnet/instructions/closeRental.d.ts +0 -79
  250. package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +0 -1
  251. package/dist/types/codama/devnet/instructions/createContract.d.ts +0 -108
  252. package/dist/types/codama/devnet/instructions/createContract.d.ts.map +0 -1
  253. package/dist/types/codama/devnet/instructions/index.d.ts +0 -16
  254. package/dist/types/codama/devnet/instructions/index.d.ts.map +0 -1
  255. package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts +0 -67
  256. package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts.map +0 -1
  257. package/dist/types/codama/devnet/instructions/payRental.d.ts +0 -99
  258. package/dist/types/codama/devnet/instructions/payRental.d.ts.map +0 -1
  259. package/dist/types/codama/devnet/instructions/resetRental.d.ts +0 -71
  260. package/dist/types/codama/devnet/instructions/resetRental.d.ts.map +0 -1
  261. package/dist/types/codama/devnet/programs/index.d.ts +0 -9
  262. package/dist/types/codama/devnet/programs/index.d.ts.map +0 -1
  263. package/dist/types/codama/devnet/programs/srsly.d.ts +0 -50
  264. package/dist/types/codama/devnet/programs/srsly.d.ts.map +0 -1
  265. package/dist/types/codama/devnet/shared/index.d.ts +0 -50
  266. package/dist/types/codama/devnet/shared/index.d.ts.map +0 -1
  267. package/dist/types/codama/devnet/types/clockData.d.ts +0 -29
  268. package/dist/types/codama/devnet/types/clockData.d.ts.map +0 -1
  269. package/dist/types/codama/devnet/types/equality.d.ts +0 -18
  270. package/dist/types/codama/devnet/types/equality.d.ts.map +0 -1
  271. package/dist/types/codama/devnet/types/execContext.d.ts +0 -48
  272. package/dist/types/codama/devnet/types/execContext.d.ts.map +0 -1
  273. package/dist/types/codama/devnet/types/index.d.ts +0 -17
  274. package/dist/types/codama/devnet/types/index.d.ts.map +0 -1
  275. package/dist/types/codama/devnet/types/paymentFrequency.d.ts +0 -22
  276. package/dist/types/codama/devnet/types/paymentFrequency.d.ts.map +0 -1
  277. package/dist/types/codama/devnet/types/serializableAccount.d.ts +0 -22
  278. package/dist/types/codama/devnet/types/serializableAccount.d.ts.map +0 -1
  279. package/dist/types/codama/devnet/types/serializableInstruction.d.ts +0 -30
  280. package/dist/types/codama/devnet/types/serializableInstruction.d.ts.map +0 -1
  281. package/dist/types/codama/devnet/types/threadResponse.d.ts +0 -42
  282. package/dist/types/codama/devnet/types/threadResponse.d.ts.map +0 -1
  283. package/dist/types/codama/devnet/types/trigger.d.ts +0 -98
  284. package/dist/types/codama/devnet/types/trigger.d.ts.map +0 -1
  285. package/dist/types/codama/devnet/types/triggerContext.d.ts +0 -75
  286. package/dist/types/codama/devnet/types/triggerContext.d.ts.map +0 -1
  287. package/dist/types/codama/mainnet/accounts/contractState.d.ts +0 -53
  288. package/dist/types/codama/mainnet/accounts/contractState.d.ts.map +0 -1
  289. package/dist/types/codama/mainnet/accounts/fleet.d.ts +0 -38
  290. package/dist/types/codama/mainnet/accounts/fleet.d.ts.map +0 -1
  291. package/dist/types/codama/mainnet/accounts/index.d.ts +0 -12
  292. package/dist/types/codama/mainnet/accounts/index.d.ts.map +0 -1
  293. package/dist/types/codama/mainnet/accounts/rentalState.d.ts +0 -46
  294. package/dist/types/codama/mainnet/accounts/rentalState.d.ts.map +0 -1
  295. package/dist/types/codama/mainnet/accounts/thread.d.ts +0 -74
  296. package/dist/types/codama/mainnet/accounts/thread.d.ts.map +0 -1
  297. package/dist/types/codama/mainnet/errors/index.d.ts +0 -9
  298. package/dist/types/codama/mainnet/errors/index.d.ts.map +0 -1
  299. package/dist/types/codama/mainnet/errors/srsly.d.ts +0 -48
  300. package/dist/types/codama/mainnet/errors/srsly.d.ts.map +0 -1
  301. package/dist/types/codama/mainnet/index.d.ts +0 -13
  302. package/dist/types/codama/mainnet/index.d.ts.map +0 -1
  303. package/dist/types/codama/mainnet/instructions/acceptRental.d.ts +0 -128
  304. package/dist/types/codama/mainnet/instructions/acceptRental.d.ts.map +0 -1
  305. package/dist/types/codama/mainnet/instructions/cancelRental.d.ts +0 -71
  306. package/dist/types/codama/mainnet/instructions/cancelRental.d.ts.map +0 -1
  307. package/dist/types/codama/mainnet/instructions/closeContract.d.ts +0 -96
  308. package/dist/types/codama/mainnet/instructions/closeContract.d.ts.map +0 -1
  309. package/dist/types/codama/mainnet/instructions/closeRental.d.ts +0 -79
  310. package/dist/types/codama/mainnet/instructions/closeRental.d.ts.map +0 -1
  311. package/dist/types/codama/mainnet/instructions/createContract.d.ts +0 -108
  312. package/dist/types/codama/mainnet/instructions/createContract.d.ts.map +0 -1
  313. package/dist/types/codama/mainnet/instructions/index.d.ts +0 -16
  314. package/dist/types/codama/mainnet/instructions/index.d.ts.map +0 -1
  315. package/dist/types/codama/mainnet/instructions/normalizeAdmin.d.ts +0 -67
  316. package/dist/types/codama/mainnet/instructions/normalizeAdmin.d.ts.map +0 -1
  317. package/dist/types/codama/mainnet/instructions/payRental.d.ts +0 -99
  318. package/dist/types/codama/mainnet/instructions/payRental.d.ts.map +0 -1
  319. package/dist/types/codama/mainnet/instructions/resetRental.d.ts +0 -71
  320. package/dist/types/codama/mainnet/instructions/resetRental.d.ts.map +0 -1
  321. package/dist/types/codama/mainnet/programs/index.d.ts +0 -9
  322. package/dist/types/codama/mainnet/programs/index.d.ts.map +0 -1
  323. package/dist/types/codama/mainnet/programs/srsly.d.ts +0 -50
  324. package/dist/types/codama/mainnet/programs/srsly.d.ts.map +0 -1
  325. package/dist/types/codama/mainnet/shared/index.d.ts +0 -50
  326. package/dist/types/codama/mainnet/shared/index.d.ts.map +0 -1
  327. package/dist/types/codama/mainnet/types/clockData.d.ts +0 -29
  328. package/dist/types/codama/mainnet/types/clockData.d.ts.map +0 -1
  329. package/dist/types/codama/mainnet/types/equality.d.ts +0 -18
  330. package/dist/types/codama/mainnet/types/equality.d.ts.map +0 -1
  331. package/dist/types/codama/mainnet/types/execContext.d.ts +0 -48
  332. package/dist/types/codama/mainnet/types/execContext.d.ts.map +0 -1
  333. package/dist/types/codama/mainnet/types/index.d.ts +0 -17
  334. package/dist/types/codama/mainnet/types/index.d.ts.map +0 -1
  335. package/dist/types/codama/mainnet/types/paymentFrequency.d.ts +0 -20
  336. package/dist/types/codama/mainnet/types/paymentFrequency.d.ts.map +0 -1
  337. package/dist/types/codama/mainnet/types/serializableAccount.d.ts +0 -22
  338. package/dist/types/codama/mainnet/types/serializableAccount.d.ts.map +0 -1
  339. package/dist/types/codama/mainnet/types/serializableInstruction.d.ts +0 -30
  340. package/dist/types/codama/mainnet/types/serializableInstruction.d.ts.map +0 -1
  341. package/dist/types/codama/mainnet/types/threadResponse.d.ts +0 -42
  342. package/dist/types/codama/mainnet/types/threadResponse.d.ts.map +0 -1
  343. package/dist/types/codama/mainnet/types/trigger.d.ts +0 -98
  344. package/dist/types/codama/mainnet/types/trigger.d.ts.map +0 -1
  345. package/dist/types/codama/mainnet/types/triggerContext.d.ts +0 -75
  346. package/dist/types/codama/mainnet/types/triggerContext.d.ts.map +0 -1
  347. package/dist/types/contract/close.d.ts +0 -37
  348. package/dist/types/contract/close.d.ts.map +0 -1
  349. package/dist/types/contract/create.d.ts +0 -70
  350. package/dist/types/contract/create.d.ts.map +0 -1
  351. package/dist/types/contract/index.d.ts +0 -3
  352. package/dist/types/contract/index.d.ts.map +0 -1
  353. package/dist/types/index.d.ts +0 -6
  354. package/dist/types/index.d.ts.map +0 -1
  355. package/dist/types/network.d.ts +0 -58
  356. package/dist/types/network.d.ts.map +0 -1
  357. package/dist/types/rental/accept.d.ts +0 -46
  358. package/dist/types/rental/accept.d.ts.map +0 -1
  359. package/dist/types/rental/cancel.d.ts +0 -20
  360. package/dist/types/rental/cancel.d.ts.map +0 -1
  361. package/dist/types/rental/close.d.ts +0 -24
  362. package/dist/types/rental/close.d.ts.map +0 -1
  363. package/dist/types/rental/index.d.ts +0 -5
  364. package/dist/types/rental/index.d.ts.map +0 -1
  365. package/dist/types/rental/reset.d.ts +0 -40
  366. package/dist/types/rental/reset.d.ts.map +0 -1
  367. package/dist/types/utils/constants.d.ts +0 -21
  368. package/dist/types/utils/constants.d.ts.map +0 -1
  369. package/dist/types/utils/index.d.ts +0 -3
  370. package/dist/types/utils/index.d.ts.map +0 -1
  371. package/dist/types/utils/profiles.d.ts +0 -48
  372. package/dist/types/utils/profiles.d.ts.map +0 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
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 interacting with the SRSLY (Space Rental from SLY) Solana program - a decentralized rental system for Star Atlas fleets with network-specific configuration support.
8
8
 
9
9
  ## Installation
10
10
 
@@ -31,14 +31,17 @@ yarn add @wuwei-labs/srsly
31
31
  ```typescript
32
32
  import {
33
33
  createContract,
34
- acceptRental,
35
- setNetwork
34
+ acceptRental,
35
+ setConfig,
36
+ setNetwork,
37
+ ATLAS_TO_STARDUST
36
38
  } from '@wuwei-labs/srsly';
37
39
 
38
- // Set global network (optional - defaults to devnet)
39
- setNetwork('mainnet');
40
+ // Option 1: Set global configuration (recommended for most apps)
41
+ setConfig({ network: 'mainnet' });
42
+ // or use the convenience function: setNetwork('mainnet');
40
43
 
41
- // Create a rental contract using global network setting (direct await)
44
+ // Now all operations use mainnet by default
42
45
  const contractInstruction = await createContract({
43
46
  owner: wallet,
44
47
  fleet: fleetAddress,
@@ -46,25 +49,35 @@ const contractInstruction = await createContract({
46
49
  rate: 1000000, // Rate in ATLAS tokens
47
50
  durationMin: 86400, // 1 day in seconds
48
51
  durationMax: 604800, // 1 week in seconds
49
- paymentsFreq: 'daily',
50
- ownerKeyIndex: 0
51
- });
52
+ paymentsFreq: 'daily'
53
+ }); // Uses mainnet from global config
54
+
55
+ // Accept a rental with automatic ATLAS to stardust conversion
56
+ const acceptInstruction = await acceptRental({
57
+ borrower: borrowerWallet,
58
+ borrowerProfile: borrowerProfileAddress,
59
+ borrowerFaction: 'mud', // or 1, 2, 3
60
+ fleet: fleetAddress,
61
+ contract: contractAddress,
62
+ rate: 100, // ATLAS tokens per duration
63
+ duration: 86400 // 1 day in seconds
64
+ // amount is automatically calculated: rate * duration * ATLAS_TO_STARDUST
65
+ }); // Uses mainnet from global config
52
66
 
53
- // Or override network for specific instruction
54
- const mainnetInstruction = await createContract(params).mainnet();
55
- const devnetInstruction = await createContract(params).devnet();
67
+ // Option 2: Override global config for specific instructions
68
+ const devnetInstruction = await createContract(params).set({ network: 'devnet' });
56
69
  ```
57
70
 
58
71
  ## Core Features
59
72
 
60
73
  ### Contract Management
61
74
 
62
- Create and manage rental contracts for Star Atlas:
75
+ Create and manage rental contracts for Star Atlas fleets:
63
76
 
64
77
  ```typescript
65
78
  import { createContract, closeContract } from '@wuwei-labs/srsly';
66
79
 
67
- // Create a new rental contract with network selection
80
+ // Create a new rental contract with network configuration
68
81
  const createIx = await createContract({
69
82
  owner: wallet,
70
83
  fleet: fleetAddress,
@@ -74,60 +87,69 @@ const createIx = await createContract({
74
87
  durationMax: 2592000, // Maximum 30 days
75
88
  paymentsFreq: 'daily',
76
89
  ownerKeyIndex: 0
77
- }).mainnet(); // Use mainnet for this instruction
90
+ }).set({ network: 'mainnet' }); // Use mainnet configuration
78
91
 
79
- // Close an existing contract using global network setting (direct await)
92
+ // Close an existing contract using devnet defaults (direct await)
80
93
  const closeIx = await closeContract({
81
94
  owner: wallet,
82
95
  fleet: fleetAddress,
83
96
  contract: contractAddress,
84
- faction: 'mud',
85
- ownerProfile: profileAddress
97
+ faction: 'mud' // or faction number: 1, 2, 3
86
98
  });
87
99
  ```
88
100
 
89
101
  ### Rental Operations
90
102
 
91
- Handle rental lifecycle operations:
103
+ Handle rental lifecycle operations with automatic token conversion:
92
104
 
93
105
  ```typescript
94
106
  import {
95
107
  acceptRental,
96
108
  cancelRental,
97
109
  closeRental,
98
- resetRental
110
+ resetRental,
111
+ ATLAS_TO_STARDUST
99
112
  } from '@wuwei-labs/srsly';
100
113
 
101
- // Accept a rental offer on devnet
114
+ // Accept a rental offer on devnet (rate-based with automatic conversion)
102
115
  const acceptIx = await acceptRental({
103
116
  borrower: borrowerWallet,
104
117
  borrowerProfile: borrowerProfileAddress,
118
+ borrowerFaction: 'oni', // or faction number: 1=mud, 2=oni, 3=ustur
119
+ fleet: fleetAddress,
105
120
  contract: contractAddress,
106
- borrowerFaction: 'oni',
107
- duration: 86400,
108
- amount: 1000000
109
- }).devnet();
121
+ rate: 100, // ATLAS tokens (not per second, just ATLAS)
122
+ duration: 86400 // 1 day in seconds
123
+ // amount = rate * duration * ATLAS_TO_STARDUST automatically calculated
124
+ }).set({ network: 'devnet' });
110
125
 
111
- // Cancel an active rental using current network setting (direct await)
126
+ // Cancel an active rental using devnet defaults (direct await)
112
127
  const cancelIx = await cancelRental({
113
128
  borrower: borrowerWallet,
114
- rental: rentalAddress
129
+ contract: contractAddress,
130
+ rentalState: rentalStateAddress
115
131
  });
116
132
 
117
133
  // Close a completed rental on mainnet
118
134
  const closeIx = await closeRental({
119
135
  borrower: borrowerWallet,
120
- rental: rentalAddress
121
- }).mainnet();
136
+ contract: contractAddress,
137
+ rentalState: rentalStateAddress,
138
+ ownerTokenAccount: ownerTokenAccountAddress
139
+ }).set({ network: 'mainnet' });
122
140
 
123
- // Reset rental state (admin only) with specific network
141
+ // Reset rental state with custom configuration
124
142
  const resetIx = await resetRental({
125
143
  fleet: fleetAddress,
126
144
  contract: contractAddress,
127
145
  rentalState: rentalStateAddress,
128
146
  faction: 'mud',
129
147
  ownerProfile: ownerProfileAddress
130
- }).network('mainnet');
148
+ }).set({
149
+ network: 'mainnet',
150
+ sageProgramAddress: 'custom...',
151
+ gameId: 'custom...'
152
+ });
131
153
  ```
132
154
 
133
155
  ### Account State Management
@@ -135,15 +157,15 @@ const resetIx = await resetRental({
135
157
  Fetch and decode account states using network-specific functions:
136
158
 
137
159
  ```typescript
138
- import { getCachedNetworkModule, setNetwork } from '@wuwei-labs/srsly';
160
+ import { getCachedNetworkModule } from '@wuwei-labs/srsly';
139
161
 
140
- // Set the network first
141
- setNetwork('mainnet');
142
-
143
- // Get network-specific account functions
162
+ // Get network-specific account functions (defaults to devnet)
144
163
  const accountsModule = await getCachedNetworkModule('accounts');
145
164
  const { fetchContractState, fetchRentalState } = accountsModule;
146
165
 
166
+ // Or specify network explicitly
167
+ const mainnetAccountsModule = await getCachedNetworkModule('accounts', 'mainnet');
168
+
147
169
  // Fetch contract state
148
170
  const contractState = await fetchContractState(rpc, contractPublicKey);
149
171
  console.log('Contract rate:', contractState.rate.toString());
@@ -155,19 +177,259 @@ console.log('Rental status:', rentalState.status);
155
177
  console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
156
178
  ```
157
179
 
180
+ ### Token Conversion
181
+
182
+ The SDK includes automatic ATLAS to stardust conversion for rental operations:
183
+
184
+ ```typescript
185
+ import { ATLAS_TO_STARDUST } from '@wuwei-labs/srsly';
186
+
187
+ // ATLAS_TO_STARDUST = 100_000_000 (1 ATLAS = 100 million stardust)
188
+ console.log('Conversion rate:', ATLAS_TO_STARDUST);
189
+
190
+ // When using acceptRental with rate and duration:
191
+ // Final amount = rate * duration * ATLAS_TO_STARDUST
192
+ // Example: 100 ATLAS * 86400 seconds * 100_000_000 = 864,000,000,000,000 stardust
193
+ ```
194
+
158
195
  ## Program Information
159
196
 
160
197
  - **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
161
198
  - **Network**: Solana Mainnet or Atlasnet
162
199
  - **Built with**: Anchor Framework
163
200
 
201
+ ## Payment Structure
202
+
203
+ 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.
204
+
205
+ ### Overview
206
+
207
+ ```text
208
+ Rental Lifecycle:
209
+ 1. Escrow Deposit (Full Payment Upfront)
210
+ 2. Periodic Payments (Based on Payment Frequency)
211
+ 3. Fee Collection (Platform + Referral Fees)
212
+ 4. Owner Payments (After Fee Deduction)
213
+ 5. Refunds (For Early Cancellation)
214
+ ```
215
+
216
+ ### 1. Escrow Deposit
217
+
218
+ When a borrower accepts a rental, they deposit the **full rental amount upfront** into an escrow account:
219
+
220
+ ```typescript
221
+ // Example: 1000 ATLAS for 10 days = 10,000 ATLAS total
222
+ const acceptIx = await acceptRental({
223
+ borrower: wallet,
224
+ borrowerProfile: profileAddress,
225
+ borrowerFaction: 'mud',
226
+ fleet: fleetAddress,
227
+ contract: contractAddress,
228
+ rate: 1000, // ATLAS tokens per day
229
+ duration: 864000, // 10 days in seconds
230
+ referralTokenAccount: referrerAddress // Optional referral
231
+ });
232
+ // Total escrowed: 1000 * 10 * 100,000,000 = 1,000,000,000,000 stardust
233
+ ```
234
+
235
+ **Key Points:**
236
+
237
+ - Full payment calculated as: `rate × duration × ATLAS_TO_STARDUST`
238
+ - Funds are held in a rental-specific escrow account
239
+ - Escrow is controlled by the rental state PDA
240
+ - No payments to owner until periodic execution
241
+ - **Minimum enforcement**: 24 hours from start time (if no payments) or last payment time
242
+
243
+ ### 2. Periodic Payments
244
+
245
+ The system creates an automated thread that executes payments based on the contract's payment frequency:
246
+
247
+ ```typescript
248
+ // Contract with daily payments
249
+ const contractIx = await createContract({
250
+ owner: wallet,
251
+ fleet: fleetAddress,
252
+ ownerProfile: profileAddress,
253
+ rate: 1000,
254
+ durationMin: 86400, // 1 day minimum
255
+ durationMax: 2592000, // 30 days maximum
256
+ paymentsFreq: 'daily' // Payments every 24 hours
257
+ });
258
+ ```
259
+
260
+ **Payment Schedule:**
261
+
262
+ - **Daily**: Payments execute daily at 00:00 UTC (not every 24 hours from creation)
263
+ - **Weekly**: Payments execute weekly at specific day/time
264
+ - **Monthly**: Payments execute monthly at specific day/time
265
+
266
+ **Pro-rata Calculation:**
267
+
268
+ Each payment is calculated based on elapsed time since the last payment:
269
+
270
+ ```text
271
+ payment_amount = (elapsed_time / frequency_seconds) × rate × ATLAS_TO_STARDUST
272
+ ```
273
+
274
+ ### 3. Fee Structure
275
+
276
+ Each payment is subject to a **10% platform fee** with optional **10% referral sharing**:
277
+
278
+ ```typescript
279
+ // Constants from the program
280
+ const SERVICE_FEE_BPS = 1000; // 10% platform fee
281
+ const REFERRAL_BPS = 1000; // 10% of total fee to referral
282
+ const BASE_BPS = 10000; // 100% in basis points
283
+ ```
284
+
285
+ **Fee Calculation:**
286
+
287
+ ```typescript
288
+ // For each payment amount
289
+ const totalFee = paymentAmount * SERVICE_FEE_BPS / BASE_BPS; // 10% of payment
290
+ const referralFee = totalFee * REFERRAL_BPS / BASE_BPS; // 10% of total fee
291
+ const platformFee = totalFee - referralFee; // 90% of total fee
292
+ const ownerPayment = paymentAmount - totalFee; // 90% of payment
293
+ ```
294
+
295
+ **Example Payment Breakdown:**
296
+
297
+ ```text
298
+ Payment Amount: 1000 ATLAS
299
+ ├── Total Fee (10%): 100 ATLAS
300
+ │ ├── Referral Fee (10% of total fee): 10 ATLAS → Referrer
301
+ │ └── Platform Fee (90% of total fee): 90 ATLAS → Platform
302
+ └── Owner Payment (90%): 900 ATLAS → Fleet Owner
303
+ ```
304
+
305
+ ### 4. Payment Distribution
306
+
307
+ Each periodic payment is distributed in this order:
308
+
309
+ 1. **Referral Payment** (if referrer exists and ≠ system_program::ID)
310
+ - Amount: `total_fee × REFERRAL_BPS ÷ BASE_BPS`
311
+ - Destination: Referrer's token account
312
+
313
+ 2. **Platform Fee Payment**
314
+ - Amount: `total_fee - referral_payment`
315
+ - Destination: Platform fee account
316
+
317
+ 3. **Owner Payment**
318
+ - Amount: `payment_amount - total_fee`
319
+ - Destination: Fleet owner's token account
320
+
321
+ **Code Example:**
322
+
323
+ ```typescript
324
+ // Accept rental with referral
325
+ const acceptIx = await acceptRental({
326
+ borrower: wallet,
327
+ borrowerProfile: profileAddress,
328
+ borrowerFaction: 'mud',
329
+ fleet: fleetAddress,
330
+ contract: contractAddress,
331
+ rate: 1000,
332
+ duration: 86400,
333
+ referralTokenAccount: referrerTokenAccount // 10% of fees
334
+ });
335
+ ```
336
+
337
+ ### 5. Refund Mechanism
338
+
339
+ 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.**
340
+
341
+ **Early Cancellation:**
342
+
343
+ ```typescript
344
+ const cancelIx = await cancelRental({
345
+ borrower: wallet,
346
+ contract: contractAddress,
347
+ rentalState: rentalStateAddress
348
+ });
349
+ ```
350
+
351
+ **Refund Scenarios:**
352
+
353
+ - **Before First Payment**: Rental remains active for 24 hours from start time, pro-rata refund for remaining time
354
+ - **After Payment(s) Made**: Rental remains active for 24 hours from last payment time, pro-rata refund for remaining time
355
+ - **Contract Closure**: Any remaining escrow returned to borrower
356
+
357
+ ### 6. Payment Timeline Example
358
+
359
+ **Scenario**: 10-day rental with daily payments, 1000 ATLAS/day rate
360
+
361
+ ```text
362
+ Day 0: Rental Accepted
363
+ ├── Escrow: 10,000 ATLAS deposited
364
+ ├── Thread: Created for daily execution at 00:00 UTC
365
+ ├── Fleet: Transferred to borrower
366
+ └── Minimum 24-hour commitment begins (from start time)
367
+
368
+ 00:00 UTC Next Day: First Payment
369
+ ├── Amount: 1,000 ATLAS from escrow
370
+ ├── Total Fee (10%): 100 ATLAS
371
+ │ ├── Referrer: 10 ATLAS (10% of total fee)
372
+ │ └── Platform: 90 ATLAS (90% of total fee)
373
+ ├── Owner: 900 ATLAS (90% of payment)
374
+ ├── Escrow: 9,000 ATLAS remaining
375
+ └── New 24-hour minimum period begins (from payment time)
376
+
377
+ Daily at 00:00 UTC: Subsequent Payments
378
+ ├── Same distribution pattern
379
+ ├── Escrow decreases by 1,000 ATLAS each day
380
+ └── Each payment resets 24-hour minimum period
381
+
382
+ Final Day at 00:00 UTC: Final Payment & Cleanup
383
+ ├── Final payment processed
384
+ ├── Thread: Automatically closed
385
+ ├── Rental State: Closed, lamports to borrower
386
+ └── Fleet: Returned to owner or contract
387
+
388
+ Early Cancellation Examples:
389
+
390
+ Scenario A - Cancel before first payment (Day 0 at 6 PM):
391
+ ├── Cancelled 6 hours after start
392
+ ├── Rental extends until 24 hours from start time (Day 1 at start time)
393
+ ├── Pro-rata refund calculated from Day 1 extended end onwards
394
+ └── Borrower receives refund for Days 1-10
395
+
396
+ Scenario B - Cancel after payments made (Day 3 at 6 PM):
397
+ ├── Cancelled 18 hours after Day 3 payment (00:00 UTC)
398
+ ├── Rental extends until 24 hours from last payment (Day 4 at 00:00 UTC)
399
+ ├── Pro-rata refund calculated from Day 4 onwards
400
+ └── Borrower receives refund for Days 4-10
401
+ ```
402
+
403
+ ### 7. Edge Cases
404
+
405
+ **Insufficient Escrow Balance:**
406
+
407
+ - Payment amount is limited to available escrow balance
408
+ - Remaining balance distributed proportionally
409
+
410
+ **Early Termination:**
411
+
412
+ - **Cancellation Notice**: Must have more than one payment period remaining to cancel
413
+ - **Minimum Period Enforcement**:
414
+ - Before first payment: Active for 24 hours from start time
415
+ - After payment(s): Active for 24 hours from last payment time
416
+ - **Pro-rata Refund**: Refund calculated from the enforced minimum end time
417
+ - Fleet returned to owner when minimum period expires
418
+ - Payment thread continues until minimum period ends
419
+
420
+ **Contract Closure:**
421
+
422
+ - Final payment processed if rental active
423
+ - All remaining resources cleaned up
424
+ - Fleet rental capability removed
425
+
164
426
  ## Payment Frequencies
165
427
 
166
428
  The SDK supports multiple payment frequencies:
167
429
 
168
- - `daily` - Daily payments
169
- - `weekly` - Weekly payments
170
- - `monthly` - Monthly payments
430
+ - `daily` - Daily payments at 00:00 UTC
431
+ - `weekly` - Weekly payments at specific day/time
432
+ - `monthly` - Monthly payments at specific day/time
171
433
 
172
434
  ## Error Handling
173
435
 
@@ -188,67 +450,125 @@ try {
188
450
 
189
451
  ## Network Configuration
190
452
 
191
- The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can configure networks globally or per instruction.
453
+ The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can set global configuration for convenience or override per instruction for flexibility.
192
454
 
193
- ### Global Network Configuration
455
+ ### Global Configuration (Recommended)
194
456
 
195
- Set the default network for all SDK operations:
457
+ Set default configuration once for all SDK operations:
196
458
 
197
459
  ```typescript
198
- import { setNetwork, getNetwork } from '@wuwei-labs/srsly';
460
+ import { setConfig, setNetwork, getConfig, createContract } from '@wuwei-labs/srsly';
461
+
462
+ // Option 1: Full configuration
463
+ setConfig({
464
+ network: 'mainnet',
465
+ gameId: 'custom-game-id...'
466
+ });
199
467
 
200
- // Set global network (defaults to 'devnet')
468
+ // Option 2: Network-only (convenience function)
201
469
  setNetwork('mainnet');
202
470
 
203
- // Check current network
204
- console.log(getNetwork()); // 'mainnet'
471
+ // Check current configuration
472
+ console.log(getConfig()); // { network: 'mainnet' }
205
473
 
206
- // All instructions will now use mainnet by default (direct await)
207
- const ix = await createContract(params);
474
+ // All operations now use mainnet by default
475
+ const ix1 = await createContract(params);
476
+ const ix2 = await acceptRental(params);
208
477
  ```
209
478
 
210
- ### Per-Instruction Network Selection
479
+ ### Per-Instruction Configuration
211
480
 
212
- Override the network for specific instructions using the fluent interface:
481
+ Override global configuration for specific instructions using the fluent `.set()` interface:
213
482
 
214
483
  ```typescript
215
- import { createContract } from '@wuwei-labs/srsly';
484
+ import { createContract, acceptRental } from '@wuwei-labs/srsly';
216
485
 
217
- // Use mainnet for this specific instruction
218
- const mainnetIx = await createContract(params).mainnet();
486
+ // Assume global config is set to mainnet
487
+ setConfig({ network: 'mainnet' });
219
488
 
220
- // Use devnet for this specific instruction
221
- const devnetIx = await createContract(params).devnet();
489
+ // Use global mainnet config
490
+ const mainnetIx = await createContract(params);
222
491
 
223
- // Use a specific network
224
- const specificIx = await createContract(params).network('mainnet');
492
+ // Override to use devnet for this specific instruction
493
+ const devnetIx = await createContract(params).set({ network: 'devnet' });
225
494
 
226
- // Use global network setting (direct await - no .build() needed!)
227
- const globalIx = await createContract(params);
495
+ // Override specific constants while keeping global network
496
+ const customIx = await createContract(params).set({
497
+ sageProgramAddress: 'custom...',
498
+ gameId: 'custom...'
499
+ // network: 'mainnet' inherited from global config
500
+ });
228
501
  ```
229
502
 
230
- ### Network Selection Methods
503
+ ### Configuration Options
231
504
 
232
505
  All SDK functions support these usage patterns:
233
506
 
234
- **Direct await (uses global network):**
507
+ **Direct await (uses global config or devnet fallback):**
508
+
235
509
  ```typescript
510
+ // Uses global configuration if set, otherwise devnet
236
511
  await createContract(params);
237
512
  await acceptRental(params);
238
513
  ```
239
514
 
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)
515
+ **Global configuration functions:**
516
+
517
+ - `setConfig({ network: 'mainnet', gameId: '...' })` - Set full global config
518
+ - `setNetwork('mainnet')` - Set global network only (convenience)
519
+ - `getConfig()` - Get current global configuration
520
+ - `clearConfig()` - Reset to devnet defaults
521
+
522
+ **Per-instruction overrides with `.set()` method:**
523
+
524
+ - `.set({ network: 'mainnet' })` - Override global network
525
+ - `.set({ sageProgramAddress: '...' })` - Override specific constants only
526
+ - `.set({ network: 'mainnet', sageProgramAddress: '...' })` - Multiple overrides
527
+
528
+ **Chainable configurations:**
529
+
530
+ ```typescript
531
+ // Chain multiple configurations (later ones override earlier ones)
532
+ await createContract(params)
533
+ .set({ network: 'devnet' })
534
+ .set({ sageProgramAddress: 'override...' });
535
+
536
+ // Examples with global config
537
+ setConfig({ network: 'mainnet' });
538
+ await createContract(params); // Uses mainnet
539
+ await acceptRental(params).set({ network: 'devnet' }); // Override to devnet
540
+ await closeContract(params).set({ gameId: 'custom...' }); // Custom gameId, mainnet network
541
+ ```
542
+
543
+ ### Available Configuration Options
245
544
 
246
545
  ```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
546
+ interface ConfigOptions {
547
+ network?: 'mainnet' | 'devnet'; // Set/override network
548
+ sageProgramAddress?: string; // Set/override SAGE program address
549
+ profileFactionProgramAddress?: string; // Set/override Profile Faction program address
550
+ gameId?: string; // Set/override SAGE game ID
551
+ }
552
+ ```
553
+
554
+ ### Network-Specific Constants
555
+
556
+ The SDK automatically resolves network-specific constants:
557
+
558
+ ```typescript
559
+ import {
560
+ getSageProgramAddress,
561
+ getProfileFactionProgramAddress,
562
+ getSageGameId
563
+ } from '@wuwei-labs/srsly';
564
+
565
+ // Get constants for devnet (default)
566
+ const sageProgram = await getSageProgramAddress();
567
+ const gameId = await getSageGameId();
568
+
569
+ // Get constants for specific network
570
+ const mainnetSageProgram = await getSageProgramAddress({ network: 'mainnet' });
571
+ const mainnetGameId = await getSageGameId({ network: 'mainnet' });
252
572
  ```
253
573
 
254
574
  ## IDL and Types
@@ -279,7 +599,8 @@ import type {
279
599
  RentalState,
280
600
  PaymentFrequency,
281
601
  ClockData,
282
- ThreadResponse
602
+ ThreadResponse,
603
+ ConfigOptions
283
604
  } from '@wuwei-labs/srsly';
284
605
 
285
606
  // Import network-specific Anchor types
@@ -287,6 +608,55 @@ import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
287
608
  import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
288
609
  ```
289
610
 
611
+ ## Constants and Utilities
612
+
613
+ ### Available Constants
614
+
615
+ ```typescript
616
+ import {
617
+ ATLAS_TO_STARDUST,
618
+ STARBASE_SEED,
619
+ STARBASE_PLAYER_SEED,
620
+ SAGE_PLAYER_PROFILE_SEED,
621
+ PROFILE_FACTION_SEED,
622
+ FACTION_MAPPING,
623
+ FACTION_SPECIFIC_CSS
624
+ } from '@wuwei-labs/srsly';
625
+
626
+ // Token conversion
627
+ console.log(ATLAS_TO_STARDUST); // 100_000_000
628
+
629
+ // Faction mappings
630
+ console.log(FACTION_MAPPING[1]); // 'mud'
631
+ console.log(FACTION_MAPPING[2]); // 'oni'
632
+ console.log(FACTION_MAPPING[3]); // 'ustur'
633
+ ```
634
+
635
+ ### Profile Derivation
636
+
637
+ ```typescript
638
+ import {
639
+ deriveProfileFaction,
640
+ deriveSagePlayerProfile,
641
+ deriveStarbase,
642
+ deriveStarbasePlayer,
643
+ deriveGameAccounts
644
+ } from '@wuwei-labs/srsly';
645
+
646
+ // Derive individual accounts with network configuration
647
+ const profileFaction = await deriveProfileFaction(profile, { network: 'mainnet' });
648
+ const starbase = await deriveStarbase('mud', gameId, { network: 'mainnet' });
649
+
650
+ // Derive all game accounts at once
651
+ const gameAccounts = await deriveGameAccounts(
652
+ profile,
653
+ 'mud',
654
+ gameId,
655
+ 0, // starbaseSeqId
656
+ { network: 'mainnet' }
657
+ );
658
+ ```
659
+
290
660
  ## Documentation
291
661
 
292
662
  - **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
@@ -295,4 +665,4 @@ import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
295
665
 
296
666
  - **Star Atlas**: The metaverse gaming ecosystem
297
667
  - **Solana**: The blockchain platform powering SRSLY
298
- - **Anchor**: The framework used to build the SRSLY program
668
+ - **Anchor**: The framework used to build the SRSLY program