Skip to content

Commit

Permalink
small fixes to Recovery code (#75)
Browse files Browse the repository at this point in the history
* small fixes

* fix path payment test
  • Loading branch information
acharb authored Oct 30, 2023
1 parent 8c7ccfa commit 9920176
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/walletSdk/Recovery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
SponsoringBuilder,
Stellar,
} from "../Horizon";
import { camelToSnakeCaseObject } from "../Utils";

// Let's prevent exporting this constructor type as
// we should not create this Recovery class directly.
Expand Down Expand Up @@ -261,13 +262,13 @@ export class Recovery extends AccountRecover {
Object.keys(this.servers).map(async (key) => {
const server = this.servers[key];

const accountIdentity = identityMap[key];
const accountIdentities = identityMap[key];

if (!accountIdentity) {
if (!accountIdentities) {
throw new RecoveryIdentityNotFoundError(key);
}

const authToken = this.sep10Auth(key).authenticate({
const authToken = await this.sep10Auth(key).authenticate({
accountKp: account,
walletSigner: server.walletSigner,
clientDomain: server.clientDomain,
Expand All @@ -280,7 +281,9 @@ export class Recovery extends AccountRecover {
const resp = await this.httpClient.post(
requestUrl,
{
identities: accountIdentity,
identities: accountIdentities.map((ai) =>
camelToSnakeCaseObject(ai),
),
},
{
headers: {
Expand Down
10 changes: 3 additions & 7 deletions test/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ describe("Path Payment", () => {
sendAmount: "5",
})
.build();
sourceKp.sign(txn);
const success = await stellar.submitTransaction(txn);
expect(success).toBe(true);
expect(txn.operations[0].type).toBe("pathPaymentStrictSend");
}, 15000);

it("should use path payment receive", async () => {
Expand All @@ -308,16 +306,14 @@ describe("Path Payment", () => {
destAmount: "5",
})
.build();
sourceKp.sign(txn);
const success = await stellar.submitTransaction(txn);
expect(success).toBe(true);
expect(txn.operations[0].type).toBe("pathPaymentStrictReceive");
}, 15000);

it("should swap", async () => {
const txBuilder = await stellar.transaction({
sourceAddress: sourceKp,
});
const txn = txBuilder.swap(new NativeAssetId(), usdcAsset, "1").build();
const txn = txBuilder.swap(new NativeAssetId(), usdcAsset, ".1").build();
sourceKp.sign(txn);
const success = await stellar.submitTransaction(txn);
expect(success).toBe(true);
Expand Down

0 comments on commit 9920176

Please sign in to comment.