Skip to content

Commit 7ad8e83

Browse files
authored
Merge pull request #1206 from kadena-community/fix/graph/simulate-functionality
[@kadena/graph] Simulate script error and inclusion of build in start script (Fix)
2 parents 2e36857 + 0a36ed9 commit 7ad8e83

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.changeset/slow-scissors-provide.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@kadena/graph': patch
3+
---
4+
5+
Fix simulate script edge case (when it attempts cross-chain transfers to the
6+
same chain). Add build step in start:generate script

packages/apps/graph/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"prisma:studio": "prisma studio",
2727
"simulate": "ts-node -T src/devnet/simulation/index.ts traffic",
2828
"start": "npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
29-
"start:generate": "pnpm run prisma:generate && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
29+
"start:generate": "pnpm build && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
3030
"test": "echo \"no test specified\""
3131
},
3232
"dependencies": {

packages/apps/graph/src/devnet/simulation/simulate.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export async function simulate({
119119

120120
// This is to simulate cross chain transfers
121121
if (transferType === 'xchaintransfer') {
122-
while (account.chainId === nextAccount.chainId) {
122+
if (account.chainId === nextAccount.chainId) {
123123
nextAccount = {
124124
...nextAccount,
125125
chainId: `${getRandomNumber(
@@ -128,6 +128,12 @@ export async function simulate({
128128
)}` as ChainId,
129129
};
130130
}
131+
132+
if (account.chainId === nextAccount.chainId) {
133+
logger.info('Skipping cross chain transfer to same chain');
134+
continue;
135+
}
136+
131137
logger.info('Cross chain transfer', account, nextAccount);
132138
result = await crossChainTransfer({
133139
from: account,

0 commit comments

Comments
 (0)