@@ -8,8 +8,6 @@ import hapi from '../hapi';
88import utils from '../utils' ;
99
1010describe ( 'ERC20Contract Test Suite' , function ( ) {
11- let tokenCreateContract ;
12- let tokenTransferContract ;
1311 let tokenAddress ;
1412 let erc20Contract ;
1513 let signers ;
@@ -20,44 +18,19 @@ describe('ERC20Contract Test Suite', function () {
2018 this . timeout ( 180000 ) ; // [diag] bound the hook so a hang flushes instead of eating the 45m job cap
2119 console . log ( '[diag] erc20c: getSigners' ) ;
2220 signers = await ethers . getSigners ( ) ;
23- console . log ( '[diag] erc20c: deploy contracts' ) ;
24- tokenCreateContract = await utils . deployTokenCreateContract ( ) ;
25- tokenTransferContract = await utils . deployTokenTransferContract ( ) ;
21+ console . log ( '[diag] erc20c: deploy erc20Contract' ) ;
2622 erc20Contract = await utils . deployERC20Contract ( ) ;
27- // Dedicated plain-ECDSA sender: v0.77 rejects EthereumTransactions from the
28- // re-keyed (KeyList) signer accounts. Fund it before the signers are re-keyed.
23+ // Relay model: one plain-ECDSA txSigner signs every contract call and no
24+ // account is ever re-keyed. v0.77 rejects EthereumTransactions from KeyList
25+ // accounts, so the signers stay untouched and act only as subjects.
2926 console . log ( '[diag] erc20c: createTxSigner' ) ;
3027 txSigner = await utils . createTxSigner ( signers [ 0 ] ) ;
31- console . log ( '[diag] erc20c: updateAccountKeys' ) ;
32- await hapi . updateAccountKeys ( [
33- await tokenCreateContract . getAddress ( ) ,
34- await tokenTransferContract . getAddress ( ) ,
35- ] ) ;
36- // Route every contract call through txSigner; signers stay owners by address.
37- tokenCreateContract = tokenCreateContract . connect ( txSigner ) ;
38- tokenTransferContract = tokenTransferContract . connect ( txSigner ) ;
3928 erc20Contract = erc20Contract . connect ( txSigner ) ;
40- console . log ( '[diag] erc20c: createFungibleToken' ) ;
41- tokenAddress = await utils . createFungibleToken (
42- tokenCreateContract ,
43- signers [ 0 ] . address ,
44- ) ;
45-
46- console . log ( '[diag] erc20c: updateTokenKeys' ) ;
47- await hapi . updateTokenKeys ( tokenAddress , [
48- await tokenCreateContract . getAddress ( ) ,
49- await tokenTransferContract . getAddress ( ) ,
50- ] ) ;
51- console . log ( '[diag] erc20c: associateToken' ) ;
52- await utils . associateToken (
53- tokenCreateContract ,
54- tokenAddress ,
55- Constants . Contract . TokenCreateContract ,
56- txSigner ,
57- ) ;
58- console . log ( '[diag] erc20c: grantTokenKyc' ) ;
59- await utils . grantTokenKyc ( tokenCreateContract , tokenAddress ) ;
60- console . log ( '[diag] erc20c: before DONE' ) ;
29+ // Token is created natively by its treasury (signer0, plain ECDSA) — no
30+ // contract-mediated create, so no account authorization is required.
31+ console . log ( '[diag] erc20c: createFungibleTokenViaSdk' ) ;
32+ tokenAddress = await hapi . createFungibleTokenViaSdk ( 0 ) ;
33+ console . log ( '[diag] erc20c: before DONE ' + tokenAddress ) ;
6134 } ) ;
6235
6336 after ( function ( ) {
@@ -87,7 +60,7 @@ describe('ERC20Contract Test Suite', function () {
8760 it ( 'should be able to get token balance of any account' , async function ( ) {
8861 const contractOwnerBalance = await erc20Contract . balanceOf (
8962 tokenAddress ,
90- await tokenCreateContract . getAddress ( ) ,
63+ await erc20Contract . getAddress ( ) ,
9164 ) ;
9265 const wallet1Balance = await erc20Contract . balanceOf (
9366 tokenAddress ,
@@ -107,12 +80,11 @@ describe('ERC20Contract Test Suite', function () {
10780 } ) ;
10881
10982 it ( 'should NOT be able to use transfer' , async function ( ) {
110- const signers = await ethers . getSigners ( ) ;
11183 const amount = 200 ;
11284
11385 const contractOwnerBalanceBefore = await erc20Contract . balanceOf (
11486 tokenAddress ,
115- await tokenCreateContract . getAddress ( ) ,
87+ await erc20Contract . getAddress ( ) ,
11688 ) ;
11789 const wallet1BalanceBefore = await erc20Contract . balanceOf (
11890 tokenAddress ,
@@ -124,14 +96,12 @@ describe('ERC20Contract Test Suite', function () {
12496 ) ;
12597
12698 try {
127- const tx = await erc20Contract
128- . connect ( txSigner )
129- . transfer (
130- tokenAddress ,
131- signers [ 1 ] . address ,
132- amount ,
133- Constants . GAS_LIMIT_1_000_000 ,
134- ) ;
99+ const tx = await erc20Contract . transfer (
100+ tokenAddress ,
101+ signers [ 1 ] . address ,
102+ amount ,
103+ Constants . GAS_LIMIT_1_000_000 ,
104+ ) ;
135105 await tx . wait ( ) ;
136106 } catch ( e ) {
137107 expect ( e ) . to . exist ;
@@ -140,7 +110,7 @@ describe('ERC20Contract Test Suite', function () {
140110
141111 const contractOwnerBalanceAfter = await erc20Contract . balanceOf (
142112 tokenAddress ,
143- await tokenCreateContract . getAddress ( ) ,
113+ await erc20Contract . getAddress ( ) ,
144114 ) ;
145115 const wallet1BalanceAfter = await erc20Contract . balanceOf (
146116 tokenAddress ,
@@ -157,7 +127,6 @@ describe('ERC20Contract Test Suite', function () {
157127 } ) ;
158128
159129 it ( 'should NOT be able to use delegateTransfer' , async function ( ) {
160- const signers = await ethers . getSigners ( ) ;
161130 const amount = 200 ;
162131
163132 const wallet1BalanceBefore = await erc20Contract . balanceOf (
@@ -170,14 +139,12 @@ describe('ERC20Contract Test Suite', function () {
170139 ) ;
171140
172141 try {
173- const tx = await erc20Contract
174- . connect ( txSigner )
175- . delegateTransfer (
176- tokenAddress ,
177- signers [ 1 ] . address ,
178- amount ,
179- Constants . GAS_LIMIT_1_000_000 ,
180- ) ;
142+ const tx = await erc20Contract . delegateTransfer (
143+ tokenAddress ,
144+ signers [ 1 ] . address ,
145+ amount ,
146+ Constants . GAS_LIMIT_1_000_000 ,
147+ ) ;
181148 await tx . wait ( ) ;
182149 } catch ( e ) {
183150 expect ( e ) . to . exist ;
@@ -198,7 +165,6 @@ describe('ERC20Contract Test Suite', function () {
198165 } ) ;
199166
200167 it ( 'should NOT be able to use approve' , async function ( ) {
201- const signers = await ethers . getSigners ( ) ;
202168 const approvedAmount = 200 ;
203169
204170 const allowanceBefore = await erc20Contract . allowance (
@@ -209,14 +175,12 @@ describe('ERC20Contract Test Suite', function () {
209175 expect ( allowanceBefore ) . to . eq ( 0 ) ;
210176
211177 try {
212- const tx = await erc20Contract
213- . connect ( txSigner )
214- . approve (
215- tokenAddress ,
216- signers [ 1 ] . address ,
217- approvedAmount ,
218- Constants . GAS_LIMIT_1_000_000 ,
219- ) ;
178+ const tx = await erc20Contract . approve (
179+ tokenAddress ,
180+ signers [ 1 ] . address ,
181+ approvedAmount ,
182+ Constants . GAS_LIMIT_1_000_000 ,
183+ ) ;
220184 await tx . wait ( ) ;
221185 } catch ( e ) {
222186 expect ( e ) . to . exist ;
@@ -232,7 +196,6 @@ describe('ERC20Contract Test Suite', function () {
232196 } ) ;
233197
234198 it ( 'should NOT be able to use delegateApprove and allowance' , async function ( ) {
235- const signers = await ethers . getSigners ( ) ;
236199 const approvedAmount = 200 ;
237200
238201 const allowanceBefore = await erc20Contract . allowance (
@@ -243,14 +206,12 @@ describe('ERC20Contract Test Suite', function () {
243206 expect ( allowanceBefore ) . to . eq ( 0 ) ;
244207
245208 try {
246- const tx = await erc20Contract
247- . connect ( txSigner )
248- . delegateApprove (
249- tokenAddress ,
250- signers [ 1 ] . address ,
251- approvedAmount ,
252- Constants . GAS_LIMIT_1_000_000 ,
253- ) ;
209+ const tx = await erc20Contract . delegateApprove (
210+ tokenAddress ,
211+ signers [ 1 ] . address ,
212+ approvedAmount ,
213+ Constants . GAS_LIMIT_1_000_000 ,
214+ ) ;
254215 await tx . wait ( ) ;
255216 } catch ( e ) {
256217 expect ( e ) . to . exist ;
@@ -266,7 +227,6 @@ describe('ERC20Contract Test Suite', function () {
266227 } ) ;
267228
268229 it ( 'should NOT be able to use delegateTransferFrom' , async function ( ) {
269- const signers = await ethers . getSigners ( ) ;
270230 const amount = 50 ;
271231
272232 const wallet1BalanceBefore = await erc20Contract . balanceOf (
@@ -284,15 +244,13 @@ describe('ERC20Contract Test Suite', function () {
284244 ) ;
285245
286246 try {
287- const tx = await erc20Contract
288- . connect ( txSigner )
289- . delegateTransferFrom (
290- tokenAddress ,
291- signers [ 0 ] . address ,
292- signers [ 1 ] . address ,
293- amount ,
294- Constants . GAS_LIMIT_1_000_000 ,
295- ) ;
247+ const tx = await erc20Contract . delegateTransferFrom (
248+ tokenAddress ,
249+ signers [ 0 ] . address ,
250+ signers [ 1 ] . address ,
251+ amount ,
252+ Constants . GAS_LIMIT_1_000_000 ,
253+ ) ;
296254 await tx . wait ( ) ;
297255 } catch ( e ) {
298256 expect ( e ) . to . exist ;
0 commit comments