Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into jcx120-patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotFriend committed Oct 18, 2023
2 parents 9db5cf6 + dae3968 commit 5c1fbe4
Show file tree
Hide file tree
Showing 42 changed files with 3,079 additions and 508 deletions.
17 changes: 8 additions & 9 deletions api/methods/getEvents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ By default soroban-rpc retains the most recent 24 hours of events.
- A `SegmentMatcher` is one of the following:
- For an exact segment match, a string containing base64-encoded ScVal
- For a wildcard single-segment match, the string "*", matches exactly one segment.
- Examples of matching token transfer events. Events are emitted here: [rs-soroban-env/event.rs at 924d86cacd58b8a162344bfe0ab37d9668f5d629]. I've decoded the base64-encoded ScVals for easier reading (both the symbols and addresses). In real usage, the `ScSymbol("transfer").toXdr().toString("base64")`, and `ScBinary(pubkeyBytes).toXdr().toString("base64")`, would be base64 encoded strings for exact matches. For example:
- Examples of matching token transfer events. Events are emitted here: [rs-soroban-env/event.rs @ `924d86c`], with base64-encoded ScVals decoded for easier reading (both the symbols and addresses). In real usage, the `ScSymbol("transfer").toXdr().toString("base64")`, and `ScBinary(pubkeyBytes).toXdr().toString("base64")`, would be base64-encoded strings for exact matches. For example:
- `[ScSymbol("transfer"), "*", "*"]`
- Matches any token transfer events
- `[ScSymbol("transfer"), "*", "GABC...123"]`
Expand All @@ -41,15 +41,14 @@ By default soroban-rpc retains the most recent 24 hours of events.
- `latestLedger`: `<string>` - Stringified-number of the current latest ledger observed by the node when this response was generated.
- `events`: `<object[]>`
- `ledger`: `<string>` - String-ified sequence number of the ledger.
- `ledgerClosedAt`: `<string>` - ISO8601 timestamp of the ledger closing time.
- `contractId`: `<string>` - ID of the emitting contract.
- `ledgerClosedAt`: `<string>` - [ISO-8601](https://www.iso.org/iso-8601-date-and-time-format.html) timestamp of the ledger closing time.
- `contractId`: `<string>` - StrKey ID (`C...`) of the emitting contract ([SEP-23](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0023.md#specification)).
- `id`: `<string>` - Unique identifier for this event.
- The event's unique id field is based on a [`toid` from Horizon] as used in Horizon's /effects endpoint.
- https://github.com/stellar/go/blob/master/services/horizon/internal/db2/history/effect.go#L58
- Specifically, it is a string containing:
- bigint(32 bit ledger sequence + 20 bit txn number + 12 bit operation) + `<hyphen>` + number for the event within the operation.
- For example:
- 1234-1
- bigint(32 bit ledger sequence + 20 bit txn number + 12 bit operation) + `<hyphen>` + number for the event within the operation.
- For example: `1234-1`
- `pagingToken`: `<string>` - Duplicate of `id` field, but in the standard place for pagination tokens.
- `inSuccessfulContractCall`: `<boolean>` - If true the event was emitted during a successful contract call.
- `topic`: `<xdr.ScVal[]>` - List containing the topic this event was emitted with.
Expand Down Expand Up @@ -99,7 +98,7 @@ The examples below only returns two transfer events that took place to/from the
"type": "contract",
"ledger": "230010",
"ledgerClosedAt": "2023-01-23T18:54:41Z",
"contractId": "d93f5c7bb0ebc4a9c8f727c5cebc4e41194d38257e1d0d910356b43bfc528813",
"contractId": "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT",
"id": "0000987885427757056-0000000001",
"pagingToken": "0000987885427757056-0000000001",
"inSuccessfulContractCall": true,
Expand All @@ -116,7 +115,7 @@ The examples below only returns two transfer events that took place to/from the
"type": "contract",
"ledger": "230170",
"ledgerClosedAt": "2023-01-23T19:08:37Z",
"contractId": "d93f5c7bb0ebc4a9c8f727c5cebc4e41194d38257e1d0d910356b43bfc528813",
"contractId": "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT",
"id": "0000988572622524416-0000000001",
"pagingToken": "0000988572622524416-0000000001",
"inSuccessfulContractCall": true,
Expand All @@ -134,5 +133,5 @@ The examples below only returns two transfer events that took place to/from the
}
```

[rs-soroban-env/event.rs at 924d86cacd58b8a162344bfe0ab37d9668f5d629]: <https://github.com/stellar/rs-soroban-env/blob/924d86cacd58b8a162344bfe0ab37d9668f5d629/soroban-env-host/src/native_contract/token/event.rs#L21-L33>
[rs-soroban-env/event.rs @ `924d86c`]: <https://github.com/stellar/rs-soroban-env/blob/924d86cacd58b8a162344bfe0ab37d9668f5d629/soroban-env-host/src/native_contract/token/event.rs#L21-L33>
[`toid` from Horizon]: <https://github.com/stellar/go/blob/master/toid/main.go>
15 changes: 9 additions & 6 deletions api/methods/getLedgerEntries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ To fetch contract wasm byte-code, use the ContractCode ledger entry key.
## Return

- `<object>`
- `entries`: Array containing the specified ledger entries which were found
- `key`: `<xdr.LedgerKey>` - The key of the ledger entry (serialized in a base64 string)
- `xdr`: `<xdr.LedgerEntryData>` - The current value of the given ledger entry (serialized in a base64 string)
- `lastModifiedLedgerSeq`: `<number>` - The ledger number of the last time this entry was updated (optional)
- `entries`: Array containing the specified ledger entries which were found.
- `key`: `<xdr.LedgerKey>` - The key of the ledger entry (serialized in a base64 string).
- `xdr`: `<xdr.LedgerEntryData>` - The current value of the given ledger entry (serialized in a base64 string).
- `lastModifiedLedgerSeq`: `<string>` - The ledger sequence number of the last time this entry was updated.
- `expirationLedgerSeq`: `<string>` - The ledger sequence number after which the ledger entry would expire. This field exists only for ContractCodeEntry and ContractDataEntry ledger entries (optional).
- `latestLedger`: `<number>` - The current latest ledger observed by the node when this response was generated.

## Examples
Expand All @@ -40,7 +41,8 @@ To fetch contract wasm byte-code, use the ContractCode ledger entry key.
{
"key": "AAAAB+qfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC",
"xdr": "AAAABwAAAADqn8uBrlSin2s78pOEfT/X6aNp/RyArK/sar1XExfgwgAAAAphIGNvbnRyYWN0AAA=",
"lastModifiedLedgerSeq": "13"
"lastModifiedLedgerSeq": "13",
"expirationLedgerSeq": "95"
}
],
"latestLedger": "179436"
Expand Down Expand Up @@ -381,7 +383,8 @@ And the response we get contains (even more) `LedgerEntryData` that we can decod
{
"key": "AAAAB2QWKBCU9yGjzDJNxaEZpxEB6A8XsD2S/lKK/sViOLiC",
"xdr": "AAAABwAAAABkFigQlPcho8wyTcWhGacRAegPF7A9kv5Siv7FYji4ggAAAlQAYXNtAQAAAAEPA2ACfn4BfmABfgF+YAAAAgcBAXYBRwAAAwQDAQICBQMBABEGGQN/AUGAgMAAC38AQYWAwAALfwBBkIDAAAsHMQUGbWVtb3J5AgAFaGVsbG8AAQFfAAMKX19kYXRhX2VuZAMBC19faGVhcF9iYXNlAwIK4QID1gIDAn8CfgF/I4CAgIAAQSBrIgEkgICAgAACQAJAIACnQf8BcSICQQ5GDQAgAkHKAEcNAQtCACEDQXshAgNAAkACQAJAAkAgAkUNAEIBIQQgAkGFgMCAAGotAAAiBUHfAEYNAyAFrSEEIAVBUGpBCkkNAiAFQb9/akEaSQ0BAkAgBUGff2pBGk8NACAEQkV8IQQMBAsQgoCAgAAACyABIAA3AwggASADQgiGQg6ENwMAQQAhAgNAAkAgAkEQRw0AQQAhAgJAA0AgAkEQRg0BIAFBEGogAmogASACaikDADcDACACQQhqIQIMAAsLIAFBEGqtQiCGQgSEQoSAgIAgEICAgIAAIQQgAUEgaiSAgICAACAEDwsgAUEQaiACakICNwMAIAJBCGohAgwACwsgBEJLfCEEDAELIARCUnwhBAsgAkEBaiECIAQgA0IGhoQhAwwACwsAAAsEAAAACwIACwsOAQBBgIDAAAsFSGVsbG8AHhFjb250cmFjdGVudm1ldGF2MAAAAAAAAAAUAAAAJQBDDmNvbnRyYWN0c3BlY3YwAAAAAAAAAAAAAAAFaGVsbG8AAAAAAAABAAAAAAAAAAJ0bwAAAAAAEQAAAAEAAAPqAAAAEQ==",
"lastModifiedLedgerSeq": "75206"
"lastModifiedLedgerSeq": "75206",
"expirationLedgerSeq": "320384"
}
],
"latestLedger": "262384"
Expand Down
111 changes: 88 additions & 23 deletions dapps/dapp-challenges/challenge-0-crowdfund.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import success from "../../static/img/success.png";
import backedResult from "../../static/img/backedResult.png";
import deployedDApp from "../../static/img/deployedDApp.png";
import { ParentChallengeForm } from "../../src/components/atoms/challenge-form";
import { ParentChallengeContractForm } from "../../src/components/atoms/challenge-contract-form";
import CompleteStepButton from "../../src/components/atoms/complete-step-button";
import StartChallengeButton from "../../src/components/atoms/start-challenge-button";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

<StartChallengeButton id={0} />

Expand All @@ -33,6 +36,7 @@ First, clone the Soroban Dapps Challenge repo and check out the `crowdfund` bran

```sh
git clone https://github.com/stellar/soroban-dapps-challenge.git
cd soroban-dapps-challenge
git checkout crowdfund
```

Expand All @@ -51,6 +55,7 @@ In your terminal, load the contracts and initialize them in the Sandbox environm
```sh
npm run setup
```

If the command runs successfully, your terminal will return a series of messages notifying you about the successful initialization of the contracts and the post-installation sequence.

```sh
Expand All @@ -73,9 +78,7 @@ Please, save your deployed contract ID, you will need it to complete the challen

:::

<CompleteStepButton id={0} progress={1}>
Mark smart contracts deployed
</CompleteStepButton>
<ParentChallengeContractForm id={0} progress={1} />

## Checkpoint 2: 🀝 Connect the Frontend to the Backend

Expand All @@ -97,45 +100,108 @@ You will need to add some Futurenet network lumens to your wallet to interact wi

> Note: These are test lumens for use with Futurenet and cannot be used on Mainnet
## Checkpoint 3: 🏦 Mint Tokens for the Crowdfunding Campaign
## Checkpoint 3: 🌟 Powering the Campaign

Fuel the vision! In this step, you will learn how to mint tokens and fund the crowdfunding campaign.

<Tabs defaultValue="mint" values={[
{label: '🏦 Mint Tokens', value: 'mint'},
{label: 'πŸ’° Fund the Campaign', value: 'fund'},
]}>

<TabItem value="mint">

<Tabs defaultValue="openDapp" values={[
{label: 'Mint', value: 'openDapp'},
{label: 'Approve', value: 'approveTx'},
{label: 'Check', value: 'checkBalance'},
]}>

<TabItem value="openDapp">

#### Open Dapp and Mint

Open the dapp frontend and click on the "Mint 100 ABND" button.

<img src={mintToken} width="40%" />

</TabItem>

<TabItem value="approveTx">

#### Approve Transaction

You should see a popup from Freighter asking you to sign the transaction. Click on "Approve" and wait for the transaction to be confirmed.

<img src={approveTokenMint} width="40%" />

</TabItem>

<TabItem value="checkBalance">

#### Check Updated Balance

You should see an updated balance in the pledge component.

<img src={updatedBalance} width="40%" />

> Note: These are test tokens for use with Futurenet and cannot be used on Mainnet
</TabItem>

</Tabs>

</TabItem>

## Checkpoint 4: πŸ’° Fund the Crowdfunding Campaign
<TabItem value="fund">

Now that you have your wallet set up, let's fund the crowdfunding campaign.
<Tabs defaultValue="setupWallet" values={[
{label: 'Deposit', value: 'setupWallet'},
{label: 'Approve', value: 'approveTx'},
{label: 'Check', value: 'confirmBalance'},
]}>

Open the frontend and click on the "Back this project" button. You should see a popup from Freighter asking you to sign the transaction.
<TabItem value="setupWallet">

#### Fund the Campaign

Now that you have your wallet set up, let's fund the crowdfunding campaign. Open the frontend and click on the "Back this project" button. You should see a popup from Freighter asking you to sign the transaction.

<img src={back100} width="40%" />

Click on "Approve" and wait for the transaction to be confirmed.
</TabItem>

<TabItem value="approveTx">

#### Approve Transaction

Once the transaction is confirmed, you should see a success message.
Click on "Approve" and wait for the transaction to be confirmed. Once the transaction is confirmed, you should see a success message.

<img src={success} width="40%" />

You should see an updated balance in the amount you have pledged in the pledge component.
</TabItem>

<TabItem value="confirmBalance">

#### Check Updated Pledged Amount

You should see an updated balance reflecting the amount you have pledged in the pledge component.

<img src={backedResult} width="40%" />

</TabItem>

</Tabs>

</TabItem>

</Tabs>

> Note: These are test tokens for use with Futurenet and cannot be used on Mainnet.
<CompleteStepButton id={0} progress={2}>
Funding completed
</CompleteStepButton>

## Checkpoint 5: 🚒 Ship it! 🚁
## Checkpoint 4: 🚒 Ship it! 🚁

Now that your dapp is fully functional, next prepare it for a new deployment on Futurenet, this time with a hosted frontend.

Expand All @@ -151,7 +217,7 @@ Then run the dev server again:
npm run dev
```

Now, open your browser and visit [http://localhost:3000](http://localhost:3000).
Now, open your browser and visit [http://localhost:3000](http://localhost:3000).

Ensure that you are connected to Futurenet and you should be able to see the frontend of your dapp!

Expand Down Expand Up @@ -199,39 +265,38 @@ You can now visit the preview link to see your deployed dapp! πŸŽ‰
<img src={deployedDApp} width="90%" />


## Checkpoint 6: πŸ’ͺ Pass the Challenge!
## Checkpoint 5: πŸ’ͺ Pass the Challenge!

Submit your public url to the challenge form and proceed to the next step to check your work.

<ParentChallengeForm id={0} />

<br/>
<br />

:::info

Join [our Community in Discord](https://discord.gg/stellardev) in case you have any issues or questions.

:::

## Checkpoint 7: βœ… Check your work!
## Checkpoint 6: βœ… Check your work!

In order to successfully complete this challenge, your work needs to be checked.
Please, follow this steps:
In order to successfully complete this challenge, your work needs to be checked. Please, follow this steps:

1. Fork [the challenge repository](https://github.com/stellar/soroban-dapps-challenge).
2. Fill `crowdfund/challenge/output.txt` file with your wallet address, contract ID and production url.
Filled file should look like:
2. Fill `crowdfund/challenge/output.txt` file with your wallet address. Filled file should look like:

```sh
public key: GBSXUXZSA2VEXN5VGOWE5ODAJLC575JCMWRJ4FFRDWSTRCJ123456789
contract Id: CBKY7UN5VGD4LIQFOBOTSUSQWK67BZZTA23NIEVWSWRR5SAT26JQN2BN
production: https://soroban-example-dapp-rho.vercel.app
Public Key: GBSXUXZSA2VEXN5VGOWE5ODAJLC575JCMWRJ4FFRDWSTRCJ123456789
```
3. Create a Pull Request to the `stellar/soroban-dapps-challenge/crowdfund` branch. When the PR will be created, CI actions will check the `crowdfund/challenge/output.txt` file data and update your progress.
4. Wait for the CI/CD pipeline results.
5. Fix errors if present:

- find the error reason in the Crowdfund challenge CI results (you can find a link right in the pull request);
- return to your forked repository;
- fix errors and commit changes. The existing PR will be checked again.

6. If the pipeline was successful, then congratulations! You completed the challenge!πŸ‘

Invite a friend to try out your dapp and ask them to provide feedback!
Expand Down
Loading

0 comments on commit 5c1fbe4

Please sign in to comment.