@helium/distributor-oracle 0.2.21 → 0.2.22-next.33
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/package.json +16 -15
- package/lib/cjs/client.js +0 -350
- package/lib/cjs/client.js.map +0 -1
- package/lib/cjs/index.js +0 -18
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/model.js +0 -101
- package/lib/cjs/model.js.map +0 -1
- package/lib/cjs/server.js +0 -413
- package/lib/cjs/server.js.map +0 -1
- package/lib/esm/src/client.js +0 -320
- package/lib/esm/src/client.js.map +0 -1
- package/lib/esm/src/index.js +0 -2
- package/lib/esm/src/index.js.map +0 -1
- package/lib/esm/src/model.js +0 -62
- package/lib/esm/src/model.js.map +0 -1
- package/lib/esm/src/server.js +0 -382
- package/lib/esm/src/server.js.map +0 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +0 -1
- package/lib/types/src/client.d.ts +0 -48
- package/lib/types/src/client.d.ts.map +0 -1
- package/lib/types/src/index.d.ts +0 -2
- package/lib/types/src/index.d.ts.map +0 -1
- package/lib/types/src/model.d.ts +0 -7
- package/lib/types/src/model.d.ts.map +0 -1
- package/lib/types/src/server.d.ts +0 -45
- package/lib/types/src/server.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
-
"version": "0.2.
|
|
8
|
+
"version": "0.2.22-next.33+2a1e1998",
|
|
9
9
|
"description": "Oracle server for the lazy distributor",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -36,39 +36,40 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@coral-xyz/anchor": "^0.26.0",
|
|
38
38
|
"@fastify/cors": "^8.1.1",
|
|
39
|
-
"@helium/account-fetch-cache": "^0.2.
|
|
39
|
+
"@helium/account-fetch-cache": "^0.2.22-next.33+2a1e1998",
|
|
40
40
|
"@helium/address": "^4.10.2",
|
|
41
|
-
"@helium/helium-entity-manager-sdk": "^0.2.
|
|
42
|
-
"@helium/helium-sub-daos-sdk": "^0.2.
|
|
43
|
-
"@helium/idls": "^0.2.
|
|
44
|
-
"@helium/lazy-distributor-sdk": "^0.2.
|
|
45
|
-
"@helium/rewards-oracle-sdk": "^0.2.
|
|
46
|
-
"@helium/spl-utils": "^0.2.
|
|
41
|
+
"@helium/helium-entity-manager-sdk": "^0.2.22-next.33+2a1e1998",
|
|
42
|
+
"@helium/helium-sub-daos-sdk": "^0.2.22-next.33+2a1e1998",
|
|
43
|
+
"@helium/idls": "^0.2.22-next.33+2a1e1998",
|
|
44
|
+
"@helium/lazy-distributor-sdk": "^0.2.22-next.33+2a1e1998",
|
|
45
|
+
"@helium/rewards-oracle-sdk": "^0.2.22-next.33+2a1e1998",
|
|
46
|
+
"@helium/spl-utils": "^0.2.22-next.33+2a1e1998",
|
|
47
47
|
"@metaplex-foundation/mpl-bubblegum": "^0.7.0",
|
|
48
48
|
"@solana/spl-token": "^0.3.8",
|
|
49
49
|
"@types/sequelize": "^4.28.14",
|
|
50
|
-
"aws-sdk": "^2.
|
|
51
|
-
"axios": "^
|
|
50
|
+
"aws-sdk": "^2.1344.0",
|
|
51
|
+
"axios": "^1.3.6",
|
|
52
52
|
"bn.js": "^5.2.0",
|
|
53
|
-
"bs58": "^
|
|
53
|
+
"bs58": "^4.0.1",
|
|
54
54
|
"cors": "^2.8.5",
|
|
55
55
|
"dotenv": "^16.0.3",
|
|
56
|
-
"fastify": "^4.
|
|
56
|
+
"fastify": "^4.13.0",
|
|
57
57
|
"ky": "^0.31.4",
|
|
58
58
|
"pg": "^8.9.0",
|
|
59
59
|
"sequelize": "^6.28.0",
|
|
60
60
|
"typescript-collections": "^1.3.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
+
"@types/bs58": "^4.0.1",
|
|
63
64
|
"@types/cors": "^2.8.12",
|
|
64
65
|
"@types/express": "^4.17.14",
|
|
65
66
|
"@types/pg": "^8.6.6",
|
|
66
67
|
"git-format-staged": "^2.1.3",
|
|
67
68
|
"nodemon": "^2.0.20",
|
|
68
69
|
"ts-loader": "^9.2.3",
|
|
69
|
-
"ts-node": "^10.
|
|
70
|
-
"typescript": "^4.
|
|
70
|
+
"ts-node": "^10.9.1",
|
|
71
|
+
"typescript": "^4.8.4",
|
|
71
72
|
"yarn": "^1.22.18"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "2a1e19980d74c21b5f51834540421b3c8a0a045e"
|
|
74
75
|
}
|
package/lib/cjs/client.js
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.formTransaction = exports.formBulkTransactions = exports.getPendingRewards = exports.getBulkRewards = exports.getCurrentRewards = void 0;
|
|
16
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
17
|
-
const helium_entity_manager_sdk_1 = require("@helium/helium-entity-manager-sdk");
|
|
18
|
-
const helium_sub_daos_sdk_1 = require("@helium/helium-sub-daos-sdk");
|
|
19
|
-
const lazy_distributor_sdk_1 = require("@helium/lazy-distributor-sdk");
|
|
20
|
-
const rewards_oracle_sdk_1 = require("@helium/rewards-oracle-sdk");
|
|
21
|
-
const spl_utils_1 = require("@helium/spl-utils");
|
|
22
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
23
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
24
|
-
const axios_1 = __importDefault(require("axios"));
|
|
25
|
-
const HNT = process.env.HNT_MINT
|
|
26
|
-
? new web3_js_1.PublicKey(process.env.HNT_MINT)
|
|
27
|
-
: spl_utils_1.HNT_MINT;
|
|
28
|
-
const DAO = (0, helium_sub_daos_sdk_1.daoKey)(HNT)[0];
|
|
29
|
-
function getCurrentRewards(program, lazyDistributor, assetId) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const lazyDistributorAcc = yield program.account.lazyDistributorV0.fetch(lazyDistributor);
|
|
32
|
-
const results = yield Promise.all(
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
lazyDistributorAcc.oracles.map((x) => axios_1.default.get(`${x.url}?assetId=${assetId.toBase58()}`)));
|
|
35
|
-
return results.map((x, idx) => {
|
|
36
|
-
return {
|
|
37
|
-
currentRewards: x.data.currentRewards,
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
oracleKey: lazyDistributorAcc.oracles[idx].oracle,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
exports.getCurrentRewards = getCurrentRewards;
|
|
45
|
-
function getBulkRewards(program, lazyDistributor, entityKeys) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const lazyDistributorAcc = yield program.account.lazyDistributorV0.fetch(lazyDistributor);
|
|
48
|
-
const results = yield Promise.all(
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
lazyDistributorAcc.oracles.map((x) => axios_1.default.post(`${x.url}/bulk-rewards`, { entityKeys })));
|
|
51
|
-
return results.map((x, idx) => {
|
|
52
|
-
return {
|
|
53
|
-
currentRewards: x.data.currentRewards,
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
oracleKey: lazyDistributorAcc.oracles[idx].oracle,
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.getBulkRewards = getBulkRewards;
|
|
61
|
-
function getPendingRewards(program, lazyDistributor, dao, entityKeys, encoding = 'b58') {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const oracleRewards = yield getBulkRewards(program, lazyDistributor, entityKeys);
|
|
64
|
-
const hemProgram = yield (0, helium_entity_manager_sdk_1.init)(program.provider);
|
|
65
|
-
const withRecipients = yield Promise.all(entityKeys.map((entityKey) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const keyToAssetK = (0, helium_entity_manager_sdk_1.keyToAssetKey)(dao, entityKey, encoding)[0];
|
|
67
|
-
const keyToAsset = yield hemProgram.account.keyToAssetV0.fetch(keyToAssetK);
|
|
68
|
-
const recipient = (0, lazy_distributor_sdk_1.recipientKey)(lazyDistributor, keyToAsset.asset)[0];
|
|
69
|
-
const recipientAcc = yield program.account.recipientV0.fetchNullable(recipient);
|
|
70
|
-
return {
|
|
71
|
-
entityKey,
|
|
72
|
-
recipientAcc,
|
|
73
|
-
};
|
|
74
|
-
})));
|
|
75
|
-
return withRecipients.reduce((acc, { entityKey, recipientAcc }) => {
|
|
76
|
-
const sortedOracleRewards = oracleRewards
|
|
77
|
-
.map((rew) => rew.currentRewards[entityKey] || new anchor_1.BN(0))
|
|
78
|
-
.sort((a, b) => new anchor_1.BN(a).sub(new anchor_1.BN(b)).toNumber());
|
|
79
|
-
const oracleMedian = new anchor_1.BN(sortedOracleRewards[Math.floor(sortedOracleRewards.length / 2)]);
|
|
80
|
-
const subbed = oracleMedian.sub((recipientAcc === null || recipientAcc === void 0 ? void 0 : recipientAcc.totalRewards) || new anchor_1.BN(0));
|
|
81
|
-
acc[entityKey] = subbed.toString();
|
|
82
|
-
return acc;
|
|
83
|
-
}, {});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
exports.getPendingRewards = getPendingRewards;
|
|
87
|
-
function formBulkTransactions({ program: lazyDistributorProgram, rewardsOracleProgram, heliumEntityManagerProgram, rewards, assets, compressionAssetAccs, lazyDistributor, lazyDistributorAcc, wallet = lazyDistributorProgram.provider.wallet.publicKey, skipOracleSign = false, assetEndpoint, getAssetFn = spl_utils_1.getAsset, getAssetProofFn = spl_utils_1.getAssetProof, }) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
if (assets.length > 100) {
|
|
90
|
-
throw new Error('Too many assets, max 100');
|
|
91
|
-
}
|
|
92
|
-
const provider = lazyDistributorProgram.provider;
|
|
93
|
-
if (!rewardsOracleProgram) {
|
|
94
|
-
rewardsOracleProgram = yield (0, rewards_oracle_sdk_1.init)(provider);
|
|
95
|
-
}
|
|
96
|
-
if (!heliumEntityManagerProgram) {
|
|
97
|
-
heliumEntityManagerProgram = yield (0, helium_entity_manager_sdk_1.init)(provider);
|
|
98
|
-
}
|
|
99
|
-
if (!lazyDistributorAcc) {
|
|
100
|
-
lazyDistributorAcc =
|
|
101
|
-
yield lazyDistributorProgram.account.lazyDistributorV0.fetch(lazyDistributor);
|
|
102
|
-
}
|
|
103
|
-
if (!compressionAssetAccs) {
|
|
104
|
-
compressionAssetAccs = yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
const assetAcc = yield getAssetFn(assetEndpoint || provider.connection.rpcEndpoint, asset);
|
|
107
|
-
if (!assetAcc) {
|
|
108
|
-
throw new Error('No asset with ID ' + asset.toBase58());
|
|
109
|
-
}
|
|
110
|
-
return assetAcc;
|
|
111
|
-
})));
|
|
112
|
-
}
|
|
113
|
-
if (compressionAssetAccs.length != assets.length) {
|
|
114
|
-
throw new Error('Assets not the same length as compressionAssetAccs');
|
|
115
|
-
}
|
|
116
|
-
let recipientKeys = assets.map((asset) => (0, lazy_distributor_sdk_1.recipientKey)(lazyDistributor, asset)[0]);
|
|
117
|
-
let recipientAccs = yield lazyDistributorProgram.account.recipientV0.fetchMultiple(recipientKeys);
|
|
118
|
-
let ixsPerAsset = yield Promise.all(recipientAccs.map((recipientAcc, idx) => __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
if (!recipientAcc) {
|
|
120
|
-
return [
|
|
121
|
-
yield (yield (0, lazy_distributor_sdk_1.initializeCompressionRecipient)({
|
|
122
|
-
program: lazyDistributorProgram,
|
|
123
|
-
assetId: assets[idx],
|
|
124
|
-
lazyDistributor,
|
|
125
|
-
assetEndpoint,
|
|
126
|
-
owner: wallet,
|
|
127
|
-
// Make the oracle pay for the recipient to avoid newly migrated users not having enough sol to claim rewards
|
|
128
|
-
payer: lazyDistributorAcc.oracles[0].oracle,
|
|
129
|
-
getAssetFn: () => Promise.resolve(compressionAssetAccs[idx]),
|
|
130
|
-
getAssetProofFn,
|
|
131
|
-
})).instruction(),
|
|
132
|
-
];
|
|
133
|
-
}
|
|
134
|
-
return [];
|
|
135
|
-
})));
|
|
136
|
-
// construct the set and distribute ixs
|
|
137
|
-
let setAndDistributeIxs = yield Promise.all(compressionAssetAccs.map((assetAcc, idx) => __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
const keyToAssetK = (0, helium_entity_manager_sdk_1.keyToAssetForAsset)(assetAcc);
|
|
139
|
-
const keyToAsset = yield heliumEntityManagerProgram.account.keyToAssetV0.fetch(keyToAssetK);
|
|
140
|
-
const entityKey = (0, helium_entity_manager_sdk_1.decodeEntityKey)(keyToAsset.entityKey, keyToAsset.keySerialization);
|
|
141
|
-
const setRewardIxs = (yield Promise.all(rewards.map((bulkRewards, oracleIdx) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
if (!(entityKey in bulkRewards.currentRewards)) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
return yield rewardsOracleProgram.methods
|
|
146
|
-
.setCurrentRewardsWrapperV1({
|
|
147
|
-
currentRewards: new anchor_1.BN(bulkRewards.currentRewards[entityKey]),
|
|
148
|
-
oracleIndex: oracleIdx,
|
|
149
|
-
})
|
|
150
|
-
.accounts({
|
|
151
|
-
lazyDistributor,
|
|
152
|
-
recipient: recipientKeys[idx],
|
|
153
|
-
keyToAsset: keyToAssetK,
|
|
154
|
-
oracle: bulkRewards.oracleKey,
|
|
155
|
-
})
|
|
156
|
-
.instruction();
|
|
157
|
-
})))).filter(spl_utils_1.truthy);
|
|
158
|
-
if (setRewardIxs.length == 0) {
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
161
|
-
const distributeIx = yield (yield (0, lazy_distributor_sdk_1.distributeCompressionRewards)({
|
|
162
|
-
program: lazyDistributorProgram,
|
|
163
|
-
assetId: assets[idx],
|
|
164
|
-
lazyDistributor,
|
|
165
|
-
rewardsMint: lazyDistributorAcc.rewardsMint,
|
|
166
|
-
getAssetFn: () => Promise.resolve(assetAcc),
|
|
167
|
-
getAssetProofFn,
|
|
168
|
-
assetEndpoint,
|
|
169
|
-
})).instruction();
|
|
170
|
-
return [...setRewardIxs, distributeIx];
|
|
171
|
-
})));
|
|
172
|
-
for (let i = 0; i < setAndDistributeIxs.length; i++) {
|
|
173
|
-
if (setAndDistributeIxs[i].length == 0) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
ixsPerAsset[i].push(...setAndDistributeIxs[i]);
|
|
177
|
-
}
|
|
178
|
-
// filter arrays where init recipient is the only ix
|
|
179
|
-
ixsPerAsset = ixsPerAsset.filter((x) => x.length > 1);
|
|
180
|
-
let blockhash = (yield provider.connection.getLatestBlockhash()).blockhash;
|
|
181
|
-
// unsigned txs
|
|
182
|
-
let initialTxs = ixsPerAsset.map((ixs) => {
|
|
183
|
-
const tx = new web3_js_1.Transaction();
|
|
184
|
-
tx.recentBlockhash = blockhash;
|
|
185
|
-
tx.feePayer = wallet;
|
|
186
|
-
tx.add(...ixs);
|
|
187
|
-
return tx;
|
|
188
|
-
});
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
const oracleUrls = lazyDistributorAcc.oracles.map((x) => x.url);
|
|
191
|
-
let serTxs = initialTxs.map((tx) => {
|
|
192
|
-
return tx.serialize({
|
|
193
|
-
requireAllSignatures: false,
|
|
194
|
-
verifySignatures: false,
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
if (!skipOracleSign) {
|
|
198
|
-
for (const oracle of oracleUrls) {
|
|
199
|
-
const res = yield axios_1.default.post(`${oracle}/bulk-sign`, {
|
|
200
|
-
transactions: serTxs.map((tx) => tx.toJSON().data),
|
|
201
|
-
});
|
|
202
|
-
serTxs = res.data.transactions.map((x) => Buffer.from(x));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
const finalTxs = serTxs.map((tx) => web3_js_1.Transaction.from(tx));
|
|
206
|
-
// Check instructions are the same
|
|
207
|
-
finalTxs.forEach((finalTx, idx) => {
|
|
208
|
-
assertSameIxns(finalTx.instructions, initialTxs[idx].instructions);
|
|
209
|
-
});
|
|
210
|
-
return finalTxs;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
exports.formBulkTransactions = formBulkTransactions;
|
|
214
|
-
function formTransaction({ program: lazyDistributorProgram, rewardsOracleProgram, provider, rewards, asset, hotspot, lazyDistributor, wallet = provider.wallet.publicKey, skipOracleSign = false, assetEndpoint, getAssetFn = spl_utils_1.getAsset, getAssetProofFn = spl_utils_1.getAssetProof, }) {
|
|
215
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
if (!asset && !hotspot) {
|
|
217
|
-
throw new Error('Must provide asset or hotspot');
|
|
218
|
-
}
|
|
219
|
-
if (!asset) {
|
|
220
|
-
asset = hotspot;
|
|
221
|
-
}
|
|
222
|
-
if (!rewardsOracleProgram) {
|
|
223
|
-
rewardsOracleProgram = yield (0, rewards_oracle_sdk_1.init)(lazyDistributorProgram.provider);
|
|
224
|
-
}
|
|
225
|
-
const assetAcc = yield getAssetFn(assetEndpoint || provider.connection.rpcEndpoint, asset);
|
|
226
|
-
if (!assetAcc) {
|
|
227
|
-
throw new Error('No asset with ID ' + asset.toBase58());
|
|
228
|
-
}
|
|
229
|
-
const keyToAsset = (0, helium_entity_manager_sdk_1.keyToAssetForAsset)(assetAcc);
|
|
230
|
-
const recipient = (0, lazy_distributor_sdk_1.recipientKey)(lazyDistributor, asset)[0];
|
|
231
|
-
const lazyDistributorAcc = (yield lazyDistributorProgram.account.lazyDistributorV0.fetch(lazyDistributor));
|
|
232
|
-
const rewardsMint = lazyDistributorAcc.rewardsMint;
|
|
233
|
-
let tx = new web3_js_1.Transaction();
|
|
234
|
-
const destinationAccount = yield (0, spl_token_1.getAssociatedTokenAddress)(rewardsMint, assetAcc.ownership.owner, true);
|
|
235
|
-
if (!(yield provider.connection.getAccountInfo(recipient))) {
|
|
236
|
-
let initRecipientIx;
|
|
237
|
-
if (assetAcc.compression.compressed) {
|
|
238
|
-
initRecipientIx = yield (yield (0, lazy_distributor_sdk_1.initializeCompressionRecipient)({
|
|
239
|
-
program: lazyDistributorProgram,
|
|
240
|
-
assetId: asset,
|
|
241
|
-
lazyDistributor,
|
|
242
|
-
assetEndpoint,
|
|
243
|
-
owner: wallet,
|
|
244
|
-
// Make the oracle pay for the recipient to avoid newly migrated users not having enough sol to claim rewards
|
|
245
|
-
payer: lazyDistributorAcc.oracles[0].oracle,
|
|
246
|
-
getAssetFn: () => Promise.resolve(assetAcc),
|
|
247
|
-
getAssetProofFn,
|
|
248
|
-
})).instruction();
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
initRecipientIx = yield lazyDistributorProgram.methods
|
|
252
|
-
.initializeRecipientV0()
|
|
253
|
-
.accounts({
|
|
254
|
-
lazyDistributor,
|
|
255
|
-
mint: asset,
|
|
256
|
-
})
|
|
257
|
-
.instruction();
|
|
258
|
-
}
|
|
259
|
-
tx.add(initRecipientIx);
|
|
260
|
-
}
|
|
261
|
-
const ixPromises = rewards.map((x, idx) => {
|
|
262
|
-
return rewardsOracleProgram.methods
|
|
263
|
-
.setCurrentRewardsWrapperV1({
|
|
264
|
-
currentRewards: new anchor_1.BN(x.currentRewards),
|
|
265
|
-
oracleIndex: idx,
|
|
266
|
-
})
|
|
267
|
-
.accounts({
|
|
268
|
-
lazyDistributor,
|
|
269
|
-
recipient,
|
|
270
|
-
keyToAsset,
|
|
271
|
-
oracle: x.oracleKey,
|
|
272
|
-
})
|
|
273
|
-
.instruction();
|
|
274
|
-
});
|
|
275
|
-
const ixs = yield Promise.all(ixPromises);
|
|
276
|
-
tx.add(...ixs);
|
|
277
|
-
tx.recentBlockhash = (yield provider.connection.getLatestBlockhash()).blockhash;
|
|
278
|
-
tx.feePayer = wallet ? wallet : provider.wallet.publicKey;
|
|
279
|
-
if (assetAcc.compression.compressed) {
|
|
280
|
-
const distributeIx = yield (yield (0, lazy_distributor_sdk_1.distributeCompressionRewards)({
|
|
281
|
-
program: lazyDistributorProgram,
|
|
282
|
-
assetId: asset,
|
|
283
|
-
lazyDistributor,
|
|
284
|
-
getAssetFn: () => Promise.resolve(assetAcc),
|
|
285
|
-
getAssetProofFn,
|
|
286
|
-
assetEndpoint,
|
|
287
|
-
})).instruction();
|
|
288
|
-
tx.add(distributeIx);
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
const distributeIx = yield lazyDistributorProgram.methods
|
|
292
|
-
.distributeRewardsV0()
|
|
293
|
-
.accounts({
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
common: {
|
|
296
|
-
recipient,
|
|
297
|
-
lazyDistributor,
|
|
298
|
-
rewardsMint,
|
|
299
|
-
owner: assetAcc.ownership.owner,
|
|
300
|
-
destinationAccount,
|
|
301
|
-
},
|
|
302
|
-
})
|
|
303
|
-
.instruction();
|
|
304
|
-
tx.add(distributeIx);
|
|
305
|
-
}
|
|
306
|
-
// @ts-ignore
|
|
307
|
-
const oracleUrls = lazyDistributorAcc.oracles.map((x) => x.url);
|
|
308
|
-
let serTx = tx.serialize({
|
|
309
|
-
requireAllSignatures: false,
|
|
310
|
-
verifySignatures: false,
|
|
311
|
-
});
|
|
312
|
-
if (!skipOracleSign) {
|
|
313
|
-
for (const oracle of oracleUrls) {
|
|
314
|
-
const res = yield axios_1.default.post(`${oracle}`, {
|
|
315
|
-
transaction: serTx,
|
|
316
|
-
});
|
|
317
|
-
serTx = Buffer.from(res.data.transaction);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
const finalTx = web3_js_1.Transaction.from(serTx);
|
|
321
|
-
// Ensure the oracle didn't pull a fast one
|
|
322
|
-
assertSameIxns(finalTx.instructions, tx.instructions);
|
|
323
|
-
return finalTx;
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
exports.formTransaction = formTransaction;
|
|
327
|
-
function assertSameIxns(instructions, instructions1) {
|
|
328
|
-
if (instructions.length !== instructions1.length) {
|
|
329
|
-
throw new Error('Extra instructions added by oracle');
|
|
330
|
-
}
|
|
331
|
-
instructions.forEach((instruction, idx) => {
|
|
332
|
-
const instruction1 = instructions1[idx];
|
|
333
|
-
if (instruction.programId.toBase58() !== instruction1.programId.toBase58()) {
|
|
334
|
-
throw new Error('Program id mismatch');
|
|
335
|
-
}
|
|
336
|
-
if (!instruction.data.equals(instruction1.data)) {
|
|
337
|
-
throw new Error('Instruction data mismatch');
|
|
338
|
-
}
|
|
339
|
-
if (instruction.keys.length !== instruction1.keys.length) {
|
|
340
|
-
throw new Error('Key length mismatch');
|
|
341
|
-
}
|
|
342
|
-
instruction.keys.forEach((key, idx) => {
|
|
343
|
-
const key1 = instruction1.keys[idx];
|
|
344
|
-
if (key.pubkey.toBase58() !== key1.pubkey.toBase58()) {
|
|
345
|
-
throw new Error('Key mismatch');
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
//# sourceMappingURL=client.js.map
|
package/lib/cjs/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Binding) || (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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./client"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
package/lib/cjs/model.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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.Reward = exports.sequelize = void 0;
|
|
39
|
-
const sequelize_1 = require("sequelize");
|
|
40
|
-
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
41
|
-
const pg = __importStar(require("pg"));
|
|
42
|
-
const host = process.env.PGHOST || "localhost";
|
|
43
|
-
const port = Number(process.env.PGPORT) || 5432;
|
|
44
|
-
exports.sequelize = new sequelize_1.Sequelize({
|
|
45
|
-
host: host,
|
|
46
|
-
dialect: "postgres",
|
|
47
|
-
port: port,
|
|
48
|
-
logging: false,
|
|
49
|
-
dialectModule: pg,
|
|
50
|
-
username: process.env.PGUSER,
|
|
51
|
-
database: process.env.PGDATABASE,
|
|
52
|
-
pool: {
|
|
53
|
-
max: 5,
|
|
54
|
-
min: 0,
|
|
55
|
-
acquire: 30000,
|
|
56
|
-
idle: 10000
|
|
57
|
-
},
|
|
58
|
-
hooks: {
|
|
59
|
-
beforeConnect: (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
const isRds = host.includes("rds.amazonaws.com");
|
|
61
|
-
let password = process.env.PGPASSWORD;
|
|
62
|
-
if (isRds && !password) {
|
|
63
|
-
const signer = new aws_sdk_1.default.RDS.Signer({
|
|
64
|
-
region: process.env.AWS_REGION,
|
|
65
|
-
hostname: process.env.PGHOST,
|
|
66
|
-
port,
|
|
67
|
-
username: process.env.PGUSER,
|
|
68
|
-
});
|
|
69
|
-
password = yield new Promise((resolve, reject) => signer.getAuthToken({}, (err, token) => {
|
|
70
|
-
if (err) {
|
|
71
|
-
return reject(err);
|
|
72
|
-
}
|
|
73
|
-
resolve(token);
|
|
74
|
-
}));
|
|
75
|
-
config.dialectOptions = {
|
|
76
|
-
ssl: {
|
|
77
|
-
require: false,
|
|
78
|
-
rejectUnauthorized: false,
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
config.password = password;
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
class Reward extends sequelize_1.Model {
|
|
87
|
-
}
|
|
88
|
-
exports.Reward = Reward;
|
|
89
|
-
Reward.init({
|
|
90
|
-
address: {
|
|
91
|
-
type: sequelize_1.STRING,
|
|
92
|
-
primaryKey: true,
|
|
93
|
-
},
|
|
94
|
-
rewards: {
|
|
95
|
-
type: sequelize_1.BIGINT,
|
|
96
|
-
},
|
|
97
|
-
lastReward: {
|
|
98
|
-
type: 'TIMESTAMP',
|
|
99
|
-
},
|
|
100
|
-
}, { sequelize: exports.sequelize, modelName: "reward_index", tableName: "reward_index", underscored: true, timestamps: false });
|
|
101
|
-
//# sourceMappingURL=model.js.map
|
package/lib/cjs/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAmE;AACnE,sDAA0B;AAC1B,uCAAyB;AAEzB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,WAAW,CAAC;AAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;AACnC,QAAA,SAAS,GAAG,IAAI,qBAAS,CAAC;IACrC,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;IAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;IAChC,IAAI,EAAE;QACJ,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;KACZ;IACD,KAAK,EAAE;QACL,aAAa,EAAE,CAAO,MAAW,EAAE,EAAE;YACnC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;YAEjD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;YACtC,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE;gBACtB,MAAM,MAAM,GAAG,IAAI,iBAAG,CAAC,GAAG,CAAC,MAAM,CAAC;oBAChC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;oBAC9B,QAAQ,EAAE,OAAO,CAAC,G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