@ethersproject/bytes#BytesLike TypeScript Examples
The following examples show how to use
@ethersproject/bytes#BytesLike.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From bodhi.js with Apache License 2.0 | 7 votes |
export function dataToString(bytes: BytesLike): string {
if (isBuffer(bytes)) {
return u8aToHex(bufferToU8a(bytes));
}
if (isU8a(bytes)) {
return u8aToHex(bytes);
}
if (Array.isArray(bytes)) {
return u8aToHex(Buffer.from(bytes));
}
return bytes as string;
}
Example #2
Source File: util.ts From fuels-ts with Apache License 2.0 | 7 votes |
getContractStorageRoot = (storageSlots: [BytesLike, BytesLike][]): string => {
const KEY_SIZE = 32;
const VALUE_SIZE = 32;
const chunks: Uint8Array[] = [];
// eslint-disable-next-line no-restricted-syntax
for (const [key, value] of storageSlots) {
const chunk = new Uint8Array(KEY_SIZE + VALUE_SIZE);
chunk.set(arrayify(key));
chunk.set(arrayify(value), KEY_SIZE);
chunks.push(chunk);
}
return calcRoot(chunks.map((c) => hexlify(c)));
}
Example #3
Source File: parseTransaction.ts From bodhi.js with Apache License 2.0 | 6 votes |
export function parseTransaction(rawTransaction: BytesLike): AcalaEvmTX {
const payload = arrayify(rawTransaction);
// Ethereum Transactions
if (payload[0] > 0x7f || payload[0] === 1 || payload[0] === 2) {
return parse(payload);
}
// EIP 712
if (payload[0] === 96) {
return parseEip712(payload);
}
return logger.throwError(`unsupported transaction type: ${payload[0]}`, Logger.errors.UNSUPPORTED_OPERATION, {
operation: 'parseTransaction',
transactionType: payload[0]
});
}
Example #4
Source File: TestRouter.d.ts From hypervisor with The Unlicense | 6 votes |
populateTransaction: {
mint(
pool: string,
tickLower: BigNumberish,
tickUpper: BigNumberish,
amount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
swap(
pool: string,
zeroForOne: boolean,
amountSpecified: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
uniswapV3MintCallback(
amount0Owed: BigNumberish,
amount1Owed: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
uniswapV3SwapCallback(
amount0Delta: BigNumberish,
amount1Delta: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
};
Example #5
Source File: ISwapRouter.d.ts From hardhat-v3-deploy with MIT License | 6 votes |
'exactOutput(tuple)'(
params: {
path: BytesLike
recipient: string
deadline: BigNumberish
amountOut: BigNumberish
amountInMaximum: BigNumberish
},
overrides?: PayableOverrides
): Promise<ContractTransaction>
Example #6
Source File: MockCrossDomainMessenger.d.ts From nova with GNU Affero General Public License v3.0 | 6 votes |
populateTransaction: {
relayMessage(
target: string,
message: BytesLike,
sender: string,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
sendMessage(
arg0: string,
arg1: BytesLike,
arg2: BigNumberish,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
xDomainMessageSender(
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
};
Example #7
Source File: parseTransaction.ts From bodhi.js with Apache License 2.0 | 6 votes |
export function checkSignatureType(rawTransaction: BytesLike): SignatureType {
const payload = arrayify(rawTransaction);
if (payload[0] > 0x7f || payload[0] === 1) return 'Ethereum'; // Legacy and EIP-155
if (payload[0] === 2) return 'Eip1559'; // EIP-1559
if (payload[0] === 96) return 'AcalaEip712'; // Acala EIP-712
return logger.throwError(`unsupported transaction type: ${payload[0]}`, Logger.errors.UNSUPPORTED_OPERATION, {
operation: 'checkSignatureType',
transactionType: payload[0]
});
}
Example #8
Source File: abi-coder.ts From fuels-ts with Apache License 2.0 | 6 votes |
decode(types: ReadonlyArray<JsonAbiFragmentType>, data: BytesLike): DecodedValue[] | undefined {
const bytes = arrayify(data);
const nonEmptyTypes = filterEmptyParams(types);
const assertParamsMatch = (newOffset: number) => {
if (newOffset !== bytes.length) {
logger.throwError('Types/values length mismatch', Logger.errors.INVALID_ARGUMENT, {
count: { types: nonEmptyTypes.length, values: bytes.length },
value: { types: nonEmptyTypes, bytes },
});
}
};
if (types.length === 0 || nonEmptyTypes.length === 0) {
// The VM is current return 0x0000000000000000, but we should treat it as undefined / void
assertParamsMatch(bytes.length ? 8 : 0);
return undefined;
}
const coders = nonEmptyTypes.map((type) => this.getCoder(type));
const coder = new TupleCoder(coders);
const [decoded, newOffset] = coder.decode(bytes, 0);
assertParamsMatch(newOffset);
return decoded as DecodedValue[];
}
Example #9
Source File: EchidnaL1NovaExecutionManager.d.ts From nova with GNU Affero General Public License v3.0 | 6 votes |
estimateGas: {
exec_should_not_affect_currentExecHash(
nonce: BigNumberish,
strategy: string,
l1Calldata: BytesLike,
gasLimit: BigNumberish,
recipient: string,
deadline: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
registerSelfAsStrategy_should_never_be_callable_twice(
riskLevel1: BigNumberish,
riskLevel2: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
should_always_be_able_to_update_gas_config(
newGasConfig: {
calldataByteGasEstimate: BigNumberish;
missingGasEstimate: BigNumberish;
strategyCallGasBuffer: BigNumberish;
execCompletedMessageGasLimit: BigNumberish;
},
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
transferFromRelayer_should_always_be_not_executable(
token: string,
amount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
};
Example #10
Source File: wallet.ts From fuels-ts with Apache License 2.0 | 6 votes |
/**
* Create wallet from mnemonic phrase
*/
static fromMnemonic(mnemonic: string, path?: string, passphrase?: BytesLike): Wallet {
const seed = Mnemonic.mnemonicToSeed(mnemonic, passphrase);
const hdWallet = HDWallet.fromSeed(seed);
const childWallet = hdWallet.derivePath(path || Wallet.defaultPath);
return new Wallet(<string>childWallet.privateKey);
}
Example #11
Source File: EchidnaL1NovaExecutionManager.d.ts From nova with GNU Affero General Public License v3.0 | 6 votes |
exec_should_not_affect_currentExecHash(
nonce: BigNumberish,
strategy: string,
l1Calldata: BytesLike,
gasLimit: BigNumberish,
recipient: string,
deadline: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
Example #12
Source File: IUniswapV3MintCallback.d.ts From hypervisor with The Unlicense | 5 votes |
functions: {
uniswapV3MintCallback(
amount0Owed: BigNumberish,
amount1Owed: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
};
Example #13
Source File: Hevm.d.ts From nova with GNU Affero General Public License v3.0 | 5 votes |
load(
arg0: string,
arg1: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
Example #14
Source File: IUniswapV3Pool.d.ts From hypervisor with The Unlicense | 5 votes |
mint(
recipient: string,
tickLower: BigNumberish,
tickUpper: BigNumberish,
amount: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
Example #15
Source File: Authority.d.ts From nova with GNU Affero General Public License v3.0 | 5 votes |
functions: {
canCall(
src: string,
dst: string,
sig: BytesLike,
overrides?: CallOverrides
): Promise<[boolean]>;
};