Skip to content

Commit

Permalink
Merge branch 'master' into xdr-json-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits authored Dec 4, 2024
2 parents df50e5f + 29c2377 commit dd9e7c6
Show file tree
Hide file tree
Showing 7 changed files with 579 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/app/(sidebar)/account/saved/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,14 @@ const SavedKeypairItem = ({
};

return (
<Box gap="sm" addlClassName="PageBody__content">
<Box
gap="sm"
addlClassName="PageBody__content"
data-testid="saved-keypair-item"
>
<Input
id={`saved-kp-${keypair.timestamp}-name`}
data-testid="saved-keypair-name"
fieldSize="md"
value={keypair.name}
readOnly
Expand All @@ -319,6 +324,7 @@ const SavedKeypairItem = ({

<Input
id={`saved-kp-${keypair.timestamp}-pk`}
data-testid="saved-keypair-pk"
fieldSize="md"
value={keypair.publicKey}
readOnly
Expand All @@ -328,6 +334,7 @@ const SavedKeypairItem = ({

<Input
id={`saved-kp-${keypair.timestamp}-sk`}
data-testid="saved-keypair-sk"
fieldSize="md"
value={keypair.secretKey}
readOnly
Expand Down
21 changes: 16 additions & 5 deletions src/app/(sidebar)/endpoints/components/SavedEndpointsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const SavedEndpointsPage = () => {

const HorizonEndpoints = () => {
if (savedEndpointsHorizon.length === 0) {
return "There are no saved Horizon Endpoints";
return `There are no saved Horizon Endpoints on ${network.label} network`;
}

return (
Expand All @@ -163,9 +163,11 @@ export const SavedEndpointsPage = () => {
gap="sm"
key={`horizon-${e.timestamp}`}
addlClassName="PageBody__content"
data-testid="saved-requests-horizon-item"
>
<Input
id={`saved-horizon-${e.timestamp}`}
data-testid="saved-horizon-name"
fieldSize="md"
value={e.name}
readOnly
Expand All @@ -178,13 +180,15 @@ export const SavedEndpointsPage = () => {
setCurrentRequestTimestamp(e.timestamp);
}}
icon={<Icon.Edit05 />}
data-testid="saved-horizon-edit"
/>
}
/>

<div className="Endpoints__urlBar">
<Input
id={`endpoint-url-${e.timestamp}`}
data-testid="saved-horizon-url"
fieldSize="md"
value={e.url}
readOnly
Expand Down Expand Up @@ -255,16 +259,17 @@ export const SavedEndpointsPage = () => {

const RpcEndpoints = () => {
if (savedRpcMethods.length === 0) {
return "There are no saved RPC Methods";
return `There are no saved RPC Methods ${network.label} network`;
}

return (
<Box gap="md">
{savedRpcMethods.map((e, idx) => (
<Box
gap="sm"
key={`horizon-${e.timestamp}`}
key={`rpc-${e.timestamp}`}
addlClassName="PageBody__content"
data-testid="saved-requests-rpc-item"
>
<Box gap="sm" direction="row">
<Badge size="md" variant="secondary">
Expand All @@ -274,6 +279,7 @@ export const SavedEndpointsPage = () => {

<Input
id={`saved-rpc-${e.timestamp}`}
data-testid="saved-rpc-name"
fieldSize="md"
value={e.name}
readOnly
Expand All @@ -286,13 +292,15 @@ export const SavedEndpointsPage = () => {
setCurrentRequestTimestamp(e.timestamp);
}}
icon={<Icon.Edit05 />}
data-testid="saved-rpc-edit"
/>
}
/>

<div className="Endpoints__urlBar">
<Input
id={`endpoint-url-${e.timestamp}`}
data-testid="saved-rpc-url"
fieldSize="md"
value={e.url}
readOnly
Expand Down Expand Up @@ -375,7 +383,10 @@ export const SavedEndpointsPage = () => {
</Box>
{expandedPayloadIndex[idx] ? (
<>
<div className="Endpoints__txTextarea">
<div
className="Endpoints__txTextarea"
data-testid="saved-rpc-payload"
>
<PrettyJsonTextarea json={e.payload} label="Payload" />
</div>
<Box gap="md" direction="row" justify="end">
Expand All @@ -394,7 +405,7 @@ export const SavedEndpointsPage = () => {
};

return (
<Box gap="md">
<Box gap="md" data-testid="saved-requests-container">
<PageCard>
<TabView
heading={{ title: "Saved Requests" }}
Expand Down
11 changes: 11 additions & 0 deletions src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@

select {
font-weight: var(--sds-fw-semi-bold);
padding-left: pxToRem(18px);
}

optgroup {
Expand All @@ -118,6 +119,16 @@
.Select__icon {
right: auto;
left: pxToRem(8px);
top: pxToRem(4px);
width: pxToRem(24px);
height: pxToRem(24px);
border: 1px solid var(--sds-clr-gray-06);
border-radius: pxToRem(24px);

svg {
width: pxToRem(16px);
height: pxToRem(16px);
}
}

.Select__container {
Expand Down
132 changes: 132 additions & 0 deletions tests/mock/localStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
export const SAVED_ACCOUNT_1 =
"GA46LGGOLXJY5OSX6N4LHV4MWDFXNGLK76I4NDNKKYAXRRSKI5AJGMXG";
export const SAVED_ACCOUNT_1_SECRET =
"SADVGAH3VA3NGZ5VLX2ZICV7JQAINB2ZJZYOPMBXUNI3YRLGWLOA2OFY";
export const SAVED_ACCOUNT_2 =
"GC5TQ7TXKHGE5JQMZPYV5KBSQ67X6PYQVU5QN7JRGWCHRA227UFPZ6LD";
export const SAVED_ACCOUNT_2_SECRET =
"SCPPMMBZBQGTGQKIPGFJDOHOPGK7SXZJGMYF76PFHF2PBLY2RWGZNSVV";

const SAVED_ACCOUNTS = [
{
timestamp: 1732287853955,
network: {
id: "testnet",
label: "Testnet",
},
name: "Account 1",
publicKey: SAVED_ACCOUNT_1,
secretKey: SAVED_ACCOUNT_1_SECRET,
},
{
timestamp: 1731083842367,
network: {
id: "testnet",
label: "Testnet",
},
name: "Account 2",
publicKey: SAVED_ACCOUNT_2,
secretKey: SAVED_ACCOUNT_2_SECRET,
},
];

const SAVED_HORIZON_ENDPOINTS = [
{
timestamp: 1733173821853,
network: { id: "testnet", label: "Testnet" },
name: "Transactions",
url: "https://horizon-testnet.stellar.org/transactions?limit=5&order=desc",
method: "GET",
route: "/endpoints/transactions",
params: { order: "desc", limit: "5" },
shareableUrl:
"https://lab.stellar.org/endpoints/transactions?$=network$id=testnet&label=Testnet&horizonUrl=https:////horizon-testnet.stellar.org&rpcUrl=https:////soroban-testnet.stellar.org&passphrase=Test%20SDF%20Network%20/;%20September%202015;&endpoints$params$order=desc&limit=5;;",
},
{
timestamp: 1733233624053,
network: { id: "testnet", label: "Testnet" },
name: "Account",
url: "https://horizon-testnet.stellar.org/accounts/GA46LGGOLXJY5OSX6N4LHV4MWDFXNGLK76I4NDNKKYAXRRSKI5AJGMXG",
method: "GET",
route: "/endpoints/accounts/single",
params: {
account_id: "GA46LGGOLXJY5OSX6N4LHV4MWDFXNGLK76I4NDNKKYAXRRSKI5AJGMXG",
},
shareableUrl:
"https://lab.stellar.org/endpoints/accounts/single?$=network$id=testnet&label=Testnet&horizonUrl=https:////horizon-testnet.stellar.org&rpcUrl=https:////soroban-testnet.stellar.org&passphrase=Test%20SDF%20Network%20/;%20September%202015;&endpoints$params$account_id=GA46LGGOLXJY5OSX6N4LHV4MWDFXNGLK76I4NDNKKYAXRRSKI5AJGMXG;;",
},
];

const SAVED_RPC_ENDPOINTS = [
{
timestamp: 1733173721157,
network: { id: "testnet", label: "Testnet" },
name: "Transactions",
url: "https://soroban-testnet.stellar.org",
method: "POST",
route: "/endpoints/rpc/get-transactions",
params: { startLedger: "1268840", limit: "5" },
shareableUrl:
"https://lab.stellar.org/endpoints/rpc/get-transactions?$=network$id=testnet&label=Testnet&horizonUrl=https:////horizon-testnet.stellar.org&rpcUrl=https:////soroban-testnet.stellar.org&passphrase=Test%20SDF%20Network%20/;%20September%202015;&endpoints$params$startLedger=1268840&limit=5;;",
payload: {
jsonrpc: "2.0",
id: 8675309,
method: "getTransactions",
params: {
startLedger: 1268840,
pagination: { limit: 5 },
xdrFormat: "base64",
},
},
rpcMethod: "getTransactions",
},
{
timestamp: 1733233741685,
network: { id: "testnet", label: "Testnet" },
name: "Simulate",
url: "https://soroban-testnet.stellar.org",
method: "POST",
route: "/endpoints/rpc/simulate-transaction",
params: {
tx: "AAAAAgAAAAAYheerp3FCahtW+3qusxzklJhfxMPQJERfPKY0lXnVjQAPQkAADQg/AAAAJAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAADGfZUR9pNoQGv+u6uGjdcwVF3zlb/mjyN53fUCn+iBGQAAABdIdugAAAAAAAAAAAKVedWNAAAAQA8JEfXRL2BLjcYHYX+6Dloij4OIR44zsu6hd9CSI/rQSgGulcIFmzY0sX4LIxdwCg/3UMOfXFEpGxIsDvaJEQuGVuCcAAAAQBYyy1VZl3iPQBI4hyv4e91Xv9KfM54jWWLVoh2HEjTWzPUsTlo6e2u/zGi+dcZxbNy/1MV9ipZuflVzLHPKlgs=",
resourceConfig: "1714814",
},
shareableUrl:
"https://lab.stellar.org/endpoints/rpc/simulate-transaction?$=network$id=testnet&label=Testnet&horizonUrl=https:////horizon-testnet.stellar.org&rpcUrl=https:////soroban-testnet.stellar.org&passphrase=Test%20SDF%20Network%20/;%20September%202015;&endpoints$params$tx=AAAAAgAAAAAYheerp3FCahtW+3qusxzklJhfxMPQJERfPKY0lXnVjQAPQkAADQg//AAAAJAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAADGfZUR9pNoQGv+u6uGjdcwVF3zlb//mjyN53fUCn+iBGQAAABdIdugAAAAAAAAAAAKVedWNAAAAQA8JEfXRL2BLjcYHYX+6Dloij4OIR44zsu6hd9CSI//rQSgGulcIFmzY0sX4LIxdwCg//3UMOfXFEpGxIsDvaJEQuGVuCcAAAAQBYyy1VZl3iPQBI4hyv4e91Xv9KfM54jWWLVoh2HEjTWzPUsTlo6e2u//zGi+dcZxbNy//1MV9ipZuflVzLHPKlgs=&resourceConfig=1714814;&saved$activeTab=rpc;;",
payload: {
jsonrpc: "2.0",
id: 8675309,
method: "simulateTransaction",
params: {
transaction:
"AAAAAgAAAAAYheerp3FCahtW+3qusxzklJhfxMPQJERfPKY0lXnVjQAPQkAADQg/AAAAJAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAADGfZUR9pNoQGv+u6uGjdcwVF3zlb/mjyN53fUCn+iBGQAAABdIdugAAAAAAAAAAAKVedWNAAAAQA8JEfXRL2BLjcYHYX+6Dloij4OIR44zsu6hd9CSI/rQSgGulcIFmzY0sX4LIxdwCg/3UMOfXFEpGxIsDvaJEQuGVuCcAAAAQBYyy1VZl3iPQBI4hyv4e91Xv9KfM54jWWLVoh2HEjTWzPUsTlo6e2u/zGi+dcZxbNy/1MV9ipZuflVzLHPKlgs=",
resourceConfig: { instructionLeeway: 1714814 },
xdrFormat: "base64",
},
},
rpcMethod: "simulateTransaction",
},
];

export const MOCK_LOCAL_STORAGE = {
cookies: [],
origins: [
{
origin: "http://localhost:3000",
localStorage: [
{
name: "stellar_lab_saved_keypairs",
value: JSON.stringify(SAVED_ACCOUNTS),
},
{
name: "stellar_lab_saved_horizon_endpoints",
value: JSON.stringify(SAVED_HORIZON_ENDPOINTS),
},
{
name: "stellar_lab_saved_rpc_endpoints",
value: JSON.stringify(SAVED_RPC_ENDPOINTS),
},
],
},
],
};
Loading

0 comments on commit dd9e7c6

Please sign in to comment.