Skip to content

Commit

Permalink
deploy tx
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingjam committed Feb 14, 2025
1 parent e992e9c commit cd300fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
21 changes: 14 additions & 7 deletions packages/ui-components/src/__tests__/transactionStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ describe('transactionStore', () => {
deploymentCalldata: mockDeploymentCalldata,
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.PENDING_SUBGRAPH);
Expand All @@ -122,7 +123,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.ERROR);
Expand All @@ -141,7 +143,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.ERROR);
Expand All @@ -161,7 +164,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.ERROR);
Expand All @@ -178,7 +182,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.ERROR);
Expand All @@ -196,7 +201,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(get(transactionStore).status).toBe(TransactionStatus.ERROR);
Expand All @@ -222,7 +228,8 @@ describe('transactionStore', () => {
deploymentCalldata: '0x',
orderbookAddress: mockOrderbookAddress as `0x${string}`,
chainId: 1,
subgraphUrl: 'test.com'
subgraphUrl: 'test.com',
network: 'flare'
});

expect(sendTransaction).toHaveBeenCalledTimes(3); // 2 approvals + 1 deployment
Expand Down
19 changes: 12 additions & 7 deletions packages/ui-components/src/lib/stores/transactionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,23 @@ const transactionStore = () => {
status: TransactionStatus.PENDING_SUBGRAPH,
message: 'Waiting for new Order to be indexed...'
}));
console.log(network)
console.log(network);

let attempts = 0;
const interval: NodeJS.Timeout = setInterval(async () => {
attempts++;
console.log("attempts", attempts)
console.log('attempts', attempts);

const addOrders = await getTransactionAddOrders(subgraphUrl, txHash);
if (attempts >= 10) {
update((state) => ({
...state,
message: 'The subgraph took too long to respond. Please check again later.',
message: 'The subgraph took too long to respond. Please check again later.'
}));
clearInterval(interval);
return transactionError(TransactionErrorMessage.TIMEOUT);
} else if (addOrders.length > 0) {
console.log(addOrders)
console.log(addOrders);
clearInterval(interval);
return transactionSuccess(txHash, '', addOrders[0].order.id, network);
}
Expand Down Expand Up @@ -195,7 +195,12 @@ const transactionStore = () => {
status: TransactionStatus.PENDING_DEPLOYMENT,
message: 'Confirming transaction...'
}));
const transactionSuccess = (hash: string, message?: string, newOrderId?: string, network?: string) => {
const transactionSuccess = (
hash: string,
message?: string,
newOrderId?: string,
network?: string
) => {
update((state) => ({
...state,
status: TransactionStatus.SUCCESS,
Expand All @@ -220,7 +225,7 @@ const transactionStore = () => {
orderbookAddress,
chainId,
subgraphUrl,
network
network
}: DeploymentTransactionArgs) => {
try {
await switchChain(config, { chainId });
Expand Down Expand Up @@ -261,7 +266,7 @@ const transactionStore = () => {
try {
awaitDeployTx(hash);
await waitForTransactionReceipt(config, { hash });
return awaitNewOrderIndexing(subgraphUrl, hash, network);
return awaitNewOrderIndexing(subgraphUrl, hash, network);
} catch {
return transactionError(TransactionErrorMessage.DEPLOYMENT_FAILED);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/lib/components/TransactionModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</div>
{:else}
<div
class="bg-primary-100 dark:bg-primary-900 mb-4 flex h-16 w-16 items-center justify-center rounded-full"
class="mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary-100 dark:bg-primary-900"
>
<Spinner color="blue" size={10} />
</div>
Expand Down

0 comments on commit cd300fe

Please sign in to comment.