-
-
CREATOR: {$mainOrder.creator}
- {#if $creatorState == CreatorState.WaitingForPartnerJoin}
-
- {:else if $creatorState == CreatorState.AllowingAutonomousSwap || $creatorState == CreatorState.WaitingPartnerAllowance}
-
- {:else if $creatorState == CreatorState.SendingTokens}
- teste4
- {:else if $creatorState == CreatorState.WaitingPartnersTransfer}
- teste5d
- {:else if $creatorState == CreatorState.Completed}
- teste6
- {/if}
-
+
+ {#if !($partnerState == PartnerState.Completed && $creatorState == CreatorState.Completed)}
+
+
CREATOR: {$mainOrder.creator}
+ {#if $creatorState == CreatorState.WaitingForPartnerJoin}
+
+ {:else if $creatorState == CreatorState.AllowingAutonomousSwap || $creatorState == CreatorState.WaitingPartnerAllowance}
+
+ {:else if $creatorState == CreatorState.SendingTokens}
+
+ {:else if $creatorState == CreatorState.WaitingPartnersTransfer}
+ teste5d
+ {:else if $creatorState == CreatorState.Completed}
+ teste6
+ {/if}
+
-
-
PARTNER: {$mainOrder.partner ? $mainOrder.partner : 'waiting...'}
- {#if $partnerState == null}
-
PARTNER
- {:else if $partnerState == PartnerState.WaitingFirstConfirmation}
-
{$creatorState = CreatorState.AllowingAutonomousSwap; $partnerState = PartnerState.AllowingAutonomousSwap}}/>
- {:else if $partnerState == PartnerState.AllowingAutonomousSwap || $partnerState == PartnerState.WaitingCreatorAllowance}
- {$creatorState = CreatorState.SendingTokens; $partnerState = PartnerState.WaitingCreatorsFunding}}/>
-
- {:else if $partnerState == PartnerState.WaitingCreatorsFunding}
- teste4
- {:else if $partnerState == PartnerState.SendingTokens}
- teste5
- {:else if $partnerState == PartnerState.Completed}
- teste6
- {/if}
-
+
+
PARTNER: {$mainOrder.partner ? $mainOrder.partner : 'waiting...'}
+ {#if $partnerState == null}
+
PARTNER
+ {:else if $partnerState == PartnerState.WaitingFirstConfirmation}
+
{$creatorState = CreatorState.AllowingAutonomousSwap; $partnerState = PartnerState.AllowingAutonomousSwap}}/>
+ {:else if $partnerState == PartnerState.AllowingAutonomousSwap || $partnerState == PartnerState.WaitingCreatorAllowance}
+
+ {#if $creatorState == CreatorState.WaitingPartnerAllowance && $partnerState == PartnerState.WaitingCreatorAllowance}
+
+ {/if}
+ {:else if $partnerState == PartnerState.WaitingCreatorsFunding}
+
+ {:else if $partnerState == PartnerState.Completed}
+ teste6
+ {/if}
+
+
+ {:else}
+
+
PARABÉNS, DEU CERTOOO!!
+ {$mainOrder.finalTransaction}
+
+ {/if}
\ No newline at end of file
diff --git a/src/components/ReturnToOrder.svelte b/src/components/ReturnToOrder.svelte
index 084cd85..9018f2f 100644
--- a/src/components/ReturnToOrder.svelte
+++ b/src/components/ReturnToOrder.svelte
@@ -63,7 +63,16 @@
})
});
- } else
+ if ($creatorSubOrder.individualStatus == 1) {
+ $creatorState = CreatorState.AllowingAutonomousSwap;
+ $partnerState = PartnerState.AllowingAutonomousSwap;
+ } else
+ if ($creatorSubOrder.individualStatus == 2) {
+ $creatorState = CreatorState.WaitingPartnersTransfer;
+ $partnerState = PartnerState.WaitingCreatorsFunding;
+ }
+ $generalState = GeneralState.OrderCreated;
+ } else
if (partner == _signer) {
let _creatorSubOrder = await _autonomousSwap.getSubOrderByUser(creator, orderId);
let _partnerSubOrder = await _autonomousSwap.getSubOrderByUser(partner, orderId);
@@ -100,64 +109,19 @@
isCreator: false
})
});
+
+ if ($partnerSubOrder.individualStatus == 1) {
+ $creatorState = CreatorState.AllowingAutonomousSwap;
+ $partnerState = PartnerState.AllowingAutonomousSwap;
+ }
+ $generalState = GeneralState.OrderJoined;
+
} else {
error = "Invalid orderId";
console.log(error)
throw new Error(error);
return
}
-
-
- console.log($mainOrder)
- console.log($creatorSubOrder)
- console.log($partnerSubOrder)
-
- if ($creatorSubOrder.)
-
-
- // let _subOrder: [BytesLike, AddressLike, BigNumberish, BigNumberish];
- // _subOrder = [
- // orderId,
- // token,
- // tokenId,
- // quantity
- // ];
-
- // const transactionResponse: ContractTransactionResponse = await _autonomousSwap.joinsOrder(..._subOrder);
- // const transactionReceipt = await transactionResponse.wait();
- // const eventLog = transactionReceipt.logs[0] as ethers.EventLog;
- // const filter = {
- // topics: [...eventLog.topics],
- // data: eventLog.data
- // }
- // const logOutput = _autonomousSwap.interface.parseLog(filter).args;
- // // console.log(logOutput)
-
- // let { creator, } = await _autonomousSwap.getOrderMembersById(logOutput.orderId as BytesLike);
- // console.log(creator)
-
- // mainOrder.update(() => {
- // return ({
- // orderId: logOutput.orderId,
- // creator,
- // partner: logOutput.who,
- // isActive: true,
- // isCreator: false
- // })
- // });
-
- // partnerSubOrder.update(() => {
- // return ({
- // token,
- // interfaceID,
- // tokenId,
- // quantity,
- // individualStatus: logOutput.newStatus
- // })
- // })
-
- // $partnerState = PartnerState.WaitingFirstConfirmation;
- // $generalState = GeneralState.OrderJoined;
}
diff --git a/src/components/creator/AllowanceStep.svelte b/src/components/creator/AllowanceStep.svelte
index 738100f..4877d71 100644
--- a/src/components/creator/AllowanceStep.svelte
+++ b/src/components/creator/AllowanceStep.svelte
@@ -20,36 +20,44 @@
ERC1155: '0xd9b67a26'
};
let interfaceID;
- let interval1;
- let interval2;
-
if (isCreator){
interfaceID = $creatorSubOrder.interfaceID;
-
- interval1 = setInterval( async () => {
- let response = await isAllowed($creatorSubOrder.token, $mainOrder.creator, interfaceID, $creatorSubOrder.quantity, $creatorSubOrder.tokenId)
- if (response) creatorAllowance = true;
- console.log(partnerAllowance)
- }, 1000);
-
+ creatorResponse()
} else {
interfaceID = $partnerSubOrder.interfaceID;
-
- interval2 = setInterval( async () => {
- let response = await isAllowed($partnerSubOrder.token, $mainOrder.partner, interfaceID, $partnerSubOrder.quantity, $partnerSubOrder.tokenId)
- if (response) partnerAllowance = true;
- console.log(partnerAllowance)
- }, 1000);
+ partnerResponse()
+ }
+
+
+ async function creatorResponse(){
+ if (creatorAllowance) return;
+ let response = await isAllowed($creatorSubOrder.token, $mainOrder.creator, interfaceID, $creatorSubOrder.quantity, $creatorSubOrder.tokenId)
+ console.log(response)
+ if (response) {
+ creatorAllowance = true;
+ $creatorState = CreatorState.WaitingPartnerAllowance;
+ }
+ console.log(partnerAllowance)
+
+ setTimeout(creatorResponse, 1000);
}
-
- if (partnerAllowance) {clearInterval(interval1); $creatorState = CreatorState.WaitingPartnerAllowance}
- if (creatorAllowance) {clearInterval(interval2); $partnerState = PartnerState.WaitingCreatorAllowance}
- // onMount(async ()=>{
-// creatorAllowance = await isAllowed($creatorSubOrder.token, interfaceID, $creatorSubOrder.quantity, $creatorSubOrder.tokenId)
-// console.log(creatorAllowance)
-// })
+ async function partnerResponse(){
+ if (partnerAllowance) return;
+ let response = await isAllowed($partnerSubOrder.token, $mainOrder.partner, interfaceID, $partnerSubOrder.quantity, $partnerSubOrder.tokenId)
+ console.log(response)
+ if (response) {
+ partnerAllowance = true;
+ $partnerState = PartnerState.WaitingCreatorAllowance;
+ }
+ console.log(partnerAllowance)
+
+ setTimeout(partnerResponse, 1000);
+ }
+
+
+
async function isAllowed(tokenAddress, owner, interfaceID, quantity, tokenId):Promise