1+ import { createCollection , describeWithExistingNode , slotAndOwnerToTokenId } from "./util" ;
12import {
2- addressToCollectionId ,
3- createCollection ,
4- describeWithExistingNode ,
5- extractRevertReason ,
6- slotAndOwnerToTokenId ,
7- } from "./util" ;
8- import {
9- GAS_LIMIT ,
103 FAITH ,
114 SELECTOR_LOG_EVOLVED_WITH_EXTERNAL_TOKEN_URI ,
125 SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI ,
136 SELECTOR_LOG_OWNERSHIP_TRANSFERRED ,
14- SELECTOR_LOG_PUBLIC_MINTING_ENABLED ,
15- SELECTOR_LOG_PUBLIC_MINTING_DISABLED ,
16- ALITH ,
17- ALITH_PRIVATE_KEY ,
187} from "./config" ;
198import { expect } from "chai" ;
209import Contract from "web3-eth-contract" ;
@@ -47,9 +36,10 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
4736 const tokenURI = "https://example.com" ;
4837
4938 let nonce = await context . web3 . eth . getTransactionCount ( FAITH ) ;
39+ const estimatedGas = await collectionContract . methods . mintWithExternalURI ( to , slot , tokenURI ) . estimateGas ( ) ;
5040 const result = await collectionContract . methods
5141 . mintWithExternalURI ( to , slot , tokenURI )
52- . send ( { from : FAITH , gas : GAS_LIMIT , nonce : nonce ++ } ) ;
42+ . send ( { from : FAITH , gas : estimatedGas , nonce : nonce ++ } ) ;
5343 expect ( result . status ) . to . be . eq ( true ) ;
5444
5545 const tokenId = result . events . MintedWithExternalURI . returnValues . _tokenId ;
@@ -72,9 +62,10 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
7262 const to = FAITH ;
7363 const tokenURI = "https://example.com" ;
7464
65+ const estimatedGas = await collectionContract . methods . mintWithExternalURI ( to , slot , tokenURI ) . estimateGas ( ) ;
7566 const result = await collectionContract . methods
7667 . mintWithExternalURI ( to , slot , tokenURI )
77- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
68+ . send ( { from : FAITH , gas : estimatedGas } ) ;
7869 expect ( result . status ) . to . be . eq ( true ) ;
7970
8071 expect ( Object . keys ( result . events ) . length ) . to . be . eq ( 1 ) ;
@@ -108,14 +99,18 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
10899 const tokenId = slotAndOwnerToTokenId ( slot , to ) ;
109100 const tokenIdDecimal = new BN ( tokenId , 16 , "be" ) . toString ( 10 ) ;
110101
102+ var estimatedGas = await collectionContract . methods . mintWithExternalURI ( to , slot , tokenURI ) . estimateGas ( ) ;
111103 const mintingResult = await collectionContract . methods
112104 . mintWithExternalURI ( to , slot , tokenURI )
113- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
105+ . send ( { from : FAITH , gas : estimatedGas } ) ;
114106 expect ( mintingResult . status ) . to . be . eq ( true ) ;
115107
108+ estimatedGas = await collectionContract . methods
109+ . evolveWithExternalURI ( tokenIdDecimal , newTokenURI )
110+ . estimateGas ( ) ;
116111 const evolvingResult = await collectionContract . methods
117112 . evolveWithExternalURI ( tokenIdDecimal , newTokenURI )
118- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
113+ . send ( { from : FAITH , gas : estimatedGas } ) ;
119114 expect ( evolvingResult . status ) . to . be . eq ( true ) ;
120115
121116 const got = await collectionContract . methods . tokenURI ( tokenIdDecimal ) . call ( ) ;
@@ -130,14 +125,18 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
130125 const tokenId = slotAndOwnerToTokenId ( slot , to ) ;
131126 const tokenIdDecimal = new BN ( tokenId , 16 , "be" ) . toString ( 10 ) ;
132127
128+ var estimatedGas = await collectionContract . methods . mintWithExternalURI ( to , slot , tokenURI ) . estimateGas ( ) ;
133129 const mintingResult = await collectionContract . methods
134130 . mintWithExternalURI ( to , slot , tokenURI )
135- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
131+ . send ( { from : FAITH , gas : estimatedGas } ) ;
136132 expect ( mintingResult . status ) . to . be . eq ( true ) ;
137133
134+ estimatedGas = await collectionContract . methods
135+ . evolveWithExternalURI ( tokenIdDecimal , newTokenURI )
136+ . estimateGas ( ) ;
138137 const evolvingResult = await collectionContract . methods
139138 . evolveWithExternalURI ( tokenIdDecimal , newTokenURI )
140- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
139+ . send ( { from : FAITH , gas : estimatedGas } ) ;
141140 expect ( evolvingResult . status ) . to . be . eq ( true ) ;
142141
143142 expect ( Object . keys ( evolvingResult . events ) . length ) . to . be . eq ( 1 ) ;
@@ -171,9 +170,10 @@ describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
171170 const newOwner = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" ;
172171
173172 expect ( await collectionContract . methods . owner ( ) . call ( ) ) . to . be . eq ( FAITH ) ;
173+ const estimatedGas = await collectionContract . methods . transferOwnership ( newOwner ) . estimateGas ( ) ;
174174 const tranferringResult = await collectionContract . methods
175175 . transferOwnership ( newOwner )
176- . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
176+ . send ( { from : FAITH , gas : estimatedGas } ) ;
177177 expect ( tranferringResult . status ) . to . be . eq ( true ) ;
178178 expect ( await collectionContract . methods . owner ( ) . call ( ) ) . to . be . eq ( newOwner ) ;
179179
@@ -198,10 +198,13 @@ describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
198198 expect ( tranferringResult . events . OwnershipTransferred . raw . data ) . to . be . eq ( "0x" ) ;
199199
200200 try {
201- await collectionContract . methods . transferOwnership ( FAITH ) . send ( { from : FAITH , gas : GAS_LIMIT } ) ;
201+ const estimatedGas = await collectionContract . methods . transferOwnership ( FAITH ) . estimateGas ( ) ;
202+ await collectionContract . methods . transferOwnership ( FAITH ) . send ( { from : FAITH , gas : estimatedGas } ) ;
202203 expect . fail ( "Expected error was not thrown" ) ; // Ensure an error is thrown
203204 } catch ( error ) {
204- expect ( await extractRevertReason ( context , error . receipt . transactionHash ) ) . to . eq ( "NoPermission" ) ;
205+ expect ( error . message ) . to . eq (
206+ "Returned error: VM Exception while processing transaction: revert NoPermission"
207+ ) ;
205208 }
206209 } ) ;
207210} ) ;
0 commit comments