Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
duelingbenjos committed Jun 26, 2024
2 parents aa3662c + db1a637 commit ca4b668
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
57 changes: 54 additions & 3 deletions src/smart-contracts/concepts/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,63 @@ Metering is set to false so that the executor does not use any stamps when execu

### Step 1: Submit Transaction

<center><img src='../img/import.png' width=75%></center>

```txt
+----------------+
+------------------------| Error returned |<-----+
| | to Executor | |
| +----------------+ |
| Module Loader |
| +----------------+ |
| | - - - | |
| Does this | - - | |
|-------------\ v mart contract | | - - - | | |
| transaction -\ +----------+ exist? | | state |-------No--+
| submitted - | Executor |----------------->| - - - - |
| to Executor -/ +----------+ | | |
|-------------/ ^ | Yes |
| | | |
| | v |
| | +--------+ |
| | |contract| |
| | +--------+ |
| | | |
+----------------------+ +-------|--------+
| Smart contract | |
| returned to Executor |-----------+
+----------------------+
```
Executor retrieves the module for the smart contract if it exists.

### Step 2: Execution
<center><img src='../img/execute.png' width=75%></center>
```txt
+------------------------+
+----------------------------------| Error returned to |<--------+
| | Executor |<-----+ |
| +------------------------+ | |
| Python VM | |
| +--------------------------+ | |
| | +--------------------+ | | |
| | | Does the function |----No-+ |
| | | exist? | | |
| | +--------------------+ | |
| | | | |
| Execute this function | v | |
v on this smart contract | +--------------------+ | |
+----------+ with these arguments | | Are there enough |----No----+
| Executor |--------------------------->| | stamps | |
+----------+ | +--------------------+ |
^ | | |
| | v |
| | +--------------------+ |
| | | Execute | |
| | +--------------------+ |
| +--------------------------+
| |
| |
| +------------------------+ |
+----| Results of Execution |<-----------------+
+------------------------+
```

The executor attempts to execute a function on the smart contract. If it fails due to Python errors or invalid inputs, the executor will get a response. Otherwise, the function is called and the results of the execution are returned to the executor and which can be passed to the operator.

Expand Down
18 changes: 18 additions & 0 deletions src/smart-contracts/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ def call_direct():
- However, if `2fadab39` calls `call_direct` on the `con_indirect` contract, `con_indirect` will be returned because `con_indirect` is now the caller of this function.

:::

```txt
con_direct
ctx.signer +----------------+
| calling |
2fadab39 ---> | who_am_I( ) |
| |
+----------------+
ctx.caller = 2fadab39
con_indirect con_direct
ctx.signer +---------------+ +----------------+
| | | calling |
2fadab39 ---> | | ---> | who_am_I( ) |
| | | |
+---------------+ +----------------+
ctx.caller = con_indirect
```
A good example of how to use this would be in a token contract.

:::tip `con_token` smart-contract
Expand Down
14 changes: 14 additions & 0 deletions src/tools/xian-wallet-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@ XianWalletUtils.sendTransaction(
}
});
```

### Sign Message

To request a wallet to sign a message, you can use the `signMessage` function. This function returns a promise that resolves with the signed msg. (only works with strings, JSON, objects wont work)

```javascript
XianWalletUtils.signMessage("message")
.then(response => {
console.log('Signed Message', response.signature);
})
.catch(error => {
console.error(error);
});
```

0 comments on commit ca4b668

Please sign in to comment.