@xoxno/sdk-js 1.0.235 → 1.0.237
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/dist/cjs/sdk/stellar/__tests__/smart-account.test.d.ts +1 -0
- package/dist/cjs/sdk/stellar/auth-policy.d.ts +4 -4
- package/dist/cjs/sdk/stellar/lending.d.ts +9 -7
- package/dist/cjs/sdk/stellar/prepare.d.ts +19 -3
- package/dist/cjs/sdk/stellar/quote.d.ts +12 -3
- package/dist/esm/sdk/stellar/auth-policy.js +28 -1
- package/dist/esm/sdk/stellar/cctp.js +1 -1
- package/dist/esm/sdk/stellar/governance.js +1 -1
- package/dist/esm/sdk/stellar/lending.js +3 -3
- package/dist/esm/sdk/stellar/prepare.js +83 -2
- package/dist/esm/sdk/stellar/quote.js +5 -2
- package/dist/esm/sdk/stellar/swap.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/sdk/stellar/__tests__/smart-account.test.d.ts +1 -0
- package/dist/sdk/stellar/auth-policy.d.ts +4 -4
- package/dist/sdk/stellar/index.cjs +1 -1
- package/dist/sdk/stellar/index.esm.js +1 -1
- package/dist/sdk/stellar/lending.d.ts +9 -7
- package/dist/sdk/stellar/prepare.d.ts +19 -3
- package/dist/sdk/stellar/quote.d.ts +12 -3
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Stellar lending user-operation transaction builders.
|
|
3
3
|
*
|
|
4
4
|
* Each builder takes a typed Stellar argument object plus shared
|
|
5
|
-
* `StellarLendingBuilderOptions` ({ network, caller, sourceSequence,
|
|
5
|
+
* `StellarLendingBuilderOptions` ({ network, caller, sourceAccount?, sourceSequence,
|
|
6
6
|
* controllerAddress, ... }) and returns
|
|
7
7
|
* unsigned transaction XDR that must be prepared before wallet signing.
|
|
8
8
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Builders are RPC-free: they accept a caller-supplied `sourceSequence` so the
|
|
14
14
|
* returned XDR is deterministic and snapshot-testable. The caller fetches the
|
|
15
|
-
* current sequence via `rpc.Server.getAccount(caller)` and runs
|
|
15
|
+
* current sequence via `rpc.Server.getAccount(sourceAccount ?? caller)` and runs
|
|
16
16
|
* `rpc.Server.prepareTransaction` (simulation + Soroban footprint/auth/resource
|
|
17
17
|
* fee) before handing the XDR to the wallet to sign.
|
|
18
18
|
*/
|
|
@@ -29,17 +29,19 @@ import { type StellarSeizeModeInput, type StellarStrategySwapHopInput, type Stel
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function parseStellarTokenAmount(amount: string, decimals: number | null): string;
|
|
31
31
|
/**
|
|
32
|
-
* Stellar `G...` public key of
|
|
32
|
+
* Stellar `G...` public key of a transaction source account.
|
|
33
33
|
*/
|
|
34
34
|
export type StellarAccountAddress = string;
|
|
35
35
|
export interface StellarBuilderOptions {
|
|
36
36
|
/** Must match the API deployment, RPC and signing wallet. */
|
|
37
37
|
network: StellarNetwork;
|
|
38
|
-
/**
|
|
39
|
-
caller:
|
|
38
|
+
/** Authorizing asset owner (G... account or C... smart account). */
|
|
39
|
+
caller: string;
|
|
40
|
+
/** G... transaction source; defaults to caller. Required for a C... caller. */
|
|
41
|
+
sourceAccount?: StellarAccountAddress;
|
|
40
42
|
/**
|
|
41
|
-
* Current sequence number of
|
|
42
|
-
*
|
|
43
|
+
* Current sequence number of sourceAccount ?? caller, as a decimal string.
|
|
44
|
+
* Fetch this from Soroban RPC (`server.getAccount(sourceAccount ?? caller)`) before
|
|
43
45
|
* building. Keeping it as an input (rather than fetching inside the builder)
|
|
44
46
|
* makes builders sync-friendly, RPC-free, and deterministic for snapshot tests.
|
|
45
47
|
*/
|
|
@@ -2,6 +2,19 @@ import { rpc } from '@stellar/stellar-sdk';
|
|
|
2
2
|
import type { FeeBumpTransaction, Transaction } from '@stellar/stellar-sdk';
|
|
3
3
|
import type { BuiltStellarTx } from './lending.js';
|
|
4
4
|
import { type StellarNetwork } from './contracts.js';
|
|
5
|
+
import { type StellarPreparedTxAuthOptions } from './auth-policy.js';
|
|
6
|
+
export interface StellarAuthorizationContext {
|
|
7
|
+
readonly networkPassphrase: string;
|
|
8
|
+
readonly latestLedger: number;
|
|
9
|
+
}
|
|
10
|
+
export interface StellarAuthorizationOptions extends Pick<StellarPreparedTxAuthOptions, 'caller' | 'policy' | 'deployment'> {
|
|
11
|
+
/**
|
|
12
|
+
* Authorize one base64 SorobanAuthorizationEntry using the account's policy.
|
|
13
|
+
* Return base64 with only signature and signatureExpirationLedger changed.
|
|
14
|
+
* XDR strings keep wallet SDK instances outside this SDK's bundle boundary.
|
|
15
|
+
*/
|
|
16
|
+
authorizeEntry(entryXdr: string, context: StellarAuthorizationContext): Promise<string>;
|
|
17
|
+
}
|
|
5
18
|
/** Options for preparing unsigned XDR. The wallet must sign on this network. */
|
|
6
19
|
export interface StellarPrepareOptions {
|
|
7
20
|
/** Selected Stellar network. Omission preserves the legacy unsigned-XDR API. */
|
|
@@ -17,12 +30,14 @@ export interface StellarPrepareOptions {
|
|
|
17
30
|
* or maximum-position flows. The resulting resources must fit network limits.
|
|
18
31
|
*/
|
|
19
32
|
instructionLeeway?: number;
|
|
33
|
+
/** Custom/address authorization. Requires network; validates policy before callbacks. */
|
|
34
|
+
authorization?: StellarAuthorizationOptions;
|
|
20
35
|
}
|
|
21
|
-
/**
|
|
36
|
+
/** Custom adapters must forward authMode when address authorization is requested. */
|
|
22
37
|
export interface StellarTxPreparer {
|
|
23
38
|
simulateTransaction(tx: Transaction | FeeBumpTransaction, resources?: {
|
|
24
39
|
cpuInstructions?: number;
|
|
25
|
-
}): Promise<rpc.Api.SimulateTransactionResponse>;
|
|
40
|
+
}, authMode?: 'record' | 'enforce'): Promise<rpc.Api.SimulateTransactionResponse>;
|
|
26
41
|
}
|
|
27
42
|
export declare function tagStellarInvokedContractError(contractId: string, error: unknown): Error;
|
|
28
43
|
/**
|
|
@@ -32,7 +47,8 @@ export declare function tagStellarInvokedContractError(contractId: string, error
|
|
|
32
47
|
* @param server - Host application's RPC server on the selected network.
|
|
33
48
|
* @param xdr - Unsigned builder output, not a signed transaction.
|
|
34
49
|
* @param opts - Pass `network` explicitly; it must match the RPC and wallet.
|
|
35
|
-
* @returns Prepared, unsigned base64 XDR for
|
|
50
|
+
* @returns Prepared, unsigned base64 XDR for source signing. With authorization,
|
|
51
|
+
* address signatures are attached and checked by a second, enforced simulation.
|
|
36
52
|
* @remarks This helper does not sign, submit, or wait for confirmation. Existing
|
|
37
53
|
* calls without `network` retain a neutral hash domain because XDR contains no
|
|
38
54
|
* passphrase; always select the actual network when the wallet signs.
|
|
@@ -71,15 +71,22 @@ export interface StellarQuoteLp {
|
|
|
71
71
|
* fields the DTO does not yet declare. `alternatives` is still on the DTO but
|
|
72
72
|
* the service no longer returns it.
|
|
73
73
|
*/
|
|
74
|
+
export type StellarQuoteTransactionPayload = StellarQuoteTransactionPayloadDto & {
|
|
75
|
+
/** Address auth entries still need authorization and enforced simulation. */
|
|
76
|
+
authorizationRequired?: boolean;
|
|
77
|
+
};
|
|
74
78
|
export type StellarQuoteResponse = StellarAggregatorQuoteResponseDto & {
|
|
75
79
|
snapshot?: StellarQuoteSnapshot | null;
|
|
76
80
|
degraded?: StellarQuoteDegraded | null;
|
|
77
81
|
lp?: StellarQuoteLp | null;
|
|
78
82
|
/** Ordered LP-conversion steps; mutually exclusive with `transaction`. */
|
|
79
|
-
transactions?:
|
|
83
|
+
transactions?: StellarQuoteTransactionPayload[] | null;
|
|
84
|
+
transaction?: StellarQuoteTransactionPayload | null;
|
|
80
85
|
};
|
|
81
86
|
/** Quote request; adds `simulate`, which the DTO does not yet declare. */
|
|
82
87
|
export type StellarQuoteRequest = StellarAggregatorQuoteRequestDto & {
|
|
88
|
+
/** G... transaction source. Required with a C... sender; otherwise defaults to sender. */
|
|
89
|
+
sourceAccount?: string;
|
|
83
90
|
/** With `sender`: simulate and prepare resource data (service default `true`). */
|
|
84
91
|
simulate?: boolean;
|
|
85
92
|
};
|
|
@@ -102,11 +109,13 @@ export interface StellarQuoteFetchOptions {
|
|
|
102
109
|
* `steps`. Amounts are token base-unit decimal strings. Requote after changes
|
|
103
110
|
* to amount, direction or slippage; preparation is the execution check.
|
|
104
111
|
*
|
|
105
|
-
* Passing `sender` (G...) together with `slippage` returns a direct-swap
|
|
112
|
+
* Passing `sender` (G... or C...) together with `slippage` returns a direct-swap
|
|
106
113
|
* envelope under `transaction.envelopeXdr`. The router comes from the service's
|
|
107
114
|
* `/api/v1/config`; the `router` request field is ignored by the service and is
|
|
108
115
|
* no longer sent. Prepare the envelope before wallet signing unless
|
|
109
|
-
* `transaction.simulated` is true.
|
|
116
|
+
* `transaction.simulated` is true. C... senders require a G... `sourceAccount`.
|
|
117
|
+
* A distinct source selects Soroban execution. If `authorizationRequired` is
|
|
118
|
+
* true, authorize the address entries and enforce simulation before source signing.
|
|
110
119
|
* @param request - Exactly one of amountIn or amountOut; optional referralId is forwarded unchanged.
|
|
111
120
|
* @param opts - Quote-server URL and optional fetch options supplied by the host.
|
|
112
121
|
* @returns Quote estimates and opaque route bytes; does not execute a swap.
|