embeds

package
v2.0.0-rc.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

@nibiruchain/solidity

Nibiru EVM solidity contracts and ABIs for Nibiru-specific precompiles and core protocol functionality.

Install

yarn add @nibiruchain/solidity

# OR npm install OR bun install

Solidity code is in "@nibiruchain/solidity/contracts/*", and ABI JSON files are in "@nibiruchain/solidity/abi/*".

Hacking

Hacking - Nibiru EVM Solidity Embeds

Documentation

Overview

Package "embeds" adds access to files (smart contracts) embedded in the Go runtime. Go source files that import "embed" can use the //go:embed directive to initialize a variable of type string, \[]byte, or \[FS] with the contents of files read from the package directory or subdirectories at compile time.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Contract_ERC20Minter: The default ERC20 contract deployed during the
	// creation of a `FunToken` mapping from a bank coin.
	SmartContract_ERC20Minter = CompiledEvmContract{
		Name:      "ERC20Minter.sol",
		EmbedJSON: erc20MinterContractJSON,
	}

	// SmartContract_Funtoken: Precompile contract interface for
	// "IFunToken.sol". This precompile enables transfers of ERC20 tokens
	// to non-EVM accounts. Only the ABI is used.
	SmartContract_FunToken = CompiledEvmContract{
		Name:      "IFunToken.sol",
		EmbedJSON: funtokenPrecompileJSON,
	}

	// SmartContract_Funtoken: Precompile contract interface for
	// "Wasm.sol". This precompile enables contract invocations in the Wasm VM
	// from EVM accounts. Only the ABI is used.
	SmartContract_Wasm = CompiledEvmContract{
		Name:      "Wasm.sol",
		EmbedJSON: wasmPrecompileJSON,
	}
	SmartContract_Oracle = CompiledEvmContract{
		Name:      "Oracle.sol",
		EmbedJSON: oracleContractJSON,
	}
	SmartContract_TestERC20 = CompiledEvmContract{
		Name:      "TestERC20.sol",
		EmbedJSON: testErc20Json,
	}
	// SmartContract_TestERC20MaliciousName is a test contract
	// which simulates malicious ERC20 behavior by adding gas intensive operation
	// for function name() intended to attack funtoken creation
	SmartContract_TestERC20MaliciousName = CompiledEvmContract{
		Name:      "TestERC20MaliciousName.sol",
		EmbedJSON: testErc20MaliciousNameJson,
	}
	// SmartContract_TestERC20MaliciousTransfer is a test contract
	// which simulates malicious ERC20 behavior by adding gas intensive operation
	// for function transfer() intended to attack funtoken conversion from erc20 to bank coin
	SmartContract_TestERC20MaliciousTransfer = CompiledEvmContract{
		Name:      "TestERC20MaliciousTransfer.sol",
		EmbedJSON: testErc20MaliciousTransferJson,
	}
	// SmartContract_TestFunTokenPrecompileLocalGas is a test contract
	// which allows precompile execution with custom local gas set (calling precompile within contract)
	SmartContract_TestFunTokenPrecompileLocalGas = CompiledEvmContract{
		Name:      "TestFunTokenPrecompileLocalGas.sol",
		EmbedJSON: testFunTokenPrecompileLocalGasJson,
	}
	// SmartContract_TestNativeSendThenPrecompileSendJson is a test contract that
	// performs two sends in a single call: a native nibi send and a precompile
	// sendToBank. It tests a race condition where the state DB commit may
	// overwrite the state after the precompile execution, potentially causing a
	// loss of funds.
	SmartContract_TestNativeSendThenPrecompileSendJson = CompiledEvmContract{
		Name:      "TestNativeSendThenPrecompileSend.sol",
		EmbedJSON: testNativeSendThenPrecompileSendJson,
	}
	// SmartContract_TestERC20TransferThenPrecompileSend is a test contract that
	// performs two sends in a single call: an erc20 token transfer and a
	// precompile sendToBank. It tests a race condition where the state DB commit
	// may overwrite the state after the precompile execution, potentially
	// causing an infinite token mint.
	SmartContract_TestERC20TransferThenPrecompileSend = CompiledEvmContract{
		Name:      "TestERC20TransferThenPrecompileSend.sol",
		EmbedJSON: testERC20TransferThenPrecompileSendJson,
	}

	// SmartContract_TestPrecompileSelfCallRevert is a test contract
	// that creates another instance of itself, calls the precompile method and then force reverts.
	// It tests a race condition where the state DB commit
	// may save the wrong state before the precompile execution, not revert it entirely,
	// potentially causing an infinite mint of funds.
	SmartContract_TestPrecompileSelfCallRevert = CompiledEvmContract{
		Name:      "TestPrecompileSelfCallRevert.sol",
		EmbedJSON: testPrecompileSelfCallRevertJson,
	}
	// SmartContract_TestInfiniteRecursionERC20 is a test contract
	// which simulates malicious ERC20 behavior by adding infinite recursion in transfer() and balanceOf() functions
	SmartContract_TestInfiniteRecursionERC20 = CompiledEvmContract{
		Name:      "TestInfiniteRecursionERC20.sol",
		EmbedJSON: testInfiniteRecursionERC20Json,
	}
	// SmartContract_TestERC20TransferWithFee is a test contract
	// which simulates malicious ERC20 behavior by adding fee to the transfer() function
	SmartContract_TestERC20TransferWithFee = CompiledEvmContract{
		Name:      "TestERC20TransferWithFee.sol",
		EmbedJSON: testERC20TransferWithFee,
	}
	// SmartContract_TestRandom is a test contract which tests random function
	SmartContract_TestRandom = CompiledEvmContract{
		Name:      "TestRandom.sol",
		EmbedJSON: testRandom,
	}
	// SmartContract_TestBytes32Metadata is a test contract which tests contract that have bytes32 as metadata
	SmartContract_TestBytes32Metadata = CompiledEvmContract{
		Name:      "MKR.sol",
		EmbedJSON: testMetadataBytes32,
	}

	// SmartContract_TestPrecompileSendToBankThenERC20Transfer is a test contract that sends to bank then calls ERC20 transfer
	SmartContract_TestPrecompileSendToBankThenERC20Transfer = CompiledEvmContract{
		Name:      "TestPrecompileSendToBankThenERC20Transfer.sol",
		EmbedJSON: testPrecompileSendToBankThenERC20Transfer,
	}
)

Functions

This section is empty.

Types

type CompiledEvmContract

type CompiledEvmContract struct {
	Name      string
	EmbedJSON []byte

	// filled in post-load
	ABI      *gethabi.ABI `json:"abi"`
	Bytecode []byte       `json:"bytecode"`
}

func (*CompiledEvmContract) MustLoad

func (sc *CompiledEvmContract) MustLoad()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL