github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/solts/sol/NegationLib.abi.ts (about)

     1  //Code generated by solts. DO NOT EDIT.
     2  import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index';
     3  interface Provider {
     4    deploy(
     5      data: string | Uint8Array,
     6      contractMeta?: {
     7        abi: string;
     8        codeHash: Uint8Array;
     9      }[],
    10    ): Promise<Address>;
    11    call(data: string | Uint8Array, address: string): Promise<Uint8Array | undefined>;
    12    callSim(data: string | Uint8Array, address: string): Promise<Uint8Array | undefined>;
    13    listen(
    14      signatures: string[],
    15      address: string,
    16      callback: (err?: Error, event?: Event) => CancelStreamSignal | void,
    17      start?: 'first' | 'latest' | 'stream' | number,
    18      end?: 'first' | 'latest' | 'stream' | number,
    19    ): unknown;
    20    contractCodec(contractABI: string): ContractCodec;
    21  }
    22  export type Caller = typeof defaultCall;
    23  export async function defaultCall<Output>(
    24    client: Provider,
    25    addr: string,
    26    data: Uint8Array,
    27    isSim: boolean,
    28    callback: (returnData: Uint8Array | undefined) => Output,
    29  ): Promise<Output> {
    30    const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr));
    31    return callback(returnData);
    32  }
    33  export namespace NegationLib {
    34    export const contractName = 'NegationLib';
    35    export const abi =
    36      '[{"constant":true,"inputs":[{"internalType":"int256","name":"a","type":"int256"}],"name":"negate","outputs":[{"internalType":"int256","name":"inverse","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"}]';
    37    export const bytecode =
    38      '60b9610025600b82828239805160001a60731461001857fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806325b832d9146038575b600080fd5b606160048036036020811015604c57600080fd5b81019080803590602001909291905050506077565b6040518082815260200191505060405180910390f35b600081600003905091905056fea265627a7a7231582025f0a2f322c335616644c87b35a42bad6fad892fda8312ab90121566f216478c64736f6c63430005110032';
    39    export const deployedBytecode =
    40      '730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806325b832d9146038575b600080fd5b606160048036036020811015604c57600080fd5b81019080803590602001909291905050506077565b6040518082815260200191505060405180910390f35b600081600003905091905056fea265627a7a7231582025f0a2f322c335616644c87b35a42bad6fad892fda8312ab90121566f216478c64736f6c63430005110032';
    41    export function deploy({
    42      client,
    43      withContractMeta,
    44    }: {
    45      client: Provider;
    46      withContractMeta?: boolean;
    47    }): Promise<string> {
    48      const codec = client.contractCodec(abi);
    49      const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]);
    50      return client.deploy(
    51        data,
    52        withContractMeta
    53          ? [
    54              {
    55                abi: NegationLib.abi,
    56                codeHash: new Keccak(256).update(NegationLib.deployedBytecode, 'hex').digest('binary'),
    57              },
    58            ]
    59          : undefined,
    60      );
    61    }
    62    export async function deployContract(deps: { client: Provider; withContractMeta?: boolean }): Promise<Contract> {
    63      const address = await deploy(deps);
    64      return contract(deps.client, address);
    65    }
    66    export type Contract = ReturnType<typeof contract>;
    67    export const contract = (client: Provider, address: string) =>
    68      ({
    69        name: 'NegationLib',
    70        address,
    71        functions: {
    72          negate(
    73            a: number,
    74            call = defaultCall,
    75          ): Promise<{
    76            inverse: number;
    77          }> {
    78            const data = encode(client).negate(a);
    79            return call<{
    80              inverse: number;
    81            }>(client, address, data, true, (data: Uint8Array | undefined) => {
    82              return decode(client, data).negate();
    83            });
    84          },
    85        } as const,
    86      } as const);
    87    export const encode = (client: Provider) => {
    88      const codec = client.contractCodec(abi);
    89      return {
    90        negate: (a: number) => {
    91          return codec.encodeFunctionData('25B832D9', a);
    92        },
    93      };
    94    };
    95    export const decode = (client: Provider, data: Uint8Array | undefined, topics: Uint8Array[] = []) => {
    96      const codec = client.contractCodec(abi);
    97      return {
    98        negate: (): {
    99          inverse: number;
   100        } => {
   101          const [inverse] = codec.decodeFunctionResult('25B832D9', data);
   102          return { inverse: inverse };
   103        },
   104      };
   105    };
   106  }