Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
echo "environment=dev" >> $GITHUB_OUTPUT
fi

- name: Validate contract data
run: python3 scripts/validate_contract_data.py

- name: Build distribution files
run: |
python3 scripts/build_dist.py \
Expand All @@ -76,3 +79,17 @@ jobs:
password: ${{ github.ref == 'refs/heads/main' && secrets.FTP_PASSWORD_PROD || github.ref == 'refs/heads/staging' && secrets.FTP_PASSWORD_STAGING || secrets.FTP_PASSWORD_DEV }}
local-dir: dist/
server-dir: /

- name: Trigger TypeScript contract sync
if: github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.QUBIC_TYPESCRIPT_REPO_TOKEN }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "QUBIC_TYPESCRIPT_REPO_TOKEN is not configured; skipping sync dispatch."
exit 0
fi

gh api repos/qubic/qubic-typescript/dispatches \
-f event_type=static-contract-registry-updated \
-f client_payload[static_ref]=main
3 changes: 3 additions & 0 deletions .github/workflows/refresh-smart-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Run update script
run: python3 scripts/update_smart_contracts.py

- name: Validate contract data
run: python3 scripts/validate_contract_data.py

- name: Get checksum after update
id: after
run: |
Expand Down
51 changes: 51 additions & 0 deletions data/contracts/schemas/contract_manifest.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://static.qubic.org/schemas/contract_manifest.schema.json",
"title": "Qubic contract data manifest",
"type": "object",
"required": ["schemaVersion", "generatedAt", "generator", "sources", "files"],
"additionalProperties": true,
"properties": {
"schemaVersion": { "type": "integer", "const": 1 },
"generatedAt": { "type": "string", "format": "date-time" },
"generator": {
"type": "object",
"required": ["name", "version"],
"additionalProperties": true,
"properties": {
"name": { "type": "string", "minLength": 1 },
"version": { "type": "string", "minLength": 1 },
"commit": { "type": "string" }
}
},
"sources": {
"type": "object",
"required": ["coreRepo", "latestEpoch"],
"additionalProperties": true,
"properties": {
"coreRepo": { "type": "string", "format": "uri" },
"latestEpoch": { "type": "integer", "minimum": 0 },
"latestCoreTag": { "type": "string" },
"epochRefsHash": { "$ref": "#/$defs/hash" }
}
},
"files": {
"type": "object",
"additionalProperties": {
"type": "object",
"required": ["hash", "schema"],
"additionalProperties": true,
"properties": {
"hash": { "$ref": "#/$defs/hash" },
"schema": { "type": "string", "minLength": 1 }
}
}
}
},
"$defs": {
"hash": {
"type": "string",
"pattern": "^sha256:[a-f0-9]{64}$"
}
}
}
124 changes: 124 additions & 0 deletions data/contracts/schemas/contract_registry.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://static.qubic.org/schemas/contract_registry.schema.json",
"title": "Qubic contract ABI registry",
"type": "object",
"required": ["schemaVersion", "updatedAt", "versions"],
"additionalProperties": true,
"properties": {
"schemaVersion": { "type": "integer", "const": 1 },
"updatedAt": { "type": "string", "format": "date-time" },
"versions": {
"type": "array",
"items": { "$ref": "#/$defs/contractAbiVersion" }
}
},
"$defs": {
"fieldType": {
"type": "string",
"enum": [
"uint8",
"uint16",
"uint32",
"uint64",
"sint8",
"sint16",
"sint32",
"sint64",
"uint128",
"id",
"bytes",
"array",
"struct"
]
},
"binaryField": {
"type": "object",
"required": ["name", "type", "offset", "byteLength"],
"additionalProperties": true,
"properties": {
"name": { "type": "string", "minLength": 1 },
"type": { "$ref": "#/$defs/fieldType" },
"offset": { "type": "integer", "minimum": 0 },
"byteLength": { "type": "integer", "minimum": 0 },
"description": { "type": "string" },
"arrayLength": { "type": "integer", "minimum": 0 },
"arrayItemType": { "$ref": "#/$defs/fieldType" },
"arrayItemByteLength": { "type": "integer", "minimum": 0 },
"arrayItemStructRef": { "type": "string" },
"structRef": { "type": "string" }
}
},
"namedStruct": {
"type": "object",
"required": ["name", "fields", "byteLength"],
"additionalProperties": true,
"properties": {
"name": { "type": "string", "minLength": 1 },
"fields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"byteLength": { "type": "integer", "minimum": 0 }
}
},
"contractCall": {
"type": "object",
"required": ["kind", "inputType", "name", "inputFields", "outputFields", "inputSize", "outputSize"],
"additionalProperties": true,
"properties": {
"kind": { "type": "string", "enum": ["procedure", "function"] },
"inputType": { "type": "integer", "minimum": 0 },
"name": { "type": "string", "minLength": 1 },
"description": { "type": "string" },
"inputFields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"outputFields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"inputSize": { "type": "integer", "minimum": 0 },
"outputSize": { "type": "integer", "minimum": 0 },
"requiresAmount": { "type": "boolean" },
"sourceRef": { "type": "string" }
}
},
"contractAbiVersion": {
"type": "object",
"required": [
"contractIndex",
"contractName",
"effectiveFromEpoch",
"effectiveToEpoch",
"structs",
"procedures",
"functions"
],
"additionalProperties": true,
"properties": {
"contractIndex": { "type": "integer", "minimum": 1 },
"contractName": { "type": "string", "minLength": 1 },
"contractAddress": { "type": "string", "minLength": 56, "maxLength": 60 },
"effectiveFromEpoch": { "type": "integer", "minimum": 0 },
"effectiveToEpoch": { "type": ["integer", "null"], "minimum": 0 },
"coreVersion": { "type": "string" },
"coreCommit": { "type": "string" },
"structs": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/namedStruct" }
},
"procedures": {
"type": "array",
"items": { "$ref": "#/$defs/contractCall" }
},
"functions": {
"type": "array",
"items": { "$ref": "#/$defs/contractCall" }
},
"changelog": { "type": "string" }
}
}
}
}
102 changes: 102 additions & 0 deletions data/contracts/schemas/contract_snapshot.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://static.qubic.org/schemas/contract_snapshot.schema.json",
"title": "Qubic contract ABI snapshot",
"type": "object",
"required": ["contractIndex", "contractName", "epoch", "structs", "procedures", "functions"],
"additionalProperties": true,
"properties": {
"contractIndex": { "type": "integer", "minimum": 1 },
"contractName": { "type": "string", "minLength": 1 },
"contractAddress": { "type": "string", "minLength": 56, "maxLength": 60 },
"epoch": { "type": "integer", "minimum": 0 },
"coreVersion": { "type": "string" },
"coreCommit": { "type": "string" },
"structs": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/namedStruct" }
},
"procedures": {
"type": "array",
"items": { "$ref": "#/$defs/contractCall" }
},
"functions": {
"type": "array",
"items": { "$ref": "#/$defs/contractCall" }
},
"changelog": { "type": "string" }
},
"$defs": {
"fieldType": {
"type": "string",
"enum": [
"uint8",
"uint16",
"uint32",
"uint64",
"sint8",
"sint16",
"sint32",
"sint64",
"uint128",
"id",
"bytes",
"array",
"struct"
]
},
"binaryField": {
"type": "object",
"required": ["name", "type", "offset", "byteLength"],
"additionalProperties": true,
"properties": {
"name": { "type": "string", "minLength": 1 },
"type": { "$ref": "#/$defs/fieldType" },
"offset": { "type": "integer", "minimum": 0 },
"byteLength": { "type": "integer", "minimum": 0 },
"description": { "type": "string" },
"arrayLength": { "type": "integer", "minimum": 0 },
"arrayItemType": { "$ref": "#/$defs/fieldType" },
"arrayItemByteLength": { "type": "integer", "minimum": 0 },
"arrayItemStructRef": { "type": "string" },
"structRef": { "type": "string" }
}
},
"namedStruct": {
"type": "object",
"required": ["name", "fields", "byteLength"],
"additionalProperties": true,
"properties": {
"name": { "type": "string", "minLength": 1 },
"fields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"byteLength": { "type": "integer", "minimum": 0 }
}
},
"contractCall": {
"type": "object",
"required": ["kind", "inputType", "name", "inputFields", "outputFields", "inputSize", "outputSize"],
"additionalProperties": true,
"properties": {
"kind": { "type": "string", "enum": ["procedure", "function"] },
"inputType": { "type": "integer", "minimum": 0 },
"name": { "type": "string", "minLength": 1 },
"description": { "type": "string" },
"inputFields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"outputFields": {
"type": "array",
"items": { "$ref": "#/$defs/binaryField" }
},
"inputSize": { "type": "integer", "minimum": 0 },
"outputSize": { "type": "integer", "minimum": 0 },
"requiresAmount": { "type": "boolean" },
"sourceRef": { "type": "string" }
}
}
}
}
13 changes: 13 additions & 0 deletions data/contracts/schemas/epoch_refs.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://static.qubic.org/schemas/epoch_refs.schema.json",
"title": "Qubic core epoch references",
"type": "object",
"additionalProperties": {
"type": "string",
"minLength": 1
},
"propertyNames": {
"pattern": "^[0-9]+$"
}
}
58 changes: 58 additions & 0 deletions data/contracts/schemas/smart_contracts.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://static.qubic.org/schemas/smart_contracts.schema.json",
"title": "Qubic smart contracts metadata",
"type": "object",
"required": ["smart_contracts"],
"additionalProperties": true,
"properties": {
"smart_contracts": {
"type": "array",
"items": { "$ref": "#/$defs/smartContract" }
}
},
"$defs": {
"smartContract": {
"type": "object",
"required": [
"filename",
"name",
"label",
"githubUrl",
"contractIndex",
"address",
"procedures",
"allowTransferShares",
"firstUseEpoch",
"sharesAuctionEpoch"
],
"additionalProperties": true,
"properties": {
"filename": { "type": "string", "pattern": "^[A-Za-z0-9_]+\\.h$" },
"name": { "type": "string", "minLength": 1 },
"label": { "type": "string", "minLength": 1 },
"githubUrl": { "type": "string", "format": "uri" },
"contractIndex": { "type": "integer", "minimum": 1 },
"address": { "type": "string", "minLength": 56, "maxLength": 60 },
"allowTransferShares": { "type": "boolean" },
"firstUseEpoch": { "type": "integer", "minimum": 0 },
"sharesAuctionEpoch": { "type": "integer", "minimum": 0 },
"procedures": {
"type": "array",
"items": { "$ref": "#/$defs/procedure" }
}
}
},
"procedure": {
"type": "object",
"required": ["id", "name"],
"additionalProperties": true,
"properties": {
"id": { "type": "integer", "minimum": 0 },
"name": { "type": "string", "minLength": 1 },
"sourceIdentifier": { "type": "string", "minLength": 1 },
"fee": { "type": "integer", "minimum": 0 }
}
}
}
}
Loading
Loading