This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Fn = (...args: any) => any | |
type Awaited<T> = T extends PromiseLike<infer U> ? U : T | |
export function someDecorator<V extends Fn>(method: V) { | |
// Do some initialization logic here | |
return async function (...args: Parameters<V>): Promise<Awaited<ReturnType<V>>> { | |
// Do some args manipulation or validation | |
const value = await method(...args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "./IERC1155.sol"; | |
import "./IERC1155Receiver.sol"; | |
import "./extensions/IERC1155MetadataURI.sol"; | |
import "../../utils/Address.sol"; | |
import "../../utils/Context.sol"; | |
import "../../utils/introspection/ERC165.sol"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Moralis from "moralis"; | |
const defaultQueryOptions = { | |
live: false, | |
skip: false, | |
filter: () => {}, | |
onCreate: (object, vs) => [object].concat(vs ?? []), | |
onUpdate: (object, vs) => vs.map((v) => (v.id === object.id ? object : v)), | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodeApi = "https://nodeapi.energi.network/"; | |
const owner = "YOUR_MASTERNODE_OWNER_ADDRESS" | |
estimateBlocksTilNextMasternodeReward(owner) | |
.then(({ estimatedTimestamp }) => console.log(`Next reward at ${new Date(estimatedTimestamp).toLocaleString()}`)) | |
function listMasternodes () { | |
return rpc(nodeApi, "masternode_listMasternodes"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeExecutableSchema } from '@graphql-tools/schema' | |
import { addResolveFunctionsToSchema } from 'apollo-server' | |
import { graphqlTypeDate, graphqlTypeObjectId, makeAugmentedSchema, mongoTypeDefs } from 'ts-mongo-codegen' | |
// The following import is the file generated in previous step | |
import { mountainMutationResolvers, mountainQueryResolvers, mountainResolvers } from './types.generated' | |
import { composeResolvers } from '@graphql-tools/resolvers-composition' | |
import { mountainSchema } from './gql/mountains' | |
import { isAuthenticated } from './auth' | |
// Make an executable schema with the mongo types and our custom mountain schema type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"schema": ["./node_modules/ts-mongo-codegen/dist/types/mongo-types.ts", "./src/gql/*.ts"], | |
"generates": { | |
"./src/types.generated.ts": { | |
"plugins": [ | |
"typescript", | |
"typescript-operations", | |
"typescript-resolvers", | |
"ts-mongo-codegen" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gql from 'graphql-tag' | |
export const mountainSchema = gql` | |
type Mountain @collection(name: "mountains", crud: true) { | |
id: ObjectId | |
name: String @insert @set @filter | |
meters: Float @insert @set @filter | |
feet: Float @insert @set @filter | |
location: String @insert @set @filter | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { hawk, hawkeye, useHawkState, useHawkSetState } from 'react-hawk'; | |
import Counter from '../Components/Counter' | |
const counterState = hawk({ | |
key: 'counter', | |
default: 0 | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { atom, selector, useRecoilValue, useSetRecoilState } from 'recoil'; | |
import Counter from '../Components/Counter' | |
const counterState = atom({ | |
key: 'counter', | |
default: 0 | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { | |
createContext, | |
useContext, | |
useState, | |
FC, | |
Dispatch, | |
SetStateAction, | |
} from "react"; | |
import Counter from "../Components/Counter"; |
NewerOlder