Skip to content

Commit

Permalink
Fix: allow colony creation with non-colony network tokens
Browse files Browse the repository at this point in the history
Basically, don't presume the token client has the `.locked()`
method available, since the ERC-20 doesn't enforce that.

Just try/catch it, and if not, set the token as 'unlocked'

Fixes: #2264
  • Loading branch information
rdig committed Apr 22, 2024
1 parent cf29884 commit 1ea2392
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion amplify/backend/function/createUniqueColony/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/redux/sagas/colony/colonyCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ function* colonyCreate({
},
{
timeout: 30000,
retryLimit: 0,
},
);

Expand Down Expand Up @@ -335,6 +336,7 @@ function* colonyCreate({
},
{
timeout: 30000,
retryLimit: 0,
},
);

Expand Down

0 comments on commit 1ea2392

Please sign in to comment.