@karn_lat/protocol-sdk 0.1.0-alpha.1

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 (157) hide show
  1. package/README.md +68 -0
  2. package/dist/__tests__/setup.d.ts +14 -0
  3. package/dist/__tests__/setup.d.ts.map +1 -0
  4. package/dist/__tests__/setup.js +44 -0
  5. package/dist/__tests__/setup.js.map +1 -0
  6. package/dist/clients/GovernorClient.d.ts +9 -0
  7. package/dist/clients/GovernorClient.d.ts.map +1 -0
  8. package/dist/clients/GovernorClient.js +18 -0
  9. package/dist/clients/GovernorClient.js.map +1 -0
  10. package/dist/clients/TreasuryClient.d.ts +9 -0
  11. package/dist/clients/TreasuryClient.d.ts.map +1 -0
  12. package/dist/clients/TreasuryClient.js +18 -0
  13. package/dist/clients/TreasuryClient.js.map +1 -0
  14. package/dist/clients/ValocracyClient.d.ts +13 -0
  15. package/dist/clients/ValocracyClient.d.ts.map +1 -0
  16. package/dist/clients/ValocracyClient.js +32 -0
  17. package/dist/clients/ValocracyClient.js.map +1 -0
  18. package/dist/clients/index.d.ts +4 -0
  19. package/dist/clients/index.d.ts.map +1 -0
  20. package/dist/clients/index.js +4 -0
  21. package/dist/clients/index.js.map +1 -0
  22. package/dist/generated/governor/src/index.d.ts +400 -0
  23. package/dist/generated/governor/src/index.d.ts.map +1 -0
  24. package/dist/generated/governor/src/index.js +63 -0
  25. package/dist/generated/governor/src/index.js.map +1 -0
  26. package/dist/generated/treasury/src/index.d.ts +474 -0
  27. package/dist/generated/treasury/src/index.d.ts.map +1 -0
  28. package/dist/generated/treasury/src/index.js +54 -0
  29. package/dist/generated/treasury/src/index.js.map +1 -0
  30. package/dist/generated/valocracy/src/index.d.ts +807 -0
  31. package/dist/generated/valocracy/src/index.d.ts.map +1 -0
  32. package/dist/generated/valocracy/src/index.js +114 -0
  33. package/dist/generated/valocracy/src/index.js.map +1 -0
  34. package/dist/index.d.ts +5 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +5 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/react/hooks/useGovernor.d.ts +24 -0
  39. package/dist/react/hooks/useGovernor.d.ts.map +1 -0
  40. package/dist/react/hooks/useGovernor.js +45 -0
  41. package/dist/react/hooks/useGovernor.js.map +1 -0
  42. package/dist/react/hooks/useMultiWallet.d.ts +35 -0
  43. package/dist/react/hooks/useMultiWallet.d.ts.map +1 -0
  44. package/dist/react/hooks/useMultiWallet.js +87 -0
  45. package/dist/react/hooks/useMultiWallet.js.map +1 -0
  46. package/dist/react/hooks/useTreasury.d.ts +14 -0
  47. package/dist/react/hooks/useTreasury.d.ts.map +1 -0
  48. package/dist/react/hooks/useTreasury.js +45 -0
  49. package/dist/react/hooks/useTreasury.js.map +1 -0
  50. package/dist/react/hooks/useValocracy.d.ts +16 -0
  51. package/dist/react/hooks/useValocracy.d.ts.map +1 -0
  52. package/dist/react/hooks/useValocracy.js +54 -0
  53. package/dist/react/hooks/useValocracy.js.map +1 -0
  54. package/dist/react/hooks/useWallet.d.ts +13 -0
  55. package/dist/react/hooks/useWallet.d.ts.map +1 -0
  56. package/dist/react/hooks/useWallet.js +51 -0
  57. package/dist/react/hooks/useWallet.js.map +1 -0
  58. package/dist/react/index.d.ts +7 -0
  59. package/dist/react/index.d.ts.map +1 -0
  60. package/dist/react/index.js +7 -0
  61. package/dist/react/index.js.map +1 -0
  62. package/dist/react/providers/KarnProvider.d.ts +25 -0
  63. package/dist/react/providers/KarnProvider.d.ts.map +1 -0
  64. package/dist/react/providers/KarnProvider.js +25 -0
  65. package/dist/react/providers/KarnProvider.js.map +1 -0
  66. package/dist/utils/decay.d.ts +19 -0
  67. package/dist/utils/decay.d.ts.map +1 -0
  68. package/dist/utils/decay.js +33 -0
  69. package/dist/utils/decay.js.map +1 -0
  70. package/dist/utils/index.d.ts +4 -0
  71. package/dist/utils/index.d.ts.map +1 -0
  72. package/dist/utils/index.js +4 -0
  73. package/dist/utils/index.js.map +1 -0
  74. package/dist/utils/polling.d.ts +75 -0
  75. package/dist/utils/polling.d.ts.map +1 -0
  76. package/dist/utils/polling.js +104 -0
  77. package/dist/utils/polling.js.map +1 -0
  78. package/dist/utils/simulation.d.ts +67 -0
  79. package/dist/utils/simulation.d.ts.map +1 -0
  80. package/dist/utils/simulation.js +88 -0
  81. package/dist/utils/simulation.js.map +1 -0
  82. package/dist/wallet/WalletManager.d.ts +77 -0
  83. package/dist/wallet/WalletManager.d.ts.map +1 -0
  84. package/dist/wallet/WalletManager.js +268 -0
  85. package/dist/wallet/WalletManager.js.map +1 -0
  86. package/dist/wallet/adapters/AlbedoAdapter.d.ts +47 -0
  87. package/dist/wallet/adapters/AlbedoAdapter.d.ts.map +1 -0
  88. package/dist/wallet/adapters/AlbedoAdapter.js +84 -0
  89. package/dist/wallet/adapters/AlbedoAdapter.js.map +1 -0
  90. package/dist/wallet/adapters/FreighterAdapter.d.ts +42 -0
  91. package/dist/wallet/adapters/FreighterAdapter.d.ts.map +1 -0
  92. package/dist/wallet/adapters/FreighterAdapter.js +107 -0
  93. package/dist/wallet/adapters/FreighterAdapter.js.map +1 -0
  94. package/dist/wallet/adapters/LobstrAdapter.d.ts +34 -0
  95. package/dist/wallet/adapters/LobstrAdapter.d.ts.map +1 -0
  96. package/dist/wallet/adapters/LobstrAdapter.js +89 -0
  97. package/dist/wallet/adapters/LobstrAdapter.js.map +1 -0
  98. package/dist/wallet/adapters/RabetAdapter.d.ts +39 -0
  99. package/dist/wallet/adapters/RabetAdapter.d.ts.map +1 -0
  100. package/dist/wallet/adapters/RabetAdapter.js +104 -0
  101. package/dist/wallet/adapters/RabetAdapter.js.map +1 -0
  102. package/dist/wallet/adapters/xBullAdapter.d.ts +41 -0
  103. package/dist/wallet/adapters/xBullAdapter.d.ts.map +1 -0
  104. package/dist/wallet/adapters/xBullAdapter.js +72 -0
  105. package/dist/wallet/adapters/xBullAdapter.js.map +1 -0
  106. package/dist/wallet/index.d.ts +20 -0
  107. package/dist/wallet/index.d.ts.map +1 -0
  108. package/dist/wallet/index.js +23 -0
  109. package/dist/wallet/index.js.map +1 -0
  110. package/dist/wallet/types.d.ts +165 -0
  111. package/dist/wallet/types.d.ts.map +1 -0
  112. package/dist/wallet/types.js +50 -0
  113. package/dist/wallet/types.js.map +1 -0
  114. package/examples/basic-usage.ts +28 -0
  115. package/jest.config.js +37 -0
  116. package/package.json +58 -0
  117. package/src/__tests__/README.md +364 -0
  118. package/src/__tests__/setup.ts +57 -0
  119. package/src/__tests__/utils/decay.test.ts +331 -0
  120. package/src/__tests__/wallet/WalletManager.test.ts +410 -0
  121. package/src/clients/GovernorClient.ts +23 -0
  122. package/src/clients/TreasuryClient.ts +23 -0
  123. package/src/clients/ValocracyClient.ts +48 -0
  124. package/src/clients/index.ts +3 -0
  125. package/src/generated/governor/README.md +54 -0
  126. package/src/generated/governor/package.json +17 -0
  127. package/src/generated/governor/src/index.ts +428 -0
  128. package/src/generated/governor/tsconfig.json +98 -0
  129. package/src/generated/treasury/README.md +54 -0
  130. package/src/generated/treasury/package.json +17 -0
  131. package/src/generated/treasury/src/index.ts +495 -0
  132. package/src/generated/treasury/tsconfig.json +98 -0
  133. package/src/generated/valocracy/README.md +54 -0
  134. package/src/generated/valocracy/package.json +17 -0
  135. package/src/generated/valocracy/src/index.ts +831 -0
  136. package/src/generated/valocracy/tsconfig.json +98 -0
  137. package/src/index.ts +4 -0
  138. package/src/react/hooks/useGovernor.ts +69 -0
  139. package/src/react/hooks/useMultiWallet.ts +169 -0
  140. package/src/react/hooks/useTreasury.ts +57 -0
  141. package/src/react/hooks/useValocracy.ts +66 -0
  142. package/src/react/hooks/useWallet.ts +60 -0
  143. package/src/react/index.ts +6 -0
  144. package/src/react/providers/KarnProvider.tsx +63 -0
  145. package/src/utils/decay.ts +44 -0
  146. package/src/utils/index.ts +3 -0
  147. package/src/utils/polling.ts +193 -0
  148. package/src/utils/simulation.ts +136 -0
  149. package/src/wallet/WalletManager.ts +360 -0
  150. package/src/wallet/adapters/AlbedoAdapter.ts +140 -0
  151. package/src/wallet/adapters/FreighterAdapter.ts +179 -0
  152. package/src/wallet/adapters/LobstrAdapter.ts +142 -0
  153. package/src/wallet/adapters/RabetAdapter.ts +162 -0
  154. package/src/wallet/adapters/xBullAdapter.ts +123 -0
  155. package/src/wallet/index.ts +37 -0
  156. package/src/wallet/types.ts +204 -0
  157. package/tsconfig.json +40 -0
@@ -0,0 +1,495 @@
1
+ import { Buffer } from "buffer";
2
+ import { Address } from '@stellar/stellar-sdk';
3
+ import {
4
+ AssembledTransaction,
5
+ Client as ContractClient,
6
+ ClientOptions as ContractClientOptions,
7
+ MethodOptions,
8
+ Result,
9
+ Spec as ContractSpec,
10
+ } from '@stellar/stellar-sdk/contract';
11
+ import type {
12
+ u32,
13
+ i32,
14
+ u64,
15
+ i64,
16
+ u128,
17
+ i128,
18
+ u256,
19
+ i256,
20
+ Option,
21
+ Typepoint,
22
+ Duration,
23
+ } from '@stellar/stellar-sdk/contract';
24
+ export * from '@stellar/stellar-sdk'
25
+ export * as contract from '@stellar/stellar-sdk/contract'
26
+ export * as rpc from '@stellar/stellar-sdk/rpc'
27
+
28
+ if (typeof window !== 'undefined') {
29
+ //@ts-ignore Buffer exists
30
+ window.Buffer = window.Buffer || Buffer;
31
+ }
32
+
33
+
34
+
35
+
36
+ export const TreasuryError = {
37
+ 1: {message:"AlreadyInitialized"},
38
+ 2: {message:"NotInitialized"},
39
+ 3: {message:"NotAuthorized"},
40
+ 4: {message:"InsufficientShares"},
41
+ 5: {message:"InsufficientAssets"},
42
+ 6: {message:"ZeroAmount"},
43
+ 7: {message:"ReentrancyDetected"},
44
+ 8: {message:"MathOverflow"},
45
+ 9: {message:"LabNotFound"},
46
+ 10: {message:"LabNotActive"},
47
+ 11: {message:"InsufficientClaimable"}
48
+ }
49
+
50
+
51
+ /**
52
+ * Lab Funding Struct
53
+ */
54
+ export interface Lab {
55
+ funder: string;
56
+ id: u32;
57
+ scholarship_per_member: i128;
58
+ status: LabStatus;
59
+ total_amount: i128;
60
+ }
61
+
62
+ /**
63
+ * Storage keys for the Treasury contract
64
+ */
65
+ export type DataKey = {tag: "Valocracy", values: void} | {tag: "Governor", values: void} | {tag: "AssetToken", values: void} | {tag: "TotalShares", values: void} | {tag: "UserShares", values: readonly [string]} | {tag: "ReentrancyLock", values: void} | {tag: "LabCounter", values: void} | {tag: "Lab", values: readonly [u32]} | {tag: "ClaimableBalance", values: readonly [string]};
66
+
67
+ /**
68
+ * Status of a Lab
69
+ */
70
+ export type LabStatus = {tag: "Active", values: void} | {tag: "Cancelled", values: void} | {tag: "Completed", values: void};
71
+
72
+ export interface Client {
73
+ /**
74
+ * Construct and simulate a asset transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
75
+ * Get the underlying asset token address
76
+ */
77
+ asset: (options?: {
78
+ /**
79
+ * The fee to pay for the transaction. Default: BASE_FEE
80
+ */
81
+ fee?: number;
82
+
83
+ /**
84
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
85
+ */
86
+ timeoutInSeconds?: number;
87
+
88
+ /**
89
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
90
+ */
91
+ simulate?: boolean;
92
+ }) => Promise<AssembledTransaction<Option<string>>>
93
+
94
+ /**
95
+ * Construct and simulate a spend transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
96
+ * Spend treasury assets — only callable by the Governor contract
97
+ *
98
+ * This is invoked as part of executing an approved governance proposal.
99
+ */
100
+ spend: ({receiver, amount}: {receiver: string, amount: i128}, options?: {
101
+ /**
102
+ * The fee to pay for the transaction. Default: BASE_FEE
103
+ */
104
+ fee?: number;
105
+
106
+ /**
107
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
108
+ */
109
+ timeoutInSeconds?: number;
110
+
111
+ /**
112
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
113
+ */
114
+ simulate?: boolean;
115
+ }) => Promise<AssembledTransaction<Result<void>>>
116
+
117
+ /**
118
+ * Construct and simulate a deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
119
+ * Deposit shares to a user account
120
+ *
121
+ * This is called by the Valocracy contract when minting NFTs.
122
+ * Shares represent the user's claim on treasury assets.
123
+ */
124
+ deposit: ({receiver, shares}: {receiver: string, shares: i128}, options?: {
125
+ /**
126
+ * The fee to pay for the transaction. Default: BASE_FEE
127
+ */
128
+ fee?: number;
129
+
130
+ /**
131
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
132
+ */
133
+ timeoutInSeconds?: number;
134
+
135
+ /**
136
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
137
+ */
138
+ simulate?: boolean;
139
+ }) => Promise<AssembledTransaction<Result<void>>>
140
+
141
+ /**
142
+ * Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
143
+ * Upgrade the contract to a new WASM hash.
144
+ * Only callable by the governor (requires governance proposal).
145
+ */
146
+ upgrade: ({new_wasm_hash}: {new_wasm_hash: Buffer}, options?: {
147
+ /**
148
+ * The fee to pay for the transaction. Default: BASE_FEE
149
+ */
150
+ fee?: number;
151
+
152
+ /**
153
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
154
+ */
155
+ timeoutInSeconds?: number;
156
+
157
+ /**
158
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
159
+ */
160
+ simulate?: boolean;
161
+ }) => Promise<AssembledTransaction<Result<void>>>
162
+
163
+ /**
164
+ * Construct and simulate a fund_lab transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
165
+ * Fund a new Lab (Scholarship)
166
+ *
167
+ * Only callable by the funder.
168
+ */
169
+ fund_lab: ({funder, total_amount, scholarship_per_member}: {funder: string, total_amount: i128, scholarship_per_member: i128}, options?: {
170
+ /**
171
+ * The fee to pay for the transaction. Default: BASE_FEE
172
+ */
173
+ fee?: number;
174
+
175
+ /**
176
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
177
+ */
178
+ timeoutInSeconds?: number;
179
+
180
+ /**
181
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
182
+ */
183
+ simulate?: boolean;
184
+ }) => Promise<AssembledTransaction<Result<u32>>>
185
+
186
+ /**
187
+ * Construct and simulate a governor transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
188
+ * Get governor contract address
189
+ */
190
+ governor: (options?: {
191
+ /**
192
+ * The fee to pay for the transaction. Default: BASE_FEE
193
+ */
194
+ fee?: number;
195
+
196
+ /**
197
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
198
+ */
199
+ timeoutInSeconds?: number;
200
+
201
+ /**
202
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
203
+ */
204
+ simulate?: boolean;
205
+ }) => Promise<AssembledTransaction<Option<string>>>
206
+
207
+ /**
208
+ * Construct and simulate a withdraw transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
209
+ * Withdraw assets by burning shares
210
+ *
211
+ * Converts shares to underlying assets based on current ratio.
212
+ */
213
+ withdraw: ({caller, receiver, shares}: {caller: string, receiver: string, shares: i128}, options?: {
214
+ /**
215
+ * The fee to pay for the transaction. Default: BASE_FEE
216
+ */
217
+ fee?: number;
218
+
219
+ /**
220
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
221
+ */
222
+ timeoutInSeconds?: number;
223
+
224
+ /**
225
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
226
+ */
227
+ simulate?: boolean;
228
+ }) => Promise<AssembledTransaction<Result<i128>>>
229
+
230
+ /**
231
+ * Construct and simulate a shares_of transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
232
+ * Get shares for a specific user
233
+ */
234
+ shares_of: ({account}: {account: string}, options?: {
235
+ /**
236
+ * The fee to pay for the transaction. Default: BASE_FEE
237
+ */
238
+ fee?: number;
239
+
240
+ /**
241
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
242
+ */
243
+ timeoutInSeconds?: number;
244
+
245
+ /**
246
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
247
+ */
248
+ simulate?: boolean;
249
+ }) => Promise<AssembledTransaction<i128>>
250
+
251
+ /**
252
+ * Construct and simulate a valocracy transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
253
+ * Get valocracy contract address
254
+ */
255
+ valocracy: (options?: {
256
+ /**
257
+ * The fee to pay for the transaction. Default: BASE_FEE
258
+ */
259
+ fee?: number;
260
+
261
+ /**
262
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
263
+ */
264
+ timeoutInSeconds?: number;
265
+
266
+ /**
267
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
268
+ */
269
+ simulate?: boolean;
270
+ }) => Promise<AssembledTransaction<Option<string>>>
271
+
272
+ /**
273
+ * Construct and simulate a initialize transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
274
+ * Initialize the Treasury contract.
275
+ *
276
+ * No admin: stores valocracy, governor, and asset token addresses.
277
+ * All privileged operations go through the governor (governance).
278
+ */
279
+ initialize: ({valocracy, governor, asset_token}: {valocracy: string, governor: string, asset_token: string}, options?: {
280
+ /**
281
+ * The fee to pay for the transaction. Default: BASE_FEE
282
+ */
283
+ fee?: number;
284
+
285
+ /**
286
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
287
+ */
288
+ timeoutInSeconds?: number;
289
+
290
+ /**
291
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
292
+ */
293
+ simulate?: boolean;
294
+ }) => Promise<AssembledTransaction<Result<void>>>
295
+
296
+ /**
297
+ * Construct and simulate a total_assets transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
298
+ * Get total assets in the treasury by querying the actual token balance
299
+ */
300
+ total_assets: (options?: {
301
+ /**
302
+ * The fee to pay for the transaction. Default: BASE_FEE
303
+ */
304
+ fee?: number;
305
+
306
+ /**
307
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
308
+ */
309
+ timeoutInSeconds?: number;
310
+
311
+ /**
312
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
313
+ */
314
+ simulate?: boolean;
315
+ }) => Promise<AssembledTransaction<i128>>
316
+
317
+ /**
318
+ * Construct and simulate a total_shares transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
319
+ * Get total shares outstanding
320
+ */
321
+ total_shares: (options?: {
322
+ /**
323
+ * The fee to pay for the transaction. Default: BASE_FEE
324
+ */
325
+ fee?: number;
326
+
327
+ /**
328
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
329
+ */
330
+ timeoutInSeconds?: number;
331
+
332
+ /**
333
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
334
+ */
335
+ simulate?: boolean;
336
+ }) => Promise<AssembledTransaction<i128>>
337
+
338
+ /**
339
+ * Construct and simulate a update_governor transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
340
+ * Update the governor contract address (migration path).
341
+ * Only callable by the current governor.
342
+ */
343
+ update_governor: ({new_governor}: {new_governor: string}, options?: {
344
+ /**
345
+ * The fee to pay for the transaction. Default: BASE_FEE
346
+ */
347
+ fee?: number;
348
+
349
+ /**
350
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
351
+ */
352
+ timeoutInSeconds?: number;
353
+
354
+ /**
355
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
356
+ */
357
+ simulate?: boolean;
358
+ }) => Promise<AssembledTransaction<Result<void>>>
359
+
360
+ /**
361
+ * Construct and simulate a preview_withdraw transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
362
+ * Preview how many assets a share amount would yield
363
+ */
364
+ preview_withdraw: ({shares}: {shares: i128}, options?: {
365
+ /**
366
+ * The fee to pay for the transaction. Default: BASE_FEE
367
+ */
368
+ fee?: number;
369
+
370
+ /**
371
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
372
+ */
373
+ timeoutInSeconds?: number;
374
+
375
+ /**
376
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
377
+ */
378
+ simulate?: boolean;
379
+ }) => Promise<AssembledTransaction<Result<i128>>>
380
+
381
+ /**
382
+ * Construct and simulate a approve_scholarship transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
383
+ * Approve scholarship for a member
384
+ *
385
+ * Releases scholarship funds to a member's claimable balance.
386
+ * Only callable by governor (governance/admin/mentor approval).
387
+ */
388
+ approve_scholarship: ({lab_id, member}: {lab_id: u32, member: string}, options?: {
389
+ /**
390
+ * The fee to pay for the transaction. Default: BASE_FEE
391
+ */
392
+ fee?: number;
393
+
394
+ /**
395
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
396
+ */
397
+ timeoutInSeconds?: number;
398
+
399
+ /**
400
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
401
+ */
402
+ simulate?: boolean;
403
+ }) => Promise<AssembledTransaction<Result<void>>>
404
+
405
+ /**
406
+ * Construct and simulate a withdraw_scholarship transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
407
+ * Withdraw scholarship funds
408
+ *
409
+ * Allows members to withdraw their approved scholarship funds.
410
+ * Updated to check claimable balance instead of shares.
411
+ */
412
+ withdraw_scholarship: ({member, amount}: {member: string, amount: i128}, options?: {
413
+ /**
414
+ * The fee to pay for the transaction. Default: BASE_FEE
415
+ */
416
+ fee?: number;
417
+
418
+ /**
419
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
420
+ */
421
+ timeoutInSeconds?: number;
422
+
423
+ /**
424
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
425
+ */
426
+ simulate?: boolean;
427
+ }) => Promise<AssembledTransaction<Result<void>>>
428
+
429
+ /**
430
+ * Construct and simulate a get_claimable_balance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
431
+ * Get claimable balance for a member
432
+ *
433
+ * Returns the amount of scholarship funds available for withdrawal.
434
+ */
435
+ get_claimable_balance: ({member}: {member: string}, options?: {
436
+ /**
437
+ * The fee to pay for the transaction. Default: BASE_FEE
438
+ */
439
+ fee?: number;
440
+
441
+ /**
442
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
443
+ */
444
+ timeoutInSeconds?: number;
445
+
446
+ /**
447
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
448
+ */
449
+ simulate?: boolean;
450
+ }) => Promise<AssembledTransaction<i128>>
451
+
452
+ }
453
+ export class Client extends ContractClient {
454
+ static async deploy<T = Client>(
455
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
456
+ options: MethodOptions &
457
+ Omit<ContractClientOptions, "contractId"> & {
458
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
459
+ wasmHash: Buffer | string;
460
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
461
+ salt?: Buffer | Uint8Array;
462
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
463
+ format?: "hex" | "base64";
464
+ }
465
+ ): Promise<AssembledTransaction<T>> {
466
+ return ContractClient.deploy(null, options)
467
+ }
468
+ constructor(public readonly options: ContractClientOptions) {
469
+ super(
470
+ new ContractSpec([ "AAAAAAAAACZHZXQgdGhlIHVuZGVybHlpbmcgYXNzZXQgdG9rZW4gYWRkcmVzcwAAAAAABWFzc2V0AAAAAAAAAAAAAAEAAAPoAAAAEw==",
471
+ "AAAAAAAAAIdTcGVuZCB0cmVhc3VyeSBhc3NldHMg4oCUIG9ubHkgY2FsbGFibGUgYnkgdGhlIEdvdmVybm9yIGNvbnRyYWN0CgpUaGlzIGlzIGludm9rZWQgYXMgcGFydCBvZiBleGVjdXRpbmcgYW4gYXBwcm92ZWQgZ292ZXJuYW5jZSBwcm9wb3NhbC4AAAAABXNwZW5kAAAAAAAAAgAAAAAAAAAIcmVjZWl2ZXIAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAABAAAD6QAAA+0AAAAAAAAH0AAAAA1UcmVhc3VyeUVycm9yAAAA",
472
+ "AAAAAAAAAJNEZXBvc2l0IHNoYXJlcyB0byBhIHVzZXIgYWNjb3VudAoKVGhpcyBpcyBjYWxsZWQgYnkgdGhlIFZhbG9jcmFjeSBjb250cmFjdCB3aGVuIG1pbnRpbmcgTkZUcy4KU2hhcmVzIHJlcHJlc2VudCB0aGUgdXNlcidzIGNsYWltIG9uIHRyZWFzdXJ5IGFzc2V0cy4AAAAAB2RlcG9zaXQAAAAAAgAAAAAAAAAIcm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AAAADFHb3Zlcm5vciBjb250cmFjdCBhZGRyZXNzIChhdXRob3JpemVkIGZvciBzcGVuZHMpAAAAAAAACEdvdmVybm9yAAAAAAAAABZVbmRlcmx5aW5nIGFzc2V0IHRva2VuAAAAAAAKQXNzZXRUb2tlbgAAAAAAAAAAABhUb3RhbCBzaGFyZXMgb3V0c3RhbmRpbmcAAAALVG90YWxTaGFyZXMAAAAAAQAAABZVc2VyIGFkZHJlc3MgLT4gc2hhcmVzAAAAAAAKVXNlclNoYXJlcwAAAAAAAQAAABMAAAAAAAAAD1JlZW50cmFuY3kgbG9jawAAAAAOUmVlbnRyYW5jeUxvY2sAAAAAAAAAAAAfTGFiIGNvdW50ZXIgKGZvciBJRCBnZW5lcmF0aW9uKQAAAAAKTGFiQ291bnRlcgAAAAAAAQAAAA1MYWIgSUQgLT4gTGFiAAAAAAAAA0xhYgAAAAABAAAABAAAAAEAAAA1VXNlciBhZGRyZXNzIC0+IENsYWltYWJsZSBiYWxhbmNlIChTY2hvbGFyc2hpcCBmdW5kcykAAAAAAAAQQ2xhaW1hYmxlQmFsYW5jZQAAAAEAAAAT",
490
+ "AAAAAgAAAA9TdGF0dXMgb2YgYSBMYWIAAAAAAAAAAAlMYWJTdGF0dXMAAAAAAAADAAAAAAAAAAAAAAAGQWN0aXZlAAAAAAAAAAAAAAAAAAlDYW5jZWxsZWQAAAAAAAAAAAAAAAAAAAlDb21wbGV0ZWQAAAA=" ]),
491
+ options
492
+ )
493
+ }
494
+
495
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+ /* Projects */
5
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
+ /* Language and Environment */
12
+ "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
15
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
16
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
+ /* Modules */
25
+ "module": "NodeNext", /* Specify what module code is generated. */
26
+ // "rootDir": "./", /* Specify the root folder within your source files. */
27
+ "moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
28
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
31
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
32
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
33
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
34
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
35
+ // "resolveJsonModule": true, /* Enable importing .json files. */
36
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
37
+ /* JavaScript Support */
38
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
39
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
40
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
41
+ /* Emit */
42
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
43
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
44
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
45
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
46
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
47
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
48
+ // "removeComments": true, /* Disable emitting comments. */
49
+ // "noEmit": true, /* Disable emitting files from a compilation. */
50
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
51
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
52
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
53
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
54
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
55
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
56
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
57
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
58
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
59
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
60
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
61
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
62
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
63
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
64
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
65
+ /* Interop Constraints */
66
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
67
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
68
+ // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
69
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
70
+ // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
71
+ /* Type Checking */
72
+ // "strict": true, /* Enable all strict type-checking options. */
73
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
74
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
75
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
76
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
77
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
78
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
79
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
80
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
81
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
82
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
83
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
84
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
85
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
86
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
87
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
88
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
89
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
90
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
91
+ /* Completeness */
92
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
93
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
94
+ },
95
+ "include": [
96
+ "src/*"
97
+ ]
98
+ }
@@ -0,0 +1,54 @@
1
+ # valocracy JS
2
+
3
+ JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `valocracy` via Soroban RPC.
4
+
5
+ This library was automatically generated by Soroban CLI using a command similar to:
6
+
7
+ ```bash
8
+ soroban contract bindings ts \
9
+ --rpc-url INSERT_RPC_URL_HERE \
10
+ --network-passphrase "INSERT_NETWORK_PASSPHRASE_HERE" \
11
+ --contract-id INSERT_CONTRACT_ID_HERE \
12
+ --output-dir ./path/to/valocracy
13
+ ```
14
+
15
+ The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily.
16
+
17
+ # To publish or not to publish
18
+
19
+ This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command.
20
+
21
+ But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path:
22
+
23
+ ```json
24
+ "dependencies": {
25
+ "valocracy": "./path/to/this/folder"
26
+ }
27
+ ```
28
+
29
+ However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract.
30
+
31
+ ```json
32
+ "scripts": {
33
+ "postinstall": "soroban contract bindings ts --rpc-url INSERT_RPC_URL_HERE --network-passphrase \"INSERT_NETWORK_PASSPHRASE_HERE\" --id INSERT_CONTRACT_ID_HERE --name valocracy"
34
+ }
35
+ ```
36
+
37
+ Obviously you need to adjust the above command based on the actual command you used to generate the library.
38
+
39
+ # Use it
40
+
41
+ Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods:
42
+
43
+ ```js
44
+ import { Contract, networks } from "valocracy"
45
+
46
+ const contract = new Contract({
47
+ ...networks.futurenet, // for example; check which networks this library exports
48
+ rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers
49
+ })
50
+
51
+ contract.|
52
+ ```
53
+
54
+ As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code.