Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes to Recovery code #75

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

@acharb acharb Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated fix. This test fails intermittently when usdc-xlm order book is volatile on testnet, so fixing to just check the operation type (.swap is still submitting to the network and uses .pathPay)

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
Loading