mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 14:33:12 +00:00
Minor updates, error messages etc
This commit is contained in:
parent
e7e34956a3
commit
ffcfb95e02
@ -1,11 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Install Anvil
|
||||
if ! command -v anvil &> /dev/null; then
|
||||
./scripts/install_anvil.sh
|
||||
fi
|
||||
./scripts/install_anvil.sh
|
||||
|
||||
#Install pnpm
|
||||
if ! command -v pnpm &> /dev/null; then
|
||||
./scripts/install_pnpm.sh
|
||||
fi
|
||||
./scripts/install_pnpm.sh
|
||||
@ -89,14 +89,16 @@ suite "Onchain group manager":
|
||||
raise newException(CatchableError, "Failed to deploy test token contract")
|
||||
let TOKEN_ADDRESS = testTokenAddressRes.get()
|
||||
|
||||
let differentContractAddress =
|
||||
let differentContractAddress = (
|
||||
waitFor executeForgeContractDeployScripts(privateKey, acc, web3)
|
||||
if differentContractAddress.isErr():
|
||||
error "Failed to deploy RLN contract", error = differentContractAddress.error
|
||||
).valueOr:
|
||||
assert false, "Failed to deploy RLN contract: " & $error
|
||||
return
|
||||
|
||||
# simulating a change in the contractAddress
|
||||
let manager2 = OnchainGroupManager(
|
||||
ethClientUrls: @[EthClient],
|
||||
ethContractAddress: $differentContractAddress.get(),
|
||||
ethContractAddress: $differentContractAddress,
|
||||
rlnInstance: manager.rlnInstance,
|
||||
onFatalErrorAction: proc(errStr: string) =
|
||||
assert false, errStr
|
||||
|
||||
@ -119,7 +119,7 @@ proc sendMintCall*(
|
||||
|
||||
let amountHex = amountTokens.toHex()
|
||||
let amountWithout0x =
|
||||
if amountHex.startsWith("0x"):
|
||||
if amountHex.toLower().startsWith("0x"):
|
||||
amountHex[2 .. ^1]
|
||||
else:
|
||||
amountHex
|
||||
@ -308,7 +308,7 @@ proc approveTokenAllowanceAndVerify*(
|
||||
tokenAddress: Address,
|
||||
spender: Address,
|
||||
amountWei: UInt256,
|
||||
): Future[bool] {.async.} =
|
||||
): Future[Result[void, string]] {.async.} =
|
||||
debug "Starting approval process",
|
||||
owner = accountFrom,
|
||||
tokenAddress = tokenAddress,
|
||||
@ -328,8 +328,7 @@ proc approveTokenAllowanceAndVerify*(
|
||||
|
||||
# Check if status is present and successful
|
||||
if receipt.status.isNone or receipt.status.get != 1.Quantity:
|
||||
error "Approval transaction failed"
|
||||
return false
|
||||
return err("Approval transaction failed")
|
||||
|
||||
# Give it a moment for the state to settle
|
||||
await sleepAsync(100.milliseconds)
|
||||
@ -338,7 +337,12 @@ proc approveTokenAllowanceAndVerify*(
|
||||
let allowanceAfter = await checkAllowance(web3, tokenAddress, accountFrom, spender)
|
||||
debug "Allowance after approval", amount = allowanceAfter
|
||||
|
||||
return allowanceAfter >= amountWei
|
||||
if allowanceAfter >= amountWei:
|
||||
return ok()
|
||||
else:
|
||||
error "Allowance is insufficient after approval",
|
||||
amount = allowanceAfter, expected = amountWei
|
||||
return err("Allowance is insufficient after approval")
|
||||
|
||||
proc executeForgeContractDeployScripts*(
|
||||
pk: keys.PrivateKey, acc: Address, web3: Web3
|
||||
@ -348,12 +352,11 @@ proc executeForgeContractDeployScripts*(
|
||||
|
||||
# All RLN related tests should be run from the root directory of the project
|
||||
let submodulePath = "./vendor/waku-rlnv2-contract"
|
||||
# Default Anvil account[1] privatekey
|
||||
# let PRIVATE_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
|
||||
let PRIVATE_KEY = $pk
|
||||
|
||||
let privateKey = $pk
|
||||
let forgePath = getForgePath()
|
||||
debug "Forge path", forgePath
|
||||
debug "contract deployer account details", account = acc, pk = pk
|
||||
debug "contract deployer account details", account = acc, privateKey = privateKey
|
||||
|
||||
# Build the Foundry project
|
||||
let (forgeCleanOutput, forgeCleanExitCode) =
|
||||
@ -387,7 +390,7 @@ proc executeForgeContractDeployScripts*(
|
||||
|
||||
# Deploy LinearPriceCalculator contract
|
||||
let forgeCmdPriceCalculator =
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployPriceCalculator --private-key {PRIVATE_KEY} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployPriceCalculator --private-key {privateKey} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
let (outputDeployPriceCalculator, exitCodeDeployPriceCalculator) =
|
||||
execCmdEx(forgeCmdPriceCalculator)
|
||||
debug "Executed forge command to deploy LinearPriceCalculator contract",
|
||||
@ -405,7 +408,7 @@ proc executeForgeContractDeployScripts*(
|
||||
putEnv("PRICE_CALCULATOR_ADDRESS", priceCalculatorAddress)
|
||||
|
||||
let forgeCmdWakuRln =
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployWakuRlnV2 --private-key {PRIVATE_KEY} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployWakuRlnV2 --private-key {privateKey} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
let (outputDeployWakuRln, exitCodeDeployWakuRln) = execCmdEx(forgeCmdWakuRln)
|
||||
debug "Executed forge command to deploy WakuRlnV2 contract",
|
||||
output = outputDeployWakuRln
|
||||
@ -425,7 +428,7 @@ proc executeForgeContractDeployScripts*(
|
||||
|
||||
# Deploy Proxy contract
|
||||
let forgeCmdProxy =
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployProxy --private-key {PRIVATE_KEY} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
fmt"""cd {submodulePath} && {forgePath} script script/Deploy.s.sol --broadcast -vvvv --rpc-url http://localhost:8540 --tc DeployProxy --private-key {privateKey} && rm -rf broadcast/*/*/run-1*.json && rm -rf cache/*/*/run-1*.json"""
|
||||
let (outputDeployProxy, exitCodeDeployProxy) = execCmdEx(forgeCmdProxy)
|
||||
debug "Executed forge command to deploy proxy contract", output = outputDeployProxy
|
||||
if exitCodeDeployProxy != 0:
|
||||
|
||||
@ -39,7 +39,7 @@ proc TheWakuNetworkConf*(T: type ClusterConf): ClusterConf =
|
||||
rlnRelayDynamic: true,
|
||||
rlnRelayChainId: RelayChainId,
|
||||
rlnEpochSizeSec: 600,
|
||||
rlnRelayUserMessageLimit: 20,
|
||||
rlnRelayUserMessageLimit: 100,
|
||||
numShardsInNetwork: 8,
|
||||
discv5Discovery: true,
|
||||
discv5BootstrapNodes:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user