@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,428 @@
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 GovernorError = {
37
+ 1: {message:"AlreadyInitialized"},
38
+ 2: {message:"NotInitialized"},
39
+ 3: {message:"NotAuthorized"},
40
+ 4: {message:"ProposalNotFound"},
41
+ 5: {message:"VotingNotStarted"},
42
+ 6: {message:"VotingEnded"},
43
+ 7: {message:"AlreadyVoted"},
44
+ 8: {message:"NoVotingPower"},
45
+ 9: {message:"ProposalNotSucceeded"},
46
+ 10: {message:"ProposalAlreadyExecuted"},
47
+ 11: {message:"InvalidProposalState"},
48
+ 12: {message:"NotAMember"},
49
+ 13: {message:"ReentrancyDetected"}
50
+ }
51
+
52
+
53
+ export interface GovernanceConfig {
54
+ /**
55
+ * Minimum Mana required to create a proposal
56
+ */
57
+ proposal_threshold: u64;
58
+ /**
59
+ * Percentage of votes required for a proposal to pass (e.g. 51)
60
+ */
61
+ quorum_percentage: u64;
62
+ /**
63
+ * Voting delay in seconds (time between proposal creation and voting start)
64
+ */
65
+ voting_delay: u64;
66
+ /**
67
+ * Voting period in seconds (duration of voting)
68
+ */
69
+ voting_period: u64;
70
+ }
71
+
72
+ /**
73
+ * Storage keys for the Governor contract
74
+ */
75
+ export type DataKey = {tag: "Valocracy", values: void} | {tag: "ProposalCount", values: void} | {tag: "Proposal", values: readonly [u64]} | {tag: "Vote", values: readonly [u64, string]} | {tag: "ReentrancyLock", values: void} | {tag: "Config", values: void};
76
+
77
+
78
+ /**
79
+ * An action to execute when proposal succeeds
80
+ */
81
+ export interface Action {
82
+ /**
83
+ * Arguments as raw vals (simplified)
84
+ */
85
+ args: Array<any>;
86
+ /**
87
+ * Contract to call
88
+ */
89
+ contract_id: string;
90
+ /**
91
+ * Function name to invoke
92
+ */
93
+ function: string;
94
+ }
95
+
96
+
97
+ /**
98
+ * A governance proposal
99
+ */
100
+ export interface Proposal {
101
+ /**
102
+ * Actions to execute on success
103
+ */
104
+ actions: Array<Action>;
105
+ /**
106
+ * Total votes against
107
+ */
108
+ against_votes: u64;
109
+ /**
110
+ * Description of the proposal
111
+ */
112
+ description: string;
113
+ /**
114
+ * Timestamp when voting ends
115
+ */
116
+ end_time: u64;
117
+ /**
118
+ * Whether the proposal has been executed
119
+ */
120
+ executed: boolean;
121
+ /**
122
+ * Total votes in favor
123
+ */
124
+ for_votes: u64;
125
+ /**
126
+ * Unique proposal ID
127
+ */
128
+ id: u64;
129
+ /**
130
+ * Address that created the proposal
131
+ */
132
+ proposer: string;
133
+ /**
134
+ * Timestamp when voting starts
135
+ */
136
+ start_time: u64;
137
+ }
138
+
139
+ /**
140
+ * Proposal state enum
141
+ */
142
+ export enum ProposalState {
143
+ Pending = 0,
144
+ Active = 1,
145
+ Succeeded = 2,
146
+ Defeated = 3,
147
+ Executed = 4,
148
+ }
149
+
150
+ export interface Client {
151
+ /**
152
+ * Construct and simulate a execute 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.
153
+ * Execute a succeeded proposal
154
+ */
155
+ execute: ({proposal_id}: {proposal_id: u64}, options?: {
156
+ /**
157
+ * The fee to pay for the transaction. Default: BASE_FEE
158
+ */
159
+ fee?: number;
160
+
161
+ /**
162
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
163
+ */
164
+ timeoutInSeconds?: number;
165
+
166
+ /**
167
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
168
+ */
169
+ simulate?: boolean;
170
+ }) => Promise<AssembledTransaction<Result<void>>>
171
+
172
+ /**
173
+ * Construct and simulate a propose 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.
174
+ * Create a new proposal.
175
+ *
176
+ * Open to any member (level > 0 in the Valocracy contract).
177
+ */
178
+ propose: ({proposer, description, actions}: {proposer: string, description: string, actions: Array<Action>}, options?: {
179
+ /**
180
+ * The fee to pay for the transaction. Default: BASE_FEE
181
+ */
182
+ fee?: number;
183
+
184
+ /**
185
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
186
+ */
187
+ timeoutInSeconds?: number;
188
+
189
+ /**
190
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
191
+ */
192
+ simulate?: boolean;
193
+ }) => Promise<AssembledTransaction<Result<u64>>>
194
+
195
+ /**
196
+ * 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.
197
+ * Upgrade the contract to a new WASM hash.
198
+ * Only callable by the governor itself (requires governance proposal).
199
+ */
200
+ upgrade: ({new_wasm_hash}: {new_wasm_hash: Buffer}, options?: {
201
+ /**
202
+ * The fee to pay for the transaction. Default: BASE_FEE
203
+ */
204
+ fee?: number;
205
+
206
+ /**
207
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
208
+ */
209
+ timeoutInSeconds?: number;
210
+
211
+ /**
212
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
213
+ */
214
+ simulate?: boolean;
215
+ }) => Promise<AssembledTransaction<Result<void>>>
216
+
217
+ /**
218
+ * Construct and simulate a cast_vote 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.
219
+ * Cast a vote on a proposal
220
+ */
221
+ cast_vote: ({voter, proposal_id, support}: {voter: string, proposal_id: u64, support: boolean}, options?: {
222
+ /**
223
+ * The fee to pay for the transaction. Default: BASE_FEE
224
+ */
225
+ fee?: number;
226
+
227
+ /**
228
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
229
+ */
230
+ timeoutInSeconds?: number;
231
+
232
+ /**
233
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
234
+ */
235
+ simulate?: boolean;
236
+ }) => Promise<AssembledTransaction<Result<u64>>>
237
+
238
+ /**
239
+ * Construct and simulate a has_voted 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.
240
+ * Check if an account has voted on a proposal
241
+ */
242
+ has_voted: ({proposal_id, voter}: {proposal_id: u64, voter: string}, options?: {
243
+ /**
244
+ * The fee to pay for the transaction. Default: BASE_FEE
245
+ */
246
+ fee?: number;
247
+
248
+ /**
249
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
250
+ */
251
+ timeoutInSeconds?: number;
252
+
253
+ /**
254
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
255
+ */
256
+ simulate?: boolean;
257
+ }) => Promise<AssembledTransaction<boolean>>
258
+
259
+ /**
260
+ * 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.
261
+ * Get valocracy contract address
262
+ */
263
+ valocracy: (options?: {
264
+ /**
265
+ * The fee to pay for the transaction. Default: BASE_FEE
266
+ */
267
+ fee?: number;
268
+
269
+ /**
270
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
271
+ */
272
+ timeoutInSeconds?: number;
273
+
274
+ /**
275
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
276
+ */
277
+ simulate?: boolean;
278
+ }) => Promise<AssembledTransaction<Option<string>>>
279
+
280
+ /**
281
+ * 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.
282
+ * Initialize the Governor contract.
283
+ *
284
+ * No admin: only stores the Valocracy contract address for membership checks
285
+ * and voting power queries.
286
+ */
287
+ initialize: ({valocracy}: {valocracy: string}, options?: {
288
+ /**
289
+ * The fee to pay for the transaction. Default: BASE_FEE
290
+ */
291
+ fee?: number;
292
+
293
+ /**
294
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
295
+ */
296
+ timeoutInSeconds?: number;
297
+
298
+ /**
299
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
300
+ */
301
+ simulate?: boolean;
302
+ }) => Promise<AssembledTransaction<Result<void>>>
303
+
304
+ /**
305
+ * Construct and simulate a get_proposal 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.
306
+ * Get a proposal by ID
307
+ */
308
+ get_proposal: ({proposal_id}: {proposal_id: u64}, options?: {
309
+ /**
310
+ * The fee to pay for the transaction. Default: BASE_FEE
311
+ */
312
+ fee?: number;
313
+
314
+ /**
315
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
316
+ */
317
+ timeoutInSeconds?: number;
318
+
319
+ /**
320
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
321
+ */
322
+ simulate?: boolean;
323
+ }) => Promise<AssembledTransaction<Option<Proposal>>>
324
+
325
+ /**
326
+ * Construct and simulate a update_config 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.
327
+ * Update governance configuration.
328
+ * Only callable by the Governor (self-governance).
329
+ */
330
+ update_config: ({config}: {config: GovernanceConfig}, options?: {
331
+ /**
332
+ * The fee to pay for the transaction. Default: BASE_FEE
333
+ */
334
+ fee?: number;
335
+
336
+ /**
337
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
338
+ */
339
+ timeoutInSeconds?: number;
340
+
341
+ /**
342
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
343
+ */
344
+ simulate?: boolean;
345
+ }) => Promise<AssembledTransaction<Result<void>>>
346
+
347
+ /**
348
+ * Construct and simulate a proposal_count 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.
349
+ * Get the number of proposals
350
+ */
351
+ proposal_count: (options?: {
352
+ /**
353
+ * The fee to pay for the transaction. Default: BASE_FEE
354
+ */
355
+ fee?: number;
356
+
357
+ /**
358
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
359
+ */
360
+ timeoutInSeconds?: number;
361
+
362
+ /**
363
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
364
+ */
365
+ simulate?: boolean;
366
+ }) => Promise<AssembledTransaction<u64>>
367
+
368
+ /**
369
+ * Construct and simulate a get_proposal_state 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.
370
+ * Get the current state of a proposal
371
+ */
372
+ get_proposal_state: ({proposal_id}: {proposal_id: u64}, options?: {
373
+ /**
374
+ * The fee to pay for the transaction. Default: BASE_FEE
375
+ */
376
+ fee?: number;
377
+
378
+ /**
379
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
380
+ */
381
+ timeoutInSeconds?: number;
382
+
383
+ /**
384
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
385
+ */
386
+ simulate?: boolean;
387
+ }) => Promise<AssembledTransaction<Result<ProposalState>>>
388
+
389
+ }
390
+ export class Client extends ContractClient {
391
+ static async deploy<T = Client>(
392
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
393
+ options: MethodOptions &
394
+ Omit<ContractClientOptions, "contractId"> & {
395
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
396
+ wasmHash: Buffer | string;
397
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
398
+ salt?: Buffer | Uint8Array;
399
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
400
+ format?: "hex" | "base64";
401
+ }
402
+ ): Promise<AssembledTransaction<T>> {
403
+ return ContractClient.deploy(null, options)
404
+ }
405
+ constructor(public readonly options: ContractClientOptions) {
406
+ super(
407
+ new ContractSpec([ "AAAAAAAAABxFeGVjdXRlIGEgc3VjY2VlZGVkIHByb3Bvc2FsAAAAB2V4ZWN1dGUAAAAAAQAAAAAAAAALcHJvcG9zYWxfaWQAAAAABgAAAAEAAAPpAAAD7QAAAAAAAAfQAAAADUdvdmVybm9yRXJyb3IAAAA=",
408
+ "AAAAAAAAAFFDcmVhdGUgYSBuZXcgcHJvcG9zYWwuCgpPcGVuIHRvIGFueSBtZW1iZXIgKGxldmVsID4gMCBpbiB0aGUgVmFsb2NyYWN5IGNvbnRyYWN0KS4AAAAAAAAHcHJvcG9zZQAAAAADAAAAAAAAAAhwcm9wb3NlcgAAABMAAAAAAAAAC2Rlc2NyaXB0aW9uAAAAABAAAAAAAAAAB2FjdGlvbnMAAAAD6gAAB9AAAA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B2b3RlcyBpbiBmYXZvcgAAAAlmb3Jfdm90ZXMAAAAAAAAGAAAAElVuaXF1ZSBwcm9wb3NhbCBJRAAAAAAAAmlkAAAAAAAGAAAAIUFkZHJlc3MgdGhhdCBjcmVhdGVkIHRoZSBwcm9wb3NhbAAAAAAAAAhwcm9wb3NlcgAAABMAAAAcVGltZXN0YW1wIHdoZW4gdm90aW5nIHN0YXJ0cwAAAApzdGFydF90aW1lAAAAAAAG",
423
+ "AAAAAwAAABNQcm9wb3NhbCBzdGF0ZSBlbnVtAAAAAAAAAAANUHJvcG9zYWxTdGF0ZQAAAAAAAAUAAAAbV2FpdGluZyBmb3Igdm90aW5nIHRvIHN0YXJ0AAAAAAdQZW5kaW5nAAAAAAAAAAAQVm90aW5nIGlzIGFjdGl2ZQAAAAZBY3RpdmUAAAAAAAEAAAAfUHJvcG9zYWwgc3VjY2VlZGVkIChxdW9ydW0gbWV0KQAAAAAJU3VjY2VlZGVkAAAAAAAAAgAAACJQcm9wb3NhbCBkZWZlYXRlZCAocXVvcnVtIG5vdCBtZXQpAAAAAAAIRGVmZWF0ZWQAAAADAAAAGlByb3Bvc2FsIGhhcyBiZWVuIGV4ZWN1dGVkAAAAAAAIRXhlY3V0ZWQAAAAE" ]),
424
+ options
425
+ )
426
+ }
427
+
428
+ }
@@ -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
+ # treasury JS
2
+
3
+ JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `treasury` 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/treasury
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
+ "treasury": "./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 treasury"
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 "treasury"
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.
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "name": "treasury",
4
+ "type": "module",
5
+ "exports": "./dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc"
9
+ },
10
+ "dependencies": {
11
+ "@stellar/stellar-sdk": "^14.1.1",
12
+ "buffer": "6.0.3"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.6.2"
16
+ }
17
+ }