Skip to content

Commit b882f46

Browse files
author
Enrique A.
committed
Adding requestAccess logic to the cactus link module
1 parent cef6bbc commit b882f46

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/sdk/modules/cactuslink.module.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare const window: {
99
signTransaction(
1010
xdr: string,
1111
opts?: { address?: string; networkPassphrase?: string },
12-
): Promise<{ signedTxXdr: string}>;
12+
): Promise<{ signedTxXdr: string }>;
1313
signAuthEntry(
1414
authEntry: string,
1515
opts?: { address?: string; networkPassphrase?: string },
@@ -42,10 +42,15 @@ export class CactusLinkModule implements ModuleInterface {
4242
return typeof window !== "undefined" && !!window.cactuslink_stellar;
4343
}
4444

45-
async getAddress(): Promise<{ address: string }> {
45+
async getAddress(params: { skipRequestAccess?: boolean }): Promise<{ address: string }> {
4646
try {
4747
await this.runChecks();
4848

49+
if (params?.skipRequestAccess !== true) {
50+
const requestAccessResult = await window.cactuslink_stellar!.requestAccess();
51+
if (requestAccessResult.error) return Promise.reject(parseError(requestAccessResult.error));
52+
}
53+
4954
const { address } = await window.cactuslink_stellar!.getAddress();
5055
if (!address) {
5156
return Promise.reject({
@@ -100,7 +105,7 @@ export class CactusLinkModule implements ModuleInterface {
100105
}
101106

102107
return {
103-
signedAuthEntry
108+
signedAuthEntry,
104109
};
105110
} catch (e) {
106111
throw parseError(e);
@@ -127,7 +132,7 @@ export class CactusLinkModule implements ModuleInterface {
127132
}
128133

129134
return {
130-
signedMessage
135+
signedMessage,
131136
};
132137
} catch (e) {
133138
throw parseError(e);

0 commit comments

Comments
 (0)