Skip to content

Commit

Permalink
Merge pull request #4 from soramitsu/SP-connect-draft-wrapper
Browse files Browse the repository at this point in the history
feat: draft layouts, MetaMask and WalletConnect integration, ethers.js wrapper and GraphQL draft wrapper
  • Loading branch information
Victorius authored Jun 6, 2024
2 parents 916823c + 8328a76 commit 27c8da3
Show file tree
Hide file tree
Showing 34 changed files with 9,969 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:vue/vue3-recommended",
"prettier",
"@vue/eslint-config-typescript",
],
rules: {
// override/add rules settings here, such as:
// 'vue/no-unused-vars': 'error'
},
};
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# stakepad-frontend
Designing a Better World Through Decentralized Technologies
## Description of the project

Stakepad is the Web3 platform that aims to be convenient and powerful tool for the common user interactions with the staking pools and for the managing staking pools based on the ERC-20 and ERC-721 protocols. It allows to:

- Stake, unstake tokens and claim rewards
- Create a staking pool
- Manage an existing staking pool
- View a statistics about the staking pool


## How to launch?

1. Clone the repository
2. Install the dependencies with the command `npm i`. Node version 18+ is required.
3. Site is now available at the `localhost:5173`
114 changes: 114 additions & 0 deletions __mocks__/ethers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import BigNumber from "bignumber.js";

type MockWeb3Provider = {
gas: string;
address: string;
api_key: string;
getCode(): string;
getGasPrice(): BigNumber;
estimateGas(): string;
getFeeData(): { gasPrice: BigNumber };
getTransactionCount(): string;
getSigner(): any;
};

type MockJsonRpcProvider = {
gas: string;
node: string;
getGasPrice(): BigNumber;
estimateGas(): string;
getFeeData(): { gasPrice: BigNumber };
getTransactionCount(): string;
getCode(): string;
getSigner(): any;
};

type MockContract = {
decimals: () => number;
estimateGas: {
transfer: () => BigNumber;
};
transfer: () => {
hash: string;
};
connect: any
};

const gas = "21000";
const nonce = "1";
const code = "0x";
const getSigner = () => {
return {
getTransactionCount: () => 100,
sendTransaction: (..._: any) => ({
hash: "0x0"
}),
signMessage: (message: string) => ({
message
})
}
}

export const ethers = {
providers: {
Web3Provider: function (
this: MockWeb3Provider,
address: string,
apiKey: string,
) {
this.gas = gas;
this.address = address;
this.api_key = apiKey;
this.getCode = () => code;
this.getGasPrice = () => new BigNumber(this.gas);
this.estimateGas = () => this.gas;
this.getFeeData = () => ({ gasPrice: new BigNumber(this.gas) });
this.getTransactionCount = () => nonce;
this.getSigner = getSigner
},
JsonRpcProvider: function (this: MockJsonRpcProvider, node: string) {
this.gas = gas;
this.node = node;
this.getGasPrice = () =>
Promise.resolve(new BigNumber(this.gas)) as unknown as BigNumber;
this.estimateGas = () => this.gas;
this.getFeeData = () => ({ gasPrice: new BigNumber(this.gas) });
this.getTransactionCount = () => nonce;
this.getCode = () => code;
this.getSigner = getSigner
},
},
utils: {
parseEther: (amount: string | number) => {
return new BigNumber(amount).mul(Math.pow(10, 18)).toString();
},
formatEther: (amount: string | number) => {
return "0.000001";
},
parseUnits: (amount: string, decimals: number) => {
return new BigNumber(amount).mul(Math.pow(10, decimals)).toString();
},
isAddress: (address: string) => {
return /^(0x)?[0-9a-fA-F]{40}$/.test(address);
},
hexlify: (amount: number) => {
const value = amount.toString(16);
if (value.length % 2) {
return "0x0" + value;
}
return code + value;
},
},
Contract: function (this: MockContract) {
this.decimals = () => 18;
this.estimateGas = {
transfer: () => new BigNumber(21000),
};
this.transfer = () => ({
hash: "0x5555555555555555555555555555555555555555555555555555555555555555",
});
this.connect = (contract: any) => ({
...contract,
})
},
};
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Staking</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Loading

0 comments on commit 27c8da3

Please sign in to comment.