Skip to content

Commit

Permalink
Bump provider v0.0.1-rc8 (#2)
Browse files Browse the repository at this point in the history
* bump provider 0.0.1-rc8

* rm unused env var
  • Loading branch information
RetricSu authored Aug 20, 2021
1 parent 1a5dd1c commit a03094c
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 28 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ create `.env` file. (due to React's env variable issue, the extra `REACT_APP_` p
```sh
cat > ./.env <<EOF
REACT_APP_WEB3_JSON_RPC=<godwoken web3 rpc>
REACT_APP_ROLLUP_TYPE_HASH=<godwoken rollup type hash>
REACT_APP_ETH_ACCOUNT_LOCK_CODE_HASH=<eth account lock code hash>
REACT_APP_WEB3_WS_JSON_RPC=<godwoken web3 websocket rpc>
REACT_APP_PRIVATE_KEY=<your eth test private key, do not use in production>
REACT_APP_ETH_ADDRESS=<your eth test address, match with private_key above>
EOF
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@polyjuice-provider/ethers": "^0.0.1-rc6",
"@polyjuice-provider/web3": "^0.0.1-rc6",
"@polyjuice-provider/ethers": "^0.0.1-rc8",
"@polyjuice-provider/web3": "^0.0.1-rc8",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand Down
41 changes: 41 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import "./App.css";
import { AbiItems } from "@polyjuice-provider/base";
import {
polyjuiceWallet,
polyjuiceWalletWebsocket,
polyjuiceWebsocketProvider,
polyjuiceWeb3HttpProvider,
polyjuiceWeb3,
ethersWeb3Provider,
Expand Down Expand Up @@ -162,6 +164,33 @@ function App() {
console.log(txResponse);
};

const [newBlockNumber, setNewBlockNumber] = useState<number | string>();
const [isStartSubscribeBlockNumber, setIsStartSubscribeBlockNumber] = useState<boolean>(false);
const subscribeBlocks = () => {
setIsStartSubscribeBlockNumber(true);
polyjuiceWebsocketProvider.on("block", (data)=>{
setNewBlockNumber(data);
})
}

const sendTxUsingEthersContractWithPkWalletSigning = async () => {
const simpleStorageV2Contract = new ethers.Contract(
(deployedContractAddress || process.env.REACT_APP_EXAMPLE_CONTRACT_ADDRESS)!,
SIMPLE_STORAGE_V2_ABI,
polyjuiceWalletWebsocket
);
let overrides = {
gasLimit: 0x54d30,
gasPrice: 0x0,
value: 0x0,
};
const txResponse = await simpleStorageV2Contract.set(
process.env.REACT_APP_ETH_ADDRESS,
overrides
);
console.log(txResponse);
};

return (
<div className="App">
<header>
Expand Down Expand Up @@ -191,6 +220,18 @@ function App() {
sendTxUsingEthersContractWithMetamaskSigning
</button>
</p>
<p>
<button onClick={sendTxUsingEthersContractWithPkWalletSigning}>
sendTxUsingEthersContractWithPkWalletSigning
</button>
</p>
<p>
<button onClick={subscribeBlocks}>
subscribeBlocks
</button>
<p> subscribe status: {isStartSubscribeBlockNumber ? "running" : "not yet"} </p>
<h4>new Block Number: {newBlockNumber}</h4>
</p>
</header>
</div>
);
Expand Down
19 changes: 14 additions & 5 deletions src/godwoken.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
PolyjuiceConfig,
PolyjuiceWallet,
PolyjuiceJsonRpcProvider,
PolyjuiceWebsocketProvider
} from "@polyjuice-provider/ethers";
import { PolyjuiceHttpProvider } from "@polyjuice-provider/web3";
import { providers, Signer } from "ethers";
import { AbiItems } from "@polyjuice-provider/base";
import { AbiItems, PolyjuiceConfig } from "@polyjuice-provider/base";
import Web3 from "web3";

// !do not use dotenv in production,
Expand Down Expand Up @@ -79,11 +79,11 @@ export const SIMPLE_STORAGE_V2_BYTECODE =
"0x608060405234801561001057600080fd5b50610882806100206000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80632801617e146100675780634ef65c3b146100835780636d4ce63c1461009f5780639f494991146100bd578063d1d1a6f3146100d9578063d504ea1d146100f7575b600080fd5b610081600480360361007c91908101906104cb565b610115565b005b61009d60048036036100989190810190610535565b610158565b005b6100a7610162565b6040516100b491906106af565b60405180910390f35b6100d760048036036100d291908101906104f4565b61018b565b005b6100e16101a5565b6040516100ee91906106ec565b60405180910390f35b6100ff61028c565b60405161010c91906106ca565b60405180910390f35b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b8060028190555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b80600190805190602001906101a192919061031a565b5050565b6101ad6103a4565b604051806060016040528060025481526020016000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600180548060200260200160405190810160405280929190818152602001828054801561027f57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610235575b5050505050815250905090565b6060600180548060200260200160405190810160405280929190818152602001828054801561031057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116102c6575b5050505050905090565b828054828255906000526020600020908101928215610393579160200282015b828111156103925782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061033a565b5b5090506103a091906103db565b5090565b604051806060016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001606081525090565b61041b91905b8082111561041757600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016103e1565b5090565b90565b60008135905061042d81610811565b92915050565b600082601f83011261044457600080fd5b81356104576104528261073b565b61070e565b9150818183526020840193506020810190508385602084028201111561047c57600080fd5b60005b838110156104ac5781610492888261041e565b84526020840193506020830192505060018101905061047f565b5050505092915050565b6000813590506104c581610828565b92915050565b6000602082840312156104dd57600080fd5b60006104eb8482850161041e565b91505092915050565b60006020828403121561050657600080fd5b600082013567ffffffffffffffff81111561052057600080fd5b61052c84828501610433565b91505092915050565b60006020828403121561054757600080fd5b6000610555848285016104b6565b91505092915050565b600061056a8383610576565b60208301905092915050565b61057f816107d5565b82525050565b61058e816107d5565b82525050565b600061059f8261078e565b6105a981856107c4565b93506105b483610773565b8060005b838110156105e55781516105cc888261055e565b97506105d7836107a6565b9250506001810190506105b8565b5085935050505092915050565b60006105fd82610783565b61060781856107b3565b935061061283610763565b8060005b8381101561064357815161062a888261055e565b975061063583610799565b925050600181019050610616565b5085935050505092915050565b600060608301600083015161066860008601826106a0565b50602083015161067b6020860182610576565b506040830151848203604086015261069382826105f2565b9150508091505092915050565b6106a981610807565b82525050565b60006020820190506106c46000830184610585565b92915050565b600060208201905081810360008301526106e48184610594565b905092915050565b600060208201905081810360008301526107068184610650565b905092915050565b6000604051905081810181811067ffffffffffffffff8211171561073157600080fd5b8060405250919050565b600067ffffffffffffffff82111561075257600080fd5b602082029050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006107e0826107e7565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61081a816107d5565b811461082557600080fd5b50565b61083181610807565b811461083c57600080fd5b5056fea365627a7a72315820ef73bb2343fb2e9ee8b5eec1bdc20a2589f69bd4bd6560e1a7f335f520a6068f6c6578706572696d656e74616cf564736f6c63430005100040";

export const privateKey = process.env.REACT_APP_PRIVATE_KEY!;
export const httpRpcUrl = process.env.REACT_APP_WEB3_JSON_RPC!;
export const wsRpcUrl = process.env.REACT_APP_WEB3_WS_JSON_RPC!;

export const polyjuiceConfig: PolyjuiceConfig = {
rollupTypeHash: process.env.REACT_APP_ROLLUP_TYPE_HASH!,
ethAccountLockCodeHash: process.env.REACT_APP_ETH_ACCOUNT_LOCK_CODE_HASH!,
web3Url: process.env.REACT_APP_WEB3_JSON_RPC,
web3Url: httpRpcUrl,
abiItems: SIMPLE_STORAGE_V2_ABI as AbiItems
};

Expand All @@ -99,11 +99,20 @@ export const polyjuiceJsonRpcProvider = new PolyjuiceJsonRpcProvider(
polyjuiceConfig,
polyjuiceConfig.web3Url
);
export const polyjuiceWebsocketProvider = new PolyjuiceWebsocketProvider(
polyjuiceConfig,
wsRpcUrl
)
export const polyjuiceWallet = new PolyjuiceWallet(
privateKey,
polyjuiceConfig,
polyjuiceJsonRpcProvider
);
export const polyjuiceWalletWebsocket = new PolyjuiceWallet(
privateKey,
polyjuiceConfig,
polyjuiceWebsocketProvider
);

export const ethersWeb3Provider = new providers.Web3Provider(
polyjuiceWeb3HttpProvider
Expand Down
77 changes: 58 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1888,13 +1888,13 @@
schema-utils "^2.6.5"
source-map "^0.7.3"

"@polyjuice-provider/base@0.0.1-rc6":
version "0.0.1-rc6"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/base/-/base-0.0.1-rc6.tgz#7b9193802caa4cb1e2d18ba8293ce471508830ae"
integrity sha512-cXygyvsOFBxW402QaZM5YoHRX6+mKsI4qz42j06b+/IWOT9cHx1AIdDpOWhtwGf0uZq/9D5hDcxZDCL4fxRnTw==
"@polyjuice-provider/base@0.0.1-rc8":
version "0.0.1-rc8"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/base/-/base-0.0.1-rc8.tgz#0ca920ed099fea00cce6089fa7b07d987b489b5a"
integrity sha512-+KkIYCxwy2FBQFgBQ+5bj355obkHw4HgrIVDzRvHJs8JXoUsQJndwvAV6fvsmazXfTTQDM/tjAC7Gwuwc0Y1PQ==
dependencies:
"@ckb-lumos/base" "^0.16.0"
"@polyjuice-provider/godwoken" "^0.0.1-rc6"
"@polyjuice-provider/godwoken" "^0.0.1-rc8"
buffer "^6.0.3"
encoding "^0.1.13"
eth-sig-util "^3.0.1"
Expand All @@ -1903,35 +1903,36 @@
web3 "^1.3.4"
xhr2-cookies "^1.1.0"

"@polyjuice-provider/ethers@^0.0.1-rc6":
version "0.0.1-rc6"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/ethers/-/ethers-0.0.1-rc6.tgz#6062dc1fdbdfcef2dea423a437bfd6f6031d43fe"
integrity sha512-CWTBLp+OHas1DD8vWDvOYkXjg8rmB4fuPD22X4QJbddMghvnj/hqwbY+rjb7ravjIVs56EkFKOe3uVF+azQoiQ==
"@polyjuice-provider/ethers@^0.0.1-rc8":
version "0.0.1-rc8"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/ethers/-/ethers-0.0.1-rc8.tgz#6960b98bb45122076cdd27673f056ee5c82a285f"
integrity sha512-XR11vQehtFxY/fulgrggbKkX+mJsXrbRYCPIR/VAGDxby+s38ZIE+QiMwhHLMmEJV8tXKTvd5txVZn2ZCuiwZg==
dependencies:
"@polyjuice-provider/base" "0.0.1-rc6"
"@polyjuice-provider/base" "0.0.1-rc8"
buffer "^6.0.3"
encoding "^0.1.13"
ethers "^5.4.0"

"@polyjuice-provider/godwoken@^0.0.1-rc6":
version "0.0.1-rc6"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/godwoken/-/godwoken-0.0.1-rc6.tgz#7a88a38fd3665d2cabf5faa800b27d18a713c572"
integrity sha512-IjtnqKKefiDFnBumZC76YZu6mX8vV95rwrCCtbtDPk5mXJaHx4Th7NnFwrEayU/Ms7m12RDAEbs4TP9qd5Nxlg==
"@polyjuice-provider/godwoken@^0.0.1-rc8":
version "0.0.1-rc8"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/godwoken/-/godwoken-0.0.1-rc8.tgz#fc9861dec2076e60d77cf1d1faf9b15103988007"
integrity sha512-1fTIYs829/GUsO6tiM8Y1ERzNOd1M8+R5raaUOOCNslhkQMR/DGepH4KQsMmjrYndXEbS6lIJlx3/NzdJdgtUQ==
dependencies:
"@ckb-lumos/base" "^0.16.0"
ckb-js-toolkit "^0.9.3"
immutable "^4.0.0-rc.12"
keccak256 "^1.0.2"

"@polyjuice-provider/web3@^0.0.1-rc6":
version "0.0.1-rc6"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/web3/-/web3-0.0.1-rc6.tgz#280ca03dd0caa8a93b82ca8ad904656ece99537e"
integrity sha512-edHAupXCNTMReP5c1ZOPMCNQfo/KsZfuWib3pn1rJ28mE609GWUjyHWb72k23cjovI9KYWN5fD2PTCO0hZ2MqQ==
"@polyjuice-provider/web3@^0.0.1-rc8":
version "0.0.1-rc8"
resolved "https://registry.yarnpkg.com/@polyjuice-provider/web3/-/web3-0.0.1-rc8.tgz#a516994b5ed76cdddb8e5466473f426eee120bbf"
integrity sha512-V50sNG4oZsVMJCzc0pJsvA3JsdVYti+G3OJy77DZxy4qJanXfuz4CrWVQF9bZU0jHZ3DuuevojvhncGbmmTThg==
dependencies:
"@polyjuice-provider/base" "0.0.1-rc6"
"@polyjuice-provider/base" "0.0.1-rc8"
buffer "^6.0.3"
encoding "^0.1.13"
web3 "^1.4.0"
web3-providers-ws "^1.5.2"
xhr2-cookies "^1.1.0"

"@rollup/plugin-node-resolve@^7.1.1":
Expand Down Expand Up @@ -12693,6 +12694,14 @@ web3-core-helpers@1.4.0:
web3-eth-iban "1.4.0"
web3-utils "1.4.0"

web3-core-helpers@1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.5.2.tgz#b6bd5071ca099ba3f92dfafb552eed2b70af2795"
integrity sha512-U7LJoeUdQ3aY9t5gU7t/1XpcApsWm+4AcW5qKl/44ZxD44w0Dmsq1c5zJm3GuLr/a9MwQfXK4lpmvxVQWHHQRg==
dependencies:
web3-eth-iban "1.5.2"
web3-utils "1.5.2"

web3-core-method@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.4.0.tgz#0e26001e4029d359731b25a82e0bed4d1bef8392"
Expand Down Expand Up @@ -12811,6 +12820,14 @@ web3-eth-iban@1.4.0:
bn.js "^4.11.9"
web3-utils "1.4.0"

web3-eth-iban@1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.5.2.tgz#f390ad244ef8a6c94de7c58736b0b80a484abc8e"
integrity sha512-C04YDXuSG/aDwOHSX+HySBGb0KraiAVt+/l1Mw7y/fCUrKC/K0yYzMYqY/uYOcvLtepBPsC4ZfUYWUBZ2PO8Vg==
dependencies:
bn.js "^4.11.9"
web3-utils "1.5.2"

web3-eth-personal@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.4.0.tgz#77420d1f49e36f8c461a61aeabac16045d8592c0"
Expand Down Expand Up @@ -12878,6 +12895,15 @@ web3-providers-ws@1.4.0:
web3-core-helpers "1.4.0"
websocket "^1.0.32"

web3-providers-ws@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.5.2.tgz#d336a93ed608b40cdcadfadd1f1bc8d32ea046e0"
integrity sha512-xy9RGlyO8MbJDuKv2vAMDkg+en+OvXG0CGTCM2BTl6l1vIdHpCa+6A/9KV2rK8aU9OBZ7/Pf+Y19517kHVl9RA==
dependencies:
eventemitter3 "4.0.4"
web3-core-helpers "1.5.2"
websocket "^1.0.32"

web3-shh@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.4.0.tgz#d22ff8dce16987bef73172191d9e95c3ccf0aa80"
Expand All @@ -12902,6 +12928,19 @@ web3-utils@1.4.0:
underscore "1.12.1"
utf8 "3.0.0"

web3-utils@1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.5.2.tgz#150982dcb1918ffc54eba87528e28f009ebc03aa"
integrity sha512-quTtTeQJHYSxAwIBOCGEcQtqdVcFWX6mCFNoqnp+mRbq+Hxbs8CGgO/6oqfBx4OvxIOfCpgJWYVHswRXnbEu9Q==
dependencies:
bn.js "^4.11.9"
eth-lib "0.2.8"
ethereum-bloom-filters "^1.0.6"
ethjs-unit "0.1.6"
number-to-bn "1.7.0"
randombytes "^2.1.0"
utf8 "3.0.0"

web3@^1.3.4, web3@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/web3/-/web3-1.4.0.tgz#717c01723226daebab9274be5cb56644de860688"
Expand Down

0 comments on commit a03094c

Please sign in to comment.