Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add wait to txs #524

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"type-check": "tsc --noEmit",
"postinstall": "husky install && npm run copy:address",
"copy:address": "node scripts/copy-addresses.js",
"codegen:apollo": "apollo client:codegen --endpoint=https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph --target typescript --tsFileExtension=d.ts --outputFlat src/@types/subgraph/",
"codegen:apollo": "apollo client:codegen --endpoint=https://subgraph.v4.genx.minimal-gaia-x.eu/subgraphs/name/oceanprotocol/ocean-subgraph --target typescript --tsFileExtension=d.ts --outputFlat src/@types/subgraph/",
"storybook": "cross-env NODE_ENV=test start-storybook -p 6006 --quiet",
"storybook:build": "cross-env NODE_ENV=test build-storybook"
},
Expand Down
17 changes: 11 additions & 6 deletions src/@utils/dispenser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ export async function setMinterToPublisher(
): Promise<ethers.providers.TransactionResponse> {
const datatokenInstance = new Datatoken(signer)

const response = await datatokenInstance.removeMinter(
const removeMinterTx = await datatokenInstance.removeMinter(
datatokenAddress,
accountId,
accountId
)

if (!response) {
if (!removeMinterTx) {
moritzkirstein marked this conversation as resolved.
Show resolved Hide resolved
setError('Updating DDO failed.')
LoggerInstance.error('Failed at cancelMinter')
}
return response

await removeMinterTx.wait()

return removeMinterTx
}

export async function setMinterToDispenser(
Expand All @@ -30,14 +33,16 @@ export async function setMinterToDispenser(
): Promise<ethers.providers.TransactionResponse> {
const datatokenInstance = new Datatoken(signer)

const response = await datatokenInstance.addMinter(
const addMinterTx = await datatokenInstance.addMinter(
datatokenAddress,
accountId,
accountId
)
if (!response) {
if (!addMinterTx) {
setError('Updating DDO failed.')
LoggerInstance.error('Failed at makeMinter')
}
return response
await addMinterTx.wait()

return addMinterTx
moritzkirstein marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions src/components/Asset/Edit/EditComputeDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function EditComputeDataset({
LoggerInstance.error(content.form.error)
return
} else {
await setMetadataTx.wait()
if (asset.accessDetails.type === 'free') {
const tx = await setMinterToDispenser(
signer,
Expand Down
1 change: 1 addition & 0 deletions src/components/Asset/Edit/EditMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default function Edit({
LoggerInstance.error(content.form.error)
return
} else {
await setMetadataTx.wait()
if (asset.accessDetails.type === 'free') {
const tx = await setMinterToDispenser(
signer,
Expand Down
Loading