Skip to content

Commit

Permalink
Merge pull request #475 from polywrap/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.43
  • Loading branch information
dOrgJelli authored Sep 17, 2021
2 parents 8d0721b + 4e37d30 commit 443b217
Show file tree
Hide file tree
Showing 30 changed files with 483 additions and 142 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Web3API 0.0.1-prealpha.43
## Features
* `@web3api/client-js`: Added the `client.subscribe(...)` method, enabling users to easily send queries at a specified frequency.

## Bugs
* `@web3api/tracing-js`: Replaced the `util-inspect` dependency with a browser compatible one.

# Web3API 0.0.1-prealpha.42
## Bugs
* `@web3api/schema-parse`: Removed unnecessary sanitization for imported methods without any arguments.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1-prealpha.42
0.0.1-prealpha.43
8 changes: 4 additions & 4 deletions packages/apis/uniswapv2/src/__tests__/e2e/fetch_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import { ChainId, Pair, Token, TokenAmount } from "./types";
import path from "path";
import { getRedirects, getTokenList } from "../testUtils";
import { getPlugins, getTokenList } from "../testUtils";
import * as uni from "@uniswap/sdk";
import * as ethers from "ethers";

Expand All @@ -20,8 +20,8 @@ describe("Fetch", () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);
// deploy api
const apiPath: string = path.resolve(__dirname + "/../../../");
const api = await buildAndDeployApi(apiPath, ipfs, ensAddress);
Expand Down
8 changes: 4 additions & 4 deletions packages/apis/uniswapv2/src/__tests__/e2e/pair_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import * as path from "path";
import { Pair, Token, TokenAmount } from "./types";
import { getPairData, getRedirects, getTokenList, getUniPairs } from "../testUtils";
import { getPairData, getPlugins, getTokenList, getUniPairs } from "../testUtils";
import * as uni from "@uniswap/sdk";

jest.setTimeout(150000);
Expand All @@ -17,8 +17,8 @@ describe('Pair', () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);
// deploy api
const apiPath: string = path.resolve(__dirname + "/../../../");
const api = await buildAndDeployApi(apiPath, ipfs, ensAddress);
Expand Down
8 changes: 4 additions & 4 deletions packages/apis/uniswapv2/src/__tests__/e2e/route_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import * as path from "path";
import { Pair, Route, Token } from "./types";
import { getPairData, getRedirects, getTokenList, getUniPairs } from "../testUtils";
import { getPairData, getPlugins, getTokenList, getUniPairs } from "../testUtils";
import * as uni from "@uniswap/sdk";

jest.setTimeout(360000);
Expand All @@ -19,8 +19,8 @@ describe('Route', () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);
// deploy api
const apiPath: string = path.resolve(__dirname + "/../../../");
const api = await buildAndDeployApi(apiPath, ipfs, ensAddress);
Expand Down
8 changes: 4 additions & 4 deletions packages/apis/uniswapv2/src/__tests__/e2e/router_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import {
ChainId,
Pair,
Expand All @@ -16,7 +16,7 @@ import {
getBestTradeExactIn,
getBestTradeExactOut,
getPairData,
getRedirects,
getPlugins,
getTokenList,
getUniPairs
} from "../testUtils";
Expand All @@ -40,8 +40,8 @@ describe("Router", () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects: redirects, tracingEnabled: true });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);

// deploy api
const apiPath: string = path.resolve(__dirname + "../../../../");
Expand Down
10 changes: 5 additions & 5 deletions packages/apis/uniswapv2/src/__tests__/e2e/swap_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import { Currency, Pair, Token, Trade, TxResponse } from "./types";
import path from "path";
import { getRedirects, getTokenList } from "../testUtils";
import { getPlugins, getTokenList } from "../testUtils";
import { Contract, ethers, providers } from "ethers";
import erc20ABI from "./testData/erc20ABI.json";

jest.setTimeout(120000);
jest.setTimeout(360000);

describe("Swap", () => {

Expand All @@ -23,8 +23,8 @@ describe("Swap", () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects: redirects, tracingEnabled: true });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);

// deploy api
const apiPath: string = path.resolve(__dirname + "../../../../");
Expand Down
8 changes: 4 additions & 4 deletions packages/apis/uniswapv2/src/__tests__/e2e/trade_e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ClientConfig, Web3ApiClient } from "@web3api/client-js";
import { buildAndDeployApi, initTestEnvironment, stopTestEnvironment } from "@web3api/test-env-js";
import * as path from "path";
import { ChainId, Pair, Route, Token, TokenAmount, Trade } from "./types";
import { getPairData, getRedirects, getTokenList, getUniPairs } from "../testUtils";
import { getPairData, getPlugins, getTokenList, getUniPairs } from "../testUtils";
import * as uni from "@uniswap/sdk";

jest.setTimeout(120000);
Expand All @@ -19,8 +19,8 @@ describe('trade e2e', () => {
beforeAll(async () => {
const { ethereum: testEnvEtherem, ensAddress, ipfs } = await initTestEnvironment();
// get client
const redirects: UriRedirect[] = getRedirects(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient({ redirects });
const config: ClientConfig = getPlugins(testEnvEtherem, ipfs, ensAddress);
client = new Web3ApiClient(config);
// deploy api
const apiPath: string = path.resolve(__dirname + "/../../../");
const api = await buildAndDeployApi(apiPath, ipfs, ensAddress);
Expand Down
44 changes: 22 additions & 22 deletions packages/apis/uniswapv2/src/__tests__/query/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -96,7 +96,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x64");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand Down Expand Up @@ -126,7 +126,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromNull<u32>(),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromValue<u32>(50),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -179,7 +179,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand All @@ -201,7 +201,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -216,7 +216,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});
});
Expand Down Expand Up @@ -244,7 +244,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -258,7 +258,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x80");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand Down Expand Up @@ -288,7 +288,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -303,7 +303,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand All @@ -325,7 +325,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromNull<boolean>()
Expand All @@ -340,7 +340,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});
});
Expand Down Expand Up @@ -373,7 +373,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand All @@ -387,7 +387,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x64");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand All @@ -413,7 +413,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand All @@ -428,7 +428,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});

Expand All @@ -450,7 +450,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand All @@ -465,7 +465,7 @@ describe("swapCallParameters", () => {
"0x0000000000000000000000000000000000000004"
]);
expect(result.value).toStrictEqual("0x0");
const deadlineDifference = (Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
const deadlineDifference = (<u32>Date.now() / 1000) as number - parseInt(result.args[result.args.length - 1]) as number;
expect(deadlineDifference < 5).toBe(true);
});
});
Expand Down Expand Up @@ -494,7 +494,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand Down Expand Up @@ -530,7 +530,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand Down Expand Up @@ -558,7 +558,7 @@ describe("swapCallParameters", () => {
tradeOptions: {
ttl: Nullable.fromValue<u32>(50),
recipient: "0x0000000000000000000000000000000000000004",
unixTimestamp: Date.now() / 1000,
unixTimestamp: <u32>Date.now() / 1000,
allowedSlippage: "0.01",
deadline: Nullable.fromNull<u32>(),
feeOnTransfer: Nullable.fromValue<boolean>(true)
Expand Down
Loading

0 comments on commit 443b217

Please sign in to comment.