TradeTrust / document-creator-website

https://creator.tradetrust.io
Apache License 2.0
1 stars 15 forks source link

SchemaValidationError when submitting document - Additional Properties Not Expected #309

Closed gas-limit closed 6 months ago

gas-limit commented 1 year ago

Description

Encountering a SchemaValidationError when issuing a document using the TradeTrust framework. The validation process flags several properties that I understood to be required but are being treated as additional, unexpected properties.

To Reproduce

Below are the details of the schema and the form data being submitted, which is leading to the errors:

Schema Being Validated Against:

{
  "type": "object",
  "additionalProperties": false,
  "required": ["blNumber", "scac"],
  "properties": {
    "blNumber": {
      "title": "BL Number",
      "type": "string"
    },
    "carrierName": {
      "title": "Signed for the Carrier",
      "type": "string"
    },
    "consignee": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      }
    },
    "notifyParty": {
      "title": "Notify Party",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      }
    },
    "packages": {
      "title": "Packages",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "measurement": {
            "type": "string"
          },
          "weight": {
            "type": "string"
          }
        }
      }
    },
    "placeOfDelivery": {
      "title": "Place of Delivery",
      "type": "string"
    },
    "placeOfReceipt": {
      "title": "Place of Receipt",
      "type": "string"
    },
    "portOfDischarge": {
      "title": "Port of Discharge",
      "type": "string"
    },
    "portOfLoading": {
      "title": "Port of Loading",
      "type": "string"
    },
    "scac": {
      "title": "Standard Carrier Alpha Code (SCAC)",
      "type": "string"
    },
    "shipper": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "address": {
          "type": "object",
          "properties": {
            "country": {
              "type": "string"
            },
            "street": {
              "type": "string"
            }
          }
        }
      }
    },
    "vessel": {
      "type": "string"
    },
    "voyageNo": {
      "title": "Voyage No.",
      "type": "string"
    }
  }
}

Form Data Submitted:

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json",
    "https://schemata.openattestation.com/io/tradetrust/bill-of-lading/1.0/bill-of-lading-context.json"
  ],
  "type": [
    "VerifiableCredential",
    "OpenAttestationCredential"
  ],
  "version": "https://schema.openattestation.com/3.0/schema.json",
  "issuanceDate": "2023-11-08T01:37:51.275Z",
  "issuer": {
    "id": "joshtest",
    "name": "DEMO TOKEN REGISTRY",
    "type": "OpenAttestationIssuer"
  },
  "openAttestationMetadata": {
    "template": {
      "name": "BILL_OF_LADING",
      "type": "EMBEDDED_RENDERER",
      "url": "https://generic-templates.tradetrust.io"
    },
    "proof": {
      "method": "TOKEN_REGISTRY",
      "value": "0x6dA659B82ae955fCBE374efad6174799CA2C4ABe",
      "type": "OpenAttestationProofMethod",
      "revocation": {
        "type": "NONE"
      }
    },
    "identityProof": {
      "type": "DNS-TXT",
      "identifier": "docushield.live"
    }
  },
  "credentialSubject": {},
  "network": {
    "chain": "xdcapothem",
    "chainId": "51"
  },
  "blNumber": "011111",
  "scac": "011111",
  "voyageNo": "0111",
  "vessel": "DTG TEST",
  "shipper": {
    "address": {
      "street": "321312 DTGTEST STREET",
      "country": "USA"
    }
  },
  "consignee": {
    "name": "DTG TEST"
  },
  "notifyParty": {
    "name": "DTG TEST"
  },
  "packages": [
    {
      "description": "DTG TEST",
      "measurement": "232 inches",
      "weight": "53 kg"
    }
  ],
  "placeOfReceipt": "DTG TEST 3",
  "portOfLoading": "DTG TEST 1",
  "portOfDischarge": "DTG TEST 2",
  "placeOfDelivery": "DTG TEST 4"
}

Expected Behavior

I anticipated that the document would be successfully validated and accepted. Instead, the validation process resulted in the following error message:


This form has errors. Please fix the errors to proceed.

additionalProperty: version
additionalProperty: @context
additionalProperty: type
additionalProperty: issuanceDate
additionalProperty: openAttestationMetadata
additionalProperty: credentialSubject
additionalProperty: issuer
additionalProperty: network

Additional Context and Attempts to Resolve

Could you please assist by providing some insight into why these properties are being flagged as additional and not expected by the schema? Any guidance on resolving these schema validation errors would be greatly appreciated.

osslgtm commented 12 months ago

can i check on where you've gotten the schema from ?

the schema doesn't look like a complete schema for a TT document

gas-limit commented 12 months ago

I am creating the config.json modeled after config-v3 I have deleted all forms except for the bill of lading transferrable record Here is a config.json I've been using

{
  "network": "xdcapothem",
  "wallet": {
    "type": "ENCRYPTED_JSON",
    "encryptedJson": "{\"address\":\"08678fe03afd589bd0d123323a903d20d81c708b\",\"id\":\"67e47738-b068-4dc0-92e6-9596a44ccaaf\",\"version\":3,\"crypto\":{\"cipher\":\"aes-128-ctr\",\"cipherparams\":{\"iv\":\"6ec20112aec246ce19cae58cea674762\"},\"ciphertext\":\"a6bd0b6fa0716070e129645e5e1fb986e4f58aa886f78379f555d938927b152a\",\"kdf\":\"scrypt\",\"kdfparams\":{\"salt\":\"18d5e8aa3b9f60a9fd4b3ff1c5d5961805ca1c04952f178b2a47415878fa14bb\",\"n\":131072,\"dklen\":32,\"p\":1,\"r\":8},\"mac\":\"d2734ac0be40930ae1e304a22f683eccc895aa8026c6594f6dc975dde32ea47d\"}}"
  },
  "forms": [
    {
      "name": "Bill of Lading",
      "type": "TRANSFERABLE_RECORD",
      "defaults": {
        "version": "https://schema.openattestation.com/3.0/schema.json",
        "@context": [
          "https://www.w3.org/2018/credentials/v1",
          "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json",
          "https://schemata.openattestation.com/io/tradetrust/bill-of-lading/1.0/bill-of-lading-context.json"
        ],
        "type": [
          "VerifiableCredential",
          "OpenAttestationCredential"
        ],
        "issuanceDate": "2023-11-08T01:37:51.275Z",
        "openAttestationMetadata": {
          "template": {
            "type": "EMBEDDED_RENDERER",
            "name": "BILL_OF_LADING",
            "url": "https://generic-templates.tradetrust.io"
          },
          "proof": {
            "type": "OpenAttestationProofMethod",
            "method": "TOKEN_REGISTRY",
            "value": "0x6dA659B82ae955fCBE374efad6174799CA2C4ABe",
            "revocation": {
              "type": "NONE"
            }
          },
          "identityProof": {
            "type": "DNS-TXT",
            "identifier": "docushield.live"
          }
        },
        "credentialSubject": {},
        "issuer": {
          "id": "joshtest",
          "name": "DEMO TOKEN REGISTRY",
          "type": "OpenAttestationIssuer"
        },
        "network": {
          "chain": "xdcapothem",
          "chainId": "51"
        }
      },
      "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "blNumber",
          "scac"
        ],
        "properties": {
          "blNumber": {
            "type": "string",
            "title": "BL Number"
          },
          "scac": {
            "type": "string",
            "title": "Standard Carrier Alpha Code (SCAC)"
          },
          "carrierName": {
            "title": "Signed for the Carrier",
            "type": "string"
          },
          "shipper": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "consignee": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              }
            }
          },
          "notifyParty": {
            "title": "Notify Party",
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              }
            }
          },
          "vessel": {
            "type": "string"
          },
          "voyageNo": {
            "title": "Voyage No.",
            "type": "string"
          },
          "portOfLoading": {
            "title": "Port of Loading",
            "type": "string"
          },
          "portOfDischarge": {
            "title": "Port of Discharge",
            "type": "string"
          },
          "placeOfReceipt": {
            "title": "Place of Receipt",
            "type": "string"
          },
          "placeOfDelivery": {
            "title": "Place of Delivery",
            "type": "string"
          },
          "packages": {
            "type": "array",
            "title": "Packages",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "measurement": {
                  "type": "string"
                },
                "weight": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  ]
}
isaackps commented 12 months ago

Hi @gas-limit, I would think that the config file used contain some errors.

1) the forms[0].issuer.id should be a url, in this case u can have a dummy url. 2) the forms[0].network.chain should be "XDC".

Maybe you could try it out again to see if the changes would solve your problem. Alternatively, you could reference our config for XDC network here: https://github.com/TradeTrust/tradetrust-config/blob/master/build/xdcapothem/config-v3.json

Hope this helps, and if you have further issue please feel free to post here too.

gas-limit commented 12 months ago

Thank you for your reply. I have tried the recommendations but unfortunately I still get the same errors additionalProperty

  1. I have changed the issuerId to a url
  2. I have changed the network.chain to "XDC"

from JSON Schema Validation (JSV):

additionalProperty: version
additionalProperty: @context
additionalProperty: type
additionalProperty: issuanceDate
additionalProperty: openAttestationMetadata
additionalProperty: credentialSubject
additionalProperty: issuer
additionalProperty: network

do I need to possibly need to update a schema in the codebase to follow my config.json schema?

isaackps commented 12 months ago

Hi @gas-limit,

does your config file work with our TradeTrust creator? alternatively, can i suggest you to copy a form from one of our V3 config (https://github.com/TradeTrust/tradetrust-config/blob/master/build/xdcapothem/config-v3.json) and try it out on your copy of TT creator.

Do let us know the result. It may be other issue causing the error.

gas-limit commented 12 months ago

I am generating a JSON in a separate react app at first, which I believe to be the correct format.

Per your suggestion, I have copied the sample config.json from the posted link https://github.com/TradeTrust/tradetrust-config/blob/master/build/xdcapothem/config-v3.json

and I have changed only three things:

  1. my encrypted wallet keystring (for my wallet)
  2. my dns txt address "docushield.live"
  3. my document store contract address

unfortunately I have the same results

export const SAMPLE_CONFIG = {
    "network": "xdcapothem",
    "wallet": {
      "type": "ENCRYPTED_JSON",
      "encryptedJson": "{\"address\":\"08678fe03afd589bd0d123323a903d20d81c708b\",\"id\":\"4175c918-c22f-4ce4-90b8-e64b4b67f5cf\",\"version\":3,\"crypto\":{\"cipher\":\"aes-128-ctr\",\"cipherparams\":{\"iv\":\"7d6ea747ab33f3bfd4c80f1747c99ec5\"},\"ciphertext\":\"7b43be6299d1b963a71babc7537e235b8fc129bc632c45ce282341d49be4260c\",\"kdf\":\"scrypt\",\"kdfparams\":{\"salt\":\"2b323e5b6d7d258c734553dd6aad0d3c34ee16875b53da5c459a8c2844d0f7fb\",\"n\":131072,\"dklen\":32,\"p\":1,\"r\":8},\"mac\":\"ecdfb2aac300777ceb8e2b63ef9199d9dd209f0658e6dfaf43188fe5b9cbbc29\"}}"
    },
    "documentStorage": {
      "apiKey": "randomKey",
      "url": "https://tradetrust-functions.netlify.app/.netlify/functions/storage"
    },
    "forms": [
      {
        "name": "TradeTrust Bill of Lading v3",
        "type": "TRANSFERABLE_RECORD",
        "defaults": {
          "version": "https://schema.openattestation.com/3.0/schema.json",
          "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json",
            "https://schemata.openattestation.com/io/tradetrust/bill-of-lading/1.0/bill-of-lading-context.json"
          ],
          "type": [
            "VerifiableCredential",
            "OpenAttestationCredential"
          ],
          "issuanceDate": "2010-01-01T19:23:24Z",
          "openAttestationMetadata": {
            "template": {
              "type": "EMBEDDED_RENDERER",
              "name": "BILL_OF_LADING",
              "url": "https://generic-templates.tradetrust.io"
            },
            "proof": {
              "type": "OpenAttestationProofMethod",
              "method": "TOKEN_REGISTRY",
              "value": "0xc6c3d51b495E767D26b7023D132d538ff0a7c069",
              "revocation": {
                "type": "NONE"
              }
            },
            "identityProof": {
              "type": "DNS-TXT",
              "identifier": "docushield.live"
            }
          },
          "credentialSubject": {},
          "issuer": {
            "id": "https://example.com",
            "name": "DEMO TOKEN REGISTRY",
            "type": "OpenAttestationIssuer"
          },
          "network": {
            "chain": "XDC",
            "chainId": "51"
          }
        },
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "blNumber",
            "scac"
          ],
          "properties": {
            "blNumber": {
              "type": "string",
              "title": "BL Number"
            },
            "scac": {
              "type": "string",
              "title": "Standard Carrier Alpha Code (SCAC)"
            },
            "carrierName": {
              "title": "Signed for the Carrier",
              "type": "string"
            },
            "shipper": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "address": {
                  "type": "object",
                  "properties": {
                    "street": {
                      "type": "string"
                    },
                    "country": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "consignee": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                }
              }
            },
            "notifyParty": {
              "title": "Notify Party",
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                }
              }
            },
            "vessel": {
              "type": "string"
            },
            "voyageNo": {
              "title": "Voyage No.",
              "type": "string"
            },
            "portOfLoading": {
              "title": "Port of Loading",
              "type": "string"
            },
            "portOfDischarge": {
              "title": "Port of Discharge",
              "type": "string"
            },
            "placeOfReceipt": {
              "title": "Place of Receipt",
              "type": "string"
            },
            "placeOfDelivery": {
              "title": "Place of Delivery",
              "type": "string"
            },
            "packages": {
              "type": "array",
              "title": "Packages",
              "items": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string"
                  },
                  "measurement": {
                    "type": "string"
                  },
                  "weight": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      {
        "name": "TradeTrust ChAFTA Certificate of Origin v3",
        "type": "VERIFIABLE_DOCUMENT",
        "defaults": {
          "version": "https://schema.openattestation.com/3.0/schema.json",
          "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "https://schemata.openattestation.com/io/tradetrust/certificate-of-origin/1.0/certificate-of-origin-context.json",
            "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json"
          ],
          "type": [
            "VerifiableCredential",
            "OpenAttestationCredential"
          ],
          "issuanceDate": "2010-01-01T19:23:24Z",
          "openAttestationMetadata": {
            "template": {
              "type": "EMBEDDED_RENDERER",
              "name": "CHAFTA_COO",
              "url": "https://generic-templates.tradetrust.io"
            },
            "proof": {
              "type": "OpenAttestationProofMethod",
              "method": "DOCUMENT_STORE",
              "value": "0x268852277C0eED5A9999B41b0FdbA0443De76475",
              "revocation": {
                "type": "NONE"
              }
            },
            "identityProof": {
              "type": "DNS-TXT",
              "identifier": "tradetrust-apothem.xdc.network"
            }
          },
          "credentialSubject": {},
          "issuer": {
            "id": "https://example.com",
            "name": "DEMO DOCUMENT STORE",
            "type": "OpenAttestationIssuer"
          },
          "network": {
            "chain": "XDC",
            "chainId": "51"
          }
        },
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "iD": {
              "type": "string",
              "title": "COO ID"
            },
            "issueDateTime": {
              "type": "string",
              "title": "Issued Date & Time"
            },
            "firstSignatoryAuthentication": {
              "title": "Signatory Authentication",
              "type": "object",
              "properties": {
                "signature": {
                  "type": "string",
                  "title": "First Signatory"
                },
                "actualDateTime": {
                  "type": "string",
                  "title": "Actual Date Time"
                }
              }
            },
            "supplyChainConsignment": {
              "type": "object",
              "properties": {
                "iD": {
                  "type": "string",
                  "title": "iD"
                },
                "information": {
                  "type": "string",
                  "title": "Consignment Information"
                },
                "exportCountry": {
                  "title": "Export country",
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "title": "Country code"
                    }
                  }
                },
                "exporter": {
                  "title": "Exporter",
                  "type": "object",
                  "properties": {
                    "iD": {
                      "title": "iD",
                      "type": "string"
                    },
                    "name": {
                      "title": "Name",
                      "type": "string"
                    },
                    "postalAddress": {
                      "title": "",
                      "type": "object",
                      "properties": {
                        "line1": {
                          "type": "string",
                          "title": "Address Line 1"
                        },
                        "line2": {
                          "type": "string",
                          "title": "Address Line 2"
                        },
                        "cityName": {
                          "type": "string",
                          "title": "City"
                        },
                        "postcode": {
                          "type": "string",
                          "title": "Postal code"
                        },
                        "countrySubDivisionName": {
                          "type": "string",
                          "title": "Country Sub Division name"
                        },
                        "countryCode": {
                          "type": "string",
                          "title": "Country code"
                        }
                      }
                    }
                  }
                },
                "importCountry": {
                  "type": "object",
                  "title": "Import country",
                  "properties": {
                    "code": {
                      "type": "string",
                      "title": "Country code"
                    }
                  }
                },
                "importer": {
                  "title": "Importer's Details (if known)",
                  "type": "object",
                  "properties": {
                    "iD": {
                      "title": "importer iD",
                      "type": "string"
                    },
                    "name": {
                      "title": "Name",
                      "type": "string"
                    },
                    "postalAddress": {
                      "title": "",
                      "type": "object",
                      "properties": {
                        "line1": {
                          "type": "string",
                          "title": "Address Line 1"
                        },
                        "line2": {
                          "type": "string",
                          "title": "Address Line 2"
                        },
                        "cityName": {
                          "type": "string",
                          "title": "City"
                        },
                        "postcode": {
                          "type": "string",
                          "title": "Postal code"
                        },
                        "countrySubDivisionName": {
                          "type": "string",
                          "title": "Country Sub Division name"
                        },
                        "countryCode": {
                          "type": "string",
                          "title": "Country code"
                        }
                      }
                    }
                  }
                },
                "includedConsignmentItems": {
                  "type": "array",
                  "title": "Included Consignment Items",
                  "items": {
                    "type": "object",
                    "properties": {
                      "iD": {
                        "type": "string",
                        "title": "iD"
                      },
                      "information": {
                        "type": "string",
                        "title": "Information"
                      },
                      "crossBorderRegulatoryProcedure": {
                        "type": "object",
                        "title": "",
                        "properties": {
                          "originCriteriaText": {
                            "type": "string",
                            "title": "Origin criteria text"
                          }
                        }
                      },
                      "manufacturer": {
                        "type": "object",
                        "title": "Manufacturer",
                        "properties": {
                          "iD": {
                            "type": "string",
                            "title": "iD"
                          },
                          "name": {
                            "type": "string",
                            "title": "Name"
                          },
                          "postalAddress": {
                            "title": "",
                            "type": "object",
                            "properties": {
                              "line1": {
                                "type": "string",
                                "title": "Address Line 1"
                              },
                              "line2": {
                                "type": "string",
                                "title": "Address Line 2"
                              },
                              "cityName": {
                                "type": "string",
                                "title": "City"
                              },
                              "postcode": {
                                "type": "string",
                                "title": "Postal code"
                              },
                              "countrySubDivisionName": {
                                "type": "string",
                                "title": "Country Sub Division name"
                              },
                              "countryCode": {
                                "type": "string",
                                "title": "Country code"
                              }
                            }
                          }
                        }
                      },
                      "tradeLineItems": {
                        "type": "array",
                        "title": "Trade line Items",
                        "items": {
                          "type": "object",
                          "properties": {
                            "sequenceNumber": {
                              "type": "integer",
                              "title": "Sequence Number"
                            },
                            "invoiceReference": {
                              "type": "object",
                              "title": "Invoice reference",
                              "properties": {
                                "iD": {
                                  "type": "string",
                                  "title": "iD"
                                },
                                "formattedIssueDateTime": {
                                  "type": "string",
                                  "title": "Formatted issue date & time"
                                },
                                "attachedBinaryFile": {
                                  "type": "object",
                                  "title": "",
                                  "properties": {
                                    "uRI": {
                                      "type": "string",
                                      "title": "Attached binary file uRI"
                                    }
                                  }
                                }
                              }
                            },
                            "tradeProduct": {
                              "type": "object",
                              "title": "Trade product",
                              "properties": {
                                "iD": {
                                  "type": "string",
                                  "title": "iD"
                                },
                                "description": {
                                  "type": "string",
                                  "title": "Description"
                                },
                                "harmonisedTariffCode": {
                                  "type": "object",
                                  "title": "",
                                  "properties": {
                                    "classCode": {
                                      "type": "string",
                                      "title": "Harmonised tariff class code"
                                    },
                                    "className": {
                                      "type": "string",
                                      "title": "Harmonised tariff class name"
                                    }
                                  }
                                },
                                "originCountry": {
                                  "type": "object",
                                  "title": "Origin country",
                                  "properties": {
                                    "code": {
                                      "type": "string",
                                      "title": "Code"
                                    }
                                  }
                                }
                              }
                            },
                            "transportPackages": {
                              "type": "array",
                              "title": "Transport packages",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "iD": {
                                    "type": "string",
                                    "title": "iD"
                                  },
                                  "grossVolume": {
                                    "type": "string",
                                    "title": "Gross volume"
                                  },
                                  "grossWeight": {
                                    "type": "string",
                                    "title": "Gross weight"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "loadingBaseportLocation": {
                  "type": "object",
                  "title": "Loading Baseport Location",
                  "properties": {
                    "iD": {
                      "type": "string",
                      "title": "iD"
                    },
                    "name": {
                      "type": "string",
                      "title": "Name"
                    }
                  }
                },
                "mainCarriageTransportMovement": {
                  "title": "Main Carraige Transport Movement",
                  "type": "object",
                  "properties": {
                    "iD": {
                      "type": "string",
                      "title": "iD"
                    },
                    "information": {
                      "type": "string",
                      "title": "Information"
                    },
                    "usedTransportMeans": {
                      "title": "",
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "title": "Used transport"
                        },
                        "iD": {
                          "type": "string",
                          "title": "Used transport iD"
                        }
                      }
                    },
                    "departureEvent": {
                      "title": "",
                      "type": "object",
                      "properties": {
                        "departureDateTime": {
                          "type": "string",
                          "title": "Departure date and time"
                        }
                      }
                    }
                  }
                },
                "unloadingBaseportLocation": {
                  "type": "object",
                  "title": "Unloading Baseport Location",
                  "properties": {
                    "iD": {
                      "type": "string",
                      "title": "iD"
                    },
                    "name": {
                      "type": "string",
                      "title": "Name"
                    }
                  }
                }
              }
            }
          }
        },
        "uiSchema": {
          "firstSignatoryAuthentication": {
            "signature": {
              "ui:widget": "file",
              "ui:options": {
                "text": "Upload Signature",
                "accept": ".png, .jpeg, .jpg"
              }
            },
            "actualDateTime": {
              "ui:widget": "datetime"
            }
          },
          "issueDateTime": {
            "ui:widget": "datetime"
          },
          "supplyChainConsignment": {
            "includedConsignmentItems": {
              "items": {
                "tradeLineItems": {
                  "items": {
                    "invoiceReference": {
                      "formattedIssueDateTime": {
                        "ui:widget": "datetime"
                      }
                    }
                  }
                }
              }
            },
            "mainCarriageTransportMovement": {
              "departureEvent": {
                "departureDateTime": {
                  "ui:widget": "datetime"
                }
              }
            }
          }
        },
        "attachments": {
          "allow": true,
          "accept": ".pdf"
        },
        "extension": "tt"
      },
      {
        "name": "TradeTrust Covering Letter v3",
        "type": "VERIFIABLE_DOCUMENT",
        "defaults": {
          "version": "https://schema.openattestation.com/3.0/schema.json",
          "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "https://schemata.openattestation.com/io/tradetrust/cover-letter/1.0/cover-letter-context.json",
            "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json"
          ],
          "type": [
            "VerifiableCredential",
            "OpenAttestationCredential"
          ],
          "issuanceDate": "2010-01-01T19:23:24Z",
          "openAttestationMetadata": {
            "template": {
              "type": "EMBEDDED_RENDERER",
              "name": "COVERING_LETTER",
              "url": "https://generic-templates.tradetrust.io"
            },
            "proof": {
              "type": "OpenAttestationProofMethod",
              "method": "DOCUMENT_STORE",
              "value": "0x268852277C0eED5A9999B41b0FdbA0443De76475",
              "revocation": {
                "type": "NONE"
              }
            },
            "identityProof": {
              "type": "DNS-TXT",
              "identifier": "tradetrust-apothem.xdc.network"
            }
          },
          "credentialSubject": {},
          "issuer": {
            "id": "https://example.com",
            "name": "DEMO DOCUMENT STORE",
            "type": "OpenAttestationIssuer"
          },
          "network": {
            "chain": "XDC",
            "chainId": "51"
          }
        },
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "logo": {
              "type": "string",
              "title": "Cover Letter Logo"
            },
            "title": {
              "type": "string",
              "title": "Document Title"
            },
            "remarks": {
              "type": "string",
              "title": "Remarks"
            },
            "backgroundColor": {
              "type": "string",
              "title": "Background Color"
            },
            "titleColor": {
              "type": "string",
              "title": "Title Color"
            },
            "remarksColor": {
              "type": "string",
              "title": "Remarks Color"
            }
          }
        },
        "attachments": {
          "allow": true
        },
        "uiSchema": {
          "logo": {
            "ui:widget": "file",
            "ui:options": {
              "text": "Upload Cover Letter Logo",
              "accept": ".png, .jpeg, .jpg"
            }
          },
          "remarks": {
            "ui:widget": "textarea"
          },
          "backgroundColor": {
            "ui:widget": "color",
            "ui:options": {
              "emptyValue": "#ffffff"
            }
          },
          "titleColor": {
            "ui:widget": "color",
            "ui:options": {
              "emptyValue": "#4e4e50"
            }
          },
          "remarksColor": {
            "ui:widget": "color",
            "ui:options": {
              "emptyValue": "#4e4e50"
            }
          }
        },
        "extension": "tt"
      },
      {
        "name": "TradeTrust Invoice v3 (DNS-DID)",
        "type": "VERIFIABLE_DOCUMENT",
        "defaults": {
          "version": "https://schema.openattestation.com/3.0/schema.json",
          "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "https://schemata.openattestation.com/io/tradetrust/Invoice/1.0/invoice-context.json",
            "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json"
          ],
          "type": [
            "VerifiableCredential",
            "OpenAttestationCredential"
          ],
          "issuanceDate": "2010-01-01T19:23:24Z",
          "openAttestationMetadata": {
            "template": {
              "type": "EMBEDDED_RENDERER",
              "name": "INVOICE",
              "url": "https://generic-templates.tradetrust.io"
            },
            "proof": {
              "type": "OpenAttestationProofMethod",
              "method": "DID",
              "value": "did:ethr:0xa11fa990109b0cb2e5c18f8653af5599b194e258",
              "revocation": {
                "type": "NONE"
              }
            },
            "identityProof": {
              "type": "DNS-DID",
              "identifier": "tradetrust-apothem.xdc.network"
            }
          },
          "credentialSubject": {},
          "issuer": {
            "id": "https://example.com",
            "name": "DEMO DNS-DID",
            "type": "OpenAttestationIssuer"
          },
          "network": {
            "chain": "XDC",
            "chainId": "51"
          }
        },
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "title": "Invoice ID"
            },
            "date": {
              "type": "string",
              "title": "Date"
            },
            "customerId": {
              "type": "string",
              "title": "Customer ID"
            },
            "terms": {
              "type": "string",
              "title": "Terms"
            },
            "billFrom": {
              "type": "object",
              "title": "Bill From",
              "properties": {
                "name": {
                  "type": "string",
                  "title": "Name"
                },
                "streetAddress": {
                  "type": "string",
                  "title": "Street Address"
                },
                "city": {
                  "type": "string",
                  "title": "City"
                },
                "postalCode": {
                  "type": "string",
                  "title": "Postal Code"
                },
                "phoneNumber": {
                  "type": "string",
                  "title": "Phone Number"
                }
              }
            },
            "billTo": {
              "type": "object",
              "title": "Bill To",
              "properties": {
                "name": {
                  "type": "string",
                  "title": "Name"
                },
                "email": {
                  "type": "string",
                  "title": "Email"
                },
                "company": {
                  "type": "object",
                  "title": "Bill To Company",
                  "properties": {
                    "name": {
                      "type": "string",
                      "title": "Name"
                    },
                    "streetAddress": {
                      "type": "string",
                      "title": "Street Address"
                    },
                    "city": {
                      "type": "string",
                      "title": "City"
                    },
                    "postalCode": {
                      "type": "string",
                      "title": "Postal Code"
                    },
                    "phoneNumber": {
                      "type": "string",
                      "title": "Phone Number"
                    }
                  }
                }
              }
            },
            "billableItems": {
              "type": "array",
              "title": "Billable Items",
              "items": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "title": "Description"
                  },
                  "quantity": {
                    "type": "string",
                    "title": "Quantity"
                  },
                  "unitPrice": {
                    "type": "string",
                    "title": "Unit Price"
                  },
                  "amount": {
                    "type": "string",
                    "title": "Amount"
                  }
                }
              }
            },
            "subtotal": {
              "type": "string",
              "title": "Subtotal"
            },
            "tax": {
              "type": "string",
              "title": "Tax (%)"
            },
            "taxTotal": {
              "type": "string",
              "title": "Tax Total"
            },
            "total": {
              "type": "string",
              "title": "Total"
            }
          }
        },
        "uiSchema": {
          "date": {
            "ui:widget": "date"
          }
        },
        "extension": "tt"
      },
      {
        "name": "TradeTrust Invoice v3",
        "type": "VERIFIABLE_DOCUMENT",
        "defaults": {
          "version": "https://schema.openattestation.com/3.0/schema.json",
          "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "https://schemata.openattestation.com/io/tradetrust/Invoice/1.0/invoice-context.json",
            "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json"
          ],
          "type": [
            "VerifiableCredential",
            "OpenAttestationCredential"
          ],
          "issuanceDate": "2010-01-01T19:23:24Z",
          "openAttestationMetadata": {
            "template": {
              "type": "EMBEDDED_RENDERER",
              "name": "INVOICE",
              "url": "https://generic-templates.tradetrust.io"
            },
            "proof": {
              "type": "OpenAttestationProofMethod",
              "method": "DOCUMENT_STORE",
              "value": "0x268852277C0eED5A9999B41b0FdbA0443De76475",
              "revocation": {
                "type": "NONE"
              }
            },
            "identityProof": {
              "type": "DNS-TXT",
              "identifier": "tradetrust-apothem.xdc.network"
            }
          },
          "credentialSubject": {},
          "issuer": {
            "id": "https://example.com",
            "name": "DEMO DOCUMENT STORE",
            "type": "OpenAttestationIssuer"
          },
          "network": {
            "chain": "XDC",
            "chainId": "51"
          }
        },
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "title": "Invoice ID"
            },
            "date": {
              "type": "string",
              "title": "Date"
            },
            "customerId": {
              "type": "string",
              "title": "Customer ID"
            },
            "terms": {
              "type": "string",
              "title": "Terms"
            },
            "billFrom": {
              "type": "object",
              "title": "Bill From",
              "properties": {
                "name": {
                  "type": "string",
                  "title": "Name"
                },
                "streetAddress": {
                  "type": "string",
                  "title": "Street Address"
                },
                "city": {
                  "type": "string",
                  "title": "City"
                },
                "postalCode": {
                  "type": "string",
                  "title": "Postal Code"
                },
                "phoneNumber": {
                  "type": "string",
                  "title": "Phone Number"
                }
              }
            },
            "billTo": {
              "type": "object",
              "title": "Bill To",
              "properties": {
                "name": {
                  "type": "string",
                  "title": "Name"
                },
                "email": {
                  "type": "string",
                  "title": "Email"
                },
                "company": {
                  "type": "object",
                  "title": "Bill To Company",
                  "properties": {
                    "name": {
                      "type": "string",
                      "title": "Name"
                    },
                    "streetAddress": {
                      "type": "string",
                      "title": "Street Address"
                    },
                    "city": {
                      "type": "string",
                      "title": "City"
                    },
                    "postalCode": {
                      "type": "string",
                      "title": "Postal Code"
                    },
                    "phoneNumber": {
                      "type": "string",
                      "title": "Phone Number"
                    }
                  }
                }
              }
            },
            "billableItems": {
              "type": "array",
              "title": "Billable Items",
              "items": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "title": "Description"
                  },
                  "quantity": {
                    "type": "string",
                    "title": "Quantity"
                  },
                  "unitPrice": {
                    "type": "string",
                    "title": "Unit Price"
                  },
                  "amount": {
                    "type": "string",
                    "title": "Amount"
                  }
                }
              }
            },
            "subtotal": {
              "type": "string",
              "title": "Subtotal"
            },
            "tax": {
              "type": "string",
              "title": "Tax (%)"
            },
            "taxTotal": {
              "type": "string",
              "title": "Tax Total"
            },
            "total": {
              "type": "string",
              "title": "Total"
            }
          }
        },
        "uiSchema": {
          "date": {
            "ui:widget": "date"
          }
        },
        "extension": "tt"
      }
    ]
  }
isaackps commented 12 months ago

ok just to be save, document store is for verifiable document and token registry is for transferable records, they are not interchangeable.

so, how about u putting the config file into our creator(https://creator.tradetrust.io/)? password will be the password for your encrypted wallet.

gas-limit commented 12 months ago

Sorry for the miscommunication. I understand that document store is for verifiable documents and token registry is for transferrable records. In this case I'm using the tradetrust token

I just tried that and I have this error:

image

here is the error log:

[
  {
    "files": "TradeTrust-Bill-of-Lading-v3-1",
    "error": {
      "reason": "resolver or addr is not configured for ENS name",
      "code": "INVALID_ARGUMENT",
      "argument": "name",
      "value": ""
    }
  }
]
isaackps commented 12 months ago

i used the config file you provided above and change only:

  1. Encrypted wallet string
  2. Token Registry Address
  3. Domain name

And I did not encounter the error you mention above. I am using creator.tradetrust.io to do the issuing.

{
  "network": "xdcapothem",
  "wallet": {
    "type": "ENCRYPTED_JSON",
    "encryptedJson": "<encrypted-wallet-string>"
  },
  "documentStorage": {
    "apiKey": "randomKey",
    "url": "https://tradetrust-functions.netlify.app/.netlify/functions/storage"
  },
  "forms": [
    {
      "name": "TradeTrust Bill of Lading v3",
      "type": "TRANSFERABLE_RECORD",
      "defaults": {
        "version": "https://schema.openattestation.com/3.0/schema.json",
        "@context": [
          "https://www.w3.org/2018/credentials/v1",
          "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json",
          "https://schemata.openattestation.com/io/tradetrust/bill-of-lading/1.0/bill-of-lading-context.json"
        ],
        "type": ["VerifiableCredential", "OpenAttestationCredential"],
        "issuanceDate": "2010-01-01T19:23:24Z",
        "openAttestationMetadata": {
          "template": {
            "type": "EMBEDDED_RENDERER",
            "name": "BILL_OF_LADING",
            "url": "https://generic-templates.tradetrust.io"
          },
          "proof": {
            "type": "OpenAttestationProofMethod",
            "method": "TOKEN_REGISTRY",
            "value": "<Token-Registry-Address>",
            "revocation": {
              "type": "NONE"
            }
          },
          "identityProof": {
            "type": "DNS-TXT",
            "identifier": "<domain>"
          }
        },
        "credentialSubject": {},
        "issuer": {
          "id": "https://example.com",
          "name": "DEMO TOKEN REGISTRY",
          "type": "OpenAttestationIssuer"
        },
        "network": {
          "chain": "XDC",
          "chainId": "51"
        }
      },
      "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": ["blNumber", "scac"],
        "properties": {
          "blNumber": {
            "type": "string",
            "title": "BL Number"
          },
          "scac": {
            "type": "string",
            "title": "Standard Carrier Alpha Code (SCAC)"
          },
          "carrierName": {
            "title": "Signed for the Carrier",
            "type": "string"
          },
          "shipper": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "consignee": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              }
            }
          },
          "notifyParty": {
            "title": "Notify Party",
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              }
            }
          },
          "vessel": {
            "type": "string"
          },
          "voyageNo": {
            "title": "Voyage No.",
            "type": "string"
          },
          "portOfLoading": {
            "title": "Port of Loading",
            "type": "string"
          },
          "portOfDischarge": {
            "title": "Port of Discharge",
            "type": "string"
          },
          "placeOfReceipt": {
            "title": "Place of Receipt",
            "type": "string"
          },
          "placeOfDelivery": {
            "title": "Place of Delivery",
            "type": "string"
          },
          "packages": {
            "type": "array",
            "title": "Packages",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "measurement": {
                  "type": "string"
                },
                "weight": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  ]
}

Maybe you could reference this config file.

gas-limit commented 11 months ago

I tried this, and still the same result. My suspicion now is that I am not encrypting the keystring to the correct format. I am using ethers.

  async function initializeWallet() {
    const wallet = new Wallet(privateKey);
    const walletJson = await wallet.encrypt(password);

    const parsedWalletJson = JSON.parse(walletJson);

    return JSON.stringify(parsedWalletJson, null, 2);
}
isaackps commented 11 months ago

if you are talking about the encrypted wallet it looks ok, as long as you have a wallet string. and from the looks of this function it is it looks like we are getting the correct.

I suspect its the raw form of document that is not conform to the schema and when doing a wrapping of the document it is throwing the error, in your copy of TT creator can you make sure that the raw document is conform to OA v3 schema. (https://github.com/Open-Attestation/open-attestation/blob/master/src/3.0/schema/schema.json)

if it still fails, alternatively, we would recommend that you use OA V2 schema.

gas-limit commented 11 months ago

@isaackps where can I check the raw form of the document? I did not change much from my clone. sorry if the question was ambiguous.

isaackps commented 11 months ago

@gas-limit in the file publish.tsx there is a function groupDocumentsIntoJobs, scroll down to the part for const transferableDocuments = await wrapDocument([rawDocument]) (line 202), that is were we do the wrapping of the raw documents. maybe you can debug from there and trace back to where the rawDocument changed. Do also note that the function wrapDocuments does auto wrapping of V3 and V2 documents in line 108 of publish.tsx, it may have failed the utils.isRawV3Document() function test that is why it may be using V2 function to wrap V3 document which is wrong.

From my understanding the error derive from the wrapDocumentsV3 or wrapDocumentsV2 function, where the document doesn't conform to the correct schema.

Also, the config file that I sent you above is working with TT creator (creator.tradetrust.io), as i have tested out, so if you can, use it as the base to debug on your clone version of creator.

Hope this helps. :)

gas-limit commented 11 months ago

Thanks, I will try this and get back

gas-limit commented 11 months ago

When using the base config.json from the previous messages, it seems the app fails to execute any code in publish.tsx, resulting in 'additional properties' errors. However, if I modify the config to set additionalProperties to true, the code in publish.tsx is reachable.

In exploring the code, I noticed it fails at the line const transferableDocuments = await wrapDocument([rawDocument], which you pointed out. Although it attempts to wrap the document as a V3, it doesn't succeed. Here's the relevant section of code for reference:

const wrapDocuments = async (rawDocuments: any[]) => {
  console.log("--- wrapDocuments() ---");
  console.log("wrapDocuments rawDocuments", rawDocuments);
  console.log("is a RawV3 " + utils.isRawV3Document(rawDocuments[0])); // returns true
  return utils.isRawV3Document(rawDocuments[0]) ?
    await wrapDocumentsV3(rawDocuments) : 
    wrapDocumentsV2(rawDocuments);
};

Switching to an OA V2 schema, however, leads to a different error, as indicated by the logs:

[
  {
    "files": "TradeTrust-Bill-of-Lading-v3-1",
    "error": {
      "reason": "resolver or addr is not configured for ENS name",
      "code": "INVALID_ARGUMENT",
      "argument": "name",
      "value": ""
    }
  }
]

This error suggests there might be an issue with the ENS name configuration or maybe even the contract. Could you please provide further guidance on how to resolve this, or suggest alternative configuration adjustments? Your assistance would be greatly appreciated in navigating these technical challenges.

isaackps commented 11 months ago

Hi,

before we proceed further, I just wants to make sure on some stuffs. 1) you are using the same version of packages in your forked version as our creator. 2) make sure that the rawDocuments contain all V3 raw documents. 3) if you are switching to V2, please make sure that the raw documents all conforms to V2 schema.

Also, from the looks of it, the issue you are encountering is a mismatch of schema, thus the error. Please double check the rawDocument again and run it through the wrapping function.

Please also note: If the config file works in our creator.tradetrust.io, it should work in your forked version, unless you have change something on the schema part.

gas-limit commented 11 months ago

Hello, I will surely check on the three things you've listed.

I was unable to make any of the templates from V2 Config nor V3 Config templates to work on creator.tradetrust.io, running into the same error each time.

image

V2 Log File:

[
  {
    "files": "TradeTrust-Bill-of-Lading-v2-(Carrier)-1",
    "error": {
      "reason": "resolver or addr is not configured for ENS name",
      "code": "INVALID_ARGUMENT",
      "argument": "name",
      "value": ""
    }
  }
]

V3 Log File:

[
  {
    "files": "TradeTrust-Bill-of-Lading-v3-1",
    "error": {
      "reason": "resolver or addr is not configured for ENS name",
      "code": "INVALID_ARGUMENT",
      "argument": "name",
      "value": ""
    }
  }
]
gas-limit commented 11 months ago
  1. you are using the same version of packages in your forked version as our creator.
  2. make sure that the rawDocuments contain all V3 raw documents.
  3. if you are switching to V2, please make sure that the raw documents all conforms to V2 schema.

Hello @isaackps ,

  1. I have recloned the document creator using the same packages I believe. a. Both package.json are identical b. When comparing both package-lock.json, The penpal-v4 package, which is version npm:penpal@4.1.1, has been moved from one location to another within the file. In my clone package-lock.json, this package was listed under dependencies of another package, but in the original tradetrust package-lock.json, it's listed as a top-level dependency. I'm not sure if that is an issue or not.
  2. I believe they are all V3 raw documents because I have just copied the example config.json from the examples from config-v3.json
  3. and in V2, I have tried config-v2.json.

It seems that the defaults field is being recognized as additional fields for both V2 and V3. For V2:

additionalProperty: $template
additionalProperty: issuers
additionalProperty: network
tradetrustimda commented 6 months ago

Closing this due to inactivity