@@ -9,63 +9,75 @@ import utils from '../utils';
99
1010describe ( 'ERC721Contract Test Suite' , function ( ) {
1111 let tokenCreateContract ;
12- let tokenTransferContract ;
1312 let tokenAddress ;
1413 let erc721Contract ;
1514 let mintedTokenSerialNumber ;
1615 let nftInitialOwnerAddress ;
1716 let signers , firstWallet , secondWallet ;
1817
1918 before ( async function ( ) {
19+ this . timeout ( 180000 ) ; // [diag] bound the hook so a hang flushes instead of eating the 45m job cap
20+ const step = async ( label , fn ) => {
21+ console . log ( '[diag] erc721c: ' + label ) ;
22+ try {
23+ return await fn ( ) ;
24+ } catch ( err ) {
25+ utils . logRelayError ( 'erc721c:' + label , err ) ;
26+ throw err ;
27+ }
28+ } ;
2029 signers = await ethers . getSigners ( ) ;
21- tokenCreateContract = await utils . deployTokenCreateContract ( ) ;
22- tokenTransferContract = await utils . deployTokenTransferContract ( ) ;
23- await hapi . updateAccountKeys ( [
24- await tokenCreateContract . getAddress ( ) ,
25- await tokenTransferContract . getAddress ( ) ,
26- ] ) ;
27- erc721Contract = await utils . deployERC721Contract ( ) ;
28- tokenAddress = await utils . createNonFungibleToken (
29- tokenCreateContract ,
30- signers [ 0 ] . address ,
30+ firstWallet = signers [ 0 ] ;
31+ secondWallet = signers [ 1 ] ;
32+ tokenCreateContract = await step ( 'deployTokenCreateContract' , ( ) =>
33+ utils . deployTokenCreateContract ( ) ,
3134 ) ;
32- await hapi . updateTokenKeys ( tokenAddress , [
33- await tokenCreateContract . getAddress ( ) ,
34- await tokenTransferContract . getAddress ( ) ,
35- ] ) ;
36- mintedTokenSerialNumber = await utils . mintNFT (
37- tokenCreateContract ,
38- tokenAddress ,
35+ erc721Contract = await step ( 'deployERC721Contract' , ( ) =>
36+ utils . deployERC721Contract ( ) ,
3937 ) ;
40- await utils . associateToken (
41- tokenCreateContract ,
42- tokenAddress ,
43- Constants . Contract . TokenCreateContract ,
38+ const erc721Addr = await erc721Contract . getAddress ( ) ;
39+ // Relay model: no account re-keying. The token is precompile-created (so the
40+ // contract can read its ERC721 facade) with firstWallet — the tx sender — as
41+ // treasury, which its own signature authorizes, and the NFT is minted
42+ // straight to it. So no re-key and no separate transfer to seed ownership.
43+ tokenAddress = await step ( 'createNonFungibleToken' , ( ) =>
44+ utils . createNonFungibleToken ( tokenCreateContract , firstWallet . address ) ,
4445 ) ;
45- await utils . grantTokenKyc ( tokenCreateContract , tokenAddress ) ;
46- firstWallet = signers [ 0 ] ;
47- secondWallet = signers [ 1 ] ;
48-
49- await tokenCreateContract . associateTokenPublic (
50- await erc721Contract . getAddress ( ) ,
51- tokenAddress ,
52- Constants . GAS_LIMIT_1_000_000 ,
46+ mintedTokenSerialNumber = await step ( 'mintNFT' , ( ) =>
47+ utils . mintNFT ( tokenCreateContract , tokenAddress ) ,
5348 ) ;
54-
55- await tokenCreateContract . grantTokenKycPublic (
56- tokenAddress ,
57- await erc721Contract . getAddress ( ) ,
58- Constants . GAS_LIMIT_1_000_000 ,
49+ // Receivers must be associated + KYC-granted (treasury firstWallet is
50+ // exempt). secondWallet self-associates with its own key; the contract holds
51+ // the inherited KYC key so it grants KYC without the target signing.
52+ await step ( 'associate secondWallet' , ( ) =>
53+ hapi . associateWithSigner (
54+ utils . getHardhatSignerPrivateKeyByIndex ( 1 ) ,
55+ tokenAddress ,
56+ ) ,
5957 ) ;
60-
61- await tokenTransferContract . transferNFTPublic (
62- tokenAddress ,
63- await tokenCreateContract . getAddress ( ) ,
64- signers [ 0 ] . address ,
65- mintedTokenSerialNumber ,
66- Constants . GAS_LIMIT_1_000_000 ,
58+ await step ( 'grantKyc secondWallet' , ( ) =>
59+ tokenCreateContract . grantTokenKycPublic (
60+ tokenAddress ,
61+ secondWallet . address ,
62+ Constants . GAS_LIMIT_1_000_000 ,
63+ ) ,
64+ ) ;
65+ await step ( 'associate erc721Contract' , ( ) =>
66+ tokenCreateContract . associateTokenPublic (
67+ erc721Addr ,
68+ tokenAddress ,
69+ Constants . GAS_LIMIT_1_000_000 ,
70+ ) ,
6771 ) ;
68- nftInitialOwnerAddress = signers [ 0 ] . address ;
72+ await step ( 'grantKyc erc721Contract' , ( ) =>
73+ tokenCreateContract . grantTokenKycPublic (
74+ tokenAddress ,
75+ erc721Addr ,
76+ Constants . GAS_LIMIT_1_000_000 ,
77+ ) ,
78+ ) ;
79+ nftInitialOwnerAddress = firstWallet . address ;
80+ console . log ( '[diag] erc721c: before DONE' ) ;
6981 } ) ;
7082
7183 after ( function ( ) {
@@ -225,16 +237,10 @@ describe('ERC721Contract Test Suite', function () {
225237 let serialNumber ;
226238
227239 before ( async function ( ) {
240+ // Minted straight to the treasury (firstWallet), so no transfer needed.
228241 serialNumber = await utils . mintNFT ( tokenCreateContract , tokenAddress , [
229242 '0x02' ,
230243 ] ) ;
231- await tokenTransferContract . transferNFTPublic (
232- tokenAddress ,
233- await tokenCreateContract . getAddress ( ) ,
234- signers [ 0 ] . address ,
235- serialNumber ,
236- Constants . GAS_LIMIT_1_000_000 ,
237- ) ;
238244 } ) ;
239245
240246 it ( 'should NOT be able to execute approve' , async function ( ) {
0 commit comments