Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Web3API 0.0.1-prealpha.12
## Bug Fixes
* Added schemas to plugin manifest modules, removing the need for `import_redirects`.
* Fixed the IpfsPlugin's `addFile` method.
* Improved the api/assemblyscript template project.

# Web3API 0.0.1-prealpha.11
## Bug Fixes
* `@web3api/cli`: Include the internationalization JSON files in the published package.
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.11
0.0.1-prealpha.12
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"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",
"lint:ci": "lerna run lint",
"test": "lerna run test --no-private --ignore @web3api/client-js && lerna run test --scope @web3api/client-js",
"test:ci": "lerna run test:ci --no-private --ignore @web3api/client-js && lerna run test:ci --scope @web3api/client-js",
"version:apply": "npx lerna version $(cat VERSION) --exact --no-git-tag-version --yes",
Expand Down
22 changes: 21 additions & 1 deletion packages/js/plugins/ens/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@ import { PluginManifest, Uri } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
# TODO: should import and "implements" the api-resolver core-api schema
# https://github.com/Web3-API/monorepo/issues/75

type Query {
tryResolveUri(
authority: String!
path: String!
): ApiResolver_MaybeUriOrManifest

getFile(
path: String!
): Bytes
}

# TODO: should get replaced with an import
# https://github.com/Web3-API/monorepo/issues/75
type ApiResolver_MaybeUriOrManifest {
uri: String
manifest: String
}`,
implemented: [new Uri("w3/api-resolver")],
imported: [new Uri("ens/ethereum.web3api.eth")],
};
22 changes: 21 additions & 1 deletion packages/js/plugins/ethereum/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@ import { PluginManifest } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
type Query {
callView(
address: String!
method: String!
args: [String!]!
): String!
}

type Mutation {
sendTransaction(
address: String!
method: String!
args: [String!]!
): String!

deployContract(
abi: String!
bytecode: String!
): String!
}`,
implemented: [],
imported: [],
};
10 changes: 9 additions & 1 deletion packages/js/plugins/graph-node/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { PluginManifest } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
type Query {
querySubgraph(
subgraphId: String!
query: String!
): String! """JSON!"""
"""TODO: support JSON type as base type?"""
"""I think this would be helpful for dynamic data"""
}`,
implemented: [],
imported: [],
};
41 changes: 40 additions & 1 deletion packages/js/plugins/http/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,46 @@ import { PluginManifest } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
type Header {
key: String!
value: String!
}

type UrlParam {
key: String!
value: String!
}

type Response {
status: Int!
statusText: String!
headers: [Header!]
body: String
}

type Request {
headers: [Header!]
urlParams: [UrlParam!]
responseType: String! # "TEXT" || "BINARY"
body: String
}

# Enum types curently not supported
#
# enum ResponseType {
# TEXT
# BINARY
# }

type Query {
get(url: String!, request: Request): Response
}

type Mutation {
post(url: String!, request: Request): Response
}
`,
implemented: [],
imported: [],
};
7 changes: 1 addition & 6 deletions packages/js/plugins/ipfs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ type Query {
type Mutation {
# TODO: Allow for custom type CID
# https://github.com/web3-api/monorepo/issues/103
addFile(data: Bytes!): AddResult!
}

type AddResult {
path: String!
cid: String!
addFile(data: Bytes!): String!
}

# TODO: should get replaced with an import
Expand Down
14 changes: 11 additions & 3 deletions packages/js/plugins/ipfs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@ export class IpfsPlugin extends Plugin {
public async add(
data: Uint8Array
): Promise<{
path: string;
cid: CID;
name: string;
hash: CID;
}> {
return await this._ipfs.add(data);
const result = await this._ipfs.add(data);

if (result.length === 0) {
throw Error(
`IpfsPlugin:add failed to add contents. Result of length 0 returned.`
);
}

return result[0];
}

public async cat(cid: string): Promise<Buffer> {
Expand Down
30 changes: 29 additions & 1 deletion packages/js/plugins/ipfs/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ import { PluginManifest, Uri } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
# TODO: should import and "implements" the api-resolver core-api schema
# https://github.com/Web3-API/monorepo/issues/75

type Query {
catFile(cid: String!): Bytes!

tryResolveUri(
authority: String!
path: String!
): ApiResolver_MaybeUriOrManifest

getFile(
path: String!
): Bytes
}

type Mutation {
# TODO: Allow for custom type CID
# https://github.com/web3-api/monorepo/issues/103
addFile(data: Bytes!): String!
}

# TODO: should get replaced with an import
# https://github.com/Web3-API/monorepo/issues/75
type ApiResolver_MaybeUriOrManifest {
uri: String
manifest: String
}`,
implemented: [new Uri("w3/api-resolver")],
imported: [],
};
7 changes: 2 additions & 5 deletions packages/js/plugins/ipfs/src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { PluginModule } from "@web3api/core-js";
// https://github.com/web3-api/monorepo/issues/101
export const mutation = (ipfs: IpfsPlugin): PluginModule => ({
addFile: async (input: { data: Uint8Array }) => {
const { path, cid } = await ipfs.add(input.data);
return {
path,
cid,
};
const { hash } = await ipfs.add(input.data);
return hash;
},
});

Expand Down
19 changes: 18 additions & 1 deletion packages/js/plugins/logger/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@ import { PluginManifest, Uri } from "@web3api/core-js";
export const manifest: PluginManifest = {
// TODO: use the schema.graphql
// https://github.com/web3-api/monorepo/issues/101
schema: "type Query { dummy: String }",
schema: `
# TODO: should import and "implements" the logger core-api schema
# https://github.com/Web3-API/monorepo/issues/75

enum LogLevel {
DEBUG,
INFO,
WARN,
ERROR,
}

type Query {
log(
level: LogLevel!
message: String!
): Boolean!
}
`,
implemented: [new Uri("w3/logger")],
imported: [],
};
1 change: 1 addition & 0 deletions packages/templates/api/assemblyscript/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
node_modules
w3
1 change: 1 addition & 0 deletions packages/templates/api/assemblyscript/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.16.0
13 changes: 9 additions & 4 deletions packages/templates/api/assemblyscript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"private": true,
"version": "0.0.1-prealpha.10",
"scripts": {
"build": "npx w3 build",
"contracts:deploy": "node ./deploy-contracts.js",
"test:env:up": "npx w3 test-env up && yarn contracts:deploy",
"test:env:down": "npx w3 test-env down"
"build": "yarn build:contract && yarn build:web3api",
"build:web3api": "npx w3 build",
"build:contract": "node ./scripts/build-contract.js",
"test:env:up": "npx w3 test-env up",
"test:env:down": "npx w3 test-env down",
"deploy": "yarn deploy:contract && yarn deploy:web3api",
"deploy:web3api": "npx w3 build --ipfs http://localhost:5001 --test-ens simplestorage.eth",
"deploy:contract": "node ./scripts/deploy-contract.js",
"test": "npx w3 query ./recipes/e2e.json"
},
"devDependencies": {
"@web3api/cli": "0.0.1-prealpha.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ async function main() {
if (output.contracts) {
console.log("✔️ Compiled SimpleStorage.sol");
} else {
throw Error(`Error: Failed to compile SimpleStorage.sol.\n${output}`);
throw Error(
`Error: Failed to compile SimpleStorage.sol.\n${JSON.stringify(output, null, 2)}`
);
}

// Fetch the compiled contract's abi & bytecode
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"abi":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}],"bytecode":"0x608060405234801561001057600080fd5b506101da806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806360fe47b11461003b5780636d4ce63c14610057575b600080fd5b610055600480360381019061005091906100d4565b610075565b005b61005f6100b6565b60405161006c9190610136565b60405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec336040516100ab919061011b565b60405180910390a150565b60008054905090565b6000813590506100ce8161018d565b92915050565b6000602082840312156100e657600080fd5b60006100f4848285016100bf565b91505092915050565b61010681610151565b82525050565b61011581610183565b82525050565b600060208201905061013060008301846100fd565b92915050565b600060208201905061014b600083018461010c565b92915050565b600061015c82610163565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61019681610183565b81146101a157600080fd5b5056fea26469706673582212201c077cc51c9ee22b2559a72a23b493543955b232bac1b59a2e6f2b89ac0bf39d64736f6c63430008030033"}
{"abi":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"data","type":"uint256"}],"name":"DataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"HashSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"setHash","outputs":[],"stateMutability":"nonpayable","type":"function"}],"bytecode":"0x608060405234801561001057600080fd5b506105d9806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ed83fd41461005157806360fe47b11461006d5780636d4ce63c14610089578063d13319c4146100a7575b600080fd5b61006b600480360381019061006691906102f6565b6100c5565b005b6100876004803603810190610082919061033b565b610116565b005b610091610159565b60405161009e9190610465565b60405180910390f35b6100af610162565b6040516100bc9190610443565b60405180910390f35b8181600191906100d69291906101f4565b507f7701f49eb9aabe8890631508a9092eabb511a34566c30f2d94ff4420da1ccb1333838360405161010a939291906103e8565b60405180910390a15050565b806000819055507f7c94a94848d5859b1a30c887dc5740bf8d1cf789779be90adda1d0d34dd25022338260405161014e92919061041a565b60405180910390a150565b60008054905090565b6060600180546101719061051a565b80601f016020809104026020016040519081016040528092919081815260200182805461019d9061051a565b80156101ea5780601f106101bf576101008083540402835291602001916101ea565b820191906000526020600020905b8154815290600101906020018083116101cd57829003601f168201915b5050505050905090565b8280546102009061051a565b90600052602060002090601f0160209004810192826102225760008555610269565b82601f1061023b57803560ff1916838001178555610269565b82800160010185558215610269579182015b8281111561026857823582559160200191906001019061024d565b5b509050610276919061027a565b5090565b5b8082111561029357600081600090555060010161027b565b5090565b60008083601f8401126102a957600080fd5b8235905067ffffffffffffffff8111156102c257600080fd5b6020830191508360018202830111156102da57600080fd5b9250929050565b6000813590506102f08161058c565b92915050565b6000806020838503121561030957600080fd5b600083013567ffffffffffffffff81111561032357600080fd5b61032f85828601610297565b92509250509250929050565b60006020828403121561034d57600080fd5b600061035b848285016102e1565b91505092915050565b61036d8161049c565b82525050565b600061037f838561048b565b935061038c8385846104d8565b6103958361057b565b840190509392505050565b60006103ab82610480565b6103b5818561048b565b93506103c58185602086016104e7565b6103ce8161057b565b840191505092915050565b6103e2816104ce565b82525050565b60006040820190506103fd6000830186610364565b8181036020830152610410818486610373565b9050949350505050565b600060408201905061042f6000830185610364565b61043c60208301846103d9565b9392505050565b6000602082019050818103600083015261045d81846103a0565b905092915050565b600060208201905061047a60008301846103d9565b92915050565b600081519050919050565b600082825260208201905092915050565b60006104a7826104ae565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156105055780820151818401526020810190506104ea565b83811115610514576000848401525b50505050565b6000600282049050600182168061053257607f821691505b602082108114156105465761054561054c565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b610595816104ce565b81146105a057600080fd5b5056fea26469706673582212204f956d7623b7fe0a5a722d01575cc1d310a1a18086a604796ff457447881740864736f6c63430008030033"}
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
pragma solidity 0.8.3;

contract SimpleStorage {
uint data;
uint256 data;
string ipfsHash;

event DataSet(address from);
event DataSet(address from, uint256 data);
event HashSet(address from, string ipfsHash);

function set(uint256 x) public {
data = x;
emit DataSet(msg.sender);
emit DataSet(msg.sender, x);
}

function get() public view returns (uint256) {
return data;
}

function setHash(string calldata x) public {
ipfsHash = x;
emit HashSet(msg.sender, x);
}

function getHash() public view returns (string memory) {
return ipfsHash;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// NOTE: This file is auto-generate, see deploy-contract.js
export const abi = `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]`;
export const bytecode = "0x608060405234801561001057600080fd5b506101da806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806360fe47b11461003b5780636d4ce63c14610057575b600080fd5b610055600480360381019061005091906100d4565b610075565b005b61005f6100b6565b60405161006c9190610136565b60405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec336040516100ab919061011b565b60405180910390a150565b60008054905090565b6000813590506100ce8161018d565b92915050565b6000602082840312156100e657600080fd5b60006100f4848285016100bf565b91505092915050565b61010681610151565b82525050565b61011581610183565b82525050565b600060208201905061013060008301846100fd565b92915050565b600060208201905061014b600083018461010c565b92915050565b600061015c82610163565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61019681610183565b81146101a157600080fd5b5056fea26469706673582212201c077cc51c9ee22b2559a72a23b493543955b232bac1b59a2e6f2b89ac0bf39d64736f6c63430008030033";
export const abi = `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"data","type":"uint256"}],"name":"DataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"HashSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"setHash","outputs":[],"stateMutability":"nonpayable","type":"function"}]`;
export const bytecode = "0x608060405234801561001057600080fd5b506105d9806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ed83fd41461005157806360fe47b11461006d5780636d4ce63c14610089578063d13319c4146100a7575b600080fd5b61006b600480360381019061006691906102f6565b6100c5565b005b6100876004803603810190610082919061033b565b610116565b005b610091610159565b60405161009e9190610465565b60405180910390f35b6100af610162565b6040516100bc9190610443565b60405180910390f35b8181600191906100d69291906101f4565b507f7701f49eb9aabe8890631508a9092eabb511a34566c30f2d94ff4420da1ccb1333838360405161010a939291906103e8565b60405180910390a15050565b806000819055507f7c94a94848d5859b1a30c887dc5740bf8d1cf789779be90adda1d0d34dd25022338260405161014e92919061041a565b60405180910390a150565b60008054905090565b6060600180546101719061051a565b80601f016020809104026020016040519081016040528092919081815260200182805461019d9061051a565b80156101ea5780601f106101bf576101008083540402835291602001916101ea565b820191906000526020600020905b8154815290600101906020018083116101cd57829003601f168201915b5050505050905090565b8280546102009061051a565b90600052602060002090601f0160209004810192826102225760008555610269565b82601f1061023b57803560ff1916838001178555610269565b82800160010185558215610269579182015b8281111561026857823582559160200191906001019061024d565b5b509050610276919061027a565b5090565b5b8082111561029357600081600090555060010161027b565b5090565b60008083601f8401126102a957600080fd5b8235905067ffffffffffffffff8111156102c257600080fd5b6020830191508360018202830111156102da57600080fd5b9250929050565b6000813590506102f08161058c565b92915050565b6000806020838503121561030957600080fd5b600083013567ffffffffffffffff81111561032357600080fd5b61032f85828601610297565b92509250509250929050565b60006020828403121561034d57600080fd5b600061035b848285016102e1565b91505092915050565b61036d8161049c565b82525050565b600061037f838561048b565b935061038c8385846104d8565b6103958361057b565b840190509392505050565b60006103ab82610480565b6103b5818561048b565b93506103c58185602086016104e7565b6103ce8161057b565b840191505092915050565b6103e2816104ce565b82525050565b60006040820190506103fd6000830186610364565b8181036020830152610410818486610373565b9050949350505050565b600060408201905061042f6000830185610364565b61043c60208301846103d9565b9392505050565b6000602082019050818103600083015261045d81846103a0565b905092915050565b600060208201905061047a60008301846103d9565b92915050565b600081519050919050565b600082825260208201905092915050565b60006104a7826104ae565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156105055780820151818401526020810190506104ea565b83811115610514576000848401525b50505050565b6000600282049050600182168061053257607f821691505b602082108114156105465761054561054c565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b610595816104ce565b81146105a057600080fd5b5056fea26469706673582212204f956d7623b7fe0a5a722d01575cc1d310a1a18086a604796ff457447881740864736f6c63430008030033";
6 changes: 4 additions & 2 deletions packages/templates/api/assemblyscript/src/mutation/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Ethereum_Mutation } from "./w3/imported";
import { Input_setData } from "./w3";
import {
Ethereum_Mutation,
Input_setData
} from "./w3";
import { abi, bytecode } from "../contracts/SimpleStorage";

export function setData(input: Input_setData): string {
Expand Down
Loading