Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pocket/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ app.post('/api/stake', (req, res) => {
res.send(response);
})

app.post('/api/sign', (req, res) => {
const passphrase = shell.exec(`echo $KEYFILE_PASSPHRASE`).stdout.trim();
const address = shell.exec(`pocket accounts list --datadir=/home/app/.pocket/ | cut -d' ' -f2- `).stdout.trim();
const message = req.body.message;
const response = shell.exec(`pocket accounts sign ${address} ${message} --datadir=/home/app/.pocket/ --pwd "${passphrase}"`).stdout.trim();
res.send(response);
})

var server = app.listen(CUSTOM_UI_HTTP_PORT, function () {
var host = server.address().address;
var port = server.address().port;
Expand Down
71 changes: 71 additions & 0 deletions pocket/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function App() {
const [availableChains, setAvailableChains] = useState<[Chain]>();
const [currentBlock, setCurrentBlock] = useState<number | null>(null);
const [amountToStake, setAmountToStake] = useState<number | null>(null);
const [message, setMessage] = useState<string | null>(null);
const [selectedChains, setSelectedChains] = useState(new Map());
const [first, setFirst] = useState(true);
const [txhash, setTxhash] = useState<string | null>(null);
Expand Down Expand Up @@ -91,6 +92,16 @@ function App() {
}
}

// working on message signing variable
const signMessage = async () => {
try {
setMessage(null);
if (message)
}
appService.signMessage({message});
}


function handleChange(id:string, isChecked: boolean) {
let modifiedMap = selectedChains;
if(modifiedMap?.get(id) && !isChecked) {
Expand Down Expand Up @@ -242,6 +253,66 @@ function App() {
Stake = Initial Stake. Re-stake = staking again after changing chains or amount staked.
</Form.Text>
</div>

<div>
<Form.Label> Sign Message with your Account </Form.Label>
</div>
<div>
<Form.Label>Address</Form.Label>
</div>
<div>
<Form.Control
type="text"
placeholder="Validator address"
value={account?.address ?? 'Unknown'}
disabled={true}
readOnly={true}
/>
<Form.Text>
Address to Sign Message
</Form.Text>
</div>
<div>
<Form.Label>Message</Form.Label>
</div>
<div>
<Form.Control
type="text"
placeholder="Message to be signed"
value={messageToSign ?? 'Unknown'}
disabled={false}
readOnly={false}
/>
<Form.Text>
You can enter any message to be signed here, but it's primary use is to self-sign the address of the account,
</Form.Text>
</div>
<div>
<Form.Text>
You are using to stake with in order to prove ownership of the account, and begin the Node-Runner Tropy Process.
</Form.Text>
</div>
<div>
<Form.Text>
More info on the Node-Runner Trophy Process <a href="https://docs.pokt.network/home/paths/node-runner#node-runner-trophy-process" target="_blank" rel="noreferrer">here</a>.
</Form.Text>
</div>
<div>
<Button
onClick={() => signMessage()}
disabled={(currentBlock ?? 0) === 0}
>{account?.node ?? `Sign`}</Button>
{txhash && (
<Form.Text>
{` `}Tx: {txhash}
</Form.Text>
)}
{(currentBlock ?? 0) === 0 && (
<Form.Text>
{` `}(Syncing...)
</Form.Text>
)}
</div>
</div>
</Form.Group>

Expand Down
5 changes: 5 additions & 0 deletions pocket/ui/src/services/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ export class AppService {
return response.data;
}

public async signMessage(message: string) {
const response = await axios.post(`/api/signMessage`, {message});
return response.data;
}

}