@@ -5,6 +5,7 @@ import { myLog } from '../utils/log_tools';
55import Web3 from 'web3' ;
66import { genExchangeData , sendRawTx } from './contract_api' ;
77import contracts from './ethereum/contracts' ;
8+ import { ApproveParam , ContractNFTMetaParam , DepositNFTParam , IsApproveParam } from '../defs/nft_defs' ;
89
910export enum NFTType {
1011 ERC1155 = 0 ,
@@ -45,13 +46,12 @@ export class NFTAPI extends BaseAPI {
4546 type === NFTType . ERC1155 ? contracts . Contracts . erc1155Abi : contracts . Contracts . erc721Abi ,
4647 contractAddress
4748 ) ;
48-
49- // new Contract(
50- // type === NFTType.ERC1155 ? erc1155Abi : erc721Abi,
51- // contractAddress
52- // );
5349 }
5450
51+ /**
52+ * getInfoForNFTTokens
53+ * @param nftDatas NftData[]
54+ */
5555 public async getInfoForNFTTokens ( { nftDatas} : { nftDatas : NftData [ ] } ) : Promise < { [ key : string ] : NFTTokenInfo } | undefined > {
5656 try {
5757 const reqParams : ReqParams = {
@@ -74,27 +74,33 @@ export class NFTAPI extends BaseAPI {
7474 }
7575 }
7676
77+ /**
78+ * getContractNFTMeta
79+ * @param web3
80+ * @param tokenAddress
81+ * @param _id
82+ * @param nftType
83+ */
7784 public async getContractNFTMeta ( {
7885 web3,
7986 tokenAddress,
8087 _id,
8188 nftType = NFTType . ERC1155 ,
82- } : { web3 : any , tokenAddress : string , _id : string , nftType ?: NFTType } ) {
89+ } : ContractNFTMetaParam ) {
8390 try {
8491 const result = await this . callContractMethod ( web3 , NFTMethod . uri , [ _id ] ,
8592 tokenAddress ,
8693 nftType )
8794 myLog ( tokenAddress , '_id' , _id , result ) ;
8895 return await ( fetch ( result . replace ( '{id}' , _id ) ) . then ( response => response . json ( ) ) )
89-
9096 } catch ( error ) {
9197 return undefined
9298 }
9399
94100 }
95101
96102 /**
97- *
103+ * approveNFT
98104 * @param web3
99105 * @param from The address that deposits the funds to the exchange
100106 * @param to The address deposits to
@@ -119,19 +125,7 @@ export class NFTAPI extends BaseAPI {
119125 chainId,
120126 nonce,
121127 sendByMetaMask = true
122- } : {
123- web3 : Web3 ,
124- from : string ,
125- depositAddress : string ,
126- tokenAddress : string ,
127- tokenId : string ,
128- nftType : NFTType ,
129- gasPrice : number ,
130- gasLimit : number ,
131- chainId : ChainId ,
132- nonce : number ,
133- sendByMetaMask ?: boolean
134- } ) {
128+ } : ApproveParam ) {
135129 let data : any ;
136130
137131 if ( nftType === NFTType . ERC1155 ) {
@@ -150,19 +144,21 @@ export class NFTAPI extends BaseAPI {
150144
151145 }
152146
147+ /**
148+ * isApprovedForAll
149+ * @param web3
150+ * @param from The address that deposits the funds to the exchange
151+ * @param exchangeAddress loopring exchange address
152+ * @param nftType NFTType
153+ * @param tokenAddress The address of NFT token
154+ */
153155 public async isApprovedForAll ( {
154156 web3,
155157 from,
156158 exchangeAddress,
157159 nftType = NFTType . ERC1155 ,
158160 tokenAddress,
159- } : {
160- web3 : Web3 ,
161- from : string ,
162- exchangeAddress : string ,
163- nftType : NFTType ,
164- tokenAddress : string
165- } // chainId: ChainId,
161+ } : IsApproveParam
166162 ) {
167163
168164 try {
@@ -176,6 +172,23 @@ export class NFTAPI extends BaseAPI {
176172 }
177173 }
178174
175+
176+ /**
177+ * @DepositParam an NFT to the specified account.
178+ * @param web3
179+ * @param from The address that deposits the funds to the exchange
180+ * @param to The account owner's address receiving the funds
181+ * @param nftType The type of NFT contract address (ERC721/ERC1155/...)
182+ * @param tokenAddress The address of NFT token
183+ * @param nftID The token type 'id`.
184+ * @param amount The amount of tokens to deposit.
185+ * @param nonce: number,
186+ * @param gasPrice: number,
187+ * @param gasLimit: number,
188+ * @param extraData Optional extra data used by the deposit contract.
189+ * @param chainId 0|5
190+ * @param sendByMetaMask boolean
191+ */
179192 public async depositNFT (
180193 {
181194 web3,
@@ -191,21 +204,7 @@ export class NFTAPI extends BaseAPI {
191204 nonce,
192205 extraData,
193206 sendByMetaMask = true
194- } : {
195- web3 : Web3 ,
196- from : string ,
197- exchangeAddress : string ,
198- nftType ?: NFTType ,
199- tokenAddress : string ,
200- nftID : string ,
201- amount : number ,
202- gasPrice : number ,
203- gasLimit : number ,
204- chainId ?: ChainId ,
205- nonce : number ,
206- extraData ?: any ,
207- sendByMetaMask ?: boolean
208- }
207+ } : DepositNFTParam
209208 ) {
210209 const data = genExchangeData ( NFTMethod . depositNFT , {
211210 from,
@@ -226,20 +225,4 @@ export class NFTAPI extends BaseAPI {
226225}
227226
228227
229- /**
230- * @description Deposits an NFT to the specified account.
231- * @param web3
232- * @param from The address that deposits the funds to the exchange
233- * @param to The account owner's address receiving the funds
234- * @param nftType The type of NFT contract address (ERC721/ERC1155/...)
235- * @param tokenAddress The address of the token
236- * @param nftID The token type 'id`.
237- * @param amount The amount of tokens to deposit.
238- * @param nonce: number,
239- * @param gasPrice: number,
240- * @param gasLimit: number,
241- * @param extraData Optional extra data used by the deposit contract.
242- * @param chainId 0|5
243- * @param sendByMetaMask boolean
244- */
245228
0 commit comments