@@ -17,8 +17,9 @@ import {
1717 ERCType ,
1818 CryptoConfig ,
1919 CreateProgressStep ,
20+ Account ,
2021} from '../types'
21- import { executeWithProgressEvent , getCurrentAccount } from '../utils'
22+ import { executeWithProgressEvent } from '../utils'
2223import { _getDTPInstance , _encryptFileMetadata } from '../utils/dtp'
2324
2425/**
@@ -167,6 +168,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
167168 * This will return the DDO created (including the unique identifier of the asset - aka DID).
168169 *
169170 * @param asset
171+ * @param asset.userAccount The user account
170172 * @param asset.assetAttributes The attribute object discribing the asset (metadata, price, encryption method, etc...)
171173 * @param asset.publishMetadata Allows to specify if the metadata should be stored in different backends
172174 * @param asset.txParams Optional transaction parameters
@@ -177,6 +179,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
177179 */
178180 const publishAsset = async ( {
179181 assetAttributes,
182+ userAccount,
180183 publishMetadata = PublishMetadata . OnlyMetadataAPI ,
181184 txParameters,
182185 password,
@@ -185,6 +188,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
185188 } :
186189 {
187190 assetAttributes : AssetAttributes ;
191+ userAccount : Account ;
188192 publishMetadata ?: PublishMetadata ;
189193 txParameters ?: TxParameters ,
190194 password ?: string ,
@@ -194,14 +198,12 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
194198 try {
195199 setIsProcessing ( true )
196200
197- const accountWallet = await getCurrentAccount ( sdk )
198-
199- if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== accountWallet . getId ( ) . toLowerCase ( ) ) {
201+ if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== userAccount . getId ( ) . toLowerCase ( ) ) {
200202 Logger . error (
201203 'Your login is expired or not valid'
202204 )
203205
204- await account . generateToken ( )
206+ await account . generateToken ( userAccount )
205207 }
206208
207209 if ( password ) {
@@ -212,7 +214,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
212214
213215 const ddo = await executeWithProgressEvent ( ( ) => sdk . assets . create (
214216 assetAttributes ,
215- accountWallet ,
217+ userAccount ,
216218 publishMetadata ,
217219 txParameters ,
218220 ) , onEvent )
@@ -239,6 +241,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
239241 * (given the `nftAddress` parameter)
240242 *
241243 * @param nft721
244+ * @param nft721.userAccount The user account
242245 * @param nft721.nftAttributes The attribute object discribing the asset (metadata, price, encryption method, etc...)
243246 * @param nft721.nftAddress NFT721 contract address to load
244247 * @param nft721.publishMetadata Allows to specify if the metadata should be stored in different backends
@@ -251,6 +254,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
251254 const publishNFT721 = async ( {
252255 nftAttributes,
253256 nftAddress,
257+ userAccount,
254258 publishMetadata = PublishMetadata . OnlyMetadataAPI ,
255259 txParameters,
256260 password,
@@ -260,6 +264,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
260264 {
261265 nftAttributes : NFTAttributes ;
262266 nftAddress : string ;
267+ userAccount : Account ;
263268 publishMetadata ?: PublishMetadata ;
264269 txParameters ?: TxParameters ,
265270 password ?: string ,
@@ -269,13 +274,11 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
269274 try {
270275 setIsProcessing ( true )
271276
272- const accountWallet = await getCurrentAccount ( sdk )
273-
274- if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== accountWallet . getId ( ) . toLowerCase ( ) ) {
277+ if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== userAccount . getId ( ) . toLowerCase ( ) ) {
275278 setErrorAssetMessage (
276279 'Your login is expired. Please first sign with your wallet and after try again'
277280 )
278- await account . generateToken ( )
281+ await account . generateToken ( userAccount )
279282 }
280283
281284 if ( password ) {
@@ -288,7 +291,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
288291
289292 const ddo = await executeWithProgressEvent ( ( ) => sdk . nfts721 . create (
290293 nftAttributes ,
291- accountWallet ,
294+ userAccount ,
292295 publishMetadata ,
293296 txParameters ,
294297 ) , onEvent )
@@ -316,6 +319,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
316319 * This method will create a new digital asset associated to a ERC-1155 NFT contract.
317320 *
318321 * @param nft1155
322+ * @param nft1155.userAccount The user account
319323 * @param nft1155.neverminedNodeAddress Node address to approve to handle the NFT
320324 * @param nft1155.metadata The metadata object describing the asset
321325 * @param nft1155.cap The maximum number of editions that can be minted. If `0` means there is no limit (uncapped)
@@ -333,6 +337,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
333337 */
334338 const publishNFT1155 = async ( {
335339 nftAttributes,
340+ userAccount,
336341 publishMetadata = PublishMetadata . OnlyMetadataAPI ,
337342 txParameters,
338343 password,
@@ -341,6 +346,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
341346 } :
342347 {
343348 nftAttributes : NFTAttributes ;
349+ userAccount : Account ;
344350 publishMetadata ?: PublishMetadata ;
345351 txParameters ?: TxParameters ,
346352 password ?: string ,
@@ -350,13 +356,11 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
350356 try {
351357 setIsProcessing ( true )
352358
353- const accountWallet = await getCurrentAccount ( sdk )
354-
355- if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== accountWallet . getId ( ) . toLowerCase ( ) ) {
359+ if ( ! account . isTokenValid ( ) || account . getAddressTokenSigner ( ) . toLowerCase ( ) !== userAccount . getId ( ) . toLowerCase ( ) ) {
356360 setErrorAssetMessage (
357361 'Your login is expired. Please first sign with your wallet and after try again'
358362 )
359- await account . generateToken ( )
363+ await account . generateToken ( userAccount )
360364 }
361365
362366 if ( ! config . neverminedNodeAddress ) {
@@ -372,7 +376,7 @@ export const AssetPublishProvider = ({ children }: { children: React.ReactElemen
372376
373377 const ddo = await executeWithProgressEvent ( ( ) => sdk . nfts1155 . create (
374378 nftAttributes ,
375- accountWallet ,
379+ userAccount ,
376380 publishMetadata ,
377381 txParameters
378382 ) , onEvent )
0 commit comments