abi-wan-kanabi
Advanced tools
Comparing version 2.1.0-rc.4 to 2.1.0-rc.5
@@ -65,3 +65,3 @@ #!/usr/bin/env node | ||
// function calls (\`const ret = contract.your_function()\`) and you'll get | ||
// helpful editor autocompletion, linting errors ... | ||
// helpful editor autocompletion, linting errors ... for free ! Enjoy ! | ||
} | ||
@@ -86,1 +86,2 @@ main().catch(console.error)`; | ||
run().catch(console.error); | ||
//# sourceMappingURL=generate.js.map |
{ | ||
"name": "abi-wan-kanabi", | ||
"version": "2.1.0-rc.4", | ||
"version": "2.1.0-rc.5", | ||
"description": "Abi parser for Cairo smart contracts, based on wagmi abitype", | ||
@@ -9,4 +9,8 @@ "main": "index.js", | ||
}, | ||
"files": ["dist"], | ||
"scripts": { | ||
"generate": "tsc && node dist/generate.js", | ||
"build": "tsc", | ||
"clean": "rm -rf dist", | ||
"prepack": "npm run clean && npm run build", | ||
"generate": "npm run build && node dist/generate.js", | ||
"test": "vitest", | ||
@@ -13,0 +17,0 @@ "coverage": "vitest run --coverage", |
@@ -56,2 +56,32 @@ # ABI-WAN-KANABI | ||
### Usage with `starknet.js` | ||
Let's say you want to interact with the [Ekubu: Core](https://starkscan.co/contract/0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b) contract using starknet.js, using abiwan you can get the correct types for the contract's functions | ||
You need to first get the **Abi** of the contract and export it in a typescript file, you can do so using one command combining both [`starkli`](https://github.com/xJonathanLEI/starkli) (tested with version 0.2.3) and `npx abi-wan-kanabi`: | ||
```bash | ||
starkli class-at "0x0000000dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b" --network mainnet | npx abi-wan-kanabi --input /dev/stdin --output abi.ts | ||
``` | ||
The command will get the contract class from the network, and pipe it to abiwan, which will generate `abi.ts` with `export const ABI = [YOUR ABI HERE]` that we'll import later to get type information, the command will also print a helpful snippet that you can use to get started | ||
```javascript | ||
import { Contract, RpcProvider, constants } from 'starknet'; | ||
import { ABI } from './abi'; | ||
async function main() { | ||
const address = "CONTRACT_ADDRESS_HERE"; | ||
const provider = new RpcProvider({ nodeUrl: constants.NetworkName.SN_MAIN }); | ||
const contract = new Contract(ABI, address, provider).typedv2(ABI); | ||
const version = await contract.getVersion(); | ||
console.log("version", version) | ||
// Abiwan is now successfully installed, just start writing your contract | ||
// function calls (`const ret = contract.your_function()`) and you'll get | ||
// helpful editor autocompletion, linting errors ... | ||
} | ||
main().catch(console.error) | ||
``` | ||
### Build | ||
@@ -58,0 +88,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96354
27
219
1475
1