diff --git a/amplify/backend/function/createUniqueColony/src/index.js b/amplify/backend/function/createUniqueColony/src/index.js index 63679de8242..af288a2a7b8 100644 --- a/amplify/backend/function/createUniqueColony/src/index.js +++ b/amplify/backend/function/createUniqueColony/src/index.js @@ -227,7 +227,12 @@ exports.handler = async (event) => { const providerNetwork = await provider.getNetwork(); const chainId = String(providerNetwork.chainId); const version = await colonyClient.version(); - const isTokenLocked = colonyClient.tokenClient.locked(); + let isTokenLocked = false; + try { + isTokenLocked = await colonyClient.tokenClient.locked(); + } catch (error) { + // token doesn not support the `locked()` method + } /* * Create the colony diff --git a/src/redux/sagas/colony/colonyCreate.ts b/src/redux/sagas/colony/colonyCreate.ts index 92b6ee9c06a..d16d34e3e70 100644 --- a/src/redux/sagas/colony/colonyCreate.ts +++ b/src/redux/sagas/colony/colonyCreate.ts @@ -7,7 +7,7 @@ import { ColonyRole, colonyRoles2Hex, } from '@colony/colony-js'; -import { utils } from 'ethers'; +import { utils, providers } from 'ethers'; import { poll } from 'ethers/lib/utils'; import { all, call, put } from 'redux-saga/effects'; @@ -15,12 +15,10 @@ import { ADDRESS_ZERO, DEFAULT_TOKEN_DECIMALS, supportedExtensionsConfig, + isDev, + GANACHE_LOCAL_RPC_URL, } from '~constants/index.ts'; -import { - type ColonyManager, - ContextModule, - getContext, -} from '~context/index.ts'; +import { ContextModule, getContext } from '~context/index.ts'; import { CreateColonyEtherealMetadataDocument, type CreateColonyEtherealMetadataMutation, @@ -52,8 +50,8 @@ import { putError, takeFrom, takeLatestCancellable, - getColonyManager, initiateTransaction, + getNetworkClient, } from '../utils/index.ts'; function* colonyCreate({ @@ -74,7 +72,17 @@ function* colonyCreate({ const apolloClient = getContext(ContextModule.ApolloClient); const wallet = getContext(ContextModule.Wallet); const walletAddress = utils.getAddress(wallet.address); - const colonyManager: ColonyManager = yield getColonyManager(); + // const colonyManager: ColonyManager = yield getColonyManager(); + + const provider = (() => { + if (isDev) { + return new providers.JsonRpcProvider(GANACHE_LOCAL_RPC_URL); + } + return new providers.Web3Provider(window.ethereum!); + })(); + + const networkClient = yield call(getNetworkClient, provider); + const channelNames: string[] = []; /* @@ -263,10 +271,7 @@ function* colonyCreate({ const colonyClient = yield poll( async () => { try { - const client = await colonyManager.getClient( - ClientType.ColonyClient, - colonyAddress, - ); + const client = await networkClient.getColonyClient(colonyAddress); return client; } catch (err) { return undefined; @@ -274,6 +279,7 @@ function* colonyCreate({ }, { timeout: 30000, + retryLimit: 0, }, ); @@ -335,6 +341,7 @@ function* colonyCreate({ }, { timeout: 30000, + retryLimit: 0, }, );