Skip to content

Instantly share code, notes, and snippets.

View Dhaiwat10's full-sized avatar

dhai Dhaiwat10

View GitHub Profile
@Dhaiwat10
Dhaiwat10 / RentableNFT_Flattened.sol
Created June 9, 2022 08:25
flattened rentable nfts contract
// Sources flattened with hardhat v2.9.9 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/[email protected]
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
@Dhaiwat10
Dhaiwat10 / OnboardingLayout.test.tsx
Last active March 6, 2022 08:05
wagmi hooks mock
import { render, screen } from '@testing-library/react';
import { OnboardingLayout } from './OnboardingLayout';
import * as wagmi from 'wagmi';
describe('OnboardingLaout', () => {
test('all sections are being rendered', () => {
const spyUseConnect = jest.spyOn(wagmi, 'useConnect');
spyUseConnect.mockReturnValue([
{
// @ts-ignore we are not returning all the fields returned by the actual data field. We don't need to
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
// We first import some OpenZeppelin Contracts.
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import {StringUtils} from "./StringUtils.sol";
// We import another help function
import {Base64} from "./Base64.sol";
@Dhaiwat10
Dhaiwat10 / useTransaction.tsx
Created December 14, 2021 15:15
`useTransaction` hook
export default function App() {
const { connectWallet, connected } = useWallet();
const greeterContract = useContract(CONTRACT_ADDRESS, abi);
const [greeting, setGreeting] = useState();
const [input, setInput] = useState();
const { execute, error, loading } = useTransaction(greeterContract.setGreeting, [input]);
const fetchGreeting = useCallback(async () => {
@Dhaiwat10
Dhaiwat10 / agora.ts
Created November 3, 2021 03:17
AgoraRTC TypeScript implementation
import AgoraRTC, {
IAgoraRTCClient,
IAgoraRTCRemoteUser,
ILocalAudioTrack,
ILocalVideoTrack,
IMicrophoneAudioTrack,
} from 'agora-rtc-sdk-ng';
import { RtcTokenBuilder, RtcRole } from 'agora-access-token';