Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b2b8afa
refactor: use environment instead of apiUrl
bergarces Jan 16, 2024
3c70d3c
chore: patch to run tests
bergarces Jan 16, 2024
824fe7e
feat: progress
bergarces Jan 16, 2024
31dc71e
fix: minor test changes
bergarces Jan 16, 2024
9a8ede5
fix: lock file
bergarces Jan 16, 2024
af09368
fix: change parameter name
bergarces Jan 16, 2024
e261983
missing package patch
bergarces Jan 16, 2024
7fd2a83
fix: progress
bergarces Jan 17, 2024
9776bb0
fix: patch updates
bergarces Jan 18, 2024
98a9b92
fix: add migration
bergarces Jan 18, 2024
d2066c6
fix: add migration
bergarces Jan 18, 2024
4e2b1e8
fix: patch
bergarces Jan 18, 2024
cec0a96
fix: more patch changes
bergarces Jan 18, 2024
3ff297d
fix: rebased changes
bergarces Jan 18, 2024
18d0a34
fix: revert migration
bergarces Jan 18, 2024
6546fc8
fix: missing lock file
bergarces Jan 18, 2024
6526753
Merge branch 'develop' into MMI-2119-env-name-as-key
bergarces Jan 19, 2024
02b1e52
remove patches
bergarces Jan 23, 2024
09cb481
Merge branch 'develop' into MMI-2119-env-name-as-key
bergarces Jan 23, 2024
658c90c
remove apiUrl from account array
bergarces Jan 23, 2024
220420f
dedupe
bergarces Jan 24, 2024
602e12d
Merge branch 'develop' into MMI-2119-env-name-as-key
bergarces Jan 24, 2024
1701c0d
remove log refactors for safety
bergarces Jan 24, 2024
ce84a43
remove comments and logs
bergarces Jan 24, 2024
bc23ace
update view to remove api-url input text, as we dont need it anymore
zone-live Feb 5, 2024
1fdf5c5
removes unused string and unit test
zone-live Feb 5, 2024
b3a7935
removes unused string
zone-live Feb 6, 2024
802f282
Merge branch 'develop' into MMI-2119-env-name-as-key
zone-live Feb 6, 2024
5988962
adds fallback for when custodian doesn't have a env name, will use it…
zone-live Feb 8, 2024
796f42a
lint fix
zone-live Feb 8, 2024
f5c77e9
Merge branch 'develop' into MMI-2119-env-name-as-key
zone-live Feb 8, 2024
0bdc58b
Merge branch 'develop' into MMI-2119-env-name-as-key
zone-live Feb 14, 2024
7d55e07
packages update
zone-live Feb 14, 2024
44c5663
Merge branch 'MMI-2119-env-name-as-key' of github.com:MetaMask/metama…
zone-live Feb 14, 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
3 changes: 0 additions & 3 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/es/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/fr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/hi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/id/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ja/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ko/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/pt/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ru/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tl/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/vi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/zh_CN/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions app/scripts/controllers/mmi-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default class MMIController extends EventEmitter {
custodianDetails: accounts[item].custodianDetails,
labels: accounts[item].labels,
token: accounts[item].token,
apiUrl: accounts[item].apiUrl,
envName: custodianName,
custodyType: custodian.keyringClass.type,
chainId: accounts[item].chainId,
})),
Expand All @@ -278,7 +278,6 @@ export default class MMIController extends EventEmitter {
name: accounts[item].name,
custodianDetails: accounts[item].custodianDetails,
labels: accounts[item].labels,
apiUrl: accounts[item].apiUrl,
custodyType: custodian.keyringClass.type,
custodianName,
chainId: accounts[item].chainId,
Expand Down Expand Up @@ -362,7 +361,7 @@ export default class MMIController extends EventEmitter {

async getCustodianAccounts(
token,
apiUrl,
envName,
custodianType,
getNonImportedAccounts,
) {
Expand Down Expand Up @@ -391,14 +390,14 @@ export default class MMIController extends EventEmitter {

const accounts = await keyring.getCustodianAccounts(
token,
apiUrl,
envName,
null,
getNonImportedAccounts,
);
return accounts;
}

async getCustodianAccountsByAddress(token, apiUrl, address, custodianType) {
async getCustodianAccountsByAddress(token, envName, address, custodianType) {
let keyring;

if (custodianType) {
Expand All @@ -412,7 +411,11 @@ export default class MMIController extends EventEmitter {
throw new Error('No custodian specified');
}

const accounts = await keyring.getCustodianAccounts(token, apiUrl, address);
const accounts = await keyring.getCustodianAccounts(
token,
envName,
address,
);
return accounts;
}

Expand Down Expand Up @@ -530,18 +533,19 @@ export default class MMIController extends EventEmitter {
return keyring ? keyring.getAllAccountsWithToken(token) : [];
}

async setCustodianNewRefreshToken({ address, newAuthDetails }) {
async setCustodianNewRefreshToken({ address, refreshToken }) {
const custodyType = this.custodyController.getCustodyTypeByAddress(
toChecksumHexAddress(address),
);

const keyring = await this.addKeyringIfNotExists(custodyType);

await keyring.replaceRefreshTokenAuthDetails(address, newAuthDetails);
await keyring.replaceRefreshTokenAuthDetails(address, refreshToken);
}

async handleMmiCheckIfTokenIsPresent(req) {
const { token, apiUrl } = req.params;
const { token, envName } = req.params;
// TODO (Bernardo) - Check if this is the case
const custodyType = 'Custody - JSONRPC'; // Only JSONRPC is supported for now
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? Isn't ECA3 supported as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be yes, this will need to be updated and a ticket created for it. Ty! 👍🏼


// This can only work if the extension is unlocked
Expand All @@ -551,7 +555,7 @@ export default class MMIController extends EventEmitter {

return await this.custodyController.handleMmiCheckIfTokenIsPresent({
token,
apiUrl,
envName,
keyring,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default mmiAuthenticate;
* @typedef {object} MmiCheckIfTokenIsPresentParam
* @property {string} service - The service to which we are authenticating, e.g. 'codefi-compliance'
* @property {object} environment - The environment in which we are authenticating, e.g. 'saturn-dev'
* @property {apiUrl} apiUrl - The API URL to which we are authenticating, e.g. 'https://saturn-custody.codefi.network/eth'
* @property {envName} envName - The environment to which we are authenticating, e.g. 'neptune-custody-prod'
* @property {object} token - The token used to authenticate
*/

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@
"@lavamoat/lavadome-react": "0.0.11",
"@lavamoat/snow": "^2.0.1",
"@material-ui/core": "^4.11.0",
"@metamask-institutional/custody-controller": "^0.2.18",
"@metamask-institutional/custody-keyring": "^1.0.7",
"@metamask-institutional/extension": "^0.3.12",
"@metamask-institutional/institutional-features": "^1.2.9",
"@metamask-institutional/custody-controller": "^0.2.20",
"@metamask-institutional/custody-keyring": "^1.0.10",
"@metamask-institutional/extension": "^0.3.13",
"@metamask-institutional/institutional-features": "^1.2.11",
"@metamask-institutional/portfolio-dashboard": "^1.4.0",
"@metamask-institutional/rpc-allowlist": "^1.0.0",
"@metamask-institutional/sdk": "^0.1.23",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,6 @@ exports[`JwtUrlForm shows JWT text area when no jwt token exists 1`] = `
/>
</div>
</div>
<div
class="mm-box mm-box--width-full"
>
<p
class="mm-box mm-text mm-text--body-md mm-box--display-block mm-box--color-text-default"
/>
<div
class="mm-box mm-box--margin-top-4"
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
>
<div
class="MuiInputBase-root MuiInput-root TextField-inputRoot-57 MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl"
>
<input
aria-invalid="false"
class="MuiInputBase-input MuiInput-input"
data-testid="jwt-api-url-input"
dir="auto"
id="api-url-box"
type="text"
value="url"
/>
</div>
</div>
</div>
</div>
</div>
</div>
`;
26 changes: 0 additions & 26 deletions ui/components/institutional/jwt-url-form/jwt-url-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from '../../../helpers/constants/design-system';
import { ButtonVariant, Box, Button, Text } from '../../component-library';
import TextArea from '../../ui/textarea';
import TextField from '../../ui/text-field';
import JwtDropdown from '../jwt-dropdown';

const JwtUrlForm = (props) => {
Expand Down Expand Up @@ -101,40 +100,15 @@ const JwtUrlForm = (props) => {
</Box>
)}
</Box>
<Box width={BlockSize.Full}>
<Text display={Display.Block} variant={TextVariant.bodyMd}>
{props.urlInputText}
</Text>
<Box marginTop={4}>
<TextField
fullWidth
id="api-url-box"
data-testid="jwt-api-url-input"
type="text"
onChange={(e) => {
props.onUrlChange(e.target.value);
}}
value={props.apiUrl}
inputProps={{
backgroundColor: BackgroundColor.backgroundDefault,
color: TextColor.textDefault,
padding: 2,
}}
/>
</Box>
</Box>
</Box>
);
};

JwtUrlForm.propTypes = {
jwtList: PropTypes.array.isRequired,
onUrlChange: PropTypes.func.isRequired,
onJwtChange: PropTypes.func.isRequired,
currentJwt: PropTypes.string,
jwtInputText: PropTypes.string,
apiUrl: PropTypes.string,
urlInputText: PropTypes.string,
};

export default JwtUrlForm;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export default {
args: {
jwtList: ['jwt1', 'jwt2', 'jwt3'],
currentJwt: 'jwt1',
urlInputText: 'url',
apiUrl: 'https://apiurl.io/v1',
jwtInputText: 'some input text',
onJwtChange: () => {
/**/
Expand Down
19 changes: 0 additions & 19 deletions ui/components/institutional/jwt-url-form/jwt-url-form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ describe('JwtUrlForm', function () {
currentJwt: 'jwt1',
onJwtChange: jest.fn(),
jwtInputText: 'input text',
apiUrl: 'url',
urlInputText: '',
onUrlChange: jest.fn(),
};

Expand All @@ -42,23 +40,6 @@ describe('JwtUrlForm', function () {
expect(screen.getByText('input text')).toBeInTheDocument();
});

it('calls onUrlChange when API URL input value changes', () => {
const { getByTestId } = renderWithProvider(
<JwtUrlForm {...props} />,
store,
);

const apiUrlinput = getByTestId('jwt-api-url-input');

fireEvent.change(apiUrlinput, { target: { value: 'url' } });

fireEvent.change(apiUrlinput, {
target: { value: 'new url' },
});

expect(props.onUrlChange).toHaveBeenCalled();
});

it('shows JWT text area when no jwt token exists', () => {
const customProps = {
...props,
Expand Down
1 change: 1 addition & 0 deletions ui/helpers/utils/institutional/find-by-custodian-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Custodian = {
version: number;
};

// TODO (Bernardo) - There can be multiple custodian with the same name, envName should be used instead
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't changed anything from this function as it's out of scope for this ticket, but I think it would be best to filter by envName/custodianName.

It's being used in two places and both of them have access to the envName.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Will create a ticket for it as well 👍🏼

export function findCustodianByDisplayName(
displayName: string,
custodians: Custodian[],
Expand Down
Loading