Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Refresh six classic guides #723

Draft
wants to merge 107 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
a125983
🔁 Channel accounts: explain resolutions
JFWooten4 Jun 20, 2024
01424db
🔁 Channel accounts: simplify narrative
JFWooten4 Jun 22, 2024
37e38c3
🔁 Channel accounts: specify cards
JFWooten4 Jun 23, 2024
9ed2a0a
🔁 Channel accounts: finalize visuals
JFWooten4 Jun 23, 2024
44309a2
🔁 Channel accounts: simplify narrative
JFWooten4 Jun 26, 2024
dd7d761
🔁 Channel accounts: expand details
JFWooten4 Jun 26, 2024
c4a46dc
Merge branch 'stellar:main' into refresh-classic-guides
JFWooten4 Jul 5, 2024
68f165d
🔁 Channel accounts: hyperlinks, context
JFWooten4 Jul 7, 2024
07e613a
🔁 Channel accounts: initial diagrams
JFWooten4 Jul 9, 2024
bf6e15f
🔁 Channel accounts: reference configuration
JFWooten4 Jul 9, 2024
15d1288
🔁 Channel accounts: KaTeX formatting
JFWooten4 Jul 10, 2024
b874bc7
🔁 Channel accounts: context, links
JFWooten4 Jul 10, 2024
e290fb3
🔁 Channel accounts: conceptual images
JFWooten4 Jul 12, 2024
1f8a904
🔁 Channel accounts: simplify image
JFWooten4 Jul 12, 2024
46f49c6
🔁 Channel accounts: prioritize readability
JFWooten4 Jul 14, 2024
3f2e731
🔁 Channel accounts: overload example
JFWooten4 Jul 14, 2024
8a3d963
🔁 Channel accounts: configuration example
JFWooten4 Jul 15, 2024
cd7f447
🫴🏽 Claimable balances: first example
JFWooten4 Jul 18, 2024
e2248db
🫴🏽 Claimable balances: second example
JFWooten4 Jul 29, 2024
1992240
🫴🏽 Claimable balances: third example
JFWooten4 Jul 29, 2024
ee6175a
🫴🏽 Claimable balances: expand precomputation
JFWooten4 Aug 2, 2024
95ffe3c
🔎 Refresh: asset design considerations
JFWooten4 Aug 5, 2024
d93ae63
🦞 Clawbacks: confer readable diction
JFWooten4 Aug 5, 2024
e1611fc
🦞 Clawbacks: minor example diction
JFWooten4 Aug 5, 2024
03ac66d
🦞 Clawbacks: format account names
JFWooten4 Aug 5, 2024
86f3ca8
🦞 Clawbacks: format more names
JFWooten4 Aug 5, 2024
d1a9252
🦞 Clawbacks: apply name diction
JFWooten4 Aug 5, 2024
eb0e9be
🦞 Clawbacks: translate preamble example
JFWooten4 Aug 6, 2024
f4ad468
🦞 Clawbacks: expand example one
JFWooten4 Aug 6, 2024
e72e4a8
🦞 Clawbacks: translate next instances
JFWooten4 Aug 6, 2024
09fa456
🦞 Clawbacks: continue example dev
JFWooten4 Aug 6, 2024
b3e3230
💱 Trading examples: add lumenaut
JFWooten4 Aug 8, 2024
ee66e13
⏬ Prep for GH sync
JFWooten4 Aug 12, 2024
364f656
Merge remote-tracking branch 'upstream/main' into refresh-classic-guides
JFWooten4 Aug 12, 2024
6e866b7
Merge remote-tracking branch 'upstream/main' into refresh-classic-guides
JFWooten4 Aug 21, 2024
080ec03
💱 Trading examples: clarify narrative
JFWooten4 Sep 13, 2024
b529869
💱 Trading examples: contextualize sources
JFWooten4 Sep 13, 2024
127142e
↕️ Merge branch with self
JFWooten4 Sep 13, 2024
fea178f
🙌 Missed a reference link
JFWooten4 Sep 13, 2024
1a12877
💱 Trading examples: sell offers
JFWooten4 Sep 16, 2024
550b941
💱 Trading examples: level two
JFWooten4 Sep 16, 2024
fff2713
💱 Trading examples: time & sales
JFWooten4 Sep 16, 2024
06d249d
Merge remote-tracking branch 'upstream/main' into refresh-classic-guides
JFWooten4 Sep 30, 2024
4658706
🔁 Sync, move work items
JFWooten4 Sep 30, 2024
760d423
🔁 Clarify channel context links
JFWooten4 Oct 1, 2024
3d30353
🔁 Further advance text flow
JFWooten4 Oct 4, 2024
f6691fa
🔁 Start last code examples
JFWooten4 Oct 7, 2024
b273d71
🔁 Remove random channel generation
JFWooten4 Oct 7, 2024
954210d
🔁 Rest of authorization example
JFWooten4 Oct 7, 2024
ce8d61e
🔁 Remove adding channel custody
JFWooten4 Oct 7, 2024
7cb4b01
🔁 Clear up last tasks
JFWooten4 Oct 7, 2024
56c608a
🔁 Start state rotation example
JFWooten4 Oct 7, 2024
f83f4ad
🔁 Temporary merge, nonfinal publication
JFWooten4 Oct 11, 2024
1a91082
🔗 Minimum compilation link requirements
JFWooten4 Oct 15, 2024
11555a0
🖌️ Prettier compilation demo fixes
JFWooten4 Oct 15, 2024
d521205
🔁 Clarify base fee, miscellaneous 🤝🏻
JFWooten4 Oct 16, 2024
33f342e
Merge branch 'stellar:main' into refresh-classic-guides
JFWooten4 Oct 17, 2024
09fffca
👽 Translate java to JS
JFWooten4 Oct 19, 2024
03d2199
🔁 Last example java & go
JFWooten4 Oct 22, 2024
1c8851d
Merge branch 'stellar:main' into refresh-classic-guides
JFWooten4 Oct 22, 2024
cb9687a
🔁 Closing example explanation, diagrams
JFWooten4 Oct 22, 2024
06183cc
🔁 Put back `set timeouts`
JFWooten4 Oct 22, 2024
cbe3aca
🔁 Cleanup remaining frame items
JFWooten4 Oct 23, 2024
b45f8b2
🔁 Comment active-tense transitive verbs
JFWooten4 Oct 23, 2024
a73d966
🔁 Finalize the story flow
JFWooten4 Oct 23, 2024
a3c5d64
🔁 Polish off minor syntax
JFWooten4 Oct 23, 2024
eac05da
🔗 Remove depricated community link
JFWooten4 Oct 27, 2024
91b40fd
🔎 Clarify note on trustlines
JFWooten4 Oct 27, 2024
7109cb5
🫴🏽 Finish most cleaning up
JFWooten4 Nov 4, 2024
320de48
Merge branch 'main' into refresh-classic-guides
JFWooten4 Nov 4, 2024
0948700
🔗 Update simplified syntax reference
JFWooten4 Nov 4, 2024
19fbf45
🦞 Clean up final examples
JFWooten4 Nov 4, 2024
75a3ea0
💱 Remove items explicitly moved
JFWooten4 Nov 5, 2024
9bc3c63
💱 Remove duplicate placeholder drafts
JFWooten4 Nov 5, 2024
2a2638c
💱 Sidebar section intro description
JFWooten4 Nov 5, 2024
9d01898
💱 First rewrite run through
JFWooten4 Nov 6, 2024
32455bb
💱 Clean up scaffolding leftovers
JFWooten4 Nov 19, 2024
da7e8a3
💱 Translate starting AMM preamble
JFWooten4 Nov 19, 2024
a5c1874
💱 Capital pool > liquidity pool
JFWooten4 Nov 19, 2024
f8a304f
💱 Translate two AMM steps
JFWooten4 Nov 20, 2024
535b09b
📍 Follow up on this
JFWooten4 Nov 24, 2024
be7abb0
💱 Translate removing AMM liquidity
JFWooten4 Nov 24, 2024
eb18115
💱 Translate Java wrap-up example
JFWooten4 Nov 24, 2024
f871bab
💱 Last legacy, 535b09babed7a2afef37d58250f13ff01c2544fa fix
JFWooten4 Nov 24, 2024
b7f4a07
💱 Clean up go conclusion
JFWooten4 Nov 24, 2024
5492eb3
📌 Simplify starting frame, independence
JFWooten4 Nov 24, 2024
80784d8
💱 Seperate preliminary config, example
JFWooten4 Nov 25, 2024
f1a50e2
🖌️ Update prettier config note
JFWooten4 Nov 26, 2024
a4bdaeb
💱 Optimize, clarify global declarations
JFWooten4 Nov 26, 2024
ddd80c6
Merge branch 'main' into refresh-classic-guides
JFWooten4 Dec 6, 2024
81efcf5
💱 DEX code examples setup
JFWooten4 Dec 8, 2024
c7865bb
💱 Initial sell offer examples
JFWooten4 Dec 8, 2024
1f31ba4
💱 Example resolving limit OB
JFWooten4 Dec 8, 2024
34fb3b0
💱 Pricing point local calculation
JFWooten4 Dec 9, 2024
8417495
💱 Start prepping final flow
JFWooten4 Dec 10, 2024
d6d2335
💱 Continue on the intro
JFWooten4 Dec 11, 2024
2dc7db6
💱 Start of execution chat
JFWooten4 Dec 12, 2024
7f9bdc6
💱 Migrate some ancillary points
JFWooten4 Dec 12, 2024
909911a
💱 Introduce the OB outreach
JFWooten4 Dec 12, 2024
62b35af
💱 Translate pricing calculation examples
JFWooten4 Dec 13, 2024
24e3bb4
🖋 Some primative punctuation upgrades
JFWooten4 Dec 31, 2024
59d3686
💱 Remove elementary explanation diction
JFWooten4 Dec 31, 2024
873423e
Merge branch 'refresh-classic-guides' of https://github.com/JFWooten4…
JFWooten4 Dec 31, 2024
49477f8
🐛 Reinstate space line seperators
JFWooten4 Dec 31, 2024
2cbe9ab
Merge branch 'refresh-classic-guides' of https://github.com/JFWooten4…
JFWooten4 Dec 31, 2024
a7e985b
Merge branch 'main' into refresh-classic-guides
JFWooten4 Jan 17, 2025
25dcb88
✏ Operations as complete(r) sentences
JFWooten4 Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🦞 Clawbacks: translate preamble example
  • Loading branch information
JFWooten4 committed Aug 6, 2024
commit eb0e9be5746997ba93f05826e9c6b7fc715e0412
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For basic parameters, see the Create Claimable Balance entry in our [List of Ope

- **`Claim_Predicate_` Claimant**: an object that holds both the destination account that can claim the `ClaimableBalanceEntry` and a `ClaimPredicate` that must evaluate to true for the claim to succeed.

- **A `ClaimPredicate`**: a recursive data structure that can be used to construct complex conditionals using different `ClaimPredicateTypes`. Below are some examples with the `Claim_Predicate_` prefix removed for readability. Note that the SDKs expect the Unix timestamps to be expressed in seconds.
- **`ClaimPredicate`**: a recursive data structure that can be used to construct complex conditionals using different `ClaimPredicateTypes`. Below are some examples with the `Claim_Predicate_` prefix removed for readability. Note that the SDKs expect the Unix timestamps to be expressed in seconds.

- `UNCONDITIONAL`: Can claim at any time.
- `BEFORE_RELATIVE_TIME(X)`: Can claim if the close time of the ledger including the claim is before X seconds, plus the ledger close time in which the `ClaimableBalanceEntry` was created.
Expand Down
263 changes: 242 additions & 21 deletions docs/learn/encyclopedia/transactions-specialized/clawbacks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def establishTrustline(recipient, key):
tx = buildTx(recipient, key, [
Operation.change_trust(
asset=AstroToken,
limit="5000"
)
])
return server.submit_transaction(tx)
Expand All @@ -100,22 +99,29 @@ def preamble():
def buildTx(source, signer, ops):
tx = TransactionBuilder(
source,
network_passphrase=Network.TESTNET,
base_fee=Network.BASE_FEE
network_passphrase = Network.TESTNET,
base_fee = Network.BASE_FEE
)
for op in ops:
tx.append_operation(op)
tx.set_timeout(30)
tx.set_timeout(3600)
tx = tx.build()
tx.sign(signer)
return tx

def showBalances(accounts):
for accs in accounts:
print(f"{accs.account_id[:5]}: {getBalance(acc)}")
print(f"{accs.account_id}: {getBalance(accs)}")

def getBalance(account):
return account.balances[0].balance
for balance in account.balances:
if(
balance["asset_type"] != "native" and
balance["asset_code"] == AstroToken.code and
balance["asset_issuer"] == AstroToken.issuer
):
return balance["balance"]
return "0"
```

```js
Expand Down Expand Up @@ -153,7 +159,6 @@ const establishTrustline = function (recipient, key) {
buildTx(recipient, key, [
sdk.Operation.changeTrust({
asset: AstroToken,
limit: "5000", // arbitrary
}),
]),
);
Expand Down Expand Up @@ -188,25 +193,252 @@ function buildTx(source, signer, ops) {
networkPassphrase: StellarSdk.Networks.TESTNET,
});
ops.forEach((op) => tx.addOperation(op));
tx = tx.setTimeout(30).build();
tx = tx.setTimeout(3600).build();
tx.sign(signer);
return tx;
}

// Prints the balances of a list of accounts.
function showBalances(accounts) {
accounts.forEach((acc) => {
console.log(`${acc.accountId().substring(0, 5)}: ${getBalance(acc)}`);
console.log(`${acc.accountId()}: ${getBalance(acc)}`);
});
}

// Retrieves the balance of AstroToken in `account`.
function getBalance(account) {
const balances = account.balances.filter((balance) => {
return (
balance.asset_code == AstroToken.code &&
balance.asset_issuer == AstroToken.issuer
);
});
return balances.length > 0 ? balances[0].balance : "0";
}
```

```java

import org.stellar.sdk.*;
import org.stellar.sdk.requests.RequestBuilder;
import org.stellar.sdk.responses.AccountResponse;
import org.stellar.sdk.responses.SubmitTransactionResponse;

public class Clawback {

private static final Server server = new Server("https://horizon-testnet.stellar.org");
private static final KeyPair A = KeyPair.fromSecretSeed("SAQLZCQA6AYUXK6JSKVPJ2MZ5K5IIABJOEQIG4RVBHX4PG2KMRKWXCHJ");
private static final KeyPair B = KeyPair.fromSecretSeed("SAAY2H7SANIS3JLFBFPLJRTYNLUYH4UTROIKRVFI4FEYV4LDW5Y7HDZ4");
private static final KeyPair C = KeyPair.fromSecretSeed("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4");
private static final Asset AstroToken = Asset.createNonNativeAsset("ClawbackCoin", A.getAccountId());

public static void main(String[] args) throws IOException {
AccountResponse[] accounts = getAccounts();
AccountResponse accountA = accounts[0];
AccountResponse accountB = accounts[1];
AccountResponse accountC = accounts[2];

enableClawback(accountA, A);
establishTrustline(accountB, B);
establishTrustline(accountC, C);
}

// Enables AuthClawbackEnabledFlag on an account.
private static void enableClawback(AccountResponse account, KeyPair keys) throws IOException {
Transaction transaction = buildTx(account, keys, new Operation[]{
new SetOptionsOperation.Builder()
.setSetFlags(AccountFlag.AUTH_CLAWBACK_ENABLED_FLAG | AccountFlag.AUTH_REVOCABLE_FLAG)
// Also add `revocable` for control over who can hold the asset.
.build()
});
SubmitTransactionResponse response = server.submitTransaction(transaction);
System.out.println("Clawback enabled: " + response);
}

// Establishes a trustline for `recipient` for AstroToken (from above).
private static void establishTrustline(AccountResponse recipient, KeyPair key) throws IOException {
Transaction transaction = buildTx(recipient, key, new Operation[]{
new ChangeTrustOperation.Builder(AstroToken, "922337203685.4775807").build()
});
SubmitTransactionResponse response = server.submitTransaction(transaction);
System.out.println("Trustline established: " + response);
}

// Retrieves latest account info for all accounts.
private static AccountResponse[] getAccounts() throws IOException {
AccountResponse accountA = server.accounts().account(A.getAccountId());
AccountResponse accountB = server.accounts().account(B.getAccountId());
AccountResponse accountC = server.accounts().account(C.getAccountId());
return new AccountResponse[]{accountA, accountB, accountC};
}

// Helper method to build and sign a transaction
private static Transaction buildTx(AccountResponse source, KeyPair signer, Operation[] ops) {
Transaction.Builder txBuilder = new Transaction.Builder(source, Network.TESTNET)
.setTimeout(3600)
.setBaseFee(Transaction.MIN_BASE_FEE);

for (Operation op : ops) {
txBuilder.addOperation(op);
}

Transaction transaction = txBuilder.build();
transaction.sign(signer);
return transaction;
}

// Prints the balances of a list of accounts.
private static void showBalances(AccountResponse[] accounts) throws IOException {
for (AccountResponse account : accounts) {
System.out.println(
account.getAccountId() +
": " +
getBalance(account)
);
}
}

// Retrieves the balance of AstroToken in `account`.
private static String getBalance(AccountResponse account) {
for (AccountResponse.Balance balance : account.getBalances()) {
if (!balance.getAssetType().equals("native") &&
balance.getAssetCode().equals(AstroToken.getCode()) &&
balance.getAssetIssuer().equals(AstroToken.getIssuer())) {
return balance.getBalance();
}
}
return "0";
}
}
```

```go
package main

import (
"fmt"
"github.com/stellar/go/build"
"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/keypair"
"github.com/stellar/go/network"
"github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/txnbuild"
)

var client = horizonclient.DefaultTestNetClient

var (
A = keypair.MustParseFull("SAQLZCQA6AYUXK6JSKVPJ2MZ5K5IIABJOEQIG4RVBHX4PG2KMRKWXCHJ")
B = keypair.MustParseFull("SAAY2H7SANIS3JLFBFPLJRTYNLUYH4UTROIKRVFI4FEYV4LDW5Y7HDZ4")
C = keypair.MustParseFull("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4")

AstroToken = txnbuild.CreditAsset{Code: "ClawbackCoin", Issuer: A.Address()}
)

// Enables AuthClawbackEnabledFlag on an account.
func enableClawback(account horizon.Account, keys *keypair.Full) {
tx, err := buildTx(account, keys, []txnbuild.Operation{
&txnbuild.SetOptions{
SetFlags: []txnbuild.AccountFlag{
txnbuild.AuthClawbackEnabled,
txnbuild.AuthRevocable,
// Also add `revocable` for control over who can hold the asset.
},
},
})
check(err)
resp, err := client.SubmitTransaction(tx)
check(err)
fmt.Println("Clawback enabled:", resp)
}

// Establishes a trustline for `recipient` for AstroToken (from above).
func establishTrustline(recipient horizon.Account, key *keypair.Full) {
tx, err := buildTx(recipient, key, []txnbuild.Operation{
&txnbuild.ChangeTrust{
Line: AstroToken,
},
})
check(err)
resp, err := client.SubmitTransaction(tx)
check(err)
fmt.Println("Trustline established:", resp)
}

// Retrieves latest account info for all accounts.
func getAccounts() ([]horizon.Account, error) {
accountA, err := client.AccountDetail(
horizonclient.AccountRequest{
AccountID: A.Address(),
},
)
check(err)
accountB, err := client.AccountDetail(
horizonclient.AccountRequest{
AccountID: B.Address(),
},
)
check(err)
accountC, err := client.AccountDetail(
horizonclient.AccountRequest{
AccountID: C.Address(),
},
)
check(err)
return []horizon.Account{accountA, accountB, accountC}, nil
}

// Helper method to build and sign a transaction.
func buildTx(source horizon.Account, signer *keypair.Full, ops []txnbuild.Operation) (*txnbuild.Transaction, error) {
tx, err := txnbuild.NewTransaction(
txnbuild.TransactionParams{
SourceAccount: &source,
IncrementSequenceNum: true,
BaseFee: txnbuild.MinBaseFee,
Operations: ops,
Timebounds: txnbuild.NewTimeout(3600),
},
)
check(err)
tx, err = tx.Sign(network.TestNetworkPassphrase, signer)
check(err)
return tx, nil
}

// Enables clawback on A, and establishes trustlines from C, B -> A.
func main() {
accounts, err := getAccounts()
check(err)
accountA := accounts[0]
accountB := accounts[1]
accountC := accounts[2]

enableClawback(accountA, A)
establishTrustline(accountB, B)
establishTrustline(accountC, C)
}

// Prints the balances of a list of accounts.
func showBalances(accounts []horizon.Account) {
for _, acc := range accounts {
fmt.Printf(
"%s: %s\n",
acc.AccountID,
getBalance(acc),
)
}
}

// Retrieves the balance of AstroToken in `account`.
func getBalance(account horizon.Account) string {
for _, balance := range account.Balances {
if balance.Asset.Type != "native" &&
balance.Asset.Code == AstroToken.GetCode() &&
balance.Asset.Issuer == AstroToken.GetIssuer() {
return balance.Balance
}
}
return "0"
}
```

</CodeExample>
Expand Down Expand Up @@ -245,17 +477,6 @@ function doClawback(byAccount, byKey, fromAccount, amount) {
]),
);
}

// Retrieves the balance of AstroToken in `account`.
function getBalance(account) {
const balances = account.balances.filter((balance) => {
return (
balance.asset_code == AstroToken.code &&
balance.asset_issuer == AstroToken.issuer
);
});
return balances.length > 0 ? balances[0].balance : "0";
}
```

</CodeExample>
Expand Down
7 changes: 5 additions & 2 deletions docs/learn/fundamentals/stellar-data-structures/accounts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ A base reserve is a unit of measurement used to calculate an account’s minimum

Account data is stored in subentries, each of which increases an account’s minimum balance by one base reserve (0.5 XLM). An account cannot have more than 1,000 subentries. Possible subentries are:

- Trustlines (includes traditional assets and pool shares)
- Trustlines
- Includes traditional assets and pool shares
- Offers
- Additional signers
- Data entries (includes data made with the `manageData` operation, not smart contract ledger entries)
- Data entries
- Includes data made with the `manageData` operation
- Does not include smart contract ledger entries

## Trustlines

Expand Down
2 changes: 1 addition & 1 deletion docs/learn/glossary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Read more in the [Operations and Transactions section](./fundamentals/transactio

### Transaction envelope

A transaction plus its signature(s) is called a transaction envelop.
A transaction plus its signature(s) is called a transaction envelope.

### Transaction fee

Expand Down