@zebec-network/zebec-vault-sdk 1.0.7 → 1.1.0
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/README.md +116 -7
- package/dist/artifacts/zebec_vault.d.ts +8 -144
- package/dist/artifacts/zebec_vault.json +631 -154
- package/dist/pda.d.ts +0 -1
- package/dist/pda.js +0 -5
- package/dist/service.d.ts +1 -7
- package/dist/service.js +2 -32
- package/dist/types.d.ts +1 -0
- package/package.json +4 -3
package/dist/pda.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Address } from "@coral-xyz/anchor";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
export declare function deriveVaultSigner(vault: Address, programId: Address): [PublicKey, number];
|
|
4
|
-
export declare function deriveWhitelist(programId: Address): [PublicKey, number];
|
package/dist/pda.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deriveVaultSigner = deriveVaultSigner;
|
|
4
|
-
exports.deriveWhitelist = deriveWhitelist;
|
|
5
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
6
|
const SEEDS = {
|
|
@@ -12,7 +11,3 @@ function deriveVaultSigner(vault, programId) {
|
|
|
12
11
|
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.VAULT_SIGNER), (0, anchor_1.translateAddress)(vault).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
13
12
|
return addressAndBump;
|
|
14
13
|
}
|
|
15
|
-
function deriveWhitelist(programId) {
|
|
16
|
-
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.WHITELIST)], (0, anchor_1.translateAddress)(programId));
|
|
17
|
-
return addressAndBump;
|
|
18
|
-
}
|
package/dist/service.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AccountMeta, Keypair, PublicKey, Signer, TransactionInstruction } from
|
|
|
3
3
|
import { TransactionPayload } from "@zebec-network/solana-common";
|
|
4
4
|
import { ZebecVaultIdlV1 } from "./artifacts";
|
|
5
5
|
import { RpcNetwork } from "./constants";
|
|
6
|
-
import { Numeric, ProposalAction, ProposalInfo, VaultInfo
|
|
6
|
+
import { Numeric, ProposalAction, ProposalInfo, VaultInfo } from "./types";
|
|
7
7
|
export declare class ZebecVaultService {
|
|
8
8
|
readonly provider: Provider;
|
|
9
9
|
readonly program: Program<ZebecVaultIdlV1>;
|
|
@@ -20,7 +20,6 @@ export declare class ZebecVaultService {
|
|
|
20
20
|
getDeleteProposalInstruction(proposal: PublicKey): Promise<TransactionInstruction>;
|
|
21
21
|
getExecuteProposalInstruction(caller: PublicKey, proposal: PublicKey, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
22
22
|
getExecuteProposalDirectInstruction(vault: PublicKey, proposer: PublicKey, actions: ProposalAction[], remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
23
|
-
getWhitelistTokenInstruction(whitelister: PublicKey, tokenAddresses: PublicKey[]): Promise<TransactionInstruction>;
|
|
24
23
|
createVault(params: {
|
|
25
24
|
payer?: Address;
|
|
26
25
|
vaultKeypair?: Keypair;
|
|
@@ -76,15 +75,10 @@ export declare class ZebecVaultService {
|
|
|
76
75
|
partialSigners?: Signer[];
|
|
77
76
|
addressLookupTables?: Address[];
|
|
78
77
|
}): Promise<TransactionPayload>;
|
|
79
|
-
whitelistTokens(params: {
|
|
80
|
-
whitelister?: Address;
|
|
81
|
-
tokenAddresses: Address[];
|
|
82
|
-
}): Promise<TransactionPayload>;
|
|
83
78
|
private _createTransactionPayload;
|
|
84
79
|
getVaultsInfoOfUser(user?: Address): Promise<VaultInfo[]>;
|
|
85
80
|
getAllVaultsInfo(): Promise<VaultInfo[]>;
|
|
86
81
|
getProposalsInfoOfVault(vault: Address): Promise<ProposalInfo[]>;
|
|
87
|
-
getWhitelistInfo(): Promise<WhitelistInfo | null>;
|
|
88
82
|
get programId(): PublicKey;
|
|
89
83
|
get connection(): import("@solana/web3.js").Connection;
|
|
90
84
|
}
|
package/dist/service.js
CHANGED
|
@@ -140,16 +140,6 @@ class ZebecVaultService {
|
|
|
140
140
|
.remainingAccounts(remainingAccounts)
|
|
141
141
|
.instruction();
|
|
142
142
|
}
|
|
143
|
-
async getWhitelistTokenInstruction(whitelister, tokenAddresses) {
|
|
144
|
-
return this.program.methods
|
|
145
|
-
.whitelistToken({
|
|
146
|
-
tokenAddresses,
|
|
147
|
-
})
|
|
148
|
-
.accounts({
|
|
149
|
-
whitelister,
|
|
150
|
-
})
|
|
151
|
-
.instruction();
|
|
152
|
-
}
|
|
153
143
|
async createVault(params) {
|
|
154
144
|
const payer = params.payer ? (0, anchor_1.translateAddress)(params.payer) : this.provider.publicKey;
|
|
155
145
|
if (!payer) {
|
|
@@ -335,15 +325,6 @@ class ZebecVaultService {
|
|
|
335
325
|
}
|
|
336
326
|
return this._createTransactionPayload(proposer, [ix], params.partialSigners, addressLookupTableAccounts);
|
|
337
327
|
}
|
|
338
|
-
async whitelistTokens(params) {
|
|
339
|
-
const whitelister = params.whitelister ? (0, anchor_1.translateAddress)(params.whitelister) : this.provider.publicKey;
|
|
340
|
-
if (!whitelister) {
|
|
341
|
-
throw new Error("Either provide a whitelister or use AnchorProvider for provider in the service");
|
|
342
|
-
}
|
|
343
|
-
const tokens = params.tokenAddresses.map((address) => (0, anchor_1.translateAddress)(address));
|
|
344
|
-
const ix = await this.getWhitelistTokenInstruction(whitelister, tokens);
|
|
345
|
-
return this._createTransactionPayload(whitelister, [ix]);
|
|
346
|
-
}
|
|
347
328
|
async _createTransactionPayload(payerKey, instructions, signers, addressLookupTableAccounts) {
|
|
348
329
|
const errorMap = new Map();
|
|
349
330
|
this.program.idl.errors.forEach((error) => errorMap.set(error.code, error.msg));
|
|
@@ -441,27 +422,16 @@ class ZebecVaultService {
|
|
|
441
422
|
return {
|
|
442
423
|
proposal: accountInfo.pubkey,
|
|
443
424
|
vault: proposalAccount.vault,
|
|
444
|
-
proposalStage: proposalAccount.
|
|
425
|
+
proposalStage: proposalAccount.proposalStage,
|
|
445
426
|
createdDate: proposalAccount.createdDate.toNumber(),
|
|
446
427
|
expiryDate: proposalAccount.expiryDate.toNumber(),
|
|
447
|
-
isExecuted: proposalAccount.isExecuted,
|
|
448
428
|
name: proposalAccount.name,
|
|
449
429
|
actions: proposalAccount.actions,
|
|
430
|
+
isExecuted: proposalAccount.isExecuted,
|
|
450
431
|
};
|
|
451
432
|
});
|
|
452
433
|
return proposals;
|
|
453
434
|
}
|
|
454
|
-
async getWhitelistInfo() {
|
|
455
|
-
const [whitelist] = (0, pda_1.deriveWhitelist)(this.programId);
|
|
456
|
-
const whitelistAccount = await this.program.account.whitelist.fetchNullable(whitelist, this.connection.commitment);
|
|
457
|
-
if (!whitelistAccount) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
return {
|
|
461
|
-
...whitelistAccount,
|
|
462
|
-
whitelist,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
435
|
get programId() {
|
|
466
436
|
return this.program.programId;
|
|
467
437
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zebec-network/zebec-vault-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "An SDK for zebec vault solana program",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"build": "npm run clean && tsc",
|
|
22
22
|
"clean": "rimraf ./dist",
|
|
23
23
|
"format": "prettier --write .",
|
|
24
|
-
"test": "ts-mocha -p ./tsconfig.json -t 1000000000"
|
|
24
|
+
"test:single": "ts-mocha -p ./tsconfig.json -t 1000000000",
|
|
25
|
+
"test": "ts-mocha -p ./tsconfig.json -t 1000000000 test/**/*.test.ts"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/mocha": "^10.0.10",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@coral-xyz/anchor": "^0.31.1",
|
|
40
41
|
"@solana/web3.js": "^1.98.2",
|
|
41
42
|
"@types/bn.js": "^5.2.0",
|
|
42
|
-
"@zebec-network/solana-common": "^1.5.
|
|
43
|
+
"@zebec-network/solana-common": "^1.5.1",
|
|
43
44
|
"bignumber.js": "^9.3.0",
|
|
44
45
|
"buffer": "^6.0.3"
|
|
45
46
|
}
|