Skip to content

Commit

Permalink
Merge branch 'gerhard/uma-2547-adding-unsupported-treasury-crashes-pr…
Browse files Browse the repository at this point in the history
…oposal-page' into validation-fixes
  • Loading branch information
gsteenkamp89 committed Apr 19, 2024
2 parents 29275bf + d29c986 commit 0654a34
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 73 deletions.
17 changes: 13 additions & 4 deletions src/components/SettingsTreasuriesBlockItemButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { TreasuryWallet } from '@/helpers/interfaces';
import { Network } from '@/plugins/oSnap/types';
import { getIsOsnapEnabled } from '@/plugins/oSnap/utils/getters';
import { ConfigError, getIsOsnapEnabled } from '@/plugins/oSnap/utils/getters';
const props = defineProps<{
treasury: TreasuryWallet;
Expand All @@ -17,13 +17,21 @@ const emit = defineEmits<{
}>();
const isOsnapEnabled = ref(false);
const isChainSupported = ref(true);
async function updateIsOsnapEnabled() {
if (!props.hasOsnapPlugin) return;
isOsnapEnabled.value = await getIsOsnapEnabled(
const isEnabled = await getIsOsnapEnabled(
props.treasury.network as Network,
props.treasury.address
);
).catch(e => {
if (e instanceof ConfigError) {
isChainSupported.value = false;
return false;
}
return false;
});
isOsnapEnabled.value = isEnabled;
}
onMounted(async () => {
Expand All @@ -47,12 +55,13 @@ onUnmounted(() => {
</div>
<div class="ml-auto mr-3">
<SettingsTreasuryActivateOsnapButton
v-show="hasOsnapPlugin"
v-if="hasOsnapPlugin && isChainSupported"
:is-osnap-enabled="isOsnapEnabled"
@click.stop="
!isViewOnly && emit('configureOsnap', treasuryIndex, isOsnapEnabled)
"
/>
<div v-else>oSnap unavailable</div>
</div>
<BaseButtonIcon
v-show="!isViewOnly"
Expand Down
1 change: 1 addition & 0 deletions src/helpers/boost/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const BOOST_WHITELIST_SETTINGS = {
'mimo.eth',
'vote.vitadao.eth',
'shutterdao0x36.eth',
'testeteste123.eth',
// Internal testers
'testsnap.eth',
'fabien.eth',
Expand Down
51 changes: 30 additions & 21 deletions src/plugins/oSnap/Create.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ExtendedSpace, TreasuryWallet } from '@/helpers/interfaces';
import { ExtendedSpace } from '@/helpers/interfaces';
import { formatUnits } from '@ethersproject/units';
import { cloneDeep } from 'lodash';
import SelectSafe from './components/Input/SelectSafe.vue';
Expand All @@ -11,7 +11,8 @@ import {
Network,
OsnapPluginData,
Token,
Transaction
Transaction,
nonNullable
} from './types';
import {
getGnosisSafeBalances,
Expand Down Expand Up @@ -159,34 +160,42 @@ async function fetchCollectibles(network: Network, gnosisSafeAddress: string) {
// maps over the treasuries and creates a safe for each one
// only returns safes that have oSnap enabled
async function createOsnapEnabledSafes() {
const treasuriesWithOsnapEnabled = (
await Promise.all(
props.space.treasuries.map(async treasury => {
const isOsnapEnabled = await getIsOsnapEnabled(
treasury.network as Network,
treasury.address
);
return isOsnapEnabled ? treasury : null;
})
)
).filter(treasury => treasury !== null) as TreasuryWallet[];
const treasuryPromises = await Promise.allSettled(
props.space.treasuries.map(async treasury => {
const isOsnapEnabled = await getIsOsnapEnabled(
treasury.network as Network,
treasury.address
);
return isOsnapEnabled ? treasury : null;
})
);
const safes: GnosisSafe[] = await Promise.all(
const treasuriesWithOsnapEnabled = treasuryPromises
.map(res => (res.status === 'fulfilled' ? res.value : null))
.filter(nonNullable);
const safePromises = await Promise.allSettled(
treasuriesWithOsnapEnabled.map(async treasury => {
const moduleAddress = await getModuleAddressForTreasury(
treasury.network as Network,
treasury.address
);
return {
safeName: treasury.name,
safeAddress: toChecksumAddress(treasury.address),
network: treasury.network as Network,
transactions: [] as Transaction[],
moduleAddress
};
return moduleAddress
? {
safeName: treasury.name,
safeAddress: toChecksumAddress(treasury.address),
network: treasury.network as Network,
transactions: [] as Transaction[],
moduleAddress
}
: null;
})
);
const safes = safePromises
.map(res => (res.status === 'fulfilled' ? res.value : null))
.filter(nonNullable);
return safes;
}
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/oSnap/components/Input/SelectSafe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ const isModalOpen = ref(false);
<div class="mb-2">
<TuneButtonSelect
:model-value="
safes.find(safe => safe.safeAddress === selectedSafe?.safeAddress)
?.safeName || 'Select Safe'
safes.find(
safe =>
safe.safeAddress === selectedSafe?.safeAddress &&
safe.network === selectedSafe.network
)?.safeName || 'Select Safe'
"
@select="isModalOpen = true"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function makeSafeDescription(safe: GnosisSafe) {
<div class="mx-0 my-4 flex flex-col space-y-3 md:mx-4">
<button v-for="(safe, key) in safes" :key="key" @click="select(safe)">
<BaseModalSelectItem
:selected="safe.safeAddress === selected?.safeAddress"
:selected="
safe.safeAddress === selected?.safeAddress &&
safe.network === selected.network
"
:title="safe.safeName"
:description="makeSafeDescription(safe)"
/>
Expand Down
21 changes: 21 additions & 0 deletions src/plugins/oSnap/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ export const EXPLORER_API_URLS = {
'137': 'https://api.polygonscan.com/api',
'56': 'https://api.bscscan.com/api',
'42161': 'https://api.arbiscan.io/api',
'8453' : 'https://api.basescan.org/api',
// '1116': Add 'https://openapi.coredao.org/api' if API key requirement is removed
'11155111': 'https://api-sepolia.etherscan.io/api',
} as const;
Expand All @@ -1116,6 +1117,7 @@ export const GNOSIS_SAFE_TRANSACTION_API_URLS = {
'5': 'https://safe-transaction-goerli.safe.global/api',
'10': 'https://safe-transaction-optimism.safe.global/api',
'100': 'https://safe-transaction-gnosis-chain.safe.global/api',
'8453': 'https://safe-transaction-base.safe.global/api',
'73799': 'https://safe-transaction-volta.safe.global/api',
'246': 'https://safe-transaction-ewc.safe.global/api',
'137': 'https://safe-transaction-polygon.safe.global/api',
Expand All @@ -1135,6 +1137,7 @@ export const SAFE_APP_URLS = {
'56': 'https://app.safe.global/apps/open',
'42161': 'https://app.safe.global/apps/open',
'1116': 'https://safe.coredao.org/apps/open',
'8453': 'https://app.safe.global/apps/open',
'11155111': 'https://app.safe.global/apps/open',
} as const;

Expand Down Expand Up @@ -1445,6 +1448,15 @@ export const contractData = [
'https://thegraph.coredao.org/subgraphs/name/umaprotocol/core-optimistic-oracle-v3',
deployBlock: 11341063
},
{
// base
network: '8453',
name: 'OptimisticOracleV3',
address: '0x2aBf1Bd76655de80eDB3086114315Eec75AF500c',
subgraph:
'https://api.studio.thegraph.com/query/1057/base-optimistic-oracle-v3/version/latest',
deployBlock: 12066343
},
{
// sepolia
network: '11155111',
Expand Down Expand Up @@ -1527,6 +1539,15 @@ export const contractData = [
subgraph:
'https://thegraph.coredao.org/subgraphs/name/umaprotocol/core-optimistic-governor'
},
{
// base
network: '8453',
name: 'OptimisticGovernor',
address: '0x80bCA2E1c272239AdFDCdc87779BC8Af6E12e633',
deployBlock: 13062540,
subgraph:
'https://api.studio.thegraph.com/query/1057/base-optimistic-governor/version/latest'
},
{
// sepolia
network: '11155111',
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/oSnap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,7 @@ export type Integer = `int${number}` | `uint${number}`;
export function isIntegerType(type: InputTypes): type is Integer {
return type.includes('int');
}

export function nonNullable<T>(value: T): value is NonNullable<T> {
return value !== null;
}
Loading

0 comments on commit 0654a34

Please sign in to comment.