Skip to content

Commit b3e5bbd

Browse files
authored
Display deployed account address on /account/create (#175)
1 parent 5cfc5ad commit b3e5bbd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

server/api/contract/extensions/accountFactory/write/createAccount.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { queueTx } from "../../../../../../src/db/transactions/queueTx";
66
import {
77
contractParamSchema,
88
standardResponseSchema,
9-
transactionWritesResponseSchema,
109
} from "../../../../../helpers";
10+
import { prebuiltDeployResponseSchema } from "../../../../../schemas/prebuilts";
1111
import { getChainIdFromChain } from "../../../../../utilities/chain";
1212
import { getContract } from "../../../../../utils/cache/getContract";
1313

@@ -25,7 +25,7 @@ const BodySchema = Type.Object({
2525
export const createAccount = async (fastify: FastifyInstance) => {
2626
fastify.route<{
2727
Params: Static<typeof contractParamSchema>;
28-
Reply: Static<typeof transactionWritesResponseSchema>;
28+
Reply: Static<typeof prebuiltDeployResponseSchema>;
2929
Body: Static<typeof BodySchema>;
3030
}>({
3131
method: "POST",
@@ -39,7 +39,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
3939
body: BodySchema,
4040
response: {
4141
...standardResponseSchema,
42-
[StatusCodes.OK]: transactionWritesResponseSchema,
42+
[StatusCodes.OK]: prebuiltDeployResponseSchema,
4343
},
4444
},
4545
handler: async (req, rep) => {
@@ -59,14 +59,24 @@ export const createAccount = async (fastify: FastifyInstance) => {
5959
admin_address,
6060
extra_data,
6161
);
62-
const queueId = await queueTx({
62+
const deployedAddress =
63+
await contract.accountFactory.predictAccountAddress(
64+
admin_address,
65+
extra_data,
66+
);
67+
const queuedId = await queueTx({
6368
tx,
6469
chainId,
6570
extension: "account-factory",
71+
deployedContractAddress: deployedAddress,
72+
deployedContractType: "account",
6673
});
6774

6875
rep.status(StatusCodes.OK).send({
69-
result: queueId,
76+
result: {
77+
queuedId,
78+
deployedAddress,
79+
},
7080
});
7181
},
7282
});

0 commit comments

Comments
 (0)