Skip to content

Commit

Permalink
added test script for balances (paritytech#276)
Browse files Browse the repository at this point in the history
* added test script

* update type

* publish types
  • Loading branch information
joelamouche authored Mar 11, 2021
1 parent 302187d commit 601d78c
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 111 deletions.
1 change: 1 addition & 0 deletions moonbeam-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const moonbeamDefinitions = {
minmax: [19, undefined],
types: {
AccountId: "EthereumAccountId",
AccountInfo: "AccountInfoWithProviders",
Address: "AccountId",
Balance: "u128",
LookupSource: "AccountId",
Expand Down
2 changes: 1 addition & 1 deletion moonbeam-types-bundle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moonbeam-types-bundle",
"version": "1.1.8",
"version": "1.1.9",
"description": "Bundled types to instantiate the Polkadot JS api with a Moonbeam network",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
9 changes: 4 additions & 5 deletions tools/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "frontier-contract-web3",
"version": "0.0.0",
"name": "moonbeam-tools",
"version": "0.0.1",
"dependencies": {
"@polkadot/api": "^3.11.1",
"@polkadot/util-crypto": "^5.9.2",
"@polkadot/api": "^4.0.3",
"@polkadot/util-crypto": "^6.0.5",
"bip39": "^3.0.3",
"eth-block-tracker": "^4.4.3",
"ethereumjs-wallet": "^1.0.0",
Expand All @@ -13,7 +13,6 @@
"polkadot-launch": "PureStake/polkadot-launch#moonbeam-launch",
"rlp": "^2.2.6",
"solc": "^0.8.0",
"substrate-evm-contracts": "file:truffle",
"truffle-privatekey-provider": "^1.5.0",
"ts-node": "^8.10.1",
"typescript": "^3.9.5",
Expand Down
24 changes: 24 additions & 0 deletions tools/test-alpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ApiPromise, WsProvider } from "@polkadot/api";
import Web3 from "web3";
import { typesBundle } from "../moonbeam-types-bundle";
const wsProviderUrl = `wss://wss.testnet.moonbeam.network`;
const GERALD = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d";

export default async function test(ACC: string) {
const web3 = new Web3(wsProviderUrl);
let balance = await web3.eth.getBalance(ACC);
console.log("BALANCE WEB3", balance.toString());

const wsProvider = new WsProvider(wsProviderUrl);
const polkadotApi = await ApiPromise.create({
provider: wsProvider,
typesBundle: typesBundle as any,
});
const account = await polkadotApi.query.system.account(ACC);
// console.log("BALANCE API", account.data.feeFrozen.toString());
// console.log("BALANCE API", account.data.miscFrozen.toString());
// console.log("BALANCE API", account.data.reserved.toString());
console.log("BALANCE API", account.data.free.toString());
}
test(FAITH);
Loading

0 comments on commit 601d78c

Please sign in to comment.