Skip to content

Commit

Permalink
Merge branch 'master' into add-more-address-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Apr 3, 2024
2 parents 4e28eb0 + 678fc13 commit 57fca34
Show file tree
Hide file tree
Showing 59 changed files with 1,570 additions and 277 deletions.
45 changes: 41 additions & 4 deletions .project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"infos": {
"Add": {
"sourceFile": "add/add.ral",
"sourceCodeHash": "f7d27ecff8f7da7afcfee957842d8629930c9980f87a1c6d17561bb1fbe6dab6",
"bytecodeDebugPatch": "=8+4=1-1=2-2+64=3-1+d=37+77e010a=1+1646450726976617465=154",
"codeHashDebug": "a49f0624ccbec8df1bf3ad7f628fb47a42cc448fe7369fc0da02071df6787b69",
"sourceCodeHash": "95b2d5b3755f9a00b616a8beaccf7b42da269ae57a25ec825c333395cd2a23bc",
"bytecodeDebugPatch": "=8+4=1-1=2-1=1+3=2-2+6c=37+77e010a=1+1646450726976617465=152",
"codeHashDebug": "6d87d293224fce4601a8e315e6a384aca46fdd1adab1402ffae8cc454b94a66e",
"warnings": [
"The return values of the function \"Add.copyCreateSubContract\" are not used. If this is intentional, consider using anonymous variables to suppress this warning.",
"No external caller check for function \"Add.createSubContract\". Please use \"checkCaller!(...)\" in the function or its callees, or disable it with \"@using(checkExternalCaller = false)\".",
Expand Down Expand Up @@ -164,15 +164,38 @@
"codeHashDebug": "",
"warnings": []
},
"InsertIntoMap": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f035aeb3d53b039a81f497a02e5d3fb6fdd38a09251c55a41c3672b31fdd4182",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"Main": {
"sourceFile": "add/add.ral",
"sourceCodeHash": "f7d27ecff8f7da7afcfee957842d8629930c9980f87a1c6d17561bb1fbe6dab6",
"sourceCodeHash": "95b2d5b3755f9a00b616a8beaccf7b42da269ae57a25ec825c333395cd2a23bc",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": [
"The return values of the function \"Add.add\" are not used. If this is intentional, consider using anonymous variables to suppress this warning."
]
},
"MapTest": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f035aeb3d53b039a81f497a02e5d3fb6fdd38a09251c55a41c3672b31fdd4182",
"bytecodeDebugPatch": "=6-1+4=3-1+a=2-2+11=3-1+3=3-1+5=12-1+b=40+7a037e0300012c00=56+7a037e0300012c00=217-1+a=114+7a047e0300012c00=46+7a047e0300012c00=136",
"codeHashDebug": "76d94621028b765345f083b3d7124c355a7fd8ca45e9253fc2661102f5533d11",
"warnings": [
"No external caller check for function \"MapTest.insert\". Please use \"checkCaller!(...)\" in the function or its callees, or disable it with \"@using(checkExternalCaller = false)\"."
]
},
"MapValue": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f035aeb3d53b039a81f497a02e5d3fb6fdd38a09251c55a41c3672b31fdd4182",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"MetaData": {
"sourceFile": "test/metadata.ral",
"sourceCodeHash": "79099ed139ae980aeb7010a648998ebeaf4ee4102cb76c40addb1a0d5dd9c684",
Expand Down Expand Up @@ -233,6 +256,13 @@
"codeHashDebug": "c21e66486f3fa9f78555b71d30ba1ffd2f5a4bf8624647b97ed3748db20e295a",
"warnings": []
},
"RemoveFromMap": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f035aeb3d53b039a81f497a02e5d3fb6fdd38a09251c55a41c3672b31fdd4182",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"Sub": {
"sourceFile": "sub/sub.ral",
"sourceCodeHash": "c8b669babea2f36bdb8f92afb17747bfb9eecb13ac17c5a02388426c91a4434e",
Expand Down Expand Up @@ -261,6 +291,13 @@
"codeHashDebug": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd",
"warnings": []
},
"UpdateMapValue": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f035aeb3d53b039a81f497a02e5d3fb6fdd38a09251c55a41c3672b31fdd4182",
"bytecodeDebugPatch": "",
"codeHashDebug": "",
"warnings": []
},
"UpdateUserAccount": {
"sourceFile": "test/struct.ral",
"sourceCodeHash": "7690ad7d8b8c4b952fc6f439eb75648164532e055e6a47881882097c0600bb6a",
Expand Down
4 changes: 2 additions & 2 deletions artifacts/add/Add.ral.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "v2.11.0",
"name": "Add",
"bytecode": "02040d4036405740600100020402041600160100010200000202021605160016015f06160016015fa00016002a16012aa100a000160016010e0dce0001000201030404000b160313c40de0b6b3a7640000a2160116021401001600130164c1180102010100021600b0",
"codeHash": "2b9e382c20b4facf21eb745a46a72447dae221c274518e19c60b5ddfe478cc9c",
"bytecode": "02040d40364056405f0100020402041600160100010200000202021605160016015f06160016015fa00016002a16012aa100a000160016010e0dce000100020103040600101300641600130164170517041603d1a21601160216041605c1180102010100021600b0",
"codeHash": "97dbb799a710b8cf8dd878e3892333657c26020014bd2f0099850a26bd39668a",
"fieldsSig": {
"names": [
"sub",
Expand Down
15 changes: 15 additions & 0 deletions artifacts/structs.ral.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
[
{
"name": "MapValue",
"fieldNames": [
"id",
"balance"
],
"fieldTypes": [
"U256",
"U256"
],
"isMutable": [
false,
true
]
},
{
"name": "TokenBalance",
"fieldNames": [
Expand Down
34 changes: 34 additions & 0 deletions artifacts/test/InsertIntoMap.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "v2.11.0",
"name": "InsertIntoMap",
"bytecodeTemplate": "01010300020010{2}{3}17011700{1}d10e2ca2{1}160016010f0c{0}0100",
"fieldsSig": {
"names": [
"mapTest",
"from",
"value"
],
"types": [
"MapTest",
"Address",
"MapValue"
],
"isMutable": [
false,
false,
false
]
},
"functions": [
{
"name": "main",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": []
}
]
}
113 changes: 113 additions & 0 deletions artifacts/test/MapTest.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"version": "v2.11.0",
"name": "MapTest",
"bytecode": "0005403c409c40f6411e41370103030300151600d1a2140a5f5f6d61705f5f305f5f160047441601b11602d202011600d1a2140a5f5f6d61705f5f315f5f16014044b11602d201010100010400402a0c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116020d2a0c0e0c140a5f5f6d61705f5f305f5f16004744cb010216020d2a0c0e0c140a5f5f6d61705f5f315f5f16014044cb0102010001040040240c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116000d0c140a5f5f6d61705f5f305f5f16004744cb010316000d0c140a5f5f6d61705f5f315f5f16014044cb01030100010202110c0d0d140a5f5f6d61705f5f305f5f16004744cb1701160101000c0d0d1601010102010001010107140a5f5f6d61705f5f305f5f16004744cbc502",
"codeHash": "9ff6f47837ee2d8f2cb22fe5cfeb05f64d42915aa8b30dbb96783f3e99c363f6",
"fieldsSig": {
"names": [],
"types": [],
"isMutable": []
},
"eventsSig": [],
"functions": [
{
"name": "insert",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [
"key",
"value"
],
"paramTypes": [
"Address",
"MapValue"
],
"paramIsMutable": [
false,
false
],
"returnTypes": []
},
{
"name": "update",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": []
},
{
"name": "remove",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": []
},
{
"name": "get",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": [
"MapValue"
]
},
{
"name": "contains",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": [
"Bool"
]
}
],
"constants": [],
"enums": [],
"mapsSig": {
"names": [
"map0",
"map1"
],
"types": [
"Map[Address,MapValue]",
"Map[U256,U256]"
]
}
}
31 changes: 31 additions & 0 deletions artifacts/test/RemoveFromMap.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "v2.11.0",
"name": "RemoveFromMap",
"bytecodeTemplate": "01010300000005{1}0d0c{0}0102",
"fieldsSig": {
"names": [
"mapTest",
"key"
],
"types": [
"MapTest",
"Address"
],
"isMutable": [
false,
false
]
},
"functions": [
{
"name": "main",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": []
}
]
}
31 changes: 31 additions & 0 deletions artifacts/test/UpdateMapValue.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "v2.11.0",
"name": "UpdateMapValue",
"bytecodeTemplate": "01010300000005{1}0d0c{0}0101",
"fieldsSig": {
"names": [
"mapTest",
"key"
],
"types": [
"MapTest",
"Address"
],
"isMutable": [
false,
false
]
},
"functions": [
{
"name": "main",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": []
}
]
}
33 changes: 22 additions & 11 deletions artifacts/ts/Add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import {
fetchContractState,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
TestContractResultWithoutMaps,
} from "@alephium/web3";
import { default as AddContractJson } from "../add/Add.ral.json";
import { getContractByCodeHash } from "./contracts";
import { Balances, TokenBalance, AllStructs } from "./types";
import { Balances, MapValue, TokenBalance, AllStructs } from "./types";

// Custom types for the contract
export namespace AddTypes {
Expand Down Expand Up @@ -73,26 +75,35 @@ class Factory extends ContractFactory<AddInstance, AddTypes.Fields> {

tests = {
add: async (
params: TestContractParams<AddTypes.Fields, { array: [bigint, bigint] }>
): Promise<TestContractResult<[bigint, bigint]>> => {
params: TestContractParamsWithoutMaps<
AddTypes.Fields,
{ array: [bigint, bigint] }
>
): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
return testMethod(this, "add", params);
},
addPrivate: async (
params: TestContractParams<AddTypes.Fields, { array: [bigint, bigint] }>
): Promise<TestContractResult<[bigint, bigint]>> => {
params: TestContractParamsWithoutMaps<
AddTypes.Fields,
{ array: [bigint, bigint] }
>
): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
return testMethod(this, "addPrivate", params);
},
createSubContract: async (
params: TestContractParams<
params: TestContractParamsWithoutMaps<
AddTypes.Fields,
{ a: bigint; path: HexString; subContractId: HexString; payer: Address }
>
): Promise<TestContractResult<null>> => {
): Promise<TestContractResultWithoutMaps<null>> => {
return testMethod(this, "createSubContract", params);
},
destroy: async (
params: TestContractParams<AddTypes.Fields, { caller: Address }>
): Promise<TestContractResult<null>> => {
params: TestContractParamsWithoutMaps<
AddTypes.Fields,
{ caller: Address }
>
): Promise<TestContractResultWithoutMaps<null>> => {
return testMethod(this, "destroy", params);
},
};
Expand All @@ -102,8 +113,8 @@ class Factory extends ContractFactory<AddInstance, AddTypes.Fields> {
export const Add = new Factory(
Contract.fromJson(
AddContractJson,
"=8+4=1-1=2-2+64=3-1+d=37+77e010a=1+1646450726976617465=154",
"a49f0624ccbec8df1bf3ad7f628fb47a42cc448fe7369fc0da02071df6787b69",
"=8+4=1-1=2-1=1+3=2-2+6c=37+77e010a=1+1646450726976617465=152",
"6d87d293224fce4601a8e315e6a384aca46fdd1adab1402ffae8cc454b94a66e",
AllStructs
)
);
Expand Down
Loading

0 comments on commit 57fca34

Please sign in to comment.