Skip to content

Commit

Permalink
feat: change typechain imports to fuels (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Mar 12, 2022
1 parent d652af5 commit 2bfac73
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 27 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/example-contract/src/example-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ describe('ExampleContract', () => {

// Assert
expect(result.toNumber()).toEqual(1337);

// Try co call from the factory
const contractInstance = ExampleContractAbi__factory.connect(contract.id, wallet);
const resultInstance = await contractInstance.functions.return_input(1337);

expect(resultInstance.toNumber()).toBe(1337);
});
});
1 change: 1 addition & 0 deletions packages/fuels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@ethersproject/bignumber": "^5.6.0",
"@ethersproject/bytes": "^5.6.0",
"@fuel-ts/abi-coder": "0.3.0",
"@fuel-ts/constants": "0.3.0",
"@fuel-ts/contract": "0.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/fuels/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from '@ethersproject/bytes';
export * from '@ethersproject/bignumber';
export * from '@fuel-ts/abi-coder';
export * from '@fuel-ts/constants';
Expand Down
14 changes: 9 additions & 5 deletions packages/typechain-target-fuels/example/types/Demo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
/* tslint:disable */
/* eslint-disable */

import { Interface, FunctionFragment, DecodedValue } from "@fuel-ts/abi-coder";
import { Contract, Overrides } from "@fuel-ts/contract";
import { Provider } from "@fuel-ts/providers";
import { BigNumberish } from "@ethersproject/bignumber";
import { BytesLike } from "@ethersproject/bytes";
import type {
Interface,
FunctionFragment,
DecodedValue,
Contract,
Overrides,
BigNumberish,
BytesLike,
} from "fuels";

export type PersonStruct = { name: string; address: string };

Expand Down
14 changes: 9 additions & 5 deletions packages/typechain-target-fuels/example/types/Token.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
/* tslint:disable */
/* eslint-disable */

import { Interface, FunctionFragment, DecodedValue } from "@fuel-ts/abi-coder";
import { Contract, Overrides } from "@fuel-ts/contract";
import { Provider } from "@fuel-ts/providers";
import { BigNumberish } from "@ethersproject/bignumber";
import { BytesLike } from "@ethersproject/bytes";
import type {
Interface,
FunctionFragment,
DecodedValue,
Contract,
Overrides,
BigNumberish,
BytesLike,
} from "fuels";

export type ArgsStruct = { reciever: string; amount: BigNumberish };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
/* tslint:disable */
/* eslint-disable */

import { Interface } from "@fuel-ts/abi-coder";
import type { Provider } from "@fuel-ts/providers";
import type { Wallet } from "@fuel-ts/wallet";
import { Contract } from "@fuel-ts/contract";
import type { Provider, Wallet } from "fuels";
import { Interface, Contract } from "fuels";
import type { Demo, DemoInterface } from "../Demo";
const _abi = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
/* tslint:disable */
/* eslint-disable */

import { Interface } from "@fuel-ts/abi-coder";
import type { Provider } from "@fuel-ts/providers";
import type { Wallet } from "@fuel-ts/wallet";
import { Contract } from "@fuel-ts/contract";
import type { Provider, Wallet } from "fuels";
import { Interface, Contract } from "fuels";
import type { Token, TokenInterface } from "../Token";
const _abi = [
{
Expand Down
12 changes: 3 additions & 9 deletions packages/typechain-target-fuels/src/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ import generateStruct from './structs';
*/
export function codegenContractTypings(contract: Contract, codegenConfig: CodegenConfig): string {
const template = `
import { Interface, FunctionFragment, DecodedValue } from '@fuel-ts/abi-coder';
import { Contract, Overrides } from '@fuel-ts/contract';
import { Provider } from '@fuel-ts/providers';
import { BigNumberish } from '@ethersproject/bignumber';
import { BytesLike } from '@ethersproject/bytes';
import type { Interface, FunctionFragment, DecodedValue, Contract, Overrides, BigNumberish, BytesLike } from 'fuels';
${Object.values(contract.structs)
.map((v) => generateStruct(v[0]))
Expand Down Expand Up @@ -89,10 +85,8 @@ function codegenCommonContractFactory(
abi: RawAbiDefinition[]
): { header: string; body: string } {
const header = `
import { Interface } from "@fuel-ts/abi-coder";
import type { Provider } from "@fuel-ts/providers";
import type { Wallet } from "@fuel-ts/wallet";
import { Contract } from "@fuel-ts/contract";
import type { Provider, Wallet } from "fuels";
import { Interface, Contract } from "fuels";
import type { ${contract.name}, ${contract.name}Interface } from "../${contract.name}";
const _abi = ${JSON.stringify(abi, null, 2)};
`.trim();
Expand Down

0 comments on commit 2bfac73

Please sign in to comment.