Skip to content

Instantly share code, notes, and snippets.

@S3bb1
Last active July 17, 2020 10:59
Show Gist options
  • Save S3bb1/eda94c3520b4dfd89416a1dc82c896c9 to your computer and use it in GitHub Desktop.
Save S3bb1/eda94c3520b4dfd89416a1dc82c896c9 to your computer and use it in GitHub Desktop.
evan.network digital identities presentation
{
"description": {
"author": "Evan GmbH",
"dbcpVersion": 2,
"description": "",
"i18n": {
"de": {
"description": "",
"name": "Linde Arbeitsbühne"
},
"en": {
"description": "",
"name": "Linde Aerial Platform"
}
},
"name": "lindig_aerial_platform",
"version": "0.1.0"
},
"plugins": {
"rentalCalendar": {
"description": {
"author": "Lindig",
"dbcpVersion": 2,
"description": "",
"i18n": {
"de": {
"calendar": {
"name": "Mietkalender"
},
"description": "",
"name": "Mietkalender"
},
"en": {
"calendar": {
"name": "Rental calendar"
},
"description": "",
"name": "Rental calendar"
}
},
"name": "calendar",
"version": "1.0.0"
},
"template": {
"properties": {
"calendar": {
"dataSchema": {
"items": {
"properties": {
"details": {
"additionalProperties": true,
"type": "object"
},
"from": {
"default": "",
"type": "number"
},
"orderDetails": {
"additionalProperties": true,
"type": "object"
},
"orderHistory": {
"additionalProperties": true,
"type": "object"
},
"to": {
"default": "",
"type": "number"
},
"type": {
"default": "",
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"permissions": {
"0": [
"set",
"remove"
]
},
"type": "list"
}
},
"type": "metadata"
}
},
"Metadata": {
"description": {
"author": "Lindig",
"dbcpVersion": 2,
"description": "",
"i18n": {
"de": {
"description": "",
"name": "Produktdaten"
},
"en": {
"description": "",
"name": "Product data"
}
},
"name": "metadata",
"version": "1.0.0"
},
"template": {
"properties": {
"identity": {
"dataSchema": {
"$id": "identity_schema",
"properties": {
"chassisNumber": {
"default": "",
"type": "string"
},
"machineCategory": {
"default": "",
"minLength": 1,
"type": "string"
},
"machineClass": {
"minLength": 1,
"type": "string"
},
"machineId": {
"default": "",
"minLength": 1,
"type": "string"
},
"manufacturer": {
"default": "",
"minLength": 1,
"type": "string"
},
"manufacturerModelDesignation": {
"default": "",
"minLength": 1,
"type": "string"
},
"yom": {
"default": "",
"type": "number"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"machineClass": "Arbeitsbühne",
"machineCategory": "Arbeitsbühne",
"manufacturer": "Linde",
"manufacturerModelDesignation": "GSB 4711"
}
},
"owner": {
"dataSchema": {
"$id": "owner_schema",
"properties": {
"internalAssetDesignation": {
"default": "",
"type": "string"
},
"internalModelDesignation": {
"default": "",
"type": "string"
},
"internalSystemDesignation": {
"default": "",
"type": "string"
},
"licensePlate": {
"default": "",
"type": "string"
},
"owner": {
"default": "",
"minLength": 1,
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {}
},
"characteristics": {
"dataSchema": {
"$id": "characteristics_schema",
"properties": {
"certificateOfQualification": {
"default": "",
"type": "string"
},
"color": {
"default": "",
"type": "string"
},
"licenseClass": {
"default": "",
"type": "string"
},
"profilePicture": {
"$comment": "{\"isEncryptedFile\": true}",
"maxItems": 1,
"properties": {
"additionalProperties": false,
"files": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"files"
],
"type": "object"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"profilePicture": {
"files": []
}
}
},
"documents": {
"dataSchema": {
"$id": "documents_schema",
"properties": {
"machinePictures": {
"$comment": "{\"isEncryptedFile\": true}",
"maxItems": 10,
"properties": {
"additionalProperties": false,
"files": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"files"
],
"type": "object"
},
"operaterFilm": {
"$comment": "{\"isEncryptedFile\": true}",
"maxItems": 3,
"properties": {
"additionalProperties": false,
"files": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"files"
],
"type": "object"
},
"operationManual": {
"$comment": "{\"isEncryptedFile\": true}",
"maxItems": 5,
"properties": {
"additionalProperties": false,
"files": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"files"
],
"type": "object"
},
"workingChart": {
"$comment": "{\"isEncryptedFile\": true}",
"maxItems": 3,
"properties": {
"additionalProperties": false,
"files": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"files"
],
"type": "object"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"machinePictures": {
"files": []
},
"operaterFilm": {
"files": []
},
"operationManual": {
"files": []
},
"workingChart": {
"files": []
}
}
},
"dimensions": {
"dataSchema": {
"$id": "dimensions_schema",
"properties": {
"groundClearanceCentre": {
"default": "",
"type": "number"
},
"groundClearanceCentreUnit": {
"type": "string"
},
"height": {
"default": "",
"type": "number"
},
"heightStowed": {
"default": "",
"type": "number"
},
"heightStowedUnit": {
"type": "string"
},
"heightUnit": {
"minLength": 1,
"type": "string"
},
"length": {
"default": "",
"type": "number"
},
"lengthStowed": {
"default": "",
"type": "number"
},
"lengthStowedUnit": {
"type": "string"
},
"lengthUnit": {
"minLength": 1,
"type": "string"
},
"outrigger": {
"default": "",
"type": "string"
},
"platformLength": {
"default": "",
"type": "number"
},
"platformLengthUnit": {
"type": "string"
},
"platformWidth": {
"default": "",
"type": "number"
},
"platformWidthUnit": {
"type": "string"
},
"wheelbase": {
"default": "",
"type": "number"
},
"wheelbaseUnit": {
"type": "string"
},
"width": {
"default": "",
"type": "number"
},
"widthStowed": {
"default": "",
"type": "number"
},
"widthStowedUnit": {
"type": "string"
},
"widthUnit": {
"minLength": 1,
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"groundClearanceCentreUnit": "mm",
"heightStowedUnit": "mm",
"heightUnit": "mm",
"lengthStowedUnit": "mm",
"lengthUnit": "mm",
"platformLengthUnit": "mm",
"platformWidthUnit": "mm",
"wheelbaseUnit": "mm",
"widthStowedUnit": "mm",
"widthUnit": "mm"
}
},
"performance": {
"dataSchema": {
"$id": "performance_schema",
"properties": {
"gradeability": {
"default": "",
"type": "number"
},
"gradeabilityUnit": {
"type": "string"
},
"jib": {
"default": "",
"type": "string"
},
"maximumLoadCapacity": {
"default": "",
"type": "number"
},
"maximumLoadCapacityUnit": {
"minLength": 1,
"type": "string"
},
"maximumPersonsAllowed": {
"default": "",
"type": "number"
},
"maximumReach": {
"default": "",
"type": "number"
},
"maximumReachUnit": {
"type": "string"
},
"maximumWorkingHeight": {
"default": "",
"type": "number"
},
"maximumWorkingHeightUnit": {
"minLength": 1,
"type": "string"
},
"maximumStandingPlatformHeight": {
"default": "",
"type": "number"
},
"maximumStandingPlatformHeightUnit": {
"minLength": 1,
"type": "string"
},
"movability": {
"default": "",
"type": "string"
},
"oscillatingAxle": {
"default": "",
"type": "string"
},
"platformExtension": {
"default": "",
"type": "string"
},
"rotationType": {
"default": "",
"type": "string"
},
"rotationUnit": {
"type": "string"
},
"turntableRotation": {
"default": "",
"type": "number"
},
"upAndOverHeight": {
"default": "",
"type": "number"
},
"upAndOverHeightUnit": {
"minLength": 1,
"type": "string"
},
"usability": {
"default": "",
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"gradeabilityUnit": "° (Grad), % (Prozent)",
"maximumLoadCapacityUnit": "kg",
"maximumReachUnit": "m",
"maximumWorkingHeightUnit": "m",
"maximumStandingPlatformHeightUnit": "m",
"rotationUnit": "° (Grad)",
"upAndOverHeightUnit": "m"
}
},
"drive": {
"dataSchema": {
"$id": "drive_schema",
"properties": {
"awd": {
"default": "",
"type": "string"
},
"batteryCapacity": {
"default": "",
"type": "number"
},
"batteryType": {
"default": "",
"type": "string"
},
"batteryVoltage": {
"default": "",
"type": "number"
},
"capacityUnit": {
"type": "string"
},
"driveType": {
"default": "",
"minLength": 1,
"type": "string"
},
"powerCobustionEngine": {
"default": "",
"type": "number"
},
"powerUnit": {
"type": "string"
},
"tankCapacity": {
"default": "",
"type": "number"
},
"tankCapacityUnit": {
"type": "string"
},
"voltageUnit": {
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"capacityUnit": "Ah",
"powerUnit": "kW",
"tankCapacityUnit": "l",
"voltageUnit": "V"
}
},
"weights": {
"dataSchema": {
"$id": "weights_schema",
"properties": {
"batteryWeight": {
"default": "",
"type": "number"
},
"batteryWeightUnit": {
"type": "string"
},
"groundPressure": {
"default": "",
"type": "number"
},
"groundPressureUnit": {
"type": "string"
},
"serviceWeight": {
"default": "",
"type": "number"
},
"serviceWeightUnit": {
"minLength": 1,
"type": "string"
},
"trailerLoad": {
"default": "",
"type": "number"
},
"trailerLoadUnit": {
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"batteryWeightUnit": "kg",
"groundPressureUnit": "psi / kg",
"serviceWeightUnit": "kg",
"trailerLoadUnit": "kg"
}
},
"wheels": {
"dataSchema": {
"$id": "wheels_schema",
"properties": {
"markingNonMarking": {
"default": "",
"type": "string"
},
"tireType": {
"default": "",
"minLength": 1,
"type": "string"
},
"wheelNumberFront": {
"default": "",
"type": "number"
},
"wheelNumberRear": {
"default": "",
"type": "number"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {}
},
"others": {
"dataSchema": {
"$id": "others_schema",
"properties": {
"soundLevelAtOperatorsEar": {
"default": "",
"type": "number"
},
"soundLevelUnit": {
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {
"soundLevelUnit": "dbA"
}
},
"locationData": {
"dataSchema": {
"$id": "locationData_schema",
"properties": {
"actualLocation": {
"default": "",
"type": "string"
},
"assignedLocation": {
"default": "",
"type": "string"
},
"city": {
"default": "",
"type": "string"
},
"country": {
"default": "",
"type": "string"
},
"houseNumber": {
"default": "",
"type": "string"
},
"latitude": {
"default": "",
"type": "string"
},
"longitude": {
"default": "",
"type": "string"
},
"street": {
"default": "",
"type": "string"
},
"zipCode": {
"default": "",
"type": "string"
}
},
"type": "object"
},
"permissions": {
"0": [
"set"
]
},
"type": "entry",
"value": {}
}
},
"type": "metadata"
}
},
"transportorders": {
"description": {
"author": "Lindig",
"dbcpVersion": 2,
"description": "",
"i18n": {
"de": {
"description": "",
"name": "Übergabeprozess",
"transportorders": {
"name": "Übergabeprozess"
}
},
"en": {
"description": "",
"name": "Transport Orders",
"transportorders": {
"name": "Transport Orders"
}
}
},
"name": "transportorders",
"version": "1.0.0"
},
"template": {
"properties": {
"transportorders": {
"dataSchema": {
"items": {
"default": "",
"minLength": 1,
"type": "string"
},
"type": "array"
},
"permissions": {
"0": [
"set",
"remove"
]
},
"type": "list"
}
},
"type": "metadata"
}
}
}
}
// require blockchain-core dependencies
const Web3 = require('web3');
// require blockchain-core
const { Ipfs, createDefaultRuntime, DigitalTwin, Container } = require('@evan.network/api-blockchain-core')
// ipfs configuration for evan.network testnet storage
const ipfsConfig = {host: 'ipfs.test.evan.network', port: '443', protocol: 'https'}
// web3 provider config (currently evan.network testcore)
const web3Provider = 'wss://testcore.evan.network/ws'
async function init() {
// initialize dependencies
const provider = new Web3.providers.WebsocketProvider(
web3Provider,
{ clientConfig: { keepalive: true, keepaliveInterval: 5000 } })
const web3 = new Web3(provider, { transactionConfirmationBlocks: 1 })
const dfs = new Ipfs({ dfsConfig: ipfsConfig })
// create runtime
const runtime = await createDefaultRuntime(
web3,
dfs,
{
mnemonic: 'lucky sort luxury wreck fever process venture frown curious shadow security just',
password: 'Test1234',
useIdentity: true
}
)
const runtime_other = await createDefaultRuntime(
web3,
dfs,
{
mnemonic: 'blanket vintage honey illness roof column flash number organ page monitor faculty',
password: 'Test1234',
useIdentity: true
}
)
const myForklift = await getDigitalTwin(runtime, '0xd5907875723970b0BC329A51930A5f54BA00741E')
const myForklift_other = await getDigitalTwin(runtime_other, '0xd5907875723970b0BC329A51930A5f54BA00741E')
const metadataPlugin = await getPluginContainer(myForklift, 'Metadata');
const identity = await metadataPlugin.getEntry('identity')
console.log('Loaded from account ' + runtime.activeIdentity)
console.dir(identity);
identity.machineId = 'NewId12345'
console.log('Setting machineId to ' + identity.machineId + ' from account ' + runtime_other.activeIdentity)
await metadataPlugin.setEntry('identity', identity)
const metadataPlugin_other = await getPluginContainer(myForklift_other, 'Metadata')
console.log('Loaded from account ' + runtime_other.activeIdentity)
console.dir(await metadataPlugin_other.getEntry('identity'))
process.exit()
}
async function getDigitalTwin(runtime, address){
const digitalTwin = new DigitalTwin(runtime, {
accountId: runtime.activeIdentity,
address: address
});
return digitalTwin;
}
async function getPluginContainer(digitalTwin, name) {
const plugin = await digitalTwin.getEntry(name);
return plugin.value;
}
init();
{
"name": "digital-identities-presentation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "evan.network",
"dependencies": {
"@evan.network/api-blockchain-core": "^2.19.0",
"web3": "2.0.0-alpha"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment