Skip to content

Commit

Permalink
Merge pull request #332 from alephium/ralph-struct
Browse files Browse the repository at this point in the history
Support struct in Ralph
  • Loading branch information
polarker authored Mar 8, 2024
2 parents 1587a3d + 0017ee7 commit 2d67294
Show file tree
Hide file tree
Showing 68 changed files with 1,076 additions and 378 deletions.
33 changes: 32 additions & 1 deletion .project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fullNodeVersion": "v2.9.0",
"fullNodeVersion": "v2.10.0",
"compilerOptionsUsed": {
"ignoreUnusedConstantsWarnings": false,
"ignoreUnusedVariablesWarnings": false,
Expand Down Expand Up @@ -28,6 +28,13 @@
"Found unused constants in Assert: A, Addresses.A, Addresses.B, B, ByteVecs.A, ByteVecs.B, C, Numbers.A, Numbers.B"
]
},
"Balances": {
"sourceFile": "test/struct.ral",
"sourceCodeHash": "7690ad7d8b8c4b952fc6f439eb75648164532e055e6a47881882097c0600bb6a",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"Debug": {
"sourceFile": "test/debug.ral",
"sourceCodeHash": "0d7cdfad264cf2009dd8907b716ba0d79cc4cf722b35773129645c5415bcb4dc",
Expand Down Expand Up @@ -234,13 +241,37 @@
"codeHashDebug": "",
"warnings": []
},
"TokenBalance": {
"sourceFile": "test/struct.ral",
"sourceCodeHash": "7690ad7d8b8c4b952fc6f439eb75648164532e055e6a47881882097c0600bb6a",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"TokenTest": {
"sourceFile": "token/token_test.ral",
"sourceCodeHash": "c1e103565399f5caa255ce48c8b441001c928754cea5722467521446d36ca3f4",
"bytecodeDebugPatch": "",
"codeHashDebug": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd",
"warnings": []
},
"UpdateUserAccount": {
"sourceFile": "test/struct.ral",
"sourceCodeHash": "7690ad7d8b8c4b952fc6f439eb75648164532e055e6a47881882097c0600bb6a",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"UserAccount": {
"sourceFile": "test/struct.ral",
"sourceCodeHash": "7690ad7d8b8c4b952fc6f439eb75648164532e055e6a47881882097c0600bb6a",
"bytecodeDebugPatch": "",
"codeHashDebug": "be41c84b7e99a544bd39df7eb24bc8c221f4ac66b7c0d774dfe96b92745167cc",
"warnings": [
"Function \"UserAccount.updateBalance\" updates fields. Please use \"@using(updateFields = true)\" for the function.",
"Function \"UserAccount.updateAddress\" updates fields. Please use \"@using(updateFields = true)\" for the function."
]
},
"Warnings": {
"sourceFile": "test/warnings.ral",
"sourceCodeHash": "974d69b74d3b88e9c5c23e8c8674d78dcd2e9b261fcae7be5adafddb777a3d01",
Expand Down
4 changes: 2 additions & 2 deletions artifacts/add/Add.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Add",
"bytecode": "02040d4036405740600100020402041600160100010200000202021605160016015f06160016015fa00016002a16012aa100a000160016010e0dce0001000201030404000b160313c40de0b6b3a7640000a2160116021401001600130164c1180102010100021600b0",
"codeHash": "2b9e382c20b4facf21eb745a46a72447dae221c274518e19c60b5ddfe478cc9c",
Expand All @@ -9,7 +9,7 @@
"result"
],
"types": [
"ByteVec",
"Sub",
"U256"
],
"isMutable": [
Expand Down
4 changes: 2 additions & 2 deletions artifacts/add/DestroyAdd.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DestroyAdd",
"bytecodeTemplate": "01010300000005{1}0d0c{0}0103",
"fieldsSig": {
Expand All @@ -8,7 +8,7 @@
"caller"
],
"types": [
"ByteVec",
"Add",
"Address"
],
"isMutable": [
Expand Down
2 changes: 1 addition & 1 deletion artifacts/add/Main.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Main",
"bytecodeTemplate": "0101030001000a{0}17000e0d0e0e160001001818",
"fieldsSig": {
Expand Down
2 changes: 1 addition & 1 deletion artifacts/greeter/Greeter.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Greeter",
"bytecode": "19010c010000000105030c7bce0002",
"codeHash": "3813cf61a6e0f126463190119cd861a14ca9c2f92839e193c4f9934517b02477",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/greeter/GreeterMain.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "GreeterMain",
"bytecodeTemplate": "01010300020014{0}17000c0d160001000d2f0c7b{0}17010c0d160101000d2f0c7b",
"fieldsSig": {
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest1.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest1",
"bytecode": "020109010000000102ce0102",
"codeHash": "3d89da71c0a6e905dd54267f897137ec6beb9603bb787e0e4a36bfc76f7a712b",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest2.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest2",
"bytecode": "02020912010000000102ce0102010000000102ce0002",
"codeHash": "c3e8a33252664e2f79903788d8abd79ee2c6785c580fa6911a0868436c59f59e",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest3.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest3",
"bytecode": "0202090f010000000102ce0102010000000000",
"codeHash": "75181639c8575ce108d1ecb0b1b73a373a8652ffe6f5f6621d9f9eee5a0b2eb4",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest4.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest4",
"bytecode": "02020911010000000102ce01020100000001020402",
"codeHash": "d8f8650c15cc96211608a52ae7d43a15d7b28306ac13acec672c0f1ed02a0538",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest5.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest5",
"bytecode": "02020914010000000102ce0102010000000304ce000c0c02",
"codeHash": "65c9d8a07f42939e84b4ae2fdc94dbbe3545c8ddb0832df08ef69b3cab50ebe3",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest6.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest6",
"bytecode": "02020912010000000102ce01020100000002030c0d02",
"codeHash": "88822622be55e862a1759c4e0c02300da75fe9e3dbe73c8fbe0fa8714996629e",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/DeprecatedNFTTest7.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "DeprecatedNFTTest7",
"bytecode": "02020913010000000102ce0102010000000203ce000b02",
"codeHash": "33ddc42a153c6b9940924d989dcd107d7ff234ecbe9c494ece35ed06bd24450d",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/MintNFTTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "MintNFTTest",
"bytecodeTemplate": "01010300000015{2}4c0ab413c40de0b6b3a7640000a2{1}0d0d{0}0107184a09b413c40de0b6b3a7640000a2{1}0d0d{0}010418",
"fieldsSig": {
Expand Down
4 changes: 2 additions & 2 deletions artifacts/nft/NFTCollectionTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "NFTCollectionTest",
"bytecode": "04050912402d40404085010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030105011eb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402",
"codeHash": "c84f4fd5d3fdee90b3421174c85011437a10c6f440e0c261b1f69ff77bc5ab70",
Expand Down Expand Up @@ -64,7 +64,7 @@
false
],
"returnTypes": [
"ByteVec"
"INFT"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "NFTCollectionWithRoyaltyTest",
"bytecode": "06080912402d40404050405b406c40b1010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b0100020201061601ce032c1367102d0201010202000316001601a9010202020008b4ce02450d7b16001601a801030105011eb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402",
"codeHash": "1c162da87d31289c9b392bd48767386336bb1d208101a8680d92b7dc74098ce0",
Expand Down Expand Up @@ -70,7 +70,7 @@
false
],
"returnTypes": [
"ByteVec"
"INFT"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/NFTTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "NFTTest",
"bytecode": "04020914010000000102ce0202010000000203ce00ce0102",
"codeHash": "4897086210869e612d82995b765a447c5319a55a56e8a0c3c07b4d9ca81e15b1",
Expand Down
4 changes: 2 additions & 2 deletions artifacts/nft/WithdrawNFTCollectionTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "WithdrawNFTCollectionTest",
"bytecodeTemplate": "01010300000006b4{1}0e0c{0}0106",
"fieldsSig": {
Expand All @@ -8,7 +8,7 @@
"amount"
],
"types": [
"ByteVec",
"INFTCollectionWithRoyalty",
"U256"
],
"isMutable": [
Expand Down
2 changes: 1 addition & 1 deletion artifacts/nft/WrongNFTTest.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "WrongNFTTest",
"bytecode": "04020917010000000102ce0202010000000206040c7bce00ce0102",
"codeHash": "7dd2ed643a98b2a1a52a9b9e536fcdae60d961b583b8109f777d846bfdfcae8d",
Expand Down
32 changes: 32 additions & 0 deletions artifacts/structs.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"name": "TokenBalance",
"fieldNames": [
"tokenId",
"amount"
],
"fieldTypes": [
"ByteVec",
"U256"
],
"isMutable": [
false,
true
]
},
{
"name": "Balances",
"fieldNames": [
"totalAmount",
"tokens"
],
"fieldTypes": [
"U256",
"[TokenBalance;2]"
],
"isMutable": [
true,
true
]
}
]
2 changes: 1 addition & 1 deletion artifacts/sub/Sub.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Sub",
"bytecode": "01011901000202010c05160016015fa00016002a16012ba100a00002",
"codeHash": "513645f5c95a28d55a51070f3d5c51edbda05a98f46b23cad59952e2ee4846a1",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/test/Assert.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Assert",
"bytecode": "00010b0100000000050d0e2f0f7b",
"codeHash": "5bd05924fb9a23ea105df065a8c2dfa463b9ee53cc14a60320140d19dd6151ca",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/test/Debug.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "Debug",
"bytecode": "000106010000000000",
"codeHash": "928360bf58942dd1fdd8d197e0e2ef59ecddbf71a6e8fe25d2c0665274f80ce3",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/test/MetaData.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "MetaData",
"bytecode": "0003144027402e010300000005b4b413c40de0b6b3a7640000a702000200000004b213c40de0b6b3a7640000a90200000000000102",
"codeHash": "cade0de390b8e15960b263ac35aa013cb84f844bce6e3e53e6bfe2cc9166623f",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/test/OwnerOnly.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "OwnerOnly",
"bytecode": "01010c010000000005b4ce00450c7b",
"codeHash": "c21e66486f3fa9f78555b71d30ba1ffd2f5a4bf8624647b97ed3748db20e295a",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/test/TemplateArrayVar.ral.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v2.9.0",
"version": "v2.10.0",
"name": "TemplateArrayVar",
"bytecodeTemplate": "010103000e00408d{1}{2}{3}{4}1703170217011700{6}{7}{8}170617051704{0}18{5}1816030f2f16020e2f1a16010d2f1a16000c2f1a0c7b160016011708170716070c2f16080d2f1a0c7b16021603170a170916090e2f160a0f2f1a0c7b16060e2f16050d2f1a16040c2f1a0c7b0c170b160b0e314c40260c170c160c0e314c1b160b7a0e314d0e2c160c7a0e314d2a78160b0e2c160c2a2f0c7b160c0d2a170c4a21160b0d2a170b4a7fd60c170d160d0f314c11160d7a0f314d102a78160d2f0c7b160d0d2a170d4a2b",
"fieldsSig": {
Expand Down
34 changes: 34 additions & 0 deletions artifacts/test/UpdateUserAccount.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "v2.10.0",
"name": "UpdateUserAccount",
"bytecodeTemplate": "01010300040015{1}{2}{3}{4}17031702170117001600160116021603100c{0}0100{5}0d0c{0}0101",
"fieldsSig": {
"names": [
"account",
"tokens",
"address"
],
"types": [
"UserAccount",
"[TokenBalance;2]",
"Address"
],
"isMutable": [
false,
false,
false
]
},
"functions": [
{
"name": "main",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": []
}
]
}
Loading

0 comments on commit 2d67294

Please sign in to comment.