{"_id":"@archisinal/typechain-polkadot","_rev":"8-f8ff076cdc11098d24734a48e6380029","name":"@archisinal/typechain-polkadot","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.1":{"name":"@archisinal/typechain-polkadot","version":"1.0.1","author":{"name":"Supercolony-net"},"_id":"@archisinal/typechain-polkadot@1.0.1","maintainers":[{"name":"semirazov","email":"semirazov94@gmail.com"}],"homepage":"https://github.com/archisinal/typechain-polkadot#readme","bugs":{"url":"https://github.com/archisinal/typechain-polkadot/issues"},"bin":{"typechain-polkadot":"bin/index.js"},"dist":{"shasum":"91d0cbfe07a2910e51521adc76fa9020248f3d5d","tarball":"https://registry.npmjs.org/@archisinal/typechain-polkadot/-/typechain-polkadot-1.0.1.tgz","fileCount":40,"integrity":"sha512-G9I0ZuVDKVdYh+TA7WkMHGpB9Wfjr8v/mgjLkqXfwk4ToLcddgAhAHQLQtfDRMmEmRyqRduI3zOBI1q/yAPOiw==","signatures":[{"sig":"MEUCIQDxeNER/IRIwxLiFgsHTJBJrM0qxixK6jEGiT0a4XVLNgIgOj61oGAjntmiUwETUJFcRnKUp9EobRQUuLoXKIKDNLM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":88914},"engines":{"npm":">=7.0.0","node":">=16.0.0"},"gitHead":"fe4c3cbc02a1c7f85a0e1fa390bb74b3cb9d6867","scripts":{"lint":"eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\"","start":"ts-node index.ts --in artifacts --out out","lint:fix":"eslint --fix \"{src,tests}/**/*.{js,jsx,ts,tsx}\""},"_npmUser":{"name":"semirazov","email":"semirazov94@gmail.com"},"repository":{"url":"git+https://github.com/archisinal/typechain-polkadot.git","type":"git"},"_npmVersion":"10.1.0","description":"---","directories":{},"_nodeVersion":"20.9.0","dependencies":{"yargs":"^17.5.1","eslint":"^8.18.0","ts-node":"^10.7.0","fs-extra":"^9.1.0","prettier":"^2.7.1","camelcase":"^6.3.0","handlebars":"^4.7.7","@types/node":"^18.11.18","@types/yargs":"^17.0.10","@polkadot/api":"^10.8.1","@types/fs-extra":"^9.0.13","@polkadot/keyring":"^12.2.2","@polkadot/api-contract":"^10.8.1","@archisinal/typechain-polkadot-parser":"1.0.1"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"hjson":"^3.2.2","eslint":"^8.18.0","ts-jest":"^28.0.3","typescript":"^4.7.4","@types/jest":"^27.5.2","@types/bn.js":"^5.1.0","@types/eslint":"^8.4.3","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","@typescript-eslint/parser":"^5.25.0","@archisinal/typechain-types":"1.0.1","@typescript-eslint/eslint-plugin":"^5.25.0","eslint-import-resolver-typescript":"^2.7.1"},"_npmOperationalInternal":{"tmp":"tmp/typechain-polkadot_1.0.1_1702410335568_0.15554832377804728","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@archisinal/typechain-polkadot","version":"1.0.2","author":{"name":"Supercolony-net"},"_id":"@archisinal/typechain-polkadot@1.0.2","maintainers":[{"name":"semirazov","email":"semirazov94@gmail.com"}],"homepage":"https://github.com/archisinal/typechain-polkadot#readme","bugs":{"url":"https://github.com/archisinal/typechain-polkadot/issues"},"bin":{"typechain-polkadot":"bin/index.js"},"dist":{"shasum":"81e569040530e820cf644dd83f305572bf456608","tarball":"https://registry.npmjs.org/@archisinal/typechain-polkadot/-/typechain-polkadot-1.0.2.tgz","fileCount":40,"integrity":"sha512-mYw8y3rmpjtasVQ0vbctVaiMPwRE6LiT9hQeBJdvrRbHotxJdBKvMoBs561Kx2OjVxeTr/KJnCCnLyBRuN3wOg==","signatures":[{"sig":"MEUCIC3hGEkRYAX/bnMx+D6uqAD3eEdAFA7Od7qq1jPFyx1gAiEA8+QL+zHL81nPmYqLn+novz7FH0uA/mc53NnxrgZO7bk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":86413},"engines":{"npm":">=7.0.0","node":">=16.0.0"},"gitHead":"fe4c3cbc02a1c7f85a0e1fa390bb74b3cb9d6867","scripts":{"lint":"eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\"","start":"ts-node index.ts --in artifacts --out out","lint:fix":"eslint --fix \"{src,tests}/**/*.{js,jsx,ts,tsx}\""},"_npmUser":{"name":"semirazov","email":"semirazov94@gmail.com"},"repository":{"url":"git+https://github.com/archisinal/typechain-polkadot.git","type":"git"},"_npmVersion":"10.2.4","description":"---","directories":{},"_nodeVersion":"20.11.1","dependencies":{"yargs":"^17.5.1","eslint":"^8.18.0","ts-node":"^10.7.0","fs-extra":"^9.1.0","prettier":"^2.7.1","camelcase":"^6.3.0","handlebars":"^4.7.7","@types/node":"^18.11.18","@types/yargs":"^17.0.10","@polkadot/api":"^12.3.1","@types/fs-extra":"^9.0.13","@polkadot/keyring":"^13.0.2","@polkadot/api-contract":"^12.3.1","@archisinal/typechain-polkadot-parser":"1.0.2"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"hjson":"^3.2.2","eslint":"^8.18.0","ts-jest":"^28.0.3","typescript":"^4.7.4","@types/jest":"^27.5.2","@types/bn.js":"^5.1.0","@types/eslint":"^8.4.3","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","@typescript-eslint/parser":"^5.25.0","@archisinal/typechain-types":"1.0.2","@typescript-eslint/eslint-plugin":"^5.25.0","eslint-import-resolver-typescript":"^2.7.1"},"_npmOperationalInternal":{"tmp":"tmp/typechain-polkadot_1.0.2_1723715624815_0.9225351370420543","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@archisinal/typechain-polkadot","version":"1.0.3","author":{"name":"Supercolony-net"},"_id":"@archisinal/typechain-polkadot@1.0.3","maintainers":[{"name":"semirazov","email":"semirazov94@gmail.com"}],"homepage":"https://github.com/archisinal/typechain-polkadot#readme","bugs":{"url":"https://github.com/archisinal/typechain-polkadot/issues"},"bin":{"typechain-polkadot":"bin/index.js"},"dist":{"shasum":"ffe296d61a9b2a93dac55bb93e4f3c8dabdaf9bf","tarball":"https://registry.npmjs.org/@archisinal/typechain-polkadot/-/typechain-polkadot-1.0.3.tgz","fileCount":40,"integrity":"sha512-DwUPBuWcye5nLzT7vr9vijYP0tqZaet0gHBZrF0m72IhmuMI5jyA2EC3k6Hwmkzhoh4BgujIjtyPLUo36ISqlw==","signatures":[{"sig":"MEUCIEI9/Ez4NrOrKOBRBScbyEnf+I1om/DJPAQqHu5YVOwHAiEA5mnxkF0BVmeJdMnM3O3DLsQTfpV//9q80momscGFL6o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":86371},"engines":{"npm":">=7.0.0","node":">=16.0.0"},"gitHead":"fe4c3cbc02a1c7f85a0e1fa390bb74b3cb9d6867","scripts":{"lint":"eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\"","start":"ts-node index.ts --in artifacts --out out","lint:fix":"eslint --fix \"{src,tests}/**/*.{js,jsx,ts,tsx}\""},"_npmUser":{"name":"semirazov","email":"semirazov94@gmail.com"},"repository":{"url":"git+https://github.com/archisinal/typechain-polkadot.git","type":"git"},"_npmVersion":"10.2.4","description":"---","directories":{},"_nodeVersion":"20.11.1","dependencies":{"yargs":"^17.5.1","eslint":"^8.18.0","ts-node":"^10.7.0","fs-extra":"^9.1.0","prettier":"^2.7.1","camelcase":"^6.3.0","handlebars":"^4.7.7","@types/node":"^18.11.18","@types/yargs":"^17.0.10","@polkadot/api":"^12.3.1","@types/fs-extra":"^9.0.13","@polkadot/keyring":"^13.0.2","@polkadot/api-contract":"^12.3.1","@archisinal/typechain-polkadot-parser":"1.0.2"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"hjson":"^3.2.2","eslint":"^8.18.0","ts-jest":"^28.0.3","typescript":"^4.7.4","@types/jest":"^27.5.2","@types/bn.js":"^5.1.0","@types/eslint":"^8.4.3","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","@typescript-eslint/parser":"^5.25.0","@archisinal/typechain-types":"1.0.2","@typescript-eslint/eslint-plugin":"^5.25.0","eslint-import-resolver-typescript":"^2.7.1"},"_npmOperationalInternal":{"tmp":"tmp/typechain-polkadot_1.0.3_1723744046861_0.8908771049297295","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@archisinal/typechain-polkadot","version":"1.0.4","scripts":{"start":"ts-node index.ts --in artifacts --out out","lint":"eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\"","lint:fix":"eslint --fix \"{src,tests}/**/*.{js,jsx,ts,tsx}\""},"bin":{"typechain-polkadot":"bin/index.js"},"engines":{"node":">=16.0.0","npm":">=7.0.0"},"engineStrict":true,"dependencies":{"@archisinal/typechain-polkadot-parser":"1.0.2","@polkadot/api":"^12.3.1","@polkadot/api-contract":"^12.3.1","@polkadot/keyring":"^13.0.2","@types/fs-extra":"^9.0.13","@types/node":"^18.11.18","@types/yargs":"^17.0.10","camelcase":"^6.3.0","eslint":"^8.18.0","fs-extra":"^9.1.0","handlebars":"^4.7.7","prettier":"^2.7.1","ts-node":"^10.7.0","yargs":"^17.5.1"},"devDependencies":{"@archisinal/typechain-types":"1.0.2","@types/bn.js":"^5.1.0","@types/eslint":"^8.4.3","@types/jest":"^27.5.2","@typescript-eslint/eslint-plugin":"^5.25.0","@typescript-eslint/parser":"^5.25.0","eslint":"^8.18.0","eslint-import-resolver-typescript":"^2.7.1","eslint-plugin-import":"^2.26.0","eslint-plugin-node":"^11.1.0","hjson":"^3.2.2","ts-jest":"^28.0.3","typescript":"^4.7.4"},"author":{"name":"Supercolony-net"},"homepage":"https://github.com/archisinal/typechain-polkadot#readme","repository":{"type":"git","url":"git+https://github.com/archisinal/typechain-polkadot.git"},"bugs":{"url":"https://github.com/archisinal/typechain-polkadot/issues"},"gitHead":"fe4c3cbc02a1c7f85a0e1fa390bb74b3cb9d6867","_id":"@archisinal/typechain-polkadot@1.0.4","description":"---","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-DmE4wK+I0HTN/wwbwZZTq3fIdCmX/u/I0J2FYK0guJIl8+x+EKvpe1njQQrUgg2ZWzkmaarTXCv8lrFeXFJ/3g==","shasum":"88dd603987c572f34c2113b69edf6f2dd6963695","tarball":"https://registry.npmjs.org/@archisinal/typechain-polkadot/-/typechain-polkadot-1.0.4.tgz","fileCount":40,"unpackedSize":86359,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICY0PQP3DWFR16lb1pYCqi3NpGbQLxAcIkN3bKtC6Vb+AiA3nDMPJgxDPoYJ3gjwuuaFYMDnMlW72dY2sv1Fzov5NA=="}]},"_npmUser":{"name":"semirazov","email":"semirazov94@gmail.com"},"directories":{},"maintainers":[{"name":"semirazov","email":"semirazov94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typechain-polkadot_1.0.4_1723745268213_0.751657035339423"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-12T19:45:35.477Z","modified":"2024-08-15T18:07:48.601Z","1.1.1":"2023-12-12T19:15:32.977Z","1.0.0":"2023-12-12T19:33:23.713Z","1.0.1":"2023-12-12T19:45:35.712Z","1.0.2":"2024-08-15T09:53:45.042Z","1.0.3":"2024-08-15T17:47:27.060Z","1.0.4":"2024-08-15T18:07:48.388Z"},"bugs":{"url":"https://github.com/archisinal/typechain-polkadot/issues"},"author":{"name":"Supercolony-net"},"homepage":"https://github.com/archisinal/typechain-polkadot#readme","repository":{"type":"git","url":"git+https://github.com/archisinal/typechain-polkadot.git"},"description":"---","maintainers":[{"name":"semirazov","email":"semirazov94@gmail.com"}],"readme":"# Typechain-polkadot\n\n---\n\nPackage for generating TypeScript definitions & runtime code for Polkadot smart contracts.\n\n---\n\n## Usage\n\nIn your project install this package:\n\n```bash\nnpm i -D @archisinal/typechain-polkadot\n```\n\nNow you can use it to generate TS definitions & runtime code for Polkadot smart contracts. To use typechain-polkadot.\n\n> Note, that ink! contracts generate two files: `metadata.json` and `<contract-name>.contract`. You need to provide both of them to typechain-polkadot, and rename `metadata.json` to `<contract-name>.json`.\n\nTypechain can be used in two ways:\n\n- As a CLI tool\n- As a library\n\n### CLI tool\n\nAfter installing the package, you can use it as a CLI tool. To use it, run the following command:\n\n```bash\nnpx @archisinal/typechain-polkadot --input path/to/abis --output path/to/output\n```\n\n## Methods and namespaces used in the typechain, and their description\n\n### build-extrinsic\n\nIn this namespace you can find all the functions that are related to building extrinsics.\n\n```typescript\nconst tx = contract.buildExtrinsic.<methodName>(...args, options);\n\ntx.signAndSend(account, (result) => {\n\t// Handle result\n});\n```\n\n### constructors\nUsed to deploy contracts, using different constructors.\n\nLet's deploy the following contract:\n```rust\n#![cfg_attr(not(feature = \"std\"), no_std)]\n#![feature(min_specialization)]\n\n#[openbrush::contract]\npub mod my_psp22 {\n\n    // imports from openbrush\n\tuse openbrush::contracts::psp22::*;\n\tuse openbrush::traits::Storage;\n\n    #[ink(storage)]\n    #[derive(Default, Storage)]\n    pub struct Contract {\n    \t#[storage_field]\n\t\tpsp22: psp22::Data,\n    }\n\n    // Section contains default implementation without any modifications\n\timpl PSP22 for Contract {}\n\n    impl Contract {\n        #[ink(constructor)]\n        pub fn new(initial_supply: Balance) -> Self {\n            let mut _instance = Self::default();\n\t\t\t_instance._mint_to(_instance.env().caller(), initial_supply).expect(\"Should mint\");\n\t\t\t_instance\n        }\n    }\n}\n```\nThis contract has a constructor `new` with one argument `initial_supply`.\nTo deploy this contract, you need to use the following code:\n```typescript\n// Import here Constructors and Contract classes\n\n// Here we are creating an instance of the Constructors class, which is used to deploy contracts,\n// Constructors is typechain-generated class that contains all the constructors of the contract\nconst factory = new Constructors(api, UserAlice);\n\n// You can access to the different constructors using the name of the constructor, here we will use \"new\"\nconst {result, address} = await factory.new('10', {});\n\n// Here we are creating an instance of the Contract class, which is used to interact with the deployed contract\ncontract = new Contract(address, UserAlice, api);\n```\n\n### contract\n\nContract is the main namespace for interacting with contracts. It contains all the functions that are related to contracts.\n\n```typescript\nconst contract = new Contract(\n\t\taddress,\n\t\tsigner,\n\t\tnativeAPI,\n)\n\ncontract.name() // get the name of the contract\n\ncontract.address() // get the address of the contract\n\ncontract.abi() // get the abi of the contract\n\ncontract.<namespace>.<functionName>(...args, options) // call a function from a namespace\n// namespace can be tx, query, events, etc.\n\ncontract.withSigner(signer)\n// change the signer of the contract in the current context,\n// basically it will create a new contract with the new signer\n\ncontract.withAddress(address)\n// change the address of the contract in the current context,\n// basically it will create a new contract with the new address\n// useful for proxy contracts\n\ncontract.withAPI(api)\n// change the api of the contract in the current context\n// basically it will create a new contract with the new api\n\n```\n\n### data\nUtility file. Contains all info about types. It's used in runtime to parse return values from contracts.\n\n### mixed-methods\nThis namespace contains both tx and query methods.\n\n```typescript\ncontract.mixedMethods.<functionName>(...args, options)\n```\n\n### query\nThis namepsace contains all query methods\n\n```typescript\nconst result = contract.query.<functionName>(...args, options)\n\nconsole.log(result.value)\n```\n\nYou can also use it to get errors from contracts\n\n```typescript\ntry {\n\tawait contract.withSigner(UserBob).query.transfer(UserAlice.address, '10', []);\n} catch ({ _err }) {\n\tconsole.log(_err);\n}\n```\n```bash\nconsole.log\n\t{ insufficientBalance: null }\n```\n\n### tx-sign-and-send\n\nThis namespace is used send transactions.\n\n```typescript\nconst result = await contract.tx.<functionName>(...args, options)\n```\n\n### Library\n\nYou can also use typechain-polkadot as a library. To use it, you need to import it in your code:\n\n```typescript\nimport {Typechain} from '@archisinal/typechain-polkadot/src/types/typechain';\nimport {testPathPatternToRegExp} from \"jest-util\";\n\nconst typechain = new Typechain();\n\ntypechain.loadDefaultPlugins();\n\ntypechain.run(\n\tpathToInput,\n\tpathToOutput\n)\n```\n\n## Plugins\n\nTypechain-polkadot uses plugins to generate code. By default, it uses the following plugins:\n\n- build-extrinsic [docs](./docs/build-extrinsic.md)\n- constructors [docs](./docs/constructors.md)\n- contract [docs](./docs/contract.md)\n- data [docs](./docs/data.md)\n- events [docs](./docs/events.md)\n- events-types [docs](./docs/events-types.md)\n- mixed-methods [docs](./docs/mixed-methods.md)\n- query [docs](./docs/query.md)\n- tx-sign-and-send [docs](./docs/tx-sign-and-send.md)\n\n\n\nYou can also create your own plugins to add some custom logic to the typechain-polkadot. To do this, you need to create a class that implements the `TypechainPlugin` interface:\n\n```typescript\nimport {TypechainPlugin} from '@archisinal/typechain-polkadot/src/types/interfaces';\nimport {Abi} from \"@polkadot/api-contract\";\n\n/**\n * generates a contract file\n *\n * @param abi - The ABI of the contract\n * @param fileName - The name of the file to write to\n * @param absPathToOutput - The absolute path to the output directory\n * @param absPathToABIs - The absolute path to the ABIs directory\n */\nfunction generate(abi: Abi, fileName: string, absPathToOutput: string, absPathToABIs: string) {\n\tconsole.log('Hello World!');\n}\n\nexport default class HelloWorldPlugin implements TypechainPlugin {\n\n\tname: string = 'HelloWorld';\n\toutputDir: string = 'HelloWorld';\n\n\tgenerate(abi: Abi, fileName: string, absPathToABIs: string, absPathToOutput: string): void {\n\t\tgenerate(abi, fileName, absPathToOutput, absPathToABIs);\n\t}\n}\n```\n\nThen you need to add your plugin to the list of plugins:\n\n```typescript\ntypechain.loadPlugins(new MyPlugin());\n```\n\nOr you can load them via cli:\n\n```bash\nnpx @archisinal/typechain-polkadot --input path/to/abis --output path/to/output --plugins ./plugins-directory\n```\n> Note: if you're using the cli, every plugin should end with `.plugin.ts` and have default export of the plugin itself.\n\nAlso you can use `loadPluginsFromFiles` method to load plugins from files:\n\n```typescript\ntypechain.loadPluginsFromFiles(\n\t'./plugins-directory'\n)\n```\n\n## Example of plugins usage\n\nYou can find an example of plugins usage in the [examples](../../examples) directory.\n\n","readmeFilename":"README.md"}