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..de8cbe8fb98 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,19 @@ 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); + + console.info({ networkClient }); + const channelNames: string[] = []; /* @@ -262,21 +272,24 @@ function* colonyCreate({ */ const colonyClient = yield poll( async () => { + console.info('attempting to get colony client'); try { - const client = await colonyManager.getClient( - ClientType.ColonyClient, - colonyAddress, - ); + const client = await networkClient.getColonyClient(colonyAddress); + console.info(client); return client; } catch (err) { + console.error('fetching colony client errored out', err); return undefined; } }, { timeout: 30000, + retryLimit: 0, }, ); + console.info({ colonyClient }); + /* * Add a colonyAddress identifier to all pending transactions. */ @@ -335,6 +348,7 @@ function* colonyCreate({ }, { timeout: 30000, + retryLimit: 0, }, ); diff --git a/src/redux/sagas/transactions/getTransactionPromise.ts b/src/redux/sagas/transactions/getTransactionPromise.ts index 7894fb2b292..4774596c826 100644 --- a/src/redux/sagas/transactions/getTransactionPromise.ts +++ b/src/redux/sagas/transactions/getTransactionPromise.ts @@ -39,6 +39,7 @@ async function getTransactionPromise( } console.info('TX DEBUG', { + colonyJSClient: client, client: client?.clientType || 'unknownContractClient', methodName, params,