Minting OADA
// src/oada/actions.ts
// Type definition for OADA minting requests
// Specifies the amount of ADA to convert to OADA tokens
type BuyOadaRequest = {
amount: bigint;
};// src/oada/actions.ts
// Async thunk for minting OADA tokens from ADA
// Handles the complete minting process including transaction creation, signing, and submission
export const buyOada = createAsyncThunk<
BasicResponse<string>,
BuyOadaRequest,
{
dispatch: AppDispatch;
state: RootState;
extra: Services;
rejectValue: FailResponse;
}
>("buyOada", async (request: BuyOadaRequest, thunkApi) => {
// Implementation details for minting OADA tokens
const requestOptions = {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json;charset=UTF-8",
},
body: Json.stringify(request),
};
const rawResponse = await fetch(
`${oadaEndpointsUrl}/buy-oada`,
requestOptions
);
const wallet = thunkApi.getState().wallet.wallet!;
const [utxos, changeAddress] = await getWalletUtxos(wallet);
const addFee = (recipe: TxRecipe) => {
oadaFeeAddress &&
oadaMintFee &&
recipe.txOuts.push({
address: oadaFeeAddress,
value: { lovelace: oadaMintFee },
datum: null,
refScript: null,
});
return recipe;
};
const signedTxResponse = await getRecipeBuildSendTx(
utxos,
changeAddress,
rawResponse,
addFee
);
return signedTxResponse;
});Key features of the minting process:
Last updated