-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before ContractClient lived in stellar-sdk, we allowed (the equivalent of [[1]]) setting `publicKey` to `undefined`. This is handy, if you're trying to get the result of view calls and you only need the simulation. Our main onboarding tutorial assumes that we have this functionality, and it definitely makes for a more incremental build-up of mental models about how Soroban and Stellar work. While making ContractClient, we thought maybe this added unnecessary complexity to the interface, and further thought people would be able to pass `Keypair.random()` if they wanted a fake account. The trouble with the `Keypair.random()` approach is that the call to `server.getAccount` fails, because the account has not been funded. We _could_ fix this by doing: let account: Account; try { account = tx.server.getAccount(options.publicKey) } catch () { account = new Account(options.publicKey, '0') } But this seems clumsy. Even if there's a better way to check that the caught error is the error we expect (`{ code: 404, message: 'Account not found' }`), why allow passing a publicKey if it's actually ignored? It seems like a clearer expression of intent to allow the publicKey to be `undefined`. ^[1]: https://github.com/stellar/soroban-cli/blob/5f367edb3cf4511794b64aed60a23c5d8b6b55e6/cmd/crates/soroban-spec-typescript/src/project_template/src/assembled-tx.ts#L247-L257
- Loading branch information
Showing
5 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters