Some checks failed
Integration Tests / test-service-integration (push) Successful in 2m16s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 25s
Package Tests / Python package - aitbc-core (push) Successful in 22s
Package Tests / Python package - aitbc-crypto (push) Successful in 14s
Package Tests / Python package - aitbc-sdk (push) Successful in 18s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 6s
Package Tests / JavaScript package - aitbc-token (push) Successful in 21s
Production Tests / Production Integration Tests (push) Failing after 10s
Python Tests / test-python (push) Failing after 2m41s
Security Scanning / security-scan (push) Failing after 46s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 16s
Smart Contract Tests / lint-solidity (push) Successful in 12s
- Simplified npm install commands in CI workflows by removing fallback logic - Added aitbc-crypto local dependency installation for aitbc-sdk in package-tests.yml - Removed aitbc-token specific Hardhat dependency workarounds from package-tests.yml - Fixed bare except clause in agent_daemon.py to catch specific json.JSONDecodeError - Moved aitbc-crypto from poetry.dependencies to standard dependencies in aitbc-sdk - Fixed MyPy type errors in receip
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import type { HardhatEthers } from "@nomicfoundation/hardhat-ethers/types";
|
|
import { network } from "hardhat";
|
|
import type { NetworkConnection } from "hardhat/types/network";
|
|
|
|
type HardhatConnection = NetworkConnection & {
|
|
ethers: HardhatEthers;
|
|
};
|
|
|
|
function envOrDefault(name: string, fallback?: string): string | undefined {
|
|
const value = process.env[name]?.trim();
|
|
return value && value.length > 0 ? value : fallback;
|
|
}
|
|
|
|
async function main() {
|
|
const { ethers } = (await network.connect()) as HardhatConnection;
|
|
const [deployer, coordinatorCandidate] = await ethers.getSigners();
|
|
|
|
console.log("Deploying AIToken using admin:", deployer.address);
|
|
|
|
const contractFactory = await ethers.getContractFactory("AIToken");
|
|
const token = await contractFactory.deploy(deployer.address);
|
|
await token.waitForDeployment();
|
|
|
|
const contractAddress = await token.getAddress();
|
|
console.log("AIToken deployed to:", contractAddress);
|
|
|
|
const coordinatorRole = await token.COORDINATOR_ROLE();
|
|
const attestorRole = await token.ATTESTOR_ROLE();
|
|
|
|
const coordinatorAddress = envOrDefault(
|
|
"COORDINATOR_ADDRESS",
|
|
coordinatorCandidate.address,
|
|
);
|
|
if (!coordinatorAddress) {
|
|
throw new Error(
|
|
"COORDINATOR_ADDRESS not provided and could not infer fallback signer address",
|
|
);
|
|
}
|
|
|
|
if (!(await token.hasRole(coordinatorRole, coordinatorAddress))) {
|
|
console.log("Granting coordinator role to", coordinatorAddress);
|
|
const tx = await token.grantRole(coordinatorRole, coordinatorAddress);
|
|
await tx.wait();
|
|
} else {
|
|
console.log("Coordinator role already assigned to", coordinatorAddress);
|
|
}
|
|
|
|
const attestorAddress = envOrDefault("ATTESTOR_ADDRESS");
|
|
if (attestorAddress) {
|
|
if (!(await token.hasRole(attestorRole, attestorAddress))) {
|
|
console.log("Granting attestor role to", attestorAddress);
|
|
const tx = await token.grantRole(attestorRole, attestorAddress);
|
|
await tx.wait();
|
|
} else {
|
|
console.log("Attestor role already assigned to", attestorAddress);
|
|
}
|
|
} else {
|
|
console.log("No ATTESTOR_ADDRESS provided; skipping attestor role grant.");
|
|
}
|
|
|
|
console.log("Deployment complete. Export AITOKEN_ADDRESS=", contractAddress);
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error(error);
|
|
process.exitCode = 1;
|
|
});
|