GSMA-CPAS / BWRP-UI

Apache License 2.0
1 stars 0 forks source link

contract header payload compatibility with WebApp #53

Closed zkong-gsma closed 3 years ago

zkong-gsma commented 3 years ago

the request for

https://github.com/GSMA-CPAS/BWRP/wiki/Document-Structure

https://github.com/GSMA-CPAS/BWRP-common-adapter/issues/26

is mostly done.

While extending support for webapp's

/src/store/modules/document.js

this was "designed" to take Object from your "LocalStorageAdapter" which contains structure of

          await this.database.query(
              'CREATE TABLE IF NOT EXISTS documents (' +
              '`id` INT AUTO_INCREMENT, ' +
              '`documentId` VARCHAR(128) NOT NULL, ' +
              '`fromMSP` VARCHAR(64) NOT NULL, ' +
              '`toMSP` VARCHAR(64) NOT NULL, ' +
              '`data` json NOT NULL, ' +
              '`state` VARCHAR(64) NOT NULL, ' +
              '`ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, ' +
              '`fromStorageKey` VARCHAR(64) AS (SHA2(CONCAT(fromMSP, documentId), 256)) STORED NOT NULL, ' +
              '`toStorageKey` VARCHAR(64) AS (SHA2(CONCAT(toMSP, documentId), 256)) STORED NOT NULL, ' +
              'PRIMARY KEY (id), ' +
              'UNIQUE INDEX documentId (documentId))');

so, before we modified common-adapter to the new "msps"

the return structure fitted exactly with your "LocalStorageAdapter" response.

hence making it work (switching over from Local -> commonAdapter) was easy.

You have now proposed to change it to "msps".

to make it compatible, either someone needs to re-write "/src/store/modules/document.js"

or the common Service will need to convert header.msps back to "header.fromMsp, header.toMsp" again. which was what its originally doing.

So, back to the question. Why are we doing this?

sschulz-t commented 3 years ago

I think this implementation happened way before we discussed and then decided on the actual structure :)

zkong-gsma commented 3 years ago

so, are we going to change webapp? and who is going to change?

zkong-gsma commented 3 years ago

the "about" to go live version of common-adapter is now giving.

curl -X GET "http://tmus.poc.com.local:3040/api/v1/contracts/" -H  "accept: application/json"
[
  {
    "contractId": "6012b0678d3cc1001d7b5ebd0d2f",
    "header": {
      "type": "contract",
      "version": "1.0",
      "msps": {
        "DTAG": {
          "signatures": []
        },
        "TMUS": {
          "signatures": []
        }
      }
    },
    "body": {
      "metadata": {
        "name": "test",
        "authors": null
      },
      "framework": {
        "term": {
          "start": "2021-01-01T00:00:00.000Z",
          "end": "2021-02-28T00:00:00.000Z"
        },
        "partyInformation": {
          "DTAG": {
            "contractCurrency": "EUR",
            "defaultTadigCodes": [
              "aaa"
            ]
          },
          "TMUS": {
            "contractCurrency": "EUR",
            "defaultTadigCodes": [
              "bbb"
            ]
          }
        }
      }
    },
    "state": "RECEIVED",
    "referenceId": "86124b3e39a16aa8a5e505cfd06528fd620ab48069806f1bee508457b0f4e670",
    "creationDate": "2021-01-28T12:39:03.206Z",
    "lastModificationDate": "2021-01-28T12:39:03.206Z"
  },
  {
    "contractId": "6012b00b8d3cc1001d7b5ebb4101",
    "header": {
      "type": "contract",
      "version": "1.0",
      "msps": {
        "DTAG": {
          "signatures": []
        },
        "TMUS": {
          "signatures": []
        }
      }
    },
    "body": {
      "metadata": {
        "name": "test",
        "authors": null
      },
      "framework": {
        "term": {
          "start": "2021-01-01T00:00:00.000Z",
          "end": "2021-02-28T00:00:00.000Z"
        },
        "partyInformation": {
          "DTAG": {
            "contractCurrency": "EUR",
            "defaultTadigCodes": [
              "aaa"
            ]
          },
          "TMUS": {
            "contractCurrency": "EUR",
            "defaultTadigCodes": [
              "bbb"
            ]
          }
        }
      }
    },
    "state": "RECEIVED",
    "referenceId": "0308abe195bd999cb4b82be613e72a118949a079ec12c185a858a95cb6294af4",
    "creationDate": "2021-01-28T12:37:31.476Z",
    "lastModificationDate": "2021-01-28T12:37:31.476Z"
  }
]

and

curl -X GET "http://tmus.poc.com.local:3040/api/v1/contracts/6012b0678d3cc1001d7b5ebd0d2f" -H  "accept: application/json"
{
  "contractId": "6012b0678d3cc1001d7b5ebd0d2f",
  "header": {
    "type": "contract",
    "version": "1.0",
    "msps": {
      "DTAG": {
        "signatures": [],
        "minSignatures": 1
      },
      "TMUS": {
        "signatures": [],
        "minSignatures": 1
      }
    }
  },
  "body": {
    "metadata": {
      "name": "test",
      "authors": null
    },
    "framework": {
      "term": {
        "start": "2021-01-01T00:00:00.000Z",
        "end": "2021-02-28T00:00:00.000Z"
      },
      "partyInformation": {
        "DTAG": {
          "contractCurrency": "EUR",
          "defaultTadigCodes": [
            "aaa"
          ]
        },
        "TMUS": {
          "contractCurrency": "EUR",
          "defaultTadigCodes": [
            "bbb"
          ]
        }
      }
    }
  },
  "state": "RECEIVED",
  "referenceId": "86124b3e39a16aa8a5e505cfd06528fd620ab48069806f1bee508457b0f4e670",
  "creationDate": "2021-01-28T12:39:03.206Z",
  "lastModificationDate": "2021-01-28T12:39:03.206Z"
}

as per-requested.

its breaking "webapp" currently when click to view in details.

sgerhardt-trilobyte commented 3 years ago

@tantonovics can you please check and do the change ... thanks! @zkong-gsma fyi BlockchainAdapter and LocalStorageAdapter deactivated now. UI only use common-adapter

sgerhardt-trilobyte commented 3 years ago

@zkong-gsma changes to /api/v1/contracts/ looks good. thanks! we will fix the ui part

zkong-gsma commented 3 years ago

i will update by COB with a "branch" in "development-setup" that has working

common-adapter->blockchain-adapter-chaincode. (as there are dependencies)

as the "ui", it will also be a copy where i have extended the "CommonService" to include all other "Usages" and "settlement" functions.

I will leave the "contract" part as-is, which already contains alot of "post" processing. Kindly take this advantage to remove them as well.

Is this plan ok?

zkong-gsma commented 3 years ago

Sorry for abit late.

Here is what its availabe.

a "Development setup" branch https://github.com/GSMA-CPAS/BWRP-development-setup.git -b common-adapter-update-test

this includes "ui" https://github.com/GSMA-CPAS/BWRP-UI.git -b common-adapter-updates which as

"common-adapter" https://github.com/GSMA-CPAS/BWRP-common-adapter.git -b master which is also tagged as "v0.2". this version includes all the latest Updates and features requested.

"blockchain-adapter" https://github.com/GSMA-CPAS/BWRP-blockchain-adapter.git -b master updated to branch master to have support for "documentId->referenceId" rename.

"chaincode" https://github.com/GSMA-CPAS/BWRP-chaincode.git -b master updated to branch master to have support for "documentId->referenceId" rename.