-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b57e806
commit 94ec7ff
Showing
6 changed files
with
104 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Getting Started | ||
|
||
## Installation | ||
|
||
::: code-group | ||
|
||
```sh [npm] | ||
$ npm add TBD_LIBRARY_NAME | ||
``` | ||
|
||
```sh [yarn] | ||
$ yarn add TBD_LIBRARY_NAME | ||
``` | ||
::: | ||
|
||
## Example Query | ||
|
||
### Standard Syntax | ||
```js | ||
/* | ||
* Queries the configuration for the swap pair | ||
*/ | ||
async function queryPairConfig({ | ||
contractAddress, | ||
codeHash, | ||
lcdEndpoint, | ||
chainId, | ||
}:{ | ||
contractAddress: string, | ||
codeHash?: string, // recommended for fastest query performance | ||
lcdEndpoint?: string, // defaults to public endpoint | ||
chainId?: string, // defaults to mainnet | ||
}): Promise<PairConfig> | ||
``` | ||
::: warning | ||
The LCD endpoint is an optional property. We provide one as a default inside ShadeJS to get you started quickly on Secret Network mainnet using a public API. It is still recommended that you provide your own because performance of the default endpoint is not guaranteed. | ||
::: | ||
```js | ||
try{ | ||
const output = await queryPairConfig({ | ||
contractAddress: '[PAIR_CONTRACT_ADDRESS]', | ||
}) | ||
// do something with the successful output | ||
} catch { | ||
// do something with the error | ||
} | ||
``` | ||
### RxJS Syntax | ||
|
||
Under the hood, ShadeJS uses <a href="https://rxjs.dev/" target="_blank">RxJS</a> as an observables library to build asynchronous functions. The async functions provided for interacting with the blockchain have an RxJS version as an alternative, and users can decide which one to use based on their preference. | ||
::: tip | ||
The standard async/await syntax funcion is designed as a simple wrapper function around the RxJS, so either way you are calling the RxJS version! | ||
::: | ||
|
||
```js | ||
/* | ||
* Queries the configuration for the swap pair | ||
*/ | ||
function queryPairConfig$({ | ||
contractAddress, | ||
codeHash, | ||
lcdEndpoint, | ||
chainId, | ||
}:{ | ||
contractAddress: string, | ||
codeHash?: string, | ||
lcdEndpoint?: string, | ||
chainId?: string, | ||
}): Observable<PairConfig> | ||
``` | ||
```js | ||
queryPairConfig$({ | ||
contractAddress: '[PAIR_CONTRACT_ADDRESS]', | ||
}).subscribe({ | ||
next: () => { | ||
// do something with the successful output | ||
}, | ||
error: () => { | ||
// do something with the error | ||
} | ||
}) | ||
|
||
``` | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# What is ShadeJS? | ||
|
||
ShadeJS is a typescript SDK for interacting with <a href="https://shadeprotocol.io/" target="_blank">Shade Protocol</a> and <a href="https://scrt.network/" target="_blank">Secret Network</a> smart contracts. It is designed as a wrapper for <a href="https://github.com/scrtlabs/secret.js" target="_blank">Secret.js</a> and abstracts the complexity of secret client management (for queries), as well as providing simple-to-use typescript interfaces for the inputs and outputs of contracts. In addition, it implements multi-query optimizations in order to obtain large on-chain data sets in a highly efficient manner. | ||
|
||
## Out of Scope | ||
In its current state, ShadeJS does NOT include services to execute contracts via a <a href="https://secretjs.scrt.network/#integrations" target="_blank">Secret Signing Client.</a> This is becuase signing transactions requires a complex integration with multiple types of wallets. However, ShadeJS DOES include message creator functions for executions that can be easily imported into your project, so that you can call them from your own signing client manager. |