Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
Refactor contracts and sandboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Dec 17, 2019
1 parent 9220a58 commit 3a87430
Show file tree
Hide file tree
Showing 27 changed files with 1,452 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Local: Ganache-cli
NODE_URL=ws://localhost:8545
STABLE_COIN_CONTRACT_ADDRESS=0x855d1c79Ad3fb086D516554Dc7187E3Fdfc1C79a

# Rinkeby
#NODE_URL=https://rinkeby.infura.io/v3/<your-api-key>
#STABLE_COIN_CONTRACT_ADDRESS=0x9046451F7cF124c1d7d1832F76F5e98a33D1610E

# Production
#NODE_URL=https://mainnet.infura.io/v3/<your-api-key>
#STABLE_COIN_CONTRACT_ADDRESS=<not-deployed-yet>

# WEB: Front end. It can be any instance of this web https://github.com/gnosis/dex-react
WEB_BASE_URL=https://dex-react

NODE_URL=http://localhost:8545
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint src --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js",
"verify": "npm run lint && npm run test",
"sandbox": "DEBUG=ERROR-*,WARN-*,INFO-*,DEBUG-*,-DEBUG-helper*,-DEBUG-util* nodemon -r dotenv/config"
"sandbox": "DEBUG=ERROR-*,WARN-*,INFO-*,DEBUG-*,-DEBUG-helper*,-DEBUG-util* nodemon -r dotenv/config -r tsconfig-paths/register"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -62,6 +62,7 @@
"rimraf": "^3.0.0",
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.2"
}
}
225 changes: 225 additions & 0 deletions src/contracts/Erc20ABI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
import { AbiItem } from 'web3-utils'

const Erc20Abi: AbiItem[] = [
{
constant: true,
inputs: [],
name: 'name',
outputs: [
{
name: '',
type: 'string'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: false,
inputs: [
{
name: '_spender',
type: 'address'
},
{
name: '_value',
type: 'uint256'
}
],
name: 'approve',
outputs: [
{
name: '',
type: 'bool'
}
],
payable: false,
stateMutability: 'nonpayable',
type: 'function'
},
{
constant: true,
inputs: [],
name: 'totalSupply',
outputs: [
{
name: '',
type: 'uint256'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: false,
inputs: [
{
name: '_from',
type: 'address'
},
{
name: '_to',
type: 'address'
},
{
name: '_value',
type: 'uint256'
}
],
name: 'transferFrom',
outputs: [
{
name: '',
type: 'bool'
}
],
payable: false,
stateMutability: 'nonpayable',
type: 'function'
},
{
constant: true,
inputs: [],
name: 'decimals',
outputs: [
{
name: '',
type: 'uint8'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: true,
inputs: [
{
name: '_owner',
type: 'address'
}
],
name: 'balanceOf',
outputs: [
{
name: 'balance',
type: 'uint256'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: true,
inputs: [],
name: 'symbol',
outputs: [
{
name: '',
type: 'string'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: false,
inputs: [
{
name: '_to',
type: 'address'
},
{
name: '_value',
type: 'uint256'
}
],
name: 'transfer',
outputs: [
{
name: '',
type: 'bool'
}
],
payable: false,
stateMutability: 'nonpayable',
type: 'function'
},
{
constant: true,
inputs: [
{
name: '_owner',
type: 'address'
},
{
name: '_spender',
type: 'address'
}
],
name: 'allowance',
outputs: [
{
name: '',
type: 'uint256'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
payable: true,
stateMutability: 'payable',
type: 'fallback'
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: 'owner',
type: 'address'
},
{
indexed: true,
name: 'spender',
type: 'address'
},
{
indexed: false,
name: 'value',
type: 'uint256'
}
],
name: 'Approval',
type: 'event'
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: 'from',
type: 'address'
},
{
indexed: true,
name: 'to',
type: 'address'
},
{
indexed: false,
name: 'value',
type: 'uint256'
}
],
name: 'Transfer',
type: 'event'
}
]
export default Erc20Abi
29 changes: 29 additions & 0 deletions src/contracts/Erc20Contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import BN from 'bn.js'

import { TransactionObject } from 'contracts/types'
import { Contract } from 'web3-eth-contract'

export interface Erc20Contract extends Contract {
clone(): Erc20Contract

methods: {
totalSupply(): TransactionObject<string>
decimals(): TransactionObject<string>
symbol(): TransactionObject<string>
name(): TransactionObject<string>

balanceOf(owner: string): TransactionObject<string, [string]>

allowance(owner: string, spender: string): TransactionObject<string, [string, string]>

approve(spender: string, value: number | string | BN): TransactionObject<boolean, [string, string | number | BN]>

transfer(to: string, value: number | string | BN): TransactionObject<boolean, [string, string | number | BN]>

transferFrom(
from: string,
to: string,
value: number | string | BN,
): TransactionObject<boolean, [string, string, string | number | BN]>
}
}

0 comments on commit 3a87430

Please sign in to comment.