Skip to content

Commit

Permalink
chore: return preimage for intraledger payments in galoy connector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms authored Jan 24, 2024
1 parent 5b8fa25 commit 409f52a
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/extension/background-script/connectors/galoy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ class Galoy implements Connector {
}
}
... on SettlementViaIntraLedger {
__typename
counterPartyWalletId
counterPartyUsername
${
this.config.apiCompatibilityMode
? "counterPartyWalletId"
: "preImage"
}
}
}
}
Expand Down Expand Up @@ -203,7 +205,10 @@ class Galoy implements Connector {
transactions.push({
id: edge.cursor,
memo: tx.memo,
preimage: tx.settlementVia.preImage || "",
preimage:
tx.settlementVia.preImage ||
tx.settlementVia.paymentSecret ||
"",
payment_hash: tx.initiationVia.paymentHash || "",
settled: tx.status === "SUCCESS",
settleDate: createdAtDate.getTime(),
Expand Down Expand Up @@ -283,8 +288,11 @@ class Galoy implements Connector {
}
}
... on SettlementViaIntraLedger {
counterPartyUsername
counterPartyWalletId
${
this.config.apiCompatibilityMode
? "counterPartyWalletId"
: "preImage"
}
}
}
}
Expand Down Expand Up @@ -321,10 +329,7 @@ class Galoy implements Connector {
preimageMessage =
transaction.settlementVia.preImage ||
transaction.settlementVia.paymentSecret;
} else if (
"counterPartyUsername" in transaction.settlementVia ||
"counterPartyWalletId" in transaction.settlementVia
) {
} else if ("counterPartyWalletId" in transaction.settlementVia) {
preimageMessage = "No preimage, the payment was settled intraledger";
}
}
Expand Down Expand Up @@ -382,9 +387,11 @@ class Galoy implements Connector {
}
}
... on SettlementViaIntraLedger {
__typename
counterPartyWalletId
counterPartyUsername
${
this.config.apiCompatibilityMode
? "counterPartyWalletId"
: "preImage"
}
}
}
}
Expand Down Expand Up @@ -424,7 +431,7 @@ class Galoy implements Connector {
return {
data: {
paid: tx.node.status === "SUCCESS",
preimage: tx.node.settlementVia.__typename
preimage: tx.node.settlementVia.counterPartyWalletId
? "Payment executed internally"
: tx.node.settlementVia.preImage || "No preimage received",
},
Expand Down Expand Up @@ -531,9 +538,8 @@ type TransactionNode = {
};
settlementVia: {
preImage?: string;
__typename?: string;
paymentSecret?: string;
counterPartyWalletId?: string;
counterPartyUsername?: string;
};
};

Expand Down

0 comments on commit 409f52a

Please sign in to comment.