@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,117 @@
1
+ import { ethers } from "ethers";
2
+ import PaladinClient from "../paladin";
3
+ import { TransactionFuture } from "../transaction";
4
+ import { PaladinVerifier } from "../verifier";
5
+ export declare const notoConstructorABI: (withHooks: boolean) => ethers.JsonFragment;
6
+ export interface IGroupInfo {
7
+ salt: string;
8
+ members: string[];
9
+ }
10
+ export interface NotoConstructorParams {
11
+ name?: string;
12
+ symbol?: string;
13
+ notary: PaladinVerifier;
14
+ notaryMode: "basic" | "hooks";
15
+ options?: {
16
+ basic?: {
17
+ restrictMint: boolean;
18
+ allowBurn: boolean;
19
+ allowLock: boolean;
20
+ };
21
+ hooks?: {
22
+ publicAddress: string;
23
+ privateGroup?: IGroupInfo;
24
+ privateAddress?: string;
25
+ };
26
+ };
27
+ }
28
+ export interface NotoMintParams {
29
+ to: PaladinVerifier;
30
+ amount: string | number;
31
+ data: string;
32
+ }
33
+ export interface NotoBurnParams {
34
+ amount: string | number;
35
+ data: string;
36
+ }
37
+ export interface NotoBurnFromParams {
38
+ from: PaladinVerifier;
39
+ amount: string | number;
40
+ data: string;
41
+ }
42
+ export interface NotoTransferParams {
43
+ to: PaladinVerifier;
44
+ amount: string | number;
45
+ data: string;
46
+ }
47
+ export interface NotoTransferFromParams {
48
+ from: PaladinVerifier;
49
+ to: PaladinVerifier;
50
+ amount: string | number;
51
+ data: string;
52
+ }
53
+ export interface NotoLockParams {
54
+ amount: string | number;
55
+ data: string;
56
+ }
57
+ export interface NotoUnlockParams {
58
+ lockId: string;
59
+ from: PaladinVerifier;
60
+ recipients: UnlockRecipient[];
61
+ data: string;
62
+ }
63
+ export interface UnlockRecipient {
64
+ to: PaladinVerifier;
65
+ amount: string | number;
66
+ }
67
+ export interface NotoDelegateLockParams {
68
+ lockId: string;
69
+ unlock: NotoUnlockPublicParams;
70
+ delegate: string;
71
+ data: string;
72
+ }
73
+ export interface NotoUnlockPublicParams {
74
+ txId: string;
75
+ lockedInputs: string[];
76
+ lockedOutputs: string[];
77
+ outputs: string[];
78
+ signature: string;
79
+ data: string;
80
+ }
81
+ export interface NotoBalanceOfParams {
82
+ account: string;
83
+ }
84
+ export interface NotoBalanceOfResult {
85
+ totalBalance: string;
86
+ totalStates: string;
87
+ overflow: boolean;
88
+ }
89
+ export declare class NotoFuture extends TransactionFuture {
90
+ waitForDeploy(waitMs?: number): Promise<NotoInstance | undefined>;
91
+ }
92
+ export declare class NotoFactory {
93
+ private paladin;
94
+ readonly domain: string;
95
+ constructor(paladin: PaladinClient, domain: string);
96
+ using(paladin: PaladinClient): NotoFactory;
97
+ newNoto(from: PaladinVerifier, data: NotoConstructorParams): NotoFuture;
98
+ }
99
+ export declare class NotoInstance {
100
+ private paladin;
101
+ readonly address: string;
102
+ constructor(paladin: PaladinClient, address: string);
103
+ using(paladin: PaladinClient): NotoInstance;
104
+ mint(from: PaladinVerifier, data: NotoMintParams): TransactionFuture;
105
+ transfer(from: PaladinVerifier, data: NotoTransferParams): TransactionFuture;
106
+ transferFrom(from: PaladinVerifier, data: NotoTransferFromParams): TransactionFuture;
107
+ prepareTransfer(from: PaladinVerifier, data: NotoTransferParams): Promise<string>;
108
+ burn(from: PaladinVerifier, data: NotoBurnParams): TransactionFuture;
109
+ burnFrom(from: PaladinVerifier, data: NotoBurnFromParams): TransactionFuture;
110
+ lock(from: PaladinVerifier, data: NotoLockParams): TransactionFuture;
111
+ unlock(from: PaladinVerifier, data: NotoUnlockParams): TransactionFuture;
112
+ unlockAsDelegate(from: PaladinVerifier, data: NotoUnlockPublicParams): TransactionFuture;
113
+ prepareUnlock(from: PaladinVerifier, data: NotoUnlockParams): TransactionFuture;
114
+ delegateLock(from: PaladinVerifier, data: NotoDelegateLockParams): TransactionFuture;
115
+ encodeUnlock(data: NotoUnlockPublicParams): string;
116
+ balanceOf(from: PaladinVerifier, data: NotoBalanceOfParams): Promise<NotoBalanceOfResult>;
117
+ }
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.NotoInstance = exports.NotoFactory = exports.NotoFuture = exports.notoConstructorABI = void 0;
27
+ const ethers_1 = require("ethers");
28
+ const interfaces_1 = require("../interfaces");
29
+ const transaction_1 = require("../transaction");
30
+ const notoJSON = __importStar(require("./abis/INoto.json"));
31
+ const notoPrivateJSON = __importStar(require("./abis/INotoPrivate.json"));
32
+ const notoConstructorABI = (withHooks) => ({
33
+ type: "constructor",
34
+ inputs: [
35
+ { name: "name", type: "string" },
36
+ { name: "symbol", type: "string" },
37
+ { name: "notary", type: "string" },
38
+ { name: "notaryMode", type: "string" },
39
+ {
40
+ name: "options",
41
+ type: "tuple",
42
+ components: [
43
+ ...(withHooks
44
+ ? [
45
+ {
46
+ name: "hooks",
47
+ type: "tuple",
48
+ components: [
49
+ {
50
+ name: "privateGroup",
51
+ type: "tuple",
52
+ components: [
53
+ { name: "salt", type: "bytes32" },
54
+ { name: "members", type: "string[]" },
55
+ ],
56
+ },
57
+ { name: "publicAddress", type: "address" },
58
+ { name: "privateAddress", type: "address" },
59
+ ],
60
+ },
61
+ ]
62
+ : [
63
+ {
64
+ name: "basic",
65
+ type: "tuple",
66
+ components: [
67
+ { name: "restrictMint", type: "bool" },
68
+ { name: "allowBurn", type: "bool" },
69
+ { name: "allowLock", type: "bool" },
70
+ ],
71
+ },
72
+ ]),
73
+ ],
74
+ },
75
+ ],
76
+ });
77
+ exports.notoConstructorABI = notoConstructorABI;
78
+ // Represents an in-flight Noto deployment
79
+ class NotoFuture extends transaction_1.TransactionFuture {
80
+ async waitForDeploy(waitMs) {
81
+ const receipt = await this.waitForReceipt(waitMs);
82
+ return receipt?.contractAddress
83
+ ? new NotoInstance(this.paladin, receipt.contractAddress)
84
+ : undefined;
85
+ }
86
+ }
87
+ exports.NotoFuture = NotoFuture;
88
+ class NotoFactory {
89
+ constructor(paladin, domain) {
90
+ this.paladin = paladin;
91
+ this.domain = domain;
92
+ }
93
+ using(paladin) {
94
+ return new NotoFactory(paladin, this.domain);
95
+ }
96
+ newNoto(from, data) {
97
+ return new NotoFuture(this.paladin, this.paladin.ptx.sendTransaction({
98
+ type: interfaces_1.TransactionType.PRIVATE,
99
+ domain: this.domain,
100
+ abi: [(0, exports.notoConstructorABI)(!!data.options?.hooks)],
101
+ function: "",
102
+ from: from.lookup,
103
+ data: {
104
+ ...data,
105
+ name: data.name ?? "",
106
+ symbol: data.symbol ?? "",
107
+ notary: data.notary.lookup,
108
+ options: {
109
+ basic: {
110
+ restrictMint: true,
111
+ allowBurn: true,
112
+ allowLock: true,
113
+ ...data.options?.basic,
114
+ },
115
+ ...data.options,
116
+ },
117
+ },
118
+ }));
119
+ }
120
+ }
121
+ exports.NotoFactory = NotoFactory;
122
+ class NotoInstance {
123
+ constructor(paladin, address) {
124
+ this.paladin = paladin;
125
+ this.address = address;
126
+ }
127
+ using(paladin) {
128
+ return new NotoInstance(paladin, this.address);
129
+ }
130
+ mint(from, data) {
131
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
132
+ type: interfaces_1.TransactionType.PRIVATE,
133
+ abi: notoPrivateJSON.abi,
134
+ function: "mint",
135
+ to: this.address,
136
+ from: from.lookup,
137
+ data: {
138
+ ...data,
139
+ to: data.to.lookup,
140
+ },
141
+ }));
142
+ }
143
+ transfer(from, data) {
144
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
145
+ type: interfaces_1.TransactionType.PRIVATE,
146
+ abi: notoPrivateJSON.abi,
147
+ function: "transfer",
148
+ to: this.address,
149
+ from: from.lookup,
150
+ data: {
151
+ ...data,
152
+ to: data.to.lookup,
153
+ },
154
+ }));
155
+ }
156
+ transferFrom(from, data) {
157
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
158
+ type: interfaces_1.TransactionType.PRIVATE,
159
+ abi: notoPrivateJSON.abi,
160
+ function: "transferFrom",
161
+ to: this.address,
162
+ from: from.lookup,
163
+ data: {
164
+ ...data,
165
+ from: data.from.lookup,
166
+ to: data.to.lookup,
167
+ },
168
+ }));
169
+ }
170
+ prepareTransfer(from, data) {
171
+ return this.paladin.prepareTransaction({
172
+ type: interfaces_1.TransactionType.PRIVATE,
173
+ abi: notoPrivateJSON.abi,
174
+ function: "transfer",
175
+ to: this.address,
176
+ from: from.lookup,
177
+ data: {
178
+ ...data,
179
+ to: data.to.lookup,
180
+ },
181
+ });
182
+ }
183
+ burn(from, data) {
184
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
185
+ type: interfaces_1.TransactionType.PRIVATE,
186
+ abi: notoPrivateJSON.abi,
187
+ function: "burn",
188
+ to: this.address,
189
+ from: from.lookup,
190
+ data,
191
+ }));
192
+ }
193
+ burnFrom(from, data) {
194
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
195
+ type: interfaces_1.TransactionType.PRIVATE,
196
+ abi: notoPrivateJSON.abi,
197
+ function: "burnFrom",
198
+ to: this.address,
199
+ from: from.lookup,
200
+ data: {
201
+ ...data,
202
+ from: data.from.lookup,
203
+ }
204
+ }));
205
+ }
206
+ lock(from, data) {
207
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
208
+ type: interfaces_1.TransactionType.PRIVATE,
209
+ abi: notoPrivateJSON.abi,
210
+ function: "lock",
211
+ to: this.address,
212
+ from: from.lookup,
213
+ data,
214
+ }));
215
+ }
216
+ unlock(from, data) {
217
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
218
+ type: interfaces_1.TransactionType.PRIVATE,
219
+ abi: notoPrivateJSON.abi,
220
+ function: "unlock",
221
+ to: this.address,
222
+ from: from.lookup,
223
+ data: {
224
+ ...data,
225
+ from: data.from.lookup,
226
+ recipients: data.recipients.map((recipient) => ({
227
+ to: recipient.to.lookup,
228
+ amount: recipient.amount,
229
+ })),
230
+ },
231
+ }));
232
+ }
233
+ unlockAsDelegate(from, data) {
234
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
235
+ type: interfaces_1.TransactionType.PUBLIC,
236
+ abi: notoJSON.abi,
237
+ function: "unlock",
238
+ to: this.address,
239
+ from: from.lookup,
240
+ data,
241
+ }));
242
+ }
243
+ prepareUnlock(from, data) {
244
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
245
+ type: interfaces_1.TransactionType.PRIVATE,
246
+ abi: notoPrivateJSON.abi,
247
+ function: "prepareUnlock",
248
+ to: this.address,
249
+ from: from.lookup,
250
+ data: {
251
+ ...data,
252
+ from: data.from.lookup,
253
+ recipients: data.recipients.map((recipient) => ({
254
+ to: recipient.to.lookup,
255
+ amount: recipient.amount,
256
+ })),
257
+ },
258
+ }));
259
+ }
260
+ delegateLock(from, data) {
261
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
262
+ type: interfaces_1.TransactionType.PRIVATE,
263
+ abi: notoPrivateJSON.abi,
264
+ function: "delegateLock",
265
+ to: this.address,
266
+ from: from.lookup,
267
+ data,
268
+ }));
269
+ }
270
+ encodeUnlock(data) {
271
+ return new ethers_1.ethers.Interface(notoJSON.abi).encodeFunctionData("unlock", [
272
+ data.txId,
273
+ data.lockedInputs,
274
+ data.lockedOutputs,
275
+ data.outputs,
276
+ data.signature,
277
+ data.data,
278
+ ]);
279
+ }
280
+ balanceOf(from, data) {
281
+ return this.paladin.call({
282
+ type: interfaces_1.TransactionType.PRIVATE,
283
+ domain: "noto",
284
+ abi: notoPrivateJSON.abi,
285
+ function: "balanceOf",
286
+ to: this.address,
287
+ from: from.lookup,
288
+ data,
289
+ });
290
+ }
291
+ }
292
+ exports.NotoInstance = NotoInstance;
@@ -0,0 +1,84 @@
1
+ import { ethers } from "ethers";
2
+ import { IPrivacyGroup, IPrivacyGroupEVMCall, IPrivacyGroupEVMTXInput, IPrivacyGroupResume } from "../interfaces/privacygroups";
3
+ import PaladinClient from "../paladin";
4
+ import { TransactionFuture } from "../transaction";
5
+ import { PaladinVerifier } from "../verifier";
6
+ export interface PenteGroupTransactionInput {
7
+ from: string;
8
+ methodAbi: ethers.JsonFragment;
9
+ to: string;
10
+ data: {
11
+ [key: string]: any;
12
+ };
13
+ }
14
+ export interface PenteContractTransactionInput {
15
+ from: string;
16
+ function: string;
17
+ data?: {
18
+ [key: string]: any;
19
+ };
20
+ }
21
+ export interface PenteDeploy {
22
+ abi: ReadonlyArray<ethers.JsonFragment>;
23
+ bytecode: string;
24
+ from: string;
25
+ inputs?: any;
26
+ }
27
+ export interface PentePrivacyGroupParams {
28
+ name?: string;
29
+ members: (string | PaladinVerifier)[];
30
+ salt?: string;
31
+ evmVersion?: string;
32
+ endorsementType?: string;
33
+ externalCallsEnabled?: boolean;
34
+ additionalProperties?: {
35
+ [x: string]: unknown;
36
+ };
37
+ }
38
+ export interface PenteApproveTransitionParams {
39
+ txId: string;
40
+ delegate: string;
41
+ transitionHash: string;
42
+ signatures: string[];
43
+ }
44
+ export declare class PentePrivacyGroupFuture {
45
+ private paladin;
46
+ private group;
47
+ tx: Promise<TransactionFuture | undefined>;
48
+ constructor(paladin: PaladinClient, group: IPrivacyGroup | Promise<IPrivacyGroup>);
49
+ waitForReceipt(waitMs?: number, full?: boolean): Promise<import("../interfaces").ITransactionReceipt | undefined>;
50
+ waitForDeploy(waitMs?: number): Promise<PentePrivacyGroup | undefined>;
51
+ }
52
+ export declare class PenteFactory {
53
+ private paladin;
54
+ readonly domain: string;
55
+ constructor(paladin: PaladinClient, domain: string);
56
+ using(paladin: PaladinClient): PenteFactory;
57
+ newPrivacyGroup(input: PentePrivacyGroupParams): PentePrivacyGroupFuture;
58
+ resumePrivacyGroup(input: IPrivacyGroupResume): Promise<PentePrivacyGroup | undefined>;
59
+ }
60
+ export declare class PentePrivacyGroup {
61
+ private paladin;
62
+ readonly group: IPrivacyGroup;
63
+ readonly address: string;
64
+ readonly salt: string;
65
+ readonly members: string[];
66
+ constructor(paladin: PaladinClient, group: IPrivacyGroup);
67
+ using(paladin: PaladinClient): PentePrivacyGroup;
68
+ deploy(params: PenteDeploy, txOptions?: Partial<IPrivacyGroupEVMTXInput>): PentePrivateDeployFuture;
69
+ sendTransaction(transaction: PenteGroupTransactionInput, txOptions?: Partial<IPrivacyGroupEVMTXInput>): TransactionFuture;
70
+ call(transaction: PenteGroupTransactionInput, txOptions?: Partial<IPrivacyGroupEVMCall>): Promise<any>;
71
+ approveTransition(from: PaladinVerifier, data: PenteApproveTransitionParams): TransactionFuture;
72
+ }
73
+ export declare class PentePrivateDeployFuture extends TransactionFuture {
74
+ waitForDeploy(waitMs?: number): Promise<string | undefined>;
75
+ }
76
+ export declare abstract class PentePrivateContract<ConstructorParams> {
77
+ protected evm: PentePrivacyGroup;
78
+ protected abi: ReadonlyArray<ethers.JsonFragment>;
79
+ readonly address: string;
80
+ constructor(evm: PentePrivacyGroup, abi: ReadonlyArray<ethers.JsonFragment>, address: string);
81
+ abstract using(paladin: PaladinClient): PentePrivateContract<ConstructorParams>;
82
+ sendTransaction(transaction: PenteContractTransactionInput, txOptions?: Partial<IPrivacyGroupEVMTXInput>): TransactionFuture;
83
+ call(transaction: PenteContractTransactionInput, txOptions?: Partial<IPrivacyGroupEVMCall>): Promise<any>;
84
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PentePrivateContract = exports.PentePrivateDeployFuture = exports.PentePrivacyGroup = exports.PenteFactory = exports.PentePrivacyGroupFuture = void 0;
27
+ const interfaces_1 = require("../interfaces");
28
+ const transaction_1 = require("../transaction");
29
+ const penteJSON = __importStar(require("./abis/PentePrivacyGroup.json"));
30
+ // Represents an in-flight Pente privacy group deployment
31
+ class PentePrivacyGroupFuture {
32
+ constructor(paladin, group) {
33
+ this.paladin = paladin;
34
+ this.group = group;
35
+ this.tx = Promise.resolve(group).then((group) => group.genesisTransaction
36
+ ? new transaction_1.TransactionFuture(paladin, group.genesisTransaction)
37
+ : undefined);
38
+ }
39
+ async waitForReceipt(waitMs, full = false) {
40
+ const tx = await this.tx;
41
+ return tx?.waitForReceipt(waitMs, full);
42
+ }
43
+ async waitForDeploy(waitMs) {
44
+ const group = await this.group;
45
+ const receipt = await this.waitForReceipt(waitMs);
46
+ group.contractAddress = receipt?.contractAddress;
47
+ return group.contractAddress
48
+ ? new PentePrivacyGroup(this.paladin, group)
49
+ : undefined;
50
+ }
51
+ }
52
+ exports.PentePrivacyGroupFuture = PentePrivacyGroupFuture;
53
+ class PenteFactory {
54
+ constructor(paladin, domain) {
55
+ this.paladin = paladin;
56
+ this.domain = domain;
57
+ }
58
+ using(paladin) {
59
+ return new PenteFactory(paladin, this.domain);
60
+ }
61
+ newPrivacyGroup(input) {
62
+ return new PentePrivacyGroupFuture(this.paladin, this.paladin.pgroup.createGroup({
63
+ domain: this.domain,
64
+ name: input.name,
65
+ members: input.members.map((m) => m.toString()),
66
+ configuration: {
67
+ evmVersion: input.evmVersion,
68
+ endorsementType: input.endorsementType,
69
+ externalCallsEnabled: input.externalCallsEnabled === true
70
+ ? "true"
71
+ : input.externalCallsEnabled === false
72
+ ? "false"
73
+ : undefined,
74
+ },
75
+ }));
76
+ }
77
+ async resumePrivacyGroup(input) {
78
+ const existingGroup = await this.paladin.getPrivacyGroupById(this.domain, input.id);
79
+ return existingGroup?.contractAddress
80
+ ? new PentePrivacyGroup(this.paladin, existingGroup)
81
+ : undefined;
82
+ }
83
+ }
84
+ exports.PenteFactory = PenteFactory;
85
+ class PentePrivacyGroup {
86
+ constructor(paladin, group) {
87
+ this.paladin = paladin;
88
+ this.group = group;
89
+ if (group.contractAddress === undefined) {
90
+ throw new Error(`Supplied group '${group.id}' is missing a contract address. Check transaction ${group.genesisTransaction}`);
91
+ }
92
+ this.address = group.contractAddress;
93
+ this.salt = group.id; // when bypassing privacy group helper functionality, and directly building Pente private transactions
94
+ this.members = group.members;
95
+ }
96
+ using(paladin) {
97
+ return new PentePrivacyGroup(paladin, this.group);
98
+ }
99
+ deploy(params, txOptions) {
100
+ // Find the constructor in the ABI
101
+ const constructor = params.abi.find((entry) => entry.type === "constructor") || { type: "constructor", inputs: [] };
102
+ const transaction = {
103
+ ...txOptions,
104
+ domain: this.group.domain,
105
+ group: this.group.id,
106
+ from: params.from,
107
+ input: params.inputs,
108
+ bytecode: params.bytecode,
109
+ function: constructor,
110
+ };
111
+ return new PentePrivateDeployFuture(this.paladin, this.paladin.sendPrivacyGroupTransaction(transaction));
112
+ }
113
+ // sendTransaction functions in the contract (write)
114
+ sendTransaction(transaction, txOptions) {
115
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendPrivacyGroupTransaction({
116
+ ...txOptions,
117
+ domain: this.group.domain,
118
+ group: this.group.id,
119
+ from: transaction.from,
120
+ to: transaction.to,
121
+ input: transaction.data,
122
+ function: transaction.methodAbi,
123
+ }));
124
+ }
125
+ // call functions in the contract (read-only)
126
+ async call(transaction, txOptions) {
127
+ return this.paladin.callPrivacyGroup({
128
+ ...txOptions,
129
+ domain: this.group.domain,
130
+ group: this.group.id,
131
+ from: transaction.from || "sdk.default",
132
+ to: transaction.to,
133
+ input: transaction.data,
134
+ function: transaction.methodAbi,
135
+ });
136
+ }
137
+ approveTransition(from, data) {
138
+ return new transaction_1.TransactionFuture(this.paladin, this.paladin.sendTransaction({
139
+ type: interfaces_1.TransactionType.PUBLIC,
140
+ abi: penteJSON.abi,
141
+ function: "approveTransition",
142
+ to: this.address,
143
+ from: from.lookup,
144
+ data,
145
+ }));
146
+ }
147
+ }
148
+ exports.PentePrivacyGroup = PentePrivacyGroup;
149
+ // Represents an in-flight contract deployment within a privacy group
150
+ class PentePrivateDeployFuture extends transaction_1.TransactionFuture {
151
+ async waitForDeploy(waitMs) {
152
+ const receipt = await this.waitForReceipt(waitMs, true);
153
+ return receipt?.domainReceipt !== undefined &&
154
+ "receipt" in receipt.domainReceipt
155
+ ? receipt.domainReceipt.receipt.contractAddress
156
+ : undefined;
157
+ }
158
+ }
159
+ exports.PentePrivateDeployFuture = PentePrivateDeployFuture;
160
+ class PentePrivateContract {
161
+ constructor(evm, abi, address) {
162
+ this.evm = evm;
163
+ this.abi = abi;
164
+ this.address = address;
165
+ }
166
+ sendTransaction(transaction, txOptions) {
167
+ const method = this.abi.find((entry) => entry.name === transaction.function);
168
+ if (method === undefined) {
169
+ throw new Error(`Method '${transaction.function}' not found`);
170
+ }
171
+ return this.evm.sendTransaction({
172
+ from: transaction.from,
173
+ to: this.address,
174
+ methodAbi: method,
175
+ data: transaction.data ?? [],
176
+ }, txOptions);
177
+ }
178
+ call(transaction, txOptions) {
179
+ const method = this.abi.find((entry) => entry.name === transaction.function);
180
+ if (method === undefined) {
181
+ throw new Error(`Method '${transaction.function}' not found`);
182
+ }
183
+ return this.evm.call({
184
+ from: transaction.from,
185
+ to: this.address,
186
+ methodAbi: method,
187
+ data: transaction.data ?? [],
188
+ }, txOptions);
189
+ }
190
+ }
191
+ exports.PentePrivateContract = PentePrivateContract;