From b6820f729d078f084cc866dd80f4b427c04deb3c Mon Sep 17 00:00:00 2001 From: Silas Davis Date: Tue, 25 May 2021 16:44:42 +0200 Subject: [PATCH 1/4] Fix collisions in ABI output, submit contract metadata on deploy, remove GRPC dependencies from codegen interface.gd.ts - Switched to a hierarchical bin folder to only require contract names to be unique within their own directory - Send contract ABIs to Burrow from codegen deploy function - Remove dependency on GRPC types to improve ergonomics and not couple GRPC codegen to the provider interface hopefully to give better compatibility between versions - Use duck-typed interface for CancelStreamSignal so that cancel signal is not path dependent (for compatibiltiy between multiple Burrow versions where possible in same project) Signed-off-by: Silas Davis --- execution/evm/abi/abi.go | 4 +- js/package.json | 4 +- js/src/client.ts | 35 +- js/src/contracts/call.ts | 19 +- js/src/contracts/compile.ts | 13 +- js/src/contracts/contract.ts | 33 +- js/src/contracts/event.ts | 6 +- js/src/events.ts | 131 +++- js/src/index.ts | 9 +- js/src/solts/api.ts | 23 +- js/src/solts/build.ts | 135 +++- js/src/solts/interface.gd.ts | 22 +- js/src/solts/lib/caller.ts | 5 +- js/src/solts/lib/compile.ts | 19 +- js/src/solts/lib/contract.ts | 78 +- js/src/solts/lib/deployer.ts | 76 +- js/src/solts/lib/events.ts | 25 +- js/src/solts/lib/linker.ts | 97 --- js/src/solts/lib/provider.ts | 85 ++- js/src/solts/lib/solidity.test.ts | 2 +- js/src/solts/lib/syntax.ts | 19 +- js/src/solts/sol/Addition.abi.ts | 39 +- js/src/solts/sol/Contains.abi.ts | 39 +- js/src/solts/sol/Creator.abi.ts | 53 +- js/src/solts/sol/Eventer.abi.ts | 59 +- js/src/solts/sol/MultipleReturns.abi.ts | 39 +- js/src/solts/sol/Unnamed.abi.ts | 39 +- js/src/solts/sol/build.ts | 6 +- js/src/solts/sol/{ => storage}/Storage.abi.ts | 41 +- js/src/solts/sol/{ => storage}/Storage.sol | 0 js/yarn.lock | 668 +++++++++--------- 31 files changed, 950 insertions(+), 873 deletions(-) delete mode 100644 js/src/solts/lib/linker.ts rename js/src/solts/sol/{ => storage}/Storage.abi.ts (69%) rename js/src/solts/sol/{ => storage}/Storage.sol (100%) diff --git a/execution/evm/abi/abi.go b/execution/evm/abi/abi.go index 79244b2b4..bb2a242f0 100644 --- a/execution/evm/abi/abi.go +++ b/execution/evm/abi/abi.go @@ -30,12 +30,12 @@ func LoadPath(abiFileOrDirs ...string) (*Spec, error) { specs := make([]*Spec, 0) for _, dir := range abiFileOrDirs { - err := filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error { + err := filepath.WalkDir(dir, func(path string, dir os.DirEntry, err error) error { if err != nil { return fmt.Errorf("error returned while walking abiDir '%s': %v", dir, err) } ext := filepath.Ext(path) - if fi.IsDir() || !(ext == ".bin" || ext == ".abi" || ext == ".json") { + if dir.IsDir() || !(ext == ".bin" || ext == ".abi" || ext == ".json") { return nil } abiSpc, err := ReadSpecFile(path) diff --git a/js/package.json b/js/package.json index 134fd6288..5a27944e4 100644 --- a/js/package.json +++ b/js/package.json @@ -1,5 +1,5 @@ { - "version": "0.0.0", + "version": "0.33.1-dev.e4b5f85b9", "name": "@hyperledger/burrow", "description": "TypeScript library that calls a Hyperledger Burrow server over GRPC.", "main": "./dist/index.js", @@ -21,7 +21,7 @@ }, "dependencies": { "@grpc/grpc-js": "^1.3.0", - "ethers": "^5.1.4", + "ethers": "^5.2.0", "google-protobuf": "^3.15.8", "sha3": "^2.1.4", "solc_v5": "npm:solc@^0.5.17", diff --git a/js/src/client.ts b/js/src/client.ts index b02bfd11d..bac20accc 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -1,7 +1,7 @@ import * as grpc from '@grpc/grpc-js'; import { Interface } from 'ethers/lib/utils'; -import { Event, TxExecution } from '../proto/exec_pb'; -import { CallTx, ContractMeta } from '../proto/payload_pb'; +import { TxExecution } from '../proto/exec_pb'; +import { CallTx } from '../proto/payload_pb'; import { ExecutionEventsClient, IExecutionEventsClient } from '../proto/rpcevents_grpc_pb'; import { IQueryClient, QueryClient } from '../proto/rpcquery_grpc_pb'; import { GetMetadataParam, StatusParam } from '../proto/rpcquery_pb'; @@ -9,11 +9,11 @@ import { ITransactClient, TransactClient } from '../proto/rpctransact_grpc_pb'; import { ResultStatus } from '../proto/rpc_pb'; import { ContractCodec, getContractCodec } from './codec'; import { Address } from './contracts/abi'; -import { makeCallTx } from './contracts/call'; +import { getContractMeta, makeCallTx } from './contracts/call'; import { CallOptions, Contract, ContractInstance } from './contracts/contract'; import { toBuffer } from './convert'; import { getException } from './error'; -import { Bounds, EventCallback, EventStream, getBlockRange, queryFor, stream } from './events'; +import { Bounds, Event, EventCallback, EventStream, getBlockRange, queryFor, stream } from './events'; import { Namereg } from './namereg'; import { Provider } from './solts/interface.gd'; @@ -125,8 +125,17 @@ export class Client implements Provider { // Methods below implement the generated codegen provider // TODO: should probably generate canonical version of Provider interface somewhere outside of files - async deploy(msg: CallTx): Promise
{ - const txe = await this.callTxSync(msg); + async deploy( + data: string | Uint8Array, + contractMeta: { abi: string; codeHash: Uint8Array }[] = [], + ): Promise
{ + const tx = makeCallTx( + toBuffer(data), + this.account, + undefined, + contractMeta.map(({ abi, codeHash }) => getContractMeta(abi, codeHash)), + ); + const txe = await this.callTxSync(tx); const contractAddress = txe.getReceipt()?.getContractaddress_asU8(); if (!contractAddress) { throw new Error(`deploy appears to have succeeded but contract address is missing from result: ${txe}`); @@ -134,13 +143,15 @@ export class Client implements Provider { return Buffer.from(contractAddress).toString('hex').toUpperCase(); } - async call(msg: CallTx): Promise { - const txe = await this.callTxSync(msg); + async call(data: string | Uint8Array, address: string): Promise { + const tx = makeCallTx(toBuffer(data), this.account, address); + const txe = await this.callTxSync(tx); return txe.getResult()?.getReturn_asU8(); } - async callSim(msg: CallTx): Promise { - const txe = await this.callTxSim(msg); + async callSim(data: string | Uint8Array, address: string): Promise { + const tx = makeCallTx(toBuffer(data), this.account, address); + const txe = await this.callTxSim(tx); return txe.getResult()?.getReturn_asU8(); } @@ -154,10 +165,6 @@ export class Client implements Provider { return stream(this.executionEvents, getBlockRange(start, end), queryFor({ address, signatures }), callback); } - payload(data: string | Uint8Array, address?: string, contractMeta: ContractMeta[] = []): CallTx { - return makeCallTx(typeof data === 'string' ? toBuffer(data) : data, this.account, address, contractMeta); - } - contractCodec(contractABI: string): ContractCodec { const iface = new Interface(contractABI); return getContractCodec(iface); diff --git a/js/src/contracts/call.ts b/js/src/contracts/call.ts index a13c87cc8..2acf39982 100644 --- a/js/src/contracts/call.ts +++ b/js/src/contracts/call.ts @@ -2,13 +2,14 @@ import * as grpc from '@grpc/grpc-js'; import { Metadata } from '@grpc/grpc-js'; import { callErrorFromStatus } from '@grpc/grpc-js/build/src/call'; import { AbiCoder, FunctionFragment, Interface, Result as DecodedResult } from 'ethers/lib/utils'; +import { Keccak } from 'sha3'; import { SolidityFunction } from 'solc'; import { Result } from '../../proto/exec_pb'; import { CallTx, ContractMeta, TxInput } from '../../proto/payload_pb'; import { Envelope } from '../../proto/txs_pb'; import { Pipe } from '../client'; import { postDecodeResult, preEncodeResult, toBuffer } from '../convert'; -import { Address } from './abi'; +import { ABI, Address } from './abi'; import { CallOptions } from './contract'; export const DEFAULT_GAS = 1111111111; @@ -48,6 +49,22 @@ export function makeCallTx( return payload; } +export function getContractMetaFromBytecode(abi: ABI, deployedBytecode: string): ContractMeta { + const hasher = new Keccak(256); + const codeHash = hasher.update(deployedBytecode, 'hex').digest(); + return getContractMeta(abi, codeHash); +} + +export function getContractMeta(abi: ABI | string, codeHash: Uint8Array): ContractMeta { + const meta = new ContractMeta(); + if (typeof abi !== 'string') { + abi = JSON.stringify({ Abi: abi }); + } + meta.setMeta(abi); + meta.setCodehash(codeHash); + return meta; +} + export type TransactionResult = { contractAddress: string; height: number; diff --git a/js/src/contracts/compile.ts b/js/src/contracts/compile.ts index 8bd825a72..6f8d7b3ce 100644 --- a/js/src/contracts/compile.ts +++ b/js/src/contracts/compile.ts @@ -1,5 +1,14 @@ import solc from 'solc_v5'; -import { CompiledContract, Contract } from './contract'; +import { ABI } from './abi'; +import { Contract } from './contract'; + +export type CompiledContract = { + abi: ABI; + // Required to deploy a contract + bytecode?: string; + // Required to submit an ABI when deploying a contract + deployedBytecode?: string; +}; // Compile solidity source code export function compile( @@ -29,7 +38,7 @@ export function compile( ); } -function getCompiledCode(contract: solc.Contract): CompiledContract { +function getCompiledCode(contract: solc.Contract): Required { return { abi: contract.abi, bytecode: contract.evm.bytecode.object, diff --git a/js/src/contracts/contract.ts b/js/src/contracts/contract.ts index ad1c6e7db..6446be1f1 100644 --- a/js/src/contracts/contract.ts +++ b/js/src/contracts/contract.ts @@ -1,11 +1,11 @@ import { EventFragment, Fragment, FunctionFragment, Interface, LogDescription } from 'ethers/lib/utils'; -import { Keccak } from 'sha3'; import { CallTx, ContractMeta } from '../../proto/payload_pb'; import { Client } from '../client'; import { preEncodeResult, toBuffer } from '../convert'; -import { EventStream } from '../events'; -import { ABI, Address } from './abi'; -import { call, callFunction, CallResult, DecodeResult, makeCallTx } from './call'; +import { EventStream } from "../events"; +import { Address } from './abi'; +import { call, callFunction, CallResult, DecodeResult, getContractMetaFromBytecode, makeCallTx } from './call'; +import { CompiledContract } from './compile'; import { EventCallback, listen } from './event'; export const meta: unique symbol = Symbol('meta'); @@ -39,14 +39,6 @@ export function getAddress(instance: ContractInstance): Address { return instance[meta].address; } -export type CompiledContract = { - abi: ABI; - // Required to deploy a contract - bytecode?: string; - // Required to submit an ABI when deploying a contract - deployedBytecode?: string; -}; - export class Contract { private readonly iface: Interface; @@ -74,7 +66,9 @@ export class Contract { } meta(): ContractMeta[] { - return [this.code, ...this.childCode].map(contractMeta).filter((m): m is ContractMeta => Boolean(m)); + return [this.code, ...this.childCode] + .map(({ abi, deployedBytecode }) => abi && deployedBytecode && getContractMetaFromBytecode(abi, deployedBytecode)) + .filter((m): m is ContractMeta => Boolean(m)); } async deploy(burrow: Client, ...args: unknown[]): Promise { @@ -147,19 +141,6 @@ function contractEvent(iface: Interface, frag: EventFragment, burrow: Client, co return func; } -function contractMeta({ abi, deployedBytecode }: CompiledContract): ContractMeta | void { - // We can only calculate the codeHash if we have the deployedCode - if (abi.length == 0 || !deployedBytecode) { - return undefined; - } - const meta = new ContractMeta(); - const hasher = new Keccak(256); - const codeHash = hasher.update(deployedBytecode, 'hex').digest(); - meta.setMeta(JSON.stringify({ Abi: abi })); - meta.setCodehash(codeHash); - return meta; -} - function attachFunction( iface: Interface, frag: Fragment, diff --git a/js/src/contracts/event.ts b/js/src/contracts/event.ts index 879b12915..5bbfb9912 100644 --- a/js/src/contracts/event.ts +++ b/js/src/contracts/event.ts @@ -24,14 +24,14 @@ export function listen( if (err) { return isEndOfStream(err) ? undefined : callback(err); } - const log = event?.getLog(); + const log = event?.log; if (!log) { return callback(new Error(`no LogEvent or Error provided`)); } try { const result = iface.parseLog({ - topics: log.getTopicsList_asU8().map((topic) => prefixedHexString(topic)), - data: prefixedHexString(log.getData_asU8()), + topics: log.topics.map((topic) => prefixedHexString(topic)), + data: prefixedHexString(log.data), }); return callback(undefined, { ...result, diff --git a/js/src/events.ts b/js/src/events.ts index dbf1580f1..0a86ef9ed 100644 --- a/js/src/events.ts +++ b/js/src/events.ts @@ -1,5 +1,5 @@ import * as grpc from '@grpc/grpc-js'; -import { Event } from '../proto/exec_pb'; +import { Event as BurrowEvent } from '../proto/exec_pb'; import { IExecutionEventsClient } from '../proto/rpcevents_grpc_pb'; import { BlockRange, BlocksRequest, Bound, EventsResponse } from '../proto/rpcevents_pb'; import { Address } from './contracts/abi'; @@ -8,10 +8,52 @@ import BoundType = Bound.BoundType; export type EventStream = grpc.ClientReadableStream; +export type Event = { + header: Header; + log: Log; +}; + +export type Header = { + height: number; + index: number; + txHash: string; + eventId: string; +}; + +export type Log = { + data: Uint8Array; + topics: Uint8Array[]; +}; + +// We opt for a duck-type brand rather than a unique symbol so that dependencies using different versions of Burrow +const SignalCodes = { + cancelStream: 'cancelStream', + endOfStream: 'endOfStream', +} as const; + +type SignalCodes = keyof typeof SignalCodes; + +// can be used together when compatible (since Signal is exported by the Provider interface) +export interface Signal { + __isBurrowSignal__: '__isBurrowSignal__'; + signal: T; +} + +export type CancelStreamSignal = Signal<'cancelStream'>; + +const cancelStream: CancelStreamSignal = { + __isBurrowSignal__: '__isBurrowSignal__', + signal: 'cancelStream', +} as const; + +export const Signal = Object.freeze({ + cancelStream, +} as const); + // Surprisingly, this seems to be as good as it gets at the time of writing (https://github.com/Microsoft/TypeScript/pull/17819) // that is, defining various types of union here does not help on the consumer side to infer exactly one of err or log // will be defined -export type EventCallback = (err?: Error, event?: T) => Signal | void; +export type EventCallback = (err?: Error, event?: T) => CancelStreamSignal | void; export type Bounds = number | 'first' | 'latest' | 'stream'; @@ -19,16 +61,13 @@ export type FiniteBounds = number | 'first' | 'latest'; type EventRegistry = Record; -// Emitted for consumers when stream ends -const endOfStream: unique symbol = Symbol('EndOfStream'); -// Emitted by consumers to signal the stream should end -export const cancelStream: unique symbol = Symbol('CancelStream'); +// Note: typescript breaks instanceof for Error (https://github.com/microsoft/TypeScript/issues/13965) +const burrowSignalToken = '__isBurrowSignal__' as const; -export type Signal = typeof cancelStream; +class EndOfStreamError extends Error implements Signal<'endOfStream'> { + __isBurrowSignal__ = burrowSignalToken; -// Note: typescript breaks instanceof for Error (https://github.com/microsoft/TypeScript/issues/13965) -class EndOfStreamError extends Error { - public readonly endOfStream = endOfStream; + public readonly signal = 'endOfStream'; constructor() { super('End of stream, no more data will be sent - use isEndOfStream(err) to check for this signal'); @@ -37,8 +76,17 @@ class EndOfStreamError extends Error { const endOfStreamError = Object.freeze(new EndOfStreamError()); -export function isEndOfStream(err: Error): boolean { - return (err as EndOfStreamError).endOfStream === endOfStream; +export function isBurrowSignal(value: unknown): value is Signal { + const v = value as Signal; + return v && v.__isBurrowSignal__ === burrowSignalToken && (v.signal === 'cancelStream' || v.signal === 'endOfStream'); +} + +export function isEndOfStream(value: unknown): value is Signal<'endOfStream'> { + return isBurrowSignal(value) && value.signal === 'endOfStream'; +} + +export function isCancelStream(value: unknown): value is CancelStreamSignal { + return isBurrowSignal(value) && value.signal === 'cancelStream'; } export function getBlockRange(start: Bounds = 'latest', end: Bounds = 'stream'): BlockRange { @@ -62,8 +110,15 @@ export function stream( stream.on('data', (data: EventsResponse) => { const cancel = data .getEventsList() - .map((event) => callback(undefined, event)) - .find((s) => s === cancelStream); + .map((event) => { + try { + return callback(undefined, burrowEventToInterfaceEvent(event)); + } catch (err) { + stream.cancel(); + throw err; + } + }) + .find(isCancelStream); if (cancel) { stream.cancel(); } @@ -128,7 +183,7 @@ function boundsToBound(bounds: Bounds): Bound { } export function readEvents( - listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => EventStream, + listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => unknown, start: FiniteBounds = 'first', end: FiniteBounds = 'latest', limit?: number, @@ -137,7 +192,7 @@ export function readEvents( listener, (events, event) => { if (limit && events.length === limit) { - return cancelStream; + return Signal.cancelStream; } events.push(event); return events; @@ -149,8 +204,8 @@ export function readEvents( } export function iterateEvents( - listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => EventStream, - reducer: (event: T) => Signal | void, + listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => unknown, + reducer: (event: T) => CancelStreamSignal | void, start: FiniteBounds = 'first', end: FiniteBounds = 'latest', ): Promise { @@ -158,8 +213,8 @@ export function iterateEvents( } export function reduceEvents( - listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => EventStream, - reducer: (accumulator: U, event: T) => U | Signal, + listener: (callback: EventCallback, start?: Bounds, end?: Bounds) => unknown, + reducer: (accumulator: U, event: T) => U | CancelStreamSignal, initialValue: U, start: FiniteBounds = 'first', end: FiniteBounds = 'latest', @@ -176,12 +231,12 @@ export function reduceEvents( } if (!event) { reject(new Error(`received empty event`)); - return cancelStream; + return Signal.cancelStream; } const reduced = reducer(accumulator, event); - if (reduced === cancelStream) { + if (isCancelStream(reduced)) { resolve(accumulator); - return cancelStream; + return Signal.cancelStream; } accumulator = reduced; }, @@ -197,11 +252,7 @@ export const listenerFor = ( eventRegistry: EventRegistry, decode: (client: Provider, data?: Uint8Array, topics?: Uint8Array[]) => Record unknown>, eventNames: T[], -) => ( - callback: EventCallback<{ name: T; payload: unknown; event: Event }>, - start?: Bounds, - end?: Bounds, -): EventStream => { +) => (callback: EventCallback<{ name: T; payload: unknown; event: Event }>, start?: Bounds, end?: Bounds): unknown => { const signatureToName = eventNames.reduce((acc, n) => acc.set(eventRegistry[n].signature, n), new Map()); return client.listen( @@ -214,8 +265,7 @@ export const listenerFor = ( if (!event) { return callback(new Error(`Empty event received`)); } - const topics = event?.getLog()?.getTopicsList_asU8(); - const log0 = topics?.[0]; + const log0 = event.log.topics[0]; if (!log0) { return callback(new Error(`Event has no Log0: ${event?.toString()}`)); } @@ -226,11 +276,28 @@ export const listenerFor = ( new Error(`Could not find event with signature ${signature} in registry: ${JSON.stringify(eventRegistry)}`), ); } - const data = event?.getLog()?.getData_asU8(); - const payload = decode(client, data, topics)[name](); + const payload = decode(client, event.log.data, event.log.topics)[name](); return callback(undefined, { name, payload, event }); }, start, end, ); }; + +export function burrowEventToInterfaceEvent(event: BurrowEvent): Event { + const log = event.getLog(); + const header = event.getHeader(); + return { + log: { + data: log?.getData_asU8() ?? new Uint8Array(), + topics: log?.getTopicsList_asU8() || [], + }, + header: { + height: header?.getHeight() ?? 0, + index: header?.getIndex() ?? 0, + eventId: header?.getEventid() ?? '', + + txHash: Buffer.from(header?.getTxhash_asU8() ?? []).toString('hex'), + }, + }; +} diff --git a/js/src/index.ts b/js/src/index.ts index 084dbd829..5b65c8c20 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -1,4 +1,4 @@ -export { Event, LogEvent, TxExecution } from '../proto/exec_pb'; +export * as Exec from '../proto/exec_pb'; export { CallTx, TxInput } from '../proto/payload_pb'; export { BlockRange } from '../proto/rpcevents_pb'; export { Client } from './client'; @@ -8,14 +8,17 @@ export { makeCallTx } from './contracts/call'; export { Contract } from './contracts/contract'; export { Result } from './convert'; export { - cancelStream, - EventStream, + CancelStreamSignal, + Event, + Header, isEndOfStream, iterateEvents, listenerFor, + Log, readEvents, reduceEvents, Signal, } from './events'; export { build } from './solts/build'; export { Caller, defaultCall, Provider } from './solts/interface.gd'; +export { linker } from './solts/lib/compile'; diff --git a/js/src/solts/api.ts b/js/src/solts/api.ts index 2d9be2bc2..ed84405cc 100644 --- a/js/src/solts/api.ts +++ b/js/src/solts/api.ts @@ -3,10 +3,14 @@ import { ABI } from './lib/abi'; import { callerTypes, createCallerFunction } from './lib/caller'; import { declareContractType, generateContractObject } from './lib/contract'; import { generateDecodeObject } from './lib/decoder'; -import { generateDeployContractFunction, generateDeployFunction } from './lib/deployer'; +import { + bytecodeName, + deployedBytecodeName, + generateDeployContractFunction, + generateDeployFunction, +} from './lib/deployer'; import { generateEncodeObject } from './lib/encoder'; import { declareEvents, eventTypes } from './lib/events'; -import { createLinkerFunction } from './lib/linker'; import { Provider } from './lib/provider'; import { getContractMethods } from './lib/solidity'; import { declareConstant, ExportToken, importBurrow, importReadable } from './lib/syntax'; @@ -17,19 +21,20 @@ export { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, toke export type Compiled = { name: string; abi: ABI.FunctionOrEvent[]; - bin: string; + bytecode: string; + deployedBytecode: string; links: Array; }; const contractNameName = factory.createIdentifier('contactName'); const abiName = factory.createIdentifier('abi'); -const bytecodeName = factory.createIdentifier('bytecode'); // Note: this is a very useful tool for discovering the correct Typescript factory API calls to produce a particular //piece of syntax: https://ts-ast-viewer.com export function newFile(contracts: Compiled[], burrowImportPath: string): ts.Node[] { const provider = new Provider(); + const contractNames = contracts.map((c) => factory.createIdentifier(c.name)); return [ ts.addSyntheticLeadingComment( importReadable(), @@ -40,18 +45,18 @@ export function newFile(contracts: Compiled[], burrowImportPath: string): ts.Nod provider.createInterface(), ...callerTypes, createCallerFunction(provider), - createLinkerFunction(), ...contracts.map((contract) => { const methods = getContractMethods(contract.abi); const deploy = contract.abi.find((abi): abi is Func => abi.type === 'constructor'); // No deploy function for interfaces - const deployMembers = contract.bin + const deployMembers = contract.bytecode ? [ - declareConstant(bytecodeName, factory.createStringLiteral(contract.bin, true), true), - generateDeployFunction(deploy, bytecodeName, contract.links, provider, abiName), - generateDeployContractFunction(deploy, bytecodeName, contract.links, provider), + declareConstant(bytecodeName, factory.createStringLiteral(contract.bytecode, true), true), + declareConstant(deployedBytecodeName, factory.createStringLiteral(contract.bytecode, true), true), + generateDeployFunction(deploy, contract.links, provider, abiName, contractNames), + generateDeployContractFunction(deploy, contract.links, provider), ] : []; diff --git a/js/src/solts/build.ts b/js/src/solts/build.ts index c7a94e247..5bb65c22c 100644 --- a/js/src/solts/build.ts +++ b/js/src/solts/build.ts @@ -1,9 +1,9 @@ -import * as fs from 'fs'; +import { promises as fs } from 'fs'; import * as path from 'path'; import * as solcv5 from 'solc_v5'; import * as solcv8 from 'solc_v8'; import { Compiled, newFile, printNodes, tokenizeLinks } from './api'; -import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles } from './lib/compile'; +import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, Solidity } from './lib/compile'; const solcCompilers = { v5: solcv5, @@ -12,8 +12,11 @@ const solcCompilers = { export const defaultBuildOptions = { solcVersion: 'v5' as keyof typeof solcCompilers, - burrowImportPath: '@hyperledger/burrow' as string, + burrowImportPath: (sourceFile: string) => '@hyperledger/burrow' as string, binPath: 'bin' as string, + abiExt: '.abi' as string, + // Used to resolve layout in bin folder - defaults to srcPath if is passed or process.cwd() otherwise + basePath: undefined as undefined | string, } as const; export type BuildOptions = typeof defaultBuildOptions; @@ -25,10 +28,13 @@ export type BuildOptions = typeof defaultBuildOptions; * - Generates typescript code to deploy the contracts * - Outputs the ABI files into bin to be later included in the distribution (for Vent and other ABI-consuming services) */ -export function build(srcPathOrFiles: string | string[], opts?: Partial): void { - const { solcVersion, binPath, burrowImportPath } = { ...defaultBuildOptions, ...opts }; - fs.mkdirSync(binPath, { recursive: true }); - const solidityFiles = getSourceFilesList(srcPathOrFiles); +export async function build(srcPathOrFiles: string | string[], opts?: Partial): Promise { + const { solcVersion, binPath, basePath, burrowImportPath, abiExt } = { ...defaultBuildOptions, ...opts }; + const basePathPrefix = new RegExp( + '^' + path.resolve(basePath ?? (typeof srcPathOrFiles === 'string' ? srcPathOrFiles : process.cwd())), + ); + await fs.mkdir(binPath, { recursive: true }); + const solidityFiles = await getSourceFilesList(srcPathOrFiles); const inputDescription = inputDescriptionFromFiles(solidityFiles); const input = encodeInput(inputDescription); const solc = solcCompilers[solcVersion]; @@ -38,35 +44,102 @@ export function build(srcPathOrFiles: string | string[], opts?: Partial err.formattedMessage).join('\n')); } - for (const filename of Object.keys(output.contracts)) { - const compiled: Compiled[] = []; - const solidity = output.contracts[filename]; - for (const contract of Object.keys(solidity)) { - const comp = output.contracts[filename][contract]; - compiled.push({ - name: contract, - abi: comp.abi, - bin: comp.evm.bytecode.object, - links: tokenizeLinks(comp.evm.bytecode.linkReferences), - }); - } - const target = filename.replace(/\.[^/.]+$/, '.abi.ts'); - // Write the ABIs emitted for each file to the name of that file without extension. We flatten into a single - // directory because that's what burrow deploy has always done. + const plan = Object.keys(output.contracts).map((filename) => ({ + source: filename, + target: filename.replace(/\.[^/.]+$/, '.abi.ts'), + contracts: Object.entries(output.contracts[filename]).map(([name, contract]) => ({ + name, + contract, + })), + })); - for (const [name, contract] of Object.entries(solidity)) { - fs.writeFileSync(path.join('bin', name + '.bin'), JSON.stringify(contract)); - } - fs.writeFileSync(target, printNodes(...newFile(compiled, burrowImportPath))); + const binPlan = plan.flatMap((f) => { + return f.contracts.map(({ name, contract }) => ({ + source: f.source, + name, + filename: path.join(binPath, path.dirname(path.resolve(f.source)).replace(basePathPrefix, ''), name + abiExt), + abi: JSON.stringify(contract), + })); + }); + + const dupes = findDupes(binPlan, (b) => b.filename); + + if (dupes.length) { + const dupeDescs = dupes.map(({ key, dupes }) => ({ duplicate: key, sources: dupes.map((d) => d.source) })); + throw Error( + `Duplicate contract names found (these contracts will result ABI filenames that will collide since ABIs ` + + `are flattened in '${binPath}'):\n${dupeDescs.map((d) => JSON.stringify(d)).join('\n')}`, + ); } + + // Write the ABIs emitted for each file to the name of that file without extension. We flatten into a single + // directory because that's what burrow deploy has always done. + await Promise.all([ + ...binPlan.map(async ({ filename, abi }) => { + await fs.mkdir(path.dirname(filename), { recursive: true }); + await fs.writeFile(filename, abi); + }), + ...plan.map(({ source, target, contracts }) => + fs.writeFile( + target, + printNodes( + ...newFile( + contracts.map(({ name, contract }) => getCompiled(name, contract)), + burrowImportPath(source), + ), + ), + ), + ), + ]); +} + +function getCompiled(name: string, contract: Solidity.Contract): Compiled { + return { + name, + abi: contract.abi, + bytecode: contract.evm.bytecode.object, + deployedBytecode: contract.evm.deployedBytecode.object, + links: tokenizeLinks(contract.evm.bytecode.linkReferences), + }; } -function getSourceFilesList(srcPathOrFiles: string | string[]): string[] { +function findDupes(list: T[], by: (t: T) => string): { key: string; dupes: T[] }[] { + const grouped = list.reduce((acc, t) => { + const k = by(t); + if (!acc[k]) { + acc[k] = []; + } + acc[k].push(t); + return acc; + }, {} as Record); + return Object.entries(grouped) + .filter(([_, group]) => group.length > 1) + .map(([key, dupes]) => ({ + key, + dupes, + })); +} + +async function getSourceFilesList(srcPathOrFiles: string | string[]): Promise { if (typeof srcPathOrFiles === 'string') { - return fs - .readdirSync(srcPathOrFiles, { withFileTypes: true }) - .filter((f) => path.extname(f.name) === '.sol') - .map((f) => path.join(srcPathOrFiles, f.name)); + const files: string[] = []; + for await (const f of walkDir(srcPathOrFiles)) { + if (path.extname(f) === '.sol') { + files.push(f); + } + } + return files; } return srcPathOrFiles; } + +async function* walkDir(dir: string): AsyncGenerator { + for await (const d of await fs.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) { + yield* walkDir(entry); + } else if (d.isFile()) { + yield entry; + } + } +} diff --git a/js/src/solts/interface.gd.ts b/js/src/solts/interface.gd.ts index fd251f8c3..478e87d87 100644 --- a/js/src/solts/interface.gd.ts +++ b/js/src/solts/interface.gd.ts @@ -1,18 +1,23 @@ //Generated by solts - run yarn generate:provider to regenerate if solts Provider code is changed -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../index'; export type Caller = typeof defaultCall; export interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export async function defaultCall( @@ -22,7 +27,6 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } diff --git a/js/src/solts/lib/caller.ts b/js/src/solts/lib/caller.ts index 8af02f12e..99b4e796d 100644 --- a/js/src/solts/lib/caller.ts +++ b/js/src/solts/lib/caller.ts @@ -52,16 +52,15 @@ export function createCallerFunction(provider: Provider): ts.FunctionDeclaration factory.createTypeReferenceNode(PromiseType, [factory.createTypeReferenceNode(output, undefined)]), factory.createBlock( [ - declareConstant(payload, provider.methods.payload.call(client, data, addr)), declareConstant( returnData, factory.createAwaitExpression( factory.createConditionalExpression( isSim, QuestionToken, - provider.methods.callSim.call(client, payload), + provider.methods.callSim.call(client, data, addr), ColonToken, - provider.methods.call.call(client, payload), + provider.methods.call.call(client, data, addr), ), ), ), diff --git a/js/src/solts/lib/compile.ts b/js/src/solts/lib/compile.ts index 4b10eaa61..a91fab81c 100644 --- a/js/src/solts/lib/compile.ts +++ b/js/src/solts/lib/compile.ts @@ -4,17 +4,18 @@ import { ABI } from './abi'; import InputDescription = Solidity.InputDescription; export namespace Solidity { - type Bytecode = { + export type Bytecode = { linkReferences: any; object: string; opcodes: string; sourceMap: string; }; - type Contract = { + export type Contract = { assembly: any; evm: { bytecode: Bytecode; + deployedBytecode: Bytecode; }; functionHashes: any; gasEstimates: any; @@ -25,7 +26,7 @@ export namespace Solidity { srcmapRuntime: string; }; - type Source = { + export type Source = { AST: any; }; @@ -99,3 +100,15 @@ export function tokenizeLinks(links: Record>): s } return libraries; } + +export function linker(bytecode: string, links: { name: string; address: string }[]): string { + for (const { name, address } of links) { + const paddedAddress = address + Array(40 - address.length + 1).join('0'); + const truncated = name.slice(0, 36); + const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; + while (bytecode.indexOf(label) >= 0) { + bytecode = bytecode.replace(label, paddedAddress); + } + } + return bytecode; +} diff --git a/js/src/solts/lib/contract.ts b/js/src/solts/lib/contract.ts index 46b9b257d..1d325574c 100644 --- a/js/src/solts/lib/contract.ts +++ b/js/src/solts/lib/contract.ts @@ -5,8 +5,8 @@ import { encodeName } from './encoder'; import { BoundsType, CallbackReturnType, - callGetDataFromEvent, - callGetTopicsFromEvent, + dataFromEvent, + topicsFromEvent, createListener, createListenerForFunction, eventSigHash, @@ -15,7 +15,6 @@ import { errName, EventErrParameter, eventName, EventParameter, Provider } from import { ContractMethodsList, getRealType, inputOuputsToType, Signature } from './solidity'; import { asConst, - asRefNode, constObject, createCall, createCallbackType, @@ -23,7 +22,6 @@ import { createPromiseOf, declareConstant, EqualsGreaterThanToken, - EventStream, ExportToken, MaybeUint8ArrayType, Method, @@ -31,6 +29,7 @@ import { ReturnType, StringType, Undefined, + UnknownType, } from './syntax'; export const contractFunctionName = factory.createIdentifier('contract'); @@ -161,43 +160,46 @@ function solidityEvent(name: string, signature: Signature, provider: Provider): const start = factory.createIdentifier('start'); const end = factory.createIdentifier('end'); // Receivers of LogEventParameter - const data = callGetDataFromEvent(eventName); - const topics = callGetTopicsFromEvent(eventName); + const data = dataFromEvent(eventName); + const topics = topicsFromEvent(eventName); const decoderFunction = prop(createCall(decodeName, [clientName, data, topics]), name); - return new Method(name) - .parameter( - callback, - createCallbackType( - [EventErrParameter, createParameter(eventName, inputOuputsToType(signature.inputs), undefined, true)], - CallbackReturnType, - ), - ) - .parameter(start, BoundsType, true) - .parameter(end, BoundsType, true) - .returns(asRefNode(EventStream)) - .declaration([ - factory.createReturnStatement( - provider.methods.listen.call( - clientName, - factory.createArrayLiteralExpression([factory.createStringLiteral(eventSigHash(name, signature.inputs))]), - addressName, - - factory.createArrowFunction( - undefined, - undefined, - [EventErrParameter, EventParameter], - undefined, - undefined, - factory.createBlock([ - factory.createIfStatement(errName, factory.createReturnStatement(createCall(callback, [errName]))), - factory.createReturnStatement(createCall(callback, [Undefined, createCall(decoderFunction)])), - ]), + return ( + new Method(name) + .parameter( + callback, + createCallbackType( + [EventErrParameter, createParameter(eventName, inputOuputsToType(signature.inputs), undefined, true)], + CallbackReturnType, + ), + ) + .parameter(start, BoundsType, true) + .parameter(end, BoundsType, true) + // type may be EventStream, allow type assertion without polluting inteface + .returns(UnknownType) + .declaration([ + factory.createReturnStatement( + provider.methods.listen.call( + clientName, + factory.createArrayLiteralExpression([factory.createStringLiteral(eventSigHash(name, signature.inputs))]), + addressName, + + factory.createArrowFunction( + undefined, + undefined, + [EventErrParameter, EventParameter], + undefined, + undefined, + factory.createBlock([ + factory.createIfStatement(errName, factory.createReturnStatement(createCall(callback, [errName]))), + factory.createReturnStatement(createCall(callback, [Undefined, createCall(decoderFunction)])), + ]), + ), + start, + end, ), - start, - end, ), - ), - ]); + ]) + ); } function createGroup(name: ts.Identifier, elements: ObjectLiteralElementLike[]): ts.PropertyAssignment { diff --git a/js/src/solts/lib/deployer.ts b/js/src/solts/lib/deployer.ts index 883d2b338..39d1f4df7 100644 --- a/js/src/solts/lib/deployer.ts +++ b/js/src/solts/lib/deployer.ts @@ -1,19 +1,18 @@ import ts, { factory, FunctionDeclaration, SyntaxKind } from 'typescript'; import { ABI } from './abi'; import { contractFunctionName, contractTypeName } from './contract'; -import { linkerName } from './linker'; import { callEncodeDeploy, Provider } from './provider'; import { getRealType, sha3, tokenizeString } from './solidity'; import { AsyncToken, BufferType, - createAssignmentStatement, createCall, createParameter, createPromiseOf, declareConstant, - declareLet, ExportToken, + hexToBuffer, + linkerName, PromiseType, prop, StringType, @@ -21,37 +20,50 @@ import { export const deployName = factory.createIdentifier('deploy'); export const deployContractName = factory.createIdentifier('deployContract'); +export const bytecodeName = factory.createIdentifier('bytecode'); +export const deployedBytecodeName = factory.createIdentifier('deployedBytecode'); // Variable names -const payloadName = factory.createIdentifier('payload'); const linkedBytecodeName = factory.createIdentifier('linkedBytecode'); const dataName = factory.createIdentifier('data'); const clientName = factory.createIdentifier('client'); export function generateDeployFunction( abi: ABI.Func | undefined, - bytecodeName: ts.Identifier, links: string[], provider: Provider, abiName: ts.Identifier, + contractNames: ts.Identifier[], ): FunctionDeclaration { const output = factory.createExpressionWithTypeArguments(PromiseType, [StringType]); const statements: ts.Statement[] = []; statements.push(provider.declareContractCodec(clientName, abiName)); - statements.push(declareLet(linkedBytecodeName, bytecodeName)); - statements.push( - ...links.map((link) => - createAssignmentStatement( - linkedBytecodeName, - createCall(linkerName, [ - linkedBytecodeName, - factory.createStringLiteral('$' + sha3(link).toLowerCase().slice(0, 34) + '$'), - factory.createIdentifier(tokenizeString(link)), + + let bytecode = bytecodeName; + const linksName = factory.createIdentifier('links'); + + if (links.length) { + const linksArray = factory.createArrayLiteralExpression( + links.map((link) => + factory.createObjectLiteralExpression([ + factory.createPropertyAssignment( + 'name', + factory.createStringLiteral('$' + sha3(link).toLowerCase().slice(0, 34) + '$'), + ), + factory.createPropertyAssignment( + 'address', + + factory.createIdentifier(tokenizeString(link)), + ), ]), ), - ), - ); + ); + statements.push(declareConstant(linksName, linksArray)); + statements.push(declareConstant(linkedBytecodeName, createCall(linkerName, [bytecodeName, linksName]))); + + bytecode = linkedBytecodeName; + } const args = abi?.inputs?.map((arg) => factory.createIdentifier(arg.name)) ?? []; @@ -59,16 +71,22 @@ export function generateDeployFunction( declareConstant( dataName, createCall(prop(BufferType, 'concat'), [ - factory.createArrayLiteralExpression([ - createCall(prop(BufferType, 'from'), [linkedBytecodeName, factory.createStringLiteral('hex')]), - callEncodeDeploy(args), - ]), + factory.createArrayLiteralExpression([hexToBuffer(bytecode), callEncodeDeploy(args)]), ]), ), ); - statements.push(declareConstant(payloadName, provider.methods.payload.call(clientName, dataName, undefined))); - const deployFn = provider.methods.deploy.call(clientName, payloadName); + const deployFn = provider.methods.deploy.call( + clientName, + dataName, + contractNames.map((n) => { + const deployedBytecode = prop(n, deployedBytecodeName); + return { + abi: prop(n, abiName), + codeHash: hexToBuffer(links.length ? createCall(linkerName, [deployedBytecode, linksName]) : deployedBytecode), + }; + }), + ); statements.push(factory.createReturnStatement(deployFn)); @@ -78,7 +96,7 @@ export function generateDeployFunction( undefined, deployName, undefined, - deployParameters(abi, bytecodeName, links, provider), + deployParameters(abi, links, provider), output, factory.createBlock(statements, true), ); @@ -86,11 +104,10 @@ export function generateDeployFunction( export function generateDeployContractFunction( abi: ABI.Func | undefined, - bytecodeName: ts.Identifier, links: string[], provider: Provider, -) { - const parameters = deployParameters(abi, bytecodeName, links, provider); +): ts.FunctionDeclaration { + const parameters = deployParameters(abi, links, provider); const addressName = factory.createIdentifier('address'); const callDeploy = factory.createAwaitExpression( createCall(deployName, [ @@ -112,12 +129,7 @@ export function generateDeployContractFunction( ); } -function deployParameters( - abi: ABI.Func | undefined, - bytecodeName: ts.Identifier, - links: string[], - provider: Provider, -): ts.ParameterDeclaration[] { +function deployParameters(abi: ABI.Func | undefined, links: string[], provider: Provider): ts.ParameterDeclaration[] { const parameters = abi ? abi.inputs?.map((input) => createParameter(input.name, getRealType(input.type))) ?? [] : []; return [ createParameter(clientName, provider.type()), diff --git a/js/src/solts/lib/events.ts b/js/src/solts/lib/events.ts index 963a8ef4a..e2cc49156 100644 --- a/js/src/solts/lib/events.ts +++ b/js/src/solts/lib/events.ts @@ -5,19 +5,18 @@ import { EventErrParameter, eventName } from './provider'; import { ContractMethodsList, getRealType, InputOutput, sha3 } from './solidity'; import { arrowFuncT, + CancelStreamSignalType, constObject, createCall, createParameter, declareConstant, EqualsGreaterThanToken, - EventStreamType, EventType, ExportToken, listenerForName, NumberType, prop, ReturnType, - SignalType, TType, UnknownType, VoidType, @@ -29,13 +28,13 @@ export const BoundsType = factory.createUnionTypeNode([ ...['first', 'latest', 'stream'].map((s) => factory.createLiteralTypeNode(factory.createStringLiteral(s))), NumberType, ]); -export const CallbackReturnType = factory.createUnionTypeNode([SignalType, VoidType]); +export const CallbackReturnType = factory.createUnionTypeNode([CancelStreamSignalType, VoidType]); const typedListenerName = factory.createIdentifier('TypedListener'); -const getLogName = factory.createIdentifier('getLog'); -const getDataName = factory.createIdentifier('getData_asU8'); -const getTopicsName = factory.createIdentifier('getTopicsList_asU8'); +const logName = factory.createIdentifier('log'); +const dataName = factory.createIdentifier('data'); +const topicsName = factory.createIdentifier('topics'); const taggedPayloadName = factory.createIdentifier('TaggedPayload'); const solidityEventName = factory.createIdentifier('SolidityEvent'); const eventRegistryName = factory.createIdentifier('EventRegistry'); @@ -51,16 +50,12 @@ export function eventSigHash(name: string, inputs: InputOutput[]): string { return sha3(eventSignature(name, inputs)); } -function callGetLogFromEvent(event: ts.Expression): ts.CallExpression { - return createCall(prop(event, getLogName, true)); +export function dataFromEvent(event: ts.Expression): ts.Expression { + return prop(prop(event, logName, true), dataName); } -export function callGetDataFromEvent(event: ts.Expression): ts.CallExpression { - return createCall(prop(callGetLogFromEvent(event), getDataName, true)); -} - -export function callGetTopicsFromEvent(event: ts.Expression): ts.CallExpression { - return createCall(prop(callGetLogFromEvent(event), getTopicsName, true)); +export function topicsFromEvent(event: ts.Expression): ts.Expression { + return prop(prop(event, logName, true), topicsName); } export function createListenerForFunction(clientName: ts.Identifier, addressName: ts.Identifier): ts.ArrowFunction { @@ -215,7 +210,7 @@ export function eventTypes(): ts.TypeAliasDeclaration[] { createParameter('start', BoundsType, undefined, true), createParameter('end', BoundsType, undefined, true), ], - EventStreamType, + UnknownType, ), ), ]; diff --git a/js/src/solts/lib/linker.ts b/js/src/solts/lib/linker.ts deleted file mode 100644 index 2c09c8669..000000000 --- a/js/src/solts/lib/linker.ts +++ /dev/null @@ -1,97 +0,0 @@ -import ts, { factory } from 'typescript'; -import { createCall, createParameter, declareConstant, StringType } from './syntax'; - -export const linkerName = factory.createIdentifier('linker'); - -export function createLinkerFunction(): ts.FunctionDeclaration { - const bytecode = factory.createIdentifier('bytecode'); - const name = factory.createIdentifier('name'); - const address = factory.createIdentifier('address'); - - const truncated = factory.createIdentifier('truncated'); - const label = factory.createIdentifier('label'); - - return factory.createFunctionDeclaration( - undefined, - undefined, - undefined, - linkerName, - undefined, - [createParameter(bytecode, StringType), createParameter(name, StringType), createParameter(address, StringType)], - StringType, - factory.createBlock( - [ - factory.createExpressionStatement( - factory.createAssignment( - address, - adds( - address, - arrayJoin( - factory.createAdd( - factory.createSubtract( - factory.createNumericLiteral('40'), - factory.createPropertyAccessExpression(address, 'length'), - ), - factory.createNumericLiteral('1'), - ), - '0', - ), - ), - ), - ), - declareConstant( - truncated, - createCall(factory.createPropertyAccessExpression(name, 'slice'), [ - factory.createNumericLiteral('0'), - factory.createNumericLiteral('36'), - ]), - ), - declareConstant( - label, - adds( - factory.createAdd(factory.createStringLiteral('__'), truncated), - arrayJoin( - factory.createSubtract( - factory.createNumericLiteral('37'), - factory.createPropertyAccessExpression(truncated, 'length'), - ), - '_', - ), - factory.createStringLiteral('__'), - ), - ), - factory.createWhileStatement( - factory.createBinaryExpression( - createCall(factory.createPropertyAccessExpression(bytecode, 'indexOf'), [label]), - ts.SyntaxKind.GreaterThanEqualsToken, - factory.createNumericLiteral('0'), - ), - factory.createExpressionStatement( - factory.createAssignment( - bytecode, - createCall(factory.createPropertyAccessExpression(bytecode, 'replace'), [label, address]), - ), - ), - ), - factory.createReturnStatement(bytecode), - ], - true, - ), - ); -} - -function adds(...exp: ts.Expression[]) { - return exp.reduce((all, next) => { - return factory.createAdd(all, next); - }); -} - -function arrayJoin(length: ts.Expression, literal: string) { - return createCall( - factory.createPropertyAccessExpression( - createCall(factory.createIdentifier('Array'), [length]), - factory.createIdentifier('join'), - ), - [factory.createStringLiteral(literal)], - ); -} diff --git a/js/src/solts/lib/provider.ts b/js/src/solts/lib/provider.ts index 455dbf648..1edd54857 100644 --- a/js/src/solts/lib/provider.ts +++ b/js/src/solts/lib/provider.ts @@ -2,8 +2,6 @@ import ts, { factory } from 'typescript'; import { BoundsType, CallbackReturnType } from './events'; import { AddressType, - asRefNode, - CallTxType, ContractCodecType, createCall, createCallbackType, @@ -11,13 +9,13 @@ import { createPromiseOf, declareConstant, ErrorType, - EventStream, EventType, ExportToken, MaybeUint8ArrayType, Method, StringType, Uint8ArrayType, + UnknownType, } from './syntax'; export const errName = factory.createIdentifier('err'); @@ -28,41 +26,82 @@ export const EventErrParameter = createParameter(errName, ErrorType, undefined, export const EventParameter = createParameter(eventName, EventType, undefined, true); class Deploy extends Method { - params = [createParameter('msg', CallTxType)]; + private abiName = factory.createIdentifier('abi'); + private codeHashName = factory.createIdentifier('codeHash'); + + params = [ + createParameter('data', factory.createUnionTypeNode([StringType, Uint8ArrayType])), + createParameter( + 'contractMeta', + factory.createArrayTypeNode( + factory.createTypeLiteralNode([ + factory.createPropertySignature(undefined, this.abiName, undefined, StringType), + factory.createPropertySignature(undefined, this.codeHashName, undefined, Uint8ArrayType), + ]), + ), + undefined, + true, + ), + ]; ret = createPromiseOf(AddressType); constructor() { super('deploy'); } - call(exp: ts.Expression, tx: ts.Identifier): ts.CallExpression { - return createCall(factory.createPropertyAccessExpression(exp, this.id), [tx]); + call( + exp: ts.Expression, + data: ts.Expression, + contractMeta?: { abi: ts.Expression; codeHash: ts.Expression }[], + ): ts.CallExpression { + return createCall( + factory.createPropertyAccessExpression(exp, this.id), + contractMeta + ? [ + data, + factory.createArrayLiteralExpression( + contractMeta.map(({ abi, codeHash }) => + factory.createObjectLiteralExpression([ + factory.createPropertyAssignment(this.abiName, abi), + factory.createPropertyAssignment(this.codeHashName, codeHash), + ]), + ), + ), + ] + : [data], + ); } } class Call extends Method { - params = [createParameter('msg', CallTxType)]; + params = [ + createParameter('data', factory.createUnionTypeNode([StringType, Uint8ArrayType])), + createParameter('address', StringType), + ]; ret = createPromiseOf(MaybeUint8ArrayType); constructor() { super('call'); } - call(exp: ts.Expression, tx: ts.Identifier) { - return createCall(factory.createPropertyAccessExpression(exp, this.id), [tx]); + call(exp: ts.Expression, data: ts.Expression, address: ts.Expression) { + return createCall(factory.createPropertyAccessExpression(exp, this.id), [data, address]); } } class CallSim extends Method { - params = [createParameter('msg', CallTxType)]; + params = [ + createParameter('data', factory.createUnionTypeNode([StringType, Uint8ArrayType])), + createParameter('address', StringType), + ]; ret = createPromiseOf(MaybeUint8ArrayType); constructor() { super('callSim'); } - call(exp: ts.Expression, tx: ts.Identifier) { - return createCall(factory.createPropertyAccessExpression(exp, this.id), [tx]); + call(exp: ts.Expression, data: ts.Expression, address: ts.Expression) { + return createCall(factory.createPropertyAccessExpression(exp, this.id), [data, address]); } } @@ -74,7 +113,7 @@ class Listen extends Method { createParameter('start', BoundsType, undefined, true), createParameter('end', BoundsType, undefined, true), ]; - ret = asRefNode(EventStream); + ret = UnknownType; constructor() { super('listen'); @@ -92,24 +131,6 @@ class Listen extends Method { } } -class Payload extends Method { - params = [ - createParameter('data', factory.createUnionTypeNode([StringType, Uint8ArrayType])), - createParameter('address', StringType, undefined, true), - ]; - ret = CallTxType; - - constructor() { - super('payload'); - } - - call(provider: ts.Expression, data: ts.Expression, addr?: ts.Expression) { - return addr - ? createCall(factory.createPropertyAccessExpression(provider, this.id), [data, addr]) - : createCall(factory.createPropertyAccessExpression(provider, this.id), [data]); - } -} - class ContractCodec extends Method { params = [createParameter('contractABI', StringType)]; ret = ContractCodecType; @@ -131,7 +152,6 @@ export class Provider { call: new Call(), callSim: new CallSim(), listen: new Listen(), - payload: new Payload(), contractCodec: new ContractCodec(), }; @@ -147,7 +167,6 @@ export class Provider { this.methods.call.signature(), this.methods.callSim.signature(), this.methods.listen.signature(), - this.methods.payload.signature(), this.methods.contractCodec.signature(), ], ); diff --git a/js/src/solts/lib/solidity.test.ts b/js/src/solts/lib/solidity.test.ts index 2348b5b47..009b35526 100644 --- a/js/src/solts/lib/solidity.test.ts +++ b/js/src/solts/lib/solidity.test.ts @@ -1,6 +1,6 @@ import assert from 'assert'; import { ABI } from './abi'; -import { getSize, sha3, nameFromABI, tokenizeString } from './solidity'; +import { getSize, nameFromABI, sha3, tokenizeString } from './solidity'; describe('abi helpers', function () { it('should compute a valid method id', async function () { diff --git a/js/src/solts/lib/syntax.ts b/js/src/solts/lib/syntax.ts index ccd02eb76..18c113e8a 100644 --- a/js/src/solts/lib/syntax.ts +++ b/js/src/solts/lib/syntax.ts @@ -5,7 +5,6 @@ export const VoidType = factory.createTypeReferenceNode('void', undefined); export const StringType = factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); export const NumberType = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); export const BooleanType = factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword); -export const AnyType = factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword); export const UnknownType = factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword); export const UndefinedType = factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword); export const Uint8ArrayType = factory.createTypeReferenceNode('Uint8Array'); @@ -14,23 +13,20 @@ export const MaybeUint8ArrayType = factory.createUnionTypeNode([Uint8ArrayType, export const PromiseType = factory.createIdentifier('Promise'); export const ReadableType = factory.createIdentifier('Readable'); export const BufferType = factory.createIdentifier('Buffer'); -export const CallTx = factory.createIdentifier('CallTx'); export const Address = factory.createIdentifier('Address'); -export const EventStream = factory.createIdentifier('EventStream'); export const Event = factory.createIdentifier('Event'); export const ContractCodec = factory.createIdentifier('ContractCodec'); export const Result = factory.createIdentifier('Result'); -export const Signal = factory.createIdentifier('Signal'); +export const CancelStreamSignal = factory.createIdentifier('CancelStreamSignal'); export const ReturnType = factory.createIdentifier('ReturnType'); export const listenerForName = factory.createIdentifier('listenerFor'); +export const linkerName = factory.createIdentifier('linker'); export const TType = factory.createTypeReferenceNode('T'); -export const CallTxType = factory.createTypeReferenceNode(CallTx); export const AddressType = factory.createTypeReferenceNode(Address); export const EventType = factory.createTypeReferenceNode(Event); export const ContractCodecType = factory.createTypeReferenceNode(ContractCodec); -export const EventStreamType = factory.createTypeReferenceNode(EventStream); -export const SignalType = factory.createTypeReferenceNode(Signal); +export const CancelStreamSignalType = factory.createTypeReferenceNode(CancelStreamSignal); export const PrivateToken = factory.createToken(ts.SyntaxKind.PrivateKeyword); export const PublicToken = factory.createToken(ts.SyntaxKind.PublicKeyword); @@ -80,6 +76,10 @@ export function arrowFunc(params: ts.ParameterDeclaration[], body: ConciseBody): return factory.createArrowFunction(undefined, undefined, params, undefined, EqualsGreaterThanToken, body); } +export function hexToBuffer(arg: ts.Expression): ts.CallExpression { + return createCall(prop(BufferType, 'from'), [arg, factory.createStringLiteral('hex')]); +} + export function arrowFuncT( params: ts.ParameterDeclaration[], constraint: TypeNode | undefined, @@ -236,13 +236,12 @@ export function importBurrow(burrowImportPath: string): ts.ImportDeclaration { return importFrom( burrowImportPath, Address, - CallTx, ContractCodec, - Signal, + CancelStreamSignal, Event, - EventStream, listenerForName, Result, + linkerName, ); } diff --git a/js/src/solts/sol/Addition.abi.ts b/js/src/solts/sol/Addition.abi.ts index d9ceeb1ae..017c506f9 100644 --- a/js/src/solts/sol/Addition.abi.ts +++ b/js/src/solts/sol/Addition.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Addition { export const contactName = 'Addition'; export const abi = '[{"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"}]'; export const bytecode = '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a5f3c23b14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600081830190509291505056fea265627a7a72315820bf9f1b3176bb0e5383e0dbeabc3258cbe895f39124127f38452c4ce85df9672964736f6c63430005110032'; + export const deployedBytecode = + '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a5f3c23b14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600081830190509291505056fea265627a7a72315820bf9f1b3176bb0e5383e0dbeabc3258cbe895f39124127f38452c4ce85df9672964736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [{ abi: Addition.abi, codeHash: Buffer.from(Addition.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); diff --git a/js/src/solts/sol/Contains.abi.ts b/js/src/solts/sol/Contains.abi.ts index e4532da42..3d09d8408 100644 --- a/js/src/solts/sol/Contains.abi.ts +++ b/js/src/solts/sol/Contains.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Contains { export const contactName = 'Contains'; export const abi = '[{"constant":true,"inputs":[{"internalType":"address[]","name":"_list","type":"address[]"},{"internalType":"address","name":"_value","type":"address"}],"name":"contains","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256[]","name":"_list","type":"uint256[]"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"contains","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"}]'; export const bytecode = '608060405234801561001057600080fd5b50610304806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80633da80d661461003b578063b32b8e2c1461012b575b600080fd5b6101116004803603604081101561005157600080fd5b810190808035906020019064010000000081111561006e57600080fd5b82018360208201111561008057600080fd5b803590602001918460208302840111640100000000831117156100a257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610205565b604051808215151515815260200191505060405180910390f35b6101eb6004803603604081101561014157600080fd5b810190808035906020019064010000000081111561015e57600080fd5b82018360208201111561017057600080fd5b8035906020019184602083028401116401000000008311171561019257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610280565b604051808215151515815260200191505060405180910390f35b600080600090505b8351811015610274578273ffffffffffffffffffffffffffffffffffffffff1684828151811061023957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561026757600191505061027a565b808060010191505061020d565b50600090505b92915050565b600080600090505b83518110156102c3578284828151811061029e57fe5b602002602001015114156102b65760019150506102c9565b8080600101915050610288565b50600090505b9291505056fea265627a7a7231582032d6f06ddf667cc291458c6ed27a81fe8ef6fa213f3cf25c0fef50500bc05f2264736f6c63430005110032'; + export const deployedBytecode = + '608060405234801561001057600080fd5b50610304806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80633da80d661461003b578063b32b8e2c1461012b575b600080fd5b6101116004803603604081101561005157600080fd5b810190808035906020019064010000000081111561006e57600080fd5b82018360208201111561008057600080fd5b803590602001918460208302840111640100000000831117156100a257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610205565b604051808215151515815260200191505060405180910390f35b6101eb6004803603604081101561014157600080fd5b810190808035906020019064010000000081111561015e57600080fd5b82018360208201111561017057600080fd5b8035906020019184602083028401116401000000008311171561019257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610280565b604051808215151515815260200191505060405180910390f35b600080600090505b8351811015610274578273ffffffffffffffffffffffffffffffffffffffff1684828151811061023957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561026757600191505061027a565b808060010191505061020d565b50600090505b92915050565b600080600090505b83518110156102c3578284828151811061029e57fe5b602002602001015114156102b65760019150506102c9565b8080600101915050610288565b50600090505b9291505056fea265627a7a7231582032d6f06ddf667cc291458c6ed27a81fe8ef6fa213f3cf25c0fef50500bc05f2264736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [{ abi: Contains.abi, codeHash: Buffer.from(Contains.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); diff --git a/js/src/solts/sol/Creator.abi.ts b/js/src/solts/sol/Creator.abi.ts index 2bcdb0ed6..17e122f03 100644 --- a/js/src/solts/sol/Creator.abi.ts +++ b/js/src/solts/sol/Creator.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,24 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Creator { export const contactName = 'Creator'; export const abi = '[{"constant":false,"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"create","outputs":[{"internalType":"address","name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]'; export const bytecode = '608060405234801561001057600080fd5b50610504806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b6a46b3b14610030575b600080fd5b6100a76004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b90919293919293905050506100e9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600082826040516100f990610153565b80806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509350505050604051809103906000f08015801561014a573d6000803e3d6000fd5b50905092915050565b61036f806101618339019056fe60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032a265627a7a72315820cf64c1da8de972eb1f9f2b5e6799c7af3385d3ee9b08b51fb8d7b060fa7eb4e864736f6c63430005110032'; + export const deployedBytecode = + '608060405234801561001057600080fd5b50610504806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b6a46b3b14610030575b600080fd5b6100a76004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b90919293919293905050506100e9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600082826040516100f990610153565b80806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509350505050604051809103906000f08015801561014a573d6000803e3d6000fd5b50905092915050565b61036f806101618339019056fe60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032a265627a7a72315820cf64c1da8de972eb1f9f2b5e6799c7af3385d3ee9b08b51fb8d7b060fa7eb4e864736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [ + { abi: Creator.abi, codeHash: Buffer.from(Creator.deployedBytecode, 'hex') }, + { abi: Proxy.abi, codeHash: Buffer.from(Proxy.deployedBytecode, 'hex') }, + ]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); @@ -98,12 +96,15 @@ export namespace Proxy { '[{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"get","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]'; export const bytecode = '60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032'; + export const deployedBytecode = + '60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032'; export function deploy(client: Provider, _name: string): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy(_name)]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy(_name)]); + return client.deploy(data, [ + { abi: Creator.abi, codeHash: Buffer.from(Creator.deployedBytecode, 'hex') }, + { abi: Proxy.abi, codeHash: Buffer.from(Proxy.deployedBytecode, 'hex') }, + ]); } export async function deployContract(client: Provider, _name: string): Promise { const address = await deploy(client, _name); diff --git a/js/src/solts/sol/Eventer.abi.ts b/js/src/solts/sol/Eventer.abi.ts index 33edc85d1..3d3c370d0 100644 --- a/js/src/solts/sol/Eventer.abi.ts +++ b/js/src/solts/sol/Eventer.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, listenerFor, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, listenerFor } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Eventer { export const contactName = 'Eventer'; export const abi = '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"eventId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"intervalId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"eventAddress","type":"address"},{"indexed":false,"internalType":"string","name":"namespace","type":"string"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"controller","type":"address"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"},{"indexed":false,"internalType":"string","name":"metadata","type":"string"}],"name":"Init","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"timestamp","type":"int256"},{"indexed":false,"internalType":"string","name":"place","type":"string"},{"indexed":false,"internalType":"string","name":"postalAddress","type":"string"}],"name":"MonoRampage","type":"event"},{"constant":false,"inputs":[],"name":"announce","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]'; export const bytecode = '6080604052348015600f57600080fd5b506102b58061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638f970df014610030575b600080fd5b61003861003a565b005b607b7f6a35688e78094e86ac7dd4593423fa89415105dc68a0766b27106861ef4102146040518080602001806020018381038352600d8152602001807f53616e74612045756c61726961000000000000000000000000000000000000008152506020018381038252600a8152602001807f53616e74204a75616d65000000000000000000000000000000000000000000008152506020019250505060405180910390a27f696e74657276616c3200000000000000000000000000000000000000000000007f6576656e743100000000000000000000000000000000000000000000000000007f5f20df97ee573ab8b43581cf3ff905f3507ad2329b7efe6f92e802b4fad031c17359c99d4ebf520619ee7f806f11d90a9cac02ce06336004604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001848103845260068152602001807f64696e696e670000000000000000000000000000000000000000000000000000815250602001848103835260098152602001807f627265616b666173740000000000000000000000000000000000000000000000815250602001848103825260178152602001807f6261636f6e2c6265616e732c656767732c746f6d61746f000000000000000000815250602001965050505050505060405180910390a356fea265627a7a72315820a6cd65593c9a8f5ed08f75519d9dd5664bcdf3a4bb67c8f507e1a69ed348f04f64736f6c63430005110032'; + export const deployedBytecode = + '6080604052348015600f57600080fd5b506102b58061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638f970df014610030575b600080fd5b61003861003a565b005b607b7f6a35688e78094e86ac7dd4593423fa89415105dc68a0766b27106861ef4102146040518080602001806020018381038352600d8152602001807f53616e74612045756c61726961000000000000000000000000000000000000008152506020018381038252600a8152602001807f53616e74204a75616d65000000000000000000000000000000000000000000008152506020019250505060405180910390a27f696e74657276616c3200000000000000000000000000000000000000000000007f6576656e743100000000000000000000000000000000000000000000000000007f5f20df97ee573ab8b43581cf3ff905f3507ad2329b7efe6f92e802b4fad031c17359c99d4ebf520619ee7f806f11d90a9cac02ce06336004604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001848103845260068152602001807f64696e696e670000000000000000000000000000000000000000000000000000815250602001848103835260098152602001807f627265616b666173740000000000000000000000000000000000000000000000815250602001848103825260178152602001807f6261636f6e2c6265616e732c656767732c746f6d61746f000000000000000000815250602001965050505050505060405180910390a356fea265627a7a72315820a6cd65593c9a8f5ed08f75519d9dd5664bcdf3a4bb67c8f507e1a69ed348f04f64736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [{ abi: Eventer.abi, codeHash: Buffer.from(Eventer.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); @@ -62,7 +57,7 @@ export namespace Eventer { callback: (err?: Error, event?: TaggedPayload) => void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ) => EventStream; + ) => unknown; const events = { Init: { signature: '5F20DF97EE573AB8B43581CF3FF905F3507AD2329B7EFE6F92E802B4FAD031C1', @@ -125,10 +120,10 @@ export namespace Eventer { threshold: number; metadata: string; }, - ) => Signal | void, + ) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream { + ): unknown { return client.listen( ['5F20DF97EE573AB8B43581CF3FF905F3507AD2329B7EFE6F92E802B4FAD031C1'], address, @@ -136,10 +131,7 @@ export namespace Eventer { if (err) { return callback(err); } - return callback( - undefined, - decode(client, event?.getLog()?.getData_asU8(), event?.getLog()?.getTopicsList_asU8()).Init(), - ); + return callback(undefined, decode(client, event?.log.data, event?.log.topics).Init()); }, start, end, @@ -153,10 +145,10 @@ export namespace Eventer { place: string; postalAddress: string; }, - ) => Signal | void, + ) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream { + ): unknown { return client.listen( ['6A35688E78094E86AC7DD4593423FA89415105DC68A0766B27106861EF410214'], address, @@ -164,10 +156,7 @@ export namespace Eventer { if (err) { return callback(err); } - return callback( - undefined, - decode(client, event?.getLog()?.getData_asU8(), event?.getLog()?.getTopicsList_asU8()).MonoRampage(), - ); + return callback(undefined, decode(client, event?.log.data, event?.log.topics).MonoRampage()); }, start, end, diff --git a/js/src/solts/sol/MultipleReturns.abi.ts b/js/src/solts/sol/MultipleReturns.abi.ts index 44802ff0d..3f02e5be3 100644 --- a/js/src/solts/sol/MultipleReturns.abi.ts +++ b/js/src/solts/sol/MultipleReturns.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Multiple { export const contactName = 'Multiple'; export const abi = '[{"constant":true,"inputs":[],"name":"get","outputs":[{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"}]'; export const bytecode = '6080604052348015600f57600080fd5b5060ab8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80636d4ce63c14602d575b600080fd5b60336057565b60405180848152602001838152602001828152602001935050505060405180910390f35b600080600060016002600382925081915080905092509250925090919256fea265627a7a72315820db13aa50f1e1ad94cdc8fb2b158b105d0d0812d53d9851ed8a9bfa5447e3c17864736f6c63430005110032'; + export const deployedBytecode = + '6080604052348015600f57600080fd5b5060ab8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80636d4ce63c14602d575b600080fd5b60336057565b60405180848152602001838152602001828152602001935050505060405180910390f35b600080600060016002600382925081915080905092509250925090919256fea265627a7a72315820db13aa50f1e1ad94cdc8fb2b158b105d0d0812d53d9851ed8a9bfa5447e3c17864736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [{ abi: Multiple.abi, codeHash: Buffer.from(Multiple.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); diff --git a/js/src/solts/sol/Unnamed.abi.ts b/js/src/solts/sol/Unnamed.abi.ts index 3ba22926d..780d1cfb6 100644 --- a/js/src/solts/sol/Unnamed.abi.ts +++ b/js/src/solts/sol/Unnamed.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Unnamed { export const contactName = 'Unnamed'; export const abi = '[{"constant":true,"inputs":[{"internalType":"int256","name":"a","type":"int256"},{"internalType":"int256","name":"","type":"int256"}],"name":"set","outputs":[{"internalType":"int256","name":"sum","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"}]'; export const bytecode = '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806304c402f414602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600082830190509291505056fea265627a7a72315820c692aa5593a39c498f58c4a0221aa0b6ca567436b02c62f90b9214af7b7c390064736f6c63430005110032'; + export const deployedBytecode = + '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806304c402f414602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600082830190509291505056fea265627a7a72315820c692aa5593a39c498f58c4a0221aa0b6ca567436b02c62f90b9214af7b7c390064736f6c63430005110032'; export function deploy(client: Provider): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy()]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); + return client.deploy(data, [{ abi: Unnamed.abi, codeHash: Buffer.from(Unnamed.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider): Promise { const address = await deploy(client); diff --git a/js/src/solts/sol/build.ts b/js/src/solts/sol/build.ts index 5e823488a..2542ad97b 100644 --- a/js/src/solts/sol/build.ts +++ b/js/src/solts/sol/build.ts @@ -2,4 +2,8 @@ import * as path from 'path'; import { build } from '../build'; // Build these before any tests tha may rely on the generated output -build(path.join(__dirname, '..', '..', '..', 'src', 'solts', 'sol'), { burrowImportPath: '../../index' }); +const basePath = path.join(__dirname, '..', '..', '..', 'src', 'solts', 'sol'); +build(basePath, { burrowImportPath: (file) => path.join(path.relative(file, basePath), '../index') }).catch((err) => { + console.log(`Could not build solts test files: ${err}`, err); + process.exit(1); +}); diff --git a/js/src/solts/sol/Storage.abi.ts b/js/src/solts/sol/storage/Storage.abi.ts similarity index 69% rename from js/src/solts/sol/Storage.abi.ts rename to js/src/solts/sol/storage/Storage.abi.ts index cd6966519..26fac97bb 100644 --- a/js/src/solts/sol/Storage.abi.ts +++ b/js/src/solts/sol/storage/Storage.abi.ts @@ -1,17 +1,22 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CallTx, ContractCodec, Event, EventStream, Signal } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event } from '../../../index'; interface Provider { - deploy(msg: CallTx): Promise
; - call(msg: CallTx): Promise; - callSim(msg: CallTx): Promise; + deploy( + data: string | Uint8Array, + contractMeta?: { + abi: string; + codeHash: Uint8Array; + }[], + ): Promise
; + call(data: string | Uint8Array, address: string): Promise; + callSim(data: string | Uint8Array, address: string): Promise; listen( signatures: string[], address: string, - callback: (err?: Error, event?: Event) => Signal | void, + callback: (err?: Error, event?: Event) => CancelStreamSignal | void, start?: 'first' | 'latest' | 'stream' | number, end?: 'first' | 'latest' | 'stream' | number, - ): EventStream; - payload(data: string | Uint8Array, address?: string): CallTx; + ): unknown; contractCodec(contractABI: string): ContractCodec; } export type Caller = typeof defaultCall; @@ -22,31 +27,21 @@ export async function defaultCall( isSim: boolean, callback: (returnData: Uint8Array | undefined) => Output, ): Promise { - const payload = client.payload(data, addr); - const returnData = await (isSim ? client.callSim(payload) : client.call(payload)); + const returnData = await (isSim ? client.callSim(data, addr) : client.call(data, addr)); return callback(returnData); } -function linker(bytecode: string, name: string, address: string): string { - address = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, address); - } - return bytecode; -} export namespace Storage { export const contactName = 'Storage'; export const abi = '[{"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"}]'; export const bytecode = - '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820f111616fdeed05afb6d4e43891f3c42451310bf48d12f72b2864c23005c11fb664736f6c63430005110032'; + '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; + export const deployedBytecode = + '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; export function deploy(client: Provider, x: number): Promise { const codec = client.contractCodec(abi); - const linkedBytecode = bytecode; - const data = Buffer.concat([Buffer.from(linkedBytecode, 'hex'), codec.encodeDeploy(x)]); - const payload = client.payload(data); - return client.deploy(payload); + const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy(x)]); + return client.deploy(data, [{ abi: Storage.abi, codeHash: Buffer.from(Storage.deployedBytecode, 'hex') }]); } export async function deployContract(client: Provider, x: number): Promise { const address = await deploy(client, x); diff --git a/js/src/solts/sol/Storage.sol b/js/src/solts/sol/storage/Storage.sol similarity index 100% rename from js/src/solts/sol/Storage.sol rename to js/src/solts/sol/storage/Storage.sol diff --git a/js/yarn.lock b/js/yarn.lock index d8f4b6658..4df0e4a22 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -38,343 +38,343 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@ethersproject/abi@5.1.2", "@ethersproject/abi@^5.1.0": - version "5.1.2" - resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.2.tgz#a8e75cd0455e6dc9e4861c3d1c22bbe436c1d775" - integrity sha512-uMhoQVPX0UtfzTpekYQSEUcJGDgsJ25ifz+SV6PDETWaUFhcR8RNgb1QPTASP13inW8r6iy0/Xdq9D5hK2pNvA== - dependencies: - "@ethersproject/address" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/hash" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - -"@ethersproject/abstract-provider@5.1.0", "@ethersproject/abstract-provider@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz#1f24c56cda5524ef4ed3cfc562a01d6b6f8eeb0b" - integrity sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ== - dependencies: - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/networks" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" - "@ethersproject/web" "^5.1.0" - -"@ethersproject/abstract-signer@5.1.0", "@ethersproject/abstract-signer@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz#744c7a2d0ebe3cc0bc38294d0f53d5ca3f4e49e3" - integrity sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w== - dependencies: - "@ethersproject/abstract-provider" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - -"@ethersproject/address@5.1.0", "@ethersproject/address@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz#3854fd7ebcb6af7597de66f847c3345dae735b58" - integrity sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg== - dependencies: - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/rlp" "^5.1.0" - -"@ethersproject/base64@5.1.0", "@ethersproject/base64@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz#27240c174d0a4e13f6eae87416fd876caf7f42b6" - integrity sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g== - dependencies: - "@ethersproject/bytes" "^5.1.0" - -"@ethersproject/basex@5.1.0", "@ethersproject/basex@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz#80da2e86f9da0cb5ccd446b337364d791f6a131c" - integrity sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg== - dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - -"@ethersproject/bignumber@5.1.1", "@ethersproject/bignumber@^5.1.0": - version "5.1.1" - resolved "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.1.tgz#84812695253ccbc639117f7ac49ee1529b68e637" - integrity sha512-AVz5iqz7+70RIqoQTznsdJ6DOVBYciNlvO+AlQmPTB6ofCvoihI9bQdr6wljsX+d5W7Yc4nyvQvP4JMzg0Agig== +"@ethersproject/abi@5.2.0", "@ethersproject/abi@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.2.0.tgz#e2ca0b7f7e3b83e4d427ed8b38fdc1c48e2bb00f" + integrity sha512-24ExfHa0VbIOUHbB36b6lCVmWkaIVmrd9/m8MICtmSsRKzlugWqUD0B8g0zrRylXNxAOc3V6T4xKJ8jEDSvp3w== + dependencies: + "@ethersproject/address" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/hash" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + +"@ethersproject/abstract-provider@5.2.0", "@ethersproject/abstract-provider@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.2.0.tgz#b5c24b162f119b5d241738ded9555186013aa77d" + integrity sha512-Xi7Pt+CulRijc/vskBGIaYMEhafKjoNx8y4RNj/dnSpXHXScOJUSTtypqGBUngZddRbcwZGbHwEr6DZoKZwIZA== + dependencies: + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/networks" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" + "@ethersproject/web" "^5.2.0" + +"@ethersproject/abstract-signer@5.2.0", "@ethersproject/abstract-signer@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.2.0.tgz#8e291fb6558b4190fb3e2fe440a9ffd092a2f459" + integrity sha512-JTXzLUrtoxpOEq1ecH86U7tstkEa9POKAGbGBb+gicbjGgzYYkLR4/LD83SX2/JNWvtYyY8t5errt5ehiy1gxQ== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" + "@ethersproject/abstract-provider" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + +"@ethersproject/address@5.2.0", "@ethersproject/address@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/address/-/address-5.2.0.tgz#afcfa92db84582f54a60a9da361cea4aae450a69" + integrity sha512-2YfZlalWefOEfnr/CdqKRrgMgbKidYc+zG4/ilxSdcryZSux3eBU5/5btAT/hSiaHipUjd8UrWK8esCBHU6QNQ== + dependencies: + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/rlp" "^5.2.0" + +"@ethersproject/base64@5.2.0", "@ethersproject/base64@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.2.0.tgz#e01066d25e5b4e8a051545163bee5def47bd9534" + integrity sha512-D9wOvRE90QBI+yFsKMv0hnANiMzf40Xicq9JZbV9XYzh7srImmwmMcReU2wHjOs9FtEgSJo51Tt+sI1dKPYKDg== + dependencies: + "@ethersproject/bytes" "^5.2.0" + +"@ethersproject/basex@5.2.0", "@ethersproject/basex@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.2.0.tgz#f921039e3bdfdab8c5a7ba8b21e81c83fc1ab98b" + integrity sha512-Oo7oX7BmaHLY/8ZsOLI5W0mrSwPBb1iboosN17jfK/4vGAtKjAInDai9I72CzN4NRJaMN5FkFLoPYywGqgGHlg== + dependencies: + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + +"@ethersproject/bignumber@5.2.0", "@ethersproject/bignumber@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.2.0.tgz#03f91ea740c5adb6f8c6a2e91bb4ee5ffaff5503" + integrity sha512-+MNQTxwV7GEiA4NH/i51UqQ+lY36O0rxPdV+0qzjFSySiyBlJpLk6aaa4UTvKmYWlI7YKZm6vuyCENeYn7qAOw== + dependencies: + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" bn.js "^4.4.0" -"@ethersproject/bytes@5.1.0", "@ethersproject/bytes@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz#55dfa9c4c21df1b1b538be3accb50fb76d5facfd" - integrity sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g== +"@ethersproject/bytes@5.2.0", "@ethersproject/bytes@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.2.0.tgz#327917d5a1600f92fd2a9da4052fa6d974583132" + integrity sha512-O1CRpvJDnRTB47vvW8vyqojUZxVookb4LJv/s06TotriU3Xje5WFvlvXJu1yTchtxTz9BbvJw0lFXKpyO6Dn7w== dependencies: - "@ethersproject/logger" "^5.1.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/constants@5.1.0", "@ethersproject/constants@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz#4e7da6367ea0e9be87585d8b09f3fccf384b1452" - integrity sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw== +"@ethersproject/constants@5.2.0", "@ethersproject/constants@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.2.0.tgz#ccea78ce325f78abfe7358397c03eec570518d92" + integrity sha512-p+34YG0KbHS20NGdE+Ic0M6egzd7cDvcfoO9RpaAgyAYm3V5gJVqL7UynS87yCt6O6Nlx6wRFboPiM5ctAr+jA== dependencies: - "@ethersproject/bignumber" "^5.1.0" + "@ethersproject/bignumber" "^5.2.0" -"@ethersproject/contracts@5.1.1": - version "5.1.1" - resolved "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.1.tgz#c66cb6d618fcbd73e20a6b808e8f768b2b781d0b" - integrity sha512-6WwktLJ0DFWU8pDkgH4IGttQHhQN4SnwKFu9h+QYVe48VGWtbDu4W8/q/7QA1u/HWlWMrKxqawPiZUJj0UMvOw== - dependencies: - "@ethersproject/abi" "^5.1.0" - "@ethersproject/abstract-provider" "^5.1.0" - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/address" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" - -"@ethersproject/hash@5.1.0", "@ethersproject/hash@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz#40961d64837d57f580b7b055e0d74174876d891e" - integrity sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ== - dependencies: - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/address" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - -"@ethersproject/hdnode@5.1.0", "@ethersproject/hdnode@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz#2bf5c4048935136ce83e9242e1bd570afcc0bc83" - integrity sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg== - dependencies: - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/basex" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/pbkdf2" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/sha2" "^5.1.0" - "@ethersproject/signing-key" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" - "@ethersproject/wordlists" "^5.1.0" - -"@ethersproject/json-wallets@5.1.0", "@ethersproject/json-wallets@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz#bba7af2e520e8aea4d3829d80520db5d2e4fb8d2" - integrity sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA== - dependencies: - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/address" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/hdnode" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/pbkdf2" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/random" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" +"@ethersproject/contracts@5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.2.0.tgz#f54e12ec4a323f2bf93c338034839cc6dfc1e347" + integrity sha512-/2fg5tWPG6Z4pciEWpwGji3ggGA5j0ChVNF7NTmkOhvFrrJuWnRpzbvYA00nz8tBDNCOV3cwub5zfWRpgwYEJQ== + dependencies: + "@ethersproject/abi" "^5.2.0" + "@ethersproject/abstract-provider" "^5.2.0" + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/address" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" + +"@ethersproject/hash@5.2.0", "@ethersproject/hash@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.2.0.tgz#2d21901eafc5bdb738b4ad96bee364d371ec724b" + integrity sha512-wEGry2HFFSssFiNEkFWMzj1vpdFv4rQlkBp41UfL6J58zKGNycoAWimokITDMk8p7548MKr27h48QfERnNKkRw== + dependencies: + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/address" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + +"@ethersproject/hdnode@5.2.0", "@ethersproject/hdnode@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.2.0.tgz#efea9b2f713e55aa5ba23cc62b4aac6d08dcfa53" + integrity sha512-ffq2JrW5AftCmfWZ8DxpdWdw/x06Yn+e9wrWHLpj8If1+w87W4LbTMRUaUmO1DUSN8H8g/6kMUKCTJPVuxsuOw== + dependencies: + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/basex" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/pbkdf2" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/sha2" "^5.2.0" + "@ethersproject/signing-key" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" + "@ethersproject/wordlists" "^5.2.0" + +"@ethersproject/json-wallets@5.2.0", "@ethersproject/json-wallets@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.2.0.tgz#d41c7c39e4d236b586e26e2145b09ac49dc56608" + integrity sha512-iWxSm9XiugEtaehYD6w1ImmXeatjcGcrQvffZVJHH1UqV4FckDzrOYnZBRHPQRYlnhNVrGTld1+S0Cu4MB8gdw== + dependencies: + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/address" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/hdnode" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/pbkdf2" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/random" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" aes-js "3.0.0" scrypt-js "3.0.1" -"@ethersproject/keccak256@5.1.0", "@ethersproject/keccak256@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz#fdcd88fb13bfef4271b225cdd8dec4d315c8e60e" - integrity sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig== +"@ethersproject/keccak256@5.2.0", "@ethersproject/keccak256@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.2.0.tgz#15257862807c23f24a3209d1016d322dca85a464" + integrity sha512-LqyxTwVANga5Y3L1yo184czW6b3PibabN8xyE/eOulQLLfXNrHHhwrOTpOhoVRWCICVCD/5SjQfwqTrczjS7jQ== dependencies: - "@ethersproject/bytes" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" js-sha3 "0.5.7" -"@ethersproject/logger@5.1.0", "@ethersproject/logger@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz#4cdeeefac029373349d5818f39c31b82cc6d9bbf" - integrity sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw== +"@ethersproject/logger@5.2.0", "@ethersproject/logger@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.2.0.tgz#accf5348251f78b6c8891af67f42490a4ea4e5ae" + integrity sha512-dPZ6/E3YiArgG8dI/spGkaRDry7YZpCntf4gm/c6SI8Mbqiihd7q3nuLN5VvDap/0K3xm3RE1AIUOcUwwh2ezQ== -"@ethersproject/networks@5.1.0", "@ethersproject/networks@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz#f537290cb05aa6dc5e81e910926c04cfd5814bca" - integrity sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA== +"@ethersproject/networks@5.2.0", "@ethersproject/networks@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.2.0.tgz#66c23c6ac477dd703645b2c971ac842d8b8aa524" + integrity sha512-q+htMgq7wQoEnjlkdHM6t1sktKxNbEB/F6DQBPNwru7KpQ1R0n0UTIXJB8Rb7lSnvjqcAQ40X3iVqm94NJfYDw== dependencies: - "@ethersproject/logger" "^5.1.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/pbkdf2@5.1.0", "@ethersproject/pbkdf2@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz#6b740a85dc780e879338af74856ca2c0d3b24d19" - integrity sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew== +"@ethersproject/pbkdf2@5.2.0", "@ethersproject/pbkdf2@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.2.0.tgz#8166a7a7238a5fd1d9bb6eb2000fea0f19fdde06" + integrity sha512-qKOoO6yir/qnAgg6OP3U4gRuZ6jl9P7xwggRu/spVfnuaR+wa490AatWLqB1WOXKf6JFjm5yOaT/T5fCICQVdQ== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/sha2" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/sha2" "^5.2.0" -"@ethersproject/properties@5.1.0", "@ethersproject/properties@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz#9484bd6def16595fc6e4bdc26f29dff4d3f6ac42" - integrity sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg== +"@ethersproject/properties@5.2.0", "@ethersproject/properties@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.2.0.tgz#8fadf367f7ac7357019d0224aa579b234c545ac1" + integrity sha512-oNFkzcoGwXXV+/Yp/MLcDLrL/2i360XIy2YN9yRZJPnIbLwjroFNLiRzLs6PyPw1D09Xs8OcPR1/nHv6xDKE2A== dependencies: - "@ethersproject/logger" "^5.1.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/providers@5.1.2": - version "5.1.2" - resolved "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.2.tgz#4e4459698903f911402fe91aa7544eb07f3921ed" - integrity sha512-GqsS8rd+eyd4eNkcNgzZ4l9IRULBPUZa7JPnv22k4MHflMobUseyhfbVnmoN5bVNNkOxjV1IPTw9i0sV1hwdpg== - dependencies: - "@ethersproject/abstract-provider" "^5.1.0" - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/address" "^5.1.0" - "@ethersproject/basex" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/hash" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/networks" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/random" "^5.1.0" - "@ethersproject/rlp" "^5.1.0" - "@ethersproject/sha2" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" - "@ethersproject/web" "^5.1.0" +"@ethersproject/providers@5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.2.0.tgz#b2f3e3b2ca4567c8372543ceb6f3c6e3a2370783" + integrity sha512-Yf/ZUqCrVr+jR0SHA9GuNZs4R1xnV9Ibnh1TlOa0ZzI6o+Qf8bEyE550k9bYI4zk2f9x9baX2RRs6BJY7Jz/WA== + dependencies: + "@ethersproject/abstract-provider" "^5.2.0" + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/address" "^5.2.0" + "@ethersproject/basex" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/hash" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/networks" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/random" "^5.2.0" + "@ethersproject/rlp" "^5.2.0" + "@ethersproject/sha2" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" + "@ethersproject/web" "^5.2.0" bech32 "1.1.4" ws "7.2.3" -"@ethersproject/random@5.1.0", "@ethersproject/random@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz#0bdff2554df03ebc5f75689614f2d58ea0d9a71f" - integrity sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw== +"@ethersproject/random@5.2.0", "@ethersproject/random@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/random/-/random-5.2.0.tgz#1d7e19f17d88eda56228a263063826829e49eebe" + integrity sha512-7Nd3qjivBGlDCGDuGYjPi8CXdtVhRZ7NeyBXoJgtnJBwn1S01ahrbMeOUVmRVWrFM0YiSEPEGo7i4xEu2gRPcg== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/rlp@5.1.0", "@ethersproject/rlp@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz#700f4f071c27fa298d3c1d637485fefe919dd084" - integrity sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw== +"@ethersproject/rlp@5.2.0", "@ethersproject/rlp@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.2.0.tgz#bbf605183818a9d96bdc40323d734c79e26cfaca" + integrity sha512-RqGsELtPWxcFhOOhSr0lQ2hBNT9tBE08WK0tb6VQbCk97EpqkbgP8yXED9PZlWMiRGchJTw6S+ExzK62XMX/fw== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/sha2@5.1.0", "@ethersproject/sha2@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz#6ca42d1a26884b3e32ffa943fe6494af7211506c" - integrity sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA== +"@ethersproject/sha2@5.2.0", "@ethersproject/sha2@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.2.0.tgz#ae18fa6c09c6d99fa2b564dac7276bcd513c1579" + integrity sha512-Wqqptfn0PRO2mvmpktPW1HOLrrCyGtxhVQxO1ZyePoGrcEOurhICOlIvkTogoX4Q928D3Z9XtSSCUbdOJUF2kg== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" hash.js "1.1.3" -"@ethersproject/signing-key@5.1.0", "@ethersproject/signing-key@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz#6eddfbddb6826b597b9650e01acf817bf8991b9c" - integrity sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw== +"@ethersproject/signing-key@5.2.0", "@ethersproject/signing-key@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.2.0.tgz#e8eb10d3c0f4a575479db8d70c62aaf93cd384d1" + integrity sha512-9A+dVSkrVAPuhJnWqLWV/NkKi/KB4iagTKEuojfuApUfeIHEhpwQ0Jx3cBimk7qWISSSKdgiAmIqpvVtZ5FEkg== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" bn.js "^4.4.0" elliptic "6.5.4" -"@ethersproject/solidity@5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz#095a9c75244edccb26c452c155736d363399b954" - integrity sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ== +"@ethersproject/solidity@5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.2.0.tgz#ac902d8f8b11bf58fd37ccf77392178cbbd0b08f" + integrity sha512-EEFlNyEnONW3CWF8UGWPcqxJUHiaIoofO7itGwO/2gvGpnwlL+WUV+GmQoHNxmn+QJeOHspnZuh6NOVrJL6H1g== + dependencies: + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/sha2" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + +"@ethersproject/strings@5.2.0", "@ethersproject/strings@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.2.0.tgz#e93d989859587191c3f64bda124d9dedbc3f5a97" + integrity sha512-RmjX800wRYKgrzo2ZCSlA8OCQYyq4+M46VgjSVDVyYkLZctBXC3epqlppDA24R7eo856KNbXqezZsMnHT+sSuA== dependencies: - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/sha2" "^5.1.0" - "@ethersproject/strings" "^5.1.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/strings@5.1.0", "@ethersproject/strings@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz#0f95a56c3c8c9d5510a06c241d818779750e2da5" - integrity sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw== +"@ethersproject/transactions@5.2.0", "@ethersproject/transactions@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.2.0.tgz#052e2ef8f8adf7037ebe4cc47aad2a61950e6491" + integrity sha512-QrGbhGYsouNNclUp3tWMbckMsuXJTOsA56kT3BuRrLlXJcUH7myIihajXdSfKcyJsvHJPrGZP+U3TKh+sLzZtg== + dependencies: + "@ethersproject/address" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/rlp" "^5.2.0" + "@ethersproject/signing-key" "^5.2.0" + +"@ethersproject/units@5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/units/-/units-5.2.0.tgz#08643e5d4583ecc1a32b103c1157f7ae80803392" + integrity sha512-yrwlyomXcBBHp5oSrLxlLkyHN7dVu3PO7hMbQXc00h388zU4TF3o/PAIUhh+x695wgJ19Fa8YgUWCab3a1RDwA== dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/logger" "^5.1.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/constants" "^5.2.0" + "@ethersproject/logger" "^5.2.0" -"@ethersproject/transactions@5.1.1", "@ethersproject/transactions@^5.1.0": - version "5.1.1" - resolved "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.1.tgz#5a6bbb25fb062c3cc75eb0db12faefcdd3870813" - integrity sha512-Nwgbp09ttIVN0OoUBatCXaHxR7grWPHbozJN8v7AXDLrl6nnOIBEMDh+yJTnosSQlFhcyjfTGGN+Mx6R8HdvMw== - dependencies: - "@ethersproject/address" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/rlp" "^5.1.0" - "@ethersproject/signing-key" "^5.1.0" - -"@ethersproject/units@5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz#b6ab3430ebc22adc3cb4839516496f167bee3ad5" - integrity sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA== - dependencies: - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/constants" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - -"@ethersproject/wallet@5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz#134c5816eaeaa586beae9f9ff67891104a2c9a15" - integrity sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ== - dependencies: - "@ethersproject/abstract-provider" "^5.1.0" - "@ethersproject/abstract-signer" "^5.1.0" - "@ethersproject/address" "^5.1.0" - "@ethersproject/bignumber" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/hash" "^5.1.0" - "@ethersproject/hdnode" "^5.1.0" - "@ethersproject/json-wallets" "^5.1.0" - "@ethersproject/keccak256" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/random" "^5.1.0" - "@ethersproject/signing-key" "^5.1.0" - "@ethersproject/transactions" "^5.1.0" - "@ethersproject/wordlists" "^5.1.0" - -"@ethersproject/web@5.1.0", "@ethersproject/web@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz#ed56bbe4e3d9a8ffe3b2ed882da5c62d3551381b" - integrity sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA== - dependencies: - "@ethersproject/base64" "^5.1.0" - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/strings" "^5.1.0" - -"@ethersproject/wordlists@5.1.0", "@ethersproject/wordlists@^5.1.0": - version "5.1.0" - resolved "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz#54eb9ef3a00babbff90ffe124e19c89e07e6aace" - integrity sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ== - dependencies: - "@ethersproject/bytes" "^5.1.0" - "@ethersproject/hash" "^5.1.0" - "@ethersproject/logger" "^5.1.0" - "@ethersproject/properties" "^5.1.0" - "@ethersproject/strings" "^5.1.0" +"@ethersproject/wallet@5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.2.0.tgz#b5a8406676067e34f633536a4cb53c2ff98c0b5c" + integrity sha512-uPdjZwUmAJLo1+ybR/G/rL9pv/NEcCqOsjn6RJFvG7RmwP2kS1v5C+F+ysgx2W/PxBIVT+2IEsfXLbBz8s/6Rg== + dependencies: + "@ethersproject/abstract-provider" "^5.2.0" + "@ethersproject/abstract-signer" "^5.2.0" + "@ethersproject/address" "^5.2.0" + "@ethersproject/bignumber" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/hash" "^5.2.0" + "@ethersproject/hdnode" "^5.2.0" + "@ethersproject/json-wallets" "^5.2.0" + "@ethersproject/keccak256" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/random" "^5.2.0" + "@ethersproject/signing-key" "^5.2.0" + "@ethersproject/transactions" "^5.2.0" + "@ethersproject/wordlists" "^5.2.0" + +"@ethersproject/web@5.2.0", "@ethersproject/web@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/web/-/web-5.2.0.tgz#47d8e152e7fcc07ba0aff4f99fde268fde79dd7a" + integrity sha512-mYb9qxGlOBFR2pR6t1CZczuqqX6r8RQGn7MtwrBciMex3cvA/qs+wbmcDgl+/OZY0Pco/ih6WHQRnVi+4sBeCQ== + dependencies: + "@ethersproject/base64" "^5.2.0" + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/strings" "^5.2.0" + +"@ethersproject/wordlists@5.2.0", "@ethersproject/wordlists@^5.2.0": + version "5.2.0" + resolved "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.2.0.tgz#afcce0229e9ef64af1bf8a1e96571fa441e9f444" + integrity sha512-/7TG5r/Zm8Wd9WhoqQ4QnntgMkIfIZ8QVrpU81muiChLD26XLOgmyiqKPL7K058uYt7UZ0wzbXjxyCYadU3xFQ== + dependencies: + "@ethersproject/bytes" "^5.2.0" + "@ethersproject/hash" "^5.2.0" + "@ethersproject/logger" "^5.2.0" + "@ethersproject/properties" "^5.2.0" + "@ethersproject/strings" "^5.2.0" "@grpc/grpc-js@^1.3.0": version "1.3.0" @@ -1034,41 +1034,41 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -ethers@^5.1.4: - version "5.1.4" - resolved "https://registry.npmjs.org/ethers/-/ethers-5.1.4.tgz#8ae973705ed962f8f41dc59693704002a38dd18b" - integrity sha512-EAPQ/fgGRu0PoR/VNFnHTMOtG/IZ0AItdW55C9T8ffmVu0rnyllZL404eBF66elJehOLz2kxnUrhXpE7TCpW7g== - dependencies: - "@ethersproject/abi" "5.1.2" - "@ethersproject/abstract-provider" "5.1.0" - "@ethersproject/abstract-signer" "5.1.0" - "@ethersproject/address" "5.1.0" - "@ethersproject/base64" "5.1.0" - "@ethersproject/basex" "5.1.0" - "@ethersproject/bignumber" "5.1.1" - "@ethersproject/bytes" "5.1.0" - "@ethersproject/constants" "5.1.0" - "@ethersproject/contracts" "5.1.1" - "@ethersproject/hash" "5.1.0" - "@ethersproject/hdnode" "5.1.0" - "@ethersproject/json-wallets" "5.1.0" - "@ethersproject/keccak256" "5.1.0" - "@ethersproject/logger" "5.1.0" - "@ethersproject/networks" "5.1.0" - "@ethersproject/pbkdf2" "5.1.0" - "@ethersproject/properties" "5.1.0" - "@ethersproject/providers" "5.1.2" - "@ethersproject/random" "5.1.0" - "@ethersproject/rlp" "5.1.0" - "@ethersproject/sha2" "5.1.0" - "@ethersproject/signing-key" "5.1.0" - "@ethersproject/solidity" "5.1.0" - "@ethersproject/strings" "5.1.0" - "@ethersproject/transactions" "5.1.1" - "@ethersproject/units" "5.1.0" - "@ethersproject/wallet" "5.1.0" - "@ethersproject/web" "5.1.0" - "@ethersproject/wordlists" "5.1.0" +ethers@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/ethers/-/ethers-5.2.0.tgz#13452e35947ab5d77053286d1f7161ee666c85ba" + integrity sha512-HqFGU2Qab0mAg3y1eHKVMXS4i1gTObMY0/4+x4LiO72NHhJL3Z795gnqyivmwG1J8e5NLSlRSfyIR7TL0Hw3ig== + dependencies: + "@ethersproject/abi" "5.2.0" + "@ethersproject/abstract-provider" "5.2.0" + "@ethersproject/abstract-signer" "5.2.0" + "@ethersproject/address" "5.2.0" + "@ethersproject/base64" "5.2.0" + "@ethersproject/basex" "5.2.0" + "@ethersproject/bignumber" "5.2.0" + "@ethersproject/bytes" "5.2.0" + "@ethersproject/constants" "5.2.0" + "@ethersproject/contracts" "5.2.0" + "@ethersproject/hash" "5.2.0" + "@ethersproject/hdnode" "5.2.0" + "@ethersproject/json-wallets" "5.2.0" + "@ethersproject/keccak256" "5.2.0" + "@ethersproject/logger" "5.2.0" + "@ethersproject/networks" "5.2.0" + "@ethersproject/pbkdf2" "5.2.0" + "@ethersproject/properties" "5.2.0" + "@ethersproject/providers" "5.2.0" + "@ethersproject/random" "5.2.0" + "@ethersproject/rlp" "5.2.0" + "@ethersproject/sha2" "5.2.0" + "@ethersproject/signing-key" "5.2.0" + "@ethersproject/solidity" "5.2.0" + "@ethersproject/strings" "5.2.0" + "@ethersproject/transactions" "5.2.0" + "@ethersproject/units" "5.2.0" + "@ethersproject/wallet" "5.2.0" + "@ethersproject/web" "5.2.0" + "@ethersproject/wordlists" "5.2.0" fast-deep-equal@^3.1.1: version "3.1.3" From f4192e3ce5741b90b31b9798d8559a9f50f00aa8 Mon Sep 17 00:00:00 2001 From: Silas Davis Date: Thu, 27 May 2021 07:49:10 +0200 Subject: [PATCH 2/4] Upgrade to Go 1.16 Signed-off-by: Silas Davis --- .github/Dockerfile | 10 +- .github/workflows/main.yaml | 2 +- .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 4 +- Dockerfile | 6 +- Makefile | 2 +- go.mod | 4 +- js/package.json | 2 +- js/src/contracts/abi.ts | 47 +++++--- .../{solts/lib => contracts}/compile.test.ts | 0 js/src/contracts/compile.ts | 112 +++++++++++++++++ js/src/index.ts | 3 +- js/src/solts/api.ts | 6 +- js/src/solts/build.ts | 7 +- js/src/solts/lib/abi.ts | 31 ----- js/src/solts/lib/compile.ts | 114 ------------------ js/src/solts/lib/deployer.ts | 26 ++-- js/src/solts/lib/provider.ts | 38 +++--- js/src/solts/lib/solidity.test.ts | 2 +- js/src/solts/lib/solidity.ts | 2 +- js/src/solts/lib/syntax.ts | 20 ++- js/src/solts/sol/Addition.abi.ts | 17 ++- js/src/solts/sol/Contains.abi.ts | 17 ++- js/src/solts/sol/Creator.abi.ts | 44 ++++--- js/src/solts/sol/Eventer.abi.ts | 17 ++- js/src/solts/sol/MultipleReturns.abi.ts | 17 ++- js/src/solts/sol/Unnamed.abi.ts | 17 ++- js/src/solts/sol/storage/Storage.abi.ts | 17 ++- js/src/test/solts.test.ts | 9 +- 29 files changed, 322 insertions(+), 273 deletions(-) rename js/src/{solts/lib => contracts}/compile.test.ts (100%) delete mode 100644 js/src/solts/lib/abi.ts delete mode 100644 js/src/solts/lib/compile.ts diff --git a/.github/Dockerfile b/.github/Dockerfile index 537e70c53..15c2ae40b 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -1,8 +1,8 @@ -FROM golang:1.15-alpine3.13 +FROM golang:1.16-alpine3.13 MAINTAINER Monax -ENV DOCKER_VERSION "17.12.1-ce" -ENV GORELEASER_VERSION "v0.104.1" +ENV DOCKER_VERSION "20.10.6" +ENV GORELEASER_VERSION "v0.166.1" # This is the image used by the Circle CI config # Update remote with 'make push_ci_image' RUN apk add --update --no-cache \ @@ -22,8 +22,8 @@ RUN apk add --update --no-cache \ libffi-dev \ openssl-dev \ python3-dev \ - py-pip -RUN pip3 install docker-compose + py-pip \ + docker-compose # get docker client WORKDIR /usr/bin RUN curl -sS -L https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_VERSION.tgz | tar xz --strip-components 1 docker/docker diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e139b5584..1f2d73999 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v1 with: - go-version: 1.15 + go-version: 1.16 id: go - uses: actions/checkout@v2 - run: make test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f238760fa..554e83c9a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,7 +13,7 @@ jobs: - run: git fetch --prune --unshallow - uses: actions/setup-go@v1 with: - go-version: 1.15 + go-version: 1.16 - uses: goreleaser/goreleaser-action@v1 with: version: latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7b5a1c223..95e8b5867 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v1 with: - go-version: 1.15 + go-version: 1.16 id: go - uses: actions/checkout@v2 - run: git fetch --unshallow --prune @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/setup-go@v1 with: - go-version: 1.15 + go-version: 1.16 id: go - uses: actions/checkout@v1 - run: make test_integration diff --git a/Dockerfile b/Dockerfile index 559cb5030..997a27b90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # For solc binary -FROM ethereum/solc:0.5.12 as solc-builder +FROM ethereum/solc:0.5.15 as solc-builder # We use a multistage build to avoid bloating our deployment image with build dependencies -FROM golang:1.15-alpine3.12 as builder +FROM golang:1.16-alpine3.13 as builder RUN apk add --no-cache --update git bash make musl-dev gcc libc6-compat @@ -13,7 +13,7 @@ WORKDIR $REPO RUN make build # This will be our base container image -FROM alpine:3.11 +FROM alpine:3.13 # Variable arguments to populate labels ARG USER=burrow diff --git a/Makefile b/Makefile index ad8b68863..2de82af04 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ REPO := $(shell pwd) # Our own Go files containing the compiled bytecode of solidity files as a constant -export CI_IMAGE=hyperledger/burrow:ci-2 +export CI_IMAGE=hyperledger/burrow:ci-3 VERSION := $(shell scripts/version.sh) # Gets implicit default GOPATH if not set diff --git a/go.mod b/go.mod index e29382832..44d62976c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hyperledger/burrow -go 1.15 +go 1.16 require ( github.com/BurntSushi/toml v0.3.1 @@ -52,7 +52,7 @@ require ( github.com/xlab/treeprint v1.0.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/net v0.0.0-20210119194325-5f4716e94777 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/js/package.json b/js/package.json index 5a27944e4..d8d68f28a 100644 --- a/js/package.json +++ b/js/package.json @@ -1,5 +1,5 @@ { - "version": "0.33.1-dev.e4b5f85b9", + "version": "0.33.1-dev.4b4d42399", "name": "@hyperledger/burrow", "description": "TypeScript library that calls a Hyperledger Burrow server over GRPC.", "main": "./dist/index.js", diff --git a/js/src/contracts/abi.ts b/js/src/contracts/abi.ts index d26c61e3c..17afc790b 100644 --- a/js/src/contracts/abi.ts +++ b/js/src/contracts/abi.ts @@ -6,7 +6,37 @@ export type Address = string; export type FunctionIO = FunctionInput & FunctionOutput; -// TODO: replace with ethers js +export namespace ABI { + export type Func = { + type: 'function' | 'constructor' | 'fallback'; + name: string; + inputs?: Array; + outputs?: Array; + stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'; + payable?: boolean; + constant?: boolean; + }; + + export type Event = { + type: 'event'; + name: string; + inputs: Array; + anonymous: boolean; + }; + + export type FunctionInput = { + name: string; + type: string; + components?: FunctionInput[]; + internalType?: string; + }; + + export type FunctionOutput = FunctionInput; + export type EventInput = FunctionInput & { indexed?: boolean }; + + export type FunctionIO = FunctionInput & FunctionOutput; + export type FunctionOrEvent = Func | Event; +} export function transformToFullName(abi: SolidityFunction | Event): string { if (abi.name.indexOf('(') !== -1) { @@ -15,18 +45,3 @@ export function transformToFullName(abi: SolidityFunction | Event): string { const typeName = (abi.inputs as Array).map((i) => i.type).join(','); return abi.name + '(' + typeName + ')'; } - -export function extractDisplayName(name: string): string { - const length = name.indexOf('('); - return length !== -1 ? name.substr(0, length) : name; -} - -export function extractTypeName(name: string): string { - /// TODO: make it invulnerable - const length = name.indexOf('('); - return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : ''; -} - -export function isFunction(abi: SolidityFunction | Event): abi is SolidityFunction { - return abi.type === 'function' || abi.type === 'constructor'; -} diff --git a/js/src/solts/lib/compile.test.ts b/js/src/contracts/compile.test.ts similarity index 100% rename from js/src/solts/lib/compile.test.ts rename to js/src/contracts/compile.test.ts diff --git a/js/src/contracts/compile.ts b/js/src/contracts/compile.ts index 6f8d7b3ce..8dc0ca1dd 100644 --- a/js/src/contracts/compile.ts +++ b/js/src/contracts/compile.ts @@ -1,3 +1,5 @@ +import fs from 'fs'; +import { ResolvedImport } from 'solc'; import solc from 'solc_v5'; import { ABI } from './abi'; import { Contract } from './contract'; @@ -10,6 +12,62 @@ export type CompiledContract = { deployedBytecode?: string; }; +export namespace Solidity { + export type Bytecode = { + linkReferences: any; + object: string; + opcodes: string; + sourceMap: string; + }; + + export type Contract = { + assembly: any; + evm: { + bytecode: Bytecode; + deployedBytecode: Bytecode; + }; + functionHashes: any; + gasEstimates: any; + abi: ABI.FunctionOrEvent[]; + opcodes: string; + runtimeBytecode: string; + srcmap: string; + srcmapRuntime: string; + }; + + export type Source = { + AST: any; + }; + + export type InputDescription = { + language: string; + sources: Record; + settings: { + outputSelection: Record>>; + }; + }; + + type Error = { + sourceLocation?: { + file: string; + start: number; + end: number; + }; + type: string; + component: string; + severity: 'error' | 'warning'; + message: string; + formattedMessage?: string; + }; + + export type OutputDescription = { + contracts: Record>; + errors: Array; + sourceList: Array; + sources: Record; + }; +} + // Compile solidity source code export function compile( source: string, @@ -45,3 +103,57 @@ function getCompiledCode(contract: solc.Contract): Required { deployedBytecode: contract.evm.deployedBytecode.object, }; } + +function NewInputDescription(): Solidity.InputDescription { + return { + language: 'Solidity', + sources: {}, + settings: { outputSelection: {} }, + }; +} + +export function encodeInput(obj: Solidity.InputDescription): string { + return JSON.stringify(obj); +} + +export function decodeOutput(str: string): Solidity.OutputDescription { + return JSON.parse(str); +} + +export function inputDescriptionFromFiles(names: string[]): Solidity.InputDescription { + const desc = NewInputDescription(); + names.map((name) => { + desc.sources[name] = { content: fs.readFileSync(name).toString() }; + desc.settings.outputSelection[name] = {}; + desc.settings.outputSelection[name]['*'] = ['*']; + }); + return desc; +} + +export function importLocal(path: string): ResolvedImport { + return { + contents: fs.readFileSync(path).toString(), + }; +} + +export function tokenizeLinks(links: Record>): string[] { + const libraries: Array = []; + for (const file in links) { + for (const library in links[file]) { + libraries.push(file + ':' + library); + } + } + return libraries; +} + +export function linker(bytecode: string, links: { name: string; address: string }[]): string { + for (const { name, address } of links) { + const paddedAddress = address + Array(40 - address.length + 1).join('0'); + const truncated = name.slice(0, 36); + const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; + while (bytecode.indexOf(label) >= 0) { + bytecode = bytecode.replace(label, paddedAddress); + } + } + return bytecode; +} diff --git a/js/src/index.ts b/js/src/index.ts index 5b65c8c20..819f02489 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -1,3 +1,4 @@ +export { Keccak } from 'sha3'; export * as Exec from '../proto/exec_pb'; export { CallTx, TxInput } from '../proto/payload_pb'; export { BlockRange } from '../proto/rpcevents_pb'; @@ -5,6 +6,7 @@ export { Client } from './client'; export { ContractCodec } from './codec'; export { Address } from './contracts/abi'; export { makeCallTx } from './contracts/call'; +export { linker } from './contracts/compile'; export { Contract } from './contracts/contract'; export { Result } from './convert'; export { @@ -21,4 +23,3 @@ export { } from './events'; export { build } from './solts/build'; export { Caller, defaultCall, Provider } from './solts/interface.gd'; -export { linker } from './solts/lib/compile'; diff --git a/js/src/solts/api.ts b/js/src/solts/api.ts index ed84405cc..7d02f49ca 100644 --- a/js/src/solts/api.ts +++ b/js/src/solts/api.ts @@ -1,5 +1,5 @@ import ts, { factory } from 'typescript'; -import { ABI } from './lib/abi'; +import { ABI } from "../contracts/abi"; import { callerTypes, createCallerFunction } from './lib/caller'; import { declareContractType, generateContractObject } from './lib/contract'; import { generateDecodeObject } from './lib/decoder'; @@ -16,7 +16,7 @@ import { getContractMethods } from './lib/solidity'; import { declareConstant, ExportToken, importBurrow, importReadable } from './lib/syntax'; import Func = ABI.Func; -export { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, tokenizeLinks } from './lib/compile'; +export { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, tokenizeLinks } from '../contracts/compile'; export type Compiled = { name: string; @@ -54,7 +54,7 @@ export function newFile(contracts: Compiled[], burrowImportPath: string): ts.Nod const deployMembers = contract.bytecode ? [ declareConstant(bytecodeName, factory.createStringLiteral(contract.bytecode, true), true), - declareConstant(deployedBytecodeName, factory.createStringLiteral(contract.bytecode, true), true), + declareConstant(deployedBytecodeName, factory.createStringLiteral(contract.deployedBytecode, true), true), generateDeployFunction(deploy, contract.links, provider, abiName, contractNames), generateDeployContractFunction(deploy, contract.links, provider), ] diff --git a/js/src/solts/build.ts b/js/src/solts/build.ts index 5bb65c22c..0a2d994b1 100644 --- a/js/src/solts/build.ts +++ b/js/src/solts/build.ts @@ -2,8 +2,8 @@ import { promises as fs } from 'fs'; import * as path from 'path'; import * as solcv5 from 'solc_v5'; import * as solcv8 from 'solc_v8'; +import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, Solidity } from '../contracts/compile'; import { Compiled, newFile, printNodes, tokenizeLinks } from './api'; -import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, Solidity } from './lib/compile'; const solcCompilers = { v5: solcv5, @@ -29,7 +29,10 @@ export type BuildOptions = typeof defaultBuildOptions; * - Outputs the ABI files into bin to be later included in the distribution (for Vent and other ABI-consuming services) */ export async function build(srcPathOrFiles: string | string[], opts?: Partial): Promise { - const { solcVersion, binPath, basePath, burrowImportPath, abiExt } = { ...defaultBuildOptions, ...opts }; + const { solcVersion, binPath, basePath, burrowImportPath, abiExt } = { + ...defaultBuildOptions, + ...opts, + }; const basePathPrefix = new RegExp( '^' + path.resolve(basePath ?? (typeof srcPathOrFiles === 'string' ? srcPathOrFiles : process.cwd())), ); diff --git a/js/src/solts/lib/abi.ts b/js/src/solts/lib/abi.ts deleted file mode 100644 index c3a82cd75..000000000 --- a/js/src/solts/lib/abi.ts +++ /dev/null @@ -1,31 +0,0 @@ -export namespace ABI { - export type Func = { - type: 'function' | 'constructor' | 'fallback'; - name: string; - inputs?: Array; - outputs?: Array; - stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'; - payable?: boolean; - constant?: boolean; - }; - - export type Event = { - type: 'event'; - name: string; - inputs: Array; - anonymous: boolean; - }; - - export type FunctionInput = { - name: string; - type: string; - components?: FunctionInput[]; - internalType?: string; - }; - - export type FunctionOutput = FunctionInput; - export type EventInput = FunctionInput & { indexed?: boolean }; - - export type FunctionIO = FunctionInput & FunctionOutput; - export type FunctionOrEvent = Func | Event; -} diff --git a/js/src/solts/lib/compile.ts b/js/src/solts/lib/compile.ts deleted file mode 100644 index a91fab81c..000000000 --- a/js/src/solts/lib/compile.ts +++ /dev/null @@ -1,114 +0,0 @@ -import * as fs from 'fs'; -import { ResolvedImport } from 'solc'; -import { ABI } from './abi'; -import InputDescription = Solidity.InputDescription; - -export namespace Solidity { - export type Bytecode = { - linkReferences: any; - object: string; - opcodes: string; - sourceMap: string; - }; - - export type Contract = { - assembly: any; - evm: { - bytecode: Bytecode; - deployedBytecode: Bytecode; - }; - functionHashes: any; - gasEstimates: any; - abi: ABI.FunctionOrEvent[]; - opcodes: string; - runtimeBytecode: string; - srcmap: string; - srcmapRuntime: string; - }; - - export type Source = { - AST: any; - }; - - export type InputDescription = { - language: string; - sources: Record; - settings: { - outputSelection: Record>>; - }; - }; - - type Error = { - sourceLocation?: { - file: string; - start: number; - end: number; - }; - type: string; - component: string; - severity: 'error' | 'warning'; - message: string; - formattedMessage?: string; - }; - - export type OutputDescription = { - contracts: Record>; - errors: Array; - sourceList: Array; - sources: Record; - }; -} - -function NewInputDescription(): Solidity.InputDescription { - return { - language: 'Solidity', - sources: {}, - settings: { outputSelection: {} }, - }; -} - -export function encodeInput(obj: Solidity.InputDescription): string { - return JSON.stringify(obj); -} - -export function decodeOutput(str: string): Solidity.OutputDescription { - return JSON.parse(str); -} - -export function inputDescriptionFromFiles(names: string[]): InputDescription { - const desc = NewInputDescription(); - names.map((name) => { - desc.sources[name] = { content: fs.readFileSync(name).toString() }; - desc.settings.outputSelection[name] = {}; - desc.settings.outputSelection[name]['*'] = ['*']; - }); - return desc; -} - -export function importLocal(path: string): ResolvedImport { - return { - contents: fs.readFileSync(path).toString(), - }; -} - -export function tokenizeLinks(links: Record>): string[] { - const libraries: Array = []; - for (const file in links) { - for (const library in links[file]) { - libraries.push(file + ':' + library); - } - } - return libraries; -} - -export function linker(bytecode: string, links: { name: string; address: string }[]): string { - for (const { name, address } of links) { - const paddedAddress = address + Array(40 - address.length + 1).join('0'); - const truncated = name.slice(0, 36); - const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__'; - while (bytecode.indexOf(label) >= 0) { - bytecode = bytecode.replace(label, paddedAddress); - } - } - return bytecode; -} diff --git a/js/src/solts/lib/deployer.ts b/js/src/solts/lib/deployer.ts index 39d1f4df7..e690e6af9 100644 --- a/js/src/solts/lib/deployer.ts +++ b/js/src/solts/lib/deployer.ts @@ -1,10 +1,11 @@ import ts, { factory, FunctionDeclaration, SyntaxKind } from 'typescript'; -import { ABI } from './abi'; +import { ABI } from '../../contracts/abi'; import { contractFunctionName, contractTypeName } from './contract'; import { callEncodeDeploy, Provider } from './provider'; import { getRealType, sha3, tokenizeString } from './solidity'; import { AsyncToken, + BooleanType, BufferType, createCall, createParameter, @@ -12,6 +13,7 @@ import { declareConstant, ExportToken, hexToBuffer, + hexToKeccak256, linkerName, PromiseType, prop, @@ -22,6 +24,7 @@ export const deployName = factory.createIdentifier('deploy'); export const deployContractName = factory.createIdentifier('deployContract'); export const bytecodeName = factory.createIdentifier('bytecode'); export const deployedBytecodeName = factory.createIdentifier('deployedBytecode'); +export const withContractMetaName = factory.createIdentifier('withContractMeta'); // Variable names const linkedBytecodeName = factory.createIdentifier('linkedBytecode'); @@ -76,17 +79,15 @@ export function generateDeployFunction( ), ); - const deployFn = provider.methods.deploy.call( - clientName, - dataName, - contractNames.map((n) => { - const deployedBytecode = prop(n, deployedBytecodeName); - return { - abi: prop(n, abiName), - codeHash: hexToBuffer(links.length ? createCall(linkerName, [deployedBytecode, linksName]) : deployedBytecode), - }; - }), - ); + const contractMeta = contractNames.map((n) => { + const deployedBytecode = prop(n, deployedBytecodeName); + return { + abi: prop(n, abiName), + codeHash: hexToKeccak256(links.length ? createCall(linkerName, [deployedBytecode, linksName]) : deployedBytecode), + }; + }); + + const deployFn = provider.methods.deploy.call(clientName, dataName, withContractMetaName, contractMeta); statements.push(factory.createReturnStatement(deployFn)); @@ -135,5 +136,6 @@ function deployParameters(abi: ABI.Func | undefined, links: string[], provider: createParameter(clientName, provider.type()), ...links.map((link) => createParameter(factory.createIdentifier(tokenizeString(link)), StringType)), ...parameters, + createParameter(withContractMetaName, BooleanType, factory.createFalse()), ]; } diff --git a/js/src/solts/lib/provider.ts b/js/src/solts/lib/provider.ts index 1edd54857..f877b4f58 100644 --- a/js/src/solts/lib/provider.ts +++ b/js/src/solts/lib/provider.ts @@ -2,6 +2,7 @@ import ts, { factory } from 'typescript'; import { BoundsType, CallbackReturnType } from './events'; import { AddressType, + ColonToken, ContractCodecType, createCall, createCallbackType, @@ -13,8 +14,10 @@ import { ExportToken, MaybeUint8ArrayType, Method, + QuestionToken, StringType, Uint8ArrayType, + Undefined, UnknownType, } from './syntax'; @@ -52,24 +55,27 @@ class Deploy extends Method { call( exp: ts.Expression, data: ts.Expression, - contractMeta?: { abi: ts.Expression; codeHash: ts.Expression }[], + withContractMeta: ts.Expression, + contractMeta: { abi: ts.Expression; codeHash: ts.Expression }[], ): ts.CallExpression { - return createCall( - factory.createPropertyAccessExpression(exp, this.id), - contractMeta - ? [ - data, - factory.createArrayLiteralExpression( - contractMeta.map(({ abi, codeHash }) => - factory.createObjectLiteralExpression([ - factory.createPropertyAssignment(this.abiName, abi), - factory.createPropertyAssignment(this.codeHashName, codeHash), - ]), - ), - ), - ] - : [data], + const contractMetaLiteral = factory.createArrayLiteralExpression( + contractMeta.map(({ abi, codeHash }) => + factory.createObjectLiteralExpression([ + factory.createPropertyAssignment(this.abiName, abi), + factory.createPropertyAssignment(this.codeHashName, codeHash), + ]), + ), ); + return createCall(factory.createPropertyAccessExpression(exp, this.id), [ + data, + // TODO: Contracts that may create contracts need to be deployed with contract meta for all contracts they create + // unfortunately we have no good way to determine from solc output which contracts a contract may create, so + // short of pushing all contract meta to every contract in a family of contracts we cannot safely deploy with meta + // in the general case this Burrow throws on creating a new contract if a) the parent has meta, and b) the child + // meta cannot be found. The solution is to delocalise the contract storage from the parent contract and have + // a global registry of metadata to query against when creating a contract + factory.createConditionalExpression(withContractMeta, QuestionToken, contractMetaLiteral, ColonToken, Undefined), + ]); } } diff --git a/js/src/solts/lib/solidity.test.ts b/js/src/solts/lib/solidity.test.ts index 009b35526..d966b2634 100644 --- a/js/src/solts/lib/solidity.test.ts +++ b/js/src/solts/lib/solidity.test.ts @@ -1,5 +1,5 @@ import assert from 'assert'; -import { ABI } from './abi'; +import { ABI } from '../../contracts/abi'; import { getSize, nameFromABI, sha3, tokenizeString } from './solidity'; describe('abi helpers', function () { diff --git a/js/src/solts/lib/solidity.ts b/js/src/solts/lib/solidity.ts index c0bac89c7..bf21e3e6c 100644 --- a/js/src/solts/lib/solidity.ts +++ b/js/src/solts/lib/solidity.ts @@ -1,6 +1,6 @@ import { Keccak } from 'sha3'; import ts, { factory, TypeNode } from 'typescript'; -import { ABI } from './abi'; +import { ABI } from '../../contracts/abi'; import { asArray, asRefNode, asTuple, BooleanType, BufferType, NumberType, StringType, VoidType } from './syntax'; export function sha3(str: string): string { diff --git a/js/src/solts/lib/syntax.ts b/js/src/solts/lib/syntax.ts index 18c113e8a..c4d376329 100644 --- a/js/src/solts/lib/syntax.ts +++ b/js/src/solts/lib/syntax.ts @@ -21,6 +21,7 @@ export const CancelStreamSignal = factory.createIdentifier('CancelStreamSignal') export const ReturnType = factory.createIdentifier('ReturnType'); export const listenerForName = factory.createIdentifier('listenerFor'); export const linkerName = factory.createIdentifier('linker'); +export const keccakName = factory.createIdentifier('Keccak'); export const TType = factory.createTypeReferenceNode('T'); export const AddressType = factory.createTypeReferenceNode(Address); @@ -80,6 +81,20 @@ export function hexToBuffer(arg: ts.Expression): ts.CallExpression { return createCall(prop(BufferType, 'from'), [arg, factory.createStringLiteral('hex')]); } +export function hexToKeccak256(str: ts.Expression): ts.CallExpression { + // new Keccak(256).update(str).digest('binary'); + return createCall( + prop( + createCall( + prop(factory.createNewExpression(keccakName, undefined, [factory.createNumericLiteral('256')]), 'update'), + [str, factory.createStringLiteral('hex')], + ), + 'digest', + ), + [factory.createStringLiteral('binary')], + ); +} + export function arrowFuncT( params: ts.ParameterDeclaration[], constraint: TypeNode | undefined, @@ -236,12 +251,13 @@ export function importBurrow(burrowImportPath: string): ts.ImportDeclaration { return importFrom( burrowImportPath, Address, - ContractCodec, CancelStreamSignal, + ContractCodec, Event, + linkerName, listenerForName, Result, - linkerName, + keccakName, ); } diff --git a/js/src/solts/sol/Addition.abi.ts b/js/src/solts/sol/Addition.abi.ts index 017c506f9..6a2d69b01 100644 --- a/js/src/solts/sol/Addition.abi.ts +++ b/js/src/solts/sol/Addition.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Addition { export const bytecode = '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a5f3c23b14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600081830190509291505056fea265627a7a72315820bf9f1b3176bb0e5383e0dbeabc3258cbe895f39124127f38452c4ce85df9672964736f6c63430005110032'; export const deployedBytecode = - '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a5f3c23b14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600081830190509291505056fea265627a7a72315820bf9f1b3176bb0e5383e0dbeabc3258cbe895f39124127f38452c4ce85df9672964736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '6080604052348015600f57600080fd5b506004361060285760003560e01c8063a5f3c23b14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600081830190509291505056fea265627a7a72315820bf9f1b3176bb0e5383e0dbeabc3258cbe895f39124127f38452c4ce85df9672964736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [{ abi: Addition.abi, codeHash: Buffer.from(Addition.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Addition.abi, codeHash: new Keccak(256).update(Addition.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/solts/sol/Contains.abi.ts b/js/src/solts/sol/Contains.abi.ts index 3d09d8408..1e3dd32a5 100644 --- a/js/src/solts/sol/Contains.abi.ts +++ b/js/src/solts/sol/Contains.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Contains { export const bytecode = '608060405234801561001057600080fd5b50610304806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80633da80d661461003b578063b32b8e2c1461012b575b600080fd5b6101116004803603604081101561005157600080fd5b810190808035906020019064010000000081111561006e57600080fd5b82018360208201111561008057600080fd5b803590602001918460208302840111640100000000831117156100a257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610205565b604051808215151515815260200191505060405180910390f35b6101eb6004803603604081101561014157600080fd5b810190808035906020019064010000000081111561015e57600080fd5b82018360208201111561017057600080fd5b8035906020019184602083028401116401000000008311171561019257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610280565b604051808215151515815260200191505060405180910390f35b600080600090505b8351811015610274578273ffffffffffffffffffffffffffffffffffffffff1684828151811061023957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561026757600191505061027a565b808060010191505061020d565b50600090505b92915050565b600080600090505b83518110156102c3578284828151811061029e57fe5b602002602001015114156102b65760019150506102c9565b8080600101915050610288565b50600090505b9291505056fea265627a7a7231582032d6f06ddf667cc291458c6ed27a81fe8ef6fa213f3cf25c0fef50500bc05f2264736f6c63430005110032'; export const deployedBytecode = - '608060405234801561001057600080fd5b50610304806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80633da80d661461003b578063b32b8e2c1461012b575b600080fd5b6101116004803603604081101561005157600080fd5b810190808035906020019064010000000081111561006e57600080fd5b82018360208201111561008057600080fd5b803590602001918460208302840111640100000000831117156100a257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610205565b604051808215151515815260200191505060405180910390f35b6101eb6004803603604081101561014157600080fd5b810190808035906020019064010000000081111561015e57600080fd5b82018360208201111561017057600080fd5b8035906020019184602083028401116401000000008311171561019257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610280565b604051808215151515815260200191505060405180910390f35b600080600090505b8351811015610274578273ffffffffffffffffffffffffffffffffffffffff1684828151811061023957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561026757600191505061027a565b808060010191505061020d565b50600090505b92915050565b600080600090505b83518110156102c3578284828151811061029e57fe5b602002602001015114156102b65760019150506102c9565b8080600101915050610288565b50600090505b9291505056fea265627a7a7231582032d6f06ddf667cc291458c6ed27a81fe8ef6fa213f3cf25c0fef50500bc05f2264736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '608060405234801561001057600080fd5b50600436106100365760003560e01c80633da80d661461003b578063b32b8e2c1461012b575b600080fd5b6101116004803603604081101561005157600080fd5b810190808035906020019064010000000081111561006e57600080fd5b82018360208201111561008057600080fd5b803590602001918460208302840111640100000000831117156100a257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610205565b604051808215151515815260200191505060405180910390f35b6101eb6004803603604081101561014157600080fd5b810190808035906020019064010000000081111561015e57600080fd5b82018360208201111561017057600080fd5b8035906020019184602083028401116401000000008311171561019257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610280565b604051808215151515815260200191505060405180910390f35b600080600090505b8351811015610274578273ffffffffffffffffffffffffffffffffffffffff1684828151811061023957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561026757600191505061027a565b808060010191505061020d565b50600090505b92915050565b600080600090505b83518110156102c3578284828151811061029e57fe5b602002602001015114156102b65760019150506102c9565b8080600101915050610288565b50600090505b9291505056fea265627a7a7231582032d6f06ddf667cc291458c6ed27a81fe8ef6fa213f3cf25c0fef50500bc05f2264736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [{ abi: Contains.abi, codeHash: Buffer.from(Contains.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Contains.abi, codeHash: new Keccak(256).update(Contains.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/solts/sol/Creator.abi.ts b/js/src/solts/sol/Creator.abi.ts index 17e122f03..60d545df4 100644 --- a/js/src/solts/sol/Creator.abi.ts +++ b/js/src/solts/sol/Creator.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,17 +37,22 @@ export namespace Creator { export const bytecode = '608060405234801561001057600080fd5b50610504806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b6a46b3b14610030575b600080fd5b6100a76004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b90919293919293905050506100e9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600082826040516100f990610153565b80806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509350505050604051809103906000f08015801561014a573d6000803e3d6000fd5b50905092915050565b61036f806101618339019056fe60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032a265627a7a72315820cf64c1da8de972eb1f9f2b5e6799c7af3385d3ee9b08b51fb8d7b060fa7eb4e864736f6c63430005110032'; export const deployedBytecode = - '608060405234801561001057600080fd5b50610504806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b6a46b3b14610030575b600080fd5b6100a76004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b90919293919293905050506100e9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600082826040516100f990610153565b80806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509350505050604051809103906000f08015801561014a573d6000803e3d6000fd5b50905092915050565b61036f806101618339019056fe60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032a265627a7a72315820cf64c1da8de972eb1f9f2b5e6799c7af3385d3ee9b08b51fb8d7b060fa7eb4e864736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b6a46b3b14610030575b600080fd5b6100a76004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b90919293919293905050506100e9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600082826040516100f990610153565b80806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509350505050604051809103906000f08015801561014a573d6000803e3d6000fd5b50905092915050565b61036f806101618339019056fe60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032a265627a7a72315820cf64c1da8de972eb1f9f2b5e6799c7af3385d3ee9b08b51fb8d7b060fa7eb4e864736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [ - { abi: Creator.abi, codeHash: Buffer.from(Creator.deployedBytecode, 'hex') }, - { abi: Proxy.abi, codeHash: Buffer.from(Proxy.deployedBytecode, 'hex') }, - ]); + return client.deploy( + data, + withContractMeta + ? [ + { abi: Creator.abi, codeHash: new Keccak(256).update(Creator.deployedBytecode, 'hex').digest('binary') }, + { abi: Proxy.abi, codeHash: new Keccak(256).update(Proxy.deployedBytecode, 'hex').digest('binary') }, + ] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } export type Contract = ReturnType; @@ -97,17 +102,22 @@ export namespace Proxy { export const bytecode = '60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032'; export const deployedBytecode = - '60806040526040518060200160405280600081525060009080519060200190610029929190610131565b5034801561003657600080fd5b5060405161036f38038061036f8339818101604052602081101561005957600080fd5b810190808051604051939291908464010000000082111561007957600080fd5b8382019150602082018581111561008f57600080fd5b82518660018202830111640100000000821117156100ac57600080fd5b8083526020830192505050908051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b50604052505050806000908051906020019061012a929190610131565b50506101d6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017257805160ff19168380011785556101a0565b828001600101855582156101a0579182015b8281111561019f578251825591602001919060010190610184565b5b5090506101ad91906101b1565b5090565b6101d391905b808211156101cf5760008160009055506001016101b7565b5090565b90565b61018a806101e56000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032'; - export function deploy(client: Provider, _name: string): Promise { + '608060405234801561001057600080fd5b506004361061002b5760003560e01c80636d4ce63c14610030575b600080fd5b6100386100b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561007857808201518184015260208101905061005d565b50505050905090810190601f1680156100a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561014b5780601f106101205761010080835404028352916020019161014b565b820191906000526020600020905b81548152906001019060200180831161012e57829003601f168201915b505050505090509056fea265627a7a723158206774e6bd107164a63f42ab8950431a6d5e09eed4da0c066049dc9db7278bbeb364736f6c63430005110032'; + export function deploy(client: Provider, _name: string, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy(_name)]); - return client.deploy(data, [ - { abi: Creator.abi, codeHash: Buffer.from(Creator.deployedBytecode, 'hex') }, - { abi: Proxy.abi, codeHash: Buffer.from(Proxy.deployedBytecode, 'hex') }, - ]); + return client.deploy( + data, + withContractMeta + ? [ + { abi: Creator.abi, codeHash: new Keccak(256).update(Creator.deployedBytecode, 'hex').digest('binary') }, + { abi: Proxy.abi, codeHash: new Keccak(256).update(Proxy.deployedBytecode, 'hex').digest('binary') }, + ] + : undefined, + ); } - export async function deployContract(client: Provider, _name: string): Promise { - const address = await deploy(client, _name); + export async function deployContract(client: Provider, _name: string, withContractMeta = false): Promise { + const address = await deploy(client, _name, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/solts/sol/Eventer.abi.ts b/js/src/solts/sol/Eventer.abi.ts index 3d3c370d0..326acc1a2 100644 --- a/js/src/solts/sol/Eventer.abi.ts +++ b/js/src/solts/sol/Eventer.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event, listenerFor } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak, listenerFor } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Eventer { export const bytecode = '6080604052348015600f57600080fd5b506102b58061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638f970df014610030575b600080fd5b61003861003a565b005b607b7f6a35688e78094e86ac7dd4593423fa89415105dc68a0766b27106861ef4102146040518080602001806020018381038352600d8152602001807f53616e74612045756c61726961000000000000000000000000000000000000008152506020018381038252600a8152602001807f53616e74204a75616d65000000000000000000000000000000000000000000008152506020019250505060405180910390a27f696e74657276616c3200000000000000000000000000000000000000000000007f6576656e743100000000000000000000000000000000000000000000000000007f5f20df97ee573ab8b43581cf3ff905f3507ad2329b7efe6f92e802b4fad031c17359c99d4ebf520619ee7f806f11d90a9cac02ce06336004604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001848103845260068152602001807f64696e696e670000000000000000000000000000000000000000000000000000815250602001848103835260098152602001807f627265616b666173740000000000000000000000000000000000000000000000815250602001848103825260178152602001807f6261636f6e2c6265616e732c656767732c746f6d61746f000000000000000000815250602001965050505050505060405180910390a356fea265627a7a72315820a6cd65593c9a8f5ed08f75519d9dd5664bcdf3a4bb67c8f507e1a69ed348f04f64736f6c63430005110032'; export const deployedBytecode = - '6080604052348015600f57600080fd5b506102b58061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638f970df014610030575b600080fd5b61003861003a565b005b607b7f6a35688e78094e86ac7dd4593423fa89415105dc68a0766b27106861ef4102146040518080602001806020018381038352600d8152602001807f53616e74612045756c61726961000000000000000000000000000000000000008152506020018381038252600a8152602001807f53616e74204a75616d65000000000000000000000000000000000000000000008152506020019250505060405180910390a27f696e74657276616c3200000000000000000000000000000000000000000000007f6576656e743100000000000000000000000000000000000000000000000000007f5f20df97ee573ab8b43581cf3ff905f3507ad2329b7efe6f92e802b4fad031c17359c99d4ebf520619ee7f806f11d90a9cac02ce06336004604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001848103845260068152602001807f64696e696e670000000000000000000000000000000000000000000000000000815250602001848103835260098152602001807f627265616b666173740000000000000000000000000000000000000000000000815250602001848103825260178152602001807f6261636f6e2c6265616e732c656767732c746f6d61746f000000000000000000815250602001965050505050505060405180910390a356fea265627a7a72315820a6cd65593c9a8f5ed08f75519d9dd5664bcdf3a4bb67c8f507e1a69ed348f04f64736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '608060405234801561001057600080fd5b506004361061002b5760003560e01c80638f970df014610030575b600080fd5b61003861003a565b005b607b7f6a35688e78094e86ac7dd4593423fa89415105dc68a0766b27106861ef4102146040518080602001806020018381038352600d8152602001807f53616e74612045756c61726961000000000000000000000000000000000000008152506020018381038252600a8152602001807f53616e74204a75616d65000000000000000000000000000000000000000000008152506020019250505060405180910390a27f696e74657276616c3200000000000000000000000000000000000000000000007f6576656e743100000000000000000000000000000000000000000000000000007f5f20df97ee573ab8b43581cf3ff905f3507ad2329b7efe6f92e802b4fad031c17359c99d4ebf520619ee7f806f11d90a9cac02ce06336004604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001848103845260068152602001807f64696e696e670000000000000000000000000000000000000000000000000000815250602001848103835260098152602001807f627265616b666173740000000000000000000000000000000000000000000000815250602001848103825260178152602001807f6261636f6e2c6265616e732c656767732c746f6d61746f000000000000000000815250602001965050505050505060405180910390a356fea265627a7a72315820a6cd65593c9a8f5ed08f75519d9dd5664bcdf3a4bb67c8f507e1a69ed348f04f64736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [{ abi: Eventer.abi, codeHash: Buffer.from(Eventer.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Eventer.abi, codeHash: new Keccak(256).update(Eventer.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } type EventRegistry = typeof events; diff --git a/js/src/solts/sol/MultipleReturns.abi.ts b/js/src/solts/sol/MultipleReturns.abi.ts index 3f02e5be3..4b94c0277 100644 --- a/js/src/solts/sol/MultipleReturns.abi.ts +++ b/js/src/solts/sol/MultipleReturns.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Multiple { export const bytecode = '6080604052348015600f57600080fd5b5060ab8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80636d4ce63c14602d575b600080fd5b60336057565b60405180848152602001838152602001828152602001935050505060405180910390f35b600080600060016002600382925081915080905092509250925090919256fea265627a7a72315820db13aa50f1e1ad94cdc8fb2b158b105d0d0812d53d9851ed8a9bfa5447e3c17864736f6c63430005110032'; export const deployedBytecode = - '6080604052348015600f57600080fd5b5060ab8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80636d4ce63c14602d575b600080fd5b60336057565b60405180848152602001838152602001828152602001935050505060405180910390f35b600080600060016002600382925081915080905092509250925090919256fea265627a7a72315820db13aa50f1e1ad94cdc8fb2b158b105d0d0812d53d9851ed8a9bfa5447e3c17864736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '6080604052348015600f57600080fd5b506004361060285760003560e01c80636d4ce63c14602d575b600080fd5b60336057565b60405180848152602001838152602001828152602001935050505060405180910390f35b600080600060016002600382925081915080905092509250925090919256fea265627a7a72315820db13aa50f1e1ad94cdc8fb2b158b105d0d0812d53d9851ed8a9bfa5447e3c17864736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [{ abi: Multiple.abi, codeHash: Buffer.from(Multiple.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Multiple.abi, codeHash: new Keccak(256).update(Multiple.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/solts/sol/Unnamed.abi.ts b/js/src/solts/sol/Unnamed.abi.ts index 780d1cfb6..e00893a6a 100644 --- a/js/src/solts/sol/Unnamed.abi.ts +++ b/js/src/solts/sol/Unnamed.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Unnamed { export const bytecode = '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806304c402f414602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600082830190509291505056fea265627a7a72315820c692aa5593a39c498f58c4a0221aa0b6ca567436b02c62f90b9214af7b7c390064736f6c63430005110032'; export const deployedBytecode = - '608060405234801561001057600080fd5b5060b88061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806304c402f414602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600082830190509291505056fea265627a7a72315820c692aa5593a39c498f58c4a0221aa0b6ca567436b02c62f90b9214af7b7c390064736f6c63430005110032'; - export function deploy(client: Provider): Promise { + '6080604052348015600f57600080fd5b506004361060285760003560e01c806304c402f414602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506076565b6040518082815260200191505060405180910390f35b600082830190509291505056fea265627a7a72315820c692aa5593a39c498f58c4a0221aa0b6ca567436b02c62f90b9214af7b7c390064736f6c63430005110032'; + export function deploy(client: Provider, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy()]); - return client.deploy(data, [{ abi: Unnamed.abi, codeHash: Buffer.from(Unnamed.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Unnamed.abi, codeHash: new Keccak(256).update(Unnamed.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider): Promise { - const address = await deploy(client); + export async function deployContract(client: Provider, withContractMeta = false): Promise { + const address = await deploy(client, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/solts/sol/storage/Storage.abi.ts b/js/src/solts/sol/storage/Storage.abi.ts index 26fac97bb..4842eb10d 100644 --- a/js/src/solts/sol/storage/Storage.abi.ts +++ b/js/src/solts/sol/storage/Storage.abi.ts @@ -1,5 +1,5 @@ //Code generated by solts. DO NOT EDIT. -import { Address, CancelStreamSignal, ContractCodec, Event } from '../../../index'; +import { Address, CancelStreamSignal, ContractCodec, Event, Keccak } from '../../../index'; interface Provider { deploy( data: string | Uint8Array, @@ -37,14 +37,19 @@ export namespace Storage { export const bytecode = '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; export const deployedBytecode = - '608060405234801561001057600080fd5b506040516101203803806101208339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060c68061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; - export function deploy(client: Provider, x: number): Promise { + '6080604052348015600f57600080fd5b506004361060325760003560e01c80636d4ce63c146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506087565b005b60008054905090565b806000819055505056fea265627a7a72315820df6fea8cbd336a45734df49c645eb1a45497cd5babf1e4c20c340998d6d9cb6264736f6c63430005110032'; + export function deploy(client: Provider, x: number, withContractMeta = false): Promise { const codec = client.contractCodec(abi); const data = Buffer.concat([Buffer.from(bytecode, 'hex'), codec.encodeDeploy(x)]); - return client.deploy(data, [{ abi: Storage.abi, codeHash: Buffer.from(Storage.deployedBytecode, 'hex') }]); + return client.deploy( + data, + withContractMeta + ? [{ abi: Storage.abi, codeHash: new Keccak(256).update(Storage.deployedBytecode, 'hex').digest('binary') }] + : undefined, + ); } - export async function deployContract(client: Provider, x: number): Promise { - const address = await deploy(client, x); + export async function deployContract(client: Provider, x: number, withContractMeta = false): Promise { + const address = await deploy(client, x, withContractMeta); return contract(client, address); } export type Contract = ReturnType; diff --git a/js/src/test/solts.test.ts b/js/src/test/solts.test.ts index 71d7bf20c..7bb215cdb 100644 --- a/js/src/test/solts.test.ts +++ b/js/src/test/solts.test.ts @@ -6,14 +6,13 @@ import { burrow } from './test'; describe('solts', () => { it('can deploy and call from codegen', async () => { - const address = await Addition.deploy(burrow); - const add = Addition.contract(burrow, address); - const { sum } = await add.functions.add(2342, 23432); + const adder = await Addition.deployContract(burrow, true); + const { sum } = await adder.functions.add(2342, 23432); assert.strictEqual(sum, 25774); }); it('can receive events', async () => { - const eventer = Eventer.contract(burrow, await Eventer.deploy(burrow)); + const eventer = await Eventer.deployContract(burrow, true); await eventer.functions.announce(); await eventer.functions.announce(); await eventer.functions.announce(); @@ -25,7 +24,7 @@ describe('solts', () => { }); it('can listen to multiple events', async () => { - const eventer = Eventer.contract(burrow, await Eventer.deploy(burrow)); + const eventer = await Eventer.deployContract(burrow, true); await eventer.functions.announce(); await eventer.functions.announce(); const listener = eventer.listenerFor(['MonoRampage', 'Init']); From df51a82e14b60a905dec3dc26ce9d654e44b3b8e Mon Sep 17 00:00:00 2001 From: Silas Davis Date: Thu, 27 May 2021 15:21:28 +0200 Subject: [PATCH 3/4] Just use @ethersproject/abi Signed-off-by: Silas Davis --- js/package.json | 4 +- js/src/client.ts | 2 +- js/src/codec.ts | 2 +- js/src/contracts/call.ts | 4 +- js/src/contracts/contract.ts | 10 +- js/src/contracts/event.ts | 2 +- js/src/solts/lib/deployer.ts | 1 - js/src/test/bn.test.ts | 14 +- js/src/test/event-listen.test.ts | 2 +- js/yarn.lock | 263 +++---------------------------- 10 files changed, 35 insertions(+), 269 deletions(-) diff --git a/js/package.json b/js/package.json index d8d68f28a..b0b579537 100644 --- a/js/package.json +++ b/js/package.json @@ -1,5 +1,5 @@ { - "version": "0.33.1-dev.4b4d42399", + "version": "0.0.0", "name": "@hyperledger/burrow", "description": "TypeScript library that calls a Hyperledger Burrow server over GRPC.", "main": "./dist/index.js", @@ -21,7 +21,7 @@ }, "dependencies": { "@grpc/grpc-js": "^1.3.0", - "ethers": "^5.2.0", + "@ethersproject/abi": "^5.2.0", "google-protobuf": "^3.15.8", "sha3": "^2.1.4", "solc_v5": "npm:solc@^0.5.17", diff --git a/js/src/client.ts b/js/src/client.ts index bac20accc..5a12efc1a 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -1,5 +1,5 @@ +import { Interface } from '@ethersproject/abi'; import * as grpc from '@grpc/grpc-js'; -import { Interface } from 'ethers/lib/utils'; import { TxExecution } from '../proto/exec_pb'; import { CallTx } from '../proto/payload_pb'; import { ExecutionEventsClient, IExecutionEventsClient } from '../proto/rpcevents_grpc_pb'; diff --git a/js/src/codec.ts b/js/src/codec.ts index bd3ef8726..7d52e7c50 100644 --- a/js/src/codec.ts +++ b/js/src/codec.ts @@ -1,4 +1,4 @@ -import { EventFragment, Fragment, FunctionFragment, Interface } from 'ethers/lib/utils'; +import { EventFragment, Fragment, FunctionFragment, Interface } from '@ethersproject/abi'; import { postDecodeResult, preEncodeResult, prefixedHexString, toBuffer } from './convert'; export type ContractCodec = { diff --git a/js/src/contracts/call.ts b/js/src/contracts/call.ts index 2acf39982..27c7c426f 100644 --- a/js/src/contracts/call.ts +++ b/js/src/contracts/call.ts @@ -1,7 +1,7 @@ +import { AbiCoder, FunctionFragment, Interface, Result as DecodedResult } from '@ethersproject/abi'; import * as grpc from '@grpc/grpc-js'; import { Metadata } from '@grpc/grpc-js'; import { callErrorFromStatus } from '@grpc/grpc-js/build/src/call'; -import { AbiCoder, FunctionFragment, Interface, Result as DecodedResult } from 'ethers/lib/utils'; import { Keccak } from 'sha3'; import { SolidityFunction } from 'solc'; import { Result } from '../../proto/exec_pb'; @@ -14,8 +14,6 @@ import { CallOptions } from './contract'; export const DEFAULT_GAS = 1111111111; -export { Result as DecodeResult } from 'ethers/lib/utils'; - const WasmMagic = Buffer.from('\0asm'); const coder = new AbiCoder(); diff --git a/js/src/contracts/contract.ts b/js/src/contracts/contract.ts index 6446be1f1..c2cc33607 100644 --- a/js/src/contracts/contract.ts +++ b/js/src/contracts/contract.ts @@ -1,10 +1,10 @@ -import { EventFragment, Fragment, FunctionFragment, Interface, LogDescription } from 'ethers/lib/utils'; +import { EventFragment, Fragment, FunctionFragment, Interface, LogDescription } from '@ethersproject/abi'; import { CallTx, ContractMeta } from '../../proto/payload_pb'; import { Client } from '../client'; -import { preEncodeResult, toBuffer } from '../convert'; -import { EventStream } from "../events"; +import { preEncodeResult, Result, toBuffer } from '../convert'; +import { EventStream } from '../events'; import { Address } from './abi'; -import { call, callFunction, CallResult, DecodeResult, getContractMetaFromBytecode, makeCallTx } from './call'; +import { call, callFunction, CallResult, getContractMetaFromBytecode, makeCallTx } from './call'; import { CompiledContract } from './compile'; import { EventCallback, listen } from './event'; @@ -99,7 +99,7 @@ type ContractFunction = GenericFunction & { at: (address: string) => GenericFunction; atSim: (address: string) => GenericFunction; encode: (...args: unknown[]) => string; - decode: (output: Uint8Array) => DecodeResult; + decode: (output: Uint8Array) => Result; }; export type ContractEvent = ((cb: EventCallback) => EventStream) & { diff --git a/js/src/contracts/event.ts b/js/src/contracts/event.ts index 5bbfb9912..3a3a90065 100644 --- a/js/src/contracts/event.ts +++ b/js/src/contracts/event.ts @@ -1,4 +1,4 @@ -import { EventFragment, FormatTypes, Interface, LogDescription } from 'ethers/lib/utils'; +import { EventFragment, FormatTypes, Interface, LogDescription } from '@ethersproject/abi'; import { Keccak } from 'sha3'; import { Client } from '../client'; import { postDecodeResult, prefixedHexString } from '../convert'; diff --git a/js/src/solts/lib/deployer.ts b/js/src/solts/lib/deployer.ts index e690e6af9..8f2261625 100644 --- a/js/src/solts/lib/deployer.ts +++ b/js/src/solts/lib/deployer.ts @@ -56,7 +56,6 @@ export function generateDeployFunction( ), factory.createPropertyAssignment( 'address', - factory.createIdentifier(tokenizeString(link)), ), ]), diff --git a/js/src/test/bn.test.ts b/js/src/test/bn.test.ts index 2872a62ce..27c4cec77 100644 --- a/js/src/test/bn.test.ts +++ b/js/src/test/bn.test.ts @@ -1,5 +1,4 @@ import * as assert from 'assert'; -import { BigNumber } from 'ethers/lib/ethers'; import { compile } from '../contracts/compile'; import { burrow } from './test'; @@ -21,15 +20,12 @@ describe('BN', function () { const instance = await contract.deploy(burrow); const [number] = await instance.getNumber(); - const expected = BigNumber.from('10000000000000000000'); - assert.ok(expected.eq(number)); + assert.strictEqual(number.toString(), '10000000000000000000'); - await instance.mul(100, -300).then(([number]: any) => { - assert.strictEqual(number, -30000); - }); + const [smallNumber] = await instance.mul(100, -300); + assert.strictEqual(smallNumber, -30000); - await instance.mul(BigNumber.from('18446744073709551616'), 102).then(([number]: any) => { - assert.ok(BigNumber.from('1881567895518374264832').eq(number)); - }); + const [bigNumber] = await instance.mul('18446744073709551616', 102); + assert.strictEqual(bigNumber.toString(), '1881567895518374264832'); }); }); diff --git a/js/src/test/event-listen.test.ts b/js/src/test/event-listen.test.ts index 7f9c4fddc..754886362 100644 --- a/js/src/test/event-listen.test.ts +++ b/js/src/test/event-listen.test.ts @@ -1,5 +1,5 @@ +import { LogDescription } from '@ethersproject/abi'; import * as assert from 'assert'; -import { LogDescription } from 'ethers/lib/utils'; import { compile } from '../contracts/compile'; import { ContractEvent } from '../contracts/contract'; import { burrow } from './test'; diff --git a/js/yarn.lock b/js/yarn.lock index 4df0e4a22..3b9b83923 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -38,7 +38,7 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@ethersproject/abi@5.2.0", "@ethersproject/abi@^5.2.0": +"@ethersproject/abi@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.2.0.tgz#e2ca0b7f7e3b83e4d427ed8b38fdc1c48e2bb00f" integrity sha512-24ExfHa0VbIOUHbB36b6lCVmWkaIVmrd9/m8MICtmSsRKzlugWqUD0B8g0zrRylXNxAOc3V6T4xKJ8jEDSvp3w== @@ -53,7 +53,7 @@ "@ethersproject/properties" "^5.2.0" "@ethersproject/strings" "^5.2.0" -"@ethersproject/abstract-provider@5.2.0", "@ethersproject/abstract-provider@^5.2.0": +"@ethersproject/abstract-provider@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.2.0.tgz#b5c24b162f119b5d241738ded9555186013aa77d" integrity sha512-Xi7Pt+CulRijc/vskBGIaYMEhafKjoNx8y4RNj/dnSpXHXScOJUSTtypqGBUngZddRbcwZGbHwEr6DZoKZwIZA== @@ -66,7 +66,7 @@ "@ethersproject/transactions" "^5.2.0" "@ethersproject/web" "^5.2.0" -"@ethersproject/abstract-signer@5.2.0", "@ethersproject/abstract-signer@^5.2.0": +"@ethersproject/abstract-signer@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.2.0.tgz#8e291fb6558b4190fb3e2fe440a9ffd092a2f459" integrity sha512-JTXzLUrtoxpOEq1ecH86U7tstkEa9POKAGbGBb+gicbjGgzYYkLR4/LD83SX2/JNWvtYyY8t5errt5ehiy1gxQ== @@ -77,7 +77,7 @@ "@ethersproject/logger" "^5.2.0" "@ethersproject/properties" "^5.2.0" -"@ethersproject/address@5.2.0", "@ethersproject/address@^5.2.0": +"@ethersproject/address@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/address/-/address-5.2.0.tgz#afcfa92db84582f54a60a9da361cea4aae450a69" integrity sha512-2YfZlalWefOEfnr/CdqKRrgMgbKidYc+zG4/ilxSdcryZSux3eBU5/5btAT/hSiaHipUjd8UrWK8esCBHU6QNQ== @@ -88,22 +88,14 @@ "@ethersproject/logger" "^5.2.0" "@ethersproject/rlp" "^5.2.0" -"@ethersproject/base64@5.2.0", "@ethersproject/base64@^5.2.0": +"@ethersproject/base64@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.2.0.tgz#e01066d25e5b4e8a051545163bee5def47bd9534" integrity sha512-D9wOvRE90QBI+yFsKMv0hnANiMzf40Xicq9JZbV9XYzh7srImmwmMcReU2wHjOs9FtEgSJo51Tt+sI1dKPYKDg== dependencies: "@ethersproject/bytes" "^5.2.0" -"@ethersproject/basex@5.2.0", "@ethersproject/basex@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.2.0.tgz#f921039e3bdfdab8c5a7ba8b21e81c83fc1ab98b" - integrity sha512-Oo7oX7BmaHLY/8ZsOLI5W0mrSwPBb1iboosN17jfK/4vGAtKjAInDai9I72CzN4NRJaMN5FkFLoPYywGqgGHlg== - dependencies: - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - -"@ethersproject/bignumber@5.2.0", "@ethersproject/bignumber@^5.2.0": +"@ethersproject/bignumber@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.2.0.tgz#03f91ea740c5adb6f8c6a2e91bb4ee5ffaff5503" integrity sha512-+MNQTxwV7GEiA4NH/i51UqQ+lY36O0rxPdV+0qzjFSySiyBlJpLk6aaa4UTvKmYWlI7YKZm6vuyCENeYn7qAOw== @@ -112,37 +104,21 @@ "@ethersproject/logger" "^5.2.0" bn.js "^4.4.0" -"@ethersproject/bytes@5.2.0", "@ethersproject/bytes@^5.2.0": +"@ethersproject/bytes@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.2.0.tgz#327917d5a1600f92fd2a9da4052fa6d974583132" integrity sha512-O1CRpvJDnRTB47vvW8vyqojUZxVookb4LJv/s06TotriU3Xje5WFvlvXJu1yTchtxTz9BbvJw0lFXKpyO6Dn7w== dependencies: "@ethersproject/logger" "^5.2.0" -"@ethersproject/constants@5.2.0", "@ethersproject/constants@^5.2.0": +"@ethersproject/constants@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.2.0.tgz#ccea78ce325f78abfe7358397c03eec570518d92" integrity sha512-p+34YG0KbHS20NGdE+Ic0M6egzd7cDvcfoO9RpaAgyAYm3V5gJVqL7UynS87yCt6O6Nlx6wRFboPiM5ctAr+jA== dependencies: "@ethersproject/bignumber" "^5.2.0" -"@ethersproject/contracts@5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.2.0.tgz#f54e12ec4a323f2bf93c338034839cc6dfc1e347" - integrity sha512-/2fg5tWPG6Z4pciEWpwGji3ggGA5j0ChVNF7NTmkOhvFrrJuWnRpzbvYA00nz8tBDNCOV3cwub5zfWRpgwYEJQ== - dependencies: - "@ethersproject/abi" "^5.2.0" - "@ethersproject/abstract-provider" "^5.2.0" - "@ethersproject/abstract-signer" "^5.2.0" - "@ethersproject/address" "^5.2.0" - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/constants" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/transactions" "^5.2.0" - -"@ethersproject/hash@5.2.0", "@ethersproject/hash@^5.2.0": +"@ethersproject/hash@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.2.0.tgz#2d21901eafc5bdb738b4ad96bee364d371ec724b" integrity sha512-wEGry2HFFSssFiNEkFWMzj1vpdFv4rQlkBp41UfL6J58zKGNycoAWimokITDMk8p7548MKr27h48QfERnNKkRw== @@ -156,44 +132,7 @@ "@ethersproject/properties" "^5.2.0" "@ethersproject/strings" "^5.2.0" -"@ethersproject/hdnode@5.2.0", "@ethersproject/hdnode@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.2.0.tgz#efea9b2f713e55aa5ba23cc62b4aac6d08dcfa53" - integrity sha512-ffq2JrW5AftCmfWZ8DxpdWdw/x06Yn+e9wrWHLpj8If1+w87W4LbTMRUaUmO1DUSN8H8g/6kMUKCTJPVuxsuOw== - dependencies: - "@ethersproject/abstract-signer" "^5.2.0" - "@ethersproject/basex" "^5.2.0" - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/pbkdf2" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/sha2" "^5.2.0" - "@ethersproject/signing-key" "^5.2.0" - "@ethersproject/strings" "^5.2.0" - "@ethersproject/transactions" "^5.2.0" - "@ethersproject/wordlists" "^5.2.0" - -"@ethersproject/json-wallets@5.2.0", "@ethersproject/json-wallets@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.2.0.tgz#d41c7c39e4d236b586e26e2145b09ac49dc56608" - integrity sha512-iWxSm9XiugEtaehYD6w1ImmXeatjcGcrQvffZVJHH1UqV4FckDzrOYnZBRHPQRYlnhNVrGTld1+S0Cu4MB8gdw== - dependencies: - "@ethersproject/abstract-signer" "^5.2.0" - "@ethersproject/address" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/hdnode" "^5.2.0" - "@ethersproject/keccak256" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/pbkdf2" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/random" "^5.2.0" - "@ethersproject/strings" "^5.2.0" - "@ethersproject/transactions" "^5.2.0" - aes-js "3.0.0" - scrypt-js "3.0.1" - -"@ethersproject/keccak256@5.2.0", "@ethersproject/keccak256@^5.2.0": +"@ethersproject/keccak256@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.2.0.tgz#15257862807c23f24a3209d1016d322dca85a464" integrity sha512-LqyxTwVANga5Y3L1yo184czW6b3PibabN8xyE/eOulQLLfXNrHHhwrOTpOhoVRWCICVCD/5SjQfwqTrczjS7jQ== @@ -201,67 +140,26 @@ "@ethersproject/bytes" "^5.2.0" js-sha3 "0.5.7" -"@ethersproject/logger@5.2.0", "@ethersproject/logger@^5.2.0": +"@ethersproject/logger@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.2.0.tgz#accf5348251f78b6c8891af67f42490a4ea4e5ae" integrity sha512-dPZ6/E3YiArgG8dI/spGkaRDry7YZpCntf4gm/c6SI8Mbqiihd7q3nuLN5VvDap/0K3xm3RE1AIUOcUwwh2ezQ== -"@ethersproject/networks@5.2.0", "@ethersproject/networks@^5.2.0": +"@ethersproject/networks@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.2.0.tgz#66c23c6ac477dd703645b2c971ac842d8b8aa524" integrity sha512-q+htMgq7wQoEnjlkdHM6t1sktKxNbEB/F6DQBPNwru7KpQ1R0n0UTIXJB8Rb7lSnvjqcAQ40X3iVqm94NJfYDw== dependencies: "@ethersproject/logger" "^5.2.0" -"@ethersproject/pbkdf2@5.2.0", "@ethersproject/pbkdf2@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.2.0.tgz#8166a7a7238a5fd1d9bb6eb2000fea0f19fdde06" - integrity sha512-qKOoO6yir/qnAgg6OP3U4gRuZ6jl9P7xwggRu/spVfnuaR+wa490AatWLqB1WOXKf6JFjm5yOaT/T5fCICQVdQ== - dependencies: - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/sha2" "^5.2.0" - -"@ethersproject/properties@5.2.0", "@ethersproject/properties@^5.2.0": +"@ethersproject/properties@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.2.0.tgz#8fadf367f7ac7357019d0224aa579b234c545ac1" integrity sha512-oNFkzcoGwXXV+/Yp/MLcDLrL/2i360XIy2YN9yRZJPnIbLwjroFNLiRzLs6PyPw1D09Xs8OcPR1/nHv6xDKE2A== dependencies: "@ethersproject/logger" "^5.2.0" -"@ethersproject/providers@5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.2.0.tgz#b2f3e3b2ca4567c8372543ceb6f3c6e3a2370783" - integrity sha512-Yf/ZUqCrVr+jR0SHA9GuNZs4R1xnV9Ibnh1TlOa0ZzI6o+Qf8bEyE550k9bYI4zk2f9x9baX2RRs6BJY7Jz/WA== - dependencies: - "@ethersproject/abstract-provider" "^5.2.0" - "@ethersproject/abstract-signer" "^5.2.0" - "@ethersproject/address" "^5.2.0" - "@ethersproject/basex" "^5.2.0" - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/constants" "^5.2.0" - "@ethersproject/hash" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/networks" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/random" "^5.2.0" - "@ethersproject/rlp" "^5.2.0" - "@ethersproject/sha2" "^5.2.0" - "@ethersproject/strings" "^5.2.0" - "@ethersproject/transactions" "^5.2.0" - "@ethersproject/web" "^5.2.0" - bech32 "1.1.4" - ws "7.2.3" - -"@ethersproject/random@5.2.0", "@ethersproject/random@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/random/-/random-5.2.0.tgz#1d7e19f17d88eda56228a263063826829e49eebe" - integrity sha512-7Nd3qjivBGlDCGDuGYjPi8CXdtVhRZ7NeyBXoJgtnJBwn1S01ahrbMeOUVmRVWrFM0YiSEPEGo7i4xEu2gRPcg== - dependencies: - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - -"@ethersproject/rlp@5.2.0", "@ethersproject/rlp@^5.2.0": +"@ethersproject/rlp@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.2.0.tgz#bbf605183818a9d96bdc40323d734c79e26cfaca" integrity sha512-RqGsELtPWxcFhOOhSr0lQ2hBNT9tBE08WK0tb6VQbCk97EpqkbgP8yXED9PZlWMiRGchJTw6S+ExzK62XMX/fw== @@ -269,16 +167,7 @@ "@ethersproject/bytes" "^5.2.0" "@ethersproject/logger" "^5.2.0" -"@ethersproject/sha2@5.2.0", "@ethersproject/sha2@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.2.0.tgz#ae18fa6c09c6d99fa2b564dac7276bcd513c1579" - integrity sha512-Wqqptfn0PRO2mvmpktPW1HOLrrCyGtxhVQxO1ZyePoGrcEOurhICOlIvkTogoX4Q928D3Z9XtSSCUbdOJUF2kg== - dependencies: - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - hash.js "1.1.3" - -"@ethersproject/signing-key@5.2.0", "@ethersproject/signing-key@^5.2.0": +"@ethersproject/signing-key@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.2.0.tgz#e8eb10d3c0f4a575479db8d70c62aaf93cd384d1" integrity sha512-9A+dVSkrVAPuhJnWqLWV/NkKi/KB4iagTKEuojfuApUfeIHEhpwQ0Jx3cBimk7qWISSSKdgiAmIqpvVtZ5FEkg== @@ -289,18 +178,7 @@ bn.js "^4.4.0" elliptic "6.5.4" -"@ethersproject/solidity@5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.2.0.tgz#ac902d8f8b11bf58fd37ccf77392178cbbd0b08f" - integrity sha512-EEFlNyEnONW3CWF8UGWPcqxJUHiaIoofO7itGwO/2gvGpnwlL+WUV+GmQoHNxmn+QJeOHspnZuh6NOVrJL6H1g== - dependencies: - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/keccak256" "^5.2.0" - "@ethersproject/sha2" "^5.2.0" - "@ethersproject/strings" "^5.2.0" - -"@ethersproject/strings@5.2.0", "@ethersproject/strings@^5.2.0": +"@ethersproject/strings@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.2.0.tgz#e93d989859587191c3f64bda124d9dedbc3f5a97" integrity sha512-RmjX800wRYKgrzo2ZCSlA8OCQYyq4+M46VgjSVDVyYkLZctBXC3epqlppDA24R7eo856KNbXqezZsMnHT+sSuA== @@ -309,7 +187,7 @@ "@ethersproject/constants" "^5.2.0" "@ethersproject/logger" "^5.2.0" -"@ethersproject/transactions@5.2.0", "@ethersproject/transactions@^5.2.0": +"@ethersproject/transactions@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.2.0.tgz#052e2ef8f8adf7037ebe4cc47aad2a61950e6491" integrity sha512-QrGbhGYsouNNclUp3tWMbckMsuXJTOsA56kT3BuRrLlXJcUH7myIihajXdSfKcyJsvHJPrGZP+U3TKh+sLzZtg== @@ -324,37 +202,7 @@ "@ethersproject/rlp" "^5.2.0" "@ethersproject/signing-key" "^5.2.0" -"@ethersproject/units@5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/units/-/units-5.2.0.tgz#08643e5d4583ecc1a32b103c1157f7ae80803392" - integrity sha512-yrwlyomXcBBHp5oSrLxlLkyHN7dVu3PO7hMbQXc00h388zU4TF3o/PAIUhh+x695wgJ19Fa8YgUWCab3a1RDwA== - dependencies: - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/constants" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - -"@ethersproject/wallet@5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.2.0.tgz#b5a8406676067e34f633536a4cb53c2ff98c0b5c" - integrity sha512-uPdjZwUmAJLo1+ybR/G/rL9pv/NEcCqOsjn6RJFvG7RmwP2kS1v5C+F+ysgx2W/PxBIVT+2IEsfXLbBz8s/6Rg== - dependencies: - "@ethersproject/abstract-provider" "^5.2.0" - "@ethersproject/abstract-signer" "^5.2.0" - "@ethersproject/address" "^5.2.0" - "@ethersproject/bignumber" "^5.2.0" - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/hash" "^5.2.0" - "@ethersproject/hdnode" "^5.2.0" - "@ethersproject/json-wallets" "^5.2.0" - "@ethersproject/keccak256" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/random" "^5.2.0" - "@ethersproject/signing-key" "^5.2.0" - "@ethersproject/transactions" "^5.2.0" - "@ethersproject/wordlists" "^5.2.0" - -"@ethersproject/web@5.2.0", "@ethersproject/web@^5.2.0": +"@ethersproject/web@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@ethersproject/web/-/web-5.2.0.tgz#47d8e152e7fcc07ba0aff4f99fde268fde79dd7a" integrity sha512-mYb9qxGlOBFR2pR6t1CZczuqqX6r8RQGn7MtwrBciMex3cvA/qs+wbmcDgl+/OZY0Pco/ih6WHQRnVi+4sBeCQ== @@ -365,17 +213,6 @@ "@ethersproject/properties" "^5.2.0" "@ethersproject/strings" "^5.2.0" -"@ethersproject/wordlists@5.2.0", "@ethersproject/wordlists@^5.2.0": - version "5.2.0" - resolved "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.2.0.tgz#afcce0229e9ef64af1bf8a1e96571fa441e9f444" - integrity sha512-/7TG5r/Zm8Wd9WhoqQ4QnntgMkIfIZ8QVrpU81muiChLD26XLOgmyiqKPL7K058uYt7UZ0wzbXjxyCYadU3xFQ== - dependencies: - "@ethersproject/bytes" "^5.2.0" - "@ethersproject/hash" "^5.2.0" - "@ethersproject/logger" "^5.2.0" - "@ethersproject/properties" "^5.2.0" - "@ethersproject/strings" "^5.2.0" - "@grpc/grpc-js@^1.3.0": version "1.3.0" resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.3.0.tgz#c6febaaf00ce7f53b5ec52c7cf3e2a4725b82bcb" @@ -514,11 +351,6 @@ acorn@^7.4.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -aes-js@3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" - integrity sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0= - ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -631,11 +463,6 @@ base64-js@^1.3.1: resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -bech32@1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" - integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== - binary-extensions@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" @@ -1034,42 +861,6 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -ethers@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/ethers/-/ethers-5.2.0.tgz#13452e35947ab5d77053286d1f7161ee666c85ba" - integrity sha512-HqFGU2Qab0mAg3y1eHKVMXS4i1gTObMY0/4+x4LiO72NHhJL3Z795gnqyivmwG1J8e5NLSlRSfyIR7TL0Hw3ig== - dependencies: - "@ethersproject/abi" "5.2.0" - "@ethersproject/abstract-provider" "5.2.0" - "@ethersproject/abstract-signer" "5.2.0" - "@ethersproject/address" "5.2.0" - "@ethersproject/base64" "5.2.0" - "@ethersproject/basex" "5.2.0" - "@ethersproject/bignumber" "5.2.0" - "@ethersproject/bytes" "5.2.0" - "@ethersproject/constants" "5.2.0" - "@ethersproject/contracts" "5.2.0" - "@ethersproject/hash" "5.2.0" - "@ethersproject/hdnode" "5.2.0" - "@ethersproject/json-wallets" "5.2.0" - "@ethersproject/keccak256" "5.2.0" - "@ethersproject/logger" "5.2.0" - "@ethersproject/networks" "5.2.0" - "@ethersproject/pbkdf2" "5.2.0" - "@ethersproject/properties" "5.2.0" - "@ethersproject/providers" "5.2.0" - "@ethersproject/random" "5.2.0" - "@ethersproject/rlp" "5.2.0" - "@ethersproject/sha2" "5.2.0" - "@ethersproject/signing-key" "5.2.0" - "@ethersproject/solidity" "5.2.0" - "@ethersproject/strings" "5.2.0" - "@ethersproject/transactions" "5.2.0" - "@ethersproject/units" "5.2.0" - "@ethersproject/wallet" "5.2.0" - "@ethersproject/web" "5.2.0" - "@ethersproject/wordlists" "5.2.0" - fast-deep-equal@^3.1.1: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -1315,14 +1106,6 @@ has-unicode@^2.0.0: resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= -hash.js@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" - integrity sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.0" - hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" @@ -2009,11 +1792,6 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -scrypt-js@3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - semver@^5.3.0, semver@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -2366,11 +2144,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -ws@7.2.3: - version "7.2.3" - resolved "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" - integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== - y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" From e87138a46c615978febf04b0c8eb2b725c7737cc Mon Sep 17 00:00:00 2001 From: Silas Davis Date: Fri, 28 May 2021 17:31:32 +0200 Subject: [PATCH 4/4] Prep for 0.34.0 release Signed-off-by: Silas Davis --- CHANGELOG.md | 15 +++++++++++++++ NOTES.md | 10 ++++++++-- project/history.go | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c0a015f..e16854cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,18 @@ # [Hyperledger Burrow](https://github.com/hyperledger/burrow) Changelog +## [0.34.0] - 2021-05-28 +### Changed +- [JS] Provider interface no longer depends on GRPC types to improve compatibility between versions of Burrow.js and ease of extension +- [JS] Use non-unique marker interface to indicate stream cancellation in event reducer (again for compatibility between versions and extensibility) +- [Go] Upgrade to Go 1.16 + +### Fixed +- [JS] Fix codegen silently swallowing collisions of abi files (renamed from .bin to .abi) and use hierarchical directory structure to further reduce chance of collision +- [JS] Just depende on @ethersproject/abi rather than entire umbrella project + +### Added +- [JS] Include deployedBycode and optionally submit ABI's to Burrow's contract metadata store on deploy + + ## [0.33.1] - 2021-05-24 ### Fixed - [JS] Return bytesNN as Buffer to agree with typings @@ -775,6 +789,7 @@ This release marks the start of Eris-DB as the full permissioned blockchain node - [Blockchain] Fix getBlocks to respect block height cap. +[0.34.0]: https://github.com/hyperledger/burrow/compare/v0.33.1...v0.34.0 [0.33.1]: https://github.com/hyperledger/burrow/compare/v0.33.0...v0.33.1 [0.33.0]: https://github.com/hyperledger/burrow/compare/v0.32.1...v0.33.0 [0.32.1]: https://github.com/hyperledger/burrow/compare/v0.32.0...v0.32.1 diff --git a/NOTES.md b/NOTES.md index 7b7b53441..63637952d 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,6 +1,12 @@ +### Changed +- [JS] Provider interface no longer depends on GRPC types to improve compatibility between versions of Burrow.js and ease of extension +- [JS] Use non-unique marker interface to indicate stream cancellation in event reducer (again for compatibility between versions and extensibility) +- [Go] Upgrade to Go 1.16 + ### Fixed -- [JS] Return bytesNN as Buffer to agree with typings +- [JS] Fix codegen silently swallowing collisions of abi files (renamed from .bin to .abi) and use hierarchical directory structure to further reduce chance of collision +- [JS] Just depende on @ethersproject/abi rather than entire umbrella project ### Added -- [JS] Inline sources and source maps +- [JS] Include deployedBycode and optionally submit ABI's to Burrow's contract metadata store on deploy diff --git a/project/history.go b/project/history.go index a35b837b6..714680ce1 100644 --- a/project/history.go +++ b/project/history.go @@ -47,7 +47,20 @@ func FullVersion() string { // To cut a new release add a release to the front of this slice then run the // release tagging script: ./scripts/tag_release.sh var History relic.ImmutableHistory = relic.NewHistory("Hyperledger Burrow", "https://github.com/hyperledger/burrow"). - MustDeclareReleases("0.33.1 - 2021-05-24", + MustDeclareReleases("0.34.0 - 2021-05-28", + `### Changed +- [JS] Provider interface no longer depends on GRPC types to improve compatibility between versions of Burrow.js and ease of extension +- [JS] Use non-unique marker interface to indicate stream cancellation in event reducer (again for compatibility between versions and extensibility) +- [Go] Upgrade to Go 1.16 + +### Fixed +- [JS] Fix codegen silently swallowing collisions of abi files (renamed from .bin to .abi) and use hierarchical directory structure to further reduce chance of collision +- [JS] Just depende on @ethersproject/abi rather than entire umbrella project + +### Added +- [JS] Include deployedBycode and optionally submit ABI's to Burrow's contract metadata store on deploy +`, + "0.33.1 - 2021-05-24", `### Fixed - [JS] Return bytesNN as Buffer to agree with typings