@render-foundation/utils 0.0.20 → 0.0.21
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/lib/cjs/index.js +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/squads.js +162 -0
- package/lib/cjs/squads.js.map +1 -0
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +1 -1
- package/lib/esm/src/squads.js +122 -0
- package/lib/esm/src/squads.js.map +1 -0
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/index.d.ts +1 -1
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/squads.d.ts +12 -0
- package/lib/types/src/squads.d.ts.map +1 -0
- package/package.json +2 -1
- package/CHANGELOG.md +0 -310
- package/lib/cjs/squadsV3.js +0 -63
- package/lib/cjs/squadsV3.js.map +0 -1
- package/lib/esm/src/squadsV3.js +0 -47
- package/lib/esm/src/squadsV3.js.map +0 -1
- package/lib/types/src/squadsV3.d.ts +0 -8
- package/lib/types/src/squadsV3.d.ts.map +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./wormhole"), exports);
|
|
18
18
|
__exportStar(require("./pgClient"), exports);
|
|
19
19
|
__exportStar(require("./renderClient"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./squads"), exports);
|
|
21
21
|
__exportStar(require("./logger"), exports);
|
|
22
22
|
__exportStar(require("./errorReporter"), exports);
|
|
23
23
|
__exportStar(require("./priceClient"), exports);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,6CAA2B;AAC3B,iDAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,6CAA2B;AAC3B,iDAA+B;AAC/B,2CAAyB;AACzB,2CAAwB;AACxB,kDAAgC;AAChC,gDAA8B"}
|
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.executeSqV3Transaction = exports.executeSqV4Transaction = void 0;
|
|
39
|
+
const sdk_1 = require("@sqds/sdk");
|
|
40
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
41
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
42
|
+
const spl_utils_1 = require("@render-foundation/spl-utils");
|
|
43
|
+
const logger_1 = require("./logger");
|
|
44
|
+
const multisig_1 = require("@render-foundation/multisig");
|
|
45
|
+
//import {hel} from "@render-foundation/spl-utils/lib/types"
|
|
46
|
+
const multisig = __importStar(require("@render-foundation/multisig"));
|
|
47
|
+
const multisig_2 = require("@render-foundation/multisig");
|
|
48
|
+
const executeSqV4Transaction = (connection, multisigPda, approvers, instrs, log = logger_1.consoleLogger) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
let multisigAccount = yield multisig_1.generated.Multisig.fromAccountAddress(connection, multisigPda);
|
|
50
|
+
let vaultPda = multisig.getVaultPda({
|
|
51
|
+
multisigPda,
|
|
52
|
+
index: 0,
|
|
53
|
+
programId: multisig_2.PROGRAM_ID,
|
|
54
|
+
})[0];
|
|
55
|
+
const transactionIndex = multisig.utils.toBigInt(multisigAccount.transactionIndex) + BigInt(1);
|
|
56
|
+
const txPDA = multisig.getTransactionPda({
|
|
57
|
+
multisigPda,
|
|
58
|
+
index: transactionIndex
|
|
59
|
+
})[0];
|
|
60
|
+
const txMessage = new web3_js_1.TransactionMessage({
|
|
61
|
+
payerKey: vaultPda,
|
|
62
|
+
recentBlockhash: (yield connection.getLatestBlockhash()).blockhash,
|
|
63
|
+
instructions: instrs
|
|
64
|
+
});
|
|
65
|
+
const createIx = yield multisig.instructions.vaultTransactionCreate({
|
|
66
|
+
multisigPda,
|
|
67
|
+
transactionIndex,
|
|
68
|
+
creator: approvers[0].publicKey,
|
|
69
|
+
vaultIndex: 0,
|
|
70
|
+
ephemeralSigners: 0,
|
|
71
|
+
transactionMessage: txMessage,
|
|
72
|
+
memo: `execute ${txPDA}`,
|
|
73
|
+
programId: multisig_2.PROGRAM_ID,
|
|
74
|
+
});
|
|
75
|
+
// Create Proposal account.
|
|
76
|
+
const createPropIx = yield multisig.instructions.proposalCreate({
|
|
77
|
+
multisigPda,
|
|
78
|
+
transactionIndex,
|
|
79
|
+
creator: approvers[0].publicKey,
|
|
80
|
+
programId: multisig.PROGRAM_ID,
|
|
81
|
+
});
|
|
82
|
+
//await connection.confirmTransaction(signature);
|
|
83
|
+
const createTx = new web3_js_1.Transaction().add(createIx, createPropIx);
|
|
84
|
+
for (const approver of approvers) {
|
|
85
|
+
createTx.add(yield multisig.instructions.proposalApprove({
|
|
86
|
+
multisigPda,
|
|
87
|
+
transactionIndex,
|
|
88
|
+
member: approver.publicKey,
|
|
89
|
+
memo: `${approver.publicKey} approve`,
|
|
90
|
+
programId: multisig.PROGRAM_ID,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
createTx.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
|
|
94
|
+
createTx.feePayer = approvers[0].publicKey;
|
|
95
|
+
createTx.sign(...approvers);
|
|
96
|
+
yield (0, spl_utils_1.sendAndConfirmWithRetry)(connection, createTx.serialize(), {
|
|
97
|
+
skipPreflight: true,
|
|
98
|
+
maxRetries: 10,
|
|
99
|
+
}, 'finalized');
|
|
100
|
+
log.info(`created tx ${txPDA}`);
|
|
101
|
+
log.info(`executing tx ${txPDA}`);
|
|
102
|
+
const execTx = yield multisig.transactions.vaultTransactionExecute({
|
|
103
|
+
connection: connection,
|
|
104
|
+
feePayer: approvers[0].publicKey,
|
|
105
|
+
blockhash: (yield connection.getLatestBlockhash()).blockhash,
|
|
106
|
+
multisigPda,
|
|
107
|
+
transactionIndex,
|
|
108
|
+
member: approvers[0].publicKey,
|
|
109
|
+
programId: multisig_2.PROGRAM_ID
|
|
110
|
+
});
|
|
111
|
+
execTx.sign([approvers[0]]);
|
|
112
|
+
const { txid } = yield (0, spl_utils_1.sendAndConfirmWithRetry)(connection, Buffer.from(execTx.serialize()), {
|
|
113
|
+
skipPreflight: true,
|
|
114
|
+
maxRetries: 10,
|
|
115
|
+
}, 'finalized');
|
|
116
|
+
log.info(`executing tx ${txPDA}`);
|
|
117
|
+
return { txSig: txid, txPDA };
|
|
118
|
+
});
|
|
119
|
+
exports.executeSqV4Transaction = executeSqV4Transaction;
|
|
120
|
+
const executeSqV3Transaction = (connection, squadsMsKey, clients, instrs, log = logger_1.consoleLogger) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
const msAuthorityK = (0, sdk_1.getAuthorityPDA)(squadsMsKey, new bn_js_1.default(1), sdk_1.DEFAULT_MULTISIG_PROGRAM_ID)[0];
|
|
122
|
+
let txPDA;
|
|
123
|
+
const primClient = clients[0];
|
|
124
|
+
const txIdx = yield primClient.getNextTransactionIndex(squadsMsKey);
|
|
125
|
+
txPDA = (0, sdk_1.getTxPDA)(squadsMsKey, new bn_js_1.default(txIdx), sdk_1.DEFAULT_MULTISIG_PROGRAM_ID)[0];
|
|
126
|
+
let createTx = new web3_js_1.Transaction()
|
|
127
|
+
.add(yield primClient.buildCreateTransaction(squadsMsKey, 1, txIdx));
|
|
128
|
+
let instrIdx = 1;
|
|
129
|
+
for (const i of instrs) {
|
|
130
|
+
createTx.add(yield primClient.buildAddInstruction(squadsMsKey, txPDA, i, instrIdx));
|
|
131
|
+
instrIdx += 1;
|
|
132
|
+
}
|
|
133
|
+
createTx.add(yield primClient.buildActivateTransaction(squadsMsKey, txPDA));
|
|
134
|
+
for (const c of clients) {
|
|
135
|
+
createTx.add(yield c.buildApproveTransaction(squadsMsKey, txPDA));
|
|
136
|
+
}
|
|
137
|
+
createTx.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
|
|
138
|
+
createTx.feePayer = primClient.wallet.publicKey;
|
|
139
|
+
for (const c of clients) {
|
|
140
|
+
createTx = yield c.wallet.signTransaction(createTx);
|
|
141
|
+
}
|
|
142
|
+
//createTx.sign(sharedMsKp, authorityKp)
|
|
143
|
+
yield (0, spl_utils_1.sendAndConfirmWithRetry)(connection, createTx.serialize(), {
|
|
144
|
+
skipPreflight: true,
|
|
145
|
+
maxRetries: 10,
|
|
146
|
+
}, 'finalized');
|
|
147
|
+
log.info(`created tx ${txPDA}`);
|
|
148
|
+
log.info(`executing tx ${txPDA}`);
|
|
149
|
+
let execTx = new web3_js_1.Transaction().add(yield primClient.buildExecuteTransaction(txPDA, primClient.wallet.publicKey));
|
|
150
|
+
execTx.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
|
|
151
|
+
execTx.feePayer = primClient.wallet.publicKey;
|
|
152
|
+
execTx = yield primClient.wallet.signTransaction(execTx);
|
|
153
|
+
//execTx.sign(args.solFeePayerKp)
|
|
154
|
+
const { txid } = yield (0, spl_utils_1.sendAndConfirmWithRetry)(connection, execTx.serialize(), {
|
|
155
|
+
skipPreflight: true,
|
|
156
|
+
maxRetries: 10,
|
|
157
|
+
}, 'confirmed');
|
|
158
|
+
log.info(`executed ${txid}`);
|
|
159
|
+
return { txSig: txid, txPDA };
|
|
160
|
+
});
|
|
161
|
+
exports.executeSqV3Transaction = executeSqV3Transaction;
|
|
162
|
+
//# sourceMappingURL=squads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squads.js","sourceRoot":"","sources":["../../src/squads.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAyF;AACzF,k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qBAAW,EAAE,CAAC,GAAG,CAAC,MAAM,UAAU,CAAC,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IAChH,MAAM,CAAC,eAAe,GAAG,CAAC,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAA;IAC1E,MAAM,CAAC,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAA;IAC7C,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;IACxD,iCAAiC;IACjC,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAA,mCAAuB,EAC1C,UAAU,EACV,MAAM,CAAC,SAAS,EAAE,EAClB;QACE,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,EAAE;KACf,EACD,WAAW,CACZ,CAAA;IACD,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAA;IAC5B,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC,CAAA;AAC7B,CAAC,CAAA,CAAA;AA3DY,QAAA,sBAAsB,0BA2DlC"}
|
package/lib/esm/src/index.js
CHANGED
package/lib/esm/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DEFAULT_MULTISIG_PROGRAM_ID, getAuthorityPDA, getTxPDA } from "@sqds/sdk";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
import { Transaction, TransactionMessage } from "@solana/web3.js";
|
|
4
|
+
import { sendAndConfirmWithRetry } from "@render-foundation/spl-utils";
|
|
5
|
+
import { consoleLogger } from "./logger";
|
|
6
|
+
import { generated } from "@render-foundation/multisig";
|
|
7
|
+
//import {hel} from "@render-foundation/spl-utils/lib/types"
|
|
8
|
+
import * as multisig from "@render-foundation/multisig";
|
|
9
|
+
import { PROGRAM_ID } from "@render-foundation/multisig";
|
|
10
|
+
export const executeSqV4Transaction = async (connection, multisigPda, approvers, instrs, log = consoleLogger) => {
|
|
11
|
+
let multisigAccount = await generated.Multisig.fromAccountAddress(connection, multisigPda);
|
|
12
|
+
let vaultPda = multisig.getVaultPda({
|
|
13
|
+
multisigPda,
|
|
14
|
+
index: 0,
|
|
15
|
+
programId: PROGRAM_ID,
|
|
16
|
+
})[0];
|
|
17
|
+
const transactionIndex = multisig.utils.toBigInt(multisigAccount.transactionIndex) + BigInt(1);
|
|
18
|
+
const txPDA = multisig.getTransactionPda({
|
|
19
|
+
multisigPda,
|
|
20
|
+
index: transactionIndex
|
|
21
|
+
})[0];
|
|
22
|
+
const txMessage = new TransactionMessage({
|
|
23
|
+
payerKey: vaultPda,
|
|
24
|
+
recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
|
|
25
|
+
instructions: instrs
|
|
26
|
+
});
|
|
27
|
+
const createIx = await multisig.instructions.vaultTransactionCreate({
|
|
28
|
+
multisigPda,
|
|
29
|
+
transactionIndex,
|
|
30
|
+
creator: approvers[0].publicKey,
|
|
31
|
+
vaultIndex: 0,
|
|
32
|
+
ephemeralSigners: 0,
|
|
33
|
+
transactionMessage: txMessage,
|
|
34
|
+
memo: `execute ${txPDA}`,
|
|
35
|
+
programId: PROGRAM_ID,
|
|
36
|
+
});
|
|
37
|
+
// Create Proposal account.
|
|
38
|
+
const createPropIx = await multisig.instructions.proposalCreate({
|
|
39
|
+
multisigPda,
|
|
40
|
+
transactionIndex,
|
|
41
|
+
creator: approvers[0].publicKey,
|
|
42
|
+
programId: multisig.PROGRAM_ID,
|
|
43
|
+
});
|
|
44
|
+
//await connection.confirmTransaction(signature);
|
|
45
|
+
const createTx = new Transaction().add(createIx, createPropIx);
|
|
46
|
+
for (const approver of approvers) {
|
|
47
|
+
createTx.add(await multisig.instructions.proposalApprove({
|
|
48
|
+
multisigPda,
|
|
49
|
+
transactionIndex,
|
|
50
|
+
member: approver.publicKey,
|
|
51
|
+
memo: `${approver.publicKey} approve`,
|
|
52
|
+
programId: multisig.PROGRAM_ID,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
createTx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
56
|
+
createTx.feePayer = approvers[0].publicKey;
|
|
57
|
+
createTx.sign(...approvers);
|
|
58
|
+
await sendAndConfirmWithRetry(connection, createTx.serialize(), {
|
|
59
|
+
skipPreflight: true,
|
|
60
|
+
maxRetries: 10,
|
|
61
|
+
}, 'finalized');
|
|
62
|
+
log.info(`created tx ${txPDA}`);
|
|
63
|
+
log.info(`executing tx ${txPDA}`);
|
|
64
|
+
const execTx = await multisig.transactions.vaultTransactionExecute({
|
|
65
|
+
connection: connection,
|
|
66
|
+
feePayer: approvers[0].publicKey,
|
|
67
|
+
blockhash: (await connection.getLatestBlockhash()).blockhash,
|
|
68
|
+
multisigPda,
|
|
69
|
+
transactionIndex,
|
|
70
|
+
member: approvers[0].publicKey,
|
|
71
|
+
programId: PROGRAM_ID
|
|
72
|
+
});
|
|
73
|
+
execTx.sign([approvers[0]]);
|
|
74
|
+
const { txid } = await sendAndConfirmWithRetry(connection, Buffer.from(execTx.serialize()), {
|
|
75
|
+
skipPreflight: true,
|
|
76
|
+
maxRetries: 10,
|
|
77
|
+
}, 'finalized');
|
|
78
|
+
log.info(`executing tx ${txPDA}`);
|
|
79
|
+
return { txSig: txid, txPDA };
|
|
80
|
+
};
|
|
81
|
+
export const executeSqV3Transaction = async (connection, squadsMsKey, clients, instrs, log = consoleLogger) => {
|
|
82
|
+
const msAuthorityK = getAuthorityPDA(squadsMsKey, new BN(1), DEFAULT_MULTISIG_PROGRAM_ID)[0];
|
|
83
|
+
let txPDA;
|
|
84
|
+
const primClient = clients[0];
|
|
85
|
+
const txIdx = await primClient.getNextTransactionIndex(squadsMsKey);
|
|
86
|
+
txPDA = getTxPDA(squadsMsKey, new BN(txIdx), DEFAULT_MULTISIG_PROGRAM_ID)[0];
|
|
87
|
+
let createTx = new Transaction()
|
|
88
|
+
.add(await primClient.buildCreateTransaction(squadsMsKey, 1, txIdx));
|
|
89
|
+
let instrIdx = 1;
|
|
90
|
+
for (const i of instrs) {
|
|
91
|
+
createTx.add(await primClient.buildAddInstruction(squadsMsKey, txPDA, i, instrIdx));
|
|
92
|
+
instrIdx += 1;
|
|
93
|
+
}
|
|
94
|
+
createTx.add(await primClient.buildActivateTransaction(squadsMsKey, txPDA));
|
|
95
|
+
for (const c of clients) {
|
|
96
|
+
createTx.add(await c.buildApproveTransaction(squadsMsKey, txPDA));
|
|
97
|
+
}
|
|
98
|
+
createTx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
99
|
+
createTx.feePayer = primClient.wallet.publicKey;
|
|
100
|
+
for (const c of clients) {
|
|
101
|
+
createTx = await c.wallet.signTransaction(createTx);
|
|
102
|
+
}
|
|
103
|
+
//createTx.sign(sharedMsKp, authorityKp)
|
|
104
|
+
await sendAndConfirmWithRetry(connection, createTx.serialize(), {
|
|
105
|
+
skipPreflight: true,
|
|
106
|
+
maxRetries: 10,
|
|
107
|
+
}, 'finalized');
|
|
108
|
+
log.info(`created tx ${txPDA}`);
|
|
109
|
+
log.info(`executing tx ${txPDA}`);
|
|
110
|
+
let execTx = new Transaction().add(await primClient.buildExecuteTransaction(txPDA, primClient.wallet.publicKey));
|
|
111
|
+
execTx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
112
|
+
execTx.feePayer = primClient.wallet.publicKey;
|
|
113
|
+
execTx = await primClient.wallet.signTransaction(execTx);
|
|
114
|
+
//execTx.sign(args.solFeePayerKp)
|
|
115
|
+
const { txid } = await sendAndConfirmWithRetry(connection, execTx.serialize(), {
|
|
116
|
+
skipPreflight: true,
|
|
117
|
+
maxRetries: 10,
|
|
118
|
+
}, 'confirmed');
|
|
119
|
+
log.info(`executed ${txid}`);
|
|
120
|
+
return { txSig: txid, txPDA };
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=squads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squads.js","sourceRoot":"","sources":["../../../src/squads.ts"],"names":[],"mappings":"AAAA,OAAe,EAAC,2BAA2B,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AACzF,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,OAAO,EAAgC,WAAW,EAA0B,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,aAAa,EAAe,MAAM,UAAU,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,6BAA6B,CAAC;AACtD,4DAA4D;AAC5D,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,UAAsB,EACtB,WAAsB,EACtB,SAAmB,EACnB,MAAgC,EAChC,MAAoB,aAAa,EACW,EAAE;IAE9C,IAAI,eAAe,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAC/D,UAAU,EACV,WAAW,CACZ,CAAC;IAEF,IAAI,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC;QAClC,WAAW;QACX,KAAK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