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
service_fee_percentage = 2.9 / 100 | |
service_fee_fixed = 30 | |
def add_service_fee(price): | |
return (price + service_fee_fixed) / (1 - service_fee_percentage) |
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
from django_stripe_integration import settings, helper #add helper | |
@method_decorator(csrf_exempt, name='dispatch') | |
class Checkout(generics.GenericAPIView): | |
def get(self, request, *args, **kwargs): | |
product_id = kwargs['product'] | |
product = Product.objects.get(id=product_id) | |
price = int(product.price * 100) | |
domain_url = 'http://127.0.0.1:8000/' | |
stripe.api_key = settings.STRIPE_SECRET_KEY |
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
from django.conf.urls.static import static | |
from django.contrib import admin | |
from django.urls import path, include | |
from django_stripe_integration import settings, views | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('products/', include('product.urls')), | |
path('orders/', include('orders.urls')), |
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
@method_decorator(csrf_exempt, name='dispatch') | |
class StripeConfig(generics.GenericAPIView): | |
def get(self, request, *args, **kwargs): | |
stripe_config = {'publicKey': settings.STRIPE_PUBLISHABLE_KEY} | |
return JsonResponse(stripe_config, safe=False) |
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, { useEffect, useState } from 'react'; | |
import { Accordion, Alert, Button, Col, Container, Image, Row } from "react-bootstrap"; | |
import { buyNFT, getMaxSupply, getTotalSupply } from "../../network/ethereum"; | |
import { style } from "./Home.styles"; | |
// Images | |
import Logo from '../../images/Logo.jpg'; | |
type Props = { | |
currentAccount?: string; |
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 { Button, Container, Nav, Navbar } from "react-bootstrap"; | |
import { style } from './Header.styles' | |
import { Link } from "react-router-dom"; | |
type Props = { | |
currentAccount?: string, | |
setCurrentAccount: React.Dispatch<React.SetStateAction<string | undefined>> | |
} |
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 { useEffect, useState } from "react"; | |
import { getToken, getTokenUri } from "../network/ethereum"; | |
type tokenMetadata = { | |
name: string, | |
description: string, | |
image: string, | |
edition: number | |
} |
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 { useState } from "react"; | |
export const useWallet = () => { | |
const { ethereum } = window; | |
const [currentAccount, setCurrentAccount] = useState<string | undefined>(ethereum.selectedAddress); | |
// @ts-ignore | |
ethereum.on("accountsChanged", ([newAccount]) => { | |
console.log("accountsChanged: ", newAccount); | |
setCurrentAccount(newAccount); |
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 Web3 from 'web3'; | |
import abi from '../contracts/abi.json'; | |
import { AbiItem } from "web3-utils"; | |
const rpcURL: string | undefined = process.env.REACT_APP_API_URL; | |
const web3 = new Web3(rpcURL!!); | |
const contractAddress = process.env.REACT_APP_CONTRACT_ADDRESS | |
const contract = new web3.eth.Contract(abi as AbiItem[], contractAddress); |
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 csv | |
from PIL import Image, ImageDraw, ImageFont | |
width = 512 | |
height = 512 | |
font = ImageFont.truetype("arial.ttf", size=20) | |
with open('data.csv', 'r') as f: |