Skip to content

Commit

Permalink
Display deployed account address on /account/create (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-maj authored Sep 28, 2023
1 parent 5cfc5ad commit b3e5bbd
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { queueTx } from "../../../../../../src/db/transactions/queueTx";
import {
contractParamSchema,
standardResponseSchema,
transactionWritesResponseSchema,
} from "../../../../../helpers";
import { prebuiltDeployResponseSchema } from "../../../../../schemas/prebuilts";
import { getChainIdFromChain } from "../../../../../utilities/chain";
import { getContract } from "../../../../../utils/cache/getContract";

Expand All @@ -25,7 +25,7 @@ const BodySchema = Type.Object({
export const createAccount = async (fastify: FastifyInstance) => {
fastify.route<{
Params: Static<typeof contractParamSchema>;
Reply: Static<typeof transactionWritesResponseSchema>;
Reply: Static<typeof prebuiltDeployResponseSchema>;
Body: Static<typeof BodySchema>;
}>({
method: "POST",
Expand All @@ -39,7 +39,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
body: BodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: transactionWritesResponseSchema,
[StatusCodes.OK]: prebuiltDeployResponseSchema,
},
},
handler: async (req, rep) => {
Expand All @@ -59,14 +59,24 @@ export const createAccount = async (fastify: FastifyInstance) => {
admin_address,
extra_data,
);
const queueId = await queueTx({
const deployedAddress =
await contract.accountFactory.predictAccountAddress(
admin_address,
extra_data,
);
const queuedId = await queueTx({
tx,
chainId,
extension: "account-factory",
deployedContractAddress: deployedAddress,
deployedContractType: "account",
});

rep.status(StatusCodes.OK).send({
result: queueId,
result: {
queuedId,
deployedAddress,
},
});
},
});
Expand Down

0 comments on commit b3e5bbd

Please sign in to comment.