Skip to content

Instantly share code, notes, and snippets.

@habdelra
habdelra / README.txt
Created July 1, 2021 21:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&runs=10&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
The following cs fields exist on cards:
- csRealm: The realm that the card currently resides in.
- csId: The csId distinguishes the card within its originalRealm. In some cases
it may be chosen by the person creating the card. In others it may be
chosen by the hub.
- csOriginalRealm: The realm that the card was first created in. Often times
this value will be undefined, when this value is undefined that means that the
@habdelra
habdelra / gist:f356040b35b6426c685aa1fbece2cd63
Last active February 6, 2020 19:08
Card Network Requests for Orbit
Card creation
POST http://localhost:3000/api/realms/first-ephemeral-realm/cards
Request Body:
{
"data": {
"type": "cards",
"attributes": {
"csFieldSets": {
"embedded": [
@habdelra
habdelra / data.js
Last active September 23, 2019 21:06
Card Data Service brainstorming
import Service from '@ember/service';
export default class DataService extends Service {
cache = new Map();
async getCard(id /*: string */, format /*: string*/) {
// if the card already exists in the cache, just return cached card
// return Card instance
}
@habdelra
habdelra / Creating a card using JSONAPIFactory
Last active August 7, 2019 16:57
article-card/card.js
// This file lives in an npm module with the name of 'article-card' in a cards.js file.
// (I think just using index.js might be a good idea too--i can go either way here)
const JSONAPIFactory = require('@cardstack/test-support/jsonapi-factory');
module.exports = function() {
let factory = new JSONAPIFactory();
// the card ID specified only needs to speify the last part of the multi-part ID.
// the rest of the card ID parts are derived from the package name.
// In this example we show how fields are actually cards, and we customize a field by adopting a string-field card.
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
...
},
included: [
@habdelra
habdelra / gist:f5c519790afdaf24bf371fa71b1fc464
Last active August 5, 2019 17:59
Card Relationship Polymorphism
// In this example we control the types of cards that are allowed in the event relationship
// using the "related-cards" relationship that hangs off of the field.
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
...
},
included: [
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
attributes: {
'edit-template': `
{{delegate-to content.event}} {{!-- framework decides the format to use, appears as embedded until a user clicks on it, for example --}}
{{delegate-to content.price}}
`,
'isolated-template': `
// Card Adoption example
{
data: {
type: 'cards',
id: '@foobar/events-are-us::event-cards::emberconf-2020',
attributes: {
// no need to define templates and components if we have not changed it
// when hub instantiates this card it will traverse the "adopts" graph to get the template and components for this card
// when there is more than 1 adopted card, then you must define your card's templates and components here
// Also use similar approach as ember in terms of not having a component js, where the component is just a glimmer comnponent of the outer HTML of the template,
// Sample Ticket card
// A card can represent both its schema and its data in a single document
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
attributes: {
'suggested-name': 'ticket',
'edit-template': `