Skip to content

Commit

Permalink
Merge pull request #620 from polywrap/nk/plugin-modules
Browse files Browse the repository at this point in the history
feat: improve plugin development experience
  • Loading branch information
dOrgJelli authored Apr 21, 2022
2 parents 34e0f45 + f696344 commit ba8ff13
Show file tree
Hide file tree
Showing 279 changed files with 11,084 additions and 6,931 deletions.
38 changes: 0 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,44 +132,6 @@ module.exports = {
{
files: ["*.json"],
extends: ["plugin:json/recommended"],
},
{
files: ["*.graphql"],
plugins: ["@graphql-eslint"],
parser: "@graphql-eslint/eslint-plugin",
rules: {
"function-call-argument-newline": ["error"],
"@graphql-eslint/avoid-typename-prefix": ["warn"],
"@graphql-eslint/no-hashtag-description": ["off"],
"@graphql-eslint/require-deprecation-reason": ["error"],
"@graphql-eslint/no-case-insensitive-enum-values-duplicates": ["error"],
"@graphql-eslint/description-style": ["warn", {"style":"inline"}],
"@graphql-eslint/avoid-duplicate-fields": ["error"],
"@graphql-eslint/naming-convention": ["error",
{
"FieldDefinition":"camelCase",
"InputObjectTypeDefinition":"PascalCase",
"EnumValueDefinition":"UPPER_CASE",
"InputValueDefinition":"camelCase",
"ObjectTypeDefinition":"PascalCase",
"InterfaceTypeDefinition":"PascalCase",
"EnumTypeDefinition":"PascalCase",
"UnionTypeDefinition":"PascalCase",
"ScalarTypeDefinition":"PascalCase",
"OperationDefinition":"PascalCase",
"FragmentDefinition":"PascalCase",
"QueryDefinition":"camelCase",
"leadingUnderscore":"forbid",
"trailingUnderscore":"forbid"
}],
"@graphql-eslint/possible-type-extension": ["error"],
"@graphql-eslint/unique-operation-name": ["error"],
"@graphql-eslint/unique-directive-names": ["error"],
"@graphql-eslint/unique-enum-value-names": ["error"],
"@graphql-eslint/unique-field-definition-names": ["error"],
"@graphql-eslint/unique-input-field-names": ["error"],
"@graphql-eslint/unique-type-names": ["error"],
}
}
]
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
"clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.w3",
"install:dependencies": "cd dependencies && yarn",
"preinstall": "yarn install:dependencies",
"build": "yarn build:core && yarn build:plugins && yarn build:client && yarn build:cli",
"build": "yarn build:core && yarn build:plugins && yarn build:client && yarn build:cli && yarn build:plugins:migrate",
"build:core": "lerna run build --no-private --ignore @web3api/*-plugin-js --ignore @web3api/cli* --ignore @web3api/react",
"build:plugins": "lerna run build --scope @web3api/*-plugin-js --concurrency 1",
"build:plugins:migrate": "lerna run build:migrate --scope @web3api/*-plugin-js --concurrency 1",
"build:client": "lerna run build --scope @web3api/client-js --scope @web3api/react",
"build:cli": "lerna run build --scope @web3api/cli",
"lint": "lerna run lint",
Expand All @@ -51,7 +52,6 @@
"eslint-plugin-prettier": "3.4.0",
"prettier": "2.2.1",
"graphql": "15.5.0",
"@graphql-eslint/eslint-plugin": "1.0.1",
"eslint-plugin-json": "3.0.0"
},
"resolutions": {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/__tests__/e2e/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ ${HELP}`);
`);

const expectedTypesResult = compareSync(
`${projectRoot}/src/w3`,
`${projectRoot}/src`,
`${projectRoot}/expected-types`,
{ compareContent: true }
);

expect(expectedTypesResult.differences).toBe(0);

const expectedBuildResult = compareSync(
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/__tests__/plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!expected-types/w3
!expected-types/query/w3
!expected-types/mutation/w3
233 changes: 115 additions & 118 deletions packages/cli/src/__tests__/plugin/expected-build/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,24 @@ directive @annotate(type: String!) on FIELD

### Web3API Header END ###

type Query @imports(
type Mutation @imports(
types: [
"Ethereum_Query",
"Ethereum_Mutation",
"Ethereum_Connection",
"Ethereum_TxOverrides",
"Ethereum_StaticTxResult",
"Ethereum_TxRequest",
"Ethereum_TxResponse",
"Ethereum_Access",
"Ethereum_TxReceipt",
"Ethereum_Log",
"Ethereum_EventNotification",
"Ethereum_Network",
"Ethereum_Mutation",
"Ethereum_TxResponse",
"Ethereum_Access"
"Ethereum_TxRequest"
]
) {
method(
str: String!
optStr: String
): Object!
arg: UInt32!
): String!
}

type Mutation @imports(
type Query @imports(
types: [
"Ethereum_Query",
"Ethereum_Connection",
Expand All @@ -67,15 +62,17 @@ type Mutation @imports(
"Ethereum_TxReceipt",
"Ethereum_Log",
"Ethereum_EventNotification",
"Ethereum_Network",
"Ethereum_Mutation",
"Ethereum_TxResponse",
"Ethereum_Access"
"Ethereum_Network"
]
) {
method(
arg: UInt32!
): String!
str: String!
optStr: String
): Object!
}

type QueryEnv {
arg1: String!
}

type Object {
Expand All @@ -86,6 +83,56 @@ type Object {

### Imported Queries START ###

type Ethereum_Mutation @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "Mutation"
) {
callContractMethod(
address: String!
method: String!
args: [String!]
connection: Ethereum_Connection
txOverrides: Ethereum_TxOverrides
): Ethereum_TxResponse!

callContractMethodAndWait(
address: String!
method: String!
args: [String!]
connection: Ethereum_Connection
txOverrides: Ethereum_TxOverrides
): Ethereum_TxReceipt!

sendTransaction(
tx: Ethereum_TxRequest!
connection: Ethereum_Connection
): Ethereum_TxResponse!

sendTransactionAndWait(
tx: Ethereum_TxRequest!
connection: Ethereum_Connection
): Ethereum_TxReceipt!

deployContract(
abi: String!
bytecode: String!
args: [String!]
connection: Ethereum_Connection
): String!

signMessage(
message: String!
connection: Ethereum_Connection
): String!

sendRPC(
method: String!
params: [String!]!
connection: Ethereum_Connection
): String
}

type Ethereum_Query @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
Expand Down Expand Up @@ -200,56 +247,6 @@ type Ethereum_Query @imported(
): Ethereum_Network!
}

type Ethereum_Mutation @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "Mutation"
) {
callContractMethod(
address: String!
method: String!
args: [String!]
connection: Ethereum_Connection
txOverrides: Ethereum_TxOverrides
): Ethereum_TxResponse!

callContractMethodAndWait(
address: String!
method: String!
args: [String!]
connection: Ethereum_Connection
txOverrides: Ethereum_TxOverrides
): Ethereum_TxReceipt!

sendTransaction(
tx: Ethereum_TxRequest!
connection: Ethereum_Connection
): Ethereum_TxResponse!

sendTransactionAndWait(
tx: Ethereum_TxRequest!
connection: Ethereum_Connection
): Ethereum_TxReceipt!

deployContract(
abi: String!
bytecode: String!
args: [String!]
connection: Ethereum_Connection
): String!

signMessage(
message: String!
connection: Ethereum_Connection
): String!

sendRPC(
method: String!
params: [String!]!
connection: Ethereum_Connection
): String
}

### Imported Queries END ###

### Imported Objects START ###
Expand All @@ -273,29 +270,39 @@ type Ethereum_TxOverrides @imported(
value: BigInt
}

type Ethereum_StaticTxResult @imported(
type Ethereum_TxResponse @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "StaticTxResult"
nativeType: "TxResponse"
) {
result: String!
error: Boolean!
hash: String!
to: String
from: String!
nonce: UInt32!
gasLimit: BigInt!
gasPrice: BigInt
data: String!
value: BigInt!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
confirmations: UInt32!
raw: String
r: String
s: String
v: UInt32
type: UInt32
accessList: [Ethereum_Access!]
}

type Ethereum_TxRequest @imported(
type Ethereum_Access @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "TxRequest"
nativeType: "Access"
) {
to: String
from: String
nonce: UInt32
gasLimit: BigInt
gasPrice: BigInt
data: String
value: BigInt
chainId: BigInt
type: UInt32
address: String!
storageKeys: [String!]!
}

type Ethereum_TxReceipt @imported(
Expand Down Expand Up @@ -338,59 +345,49 @@ type Ethereum_Log @imported(
logIndex: UInt32!
}

type Ethereum_EventNotification @imported(
type Ethereum_TxRequest @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "EventNotification"
nativeType: "TxRequest"
) {
data: String!
address: String!
log: Ethereum_Log!
to: String
from: String
nonce: UInt32
gasLimit: BigInt
gasPrice: BigInt
data: String
value: BigInt
chainId: BigInt
type: UInt32
}

type Ethereum_Network @imported(
type Ethereum_StaticTxResult @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "Network"
nativeType: "StaticTxResult"
) {
name: String!
chainId: BigInt!
ensAddress: String
result: String!
error: Boolean!
}

type Ethereum_TxResponse @imported(
type Ethereum_EventNotification @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "TxResponse"
nativeType: "EventNotification"
) {
hash: String!
to: String
from: String!
nonce: UInt32!
gasLimit: BigInt!
gasPrice: BigInt
data: String!
value: BigInt!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
confirmations: UInt32!
raw: String
r: String
s: String
v: UInt32
type: UInt32
accessList: [Ethereum_Access!]
address: String!
log: Ethereum_Log!
}

type Ethereum_Access @imported(
type Ethereum_Network @imported(
uri: "ens/ethereum.web3api.eth",
namespace: "Ethereum",
nativeType: "Access"
nativeType: "Network"
) {
address: String!
storageKeys: [String!]!
name: String!
chainId: BigInt!
ensAddress: String
}

### Imported Objects END ###
Loading

0 comments on commit ba8ff13

Please sign in to comment.