@huma-finance/soroban-sep41 0.0.11-beta.7

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.
package/src/index.ts ADDED
@@ -0,0 +1,421 @@
1
+ import { ContractSpec, Address } from "@stellar/stellar-sdk";
2
+ import { Buffer } from "buffer";
3
+ import {
4
+ AssembledTransaction,
5
+ ContractClient,
6
+ ContractClientOptions,
7
+ } from "@stellar/stellar-sdk/lib/contract_client/index.js";
8
+ import type {
9
+ u32,
10
+ i32,
11
+ u64,
12
+ i64,
13
+ u128,
14
+ i128,
15
+ u256,
16
+ i256,
17
+ Option,
18
+ Typepoint,
19
+ Duration,
20
+ } from "@stellar/stellar-sdk/lib/contract_client";
21
+ import { Result } from "@stellar/stellar-sdk/lib/rust_types/index.js";
22
+ export * from "@stellar/stellar-sdk";
23
+ export * from "@stellar/stellar-sdk/lib/contract_client/index.js";
24
+ export * from "@stellar/stellar-sdk/lib/rust_types/index.js";
25
+
26
+ if (typeof window !== "undefined") {
27
+ //@ts-ignore Buffer exists
28
+ window.Buffer = window.Buffer || Buffer;
29
+ }
30
+
31
+ export const networks = {
32
+ testnet: {
33
+ networkPassphrase: "Test SDF Network ; September 2015",
34
+ contractId: "CBHVVFYF3LZA7JUUBF3KK5SUQ3NWWT2MNCKJPZW6KVV7O7ZMPALFOPHR",
35
+ },
36
+ } as const;
37
+
38
+ /**
39
+ * The error codes for the contract.
40
+ */
41
+ export const Errors = {
42
+ 1: { message: "" },
43
+ 2: { message: "" },
44
+ 3: { message: "" },
45
+ 4: { message: "" },
46
+ 8: { message: "" },
47
+ 9: { message: "" },
48
+ 10: { message: "" },
49
+ 12: { message: "" },
50
+ };
51
+
52
+ export interface TokenMetadata {
53
+ decimal: u32;
54
+ name: string;
55
+ symbol: string;
56
+ }
57
+
58
+ export interface AllowanceDataKey {
59
+ from: string;
60
+ spender: string;
61
+ }
62
+
63
+ export interface AllowanceValue {
64
+ amount: i128;
65
+ expiration_ledger: u32;
66
+ }
67
+
68
+ export type DataKey =
69
+ | { tag: "Allowance"; values: readonly [AllowanceDataKey] }
70
+ | { tag: "Balance"; values: readonly [string] }
71
+ | { tag: "Nonce"; values: readonly [string] }
72
+ | { tag: "State"; values: readonly [string] };
73
+
74
+ export interface Client {
75
+ /**
76
+ * 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.
77
+ */
78
+ initialize: (
79
+ {
80
+ admin,
81
+ decimal,
82
+ name,
83
+ symbol,
84
+ }: { admin: string; decimal: u32; name: string; symbol: string },
85
+ options?: {
86
+ /**
87
+ * The fee to pay for the transaction. Default: BASE_FEE
88
+ */
89
+ fee?: number;
90
+
91
+ /**
92
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
93
+ */
94
+ timeoutInSeconds?: number;
95
+
96
+ /**
97
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
98
+ */
99
+ simulate?: boolean;
100
+ }
101
+ ) => Promise<AssembledTransaction<null>>;
102
+
103
+ /**
104
+ * Construct and simulate a mint 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.
105
+ */
106
+ mint: (
107
+ { to, amount }: { to: string; amount: i128 },
108
+ options?: {
109
+ /**
110
+ * The fee to pay for the transaction. Default: BASE_FEE
111
+ */
112
+ fee?: number;
113
+
114
+ /**
115
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
116
+ */
117
+ timeoutInSeconds?: number;
118
+
119
+ /**
120
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
121
+ */
122
+ simulate?: boolean;
123
+ }
124
+ ) => Promise<AssembledTransaction<null>>;
125
+
126
+ /**
127
+ * Construct and simulate a set_admin 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.
128
+ */
129
+ set_admin: (
130
+ { new_admin }: { new_admin: string },
131
+ options?: {
132
+ /**
133
+ * The fee to pay for the transaction. Default: BASE_FEE
134
+ */
135
+ fee?: number;
136
+
137
+ /**
138
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
139
+ */
140
+ timeoutInSeconds?: number;
141
+
142
+ /**
143
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
144
+ */
145
+ simulate?: boolean;
146
+ }
147
+ ) => Promise<AssembledTransaction<null>>;
148
+
149
+ /**
150
+ * Construct and simulate a allowance 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.
151
+ */
152
+ allowance: (
153
+ { from, spender }: { from: string; spender: string },
154
+ options?: {
155
+ /**
156
+ * The fee to pay for the transaction. Default: BASE_FEE
157
+ */
158
+ fee?: number;
159
+
160
+ /**
161
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
162
+ */
163
+ timeoutInSeconds?: number;
164
+
165
+ /**
166
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
167
+ */
168
+ simulate?: boolean;
169
+ }
170
+ ) => Promise<AssembledTransaction<i128>>;
171
+
172
+ /**
173
+ * Construct and simulate a approve 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
+ */
175
+ approve: (
176
+ {
177
+ from,
178
+ spender,
179
+ amount,
180
+ expiration_ledger,
181
+ }: { from: string; spender: string; amount: i128; expiration_ledger: u32 },
182
+ options?: {
183
+ /**
184
+ * The fee to pay for the transaction. Default: BASE_FEE
185
+ */
186
+ fee?: number;
187
+
188
+ /**
189
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
190
+ */
191
+ timeoutInSeconds?: number;
192
+
193
+ /**
194
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
195
+ */
196
+ simulate?: boolean;
197
+ }
198
+ ) => Promise<AssembledTransaction<null>>;
199
+
200
+ /**
201
+ * Construct and simulate a 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.
202
+ */
203
+ balance: (
204
+ { id }: { id: string },
205
+ options?: {
206
+ /**
207
+ * The fee to pay for the transaction. Default: BASE_FEE
208
+ */
209
+ fee?: number;
210
+
211
+ /**
212
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
213
+ */
214
+ timeoutInSeconds?: number;
215
+
216
+ /**
217
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
218
+ */
219
+ simulate?: boolean;
220
+ }
221
+ ) => Promise<AssembledTransaction<i128>>;
222
+
223
+ /**
224
+ * Construct and simulate a transfer 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.
225
+ */
226
+ transfer: (
227
+ { from, to, amount }: { from: string; to: string; amount: i128 },
228
+ options?: {
229
+ /**
230
+ * The fee to pay for the transaction. Default: BASE_FEE
231
+ */
232
+ fee?: number;
233
+
234
+ /**
235
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
236
+ */
237
+ timeoutInSeconds?: number;
238
+
239
+ /**
240
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
241
+ */
242
+ simulate?: boolean;
243
+ }
244
+ ) => Promise<AssembledTransaction<null>>;
245
+
246
+ /**
247
+ * Construct and simulate a transfer_from 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.
248
+ */
249
+ transfer_from: (
250
+ {
251
+ spender,
252
+ from,
253
+ to,
254
+ amount,
255
+ }: { spender: string; from: string; to: string; amount: i128 },
256
+ options?: {
257
+ /**
258
+ * The fee to pay for the transaction. Default: BASE_FEE
259
+ */
260
+ fee?: number;
261
+
262
+ /**
263
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
264
+ */
265
+ timeoutInSeconds?: number;
266
+
267
+ /**
268
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
269
+ */
270
+ simulate?: boolean;
271
+ }
272
+ ) => Promise<AssembledTransaction<null>>;
273
+
274
+ /**
275
+ * Construct and simulate a burn 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.
276
+ */
277
+ burn: (
278
+ { from, amount }: { from: string; amount: i128 },
279
+ 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
+ }
295
+ ) => Promise<AssembledTransaction<null>>;
296
+
297
+ /**
298
+ * Construct and simulate a burn_from 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.
299
+ */
300
+ burn_from: (
301
+ { spender, from, amount }: { spender: string; from: string; amount: i128 },
302
+ options?: {
303
+ /**
304
+ * The fee to pay for the transaction. Default: BASE_FEE
305
+ */
306
+ fee?: number;
307
+
308
+ /**
309
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
310
+ */
311
+ timeoutInSeconds?: number;
312
+
313
+ /**
314
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
315
+ */
316
+ simulate?: boolean;
317
+ }
318
+ ) => Promise<AssembledTransaction<null>>;
319
+
320
+ /**
321
+ * Construct and simulate a decimals 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.
322
+ */
323
+ decimals: (options?: {
324
+ /**
325
+ * The fee to pay for the transaction. Default: BASE_FEE
326
+ */
327
+ fee?: number;
328
+
329
+ /**
330
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
331
+ */
332
+ timeoutInSeconds?: number;
333
+
334
+ /**
335
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
336
+ */
337
+ simulate?: boolean;
338
+ }) => Promise<AssembledTransaction<u32>>;
339
+
340
+ /**
341
+ * Construct and simulate a name 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.
342
+ */
343
+ name: (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<string>>;
359
+
360
+ /**
361
+ * Construct and simulate a symbol 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
+ */
363
+ symbol: (options?: {
364
+ /**
365
+ * The fee to pay for the transaction. Default: BASE_FEE
366
+ */
367
+ fee?: number;
368
+
369
+ /**
370
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
371
+ */
372
+ timeoutInSeconds?: number;
373
+
374
+ /**
375
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
376
+ */
377
+ simulate?: boolean;
378
+ }) => Promise<AssembledTransaction<string>>;
379
+ }
380
+ export class Client extends ContractClient {
381
+ constructor(public readonly options: ContractClientOptions) {
382
+ super(
383
+ new ContractSpec([
384
+ "AAAAAAA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bG93YW5jZQAAAAAAAAEAAAfQAAAAEEFsbG93YW5jZURhdGFLZXkAAAABAAAAAAAAAAdCYWxhbmNlAAAAAAEAAAATAAAAAQAAAAAAAAAFTm9uY2UAAAAAAAABAAAAEwAAAAEAAAAAAAAABVN0YXRlAAAAAAAAAQAAABM=",
402
+ ]),
403
+ options
404
+ );
405
+ }
406
+ public readonly fromJSON = {
407
+ initialize: this.txFromJSON<null>,
408
+ mint: this.txFromJSON<null>,
409
+ set_admin: this.txFromJSON<null>,
410
+ allowance: this.txFromJSON<i128>,
411
+ approve: this.txFromJSON<null>,
412
+ balance: this.txFromJSON<i128>,
413
+ transfer: this.txFromJSON<null>,
414
+ transfer_from: this.txFromJSON<null>,
415
+ burn: this.txFromJSON<null>,
416
+ burn_from: this.txFromJSON<null>,
417
+ decimals: this.txFromJSON<u32>,
418
+ name: this.txFromJSON<string>,
419
+ symbol: this.txFromJSON<string>,
420
+ };
421
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "include": ["src/**/*"],
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "rootDir": "./src",
8
+ "outDir": "dist",
9
+ "moduleResolution": "node",
10
+ "declaration": true,
11
+ "strictNullChecks": true,
12
+ "skipLibCheck": true
13
+ }
14
+ }