@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/README.md +54 -0
- package/dist/cjs/index.d.ts +344 -0
- package/dist/cjs/index.js +88 -0
- package/dist/esm/index.d.ts +344 -0
- package/dist/esm/index.js +70 -0
- package/dist/esm/package.json +1 -0
- package/dist/scripts/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/scripts/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/scripts/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +344 -0
- package/package.json +25 -0
- package/scripts/build.mjs +37 -0
- package/scripts/tsconfig.cjs.json +7 -0
- package/scripts/tsconfig.esm.json +7 -0
- package/scripts/tsconfig.types.json +8 -0
- package/src/index.ts +421 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { AssembledTransaction, ContractClient, ContractClientOptions } from "@stellar/stellar-sdk/lib/contract_client/index.js";
|
|
2
|
+
import type { u32, i128 } from "@stellar/stellar-sdk/lib/contract_client";
|
|
3
|
+
export * from "@stellar/stellar-sdk";
|
|
4
|
+
export * from "@stellar/stellar-sdk/lib/contract_client/index.js";
|
|
5
|
+
export * from "@stellar/stellar-sdk/lib/rust_types/index.js";
|
|
6
|
+
export declare const networks: {
|
|
7
|
+
readonly testnet: {
|
|
8
|
+
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
9
|
+
readonly contractId: "CBHVVFYF3LZA7JUUBF3KK5SUQ3NWWT2MNCKJPZW6KVV7O7ZMPALFOPHR";
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The error codes for the contract.
|
|
14
|
+
*/
|
|
15
|
+
export declare const Errors: {
|
|
16
|
+
1: {
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
2: {
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
3: {
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
4: {
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
8: {
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
9: {
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
10: {
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
12: {
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export interface TokenMetadata {
|
|
42
|
+
decimal: u32;
|
|
43
|
+
name: string;
|
|
44
|
+
symbol: string;
|
|
45
|
+
}
|
|
46
|
+
export interface AllowanceDataKey {
|
|
47
|
+
from: string;
|
|
48
|
+
spender: string;
|
|
49
|
+
}
|
|
50
|
+
export interface AllowanceValue {
|
|
51
|
+
amount: i128;
|
|
52
|
+
expiration_ledger: u32;
|
|
53
|
+
}
|
|
54
|
+
export type DataKey = {
|
|
55
|
+
tag: "Allowance";
|
|
56
|
+
values: readonly [AllowanceDataKey];
|
|
57
|
+
} | {
|
|
58
|
+
tag: "Balance";
|
|
59
|
+
values: readonly [string];
|
|
60
|
+
} | {
|
|
61
|
+
tag: "Nonce";
|
|
62
|
+
values: readonly [string];
|
|
63
|
+
} | {
|
|
64
|
+
tag: "State";
|
|
65
|
+
values: readonly [string];
|
|
66
|
+
};
|
|
67
|
+
export interface Client {
|
|
68
|
+
/**
|
|
69
|
+
* 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.
|
|
70
|
+
*/
|
|
71
|
+
initialize: ({ admin, decimal, name, symbol, }: {
|
|
72
|
+
admin: string;
|
|
73
|
+
decimal: u32;
|
|
74
|
+
name: string;
|
|
75
|
+
symbol: string;
|
|
76
|
+
}, options?: {
|
|
77
|
+
/**
|
|
78
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
79
|
+
*/
|
|
80
|
+
fee?: number;
|
|
81
|
+
/**
|
|
82
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
83
|
+
*/
|
|
84
|
+
timeoutInSeconds?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
87
|
+
*/
|
|
88
|
+
simulate?: boolean;
|
|
89
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
90
|
+
/**
|
|
91
|
+
* 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.
|
|
92
|
+
*/
|
|
93
|
+
mint: ({ to, amount }: {
|
|
94
|
+
to: string;
|
|
95
|
+
amount: i128;
|
|
96
|
+
}, options?: {
|
|
97
|
+
/**
|
|
98
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
99
|
+
*/
|
|
100
|
+
fee?: number;
|
|
101
|
+
/**
|
|
102
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
103
|
+
*/
|
|
104
|
+
timeoutInSeconds?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
107
|
+
*/
|
|
108
|
+
simulate?: boolean;
|
|
109
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
110
|
+
/**
|
|
111
|
+
* 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.
|
|
112
|
+
*/
|
|
113
|
+
set_admin: ({ new_admin }: {
|
|
114
|
+
new_admin: string;
|
|
115
|
+
}, options?: {
|
|
116
|
+
/**
|
|
117
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
118
|
+
*/
|
|
119
|
+
fee?: number;
|
|
120
|
+
/**
|
|
121
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
122
|
+
*/
|
|
123
|
+
timeoutInSeconds?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
126
|
+
*/
|
|
127
|
+
simulate?: boolean;
|
|
128
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
129
|
+
/**
|
|
130
|
+
* 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.
|
|
131
|
+
*/
|
|
132
|
+
allowance: ({ from, spender }: {
|
|
133
|
+
from: string;
|
|
134
|
+
spender: string;
|
|
135
|
+
}, options?: {
|
|
136
|
+
/**
|
|
137
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
138
|
+
*/
|
|
139
|
+
fee?: number;
|
|
140
|
+
/**
|
|
141
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
142
|
+
*/
|
|
143
|
+
timeoutInSeconds?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
146
|
+
*/
|
|
147
|
+
simulate?: boolean;
|
|
148
|
+
}) => Promise<AssembledTransaction<i128>>;
|
|
149
|
+
/**
|
|
150
|
+
* 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.
|
|
151
|
+
*/
|
|
152
|
+
approve: ({ from, spender, amount, expiration_ledger, }: {
|
|
153
|
+
from: string;
|
|
154
|
+
spender: string;
|
|
155
|
+
amount: i128;
|
|
156
|
+
expiration_ledger: u32;
|
|
157
|
+
}, options?: {
|
|
158
|
+
/**
|
|
159
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
160
|
+
*/
|
|
161
|
+
fee?: number;
|
|
162
|
+
/**
|
|
163
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
164
|
+
*/
|
|
165
|
+
timeoutInSeconds?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
168
|
+
*/
|
|
169
|
+
simulate?: boolean;
|
|
170
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
171
|
+
/**
|
|
172
|
+
* 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.
|
|
173
|
+
*/
|
|
174
|
+
balance: ({ id }: {
|
|
175
|
+
id: string;
|
|
176
|
+
}, options?: {
|
|
177
|
+
/**
|
|
178
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
179
|
+
*/
|
|
180
|
+
fee?: number;
|
|
181
|
+
/**
|
|
182
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
183
|
+
*/
|
|
184
|
+
timeoutInSeconds?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
187
|
+
*/
|
|
188
|
+
simulate?: boolean;
|
|
189
|
+
}) => Promise<AssembledTransaction<i128>>;
|
|
190
|
+
/**
|
|
191
|
+
* 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.
|
|
192
|
+
*/
|
|
193
|
+
transfer: ({ from, to, amount }: {
|
|
194
|
+
from: string;
|
|
195
|
+
to: string;
|
|
196
|
+
amount: i128;
|
|
197
|
+
}, options?: {
|
|
198
|
+
/**
|
|
199
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
200
|
+
*/
|
|
201
|
+
fee?: number;
|
|
202
|
+
/**
|
|
203
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
204
|
+
*/
|
|
205
|
+
timeoutInSeconds?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
208
|
+
*/
|
|
209
|
+
simulate?: boolean;
|
|
210
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
211
|
+
/**
|
|
212
|
+
* 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.
|
|
213
|
+
*/
|
|
214
|
+
transfer_from: ({ spender, from, to, amount, }: {
|
|
215
|
+
spender: string;
|
|
216
|
+
from: string;
|
|
217
|
+
to: string;
|
|
218
|
+
amount: i128;
|
|
219
|
+
}, options?: {
|
|
220
|
+
/**
|
|
221
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
222
|
+
*/
|
|
223
|
+
fee?: number;
|
|
224
|
+
/**
|
|
225
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
226
|
+
*/
|
|
227
|
+
timeoutInSeconds?: number;
|
|
228
|
+
/**
|
|
229
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
230
|
+
*/
|
|
231
|
+
simulate?: boolean;
|
|
232
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
233
|
+
/**
|
|
234
|
+
* 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.
|
|
235
|
+
*/
|
|
236
|
+
burn: ({ from, amount }: {
|
|
237
|
+
from: string;
|
|
238
|
+
amount: i128;
|
|
239
|
+
}, options?: {
|
|
240
|
+
/**
|
|
241
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
242
|
+
*/
|
|
243
|
+
fee?: number;
|
|
244
|
+
/**
|
|
245
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
246
|
+
*/
|
|
247
|
+
timeoutInSeconds?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
250
|
+
*/
|
|
251
|
+
simulate?: boolean;
|
|
252
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
253
|
+
/**
|
|
254
|
+
* 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.
|
|
255
|
+
*/
|
|
256
|
+
burn_from: ({ spender, from, amount }: {
|
|
257
|
+
spender: string;
|
|
258
|
+
from: string;
|
|
259
|
+
amount: i128;
|
|
260
|
+
}, options?: {
|
|
261
|
+
/**
|
|
262
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
263
|
+
*/
|
|
264
|
+
fee?: number;
|
|
265
|
+
/**
|
|
266
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
267
|
+
*/
|
|
268
|
+
timeoutInSeconds?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
271
|
+
*/
|
|
272
|
+
simulate?: boolean;
|
|
273
|
+
}) => Promise<AssembledTransaction<null>>;
|
|
274
|
+
/**
|
|
275
|
+
* 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.
|
|
276
|
+
*/
|
|
277
|
+
decimals: (options?: {
|
|
278
|
+
/**
|
|
279
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
280
|
+
*/
|
|
281
|
+
fee?: number;
|
|
282
|
+
/**
|
|
283
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
284
|
+
*/
|
|
285
|
+
timeoutInSeconds?: number;
|
|
286
|
+
/**
|
|
287
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
288
|
+
*/
|
|
289
|
+
simulate?: boolean;
|
|
290
|
+
}) => Promise<AssembledTransaction<u32>>;
|
|
291
|
+
/**
|
|
292
|
+
* 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.
|
|
293
|
+
*/
|
|
294
|
+
name: (options?: {
|
|
295
|
+
/**
|
|
296
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
297
|
+
*/
|
|
298
|
+
fee?: number;
|
|
299
|
+
/**
|
|
300
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
301
|
+
*/
|
|
302
|
+
timeoutInSeconds?: number;
|
|
303
|
+
/**
|
|
304
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
305
|
+
*/
|
|
306
|
+
simulate?: boolean;
|
|
307
|
+
}) => Promise<AssembledTransaction<string>>;
|
|
308
|
+
/**
|
|
309
|
+
* 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.
|
|
310
|
+
*/
|
|
311
|
+
symbol: (options?: {
|
|
312
|
+
/**
|
|
313
|
+
* The fee to pay for the transaction. Default: BASE_FEE
|
|
314
|
+
*/
|
|
315
|
+
fee?: number;
|
|
316
|
+
/**
|
|
317
|
+
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
|
|
318
|
+
*/
|
|
319
|
+
timeoutInSeconds?: number;
|
|
320
|
+
/**
|
|
321
|
+
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
|
|
322
|
+
*/
|
|
323
|
+
simulate?: boolean;
|
|
324
|
+
}) => Promise<AssembledTransaction<string>>;
|
|
325
|
+
}
|
|
326
|
+
export declare class Client extends ContractClient {
|
|
327
|
+
readonly options: ContractClientOptions;
|
|
328
|
+
constructor(options: ContractClientOptions);
|
|
329
|
+
readonly fromJSON: {
|
|
330
|
+
initialize: (json: string) => AssembledTransaction<null>;
|
|
331
|
+
mint: (json: string) => AssembledTransaction<null>;
|
|
332
|
+
set_admin: (json: string) => AssembledTransaction<null>;
|
|
333
|
+
allowance: (json: string) => AssembledTransaction<bigint>;
|
|
334
|
+
approve: (json: string) => AssembledTransaction<null>;
|
|
335
|
+
balance: (json: string) => AssembledTransaction<bigint>;
|
|
336
|
+
transfer: (json: string) => AssembledTransaction<null>;
|
|
337
|
+
transfer_from: (json: string) => AssembledTransaction<null>;
|
|
338
|
+
burn: (json: string) => AssembledTransaction<null>;
|
|
339
|
+
burn_from: (json: string) => AssembledTransaction<null>;
|
|
340
|
+
decimals: (json: string) => AssembledTransaction<number>;
|
|
341
|
+
name: (json: string) => AssembledTransaction<string>;
|
|
342
|
+
symbol: (json: string) => AssembledTransaction<string>;
|
|
343
|
+
};
|
|
344
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.0.11-beta.7+3d00fa3",
|
|
3
|
+
"name": "@huma-finance/soroban-sep41",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@stellar/freighter-api": "2.0.0",
|
|
6
|
+
"@stellar/stellar-sdk": "11.3.0",
|
|
7
|
+
"buffer": "6.0.3"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "node ./scripts/build.mjs"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
"require": "./dist/cjs/index.js",
|
|
14
|
+
"import": "./dist/esm/index.js"
|
|
15
|
+
},
|
|
16
|
+
"typings": "dist/types/index.d.ts",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "5.3.3"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"gitHead": "3d00fa328e8a468733982ee0b8bffcf559cb4cf0"
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process"
|
|
2
|
+
import fs from "node:fs"
|
|
3
|
+
import path from "node:path"
|
|
4
|
+
|
|
5
|
+
const buildDir = "./dist"
|
|
6
|
+
|
|
7
|
+
const { error, stderr } = spawnSync("tsc", ["-b", "./scripts/tsconfig.cjs.json", "./scripts/tsconfig.esm.json", "./scripts/tsconfig.types.json"], { stdio: "inherit" })
|
|
8
|
+
|
|
9
|
+
if (error) {
|
|
10
|
+
console.error(stderr)
|
|
11
|
+
console.error(error)
|
|
12
|
+
throw error
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function createEsmModulePackageJson() {
|
|
16
|
+
fs.readdir(buildDir, function (err, dirs) {
|
|
17
|
+
if (err) {
|
|
18
|
+
throw err
|
|
19
|
+
}
|
|
20
|
+
dirs.forEach(function (dir) {
|
|
21
|
+
if (dir === "esm") {
|
|
22
|
+
// 1. add package.json file with "type": "module"
|
|
23
|
+
var packageJsonFile = path.join(buildDir, dir, "/package.json")
|
|
24
|
+
if (!fs.existsSync(packageJsonFile)) {
|
|
25
|
+
fs.writeFileSync(
|
|
26
|
+
packageJsonFile,
|
|
27
|
+
'{"type": "module"}',
|
|
28
|
+
'utf8',
|
|
29
|
+
err => { if (err) throw err }
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
createEsmModulePackageJson()
|