Skip to content

Commit

Permalink
Add the ability to set options when creating a jwk_update txn (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
heliuchuan authored Oct 22, 2024
1 parent 53a066f commit b741a1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/api/keyless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getProof,
updateFederatedKeylessJwkSetTransaction,
} from "../internal/keyless";
import { SimpleTransaction } from "../transactions";
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions";
import { HexInput } from "../types";
import { AptosConfig } from "./aptosConfig";

Expand Down Expand Up @@ -214,6 +214,7 @@ export class Keyless {
sender: Account;
iss: string;
jwksUrl?: string;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction> {
return updateFederatedKeylessJwkSetTransaction({ aptosConfig: this.config, ...args });
}
Expand Down
6 changes: 4 additions & 2 deletions src/internal/keyless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { FederatedKeylessPublicKey } from "../core/crypto/federatedKeyless";
import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount";
import { MoveVector } from "../bcs";
import { generateTransaction } from "./transactionSubmission";
import { SimpleTransaction } from "../transactions";
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions";

/**
* Retrieves a pepper value based on the provided configuration and authentication details.
Expand Down Expand Up @@ -218,8 +218,9 @@ export async function updateFederatedKeylessJwkSetTransaction(args: {
sender: Account;
iss: string;
jwksUrl?: string;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction> {
const { aptosConfig, sender, iss } = args;
const { aptosConfig, sender, iss, options } = args;
const jwksUrl = args.jwksUrl ?? (iss.endsWith("/") ? `${iss}.well-known/jwks.json` : `${iss}/.well-known/jwks.json`);
const response = await fetch(jwksUrl);
if (!response.ok) {
Expand All @@ -239,5 +240,6 @@ export async function updateFederatedKeylessJwkSetTransaction(args: {
MoveVector.MoveString(jwks.keys.map((key) => key.n)),
],
},
options,
});
}

0 comments on commit b741a1c

Please sign in to comment.