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

     1  //Code generated by solts. DO NOT EDIT.
     2  import { Address, CancelStreamSignal, ContractCodec, Event, Keccak, linker } 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 Addition {
    34    export const contractName = 'Addition';
    35    export const abi =
    36      '[{"constant":true,"inputs":[{"internalType":"int256","name":"a","type":"int256"},{"internalType":"int256","name":"b","type":"int256"}],"name":"add","outputs":[{"internalType":"int256","name":"sum","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"int256","name":"a","type":"int256"},{"internalType":"int256","name":"b","type":"int256"}],"name":"sub","outputs":[{"internalType":"int256","name":"","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"}]';
    37    export const bytecode =
    38      '608060405234801561001057600080fd5b506101b2806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063a5f3c23b1461003b578063adefc37b14610087575b600080fd5b6100716004803603604081101561005157600080fd5b8101908080359060200190929190803590602001909291905050506100d3565b6040518082815260200191505060405180910390f35b6100bd6004803603604081101561009d57600080fd5b8101908080359060200190929190803590602001909291905050506100e0565b6040518082815260200191505060405180910390f35b6000818301905092915050565b60006101758373__$c58c94ed6aafc60c33b5e1db056449bb85$__6325b832d9856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561013557600080fd5b505af4158015610149573d6000803e3d6000fd5b505050506040513d602081101561015f57600080fd5b81019080805190602001909291905050506100d3565b90509291505056fea265627a7a723158200e39adfefd6f39f3fc67f179a9482aaffb5acf36277d704070d5a0e5f22916c064736f6c63430005110032';
    39    export const deployedBytecode =
    40      '608060405234801561001057600080fd5b50600436106100365760003560e01c8063a5f3c23b1461003b578063adefc37b14610087575b600080fd5b6100716004803603604081101561005157600080fd5b8101908080359060200190929190803590602001909291905050506100d3565b6040518082815260200191505060405180910390f35b6100bd6004803603604081101561009d57600080fd5b8101908080359060200190929190803590602001909291905050506100e0565b6040518082815260200191505060405180910390f35b6000818301905092915050565b60006101758373__$c58c94ed6aafc60c33b5e1db056449bb85$__6325b832d9856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561013557600080fd5b505af4158015610149573d6000803e3d6000fd5b505050506040513d602081101561015f57600080fd5b81019080805190602001909291905050506100d3565b90509291505056fea265627a7a723158200e39adfefd6f39f3fc67f179a9482aaffb5acf36277d704070d5a0e5f22916c064736f6c63430005110032';
    41    export function deploy({
    42      client,
    43      withContractMeta,
    44      libraries: { NegationLib },
    45    }: {
    46      client: Provider;
    47      withContractMeta?: boolean;
    48      libraries: {
    49        NegationLib: string;
    50      };
    51    }): Promise<string> {
    52      const codec = client.contractCodec(abi);
    53      const links = [{ name: '$c58c94ed6aafc60c33b5e1db056449bb85$', address: NegationLib }];
    54      const linkedBytecode = linker(bytecode, links);
    55      const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]);
    56      return client.deploy(
    57        data,
    58        withContractMeta
    59          ? [
    60              {
    61                abi: Addition.abi,
    62                codeHash: new Keccak(256).update(linker(Addition.deployedBytecode, links), 'hex').digest('binary'),
    63              },
    64            ]
    65          : undefined,
    66      );
    67    }
    68    export async function deployContract(deps: {
    69      client: Provider;
    70      withContractMeta?: boolean;
    71      libraries: {
    72        NegationLib: string;
    73      };
    74    }): Promise<Contract> {
    75      const address = await deploy(deps);
    76      return contract(deps.client, address);
    77    }
    78    export type Contract = ReturnType<typeof contract>;
    79    export const contract = (client: Provider, address: string) =>
    80      ({
    81        name: 'Addition',
    82        address,
    83        functions: {
    84          add(
    85            a: number,
    86            b: number,
    87            call = defaultCall,
    88          ): Promise<{
    89            sum: number;
    90          }> {
    91            const data = encode(client).add(a, b);
    92            return call<{
    93              sum: number;
    94            }>(client, address, data, true, (data: Uint8Array | undefined) => {
    95              return decode(client, data).add();
    96            });
    97          },
    98          sub(a: number, b: number, call = defaultCall): Promise<[number]> {
    99            const data = encode(client).sub(a, b);
   100            return call<[number]>(client, address, data, true, (data: Uint8Array | undefined) => {
   101              return decode(client, data).sub();
   102            });
   103          },
   104        } as const,
   105      } as const);
   106    export const encode = (client: Provider) => {
   107      const codec = client.contractCodec(abi);
   108      return {
   109        add: (a: number, b: number) => {
   110          return codec.encodeFunctionData('A5F3C23B', a, b);
   111        },
   112        sub: (a: number, b: number) => {
   113          return codec.encodeFunctionData('ADEFC37B', a, b);
   114        },
   115      };
   116    };
   117    export const decode = (client: Provider, data: Uint8Array | undefined, topics: Uint8Array[] = []) => {
   118      const codec = client.contractCodec(abi);
   119      return {
   120        add: (): {
   121          sum: number;
   122        } => {
   123          const [sum] = codec.decodeFunctionResult('A5F3C23B', data);
   124          return { sum: sum };
   125        },
   126        sub: (): [number] => {
   127          return codec.decodeFunctionResult('ADEFC37B', data);
   128        },
   129      };
   130    };
   131  }