Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip upload metadata] add skip rule #145

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/methods/vault/transactions/create/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import validateCreateVaultArgs from './validateCreateVaultArgs'

export const commonLogic = async (values: CreateVaultTransactionInput) => {
const {
type = VaultType.Default, vaultToken, capacity, keysManagerFee, isOwnMevEscrow = false, metadataIpfsHash,
type = VaultType.Default, vaultToken, capacity, keysManagerFee, isOwnMevEscrow = false, metadataIpfsHash = '',
contracts, userAddress, options,
} = values

Expand Down
7 changes: 1 addition & 6 deletions src/methods/vault/transactions/create/createVaultEncode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ const createVaultEncode = async (values: CreateVaultInput) => {
const { image, displayName, description, ...rest } = values
const { options } = rest

let metadataIpfsHash = ''

if (image || displayName || description) {
metadataIpfsHash = await uploadMetadata({ image, displayName, description, options })
}

const metadataIpfsHash = await uploadMetadata({ image, displayName, description, options })
const { vaultFactory, params } = await commonLogic({ metadataIpfsHash, ...rest })

return vaultFactory.createVault.populateTransaction(...params)
Expand Down
7 changes: 1 addition & 6 deletions src/methods/vault/transactions/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ const create: CreateVault = async (values) => {
const { image, displayName, description, ...rest } = values
const { provider, options, userAddress } = rest

let metadataIpfsHash = ''

if (image || displayName || description) {
metadataIpfsHash = await uploadMetadata({ image, displayName, description, options })
}

const metadataIpfsHash = await uploadMetadata({ image, displayName, description, options })
const { vaultFactory, params } = await commonLogic({ metadataIpfsHash, ...rest })

const signer = await provider.getSigner(userAddress)
Expand Down
2 changes: 1 addition & 1 deletion src/methods/vault/transactions/create/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type CreateVaultCommonInput = Omit<BaseInput, 'vaultAddress'> & {
export type CreateVaultInput = CreateVaultCommonInput & UploadMetadataInput

export type CreateVaultTransactionInput = CreateVaultCommonInput & {
metadataIpfsHash: string | null
metadataIpfsHash?: string
}

export interface CreateVault {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,31 @@ type Input = UploadMetadataInput & {
}

const uploadMetadata = async (input: Input) => {
const { image = '', displayName = '', description = '', options } = input
const skip = [
input.image,
input.displayName,
input.description,
]
.every((value) => typeof value === 'undefined')

if (image) {
validateArgs.image(image)
if (skip) {
return
}

const { image = '', displayName = '', description = '', options } = input

validateArgs.string({ image, displayName, description })

validateArgs.image(image)

validateArgs.maxLength({
displayName: { value: displayName, length: 30 },
description: { value: description, length: 1000 },
})

validateArgs.string({ image, displayName, description })
if (!image && !displayName && !description) {
return ''
}

try {
const data = await graphql.backend.vault.submitUploadMetadataMutation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { vaultMulticall } from '../../../../../contracts'


type SetMetadataParams = {
metadataIpfsHash: string | null
metadataIpfsHash: string
}

const getMetadataParams = (values: SetMetadataParams) => {
Expand Down
Loading