Communicating with Portal
Learn more about Portal here, if you want:
This is good for us, because we can add any functionality without minding the backward compatibility. It is good for the users because no one can touch their instance of the contract storage.
However, this means, sadly, things are not that direct...
Learn more about it here, if you want:
We have already learned a bit about IDs while initiating our Operator.
There are many TYPEs that are supported by Portal. Modules like Withdrawal Contract, Liquidity Pools, Interfaces...
However, as Node Operators, we are only interested in two of them: Operator and Pool.
const OPERATOR = {
"CONTROLLER": <address>,
"NAME": <bytes>,
"TYPE": 4 <uint>,
"initiated": <uint>,
"maintainer": <address>,
"totalProposedValidators": <uint>,
"totalActiveValidators": <uint>,
"feeSwitch": <uint>,
"priorFee": <uint>,
"fee": <uint>,
"periodSwitch": <uint>,
"priorPeriod": <uint>,
"validatorPeriod": <uint>,
"wallet": <uint>,
"released": <uint>
};
const POOL= {
"CONTROLLER": <address>,
"NAME": <bytes>,
"TYPE": 5 <uint>,
"initiated": <uint>,
"maintainer": <address>,
"surplus": <uint>,
"secured": <uint>,
"allowance": {<OPERATOR>: <uint>},
"proposedValidators": {<OPERATOR>: <uint>},
"activeValidators": {<OPERATOR>: <uint>},
"interfaces": [<address>],
"private": <uint>, // 1 = true
"whitelist": <address>,
"withdrawalCredential": <bytes>,
"withdrawalContract": <address>,
"liquidityPool": <address>,
"liquidityPoolVersion": <uint>,
"feeSwitch": <uint>,
"priorFee": <uint>,
"fee": <uint>,
"wallet": <uint>,
"validators": [<bytes>]
};
surplus, allowance and withdrawalContract are super important for us!
const getBytes32 = (key) => {
return ethers.utils.formatBytes32String(key);
};
const getBytes = (key) => {
return Web3.utils.toHex(key);
};
await PORTAL.readUintForId(
id,
getBytes32("surplus")
);
await PORTAL.readAddressForId(
id,
getBytes32("CONTROLLER")
);
await PORTAL.readBytesForId(
id,
getBytes32("withdrawalCredential")
);
await PORTAL.readUintArrayForId(
id,
getBytes32("something"),
index
);
await PORTAL.readBytesArrayForId(
id,
getBytes32("interfaces"),
index
);
await PORTAL.readAddressArrayForId(
id,
getBytes32("validators"),
index
);
await PORTAL.readUintForId(
poolId,
await PORTAL.getKey(operatorId, getBytes32("allowance"))
);
await PORTAL.readAddressForId(
poolId,
await PORTAL.getKey(operatorId, getBytes32("something"))
);
await PORTAL.readBytesForId(
poolId,
await PORTAL.getKey(operatorId, getBytes32("something"))
);
Last modified 6mo ago