Skip to content

Commit

Permalink
startin' w/ consult to get Webpack 5
Browse files Browse the repository at this point in the history
  • Loading branch information
dysbulic committed Nov 17, 2021
0 parents commit a8da927
Show file tree
Hide file tree
Showing 63 changed files with 36,844 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
"@babel/preset-env",
[
"@babel/preset-react", {
"runtime": "automatic"
}
]
],
"plugins": [
[
"@babel/transform-runtime", {
"regenerator": true,
"corejs": 3
}
]
]
}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
node_modules/
build/
.eslintcache
ipfs/
.vscode/

# Hardhat files
cache/
artifacts/
private.key
private.mnemonic
public/page_meta.png

# Yarn Berry
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.env
631 changes: 631 additions & 0 deletions .yarn/releases/yarn-3.0.2.cjs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.0.2.cjs

logFilters:
- code: YN0013
- level: warning
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Call Meta

The aim of this program is to associate time-sensitive metadata with the playback of recordings of livestreams of pair-programming sessions and virtual meetings with the goal of making it possible to comprehend the proceedings in significantly less time.

## Technology

The video data and metainformation is stored in [IPFS](//ipfs.io) with a pointer placed in a [Ceramic](//ceramic.network) stream for discovery.

There is a DID NFT controlled document with the listing of available videos. Users can request a token giving them write access.

## Development

* `yarn && yarn start` to start the development server
* `yarn deploy` to publish to GitHub pages
108 changes: 108 additions & 0 deletions bin/create-model.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/env -S node --experimental-json-modules

import { access, readFile, writeFile } from 'node:fs/promises'
import { constants } from 'fs'
import { CeramicClient } from '@ceramicnetwork/http-client'
import { ModelManager } from '@glazed/devtools'
import { DID } from 'dids'
import { Ed25519Provider } from 'key-did-provider-ed25519'
import { getResolver } from 'key-did-resolver'
import { fromString } from 'uint8arrays'
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

;(async () => {
let raw = process.env.DID_KEY
if(!raw) {
try {
const keyFile = `${__dirname}/../private.key`
await access(keyFile, constants.R_OK)
raw = (await readFile(keyFile, 'utf8')).trim()
} catch {}
}
if(!raw) {
console.warn('$DID_KEY must be set or private.key must exist.')
console.warn('Generate it with `openssl rand -hex 32`.')
process.exit(-2)
}

const key = fromString(raw, 'base16')
const did = new DID({
provider: new Ed25519Provider(key),
resolver: getResolver(),
})
await did.authenticate()

const ceramicURI = (
process.env.CERAMIC_URI
|| 'http:https://localhost:7007'
)
console.info(`Connecting to ${ceramicURI}`)
const ceramic = new CeramicClient(ceramicURI)
ceramic.did = did

const manager = new ModelManager(ceramic)

const $schema = (
'http:https://json-schema.org/draft-07/schema#'
)
const schemaId = await manager.createSchema(
'VideoList',
{
$schema,
title: 'VideoList',
type: 'object',
properties: {
videos: {
type: 'array',
items: {
type: 'object',
properties: {
title: {
type: 'string',
maxLength: 400,
},
uri: {
type: 'string',
maxLength: 200,
},
},
},
},
},
}
)
const schemaURI = manager.getSchemaURL(schemaId)
console.info(`Wrote schema to "${schemaURI}".`)

await manager.createDefinition(
'publicVideos',
{
name: 'Public videos list',
description: 'List of publicly visible recordings of community calls and pair programming sessions.',
schema: schemaURI,
}
)

await manager.createTile(
'buildersAlign',
{
videos: [
{
title: 'MetaGame’s Builders’ Align for 1443/2/28‒3/6',
uri: 'ipfs:https://QmbPtAgWbNDo2Zwsv8RR7WNsLySkMb71QyEenuCcGPENaE/MetaGame’s%20Builders’%20Align%20for%201443⁄2⁄28‒3⁄6.json5'
}
]
},
{ schema: schemaURI },
)

const model = await manager.toPublished()
const out = `${__dirname}/../src/ceramicIds.json`
await writeFile(out, JSON.stringify(model, null, 2))

console.info(`Wrote ids to "${out}"."`)
})()
13 changes: 13 additions & 0 deletions contracts/IDXEndpointPublisher.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract IDXEndpointPublisher {
constructor() {
}

function publish(string memory caip10) public {
emit CAIP_10(caip10);
}

event CAIP_10(string caip10);
}
85 changes: 85 additions & 0 deletions contracts/VideosERC1155.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//SPDX-License-Identifier: Creative Commons 0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract VideosERC1155 is ERC1155 {
mapping (uint256 => string) private _uris;

uint8 constant ACCESS_TOKEN = 1;
uint8 constant VIDEO_TOKEN = 2;

uint256 public constant PUBLIC_ACCESS = (
ACCESS_TOKEN + (1 << 8)
);
uint256 public constant CODER_ACCESS = (
ACCESS_TOKEN + (2 << 8)
);
uint256 public constant SCRIBE_ACCESS = (
ACCESS_TOKEN + (3 << 8)
);
uint256 public constant PEER_ACCESS = (
ACCESS_TOKEN + (4 << 8)
);
uint256 public constant APPROVER_ACCESS = (
ACCESS_TOKEN + (5 << 8)
);
uint256 public constant TREASURER_ACCESS = (
ACCESS_TOKEN + (6 << 8)
);
uint256 public constant METAMANAGER_ACCESS = (
ACCESS_TOKEN + (8 << 8)
);
uint256 public constant ADMIN_ACCESS = (
ACCESS_TOKEN + (8 << 8)
);

constructor() ERC1155("Single Metadata URI Is Not Used") {
setURI(
"ipfs:https://QmNTGedv6su4LM8XFqonNCdXQYLL4z7VThha7WczGf7iMf/public%20access%20token.json",
PUBLIC_ACCESS
);
}

function mintAccessToken(
uint256 tokenId
) public {
require(
tokenId & 0xFF == ACCESS_TOKEN,
"Not an access token."
);
require(
balanceOf(msg.sender, tokenId) == 0,
"User already has the given access token"
);
_mint(msg.sender, tokenId, 1, "");
}

function contractURI()
public pure
returns (string memory) {
return "ipfs:https://QmXFiKzEnZEZNiJEHwKympHWZ8MJSbegC2Bnvvk2iKPLe5/video%20contract%20metadata.json";
}

function tokenURI(
uint256 tokenId
) public view
returns (string memory) {
return uri(tokenId);
}

function uri(
uint256 tokenId
) public view virtual override
returns (string memory) {
return _uris[tokenId];
}

function setURI(
string memory newuri,
uint256 tokenId
) public virtual {
_uris[tokenId] = newuri;
emit URI(newuri, tokenId);
}
}
83 changes: 83 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
require('@nomiclabs/hardhat-waffle')
require('hardhat-abi-exporter')
require("@nomiclabs/hardhat-etherscan")
const fs = require('fs')
require('dotenv').config(
{ path: `${__dirname}/.env` }
)

task(
'accounts',
'Prints the list of accounts',
async (_args, hre) => {
const accounts = await hre.ethers.getSigners()
const { provider } = hre.waffle
await Promise.all(
accounts.map(async ({ address: addr }) => {
const balance = (
hre.ethers.utils.formatUnits(
await provider.getBalance(addr),
"ether",
)
)
console.info(`${addr}: ${balance}`)
})
)
},
)

const mnemonic = (
fs.readFileSync('private.mnemonic')
.toString()
.trim()
)

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
// defaultNetwork: 'matic-mumbai',
defaultNetwork: 'rinkeby',
networks: {
hardhat: {
},
matic: {
url: 'https://rpc-mainnet.matic.network',
accounts: { mnemonic },
},
'matic-mumbai': {
url: 'https://rpc-mumbai.maticvigil.com',
accounts: { mnemonic },
},
rinkeby: {
url: process.env.RINKEBY_RPC_URL,
accounts: { mnemonic },
},
},
solidity: {
version: '0.8.4',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts',
},
mocha: {
timeout: 20000,
},
abiExporter: {
path: './src/contract/abi',
spacing: 2,
flat: true,
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
}
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": "src",
"module": "esnext"
},
"include": ["src"],
"exclude": ["node_modules", "build"]
}
Loading

0 comments on commit a8da927

Please sign in to comment.