@lfdecentralizedtrust/paladin-sdk 0.13.0-rc.1

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 (88) hide show
  1. package/README.md +21 -0
  2. package/build/domains/abis/INoto.json +448 -0
  3. package/build/domains/abis/INotoPrivate.json +347 -0
  4. package/build/domains/abis/IZetoFungible.json +197 -0
  5. package/build/domains/abis/PentePrivacyGroup.json +613 -0
  6. package/build/domains/abis/Zeto_Anon.json +1263 -0
  7. package/build/domains/noto.d.ts +117 -0
  8. package/build/domains/noto.js +292 -0
  9. package/build/domains/pente.d.ts +84 -0
  10. package/build/domains/pente.js +191 -0
  11. package/build/domains/zeto.d.ts +83 -0
  12. package/build/domains/zeto.js +201 -0
  13. package/build/index.d.ts +9 -0
  14. package/build/index.js +28 -0
  15. package/build/interfaces/algorithms.d.ts +3 -0
  16. package/build/interfaces/algorithms.js +9 -0
  17. package/build/interfaces/blockchainevent.d.ts +15 -0
  18. package/build/interfaces/blockchainevent.js +2 -0
  19. package/build/interfaces/blockindex.d.ts +30 -0
  20. package/build/interfaces/blockindex.js +2 -0
  21. package/build/interfaces/domains.d.ts +9 -0
  22. package/build/interfaces/domains.js +2 -0
  23. package/build/interfaces/index.d.ts +15 -0
  24. package/build/interfaces/index.js +31 -0
  25. package/build/interfaces/keymanager.d.ts +32 -0
  26. package/build/interfaces/keymanager.js +2 -0
  27. package/build/interfaces/logger.d.ts +8 -0
  28. package/build/interfaces/logger.js +2 -0
  29. package/build/interfaces/paladin.d.ts +14 -0
  30. package/build/interfaces/paladin.js +2 -0
  31. package/build/interfaces/privacygroups.d.ts +76 -0
  32. package/build/interfaces/privacygroups.js +2 -0
  33. package/build/interfaces/query.d.ts +33 -0
  34. package/build/interfaces/query.js +2 -0
  35. package/build/interfaces/registry.d.ts +26 -0
  36. package/build/interfaces/registry.js +2 -0
  37. package/build/interfaces/states.d.ts +61 -0
  38. package/build/interfaces/states.js +2 -0
  39. package/build/interfaces/transaction.d.ts +159 -0
  40. package/build/interfaces/transaction.js +12 -0
  41. package/build/interfaces/transport.d.ts +32 -0
  42. package/build/interfaces/transport.js +2 -0
  43. package/build/interfaces/verifiers.d.ts +6 -0
  44. package/build/interfaces/verifiers.js +10 -0
  45. package/build/interfaces/websocket.d.ts +57 -0
  46. package/build/interfaces/websocket.js +2 -0
  47. package/build/paladin.d.ts +265 -0
  48. package/build/paladin.js +739 -0
  49. package/build/transaction.d.ts +8 -0
  50. package/build/transaction.js +17 -0
  51. package/build/utils.d.ts +5 -0
  52. package/build/utils.js +49 -0
  53. package/build/verifier.d.ts +16 -0
  54. package/build/verifier.js +24 -0
  55. package/build/websocket.d.ts +35 -0
  56. package/build/websocket.js +177 -0
  57. package/build.gradle +75 -0
  58. package/package.json +32 -0
  59. package/scripts/abi.mjs +19 -0
  60. package/scripts/contracts.mjs +20 -0
  61. package/scripts/download.mjs +27 -0
  62. package/scripts/util.mjs +42 -0
  63. package/src/domains/noto.ts +420 -0
  64. package/src/domains/pente.ts +287 -0
  65. package/src/domains/zeto.ts +282 -0
  66. package/src/index.ts +10 -0
  67. package/src/interfaces/algorithms.ts +6 -0
  68. package/src/interfaces/blockchainevent.ts +18 -0
  69. package/src/interfaces/blockindex.ts +33 -0
  70. package/src/interfaces/domains.ts +10 -0
  71. package/src/interfaces/index.ts +15 -0
  72. package/src/interfaces/keymanager.ts +35 -0
  73. package/src/interfaces/logger.ts +8 -0
  74. package/src/interfaces/paladin.ts +17 -0
  75. package/src/interfaces/privacygroups.ts +86 -0
  76. package/src/interfaces/query.ts +37 -0
  77. package/src/interfaces/registry.ts +27 -0
  78. package/src/interfaces/states.ts +77 -0
  79. package/src/interfaces/transaction.ts +179 -0
  80. package/src/interfaces/transport.ts +35 -0
  81. package/src/interfaces/verifiers.ts +6 -0
  82. package/src/interfaces/websocket.ts +67 -0
  83. package/src/paladin.ts +1295 -0
  84. package/src/transaction.ts +17 -0
  85. package/src/utils.ts +24 -0
  86. package/src/verifier.ts +27 -0
  87. package/src/websocket.ts +217 -0
  88. package/tsconfig.json +14 -0
@@ -0,0 +1,179 @@
1
+ import { BigNumberish, ethers } from "ethers";
2
+ import { NotoUnlockPublicParams } from "../domains/noto";
3
+ import { IStateBase } from "./states";
4
+
5
+ export interface IBlock {
6
+ number: number;
7
+ hash: string;
8
+ timestamp: string;
9
+ }
10
+
11
+ export enum TransactionType {
12
+ PUBLIC = "public",
13
+ PRIVATE = "private",
14
+ }
15
+
16
+ export interface PublicTxOptions {
17
+ gas?: BigNumberish;
18
+ value?: BigNumberish;
19
+ maxPriorityFeePerGas?: BigNumberish;
20
+ maxFeePerGas?: BigNumberish;
21
+ }
22
+
23
+ export interface ITransactionBase {
24
+ type: TransactionType;
25
+ domain?: string;
26
+ function?: string;
27
+ from: string;
28
+ to?: string;
29
+ data: {
30
+ [key: string]: any;
31
+ };
32
+ }
33
+
34
+ export interface ITransaction extends ITransactionBase {
35
+ id: string;
36
+ created: string;
37
+ abiReference: string;
38
+ }
39
+
40
+ export interface IPreparedTransaction {
41
+ id: string;
42
+ domain: string;
43
+ to: string;
44
+ transaction: ITransactionBase & {
45
+ abiReference: string;
46
+ };
47
+ states: {
48
+ spent?: IStateBase[];
49
+ read?: IStateBase[];
50
+ confirmed?: IStateBase[];
51
+ info?: IStateBase[];
52
+ };
53
+ metadata: any;
54
+ }
55
+
56
+ export interface ITransactionInput extends ITransactionBase {
57
+ abiReference?: string;
58
+ abi?: ethers.InterfaceAbi;
59
+ bytecode?: string;
60
+ }
61
+
62
+ export interface ITransactionCall extends ITransactionInput {}
63
+
64
+ export interface ITransactionReceipt {
65
+ blockNumber: number;
66
+ id: string;
67
+ sequence: number;
68
+ success: boolean;
69
+ transactionHash: string;
70
+ source: string;
71
+ domain?: string;
72
+ contractAddress?: string;
73
+ states?: ITransactionStates;
74
+ domainReceipt?: IPenteDomainReceipt | INotoDomainReceipt;
75
+ failureMessage?: string;
76
+ }
77
+
78
+ export interface IPenteDomainReceipt {
79
+ receipt: {
80
+ from?: string;
81
+ to?: string;
82
+ contractAddress?: string;
83
+ logs?: IPenteLog[];
84
+ };
85
+ }
86
+
87
+ export interface IPenteLog {
88
+ address: string;
89
+ topics: string[];
90
+ data: string;
91
+ }
92
+
93
+ export interface INotoDomainReceipt {
94
+ states: {
95
+ inputs?: IReceiptState<INotoCoin>[];
96
+ outputs?: IReceiptState<INotoCoin>[];
97
+ readInputs?: IReceiptState<INotoCoin>[];
98
+ preparedOutputs?: IReceiptState<INotoCoin>[];
99
+
100
+ lockedInputs?: IReceiptState<INotoLockedCoin>[];
101
+ lockedOutputs?: IReceiptState<INotoLockedCoin>[];
102
+ readLockedInputs?: IReceiptState<INotoLockedCoin>[];
103
+ preparedLockedOutputs?: IReceiptState<INotoLockedCoin>[];
104
+ };
105
+ transfers?: {
106
+ from?: string;
107
+ to?: string;
108
+ amount: string;
109
+ }[];
110
+ lockInfo?: {
111
+ lockId: string;
112
+ delegate?: string;
113
+ unlockParams?: NotoUnlockPublicParams;
114
+ unlockCall?: string;
115
+ };
116
+ data?: string;
117
+ }
118
+
119
+ export interface IReceiptState<T> {
120
+ id: string;
121
+ data: T;
122
+ }
123
+
124
+ export interface INotoCoin {
125
+ salt: string;
126
+ owner: string;
127
+ amount: string;
128
+ }
129
+
130
+ export interface INotoLockedCoin {
131
+ lockId: string;
132
+ salt: string;
133
+ owner: string;
134
+ amount: string;
135
+ }
136
+
137
+ export interface ITransactionStates {
138
+ none?: boolean;
139
+ spent?: IStateBase[];
140
+ read?: IStateBase[];
141
+ confirmed?: IStateBase[];
142
+ info?: IStateBase[];
143
+ unavailable?: {
144
+ spent?: string[];
145
+ read?: string[];
146
+ confirmed?: string[];
147
+ info?: string[];
148
+ };
149
+ }
150
+
151
+ export enum TransactionType {
152
+ Private = "private",
153
+ Public = "public",
154
+ }
155
+
156
+ export interface IABIDecodedData {
157
+ signature: string;
158
+ definition: ethers.JsonFragment;
159
+ data: any;
160
+ summary: string; // errors only
161
+ }
162
+
163
+ export interface IStoredABI {
164
+ hash: string;
165
+ abi: ethers.InterfaceAbi;
166
+ }
167
+
168
+ export interface ITransactionReceiptListener {
169
+ name: string;
170
+ filters?: {
171
+ sequenceAbove?: number;
172
+ type?: TransactionType;
173
+ domain?: string;
174
+ };
175
+ options?: {
176
+ domainReceipts?: boolean;
177
+ incompleteStateReceiptBehavior?: "block_contract" | "process";
178
+ };
179
+ }
@@ -0,0 +1,35 @@
1
+ export interface IPeerInfo {
2
+ name: string;
3
+ stats: IPeerStats;
4
+ activated: string;
5
+ outboundTransport?: string;
6
+ outbound?: any;
7
+ outboundError?: any;
8
+ }
9
+
10
+ export interface IPeerStats {
11
+ sentMsgs: number;
12
+ receivedMsgs: number;
13
+ sentBytes: number;
14
+ receivedBytes: number;
15
+ lastSend?: string;
16
+ lastReceive?: string;
17
+ reliableHighestSent: number;
18
+ reliableAckBase: number;
19
+ }
20
+
21
+ export interface IReliableMessage {
22
+ sequence: number;
23
+ id: string;
24
+ created: string;
25
+ node: string;
26
+ messageType: string;
27
+ metadata: any;
28
+ ack?: IReliableMessageAck;
29
+ }
30
+
31
+ export interface IReliableMessageAck {
32
+ messageId: string;
33
+ time?: string;
34
+ error?: string;
35
+ }
@@ -0,0 +1,6 @@
1
+ export enum Verifiers {
2
+ ETH_ADDRESS = "eth_address",
3
+ ETH_ADDRESS_CHECKSUM = "eth_address_checksum",
4
+ HEX_ECDSA_PUBKEY_UNCOMPRESSED = "hex_ecdsa_pubkey_uncompressed",
5
+ HEX_ECDSA_PUBKEY_UNCOMPRESSED_0X = "hex_ecdsa_pubkey_uncompressed_0x",
6
+ }
@@ -0,0 +1,67 @@
1
+ import * as http from "http";
2
+ import WebSocket from "ws";
3
+ import { IEventWithData } from "./blockindex";
4
+ import { Logger } from "./logger";
5
+ import { ITransactionReceipt } from "./transaction";
6
+ import { IPrivacyGroupMessage } from "./privacygroups";
7
+
8
+ export interface WebSocketSender {
9
+ send: (json: object) => void;
10
+ ack: (subscription: string) => void;
11
+ }
12
+
13
+ export interface WebSocketConnectCallback {
14
+ (sender: WebSocketSender): void | Promise<void>;
15
+ }
16
+
17
+ export interface WebSocketEventCallback<TEvent> {
18
+ (sender: WebSocketSender, event: TEvent): void | Promise<void>;
19
+ }
20
+
21
+ export interface WebSocketClientOptions<TMessageTypes extends string> {
22
+ url: string;
23
+ username?: string;
24
+ password?: string;
25
+ subscriptions?: WebSocketSubscription<TMessageTypes>[];
26
+ logger?: Logger;
27
+ heartbeatInterval?: number;
28
+ reconnectDelay?: number;
29
+ afterConnect?: WebSocketConnectCallback;
30
+ socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs;
31
+ }
32
+
33
+ export interface WebSocketSubscription<TMessageTypes extends string> {
34
+ type: TMessageTypes;
35
+ name: string;
36
+ }
37
+
38
+ export interface WebSocketEvent {
39
+ method: "ptx_subscription" | undefined;
40
+ params: {
41
+ subscription: string;
42
+ result: TransactionReceiptBatch | TransactionEventBatch;
43
+ };
44
+ }
45
+
46
+ export interface TransactionReceiptBatch {
47
+ batchId: number;
48
+ receipts: ITransactionReceipt[];
49
+ }
50
+
51
+ export interface TransactionEventBatch {
52
+ batchId: number;
53
+ events: IEventWithData[];
54
+ }
55
+
56
+ export interface PrivacyGroupWebSocketEvent {
57
+ method: "pgroup_subscription" | undefined;
58
+ params: {
59
+ subscription: string;
60
+ result: IPrivacyGroupMessageBatch;
61
+ };
62
+ }
63
+
64
+ export interface IPrivacyGroupMessageBatch {
65
+ batchId: number;
66
+ messages: IPrivacyGroupMessage[];
67
+ }