Skip to content

Commit 5c35138

Browse files
committedFeb 24, 2023
update README and example
1 parent f576584 commit 5c35138

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed
 

‎README.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If you want to customize the button, use
3131
```js
3232
// Customized button text
3333
function ButtonText ({ pending }) {
34-
return pending ? '' : ''
34+
return pending ? 'Waiting for meson' : 'Deposit with meson'
3535
}
3636

3737
export default function App () {
@@ -47,17 +47,11 @@ export default function App () {
4747
}
4848
```
4949

50-
See a complete example in `examples/demo`
50+
See a complete example at https://github.com/MesonFi/meson-to-demo.
5151

52-
#### Plain HTML & JavaScript
52+
#### Plain JavaScript
5353

54-
You can also add meson.to directly to the html file
55-
56-
```html
57-
<script src="https://raw.githubusercontent.com/MesonFi/meson-to/main/dist/meson-to.js"></script>
58-
```
59-
60-
Once the script is loaded, you will be able to use `MesonTo` globally. If you use a package manager for your frontend project, you can also import it through
54+
If you use a package manager for your frontend project and want to call meson.to with plain JavaScript, import the global `MesonTo` class
6155

6256
```js
6357
import MesonTo from '@mesonfi/to'
@@ -67,20 +61,31 @@ To open the popup of MesonTo for cross-chain transfer, run
6761

6862
```js
6963
const appId = 'demo'
70-
const meson2 = new MesonTo(window)
64+
const meson2 = new MesonTo(window, {
65+
onCompleted: data => {
66+
// when a cross-chain transfer is successful
67+
console.log(data)
68+
}
69+
})
70+
7171
meson2.open(appId)
7272
.then(() => {
7373
// on popup closed; doesn't mean a cross-chain transfer is completed
7474
})
75-
76-
meson2.onCompleted(data => {
77-
// when a cross-chain transfer is successful
78-
console.log(data)
79-
})
8075
```
8176

8277
See the example project in `examples/plain`.
8378

79+
#### Use with `<script>`
80+
81+
You can also add meson.to directly to the html file
82+
83+
```html
84+
<script src="https://raw.githubusercontent.com/MesonFi/meson-to/main/dist/meson-to.js"></script>
85+
```
86+
87+
Once the script is loaded, you will be able to use `MesonTo` globally.
88+
8489
### Smart contract
8590

8691
The cross-chain'ed stablecoin will be transferred to the app contract from meson's contract. In order to accept the transfer correctly, your app contract needs to implement the `depositWithBeneficiary` method.
@@ -101,7 +106,7 @@ Once `depositWithBeneficiary` is supported, you can [contact us]() to register y
101106

102107
- App name
103108
- Prefered appId (popup will open at https://meson.to/{appId})
104-
- App URL (need to open popup from it in *release* mode)
109+
- App URL (need to open the popup from this URL in *release* mode)
105110
- App icon (w144 x h144)
106111
- App logo (height 144, width <= 1080)
107112
- Smart contract info (deployed chain, supported types of stablecoins, contract address)

‎examples/plain/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ <h2 class="tracking-tight text-gray-900">
4545
</div>
4646
</body>
4747
<script>
48-
const meson2 = new MesonTo(window)
49-
50-
meson2.onCompleted(data => {
51-
document.getElementById('received-display').innerHTML =
52-
`Received ${data.amount / 1e6} ${data.from.token} from ${data.fromAddress} of ${data.from.chain}.`
48+
const meson2 = new MesonTo(window, {
49+
onCompleted: data => {
50+
document.getElementById('received-display').innerHTML =
51+
`Received ${data.amount / 1e6} ${data.from.token} from ${data.fromAddress} of ${data.from.chain}.`
52+
}
5353
})
5454

5555
function onClickMesonTo (btn) {

0 commit comments

Comments
 (0)
Please sign in to comment.