-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: purge hardcoded snippets on 'using typegen' page
- Loading branch information
Showing
22 changed files
with
531 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,14 @@ | |
"author": "Fuel Labs <[email protected]> (https://fuel.network/)", | ||
"scripts": { | ||
"pretest": "run-s build:forc build:types", | ||
"build:forc": "pnpm fuels-forc build -p contract", | ||
"build:types": "pnpm fuels typegen -i contract/out/debug/demo-contract-abi.json -o src/generated-types" | ||
"build:forc": "pnpm forc:contract && pnpm forc:script && pnpm forc:predicate", | ||
"forc:contract": "pnpm fuels-forc build -p contract", | ||
"forc:script": "pnpm fuels-forc build -p script", | ||
"forc:predicate": "pnpm fuels-forc build -p predicate", | ||
"build:types": "pnpm types:contract && pnpm types:script && pnpm types:predicate", | ||
"types:contract": "pnpm fuels typegen -i contract/out/debug/demo-contract-abi.json -o src/contract-types", | ||
"types:script": "pnpm fuels typegen -i script/out/debug/script-abi.json -o src/script-types --script", | ||
"types:predicate": "pnpm fuels typegen -i predicate/out/debug/predicate-abi.json -o src/predicate-types --predicate" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[project] | ||
authors = ["Dhaiwat Pandya"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "predicate" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
predicate; | ||
|
||
fn main(input: u8) -> bool { | ||
let answer: u8 = 10; | ||
|
||
input == answer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[project] | ||
authors = ["Dhaiwat Pandya"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "script" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
script; | ||
|
||
fn main() -> u8 { | ||
10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
import type { | ||
BigNumberish, | ||
BN, | ||
BytesLike, | ||
Contract, | ||
DecodedValue, | ||
FunctionFragment, | ||
Interface, | ||
InvokeFunction, | ||
} from 'fuels'; | ||
|
||
interface DemoContractAbiInterface extends Interface { | ||
functions: { | ||
return_input: FunctionFragment; | ||
}; | ||
|
||
encodeFunctionData(functionFragment: 'return_input', values: [BigNumberish]): Uint8Array; | ||
|
||
decodeFunctionData(functionFragment: 'return_input', data: BytesLike): DecodedValue; | ||
} | ||
|
||
export class DemoContractAbi extends Contract { | ||
interface: DemoContractAbiInterface; | ||
functions: { | ||
return_input: InvokeFunction<[input: BigNumberish], BN>; | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/demo-typegen/src/contract-types/DemoContractAbi.hex.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
export default '0x740000034700000000000000000000445dfcc00110fff3005d4060495d47f000134904407648000272f0007b36f000001aec5000910000005d40604a2440000047000000000000002d8ccb5b' |
82 changes: 82 additions & 0 deletions
82
apps/demo-typegen/src/contract-types/factories/DemoContractAbi__factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
import { Interface, Contract, ContractFactory } from "fuels"; | ||
import type { Provider, Account, AbstractAddress, BytesLike, DeployContractOptions, StorageSlot } from "fuels"; | ||
import type { DemoContractAbi, DemoContractAbiInterface } from "../DemoContractAbi"; | ||
|
||
const _abi = { | ||
"types": [ | ||
{ | ||
"typeId": 0, | ||
"type": "u64", | ||
"components": null, | ||
"typeParameters": null | ||
} | ||
], | ||
"functions": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "input", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
], | ||
"name": "return_input", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
"attributes": null | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"configurables": [] | ||
}; | ||
|
||
const _storageSlots: StorageSlot[] = []; | ||
|
||
export class DemoContractAbi__factory { | ||
static readonly abi = _abi; | ||
|
||
static readonly storageSlots = _storageSlots; | ||
|
||
static createInterface(): DemoContractAbiInterface { | ||
return new Interface(_abi) as unknown as DemoContractAbiInterface | ||
} | ||
|
||
static connect( | ||
id: string | AbstractAddress, | ||
accountOrProvider: Account | Provider | ||
): DemoContractAbi { | ||
return new Contract(id, _abi, accountOrProvider) as unknown as DemoContractAbi | ||
} | ||
|
||
static async deployContract( | ||
bytecode: BytesLike, | ||
wallet: Account, | ||
options: DeployContractOptions = {} | ||
): Promise<DemoContractAbi> { | ||
const factory = new ContractFactory(bytecode, _abi, wallet); | ||
|
||
const { storageSlots } = DemoContractAbi__factory; | ||
|
||
const contract = await factory.deployContract({ | ||
storageSlots, | ||
...options, | ||
}); | ||
|
||
return contract as unknown as DemoContractAbi; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
export type { DemoContractAbi } from './DemoContractAbi'; | ||
|
||
export { DemoContractAbi__factory } from './factories/DemoContractAbi__factory'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
import type { | ||
BytesLike, | ||
Contract, | ||
DecodedValue, | ||
FunctionFragment, | ||
Interface, | ||
InvokeFunction, | ||
} from 'fuels'; | ||
|
||
interface PredicateAbiInterface extends Interface { | ||
functions: { | ||
main: FunctionFragment; | ||
}; | ||
|
||
encodeFunctionData(functionFragment: 'main', values: [string]): Uint8Array; | ||
|
||
decodeFunctionData(functionFragment: 'main', data: BytesLike): DecodedValue; | ||
} | ||
|
||
export class PredicateAbi extends Contract { | ||
interface: PredicateAbiInterface; | ||
functions: { | ||
main: InvokeFunction<[input_address: string], boolean>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 0.65.0 | ||
Forc version: 0.46.1 | ||
Fuel-Core version: 0.20.8 | ||
*/ | ||
|
||
export default '0x740000034700000000000000000000605dfcc00110fff3001aec5000910000007144000361491101764800026141110d74000007724c0002134924c05a492001764800026141111f74000001240000005d47f00410451300a141046024400000fc05c23a8f7f66222377170ddcbfea9c543dff0dd2d2ba4d0478a4521423a9d40000000000000060' |
Oops, something went wrong.