Skip to content

Commit

Permalink
fix ogmios submit
Browse files Browse the repository at this point in the history
  • Loading branch information
twwu123 committed Jan 14, 2025
1 parent 80fff1f commit 5098ef5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/mesh-provider/src/ogmios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class OgmiosProvider implements IEvaluator, ISubmitter {
}),
);
} else {
reject(result.EvaluationFailure);
reject(result);
}

client.close();
Expand Down Expand Up @@ -89,8 +89,10 @@ export class OgmiosProvider implements IEvaluator, ISubmitter {
async submitTx(tx: string): Promise<string> {
const client = await this.open();

this.send(client, "SubmitTx", {
submit: tx,
this.send(client, "submitTransaction", {
transaction: {
cbor: tx,
},
});

return new Promise((resolve, reject) => {
Expand All @@ -99,10 +101,18 @@ export class OgmiosProvider implements IEvaluator, ISubmitter {
(response: MessageEvent<string>) => {
try {
const { result } = JSON.parse(response.data);
if (result.SubmitSuccess) {
resolve(result.SubmitSuccess.txId);

if (!result) {
reject(JSON.parse(response.data).error);
}

if (
result.transaction !== null &&
result.transaction !== undefined
) {
resolve(result.transaction.id);
} else {
reject(result.SubmitFail);
reject(result);
}

client.close();
Expand Down

0 comments on commit 5098ef5

Please sign in to comment.