From 701bc0fb26d9abdacced13c83c2ca179aa37c395 Mon Sep 17 00:00:00 2001 From: Joe Andrews Date: Fri, 31 Jan 2020 20:04:09 +0000 Subject: [PATCH 1/2] feat(sdk): fix --- .../MetaMaskService/registerExtension.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/extension/src/client/services/MetaMaskService/registerExtension.js b/packages/extension/src/client/services/MetaMaskService/registerExtension.js index 37e7040ee..ec17f79ec 100644 --- a/packages/extension/src/client/services/MetaMaskService/registerExtension.js +++ b/packages/extension/src/client/services/MetaMaskService/registerExtension.js @@ -24,11 +24,16 @@ const AZTECAccount = [ name: 'linkedPublicKey', type: 'bytes', }, + { + name: 'AZTECaddress', + type: 'address', + }, ]; export default ({ address, linkedPublicKey, + aliasAddress, }) => { const accountRegistryContract = Web3Service.contract('AccountRegistry'); @@ -40,6 +45,7 @@ export default ({ const message = { account: address, + AZTECaddress: aliasAddress, linkedPublicKey, }; @@ -59,6 +65,7 @@ export default ({ export const generateTypedData = ({ address, linkedPublicKey, + aliasAddress, }) => { const accountRegistryContract = Web3Service.contract('AccountRegistry'); @@ -70,9 +77,18 @@ export const generateTypedData = ({ const message = { account: address, + AZTECaddress: aliasAddress, linkedPublicKey, }; - + console.log({ + types: { + EIP712Domain: domainParams, + AZTECAccount, + }, + domain: domainData, + primaryType: 'AZTECAccount', + message, + }); return { types: { EIP712Domain: domainParams, From bde9d5258340a79467c3992174e1a083af25037a Mon Sep 17 00:00:00 2001 From: Joe Andrews Date: Fri, 31 Jan 2020 20:12:49 +0000 Subject: [PATCH 2/2] feat(sdk): manually fix --- .../src/ui/apis/auth/linkAccountToMetaMask.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js b/packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js index 2019e7e63..a15a842ef 100644 --- a/packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js +++ b/packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js @@ -1,9 +1,20 @@ +import secp256k1 from '@aztec/secp256k1'; +import decodePrivateKey from '~/background/utils/decodePrivateKey'; +import AuthService from '~/background/services/AuthService'; import ConnectionService from '~/ui/services/ConnectionService'; export default async function linkAccountToMetaMask({ address, linkedPublicKey, }) { + const keyStore = await AuthService.getKeyStore(); + const { + pwDerivedKey, + } = await AuthService.getSession(address) || {}; + const privateKey = '0x'.concat(decodePrivateKey(keyStore, pwDerivedKey)); + const { + address: aliasAddress, + } = secp256k1.accountFromPrivateKey(privateKey); const { publicKey: spendingPublicKey, signature, @@ -13,6 +24,7 @@ export default async function linkAccountToMetaMask({ data: { address, linkedPublicKey, + aliasAddress, }, }) || {};