Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daoauth committed Jan 14, 2025
1 parent d846d8a commit 2581e13
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
16 changes: 9 additions & 7 deletions packages/ptb-builder/src/ptbFlow/nodes/commands/MoveCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ export const MoveCall = ({ id, data }: PTBNodeProp) => {
selectedTypeArgs,
),
);
convertParams(
'source',
'result',
ptbModuleData.modules[moveCallData.module].exposedFunctions[
moveCallData.function
].return,
selectedTypeArgs,
setSelectedOutputs(
convertParams(
'source',
'result',
ptbModuleData.modules[moveCallData.module].exposedFunctions[
moveCallData.function
].return,
selectedTypeArgs,
),
);
}
setNodes((nds) =>
Expand Down
7 changes: 5 additions & 2 deletions packages/ptb-builder/src/utilities/ptb/generateCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const connvert = (
if (!id) {
return 'undefined';
}
if (id.endsWith('[]')) {
return dictionary[id.replace('[]', '')].name;
}
const match = id.match(/\[(\d+)\]$/);
if (match) {
return `${dictionary[id.replace(match[0], '')].name}[${match[1]}]`;
Expand Down Expand Up @@ -56,7 +59,7 @@ const genereateCommand = (
case PTBNodeType.SplitCoins:
if (inputs[1].length === 1) {
if (inputs[1][0].endsWith('[]')) {
return `tx.splitCoins(${connvert(inputs[0], dictionary)}, ${connvert(inputs[1][0], dictionary)})`;
return `tx.splitCoins([${connvert(inputs[0], dictionary)}], ${connvert(inputs[1][0], dictionary)})`;
}
return `tx.splitCoins(${connvert(inputs[0], dictionary)}, [${connvert(inputs[1][0], dictionary)}])`;
} else {
Expand All @@ -65,7 +68,7 @@ const genereateCommand = (
case PTBNodeType.MergeCoins:
if (inputs[1].length === 1) {
if (inputs[1][0].endsWith('[]')) {
return `tx.mergeCoins(${connvert(inputs[0], dictionary)}, ${connvert(inputs[1][0], dictionary)})`;
return `tx.mergeCoins([${connvert(inputs[0], dictionary)}], ${connvert(inputs[1][0], dictionary)})`;
}
return `tx.mergeCoins(${connvert(inputs[0], dictionary)}, [${connvert(inputs[1][0], dictionary)}])`;
} else {
Expand Down
24 changes: 11 additions & 13 deletions packages/ptb-builder/src/utilities/ptb/generateTxb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const connvert = (
if (!id) {
return undefined;
}
if (id.endsWith('[]')) {
return dictionary[id.replace('[]', '')];
}
const match = id.match(/\[(\d+)\]$/);
if (match) {
const data = dictionary[id.replace(`${match[0]}`, '')];
Expand Down Expand Up @@ -74,20 +77,18 @@ const genereateCommand = (
);
return {
tx,
nestedResults: (amounts as any[]).map(
(_, i) => result[i] as NestedResult,
),
nestedResults:
node.data.splitInputs === undefined
? result
: (amounts as any[]).map((_, i) => result[i] as NestedResult),
};
}
case PTBNodeType.MergeCoins: {
const destination = connvert(inputs[0], dictionary);
let sources;
if (inputs[1].length === 1) {
if (inputs[1][0].endsWith('[]')) {
sources = connvert(inputs[1][0], dictionary);
} else {
sources = [connvert(inputs[1][0], dictionary)];
}
const temp = connvert(inputs[1][0], dictionary);
sources = Array.isArray(temp) ? temp : [temp];
} else {
sources = inputs[1].map((v) => connvert(v, dictionary));
}
Expand All @@ -101,11 +102,8 @@ const genereateCommand = (
const address = connvert(inputs[0], dictionary);
let objects;
if (inputs[1].length === 1) {
if (inputs[1][0].endsWith('[]')) {
objects = connvert(inputs[1][0], dictionary);
} else {
objects = [connvert(inputs[1][0], dictionary)];
}
const temp = connvert(inputs[1][0], dictionary);
objects = Array.isArray(temp) ? temp : [temp];
} else {
objects = inputs[1].map((v) => connvert(v, dictionary));
}
Expand Down

0 comments on commit 2581e13

Please sign in to comment.