From f8a0d8e4254a76d3a5f2a1d43d7fb55cbdf1f2d1 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:31:14 +0530 Subject: [PATCH 001/129] add: loading for syncstatus --- src/components/Collections/SyncStatus.svelte | 26 ++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/Collections/SyncStatus.svelte b/src/components/Collections/SyncStatus.svelte index 24dfd6f10..04f564e2b 100644 --- a/src/components/Collections/SyncStatus.svelte +++ b/src/components/Collections/SyncStatus.svelte @@ -250,7 +250,7 @@ Memberships just created are not yet published on the blockchain. Submit all transactions to start offering memberships.

-
+
@@ -265,7 +265,9 @@ {:then value} {:then value} - {:else}●{/if}{/await} {/each}
- {:else}●{/if}{/await}
+ {#await Promise.all([listOfoutOfSyncDescriptors, listOfoutOfSyncImages])} + + From aee96473709cf98d2570baaf094429eeaed208fd Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:32:48 +0530 Subject: [PATCH 002/129] lint --- src/components/Collections/SyncStatus.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Collections/SyncStatus.svelte b/src/components/Collections/SyncStatus.svelte index 04f564e2b..257634d9c 100644 --- a/src/components/Collections/SyncStatus.svelte +++ b/src/components/Collections/SyncStatus.svelte @@ -410,4 +410,3 @@ {/await}
- From 03334bcc5042bb9304ece7de2c009640068e8979 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:06:48 +0530 Subject: [PATCH 003/129] update: syncstate, abi --- .../Collections/CreateCollections.svelte | 6 +- src/components/Collections/SyncStatus.svelte | 51 +- src/components/Collections/types.ts | 4 +- src/plugins/collections/SyncModal.svelte | 56 +- src/plugins/collections/admin.astro | 10 +- .../assets/slot-limited-collection.svg | 22 + src/plugins/collections/index.ts | 25 +- src/plugins/collections/utils/mixSlotABI.ts | 749 ++++++++++++++++++ .../collections/utils/slotCollections.ts | 43 +- .../collections/utils/types/setImageArg.ts | 11 + 10 files changed, 950 insertions(+), 27 deletions(-) create mode 100644 src/plugins/collections/assets/slot-limited-collection.svg create mode 100644 src/plugins/collections/utils/mixSlotABI.ts diff --git a/src/components/Collections/CreateCollections.svelte b/src/components/Collections/CreateCollections.svelte index 76e5a291c..5e106fd0c 100644 --- a/src/components/Collections/CreateCollections.svelte +++ b/src/components/Collections/CreateCollections.svelte @@ -33,7 +33,7 @@ export let existingCollections: Collection[] = [] export let existingMemberships: Membership[] = [] export let collection: Collection - export let isTimeLimitedCollection: boolean = false + export let isTimeLimitedCollection: boolean | 'both' = false export let clubName: string | undefined = undefined export let isAdding: boolean = false export let useOnFinishCallback: boolean = false @@ -789,7 +789,7 @@ > - {#if isTimeLimitedCollection} + {#if isTimeLimitedCollection == true || isTimeLimitedCollection == 'both'} - {#if !isTimeLimitedCollection} + {#if isTimeLimitedCollection == false || isTimeLimitedCollection == 'both'}
{ diff --git a/src/plugins/collections/assets/slot-limited-collection.svg b/src/plugins/collections/assets/slot-limited-collection.svg new file mode 100644 index 000000000..0a72d6e52 --- /dev/null +++ b/src/plugins/collections/assets/slot-limited-collection.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/collections/index.ts b/src/plugins/collections/index.ts index bec4a91bc..5d863636e 100644 --- a/src/plugins/collections/index.ts +++ b/src/plugins/collections/index.ts @@ -41,7 +41,7 @@ export type Collection = { name: string imageSrc: string status: 'Draft' | 'Published' - isTimeLimitedCollection: boolean + isTimeLimitedCollection: boolean | 'both' endTime?: number description: string memberships: CollectionMembership[] @@ -214,6 +214,16 @@ export const getAdminPaths = (async ( memberships: [], } + const presetSlotCollection: Collection = { + id: 'preset-member-collection', + name: 'My First Quantity Limited Collection', + imageSrc: '', + description: 'This is a quantity-limited collection.', + isTimeLimitedCollection: 'both', + status: 'Draft', + memberships: [], + } + const existingMemberships = (existingMembershipsConfig?.options.find( (opt: ClubsPluginOption) => opt.key === 'memberships', @@ -275,6 +285,19 @@ export const getAdminPaths = (async ( name, }, }, + { + paths: ['collections', 'new', 'slot-limited-collection'], + component: AdminNew, + props: { + isTimeLimitedCollection: 'both', + preset: presetSlotCollection, + collections, + existingMemberships, + rpcUrl, + propertyAddress, + name, + }, + }, ] }) satisfies ClubsFunctionGetAdminPaths diff --git a/src/plugins/collections/utils/mixSlotABI.ts b/src/plugins/collections/utils/mixSlotABI.ts new file mode 100644 index 000000000..f46fb7964 --- /dev/null +++ b/src/plugins/collections/utils/mixSlotABI.ts @@ -0,0 +1,749 @@ +export const mixSlotABI = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + inputs: [ + { + internalType: 'address', + name: '_token', + type: 'address', + }, + ], + name: 'allowListToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'allowlistedTokens', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_token', + type: 'address', + }, + ], + name: 'denyListToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'property', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'price', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'description', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'dev', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_property', + type: 'address', + }, + { + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, + ], + name: 'getSlotsLeft', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_property', + type: 'address', + }, + { + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, + ], + name: 'getTimeLeft', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'property', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'price', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'image', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_contract', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'property', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'price', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'property', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'price', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, + ], + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'onBeforeMint', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + name: 'propertyImageClaimedSlots', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + name: 'propertyImages', + outputs: [ + { + internalType: 'string', + name: 'src', + type: 'string', + }, + { + internalType: 'string', + name: 'name', + type: 'string', + }, + { + internalType: 'string', + name: 'description', + type: 'string', + }, + { + components: [ + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint32', + name: 'members', + type: 'uint32', + }, + ], + internalType: 'struct SlotCollections.SlotType', + name: 'slot', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'requiredTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'requiredTokenFee', + type: 'uint256', + }, + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'address', + name: 'gateway', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_propertyAddress', + type: 'address', + }, + { + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, + ], + name: 'removeImage', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_dev', + type: 'address', + }, + ], + name: 'setDevToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_propertyAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'src', + type: 'string', + }, + { + internalType: 'string', + name: 'name', + type: 'string', + }, + { + internalType: 'string', + name: 'description', + type: 'string', + }, + { + components: [ + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint32', + name: 'members', + type: 'uint32', + }, + ], + internalType: 'struct SlotCollections.SlotType', + name: 'slot', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'requiredTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'requiredTokenFee', + type: 'uint256', + }, + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'address', + name: 'gateway', + type: 'address', + }, + ], + internalType: 'struct SlotCollections.Image[]', + name: '_images', + type: 'tuple[]', + }, + { + internalType: 'bytes32[]', + name: '_keys', + type: 'bytes32[]', + }, + ], + name: 'setImages', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_contract', + type: 'address', + }, + ], + name: 'setSwapAndStake', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'stakedAmountAtMinted', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'swapAndStake', + outputs: [ + { + internalType: 'contract ISwapAndStake', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 88d6cbfe3..ddf894458 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -10,11 +10,13 @@ import type { } from 'ethers' import { timeABI } from './timeABI' import { memberABI } from './memberABI' -import type { Image } from './types/setImageArg' +import { mixSlotABI } from './mixSlotABI' +import type { Image, MixImage } from './types/setImageArg' type AddressList = { timeSlot: string memberSlot: string + mixSlot: string } type Address = { @@ -28,6 +30,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, }, { @@ -35,6 +38,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, }, { @@ -42,6 +46,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, }, { @@ -49,6 +54,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, }, { @@ -56,6 +62,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, }, { @@ -63,6 +70,7 @@ export const address: Address[] = [ addressList: { timeSlot: '0xbE0AFf1B1AA447772e742CC23A96984399235427', memberSlot: '0x955AAd5D0DEde7C651f6f35d8024340EB89cF5a6', + mixSlot: '0x66E0400432A7A910f529694Dd4E871dEaf90B1C1', }, }, ] @@ -72,41 +80,42 @@ const defaultAddress: Address = { addressList: { timeSlot: '0x0000000000000000000000000000000000000000', memberSlot: '0x0000000000000000000000000000000000000000', + mixSlot: '0x0000000000000000000000000000000000000000', }, } export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'getSlotsLeft', - isTimeSlot: boolean, + isTimeSlot: boolean | "both", args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'propertyImages', - isTimeSlot: boolean, + isTimeSlot: boolean | "both", args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: 'setImages', - isTimeSlot: boolean, - args: [propertyAddress: string, images: Image[], keys: string[]], + isTimeSlot: boolean | "both", + args: [propertyAddress: string, images: Image[] | MixImage [], keys: string[]], ): Promise export async function callSlotCollections( provider: Signer, functionName: 'removeImage', - isTimeSlot: boolean, + isTimeSlot: boolean | "both", args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: string, - isTimeSlot: boolean, + isTimeSlot: boolean | "both", args: unknown[], ): Promise { const chainId = await ('getNetwork' in provider @@ -119,10 +128,26 @@ export async function callSlotCollections( const addressList = address.find((address) => address.chainId === chainId)?.addressList || defaultAddress.addressList + + let contractAddress, contractABI; + switch (isTimeSlot) { + case true: + contractAddress = addressList.timeSlot + contractABI = timeABI + break + case false: + contractAddress = addressList.memberSlot + contractABI = memberABI + break + case "both": + contractAddress = addressList.mixSlot + contractABI = mixSlotABI + break + } const contract = new ethers.Contract( - isTimeSlot ? addressList.timeSlot : addressList.memberSlot, - isTimeSlot ? timeABI : memberABI, + contractAddress, + contractABI, provider, ) diff --git a/src/plugins/collections/utils/types/setImageArg.ts b/src/plugins/collections/utils/types/setImageArg.ts index 03a174b91..3435cea54 100644 --- a/src/plugins/collections/utils/types/setImageArg.ts +++ b/src/plugins/collections/utils/types/setImageArg.ts @@ -9,3 +9,14 @@ export type Image = { readonly requiredTokenFee?: number | string | bigint readonly gateway?: string } + + +export type MixImage = { + readonly src?: string + readonly name?: string + readonly description?: string + readonly slots?: [string | number | bigint , string | number | bigint] + readonly requiredTokenAmount?: number | string | bigint + readonly requiredTokenFee?: number | string | bigint + readonly gateway?: string +} From 1c0f21ea72dbd528a47d8def6061c6bd987e9830 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:07:01 +0530 Subject: [PATCH 004/129] lint --- src/components/Collections/SyncStatus.svelte | 12 +- src/plugins/collections/SyncModal.svelte | 150 +++++++++--------- .../collections/utils/slotCollections.ts | 24 ++- .../collections/utils/types/setImageArg.ts | 3 +- 4 files changed, 92 insertions(+), 97 deletions(-) diff --git a/src/components/Collections/SyncStatus.svelte b/src/components/Collections/SyncStatus.svelte index f2b89d005..20a9649d4 100644 --- a/src/components/Collections/SyncStatus.svelte +++ b/src/components/Collections/SyncStatus.svelte @@ -69,14 +69,14 @@ let customDescriptorAddress switch (data.isTimeLimitedCollection) { case true: - customDescriptorAddress = customTimeDescriptorAddress - break + customDescriptorAddress = customTimeDescriptorAddress + break case false: - customDescriptorAddress = customMemberDescriptorAddress - break + customDescriptorAddress = customMemberDescriptorAddress + break case 'both': - customDescriptorAddress = customMixSlotDescriptorAddress - break + customDescriptorAddress = customMixSlotDescriptorAddress + break } const test = descriptor?.toLowerCase() === customDescriptorAddress?.toLowerCase() diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index 5f8e51c26..764eb8136 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -36,80 +36,81 @@ (collection) => collection.memberships.map((mem) => { const { decimals, address: token } = tokenInfo[mem.currency][chainId] - if(collection.isTimeLimitedCollection == true) { + if (collection.isTimeLimitedCollection == true) { return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: true, - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - deadline: collection.endTime ? BigInt(collection.endTime) : 0n, - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } - } - else if (collection.isTimeLimitedCollection == false ) { + payload: bytes32Hex(mem.payload), + source: mem, + isTimeLimitedCollection: true, + state: { + src: mem.imageSrc, + name: JSON.stringify(mem.name).slice(1, -1), + description: JSON.stringify(mem.description).slice(1, -1), + deadline: collection.endTime ? BigInt(collection.endTime) : 0n, + requiredTokenAmount: parseUnits(String(mem.price), decimals), + requiredTokenFee: mem.fee?.percentage + ? parseUnits( + new BigNumber(mem.price) + .times(mem.fee.percentage) + .dp(decimals, 1) + .toFixed(), + decimals, + ) + : 0n, + token: token, + gateway: mem.fee?.beneficiary ?? ZeroAddress, + }, + } + } else if (collection.isTimeLimitedCollection == false) { return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: false, - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - slots: mem.memberCount ? BigInt(mem.memberCount) : 0n, - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } - } - else { + payload: bytes32Hex(mem.payload), + source: mem, + isTimeLimitedCollection: false, + state: { + src: mem.imageSrc, + name: JSON.stringify(mem.name).slice(1, -1), + description: JSON.stringify(mem.description).slice(1, -1), + slots: mem.memberCount ? BigInt(mem.memberCount) : 0n, + requiredTokenAmount: parseUnits(String(mem.price), decimals), + requiredTokenFee: mem.fee?.percentage + ? parseUnits( + new BigNumber(mem.price) + .times(mem.fee.percentage) + .dp(decimals, 1) + .toFixed(), + decimals, + ) + : 0n, + token: token, + gateway: mem.fee?.beneficiary ?? ZeroAddress, + }, + } + } else { return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: "both", - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - slots: [collection.endTime ? BigInt(collection.endTime) : 0n, mem.memberCount ? BigInt(mem.memberCount) : 0n], - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } + payload: bytes32Hex(mem.payload), + source: mem, + isTimeLimitedCollection: 'both', + state: { + src: mem.imageSrc, + name: JSON.stringify(mem.name).slice(1, -1), + description: JSON.stringify(mem.description).slice(1, -1), + slots: [ + collection.endTime ? BigInt(collection.endTime) : 0n, + mem.memberCount ? BigInt(mem.memberCount) : 0n, + ], + requiredTokenAmount: parseUnits(String(mem.price), decimals), + requiredTokenFee: mem.fee?.percentage + ? parseUnits( + new BigNumber(mem.price) + .times(mem.fee.percentage) + .dp(decimals, 1) + .toFixed(), + decimals, + ) + : 0n, + token: token, + gateway: mem.fee?.beneficiary ?? ZeroAddress, + }, + } } }), ) @@ -122,7 +123,7 @@ provider: ContractRunner propertyAddress: string payload: string - isTimeLimitedCollection: boolean | "both" + isTimeLimitedCollection: boolean | 'both' }) => { return callSlotCollections( provider, @@ -147,10 +148,9 @@ ({ isTimeLimitedCollection }) => !isTimeLimitedCollection, ) const mixStates = states.filter( - ({ isTimeLimitedCollection }) => isTimeLimitedCollection == "both", + ({ isTimeLimitedCollection }) => isTimeLimitedCollection == 'both', ) - // Filter out states with empty payload const validTimeStates = timeStates.filter( ({ payload }) => payload.trim() !== '', @@ -182,7 +182,7 @@ } if (validMixStates.length) { - const res = await callSlotCollections(provider, 'setImages', "both", [ + const res = await callSlotCollections(provider, 'setImages', 'both', [ propertyAddress, validMixStates.map(({ state }) => state), validMixStates.map(({ payload }) => payload), diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index ddf894458..69d63c7b2 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -87,35 +87,35 @@ const defaultAddress: Address = { export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'getSlotsLeft', - isTimeSlot: boolean | "both", + isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'propertyImages', - isTimeSlot: boolean | "both", + isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: 'setImages', - isTimeSlot: boolean | "both", - args: [propertyAddress: string, images: Image[] | MixImage [], keys: string[]], + isTimeSlot: boolean | 'both', + args: [propertyAddress: string, images: Image[] | MixImage[], keys: string[]], ): Promise export async function callSlotCollections( provider: Signer, functionName: 'removeImage', - isTimeSlot: boolean | "both", + isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: string, - isTimeSlot: boolean | "both", + isTimeSlot: boolean | 'both', args: unknown[], ): Promise { const chainId = await ('getNetwork' in provider @@ -128,8 +128,8 @@ export async function callSlotCollections( const addressList = address.find((address) => address.chainId === chainId)?.addressList || defaultAddress.addressList - - let contractAddress, contractABI; + + let contractAddress, contractABI switch (isTimeSlot) { case true: @@ -140,16 +140,12 @@ export async function callSlotCollections( contractAddress = addressList.memberSlot contractABI = memberABI break - case "both": + case 'both': contractAddress = addressList.mixSlot contractABI = mixSlotABI break } - const contract = new ethers.Contract( - contractAddress, - contractABI, - provider, - ) + const contract = new ethers.Contract(contractAddress, contractABI, provider) const result: TransactionReceipt = await contract[functionName](...args) return result diff --git a/src/plugins/collections/utils/types/setImageArg.ts b/src/plugins/collections/utils/types/setImageArg.ts index 3435cea54..451b09f45 100644 --- a/src/plugins/collections/utils/types/setImageArg.ts +++ b/src/plugins/collections/utils/types/setImageArg.ts @@ -10,12 +10,11 @@ export type Image = { readonly gateway?: string } - export type MixImage = { readonly src?: string readonly name?: string readonly description?: string - readonly slots?: [string | number | bigint , string | number | bigint] + readonly slots?: [string | number | bigint, string | number | bigint] readonly requiredTokenAmount?: number | string | bigint readonly requiredTokenFee?: number | string | bigint readonly gateway?: string From d21f184173bd5c4634db190ccf215ad5f93e5712 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:15:36 +0530 Subject: [PATCH 005/129] add: new single descriptor --- .../Collections/CollectionCard.svelte | 14 -- .../Collections/CollectionView.svelte | 19 +-- src/components/Collections/SyncStatus.svelte | 110 +++------------- src/components/Collections/types.ts | 1 - src/plugins/collections/SyncModal.svelte | 120 ++---------------- src/plugins/collections/admin-id-id.astro | 1 - src/plugins/collections/admin-new.astro | 2 - src/plugins/collections/admin.astro | 26 +--- src/plugins/collections/index.ts | 53 +------- .../collections/utils/slotCollections.ts | 83 +++--------- .../collections/utils/types/setImageArg.ts | 14 +- 11 files changed, 59 insertions(+), 384 deletions(-) diff --git a/src/components/Collections/CollectionCard.svelte b/src/components/Collections/CollectionCard.svelte index a90017bc7..23683b4db 100644 --- a/src/components/Collections/CollectionCard.svelte +++ b/src/components/Collections/CollectionCard.svelte @@ -29,20 +29,6 @@
-

- {collection.isTimeLimitedCollection - ? 'Time Limited' - : 'Limited Amount'} -

-
-

diff --git a/src/components/Collections/CollectionView.svelte b/src/components/Collections/CollectionView.svelte index 849e85824..d2b6d5ee2 100644 --- a/src/components/Collections/CollectionView.svelte +++ b/src/components/Collections/CollectionView.svelte @@ -76,7 +76,7 @@ const getSlotsForMembership = async (membership: CollectionMembership) => { const provider = new JsonRpcProvider(rpcUrl) - let left = await callSlotCollections(provider, 'getSlotsLeft', false, [ + let left = await callSlotCollections(provider, 'getSlotsLeft', [ propertyAddress, bytes32Hex(membership.payload), ]) @@ -216,7 +216,7 @@

{/if} - {#if collection.isTimeLimitedCollection} + {#if collection.endTime !== undefined && collection.endTime > 0}
@@ -239,7 +239,6 @@ > {#each collection.memberships as mem, i} {#if validationResult === true} - {#if !collection.isTimeLimitedCollection} {#await getSlotsForMembership(mem) then slots} {/await} - {:else} - - {/if} {/if} {/each}
diff --git a/src/components/Collections/SyncStatus.svelte b/src/components/Collections/SyncStatus.svelte index 20a9649d4..12c030e55 100644 --- a/src/components/Collections/SyncStatus.svelte +++ b/src/components/Collections/SyncStatus.svelte @@ -14,7 +14,7 @@ } from '@devprotocol/util-ts' import { arrayify, clientsSTokens } from '@devprotocol/dev-kit' import PQueue from 'p-queue' - import { values } from 'ramda' + import { equals, values } from 'ramda' import type { ExpectedStatus, State } from './types' import Skeleton from '@components/Global/Skeleton.svelte' import type { CollectionMembership } from '@plugins/collections' @@ -23,7 +23,6 @@ source: CollectionMembership state: State payload: string - isTimeLimitedCollection: boolean | 'both' customDescriptor: { set: Promise } @@ -34,15 +33,12 @@ export let propertyAddress: string export let rpcUrl: string - export let customTimeDescriptorAddress: string | undefined - export let customMemberDescriptorAddress: string | undefined - export let customMixSlotDescriptorAddress: string | undefined + export let customdescriptor: string | undefined export let expected: ExpectedStatus[] export let stateFetcher: (opts: { provider: ContractRunner propertyAddress: string payload: string - isTimeLimitedCollection: boolean | 'both' }) => Promise> export let stateSetter: (opts: { provider: Signer @@ -66,18 +62,7 @@ cont.descriptorOfPropertyByPayload(propertyAddress, data.payload), ) - let customDescriptorAddress - switch (data.isTimeLimitedCollection) { - case true: - customDescriptorAddress = customTimeDescriptorAddress - break - case false: - customDescriptorAddress = customMemberDescriptorAddress - break - case 'both': - customDescriptorAddress = customMixSlotDescriptorAddress - break - } + let customDescriptorAddress = customdescriptor const test = descriptor?.toLowerCase() === customDescriptorAddress?.toLowerCase() console.log({ test, descriptor, customDescriptorAddress }) @@ -89,38 +74,37 @@ stateFetcher({ provider: prov, propertyAddress, - payload: data.payload, - isTimeLimitedCollection: data.isTimeLimitedCollection, + payload: data.payload }), ) const expectedValues = values(data.state) - const resultValues = arrayify(res ?? {}) - const test = expectedValues.every((v, i) => resultValues[i] === v) - + const resultValues = arrayify(res ?? {}).map((v) => + v instanceof Object ? values(v) : v, + ) + const test = equals(expectedValues, resultValues) console.log('checkImage', test, propertyAddress, data) + console.log('compare', [expectedValues, resultValues]) return test } const sourceStatuses: () => Status[] = () => expected.map( - ({ payload, source, state, isTimeLimitedCollection }): Status => ({ + ({ payload, source, state }): Status => ({ source, state, payload, - isTimeLimitedCollection, customDescriptor: { set: queue.add(() => checkCustomDescriptor({ payload, source, state, - isTimeLimitedCollection, }), ) as Promise, }, image: { set: queue.add(() => - checkImage({ payload, source, state, isTimeLimitedCollection }), + checkImage({ payload, source, state }), ) as Promise, }, }), @@ -164,84 +148,30 @@ const [l1, l2] = await clientsSTokens(provider) const sTokensManager = l1 ?? l2 const items = await listOfoutOfSyncDescriptors - const timeItems = items.filter( - ({ isTimeLimitedCollection }) => isTimeLimitedCollection, - ) - const memberItems = items.filter( - ({ isTimeLimitedCollection }) => !isTimeLimitedCollection, - ) - const mixSlotItems = items.filter( - ({ isTimeLimitedCollection }) => isTimeLimitedCollection === 'both', - ) // Filter out states with empty payload - const validTimeStates = timeItems.filter( - ({ payload }) => payload.trim() !== '', - ) - const validMemberStates = memberItems.filter( + const validStates = items.filter( ({ payload }) => payload.trim() !== '', ) - const validMixSlotStates = mixSlotItems.filter( - ({ payload }) => payload.trim() !== '', - ) - let resTime - let resMem - let resMixSlot - if (validTimeStates.length > 0) { - resTime = + let res + if (validStates.length > 0) { + res = (await whenDefinedAll( - [sTokensManager, customTimeDescriptorAddress], + [sTokensManager, customdescriptor], ([cont, descriptor]) => cont .setTokenURIDescriptor( propertyAddress, descriptor, - timeItems.map(({ payload }) => payload), + items.map(({ payload }) => payload), ) .catch((err) => new Error(err)), )) ?? new Error('Client error: try it again!') - const resultTime = await whenNotError(resTime, (res_) => + const resultTime = await whenNotError(res, (res_) => res_.wait().catch((err) => new Error(err)), ) syncStatusDescriptor = resultTime instanceof Error ? resultTime : false } - if (validMemberStates.length > 0) { - resMem = - (await whenDefinedAll( - [sTokensManager, customMemberDescriptorAddress], - ([cont, descriptor]) => - cont - .setTokenURIDescriptor( - propertyAddress, - descriptor, - memberItems.map(({ payload }) => payload), - ) - .catch((err) => new Error(err)), - )) ?? new Error('Client error: try it again!') - const resultMem = await whenNotError(resMem, (res_) => - res_.wait().catch((err) => new Error(err)), - ) - syncStatusDescriptor = resultMem instanceof Error ? resultMem : false - } - if (validMixSlotStates.length > 0) { - resMixSlot = - (await whenDefinedAll( - [sTokensManager, customMixSlotDescriptorAddress], - ([cont, descriptor]) => - cont - .setTokenURIDescriptor( - propertyAddress, - descriptor, - mixSlotItems.map(({ payload }) => payload), - ) - .catch((err) => new Error(err)), - )) ?? new Error('Client error: try it again!') - const resultMixSlot = await whenNotError(resMixSlot, (res_) => - res_.wait().catch((err) => new Error(err)), - ) - syncStatusDescriptor = - resultMixSlot instanceof Error ? resultMixSlot : false - } initStatuses() } @@ -252,19 +182,21 @@ payload: image.payload, state: image.state, source: image.source, - isTimeLimitedCollection: image.isTimeLimitedCollection, })) + console.log({ items }) const res = (await whenDefinedAll([items, signer], ([states, signer_]) => stateSetter({ provider: signer_, states, propertyAddress }).catch( (err) => new Error(err), ), )) ?? new Error('Client error: try it again!') + console.log({ res }) const result = await whenNotError(res, (res_) => Promise.all( res_.map((res__) => res__.wait().catch((err) => new Error(err))), ).catch((err) => new Error(err)), ) + console.log({ result }) syncStatusImages = result instanceof Error ? result : false initStatuses() } diff --git a/src/components/Collections/types.ts b/src/components/Collections/types.ts index f81d9c4e8..c265508b8 100644 --- a/src/components/Collections/types.ts +++ b/src/components/Collections/types.ts @@ -11,6 +11,5 @@ export type State = { export type ExpectedStatus = { payload: string source: CollectionMembership - isTimeLimitedCollection: boolean | 'both' state: State } diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index 764eb8136..55edbfee7 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -22,22 +22,15 @@ export let chainId: number export let rpcUrl: string - const customTimeDescriptorAddress = address.find( + const customdescriptor = address.find( ({ chainId: chainId_ }) => chainId_ === chainId, - )?.addressList.timeSlot - const customMemberDescriptorAddress = address.find( - ({ chainId: chainId_ }) => chainId_ === chainId, - )?.addressList.memberSlot - const customMixSlotDescriptorAddress = address.find( - ({ chainId: chainId_ }) => chainId_ === chainId, - )?.addressList.mixSlot + )?.addressList const expectedMemberships: ExpectedStatus[] = collections.flatMap( (collection) => collection.memberships.map((mem) => { const { decimals, address: token } = tokenInfo[mem.currency][chainId] - if (collection.isTimeLimitedCollection == true) { - return { + return { payload: bytes32Hex(mem.payload), source: mem, isTimeLimitedCollection: true, @@ -46,6 +39,7 @@ name: JSON.stringify(mem.name).slice(1, -1), description: JSON.stringify(mem.description).slice(1, -1), deadline: collection.endTime ? BigInt(collection.endTime) : 0n, + members: mem.memberCount ? BigInt(mem.memberCount) : 0n, requiredTokenAmount: parseUnits(String(mem.price), decimals), requiredTokenFee: mem.fee?.percentage ? parseUnits( @@ -60,75 +54,21 @@ gateway: mem.fee?.beneficiary ?? ZeroAddress, }, } - } else if (collection.isTimeLimitedCollection == false) { - return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: false, - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - slots: mem.memberCount ? BigInt(mem.memberCount) : 0n, - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } - } else { - return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: 'both', - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - slots: [ - collection.endTime ? BigInt(collection.endTime) : 0n, - mem.memberCount ? BigInt(mem.memberCount) : 0n, - ], - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } - } - }), + }, + ), ) const stateFetcher = async ({ provider, propertyAddress, payload, - isTimeLimitedCollection, }: { provider: ContractRunner propertyAddress: string payload: string - isTimeLimitedCollection: boolean | 'both' }) => { return callSlotCollections( provider, 'propertyImages', - isTimeLimitedCollection, [propertyAddress, payload], ) } @@ -141,51 +81,17 @@ propertyAddress: string states: ExpectedStatus[] }) => { - const timeStates = states.filter( - ({ isTimeLimitedCollection }) => isTimeLimitedCollection, - ) - const memberStates = states.filter( - ({ isTimeLimitedCollection }) => !isTimeLimitedCollection, - ) - const mixStates = states.filter( - ({ isTimeLimitedCollection }) => isTimeLimitedCollection == 'both', - ) - // Filter out states with empty payload - const validTimeStates = timeStates.filter( - ({ payload }) => payload.trim() !== '', - ) - const validMemberStates = memberStates.filter( - ({ payload }) => payload.trim() !== '', - ) - const validMixStates = mixStates.filter( + const validStates = states.filter( ({ payload }) => payload.trim() !== '', ) const results: TransactionResponse[] = [] - if (validTimeStates.length) { - const res = await callSlotCollections(provider, 'setImages', true, [ - propertyAddress, - validTimeStates.map(({ state }) => state), - validTimeStates.map(({ payload }) => payload), - ]) - results.push(res) - } - - if (validMemberStates.length) { - const res = await callSlotCollections(provider, 'setImages', false, [ - propertyAddress, - validMemberStates.map(({ state }) => state), - validMemberStates.map(({ payload }) => payload), - ]) - results.push(res) - } - - if (validMixStates.length) { - const res = await callSlotCollections(provider, 'setImages', 'both', [ + if (validStates.length) { + const res = await callSlotCollections(provider, 'setImages', [ propertyAddress, - validMixStates.map(({ state }) => state), - validMixStates.map(({ payload }) => payload), + validStates.map(({ state }) => state), + validStates.map(({ payload }) => payload), ]) results.push(res) } @@ -194,9 +100,7 @@ @@ -22,25 +20,11 @@ const baseRedirectionUrl = '/admin/collections/new' { diff --git a/src/plugins/collections/index.ts b/src/plugins/collections/index.ts index 5d863636e..b995db26c 100644 --- a/src/plugins/collections/index.ts +++ b/src/plugins/collections/index.ts @@ -41,7 +41,6 @@ export type Collection = { name: string imageSrc: string status: 'Draft' | 'Published' - isTimeLimitedCollection: boolean | 'both' endTime?: number description: string memberships: CollectionMembership[] @@ -193,37 +192,16 @@ export const getAdminPaths = (async ( 'devprotocol:clubs:collections', ) - const presetTimeCollection: Collection = { + const presetCollection: Collection = { id: 'preset-time-collection', name: 'My First Time Limited Collection', imageSrc: '', description: 'This is a time-limited collection.', - isTimeLimitedCollection: true, status: 'Draft', endTime: 0, memberships: [], } - const presetMemberCollection: Collection = { - id: 'preset-member-collection', - name: 'My First Quantity Limited Collection', - imageSrc: '', - description: 'This is a quantity-limited collection.', - isTimeLimitedCollection: false, - status: 'Draft', - memberships: [], - } - - const presetSlotCollection: Collection = { - id: 'preset-member-collection', - name: 'My First Quantity Limited Collection', - imageSrc: '', - description: 'This is a quantity-limited collection.', - isTimeLimitedCollection: 'both', - status: 'Draft', - memberships: [], - } - const existingMemberships = (existingMembershipsConfig?.options.find( (opt: ClubsPluginOption) => opt.key === 'memberships', @@ -263,34 +241,7 @@ export const getAdminPaths = (async ( paths: ['collections', 'new'], component: AdminNew, props: { - isTimeLimitedCollection: false, - preset: presetMemberCollection, - collections, - existingMemberships, - rpcUrl, - propertyAddress, - name, - }, - }, - { - paths: ['collections', 'new', 'time-limited-collection'], - component: AdminNew, - props: { - isTimeLimitedCollection: true, - preset: presetTimeCollection, - collections, - existingMemberships, - rpcUrl, - propertyAddress, - name, - }, - }, - { - paths: ['collections', 'new', 'slot-limited-collection'], - component: AdminNew, - props: { - isTimeLimitedCollection: 'both', - preset: presetSlotCollection, + preset: presetCollection, collections, existingMemberships, rpcUrl, diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 69d63c7b2..8f75d536f 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -8,114 +8,73 @@ import type { Signer, Provider, } from 'ethers' -import { timeABI } from './timeABI' -import { memberABI } from './memberABI' import { mixSlotABI } from './mixSlotABI' -import type { Image, MixImage } from './types/setImageArg' - -type AddressList = { - timeSlot: string - memberSlot: string - mixSlot: string -} +import type { Image } from './types/setImageArg' type Address = { chainId: number - addressList: AddressList + addressList: string } export const address: Address[] = [ { chainId: 1, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', }, { chainId: 4, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', }, { chainId: 42161, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', }, { chainId: 421611, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', }, { chainId: 137, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', }, { chainId: 80001, - addressList: { - timeSlot: '0xbE0AFf1B1AA447772e742CC23A96984399235427', - memberSlot: '0x955AAd5D0DEde7C651f6f35d8024340EB89cF5a6', - mixSlot: '0x66E0400432A7A910f529694Dd4E871dEaf90B1C1', - }, + addressList: '0x40be0Bc51523E6eF9b1d7F98B8545859efC708c1', }, ] const defaultAddress: Address = { chainId: 137, - addressList: { - timeSlot: '0x0000000000000000000000000000000000000000', - memberSlot: '0x0000000000000000000000000000000000000000', - mixSlot: '0x0000000000000000000000000000000000000000', - }, + addressList: '0x0000000000000000000000000000000000000000', } export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'getSlotsLeft', - isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: BrowserProvider | ContractRunner, functionName: 'propertyImages', - isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: 'setImages', - isTimeSlot: boolean | 'both', - args: [propertyAddress: string, images: Image[] | MixImage[], keys: string[]], + args: [propertyAddress: string, images: Image[], keys: string[]], ): Promise export async function callSlotCollections( provider: Signer, functionName: 'removeImage', - isTimeSlot: boolean | 'both', args: [propertyAddress: string, key: string], ): Promise export async function callSlotCollections( provider: Signer | ContractRunner | BrowserProvider, functionName: string, - isTimeSlot: boolean | 'both', args: unknown[], ): Promise { const chainId = await ('getNetwork' in provider @@ -129,23 +88,11 @@ export async function callSlotCollections( address.find((address) => address.chainId === chainId)?.addressList || defaultAddress.addressList - let contractAddress, contractABI - - switch (isTimeSlot) { - case true: - contractAddress = addressList.timeSlot - contractABI = timeABI - break - case false: - contractAddress = addressList.memberSlot - contractABI = memberABI - break - case 'both': - contractAddress = addressList.mixSlot - contractABI = mixSlotABI - break - } - const contract = new ethers.Contract(contractAddress, contractABI, provider) + const contract = new ethers.Contract( + addressList, + mixSlotABI, + provider, + ) const result: TransactionReceipt = await contract[functionName](...args) return result diff --git a/src/plugins/collections/utils/types/setImageArg.ts b/src/plugins/collections/utils/types/setImageArg.ts index 451b09f45..4cf2325af 100644 --- a/src/plugins/collections/utils/types/setImageArg.ts +++ b/src/plugins/collections/utils/types/setImageArg.ts @@ -3,18 +3,8 @@ export type Image = { readonly src?: string readonly name?: string readonly description?: string - readonly deadline?: number | string - readonly slots?: number | string - readonly requiredTokenAmount?: number | string | bigint - readonly requiredTokenFee?: number | string | bigint - readonly gateway?: string -} - -export type MixImage = { - readonly src?: string - readonly name?: string - readonly description?: string - readonly slots?: [string | number | bigint, string | number | bigint] + readonly deadline?: number | string | bigint + readonly members?: number | string | bigint readonly requiredTokenAmount?: number | string | bigint readonly requiredTokenFee?: number | string | bigint readonly gateway?: string From 8e0d78962108adf711c4d3d1a49f685436bfcedf Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:15:48 +0530 Subject: [PATCH 006/129] lint --- .../Collections/CollectionView.svelte | 28 ++++----- src/components/Collections/SyncStatus.svelte | 6 +- src/plugins/collections/SyncModal.svelte | 62 +++++++++---------- .../collections/utils/slotCollections.ts | 6 +- 4 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/components/Collections/CollectionView.svelte b/src/components/Collections/CollectionView.svelte index d2b6d5ee2..8409d0372 100644 --- a/src/components/Collections/CollectionView.svelte +++ b/src/components/Collections/CollectionView.svelte @@ -239,20 +239,20 @@ > {#each collection.memberships as mem, i} {#if validationResult === true} - {#await getSlotsForMembership(mem) then slots} - - {/await} + {#await getSlotsForMembership(mem) then slots} + + {/await} {/if} {/each}
diff --git a/src/components/Collections/SyncStatus.svelte b/src/components/Collections/SyncStatus.svelte index 12c030e55..4cf70fe7d 100644 --- a/src/components/Collections/SyncStatus.svelte +++ b/src/components/Collections/SyncStatus.svelte @@ -74,7 +74,7 @@ stateFetcher({ provider: prov, propertyAddress, - payload: data.payload + payload: data.payload, }), ) const expectedValues = values(data.state) @@ -150,9 +150,7 @@ const items = await listOfoutOfSyncDescriptors // Filter out states with empty payload - const validStates = items.filter( - ({ payload }) => payload.trim() !== '', - ) + const validStates = items.filter(({ payload }) => payload.trim() !== '') let res if (validStates.length > 0) { res = diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index 55edbfee7..94f9b9144 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -31,31 +31,30 @@ collection.memberships.map((mem) => { const { decimals, address: token } = tokenInfo[mem.currency][chainId] return { - payload: bytes32Hex(mem.payload), - source: mem, - isTimeLimitedCollection: true, - state: { - src: mem.imageSrc, - name: JSON.stringify(mem.name).slice(1, -1), - description: JSON.stringify(mem.description).slice(1, -1), - deadline: collection.endTime ? BigInt(collection.endTime) : 0n, - members: mem.memberCount ? BigInt(mem.memberCount) : 0n, - requiredTokenAmount: parseUnits(String(mem.price), decimals), - requiredTokenFee: mem.fee?.percentage - ? parseUnits( - new BigNumber(mem.price) - .times(mem.fee.percentage) - .dp(decimals, 1) - .toFixed(), - decimals, - ) - : 0n, - token: token, - gateway: mem.fee?.beneficiary ?? ZeroAddress, - }, - } - }, - ), + payload: bytes32Hex(mem.payload), + source: mem, + isTimeLimitedCollection: true, + state: { + src: mem.imageSrc, + name: JSON.stringify(mem.name).slice(1, -1), + description: JSON.stringify(mem.description).slice(1, -1), + deadline: collection.endTime ? BigInt(collection.endTime) : 0n, + members: mem.memberCount ? BigInt(mem.memberCount) : 0n, + requiredTokenAmount: parseUnits(String(mem.price), decimals), + requiredTokenFee: mem.fee?.percentage + ? parseUnits( + new BigNumber(mem.price) + .times(mem.fee.percentage) + .dp(decimals, 1) + .toFixed(), + decimals, + ) + : 0n, + token: token, + gateway: mem.fee?.beneficiary ?? ZeroAddress, + }, + } + }), ) const stateFetcher = async ({ provider, @@ -66,11 +65,10 @@ propertyAddress: string payload: string }) => { - return callSlotCollections( - provider, - 'propertyImages', - [propertyAddress, payload], - ) + return callSlotCollections(provider, 'propertyImages', [ + propertyAddress, + payload, + ]) } const stateSetter = async ({ provider, @@ -82,9 +80,7 @@ states: ExpectedStatus[] }) => { // Filter out states with empty payload - const validStates = states.filter( - ({ payload }) => payload.trim() !== '', - ) + const validStates = states.filter(({ payload }) => payload.trim() !== '') const results: TransactionResponse[] = [] if (validStates.length) { diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 8f75d536f..3c70e653f 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -88,11 +88,7 @@ export async function callSlotCollections( address.find((address) => address.chainId === chainId)?.addressList || defaultAddress.addressList - const contract = new ethers.Contract( - addressList, - mixSlotABI, - provider, - ) + const contract = new ethers.Contract(addressList, mixSlotABI, provider) const result: TransactionReceipt = await contract[functionName](...args) return result From 184f38b628a3841590c7791cf0b61eada6a8ab77 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 7 Dec 2023 08:03:59 +0530 Subject: [PATCH 007/129] Refactor image configuration in SyncModal and example.ts --- src/plugins/collections/SyncModal.svelte | 2 +- src/plugins/collections/utils/example.ts | 26 ++++--------------- .../collections/utils/slotCollections.ts | 20 +++++++------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index 94f9b9144..f24731e76 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -24,7 +24,7 @@ const customdescriptor = address.find( ({ chainId: chainId_ }) => chainId_ === chainId, - )?.addressList + )?.address const expectedMemberships: ExpectedStatus[] = collections.flatMap( (collection) => diff --git a/src/plugins/collections/utils/example.ts b/src/plugins/collections/utils/example.ts index 33931eeec..0bbaebfc5 100644 --- a/src/plugins/collections/utils/example.ts +++ b/src/plugins/collections/utils/example.ts @@ -2,42 +2,26 @@ import { callSlotCollections } from './slotCollections' import type { ethers } from 'ethers' import type { Image } from './types/setImageArg' -const TimeImages: Image[] = [ +const Images: Image[] = [ { // const { imageSrc, requiredETHAmount, requiredETHFee, gateway } = config src: 'https://example.com', name: 'example', description: 'example', deadline: 1692587652, + members: 100, requiredTokenAmount: 0, requiredTokenFee: 0, gateway: '0x0000000000000000000000000000000000000000', }, ] -const MemberImages: Image[] = [ - { - // const { imageSrc, requiredETHAmount, requiredETHFee, gateway } = config - src: 'https://example.com', - name: 'example', - description: 'example', - slots: 1, - requiredTokenAmount: 0, - requiredTokenFee: 0, - gateway: '0x0000000000000000000000000000000000000000', - }, -] + const keys: string[] = ['0x000'] export const example = async (provider: ethers.Signer) => { - const setTimeImage = await callSlotCollections(provider, 'setImages', true, [ + const setImage = await callSlotCollections(provider, 'setImages', [ '0x0000000000000000000000000000000000000000', - TimeImages, + Images, keys, ]) - const setMemberImage = await callSlotCollections( - provider, - 'setImages', - false, - ['0x0000000000000000000000000000000000000000', MemberImages, keys], - ) } diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 3c70e653f..8c0a13990 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -13,39 +13,39 @@ import type { Image } from './types/setImageArg' type Address = { chainId: number - addressList: string + address: string } export const address: Address[] = [ { chainId: 1, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', }, { chainId: 4, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', }, { chainId: 42161, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', }, { chainId: 421611, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', }, { chainId: 137, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', }, { chainId: 80001, - addressList: '0x40be0Bc51523E6eF9b1d7F98B8545859efC708c1', + address: '0x40be0Bc51523E6eF9b1d7F98B8545859efC708c1', }, ] const defaultAddress: Address = { chainId: 137, - addressList: '0x0000000000000000000000000000000000000000', + address: '0x0000000000000000000000000000000000000000', } export async function callSlotCollections( @@ -85,8 +85,8 @@ export async function callSlotCollections( }) const addressList = - address.find((address) => address.chainId === chainId)?.addressList || - defaultAddress.addressList + address.find((address) => address.chainId === chainId)?.address || + defaultAddress.address const contract = new ethers.Contract(addressList, mixSlotABI, provider) From 66a20b00124ead1b65bf9df1599bbcc921457c92 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:14:12 +0530 Subject: [PATCH 008/129] wip: working state --- .../Collections/CreateCollections.svelte | 5 - src/plugins/collections/SyncModal.svelte | 23 +- src/plugins/collections/index.ts | 4 +- src/plugins/collections/utils/mixSlotABI.ts | 986 +++++++++--------- .../collections/utils/slotCollections.ts | 3 +- 5 files changed, 509 insertions(+), 512 deletions(-) diff --git a/src/components/Collections/CreateCollections.svelte b/src/components/Collections/CreateCollections.svelte index 5e106fd0c..39e4d559c 100644 --- a/src/components/Collections/CreateCollections.svelte +++ b/src/components/Collections/CreateCollections.svelte @@ -33,7 +33,6 @@ export let existingCollections: Collection[] = [] export let existingMemberships: Membership[] = [] export let collection: Collection - export let isTimeLimitedCollection: boolean | 'both' = false export let clubName: string | undefined = undefined export let isAdding: boolean = false export let useOnFinishCallback: boolean = false @@ -789,7 +788,6 @@ > - {#if isTimeLimitedCollection == true || isTimeLimitedCollection == 'both'} - {/if} - {#if isTimeLimitedCollection == false || isTimeLimitedCollection == 'both'} - {/if}
diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index f24731e76..28c481c35 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -33,7 +33,6 @@ return { payload: bytes32Hex(mem.payload), source: mem, - isTimeLimitedCollection: true, state: { src: mem.imageSrc, name: JSON.stringify(mem.name).slice(1, -1), @@ -81,17 +80,33 @@ }) => { // Filter out states with empty payload const validStates = states.filter(({ payload }) => payload.trim() !== '') + console.log({validStates}) const results: TransactionResponse[] = [] if (validStates.length) { + try { + const args = [ + propertyAddress, + validStates.map(({ state }) => state), + validStates.map(({ payload }) => payload), + ] + console.log({args}) const res = await callSlotCollections(provider, 'setImages', [ propertyAddress, validStates.map(({ state }) => state), validStates.map(({ payload }) => payload), - ]) - results.push(res) + ]); + // const res2 = await callSlotCollections(provider, 'propertyImages', [ + // propertyAddress, + // "0x4b7f37427bb4f845726fcccf7e25390b25cf9dbfc82846d73dcc1688f93d3e4d", + // ]); + // console.log({res2}) + results.push(res); + } catch (error) { + console.log('Error in callSlotCollections:', error); } - return results + } + return results; } diff --git a/src/plugins/collections/index.ts b/src/plugins/collections/index.ts index b995db26c..c9cceb378 100644 --- a/src/plugins/collections/index.ts +++ b/src/plugins/collections/index.ts @@ -194,9 +194,9 @@ export const getAdminPaths = (async ( const presetCollection: Collection = { id: 'preset-time-collection', - name: 'My First Time Limited Collection', + name: 'My First Slot Collection', imageSrc: '', - description: 'This is a time-limited collection.', + description: 'This is a slot collection.', status: 'Draft', endTime: 0, memberships: [], diff --git a/src/plugins/collections/utils/mixSlotABI.ts b/src/plugins/collections/utils/mixSlotABI.ts index f46fb7964..ffcb4189b 100644 --- a/src/plugins/collections/utils/mixSlotABI.ts +++ b/src/plugins/collections/utils/mixSlotABI.ts @@ -1,749 +1,735 @@ -export const mixSlotABI = [ +export const mixSlotABI = [ { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: 'uint8', - name: 'version', - type: 'uint8', - }, + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } ], - name: 'Initialized', - type: 'event', + "name": "Initialized", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: 'address', - name: 'previousOwner', - type: 'address', + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" }, { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], - name: 'OwnershipTransferred', - type: 'event', + "name": "OwnershipTransferred", + "type": "event" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_token', - type: 'address', - }, + "internalType": "address", + "name": "_token", + "type": "address" + } ], - name: 'allowListToken', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "allowListToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '', - type: 'address', - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - name: 'allowlistedTokens', - outputs: [ + "name": "allowlistedTokens", + "outputs": [ { - internalType: 'bool', - name: '', - type: 'bool', - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_token', - type: 'address', - }, + "internalType": "address", + "name": "_token", + "type": "address" + } ], - name: 'denyListToken', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "denyListToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'uint256', - name: 'id', - type: 'uint256', + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - components: [ + "components": [ { - internalType: 'address', - name: 'property', - type: 'address', + "internalType": "address", + "name": "property", + "type": "address" }, { - internalType: 'uint256', - name: 'amount', - type: 'uint256', + "internalType": "uint256", + "name": "amount", + "type": "uint256" }, { - internalType: 'uint256', - name: 'price', - type: 'uint256', + "internalType": "uint256", + "name": "price", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'pendingReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "pendingReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.StakingPositions', - name: '_positions', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.StakingPositions", + "name": "_positions", + "type": "tuple" }, { - components: [ + "components": [ { - internalType: 'uint256', - name: 'entireReward', - type: 'uint256', + "internalType": "uint256", + "name": "entireReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'withdrawableReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "withdrawableReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.Rewards', - name: '', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.Rewards", + "name": "", + "type": "tuple" }, { - internalType: 'bytes32', - name: 'key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } ], - name: 'description', - outputs: [ + "name": "description", + "outputs": [ { - internalType: 'string', - name: '', - type: 'string', - }, + "internalType": "string", + "name": "", + "type": "string" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: 'dev', - outputs: [ + "inputs": [], + "name": "dev", + "outputs": [ { - internalType: 'address', - name: '', - type: 'address', - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_property', - type: 'address', + "internalType": "address", + "name": "_property", + "type": "address" }, { - internalType: 'bytes32', - name: '_key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + } ], - name: 'getSlotsLeft', - outputs: [ + "name": "getSlotsLeft", + "outputs": [ { - internalType: 'uint256', - name: '', - type: 'uint256', - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_property', - type: 'address', + "internalType": "address", + "name": "_property", + "type": "address" }, { - internalType: 'bytes32', - name: '_key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + } ], - name: 'getTimeLeft', - outputs: [ + "name": "getTimeLeft", + "outputs": [ { - internalType: 'uint256', - name: '', - type: 'uint256', - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'uint256', - name: 'id', - type: 'uint256', + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - components: [ + "components": [ { - internalType: 'address', - name: 'property', - type: 'address', + "internalType": "address", + "name": "property", + "type": "address" }, { - internalType: 'uint256', - name: 'amount', - type: 'uint256', + "internalType": "uint256", + "name": "amount", + "type": "uint256" }, { - internalType: 'uint256', - name: 'price', - type: 'uint256', + "internalType": "uint256", + "name": "price", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'pendingReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "pendingReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.StakingPositions', - name: '_positions', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.StakingPositions", + "name": "_positions", + "type": "tuple" }, { - components: [ + "components": [ { - internalType: 'uint256', - name: 'entireReward', - type: 'uint256', + "internalType": "uint256", + "name": "entireReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'withdrawableReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "withdrawableReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.Rewards', - name: '', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.Rewards", + "name": "", + "type": "tuple" }, { - internalType: 'bytes32', - name: 'key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } ], - name: 'image', - outputs: [ + "name": "image", + "outputs": [ { - internalType: 'string', - name: '', - type: 'string', - }, + "internalType": "string", + "name": "", + "type": "string" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_contract', - type: 'address', - }, + "internalType": "address", + "name": "_contract", + "type": "address" + } ], - name: 'initialize', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'uint256', - name: 'id', - type: 'uint256', + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - components: [ + "components": [ { - internalType: 'address', - name: 'property', - type: 'address', + "internalType": "address", + "name": "property", + "type": "address" }, { - internalType: 'uint256', - name: 'amount', - type: 'uint256', + "internalType": "uint256", + "name": "amount", + "type": "uint256" }, { - internalType: 'uint256', - name: 'price', - type: 'uint256', + "internalType": "uint256", + "name": "price", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'pendingReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "pendingReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.StakingPositions', - name: '_positions', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.StakingPositions", + "name": "_positions", + "type": "tuple" }, { - components: [ + "components": [ { - internalType: 'uint256', - name: 'entireReward', - type: 'uint256', + "internalType": "uint256", + "name": "entireReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'withdrawableReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "withdrawableReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.Rewards', - name: '', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.Rewards", + "name": "", + "type": "tuple" }, { - internalType: 'bytes32', - name: 'key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } ], - name: 'name', - outputs: [ + "name": "name", + "outputs": [ { - internalType: 'string', - name: '', - type: 'string', - }, + "internalType": "string", + "name": "", + "type": "string" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'uint256', - name: 'id', - type: 'uint256', + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - components: [ + "components": [ { - internalType: 'address', - name: 'property', - type: 'address', + "internalType": "address", + "name": "property", + "type": "address" }, { - internalType: 'uint256', - name: 'amount', - type: 'uint256', + "internalType": "uint256", + "name": "amount", + "type": "uint256" }, { - internalType: 'uint256', - name: 'price', - type: 'uint256', + "internalType": "uint256", + "name": "price", + "type": "uint256" }, { - internalType: 'uint256', - name: 'cumulativeReward', - type: 'uint256', + "internalType": "uint256", + "name": "cumulativeReward", + "type": "uint256" }, { - internalType: 'uint256', - name: 'pendingReward', - type: 'uint256', - }, + "internalType": "uint256", + "name": "pendingReward", + "type": "uint256" + } ], - internalType: 'struct ISTokensManagerStruct.StakingPositions', - name: '_positions', - type: 'tuple', + "internalType": "struct ISTokensManagerStruct.StakingPositions", + "name": "_positions", + "type": "tuple" }, { - internalType: 'bytes32', - name: 'key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } ], - name: 'onBeforeMint', - outputs: [ + "name": "onBeforeMint", + "outputs": [ { - internalType: 'bool', - name: '', - type: 'bool', - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: 'nonpayable', - type: 'function', + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: 'owner', - outputs: [ + "inputs": [], + "name": "owner", + "outputs": [ { - internalType: 'address', - name: '', - type: 'address', - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } ], - name: 'propertyImageClaimedSlots', - outputs: [ + "name": "propertyImageClaimedSlots", + "outputs": [ { - internalType: 'uint32', - name: '', - type: 'uint32', - }, + "internalType": "uint32", + "name": "", + "type": "uint32" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } ], - name: 'propertyImages', - outputs: [ + "name": "propertyImages", + "outputs": [ { - internalType: 'string', - name: 'src', - type: 'string', + "internalType": "string", + "name": "src", + "type": "string" }, { - internalType: 'string', - name: 'name', - type: 'string', + "internalType": "string", + "name": "name", + "type": "string" }, { - internalType: 'string', - name: 'description', - type: 'string', + "internalType": "string", + "name": "description", + "type": "string" }, { - components: [ - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256', - }, - { - internalType: 'uint32', - name: 'members', - type: 'uint32', - }, - ], - internalType: 'struct SlotCollections.SlotType', - name: 'slot', - type: 'tuple', + "internalType": "uint256", + "name": "deadline", + "type": "uint256" }, { - internalType: 'uint256', - name: 'requiredTokenAmount', - type: 'uint256', + "internalType": "uint32", + "name": "members", + "type": "uint32" }, { - internalType: 'uint256', - name: 'requiredTokenFee', - type: 'uint256', + "internalType": "uint256", + "name": "requiredTokenAmount", + "type": "uint256" }, { - internalType: 'address', - name: 'token', - type: 'address', + "internalType": "uint256", + "name": "requiredTokenFee", + "type": "uint256" }, { - internalType: 'address', - name: 'gateway', - type: 'address', + "internalType": "address", + "name": "token", + "type": "address" }, + { + "internalType": "address", + "name": "gateway", + "type": "address" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_propertyAddress', - type: 'address', + "internalType": "address", + "name": "_propertyAddress", + "type": "address" }, { - internalType: 'bytes32', - name: '_key', - type: 'bytes32', - }, + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + } ], - name: 'removeImage', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "removeImage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: 'renounceOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_dev', - type: 'address', - }, + "internalType": "address", + "name": "_dev", + "type": "address" + } ], - name: 'setDevToken', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "setDevToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_propertyAddress', - type: 'address', + "internalType": "address", + "name": "_propertyAddress", + "type": "address" }, { - components: [ + "components": [ { - internalType: 'string', - name: 'src', - type: 'string', + "internalType": "string", + "name": "src", + "type": "string" }, { - internalType: 'string', - name: 'name', - type: 'string', + "internalType": "string", + "name": "name", + "type": "string" }, { - internalType: 'string', - name: 'description', - type: 'string', + "internalType": "string", + "name": "description", + "type": "string" }, { - components: [ - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256', - }, - { - internalType: 'uint32', - name: 'members', - type: 'uint32', - }, - ], - internalType: 'struct SlotCollections.SlotType', - name: 'slot', - type: 'tuple', + "internalType": "uint256", + "name": "deadline", + "type": "uint256" }, { - internalType: 'uint256', - name: 'requiredTokenAmount', - type: 'uint256', + "internalType": "uint32", + "name": "members", + "type": "uint32" }, { - internalType: 'uint256', - name: 'requiredTokenFee', - type: 'uint256', + "internalType": "uint256", + "name": "requiredTokenAmount", + "type": "uint256" }, { - internalType: 'address', - name: 'token', - type: 'address', + "internalType": "uint256", + "name": "requiredTokenFee", + "type": "uint256" }, { - internalType: 'address', - name: 'gateway', - type: 'address', + "internalType": "address", + "name": "token", + "type": "address" }, + { + "internalType": "address", + "name": "gateway", + "type": "address" + } ], - internalType: 'struct SlotCollections.Image[]', - name: '_images', - type: 'tuple[]', + "internalType": "struct SlotCollections.Image[]", + "name": "_images", + "type": "tuple[]" }, { - internalType: 'bytes32[]', - name: '_keys', - type: 'bytes32[]', - }, + "internalType": "bytes32[]", + "name": "_keys", + "type": "bytes32[]" + } ], - name: 'setImages', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "setImages", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '_contract', - type: 'address', - }, + "internalType": "address", + "name": "_contract", + "type": "address" + } ], - name: 'setSwapAndStake', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "name": "setSwapAndStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: 'address', - name: '', - type: 'address', + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: 'uint256', - name: '', - type: 'uint256', - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - name: 'stakedAmountAtMinted', - outputs: [ + "name": "stakedAmountAtMinted", + "outputs": [ { - internalType: 'uint256', - name: '', - type: 'uint256', - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: 'swapAndStake', - outputs: [ + "inputs": [], + "name": "swapAndStake", + "outputs": [ { - internalType: 'contract ISwapAndStake', - name: '', - type: 'address', - }, + "internalType": "contract ISwapAndStake", + "name": "", + "type": "address" + } ], - stateMutability: 'view', - type: 'function', + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, -] + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 8c0a13990..72d539230 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -39,7 +39,7 @@ export const address: Address[] = [ }, { chainId: 80001, - address: '0x40be0Bc51523E6eF9b1d7F98B8545859efC708c1', + address: '0x1d82F8BA629dDfC1Ca971C38d03E087D64Cfd531', }, ] @@ -89,6 +89,7 @@ export async function callSlotCollections( defaultAddress.address const contract = new ethers.Contract(addressList, mixSlotABI, provider) + console.log({contract}) const result: TransactionReceipt = await contract[functionName](...args) return result From c35049fde8fa1b8065a80f670fa68d0a92936659 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:14:49 +0530 Subject: [PATCH 009/129] lint --- .../Collections/CreateCollections.svelte | 58 +- src/plugins/collections/SyncModal.svelte | 46 +- src/plugins/collections/utils/mixSlotABI.ts | 968 +++++++++--------- .../collections/utils/slotCollections.ts | 2 +- 4 files changed, 537 insertions(+), 537 deletions(-) diff --git a/src/components/Collections/CreateCollections.svelte b/src/components/Collections/CreateCollections.svelte index 39e4d559c..b857cb3d6 100644 --- a/src/components/Collections/CreateCollections.svelte +++ b/src/components/Collections/CreateCollections.svelte @@ -788,22 +788,22 @@ > - + - +
diff --git a/src/plugins/collections/SyncModal.svelte b/src/plugins/collections/SyncModal.svelte index 28c481c35..fc591dcf6 100644 --- a/src/plugins/collections/SyncModal.svelte +++ b/src/plugins/collections/SyncModal.svelte @@ -80,33 +80,33 @@ }) => { // Filter out states with empty payload const validStates = states.filter(({ payload }) => payload.trim() !== '') - console.log({validStates}) + console.log({ validStates }) const results: TransactionResponse[] = [] if (validStates.length) { - try { - const args = [ - propertyAddress, - validStates.map(({ state }) => state), - validStates.map(({ payload }) => payload), - ] - console.log({args}) - const res = await callSlotCollections(provider, 'setImages', [ - propertyAddress, - validStates.map(({ state }) => state), - validStates.map(({ payload }) => payload), - ]); - // const res2 = await callSlotCollections(provider, 'propertyImages', [ - // propertyAddress, - // "0x4b7f37427bb4f845726fcccf7e25390b25cf9dbfc82846d73dcc1688f93d3e4d", - // ]); - // console.log({res2}) - results.push(res); - } catch (error) { - console.log('Error in callSlotCollections:', error); + try { + const args = [ + propertyAddress, + validStates.map(({ state }) => state), + validStates.map(({ payload }) => payload), + ] + console.log({ args }) + const res = await callSlotCollections(provider, 'setImages', [ + propertyAddress, + validStates.map(({ state }) => state), + validStates.map(({ payload }) => payload), + ]) + // const res2 = await callSlotCollections(provider, 'propertyImages', [ + // propertyAddress, + // "0x4b7f37427bb4f845726fcccf7e25390b25cf9dbfc82846d73dcc1688f93d3e4d", + // ]); + // console.log({res2}) + results.push(res) + } catch (error) { + console.log('Error in callSlotCollections:', error) + } } - } - return results; + return results } diff --git a/src/plugins/collections/utils/mixSlotABI.ts b/src/plugins/collections/utils/mixSlotABI.ts index ffcb4189b..fc23d37b2 100644 --- a/src/plugins/collections/utils/mixSlotABI.ts +++ b/src/plugins/collections/utils/mixSlotABI.ts @@ -1,735 +1,735 @@ -export const mixSlotABI = [ +export const mixSlotABI = [ { - "anonymous": false, - "inputs": [ + anonymous: false, + inputs: [ { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, ], - "name": "Initialized", - "type": "event" + name: 'Initialized', + type: 'event', }, { - "anonymous": false, - "inputs": [ + anonymous: false, + inputs: [ { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', }, { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, ], - "name": "OwnershipTransferred", - "type": "event" + name: 'OwnershipTransferred', + type: 'event', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_token", - "type": "address" - } + internalType: 'address', + name: '_token', + type: 'address', + }, ], - "name": "allowListToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'allowListToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "", - "type": "address" - } + internalType: 'address', + name: '', + type: 'address', + }, ], - "name": "allowlistedTokens", - "outputs": [ + name: 'allowlistedTokens', + outputs: [ { - "internalType": "bool", - "name": "", - "type": "bool" - } + internalType: 'bool', + name: '', + type: 'bool', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_token", - "type": "address" - } + internalType: 'address', + name: '_token', + type: 'address', + }, ], - "name": "denyListToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'denyListToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "uint256", - "name": "id", - "type": "uint256" + internalType: 'uint256', + name: 'id', + type: 'uint256', }, { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "property", - "type": "address" + internalType: 'address', + name: 'property', + type: 'address', }, { - "internalType": "uint256", - "name": "amount", - "type": "uint256" + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "price", - "type": "uint256" + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "pendingReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.StakingPositions", - "name": "_positions", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "entireReward", - "type": "uint256" + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "withdrawableReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.Rewards", - "name": "", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', }, { - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - } + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, ], - "name": "description", - "outputs": [ + name: 'description', + outputs: [ { - "internalType": "string", - "name": "", - "type": "string" - } + internalType: 'string', + name: '', + type: 'string', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [], - "name": "dev", - "outputs": [ + inputs: [], + name: 'dev', + outputs: [ { - "internalType": "address", - "name": "", - "type": "address" - } + internalType: 'address', + name: '', + type: 'address', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_property", - "type": "address" + internalType: 'address', + name: '_property', + type: 'address', }, { - "internalType": "bytes32", - "name": "_key", - "type": "bytes32" - } + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, ], - "name": "getSlotsLeft", - "outputs": [ + name: 'getSlotsLeft', + outputs: [ { - "internalType": "uint256", - "name": "", - "type": "uint256" - } + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_property", - "type": "address" + internalType: 'address', + name: '_property', + type: 'address', }, { - "internalType": "bytes32", - "name": "_key", - "type": "bytes32" - } + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, ], - "name": "getTimeLeft", - "outputs": [ + name: 'getTimeLeft', + outputs: [ { - "internalType": "uint256", - "name": "", - "type": "uint256" - } + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "uint256", - "name": "id", - "type": "uint256" + internalType: 'uint256', + name: 'id', + type: 'uint256', }, { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "property", - "type": "address" + internalType: 'address', + name: 'property', + type: 'address', }, { - "internalType": "uint256", - "name": "amount", - "type": "uint256" + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "price", - "type": "uint256" + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "pendingReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.StakingPositions", - "name": "_positions", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "entireReward", - "type": "uint256" + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "withdrawableReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.Rewards", - "name": "", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', }, { - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - } + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, ], - "name": "image", - "outputs": [ + name: 'image', + outputs: [ { - "internalType": "string", - "name": "", - "type": "string" - } + internalType: 'string', + name: '', + type: 'string', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_contract", - "type": "address" - } + internalType: 'address', + name: '_contract', + type: 'address', + }, ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "uint256", - "name": "id", - "type": "uint256" + internalType: 'uint256', + name: 'id', + type: 'uint256', }, { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "property", - "type": "address" + internalType: 'address', + name: 'property', + type: 'address', }, { - "internalType": "uint256", - "name": "amount", - "type": "uint256" + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "price", - "type": "uint256" + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "pendingReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.StakingPositions", - "name": "_positions", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "entireReward", - "type": "uint256" + internalType: 'uint256', + name: 'entireReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "withdrawableReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'withdrawableReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.Rewards", - "name": "", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.Rewards', + name: '', + type: 'tuple', }, { - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - } + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, ], - "name": "name", - "outputs": [ + name: 'name', + outputs: [ { - "internalType": "string", - "name": "", - "type": "string" - } + internalType: 'string', + name: '', + type: 'string', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "uint256", - "name": "id", - "type": "uint256" + internalType: 'uint256', + name: 'id', + type: 'uint256', }, { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "property", - "type": "address" + internalType: 'address', + name: 'property', + type: 'address', }, { - "internalType": "uint256", - "name": "amount", - "type": "uint256" + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "price", - "type": "uint256" + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - "internalType": "uint256", - "name": "cumulativeReward", - "type": "uint256" + internalType: 'uint256', + name: 'cumulativeReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "pendingReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'pendingReward', + type: 'uint256', + }, ], - "internalType": "struct ISTokensManagerStruct.StakingPositions", - "name": "_positions", - "type": "tuple" + internalType: 'struct ISTokensManagerStruct.StakingPositions', + name: '_positions', + type: 'tuple', }, { - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - } + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, ], - "name": "onBeforeMint", - "outputs": [ + name: 'onBeforeMint', + outputs: [ { - "internalType": "bool", - "name": "", - "type": "bool" - } + internalType: 'bool', + name: '', + type: 'bool', + }, ], - "stateMutability": "nonpayable", - "type": "function" + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [], - "name": "owner", - "outputs": [ + inputs: [], + name: 'owner', + outputs: [ { - "internalType": "address", - "name": "", - "type": "address" - } + internalType: 'address', + name: '', + type: 'address', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, ], - "name": "propertyImageClaimedSlots", - "outputs": [ + name: 'propertyImageClaimedSlots', + outputs: [ { - "internalType": "uint32", - "name": "", - "type": "uint32" - } + internalType: 'uint32', + name: '', + type: 'uint32', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, ], - "name": "propertyImages", - "outputs": [ + name: 'propertyImages', + outputs: [ { - "internalType": "string", - "name": "src", - "type": "string" + internalType: 'string', + name: 'src', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "string", - "name": "description", - "type": "string" + internalType: 'string', + name: 'description', + type: 'string', }, { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" + internalType: 'uint256', + name: 'deadline', + type: 'uint256', }, { - "internalType": "uint32", - "name": "members", - "type": "uint32" + internalType: 'uint32', + name: 'members', + type: 'uint32', }, { - "internalType": "uint256", - "name": "requiredTokenAmount", - "type": "uint256" + internalType: 'uint256', + name: 'requiredTokenAmount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "requiredTokenFee", - "type": "uint256" + internalType: 'uint256', + name: 'requiredTokenFee', + type: 'uint256', }, { - "internalType": "address", - "name": "token", - "type": "address" + internalType: 'address', + name: 'token', + type: 'address', }, { - "internalType": "address", - "name": "gateway", - "type": "address" - } + internalType: 'address', + name: 'gateway', + type: 'address', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_propertyAddress", - "type": "address" + internalType: 'address', + name: '_propertyAddress', + type: 'address', }, { - "internalType": "bytes32", - "name": "_key", - "type": "bytes32" - } + internalType: 'bytes32', + name: '_key', + type: 'bytes32', + }, ], - "name": "removeImage", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'removeImage', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_dev", - "type": "address" - } + internalType: 'address', + name: '_dev', + type: 'address', + }, ], - "name": "setDevToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'setDevToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_propertyAddress", - "type": "address" + internalType: 'address', + name: '_propertyAddress', + type: 'address', }, { - "components": [ + components: [ { - "internalType": "string", - "name": "src", - "type": "string" + internalType: 'string', + name: 'src', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "string", - "name": "description", - "type": "string" + internalType: 'string', + name: 'description', + type: 'string', }, { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" + internalType: 'uint256', + name: 'deadline', + type: 'uint256', }, { - "internalType": "uint32", - "name": "members", - "type": "uint32" + internalType: 'uint32', + name: 'members', + type: 'uint32', }, { - "internalType": "uint256", - "name": "requiredTokenAmount", - "type": "uint256" + internalType: 'uint256', + name: 'requiredTokenAmount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "requiredTokenFee", - "type": "uint256" + internalType: 'uint256', + name: 'requiredTokenFee', + type: 'uint256', }, { - "internalType": "address", - "name": "token", - "type": "address" + internalType: 'address', + name: 'token', + type: 'address', }, { - "internalType": "address", - "name": "gateway", - "type": "address" - } + internalType: 'address', + name: 'gateway', + type: 'address', + }, ], - "internalType": "struct SlotCollections.Image[]", - "name": "_images", - "type": "tuple[]" + internalType: 'struct SlotCollections.Image[]', + name: '_images', + type: 'tuple[]', }, { - "internalType": "bytes32[]", - "name": "_keys", - "type": "bytes32[]" - } + internalType: 'bytes32[]', + name: '_keys', + type: 'bytes32[]', + }, ], - "name": "setImages", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'setImages', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_contract", - "type": "address" - } + internalType: 'address', + name: '_contract', + type: 'address', + }, ], - "name": "setSwapAndStake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + name: 'setSwapAndStake', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "internalType": "uint256", - "name": "", - "type": "uint256" - } + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "name": "stakedAmountAtMinted", - "outputs": [ + name: 'stakedAmountAtMinted', + outputs: [ { - "internalType": "uint256", - "name": "", - "type": "uint256" - } + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [], - "name": "swapAndStake", - "outputs": [ + inputs: [], + name: 'swapAndStake', + outputs: [ { - "internalType": "contract ISwapAndStake", - "name": "", - "type": "address" - } + internalType: 'contract ISwapAndStake', + name: '', + type: 'address', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] diff --git a/src/plugins/collections/utils/slotCollections.ts b/src/plugins/collections/utils/slotCollections.ts index 72d539230..a6033975f 100644 --- a/src/plugins/collections/utils/slotCollections.ts +++ b/src/plugins/collections/utils/slotCollections.ts @@ -89,7 +89,7 @@ export async function callSlotCollections( defaultAddress.address const contract = new ethers.Contract(addressList, mixSlotABI, provider) - console.log({contract}) + console.log({ contract }) const result: TransactionReceipt = await contract[functionName](...args) return result From b7b777074ab587b2473e0b2a7c9807bbcdfb297d Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:15:52 +0530 Subject: [PATCH 010/129] wip: write bettter code --- scripts/populate/custom-clubs.mjs | 113 ++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 scripts/populate/custom-clubs.mjs diff --git a/scripts/populate/custom-clubs.mjs b/scripts/populate/custom-clubs.mjs new file mode 100644 index 000000000..108260ec5 --- /dev/null +++ b/scripts/populate/custom-clubs.mjs @@ -0,0 +1,113 @@ +import { encode } from '@devprotocol/clubs-core' +import { db } from './utils/db.mjs' +import { whenCalledDirectly } from './utils/whenCalledDirectly.mjs' + +const KEY = 'clubsname' + +const populate = async (client) => { + await client.set( + KEY, + encode({ + name: 'testing-clubs-on-shubham-machine', + twitterHandle: '@doesntmatter', + description: '', + url: 'https://clubsname.clubs.place', + propertyAddress: 'propertyAdd', + adminRolePoints: 0, + chainId: 80001, + rpcUrl: + '', + options: [ + { + key: 'ogp', + value: { image: '' }, + }, + { + key: 'navigationLinks', + value: [ + { + display: 'Join', + path: '/join', + }, + { + display: 'Collections', + path: '/collections', + }, + ], + }, + { + key: 'socialLinks', + value: [ + { + display: 'YouTube', + path: 'https://www.youtube.com/user/suiundo/', + }, + ], + }, + { + key: 'avatarImgSrc', + value: 'https://i.imgur.com/jDel1t9.png', + }, + ], + plugins: [ + { + id: 'clubs-core:admin', + name: 'admin', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:theme-1', + name: 'defaultTheme', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:plugin:me', + name: 'me', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:clubsx:marketplace', + name: 'marketplace', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:plugin:members', + name: 'members', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:plugin:quests', + name: 'quests', + enable: true, + options: [], + }, + { + id: 'devprotocol:clubs:simple-memberships', + name: 'memberships', + enable: true, + options: [ + { + key: 'memberships', + value: [], + }, + ], + }, + ], + }), + ) + + console.log('set', KEY) +} + +whenCalledDirectly(async () => { + const client = await db() + await populate(client) + await client.quit() +}) + +export default populate From c8d8607f07a4f23cbcb92d33b215689b39b4ad8e Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:16:03 +0530 Subject: [PATCH 011/129] lint --- scripts/populate/custom-clubs.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/populate/custom-clubs.mjs b/scripts/populate/custom-clubs.mjs index 108260ec5..bd04a9fd6 100644 --- a/scripts/populate/custom-clubs.mjs +++ b/scripts/populate/custom-clubs.mjs @@ -15,8 +15,7 @@ const populate = async (client) => { propertyAddress: 'propertyAdd', adminRolePoints: 0, chainId: 80001, - rpcUrl: - '', + rpcUrl: '', options: [ { key: 'ogp', From bca5b39856fca092422e709ee8e294b3bd2bf7e7 Mon Sep 17 00:00:00 2001 From: Yash Agrawal Date: Thu, 14 Dec 2023 17:17:04 +0530 Subject: [PATCH 012/129] feat: fix dev staking 0 amount issue in ui --- src/plugins/admin/StakeInfo.tsx | 2 +- yarn.lock | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/plugins/admin/StakeInfo.tsx b/src/plugins/admin/StakeInfo.tsx index 4953dd7a1..d480aa72a 100644 --- a/src/plugins/admin/StakeInfo.tsx +++ b/src/plugins/admin/StakeInfo.tsx @@ -95,7 +95,7 @@ const CurrencyMembershipInfo = (props: Props) => { await signer.getAddress(), ) const fee: bigint = BigInt(response._amount || response[0]) - withdrawableAmt = formatUnits(fee, 36) + withdrawableAmt = formatUnits(fee, 18) } else if (props.fetcherType === 'cumulative') { const response = await await withdrawContract.calculateRewardAmount( props.propertyAddress, diff --git a/yarn.lock b/yarn.lock index 437fee0f2..08f2f6d11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -588,17 +588,10 @@ svelte "^4.0.0" vue "^3.2.0" -<<<<<<< HEAD "@devprotocol/clubs-plugin-posts@0.8.1": version "0.8.1" resolved "https://registry.yarnpkg.com/@devprotocol/clubs-plugin-posts/-/clubs-plugin-posts-0.8.1.tgz#5b7300c1e2d54e05cad673f60c027faf9b438922" integrity sha512-Ikd14Qn8aSMB2F+vIQMksGI2uduT0aQS8n7FjzJFVUln7k9rVqKFL7S6J4O71RTirvYg1N2/IksfI2hT+IkI4w== -======= -"@devprotocol/clubs-plugin-posts@0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@devprotocol/clubs-plugin-posts/-/clubs-plugin-posts-0.8.0.tgz#67e882bdeb01ef17d12e875af4cee021ac06dc11" - integrity sha512-V/BDEmi1XiWttSWOzJczb4MLj4p0t1CsBFD4K2AoILpoXPyiii7DnFIbjqnWehJZ/05kKedbP5w0htt/zkcVQQ== ->>>>>>> main dependencies: "@boringer-avatars/vue3" "^0.2.1" "@devprotocol/dev-kit" "8.6.0" @@ -607,11 +600,7 @@ dayjs "^1.11.8" dompurify "^3.0.5" ethers "^6.6.4" -<<<<<<< HEAD marked "11.1.0" -======= - marked "11.0.1" ->>>>>>> main photoswipe "5.4.3" ramda "0.29.1" redis "^4.6.7" @@ -7741,17 +7730,10 @@ marked@10.0.0, marked@^10.0.0: resolved "https://registry.yarnpkg.com/marked/-/marked-10.0.0.tgz#7fe1805bb908433d760e2de0fcc8841a2b2d745c" integrity sha512-YiGcYcWj50YrwBgNzFoYhQ1hT6GmQbFG8SksnYJX1z4BXTHSOrz1GB5/Jm2yQvMg4nN1FHP4M6r03R10KrVUiA== -<<<<<<< HEAD marked@11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/marked/-/marked-11.1.0.tgz#f2d12323e80ba8a97cc8262fe7e94fcc007476ab" integrity sha512-fvKJWAPEafVj1dwGwcPI5mBB/0pvViL6NlCbNDG1HOIRwwAU/jeMoFxfbRLuirO1wRH7m4yPvBqD/O1wyWvayw== -======= -marked@11.0.1: - version "11.0.1" - resolved "https://registry.yarnpkg.com/marked/-/marked-11.0.1.tgz#f8010ec2e358c0f4efedbac1ed3dbac2c7f46cdc" - integrity sha512-P4kDhFEMlvLePBPRwOcMOv6+lYUbhfbSxJFs3Jb4Qx7v6K7l+k8Dxh9CEGfRvK71tL+qIFz5y7Pe4uzt4+/A3A== ->>>>>>> main mdast-util-definitions@^6.0.0: version "6.0.0" From 84b4dda9e56681f717fed266af650658c3164224 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Fri, 15 Dec 2023 05:57:25 +0530 Subject: [PATCH 013/129] remove: unused imports --- src/components/Collections/CreateCollections.svelte | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/Collections/CreateCollections.svelte b/src/components/Collections/CreateCollections.svelte index b857cb3d6..642144c1d 100644 --- a/src/components/Collections/CreateCollections.svelte +++ b/src/components/Collections/CreateCollections.svelte @@ -1,6 +1,6 @@ - +
Date: Mon, 25 Dec 2023 05:19:31 +0000 Subject: [PATCH 115/129] fix(deps): update dependency viem to v1.21.0 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 80bd6bd04..bd3ea26ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11183,9 +11183,9 @@ vfile@^6.0.0, vfile@^6.0.1: vfile-message "^4.0.0" viem@^1.0.0, viem@^1.10.8: - version "1.20.3" - resolved "https://registry.yarnpkg.com/viem/-/viem-1.20.3.tgz#8b8360daee622295f5385949c02c86d943d14e0f" - integrity sha512-7CrmeCb2KYkeCgUmUyb1hsf+IX/PLwi+Np+Vm4YUTPeG82y3HRSgGHSaCOp3d0YtR2kXD3nv9y5kE7LBFE+wWw== + version "1.21.0" + resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.0.tgz#38b78895d750ca51b9f7caed17de3cbfcbdcb4ec" + integrity sha512-d5CSflyvoQYT8aeAANX0x7DLuW/GEBs5lh3pZRbNIxTdb/XNLHiEcuB8I262oqAgxfBTA+94kry9ISzAsHKFhA== dependencies: "@adraffy/ens-normalize" "1.10.0" "@noble/curves" "1.2.0" From 54267fed1adfe80575f59b8c42fe73a2fd5e3627 Mon Sep 17 00:00:00 2001 From: Stuart Kuentzel Date: Tue, 26 Dec 2023 14:33:36 +0900 Subject: [PATCH 116/129] find plugin by id rather than name --- package.json | 3 ++- scripts/upgrade-posts-v2.mjs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a2c160cd4..af897c66b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "flushDb": "node ./scripts/flushDb.mjs", "upgradeDb": "node ./scripts/upgrade.mjs", "genApiPaths": "node ./scripts/generate-built-in-api-paths.mjs", - "copy": "node ./scripts/copy.mjs" + "copy": "node ./scripts/copy.mjs", + "migratePosts": "node ./scripts/upgrade-posts-v2.mjs" }, "devDependencies": { "@rollup/plugin-commonjs": "^25.0.4", diff --git a/scripts/upgrade-posts-v2.mjs b/scripts/upgrade-posts-v2.mjs index 0f9948a1a..f66ff00c8 100644 --- a/scripts/upgrade-posts-v2.mjs +++ b/scripts/upgrade-posts-v2.mjs @@ -66,7 +66,7 @@ const main = async () => { * Find the posts plugin */ const pluginPost = decodedConfig.plugins.find( - (plugin) => plugin.name === 'devprotocol:clubs:plugin:posts', + (plugin) => plugin.id === 'devprotocol:clubs:plugin:posts', ) /** Club doesn't have Posts installed, continue */ From 552a97f4aa00b4477f1fd72b91fcf4122e32107a Mon Sep 17 00:00:00 2001 From: Stuart Kuentzel Date: Tue, 26 Dec 2023 14:53:12 +0900 Subject: [PATCH 117/129] fixes script searching for feeds --- scripts/upgrade-posts-v2.mjs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade-posts-v2.mjs b/scripts/upgrade-posts-v2.mjs index f66ff00c8..eefe38a98 100644 --- a/scripts/upgrade-posts-v2.mjs +++ b/scripts/upgrade-posts-v2.mjs @@ -51,7 +51,7 @@ const main = async () => { for await (const key of client.scanIterator()) { if (key.includes(':')) { // This is not a ClubsConfiguration - console.log('Skipped:', key) + // console.log('Skipped:', key) continue } @@ -78,7 +78,7 @@ const main = async () => { /** * Find the feeds option **/ - const feeds = pluginPost.options.find((option) => option.name === 'feeds') + const feeds = pluginPost.options.find((option) => option.key === 'feeds') /** Club doesn't have Posts installed, continue */ if (!feeds) { @@ -120,15 +120,18 @@ const main = async () => { */ const oldId = 'default' const newId = 'default-2' - const res = await fetch( - `https://${addedFeedValueConfig.url}/api/devprotocol:clubs:plugin:posts/${oldId}/copy/to/${newId}`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, + + console.log('addedFeedValueConfig: ', addedFeedValueConfig) + + const url = `https://${decodedConfig.url}/api/devprotocol:clubs:plugin:posts/${oldId}/copy/to/${newId}` + console.log('url is: ', url) + + const res = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', }, - ) + }) if (res.status !== 200) { console.log('Failed to copy posts content', key) From 1e51fdb676ef996b9d73c062ad41c93bbe3fc0c9 Mon Sep 17 00:00:00 2001 From: Stuart Kuentzel Date: Tue, 26 Dec 2023 14:54:18 +0900 Subject: [PATCH 118/129] :shower: cleanup --- scripts/upgrade-posts-v2.mjs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/upgrade-posts-v2.mjs b/scripts/upgrade-posts-v2.mjs index eefe38a98..9436bff3f 100644 --- a/scripts/upgrade-posts-v2.mjs +++ b/scripts/upgrade-posts-v2.mjs @@ -51,7 +51,6 @@ const main = async () => { for await (const key of client.scanIterator()) { if (key.includes(':')) { // This is not a ClubsConfiguration - // console.log('Skipped:', key) continue } @@ -120,11 +119,7 @@ const main = async () => { */ const oldId = 'default' const newId = 'default-2' - - console.log('addedFeedValueConfig: ', addedFeedValueConfig) - const url = `https://${decodedConfig.url}/api/devprotocol:clubs:plugin:posts/${oldId}/copy/to/${newId}` - console.log('url is: ', url) const res = await fetch(url, { method: 'POST', From 0292cc3055b5027d11e8239f50063e7420761c28 Mon Sep 17 00:00:00 2001 From: Stuart Kuentzel Date: Tue, 26 Dec 2023 15:11:37 +0900 Subject: [PATCH 119/129] updates posts migration script --- scripts/upgrade-posts-v2.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade-posts-v2.mjs b/scripts/upgrade-posts-v2.mjs index 9436bff3f..3a6e85b03 100644 --- a/scripts/upgrade-posts-v2.mjs +++ b/scripts/upgrade-posts-v2.mjs @@ -119,7 +119,8 @@ const main = async () => { */ const oldId = 'default' const newId = 'default-2' - const url = `https://${decodedConfig.url}/api/devprotocol:clubs:plugin:posts/${oldId}/copy/to/${newId}` + const url = `${decodedConfig.url}/api/devprotocol:clubs:plugin:posts/${oldId}/copy/to/${newId}` + console.log('Copying posts content', key, url) const res = await fetch(url, { method: 'POST', @@ -128,8 +129,11 @@ const main = async () => { }, }) - if (res.status !== 200) { + if (!res.ok) { + console.log('status is: ', res.status) + console.log('status text is: ', res.statusText) console.log('Failed to copy posts content', key) + console.log('----') continue } From 8f4802bd3991ab4418d9ee61ced7ce4fdfc0ae47 Mon Sep 17 00:00:00 2001 From: aggre Date: Tue, 26 Dec 2023 17:15:20 +0900 Subject: [PATCH 120/129] Fix some bugs in scripts/upgrade-posts-v2.mjs (#1789) * fix some bugs * prevent duplication of the same scope --- scripts/upgrade-posts-v2.mjs | 60 +++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/scripts/upgrade-posts-v2.mjs b/scripts/upgrade-posts-v2.mjs index 3a6e85b03..69cf64a44 100644 --- a/scripts/upgrade-posts-v2.mjs +++ b/scripts/upgrade-posts-v2.mjs @@ -6,6 +6,8 @@ import { toUtf8Bytes } from 'ethers' dotenv.config() +let isIndexCreated = false + const upgradeConfig = (decodedConfig, feeds) => { const upgradedConfig = { ...decodedConfig, @@ -13,14 +15,14 @@ const upgradeConfig = (decodedConfig, feeds) => { /** * Find the posts plugin */ - if (plugin.name === 'devprotocol:clubs:plugin:posts') { + if (plugin.id === 'devprotocol:clubs:plugin:posts') { /** * Find the feeds option and replace it with the new one */ const options = plugin.options.map((option) => { - if (option.name === 'feeds') { + if (option.key === 'feeds') { return { - name: 'feeds', + key: 'feeds', value: feeds, } } @@ -88,17 +90,18 @@ const main = async () => { /** * We add the new feed value for copying the posts content */ + const scope = uuidv5( + toUtf8Bytes('default-2'), + uuidv5(decodedConfig.url, uuidv5.URL), + ) const appendedFeeds = [ - ...feeds.value, + ...feeds.value.filter((feed) => feed.database.key !== scope), { id: 'default-2', slug: 'posts', database: { type: 'documents:redis', - key: uuidv5( - toUtf8Bytes('default-2'), //