opnet 1.7.2 → 1.7.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.
Files changed (120) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/bitcoin/interfaces/IUTXO.d.ts +8 -1
  3. package/browser/block/interfaces/IBlockWitness.d.ts +1 -2
  4. package/browser/contracts/CallResult.d.ts +5 -1
  5. package/browser/contracts/Contract.d.ts +1 -1
  6. package/browser/contracts/ContractData.d.ts +1 -1
  7. package/browser/contracts/interfaces/IContract.d.ts +1 -1
  8. package/browser/contracts/interfaces/IRawContract.d.ts +0 -1
  9. package/browser/epoch/interfaces/IEpoch.d.ts +1 -1
  10. package/browser/index.js +1 -1
  11. package/browser/opnet.d.ts +1 -0
  12. package/browser/providers/AbstractRpcProvider.d.ts +4 -3
  13. package/browser/providers/WebsocketRpcProvider.d.ts +51 -3
  14. package/browser/providers/interfaces/PublicKeyInfo.d.ts +4 -2
  15. package/browser/providers/websocket/OPNetError.d.ts +6 -0
  16. package/browser/providers/websocket/ProtobufLoader.d.ts +4 -0
  17. package/browser/providers/websocket/index.d.ts +3 -0
  18. package/browser/providers/websocket/types/ConnectionState.d.ts +10 -0
  19. package/browser/providers/websocket/types/PendingRequest.d.ts +9 -0
  20. package/browser/providers/websocket/types/SubscriptionType.d.ts +5 -0
  21. package/browser/providers/websocket/types/WebSocketClientConfig.d.ts +13 -0
  22. package/browser/providers/websocket/types/WebSocketErrorCodes.d.ts +63 -0
  23. package/browser/providers/websocket/types/WebSocketOpcodes.d.ts +59 -0
  24. package/browser/providers/websocket/types/WebSocketProviderTypes.d.ts +32 -0
  25. package/browser/providers/websocket/types/index.d.ts +7 -0
  26. package/browser/transactions/decoders/DeploymentTransaction.d.ts +1 -1
  27. package/browser/transactions/interfaces/transactions/ICommonTransaction.d.ts +1 -1
  28. package/browser/transactions/interfaces/transactions/IDeploymentTransaction.d.ts +0 -1
  29. package/browser/utxos/UTXOsManager.d.ts +1 -0
  30. package/browser/utxos/interfaces/IUTXOsManager.d.ts +10 -5
  31. package/build/_version.d.ts +1 -1
  32. package/build/_version.js +1 -1
  33. package/build/bitcoin/UTXOs.js +0 -3
  34. package/build/bitcoin/interfaces/IUTXO.d.ts +8 -1
  35. package/build/block/BlockWitness.js +1 -3
  36. package/build/block/interfaces/IBlockWitness.d.ts +1 -2
  37. package/build/contracts/CallResult.d.ts +5 -1
  38. package/build/contracts/CallResult.js +3 -0
  39. package/build/contracts/Contract.d.ts +1 -1
  40. package/build/contracts/Contract.js +4 -4
  41. package/build/contracts/ContractData.d.ts +1 -1
  42. package/build/contracts/ContractData.js +5 -5
  43. package/build/contracts/interfaces/IContract.d.ts +1 -1
  44. package/build/contracts/interfaces/IRawContract.d.ts +0 -1
  45. package/build/epoch/Epoch.js +1 -1
  46. package/build/epoch/interfaces/IEpoch.d.ts +1 -1
  47. package/build/opnet.d.ts +1 -0
  48. package/build/opnet.js +1 -0
  49. package/build/providers/AbstractRpcProvider.d.ts +4 -3
  50. package/build/providers/AbstractRpcProvider.js +26 -19
  51. package/build/providers/WebsocketRpcProvider.d.ts +51 -3
  52. package/build/providers/WebsocketRpcProvider.js +724 -9
  53. package/build/providers/interfaces/PublicKeyInfo.d.ts +4 -2
  54. package/build/providers/websocket/OPNetError.d.ts +6 -0
  55. package/build/providers/websocket/OPNetError.js +11 -0
  56. package/build/providers/websocket/ProtobufLoader.d.ts +4 -0
  57. package/build/providers/websocket/ProtobufLoader.js +26 -0
  58. package/build/providers/websocket/index.d.ts +3 -0
  59. package/build/providers/websocket/index.js +3 -0
  60. package/build/providers/websocket/types/ConnectionState.d.ts +10 -0
  61. package/build/providers/websocket/types/ConnectionState.js +30 -0
  62. package/build/providers/websocket/types/PendingRequest.d.ts +9 -0
  63. package/build/providers/websocket/types/PendingRequest.js +1 -0
  64. package/build/providers/websocket/types/SubscriptionType.d.ts +5 -0
  65. package/build/providers/websocket/types/SubscriptionType.js +15 -0
  66. package/build/providers/websocket/types/WebSocketClientConfig.d.ts +13 -0
  67. package/build/providers/websocket/types/WebSocketClientConfig.js +11 -0
  68. package/build/providers/websocket/types/WebSocketErrorCodes.d.ts +63 -0
  69. package/build/providers/websocket/types/WebSocketErrorCodes.js +120 -0
  70. package/build/providers/websocket/types/WebSocketOpcodes.d.ts +59 -0
  71. package/build/providers/websocket/types/WebSocketOpcodes.js +60 -0
  72. package/build/providers/websocket/types/WebSocketProviderTypes.d.ts +32 -0
  73. package/build/providers/websocket/types/WebSocketProviderTypes.js +8 -0
  74. package/build/providers/websocket/types/index.d.ts +7 -0
  75. package/build/providers/websocket/types/index.js +7 -0
  76. package/build/transactions/decoders/DeploymentTransaction.d.ts +1 -1
  77. package/build/transactions/decoders/DeploymentTransaction.js +4 -4
  78. package/build/transactions/decoders/InteractionTransaction.js +1 -1
  79. package/build/transactions/interfaces/transactions/ICommonTransaction.d.ts +1 -1
  80. package/build/transactions/interfaces/transactions/IDeploymentTransaction.d.ts +0 -1
  81. package/build/utxos/UTXOsManager.d.ts +1 -0
  82. package/build/utxos/UTXOsManager.js +30 -6
  83. package/build/utxos/interfaces/IUTXOsManager.d.ts +10 -5
  84. package/eslint.config.js +1 -0
  85. package/package.json +3 -2
  86. package/src/_version.ts +1 -1
  87. package/src/bitcoin/UTXOs.ts +5 -3
  88. package/src/bitcoin/interfaces/IUTXO.ts +26 -1
  89. package/src/block/Block.ts +1 -1
  90. package/src/block/BlockWitness.ts +1 -3
  91. package/src/block/interfaces/IBlockWitness.ts +1 -2
  92. package/src/contracts/CallResult.ts +10 -1
  93. package/src/contracts/Contract.ts +4 -4
  94. package/src/contracts/ContractData.ts +5 -5
  95. package/src/contracts/interfaces/IContract.ts +1 -1
  96. package/src/contracts/interfaces/IRawContract.ts +0 -1
  97. package/src/epoch/Epoch.ts +1 -1
  98. package/src/epoch/interfaces/IEpoch.ts +1 -1
  99. package/src/opnet.ts +3 -0
  100. package/src/providers/AbstractRpcProvider.ts +90 -31
  101. package/src/providers/WebsocketRpcProvider.ts +1003 -11
  102. package/src/providers/interfaces/PublicKeyInfo.ts +6 -2
  103. package/src/providers/websocket/OPNetError.ts +16 -0
  104. package/src/providers/websocket/ProtobufLoader.ts +58 -0
  105. package/src/providers/websocket/index.ts +3 -0
  106. package/src/providers/websocket/types/ConnectionState.ts +49 -0
  107. package/src/providers/websocket/types/PendingRequest.ts +24 -0
  108. package/src/providers/websocket/types/SubscriptionType.ts +25 -0
  109. package/src/providers/websocket/types/WebSocketClientConfig.ts +49 -0
  110. package/src/providers/websocket/types/WebSocketErrorCodes.ts +267 -0
  111. package/src/providers/websocket/types/WebSocketOpcodes.ts +106 -0
  112. package/src/providers/websocket/types/WebSocketProviderTypes.ts +60 -0
  113. package/src/providers/websocket/types/index.ts +7 -0
  114. package/src/transactions/decoders/DeploymentTransaction.ts +6 -6
  115. package/src/transactions/decoders/InteractionTransaction.ts +1 -1
  116. package/src/transactions/interfaces/transactions/ICommonTransaction.ts +1 -1
  117. package/src/transactions/interfaces/transactions/IDeploymentTransaction.ts +0 -5
  118. package/src/utxos/UTXOsManager.ts +46 -8
  119. package/src/utxos/interfaces/IUTXOsManager.ts +21 -6
  120. package/tsconfig.webpack.json +3 -4
@@ -13,6 +13,7 @@ export * from './transactions/interfaces/transactions/IInteractionTransaction.js
13
13
  export * from './providers/AbstractRpcProvider.js';
14
14
  export * from './providers/JSONRpcProvider.js';
15
15
  export * from './providers/WebsocketRpcProvider.js';
16
+ export * from './providers/websocket/index.js';
16
17
  export * from './providers/interfaces/ReorgInformation.js';
17
18
  export * from './block/Block.js';
18
19
  export * from './block/BlockGasParameters.js';
@@ -24,7 +24,7 @@ import { UTXOsManager } from '../utxos/UTXOsManager.js';
24
24
  import { JsonRpcPayload } from './interfaces/JSONRpc.js';
25
25
  import { JSONRpcMethods } from './interfaces/JSONRpcMethods.js';
26
26
  import { JsonRpcCallResult, JsonRpcResult } from './interfaces/JSONRpcResult.js';
27
- import { AddressesInfo } from './interfaces/PublicKeyInfo.js';
27
+ import { AddressesInfo, IPublicKeyInfoResult } from './interfaces/PublicKeyInfo.js';
28
28
  import { ReorgInformation } from './interfaces/ReorgInformation.js';
29
29
  export declare abstract class AbstractRpcProvider {
30
30
  readonly network: Network;
@@ -38,7 +38,7 @@ export declare abstract class AbstractRpcProvider {
38
38
  private _utxoManager;
39
39
  get utxoManager(): UTXOsManager;
40
40
  getCSV1ForAddress(address: Address): IP2WSHAddress;
41
- getPublicKeyInfo(addressRaw: string | Address): Promise<Address>;
41
+ getPublicKeyInfo(addressRaw: string | Address, isContract: boolean): Promise<Address>;
42
42
  validateAddress(addr: string | Address, network: Network): AddressTypes | null;
43
43
  getBlockNumber(): Promise<bigint>;
44
44
  getBlockByChecksum(checksum: string, prefetchTxs?: boolean): Promise<Block>;
@@ -64,7 +64,8 @@ export declare abstract class AbstractRpcProvider {
64
64
  callPayloadSingle(payload: JsonRpcPayload): Promise<JsonRpcResult>;
65
65
  callMultiplePayloads(payloads: JsonRpcPayload[]): Promise<JsonRpcCallResult>;
66
66
  buildJsonRpcPayload<T extends JSONRpcMethods>(method: T, params: unknown[]): JsonRpcPayload;
67
- getPublicKeysInfo(addresses: string | string[] | Address | Address[], logErrors?: boolean): Promise<AddressesInfo>;
67
+ getPublicKeysInfoRaw(addresses: string | string[] | Address | Address[]): Promise<IPublicKeyInfoResult>;
68
+ getPublicKeysInfo(addresses: string | string[] | Address | Address[], isContract?: boolean, logErrors?: boolean): Promise<AddressesInfo>;
68
69
  getLatestEpoch(includeSubmissions: boolean): Promise<Epoch>;
69
70
  getEpochByNumber(epochNumber: BigNumberish, includeSubmissions?: boolean): Promise<Epoch | EpochWithSubmissions>;
70
71
  getEpochByHash(epochHash: string, includeSubmissions?: boolean): Promise<Epoch | EpochWithSubmissions>;
@@ -2,9 +2,57 @@ import { Network } from '@btc-vision/bitcoin';
2
2
  import { AbstractRpcProvider } from './AbstractRpcProvider.js';
3
3
  import { JsonRpcPayload } from './interfaces/JSONRpc.js';
4
4
  import { JsonRpcCallResult } from './interfaces/JSONRpcResult.js';
5
+ import { BlockNotification, ConnectionState, EpochNotification, EventHandler, SubscriptionHandler, SubscriptionType, WebSocketClientConfig, WebSocketClientEvent } from './websocket/index.js';
6
+ export { BlockNotification, EpochNotification, EventHandler, SubscriptionHandler, WebSocketClientEvent, };
5
7
  export declare class WebSocketRpcProvider extends AbstractRpcProvider {
6
- private readonly wsUrl;
7
- constructor(url: string, network: Network);
8
- _send(payload: JsonRpcPayload): Promise<JsonRpcCallResult>;
8
+ private readonly config;
9
+ private readonly pendingRequests;
10
+ private readonly subscriptions;
11
+ private readonly eventHandlers;
12
+ private socket;
13
+ private state;
14
+ private requestId;
15
+ private reconnectAttempt;
16
+ private pingTimeout;
17
+ private sessionId;
18
+ private userRequestedDisconnect;
19
+ private protoRoot;
20
+ private protoTypes;
21
+ constructor(url: string, network: Network, config?: Partial<Omit<WebSocketClientConfig, 'url'>>);
22
+ getState(): ConnectionState;
23
+ isReady(): boolean;
24
+ connect(): Promise<void>;
25
+ disconnect(): void;
26
+ on<T>(event: WebSocketClientEvent, handler: EventHandler<T>): void;
27
+ off<T>(event: WebSocketClientEvent, handler: EventHandler<T>): void;
28
+ subscribeBlocks(handler: SubscriptionHandler<BlockNotification>): Promise<void>;
29
+ subscribeEpochs(handler: SubscriptionHandler<EpochNotification>): Promise<void>;
30
+ unsubscribe(subscriptionType: SubscriptionType): Promise<void>;
31
+ clearCache(): void;
32
+ _send(payload: JsonRpcPayload | JsonRpcPayload[]): Promise<JsonRpcCallResult>;
9
33
  protected providerUrl(url: string): string;
34
+ private sendJsonRpcRequest;
35
+ private translateJsonRpcParams;
36
+ private translateProtoResponse;
37
+ private connectWebSocket;
38
+ private buildWebSocketUrl;
39
+ private performHandshake;
40
+ private getType;
41
+ private nextRequestId;
42
+ private buildMessage;
43
+ private sendRequest;
44
+ private send;
45
+ private handleMessage;
46
+ private handleErrorResponse;
47
+ private handleBlockNotification;
48
+ private handleEpochNotification;
49
+ private handleClose;
50
+ private reconnect;
51
+ private resubscribe;
52
+ private cleanupPendingRequests;
53
+ private schedulePing;
54
+ private cancelPing;
55
+ private ping;
56
+ private emit;
57
+ private sleep;
10
58
  }
@@ -1,6 +1,5 @@
1
- import { Address } from '@btc-vision/transaction';
1
+ import { Address, MLDSASecurityLevel } from '@btc-vision/transaction';
2
2
  export interface PublicKeyInfo {
3
- readonly mldsaPublicKey: string;
4
3
  readonly mldsaAddress: string;
5
4
  readonly originalPubKey?: string;
6
5
  readonly tweakedPubkey: string;
@@ -11,6 +10,9 @@ export interface PublicKeyInfo {
11
10
  readonly p2pkhUncompressed?: string;
12
11
  readonly p2shp2wpkh?: string;
13
12
  readonly p2wpkh?: string;
13
+ readonly mldsaHashedPublicKey?: string;
14
+ readonly mldsaLevel?: MLDSASecurityLevel;
15
+ readonly mldsaPublicKey?: string | null;
14
16
  }
15
17
  export interface IPubKeyNotFoundError {
16
18
  readonly error: string;
@@ -0,0 +1,6 @@
1
+ import { WebSocketErrorCode } from './types/WebSocketErrorCodes.js';
2
+ export declare class OPNetError extends Error {
3
+ readonly code: WebSocketErrorCode;
4
+ readonly data?: Uint8Array;
5
+ constructor(code: WebSocketErrorCode, message?: string, data?: Uint8Array);
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Root, Type } from 'protobufjs';
2
+ export declare function loadProtobufSchema(baseUrl: string): Promise<Root>;
3
+ export declare function getProtobufType(root: Root, typeName: string): Type;
4
+ export declare function clearProtobufCache(): void;
@@ -0,0 +1,3 @@
1
+ export * from './OPNetError.js';
2
+ export * from './ProtobufLoader.js';
3
+ export * from './types/index.js';
@@ -0,0 +1,10 @@
1
+ export declare enum ConnectionState {
2
+ DISCONNECTED = 0,
3
+ CONNECTING = 1,
4
+ CONNECTED = 2,
5
+ HANDSHAKING = 3,
6
+ READY = 4,
7
+ RECONNECTING = 5,
8
+ CLOSING = 6
9
+ }
10
+ export declare function getConnectionStateName(state: ConnectionState): string;
@@ -0,0 +1,9 @@
1
+ import { WebSocketRequestOpcode } from './WebSocketOpcodes.js';
2
+ export interface PendingRequest<T = unknown> {
3
+ readonly requestId: number;
4
+ readonly opcode: WebSocketRequestOpcode;
5
+ readonly resolve: (value: T) => void;
6
+ readonly reject: (error: Error) => void;
7
+ readonly timeout: ReturnType<typeof setTimeout>;
8
+ readonly createdAt: number;
9
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum SubscriptionType {
2
+ BLOCKS = 0,
3
+ EPOCHS = 1
4
+ }
5
+ export declare function getSubscriptionTypeName(type: SubscriptionType): string;
@@ -0,0 +1,13 @@
1
+ export interface WebSocketClientConfig {
2
+ readonly url: string;
3
+ readonly connectTimeout?: number;
4
+ readonly requestTimeout?: number;
5
+ readonly handshakeTimeout?: number;
6
+ readonly pingInterval?: number;
7
+ readonly autoReconnect?: boolean;
8
+ readonly maxReconnectAttempts?: number;
9
+ readonly reconnectBaseDelay?: number;
10
+ readonly reconnectMaxDelay?: number;
11
+ readonly maxPendingRequests?: number;
12
+ }
13
+ export declare const DEFAULT_CONFIG: Required<Omit<WebSocketClientConfig, 'url'>>;
@@ -0,0 +1,63 @@
1
+ export declare enum ProtocolError {
2
+ MALFORMED_MESSAGE = 1,
3
+ UNKNOWN_OPCODE = 2,
4
+ HANDSHAKE_REQUIRED = 3,
5
+ HANDSHAKE_ALREADY_COMPLETED = 4,
6
+ UNSUPPORTED_PROTOCOL_VERSION = 5,
7
+ PAYLOAD_TOO_LARGE = 6,
8
+ INVALID_REQUEST_ID = 7,
9
+ CONNECTION_CLOSING = 8,
10
+ RATE_LIMIT_EXCEEDED = 9,
11
+ TOO_MANY_PENDING_REQUESTS = 10,
12
+ REQUEST_TIMEOUT = 11,
13
+ INVALID_MESSAGE_FORMAT = 12
14
+ }
15
+ export declare enum AuthError {
16
+ AUTHENTICATION_REQUIRED = 1000,
17
+ INVALID_CREDENTIALS = 1001,
18
+ SESSION_EXPIRED = 1002,
19
+ PERMISSION_DENIED = 1003,
20
+ INVALID_CLIENT_INFO = 1004
21
+ }
22
+ export declare enum ResourceError {
23
+ NOT_FOUND = 2000,
24
+ BLOCK_NOT_FOUND = 2001,
25
+ TRANSACTION_NOT_FOUND = 2002,
26
+ ADDRESS_NOT_FOUND = 2003,
27
+ CONTRACT_NOT_FOUND = 2004,
28
+ EPOCH_NOT_FOUND = 2005,
29
+ SUBSCRIPTION_NOT_FOUND = 2006,
30
+ ALREADY_EXISTS = 2100,
31
+ SUBSCRIPTION_ALREADY_EXISTS = 2101,
32
+ MAX_SUBSCRIPTIONS_REACHED = 2102
33
+ }
34
+ export declare enum ValidationError {
35
+ INVALID_PARAMS = 3000,
36
+ MISSING_REQUIRED_FIELD = 3001,
37
+ VALUE_OUT_OF_RANGE = 3002,
38
+ INVALID_ADDRESS = 3003,
39
+ INVALID_HASH = 3004,
40
+ INVALID_BLOCK_IDENTIFIER = 3005,
41
+ INVALID_TRANSACTION_DATA = 3006,
42
+ INVALID_SIGNATURE = 3007,
43
+ INVALID_CALLDATA = 3008,
44
+ INVALID_BLOCK_HEIGHT = 3009,
45
+ INVALID_EPOCH_NUMBER = 3010,
46
+ INVALID_POINTER = 3011,
47
+ INVALID_PUBLIC_KEY = 3012
48
+ }
49
+ export declare enum InternalError {
50
+ INTERNAL_ERROR = 4000,
51
+ DATABASE_ERROR = 4001,
52
+ STORAGE_ERROR = 4002,
53
+ SERIALIZATION_ERROR = 4003,
54
+ DESERIALIZATION_ERROR = 4004,
55
+ VM_ERROR = 4005,
56
+ NETWORK_ERROR = 4006,
57
+ SERVICE_UNAVAILABLE = 4007,
58
+ NOT_IMPLEMENTED = 4008,
59
+ TIMEOUT = 4009
60
+ }
61
+ export type WebSocketErrorCode = ProtocolError | AuthError | ResourceError | ValidationError | InternalError;
62
+ export declare const ErrorMessages: Readonly<Record<WebSocketErrorCode, string>>;
63
+ export declare function getErrorMessage(code: WebSocketErrorCode): string;
@@ -0,0 +1,59 @@
1
+ export declare enum WebSocketRequestOpcode {
2
+ PING = 0,
3
+ HANDSHAKE = 1,
4
+ GET_BLOCK_NUMBER = 16,
5
+ GET_BLOCK_BY_NUMBER = 17,
6
+ GET_BLOCK_BY_HASH = 18,
7
+ GET_BLOCK_BY_CHECKSUM = 19,
8
+ GET_BLOCK_WITNESS = 20,
9
+ GET_GAS = 21,
10
+ GET_TRANSACTION_BY_HASH = 32,
11
+ GET_TRANSACTION_RECEIPT = 33,
12
+ BROADCAST_TRANSACTION = 34,
13
+ GET_PREIMAGE = 35,
14
+ GET_BALANCE = 48,
15
+ GET_UTXOS = 49,
16
+ GET_PUBLIC_KEY_INFO = 50,
17
+ GET_CHAIN_ID = 64,
18
+ GET_REORG = 65,
19
+ GET_CODE = 80,
20
+ GET_STORAGE_AT = 81,
21
+ CALL = 82,
22
+ GET_LATEST_EPOCH = 96,
23
+ GET_EPOCH_BY_NUMBER = 97,
24
+ GET_EPOCH_BY_HASH = 98,
25
+ GET_EPOCH_TEMPLATE = 99,
26
+ SUBMIT_EPOCH = 100,
27
+ SUBSCRIBE_BLOCKS = 112,
28
+ SUBSCRIBE_EPOCHS = 113,
29
+ UNSUBSCRIBE = 127
30
+ }
31
+ export declare enum WebSocketResponseOpcode {
32
+ ERROR = 128,
33
+ PONG = 129,
34
+ HANDSHAKE_ACK = 130,
35
+ BLOCK_NUMBER = 144,
36
+ BLOCK = 145,
37
+ BLOCK_WITNESS = 146,
38
+ GAS = 147,
39
+ TRANSACTION = 160,
40
+ TRANSACTION_RECEIPT = 161,
41
+ BROADCAST_RESULT = 162,
42
+ PREIMAGE = 163,
43
+ BALANCE = 176,
44
+ UTXOS = 177,
45
+ PUBLIC_KEY_INFO = 178,
46
+ CHAIN_ID = 192,
47
+ REORG = 193,
48
+ CODE = 208,
49
+ STORAGE = 209,
50
+ CALL_RESULT = 210,
51
+ EPOCH = 224,
52
+ EPOCH_TEMPLATE = 225,
53
+ EPOCH_SUBMIT_RESULT = 226,
54
+ SUBSCRIPTION_CREATED = 240,
55
+ UNSUBSCRIBE_RESULT = 241,
56
+ NEW_BLOCK_NOTIFICATION = 248,
57
+ NEW_EPOCH_NOTIFICATION = 249
58
+ }
59
+ export type WebSocketOpcode = WebSocketRequestOpcode | WebSocketResponseOpcode;
@@ -0,0 +1,32 @@
1
+ import { WebSocketRequestOpcode, WebSocketResponseOpcode } from './WebSocketOpcodes.js';
2
+ export declare enum WebSocketClientEvent {
3
+ CONNECTED = "connected",
4
+ DISCONNECTED = "disconnected",
5
+ ERROR = "error",
6
+ BLOCK = "block",
7
+ EPOCH = "epoch"
8
+ }
9
+ export type EventHandler<T = unknown> = (data: T) => void;
10
+ export type SubscriptionHandler<T = unknown> = (data: T) => void;
11
+ export interface BlockNotification {
12
+ readonly blockNumber: bigint;
13
+ readonly blockHash: string;
14
+ readonly previousBlockHash: string;
15
+ readonly timestamp: bigint;
16
+ }
17
+ export interface EpochNotification {
18
+ readonly epochNumber: bigint;
19
+ readonly epochHash: string;
20
+ readonly timestamp: bigint;
21
+ }
22
+ export interface InternalPendingRequest {
23
+ readonly resolve: (value: Uint8Array) => void;
24
+ readonly reject: (error: Error) => void;
25
+ readonly timeout: ReturnType<typeof setTimeout>;
26
+ }
27
+ export interface MethodMapping {
28
+ readonly requestOpcode: WebSocketRequestOpcode;
29
+ readonly responseOpcode: WebSocketResponseOpcode;
30
+ readonly requestType: string;
31
+ readonly responseType: string;
32
+ }
@@ -0,0 +1,7 @@
1
+ export * from './ConnectionState.js';
2
+ export * from './PendingRequest.js';
3
+ export * from './SubscriptionType.js';
4
+ export * from './WebSocketClientConfig.js';
5
+ export * from './WebSocketErrorCodes.js';
6
+ export * from './WebSocketOpcodes.js';
7
+ export * from './WebSocketProviderTypes.js';
@@ -9,7 +9,7 @@ export declare class DeploymentTransaction extends TransactionBase<OPNetTransact
9
9
  readonly bytecode?: Buffer;
10
10
  readonly wasCompressed?: boolean;
11
11
  readonly deployerPubKey?: Buffer;
12
- readonly deployerClassicPubKey?: Buffer;
12
+ readonly deployerHashedPublicKey?: Buffer;
13
13
  readonly deployerAddress?: Address;
14
14
  readonly contractSeed?: Buffer;
15
15
  readonly contractSaltHash?: Buffer;
@@ -6,7 +6,7 @@ export interface ICommonTransaction<T extends OPNetTransactionTypes> extends ITr
6
6
  readonly contractAddress?: string;
7
7
  readonly contractPublicKey?: Address | string;
8
8
  readonly from?: Address | string;
9
- readonly classicFrom?: Address | string;
9
+ readonly fromLegacy?: Address | string;
10
10
  readonly wasCompressed?: boolean;
11
11
  readonly pow?: ProofOfWorkChallenge;
12
12
  }
@@ -6,7 +6,6 @@ export interface IDeploymentTransaction extends ICommonTransaction<OPNetTransact
6
6
  readonly contractPublicKey?: Address | string;
7
7
  readonly bytecode?: Buffer | string;
8
8
  readonly deployerPubKey?: Buffer | string;
9
- readonly deployerClassicPubKey?: Buffer | string;
10
9
  readonly contractSeed?: Buffer | string;
11
10
  readonly contractSaltHash?: Buffer | string;
12
11
  readonly deployerAddress?: Address | string;
@@ -13,5 +13,6 @@ export declare class UTXOsManager {
13
13
  private getAddressData;
14
14
  private maybeFetchUTXOs;
15
15
  private fetchUTXOs;
16
+ private parseUTXO;
16
17
  private syncPendingDepthWithFetched;
17
18
  }
@@ -1,14 +1,19 @@
1
- import { IUTXO } from '../../bitcoin/interfaces/IUTXO.js';
1
+ import { ISpentUTXO, RawIUTXO } from '../../bitcoin/interfaces/IUTXO.js';
2
2
  import { UTXOs } from '../../bitcoin/UTXOs.js';
3
+ export interface SpentUTXORef {
4
+ readonly transactionId: string;
5
+ readonly outputIndex: number;
6
+ }
3
7
  export interface IUTXOsData {
4
8
  readonly pending: UTXOs;
5
- readonly spentTransactions: UTXOs;
9
+ readonly spentTransactions: SpentUTXORef[];
6
10
  readonly confirmed: UTXOs;
7
11
  }
8
12
  export interface RawIUTXOsData {
9
- readonly pending: IUTXO[];
10
- readonly spentTransactions: IUTXO[];
11
- readonly confirmed: IUTXO[];
13
+ readonly pending: RawIUTXO[];
14
+ readonly spentTransactions: ISpentUTXO[];
15
+ readonly confirmed: RawIUTXO[];
16
+ readonly raw: string[];
12
17
  }
13
18
  export interface RequestUTXOsParams {
14
19
  readonly address: string;
@@ -1 +1 @@
1
- export declare const version = "1.7.2";
1
+ export declare const version = "1.7.4";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.2';
1
+ export const version = '1.7.4';
@@ -13,9 +13,6 @@ export class UTXO {
13
13
  this.isCSV = isCSV || false;
14
14
  this.value = BigInt(iUTXO.value);
15
15
  this.scriptPubKey = iUTXO.scriptPubKey;
16
- if (!iUTXO.raw) {
17
- throw new Error('Missing nonWitnessUtxo field in UTXO');
18
- }
19
16
  this.nonWitnessUtxo = Buffer.from(iUTXO.raw, 'base64');
20
17
  }
21
18
  }
@@ -1,8 +1,15 @@
1
1
  import { ScriptPubKey } from '@btc-vision/bitcoin-rpc';
2
- export interface IUTXO {
2
+ export interface RawIUTXO {
3
3
  readonly transactionId: string;
4
4
  readonly outputIndex: number;
5
5
  readonly value: bigint | string;
6
6
  readonly scriptPubKey: ScriptPubKey;
7
+ readonly raw?: number;
8
+ }
9
+ export interface IUTXO extends Omit<RawIUTXO, 'raw'> {
7
10
  readonly raw: string;
8
11
  }
12
+ export interface ISpentUTXO {
13
+ readonly transactionId: string;
14
+ readonly outputIndex: number;
15
+ }
@@ -13,9 +13,7 @@ export class BlockWitnessAPI {
13
13
  this.timestamp = data.timestamp;
14
14
  this.proofs = Object.freeze(data.proofs.map((proof) => stringBase64ToBuffer(proof)));
15
15
  this.identity = data.identity ? stringBase64ToBuffer(data.identity) : undefined;
16
- this.publicKey = data.mldsaPublicKey
17
- ? Address.fromString(data.mldsaPublicKey, data.classicPublicKey)
18
- : undefined;
16
+ this.publicKey = data.publicKey ? Address.fromString(data.publicKey) : undefined;
19
17
  }
20
18
  }
21
19
  export class BlockWitness {
@@ -13,8 +13,7 @@ export interface RawBlockWitnessAPI {
13
13
  readonly timestamp: number;
14
14
  readonly proofs: readonly string[];
15
15
  readonly identity?: string;
16
- readonly mldsaPublicKey?: string;
17
- readonly classicPublicKey?: string;
16
+ readonly publicKey?: string;
18
17
  }
19
18
  export interface IBlockWitness {
20
19
  blockNumber: bigint;
@@ -8,8 +8,10 @@ import { ContractDecodedObjectResult, DecodedOutput } from './Contract.js';
8
8
  import { IAccessList } from './interfaces/IAccessList.js';
9
9
  import { EventList, ICallResultData } from './interfaces/ICallResult.js';
10
10
  import { OPNetEvent } from './OPNetEvent.js';
11
+ import { QuantumBIP32Interface } from '@btc-vision/bip32';
11
12
  export interface TransactionParameters {
12
- readonly signer?: Signer | ECPairInterface;
13
+ readonly signer: Signer | ECPairInterface | null;
14
+ readonly mldsaSigner: QuantumBIP32Interface | null;
13
15
  readonly refundTo: string;
14
16
  readonly sender?: string;
15
17
  readonly priorityFee?: bigint;
@@ -28,6 +30,8 @@ export interface TransactionParameters {
28
30
  readonly dontUseCSVUtxos?: boolean;
29
31
  readonly maxUTXOs?: number;
30
32
  readonly throwIfUTXOsLimitReached?: boolean;
33
+ readonly linkMLDSAPublicKeyToAddress?: boolean;
34
+ readonly revealMLDSAPublicKey?: boolean;
31
35
  }
32
36
  export interface InteractionTransactionReceipt {
33
37
  readonly transactionId: string;
@@ -137,6 +137,9 @@ export class CallResult {
137
137
  note: interactionParams.note,
138
138
  anchor: interactionParams.anchor || false,
139
139
  txVersion: interactionParams.txVersion || 2,
140
+ mldsaSigner: interactionParams.mldsaSigner,
141
+ linkMLDSAPublicKeyToAddress: interactionParams.linkMLDSAPublicKeyToAddress ?? true,
142
+ revealMLDSAPublicKey: interactionParams.revealMLDSAPublicKey ?? false,
140
143
  };
141
144
  const transaction = await factory.signInteraction(params);
142
145
  if (!interactionParams.p2wda) {
@@ -35,7 +35,7 @@ export declare abstract class IBaseContract<T extends BaseContractProperties> im
35
35
  private accessList;
36
36
  private _rlAddress;
37
37
  protected constructor(address: string | Address, abi: BitcoinInterface | BitcoinInterfaceAbi, provider: AbstractRpcProvider, network: Network, from?: Address);
38
- get p2opOrTweaked(): string;
38
+ get p2op(): string;
39
39
  get contractAddress(): Promise<Address>;
40
40
  setSender(sender: Address): void;
41
41
  decodeEvents(events: NetEvent[] | ContractEvents): OPNetEvent<ContractDecodedObjectResult>[];
@@ -34,7 +34,7 @@ export class IBaseContract {
34
34
  Object.defineProperty(this, internal, { value: {} });
35
35
  this.defineInternalFunctions();
36
36
  }
37
- get p2opOrTweaked() {
37
+ get p2op() {
38
38
  if (typeof this.address !== 'string') {
39
39
  return this.address.p2op(this.network);
40
40
  }
@@ -43,7 +43,7 @@ export class IBaseContract {
43
43
  get contractAddress() {
44
44
  if (typeof this.address === 'string') {
45
45
  if (!this._rlAddress) {
46
- this._rlAddress = this.provider.getPublicKeyInfo(this.address);
46
+ this._rlAddress = this.provider.getPublicKeyInfo(this.address, true);
47
47
  }
48
48
  return this._rlAddress;
49
49
  }
@@ -56,7 +56,7 @@ export class IBaseContract {
56
56
  const decodedEvents = [];
57
57
  if (!Array.isArray(events)) {
58
58
  const tempEvents = events;
59
- events = tempEvents[this.p2opOrTweaked];
59
+ events = tempEvents[this.p2op];
60
60
  if (!Array.isArray(events) &&
61
61
  typeof this.address === 'string' &&
62
62
  this.address.startsWith('0x')) {
@@ -498,7 +498,7 @@ export class IBaseContract {
498
498
  const decoded = element.outputs
499
499
  ? this.decodeOutput(element.outputs, response.result)
500
500
  : { values: [], obj: {} };
501
- response.setTo(this.p2opOrTweaked, address);
501
+ response.setTo(this.p2op, address);
502
502
  response.setFromAddress(this.from);
503
503
  response.setDecoded(decoded);
504
504
  response.setCalldata(buffer);
@@ -8,7 +8,7 @@ export declare class ContractData implements Omit<IRawContract, 'contractPublicK
8
8
  readonly deployedTransactionId: string;
9
9
  readonly deployedTransactionHash: string;
10
10
  readonly deployerPubKey: Buffer;
11
- readonly deployerClassicPublicKey: Buffer;
11
+ readonly deployerHashedPublicKey: Buffer;
12
12
  readonly contractSeed: Buffer;
13
13
  readonly contractSaltHash: Buffer;
14
14
  readonly deployerAddress: Address;
@@ -7,7 +7,7 @@ export class ContractData {
7
7
  deployedTransactionId;
8
8
  deployedTransactionHash;
9
9
  deployerPubKey;
10
- deployerClassicPublicKey;
10
+ deployerHashedPublicKey;
11
11
  contractSeed;
12
12
  contractSaltHash;
13
13
  deployerAddress;
@@ -25,9 +25,9 @@ export class ContractData {
25
25
  this.deployerPubKey = Buffer.isBuffer(raw.deployerPubKey)
26
26
  ? raw.deployerPubKey
27
27
  : Buffer.from(raw.deployerPubKey, 'base64');
28
- this.deployerClassicPublicKey = Buffer.isBuffer(raw.deployerClassicPublicKey)
29
- ? raw.deployerClassicPublicKey
30
- : Buffer.from(raw.deployerClassicPublicKey, 'base64');
28
+ this.deployerHashedPublicKey = Buffer.isBuffer(raw.deployerAddress)
29
+ ? raw.deployerAddress
30
+ : Buffer.from(raw.deployerAddress.replace('0x', ''), 'hex');
31
31
  this.contractSeed = Buffer.isBuffer(raw.contractSeed)
32
32
  ? raw.contractSeed
33
33
  : Buffer.from(raw.contractSeed, 'base64');
@@ -36,7 +36,7 @@ export class ContractData {
36
36
  : Buffer.from(raw.contractSaltHash, 'base64');
37
37
  this.deployerAddress =
38
38
  !raw.deployerAddress && this.deployerPubKey
39
- ? new Address(this.deployerPubKey, this.deployerClassicPublicKey)
39
+ ? new Address(this.deployerHashedPublicKey, this.deployerPubKey)
40
40
  : raw.deployerAddress;
41
41
  }
42
42
  }
@@ -6,7 +6,7 @@ import { IAccessList } from './IAccessList.js';
6
6
  import { ParsedSimulatedTransaction } from './SimulatedTransaction.js';
7
7
  export interface IContract {
8
8
  readonly address: Address | string;
9
- get p2opOrTweaked(): string;
9
+ get p2op(): string;
10
10
  currentGasParameters(): Promise<BlockGasParameters>;
11
11
  setSender(sender: Address): void;
12
12
  decodeEvents(events: NetEvent[] | ContractEvents): OPNetEvent[];
@@ -7,7 +7,6 @@ export interface IRawContract {
7
7
  readonly deployedTransactionId: string;
8
8
  readonly deployedTransactionHash: string;
9
9
  readonly deployerPubKey: Buffer | string;
10
- readonly deployerClassicPublicKey: Buffer | string;
11
10
  readonly contractSeed: Buffer | string;
12
11
  readonly contractSaltHash: Buffer | string;
13
12
  readonly deployerAddress: Address;
@@ -7,7 +7,7 @@ export class EpochMiner {
7
7
  graffiti;
8
8
  constructor(data) {
9
9
  this.solution = stringToBuffer(data.solution);
10
- this.publicKey = Address.fromString(data.publicKey, data.classicPublicKey);
10
+ this.publicKey = Address.fromString(data.publicKey, data.legacyPublicKey);
11
11
  this.salt = stringToBuffer(data.salt);
12
12
  this.graffiti = data.graffiti ? stringToBuffer(data.graffiti) : undefined;
13
13
  }
@@ -20,7 +20,7 @@ export interface IEpoch {
20
20
  export interface RawEpochMiner {
21
21
  readonly solution: string;
22
22
  readonly publicKey: string;
23
- readonly classicPublicKey: string;
23
+ readonly legacyPublicKey: string;
24
24
  readonly salt: string;
25
25
  readonly graffiti?: string;
26
26
  }
package/build/opnet.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './transactions/interfaces/transactions/IInteractionTransaction.js
13
13
  export * from './providers/AbstractRpcProvider.js';
14
14
  export * from './providers/JSONRpcProvider.js';
15
15
  export * from './providers/WebsocketRpcProvider.js';
16
+ export * from './providers/websocket/index.js';
16
17
  export * from './providers/interfaces/ReorgInformation.js';
17
18
  export * from './block/Block.js';
18
19
  export * from './block/BlockGasParameters.js';
package/build/opnet.js CHANGED
@@ -13,6 +13,7 @@ export * from './transactions/interfaces/transactions/IInteractionTransaction.js
13
13
  export * from './providers/AbstractRpcProvider.js';
14
14
  export * from './providers/JSONRpcProvider.js';
15
15
  export * from './providers/WebsocketRpcProvider.js';
16
+ export * from './providers/websocket/index.js';
16
17
  export * from './providers/interfaces/ReorgInformation.js';
17
18
  export * from './block/Block.js';
18
19
  export * from './block/BlockGasParameters.js';