Skip to content

Commit

Permalink
support transferable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Jul 1, 2024
1 parent 4ab18fd commit d0e21d9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const APP = {
export const AOS = {
module: 'Pq2Zftrqut0hdisH_MC2pDOT6S4eQFoxGsFUzR6r350',
scheduler: '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA',
assetSrc: '00c9tFArqJiCl7wTGkEQcSO7lCDQQ1wh8OmS-y6G-AY',
assetSrc: 'Llx-3D4Xl_xNoGGrsixIiVUMP3fq8kn2-cBqAQ0TIcQ',
defaultToken: 'xU9zFkq3X2ZQ6olwNVvr1vUWIjc3kXTWr7xKQD6dh10',
ucm: 'U3TjJAZWJjlWBB4KAXSHKzuky81jtyh0zqH8rUL4Wd0',
pixl: 'DM3FoZUq_yebASPhgd8pEIRIzDW6muXEhxz5-JwbZwo',
Expand Down
1 change: 1 addition & 0 deletions src/helpers/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const language = {
topics: `Topics`,
topicInfo: `Topics will be attached to newly created assets`,
toUpload: `To upload`,
transferableTokensCheckInfo: `These assets will be transferable`,
turboBalance: `Turbo Balance`,
turboUploadCost: `Turbo upload cost`,
udl: `Universal Data License`,
Expand Down
1 change: 1 addition & 0 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export type UploadPayloadType =
| 'collectionCode'
| 'contentTokens'
| 'useFractionalTokens'
| 'transferableTokens'
| 'topics'
| 'content'
| 'contentList'
Expand Down
3 changes: 3 additions & 0 deletions src/store/upload/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const initStateUploadReducer = {
collectionCode: '',
contentTokens: 100,
useFractionalTokens: true,
transferableTokens: true,
banner: null,
thumbnail: null,
topics: [],
Expand Down Expand Up @@ -92,6 +93,7 @@ export function uploadReducer(state: UploadReduxType = initStateUploadReducer, a
collectionCode: '',
contentTokens: 100,
useFractionalTokens: true,
transferableTokens: true,
banner: null,
thumbnail: null,
topics: [],
Expand Down Expand Up @@ -120,6 +122,7 @@ export function uploadReducer(state: UploadReduxType = initStateUploadReducer, a
collectionCode: '',
contentTokens: 100,
useFractionalTokens: true,
transferableTokens: true,
banner: null,
thumbnail: null,
topics: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ export default function UploadStepsDetails() {
return () => clearTimeout(timeoutId);
}, [uploadReducer.data.title]);

// React.useEffect(() => {
// setTopicOptions([...DEFAULT_ASSET_TOPICS, ...uploadReducer.data.topics]);
// }, [uploadReducer.data.topics]);

async function handleTitleCheck() {
if (uploadReducer.data.title) {
setValidatingTitle(true);
Expand Down Expand Up @@ -121,6 +117,17 @@ export default function UploadStepsDetails() {
);
}

function handleTransferableChange() {
dispatch(
uploadActions.setUpload([
{
field: 'transferableTokens',
data: !uploadReducer.data.transferableTokens,
},
])
);
}

function handleTopicChange(topic: string) {
let topics = [...uploadReducer.data.topics];
if (topics.includes(topic)) {
Expand Down Expand Up @@ -228,16 +235,14 @@ export default function UploadStepsDetails() {
/>
)}
</S.COWrapper>
{/* {uploadReducer.uploadType === 'collection' && (
<FormField
label={language.collectionCode}
value={uploadReducer.data.collectionCode}
onChange={(e: any) => handleInputChange(e, 'collectionCode')}
<S.CWrapper>
<span>{language.transferableTokensCheckInfo}</span>
<Checkbox
checked={uploadReducer.data.transferableTokens}
handleSelect={handleTransferableChange}
disabled={false}
invalid={{ status: false, message: null }}
tooltip={language.collectionCodeInfo}
/>
)} */}
</S.CWrapper>
<S.TWrapper>
<S.THeader>
<span>{formatRequiredField(language.assetTopics)}</span>
Expand Down
4 changes: 3 additions & 1 deletion src/views/Upload/UploadSteps/UploadStepsDetails/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const CWrapper = styled.div`
}
`;

export const TWrapper = styled.div``;
export const TWrapper = styled.div`
margin: 20px 0 0 0;
`;

export const THeader = styled.div`
display: flex;
Expand Down
36 changes: 19 additions & 17 deletions src/views/Upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ export default function Upload() {
handler: 'Update-Assets',
});

console.log(updateAssetsResponse);

setCollectionResponse(`${language.collectionCreated}!`);
setCollectionProcessId(collectionId);
if (updateAssetsResponse) {
setCollectionResponse(`${language.collectionCreated}!`);
setCollectionProcessId(collectionId);
}
setCollectionResponse('Error occurred');
} else {
console.error('Error creating collection');
}
Expand All @@ -123,8 +124,11 @@ export default function Upload() {
case 'assets':
try {
const assetIds = await handleUploadAssets(null);
console.log(assetIds);
setAssetsResponse(`${language.assetsCreated}!`);
if (assetIds.length > 0) {
setAssetsResponse(`${language.assetsCreated}!`);
} else {
setAssetsResponse(`${language.errorOccurred}`);
}
} catch (e: any) {
console.error(e);
setAssetsResponse(e.message ?? 'Error occurred');
Expand Down Expand Up @@ -298,15 +302,13 @@ export default function Upload() {
if (bannerTx) registryTags.push({ name: 'Banner', value: bannerTx });
if (thumbnailTx) registryTags.push({ name: 'Thumbnail', value: thumbnailTx });

const updateRegistryResponse = await aos.message({
await aos.message({
process: AOS.collectionsRegistry,
signer: createDataItemSigner(globalThis.arweaveWallet),
tags: registryTags,
});

console.log(updateRegistryResponse);

const profileCollectionsUpdate = await aos.message({
await aos.message({
process: processId,
signer: createDataItemSigner(globalThis.arweaveWallet),
tags: [
Expand All @@ -315,8 +317,6 @@ export default function Upload() {
],
});

console.log(profileCollectionsUpdate);

return processId;
} else {
return null;
Expand Down Expand Up @@ -397,6 +397,10 @@ export default function Upload() {
processSrc = processSrc.replaceAll('<TICKER>', 'ATOMIC');
processSrc = processSrc.replaceAll('<DENOMINATION>', '1');
processSrc = processSrc.replaceAll('<BALANCE>', balance.toString());

if (!uploadReducer.data.transferableTokens) {
processSrc = processSrc.replace('Transferable = true', 'Transferable = false');
}
}

let processId: string;
Expand Down Expand Up @@ -439,10 +443,10 @@ export default function Upload() {
});

if (gqlResponse && gqlResponse.data.length) {
console.log(`Fetched transaction`, gqlResponse.data[0].node.id, 0);
console.log(`Fetched transaction:`, gqlResponse.data[0].node.id);
fetchedAssetId = gqlResponse.data[0].node.id;
} else {
console.log(`Transaction not found`, processId, 0);
console.log(`Transaction not found:`, processId);
retryCount++;
if (retryCount >= 10) {
throw new Error(`Transaction not found after 10 attempts, process deployment retries failed`);
Expand All @@ -464,7 +468,7 @@ export default function Upload() {
});

if (evalResult) {
const updateProfileResponse = await aos.message({
await aos.message({
process: processId,
signer: createDataItemSigner(globalThis.arweaveWallet),
tags: [
Expand All @@ -475,8 +479,6 @@ export default function Upload() {
data: JSON.stringify({ Id: processId, Quantity: balance }),
});

console.log(updateProfileResponse);

uploadedAssetsList.push(processId);
}

Expand Down

0 comments on commit d0e21d9

Please sign in to comment.