@huma-finance/soroban-huma-config 0.0.31 → 0.0.32-beta.179

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.
@@ -1,16 +1,16 @@
1
1
  import { Buffer } from "buffer";
2
- import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/contract';
3
- import type { u32 } from '@stellar/stellar-sdk/contract';
4
- export * from '@stellar/stellar-sdk';
5
- export * as contract from '@stellar/stellar-sdk/contract';
6
- export * as rpc from '@stellar/stellar-sdk/rpc';
2
+ import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions } from "@stellar/stellar-sdk/contract";
3
+ import type { u32 } from "@stellar/stellar-sdk/contract";
4
+ export * from "@stellar/stellar-sdk";
5
+ export * as contract from "@stellar/stellar-sdk/contract";
6
+ export * as rpc from "@stellar/stellar-sdk/rpc";
7
7
  export declare const networks: {
8
8
  readonly testnet: {
9
9
  readonly networkPassphrase: "Test SDF Network ; September 2015";
10
- readonly contractId: "CAMYYWFQOTFGWVGPT5R4TIGS56SDQPXJ6K37KLKOBA4G3ZLPMPPBW67K";
10
+ readonly contractId: "CDFM2ITMGBNOEVZ5LYOLOIRFYZ74M3EP2SD2KT36XESTBML4APJIW5KO";
11
11
  };
12
12
  };
13
- export declare const Errors: {
13
+ export declare const HumaConfigError: {
14
14
  101: {
15
15
  message: string;
16
16
  };
@@ -20,27 +20,6 @@ export declare const Errors: {
20
20
  103: {
21
21
  message: string;
22
22
  };
23
- 1: {
24
- message: string;
25
- };
26
- 2: {
27
- message: string;
28
- };
29
- 3: {
30
- message: string;
31
- };
32
- 4: {
33
- message: string;
34
- };
35
- 5: {
36
- message: string;
37
- };
38
- 6: {
39
- message: string;
40
- };
41
- 7: {
42
- message: string;
43
- };
44
23
  };
45
24
  export type HumaConfigDataKey = {
46
25
  tag: "HumaOwner";
@@ -100,6 +79,29 @@ export interface ProtocolFeeChangedEvent {
100
79
  new_fee_bps: u32;
101
80
  old_fee_bps: u32;
102
81
  }
82
+ export declare const CommonError: {
83
+ 1: {
84
+ message: string;
85
+ };
86
+ 2: {
87
+ message: string;
88
+ };
89
+ 3: {
90
+ message: string;
91
+ };
92
+ 4: {
93
+ message: string;
94
+ };
95
+ 5: {
96
+ message: string;
97
+ };
98
+ 6: {
99
+ message: string;
100
+ };
101
+ 7: {
102
+ message: string;
103
+ };
104
+ };
103
105
  export interface Client {
104
106
  /**
105
107
  * 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.
@@ -108,335 +110,111 @@ export interface Client {
108
110
  huma_owner: string;
109
111
  huma_treasury: string;
110
112
  sentinel: string;
111
- }, options?: {
112
- /**
113
- * The fee to pay for the transaction. Default: BASE_FEE
114
- */
115
- fee?: number;
116
- /**
117
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
118
- */
119
- timeoutInSeconds?: number;
120
- /**
121
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
122
- */
123
- simulate?: boolean;
124
- }) => Promise<AssembledTransaction<null>>;
113
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
125
114
  /**
126
115
  * Construct and simulate a set_huma_owner 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.
127
116
  */
128
117
  set_huma_owner: ({ addr }: {
129
118
  addr: string;
130
- }, options?: {
131
- /**
132
- * The fee to pay for the transaction. Default: BASE_FEE
133
- */
134
- fee?: number;
135
- /**
136
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
137
- */
138
- timeoutInSeconds?: number;
139
- /**
140
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
141
- */
142
- simulate?: boolean;
143
- }) => Promise<AssembledTransaction<null>>;
119
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
144
120
  /**
145
121
  * Construct and simulate a set_huma_treasury 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.
146
122
  */
147
123
  set_huma_treasury: ({ addr }: {
148
124
  addr: string;
149
- }, options?: {
150
- /**
151
- * The fee to pay for the transaction. Default: BASE_FEE
152
- */
153
- fee?: number;
154
- /**
155
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
156
- */
157
- timeoutInSeconds?: number;
158
- /**
159
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
160
- */
161
- simulate?: boolean;
162
- }) => Promise<AssembledTransaction<null>>;
125
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
163
126
  /**
164
127
  * Construct and simulate a set_sentinel 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
128
  */
166
129
  set_sentinel: ({ addr }: {
167
130
  addr: string;
168
- }, options?: {
169
- /**
170
- * The fee to pay for the transaction. Default: BASE_FEE
171
- */
172
- fee?: number;
173
- /**
174
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
175
- */
176
- timeoutInSeconds?: number;
177
- /**
178
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
179
- */
180
- simulate?: boolean;
181
- }) => Promise<AssembledTransaction<null>>;
131
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
182
132
  /**
183
133
  * Construct and simulate a set_liquidity_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.
184
134
  */
185
135
  set_liquidity_asset: ({ addr, valid }: {
186
136
  addr: string;
187
137
  valid: boolean;
188
- }, options?: {
189
- /**
190
- * The fee to pay for the transaction. Default: BASE_FEE
191
- */
192
- fee?: number;
193
- /**
194
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
195
- */
196
- timeoutInSeconds?: number;
197
- /**
198
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
199
- */
200
- simulate?: boolean;
201
- }) => Promise<AssembledTransaction<null>>;
138
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
202
139
  /**
203
140
  * Construct and simulate a set_protocol_fee_bps 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.
204
141
  */
205
142
  set_protocol_fee_bps: ({ fee_bps }: {
206
143
  fee_bps: u32;
207
- }, options?: {
208
- /**
209
- * The fee to pay for the transaction. Default: BASE_FEE
210
- */
211
- fee?: number;
212
- /**
213
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
214
- */
215
- timeoutInSeconds?: number;
216
- /**
217
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
218
- */
219
- simulate?: boolean;
220
- }) => Promise<AssembledTransaction<null>>;
144
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
221
145
  /**
222
146
  * Construct and simulate a pause_protocol 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.
223
147
  */
224
148
  pause_protocol: ({ caller }: {
225
149
  caller: string;
226
- }, options?: {
227
- /**
228
- * The fee to pay for the transaction. Default: BASE_FEE
229
- */
230
- fee?: number;
231
- /**
232
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
233
- */
234
- timeoutInSeconds?: number;
235
- /**
236
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
237
- */
238
- simulate?: boolean;
239
- }) => Promise<AssembledTransaction<null>>;
150
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
240
151
  /**
241
152
  * Construct and simulate a unpause_protocol 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.
242
153
  */
243
- unpause_protocol: (options?: {
244
- /**
245
- * The fee to pay for the transaction. Default: BASE_FEE
246
- */
247
- fee?: number;
248
- /**
249
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
250
- */
251
- timeoutInSeconds?: number;
252
- /**
253
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
254
- */
255
- simulate?: boolean;
256
- }) => Promise<AssembledTransaction<null>>;
154
+ unpause_protocol: (options?: MethodOptions) => Promise<AssembledTransaction<null>>;
257
155
  /**
258
156
  * Construct and simulate a add_pauser 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.
259
157
  */
260
158
  add_pauser: ({ addr }: {
261
159
  addr: string;
262
- }, options?: {
263
- /**
264
- * The fee to pay for the transaction. Default: BASE_FEE
265
- */
266
- fee?: number;
267
- /**
268
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
269
- */
270
- timeoutInSeconds?: number;
271
- /**
272
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
273
- */
274
- simulate?: boolean;
275
- }) => Promise<AssembledTransaction<null>>;
160
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
276
161
  /**
277
162
  * Construct and simulate a remove_pauser 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.
278
163
  */
279
164
  remove_pauser: ({ addr }: {
280
165
  addr: string;
281
- }, options?: {
282
- /**
283
- * The fee to pay for the transaction. Default: BASE_FEE
284
- */
285
- fee?: number;
286
- /**
287
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
288
- */
289
- timeoutInSeconds?: number;
290
- /**
291
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
292
- */
293
- simulate?: boolean;
294
- }) => Promise<AssembledTransaction<null>>;
166
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
295
167
  /**
296
168
  * 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.
297
169
  */
298
170
  upgrade: ({ new_wasm_hash }: {
299
171
  new_wasm_hash: Buffer;
300
- }, options?: {
301
- /**
302
- * The fee to pay for the transaction. Default: BASE_FEE
303
- */
304
- fee?: number;
305
- /**
306
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
307
- */
308
- timeoutInSeconds?: number;
309
- /**
310
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
311
- */
312
- simulate?: boolean;
313
- }) => Promise<AssembledTransaction<null>>;
172
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
314
173
  /**
315
174
  * Construct and simulate a get_huma_owner 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.
316
175
  */
317
- get_huma_owner: (options?: {
318
- /**
319
- * The fee to pay for the transaction. Default: BASE_FEE
320
- */
321
- fee?: number;
322
- /**
323
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
324
- */
325
- timeoutInSeconds?: number;
326
- /**
327
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
328
- */
329
- simulate?: boolean;
330
- }) => Promise<AssembledTransaction<string>>;
176
+ get_huma_owner: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
331
177
  /**
332
178
  * Construct and simulate a get_huma_treasury 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.
333
179
  */
334
- get_huma_treasury: (options?: {
335
- /**
336
- * The fee to pay for the transaction. Default: BASE_FEE
337
- */
338
- fee?: number;
339
- /**
340
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
341
- */
342
- timeoutInSeconds?: number;
343
- /**
344
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
345
- */
346
- simulate?: boolean;
347
- }) => Promise<AssembledTransaction<string>>;
180
+ get_huma_treasury: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
348
181
  /**
349
182
  * Construct and simulate a get_sentinel 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.
350
183
  */
351
- get_sentinel: (options?: {
352
- /**
353
- * The fee to pay for the transaction. Default: BASE_FEE
354
- */
355
- fee?: number;
356
- /**
357
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
358
- */
359
- timeoutInSeconds?: number;
360
- /**
361
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
362
- */
363
- simulate?: boolean;
364
- }) => Promise<AssembledTransaction<string>>;
184
+ get_sentinel: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
365
185
  /**
366
186
  * Construct and simulate a get_protocol_fee_bps 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.
367
187
  */
368
- get_protocol_fee_bps: (options?: {
369
- /**
370
- * The fee to pay for the transaction. Default: BASE_FEE
371
- */
372
- fee?: number;
373
- /**
374
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
375
- */
376
- timeoutInSeconds?: number;
377
- /**
378
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
379
- */
380
- simulate?: boolean;
381
- }) => Promise<AssembledTransaction<u32>>;
188
+ get_protocol_fee_bps: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
382
189
  /**
383
190
  * Construct and simulate a is_pauser 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.
384
191
  */
385
192
  is_pauser: ({ addr }: {
386
193
  addr: string;
387
- }, options?: {
388
- /**
389
- * The fee to pay for the transaction. Default: BASE_FEE
390
- */
391
- fee?: number;
392
- /**
393
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
394
- */
395
- timeoutInSeconds?: number;
396
- /**
397
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
398
- */
399
- simulate?: boolean;
400
- }) => Promise<AssembledTransaction<boolean>>;
194
+ }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
401
195
  /**
402
196
  * Construct and simulate a is_protocol_paused 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.
403
197
  */
404
- is_protocol_paused: (options?: {
405
- /**
406
- * The fee to pay for the transaction. Default: BASE_FEE
407
- */
408
- fee?: number;
409
- /**
410
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
411
- */
412
- timeoutInSeconds?: number;
413
- /**
414
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
415
- */
416
- simulate?: boolean;
417
- }) => Promise<AssembledTransaction<boolean>>;
198
+ is_protocol_paused: (options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
418
199
  /**
419
200
  * Construct and simulate a is_asset_valid 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.
420
201
  */
421
202
  is_asset_valid: ({ addr }: {
422
203
  addr: string;
423
- }, options?: {
424
- /**
425
- * The fee to pay for the transaction. Default: BASE_FEE
426
- */
427
- fee?: number;
428
- /**
429
- * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
430
- */
431
- timeoutInSeconds?: number;
432
- /**
433
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
434
- */
435
- simulate?: boolean;
436
- }) => Promise<AssembledTransaction<boolean>>;
204
+ }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
437
205
  }
438
206
  export declare class Client extends ContractClient {
439
207
  readonly options: ContractClientOptions;
208
+ static deploy<T = Client>(
209
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
210
+ options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
211
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
212
+ wasmHash: Buffer | string;
213
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
214
+ salt?: Buffer | Uint8Array;
215
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
216
+ format?: "hex" | "base64";
217
+ }): Promise<AssembledTransaction<T>>;
440
218
  constructor(options: ContractClientOptions);
441
219
  readonly fromJSON: {
442
220
  initialize: (json: string) => AssembledTransaction<null>;
package/dist/cjs/index.js CHANGED
@@ -36,26 +36,28 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Client = exports.Errors = exports.networks = exports.rpc = exports.contract = void 0;
39
+ exports.Client = exports.CommonError = exports.HumaConfigError = exports.networks = exports.rpc = exports.contract = void 0;
40
40
  const buffer_1 = require("buffer");
41
41
  const contract_1 = require("@stellar/stellar-sdk/contract");
42
42
  __exportStar(require("@stellar/stellar-sdk"), exports);
43
43
  exports.contract = __importStar(require("@stellar/stellar-sdk/contract"));
44
44
  exports.rpc = __importStar(require("@stellar/stellar-sdk/rpc"));
45
- if (typeof window !== 'undefined') {
45
+ if (typeof window !== "undefined") {
46
46
  //@ts-ignore Buffer exists
47
47
  window.Buffer = window.Buffer || buffer_1.Buffer;
48
48
  }
49
49
  exports.networks = {
50
50
  testnet: {
51
51
  networkPassphrase: "Test SDF Network ; September 2015",
52
- contractId: "CAMYYWFQOTFGWVGPT5R4TIGS56SDQPXJ6K37KLKOBA4G3ZLPMPPBW67K",
52
+ contractId: "CDFM2ITMGBNOEVZ5LYOLOIRFYZ74M3EP2SD2KT36XESTBML4APJIW5KO",
53
53
  }
54
54
  };
55
- exports.Errors = {
55
+ exports.HumaConfigError = {
56
56
  101: { message: "PauserRequired" },
57
57
  102: { message: "ProtocolFeeHigherThanUpperLimit" },
58
- 103: { message: "InvalidNumberOfDecimalsForLiquidityAsset" },
58
+ 103: { message: "InvalidNumberOfDecimalsForLiquidityAsset" }
59
+ };
60
+ exports.CommonError = {
59
61
  1: { message: "AlreadyInitialized" },
60
62
  2: { message: "ProtocolIsPausedOrPoolIsNotOn" },
61
63
  3: { message: "PoolOwnerOrHumaOwnerRequired" },
@@ -66,6 +68,11 @@ exports.Errors = {
66
68
  };
67
69
  class Client extends contract_1.Client {
68
70
  options;
71
+ static async deploy(
72
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
73
+ options) {
74
+ return contract_1.Client.deploy(null, options);
75
+ }
69
76
  constructor(options) {
70
77
  super(new contract_1.Spec(["AAAAAAAAAAAAAAAKaW5pdGlhbGl6ZQAAAAAAAwAAAAAAAAAKaHVtYV9vd25lcgAAAAAAEwAAAAAAAAANaHVtYV90cmVhc3VyeQAAAAAAABMAAAAAAAAACHNlbnRpbmVsAAAAEwAAAAA=",
71
78
  "AAAAAAAAAAAAAAAOc2V0X2h1bWFfb3duZXIAAAAAAAEAAAAAAAAABGFkZHIAAAATAAAAAA==",