@@ -25,52 +25,87 @@ describe('TokenTransferContract Test Suite', function () {
2525 let signers ;
2626
2727 before ( async function ( ) {
28+ this . timeout ( 180000 ) ; // [diag] bound the hook so a hang flushes instead of eating the job cap
29+ const step = async ( label , fn ) => {
30+ console . log ( '[diag] tokentransfer: ' + label ) ;
31+ try {
32+ return await fn ( ) ;
33+ } catch ( err ) {
34+ utils . logRelayError ( 'tokentransfer:' + label , err ) ;
35+ throw err ;
36+ }
37+ } ;
2838 signers = await ethers . getSigners ( ) ;
29- tokenCreateContract = await utils . deployTokenCreateContract ( ) ;
30- tokenQueryContract = await utils . deployTokenQueryContract ( ) ;
31- tokenTransferContract = await utils . deployTokenTransferContract ( ) ;
32- erc20Contract = await utils . deployERC20Contract ( ) ;
33- erc721Contract = await utils . deployERC721Contract ( ) ;
34- await hapi . updateAccountKeys ( [
35- await tokenCreateContract . getAddress ( ) ,
36- await tokenQueryContract . getAddress ( ) ,
37- await tokenTransferContract . getAddress ( ) ,
38- ] ) ;
39- tokenAddress = await utils . createFungibleToken (
40- tokenCreateContract ,
41- signers [ 0 ] . address ,
39+ tokenCreateContract = await step ( 'deployTokenCreate' , ( ) =>
40+ utils . deployTokenCreateContract ( ) ,
4241 ) ;
43- await hapi . updateTokenKeys ( tokenAddress , [
44- await tokenCreateContract . getAddress ( ) ,
45- await tokenQueryContract . getAddress ( ) ,
46- await tokenTransferContract . getAddress ( ) ,
47- ] ) ;
48- nftTokenAddress = await utils . createNonFungibleToken (
49- tokenCreateContract ,
50- signers [ 0 ] . address ,
42+ tokenQueryContract = await step ( 'deployTokenQuery' , ( ) =>
43+ utils . deployTokenQueryContract ( ) ,
44+ ) ;
45+ tokenTransferContract = await step ( 'deployTokenTransfer' , ( ) =>
46+ utils . deployTokenTransferContract ( ) ,
47+ ) ;
48+ erc20Contract = await step ( 'deployERC20' , ( ) =>
49+ utils . deployERC20Contract ( ) ,
50+ ) ;
51+ erc721Contract = await step ( 'deployERC721' , ( ) =>
52+ utils . deployERC721Contract ( ) ,
5153 ) ;
52- await hapi . updateTokenKeys ( nftTokenAddress , [
54+ const contractKeys = [
5355 await tokenCreateContract . getAddress ( ) ,
5456 await tokenQueryContract . getAddress ( ) ,
5557 await tokenTransferContract . getAddress ( ) ,
56- ] ) ;
57- mintedTokenSerialNumber = await utils . mintNFT (
58- tokenCreateContract ,
59- nftTokenAddress ,
58+ ] ;
59+ const signer1Pk = utils . getHardhatSignerPrivateKeyByIndex ( 1 ) ;
60+ // Relay model: no account re-keying. Tokens use signer0's own ECDSA admin
61+ // key + signer0 as treasury (signer0 signs the create), then updateTokenKeys
62+ // hands operational keys to the contracts. signer0 stays a plain-ECDSA
63+ // holder/sender and signs its own debits; signer1 self-associates + gets
64+ // contract-granted KYC as the transfer counterparty.
65+ tokenAddress = await step ( 'createFungibleToken' , ( ) =>
66+ utils . createFungibleTokenWithSECP256K1AdminKey (
67+ tokenCreateContract ,
68+ signers [ 0 ] . address ,
69+ utils . getSignerCompressedPublicKey ( ) ,
70+ ) ,
6071 ) ;
61-
62- await utils . associateToken (
63- tokenCreateContract ,
64- tokenAddress ,
65- Constants . Contract . TokenCreateContract ,
72+ await step ( 'updateTokenKeys FT' , ( ) =>
73+ hapi . updateTokenKeys ( tokenAddress , contractKeys ) ,
6674 ) ;
67- await utils . grantTokenKyc ( tokenCreateContract , tokenAddress ) ;
68- await utils . associateToken (
69- tokenCreateContract ,
70- nftTokenAddress ,
71- Constants . Contract . TokenCreateContract ,
75+ nftTokenAddress = await step ( 'createNonFungibleToken' , ( ) =>
76+ utils . createNonFungibleTokenWithSECP256K1AdminKey (
77+ tokenCreateContract ,
78+ signers [ 0 ] . address ,
79+ utils . getSignerCompressedPublicKey ( ) ,
80+ ) ,
81+ ) ;
82+ await step ( 'updateTokenKeys NFT' , ( ) =>
83+ hapi . updateTokenKeys ( nftTokenAddress , contractKeys ) ,
84+ ) ;
85+ mintedTokenSerialNumber = await step ( 'mintNFT' , ( ) =>
86+ utils . mintNFT ( tokenCreateContract , nftTokenAddress ) ,
87+ ) ;
88+ await step ( 'associate signer1 FT' , ( ) =>
89+ hapi . associateWithSigner ( signer1Pk , tokenAddress ) ,
90+ ) ;
91+ await step ( 'associate signer1 NFT' , ( ) =>
92+ hapi . associateWithSigner ( signer1Pk , nftTokenAddress ) ,
93+ ) ;
94+ await step ( 'grantKyc signer1 FT' , ( ) =>
95+ tokenCreateContract . grantTokenKycPublic (
96+ tokenAddress ,
97+ signers [ 1 ] . address ,
98+ Constants . GAS_LIMIT_1_000_000 ,
99+ ) ,
100+ ) ;
101+ await step ( 'grantKyc signer1 NFT' , ( ) =>
102+ tokenCreateContract . grantTokenKycPublic (
103+ nftTokenAddress ,
104+ signers [ 1 ] . address ,
105+ Constants . GAS_LIMIT_1_000_000 ,
106+ ) ,
72107 ) ;
73- await utils . grantTokenKyc ( tokenCreateContract , nftTokenAddress ) ;
108+ console . log ( '[diag] tokentransfer: before DONE' ) ;
74109 } ) ;
75110
76111 after ( function ( ) {
0 commit comments