11import { assertEx } from '@xylabs/assert'
2- import { isDefined } from '@xylabs/typeof'
3- import type {
4- CreatableProviderContext ,
5- ProviderFactoryLocator ,
6- RpcSchemaMap , TransportFactory , XyoConnection ,
7- } from '@xyo-network/xl1-sdk'
2+ import type { XyoConnection } from '@xyo-network/xl1-sdk'
83import {
9- ADDRESS_INDEX , buildJsonRpcProviderLocator , buildSimpleXyoSigner , generateXyoBaseWalletFromPhrase ,
10- HttpRpcTransport , SimpleXyoGatewayRunner , XyoConnectionMoniker ,
4+ ADDRESS_INDEX ,
5+ buildSimpleXyoSigner , generateXyoBaseWalletFromPhrase ,
6+ SimpleXyoGatewayRunner , XyoConnectionMoniker ,
117} from '@xyo-network/xl1-sdk'
128
13- let locator : ProviderFactoryLocator < CreatableProviderContext , string [ ] >
9+ import { getLocator } from './getLocator.ts'
1410
1511export const getGateway = async ( mnemonic ?: string , rpcEndpoint = 'http://localhost:8080/rpc' ) => {
1612 // Load the account to use for the transaction
@@ -30,14 +26,3 @@ export const getGateway = async (mnemonic?: string, rpcEndpoint = 'http://localh
3026 // Return a new SimpleXyoGatewayRunner instance
3127 return new SimpleXyoGatewayRunner ( connection , signer )
3228}
33-
34- export const getLocator = async ( rpcEndpoint = 'http://localhost:8080/rpc' ) => {
35- if ( isDefined ( locator ) ) return locator
36- // Determine the RPC endpoint to use for the chain connection
37- const endpoint = process . env . XYO_CHAIN_RPC_URL ?? rpcEndpoint
38- console . log ( 'Using endpoint:' , endpoint )
39-
40- const transportFactory : TransportFactory = ( schemas : RpcSchemaMap ) => new HttpRpcTransport ( endpoint , schemas )
41- locator = await buildJsonRpcProviderLocator ( { transportFactory } )
42- return locator
43- }
0 commit comments