rubixchain / rubixgoplatform

GNU General Public License v3.0
8 stars 17 forks source link

Smart Contract Fixes #192

Closed Maneesha-rubix closed 1 month ago

Maneesha-rubix commented 1 month ago

This PR resolves the existing issues with smart contract management. The issues and their resolutions are mentioned below.

Issues:

  1. Missing deployer and executor signatures from block
  2. GetSmartContractToken updating token state to TokenIsGenerated, regardless the actual token state
  3. Token deployed and token executed block were storing transaction type as TokenGeneratedType

This PR is Resolving:

  1. Adding deployer and executor signatures as initiator signature with token chain key '12'
  2. Removing unwanted token state updation from the function GetSmartContractToken
  3. Token deployed and token executed block are storing transaction type as TokenDeployedType and TokenExecutedType, respectively.

Note: Please note that, depending on the transaction type, whoever is initiating a transaction is a initiator. In case of RBT transfer, sender is initiator; in case of smart contract deploy, deployer is initiator; and in case of smart contract execution, executor is initiator. Since all three kinds of initiators are independependent of each other, they are being stored with the same token chain key i.e., '12'. Samples of each of the three initiator signatures are provided below.

Sender signature in RBT TRansfer block:

"12": {
            "hash": "40d3dc5411c1e5c2bcaba83760a9af2bc87dddafec89bda03ac0bc99eda038ed",
            "sign_type": 1,
            "initiator_did": "bafybmiavzucycaxjyb5s3gc327x72zmtvuck2cuwoaq2ioh6gtxipnpt4a",
            "priv_signature": "304402200d5c28eb74b210706a1dc2f8b2e9dcc6353e2bfa62aff46e42d8a818f8b5c1a1022019591b02d36068c5ad699b679abe32a3ba25a9d10a97582a5c9fbbf93c446e6e",
            "nlss_share_signature": "72041104e545b1e5a8983ab636b61d368cea462648077ffc3e08b56dfc1bbf14"
        }

Deployer signature in smart contract deploy block:

"12": {
            "sign_type": 0,
            "initiator_did": "bafybmicyxi3fqwpgxnerlntu6ynsn7vwtf75rjxxse4pezr2jrcoxwg7qm",
            "priv_signature": "3046022100d95a5eb1a77e345f6759fb5b874eab4434be314f0398b54371b8f133b4655af4022100c5701a991d3d47fe9ab46531ddb8210092c0a2d2f85b193b7b0cc07c87eafa99",
            "nlss_share_signature": "",
            "hash": "a25fcf60d0daf91c522358740b987331e531a186226ac3c8727d2e2d64fc0d95"
        }

Executor signature in smart contract execute block:

"12": {
            "hash": "f52100f9b883a03ece23f961c894e2a6bb1874f59c133c21009effe44df76f34",
            "sign_type": 0,
            "initiator_did": "bafybmihd273wcr6qm76qzflqo2dv2antpyd6xgyvy7ywgmzkulw4o3mshq",
            "priv_signature": "304602210097b57becf69cb6b80cbfa5875fe69aacef8dbe591a261afbf7f7ce49a4f1e3c6022100b1a9e2411e978f3071f1a38a0767d1379a0672884a6333c33da57b1d15fcbbbb",
            "nlss_share_signature": ""
        }