Skip to content

Commit 647bff0

Browse files
committed
remove logic now in helper
1 parent 6366eea commit 647bff0

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

src/helloWorld.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1-
import { assertEx } from '@xylabs/assert'
21
import { isError } from '@xylabs/typeof'
32
import { PayloadBuilder } from '@xyo-network/payload-builder'
43
import type { Payload } from '@xyo-network/payload-model'
54
import type { HashPayload, SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
6-
import {
7-
ADDRESS_INDEX, generateXyoBaseWalletFromPhrase,
8-
SimpleXyoGatewayRunner,
9-
SimpleXyoSigner,
10-
} from '@xyo-network/xl1-protocol-sdk'
11-
import { HttpRpcXyoConnection } from '@xyo-network/xl1-rpc'
125
import { config } from 'dotenv'
136

7+
import { getGateway } from './getGateway.ts'
8+
149
// Load environment variables from .env file
1510
config({ quiet: true })
1611

1712
const logger = console
1813

19-
export async function helloWorld(mnemonic?: string, rpcEndpoint = 'http://localhost:8080/rpc'): Promise<void> {
14+
export async function helloWorld(mnemonic?: string): Promise<void> {
2015
try {
2116
console.log('\n**** Starting XL1 Hello World NodeJs Sample ****\n')
2217

23-
// Load the account to use for the transaction
24-
const walletMnemonic = assertEx(process.env.XYO_WALLET_MNEMONIC ?? mnemonic, () => 'Unable to resolve mnemonic from environment variable or argument')
25-
const account = await (await generateXyoBaseWalletFromPhrase(walletMnemonic)).derivePath(ADDRESS_INDEX.XYO)
26-
console.log('Using account:', account.address)
27-
28-
// Determine the RPC endpoint to use for the chain connection
29-
const endpoint = process.env.XYO_CHAIN_RPC_URL ?? rpcEndpoint
30-
console.log('Using endpoint:', endpoint)
31-
32-
// Create a new RPC connection
33-
const connection = new HttpRpcXyoConnection({ endpoint })
34-
const signer = new SimpleXyoSigner(account)
35-
const gateway = new SimpleXyoGatewayRunner(connection, signer)
36-
3718
// Generate random data to send in the transaction
3819
const { onChainData, offChainData } = await getRandomTransactionData()
3920

21+
const gateway = await getGateway(mnemonic)
22+
4023
// Send the transaction to the network
4124
const [txHash] = await gateway.addPayloadsToChain(onChainData, offChainData)
4225

0 commit comments

Comments
 (0)