diff --git a/.project.json b/.project.json index 0217ee6f4..e74c94c0d 100644 --- a/.project.json +++ b/.project.json @@ -1,5 +1,5 @@ { - "fullNodeVersion": "v2.8.0", + "fullNodeVersion": "v2.8.2", "compilerOptionsUsed": { "ignoreUnusedConstantsWarnings": false, "ignoreUnusedVariablesWarnings": false, @@ -11,9 +11,9 @@ "infos": { "Add": { "sourceFile": "add/add.ral", - "sourceCodeHash": "6c08da762c111145d8c876e36bb9f69dcbc86368a546b4c5bfe23f0f4db1975b", - "bytecodeDebugPatch": "", - "codeHashDebug": "2b9e382c20b4facf21eb745a46a72447dae221c274518e19c60b5ddfe478cc9c", + "sourceCodeHash": "f7d27ecff8f7da7afcfee957842d8629930c9980f87a1c6d17561bb1fbe6dab6", + "bytecodeDebugPatch": "=8+4=1-1=2-2+64=3-1+d=37+77e010a=1+1646450726976617465=154", + "codeHashDebug": "a49f0624ccbec8df1bf3ad7f628fb47a42cc448fe7369fc0da02071df6787b69", "warnings": [ "No external caller check for function \"Add.createSubContract\". Please use \"checkCaller!(...)\" in the function or its callees, or disable it with \"@using(checkExternalCaller = false)\".", "No external caller check for function \"Add.add\". Please use \"checkCaller!(...)\" in the function or its callees, or disable it with \"@using(checkExternalCaller = false)\"." @@ -158,7 +158,7 @@ }, "Main": { "sourceFile": "add/add.ral", - "sourceCodeHash": "6c08da762c111145d8c876e36bb9f69dcbc86368a546b4c5bfe23f0f4db1975b", + "sourceCodeHash": "f7d27ecff8f7da7afcfee957842d8629930c9980f87a1c6d17561bb1fbe6dab6", "bytecodeDebugPatch": "", "codeHashDebug": "", "warnings": [] diff --git a/artifacts/add/Add.ral.json b/artifacts/add/Add.ral.json index 8ee90c0c2..f63b5157d 100644 --- a/artifacts/add/Add.ral.json +++ b/artifacts/add/Add.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Add", "bytecode": "02040d4036405740600100020402041600160100010200000202021605160016015f06160016015fa00016002a16012aa100a000160016010e0dce0001000201030404000b160313c40de0b6b3a7640000a2160116021401001600130164c1180102010100021600b0", "codeHash": "2b9e382c20b4facf21eb745a46a72447dae221c274518e19c60b5ddfe478cc9c", diff --git a/artifacts/add/DestroyAdd.ral.json b/artifacts/add/DestroyAdd.ral.json index ecf081835..23a028c88 100644 --- a/artifacts/add/DestroyAdd.ral.json +++ b/artifacts/add/DestroyAdd.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DestroyAdd", "bytecodeTemplate": "01010300000005{1}0d0c{0}0103", "fieldsSig": { diff --git a/artifacts/add/Main.ral.json b/artifacts/add/Main.ral.json index 64c33eaf3..288a77af3 100644 --- a/artifacts/add/Main.ral.json +++ b/artifacts/add/Main.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Main", "bytecodeTemplate": "0101030001000a{0}17000e0d0e0e160001001818", "fieldsSig": { diff --git a/artifacts/greeter/Greeter.ral.json b/artifacts/greeter/Greeter.ral.json index 23d3fb4a5..f1c827f2c 100644 --- a/artifacts/greeter/Greeter.ral.json +++ b/artifacts/greeter/Greeter.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Greeter", "bytecode": "19010c010000000105030c7bce0002", "codeHash": "3813cf61a6e0f126463190119cd861a14ca9c2f92839e193c4f9934517b02477", diff --git a/artifacts/greeter/GreeterMain.ral.json b/artifacts/greeter/GreeterMain.ral.json index 4cf1a8c61..de8ce0015 100644 --- a/artifacts/greeter/GreeterMain.ral.json +++ b/artifacts/greeter/GreeterMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "GreeterMain", "bytecodeTemplate": "01010300020014{0}17000c0d160001000d2f0c7b{0}17010c0d160101000d2f0c7b", "fieldsSig": { diff --git a/artifacts/nft/DeprecatedNFTTest1.ral.json b/artifacts/nft/DeprecatedNFTTest1.ral.json index fa9defdd0..df3d3ec4b 100644 --- a/artifacts/nft/DeprecatedNFTTest1.ral.json +++ b/artifacts/nft/DeprecatedNFTTest1.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest1", "bytecode": "020109010000000102ce0102", "codeHash": "3d89da71c0a6e905dd54267f897137ec6beb9603bb787e0e4a36bfc76f7a712b", diff --git a/artifacts/nft/DeprecatedNFTTest2.ral.json b/artifacts/nft/DeprecatedNFTTest2.ral.json index c141213d1..8e523a87f 100644 --- a/artifacts/nft/DeprecatedNFTTest2.ral.json +++ b/artifacts/nft/DeprecatedNFTTest2.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest2", "bytecode": "02020912010000000102ce0102010000000102ce0002", "codeHash": "c3e8a33252664e2f79903788d8abd79ee2c6785c580fa6911a0868436c59f59e", diff --git a/artifacts/nft/DeprecatedNFTTest3.ral.json b/artifacts/nft/DeprecatedNFTTest3.ral.json index e872f9cde..223ede191 100644 --- a/artifacts/nft/DeprecatedNFTTest3.ral.json +++ b/artifacts/nft/DeprecatedNFTTest3.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest3", "bytecode": "0202090f010000000102ce0102010000000000", "codeHash": "75181639c8575ce108d1ecb0b1b73a373a8652ffe6f5f6621d9f9eee5a0b2eb4", diff --git a/artifacts/nft/DeprecatedNFTTest4.ral.json b/artifacts/nft/DeprecatedNFTTest4.ral.json index d8cd4de4b..328d33f2c 100644 --- a/artifacts/nft/DeprecatedNFTTest4.ral.json +++ b/artifacts/nft/DeprecatedNFTTest4.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest4", "bytecode": "02020911010000000102ce01020100000001020402", "codeHash": "d8f8650c15cc96211608a52ae7d43a15d7b28306ac13acec672c0f1ed02a0538", diff --git a/artifacts/nft/DeprecatedNFTTest5.ral.json b/artifacts/nft/DeprecatedNFTTest5.ral.json index ae676590a..b3f9e2b38 100644 --- a/artifacts/nft/DeprecatedNFTTest5.ral.json +++ b/artifacts/nft/DeprecatedNFTTest5.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest5", "bytecode": "02020914010000000102ce0102010000000304ce000c0c02", "codeHash": "65c9d8a07f42939e84b4ae2fdc94dbbe3545c8ddb0832df08ef69b3cab50ebe3", diff --git a/artifacts/nft/DeprecatedNFTTest6.ral.json b/artifacts/nft/DeprecatedNFTTest6.ral.json index d74509b0d..14ae9191f 100644 --- a/artifacts/nft/DeprecatedNFTTest6.ral.json +++ b/artifacts/nft/DeprecatedNFTTest6.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest6", "bytecode": "02020912010000000102ce01020100000002030c0d02", "codeHash": "88822622be55e862a1759c4e0c02300da75fe9e3dbe73c8fbe0fa8714996629e", diff --git a/artifacts/nft/DeprecatedNFTTest7.ral.json b/artifacts/nft/DeprecatedNFTTest7.ral.json index 55973483e..7f58dbcce 100644 --- a/artifacts/nft/DeprecatedNFTTest7.ral.json +++ b/artifacts/nft/DeprecatedNFTTest7.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "DeprecatedNFTTest7", "bytecode": "02020913010000000102ce0102010000000203ce000b02", "codeHash": "33ddc42a153c6b9940924d989dcd107d7ff234ecbe9c494ece35ed06bd24450d", diff --git a/artifacts/nft/MintNFTTest.ral.json b/artifacts/nft/MintNFTTest.ral.json index 9fc2042af..ef6e2c473 100644 --- a/artifacts/nft/MintNFTTest.ral.json +++ b/artifacts/nft/MintNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "MintNFTTest", "bytecodeTemplate": "01010300000015{2}4c0ab413c40de0b6b3a7640000a2{1}0d0d{0}0107184a09b413c40de0b6b3a7640000a2{1}0d0d{0}010418", "fieldsSig": { diff --git a/artifacts/nft/NFTCollectionTest.ral.json b/artifacts/nft/NFTCollectionTest.ral.json index c4d492d6d..f5aabf5ed 100644 --- a/artifacts/nft/NFTCollectionTest.ral.json +++ b/artifacts/nft/NFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "NFTCollectionTest", "bytecode": "04050912402d40404085010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030105011eb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "c84f4fd5d3fdee90b3421174c85011437a10c6f440e0c261b1f69ff77bc5ab70", diff --git a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json index a8e339650..031edb307 100644 --- a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json +++ b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "NFTCollectionWithRoyaltyTest", "bytecode": "06080912402d40404050405b406c40b1010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b0100020201061601ce032c1367102d0201010202000316001601a9010202020008b4ce02450d7b16001601a801030105011eb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "1c162da87d31289c9b392bd48767386336bb1d208101a8680d92b7dc74098ce0", diff --git a/artifacts/nft/NFTTest.ral.json b/artifacts/nft/NFTTest.ral.json index 35e0d83e1..ee7f96bcf 100644 --- a/artifacts/nft/NFTTest.ral.json +++ b/artifacts/nft/NFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "NFTTest", "bytecode": "04020914010000000102ce0202010000000203ce00ce0102", "codeHash": "4897086210869e612d82995b765a447c5319a55a56e8a0c3c07b4d9ca81e15b1", diff --git a/artifacts/nft/WithdrawNFTCollectionTest.ral.json b/artifacts/nft/WithdrawNFTCollectionTest.ral.json index c7b714d2d..48c40914f 100644 --- a/artifacts/nft/WithdrawNFTCollectionTest.ral.json +++ b/artifacts/nft/WithdrawNFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "WithdrawNFTCollectionTest", "bytecodeTemplate": "01010300000006b4{1}0e0c{0}0106", "fieldsSig": { diff --git a/artifacts/nft/WrongNFTTest.ral.json b/artifacts/nft/WrongNFTTest.ral.json index fbf5767eb..5252ae381 100644 --- a/artifacts/nft/WrongNFTTest.ral.json +++ b/artifacts/nft/WrongNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "WrongNFTTest", "bytecode": "04020917010000000102ce0202010000000206040c7bce00ce0102", "codeHash": "7dd2ed643a98b2a1a52a9b9e536fcdae60d961b583b8109f777d846bfdfcae8d", diff --git a/artifacts/sub/Sub.ral.json b/artifacts/sub/Sub.ral.json index 0ffbf6e53..b655d8372 100644 --- a/artifacts/sub/Sub.ral.json +++ b/artifacts/sub/Sub.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Sub", "bytecode": "01011901000202010c05160016015fa00016002a16012ba100a00002", "codeHash": "513645f5c95a28d55a51070f3d5c51edbda05a98f46b23cad59952e2ee4846a1", diff --git a/artifacts/test/Assert.ral.json b/artifacts/test/Assert.ral.json index 5d746772a..1f5b53432 100644 --- a/artifacts/test/Assert.ral.json +++ b/artifacts/test/Assert.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Assert", "bytecode": "00010b0100000000050d0e2f0f7b", "codeHash": "5bd05924fb9a23ea105df065a8c2dfa463b9ee53cc14a60320140d19dd6151ca", diff --git a/artifacts/test/Debug.ral.json b/artifacts/test/Debug.ral.json index 5bf568355..bc39c524b 100644 --- a/artifacts/test/Debug.ral.json +++ b/artifacts/test/Debug.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Debug", "bytecode": "000106010000000000", "codeHash": "928360bf58942dd1fdd8d197e0e2ef59ecddbf71a6e8fe25d2c0665274f80ce3", diff --git a/artifacts/test/MetaData.ral.json b/artifacts/test/MetaData.ral.json index b4593090c..0ea4dd424 100644 --- a/artifacts/test/MetaData.ral.json +++ b/artifacts/test/MetaData.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "MetaData", "bytecode": "0003144027402e010300000005b4b413c40de0b6b3a7640000a702000200000004b213c40de0b6b3a7640000a90200000000000102", "codeHash": "cade0de390b8e15960b263ac35aa013cb84f844bce6e3e53e6bfe2cc9166623f", diff --git a/artifacts/test/Warnings.ral.json b/artifacts/test/Warnings.ral.json index 87163a066..34d406629 100644 --- a/artifacts/test/Warnings.ral.json +++ b/artifacts/test/Warnings.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "Warnings", "bytecode": "02010701000202000102", "codeHash": "9a0c90d67d729a478062d6794cf7b75c27483c50f6fe2ad13c5ed8873ad1fde2", diff --git a/artifacts/token/FakeTokenTest.ral.json b/artifacts/token/FakeTokenTest.ral.json index f4bedc34d..73601a70e 100644 --- a/artifacts/token/FakeTokenTest.ral.json +++ b/artifacts/token/FakeTokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "FakeTokenTest", "bytecode": "010509121b4024402a010000000103044d18010000000103044d18010000000103044d18010000000103044d18010000000000", "codeHash": "88d74dcc19bfd075e97c90ab5f48d374f9ff982133d8257d4efc32305c5885b3", diff --git a/artifacts/token/TokenTest.ral.json b/artifacts/token/TokenTest.ral.json index 12fc2e58e..8cd1c33ed 100644 --- a/artifacts/token/TokenTest.ral.json +++ b/artifacts/token/TokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v2.8.0", + "version": "v2.8.2", "name": "TokenTest", "bytecode": "050409121b4024010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302", "codeHash": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd", diff --git a/artifacts/ts/Add.ts b/artifacts/ts/Add.ts index 3324a0366..5ef4f87c9 100644 --- a/artifacts/ts/Add.ts +++ b/artifacts/ts/Add.ts @@ -101,8 +101,8 @@ class Factory extends ContractFactory { export const Add = new Factory( Contract.fromJson( AddContractJson, - "", - "2b9e382c20b4facf21eb745a46a72447dae221c274518e19c60b5ddfe478cc9c" + "=8+4=1-1=2-2+64=3-1+d=37+77e010a=1+1646450726976617465=154", + "a49f0624ccbec8df1bf3ad7f628fb47a42cc448fe7369fc0da02071df6787b69" ) ); diff --git a/artifacts/ts/DeprecatedNFTTest.ts b/artifacts/ts/DeprecatedNFTTest.ts deleted file mode 100644 index 19e6bb4b1..000000000 --- a/artifacts/ts/DeprecatedNFTTest.ts +++ /dev/null @@ -1,125 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { - Address, - Contract, - ContractState, - TestContractResult, - HexString, - ContractFactory, - EventSubscribeOptions, - EventSubscription, - CallContractParams, - CallContractResult, - TestContractParams, - ContractEvent, - subscribeContractEvent, - subscribeContractEvents, - testMethod, - callMethod, - multicallMethods, - fetchContractState, - ContractInstance, - getContractEventsCurrentCount, -} from "@alephium/web3"; -import { default as DeprecatedNFTTestContractJson } from "../nft/DeprecatedNFTTest.ral.json"; -import { getContractByCodeHash } from "./contracts"; - -// Custom types for the contract -export namespace DeprecatedNFTTestTypes { - export type Fields = { - uri: HexString; - }; - - export type State = ContractState; - - export interface CallMethodTable { - getTokenUri: { - params: Omit, "args">; - result: CallContractResult; - }; - } - export type CallMethodParams = - CallMethodTable[T]["params"]; - export type CallMethodResult = - CallMethodTable[T]["result"]; - export type MultiCallParams = Partial<{ - [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"]; - }>; - export type MultiCallResults = { - [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable - ? CallMethodTable[MaybeName]["result"] - : undefined; - }; -} - -class Factory extends ContractFactory< - DeprecatedNFTTestInstance, - DeprecatedNFTTestTypes.Fields -> { - getInitialFieldsWithDefaultValues() { - return this.contract.getInitialFieldsWithDefaultValues() as DeprecatedNFTTestTypes.Fields; - } - - at(address: string): DeprecatedNFTTestInstance { - return new DeprecatedNFTTestInstance(address); - } - - tests = { - getTokenUri: async ( - params: Omit< - TestContractParams, - "testArgs" - > - ): Promise> => { - return testMethod(this, "getTokenUri", params); - }, - }; -} - -// Use this object to test and deploy the contract -export const DeprecatedNFTTest = new Factory( - Contract.fromJson( - DeprecatedNFTTestContractJson, - "", - "e4ac1069a1aea968d177741c290e109285ba3771c8df9c94e07d80d328a4c0c3" - ) -); - -// Use this class to interact with the blockchain -export class DeprecatedNFTTestInstance extends ContractInstance { - constructor(address: Address) { - super(address); - } - - async fetchState(): Promise { - return fetchContractState(DeprecatedNFTTest, this); - } - - methods = { - getTokenUri: async ( - params?: DeprecatedNFTTestTypes.CallMethodParams<"getTokenUri"> - ): Promise> => { - return callMethod( - DeprecatedNFTTest, - this, - "getTokenUri", - params === undefined ? {} : params, - getContractByCodeHash - ); - }, - }; - - async multicall( - calls: Calls - ): Promise> { - return (await multicallMethods( - DeprecatedNFTTest, - this, - calls, - getContractByCodeHash - )) as DeprecatedNFTTestTypes.MultiCallResults; - } -} diff --git a/contracts/add/add.ral b/contracts/add/add.ral index b35ce2f97..230be7b50 100644 --- a/contracts/add/add.ral +++ b/contracts/add/add.ral @@ -8,6 +8,7 @@ Contract Add(sub: Sub, mut result : U256) { @using(updateFields = true) fn addPrivate(array: [U256; 2]) -> ([U256; 2]) { + emit Debug(`addPrivate`) emit Add(array[0], array[1]) emit Add1(array[0], array[1]) result = result + array[0] + array[1] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 37ea240c1..c93aafc75 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -31,7 +31,7 @@ services: condition: service_healthy alephium: - image: alephium/dev-alephium:2.8.0 + image: alephium/dev-alephium:2.8.2 restart: unless-stopped ports: - 19973:19973/tcp diff --git a/packages/cli/src/deployment.ts b/packages/cli/src/deployment.ts index 98b0628fd..e2b56f32f 100644 --- a/packages/cli/src/deployment.ts +++ b/packages/cli/src/deployment.ts @@ -36,7 +36,8 @@ import { ContractInstance, ExecutableScript, ProjectArtifact, - isHexString + isHexString, + isDevnet } from '@alephium/web3' import { PrivateKeyWallet } from '@alephium/web3-wallet' import path from 'path' @@ -318,7 +319,10 @@ function createDeployer( taskTag?: string ): Promise> => { const initialFields = addStdIdToFields(contractFactory.contract, params.initialFields ?? {}) - const initFieldsAndByteCode = contractFactory.contract.buildByteCodeToDeploy(initialFields) + const initFieldsAndByteCode = contractFactory.contract.buildByteCodeToDeploy( + initialFields, + isDevnet(network.networkId) + ) const codeHash = cryptojs.SHA256(initFieldsAndByteCode).toString() const taskId = getTaskId(contractFactory.contract, taskTag) const previous = deployContractResults.get(taskId) diff --git a/packages/web3/package.json b/packages/web3/package.json index b0435ffec..91353b510 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -27,7 +27,7 @@ }, "author": "Alephium dev ", "config": { - "alephium_version": "2.8.0", + "alephium_version": "2.8.2", "explorer_backend_version": "1.16.1" }, "scripts": { diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index 512d2597c..d48045b29 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -383,6 +383,7 @@ export interface CallContractSucceeded { txInputs: string[] txOutputs: Output[] events: ContractEventByTxId[] + debugMessages: DebugMessage[] type: string } @@ -1277,7 +1278,7 @@ export class HttpClient { /** * @title Alephium API - * @version 2.8.0 + * @version 2.8.2 * @baseUrl ../ */ export class Api extends HttpClient { diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index b43452fe0..841030a92 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -55,7 +55,8 @@ import { groupOfAddress, addressFromContractId, WebCrypto, - hexToBinUnsafe + hexToBinUnsafe, + isDevnet } from '../utils' import { getCurrentNodeProvider } from '../global' import * as path from 'path' @@ -715,7 +716,7 @@ export abstract class Artifact { this.functions = functions } - abstract buildByteCodeToDeploy(initialFields?: Fields): string + abstract buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string publicFunctions(): string[] { return this.functions.filter((func) => func.isPublic).map((func) => func.name) @@ -728,6 +729,14 @@ export abstract class Artifact { usingAssetsInContractFunctions(): string[] { return this.functions.filter((func) => func.useAssetsInContract).map((func) => func.name) } + + async isDevnet(signer: SignerProvider): Promise { + if (!signer.nodeProvider) { + return false + } + const chainParams = await signer.nodeProvider.infos.getInfosChainParams() + return isDevnet(chainParams.networkId) + } } export class Contract extends Artifact { @@ -884,7 +893,7 @@ export class Contract extends Artifact { printDebugMessages(funcName: string, messages: DebugMessage[]) { if (messages.length != 0) { console.log(`Testing ${this.name}.${funcName}:`) - messages.forEach((m) => console.log(`Debug - ${m.contractAddress} - ${m.message}`)) + messages.forEach((m) => console.log(`> Contract @ ${m.contractAddress} - ${m.message}`)) } } @@ -1039,8 +1048,9 @@ export class Contract extends Artifact { signer: SignerProvider, params: DeployContractParams

): Promise { + const isDevnet = await this.isDevnet(signer) const initialFields: Fields = params.initialFields ?? {} - const bytecode = this.buildByteCodeToDeploy(addStdIdToFields(this, initialFields)) + const bytecode = this.buildByteCodeToDeploy(addStdIdToFields(this, initialFields), isDevnet) const selectedAccount = await signer.getSelectedAccount() const signerParams: SignDeployContractTxParams = { signerAddress: selectedAccount.address, @@ -1055,9 +1065,9 @@ export class Contract extends Artifact { return signerParams } - buildByteCodeToDeploy(initialFields: Fields): string { + buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string { try { - return ralph.buildContractByteCode(this.bytecode, initialFields, this.fieldsSig) + return ralph.buildContractByteCode(isDevnet ? this.bytecodeDebug : this.bytecode, initialFields, this.fieldsSig) } catch (error) { throw new Error(`Failed to build bytecode for contract ${this.name}, error: ${error}`) } @@ -1116,7 +1126,8 @@ export class Contract extends Artifact { contracts: callResult.contracts.map((state) => Contract.fromApiContractState(state, getContractByCodeHash)), txInputs: callResult.txInputs, txOutputs: callResult.txOutputs.map((output) => fromApiOutput(output)), - events: Contract.fromApiEvents(callResult.events, addressToCodeHash, txId, getContractByCodeHash) + events: Contract.fromApiEvents(callResult.events, addressToCodeHash, txId, getContractByCodeHash), + debugMessages: callResult.debugMessages } } } @@ -1503,6 +1514,7 @@ export interface CallContractResult { txInputs: string[] txOutputs: Output[] events: ContractEvent[] + debugMessages: DebugMessage[] } function specialContractAddress(n: number): string { @@ -1767,6 +1779,7 @@ export async function callMethod } diff --git a/packages/web3/src/utils/utils.ts b/packages/web3/src/utils/utils.ts index bc3104175..121c68712 100644 --- a/packages/web3/src/utils/utils.ts +++ b/packages/web3/src/utils/utils.ts @@ -265,6 +265,10 @@ export function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)) } +export function isDevnet(networkId?: number): boolean { + return networkId !== 0 && networkId !== 1 +} + type _Eq = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? true : false export type Eq = _Eq<{ [P in keyof X]: X[P] }, { [P in keyof Y]: Y[P] }> // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars diff --git a/test/contract.test.ts b/test/contract.test.ts index 544574da9..032865724 100644 --- a/test/contract.test.ts +++ b/test/contract.test.ts @@ -94,7 +94,7 @@ describe('contract', function () { expect(contract0.fields.result).toEqual(1n) const contract1 = testResult.contracts[1] as AddTypes.State - expect(contract1.codeHash).toEqual(Add.contract.codeHash) + expect(contract1.codeHash).toEqual(Add.contract.codeHashDebug) expect(contract1.fields.sub).toEqual(subState.contractId) expect(contract1.fields.result).toEqual(3n)