Skip to content

Commit fe5bdd1

Browse files
committed
Commonify source of common interfaces
1 parent b97e9c0 commit fe5bdd1

File tree

141 files changed

+215
-7670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+215
-7670
lines changed
Lines changed: 108 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,251 @@
11
import { AbiItem } from 'web3-utils'
22

3-
export const withdrawAbi = [
3+
export const erc20Abi = [
44
{
55
anonymous: false,
66
inputs: [
77
{
88
indexed: true,
99
internalType: 'address',
10-
name: '_property',
10+
name: 'owner',
1111
type: 'address',
1212
},
1313
{
14-
indexed: false,
14+
indexed: true,
1515
internalType: 'address',
16-
name: '_from',
16+
name: 'spender',
1717
type: 'address',
1818
},
1919
{
2020
indexed: false,
21-
internalType: 'address',
22-
name: '_to',
23-
type: 'address',
21+
internalType: 'uint256',
22+
name: 'value',
23+
type: 'uint256',
2424
},
2525
],
26-
name: 'PropertyTransfer',
26+
name: 'Approval',
2727
type: 'event',
2828
},
2929
{
30+
anonymous: false,
3031
inputs: [
3132
{
33+
indexed: true,
3234
internalType: 'address',
33-
name: '',
35+
name: 'from',
3436
type: 'address',
3537
},
38+
{
39+
indexed: true,
40+
internalType: 'address',
41+
name: 'to',
42+
type: 'address',
43+
},
44+
{
45+
indexed: false,
46+
internalType: 'uint256',
47+
name: 'value',
48+
type: 'uint256',
49+
},
3650
],
37-
name: 'cumulativeWithdrawnReward',
51+
name: 'Transfer',
52+
type: 'event',
53+
},
54+
{
55+
constant: true,
56+
inputs: [],
57+
name: 'totalSupply',
3858
outputs: [
3959
{
4060
internalType: 'uint256',
4161
name: '',
4262
type: 'uint256',
4363
},
4464
],
65+
payable: false,
4566
stateMutability: 'view',
4667
type: 'function',
4768
},
4869
{
70+
constant: true,
4971
inputs: [
5072
{
5173
internalType: 'address',
52-
name: '',
53-
type: 'address',
54-
},
55-
{
56-
internalType: 'address',
57-
name: '',
74+
name: 'account',
5875
type: 'address',
5976
},
6077
],
61-
name: 'lastWithdrawnRewardCapPrice',
78+
name: 'balanceOf',
6279
outputs: [
6380
{
6481
internalType: 'uint256',
6582
name: '',
6683
type: 'uint256',
6784
},
6885
],
86+
payable: false,
6987
stateMutability: 'view',
7088
type: 'function',
7189
},
7290
{
91+
constant: false,
7392
inputs: [
7493
{
7594
internalType: 'address',
76-
name: '',
95+
name: 'recipient',
7796
type: 'address',
7897
},
7998
{
80-
internalType: 'address',
81-
name: '',
82-
type: 'address',
99+
internalType: 'uint256',
100+
name: 'amount',
101+
type: 'uint256',
83102
},
84103
],
85-
name: 'lastWithdrawnRewardPrice',
104+
name: 'transfer',
86105
outputs: [
87106
{
88-
internalType: 'uint256',
107+
internalType: 'bool',
89108
name: '',
90-
type: 'uint256',
109+
type: 'bool',
91110
},
92111
],
93-
stateMutability: 'view',
112+
payable: false,
113+
stateMutability: 'nonpayable',
94114
type: 'function',
95115
},
96116
{
117+
constant: true,
97118
inputs: [
98119
{
99120
internalType: 'address',
100-
name: '',
121+
name: 'owner',
101122
type: 'address',
102123
},
103124
{
104125
internalType: 'address',
105-
name: '',
126+
name: 'spender',
106127
type: 'address',
107128
},
108129
],
109-
name: 'pendingWithdrawal',
130+
name: 'allowance',
110131
outputs: [
111132
{
112133
internalType: 'uint256',
113134
name: '',
114135
type: 'uint256',
115136
},
116137
],
138+
payable: false,
117139
stateMutability: 'view',
118140
type: 'function',
119141
},
120142
{
121-
inputs: [],
122-
name: 'registryAddress',
123-
outputs: [
143+
constant: false,
144+
inputs: [
124145
{
125146
internalType: 'address',
126-
name: '',
147+
name: 'spender',
127148
type: 'address',
128149
},
129-
],
130-
stateMutability: 'view',
131-
type: 'function',
132-
},
133-
{
134-
inputs: [
135150
{
136-
internalType: 'address',
137-
name: '_registry',
138-
type: 'address',
151+
internalType: 'uint256',
152+
name: 'amount',
153+
type: 'uint256',
139154
},
140155
],
141-
name: 'initialize',
142-
outputs: [],
143-
stateMutability: 'nonpayable',
144-
type: 'function',
145-
},
146-
{
147-
inputs: [
156+
name: 'approve',
157+
outputs: [
148158
{
149-
internalType: 'address',
150-
name: '_property',
151-
type: 'address',
159+
internalType: 'bool',
160+
name: '',
161+
type: 'bool',
152162
},
153163
],
154-
name: 'withdraw',
155-
outputs: [],
164+
payable: false,
156165
stateMutability: 'nonpayable',
157166
type: 'function',
158167
},
159168
{
169+
constant: false,
160170
inputs: [
161171
{
162172
internalType: 'address',
163-
name: '_from',
173+
name: 'sender',
164174
type: 'address',
165175
},
166176
{
167177
internalType: 'address',
168-
name: '_to',
178+
name: 'recipient',
169179
type: 'address',
170180
},
181+
{
182+
internalType: 'uint256',
183+
name: 'amount',
184+
type: 'uint256',
185+
},
186+
],
187+
name: 'transferFrom',
188+
outputs: [
189+
{
190+
internalType: 'bool',
191+
name: '',
192+
type: 'bool',
193+
},
171194
],
172-
name: 'beforeBalanceChange',
173-
outputs: [],
195+
payable: false,
174196
stateMutability: 'nonpayable',
175197
type: 'function',
176198
},
177199
{
200+
constant: false,
178201
inputs: [
179202
{
180203
internalType: 'address',
181-
name: '_property',
204+
name: 'spender',
182205
type: 'address',
183206
},
184207
{
185-
internalType: 'address',
186-
name: '_user',
187-
type: 'address',
208+
internalType: 'uint256',
209+
name: 'addedValue',
210+
type: 'uint256',
188211
},
189212
],
190-
name: 'calculateRewardAmount',
213+
name: 'increaseAllowance',
191214
outputs: [
192215
{
193-
internalType: 'uint256',
194-
name: '_amount',
195-
type: 'uint256',
216+
internalType: 'bool',
217+
name: '',
218+
type: 'bool',
196219
},
220+
],
221+
payable: false,
222+
stateMutability: 'nonpayable',
223+
type: 'function',
224+
},
225+
{
226+
constant: false,
227+
inputs: [
197228
{
198-
internalType: 'uint256',
199-
name: '_price',
200-
type: 'uint256',
229+
internalType: 'address',
230+
name: 'spender',
231+
type: 'address',
201232
},
202233
{
203234
internalType: 'uint256',
204-
name: '_cap',
235+
name: 'subtractedValue',
205236
type: 'uint256',
206237
},
238+
],
239+
name: 'decreaseAllowance',
240+
outputs: [
207241
{
208-
internalType: 'uint256',
209-
name: '_allReward',
210-
type: 'uint256',
242+
internalType: 'bool',
243+
name: '',
244+
type: 'bool',
211245
},
212246
],
213-
stateMutability: 'view',
247+
payable: false,
248+
stateMutability: 'nonpayable',
214249
type: 'function',
215250
},
216251
] as readonly AbiItem[]

lib/l2/dev/index.spec.ts renamed to lib/ethereum/erc20/index.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import Web3 from 'web3'
2-
import { createDevContract, DevContract } from '.'
3-
import { createTransferCaller } from '../erc20/transfer'
4-
import { devAbi } from './abi'
2+
import { createErc20Contract, Erc20Contract } from '.'
3+
import { createTransferCaller } from './../erc20/transfer'
4+
import { erc20Abi } from './abi'
55
import { CustomOptions } from '../../common/option'
6-
import { createBalanceOfCaller } from '../erc20/balanceOf'
7-
import { createTotalSupplyCaller } from '../erc20/totalSupply'
8-
import { createApproveCaller } from '../erc20/approve'
9-
import { createTransferFromCaller } from '../erc20/transferFrom'
10-
import { createNameCaller } from '../erc20/name'
11-
import { createSymbolCaller } from '../erc20/symbol'
12-
import { createDecimalsCaller } from '../erc20/decimals'
13-
import { createAllowanceCaller } from '../erc20/allowance'
6+
import { createBalanceOfCaller } from './balanceOf'
7+
import { createTotalSupplyCaller } from './totalSupply'
8+
import { createApproveCaller } from './approve'
9+
import { createTransferFromCaller } from './transferFrom'
10+
import { createNameCaller } from './name'
11+
import { createSymbolCaller } from './symbol'
12+
import { createDecimalsCaller } from './decimals'
13+
import { createAllowanceCaller } from './allowance'
1414

15-
describe('dev/index.ts', () => {
16-
describe('createDevContract', () => {
15+
describe('erc20/index.ts', () => {
16+
describe('createErc20Contract', () => {
1717
it('check return object', () => {
1818
const host = 'localhost'
1919
const client = new Web3()
@@ -22,8 +22,8 @@ describe('dev/index.ts', () => {
2222
const expected: (
2323
address?: string,
2424
options?: CustomOptions
25-
) => DevContract = (address?: string, options?: CustomOptions) => {
26-
const devContract = new client.eth.Contract([...devAbi], address, {
25+
) => Erc20Contract = (address?: string, options?: CustomOptions) => {
26+
const devContract = new client.eth.Contract([...erc20Abi], address, {
2727
...options,
2828
})
2929
return {
@@ -40,7 +40,7 @@ describe('dev/index.ts', () => {
4040
}
4141
}
4242

43-
const result = createDevContract(client)
43+
const result = createErc20Contract(client)
4444

4545
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected))
4646
expect(

0 commit comments

Comments
 (0)