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 generate-openrpc-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotFriend committed Jan 9, 2024
2 parents 890114d + 665d9db commit 5683446
Show file tree
Hide file tree
Showing 178 changed files with 13,283 additions and 11,669 deletions.
9 changes: 9 additions & 0 deletions api/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Introduction
---

import DocCardList from "@theme/DocCardList";

A public discussion about the design of soroban-rpc.

<DocCardList />
2 changes: 1 addition & 1 deletion api/goals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Soroban-RPC should provide all the basic data that a dapp developer would need,
Soroban-RPC should support the developer from local testing (via the quickstart image), all the way through to production deployments.

- This implies it should be easy to deploy, and easy to maintain; with low cost, and little "admin" needed.
- The developer should be able to simply run the quickstart docker image, and quickly be ready to serve requests without needing to set up or maintain dependent infrastructure.
- The developer should be able to simply run the quickstart docker image, and quickly be ready to serve requests without needing to set up or maintain dependent infrastructure.
14 changes: 7 additions & 7 deletions api/json-rpc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ When XDR is passed as a parameter or returned, it is always a string encoded usi

Soroban-RPC provides an [OpenRPC] specification document that can be used to mock, build, and/or validate both server and client software implementations. This document is used to generate all of our [methods] documentation pages. You can view the full [specification document here]. Additionally, you can experiment with this specificaiton document in the [OpenRPC Playground].

[JSON-RPC 2.0]: <https://www.jsonrpc.org/specification>
[jsonrpc error object]: <https://www.jsonrpc.org/specification#error_object>
[JavaScript SDK]: <https://github.com/stellar/js-stellar-sdk>
[OpenRPC]: <https://open-rpc.org/>
[methods]: <./methods>
[specification document here]: <https://raw.githubusercontent.com/stellar/soroban-docs/main/static/openrpc.json>
[OpenRPC Playground]: <https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/stellar/soroban-docs/main/static/openrpc.json>
[JSON-RPC 2.0]: https://www.jsonrpc.org/specification
[jsonrpc error object]: https://www.jsonrpc.org/specification#error_object
[JavaScript SDK]: https://github.com/stellar/js-stellar-sdk
[OpenRPC]: https://open-rpc.org/
[methods]: ./methods
[specification document here]: https://raw.githubusercontent.com/stellar/soroban-docs/main/static/openrpc.json
[OpenRPC Playground]: https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/stellar/soroban-docs/main/static/openrpc.json
2 changes: 1 addition & 1 deletion api/methods/getEvents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Returns contract events

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getEvents"/>
<RpcMethod method="getEvents" />
2 changes: 1 addition & 1 deletion api/methods/getHealth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Returns node health

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getHealth"/>
<RpcMethod method="getHealth" />
2 changes: 1 addition & 1 deletion api/methods/getLatestLedger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Returns latest known ledger

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getLatestLedger"/>
<RpcMethod method="getLatestLedger" />
56 changes: 26 additions & 30 deletions api/methods/getLedgerEntries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Returns ledger entries

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getLedgerEntries"/>
<RpcMethod method="getLedgerEntries" />

### Generating `keys` Parameters

Expand Down Expand Up @@ -55,23 +55,23 @@ yarn add @stellar/stellar-sdk
```

```js
import { xdr, StrKey } from '@stellar/stellar-sdk';
import { xdr, StrKey } from "@stellar/stellar-sdk";

const getLedgerKeySymbol = (contractId, symbolText) => {
const ledgerKey = xdr.LedgerKey.contractData(
new xdr.LedgerKeyContractData({
contractId: StrKey.decodeContract(contractId),
key: xdr.ScVal.scvSymbol(symbolText)
})
key: xdr.ScVal.scvSymbol(symbolText),
}),
);
return ledgerKey.toXDR('base64');
return ledgerKey.toXDR("base64");
};

console.log(
getLedgerKeySymbol(
'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE',
'COUNTER'
)
"CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE",
"COUNTER",
),
);
```

Expand Down Expand Up @@ -105,7 +105,6 @@ console.log(getLedgerKeyAccount(
# OUTPUT: AAAAAAAAAACp3BPIqFxM9XSnW6aHvavD3GWlJGfuylOt5tZL6CQtdQ==
```


We then take our output from this function, and use it as the element in the `keys` array parameter in our call to the `getLedgerEntries` method.

```json
Expand All @@ -126,7 +125,7 @@ And the response we get contains the `LedgerEntryData` with the current informat
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"entries":[
"entries": [
{
"key": "AAAAAAAAAACp3BPIqFxM9XSnW6aHvavD3GWlJGfuylOt5tZL6CQtdQ==",
"xdr": "AAAAAAAAAACp3BPIqFxM9XSnW6aHvavD3GWlJGfuylOt5tZL6CQtdQAAABdIdugAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA",
Expand All @@ -142,9 +141,9 @@ We can then parse this result as an `xdr.LedgerEntryData` type.

```js
const parsed = xdr.LedgerEntryData.fromXDR(
'AAAAAAAAAACp3BPIqFxM9XSnW6aHvavD3GWlJGfuylOt5tZL6CQtdQAAABdIdugAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA',
'base64'
)
"AAAAAAAAAACp3BPIqFxM9XSnW6aHvavD3GWlJGfuylOt5tZL6CQtdQAAABdIdugAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA",
"base64",
);
console.log(parsed);
```

Expand Down Expand Up @@ -192,18 +191,18 @@ print(
##### JavaScript

```javascript
import { Address, xdr } from '@stellar/stellar-sdk';
import { Address, xdr } from "@stellar/stellar-sdk";

function getLedgerKeyContractCode(contractId) {
const instance = new ContractId(contractId).getFootprint();
return instance.toXDR('base64');
return instance.toXDR("base64");
}

console.log(
getLedgerKeyContractCode(
"CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE"
)
)
"CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE",
),
);
// OUTPUT: AAAABq+aJSfjs7VXHWOwJGujK30xpTI3Zt98YN/As+O6b98jAAAAFA==
```

Expand All @@ -215,9 +214,7 @@ We then take our output from this function, and use it as the element in the `ke
"id": 8675309,
"method": "getLedgerEntries",
"params": {
"keys": [
"AAAABq+aJSfjs7VXHWOwJGujK30xpTI3Zt98YN/As+O6b98jAAAAFA=="
]
"keys": ["AAAABq+aJSfjs7VXHWOwJGujK30xpTI3Zt98YN/As+O6b98jAAAAFA=="]
}
}
```
Expand Down Expand Up @@ -280,31 +277,30 @@ const { xdr } = require("@stellar/stellar-sdk");
function getLedgerKeyWasmId(contractCodeLedgerEntryData) {
const entry = xdr.LedgerEntryData.fromXDR(
contractCodeLedgerEntryData,
"base64"
"base64",
);

const instance = entry.contractData().val().instance();

let ledgerKey = xdr.LedgerKey.contractCode(
new xdr.LedgerKeyContractCode({
hash: instance.wasmHash()
})
hash: instance.wasmHash(),
}),
);

return ledgerKey.toXDR('base64');
return ledgerKey.toXDR("base64");
}

console.log(
getLedgerKeyWasmId(
"AAAABq+aJSfjs7VXHWOwJGujK30xpTI3Zt98YN/As+O6b98jAAAAFAAAABIAAAAAZBYoEJT3IaPMMk3FoRmnEQHoDxewPZL+Uor+xWI4uII="
)
)
"AAAABq+aJSfjs7VXHWOwJGujK30xpTI3Zt98YN/As+O6b98jAAAAFAAAABIAAAAAZBYoEJT3IaPMMk3FoRmnEQHoDxewPZL+Uor+xWI4uII=",
),
);
// OUTPUT: AAAAB2QWKBCU9yGjzDJNxaEZpxEB6A8XsD2S/lKK/sViOLiC
```

Now, finally we have a `LedgerKey` that correspond to the Wasm byte-code that has been deployed under the `ContractId` we started out with so very long ago. This `LedgerKey` can be used in a final request to the Soroban-RPC endpoint.


```json
{
"jsonrpc": "2.0",
Expand Down Expand Up @@ -337,4 +333,4 @@ And the response we get contains (even more) `LedgerEntryData` that we can decod
```

[`increment` example contract]: /docs/getting-started/storing-data
["View XDR" page of the Stellar Laboratory]: <https://laboratory.stellar.org/#xdr-viewer?type=LedgerEntryData&network=testnet>
["View XDR" page of the Stellar Laboratory]: https://laboratory.stellar.org/#xdr-viewer?type=LedgerEntryData&network=testnet
2 changes: 1 addition & 1 deletion api/methods/getNetwork.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Returns network config

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getNetwork"/>
<RpcMethod method="getNetwork" />
2 changes: 1 addition & 1 deletion api/methods/getTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Returns transaction details

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="getTransaction"/>
<RpcMethod method="getTransaction" />
2 changes: 1 addition & 1 deletion api/methods/sendTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Submits a transaction

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="sendTransaction"/>
<RpcMethod method="sendTransaction" />
2 changes: 1 addition & 1 deletion api/methods/simulateTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: Submits a trial contract invocation transaction

import { RpcMethod } from "@site/src/components/RpcMethod";

<RpcMethod method="simulateTransaction"/>
<RpcMethod method="simulateTransaction" />
10 changes: 3 additions & 7 deletions api/pagination.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Pagination in soroban-rpc is similar to pagination in Horizon.

For methods which support it, the pagination arguments are passed as a final object argument with two values:

- `cursor`: string - (optional) A string ID that points to a specific location in a collection of responses and is pulled from the paging_token value of a record. When a cursor is provided Soroban-RPC will *not* include the element whose id matches the cursor in the response. Only elements which appear *after* the cursor are included.
- `limit`: number - (optional) The maximum number of records returned. The limit for [getEvents](methods/getEvents) can range from 1 to 10000 - an upper limit that is hardcoded in Soroban-RPC for performance reasons. If this argument isn't designated, it defaults to 100.
- `cursor`: string - (optional) A string ID that points to a specific location in a collection of responses and is pulled from the paging*token value of a record. When a cursor is provided Soroban-RPC will \_not* include the element whose id matches the cursor in the response. Only elements which appear _after_ the cursor are included.
- `limit`: number - (optional) The maximum number of records returned. The limit for [getEvents](methods/getEvents.mdx) can range from 1 to 10000 - an upper limit that is hardcoded in Soroban-RPC for performance reasons. If this argument isn't designated, it defaults to 100.

For example, calling a method with pagination parameter set:

Expand All @@ -18,10 +18,6 @@ For example, calling a method with pagination parameter set:
"jsonrpc": "2.0",
"Id": "1",
"method": "exampleMethod",
"params": [
"other",
"arguments",
{ "cursor": "1234-1", "limit": 100 }
]
"params": ["other", "arguments", { "cursor": "1234-1", "limit": 100 }]
}
```
5 changes: 2 additions & 3 deletions dapps/index.mdx → dapps/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ While the course specifically focuses on the Soroban platform, the knowledge you

Through The Soroban Dapps Challenge, you'll have hands-on experience using Soroban's initial versions of the smart contracts environment, a Rust SDK, a CLI, and an RPC server. You'll learn how to write, test, and deploy smart contracts, and you'll get to see your code in action on Futurenet.

# What This Course Entails
## What This Course Entails

We've designed this course as a learning adventure. It's a way for developers from the Stellar ecosystem and other blockchain communities to experiment, provide feedback, and contribute to the Soroban development process.

As you progress through The Soroban Dapps Challenge, anticipate your code to break and updates to shift things. We invite you to experiment and build but also remind you that changes are afoot as we prepare for the production release.


## Getting Started

To get started, simply head over to the [Dashboard](/dashboard), connect your wallet, and see what challenges await you!

# Giving Your Feedback
## Giving Your Feedback

We value your input. Feel free to file issues in the Soroban repos or raise them in the soroban channel in the Stellar Developer [Discord](https://discord.gg/3qrBhbwE).

Expand Down
12 changes: 6 additions & 6 deletions dapps/dapp-challenges/challenge-0-crowdfund.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ npm run dev

Now open your browser and visit [http://localhost:3000](http://localhost:3000). You should be able to see the frontend of your dapp.

> Note: Follow the instructions below and ensure that you have funded your wallet address that you intend to use from browser, otherwise the dapp display will be blank and a 'Account not found' will be printed on browser's console only. If you are using Freighter, be sure that you have properly configured the Freighter Wallet by following the instructions [here](../guides/wallets#connect-a-wallet-freighter).
> Note: Follow the instructions below and ensure that you have funded your wallet address that you intend to use from browser, otherwise the dapp display will be blank and a 'Account not found' will be printed on browser's console only. If you are using Freighter, be sure that you have properly configured the Freighter Wallet by following the instructions [here](../guides/wallets.mdx#connect-a-wallet-freighter).
Now that you have the frontend running, it's time to connect it with the backend, your smart contract, that defines the rules and logic of the crowdfund campaign, including the function for accepting contributions. If you want to dig into the specifics of the contract, take a look at the video walkthrough of the contract code [here](https://youtu.be/vTz0CQYnMRQ?t=260&feature=shared).

Expand Down Expand Up @@ -225,7 +225,7 @@ You should see an updated balance reflecting the amount you have pledged in the

## Checkpoint 4: 🚢 Ship it! 🚁

Now that your dapp is fully functional, its time to deploy it to a production environment. In this step, you will learn how to deploy your dapp to Vercel, a cloud platform for static sites that offers a quick and effective way to deploy the frontend of your dapp. This section requires that you have a [Vercel account] and the Vercel cli installed.
Now that your dapp is fully functional, its time to deploy it to a production environment. In this step, you will learn how to deploy your dapp to Vercel, a cloud platform for static sites that offers a quick and effective way to deploy the frontend of your dapp. This section requires that you have a [Vercel account] and the Vercel cli installed.

If you don't have the Vercel cli installed, run the following command to install it globally:

Expand All @@ -241,7 +241,7 @@ Next, you will need to remove the `target` directory to save space for the the d
rm -rf target
```

>Note: You can build this directory again by running `soroban contract build` in the `contracts/abundance` directory.
> Note: You can build this directory again by running `soroban contract build` in the `contracts/abundance` directory.
Then, remove any existing `.vercel` directory in your project to ensure that you are starting with a clean slate:

Expand All @@ -255,7 +255,7 @@ Then, run the following command to deploy your example dapp:
vercel --prod
```

Vercel will prompt you to link your local project to a new Vercel project.
Vercel will prompt you to link your local project to a new Vercel project.
Follow the answers to the prompts below to ensure that your local project is correctly linked to a new Vercel project:

```bash
Expand Down Expand Up @@ -286,7 +286,6 @@ You can now visit the preview link to see your deployed dapp! 🎉

Remember, you must add Futurenet network lumens to your Freighter wallet to interact with the deployed example dapp. Visit https://laboratory.stellar.org/#account-creator?network=futurenet, and follow the instructions to create your Freighter account on Futurenet.


## Checkpoint 5: 💪 Pass the Challenge!

Now it's time to submit your work!
Expand All @@ -313,6 +312,7 @@ In order to successfully complete this challenge, your work needs to be checked.
```sh
Public Key: GBSXUXZSA2VEXN5VGOWE5ODAJLC575JCMWRJ4FFRDWSTRCJ123456789
```

3. Create a Pull Request to the `stellar/soroban-dapps-challenge/crowdfund` branch. When the PR is 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:
Expand Down Expand Up @@ -371,4 +371,4 @@ Then via the web UI, you should be able to:

## 🛡️🗡️ Take On More Challenges

View your progress and take on more challenges by visiting your [User Dashboard!](/dashboard)
View your progress and take on more challenges by visiting your [User Dashboard!](/dashboard)
Loading

0 comments on commit 5683446

Please sign in to comment.