1- import 'package:web3dart/web3dart .dart' as web3 ;
1+ part of '../erc20 .dart' ;
22
3- final _contractAbi = web3.ContractAbi .fromJson (
4- '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]',
5- 'Erc20' );
3+ final _contractAbi = ContractAbi .fromJson (
4+ '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]',
5+ 'Erc20' ,
6+ );
67
78/// Interface of the ERC20 standard as defined in the EIP.
8- class ERC20 extends web3. GeneratedContract {
9+ class ERC20 extends GeneratedContract {
910 /// Constructor.
1011 ERC20 ({
11- required web3. EthereumAddress address,
12- required web3. Web3Client client,
12+ required EthereumAddress address,
13+ required Web3Client client,
1314 int ? chainId,
14- }) : super (web3. DeployedContract (_contractAbi, address), client, chainId);
15+ }) : super (DeployedContract (_contractAbi, address), client, chainId);
1516
1617 /// Returns the remaining number of tokens that [spender] will be allowed to spend on behalf of [owner] through [transferFrom] . This is zero by default. This value changes when [approve] or [transferFrom] are called.
1718 ///
1819 /// The optional [atBlock] parameter can be used to view historical data. When
1920 /// set, the function will be evaluated in the specified block. By default, the
2021 /// latest on-chain block will be used.
2122 Future <BigInt > allowance (
22- web3. EthereumAddress owner,
23- web3. EthereumAddress spender, {
24- web3. BlockNum ? atBlock,
23+ EthereumAddress owner,
24+ EthereumAddress spender, {
25+ BlockNum ? atBlock,
2526 }) async {
2627 final function = self.abi.functions[0 ];
2728 assert (checkSignature (function, 'dd62ed3e' ));
@@ -36,10 +37,10 @@ class ERC20 extends web3.GeneratedContract {
3637 /// like the gas price, nonce and max gas. The `data` and `to` fields will be
3738 /// set by the contract.
3839 Future <String > approve (
39- web3. EthereumAddress spender,
40+ EthereumAddress spender,
4041 BigInt amount, {
41- required web3. Credentials credentials,
42- web3. Transaction ? transaction,
42+ required Credentials credentials,
43+ Transaction ? transaction,
4344 }) async {
4445 final function = self.abi.functions[1 ];
4546 assert (checkSignature (function, '095ea7b3' ));
@@ -52,10 +53,7 @@ class ERC20 extends web3.GeneratedContract {
5253 /// The optional [atBlock] parameter can be used to view historical data. When
5354 /// set, the function will be evaluated in the specified block. By default, the
5455 /// latest on-chain block will be used.
55- Future <BigInt > balanceOf (
56- web3.EthereumAddress account, {
57- web3.BlockNum ? atBlock,
58- }) async {
56+ Future <BigInt > balanceOf (EthereumAddress account, {BlockNum ? atBlock}) async {
5957 final function = self.abi.functions[2 ];
6058 assert (checkSignature (function, '70a08231' ));
6159 final params = [account];
@@ -68,7 +66,7 @@ class ERC20 extends web3.GeneratedContract {
6866 /// The optional [atBlock] parameter can be used to view historical data. When
6967 /// set, the function will be evaluated in the specified block. By default, the
7068 /// latest on-chain block will be used.
71- Future <BigInt > decimals ({web3. BlockNum ? atBlock}) async {
69+ Future <BigInt > decimals ({BlockNum ? atBlock}) async {
7270 final function = self.abi.functions[3 ];
7371 assert (checkSignature (function, '313ce567' ));
7472 final params = [];
@@ -81,7 +79,7 @@ class ERC20 extends web3.GeneratedContract {
8179 /// The optional [atBlock] parameter can be used to view historical data. When
8280 /// set, the function will be evaluated in the specified block. By default, the
8381 /// latest on-chain block will be used.
84- Future <String > name ({web3. BlockNum ? atBlock}) async {
82+ Future <String > name ({BlockNum ? atBlock}) async {
8583 final function = self.abi.functions[4 ];
8684 assert (checkSignature (function, '06fdde03' ));
8785 final params = [];
@@ -94,7 +92,7 @@ class ERC20 extends web3.GeneratedContract {
9492 /// The optional [atBlock] parameter can be used to view historical data. When
9593 /// set, the function will be evaluated in the specified block. By default, the
9694 /// latest on-chain block will be used.
97- Future <String > symbol ({web3. BlockNum ? atBlock}) async {
95+ Future <String > symbol ({BlockNum ? atBlock}) async {
9896 final function = self.abi.functions[5 ];
9997 assert (checkSignature (function, '95d89b41' ));
10098 final params = [];
@@ -107,7 +105,7 @@ class ERC20 extends web3.GeneratedContract {
107105 /// The optional [atBlock] parameter can be used to view historical data. When
108106 /// set, the function will be evaluated in the specified block. By default, the
109107 /// latest on-chain block will be used.
110- Future <BigInt > totalSupply ({web3. BlockNum ? atBlock}) async {
108+ Future <BigInt > totalSupply ({BlockNum ? atBlock}) async {
111109 final function = self.abi.functions[6 ];
112110 assert (checkSignature (function, '18160ddd' ));
113111 final params = [];
@@ -121,10 +119,10 @@ class ERC20 extends web3.GeneratedContract {
121119 /// like the gas price, nonce and max gas. The `data` and `to` fields will be
122120 /// set by the contract.
123121 Future <String > transfer (
124- web3. EthereumAddress recipient,
122+ EthereumAddress recipient,
125123 BigInt amount, {
126- required web3. Credentials credentials,
127- web3. Transaction ? transaction,
124+ required Credentials credentials,
125+ Transaction ? transaction,
128126 }) async {
129127 final function = self.abi.functions[7 ];
130128 assert (checkSignature (function, 'a9059cbb' ));
@@ -137,35 +135,44 @@ class ERC20 extends web3.GeneratedContract {
137135 /// The optional [transaction] parameter can be used to override parameters
138136 /// like the gas price, nonce and max gas. The `data` and `to` fields will be
139137 /// set by the contract.
140- Future <String > transferFrom (web3.EthereumAddress sender,
141- web3.EthereumAddress recipient, BigInt amount,
142- {required web3.Credentials credentials,
143- web3.Transaction ? transaction}) async {
138+ Future <String > transferFrom (
139+ EthereumAddress sender,
140+ EthereumAddress recipient,
141+ BigInt amount, {
142+ required Credentials credentials,
143+ Transaction ? transaction,
144+ }) async {
144145 final function = self.abi.functions[8 ];
145146 assert (checkSignature (function, '23b872dd' ));
146147 final params = [sender, recipient, amount];
147148 return write (credentials, transaction, function, params);
148149 }
149150
150151 /// Returns a live stream of all Approval events emitted by this contract.
151- Stream <Approval > approvalEvents (
152- {web3.BlockNum ? fromBlock, web3.BlockNum ? toBlock}) {
152+ Stream <Approval > approvalEvents ({BlockNum ? fromBlock, BlockNum ? toBlock}) {
153153 final event = self.event ('Approval' );
154- final filter = web3.FilterOptions .events (
155- contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock);
156- return client.events (filter).map ((web3.FilterEvent result) {
154+ final filter = FilterOptions .events (
155+ contract: self,
156+ event: event,
157+ fromBlock: fromBlock,
158+ toBlock: toBlock,
159+ );
160+ return client.events (filter).map ((FilterEvent result) {
157161 final decoded = event.decodeResults (result.topics! , result.data! );
158162 return Approval ._(decoded);
159163 });
160164 }
161165
162166 /// Returns a live stream of all Transfer events emitted by this contract.
163- Stream <Transfer > transferEvents (
164- {web3.BlockNum ? fromBlock, web3.BlockNum ? toBlock}) {
167+ Stream <Transfer > transferEvents ({BlockNum ? fromBlock, BlockNum ? toBlock}) {
165168 final event = self.event ('Transfer' );
166- final filter = web3.FilterOptions .events (
167- contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock);
168- return client.events (filter).map ((web3.FilterEvent result) {
169+ final filter = FilterOptions .events (
170+ contract: self,
171+ event: event,
172+ fromBlock: fromBlock,
173+ toBlock: toBlock,
174+ );
175+ return client.events (filter).map ((FilterEvent result) {
169176 final decoded = event.decodeResults (result.topics! , result.data! );
170177 return Transfer ._(decoded);
171178 });
@@ -175,15 +182,15 @@ class ERC20 extends web3.GeneratedContract {
175182/// Emitted when the allowance of a [spender] for an [owner] is set by a call to [ERC20.approve] . [value] is the new allowance.
176183class Approval {
177184 Approval ._(List <dynamic > response)
178- : owner = (response[0 ] as web3. EthereumAddress ),
179- spender = (response[1 ] as web3. EthereumAddress ),
180- value = (response[2 ] as BigInt );
185+ : owner = (response[0 ] as EthereumAddress ),
186+ spender = (response[1 ] as EthereumAddress ),
187+ value = (response[2 ] as BigInt );
181188
182189 /// The owner address.
183- final web3. EthereumAddress owner;
190+ final EthereumAddress owner;
184191
185192 /// The spender address.
186- final web3. EthereumAddress spender;
193+ final EthereumAddress spender;
187194
188195 /// Value.
189196 final BigInt value;
@@ -192,15 +199,15 @@ class Approval {
192199/// Emitted when [value] tokens are moved from one account ([from] ) to another ([to] ). Note that [value] may be zero.
193200class Transfer {
194201 Transfer ._(List <dynamic > response)
195- : from = (response[0 ] as web3. EthereumAddress ),
196- to = (response[1 ] as web3. EthereumAddress ),
197- value = (response[2 ] as BigInt );
202+ : from = (response[0 ] as EthereumAddress ),
203+ to = (response[1 ] as EthereumAddress ),
204+ value = (response[2 ] as BigInt );
198205
199206 /// From address.
200- final web3. EthereumAddress from;
207+ final EthereumAddress from;
201208
202209 /// To address.
203- final web3. EthereumAddress to;
210+ final EthereumAddress to;
204211
205212 /// Value.
206213 final BigInt value;
0 commit comments