Skip to content

Commit

Permalink
Merge pull request #229 from Web3-API/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.7 Release
  • Loading branch information
dOrgJelli authored Mar 20, 2021
2 parents 4eccf97 + ec65857 commit 9f92985
Show file tree
Hide file tree
Showing 98 changed files with 2,534 additions and 1,016 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/js-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
CI:
name: JS-CI
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Web3API 0.0.1-prealpha.7
## Features
* Console Log Web3API
* Calls log on logger plugin at uri w3://w3/logger. Default logger logs to console, but can be overridden with redirect to custom logger web3api implementation.
* Log levels: Debug, Info, Warn, Error
* `createWeb3ApiClient(...)` helper for easily setting up a Web3API Client with all needed plugins (ex: ethereum, ipfs, etc) in one function call.
* Additional support for plugins can be added in the future, without bloating the `@web3api/client-js` package thanks to dynamic imports!
* When using the Web3ApiClient, specify Web3API URIs without having to create a new URI class (`new Uri("...")`). Simply provide a string instead.
* Improved plugin instantiation interface.

## Bug Fixes
* Proper MsgPack numeric overflow assertions (closes: [#150](https://github.com/Web3-API/monorepo/issues/150))
* Proper usage of [GraphQL Aliases](https://graphql.org/learn/queries/#aliases) when invoking multiple methods in one query.

# Web3API 0.0.1-prealpha.6
## Features
* Web3API React Integration: `@web3api/react`
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.6
0.0.1-prealpha.7
29 changes: 10 additions & 19 deletions demos/simple-storage/dapp/src/web3api/setupClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Uri, UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { EnsPlugin } from "@web3api/ens-plugin-js";
import { EthereumPlugin } from "@web3api/ethereum-plugin-js";
import { IpfsPlugin } from "@web3api/ipfs-plugin-js";
import { Web3ApiClient, UriRedirect } from "@web3api/client-js";
import { ensPlugin } from "@web3api/ens-plugin-js";
import { ethereumPlugin } from "@web3api/ethereum-plugin-js";
import { ipfsPlugin } from "@web3api/ipfs-plugin-js";

export async function setupWeb3ApiClient(): Promise<Web3ApiClient> {
const ethereum = (window as any).ethereum;
Expand All @@ -11,25 +11,16 @@ export async function setupWeb3ApiClient(): Promise<Web3ApiClient> {

const redirects: UriRedirect[] = [
{
from: new Uri("w3://ens/ethereum.web3api.eth"),
to: {
factory: () => new EthereumPlugin({ provider: ethereum }),
manifest: EthereumPlugin.manifest()
}
from: "w3://ens/ethereum.web3api.eth",
to: ethereumPlugin({ provider: ethereum }),
},
{
from: new Uri("w3://ens/ipfs.web3api.eth"),
to: {
factory: () => new IpfsPlugin({ provider: 'https://ipfs.io' }),
manifest: IpfsPlugin.manifest()
}
from: "w3://ens/ipfs.web3api.eth",
to: ipfsPlugin({ provider: "https://ipfs.io" }),
},
{
from: new Uri("w3://ens/ens.web3api.eth"),
to: {
factory: () => new EnsPlugin({ }),
manifest: EnsPlugin.manifest()
}
from: "w3://ens/ens.web3api.eth",
to: ensPlugin({}),
}
];

Expand Down
4 changes: 2 additions & 2 deletions demos/simple-storage/dapp/src/web3api/simplestorage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Uri, Web3ApiClient } from "@web3api/client-js";
import { Web3ApiClient } from "@web3api/client-js";

export const uri = new Uri("ens/api.simplestorage.eth");
export const uri = "ens/api.simplestorage.eth";

export interface SetDataResult {
txReceipt: string,
Expand Down
2 changes: 1 addition & 1 deletion demos/simple-storage/protocol/web3api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
format: 0.0.1-prealpha.1
description: SimpleStorage Web3API Example
repository: https://github.com/web3-api/prototype
repository: https://github.com/web3-api/monorepo
mutation:
schema:
file: ./src/mutation/schema.graphql
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Hello and welcome to the documentation for Web3 API.
![](https://github.com/Web3-API/branding/blob/master/logo/Web3API_On_Black_BG.jpg?raw=true)

You can find all source code here in [our monorepo](https://github.com/web3-api/prototype).
You can find all source code here in [our monorepo](https://github.com/web3-api/monorepo).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"reset": "yarn clean && yarn && yarn build",
"clean": "rimraf ./**/node_modules ./**/build ./**/coverage",
"build": "lerna run build --no-private --ignore @web3api/cli && lerna run build --scope @web3api/cli",
"build": "lerna run build --no-private --ignore @web3api/cli* --ignore @web3api/react && lerna run build --scope @web3api/client-js --scope @web3api/react && lerna run build --scope @web3api/cli",
"lint": "lerna run lint",
"lint:fix": "lerna run lint -- --fix",
"lint:ci": "lerna run lint --parallel",
Expand Down
55 changes: 55 additions & 0 deletions packages/apis/console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Console Web3API

Calls log on logger plugin at uri `w3://w3/logger`. Default logger logs to console, but can be overridden with redirect to custom logger web3api implementation.

### Log levels

- DEBUG
- INFO
- WARN
- ERROR

## Example

### Usage

In schema:
```graph
#import { Query } into Console from "w3://ens/console.eth"
type Query {
customMethod(): Boolean!
}
```

In code:

```ts
import { Console_Query } from "./w3";

function customMethod(): bool {
Console_Query.info("some useful info about my API");

return true;
}
```
### How To Run

### 1. Setup Test Env

```
yarn run test:env:up
```

### 2. Build & Deploy The Web3API

```
yarn run build
yarn run deploy
```

### 3. Test The Web3API Using A Query Recipe

```
npx w3 query ./recipes/e2e.json
```
19 changes: 19 additions & 0 deletions packages/apis/console/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@web3api/console",
"description": "Web3API for logging",
"private": true,
"version": "0.0.1-prealpha.6",
"scripts": {
"build": "w3 build",
"deploy": "w3 build --ipfs http://127.0.0.1:5001 --test-ens console.eth",
"test": "w3 query ./recipes/e2e.json",
"test:ci": "yarn test:env:up && yarn deploy && yarn test && yarn test:env:down",
"test:env:up": "w3 test-env up",
"test:env:down": "w3 test-env down"
},
"devDependencies": {
"@web3api/cli": "0.0.1-prealpha.6",
"@web3api/wasm-as": "0.0.1-prealpha.6",
"js-yaml": "3.14.0"
}
}
3 changes: 3 additions & 0 deletions packages/apis/console/recipes/constants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"message": "Test message"
}
10 changes: 10 additions & 0 deletions packages/apis/console/recipes/e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"api": "ens/console.eth",
"constants": "./constants.json"
},
{
"query": "./log.graphql",
"variables": { "message": "$message" }
}
]
17 changes: 17 additions & 0 deletions packages/apis/console/recipes/log.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query Log($message: String!) {
error(
message: $message
)

info(
message: $message
)

debug(
message: $message
)

warn(
message: $message
)
}
29 changes: 29 additions & 0 deletions packages/apis/console/src/query/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Input_info, Logger_Query, Logger_LogLevel } from "./w3";

export function debug(input: Input_info): bool {
return Logger_Query.log({
message: input.message,
level: Logger_LogLevel.DEBUG
});
}

export function info(input: Input_info): bool {
return Logger_Query.log({
message: input.message,
level: Logger_LogLevel.INFO
});
}

export function warn(input: Input_info): bool {
return Logger_Query.log({
message: input.message,
level: Logger_LogLevel.WARN
});
}

export function error(input: Input_info): bool {
return Logger_Query.log({
message: input.message,
level: Logger_LogLevel.ERROR
});
}
19 changes: 19 additions & 0 deletions packages/apis/console/src/query/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import { Query, LogLevel } into Logger from "w3://w3/logger"

type Query {
debug(
message: String!
): Boolean!

info(
message: String!
): Boolean!

warn(
message: String!
): Boolean!

error(
message: String!
): Boolean!
}
12 changes: 12 additions & 0 deletions packages/apis/console/web3api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description: Console log Web3Api
repository: https://github.com/web3-api/monorepo
format: 0.0.1-prealpha.1
query:
schema:
file: ./src/query/schema.graphql
module:
language: wasm/assemblyscript
file: ./src/query/index.ts
import_redirects:
- uri: w3://w3/logger
schema: ../../core-apis/logger/schema.graphql
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"test:env:down": "w3 test-env down"
},
"devDependencies": {
"@web3api/ethereum-plugin-js": "0.0.1-prealpha.2",
"@web3api/wasm-as": "0.0.1-prealpha.2",
"@web3api/ethereum-plugin-js": "0.0.1-prealpha.6",
"@web3api/wasm-as": "0.0.1-prealpha.6",
"ethers": "5.0.8",
"js-yaml": "3.14.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/project/recipes/constants.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"SimpleStorageAddr": "0x4bf749ec68270027C5910220CEAB30Cc284c7BA2"
"SimpleStorageAddr": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab"
}
31 changes: 11 additions & 20 deletions packages/cli/src/commands/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import chalk from "chalk";
import { GluegunToolbox } from "gluegun";
import gql from "graphql-tag";
import path from "path";
import { Uri, UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { EnsPlugin } from "@web3api/ens-plugin-js";
import { EthereumPlugin } from "@web3api/ethereum-plugin-js";
import { IpfsPlugin } from "@web3api/ipfs-plugin-js";
import { UriRedirect, Web3ApiClient } from "@web3api/client-js";
import { ensPlugin } from "@web3api/ens-plugin-js";
import { ethereumPlugin } from "@web3api/ethereum-plugin-js";
import { ipfsPlugin } from "@web3api/ipfs-plugin-js";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const HELP = `
Expand Down Expand Up @@ -67,25 +67,16 @@ export default {
// maybe have it exported from test-env.
const redirects: UriRedirect[] = [
{
from: new Uri("w3://ens/ethereum.web3api.eth"),
to: {
factory: () => new EthereumPlugin({ provider: ethereum }),
manifest: EthereumPlugin.manifest(),
},
from: "w3://ens/ethereum.web3api.eth",
to: ethereumPlugin({ provider: ethereum }),
},
{
from: new Uri("w3://ens/ipfs.web3api.eth"),
to: {
factory: () => new IpfsPlugin({ provider: ipfs }),
manifest: IpfsPlugin.manifest(),
},
from: "w3://ens/ipfs.web3api.eth",
to: ipfsPlugin({ provider: ipfs }),
},
{
from: new Uri("w3://ens/ens.web3api.eth"),
to: {
factory: () => new EnsPlugin({ address: ensAddress }),
manifest: EnsPlugin.manifest(),
},
from: "w3://ens/ens.web3api.eth",
to: ensPlugin({ address: ensAddress }),
},
];

Expand Down Expand Up @@ -153,7 +144,7 @@ export default {
print.warning("-----------------------------------");

const { data, errors } = await client.query({
uri: new Uri(uri),
uri,
query: gql(query),
variables,
});
Expand Down
Loading

0 comments on commit 9f92985

Please sign in to comment.