github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/solts/sol/storage/Storage.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 Storage { 34 export const contractName = 'Storage'; 35 export const abi = 36 '[{"inputs":[{"internalType":"int256","name":"x","type":"int256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"get","outputs":[{"internalType":"int256","name":"ret","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"int256","name":"x","type":"int256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]'; 37 export const bytecode = 38 '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; 39 export const deployedBytecode = 40 '6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; 41 export function deploy( 42 { 43 client, 44 withContractMeta, 45 }: { 46 client: Provider; 47 withContractMeta?: boolean; 48 }, 49 x: number, 50 ): Promise<string> { 51 const codec = client.contractCodec(abi); 52 const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy(x)]); 53 return client.deploy( 54 data, 55 withContractMeta 56 ? [{ abi: Storage.abi, codeHash: new Keccak(256).update(Storage.deployedBytecode, 'hex').digest('binary') }] 57 : undefined, 58 ); 59 } 60 export async function deployContract( 61 deps: { 62 client: Provider; 63 withContractMeta?: boolean; 64 }, 65 x: number, 66 ): Promise<Contract> { 67 const address = await deploy(deps, x); 68 return contract(deps.client, address); 69 } 70 export type Contract = ReturnType<typeof contract>; 71 export const contract = (client: Provider, address: string) => 72 ({ 73 name: 'Storage', 74 address, 75 functions: { 76 get( 77 call = defaultCall, 78 ): Promise<{ 79 ret: number; 80 }> { 81 const data = encode(client).get(); 82 return call<{ 83 ret: number; 84 }>(client, address, data, true, (data: Uint8Array | undefined) => { 85 return decode(client, data).get(); 86 }); 87 }, 88 set(x: number, call = defaultCall): Promise<void> { 89 const data = encode(client).set(x); 90 return call<void>(client, address, data, false, (data: Uint8Array | undefined) => { 91 return decode(client, data).set(); 92 }); 93 }, 94 } as const, 95 } as const); 96 export const encode = (client: Provider) => { 97 const codec = client.contractCodec(abi); 98 return { 99 get: () => { 100 return codec.encodeFunctionData('6D4CE63C'); 101 }, 102 set: (x: number) => { 103 return codec.encodeFunctionData('E5C19B2D', x); 104 }, 105 }; 106 }; 107 export const decode = (client: Provider, data: Uint8Array | undefined, topics: Uint8Array[] = []) => { 108 const codec = client.contractCodec(abi); 109 return { 110 get: (): { 111 ret: number; 112 } => { 113 const [ret] = codec.decodeFunctionResult('6D4CE63C', data); 114 return { ret: ret }; 115 }, 116 set: (): void => { 117 return; 118 }, 119 }; 120 }; 121 }