Skip to content
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

@planetarium/lib9c: provide helper makeTx transaction to construct tx easily #2617

Open
moreal opened this issue Jun 10, 2024 · 0 comments
Open
Assignees
Labels

Comments

@moreal
Copy link
Contributor

moreal commented Jun 10, 2024

It suggests to provide helper method, makeTx with NetworkProvider interface. It expects to implement NineChronicles.Headless implement NetworkProvider.

import { Account, Address } from '@planetarium/account';
import { UnsignedTx } from '@planetarium/tx';

interface NetworkProvider {
  getNextNonce(address: Address): Promise<bigint>,
  getGenesisHash(): Promise<string>,
}

function makeTx(account: Account, provider: NetworkProvider, action: PolymorphicAction): Promise<UnsignedTx>;

Expected code:

import { HeadlessNetworkProvider } from "@planetarium/headless-network-provider"; // Temporary name
import { RawPrivateKey, Address } from "@planetarium/account";
import { makeTx, ClaimStakeReward } from "@planetarium/lib9c";

const networkProvider = new HeadlessNetworkProvider("https://9c-main-full-state.nine-chronicles.com/graphql");
const account = RawPrivateKey.generate();  // Temporary private key key.

const unsignedTx = await makeTx(account, networkProvider, new ClaimStakeReward({
  avatarAddress: Address.fromHex('<ADDRESS>'),
}));

unsignedTx
@moreal moreal added the js label Jun 10, 2024
@moreal moreal self-assigned this Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant