Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 3x 3x 3x 3x 3x | import { hexlify } from "@ethersproject/bytes";
import { toUtf8Bytes } from "@ethersproject/strings/lib/utf8";
import { arrayify } from "ethers/lib/utils";
import { DataPackagesRequestParams, requestRedstonePayload } from "../index";
export class ContractParamsProvider {
constructor(public readonly requestParams: DataPackagesRequestParams) {}
async getPayloadHex(withPrefix = true): Promise<string> {
return (
(withPrefix ? "0x" : "") + (await this.requestPayload(this.requestParams))
);
}
async getPayloadData(): Promise<number[]> {
return Array.from(arrayify(await this.getPayloadHex(true)));
}
getHexlifiedFeedIds(): string[] {
return this.getDataFeedIds().map((feed) => hexlify(toUtf8Bytes(feed)));
}
getDataFeedIds(): string[] {
return this.requestParams.dataPackagesIds;
}
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
protected async requestPayload(
requestParams: DataPackagesRequestParams
): Promise<string> {
return await requestRedstonePayload(requestParams);
}
}
|