@zebec-network/zebec-vault-sdk 1.0.1 → 1.0.2
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.
- package/assets/VaultSDKDependencyMap.png +0 -0
- package/dist/artifacts/zebec_vault.d.ts +56 -9
- package/dist/artifacts/zebec_vault.json +56 -9
- package/dist/constants.js +2 -2
- package/dist/pda.js +1 -1
- package/dist/service.d.ts +10 -6
- package/dist/service.js +40 -14
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +14 -2
- package/package.json +3 -2
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* IDL can be found at `target/idl/zebec_vault.json`.
|
|
6
6
|
*/
|
|
7
7
|
export type ZebecVault = {
|
|
8
|
-
address: "
|
|
8
|
+
address: "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim";
|
|
9
9
|
metadata: {
|
|
10
10
|
name: "zebecVault";
|
|
11
11
|
version: "0.1.0";
|
|
@@ -109,6 +109,25 @@ export type ZebecVault = {
|
|
|
109
109
|
}
|
|
110
110
|
];
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
name: "deleteProposal";
|
|
114
|
+
discriminator: [195, 115, 85, 157, 254, 15, 175, 201];
|
|
115
|
+
accounts: [
|
|
116
|
+
{
|
|
117
|
+
name: "proposer";
|
|
118
|
+
signer: true;
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "vault";
|
|
122
|
+
relations: ["proposal"];
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "proposal";
|
|
126
|
+
writable: true;
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
args: [];
|
|
130
|
+
},
|
|
112
131
|
{
|
|
113
132
|
name: "depositSol";
|
|
114
133
|
discriminator: [108, 81, 78, 117, 125, 155, 56, 200];
|
|
@@ -129,7 +148,7 @@ export type ZebecVault = {
|
|
|
129
148
|
seeds: [
|
|
130
149
|
{
|
|
131
150
|
kind: "const";
|
|
132
|
-
value: [
|
|
151
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
133
152
|
},
|
|
134
153
|
{
|
|
135
154
|
kind: "account";
|
|
@@ -172,7 +191,7 @@ export type ZebecVault = {
|
|
|
172
191
|
seeds: [
|
|
173
192
|
{
|
|
174
193
|
kind: "const";
|
|
175
|
-
value: [
|
|
194
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
176
195
|
},
|
|
177
196
|
{
|
|
178
197
|
kind: "account";
|
|
@@ -410,7 +429,7 @@ export type ZebecVault = {
|
|
|
410
429
|
seeds: [
|
|
411
430
|
{
|
|
412
431
|
kind: "const";
|
|
413
|
-
value: [
|
|
432
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
414
433
|
},
|
|
415
434
|
{
|
|
416
435
|
kind: "account";
|
|
@@ -440,7 +459,7 @@ export type ZebecVault = {
|
|
|
440
459
|
seeds: [
|
|
441
460
|
{
|
|
442
461
|
kind: "const";
|
|
443
|
-
value: [
|
|
462
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
444
463
|
},
|
|
445
464
|
{
|
|
446
465
|
kind: "account";
|
|
@@ -485,7 +504,7 @@ export type ZebecVault = {
|
|
|
485
504
|
seeds: [
|
|
486
505
|
{
|
|
487
506
|
kind: "const";
|
|
488
|
-
value: [
|
|
507
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
489
508
|
},
|
|
490
509
|
{
|
|
491
510
|
kind: "account";
|
|
@@ -528,7 +547,7 @@ export type ZebecVault = {
|
|
|
528
547
|
seeds: [
|
|
529
548
|
{
|
|
530
549
|
kind: "const";
|
|
531
|
-
value: [
|
|
550
|
+
value: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114];
|
|
532
551
|
},
|
|
533
552
|
{
|
|
534
553
|
kind: "account";
|
|
@@ -760,6 +779,10 @@ export type ZebecVault = {
|
|
|
760
779
|
name: "actionsAppended";
|
|
761
780
|
discriminator: [58, 232, 160, 225, 22, 253, 24, 141];
|
|
762
781
|
},
|
|
782
|
+
{
|
|
783
|
+
name: "proposalClosed";
|
|
784
|
+
discriminator: [57, 90, 47, 164, 105, 55, 97, 27];
|
|
785
|
+
},
|
|
763
786
|
{
|
|
764
787
|
name: "proposalCreated";
|
|
765
788
|
discriminator: [186, 8, 160, 108, 81, 13, 51, 206];
|
|
@@ -1111,6 +1134,30 @@ export type ZebecVault = {
|
|
|
1111
1134
|
];
|
|
1112
1135
|
};
|
|
1113
1136
|
},
|
|
1137
|
+
{
|
|
1138
|
+
name: "proposalClosed";
|
|
1139
|
+
type: {
|
|
1140
|
+
kind: "struct";
|
|
1141
|
+
fields: [
|
|
1142
|
+
{
|
|
1143
|
+
name: "closedBy";
|
|
1144
|
+
type: "pubkey";
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
name: "closedDate";
|
|
1148
|
+
type: "i64";
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
name: "proposal";
|
|
1152
|
+
type: "pubkey";
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
name: "vault";
|
|
1156
|
+
type: "pubkey";
|
|
1157
|
+
}
|
|
1158
|
+
];
|
|
1159
|
+
};
|
|
1160
|
+
},
|
|
1114
1161
|
{
|
|
1115
1162
|
name: "proposalCreated";
|
|
1116
1163
|
type: {
|
|
@@ -1392,9 +1439,9 @@ export type ZebecVault = {
|
|
|
1392
1439
|
{
|
|
1393
1440
|
name: "vaultSignerPrefix";
|
|
1394
1441
|
type: {
|
|
1395
|
-
array: ["u8",
|
|
1442
|
+
array: ["u8", 18];
|
|
1396
1443
|
};
|
|
1397
|
-
value: "[
|
|
1444
|
+
value: "[122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]";
|
|
1398
1445
|
}
|
|
1399
1446
|
];
|
|
1400
1447
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "zebec_vault",
|
|
5
5
|
"version": "0.1.0",
|
|
@@ -103,6 +103,25 @@
|
|
|
103
103
|
}
|
|
104
104
|
]
|
|
105
105
|
},
|
|
106
|
+
{
|
|
107
|
+
"name": "delete_proposal",
|
|
108
|
+
"discriminator": [195, 115, 85, 157, 254, 15, 175, 201],
|
|
109
|
+
"accounts": [
|
|
110
|
+
{
|
|
111
|
+
"name": "proposer",
|
|
112
|
+
"signer": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "vault",
|
|
116
|
+
"relations": ["proposal"]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "proposal",
|
|
120
|
+
"writable": true
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"args": []
|
|
124
|
+
},
|
|
106
125
|
{
|
|
107
126
|
"name": "deposit_sol",
|
|
108
127
|
"discriminator": [108, 81, 78, 117, 125, 155, 56, 200],
|
|
@@ -123,7 +142,7 @@
|
|
|
123
142
|
"seeds": [
|
|
124
143
|
{
|
|
125
144
|
"kind": "const",
|
|
126
|
-
"value": [
|
|
145
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
127
146
|
},
|
|
128
147
|
{
|
|
129
148
|
"kind": "account",
|
|
@@ -166,7 +185,7 @@
|
|
|
166
185
|
"seeds": [
|
|
167
186
|
{
|
|
168
187
|
"kind": "const",
|
|
169
|
-
"value": [
|
|
188
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
170
189
|
},
|
|
171
190
|
{
|
|
172
191
|
"kind": "account",
|
|
@@ -284,7 +303,7 @@
|
|
|
284
303
|
"seeds": [
|
|
285
304
|
{
|
|
286
305
|
"kind": "const",
|
|
287
|
-
"value": [
|
|
306
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
288
307
|
},
|
|
289
308
|
{
|
|
290
309
|
"kind": "account",
|
|
@@ -314,7 +333,7 @@
|
|
|
314
333
|
"seeds": [
|
|
315
334
|
{
|
|
316
335
|
"kind": "const",
|
|
317
|
-
"value": [
|
|
336
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
318
337
|
},
|
|
319
338
|
{
|
|
320
339
|
"kind": "account",
|
|
@@ -359,7 +378,7 @@
|
|
|
359
378
|
"seeds": [
|
|
360
379
|
{
|
|
361
380
|
"kind": "const",
|
|
362
|
-
"value": [
|
|
381
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
363
382
|
},
|
|
364
383
|
{
|
|
365
384
|
"kind": "account",
|
|
@@ -402,7 +421,7 @@
|
|
|
402
421
|
"seeds": [
|
|
403
422
|
{
|
|
404
423
|
"kind": "const",
|
|
405
|
-
"value": [
|
|
424
|
+
"value": [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]
|
|
406
425
|
},
|
|
407
426
|
{
|
|
408
427
|
"kind": "account",
|
|
@@ -514,6 +533,10 @@
|
|
|
514
533
|
"name": "ActionsAppended",
|
|
515
534
|
"discriminator": [58, 232, 160, 225, 22, 253, 24, 141]
|
|
516
535
|
},
|
|
536
|
+
{
|
|
537
|
+
"name": "ProposalClosed",
|
|
538
|
+
"discriminator": [57, 90, 47, 164, 105, 55, 97, 27]
|
|
539
|
+
},
|
|
517
540
|
{
|
|
518
541
|
"name": "ProposalCreated",
|
|
519
542
|
"discriminator": [186, 8, 160, 108, 81, 13, 51, 206]
|
|
@@ -865,6 +888,30 @@
|
|
|
865
888
|
]
|
|
866
889
|
}
|
|
867
890
|
},
|
|
891
|
+
{
|
|
892
|
+
"name": "ProposalClosed",
|
|
893
|
+
"type": {
|
|
894
|
+
"kind": "struct",
|
|
895
|
+
"fields": [
|
|
896
|
+
{
|
|
897
|
+
"name": "closed_by",
|
|
898
|
+
"type": "pubkey"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
"name": "closed_date",
|
|
902
|
+
"type": "i64"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"name": "proposal",
|
|
906
|
+
"type": "pubkey"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"name": "vault",
|
|
910
|
+
"type": "pubkey"
|
|
911
|
+
}
|
|
912
|
+
]
|
|
913
|
+
}
|
|
914
|
+
},
|
|
868
915
|
{
|
|
869
916
|
"name": "ProposalCreated",
|
|
870
917
|
"type": {
|
|
@@ -1146,9 +1193,9 @@
|
|
|
1146
1193
|
{
|
|
1147
1194
|
"name": "VAULT_SIGNER_PREFIX",
|
|
1148
1195
|
"type": {
|
|
1149
|
-
"array": ["u8",
|
|
1196
|
+
"array": ["u8", 18]
|
|
1150
1197
|
},
|
|
1151
|
-
"value": "[
|
|
1198
|
+
"value": "[122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114]"
|
|
1152
1199
|
}
|
|
1153
1200
|
]
|
|
1154
1201
|
}
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TEN_BIGNUM = exports.ZEBEC_VAULT_PROGRAM_ID = void 0;
|
|
4
4
|
const bignumber_js_1 = require("bignumber.js");
|
|
5
5
|
exports.ZEBEC_VAULT_PROGRAM_ID = {
|
|
6
|
-
"mainnet-beta": "
|
|
7
|
-
devnet: "
|
|
6
|
+
"mainnet-beta": "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim",
|
|
7
|
+
devnet: "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim",
|
|
8
8
|
};
|
|
9
9
|
exports.TEN_BIGNUM = (0, bignumber_js_1.BigNumber)(10);
|
package/dist/pda.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.deriveVaultSigner = deriveVaultSigner;
|
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const SEEDS = {
|
|
7
|
-
VAULT_SIGNER: [
|
|
7
|
+
VAULT_SIGNER: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114],
|
|
8
8
|
};
|
|
9
9
|
function deriveVaultSigner(vault, programId) {
|
|
10
10
|
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.VAULT_SIGNER), (0, anchor_1.translateAddress)(vault).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
package/dist/service.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class ZebecVaultService {
|
|
|
17
17
|
getWithdrawTokenInstruction(withdrawer: PublicKey, vault: PublicKey, tokenMint: PublicKey, amount: BN, decimals: number): Promise<TransactionInstruction>;
|
|
18
18
|
getCreateProposalInstruction(proposer: PublicKey, vault: PublicKey, proposal: PublicKey, name: string, actions: ProposalAction[], proposalAccountSize: number): Promise<TransactionInstruction>;
|
|
19
19
|
getAppendActionInstruction(proposer: PublicKey, proposal: PublicKey, actions: ProposalAction[], newProposalAccountSize: number): Promise<TransactionInstruction>;
|
|
20
|
+
getDeleteProposalInstruction(proposal: PublicKey): Promise<TransactionInstruction>;
|
|
20
21
|
getExecuteProposalInstruction(caller: PublicKey, proposal: PublicKey, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
21
22
|
getExecuteProposalDirectInstruction(vault: PublicKey, proposer: PublicKey, actions: ProposalAction[], remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
22
23
|
createVault(params: {
|
|
@@ -46,21 +47,24 @@ export declare class ZebecVaultService {
|
|
|
46
47
|
amount: Numeric;
|
|
47
48
|
}): Promise<TransactionPayload>;
|
|
48
49
|
createProposal(params: {
|
|
49
|
-
proposer
|
|
50
|
+
proposer?: Address;
|
|
50
51
|
vault: Address;
|
|
51
52
|
proposalKeypair?: Keypair;
|
|
52
53
|
name: string;
|
|
53
54
|
actions: TransactionInstruction[];
|
|
54
55
|
}): Promise<TransactionPayload>;
|
|
55
56
|
appendActions(params: {
|
|
56
|
-
proposer
|
|
57
|
+
proposer?: Address;
|
|
57
58
|
proposal: Address;
|
|
58
59
|
actions: TransactionInstruction[];
|
|
59
60
|
}): Promise<TransactionPayload>;
|
|
61
|
+
deleteProposal(params: {
|
|
62
|
+
caller?: Address;
|
|
63
|
+
proposal: Address;
|
|
64
|
+
}): Promise<TransactionPayload>;
|
|
60
65
|
executeProposal(params: {
|
|
61
|
-
caller
|
|
66
|
+
caller?: Address;
|
|
62
67
|
proposal: Address;
|
|
63
|
-
remainingAccounts: AccountMeta[];
|
|
64
68
|
}): Promise<TransactionPayload>;
|
|
65
69
|
executeProposalDirect(params: {
|
|
66
70
|
vault: Address;
|
|
@@ -68,9 +72,9 @@ export declare class ZebecVaultService {
|
|
|
68
72
|
actions: TransactionInstruction[];
|
|
69
73
|
}): Promise<TransactionPayload>;
|
|
70
74
|
private _createTransactionPayload;
|
|
71
|
-
|
|
75
|
+
getVaultsInfoOfUser(user?: Address): Promise<VaultInfo[]>;
|
|
72
76
|
getAllVaultsInfo(): Promise<VaultInfo[]>;
|
|
73
|
-
|
|
77
|
+
getProposalsInfoOfVault(vault: Address): Promise<ProposalInfo[]>;
|
|
74
78
|
get programId(): PublicKey;
|
|
75
79
|
get connection(): import("@solana/web3.js").Connection;
|
|
76
80
|
}
|
package/dist/service.js
CHANGED
|
@@ -106,6 +106,14 @@ class ZebecVaultService {
|
|
|
106
106
|
})
|
|
107
107
|
.instruction();
|
|
108
108
|
}
|
|
109
|
+
async getDeleteProposalInstruction(proposal) {
|
|
110
|
+
return this.program.methods
|
|
111
|
+
.deleteProposal()
|
|
112
|
+
.accounts({
|
|
113
|
+
proposal,
|
|
114
|
+
})
|
|
115
|
+
.instruction();
|
|
116
|
+
}
|
|
109
117
|
async getExecuteProposalInstruction(caller, proposal, remainingAccounts) {
|
|
110
118
|
return this.program.methods
|
|
111
119
|
.executeProposal()
|
|
@@ -194,12 +202,12 @@ class ZebecVaultService {
|
|
|
194
202
|
data: ix.data,
|
|
195
203
|
programId: ix.programId,
|
|
196
204
|
}));
|
|
197
|
-
const proposalAccountSize = (0, utils_1.calculateProposalSize)(actions);
|
|
205
|
+
const proposalAccountSize = (0, utils_1.calculateProposalSize)(params.name, actions);
|
|
198
206
|
if (proposalAccountSize > 10_000) {
|
|
199
207
|
throw new Error("Proposal size exceeds maximum allowed size of 10,000 bytes");
|
|
200
208
|
}
|
|
201
209
|
const ix = await this.getCreateProposalInstruction(proposer, vault, proposalKeypair.publicKey, params.name, actions, proposalAccountSize);
|
|
202
|
-
return this._createTransactionPayload(proposer, [ix]);
|
|
210
|
+
return this._createTransactionPayload(proposer, [ix], [proposalKeypair]);
|
|
203
211
|
}
|
|
204
212
|
async appendActions(params) {
|
|
205
213
|
const proposer = params.proposer ? (0, anchor_1.translateAddress)(params.proposer) : this.provider.publicKey;
|
|
@@ -216,15 +224,24 @@ class ZebecVaultService {
|
|
|
216
224
|
data: ix.data,
|
|
217
225
|
programId: ix.programId,
|
|
218
226
|
}));
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
const newProposalAccountSize = (0, utils_1.calculateProposalSize)(
|
|
227
|
+
const allActions = proposalAccount.actions;
|
|
228
|
+
allActions.push(...newActions);
|
|
229
|
+
const newProposalAccountSize = (0, utils_1.calculateProposalSize)(proposalAccount.name, allActions);
|
|
222
230
|
if (newProposalAccountSize > 10_000) {
|
|
223
231
|
throw new Error("Proposal size exceeds maximum allowed size of 10,000 bytes");
|
|
224
232
|
}
|
|
225
|
-
const ix = await this.getAppendActionInstruction(proposer, proposal,
|
|
233
|
+
const ix = await this.getAppendActionInstruction(proposer, proposal, newActions, newProposalAccountSize);
|
|
226
234
|
return this._createTransactionPayload(proposer, [ix]);
|
|
227
235
|
}
|
|
236
|
+
async deleteProposal(params) {
|
|
237
|
+
const caller = params.caller ? (0, anchor_1.translateAddress)(params.caller) : this.provider.publicKey;
|
|
238
|
+
if (!caller) {
|
|
239
|
+
throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
|
|
240
|
+
}
|
|
241
|
+
const proposal = (0, anchor_1.translateAddress)(params.proposal);
|
|
242
|
+
const ix = await this.getDeleteProposalInstruction(proposal);
|
|
243
|
+
return this._createTransactionPayload(caller, [ix]);
|
|
244
|
+
}
|
|
228
245
|
async executeProposal(params) {
|
|
229
246
|
const caller = params.caller ? (0, anchor_1.translateAddress)(params.caller) : this.provider.publicKey;
|
|
230
247
|
if (!caller) {
|
|
@@ -243,10 +260,15 @@ class ZebecVaultService {
|
|
|
243
260
|
isSigner: spec.pubkey.equals(vaultSigner) ? false : spec.isSigner,
|
|
244
261
|
isWritable: spec.isWritable,
|
|
245
262
|
}));
|
|
246
|
-
acc.push(...accounts
|
|
263
|
+
acc.push(...accounts, {
|
|
264
|
+
isSigner: false,
|
|
265
|
+
isWritable: false,
|
|
266
|
+
pubkey: current.programId,
|
|
267
|
+
});
|
|
247
268
|
return acc;
|
|
248
269
|
}, []);
|
|
249
270
|
const ix = await this.getExecuteProposalInstruction(caller, proposal, remainingAccounts);
|
|
271
|
+
console.log("ix:", JSON.stringify(ix.keys, null, 2));
|
|
250
272
|
return this._createTransactionPayload(caller, [ix]);
|
|
251
273
|
}
|
|
252
274
|
async executeProposalDirect(params) {
|
|
@@ -267,7 +289,11 @@ class ZebecVaultService {
|
|
|
267
289
|
isSigner: spec.pubkey.equals(vaultSigner) ? false : spec.isSigner,
|
|
268
290
|
isWritable: spec.isWritable,
|
|
269
291
|
}));
|
|
270
|
-
acc.push(...accounts
|
|
292
|
+
acc.push(...accounts, {
|
|
293
|
+
isSigner: false,
|
|
294
|
+
isWritable: false,
|
|
295
|
+
pubkey: current.programId,
|
|
296
|
+
});
|
|
271
297
|
return acc;
|
|
272
298
|
}, []);
|
|
273
299
|
const ix = await this.getExecuteProposalDirectInstruction(vault, proposer, actions, remainingAccounts);
|
|
@@ -285,7 +311,7 @@ class ZebecVaultService {
|
|
|
285
311
|
}
|
|
286
312
|
return new solana_common_1.TransactionPayload(this.provider.connection, errorMap, instructions, payerKey, signers, addressLookupTableAccounts, signTransaction);
|
|
287
313
|
}
|
|
288
|
-
async
|
|
314
|
+
async getVaultsInfoOfUser(user) {
|
|
289
315
|
user = user ? (0, anchor_1.translateAddress)(user) : this.provider.publicKey;
|
|
290
316
|
if (!user) {
|
|
291
317
|
throw new Error("Either provide a user or use AnchorProvider for provider in the service");
|
|
@@ -314,7 +340,7 @@ class ZebecVaultService {
|
|
|
314
340
|
return {
|
|
315
341
|
vault: accountInfo.pubkey,
|
|
316
342
|
owner: vaultAccount.owner,
|
|
317
|
-
|
|
343
|
+
createdDate: vaultAccount.createdDate.toNumber(),
|
|
318
344
|
signerBump: vaultAccount.signerBump,
|
|
319
345
|
};
|
|
320
346
|
});
|
|
@@ -338,27 +364,27 @@ class ZebecVaultService {
|
|
|
338
364
|
return {
|
|
339
365
|
vault: accountInfo.pubkey,
|
|
340
366
|
owner: vaultAccount.owner,
|
|
341
|
-
|
|
367
|
+
createdDate: vaultAccount.createdDate.toNumber(),
|
|
342
368
|
signerBump: vaultAccount.signerBump,
|
|
343
369
|
};
|
|
344
370
|
});
|
|
345
371
|
return vaults;
|
|
346
372
|
}
|
|
347
|
-
async
|
|
373
|
+
async getProposalsInfoOfVault(vault) {
|
|
348
374
|
const _vault = (0, anchor_1.translateAddress)(vault);
|
|
349
375
|
const accountInfos = await this.connection.getProgramAccounts(this.programId, {
|
|
350
376
|
commitment: this.connection.commitment,
|
|
351
377
|
filters: [
|
|
352
378
|
{
|
|
353
379
|
memcmp: {
|
|
354
|
-
offset: 0, // offset for discriminator in
|
|
380
|
+
offset: 0, // offset for discriminator in Proposal
|
|
355
381
|
bytes: anchor_1.utils.bytes.bs58.encode(this.program.idl.accounts[0].discriminator),
|
|
356
382
|
encoding: "base58",
|
|
357
383
|
},
|
|
358
384
|
},
|
|
359
385
|
{
|
|
360
386
|
memcmp: {
|
|
361
|
-
offset: 8, // offset for owner field in
|
|
387
|
+
offset: 8, // offset for owner field in Proposal
|
|
362
388
|
bytes: _vault.toBase58(),
|
|
363
389
|
encoding: "base58",
|
|
364
390
|
},
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProposalAction } from "./types";
|
|
2
2
|
export declare function calculateActionsSize(actions: ProposalAction[]): number;
|
|
3
|
-
export declare function calculateProposalSize(actions: ProposalAction[]): number;
|
|
3
|
+
export declare function calculateProposalSize(name: string, actions: ProposalAction[]): number;
|
package/dist/utils.js
CHANGED
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateActionsSize = calculateActionsSize;
|
|
4
4
|
exports.calculateProposalSize = calculateProposalSize;
|
|
5
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
6
|
function calculateActionsSize(actions) {
|
|
6
7
|
return actions
|
|
7
8
|
.map((ix) => 4 + ix.accountSpecs.length * 34 + 4 + ix.data.length + 32)
|
|
8
9
|
.reduce((acc, curr) => acc + curr, 0);
|
|
9
10
|
}
|
|
10
|
-
function calculateProposalSize(actions) {
|
|
11
|
+
function calculateProposalSize(name, actions) {
|
|
11
12
|
const ix_size = calculateActionsSize(actions);
|
|
12
|
-
const withExtraSpace = 32 +
|
|
13
|
+
const withExtraSpace = 32 +
|
|
14
|
+
1 +
|
|
15
|
+
8 +
|
|
16
|
+
8 +
|
|
17
|
+
1 +
|
|
18
|
+
/** name */
|
|
19
|
+
4 +
|
|
20
|
+
anchor_1.utils.bytes.utf8.encode(name).length +
|
|
21
|
+
/** actions */
|
|
22
|
+
4 +
|
|
23
|
+
ix_size +
|
|
24
|
+
/** extra */ 20;
|
|
13
25
|
return withExtraSpace;
|
|
14
26
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zebec-network/zebec-vault-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "An SDK for zebec vault solana program",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"author": "Ashish Sapkota",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"assets"
|
|
11
12
|
],
|
|
12
13
|
"keywords": [
|
|
13
14
|
"solana",
|