Skip to content

Commit

Permalink
Merge pull request #1206 from kadena-community/fix/graph/simulate-fun…
Browse files Browse the repository at this point in the history
…ctionality

[@kadena/graph] Simulate script error and inclusion of build in start script (Fix)
  • Loading branch information
nil-amrutlal authored Nov 9, 2023
2 parents 2e36857 + 0a36ed9 commit 7ad8e83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/slow-scissors-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@kadena/graph': patch
---

Fix simulate script edge case (when it attempts cross-chain transfers to the
same chain). Add build step in start:generate script
2 changes: 1 addition & 1 deletion packages/apps/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prisma:studio": "prisma studio",
"simulate": "ts-node -T src/devnet/simulation/index.ts traffic",
"start": "npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
"start:generate": "pnpm run prisma:generate && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
"start:generate": "pnpm build && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
"test": "echo \"no test specified\""
},
"dependencies": {
Expand Down
8 changes: 7 additions & 1 deletion packages/apps/graph/src/devnet/simulation/simulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function simulate({

// This is to simulate cross chain transfers
if (transferType === 'xchaintransfer') {
while (account.chainId === nextAccount.chainId) {
if (account.chainId === nextAccount.chainId) {
nextAccount = {
...nextAccount,
chainId: `${getRandomNumber(
Expand All @@ -128,6 +128,12 @@ export async function simulate({
)}` as ChainId,
};
}

if (account.chainId === nextAccount.chainId) {
logger.info('Skipping cross chain transfer to same chain');
continue;
}

logger.info('Cross chain transfer', account, nextAccount);
result = await crossChainTransfer({
from: account,
Expand Down

0 comments on commit 7ad8e83

Please sign in to comment.