@stellar/stellar-sdk 12.0.0-rc.1 → 12.0.0-rc.3
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/CHANGELOG.md +80 -1
- package/README.md +1 -1
- package/dist/stellar-sdk.js +1643 -466
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/{contract_client → contract}/assembled_transaction.d.ts +59 -40
- package/lib/{contract_client → contract}/assembled_transaction.js +128 -146
- package/lib/{contract_client → contract}/basic_node_signer.d.ts +2 -2
- package/lib/{contract_client → contract}/basic_node_signer.js +3 -3
- package/lib/contract/client.d.ts +51 -0
- package/lib/contract/client.js +177 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/{contract_client → contract}/index.js +19 -8
- package/lib/{contract_client → contract}/sent_transaction.d.ts +21 -10
- package/lib/{contract_client → contract}/sent_transaction.js +38 -19
- package/lib/{contract_spec.d.ts → contract/spec.d.ts} +3 -3
- package/lib/{contract_spec.js → contract/spec.js} +160 -160
- package/lib/{contract_client → contract}/types.d.ts +10 -8
- package/lib/contract/utils.d.ts +40 -0
- package/lib/{contract_client → contract}/utils.js +13 -3
- package/lib/index.d.ts +26 -2
- package/lib/index.js +10 -16
- package/lib/rpc/index.d.ts +7 -0
- package/lib/{soroban → rpc}/server.d.ts +49 -0
- package/lib/{soroban → rpc}/server.js +199 -118
- package/package.json +20 -3
- package/lib/contract_client/client.d.ts +0 -17
- package/lib/contract_client/client.js +0 -57
- package/lib/contract_client/index.d.ts +0 -6
- package/lib/contract_client/utils.d.ts +0 -23
- package/lib/rust_types/index.d.ts +0 -1
- package/lib/rust_types/index.js +0 -16
- package/lib/soroban/index.d.ts +0 -7
- /package/lib/{rust_types/result.d.ts → contract/rust_result.d.ts} +0 -0
- /package/lib/{rust_types/result.js → contract/rust_result.js} +0 -0
- /package/lib/{contract_client → contract}/types.js +0 -0
- /package/lib/{soroban → rpc}/api.d.ts +0 -0
- /package/lib/{soroban → rpc}/api.js +0 -0
- /package/lib/{soroban → rpc}/axios.d.ts +0 -0
- /package/lib/{soroban → rpc}/axios.js +0 -0
- /package/lib/{soroban → rpc}/browser.d.ts +0 -0
- /package/lib/{soroban → rpc}/browser.js +0 -0
- /package/lib/{soroban → rpc}/index.js +0 -0
- /package/lib/{soroban → rpc}/jsonrpc.d.ts +0 -0
- /package/lib/{soroban → rpc}/jsonrpc.js +0 -0
- /package/lib/{soroban → rpc}/parsers.d.ts +0 -0
- /package/lib/{soroban → rpc}/parsers.js +0 -0
- /package/lib/{soroban → rpc}/transaction.d.ts +0 -0
- /package/lib/{soroban → rpc}/transaction.js +0 -0
- /package/lib/{soroban → rpc}/utils.d.ts +0 -0
- /package/lib/{soroban → rpc}/utils.js +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { TransactionBuilder, xdr } from "@stellar/stellar-base";
|
|
2
|
+
import type { AssembledTransactionOptions, ClientOptions, Tx, XDR_BASE64 } from "./types";
|
|
3
|
+
import { Api } from "../rpc/api";
|
|
3
4
|
import { SentTransaction } from "./sent_transaction";
|
|
4
5
|
export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
5
6
|
/**
|
|
6
|
-
* The main workhorse of {@link
|
|
7
|
+
* The main workhorse of {@link Client}. This class is used to wrap a
|
|
7
8
|
* transaction-under-construction and provide high-level interfaces to the most
|
|
8
9
|
* common workflows, while still providing access to low-level stellar-sdk
|
|
9
10
|
* transaction manipulation.
|
|
10
11
|
*
|
|
11
12
|
* Most of the time, you will not construct an `AssembledTransaction` directly,
|
|
12
|
-
* but instead receive one as the return value of a `
|
|
13
|
+
* but instead receive one as the return value of a `Client` method. If
|
|
13
14
|
* you're familiar with the libraries generated by soroban-cli's `contract
|
|
14
|
-
* bindings typescript` command, these also wraps `
|
|
15
|
+
* bindings typescript` command, these also wraps `Client` and return
|
|
15
16
|
* `AssembledTransaction` instances.
|
|
16
17
|
*
|
|
17
18
|
* Let's look at examples of how to use `AssembledTransaction` for a variety of
|
|
@@ -25,20 +26,29 @@ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
25
26
|
* ```ts
|
|
26
27
|
* const { result } = await AssembledTransaction.build({
|
|
27
28
|
* method: 'myReadMethod',
|
|
28
|
-
* args: spec.funcArgsToScVals('myReadMethod', {
|
|
29
|
+
* args: spec.funcArgsToScVals('myReadMethod', {
|
|
30
|
+
* args: 'for',
|
|
31
|
+
* my: 'method',
|
|
32
|
+
* ...
|
|
33
|
+
* }),
|
|
29
34
|
* contractId: 'C123…',
|
|
30
35
|
* networkPassphrase: '…',
|
|
31
36
|
* rpcUrl: 'https://…',
|
|
32
|
-
* publicKey:
|
|
33
|
-
* parseResultXdr: (result: xdr.ScVal) =>
|
|
37
|
+
* publicKey: undefined, // irrelevant, for simulation-only read calls
|
|
38
|
+
* parseResultXdr: (result: xdr.ScVal) =>
|
|
39
|
+
* spec.funcResToNative('myReadMethod', result),
|
|
34
40
|
* })
|
|
35
41
|
* ```
|
|
36
42
|
*
|
|
37
43
|
* While that looks pretty complicated, most of the time you will use this in
|
|
38
|
-
* conjunction with {@link
|
|
44
|
+
* conjunction with {@link Client}, which simplifies it to:
|
|
39
45
|
*
|
|
40
46
|
* ```ts
|
|
41
|
-
* const { result } = await client.myReadMethod({
|
|
47
|
+
* const { result } = await client.myReadMethod({
|
|
48
|
+
* args: 'for',
|
|
49
|
+
* my: 'method',
|
|
50
|
+
* ...
|
|
51
|
+
* })
|
|
42
52
|
* ```
|
|
43
53
|
*
|
|
44
54
|
* # 2. Simple write call
|
|
@@ -47,11 +57,15 @@ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
47
57
|
* further manipulation, only one more step is needed:
|
|
48
58
|
*
|
|
49
59
|
* ```ts
|
|
50
|
-
* const assembledTx = await client.myWriteMethod({
|
|
60
|
+
* const assembledTx = await client.myWriteMethod({
|
|
61
|
+
* args: 'for',
|
|
62
|
+
* my: 'method',
|
|
63
|
+
* ...
|
|
64
|
+
* })
|
|
51
65
|
* const sentTx = await assembledTx.signAndSend()
|
|
52
66
|
* ```
|
|
53
67
|
*
|
|
54
|
-
* Here we're assuming that you're using a {@link
|
|
68
|
+
* Here we're assuming that you're using a {@link Client}, rather than
|
|
55
69
|
* constructing `AssembledTransaction`'s directly.
|
|
56
70
|
*
|
|
57
71
|
* Note that `sentTx`, the return value of `signAndSend`, is a
|
|
@@ -75,7 +89,7 @@ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
75
89
|
*
|
|
76
90
|
* If you need more control over the transaction before simulating it, you can
|
|
77
91
|
* set various {@link MethodOptions} when constructing your
|
|
78
|
-
* `AssembledTransaction`. With a {@link
|
|
92
|
+
* `AssembledTransaction`. With a {@link Client}, this is passed as a
|
|
79
93
|
* second object after the arguments (or the only object, if the method takes
|
|
80
94
|
* no arguments):
|
|
81
95
|
*
|
|
@@ -101,7 +115,8 @@ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
101
115
|
* await tx.simulate()
|
|
102
116
|
* ```
|
|
103
117
|
*
|
|
104
|
-
* If you need to inspect the simulation later, you can access it with
|
|
118
|
+
* If you need to inspect the simulation later, you can access it with
|
|
119
|
+
* `tx.simulation`.
|
|
105
120
|
*
|
|
106
121
|
* # 4. Multi-auth workflows
|
|
107
122
|
*
|
|
@@ -181,7 +196,7 @@ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
181
196
|
* ```
|
|
182
197
|
*
|
|
183
198
|
* Under the hood, this uses `signAuthEntry`, which you either need to inject
|
|
184
|
-
* during initial construction of the `
|
|
199
|
+
* during initial construction of the `Client`/`AssembledTransaction`,
|
|
185
200
|
* or which you can pass directly to `signAuthEntries`.
|
|
186
201
|
*
|
|
187
202
|
* Now Bob can again serialize the transaction and send back to Alice, where
|
|
@@ -221,13 +236,14 @@ export declare class AssembledTransaction<T> {
|
|
|
221
236
|
* cached, serializable access to the data needed by AssembledTransaction
|
|
222
237
|
* logic.
|
|
223
238
|
*/
|
|
224
|
-
simulation?:
|
|
239
|
+
simulation?: Api.SimulateTransactionResponse;
|
|
225
240
|
/**
|
|
226
241
|
* Cached simulation result. This is set after the first call to
|
|
227
|
-
* {@link simulationData}, and is used to facilitate
|
|
228
|
-
* deserialization of the AssembledTransaction.
|
|
242
|
+
* {@link AssembledTransaction#simulationData}, and is used to facilitate
|
|
243
|
+
* serialization and deserialization of the AssembledTransaction.
|
|
229
244
|
*
|
|
230
|
-
* Most of the time, if you need this data, you can call
|
|
245
|
+
* Most of the time, if you need this data, you can call
|
|
246
|
+
* `tx.simulation.result`.
|
|
231
247
|
*
|
|
232
248
|
* If you need access to this data after a transaction has been serialized
|
|
233
249
|
* and then deserialized, you can call `simulationData.result`.
|
|
@@ -235,10 +251,11 @@ export declare class AssembledTransaction<T> {
|
|
|
235
251
|
private simulationResult?;
|
|
236
252
|
/**
|
|
237
253
|
* Cached simulation transaction data. This is set after the first call to
|
|
238
|
-
* {@link simulationData}, and is used to facilitate
|
|
239
|
-
* deserialization of the AssembledTransaction.
|
|
254
|
+
* {@link AssembledTransaction#simulationData}, and is used to facilitate
|
|
255
|
+
* serialization and deserialization of the AssembledTransaction.
|
|
240
256
|
*
|
|
241
|
-
* Most of the time, if you need this data, you can call
|
|
257
|
+
* Most of the time, if you need this data, you can call
|
|
258
|
+
* `simulation.transactionData`.
|
|
242
259
|
*
|
|
243
260
|
* If you need access to this data after a transaction has been serialized
|
|
244
261
|
* and then deserialized, you can call `simulationData.transactionData`.
|
|
@@ -363,7 +380,7 @@ export declare class AssembledTransaction<T> {
|
|
|
363
380
|
static build<T>(options: AssembledTransactionOptions<T>): Promise<AssembledTransaction<T>>;
|
|
364
381
|
simulate: () => Promise<this>;
|
|
365
382
|
get simulationData(): {
|
|
366
|
-
result:
|
|
383
|
+
result: Api.SimulateHostFunctionResult;
|
|
367
384
|
transactionData: xdr.SorobanTransactionData;
|
|
368
385
|
};
|
|
369
386
|
get result(): T;
|
|
@@ -377,13 +394,13 @@ export declare class AssembledTransaction<T> {
|
|
|
377
394
|
*/
|
|
378
395
|
signAndSend: ({ force, signTransaction, }?: {
|
|
379
396
|
/**
|
|
380
|
-
* If `true`, sign and send the transaction even if it is a read call
|
|
397
|
+
* If `true`, sign and send the transaction even if it is a read call
|
|
381
398
|
*/
|
|
382
399
|
force?: boolean;
|
|
383
400
|
/**
|
|
384
401
|
* You must provide this here if you did not provide one before
|
|
385
402
|
*/
|
|
386
|
-
signTransaction?:
|
|
403
|
+
signTransaction?: ClientOptions["signTransaction"];
|
|
387
404
|
}) => Promise<SentTransaction<T>>;
|
|
388
405
|
private getStorageExpiration;
|
|
389
406
|
/**
|
|
@@ -402,29 +419,31 @@ export declare class AssembledTransaction<T> {
|
|
|
402
419
|
* One at a time, for each public key in this array, you will need to
|
|
403
420
|
* serialize this transaction with `toJSON`, send to the owner of that key,
|
|
404
421
|
* deserialize the transaction with `txFromJson`, and call
|
|
405
|
-
* {@link signAuthEntries}. Then re-serialize and send to
|
|
406
|
-
* in this list.
|
|
422
|
+
* {@link AssembledTransaction#signAuthEntries}. Then re-serialize and send to
|
|
423
|
+
* the next account in this list.
|
|
407
424
|
*/
|
|
408
425
|
needsNonInvokerSigningBy: ({ includeAlreadySigned, }?: {
|
|
409
426
|
/**
|
|
410
|
-
* Whether or not to include auth entries that have already been signed.
|
|
427
|
+
* Whether or not to include auth entries that have already been signed.
|
|
428
|
+
* Default: false
|
|
411
429
|
*/
|
|
412
430
|
includeAlreadySigned?: boolean;
|
|
413
|
-
}) =>
|
|
431
|
+
}) => string[];
|
|
414
432
|
/**
|
|
415
|
-
* If {@link needsNonInvokerSigningBy} returns a
|
|
416
|
-
* the transaction with `toJSON`, send it to
|
|
417
|
-
*
|
|
418
|
-
* machine. Internally, this will
|
|
419
|
-
* `wallet` for each.
|
|
433
|
+
* If {@link AssembledTransaction#needsNonInvokerSigningBy} returns a
|
|
434
|
+
* non-empty list, you can serialize the transaction with `toJSON`, send it to
|
|
435
|
+
* the owner of one of the public keys in the map, deserialize with
|
|
436
|
+
* `txFromJSON`, and call this method on their machine. Internally, this will
|
|
437
|
+
* use `signAuthEntry` function from connected `wallet` for each.
|
|
420
438
|
*
|
|
421
439
|
* Then, re-serialize the transaction and either send to the next
|
|
422
440
|
* `needsNonInvokerSigningBy` owner, or send it back to the original account
|
|
423
|
-
* who simulated the transaction so they can {@link sign}
|
|
424
|
-
* envelope and {@link send} it to the
|
|
441
|
+
* who simulated the transaction so they can {@link AssembledTransaction#sign}
|
|
442
|
+
* the transaction envelope and {@link AssembledTransaction#send} it to the
|
|
443
|
+
* network.
|
|
425
444
|
*
|
|
426
|
-
* Sending to all `needsNonInvokerSigningBy` owners in parallel is not
|
|
427
|
-
* supported!
|
|
445
|
+
* Sending to all `needsNonInvokerSigningBy` owners in parallel is not
|
|
446
|
+
* currently supported!
|
|
428
447
|
*/
|
|
429
448
|
signAuthEntries: ({ expiration, signAuthEntry, publicKey, }?: {
|
|
430
449
|
/**
|
|
@@ -441,10 +460,10 @@ export declare class AssembledTransaction<T> {
|
|
|
441
460
|
publicKey?: string;
|
|
442
461
|
/**
|
|
443
462
|
* You must provide this here if you did not provide one before. Default:
|
|
444
|
-
* the `signAuthEntry` function from the `
|
|
463
|
+
* the `signAuthEntry` function from the `Client` options. Must
|
|
445
464
|
* sign things as the given `publicKey`.
|
|
446
465
|
*/
|
|
447
|
-
signAuthEntry?:
|
|
466
|
+
signAuthEntry?: ClientOptions["signAuthEntry"];
|
|
448
467
|
}) => Promise<void>;
|
|
449
468
|
/**
|
|
450
469
|
* Whether this transaction is a read call. This is determined by the
|