Intu
Search
⌃K

Quick overview of how this all works

The goal of this is to help clear up potential questions
The Intu system is one that combines advanced cryptographic functionality with a smart contract that is used primarily for storage, and reference. The API calls need to be followed up with an appropriate smart contract call to store the information from the API call. You should init the INTUContract on your page, and reference INTUContract it as needed.
You should grab the users Intu dEoa after that, so the information we reference throughout these guides, like 'vaultID' is easy to do. Here is a large, but complete, function to grab all of a users vaults and transaction data, for easy usage.
const getInitialVaultInfo = async() => {
​
const alluservaults = await getUserVaults(state.signer);
​
if (uservaults.length > 0) {
for (let i = 0; i <= state.myVaults.length - 1; i++) {
const data = await getVaultInfo(alluservaults[i], state.signer);
const registered = await userIsRegistered(alluservaults[i], signerAddress, signer);
const userPrivateKey = await userEncryptedPrivateForVaults(alluservaults[i], signerAddress, signer);
const tempArray = {
vaultName: data[0],
vaultUsers: data[1],
vaultCreated: data[2][1].toNumber(),
//ethers.utils.computeAddress(data[3]),
//vaultAddress: "0x12354",
vaultAddress: data[3].length > 4 ? data[3] : "",
vaultTxThreshold: data[4][0].toNumber(),
vaultAdminThreshold: data[4][1].toNumber(),
vaultRotationThreshold: data[4][2].toNumber(),
vaultRegisteredUsers: data[5].toNumber(),
vaultEncryptionMessage: data[6],
vaultEthBalance: balanceInEth,
userRegistered: registered,
vaultId: data[2][0],
vaultStatus: data[5].toNumber() >= data[1].length ? "ready" : "registration",
txData: [],
rotateData: [],
adminChangeData: [],
vaultNfts: [],
encryptedShare: userPrivateKey,
};
const txArray = (await getVaultTransactions(vaultId, state.signer)).map((tx) => tx.toNumber());
for (let j = 0; j < txArray.length; j++) {
let txId = txArray[j];
const txInfo = await getTransactionInfo(txId, state.signer);
console.warn(txInfo);
const txdetails = ethers.utils.parseTransaction("0xe40380809470997970c51812dc3a010c7d01b50e0d17dc79c887038d7ea4c6800080018080");
let txDataRetrieved = {
chainId: txdetails.chainId,
data: txdetails.data,
gasLimit: txdetails.gasLimit ? Number(txdetails.gasLimit.toString()) : "",
gasPrice: txdetails.gasPrice ? Number(txdetails.gasPrice.toString()) : "",
maxFeePerGas: txdetails.maxFeePerGas ? Number(txdetails.maxFeePerGas.toString()) : "",
maxPriorityFeePerGas: txdetails.maxPriorityFeePerGas ? Number(txdetails.maxPriorityFeePerGas.toString()) : "",
to: txdetails.to,
type: txdetails.type,
value: ethers.utils.formatEther(txdetails.value.toString()),
transactionIndex: txArray[i],
transactionHash: txInfo[0],
userTxSubmission: txInfo[1],
txApprovedCount: Number(txInfo[2]),
txSent: txInfo[3],
vaultId: state.myVaults[i],
transactionThreshold: tempArray.vaultTxThreshold,
totalParticipants: tempArray.vaultUsers.length,
txId: txArray[j],
emptyTxData: txInfo[4],
};
tempArray.txData.push(txDataRetrieved);
}
const getAdminChangeData = await getThresholdStatusForVault(vaultId, state.signer);
if (getAdminChangeData) {
let adminNamedArray = {
newName: getAdminChangeData[0],
newThreshold: getAdminChangeData[1],
thresholdType: getAdminChangeData[2],
readyToChangeThreshold: getAdminChangeData[3][0],
readyToChangeName: getAdminChangeData[3][1],
userVotedThreshold: getAdminChangeData[4][0],
userVotedName: getAdminChangeData[4][1],
votesForThreshold: getAdminChangeData[5][0],
votesForName: getAdminChangeData[5][1],
adminThreshold: getAdminChangeData[5][2],
};
tempArray.adminChangeData.push(adminNamedArray);
}
finalVaults.push(tempArray);
}
​
// finalVaults has complete vault data for a user in an array, set it in your state.
Copyright 2023, W3 CPI, LTD