Skip to content

Commit

Permalink
updated token faucet code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-12 committed Oct 3, 2024
0 parents commit efe7502
Show file tree
Hide file tree
Showing 45 changed files with 22,819 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out/
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/require-await": "error",
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"react/no-unescaped-entities": "warn",
"react/react-in-jsx-scope": "warn"
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": ["./tsconfig.json"]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ral linguist-language=Rust
37 changes: 37 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: GitHub Pages

on:
push:
branches:
- main
pull_request:

jobs:
deploy:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "16"
cache: "npm"

- run: npm ci
- run: |
echo 'module.exports.basePath = "/nextjs-template"' >> next.config.js
- run: npm run testnet:build
env:
UPLOAD_SENTRY_SOURCEMAPS: false

- run: npm run export

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: out
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
32 changes: 32 additions & 0 deletions .project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"fullNodeVersion": "v3.5.0",
"compilerOptionsUsed": {
"ignoreUnusedConstantsWarnings": false,
"ignoreUnusedVariablesWarnings": false,
"ignoreUnusedFieldsWarnings": false,
"ignoreUnusedPrivateFunctionsWarnings": false,
"ignoreUpdateFieldsCheckWarnings": false,
"ignoreCheckExternalCallerWarnings": false,
"ignoreUnusedFunctionReturnWarnings": false
},
"infos": {
"IFungibleToken": {
"sourceFile": "../node_modules/@alephium/web3/std/fungible_token_interface.ral",
"sourceCodeHash": "62910bf11e1eeb6cb2fd468626ff606a9b06306b2b81590c3b10f6deb5966bde",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
},
"TokenFaucet": {
"sourceFile": "token.ral",
"sourceCodeHash": "3a12c7604f3899bde03ab81e81eac394a53e723c6e99bc38aeb722689826759f",
"bytecodeDebugPatch": "=20-2+67=101+3a0007e02=1+75468652063757272656e742062616c616e63652069732000=46",
"codeHashDebug": "a3309aa3a0dbd0c53b67a0c422316dcbc0571d8fa5f9ea2ab374b5c110f4efe2"
},
"Withdraw": {
"sourceFile": "withdraw.ral",
"sourceCodeHash": "52423580f02f5aab7050bfb9a14b497ea4bdcb10b3444483650f3dad8e0e5330",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
}
}
}
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This template project demonstrates how to implement a simple token faucet and expose it with a Web UI using Next.js.

## Getting Started

### Install

```
npm install
```

### Deploy the token faucet contract

```bash
# In this case devnet
npx @alephium/cli deploy -n devnet
```

This will compile and deploy the token faucet contracts to all of the
4 groups on devnet.

### Run the development server

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser
to see the token faucet application.

Download the [Alephium Extension Wallet](https://github.com/alephium/extension-wallet)
to interact with the application.
34 changes: 34 additions & 0 deletions alephium.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Configuration } from '@alephium/cli'
import { Number256 } from '@alephium/web3'

// Settings are usually for configuring
export type Settings = {
issueTokenAmount: Number256
}
const defaultSettings: Settings = { issueTokenAmount: 100n }

const configuration: Configuration<Settings> = {
networks: {
devnet: {
nodeUrl: 'http://localhost:22973',
privateKeys: [
'a642942e67258589cd2b1822c631506632db5a12aabcf413604e785300d762a5' // group 0
],
settings: defaultSettings
},

testnet: {
nodeUrl: (process.env.NODE_URL as string) ?? 'https://wallet-v20.testnet.alephium.org',
privateKeys: process.env.PRIVATE_KEYS === undefined ? [] : process.env.PRIVATE_KEYS.split(','),
settings: defaultSettings
},

mainnet: {
nodeUrl: (process.env.NODE_URL as string) ?? 'https://wallet-v20.mainnet.alephium.org',
privateKeys: process.env.PRIVATE_KEYS === undefined ? [] : process.env.PRIVATE_KEYS.split(','),
settings: defaultSettings
}
}
}

export default configuration
22 changes: 22 additions & 0 deletions artifacts/.deployments.devnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"deployerAddress": "1DrDyTr9RpRsQnDnXo2YRiPzPW4ooHX5LLoqXrqfMrpQH",
"contracts": {
"TokenFaucet": {
"txId": "641afe3ecc7c8f75ffda1049a18e8194449f6966020675b1158df1b09ba8d9f6",
"unsignedTx": "000401010103000000091500bee85f379545a2ed9f6cceb331288842f378cf0f04012ad4ac8824aae7d6f80a13c40de0b6b3a7640000a2144055060609121b4024402d404a010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000102a0000201020101001116000e320c7bb4b11600aba00016002ba10005b416005f141f0503025446030b546f6b656e46617563657402000240640306414c50480001140401024064134064ae188000dff0c1174876e8000137a444479fa782e8b88d4f95e28b3b2417e5bc30d33a5ae8486d4a8885b82b224259c1e6000381818e63bd9e35a5489b52a430accefc608fd60aa2c7c0d1b393b5239aedf6b001c6d3c20dd9b846760a800000bee85f379545a2ed9f6cceb331288842f378cf0f04012ad4ac8824aae7d6f80a00000000000000000000",
"signature": "29c00bc1c2b88f6cbdef9a5dc2da2e4e9949c4d96cce751c3ff444da9565c46760729738299a0d35fe5f35e8d8a667f2f005de33ec3ada48ff3181fe664d213b",
"gasPrice": "100000000000",
"gasAmount": 57328,
"blockHash": "483fb7415638367399d2cb8c259cef909eb4a995edd1aa35b314dca090ae6570",
"codeHash": "c97552a49aa550c7759be075f11b972a7e400f19fdd9e4eb9ca995cb370a63ca",
"contractInstance": {
"address": "ufMWQ9X4V6HWPjZ4wG7naxz5N5RD1EY8Vp1Gm55wWEWs",
"contractId": "0e72fa66049324321c591ba09bb57820a0fb77a5810af8e8f29144c928d64200",
"groupIndex": 0
},
"issueTokenAmount": "100"
}
},
"scripts": {},
"migrations": {}
}
22 changes: 22 additions & 0 deletions artifacts/.deployments.testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"deployerAddress": "1F7MXV7nht4nUQEHJezj4kFKgq5viU7zE9DYwvKMSV8Qs",
"contracts": {
"TokenFaucet": {
"txId": "ec0f2fe841367460136be4985c2b1b53a4a2ac423d577d599449447741c5ae81",
"unsignedTx": "000101010103000000091500d1a44f68cc2df5453154961b5a9aaaeeab5decdb783592201beb2d721e5cedd413c40de0b6b3a7640000a2144055060609121b4024402d404a010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000102a0000201020101001116000e320c7bb4b11600aba00016002ba10005b416005f141f0503025446030b546f6b656e46617563657402120240640306414c50480001140401024064134064ae1880017e24c1174876e800017e3d1e35527f00e5b7b27579d412e2d7262a95eaa5d09054a1f0549e7241cd97352f2b4c00020909d4a0db9c30f18ba47c8e12c369fab708bb6c3f31d9738b8d3a40aedfa22801c42d63f4421c6f2a3700d1a44f68cc2df5453154961b5a9aaaeeab5decdb783592201beb2d721e5cedd400000000000000000000",
"signature": "a6afd09fade4facb5c2f3fa6f49dd86c023848b038765732c2b83b3f527d29563776fa51f6f254be1f58b85b5d26f69dfee3377fab8348865ceac23be0396aa6",
"gasPrice": "100000000000",
"gasAmount": 97828,
"blockHash": "000000452183b593af77fc56a1711aa3a9aab563340f1c01112f6210e5d59390",
"codeHash": "7f557aef2ef16284bc32684e6feac4243de1f98055a0ff3676c9b043901160d8",
"contractInstance": {
"address": "y1btMZHTvMvHEqLTdx1JHvEXq3tmVfqsY2rwM669upiT",
"contractId": "4035e9b6e74e59a1572cc0c4cc4af5f9527076a35bedddfb0562b26a80663500",
"groupIndex": 0
},
"issueTokenAmount": "100"
}
},
"scripts": {},
"migrations": {}
}
96 changes: 96 additions & 0 deletions artifacts/TokenFaucet.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"version": "v2.12.0",
"name": "TokenFaucet",
"bytecode": "060609121b4024402d404a010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000102a0000201020101001116000e320c7bb4b11600aba00016002ba10005b416005f",
"codeHash": "3f02a0d23545568bc3face788c0202eda4244e2de567e8df482cb7f1ff611d52",
"fieldsSig": {
"names": ["symbol", "name", "decimals", "supply", "balance", "__stdInterfaceId"],
"types": ["ByteVec", "ByteVec", "U256", "U256", "U256", "ByteVec"],
"isMutable": [false, false, false, false, true, false]
},
"eventsSig": [
{
"name": "Withdraw",
"fieldNames": ["to", "amount"],
"fieldTypes": ["Address", "U256"]
}
],
"functions": [
{
"name": "getSymbol",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": ["ByteVec"]
},
{
"name": "getName",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": ["ByteVec"]
},
{
"name": "getDecimals",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": ["U256"]
},
{
"name": "getTotalSupply",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": ["U256"]
},
{
"name": "balance",
"usePreapprovedAssets": false,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": ["U256"]
},
{
"name": "withdraw",
"usePreapprovedAssets": false,
"useAssetsInContract": true,
"isPublic": true,
"paramNames": ["amount"],
"paramTypes": ["U256"],
"paramIsMutable": [false],
"returnTypes": []
}
],
"constants": [],
"enums": [
{
"name": "ErrorCodes",
"fields": [
{
"name": "InvalidWithdrawAmount",
"value": {
"type": "U256",
"value": "0"
}
}
]
}
],
"stdInterfaceId": "0001"
}
22 changes: 22 additions & 0 deletions artifacts/Withdraw.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "v2.12.0",
"name": "Withdraw",
"bytecodeTemplate": "01010300000005{1}0d0c{0}0105",
"fieldsSig": {
"names": ["token", "amount"],
"types": ["TokenFaucet", "U256"],
"isMutable": [false, false]
},
"functions": [
{
"name": "main",
"usePreapprovedAssets": true,
"useAssetsInContract": false,
"isPublic": true,
"paramNames": [],
"paramTypes": [],
"paramIsMutable": [],
"returnTypes": []
}
]
}
Loading

0 comments on commit efe7502

Please sign in to comment.