diff --git a/packages/custodyKeyring/src/MmiConfiguration.test.ts b/packages/custodyKeyring/src/MmiConfiguration.test.ts index a61e2557..5b93c60c 100644 --- a/packages/custodyKeyring/src/MmiConfiguration.test.ts +++ b/packages/custodyKeyring/src/MmiConfiguration.test.ts @@ -46,7 +46,7 @@ const v2custodian = { tokens: "All ERC-20 tokens", chains: ["Ethereum"], tags: null, - apiVersion: 2, + apiVersion: "1", custodianPublishesTransaction: false, environments: [ { @@ -57,9 +57,11 @@ const v2custodian = { websocketApiUrl: "wss://websocket.dev.metamask-institutional.io/v1/ws", apiBaseUrl: "https://saturn-custody.dev.metamask-institutional.io/eth", iconUrl: "https://saturn-custody-ui.dev.metamask-institutional.io/saturn.svg", - apiVersion: 2, + apiVersion: "1", custodianPublishesTransaction: false, isNoteToTraderSupported: true, + isManualTokenInputSupported: false, + isQRCodeSupported: false }, ], }; @@ -160,6 +162,8 @@ describe("MmiConfigurationController", () => { production: v2custodian.production, refreshTokenUrl: v2custodian.refreshTokenUrl, isNoteToTraderSupported: v2custodian.environments[0].isNoteToTraderSupported, + isManualTokenInputSupported: v2custodian.environments[0].isManualTokenInputSupported, + isQRCodeSupported: v2custodian.environments[0].isQRCodeSupported, websocketApiUrl: "wss://websocket.dev.metamask-institutional.io/v1/ws", version: 2, }, diff --git a/packages/custodyKeyring/src/MmiConfiguration.ts b/packages/custodyKeyring/src/MmiConfiguration.ts index 3aa138d8..a24fb88e 100644 --- a/packages/custodyKeyring/src/MmiConfiguration.ts +++ b/packages/custodyKeyring/src/MmiConfiguration.ts @@ -32,18 +32,18 @@ export class MmiConfigurationController { const initState = opts.initState?.mmiConfiguration ? opts.initState : { - mmiConfiguration: { - portfolio: { - enabled: false, - url: "", - cookieSetUrls: [], + mmiConfiguration: { + portfolio: { + enabled: false, + url: "", + cookieSetUrls: [], + }, + features: { + websocketApi: false, + }, + custodians: [], // NB: Custodians will always be empty when we start }, - features: { - websocketApi: false, - }, - custodians: [], // NB: Custodians will always be empty when we start - }, - }; + }; this.configurationClient = new ConfigurationClient(opts.mmiConfigurationServiceUrl); @@ -99,6 +99,13 @@ export class MmiConfigurationController { // Loop through the custodians from the API configuredCustodians.forEach(custodian => { custodian.environments.forEach(environment => { + if (environment.name.includes("bitgo")) { + environment.type = "Bitgo"; + environment.version = 1; + environment.apiVersion = undefined; + environment.websocketApiUrl = undefined; + } + // This used to check if there is no apiUrl, but now it checks by name if (legacyCustodianNames.includes(environment.name)) { // This logic checks if something is a legacy custodian @@ -110,7 +117,7 @@ export class MmiConfigurationController { if (!legacyCustodian) { console.warn(`Missing legacy custodian ${environment.name}`); } else { - if(environment.apiBaseUrl) { + if (environment.apiBaseUrl) { // Updates a legacy custodian with an API url from the configured custodian, // it's useful for bitgo that has a different API url from dev to prod legacyCustodian.apiUrl = environment.apiBaseUrl; @@ -120,7 +127,7 @@ export class MmiConfigurationController { } custodians.push({ - type: environment.apiVersion === "3" ? "ECA3" : "JSONRPC", + type: environment.apiVersion === "3" ? "ECA3" : environment.apiVersion === "1" ? "JSONRPC" : environment.type, iconUrl: custodian.iconUrl, name: custodian.name, onboardingUrl: custodian.onboardingUrl, @@ -136,7 +143,7 @@ export class MmiConfigurationController { isQRCodeSupported: environment.isQRCodeSupported, isManualTokenInputSupported: environment.isManualTokenInputSupported, custodianPublishesTransaction: environment.custodianPublishesTransaction, - version: 2, + version: !environment.apiVersion ? 1 : 2, }); }); }); diff --git a/packages/custodyKeyring/src/custodianTypes/bitgo/BitgoCustodyKeyring.ts b/packages/custodyKeyring/src/custodianTypes/bitgo/BitgoCustodyKeyring.ts index b3f16a2d..64d81db6 100644 --- a/packages/custodyKeyring/src/custodianTypes/bitgo/BitgoCustodyKeyring.ts +++ b/packages/custodyKeyring/src/custodianTypes/bitgo/BitgoCustodyKeyring.ts @@ -46,7 +46,8 @@ export class BitgoCustodyKeyring extends CustodyKeyring { }; sdkFactory = (authDetails: AuthDetails, envName: string): MMISDK => { - const custodian = this.getCustodianFromEnvName("bitgo"); + const custodianEnvName = envName !== "bitgo" ? "bitgo-test" : "bitgo"; + const custodian = this.getCustodianFromEnvName(custodianEnvName); return mmiSDKFactory(BitgoCustodianApi, authDetails, this.authType, custodian.apiUrl); }; diff --git a/packages/custodyKeyring/src/interfaces/IJsonRpcCustodian.ts b/packages/custodyKeyring/src/interfaces/IJsonRpcCustodian.ts index 023a8108..c7fea29b 100644 --- a/packages/custodyKeyring/src/interfaces/IJsonRpcCustodian.ts +++ b/packages/custodyKeyring/src/interfaces/IJsonRpcCustodian.ts @@ -1,4 +1,6 @@ interface IEnvironment { + type: string; + version: number; refreshTokenUrl: string; name: string; displayName: string;