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

[BUG] Correctly import new seed phrase #1412

Merged
merged 33 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
15124fd
Feature/standard wallet interface (#1357)
piyalbasu Jul 12, 2024
00be5d3
Feature/standard wallet interface docs (#1370)
piyalbasu Jul 17, 2024
ace7a24
add wallet change watcher + docs (#1373)
piyalbasu Jul 17, 2024
483414b
add isNonSSELEnabled flag and use that to block non-https tx's (#1374)
piyalbasu Jul 18, 2024
f81989e
moving isNonSSLEnabled to Advanced Settings
piyalbasu Jul 18, 2024
b554a20
Merge branch 'release/5.23.0' of github.com:stellar/freighter into re…
piyalbasu Jul 18, 2024
f89ee48
moving isNonSSLEnabled to Advanced Settings (#1375)
piyalbasu Jul 18, 2024
ef5d97c
Feature/connect dapp warning (#1361)
aristidesstaffieri Jul 18, 2024
c2a56de
[BUG] SAC balance shows up twice in asset list (#1376)
aristidesstaffieri Jul 22, 2024
7125832
Merge branch 'release/5.23.0' of github.com:stellar/freighter into re…
piyalbasu Jul 22, 2024
3adcd7b
Feature/doc preview build master (#1379)
piyalbasu Jul 22, 2024
9ece7d4
Merge branch 'release/5.23.0' of github.com:stellar/freighter into re…
piyalbasu Jul 22, 2024
077f20a
Bugfix/move netlify toml 2 (#1381)
piyalbasu Jul 22, 2024
7bd7158
bump freighter-api version to trigger docs build
piyalbasu Jul 23, 2024
880a215
Merge branch 'release/5.23.0' of github.com:stellar/freighter into re…
piyalbasu Jul 23, 2024
1e24b40
fix toml
piyalbasu Jul 23, 2024
30d6e67
try different netlify context
piyalbasu Jul 23, 2024
7b21d06
update yarn.lock and defensive check for blockaid "miss"
piyalbasu Jul 23, 2024
aa527a2
Merge branch 'master' into release/5.23.0
piyalbasu Jul 25, 2024
8236195
dont show dapp scan warning in grant access (#1390)
aristidesstaffieri Jul 29, 2024
6c3a584
Bugfix/sign msg auth entry buffer (#1392)
piyalbasu Jul 30, 2024
dd3f114
Merge branch 'master' into release/5.23.0
piyalbasu Jul 30, 2024
853db22
Bugfix/re enable tests (#1395)
piyalbasu Jul 30, 2024
7ef99fb
adds tx scan calls during tx sign, no UI warnings (#1393)
aristidesstaffieri Jul 31, 2024
a957de1
scan asset during Add Asset flow and Sign classic tx flow (#1405)
piyalbasu Aug 8, 2024
ce09822
upgrading ledger SDK (#1407)
piyalbasu Aug 9, 2024
273a5dd
rm ssl toggle from Preferences (#1408)
piyalbasu Aug 9, 2024
be51e69
Bump fast-xml-parser in the npm_and_yarn group across 1 directory (#1…
dependabot[bot] Aug 9, 2024
40f3fb7
Bump the minor-and-patch group across 3 directories with 26 updates (…
dependabot[bot] Aug 9, 2024
a0aa528
minor updates after merging automated dep updates (#1409)
piyalbasu Aug 9, 2024
24114a9
Merge branch 'master' into release/5.23.0
piyalbasu Aug 9, 2024
e58887a
clears session store before recovering account to avoid stale account…
aristidesstaffieri Aug 12, 2024
efb874b
Merge branch 'release/5.23.1' into fix/seed-import-reset-session
aristidesstaffieri Aug 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
timeout-minutes: 20
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.41.0-jammy
image: mcr.microsoft.com/playwright:v1.45.3-jammy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
238 changes: 128 additions & 110 deletions @shared/api/external.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { EXTERNAL_SERVICE_TYPES } from "../constants/services";
import { NetworkDetails } from "../constants/stellar";
import { sendMessageToContentScript } from "./helpers/extensionMessaging";
import { UserInfo } from "./types";

export const requestAccess = async (): Promise<string> => {
let response = { publicKey: "", error: "" };
import {
sendMessageToContentScript,
FreighterApiInternalError,
} from "./helpers/extensionMessaging";
import { FreighterApiError } from "./types";

export const requestAccess = async (): Promise<{
publicKey: string;
error?: FreighterApiError;
}> => {
let response;
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_ACCESS,
Expand All @@ -13,16 +19,16 @@ export const requestAccess = async (): Promise<string> => {
console.error(e);
}

const { publicKey, error } = response;
const { publicKey } = response || { publicKey: "" };

if (error) {
throw error;
}
return publicKey;
return { publicKey, error: response?.apiError };
};

export const requestPublicKey = async (): Promise<string> => {
let response = { publicKey: "", error: "" };
export const requestPublicKey = async (): Promise<{
publicKey: string;
error?: FreighterApiError;
}> => {
let response;
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_PUBLIC_KEY,
Expand All @@ -31,25 +37,23 @@ export const requestPublicKey = async (): Promise<string> => {
console.error(e);
}

const { publicKey, error } = response;

if (error) {
throw error;
}
return publicKey;
return { publicKey: response?.publicKey || "", error: response?.apiError };
};

export const submitTransaction = async (
transactionXdr: string,
opts?:
| string
| {
network?: string;
accountToSign?: string;
networkPassphrase?: string;
},
accountToSign?: string,
): Promise<string> => {
): Promise<{
signedTransaction: string;
signerAddress: string;
error?: FreighterApiError;
}> => {
let network = "";
let _accountToSign = "";
let networkPassphrase = "";
Expand All @@ -60,15 +64,14 @@ export const submitTransaction = async (
This logic maintains backwards compatibility for older versions
*/
if (typeof opts === "object") {
network = opts.network || "";
_accountToSign = opts.accountToSign || "";
networkPassphrase = opts.networkPassphrase || "";
} else {
network = opts || "";
_accountToSign = accountToSign || "";
}

let response = { signedTransaction: "", error: "" };
let response;
try {
response = await sendMessageToContentScript({
transactionXdr,
Expand All @@ -78,127 +81,158 @@ export const submitTransaction = async (
type: EXTERNAL_SERVICE_TYPES.SUBMIT_TRANSACTION,
});
} catch (e) {
console.error(e);
throw e;
return {
signedTransaction: "",
signerAddress: "",
error: FreighterApiInternalError,
};
}
const { signedTransaction, error } = response;
const { signedTransaction, signerAddress } = response;

if (error) {
throw error;
}
return signedTransaction;
return { signedTransaction, signerAddress, error: response?.apiError };
};

export const submitBlob = async (
export const submitMessage = async (
blob: string,
opts?: {
accountToSign?: string;
address?: string;
networkPassphrase?: string;
},
): Promise<string> => {
let response = { signedBlob: "", error: "" };
): Promise<{
signedMessage: Buffer | null;
signerAddress: string;
error?: FreighterApiError;
}> => {
let response;
const _opts = opts || {};
const accountToSign = _opts.accountToSign || "";
const accountToSign = _opts.address || "";
try {
response = await sendMessageToContentScript({
blob,
accountToSign,
type: EXTERNAL_SERVICE_TYPES.SUBMIT_BLOB,
});
} catch (e) {
console.error(e);
throw e;
return {
signedMessage: null,
signerAddress: "",
error: FreighterApiInternalError,
};
}
const { signedBlob, error } = response;
const { signedBlob, signerAddress } = response;

if (error) {
throw error;
}
return signedBlob;
return {
signedMessage: signedBlob || null,
signerAddress,
error: response?.apiError,
};
};

export const submitAuthEntry = async (
entryXdr: string,
opts?: {
accountToSign?: string;
address?: string;
networkPassphrase?: string;
},
): Promise<string> => {
let response = { signedAuthEntry: "", error: "" };
): Promise<{
signedAuthEntry: Buffer | null;
signerAddress: string;
error?: FreighterApiError;
}> => {
const _opts = opts || {};
const accountToSign = _opts.accountToSign || "";
const accountToSign = _opts.address || "";
let response;
try {
response = await sendMessageToContentScript({
entryXdr,
accountToSign,
networkPassphrase: opts?.networkPassphrase,
type: EXTERNAL_SERVICE_TYPES.SUBMIT_AUTH_ENTRY,
});
} catch (e) {
console.error(e);
return {
signedAuthEntry: null,
signerAddress: "",
error: FreighterApiInternalError,
};
}
const { signedAuthEntry, error } = response;
const { signedAuthEntry, signerAddress } = response;

if (error) {
throw error;
}
return signedAuthEntry;
return {
signedAuthEntry: signedAuthEntry || null,
signerAddress,
error: response?.apiError,
};
};

export const requestNetwork = async (): Promise<string> => {
let response = { network: "", error: "" };
export const requestNetwork = async (): Promise<{
network: string;
networkPassphrase: string;
error?: FreighterApiError;
}> => {
let response;
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_NETWORK,
type: EXTERNAL_SERVICE_TYPES.REQUEST_NETWORK_DETAILS,
});
} catch (e) {
console.error(e);
}

const { network, error } = response;
const { networkDetails } = response || {
networkDetails: { network: "", networkPassphrase: "" },
};

if (error) {
throw error;
}
return network;
return {
network: networkDetails?.network,
networkPassphrase: networkDetails?.networkPassphrase,
error: response?.apiError,
};
};

export const requestNetworkDetails = async (): Promise<{
network: string;
networkUrl: string;
networkPassphrase: string;
sorobanRpcUrl?: string;
error?: FreighterApiError;
}> => {
let response = {
let response;
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_NETWORK_DETAILS,
});
} catch (e) {
console.error(e);
}

const { networkDetails, apiError } = response || {
networkDetails: {
network: "",
networkName: "",
networkUrl: "",
networkPassphrase: "",
sorobanRpcUrl: undefined,
apiError: "",
} as NetworkDetails,
error: "",
};
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_NETWORK_DETAILS,
});
} catch (e) {
console.error(e);
}

const { networkDetails, error } = response;
const {
const { network, networkUrl, networkPassphrase, sorobanRpcUrl } =
networkDetails;

return {
network,
networkUrl,
networkPassphrase,
sorobanRpcUrl,
} = networkDetails;

if (error) {
throw error;
}
return { network, networkUrl, networkPassphrase, sorobanRpcUrl };
error: apiError,
};
};

export const requestConnectionStatus = async (): Promise<boolean> => {
export const requestConnectionStatus = async (): Promise<{
isConnected: boolean;
}> => {
let response = {
isConnected: false,
};
Expand All @@ -211,13 +245,14 @@ export const requestConnectionStatus = async (): Promise<boolean> => {
console.error(e);
}

return response.isConnected;
return { isConnected: response.isConnected };
};

export const requestAllowedStatus = async (): Promise<boolean> => {
let response = {
isAllowed: false,
};
export const requestAllowedStatus = async (): Promise<{
isAllowed: boolean;
error?: FreighterApiError;
}> => {
let response;

try {
response = await sendMessageToContentScript({
Expand All @@ -227,14 +262,16 @@ export const requestAllowedStatus = async (): Promise<boolean> => {
console.error(e);
}

return response.isAllowed;
const { isAllowed } = response || { isAllowed: false };

return { isAllowed, error: response?.apiError };
};

export const setAllowedStatus = async (): Promise<boolean> => {
let response = {
isAllowed: false,
error: "",
};
export const setAllowedStatus = async (): Promise<{
isAllowed: boolean;
error?: FreighterApiError;
}> => {
let response;

try {
response = await sendMessageToContentScript({
Expand All @@ -244,28 +281,9 @@ export const setAllowedStatus = async (): Promise<boolean> => {
console.error(e);
}

const { isAllowed, error } = response;

if (error) {
throw error;
}
return isAllowed;
};

export const requestUserInfo = async (): Promise<UserInfo> => {
let response = { userInfo: { publicKey: "" }, error: "" };
try {
response = await sendMessageToContentScript({
type: EXTERNAL_SERVICE_TYPES.REQUEST_USER_INFO,
});
} catch (e) {
console.error(e);
}

const { userInfo, error } = response;
const { isAllowed } = response || {
isAllowed: false,
};

if (error) {
throw error;
}
return userInfo;
return { isAllowed, error: response?.apiError };
};
Loading