Skip to content

Commit

Permalink
fix: fix custom contract example and return types
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Oct 23, 2024
1 parent 2543483 commit 67058b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions packages/sdk/examples/node/custom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { providers } from 'ethers';
import { providers, utils } from 'ethers';
import 'cross-fetch/dist/node-polyfill.js';
import { erc20Abi } from 'abitype/abis';

Expand All @@ -7,7 +7,6 @@ import {
ColonyNetwork,
ColonyRpcEndpoint,
CustomContract,
toEth,
} from '../../src/index.js';

const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.ArbitrumOne);
Expand All @@ -20,11 +19,13 @@ const start = async () => {
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
erc20Abi,
);
const metaColony = await colonyNetwork.getMetaColony();
const { address } = metaColony;
const [funds] = await usdc.read('balanceOf', [address as Address]);
const metaColonyAddress = await colonyNetwork
.getInternalNetworkContract()
.getMetaColony();
const funds = await usdc.read('balanceOf', [metaColonyAddress as Address]);
const formattedFunds = utils.formatUnits(funds, 6);
console.info(
`${toEth(funds)} CLNY in root team of MetaColony with address: ${address}`,
`${formattedFunds} USDC in root team of MetaColony with address: ${metaColonyAddress}`,
);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/ColonyNetwork/CustomContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class CustomContract<A extends Abi> {
AbiParametersToPrimitiveTypes<
ExtractAbiFunction<A, M>['outputs'],
'outputs'
>
>[0]
> {
// A little typecasting to make ethers happy
const customArgs = args as unknown[];
Expand All @@ -113,7 +113,7 @@ export class CustomContract<A extends Abi> {
AbiParametersToPrimitiveTypes<
ExtractAbiFunction<A, M>['outputs'],
'outputs'
>
>[0]
>;
return result;
}
Expand Down

0 comments on commit 67058b1

Please sign in to comment.