diff --git a/index.html b/index.html index 0b996b8..2b2cde8 100644 --- a/index.html +++ b/index.html @@ -1372,6 +1372,47 @@ `; + }, + offChainTransferCard(transferDetails) { + const { tokenAmount, transactionTrigger, tokenIdentification, contractName, senderAddress, receiverAddress, time, type } = transferDetails; + return html` +
  • + transfer +
    +
    Off-Chain transfer
    + ${tokenIdentification} +
    +
    + +
    +
    Contract name
    +

    ${contractName}

    +
    +
    +
    Sender address
    + + ${senderAddress} + +
    +
    +
    Receiver address
    + + ${receiverAddress} + +
    +
    +
    Amount
    +

    ${tokenAmount} ${tokenIdentification}

    +
    +
    +
    +
    Transfer trigger ID
    + +
    + View details +
    +
    +
  • `; } }; @@ -1408,8 +1449,12 @@ case 'contracttrigger': return render.contractTriggerCard(tx); break; + case 'offChainTransfer': + return render.offChainTransferCard(tx); + break; } }) + console.log(renderedTransactions) renderElem(document.getElementById(container), html`${renderedTransactions.length ? renderedTransactions : html`
    No transactions found
    `}`) } @@ -1608,119 +1653,135 @@ userChoice, nftHash, depositAmount, - amount, contractName, tokenIdentification, transactionTrigger, + onChain } = tx; let obj = { hash: txid, blockHeight, time }; - if (type != "smartContractPays") { - // determine token - obj["token"] = tokenIdentification; - switch (type) { - case 'transfer': - if (transferType == "token" || transferType == 'nft') { + if (onChain) { + if (type != "smartContractPays") { + // determine token + obj["token"] = tokenIdentification; + switch (type) { + case 'transfer': + if (transferType == "token" || transferType == 'nft') { + obj = Object.assign({}, obj, { + sender: senderAddress, + receiver: receiverAddress, + amount: tokenAmount, + type: transferType == "token" ? "tokentransfer" : "nfttransfer", + }); + latestTxArray.push(obj); + break; + } else if (transferType == 'smartContract') { + // smart contract transfer + obj = Object.assign({}, obj, { + sender: senderAddress, + receiver: receiverAddress, + amount: tokenAmount, + contractName, + userChoice, + type: "contracttransfer", + }); + latestTxArray.push(obj); + break; + } + case 'tokenIncorporation': + // token incorporation + // smart contract incorporation obj = Object.assign({}, obj, { - sender: senderAddress, - receiver: receiverAddress, - amount: tokenAmount, - type: transferType == "token" ? "tokentransfer" : "nfttransfer", + incAddress: senderAddress, + supply: tokenAmount, + type: "tokenincorp", }); latestTxArray.push(obj); break; - } else if (transferType == 'smartContract') { - // smart contract transfer + case 'smartContractIncorporation': + // smart contract incorporation + // todo : add checks to determine obj for different types of smart contract incorporation + switch (subtype) { + case 'tokenswap': + obj = Object.assign({}, obj, { + contractName, + incAddress: contractAddress, + contractType, + type: "contractincorp", + sellingToken: selling_token, + acceptingToken: accepting_token, + price, + }); + delete obj["token"]; + break; + default: + obj = Object.assign({}, obj, { + contractName, + incAddress: contractAddress, + contractType, + expiration: expiryTime, + participationFees: contractAmount, + availableChoices: "", + type: "contractincorp", + }); + break; + } + latestTxArray.push(obj); + break; + case 'nftIncorporation': + // nft incorporation + obj = Object.assign({}, obj, { + incAddress: senderAddress, + supply: tokenAmount, + type: "nftincorp", + nftHash + }); + latestTxArray.push(obj); + break; + case 'smartContractDeposit': + // smart contract deposit obj = Object.assign({}, obj, { - sender: senderAddress, - receiver: receiverAddress, - amount: tokenAmount, contractName, - userChoice, - type: "contracttransfer", + contractAddress, + contractType, + amount: depositAmount, + type: "contractdeposit", + sender: senderAddress, + receiver: receiverAddress, }); latestTxArray.push(obj); break; - } - case 'tokenIncorporation': - // token incorporation - // smart contract incorporation - obj = Object.assign({}, obj, { - incAddress: senderAddress, - supply: tokenAmount, - type: "tokenincorp", - }); - latestTxArray.push(obj); - break; - case 'smartContractIncorporation': - // smart contract incorporation - // todo : add checks to determine obj for different types of smart contract incorporation - switch (subtype) { - case 'tokenswap': - obj = Object.assign({}, obj, { - contractName, - incAddress: contractAddress, - contractType, - type: "contractincorp", - sellingToken: selling_token, - acceptingToken: accepting_token, - price, - }); - delete obj["token"]; - break; - default: - obj = Object.assign({}, obj, { - contractName, - incAddress: contractAddress, - contractType, - expiration: expiryTime, - participationFees: contractAmount, - availableChoices: "", - type: "contractincorp", - }); - break; - } - latestTxArray.push(obj); - break; - case 'nftIncorporation': - // nft incorporation - obj = Object.assign({}, obj, { - incAddress: senderAddress, - supply: tokenAmount, - type: "nftincorp", - nftHash - }); - latestTxArray.push(obj); - break; - case 'smartContractDeposit': - // smart contract deposit - obj = Object.assign({}, obj, { - contractName, - contractAddress, - contractType, - amount: depositAmount, - type: "contractdeposit", - sender: senderAddress, - receiver: receiverAddress, - }); - latestTxArray.push(obj); - break; + } + + } else { + // transaction is a FLO Smart Contract Committee trigger + + obj = Object.assign({}, obj, { + hash: txid, + blockHeight, + contractName, + contractAddress: receiverAddress, + winningChoice: triggerCondition, + committeeAddress: senderAddress, + type: 'contracttrigger' + }); + latestTxArray.push(obj); } - } else { - // transaction is a FLO Smart Contract Committee trigger - obj = Object.assign({}, obj, { - hash: txid, - blockHeight, + transactionTrigger, contractName, - contractAddress: receiverAddress, - winningChoice: triggerCondition, - committeeAddress: senderAddress, - type: 'contracttrigger' + contractAddress, + onChain: false, + type: 'offChainTransfer', + senderAddress, + receiverAddress, + tokenAmount, + tokenIdentification, + time }); latestTxArray.push(obj); }