Skip to content

Commit 6b28625

Browse files
committed
update AccountOnboard contract address and ABI
1 parent d5ff30e commit 6b28625

File tree

2 files changed

+51
-56
lines changed

2 files changed

+51
-56
lines changed

src/account/onboard-contract.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
export const ONBOARD_CONTRACT_ADDRESS = "0xadb3952a07B2c9fA7dbd2F583cd2F0412C97eC33"
1+
export const ONBOARD_CONTRACT_ADDRESS = "0x413370ed41FB9EE3aea0B1B91FD336cC0be1Bad6"
22
export const ONBOARD_CONTRACT_ABI = [
3-
{
4-
"anonymous": false,
5-
"inputs": [
6-
{
7-
"indexed": true,
8-
"internalType": "address",
9-
"name": "_from",
10-
"type": "address"
11-
},
12-
{
13-
"indexed": false,
14-
"internalType": "bytes",
15-
"name": "userKey",
16-
"type": "bytes"
17-
}
18-
],
19-
"name": "AccountOnboarded",
20-
"type": "event"
21-
},
22-
{
23-
"inputs": [
24-
{
25-
"internalType": "bytes",
26-
"name": "signedEK",
27-
"type": "bytes"
28-
},
29-
{
30-
"internalType": "bytes",
31-
"name": "signature",
32-
"type": "bytes"
33-
}
34-
],
35-
"name": "OnboardAccount",
36-
"outputs": [],
37-
"stateMutability": "nonpayable",
38-
"type": "function"
39-
}
40-
]
3+
{
4+
"anonymous": false,
5+
"inputs": [
6+
{
7+
"indexed": true,
8+
"internalType": "address",
9+
"name": "_from",
10+
"type": "address"
11+
},
12+
{
13+
"indexed": false,
14+
"internalType": "bytes",
15+
"name": "userKey",
16+
"type": "bytes"
17+
}
18+
],
19+
"name": "AccountOnboarded",
20+
"type": "event"
21+
},
22+
{
23+
"inputs": [
24+
{
25+
"internalType": "bytes",
26+
"name": "publicKey",
27+
"type": "bytes"
28+
},
29+
{
30+
"internalType": "bytes",
31+
"name": "signedEK",
32+
"type": "bytes"
33+
}
34+
],
35+
"name": "onboardAccount",
36+
"outputs": [],
37+
"stateMutability": "nonpayable",
38+
"type": "function"
39+
}
40+
]

src/account/onboard.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ function getDefaultContract(wallet: Signer) {
99
export async function onboard(user: BaseWallet, contract = getDefaultContract(user)) {
1010
const {publicKey, privateKey} = generateRSAKeyPair()
1111

12-
const signedEK = sign(keccak256(publicKey), user.privateKey)
13-
14-
const receipt = await (await contract.OnboardAccount(publicKey, signedEK, {gasLimit: 12000000})).wait()
15-
16-
if (!receipt || !receipt.logs || !receipt.logs[0]) {
17-
throw new Error("failed to onboard account")
18-
}
19-
20-
const decodedLog = contract.interface.parseLog(receipt.logs[0])
21-
22-
if (!decodedLog) {
23-
throw new Error("failed to onboard account")
24-
}
25-
26-
const encryptedKey = decodedLog.args.userKey.substring(2)
27-
28-
return decryptRSA(privateKey, encryptedKey)
12+
const signedEK = sign(keccak256(publicKey), user.privateKey)
13+
const receipt = await (await contract.onboardAccount(publicKey, signedEK, { gasLimit: 12000000 })).wait()
14+
if (!receipt || !receipt.logs || !receipt.logs[0]) {
15+
throw new Error("failed to onboard account")
16+
}
17+
const decodedLog = contract.interface.parseLog(receipt.logs[0])
18+
if (!decodedLog) {
19+
throw new Error("failed to onboard account")
20+
}
21+
const encryptedKey = decodedLog.args.userKey
22+
const buf = Buffer.from(encryptedKey.substring(2), "hex")
23+
return decryptRSA(privateKey, buf).toString("hex")
2924
}

0 commit comments

Comments
 (0)