From 61a346849e29e6ab8ccdf019c7cc23711e4bc506 Mon Sep 17 00:00:00 2001 From: Zouheir Layine Date: Thu, 26 Sep 2024 09:16:21 +0100 Subject: [PATCH] [PLA-1645] infuse token (#143) --- .github/workflows/deploy.yml | 5 ++ .github/workflows/lint.yml | 30 +++++++++ resources/js/api/index.ts | 7 +- resources/js/components/FormInput.vue | 5 +- resources/js/components/pages/Collections.vue | 2 +- resources/js/components/pages/Tokens.vue | 2 +- .../components/pages/create/CreateToken.vue | 66 +++++++++++++++++++ .../slideovers/token/MintTokenSlideover.vue | 2 - 8 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/lint.yml 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/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/pages/Collections.vue b/resources/js/components/pages/Collections.vue index 5d85456..e103a87 100644 --- a/resources/js/components/pages/Collections.vue +++ b/resources/js/components/pages/Collections.vue @@ -371,7 +371,7 @@ const fetchUri = async (uri) => { } return '-'; - } catch (e) { + } catch { return '-'; } }; 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, });