-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/hyperledger/solang into dec…
…larations Signed-off-by: Govardhan G D <[email protected]>
- Loading branch information
Showing
116 changed files
with
2,573 additions
and
1,103 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
anchor_anchor constant bobcat = anchor_anchor(address'z7FbDfQDfucxJz5o8jrGLgvSbdoeSqX5VrxBb5TVjHq'); | ||
interface anchor_anchor { | ||
@program_id("z7FbDfQDfucxJz5o8jrGLgvSbdoeSqX5VrxBb5TVjHq") | ||
interface bobcat { | ||
@selector([0xaf, 0xaf, 0x6d, 0x1f, 0x0d, 0x98, 0x9b, 0xed]) | ||
function pounce() view external returns(int64); | ||
} |
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,21 @@ | ||
contract Polymath { | ||
function call_math() external returns (uint) { | ||
return Math.sum(1, 2); | ||
} | ||
function call_english(address english_id) external returns (string) { | ||
return English.concatenate{program_id: english_id}("Hello", "world"); | ||
} | ||
} | ||
|
||
@program_id("5afzkvPkrshqu4onwBCsJccb1swrt4JdAjnpzK8N4BzZ") | ||
contract Math { | ||
function sum(uint a, uint b) external returns (uint) { | ||
return a + b; | ||
} | ||
} | ||
|
||
contract English { | ||
function concatenate(string a, string b) external returns (string) { | ||
return a + b; | ||
} | ||
} |
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,21 @@ | ||
@program_id("5afzkvPkrshqu4onwBCsJccb1swrt4JdAjnpzK8N4BzZ") | ||
contract hatchling { | ||
string name; | ||
address private origin; | ||
|
||
constructor(string id, address parent) { | ||
require(id != "", "name must be provided"); | ||
name = id; | ||
origin = parent; | ||
} | ||
|
||
function root() public returns (address) { | ||
return origin; | ||
} | ||
} | ||
|
||
contract adult { | ||
function test() external { | ||
hatchling.new("luna", address(this)); | ||
} | ||
} |
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 @@ | ||
contract kadowari { | ||
function nomi() public { | ||
// Contracts are not allowed as variables on Solana | ||
address a = address(this); | ||
} | ||
} |
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,10 @@ | ||
@program_id("H3AthiA2C1pcMahg17nEwqr9628gkXUnnzWJJ3iSDekL") | ||
contract kadowari { | ||
function nomi() public { | ||
this.nokogiri(102); | ||
} | ||
|
||
function nokogiri(int256 a) public { | ||
// ... | ||
} | ||
} |
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,27 @@ | ||
contract A { | ||
function test(address v) public { | ||
// the following four lines are equivalent to "uint32 res = v.foo(3,5);" | ||
|
||
// Note that the signature is only hashed and not parsed. So, ensure that the | ||
// arguments are of the correct type. | ||
bytes data = abi.encodeWithSignature( | ||
"global:foo", | ||
uint32(3), | ||
uint32(5) | ||
); | ||
|
||
(bool success, bytes rawresult) = v.call(data); | ||
|
||
assert(success == true); | ||
|
||
uint32 res = abi.decode(rawresult, (uint32)); | ||
|
||
assert(res == 8); | ||
} | ||
} | ||
|
||
contract B { | ||
function foo(uint32 a, uint32 b) pure public returns (uint32) { | ||
return a + b; | ||
} | ||
} |
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,16 @@ | ||
contract foo { | ||
function bar1(uint32 x, bool y) public returns (address, bytes32) { | ||
return (address(3), hex"01020304"); | ||
} | ||
|
||
function bar2(uint32 x, bool y) public returns (bool) { | ||
return !y; | ||
} | ||
} | ||
|
||
contract bar { | ||
function test(address f) public { | ||
(address f1, bytes32 f2) = foo.bar1{program_id: f}(102, false); | ||
bool f3 = foo.bar2{program_id: f}({x: 255, y: true}); | ||
} | ||
} |
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,24 @@ | ||
contract ft { | ||
function test(address p) public { | ||
// this.callback can be used as an external function type value | ||
paffling.set_callback{program_id: p}(this.callback); | ||
} | ||
|
||
function callback(int32 count, string foo) public { | ||
// ... | ||
} | ||
} | ||
|
||
contract paffling { | ||
// the first visibility "external" is for the function type, the second "internal" is | ||
// for the callback variables | ||
function(int32, string) external internal callback; | ||
|
||
function set_callback(function(int32, string) external c) public { | ||
callback = c; | ||
} | ||
|
||
function piffle() public { | ||
callback(1, "paffled"); | ||
} | ||
} |
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
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
Oops, something went wrong.