0.1.33 • Published 1 year ago

webpack-sol-loader v0.1.33

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Loader for .sol files and typescript support.

Compiles .sol with Solidity compiler. Provides following object depending on imported .sol file.

interface SolidityDocument {
    abi: AbiItem,
    bytecode: string,
    contracts: undefined
}

interface SolidityDocumentCollection {
    contracts: SolidityDocument[]
}

Installation

npm install webpack-sol-loader --save-dev

Usage

Update your webpack.config.ts:

const config: Configuration = {
	module: {
		rules: [{
			test: /\.sol?$/,
			use: {
				loader: 'webpack-sol-loader'
			}
		}]
	}
}

Just import .sol file

import wallet from './wallet.sol'
// => returns SolidityDocument or SolidityDocumentCollection that are written above.

Types

Create file webpack-sol-loader.d.ts and include the following:

type AbiType = 'function' | 'constructor' | 'event' | 'fallback' | 'receive';
type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable';

interface AbiInput {
    name: string;
    type: string;
    indexed?: boolean;
    components?: AbiInput[];
    internalType?: string;
}

interface AbiOutput {
    name: string;
    type: string;
    components?: AbiOutput[];
    internalType?: string;
}

interface AbiItem {
    anonymous?: boolean;
    constant?: boolean;
    inputs?: AbiInput[];
    name?: string;
    outputs?: AbiOutput[];
    payable?: boolean;
    stateMutability?: StateMutabilityType;
    type: AbiType;
    gas?: number;
}

interface SolidityDocument {
    abi: AbiItem,
    bytecode: string,
    contracts: undefined
}

interface SolidityDocumentCollection {
    abi: undefined,
    source: undefined,
    bytecode: undefined
    contracts: SolidityDocument[]
}

declare module '*.sol' {
    const value: SolidityDocument | SolidityDocumentCollection
    export default value
}
0.1.33

1 year ago

0.1.32

1 year ago

0.1.31

1 year ago

0.1.3

1 year ago

0.1.25

1 year ago

0.1.242

1 year ago

0.1.241

1 year ago

0.1.24

1 year ago

0.1.23

1 year ago

0.1.22

1 year ago

0.1.21

1 year ago

0.1.2

1 year ago

0.1.19

1 year ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago