@xyo-network/xl1-rpc 1.8.3 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,13 +2,7 @@ import { assertEx } from '@xylabs/assert'
2
2
  import type { Promisable } from '@xylabs/promise'
3
3
  import type { Payload } from '@xyo-network/payload-model'
4
4
  import type {
5
- AllowedBlockPayload,
6
- HydratedTransaction,
7
- InvokerPermission, Permission,
8
- XyoConnectionProvider,
9
- XyoGatewayProvider,
10
- XyoRpcConnectionConfig,
11
- XyoSigner,
5
+ AllowedBlockPayload, HydratedTransaction, InvokerPermission, Permission, XyoConnectionProvider, XyoGatewayProvider, XyoRpcConnectionConfig, XyoSigner,
12
6
  } from '@xyo-network/xl1-protocol'
13
7
 
14
8
  export abstract class AbstractXyoGateway implements XyoGatewayProvider {
@@ -37,13 +31,10 @@ export abstract class AbstractXyoGateway implements XyoGatewayProvider {
37
31
  }
38
32
 
39
33
  async submitTransaction(elevatedPayloads: AllowedBlockPayload[], additionalPayloads: Payload[]): Promise<HydratedTransaction> {
40
- return assertEx(
41
- assertEx(
42
- await this.connection(),
43
- () => 'No active connection available for transaction submission',
44
- ).submitTransaction,
45
- () => 'Active connection does not support transaction submission',
46
- )(elevatedPayloads, additionalPayloads)
34
+ const connection = await this.connection()
35
+ assertEx(connection.submitTransaction, () => 'Active connection does not support transaction submission')
36
+ const tx = await connection.submitTransaction?.(elevatedPayloads, additionalPayloads)
37
+ return assertEx(tx, () => 'Transaction submission failed')
47
38
  }
48
39
 
49
40
  abstract connection(): Promisable<XyoConnectionProvider>
@@ -1,10 +1,12 @@
1
1
  import { Account } from '@xyo-network/account'
2
2
  import type { AccountInstance } from '@xyo-network/account-model'
3
+ import type { Payload } from '@xyo-network/payload-model'
4
+ import type { AllowedBlockPayload } from '@xyo-network/xl1-protocol'
3
5
  import {
4
6
  beforeEach, describe, expect, it,
5
7
  } from 'vitest'
6
8
 
7
- import { RpcXyoConnection } from '../../provider/index.ts'
9
+ import { HttpRpcXyoConnection } from '../../provider/index.ts'
8
10
  import { MemoryXyoSigner } from '../../signer/index.ts'
9
11
  import { MemoryXyoGateway } from '../MemoryXyoGateway.ts'
10
12
 
@@ -13,14 +15,14 @@ describe('MemoryXyoGateway', () => {
13
15
  const dataLakeEndpoint = 'http://localhost:8080/chain/archivist'
14
16
  let account: AccountInstance
15
17
  let signer: MemoryXyoSigner
16
- let connection: RpcXyoConnection
18
+ let connection: HttpRpcXyoConnection
17
19
  let sut: MemoryXyoGateway
18
20
 
19
21
  beforeEach(async () => {
20
22
  account = await Account.random()
21
23
  signer = new MemoryXyoSigner(account)
22
24
 
23
- connection = new RpcXyoConnection({ endpoint, account })
25
+ connection = new HttpRpcXyoConnection({ endpoint, account })
24
26
  sut = new MemoryXyoGateway(signer, connection)
25
27
  })
26
28
 
@@ -34,4 +36,12 @@ describe('MemoryXyoGateway', () => {
34
36
  expect(sut.signer()).toBeDefined()
35
37
  })
36
38
  })
39
+ describe.skip('submitTransaction', () => {
40
+ it('should submit the transaction', async () => {
41
+ const elevatedPayloads: AllowedBlockPayload[] = []
42
+ const additionalPayloads: Payload[] = []
43
+ const tx = await sut.submitTransaction(elevatedPayloads, additionalPayloads)
44
+ expect(tx).toBeDefined()
45
+ })
46
+ })
37
47
  })
@@ -8,7 +8,7 @@ export interface SessionMessageEnvelope<T extends JsonValue> {
8
8
  }
9
9
 
10
10
  /** Only intended for web pages where the xyo global object was injected */
11
- /** @deprecated - rely on the postMessageBus to handle this for you */
11
+ /** @deprecated - this is now handled in the wallet extension */
12
12
  export const buildSessionMessageRequest = <T extends JsonRpcRequest>(data: T, destination?: string) => {
13
13
  const request: SessionMessageEnvelope<T> = {
14
14
  data,