Skip to content

Commit 246c517

Browse files
authored
protocol 27 - V2 credential opt in (#1450)
* make V2 credential usage opt-in
1 parent 6b6862d commit 246c517

11 files changed

Lines changed: 279 additions & 111 deletions

File tree

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ A breaking change will get clearly marked in this log.
66

77
## Unreleased
88

9+
### Changed
10+
11+
- Soroban auth defaults back to the legacy `SOROBAN_CREDENTIALS_ADDRESS` (V1)
12+
credential, with the CAP-71 `SOROBAN_CREDENTIALS_ADDRESS_V2` credential now
13+
available behind an opt-in instead of forced on. `ADDRESS_V2` is only valid on
14+
networks that have activated CAP-71, so emitting it before activation would
15+
fail submission; the opt-in keeps the default safe while letting you exercise
16+
V2 against networks that already support it. The default will flip to V2 once
17+
the protocol makes it mandatory. ([#1450](https://github.com/stellar/js-stellar-sdk/pull/1450))
18+
- `rpc.Server.simulateTransaction` gained a 4th optional argument,
19+
`authV2` (default `false`). When `true`, the `authV2` request flag is sent so
20+
simulation returns `ADDRESS_V2` auth entries; otherwise the flag is omitted
21+
and legacy `ADDRESS` entries are returned.
22+
- `authorizeInvocation` gained an optional `authV2` field on its params object
23+
(default `false`) selecting between `ADDRESS` and `ADDRESS_V2` credentials.
24+
- `contract.Client` / `AssembledTransaction` accept `authV2` in
25+
`MethodOptions`, threaded through to simulation.
26+
27+
928
## v16.0.0-rc.1
1029

1130
There are a few major updates in this release:

docs/guides/00-migration.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -381,37 +381,57 @@ If your code reached through the SDK for any of these, declare them yourself now
381381
Protocol 27 ([CAP-71](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0071.md))
382382
adds two address-bound Soroban credential types, `AddressV2` and
383383
`AddressWithDelegates`. This only affects code that signs Soroban authorization
384-
entries or inspects their credential arms. Depending on the network and RPC
385-
simulation behavior, authorization entries may contain either the legacy
386-
`ADDRESS` credential or the newer `ADDRESS_V2` credential. Both are valid for SDK
387-
signing flows that use the helpers below.
384+
entries or inspects their credential arms.
385+
386+
By default the SDK still uses the legacy `ADDRESS` credential: simulation is
387+
asked for `ADDRESS` entries and `authorizeInvocation` builds them. `ADDRESS_V2`
388+
is only valid on networks that have upgraded to protocol 27, so it is **opt-in** until
389+
protocol 28 makes it mandatory (at which point the default flips). Opt in with
390+
the `authV2` flag — on
391+
`rpc.Server.simulateTransaction`,
392+
on `authorizeInvocation`'s params, or via `authV2` in
393+
[`contract.Client`](/reference/contracts-client/#contractclient) /
394+
`MethodOptions` — when your target network supports it.
388395

389396
SDK-driven signing ([`contract.Client`](/reference/contracts-client/#contractclient),
390397
[`basicNodeSigner`](/reference/contracts-client/#contractbasicnodesigner),
391398
[`authorizeEntry`](/reference/core-soroban-primitives/#authorizeentry),
392399
[`signAuthEntries`](/reference/contracts-client/#contractassembledtransaction)) is
393-
forward-compatible with no code change: it signs whichever credential simulation
394-
returns. The entries below break only code that reads the credential arm or
395-
builds the signature payload by hand.
400+
forward-compatible with no code change: it signs whichever credential the entry
401+
carries, `ADDRESS` or `ADDRESS_V2`. The entries below break only code that reads
402+
the credential arm or builds the signature payload by hand.
396403

397404
For the full walkthrough of signing Soroban authorization entries, see
398405
[Authorize a Contract Call](/guides/07-contract-auth/).
399406

400-
### Auth: `authorizeInvocation` now returns `AddressV2`
407+
### Auth: `authorizeInvocation` takes a params object
401408

402409
[`authorizeInvocation`](/reference/core-soroban-primitives/#authorizeinvocation) now
403-
takes a single params object and builds `SOROBAN_CREDENTIALS_ADDRESS_V2` entries
404-
instead of legacy `ADDRESS`. Read the
405-
result with `.addressV2()`.
410+
takes a single params object instead of positional arguments. It still builds a
411+
legacy `SOROBAN_CREDENTIALS_ADDRESS` entry by default, so keep reading the result
412+
with `.address()`.
406413

407-
```ts del={1-4} ins={5-8}
414+
```ts del={1-4} ins={5-7}
408415
const entry = await authorizeInvocation(
409416
signer, validUntilLedgerSeq, invocation, publicKey, networkPassphrase,
410417
)
411-
const addr = entry.credentials().address()
412418
const entry = await authorizeInvocation({
413419
signer, validUntilLedgerSeq, invocation, networkPassphrase, publicKey,
414420
})
421+
const addr = entry.credentials().address()
422+
```
423+
424+
To build a CAP-71 `ADDRESS_V2` entry instead, pass `authV2: true` and read the
425+
result with `.addressV2()`. Only do this on networks that have upgraded to protocol 27.
426+
427+
```ts ins={6}
428+
const entry = await authorizeInvocation({
429+
signer,
430+
validUntilLedgerSeq,
431+
invocation,
432+
networkPassphrase,
433+
authV2: true,
434+
})
415435
const addr = entry.credentials().addressV2()
416436
```
417437

@@ -471,15 +491,6 @@ and rejects duplicates, as the protocol requires), then route each signer's
471491
signature with `forAddress`. Every signer signs the same payload, bound to the
472492
top-level address.
473493

474-
### Auth: closed export surface
475-
476-
The auth module's wildcard re-export was replaced with an explicit allow-list. The
477-
package root now exports exactly `authorizeEntry`, `authorizeInvocation`,
478-
`buildAuthorizationEntryPreimage`, `buildWithDelegatesEntry`, and the types
479-
`SigningCallback`, `AuthorizeInvocationParams`, `DelegateSignature`,
480-
`BuildWithDelegatesParams`. Anything else imported from the auth module (notably
481-
`getAddressCredentials`, now internal) no longer resolves.
482-
483494
### Earlier 15.x deprecation: `BalanceResponse.revocable`
484495

485496
On [`BalanceResponse`](/reference/network-rpc/#rpcapibalanceresponse), use

docs/reference/contracts-client.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,23 +423,23 @@ returns `false`, then you need to call `signAndSend` on this transaction.
423423
readonly isReadCall: boolean;
424424
```
425425

426-
**Source:** [src/contract/assembled_transaction.ts:1089](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L1089)
426+
**Source:** [src/contract/assembled_transaction.ts:1094](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L1094)
427427

428428
### `assembledTransaction.result`
429429

430430
```ts
431431
readonly result: T;
432432
```
433433

434-
**Source:** [src/contract/assembled_transaction.ts:738](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L738)
434+
**Source:** [src/contract/assembled_transaction.ts:743](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L743)
435435

436436
### `assembledTransaction.simulationData`
437437

438438
```ts
439439
readonly simulationData: { result: SimulateHostFunctionResult; transactionData: SorobanTransactionData };
440440
```
441441

442-
**Source:** [src/contract/assembled_transaction.ts:695](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L695)
442+
**Source:** [src/contract/assembled_transaction.ts:700](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L700)
443443

444444
### `assembledTransaction.needsNonInvokerSigningBy(__namedParameters)`
445445

@@ -469,7 +469,7 @@ needsNonInvokerSigningBy(__namedParameters: { includeAlreadySigned?: boolean } =
469469

470470
- **`__namedParameters`**`{ includeAlreadySigned?: boolean }` (optional) (default: `{}`)
471471

472-
**Source:** [src/contract/assembled_transaction.ts:924](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L924)
472+
**Source:** [src/contract/assembled_transaction.ts:929](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L929)
473473

474474
### `assembledTransaction.restoreFootprint(restorePreamble, account)`
475475

@@ -504,7 +504,7 @@ Client initialization.
504504
- - Throws a custom error if the
505505
restore transaction fails, providing the details of the failure.
506506

507-
**Source:** [src/contract/assembled_transaction.ts:1118](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L1118)
507+
**Source:** [src/contract/assembled_transaction.ts:1123](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L1123)
508508

509509
### `assembledTransaction.send(watcher)`
510510

@@ -521,7 +521,7 @@ send(watcher?: Watcher): Promise<SentTransaction<T>>;
521521

522522
- **`watcher`**`Watcher` (optional)
523523

524-
**Source:** [src/contract/assembled_transaction.ts:853](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L853)
524+
**Source:** [src/contract/assembled_transaction.ts:858](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L858)
525525

526526
### `assembledTransaction.sign(__namedParameters)`
527527

@@ -536,7 +536,7 @@ sign(__namedParameters: { force?: boolean; signTransaction?: SignTransaction } =
536536

537537
- **`__namedParameters`**`{ force?: boolean; signTransaction?: SignTransaction }` (optional) (default: `{}`)
538538

539-
**Source:** [src/contract/assembled_transaction.ts:766](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L766)
539+
**Source:** [src/contract/assembled_transaction.ts:771](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L771)
540540

541541
### `assembledTransaction.signAndSend(__namedParameters)`
542542

@@ -555,7 +555,7 @@ signAndSend(__namedParameters: { force?: boolean; signTransaction?: SignTransact
555555

556556
- **`__namedParameters`**`{ force?: boolean; signTransaction?: SignTransaction; watcher?: Watcher }` (optional) (default: `{}`)
557557

558-
**Source:** [src/contract/assembled_transaction.ts:871](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L871)
558+
**Source:** [src/contract/assembled_transaction.ts:876](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L876)
559559

560560
### `assembledTransaction.signAuthEntries(__namedParameters)`
561561

@@ -582,7 +582,7 @@ signAuthEntries(__namedParameters: { address?: string; authorizeEntry?: (entry:
582582

583583
- **`__namedParameters`**`{ address?: string; authorizeEntry?: (entry: SorobanAuthorizationEntry, signer: Keypair | SigningCallback, validUntilLedgerSeq: number, networkPassphrase: string, forAddress?: string) => Promise<SorobanAuthorizationEntry>; expiration?: number | Promise<number>; signAuthEntry?: SignAuthEntry }` (optional) (default: `{}`)
584584

585-
**Source:** [src/contract/assembled_transaction.ts:985](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L985)
585+
**Source:** [src/contract/assembled_transaction.ts:990](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/assembled_transaction.ts#L990)
586586

587587
### `assembledTransaction.simulate(__namedParameters)`
588588

@@ -791,7 +791,7 @@ _before_ transaction signing.
791791
const DEFAULT_TIMEOUT: number
792792
```
793793
794-
**Source:** [src/contract/types.ts:292](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L292)
794+
**Source:** [src/contract/types.ts:302](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L302)
795795
796796
## contract.NULL_ACCOUNT
797797
@@ -801,7 +801,7 @@ An impossible account on the Stellar network
801801
const NULL_ACCOUNT: "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF"
802802
```
803803
804-
**Source:** [src/contract/types.ts:298](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L298)
804+
**Source:** [src/contract/types.ts:308](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L308)
805805
806806
## contract.SentTransaction
807807
@@ -1341,7 +1341,7 @@ basicNodeSigner(keypair: Keypair, networkPassphrase: string): { signAuthEntry: S
13411341
type AssembledTransactionOptions<T = string> = MethodOptions & ClientOptions & { address?: string; args?: any[]; method: string; parseResultXdr: (xdr: xdr.ScVal) => T; submit?: boolean; submitUrl?: string }
13421342
```
13431343
1344-
**Source:** [src/contract/types.ts:260](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L260)
1344+
**Source:** [src/contract/types.ts:270](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L270)
13451345
13461346
### contract.ClientOptions
13471347
@@ -1392,7 +1392,7 @@ message: string;
13921392
Options for a smart contract method invocation.
13931393

13941394
```ts
1395-
type MethodOptions = { fee?: string; publicKey?: string; restore?: boolean; signAuthEntry?: SignAuthEntry; signTransaction?: SignTransaction; simulate?: boolean; timeoutInSeconds?: number }
1395+
type MethodOptions = { authV2?: boolean; fee?: string; publicKey?: string; restore?: boolean; signAuthEntry?: SignAuthEntry; signTransaction?: SignTransaction; simulate?: boolean; timeoutInSeconds?: number }
13961396
```
13971397
13981398
**Source:** [src/contract/types.ts:203](https://github.com/stellar/js-stellar-sdk/blob/main/src/contract/types.ts#L203)

0 commit comments

Comments
 (0)