Skip to content

Commit f6307ae

Browse files
Release 0.3.4 London (#1811)
Signed-off-by: salaheldinsoliman <[email protected]> Signed-off-by: Sean Young <[email protected]> Co-authored-by: Sean Young <[email protected]>
1 parent ca456ae commit f6307ae

File tree

31 files changed

+628
-24
lines changed

31 files changed

+628
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/docs/build
2+
/docs/.venv
23
Cargo.lock
34
/target
45
**/*.rs.bk

CHANGELOG.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,49 @@ will be documented here.
44

55
## Unreleased
66

7+
## v0.3.4 London
8+
79
### Added
10+
- **Soroban** Support for [Stellar Asset Contract(SAC)](https://developers.stellar.org/docs/tokens/stellar-asset-contract)
11+
- **Soroban** Support for [Cross Contract Calls](https://developers.stellar.org/docs/build/smart-contracts/example-contracts/cross-contract-call)
12+
- **Soroban** Support for [Soroban Authorization Framework](https://developers.stellar.org/docs/learn/fundamentals/contract-development/authorization)
13+
- **Soroban** Support for different [Soroban Storage types](https://developers.stellar.org/docs/build/guides/storage/choosing-the-right-storage)
814
- **Soroban** Work on adding support for [Stellar's Soroban](https://soroban.stellar.org/docs) contracts platforms started, by adding a skeleton that supports the Soroban runtime. [Salaheldin Soliman](https://github.com/salaheldinsoliman)
9-
1015
- The `string.concat()` and `bytes.concat()` builtin functions are supported. [seanyoung](https://github.com/seanyoung)
16+
- **Experimental**: Three address code format IR for the CFG has been implemented (disabled by default).
17+
[fanyi-zhao](https://github.com/fanyi-zhao).
18+
- **Polkadot**: Compatibility with ink! v5.0 metadata and substrate-contracts-node v0.39.0
19+
- Implement event selectors [seanyoung](https://github.com/seanyoung)
20+
- Add a feature flag for compiling language server [xermicus](https://github.com/xermicus)
21+
- Parsing the pragma solidity version numbers, making this information available in the downstream
22+
compilation pipeline [seanyoung](https://github.com/seanyoung)
1123

1224
### Changed
25+
- **Polkadot/BREAKING**: Event encoding and topics follow [ink! v5.0](https://use.ink/faq/migrating-from-ink-4-to-5#events-20-1)
1326
- **BREAKING** The non-standard extension of concatenating strings using the `+` operator
1427
has been removed, use `string.concat()` instead. [seanyoung](https://github.com/seanyoung)
1528
- Removed the `--no-log-api-return-codes` compile flag as this is now done by the runtime [xermicus](https://github.com/xermicus)
29+
- **Solana/BREAKING**: Remove balance, transfer, and send builtins from Solana [LucasSte](https://github.com/LucasSte)
30+
- No longer support numbers in octal notation [seanyoung](https://github.com/seanyoung)
31+
- Moved to LLVM version 16 [seanyoung](https://github.com/seanyoung)
32+
- Improve overloaded function call diagnostics: From Solidity 0.6 onwards, overloaded functions or events
33+
resolving to multiple candidates are an error. In earlier versions, the first result is used.
34+
[seanyoung](https://github.com/seanyoung)
35+
- **Polkadot**: Implement the caller_is_root runtime API as a builtin [xermicus](https://github.com/xermicus)
36+
37+
### Fixed
38+
- [Two Infinite loops in codegen](https://github.com/hyperledger-solang/solang/commit/c6db2acc8a3927fae17c437eeeea0d0ae49a67df), thanks to @smoelius.
39+
- [Handle abi.encode() with infinite empty arguments](https://github.com/hyperledger-solang/solang/commit/12a6d83b91f7f5a4cc48156e1112638e733e143a), thanks to @smoelius.
40+
- Unreachable code, function types with parameter/return names and unknown assembly flags are warnings
41+
instead of errors, matching with solc. [xermicus](https://github.com/xermicus)
42+
- Fixed a bunch of typos in the documentation [divdeploy](https://github.com/divdeploy)
43+
- Clean up the LLD linker context after linking each contract, preventing potential issues when compiling
44+
multiple contracts at once. [xermicus](https://github.com/xermicus)
45+
- Expression statement should be followed by a semicolon, fixing a bug where "_;" was incorrectly parsed
46+
as a variable. [seanyoung](https://github.com/seanyoung)
47+
- Represent type(T) correctly in the AST, fixing various related issues [seanyoung](https://github.com/seanyoung)
48+
- Fix a bug in abi.encodeCall() argument parsing when there is only a single argument [seanyoung](https://github.com/seanyoung)
49+
- Fixed a codegen bug when the RHS of a shift expression is a struct member [PaddyClark0](https://github.com/PaddyClark0)
1650

1751
## v0.3.3 Atlantis
1852

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "solang"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
authors = ["Sean Young <[email protected]>", "Lucas Steuernagel <[email protected]>", "Cyrill Leutwiler <[email protected]>"]
55
repository = "https://github.com/hyperledger-solang/solang"
66
documentation = "https://solang.readthedocs.io/"
@@ -10,7 +10,7 @@ description = "Solang Solidity Compiler"
1010
keywords = [ "solidity", "compiler", "solana", "polkadot", "substrate" ]
1111
rust-version = "1.85.0"
1212
edition = "2021"
13-
exclude = [ "/.*", "/docs", "/examples", "/solana-library", "/tests", "/integration", "/vscode", "/testdata" ]
13+
exclude = [ "/.*", "/docs", "/solana-library", "/tests", "/integration", "/vscode", "/testdata" ]
1414

1515
[build-dependencies]
1616
cc = "1.0"
@@ -46,7 +46,7 @@ itertools = ">=0.10, <=0.13"
4646
num-rational = "0.4"
4747
indexmap = "2.2"
4848
once_cell = "1.19"
49-
solang-parser = { path = "solang-parser", version = "0.3.3" }
49+
solang-parser = { path = "solang-parser", version = "0.3.5" }
5050
codespan-reporting = "0.11"
5151
phf = { version = "0.11", features = ["macros"] }
5252
rust-lapper = { version = "1.1", optional = true }
@@ -67,7 +67,7 @@ primitive-types = { version = "0.12", features = ["codec"] }
6767
normalize-path = "0.2.1"
6868
bitflags = "2.4"
6969
scopeguard = "1.2.0"
70-
forge-fmt = { path = "fmt", optional = true }
70+
solang-forge-fmt = { version = "0.2.0", optional = true }
7171
# We don't use ethers-core directly, but need the correct version for the
7272
# build to work.
7373
ethers-core = { version = "2.0.10", optional = true }
@@ -93,6 +93,7 @@ ink_primitives = "5.0.0"
9393
wasm_host_attr = { path = "tests/wasm_host_attr" }
9494
num-bigint = { version = "0.4", features = ["rand", "serde"]}
9595

96+
9697
[package.metadata.docs.rs]
9798
no-default-features = true
9899

@@ -104,7 +105,7 @@ soroban = ["soroban-sdk"]
104105
default = ["llvm", "wasm_opt", "language_server", "soroban"]
105106
llvm = ["inkwell", "libc"]
106107
wasm_opt = ["llvm", "wasm-opt", "contract-build"]
107-
language_server = ["tower-lsp", "forge-fmt", "ethers-core", "tokio", "rust-lapper"]
108+
language_server = ["tower-lsp", "solang-forge-fmt", "ethers-core", "tokio", "rust-lapper"]
108109

109110
[workspace]
110111
members = ["solang-parser", "fmt", "tests/wasm_host_attr"]

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://raw.githubusercontent.com/hyperledger/solang/main/docs/hl_solang_horizontal-color.svg" alt="Solang Logo" width="75%"/>
22

3-
# solang - Solidity Compiler for Solana and Polkadot
3+
# solang - Solidity Compiler for Solana, Polkadot and Soroban
44

55
[![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.gg/hyperledger)
66
[![CI](https://github.com/hyperledger-solang/solang/workflows/test/badge.svg)](https://github.com/hyperledger-solang/solang/actions)
@@ -9,7 +9,7 @@
99
[![LoC](https://tokei.rs/b1/github/hyperledger/solang?category=lines)](https://github.com/hyperledger-solang/solang)
1010

1111
Welcome to Solang, a new Solidity compiler written in rust which uses
12-
llvm as the compiler backend. Solang can compile Solidity for Solana and
12+
llvm as the compiler backend. Solang can compile Solidity for Solana, Soroban and the
1313
Polkadot Parachains with the `contracts` pallet.
1414
Solang is source compatible with Solidity 0.8,
1515
with some caveats due to differences in the underlying blockchain.
@@ -51,6 +51,40 @@ You will have a file called flipper.contract. You can use this directly in
5151
the [Contracts UI](https://contracts-ui.substrate.io/),
5252
as if your smart contract was written using ink!.
5353

54+
55+
## Build for Soroban
56+
57+
Select one of the supported contracts for Soroban, available in on Solang's repository:
58+
59+
```bash
60+
solang compile --target soroban examples/soroban/token.sol
61+
```
62+
63+
You will have a file called `token.wasm`. Deploy it using the [`Stellar CLI`](https://developers.stellar.org/docs/tools/cli), after following the [`Stellar CLI Setup Manual`](https://developers.stellar.org/docs/build/smart-contracts/getting-started/setup):
64+
65+
``` bash
66+
stellar contract deploy --source-account alice --wasm token.wasm --network testnet -- --_admin alice --_name SolangToken --_symbol SOLT --_decimals 18
67+
ℹ️ Skipping install because wasm already installed
68+
ℹ️ Using wasm hash b1c84d8b8057a62fb6d77ef55c9e7fb2e66c74136c7df32efd87a1c9d475f1b0
69+
ℹ️ Simulating deploy transaction…
70+
ℹ️ Transaction hash is fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d
71+
🔗 https://stellar.expert/explorer/testnet/tx/fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d
72+
ℹ️ Signing transaction: fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d
73+
🌎 Submitting deploy transaction…
74+
🔗 https://stellar.expert/explorer/testnet/contract/CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW
75+
✅ Deployed!
76+
CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW
77+
```
78+
79+
Once deployed, copy the deployed contract ID and interact with it:
80+
81+
``` bash
82+
stellar contract invoke --network testnet --id CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW --source-account alice -- mint --to alice --amount 120
83+
ℹ️ Signing transaction: e0d68ae85bfbe0fceed8bcadd6613e12b3159f27dbf7c18e35e94de2b4a11ee2
84+
```
85+
86+
87+
5488
## Tentative roadmap
5589

5690
Solang has a high level of compatibility with many blockchains. We are trying to ensure the compiler stays
@@ -69,6 +103,7 @@ Here is a brief description of what we envision for the next versions.
69103
| Declare accounts for a Solidity function on Solana | In progress |
70104
| Tooling for calls between ink! <> solidity | In progress |
71105
| Provide CLI for node interactions | [Done](https://github.com/hyperledger-solang/solang-aqd) |
106+
| Support all [Soroban examples](https://github.com/stellar/soroban-examples) | In progress |
72107

73108
## License
74109

docs/examples/soroban/auth.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract auth {
4+
// Only this address can call the increment function
5+
address public owner = address"GDRIX624OGPQEX264NY72UKOJQUASHU3PYKL6DDPGSTWXWJSBOTR6N7W";
6+
7+
8+
uint64 public instance counter = 20;
9+
10+
function increment() public returns (uint64) {
11+
12+
owner.requireAuth();
13+
14+
counter = counter + 1;
15+
16+
return counter;
17+
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract a {
4+
function call_b (address b, address c) public returns (uint64) {
5+
address addr = address(this);
6+
// authorize contract c to be called, with function name "get_num" and "a" as an arg.
7+
// get_num calls a.require_auth()
8+
auth.authAsCurrContract(c, "get_num", addr);
9+
bytes payload = abi.encode("increment", addr, c);
10+
(bool suc, bytes returndata) = b.call(payload);
11+
uint64 result = abi.decode(returndata, (uint64));
12+
return result;
13+
}
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract b {
4+
5+
uint64 public instance counter = 20;
6+
7+
function increment(address a, address c) public returns (uint64) {
8+
9+
a.requireAuth();
10+
bytes payload = abi.encode("get_num", a);
11+
(bool suc, bytes returndata) = c.call(payload);
12+
uint64 result = abi.decode(returndata, (uint64));
13+
14+
counter = counter + 2;
15+
16+
return counter;
17+
18+
}
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract c {
4+
function get_num(address a) public returns (uint64) {
5+
a.requireAuth();
6+
return 2;
7+
}
8+
}

docs/examples/soroban/error.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract error {
4+
uint64 public count = 1;
5+
6+
function decrement() public returns (uint64) {
7+
print("Second call will FAIL!");
8+
count -= 1;
9+
return count;
10+
}
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// SPDX-License-Identifier: Apache-2.0
2+
3+
contract storage_types {
4+
5+
uint64 public temporary var = 1;
6+
uint64 public instance var1 = 1;
7+
uint64 public persistent var2 = 2;
8+
uint64 public var3 = 2;
9+
10+
function inc() public {
11+
var++;
12+
var1++;
13+
var2++;
14+
var3++;
15+
}
16+
17+
function dec() public {
18+
var--;
19+
var1--;
20+
var2--;
21+
var3--;
22+
}
23+
}

0 commit comments

Comments
 (0)