Skip to content

Commit

Permalink
chore: support arweave jwk for turbo storage (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler authored Jan 14, 2025
1 parent 452af7f commit dde47da
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions common/protocol/src/reactors/storageProviders/Turbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,31 @@ export class Turbo implements IStorageProvider {
public name = "Turbo";
public coinDecimals = 12;

private readonly mnemonic: string;
private readonly privateKey: string;

constructor(mnemonic: string) {
if (!mnemonic) {
throw new Error("Mnemonic is empty.");
constructor(privateKey: string) {
if (!privateKey) {
throw new Error("PrivateKey is empty.");
}

this.mnemonic = mnemonic;
this.privateKey = privateKey;
}

private async authenticatedTurbo(): Promise<TurboAuthenticatedClient> {
return TurboFactory.authenticated({
privateKey: await privateKeyFromKyveMnemonic(this.mnemonic),
token: "kyve",
});
try {
return TurboFactory.authenticated({
privateKey: await privateKeyFromKyveMnemonic(this.privateKey),
token: "kyve",
});
} catch (err: any) {
if (err.message === "Invalid mnemonic format") {
return TurboFactory.authenticated({
privateKey: JSON.parse(this.privateKey),
});
}

throw err;
}
}

private unauthenticatedTurbo(): TurboUnauthenticatedClient {
Expand Down

0 comments on commit dde47da

Please sign in to comment.