diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a629f2d..b420e06 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,18 +12,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Setup Node.js uses: actions/setup-node@v2 with: node-version: '18' cache: 'npm' + - name: Install dependencies run: npm install + - name: Copy config.json run: | cp ./resources/js/config.json.example ./resources/js/config.json + - name: Build static project run: npm run prod-laravel + - name: Archive build artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a5f0f12 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,30 @@ +name: eslint +on: + push: + branches: + - master + pull_request: + +jobs: + tests: + name: Eslint & Prettier + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Run Pretty + run: npm run pretty:check + + - name: Run Eslint + run: npm run lint \ No newline at end of file diff --git a/resources/js/api/collection.ts b/resources/js/api/collection.ts index fa33dd1..8f88ae2 100644 --- a/resources/js/api/collection.ts +++ b/resources/js/api/collection.ts @@ -159,11 +159,12 @@ export class CollectionApi { return ApiService.sendPlatformRequest(data); } - static async trackCollection(collectionId: string) { + static async trackCollection(collectionId: string, hotSync: boolean = false) { const data = { query: mutations.TrackCollection, variables: { chainIds: [parseInt(collectionId)], + hotSync, }, }; diff --git a/resources/js/api/index.ts b/resources/js/api/index.ts index a1bd7a3..c15b185 100644 --- a/resources/js/api/index.ts +++ b/resources/js/api/index.ts @@ -27,6 +27,7 @@ export class ApiService { credentials = 'omit', mode, nest = true, + auth = true, }: { url: string; data?: Record; @@ -35,6 +36,7 @@ export class ApiService { credentials?: 'omit' | 'same-origin' | 'include'; mode?: 'cors' | 'no-cors' | 'same-origin' | 'navigate'; nest?: boolean; + auth?: boolean; }): Promise { let body: string | null = null; const fullUrl = url; @@ -44,10 +46,10 @@ export class ApiService { body = JSON.stringify(data); } - if (mode) { + if (auth) { if (!useAppStore().isMultiTenant) { headers.Authorization = useAppStore().authorization_token; - } else if (mode) { + } else { headers['X-CSRF-TOKEN'] = csrf; } } @@ -160,6 +162,7 @@ export class ApiService { method: HttpMethods.GET, credentials: undefined, mode: undefined, + auth: false, }); } diff --git a/resources/js/components/FormInput.vue b/resources/js/components/FormInput.vue index 7961816..26d4993 100644 --- a/resources/js/components/FormInput.vue +++ b/resources/js/components/FormInput.vue @@ -71,6 +71,7 @@ const props = withDefaults( type?: string; min?: number; modelValue?: number | string | null; + value?: number | string | null; disabled?: boolean; prefix?: string; name: string; @@ -109,10 +110,10 @@ const inputChange = (e: Event) => { const localModelValue = computed({ get() { - return props.modelValue; + return props.modelValue ?? props.value; }, set(value) { - if (localModelValue.value !== value) { + if (value && localModelValue.value !== value) { emit('update:modelValue', value); } }, diff --git a/resources/js/components/TrackCollectionModal.vue b/resources/js/components/TrackCollectionModal.vue index e31ab6f..7f3caa1 100644 --- a/resources/js/components/TrackCollectionModal.vue +++ b/resources/js/components/TrackCollectionModal.vue @@ -21,7 +21,7 @@
Cancel - Track + Track
@@ -31,24 +31,27 @@ import { DialogTitle } from '@headlessui/vue'; import Btn from '~/components/Btn.vue'; import Modal from '~/components/Modal.vue'; import FormInput from './FormInput.vue'; -import { onUnmounted, ref } from 'vue'; +import { onMounted, ref } from 'vue'; const props = defineProps<{ isOpen: boolean }>(); const emit = defineEmits(['closed', 'confirm']); const collectionId = ref(); +const loading = ref(false); const confirm = async () => { + loading.value = true; emit('confirm', collectionId.value); - closeModal(); }; const closeModal = () => { + collectionId.value = ''; emit('closed'); }; -onUnmounted(() => { +onMounted(() => { collectionId.value = ''; + loading.value = false; }); diff --git a/resources/js/components/pages/Collections.vue b/resources/js/components/pages/Collections.vue index 4e648f9..e29a38e 100644 --- a/resources/js/components/pages/Collections.vue +++ b/resources/js/components/pages/Collections.vue @@ -366,7 +366,7 @@ const fetchUri = async (uri) => { } return '-'; - } catch (e) { + } catch { return '-'; } }; @@ -427,7 +427,8 @@ const openTransactionSlide = async (transactionId: string) => { const trackCollection = async (collectionId: string) => { try { - await CollectionApi.trackCollection(collectionId); + const hotSync = !appStore.isMultiTenant; + await CollectionApi.trackCollection(collectionId, hotSync); await getCollections(); snackbar.success({ title: 'Tracking', @@ -435,10 +436,12 @@ const trackCollection = async (collectionId: string) => { save: false, }); } catch { - snackbar.info({ + snackbar.error({ title: 'Tracking', text: 'Tracking the collection failed', }); + } finally { + trackModal.value = false; } }; diff --git a/resources/js/components/pages/Tokens.vue b/resources/js/components/pages/Tokens.vue index 4f28ea1..508a827 100644 --- a/resources/js/components/pages/Tokens.vue +++ b/resources/js/components/pages/Tokens.vue @@ -98,7 +98,7 @@ " > {{ tokenNames[`${token.collection.collectionId}-${token.tokenId}`] }} diff --git a/resources/js/components/pages/create/CreateToken.vue b/resources/js/components/pages/create/CreateToken.vue index d55eee6..752ed2d 100644 --- a/resources/js/components/pages/create/CreateToken.vue +++ b/resources/js/components/pages/create/CreateToken.vue @@ -81,6 +81,13 @@ label="Description" description="The description of the token." /> +
+ +
+ + + +
appStore.collections); const isAdvanced = computed(() => mode.value === 'advanced'); +const totalInfuseAmountComputed = computed(() => { + return initialSupply.value * infuseAmount.value; +}); + const validation = yup.object({ imageUrl: stringNotRequiredSchema, name: stringRequiredSchema, description: stringNotRequiredSchema, + symbol: stringRequiredSchema, collectionId: collectionIdRequiredSchema, tokenId: stringRequiredSchema, recipient: addressRequiredSchema, @@ -491,10 +547,20 @@ const createToken = async () => { isCurrency: isCurrency.value, }, listingForbidden: listingForbidden.value, + ...(infuseEnj.value + ? { + infusion: totalInfuseAmountComputed.value, + anyoneCanInfuse: infuseAccess.value === 'Everyone', + } + : {}), attributes: [ ...simpleAttributes(), ...attributes.value.filter((a) => a.key !== '' && a.value !== ''), ], + metadata: { + name: name.value, + symbol: symbol.value, + }, }, idempotencyKey: idempotencyKey.value, skipValidation: skipValidation.value, diff --git a/resources/js/components/slideovers/token/MintTokenSlideover.vue b/resources/js/components/slideovers/token/MintTokenSlideover.vue index c15f0a2..c7aa4be 100644 --- a/resources/js/components/slideovers/token/MintTokenSlideover.vue +++ b/resources/js/components/slideovers/token/MintTokenSlideover.vue @@ -92,7 +92,6 @@ import { addressRequiredSchema, booleanNotRequiredSchema, collectionIdRequiredSchema, - numberNotRequiredSchema, numberRequiredSchema, stringNotRequiredSchema, stringRequiredSchema, @@ -130,7 +129,6 @@ const validation = yup.object({ tokenId: stringRequiredSchema, recipient: addressRequiredSchema, amount: numberRequiredSchema.typeError('Amount must be a number'), - unitPrice: numberNotRequiredSchema.min(0.01).typeError('Unit price must be a number'), idempotencyKey: stringNotRequiredSchema, skipValidation: booleanNotRequiredSchema, }); diff --git a/resources/js/graphql/mutation/TrackCollection.ts b/resources/js/graphql/mutation/TrackCollection.ts index a63f159..63c2dad 100644 --- a/resources/js/graphql/mutation/TrackCollection.ts +++ b/resources/js/graphql/mutation/TrackCollection.ts @@ -1,3 +1,3 @@ -export default `mutation addToTracked($type: ModelType! = COLLECTION, $chainIds:[BigInt!]!) { - AddToTracked(type: $type, chainIds: $chainIds, hotSync: false) +export default `mutation addToTracked($type: ModelType! = COLLECTION, $chainIds:[BigInt!]!, $hotSync: Boolean = false) { + AddToTracked(type: $type, chainIds: $chainIds, hotSync: $hotSync) }`;