-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from ideal-lab5/feat/17-refactor-create-prepar…
…e-execute feat: construct call with response data
- Loading branch information
Showing
11 changed files
with
239 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Lint Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run Prettier check | ||
run: npx prettier --check . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.vscode | ||
dist | ||
node_modules | ||
package-lock.json | ||
package-lock.json | ||
mmr_store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"printWidth": 80, | ||
"trailingComma": "es5", | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true, | ||
"arrowParens": "always", | ||
"quoteProps": "consistent", | ||
"bracketSpacing": true, | ||
"endOfLine": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import { ApiPromise, WsProvider } from "@polkadot/api"; | ||
import axios from "axios"; | ||
import { MurmurClient } from "murmur.js"; | ||
import { ApiPromise, WsProvider } from '@polkadot/api' | ||
import axios from 'axios' | ||
import { MurmurClient } from 'murmur.js' | ||
|
||
/* Polkadot API initialization */ | ||
const provider = new WsProvider("ws://127.0.0.1:9944"); | ||
console.log("Provider initialized"); | ||
const api = await ApiPromise.create({ provider }); | ||
console.log("API initialized"); | ||
const provider = new WsProvider('ws://127.0.0.1:9944') | ||
console.log('Provider initialized') | ||
const api = await ApiPromise.create({ provider }) | ||
console.log('API initialized') | ||
// Retrieve the chain & node information via rpc calls | ||
const [chain, nodeName, nodeVersion] = await Promise.all([ | ||
api.rpc.system.chain(), | ||
api.rpc.system.name(), | ||
api.rpc.system.version(), | ||
]); | ||
]) | ||
console.log( | ||
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}` | ||
); | ||
) | ||
|
||
/* Axios initialization */ | ||
const httpClient = axios.create({ | ||
baseURL: "http://127.0.0.1:8000", | ||
baseURL: 'http://127.0.0.1:8000', | ||
headers: { | ||
"Content-Type": "application/json", | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
}) | ||
|
||
/* MurmurClient initialization */ | ||
const murmurClient = new MurmurClient(httpClient, api); | ||
console.log("MurmurClient initialized"); | ||
const murmurClient = new MurmurClient(httpClient, api) | ||
console.log('MurmurClient initialized') | ||
|
||
const loguinResult = await murmurClient.authenticate("admin", "password"); | ||
console.log(loguinResult); | ||
const loguinResult = await murmurClient.authenticate('admin', 'password') | ||
console.log(loguinResult) | ||
|
||
await murmurClient.new(100, async (result: any) => { | ||
console.log(`Tx Block Hash: ${result.status.asFinalized}`); | ||
const bob = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"; | ||
const call = api.tx.balances.transferAllowDeath(bob, 1000000000000); | ||
await murmurClient.execute(call); | ||
}); | ||
console.log(`Tx Block Hash: ${result.status.asFinalized}`) | ||
const bob = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty' | ||
const call = api.tx.balances.transferAllowDeath(bob, 1000000000000) | ||
await murmurClient.execute(call) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import { ApiPromise, WsProvider } from "@polkadot/api"; | ||
import axios from "axios"; | ||
import { MurmurClient } from "murmur.js"; | ||
import { ApiPromise, WsProvider } from '@polkadot/api' | ||
import axios from 'axios' | ||
import { MurmurClient } from 'murmur.js' | ||
|
||
/* Polkadot API initialization */ | ||
const provider = new WsProvider("ws://127.0.0.1:9944"); | ||
console.log("Provider initialized"); | ||
const api = await ApiPromise.create({ provider }); | ||
console.log("API initialized"); | ||
const provider = new WsProvider('ws://127.0.0.1:9944') | ||
console.log('Provider initialized') | ||
const api = await ApiPromise.create({ provider }) | ||
console.log('API initialized') | ||
// Retrieve the chain & node information via rpc calls | ||
const [chain, nodeName, nodeVersion] = await Promise.all([ | ||
api.rpc.system.chain(), | ||
api.rpc.system.name(), | ||
api.rpc.system.version(), | ||
]); | ||
]) | ||
console.log( | ||
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}` | ||
); | ||
) | ||
|
||
/* Axios initialization */ | ||
const httpClient = axios.create({ | ||
baseURL: "https://api.example.com", | ||
baseURL: 'https://api.example.com', | ||
headers: { | ||
"Content-Type": "application/json", | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
}) | ||
|
||
/* MurmurClient initialization */ | ||
new MurmurClient(httpClient, api); | ||
console.log("MurmurClient initialized"); | ||
new MurmurClient(httpClient, api) | ||
console.log('MurmurClient initialized') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepare": "husky install" | ||
}, | ||
"author": "Ideal Labs <[email protected]>", | ||
"dependencies": { | ||
|
@@ -16,6 +17,20 @@ | |
}, | ||
"devDependencies": { | ||
"@types/node": "^22.7.4", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^15.2.10", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-organize-imports": "^4.1.0", | ||
"typescript": "^5.6.2" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx,json,md}": [ | ||
"prettier --write" | ||
] | ||
} | ||
} |
Oops, something went wrong.