-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TxBuilder: TransactionBuilder.nodeStake takes rewardDelegators #102
Conversation
d6c29c0
to
668e6a0
Compare
668e6a0
to
cf3b368
Compare
Here's the sample code to add delegators. Tx is this. Will update README.md in a follow-up patch. import "dotenv/config";
import { JsonRpcProvider } from "@pokt-foundation/pocketjs-provider";
import { KeyManager } from "@pokt-foundation/pocketjs-signer";
import { TransactionBuilder } from "@pokt-foundation/pocketjs-transaction-builder";
const PoktEndpoint = process.env.POKT_ENDPOINT;
const TxSignerKey = process.env.SIGNER_PRIVATE_KEY;
async function main() {
const provider = new JsonRpcProvider({
rpcUrl: PoktEndpoint,
dispatchers: [PoktEndpoint],
});
const height = await provider.getBlockNumber();
console.log(height);
const txSigner = await KeyManager.fromPrivateKey(TxSignerKey);
const transactionBuilder = new TransactionBuilder({
provider,
signer: txSigner,
chainID: "testnet",
});
const sendMsg = transactionBuilder.nodeStake({
amount: "16000000000",
chains: ["0001", "0002"],
serviceURL: new URL("https://poktt1698102386.c0d3r.org:443"),
outputAddress: "fc1c79e7efecf89f071ebb2ba7c6f5a98dcdfc3c",
rewardDelegators: {
"fc1c79e7efecf89f071ebb2ba7c6f5a98dcdfc3c": 30,
"54751ae3431c015a6e24d711c9d1ed4e5a276479": 40,
}
});
const txResponse = await transactionBuilder.submit({
memo: "via PocketJS",
txMsg: sendMsg,
});
console.log(txResponse.txHash);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
}); |
Can you provide an example without delegators (basically before the addition as its an optional param). As well, if a user doesn't specify delegators and there are existing delegators within a node stake, does that remove the delegators or keep it the same? Example, are these two the same: (is this even valid?)
|
Good question. If we do To stake without delegators or remove the current delegators, you just omit In a follow-up patch, I'll add both scenarios, to add/remove delegators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. As mentioned in other PR's and Discord, we will do a regression test of basic transactions of transfer, app stake/transfer, and staking using jsonrpcprovider and the webprovider to ensure all the commits did not affect functionality
This patch implements a new feature Reward Delegators (PIP-32; introduced by pokt-network/pocket-core#1581).