Skip to content

Commit 0be151d

Browse files
authored
Merge pull request #274 from Web3-API/prealpha-dev
Prep 0.0.1-prealpha.14
2 parents c43fbd8 + 0f28683 commit 0be151d

60 files changed

Lines changed: 797 additions & 299 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.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Web3API 0.0.1-prealpha.14
2+
## Features
3+
* Network Specific ENS Lookup
4+
* `@web3api/ethereum-plugin-js`: The EthereumPlugin can now be constructed with multiple network connections (mainnet, rinkeby, testnet, etc).
5+
* All Query & Mutation methods now accept an optional `connection` property which can be used to configure a specific network to be used for the action.
6+
* `@web3api/ens-plugin-js`: The EnsPlugin can now handle URIs that address specific networks. For example: `w3://ens/testnet/myweb3api.eth`. It will request the `testnet` connection to be used when querying the Ethereum Web3API.
7+
18
# Web3API 0.0.1-prealpha.13
29
## Features
310
* Improved template projects that are used with the `w3 create ...` CLI command.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1-prealpha.13
1+
0.0.1-prealpha.14

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ async function main() {
66
const contractAbi = require(`${__dirname}/src/contracts/SimpleStorage.json`);
77

88
const eth = new EthereumPlugin({
9-
provider: "http://localhost:8545"
9+
testnet: {
10+
provider: "http://localhost:8545"
11+
}
1012
});
1113

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

1620
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 & 10 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,14 +46,24 @@ export const composedSchema = {
4446
" callView(\n" +
4547
" address: String!\n" +
4648
" method: String!\n" +
47-
" args: [String!]!\n" +
49+
" args: [String!]\n" +
50+
" connection: Ethereum_Connection\n" +
4851
" ): String!\n" +
4952
"}\n" +
5053
"\n" +
5154
"### Imported Queries END ###\n" +
5255
"\n" +
5356
"### Imported Objects START ###\n" +
5457
"\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" +
5567
"### Imported Objects END ###\n",
5668
mutation:
5769
"### Web3API Header START ###\n" +
@@ -80,14 +92,18 @@ export const composedSchema = {
8092
"\n" +
8193
"type Mutation @imports(\n" +
8294
" types: [\n" +
83-
' "Ethereum_Mutation"\n' +
95+
' "Ethereum_Mutation",\n' +
96+
' "Ethereum_Connection"\n' +
8497
" ]\n" +
8598
") {\n" +
8699
" setData(\n" +
87100
" options: SetDataOptions!\n" +
101+
" connection: Ethereum_Connection\n" +
88102
" ): SetDataResult!\n" +
89103
"\n" +
90-
" deployContract: String!\n" +
104+
" deployContract(\n" +
105+
" connection: Ethereum_Connection\n" +
106+
" ): String!\n" +
91107
"}\n" +
92108
"\n" +
93109
"type SetDataOptions {\n" +
@@ -110,19 +126,31 @@ export const composedSchema = {
110126
" sendTransaction(\n" +
111127
" address: String!\n" +
112128
" method: String!\n" +
113-
" args: [String!]!\n" +
129+
" args: [String!]\n" +
130+
" connection: Ethereum_Connection\n" +
114131
" ): String!\n" +
115132
"\n" +
116133
" deployContract(\n" +
117134
" abi: String!\n" +
118135
" bytecode: String!\n" +
136+
" args: [String!]\n" +
137+
" connection: Ethereum_Connection\n" +
119138
" ): String!\n" +
120139
"}\n" +
121140
"\n" +
122141
"### Imported Queries END ###\n" +
123142
"\n" +
124143
"### Imported Objects START ###\n" +
125144
"\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" +
126154
"### Imported Objects END ###\n",
127155
combined:
128156
"### Web3API Header START ###\n" +
@@ -151,24 +179,30 @@ export const composedSchema = {
151179
"\n" +
152180
"type Query @imports(\n" +
153181
" types: [\n" +
154-
' "Ethereum_Query"\n' +
182+
' "Ethereum_Query",\n' +
183+
' "Ethereum_Connection"\n' +
155184
" ]\n" +
156185
") {\n" +
157186
" getData(\n" +
158187
" address: String!\n" +
188+
" connection: Ethereum_Connection\n" +
159189
" ): UInt32!\n" +
160190
"}\n" +
161191
"\n" +
162192
"type Mutation @imports(\n" +
163193
" types: [\n" +
164-
' "Ethereum_Mutation"\n' +
194+
' "Ethereum_Mutation",\n' +
195+
' "Ethereum_Connection"\n' +
165196
" ]\n" +
166197
") {\n" +
167198
" setData(\n" +
168199
" options: SetDataOptions!\n" +
200+
" connection: Ethereum_Connection\n" +
169201
" ): SetDataResult!\n" +
170202
"\n" +
171-
" deployContract: String!\n" +
203+
" deployContract(\n" +
204+
" connection: Ethereum_Connection\n" +
205+
" ): String!\n" +
172206
"}\n" +
173207
"\n" +
174208
"type SetDataOptions {\n" +
@@ -191,7 +225,8 @@ export const composedSchema = {
191225
" callView(\n" +
192226
" address: String!\n" +
193227
" method: String!\n" +
194-
" args: [String!]!\n" +
228+
" args: [String!]\n" +
229+
" connection: Ethereum_Connection\n" +
195230
" ): String!\n" +
196231
"}\n" +
197232
"\n" +
@@ -203,18 +238,30 @@ export const composedSchema = {
203238
" sendTransaction(\n" +
204239
" address: String!\n" +
205240
" method: String!\n" +
206-
" args: [String!]!\n" +
241+
" args: [String!]\n" +
242+
" connection: Ethereum_Connection\n" +
207243
" ): String!\n" +
208244
"\n" +
209245
" deployContract(\n" +
210246
" abi: String!\n" +
211247
" bytecode: String!\n" +
248+
" args: [String!]\n" +
249+
" connection: Ethereum_Connection\n" +
212250
" ): String!\n" +
213251
"}\n" +
214252
"\n" +
215253
"### Imported Queries END ###\n" +
216254
"\n" +
217255
"### Imported Objects START ###\n" +
218256
"\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" +
219266
"### Imported Objects END ###\n",
220267
};
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 {

0 commit comments

Comments
 (0)