Skip to content
This repository was archived by the owner on Mar 16, 2023. It is now read-only.

Commit 8dea0a5

Browse files
author
Joe Andrews
authored
Merge pull request #463 from AztecProtocol/feat-fix-aztec-sig
feat(sdk): fix
2 parents 3cb88c7 + bde9d52 commit 8dea0a5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/extension/src/client/services/MetaMaskService/registerExtension.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ const AZTECAccount = [
2424
name: 'linkedPublicKey',
2525
type: 'bytes',
2626
},
27+
{
28+
name: 'AZTECaddress',
29+
type: 'address',
30+
},
2731
];
2832

2933
export default ({
3034
address,
3135
linkedPublicKey,
36+
aliasAddress,
3237
}) => {
3338
const accountRegistryContract = Web3Service.contract('AccountRegistry');
3439

@@ -40,6 +45,7 @@ export default ({
4045

4146
const message = {
4247
account: address,
48+
AZTECaddress: aliasAddress,
4349
linkedPublicKey,
4450
};
4551

@@ -59,6 +65,7 @@ export default ({
5965
export const generateTypedData = ({
6066
address,
6167
linkedPublicKey,
68+
aliasAddress,
6269
}) => {
6370
const accountRegistryContract = Web3Service.contract('AccountRegistry');
6471

@@ -70,9 +77,18 @@ export const generateTypedData = ({
7077

7178
const message = {
7279
account: address,
80+
AZTECaddress: aliasAddress,
7381
linkedPublicKey,
7482
};
75-
83+
console.log({
84+
types: {
85+
EIP712Domain: domainParams,
86+
AZTECAccount,
87+
},
88+
domain: domainData,
89+
primaryType: 'AZTECAccount',
90+
message,
91+
});
7692
return {
7793
types: {
7894
EIP712Domain: domainParams,

packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
import secp256k1 from '@aztec/secp256k1';
2+
import decodePrivateKey from '~/background/utils/decodePrivateKey';
3+
import AuthService from '~/background/services/AuthService';
14
import ConnectionService from '~/ui/services/ConnectionService';
25

36
export default async function linkAccountToMetaMask({
47
address,
58
linkedPublicKey,
69
}) {
10+
const keyStore = await AuthService.getKeyStore();
11+
const {
12+
pwDerivedKey,
13+
} = await AuthService.getSession(address) || {};
14+
const privateKey = '0x'.concat(decodePrivateKey(keyStore, pwDerivedKey));
15+
const {
16+
address: aliasAddress,
17+
} = secp256k1.accountFromPrivateKey(privateKey);
718
const {
819
publicKey: spendingPublicKey,
920
signature,
@@ -13,6 +24,7 @@ export default async function linkAccountToMetaMask({
1324
data: {
1425
address,
1526
linkedPublicKey,
27+
aliasAddress,
1628
},
1729
}) || {};
1830

0 commit comments

Comments
 (0)