Skip to content

Commit afed387

Browse files
committed
build, test, lint all passing
1 parent dab425d commit afed387

51 files changed

Lines changed: 367 additions & 188 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/cli/src/__tests__/e2e/query.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ ${HELP}`);
5353
cwd: projectRoot
5454
}, "../../../bin/w3");
5555

56-
expect(buildCode).toEqual(0);
5756
expect(buildErr).toBe("");
57+
expect(buildCode).toEqual(0);
5858

5959
const { exitCode: code, stdout: output, stderr: queryErr } = await runCLI({
6060
args: ["query", "./recipes/e2e.json", "--test-ens"],
@@ -72,6 +72,9 @@ mutation {
7272
address: $address
7373
value: $value
7474
}
75+
connection: {
76+
networkNameOrChainId: $network
77+
}
7578
) {
7679
value
7780
txReceipt
@@ -80,7 +83,8 @@ mutation {
8083
8184
{
8285
"address": "${constants.SimpleStorageAddr}",
83-
"value": 569
86+
"value": 569,
87+
"network": "testnet"
8488
}
8589
-----------------------------------
8690
-----------------------------------

packages/cli/src/__tests__/project/deploy-contracts.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ async function main() {
1212
});
1313

1414
const address = await eth.deployContract(
15-
contractAbi.abi, `0x${contractAbi.bytecode.object}`
15+
contractAbi.abi, `0x${contractAbi.bytecode.object}`, [], {
16+
networkNameOrChainId: "testnet"
17+
}
1618
);
1719

1820
console.log(`✔️ SimpleStorage live at: ${address}`)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[
22
{
3-
"api": "ens/simplestorage.eth",
3+
"api": "ens/testnet/simplestorage.eth",
44
"constants": "./constants.json"
55
},
66
{
77
"query": "./set.graphql",
88
"variables": {
99
"address": "$SimpleStorageAddr",
10-
"value": 569
10+
"value": 569,
11+
"network": "testnet"
1112
}
1213
}
1314
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
query {
22
getData(
33
address: $address
4+
connection: {
5+
networkNameOrChainId: $network
6+
}
47
)
58
}

packages/cli/src/__tests__/project/recipes/set.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ mutation {
44
address: $address
55
value: $value
66
}
7+
connection: {
8+
networkNameOrChainId: $network
9+
}
710
) {
811
value
912
txReceipt

packages/cli/src/__tests__/project/sample.ts

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ export const composedSchema = {
2626
"\n" +
2727
"type Query @imports(\n" +
2828
" types: [\n" +
29-
' "Ethereum_Query"\n' +
29+
' "Ethereum_Query",\n' +
30+
' "Ethereum_Connection"\n' +
3031
" ]\n" +
3132
") {\n" +
3233
" getData(\n" +
3334
" address: String!\n" +
35+
" connection: Ethereum_Connection\n" +
3436
" ): UInt32!\n" +
3537
"}\n" +
3638
"\n" +
@@ -44,15 +46,24 @@ export const composedSchema = {
4446
" callView(\n" +
4547
" address: String!\n" +
4648
" method: String!\n" +
47-
" args: [String!]!\n" +
48-
" network: String\n" +
49+
" args: [String!]\n" +
50+
" connection: Ethereum_Connection\n" +
4951
" ): String!\n" +
5052
"}\n" +
5153
"\n" +
5254
"### Imported Queries END ###\n" +
5355
"\n" +
5456
"### Imported Objects START ###\n" +
5557
"\n" +
58+
"type Ethereum_Connection @imported(\n" +
59+
" uri: \"w3://ens/ethereum.web3api.eth\",\n" +
60+
" namespace: \"Ethereum\",\n" +
61+
" nativeType: \"Connection\"\n" +
62+
") {\n" +
63+
" node: String\n" +
64+
" networkNameOrChainId: String\n" +
65+
"}\n" +
66+
"\n" +
5667
"### Imported Objects END ###\n",
5768
mutation:
5869
"### Web3API Header START ###\n" +
@@ -81,14 +92,18 @@ export const composedSchema = {
8192
"\n" +
8293
"type Mutation @imports(\n" +
8394
" types: [\n" +
84-
' "Ethereum_Mutation"\n' +
95+
' "Ethereum_Mutation",\n' +
96+
' "Ethereum_Connection"\n' +
8597
" ]\n" +
8698
") {\n" +
8799
" setData(\n" +
88100
" options: SetDataOptions!\n" +
101+
" connection: Ethereum_Connection\n" +
89102
" ): SetDataResult!\n" +
90103
"\n" +
91-
" deployContract: String!\n" +
104+
" deployContract(\n" +
105+
" connection: Ethereum_Connection\n" +
106+
" ): String!\n" +
92107
"}\n" +
93108
"\n" +
94109
"type SetDataOptions {\n" +
@@ -111,19 +126,31 @@ export const composedSchema = {
111126
" sendTransaction(\n" +
112127
" address: String!\n" +
113128
" method: String!\n" +
114-
" args: [String!]!\n" +
129+
" args: [String!]\n" +
130+
" connection: Ethereum_Connection\n" +
115131
" ): String!\n" +
116132
"\n" +
117133
" deployContract(\n" +
118134
" abi: String!\n" +
119135
" bytecode: String!\n" +
136+
" args: [String!]\n" +
137+
" connection: Ethereum_Connection\n" +
120138
" ): String!\n" +
121139
"}\n" +
122140
"\n" +
123141
"### Imported Queries END ###\n" +
124142
"\n" +
125143
"### Imported Objects START ###\n" +
126144
"\n" +
145+
"type Ethereum_Connection @imported(\n" +
146+
" uri: \"w3://ens/ethereum.web3api.eth\",\n" +
147+
" namespace: \"Ethereum\",\n" +
148+
" nativeType: \"Connection\"\n" +
149+
") {\n" +
150+
" node: String\n" +
151+
" networkNameOrChainId: String\n" +
152+
"}\n" +
153+
"\n" +
127154
"### Imported Objects END ###\n",
128155
combined:
129156
"### Web3API Header START ###\n" +
@@ -152,24 +179,30 @@ export const composedSchema = {
152179
"\n" +
153180
"type Query @imports(\n" +
154181
" types: [\n" +
155-
' "Ethereum_Query"\n' +
182+
' "Ethereum_Query",\n' +
183+
' "Ethereum_Connection"\n' +
156184
" ]\n" +
157185
") {\n" +
158186
" getData(\n" +
159187
" address: String!\n" +
188+
" connection: Ethereum_Connection\n" +
160189
" ): UInt32!\n" +
161190
"}\n" +
162191
"\n" +
163192
"type Mutation @imports(\n" +
164193
" types: [\n" +
165-
' "Ethereum_Mutation"\n' +
194+
' "Ethereum_Mutation",\n' +
195+
' "Ethereum_Connection"\n' +
166196
" ]\n" +
167197
") {\n" +
168198
" setData(\n" +
169199
" options: SetDataOptions!\n" +
200+
" connection: Ethereum_Connection\n" +
170201
" ): SetDataResult!\n" +
171202
"\n" +
172-
" deployContract: String!\n" +
203+
" deployContract(\n" +
204+
" connection: Ethereum_Connection\n" +
205+
" ): String!\n" +
173206
"}\n" +
174207
"\n" +
175208
"type SetDataOptions {\n" +
@@ -192,8 +225,8 @@ export const composedSchema = {
192225
" callView(\n" +
193226
" address: String!\n" +
194227
" method: String!\n" +
195-
" args: [String!]!\n" +
196-
" network: String\n" +
228+
" args: [String!]\n" +
229+
" connection: Ethereum_Connection\n" +
197230
" ): String!\n" +
198231
"}\n" +
199232
"\n" +
@@ -205,18 +238,30 @@ export const composedSchema = {
205238
" sendTransaction(\n" +
206239
" address: String!\n" +
207240
" method: String!\n" +
208-
" args: [String!]!\n" +
241+
" args: [String!]\n" +
242+
" connection: Ethereum_Connection\n" +
209243
" ): String!\n" +
210244
"\n" +
211245
" deployContract(\n" +
212246
" abi: String!\n" +
213247
" bytecode: String!\n" +
248+
" args: [String!]\n" +
249+
" connection: Ethereum_Connection\n" +
214250
" ): String!\n" +
215251
"}\n" +
216252
"\n" +
217253
"### Imported Queries END ###\n" +
218254
"\n" +
219255
"### Imported Objects START ###\n" +
220256
"\n" +
257+
"type Ethereum_Connection @imported(\n" +
258+
" uri: \"w3://ens/ethereum.web3api.eth\",\n" +
259+
" namespace: \"Ethereum\",\n" +
260+
" nativeType: \"Connection\"\n" +
261+
") {\n" +
262+
" node: String\n" +
263+
" networkNameOrChainId: String\n" +
264+
"}\n" +
265+
"\n" +
221266
"### Imported Objects END ###\n",
222267
};
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Ethereum_Mutation } from "./w3/imported";
2-
import { Input_setData, SetDataResult } from "./w3";
2+
import { Input_setData, Input_deployContract, SetDataResult } from "./w3";
33

44
export function setData(input: Input_setData): SetDataResult {
55
const hash = Ethereum_Mutation.sendTransaction({
66
address: input.options.address,
77
method: "function set(uint256 value)",
8-
args: [input.options.value.toString()]
8+
args: [input.options.value.toString()],
9+
connection: input.connection
910
});
1011

1112
return {
@@ -14,9 +15,11 @@ export function setData(input: Input_setData): SetDataResult {
1415
};
1516
}
1617

17-
export function deployContract(): string {
18+
export function deployContract(input: Input_deployContract): string {
1819
return Ethereum_Mutation.deployContract({
1920
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"}]`,
20-
bytecode: "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033"
21+
bytecode: "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033",
22+
args: null,
23+
connection: input.connection
2124
});
2225
}

packages/cli/src/__tests__/project/src/mutation/schema.graphql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#import { Mutation } into Ethereum from "w3://ens/ethereum.web3api.eth"
1+
#import { Mutation, Connection } into Ethereum from "w3://ens/ethereum.web3api.eth"
22

33
type Mutation {
44
setData(
55
options: SetDataOptions!
6+
connection: Ethereum_Connection
67
): SetDataResult!
78

8-
deployContract: String!
9+
deployContract(
10+
connection: Ethereum_Connection
11+
): String!
912
}
1013

1114
type SetDataOptions {

packages/cli/src/__tests__/project/src/query/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export function getData(input: Input_getData): u32 {
55
const res = Ethereum_Query.callView({
66
address: input.address,
77
method: "function get() view returns (uint256)",
8-
args: []
8+
args: null,
9+
connection: input.connection
910
});
1011

1112
return U32.parseInt(res);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#import { Query } into Ethereum from "w3://ens/ethereum.web3api.eth"
1+
#import { Query, Connection } into Ethereum from "w3://ens/ethereum.web3api.eth"
22

33
type Query {
44
getData(
55
address: String!
6+
connection: Ethereum_Connection
67
): UInt32!
78
}

0 commit comments

Comments
 (0)