Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 87fd582

Browse files
authored
update widget docs (#157)
* update widget docs the `;` is misplaced. should be outside the angle bracket ``` function MyDapp() { return ( <SygmaProtocolReactWidget /> ); } ``` * add import react from "react" line * small syntax correction in the properties snippet * add export statement * add polkadot/types dependencies * add properties currently available that can modify widget behaviour * add prop desc and usage patterns * formatting * update all widget links to point to playground * dictionary * yarn.lock * dev dependency for polkadot/types * comment dependencies for polkadot * update tsblock for markdown * update props. add props to its own page * dictionary
1 parent 7628cc0 commit 87fd582

File tree

8 files changed

+97
-62
lines changed

8 files changed

+97
-62
lines changed

dictionary.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,13 @@ optionalities
470470
Base-Sepolia
471471
B3
472472
SygmaBTC
473-
sygBTC
473+
sygBTC
474+
whitelistedSourceNetworks
475+
whitelistedDestinationNetworks
476+
whitelistedSourceResources
477+
walletModules
478+
substrateProviders
479+
MAINNET
480+
sygma-props
481+
SygmaProtocolReactWidget
482+
setState

docs/01-introduction/01-index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Sygma is a fully open source ([Lesser General Public License version 3.0 (LGPL-3
1818
- Pass your first [generic message cross-chain](../03-sygma-sdk/04-Examples/02-GMP-Examples/01-GMP-Example-With-A-Simple-Storage-Contract.md)
1919
- See the [environments](../08-resources/01-environments/01-index.md) Sygma is deployed in
2020
- Look under the hood at the [architecture](../02-sygma-protocol/01-index.md)
21-
- Integrate the [Sygma Widget](https://sygma-react-widget.pages.dev/) into your dApp
21+
- Integrate the [Sygma Widget](https://docs.buildwithsygma.com/sygma-widget/playground/) into your dApp
2222
- Read more on the [Sygma Vision](02-origins.md)
2323

2424
For the complete source code, please check out [Sygma's GitHub Repositories](../08-resources/04-github-repositories.md).

docs/04-integrating-with-sygma/01-Sygma Widget/01-index.md

+1-23
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,4 @@ yarn dev
4040

4141
## How To Integrate
4242

43-
Follow the [Lit](02-lit.md) or [React](03-react.md) documentation for framework-specific instructions.
44-
45-
## Widget Properties
46-
47-
The behaviour of the Sygma Widget can be customized using configurable properties (props). A complete reference of the properties can be found under [packages/widget/src/widget.ts](https://github.com/sygmaprotocol/sygma-widget/blob/main/packages/widget/src/widget.ts)/
48-
49-
Below you will find an example of props being passed to whitelist (i.e enable) the source and destination networks in the React component:
50-
51-
```ts
52-
// App.tsx
53-
import { SygmaProtocolReactWidget } from "@buildwithsygma/sygmaprotocol-react-widget";
54-
55-
function MyDapp() {
56-
const [count, setCount] = useState(0);
57-
58-
return (
59-
<SygmaProtocolReactWidget
60-
whitelistedSourceNetworks={["sepolia"]}
61-
whitelistedDestinationNetworks={["cronos"]}
62-
/>
63-
);
64-
}
65-
```
43+
Follow the [Lit](02-lit.md) or [React](03-react.md) documentation for framework-specific instructions.

docs/04-integrating-with-sygma/01-Sygma Widget/02-lit.md

+1-17
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,4 @@ declare global {
4242
}
4343
```
4444

45-
You can also pass properties into the widget to customize its behaviour:
46-
47-
```ts
48-
render() {
49-
return html`
50-
<div>
51-
<sygmaprotocol-widget
52-
.environment=${Environment.MAINNET}
53-
.whitelistedSourceNetworks=${['sepolia']}
54-
.whitelistedDestinationNetworks=${['cronos']}
55-
></sygmaprotocol-widget>
56-
</div>
57-
`
58-
}
59-
```
60-
61-
See [widget.ts](https://github.com/sygmaprotocol/sygma-widget/blob/main/packages/widget/src/widget.ts) for all of the available properties.
45+
You can also pass properties into the widget to customize its behaviour. See [Properties](05-properties.md) for more.

docs/04-integrating-with-sygma/01-Sygma Widget/03-react.md

+6-18
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sidebar_position: 3
1111
Add the following dependencies to integrate the widget into any React project:
1212

1313
```bash
14-
yarn add @polkadot/extension-inject
14+
yarn add @polkadot/extension-inject # required for polkadot wallet injections
1515
```
1616

1717
And similarly:
@@ -25,28 +25,16 @@ yarn add @buildwithsygma/sygmaprotocol-react-widget @buildwithsygma/sygma-sdk-co
2525
After installation, add the widget into your code using:
2626

2727
```ts
28+
import React from "react";
2829
import { SygmaProtocolReactWidget } from '@buildwithsygma/sygmaprotocol-react-widget';
2930

3031
function MyDapp(){
3132
return (
32-
<SygmaProtocolReactWidget />;
33-
)
33+
<SygmaProtocolReactWidget />
34+
);
3435
}
35-
```
36-
37-
You can also pass props to the widget component to customize it:
3836

39-
```ts
40-
function MyDapp(){
41-
return (
42-
<SygmaProtocolReactWidget
43-
environment={Environment.MAINNET}
44-
whitelistedSourceNetworks={["sepolia"]}
45-
whitelistedDestinationNetworks={["cronos"]}
46-
evmProvider={myEip1193Provider}
47-
/>
48-
)
49-
}
37+
export default MyDapp;
5038
```
5139

52-
See [widget.ts](https://github.com/sygmaprotocol/sygma-widget/blob/main/packages/widget/src/widget.ts) for all of the available properties.
40+
You can also pass props to the widget component to customize widget behaviour. See [Properties](05-properties.md) for more.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
id: sygma-props
3+
slug: /sygma-widget/props
4+
title: Properties
5+
description: The following section provides details on utilizing widget properties
6+
sidebar_position: 5
7+
---
8+
9+
# Widget Properties
10+
11+
The behaviour of the Sygma Widget can be customized using configurable properties (props). A complete reference of the properties can be found under [packages/widget/src/widget.ts](https://github.com/sygmaprotocol/sygma-widget/blob/main/packages/widget/src/widget.ts).
12+
13+
:::info
14+
Note that some properties require installing additional dependencies.
15+
:::
16+
17+
The currently available properties are:
18+
- **environment**
19+
- Desc: Determines whether the widget operates on the live network (mainnet) or a testing environment (testnet).
20+
- Usage:
21+
1. Install `@polkadot/types` dependency: `yarn add -D @polkadot/types`
22+
2. Configure either MAINNET or TESTNET environment inside the SygmaProtocolReactWidget: `<SygmaProtocolReactWidget environment={Environment.MAINNET} />`
23+
- **whitelistedSourceNetworks**
24+
- Desc: Specifies which blockchain networks can be selected as the source for transactions.
25+
- Usage: `<SygmaProtocolReactWidget whitelistedSourceNetworks={["sepolia"]} />`
26+
- **whitelistedDestinationNetworks**
27+
- Desc: Specifies which blockchain networks can be selected as the destination for transactions.
28+
- Usage: `<SygmaProtocolReactWidget whitelistedDestinationNetworks={["cronos"]} />`
29+
- **whitelistedSourceResources**
30+
- Desc: Defines which assets or resources (e.g., tokens) can be selected for transaction.
31+
- Usage: `<SygmaProtocolReactWidget whitelistedSourceResources={["resourceID1", "resourceID2"]} />`
32+
- **substrateProviders**
33+
- Desc: Specifies the API endpoints or connection details for Substrate-based blockchain networks.
34+
- Usage:
35+
1. Install `@polkadot/api` dependency: `yarn add @polkadot/api`
36+
2. Add import statements to the top of the app: `import { ApiPromise, WsProvider } from '@polkadot/api';`
37+
3. Setup a `setState` action: `const [substrateProviders, setSubstrateProviders] = useState<ApiPromise[]>([]);`
38+
4. Initialize the Substrate provider:
39+
```ts
40+
useEffect(() => {
41+
const provider = new WsProvider('[YOUR_SUBSTRATE_WSS_PROVIDER_HERE]');
42+
const api = new ApiPromise({ provider });
43+
api.isReady.then(() => {
44+
console.log('API is ready');
45+
setSubstrateProviders([api]);
46+
});
47+
}, []);
48+
```
49+
5. Pass the provider into the component:
50+
```ts
51+
<SygmaProtocolReactWidget
52+
substrateProviders={substrateProviders}
53+
/>
54+
```
55+
56+
## Using Props In An Example
57+
58+
Below you will find an example of props being passed to whitelist (i.e enable) the source and destination networks in the React component:
59+
60+
```ts
61+
// App.tsx
62+
import React from "react";
63+
import { SygmaProtocolReactWidget } from "@buildwithsygma/sygmaprotocol-react-widget";
64+
import { Environment } from '@buildwithsygma/sygma-sdk-core';
65+
66+
function MyDapp() {
67+
const [count, setCount] = useState(0);
68+
69+
return (
70+
<SygmaProtocolReactWidget
71+
whitelistedSourceNetworks={["sepolia"]}
72+
whitelistedDestinationNetworks={["cronos"]}
73+
/>
74+
);
75+
}
76+
```

docs/08-resources/02-official-links.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ description: The following section details official links related to Sygma
1717

1818
#### [Testnet Explorer](https://scan.test.buildwithsygma.com)
1919

20-
#### [Testnet Transfer Widget](https://sygma-react-widget.pages.dev/)
20+
#### [Testnet Transfer Widget](https://docs.buildwithsygma.com/sygma-widget/playground/)
2121

2222
#### [Testnet Faucet](../08-resources/01-environments/03-testnet/01-obtain-testnet-tokens.md)
2323

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -13250,4 +13250,4 @@ zwitch@^1.0.0:
1325013250
zwitch@^2.0.0:
1325113251
version "2.0.4"
1325213252
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"
13253-
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==
13253+
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==

0 commit comments

Comments
 (0)