Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 0c66736

Browse files
committed
fix doc lint issues
1 parent 4c663e9 commit 0c66736

File tree

7 files changed

+67
-50
lines changed

7 files changed

+67
-50
lines changed

catalog/integration-tests/catalog-dtp.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('DTP', () => {
7777

7878
(async () => {
7979
const result = await publishNFT1155({
80-
account: publisher,
80+
userAccount: publisher,
8181
nftAttributes,
8282
password,
8383
cryptoConfig,

catalog/src/services/account.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,14 @@ export const useUserProfile = (
345345
const [addresses, setAddresses] = useState<string[]>([])
346346
const [reloadTrigger, setReloadTrigger] = useState<Date>()
347347

348-
const checkAuth = async () => {
348+
const checkAuth = async (userAccount: Account) => {
349349
let tokenObject = { token: '' }
350350
if (!account.isTokenValid()) {
351351
setIsTokenGenerated(false)
352352
setErrorMessage(
353353
'Your login is expired. Please first sign with your wallet before to continue',
354354
)
355-
tokenObject = await account.generateToken()
355+
tokenObject = await account.generateToken(userAccount)
356356
setIsTokenGenerated(Boolean(tokenObject.token))
357357
} else {
358358
tokenObject = fetchMarketplaceApiTokenFromLocalStorage()
@@ -387,7 +387,8 @@ export const useUserProfile = (
387387

388388
const submitUserProfile = async () => {
389389
try {
390-
await checkAuth()
390+
const userAccount = await sdk.accounts.getAccount(walletAddress)
391+
await checkAuth(userAccount)
391392

392393
if (!userProfile.nickname) {
393394
setInputError('Nickname is required')
@@ -428,6 +429,8 @@ export const useUserProfile = (
428429
return
429430
}
430431

432+
const userAccount = await sdk.accounts.getAccount(walletAddress)
433+
431434
setUserProfileLoadingStatus('loading')
432435

433436
const userProfileData = await sdk.services.profiles.findOneByAddress(walletAddress)
@@ -437,7 +440,7 @@ export const useUserProfile = (
437440
setNewAddress('')
438441
}
439442

440-
const tokenAuth = await checkAuth()
443+
const tokenAuth = await checkAuth(userAccount)
441444

442445
setAddresses([...userProfileData.addresses])
443446

@@ -457,7 +460,8 @@ export const useUserProfile = (
457460
setNewAddress(walletAddress)
458461
setUserProfileLoadingStatus('failed')
459462
} else if (error.message.includes('"statusCode":404')) {
460-
await account.generateToken()
463+
const userAccount = await sdk.accounts.getAccount(walletAddress)
464+
await account.generateToken(userAccount)
461465
setTimeout(async () => {
462466
try {
463467
const userProfileData = await sdk.services.profiles.findOneByAddress(walletAddress)

catalog/src/services/asset.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
2223
import {_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)

catalog/src/types/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ export interface AssetPublishProviderState {
928928
*
929929
* @param asset
930930
* @param asset.assetAttributes The attribute object discribing the asset (metadata, price, encryption method, etc...)
931-
* @param asset.account Account of the user
931+
* @param asset.userAccount Account of the user
932932
* @param asset.publishMetadata Allows to specify if the metadata should be stored in different backends
933933
* @param asset.txParams Optional transaction parameters
934934
* @param asset.password Password to encrypt metadata
@@ -938,15 +938,15 @@ export interface AssetPublishProviderState {
938938
*/
939939
publishAsset: ({
940940
assetAttributes,
941-
account,
941+
userAccount,
942942
publishMetadata,
943943
txParameters,
944944
password,
945945
cryptoConfig,
946946
onEvent,
947947
}: {
948948
assetAttributes: AssetAttributes
949-
account: Account
949+
userAccount: Account
950950
publishMetadata?: PublishMetadata
951951
txParameters?: TxParameters
952952
method?: EncryptionMethod
@@ -963,7 +963,7 @@ export interface AssetPublishProviderState {
963963
*
964964
* @param nft721
965965
* @param nft721.nftAttributes The attribute object discribing the asset (metadata, price, encryption method, etc...)
966-
* @param nft721.account Account of the user
966+
* @param nft721.userAccount Account of the user
967967
* @param nft721.nftAddress NFT721 contract address to load
968968
* @param nft721.publishMetadata Allows to specify if the metadata should be stored in different backends
969969
* @param nft721.txParams Optional transaction parameters
@@ -975,7 +975,7 @@ export interface AssetPublishProviderState {
975975
publishNFT721: ({
976976
nftAttributes,
977977
nftAddress,
978-
account,
978+
userAccount,
979979
publishMetadata,
980980
txParameters,
981981
password,
@@ -984,7 +984,7 @@ export interface AssetPublishProviderState {
984984
}: {
985985
nftAttributes: NFTAttributes
986986
nftAddress: string
987-
account: Account
987+
userAccount: Account
988988
publishMetadata?: PublishMetadata
989989
txParameters?: TxParameters
990990
method?: EncryptionMethod
@@ -1001,7 +1001,7 @@ export interface AssetPublishProviderState {
10011001
* This method will create a new digital asset associated to a ERC-1155 NFT contract.
10021002
*
10031003
* @param nft1155
1004-
* @param nft1155.account Account of the user
1004+
* @param nft1155.userAccount Account of the user
10051005
* @param nft1155.nftAttributes The attribute object discribing the asset (metadata, price, encryption method, etc...)
10061006
* @param nft1155.publishMetadata Allows to specify if the metadata should be stored in different backends
10071007
* @param nft1155.txParams Optional transaction parameters
@@ -1012,15 +1012,15 @@ export interface AssetPublishProviderState {
10121012
*/
10131013
publishNFT1155: ({
10141014
nftAttributes,
1015-
account,
1015+
userAccount,
10161016
publishMetadata,
10171017
txParameters,
10181018
password,
10191019
cryptoConfig,
10201020
onEvent,
10211021
}: {
10221022
nftAttributes: NFTAttributes
1023-
account: Account
1023+
userAccount: Account
10241024
publishMetadata?: PublishMetadata
10251025
txParameters?: TxParameters
10261026
method?: EncryptionMethod

0 commit comments

Comments
 (0)