Skip to content

Commit

Permalink
fix(sdk): package updates and commitment change
Browse files Browse the repository at this point in the history
  • Loading branch information
ogmedia committed Aug 25, 2022
1 parent bd3ffca commit b571171
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 55 deletions.
30 changes: 13 additions & 17 deletions sdk/lib/sdk/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Squads {
this.connection = connection;
this.wallet = wallet;
this.multisigProgramId = multisigProgramId !== null && multisigProgramId !== void 0 ? multisigProgramId : constants_1.DEFAULT_MULTISIG_PROGRAM_ID;
this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, anchor_1.AnchorProvider.defaultOptions());
this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, Object.assign(Object.assign({}, anchor_1.AnchorProvider.defaultOptions()), { commitment: "confirmed", preflightCommitment: "confirmed" }));
this.multisig = new anchor_1.Program(squads_mpl_json_1.default, this.multisigProgramId, this.provider);
this.programManagerProgramId =
programManagerProgramId !== null && programManagerProgramId !== void 0 ? programManagerProgramId : constants_1.DEFAULT_PROGRAM_MANAGER_PROGRAM_ID;
Expand Down Expand Up @@ -81,73 +81,73 @@ class Squads {
}
getMultisig(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.ms.fetch(address);
const accountData = yield this.multisig.account.ms.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getMultisigs(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.ms.fetchMultiple(addresses);
const accountData = yield this.multisig.account.ms.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
getTransaction(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.msTransaction.fetch(address);
const accountData = yield this.multisig.account.msTransaction.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getTransactions(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.msTransaction.fetchMultiple(addresses);
const accountData = yield this.multisig.account.msTransaction.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
getInstruction(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.msInstruction.fetch(address);
const accountData = yield this.multisig.account.msInstruction.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getInstructions(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.multisig.account.msInstruction.fetchMultiple(addresses);
const accountData = yield this.multisig.account.msInstruction.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
getProgramManager(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.programManager.fetch(address);
const accountData = yield this.programManager.account.programManager.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getProgramManagers(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.programManager.fetchMultiple(addresses);
const accountData = yield this.programManager.account.programManager.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
getManagedProgram(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.managedProgram.fetch(address);
const accountData = yield this.programManager.account.managedProgram.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getManagedPrograms(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.managedProgram.fetchMultiple(addresses);
const accountData = yield this.programManager.account.managedProgram.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
getProgramUpgrade(address) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.programUpgrade.fetch(address);
const accountData = yield this.programManager.account.programUpgrade.fetch(address, "processed");
return Object.assign(Object.assign({}, accountData), { publicKey: address });
});
}
getProgramUpgrades(addresses) {
return __awaiter(this, void 0, void 0, function* () {
const accountData = yield this.programManager.account.programUpgrade.fetchMultiple(addresses);
const accountData = yield this.programManager.account.programUpgrade.fetchMultiple(addresses, "processed");
return this._addPublicKeys(accountData, addresses);
});
}
Expand Down Expand Up @@ -374,7 +374,6 @@ class Squads {
const formattedKeys = ixKeys.map((ixKey, keyInd) => {
if ((ixData.includes(addData) || ixData.includes(addAndThreshData)) &&
keyInd === 2) {
console.log("swapping key from", ixKey.pubkey.toString(), "to", feePayer.toString());
return {
pubkey: feePayer,
isSigner: false,
Expand All @@ -387,9 +386,6 @@ class Squads {
isWritable: ixKey.isWritable,
};
});
if (ixData.includes(addData) || ixData.includes(addAndThreshData)) {
console.log(formattedKeys.map((f) => f.pubkey.toString()));
}
return [
{ pubkey, isSigner: false, isWritable: false },
{ pubkey: ixItem.programId, isSigner: false, isWritable: false },
Expand Down
5 changes: 3 additions & 2 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sqds/sdk",
"version": "1.0.2",
"version": "1.0.4",
"description": "An SDK for easily interacting with Squads Multisig Programs",
"main": "lib/sdk/src/index.js",
"files": [
Expand All @@ -11,7 +11,8 @@
"build": "./build.sh"
},
"dependencies": {
"@project-serum/anchor": "^0.24.2",
"@project-serum/anchor": "^0.25.0",
"@solana/web3.js": "^1.53.0",
"bn.js": "^5.2.1"
},
"devDependencies": {
Expand Down
33 changes: 20 additions & 13 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Squads {
this.provider = new AnchorProvider(
this.connection,
this.wallet,
AnchorProvider.defaultOptions()
{...AnchorProvider.defaultOptions(), commitment: "confirmed", preflightCommitment: "confirmed"}
);
this.multisig = new Program<SquadsMpl>(
squadsMplJSON as SquadsMpl,
Expand Down Expand Up @@ -168,29 +168,31 @@ class Squads {
);
}
async getMultisig(address: PublicKey): Promise<MultisigAccount> {
const accountData = await this.multisig.account.ms.fetch(address);
const accountData = await this.multisig.account.ms.fetch(address, "processed");
return { ...accountData, publicKey: address } as MultisigAccount;
}
async getMultisigs(
addresses: PublicKey[]
): Promise<(MultisigAccount | null)[]> {
const accountData = await this.multisig.account.ms.fetchMultiple(addresses);
const accountData = await this.multisig.account.ms.fetchMultiple(addresses, "processed");
return this._addPublicKeys(
accountData,
addresses
) as (MultisigAccount | null)[];
}
async getTransaction(address: PublicKey): Promise<TransactionAccount> {
const accountData = await this.multisig.account.msTransaction.fetch(
address
address,
"processed"
);
return { ...accountData, publicKey: address };
}
async getTransactions(
addresses: PublicKey[]
): Promise<(TransactionAccount | null)[]> {
const accountData = await this.multisig.account.msTransaction.fetchMultiple(
addresses
addresses,
"processed"
);
return this._addPublicKeys(
accountData,
Expand All @@ -199,15 +201,17 @@ class Squads {
}
async getInstruction(address: PublicKey): Promise<InstructionAccount> {
const accountData = await this.multisig.account.msInstruction.fetch(
address
address,
"processed"
);
return { ...accountData, publicKey: address };
}
async getInstructions(
addresses: PublicKey[]
): Promise<(InstructionAccount | null)[]> {
const accountData = await this.multisig.account.msInstruction.fetchMultiple(
addresses
addresses,
"processed"
);
return this._addPublicKeys(
accountData,
Expand All @@ -217,47 +221,50 @@ class Squads {

async getProgramManager(address: PublicKey): Promise<ProgramManagerAccount> {
const accountData = await this.programManager.account.programManager.fetch(
address
address,
"processed"
);
return { ...accountData, publicKey: address };
}
async getProgramManagers(
addresses: PublicKey[]
): Promise<(ProgramManagerAccount | null)[]> {
const accountData =
await this.programManager.account.programManager.fetchMultiple(addresses);
await this.programManager.account.programManager.fetchMultiple(addresses, "processed");
return this._addPublicKeys(
accountData,
addresses
) as (ProgramManagerAccount | null)[];
}
async getManagedProgram(address: PublicKey): Promise<ManagedProgramAccount> {
const accountData = await this.programManager.account.managedProgram.fetch(
address
address,
"processed"
);
return { ...accountData, publicKey: address };
}
async getManagedPrograms(
addresses: PublicKey[]
): Promise<(ManagedProgramAccount | null)[]> {
const accountData =
await this.programManager.account.managedProgram.fetchMultiple(addresses);
await this.programManager.account.managedProgram.fetchMultiple(addresses, "processed");
return this._addPublicKeys(
accountData,
addresses
) as (ManagedProgramAccount | null)[];
}
async getProgramUpgrade(address: PublicKey): Promise<ProgramUpgradeAccount> {
const accountData = await this.programManager.account.programUpgrade.fetch(
address
address,
"processed"
);
return { ...accountData, publicKey: address };
}
async getProgramUpgrades(
addresses: PublicKey[]
): Promise<(ProgramUpgradeAccount | null)[]> {
const accountData =
await this.programManager.account.programUpgrade.fetchMultiple(addresses);
await this.programManager.account.programUpgrade.fetchMultiple(addresses, "processed");
return this._addPublicKeys(
accountData,
addresses
Expand Down
83 changes: 60 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,6 @@
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@project-serum/anchor@^0.24.2":
version "0.24.2"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.24.2.tgz#a3c52a99605c80735f446ca9b3a4885034731004"
integrity sha512-0/718g8/DnEuwAidUwh5wLYphUYXhUbiClkuRNhvNoa+1Y8a4g2tJyxoae+emV+PG/Gikd/QUBNMkIcimiIRTA==
dependencies:
"@project-serum/borsh" "^0.2.5"
"@solana/web3.js" "^1.36.0"
base64-js "^1.5.1"
bn.js "^5.1.2"
bs58 "^4.0.1"
buffer-layout "^1.2.2"
camelcase "^5.3.1"
cross-fetch "^3.1.5"
crypto-hash "^1.3.0"
eventemitter3 "^4.0.7"
js-sha256 "^0.9.0"
pako "^2.0.3"
snake-case "^3.0.4"
toml "^3.0.0"

"@project-serum/anchor@^0.25.0":
version "0.25.0"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.25.0.tgz#88ee4843336005cf5a64c80636ce626f0996f503"
Expand Down Expand Up @@ -160,6 +140,29 @@
superstruct "^0.14.2"
tweetnacl "^1.0.0"

"@solana/web3.js@^1.53.0":
version "1.53.0"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.53.0.tgz#24a6341e4026fc2b993656141361c54bec917c07"
integrity sha512-QyQDA9U5b+AiTo1ANsj9WihWWECeLv6VRpiTE7xPe5hLYANXZYecnlLglNiEzVgRg/jLvR5DrCISXhHx/mAEJw==
dependencies:
"@babel/runtime" "^7.12.5"
"@ethersproject/sha2" "^5.5.0"
"@solana/buffer-layout" "^4.0.0"
bigint-buffer "^1.1.5"
bn.js "^5.0.0"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.1"
fast-stable-stringify "^1.0.0"
jayson "^3.4.4"
js-sha3 "^0.8.0"
node-fetch "2"
react-native-url-polyfill "^1.3.0"
rpc-websockets "^7.5.0"
secp256k1 "^4.0.2"
superstruct "^0.14.2"
tweetnacl "^1.0.3"

"@types/bn.js@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68"
Expand Down Expand Up @@ -443,6 +446,14 @@ buffer@6.0.1:
base64-js "^1.3.1"
ieee754 "^1.2.1"

buffer@^5.4.3:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.1.13"

buffer@~6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
Expand Down Expand Up @@ -807,7 +818,7 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

ieee754@^1.2.1:
ieee754@^1.1.13, ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
Expand Down Expand Up @@ -1205,6 +1216,11 @@ pretty-format@^28.1.1:
ansi-styles "^5.0.0"
react-is "^18.0.0"

punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
Expand All @@ -1217,6 +1233,13 @@ react-is@^18.0.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==

react-native-url-polyfill@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-1.3.0.tgz#c1763de0f2a8c22cc3e959b654c8790622b6ef6a"
integrity sha512-w9JfSkvpqqlix9UjDvJjm1EjSt652zVQ6iwCIj1cVVkwXf4jQhQgTNXY6EVTwuAmUjg6BC6k9RHCBynoLFo3IQ==
dependencies:
whatwg-url-without-unicode "8.0.0-3"

readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
Expand All @@ -1234,7 +1257,7 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==

rpc-websockets@^7.4.2:
rpc-websockets@^7.4.2, rpc-websockets@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-7.5.0.tgz#bbeb87572e66703ff151e50af1658f98098e2748"
integrity sha512-9tIRi1uZGy7YmDjErf1Ax3wtqdSSLIlnmL5OtOzgd5eqPKbsPpwDP5whUDO2LQay3Xp0CcHlcNSGzacNRluBaQ==
Expand Down Expand Up @@ -1423,7 +1446,7 @@ tslib@^2.0.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

tweetnacl@^1.0.0:
tweetnacl@^1.0.0, tweetnacl@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596"
integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==
Expand Down Expand Up @@ -1455,6 +1478,20 @@ webidl-conversions@^3.0.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

webidl-conversions@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==

whatwg-url-without-unicode@8.0.0-3:
version "8.0.0-3"
resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b"
integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==
dependencies:
buffer "^5.4.3"
punycode "^2.1.1"
webidl-conversions "^5.0.0"

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
Expand Down

0 comments on commit b571171

Please sign in to comment.