Refactor imports.

This commit is contained in:
Richard Moore 2022-09-15 22:31:00 -04:00
parent edcba76366
commit 23868e74b1
19 changed files with 86 additions and 41 deletions

@ -1,4 +1,4 @@
import { keccak256 } from "../crypto/keccak.js";
import { keccak256 } from "../crypto/index.js";
import { getBytes, throwArgumentError } from "../utils/index.js";

@ -1,4 +1,4 @@
import { keccak256 } from "../crypto/keccak.js";
import { keccak256 } from "../crypto/index.js";
import {
concat, dataSlice, getBigInt, getBytes, encodeRlp, throwArgumentError
} from "../utils/index.js";

@ -62,11 +62,16 @@ export {
export {
decodeBase58, encodeBase58,
decodeBase64, encodeBase64,
concat, dataLength, dataSlice, getBytes, getBytesCopy, hexlify,
isHexString, isBytesLike, stripZerosLeft, zeroPadBytes, zeroPadValue,
assertArgument, assertArgumentCount, assertNormalize, assertPrivate,
makeError, throwArgumentError, throwError,
isCallException, isError,
FetchRequest, FetchResponse,
getIpfsGatewayFunc, FetchRequest, FetchResponse, FetchCancelSignal,
FixedFormat, FixedNumber, formatFixed, parseFixed,
assertArgument,
fromTwos, toTwos, mask, toArray, toBigInt, toHex, toNumber,
getBigInt, getNumber, toArray, toBigInt, toHex, toNumber, toQuantity,
fromTwos, toTwos, mask,
formatEther, parseEther, formatUnits, parseUnits,
_toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String,
Utf8ErrorFuncs,
@ -111,6 +116,8 @@ export type { ProgressCallback, SignatureLike } from "./crypto/index.js";
export type { TypedDataDomain, TypedDataField } from "./hash/index.js";
export {
AbstractProvider,
FallbackProvider,
JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner,
@ -135,9 +142,16 @@ export type {
RlpStructuredData,
GetUrlResponse,
FetchRequestWithBody, FetchResponseWithBody,
FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc,
FetchGatewayFunc, FetchGetUrlFunc
FetchGatewayFunc, FetchGetUrlFunc,
EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError,
ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError,
NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError,
CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError,
ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError,
UnpredictableGasLimitError, ActionRejectedError,
CodedEthersError,
} from "./utils/index.js";
export type {

@ -1,4 +1,4 @@
import { keccak256 } from "../crypto/keccak.js";
import { keccak256 } from "../crypto/index.js";
import { toUtf8Bytes } from "../utils/index.js";
export function id(value: string): string {

@ -1,4 +1,4 @@
import { keccak256 } from "../crypto/keccak.js";
import { keccak256 } from "../crypto/index.js";
import { MessagePrefix } from "../constants/index.js";
import { concat, toUtf8Bytes } from "../utils/index.js";

@ -1,5 +1,5 @@
import { keccak256 } from "../crypto/keccak.js";
import { keccak256 } from "../crypto/index.js";
import {
concat, hexlify, throwArgumentError, toUtf8Bytes, toUtf8String
} from "../utils/index.js";

@ -104,14 +104,6 @@ export function solidityPackedKeccak256(types: ReadonlyArray<string>, values: Re
return _keccak256(solidityPacked(types, values));
}
/**
* Test Function, for fun
*
* @param foo - something fun
*/
export function test(foo: number | string): void {
}
export function solidityPackedSha256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string {
return _sha256(solidityPacked(types, values));
}

@ -1,6 +1,6 @@
import { Transaction } from "../transaction/index.js";
import {
defineProperties, resolveProperties,
defineProperties, getBigInt, resolveProperties,
throwArgumentError, throwError
} from "../utils/index.js";
@ -80,8 +80,21 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
pop.gasLimit = await this.estimateGas(pop);
}
//@TODO: Copy type logic from AbstractSigner in v5
// Populate the chain ID
const network = await (<Provider>(this.provider)).getNetwork();
if (pop.chainId != null) {
const chainId = getBigInt(pop.chainId);
if (chainId !== network.chainId) {
throwArgumentError("transaction chainId mismatch", "tx.chainId", tx.chainId);
}
} else {
pop.chainId = network.chainId;
}
//@TOOD: Don't await all over the place; save them up for
// the end for better batching
//@TODO: Copy type logic from AbstractSigner in v5
// Test how many batches is actually sent for sending a tx; compare before/after
return await resolveProperties(pop);
}

@ -1,8 +1,11 @@
/*
/////
export {
AbstractProvider, UnmanagedSubscriber
} from "./abstract-provider.js";
*/
export {
AbstractSigner,
@ -60,12 +63,16 @@ export { IpcSocketProvider };
export { SocketProvider } from "./provider-socket.js";
export { WebSocketProvider } from "./provider-websocket.js";
export {
SocketSubscriber, SocketBlockSubscriber, SocketPendingSubscriber,
SocketEventSubscriber
} from "./provider-socket.js";
/*
export type {
ProviderPlugin, Subscriber, Subscription
Subscription, Subscriber,
ProviderPlugin,
PerformActionFilter, PerformActionTransaction, PerformActionRequest
} from "./abstract-provider.js"
*/
export type { ContractRunner } from "./contracts.js";
/*
export type {
@ -89,4 +96,13 @@ export type {
Provider,
} from "./provider.js";
export type {
JsonRpcPayload, JsonRpcResult, JsonRpcError,
JsonRpcApiProviderOptions,
JsonRpcTransactionRequest,
} from "./provider-jsonrpc.js";
export type { WebSocketLike } from "./provider-websocket.js";
export type { Signer } from "./signer.js";

@ -574,6 +574,10 @@ export class TransactionReceipt implements TransactionReceiptParams, Iterable<Lo
return tx;
}
async getResult(): Promise<string> {
return <string>(await this.provider.getTransactionResult(this.hash));
}
async confirmations(): Promise<number> {
return (await this.provider.getBlockNumber()) - this.blockNumber + 1;
}
@ -971,6 +975,7 @@ export interface Provider extends ContractRunner, EventEmitterable<ProviderEvent
getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string): Promise<null | Block<TransactionResponse>>
getTransaction(hash: string): Promise<null | TransactionResponse>;
getTransactionReceipt(hash: string): Promise<null | TransactionReceipt>;
getTransactionResult(hash: string): Promise<null | string>;
////////////////////
@ -1039,6 +1044,9 @@ class DummyProvider implements Provider {
async getTransactionReceipt(hash: string): Promise<null | TransactionReceipt> {
return fail<null | TransactionReceipt>();
}
async getTransactionResult(hash: string): Promise<null | string> {
return fail<null | string>();
}
// Bloom-filter Queries
async getLogs(filter: Filter | FilterByBlockHash): Promise<Array<Log>> {

@ -1,8 +1,7 @@
import { isHexString } from "../utils/data.js";
import { isHexString, throwError } from "../utils/index.js";
import type { AbstractProvider, Subscriber } from "./abstract-provider.js";
import type { EventFilter, OrphanFilter, ProviderEvent } from "./provider.js";
import { throwError } from "../utils/index.js";
function copy(obj: any): any {
return JSON.parse(JSON.stringify(obj));

@ -62,7 +62,7 @@ async function gatewayData(url: string, signal?: FetchCancelSignal): Promise<Fet
if (!match) { throw new Error("invalid data"); }
return new FetchResponse(200, "OK", {
"content-type": (match[1] || "text/plain"),
}, (match[1] ? decodeBase64(match[3]): unpercent(match[3])));
}, (match[2] ? decodeBase64(match[3]): unpercent(match[3])));
} catch (error) {
return new FetchResponse(599, "BAD REQUEST (invalid data: URI)", { }, null, new FetchRequest(url));
}

@ -31,7 +31,10 @@ export {
export { EventPayload } from "./events.js";
export { FetchRequest, FetchResponse } from "./fetch.js";
export {
getIpfsGatewayFunc,
FetchRequest, FetchResponse, FetchCancelSignal,
} from "./fetch.js";
export { FixedFormat, FixedNumber, formatFixed, parseFixed } from "./fixednumber.js"
@ -66,8 +69,8 @@ export type { BytesLike } from "./data.js";
export type {
ErrorSignature, ErrorFetchRequestWithBody, ErrorFetchRequest,
ErrorFetchResponseWithBody, ErrorFetchResponse,
//ErrorFetchRequestWithBody, ErrorFetchRequest,
//ErrorFetchResponseWithBody, ErrorFetchResponse,
ErrorCode,
@ -85,7 +88,6 @@ export type { EventEmitterable, Listener } from "./events.js";
export type {
GetUrlResponse,
FetchRequestWithBody, FetchResponseWithBody,
FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc,
FetchGatewayFunc, FetchGetUrlFunc
} from "./fetch.js";

@ -104,11 +104,6 @@ function derivePath<T extends HDNodeLike<T>>(node: T, path: string): T {
return result;
}
export interface HDNodeWithPath {
path: string;
}
export class HDNodeWallet extends BaseWallet {
readonly publicKey!: string;

@ -7,15 +7,21 @@ export {
HDNodeVoidWallet,
HDNodeWalletManager,
} from "./hdwallet.js";
export { isCrowdsaleJson, decryptCrowdsaleJson } from "./json-crowdsale.js";
export {
isKeystoreJson,
decryptKeystoreJsonSync, decryptKeystoreJson,
encryptKeystoreJson
} from "./json-keystore.js";
export { Mnemonic } from "./mnemonic.js";
export { Wallet } from "./wallet.js";
export type { CrowdsaleAccount } from "./json-crowdsale.js";
export type {
KeystoreAccountParams, KeystoreAccount,
EncryptOptions

@ -2,7 +2,7 @@ import { CBC, pkcs7Strip } from "aes-js";
import { getAddress } from "../address/index.js";
import { pbkdf2 } from "../crypto/index.js";
import { id } from "../hash/id.js";
import { id } from "../hash/index.js";
import { getBytes, throwArgumentError } from "../utils/index.js";
import { getPassword, looseArrayify, spelunk } from "./utils.js";

@ -1,4 +1,4 @@
import { id } from "../hash/id.js";
import { id } from "../hash/index.js";
import {
hexlify, throwArgumentError, toUtf8Bytes, toUtf8String
} from "../utils/index.js";

@ -1,4 +1,4 @@
import { id } from "../hash/id.js";
import { id } from "../hash/index.js";
import { throwArgumentError, toUtf8String } from "../utils/index.js";
import { Wordlist } from "./wordlist.js";

@ -2,7 +2,7 @@
// Use the encode-latin.js script to create the necessary
// data files to be consumed by this class
import { id } from "../hash/id.js";
import { id } from "../hash/index.js";
import { throwArgumentError } from "../utils/index.js";
import { decodeOwl } from "./decode-owl.js";