@ercworldio/blockchain-shared 1.0.1-dev.9 → 1.0.2-dev.1
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 +26 -0
- package/build/chains/networks_dev.json +50 -8
- package/build/chains/networks_prod-bu.json +98 -7
- package/build/chains/networks_prod-dz.json +194 -12
- package/build/chains/networks_stg-bu.json +14 -7
- package/build/chains/networks_stg-dz.json +60 -20
- package/build/errors/AdminErrors.d.ts +5 -9
- package/build/errors/AdminErrors.d.ts.map +1 -1
- package/build/errors/AdminErrors.js +49 -24
- package/build/errors/AlchemyErrors.d.ts +14 -18
- package/build/errors/AlchemyErrors.d.ts.map +1 -1
- package/build/errors/AlchemyErrors.js +76 -49
- package/build/errors/BalanceErrors.d.ts +3 -7
- package/build/errors/BalanceErrors.d.ts.map +1 -1
- package/build/errors/BalanceErrors.js +47 -26
- package/build/errors/DatabaseErrors.d.ts +5 -9
- package/build/errors/DatabaseErrors.d.ts.map +1 -1
- package/build/errors/DatabaseErrors.js +49 -28
- package/build/errors/TransactionsErrors.d.ts +15 -20
- package/build/errors/TransactionsErrors.d.ts.map +1 -1
- package/build/errors/TransactionsErrors.js +81 -66
- package/build/errors/VoltageErrors.d.ts +8 -13
- package/build/errors/VoltageErrors.d.ts.map +1 -1
- package/build/errors/VoltageErrors.js +58 -45
- package/build/errors/WalletErrors.d.ts +6 -12
- package/build/errors/WalletErrors.d.ts.map +1 -1
- package/build/errors/WalletErrors.js +48 -37
- package/build/errors/errors.d.ts +137 -27
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +230 -66
- package/build/errors/index.d.ts +37 -36
- package/build/errors/index.d.ts.map +1 -1
- package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
- package/build/services/AlchemyWebhookAddressManager.js +3 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
- package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
- package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
- package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
- package/build/services/types/chain_manager.d.ts +6 -0
- package/build/services/types/chain_manager.d.ts.map +1 -1
- package/build/utils/Logger.d.ts.map +1 -1
- package/build/utils/Logger.js +13 -2
- package/build/utils/solana.d.ts +2 -1
- package/build/utils/solana.d.ts.map +1 -1
- package/build/utils/solana.js +28 -3
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const AsyncTTLCache_1 = __importDefault(require("../../utils/AsyncTTLCache"));
|
|
15
16
|
const ChainManager_1 = __importDefault(require("../ChainManager"));
|
|
16
17
|
const DepositAddressService_1 = __importDefault(require("../DepositAddressService"));
|
|
17
18
|
const QnNotificationsApi_1 = __importDefault(require("./QnNotificationsApi"));
|
|
@@ -20,7 +21,7 @@ const ADDRESS_SYNC_BATCH_SIZE = 500;
|
|
|
20
21
|
const ADDRESS_LOG_THRESHOLD = 1000;
|
|
21
22
|
class QnWebhookAddressManager {
|
|
22
23
|
constructor(config, db, rlc) {
|
|
23
|
-
this.cache =
|
|
24
|
+
this.cache = AsyncTTLCache_1.default.create(CACHE_TTL_MS);
|
|
24
25
|
this.config = config;
|
|
25
26
|
this.api = QnNotificationsApi_1.default.getInstance(config, rlc);
|
|
26
27
|
this.db = db;
|
|
@@ -58,34 +59,22 @@ class QnWebhookAddressManager {
|
|
|
58
59
|
.flatMap(([_, cfg]) => cfg.quicknodeNotificationConfig.map(n => (Object.assign(Object.assign({}, n), { blockchain: cfg.blockchainType }))))
|
|
59
60
|
.filter((n, i, arr) => arr.findIndex(x => x.name === n.name) === i);
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
const cached = this.cache.get(blockchain);
|
|
63
|
-
if (!cached)
|
|
64
|
-
return true;
|
|
65
|
-
return Date.now() - cached.loaded_at > CACHE_TTL_MS;
|
|
66
|
-
}
|
|
67
|
-
load(blockchain) {
|
|
62
|
+
load_entries(blockchain) {
|
|
68
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
64
|
const notif_configs = this.get_notif_configs(blockchain);
|
|
70
65
|
if (notif_configs.length === 0)
|
|
71
|
-
return;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const res = yield this.api.get_all_webhooks();
|
|
75
|
-
all_webhooks = res.data || [];
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.error(`QnWebhookAddressManager: Failed to fetch webhooks for blockchain=${blockchain}`, error);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Get all addresses to add to webhook
|
|
66
|
+
return [];
|
|
67
|
+
const res = yield this.api.get_all_webhooks();
|
|
68
|
+
const all_webhooks = res.data || [];
|
|
82
69
|
const addresses = yield this.fetch_all_db_addresses(blockchain);
|
|
70
|
+
console.log(`Loaded ${addresses.length} addresses from db`);
|
|
83
71
|
const entries = [];
|
|
84
72
|
for (const notif_config of notif_configs) {
|
|
85
73
|
const existing = all_webhooks.find(w => {
|
|
86
|
-
var _a, _b;
|
|
74
|
+
var _a, _b, _c;
|
|
87
75
|
return ((_a = w.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === notif_config.name.toLowerCase() &&
|
|
88
|
-
((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase()
|
|
76
|
+
((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase() &&
|
|
77
|
+
!((_c = w.name) === null || _c === void 0 ? void 0 : _c.includes('escrow'));
|
|
89
78
|
});
|
|
90
79
|
if (!existing) {
|
|
91
80
|
console.warn(`QnWebhookAddressManager: No webhook found for config=${notif_config.name} network=${notif_config.network}`);
|
|
@@ -99,16 +88,12 @@ class QnWebhookAddressManager {
|
|
|
99
88
|
address_set: new Set(addresses),
|
|
100
89
|
});
|
|
101
90
|
}
|
|
102
|
-
|
|
91
|
+
return entries;
|
|
103
92
|
});
|
|
104
93
|
}
|
|
105
94
|
ensure_loaded(blockchain) {
|
|
106
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
|
|
108
|
-
if (this.is_stale(blockchain)) {
|
|
109
|
-
yield this.load(blockchain);
|
|
110
|
-
}
|
|
111
|
-
return ((_a = this.cache.get(blockchain)) === null || _a === void 0 ? void 0 : _a.entries) || [];
|
|
96
|
+
return this.cache.get_value(blockchain, blockchain, (bc) => this.load_entries(bc));
|
|
112
97
|
});
|
|
113
98
|
}
|
|
114
99
|
matches_key(entry, key) {
|
|
@@ -117,12 +102,12 @@ class QnWebhookAddressManager {
|
|
|
117
102
|
add_address(blockchain, address) {
|
|
118
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
104
|
const entries = yield this.ensure_loaded(blockchain);
|
|
105
|
+
console.log(`Pushing ${entries.length} addresses: `, entries);
|
|
106
|
+
console.log(`Pushed ${entries.length} addresses `);
|
|
120
107
|
for (const entry of entries) {
|
|
121
|
-
if (entry.address_set.has(address))
|
|
122
|
-
continue;
|
|
123
108
|
entry.address_set.add(address);
|
|
124
109
|
try {
|
|
125
|
-
console.log(`Adding addresses: `, entry.address_set);
|
|
110
|
+
console.log(`add_address : Adding addresses: `, entry.address_set);
|
|
126
111
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
127
112
|
console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook`);
|
|
128
113
|
}
|
|
@@ -137,12 +122,12 @@ class QnWebhookAddressManager {
|
|
|
137
122
|
}
|
|
138
123
|
remove_address(blockchain, address) {
|
|
139
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
console.log(`Ensuring loaded...`);
|
|
140
126
|
const entries = yield this.ensure_loaded(blockchain);
|
|
141
127
|
for (const entry of entries) {
|
|
142
|
-
if (!entry.address_set.has(address))
|
|
143
|
-
continue;
|
|
144
128
|
entry.address_set.delete(address);
|
|
145
129
|
try {
|
|
130
|
+
console.log(`remove_address: Updating webhook addresses to :`, Array.from(entry.address_set));
|
|
146
131
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
147
132
|
console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook`);
|
|
148
133
|
}
|
|
@@ -169,10 +154,10 @@ class QnWebhookAddressManager {
|
|
|
169
154
|
const entries = (yield this.ensure_loaded(blockchain))
|
|
170
155
|
.filter(e => keys.some(k => this.matches_key(e, k)));
|
|
171
156
|
for (const entry of entries) {
|
|
172
|
-
if (entry.address_set.has(address))
|
|
173
|
-
|
|
174
|
-
entry.address_set.add(address);
|
|
157
|
+
if (!entry.address_set.has(address) && !entry.address_set.has(address.toLowerCase()))
|
|
158
|
+
entry.address_set.add(address);
|
|
175
159
|
try {
|
|
160
|
+
console.log(`add_address_to_chain: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
|
|
176
161
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
177
162
|
console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook (chain ${chain_id})`);
|
|
178
163
|
}
|
|
@@ -199,10 +184,10 @@ class QnWebhookAddressManager {
|
|
|
199
184
|
const entries = (yield this.ensure_loaded(blockchain))
|
|
200
185
|
.filter(e => keys.some(k => this.matches_key(e, k)));
|
|
201
186
|
for (const entry of entries) {
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
entry.address_set.delete(address);
|
|
187
|
+
if (entry.address_set.has(address) || entry.address_set.has(address.toLowerCase()))
|
|
188
|
+
entry.address_set.delete(address);
|
|
205
189
|
try {
|
|
190
|
+
console.log(`remove_address_from_chain: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
|
|
206
191
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
207
192
|
console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook (chain ${chain_id})`);
|
|
208
193
|
}
|
|
@@ -226,10 +211,9 @@ class QnWebhookAddressManager {
|
|
|
226
211
|
const entries = (yield this.ensure_loaded(blockchain))
|
|
227
212
|
.filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
|
|
228
213
|
for (const entry of entries) {
|
|
229
|
-
if (entry.address_set.has(address))
|
|
230
|
-
continue;
|
|
231
214
|
entry.address_set.add(address);
|
|
232
215
|
try {
|
|
216
|
+
console.log(`sync_add_to_remaining: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
|
|
233
217
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
234
218
|
console.log(`QnWebhookAddressManager: Synced add ${address} to ${entry.name} webhook`);
|
|
235
219
|
}
|
|
@@ -251,10 +235,9 @@ class QnWebhookAddressManager {
|
|
|
251
235
|
const entries = (yield this.ensure_loaded(blockchain))
|
|
252
236
|
.filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
|
|
253
237
|
for (const entry of entries) {
|
|
254
|
-
if (!entry.address_set.has(address))
|
|
255
|
-
continue;
|
|
256
238
|
entry.address_set.delete(address);
|
|
257
239
|
try {
|
|
240
|
+
console.log(`sync_remove_from_remaining: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
|
|
258
241
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
259
242
|
console.log(`QnWebhookAddressManager: Synced remove ${address} from ${entry.name} webhook`);
|
|
260
243
|
}
|
|
@@ -27,6 +27,7 @@ declare class SetupNotifications extends BaseErrors {
|
|
|
27
27
|
* The `blockchain` filter value in DepositAddressService is the string stored
|
|
28
28
|
* in the DB — e.g. "solana", "evm", "ethereum", etc.
|
|
29
29
|
*/
|
|
30
|
+
private fetch_contract_addresses;
|
|
30
31
|
private fetch_all_db_addresses;
|
|
31
32
|
/**
|
|
32
33
|
* Register a newly-created webhook entry in the internal maps.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupNotifications.d.ts","sourceRoot":"","sources":["../../../src/services/quicknode-notifications/SetupNotifications.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SetupNotifications.d.ts","sourceRoot":"","sources":["../../../src/services/quicknode-notifications/SetupNotifications.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAUlE,MAAM,WAAW,wBAAwB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,cAAc,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAWD,cAAM,kBAAmB,SAAQ,UAAU;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAC5C,OAAO,CAAC,GAAG,CAAqB;IAEhC,OAAO,CAAC,WAAW,CAAoD;IAEvE,OAAO,CAAC,aAAa,CAA8D;IAEnF,OAAO,CAAC,eAAe,CAAqD;IAC5E,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO;IAOP,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,GAAG,kBAAkB;IAO5F,mBAAmB,IAAI,MAAM,EAAE;IAI/B,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAOhF;;;;OAIG;YACW,wBAAwB;YAoBxB,sBAAsB;IAuBpC;;OAEG;IACH,OAAO,CAAC,cAAc;IAOT,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA0H3B,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyDvE,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAe1F;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -12,11 +12,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
15
17
|
const errors_1 = __importDefault(require("../../errors/errors"));
|
|
16
18
|
const ChainManager_1 = __importDefault(require("../ChainManager"));
|
|
17
19
|
const DepositAddressService_1 = __importDefault(require("../DepositAddressService"));
|
|
18
20
|
const QuicknodeWebhookSignature_1 = __importDefault(require("../QuicknodeWebhookSignature"));
|
|
19
21
|
const QnNotificationsApi_1 = __importDefault(require("./QnNotificationsApi"));
|
|
22
|
+
const Wallets_1 = require("../../utils/Wallets");
|
|
23
|
+
const __1 = require("../..");
|
|
20
24
|
const ADDRESS_SYNC_BATCH_SIZE = 500;
|
|
21
25
|
const ADDRESS_LOG_THRESHOLD = 1000;
|
|
22
26
|
class SetupNotifications extends errors_1.default {
|
|
@@ -53,6 +57,27 @@ class SetupNotifications extends errors_1.default {
|
|
|
53
57
|
* The `blockchain` filter value in DepositAddressService is the string stored
|
|
54
58
|
* in the DB — e.g. "solana", "evm", "ethereum", etc.
|
|
55
59
|
*/
|
|
60
|
+
fetch_contract_addresses(notif_config) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!notif_config.chain_id) {
|
|
64
|
+
console.warn(`SetupNotifications: source='contract' but no chain_id set for ${notif_config.name} — skipping`);
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const chain_manager = ChainManager_1.default.getInstance(this.config);
|
|
68
|
+
const escrow_config = chain_manager.getEscrowContractForChain(notif_config.chain_id);
|
|
69
|
+
// Derive vault authority for solana escrow program
|
|
70
|
+
if (notif_config.chain_id !== undefined && notif_config.blockchain === constants_1.BLOCKCHAINS.SOLANA) {
|
|
71
|
+
const chain_manager = ChainManager_1.default.getInstance(this.config);
|
|
72
|
+
const escrow_config = chain_manager.getEscrowContractForChain(parseInt(notif_config.chain_id.toString()));
|
|
73
|
+
// TODO handle multiple escrow contracts on solana
|
|
74
|
+
const escrow_program_pubkey = new web3_js_1.PublicKey((0, Wallets_1.normalizeAddress)(escrow_config.addresses[0], "solana"));
|
|
75
|
+
const vault_authority = __1.EscrowService.findVaultAuthorityPda(escrow_program_pubkey);
|
|
76
|
+
return [vault_authority.toString()];
|
|
77
|
+
}
|
|
78
|
+
return (_a = escrow_config === null || escrow_config === void 0 ? void 0 : escrow_config.addresses) !== null && _a !== void 0 ? _a : [];
|
|
79
|
+
});
|
|
80
|
+
}
|
|
56
81
|
fetch_all_db_addresses(blockchain) {
|
|
57
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
83
|
const service = new DepositAddressService_1.default(this.db);
|
|
@@ -117,8 +142,10 @@ class SetupNotifications extends errors_1.default {
|
|
|
117
142
|
return ((_a = w.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === notif_config.name.toLowerCase() &&
|
|
118
143
|
((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase();
|
|
119
144
|
});
|
|
120
|
-
// Fetch
|
|
121
|
-
const db_addresses =
|
|
145
|
+
// Fetch addresses — contract source uses escrow addresses, wallet source uses DB deposit addresses
|
|
146
|
+
const db_addresses = notif_config.source === 'contract'
|
|
147
|
+
? yield this.fetch_contract_addresses(notif_config)
|
|
148
|
+
: yield this.fetch_all_db_addresses(notif_config.blockchain);
|
|
122
149
|
console.log(`SetupNotifications: ${db_addresses.length} DB addresses for blockchain=${notif_config.blockchain}`);
|
|
123
150
|
let webhook_id;
|
|
124
151
|
if (existing) {
|
|
@@ -12,6 +12,10 @@ export type QuicknodeNotificationConfig = {
|
|
|
12
12
|
name: string;
|
|
13
13
|
network: string;
|
|
14
14
|
template: 'solanaWalletFilter' | 'evmWalletFilter';
|
|
15
|
+
/** 'wallet' (default) = custodial deposit addresses; 'contract' = escrow contract addresses */
|
|
16
|
+
source?: 'wallet' | 'contract';
|
|
17
|
+
/** Required when source === 'contract' — the chain ID to look up the escrow contract */
|
|
18
|
+
chain_id?: number;
|
|
15
19
|
};
|
|
16
20
|
export type QuicknodeStreamConfig = {
|
|
17
21
|
network: string;
|
|
@@ -46,6 +50,8 @@ export interface ChainAccountingDetails {
|
|
|
46
50
|
treasury_receiver: string;
|
|
47
51
|
overflow_treasury_receiver: string;
|
|
48
52
|
overflow_threshold_decimal: number;
|
|
53
|
+
min_funding_wallet_balance_usd: number;
|
|
54
|
+
allowed_receivers: string[];
|
|
49
55
|
}
|
|
50
56
|
export interface TronConfig {
|
|
51
57
|
trxTransferCost: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_manager.d.ts","sourceRoot":"","sources":["../../../src/services/types/chain_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,6BAA6B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,kB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AI;IAI/C;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM;IAcxE;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAI/C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAI9C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAM9C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAO/C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAM/C;;OAEG;IACH,OAAO,CAAC,aAAa;IAuCrB;;OAEG;IACH,OAAO,CAAC,cAAc;CAezB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,aAAa,MAAM,EAAE,UAAU,UAAU,KAAG,MAExF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/build/utils/Logger.js
CHANGED
|
@@ -84,8 +84,9 @@ class Logger {
|
|
|
84
84
|
* Warn level - sent to ElasticSearch
|
|
85
85
|
*/
|
|
86
86
|
warn(message, data) {
|
|
87
|
-
|
|
88
|
-
this.
|
|
87
|
+
const logData = this.normalizeData(data);
|
|
88
|
+
this.pino.warn(Object.assign({ source: this.source }, logData), message);
|
|
89
|
+
this.indexToElastic('Warning', message, logData);
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
92
|
* Error level - sent to ElasticSearch
|
|
@@ -129,6 +130,16 @@ class Logger {
|
|
|
129
130
|
stack: value.stack,
|
|
130
131
|
};
|
|
131
132
|
}
|
|
133
|
+
else if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
134
|
+
// Recurse one level to catch nested Error objects (e.g. { data: { err: Error } })
|
|
135
|
+
const nested = {};
|
|
136
|
+
for (const [nk, nv] of Object.entries(value)) {
|
|
137
|
+
nested[nk] = nv instanceof Error
|
|
138
|
+
? { name: nv.name, message: nv.message, stack: nv.stack }
|
|
139
|
+
: nv;
|
|
140
|
+
}
|
|
141
|
+
normalized[key] = nested;
|
|
142
|
+
}
|
|
132
143
|
else {
|
|
133
144
|
normalized[key] = value;
|
|
134
145
|
}
|
package/build/utils/solana.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export declare const handle_transfer_batch: (payloads: SolanaTransactionRequest[
|
|
|
70
70
|
success: SolanaTransactionSuccessRequest[];
|
|
71
71
|
failed: SolanaTransactionRequest[];
|
|
72
72
|
}>;
|
|
73
|
-
export declare const find_transfer_instruction: (tx: SolanaTransactionLog) => TransferInstructionRecord;
|
|
73
|
+
export declare const find_transfer_instruction: (tx: SolanaTransactionLog, receiver?: string) => TransferInstructionRecord;
|
|
74
|
+
export declare const find_transfer_instruction_depr: (tx: SolanaTransactionLog) => TransferInstructionRecord;
|
|
74
75
|
export declare const getSolanaConnection: (chainId: string, config: IConfig) => web3.Connection;
|
|
75
76
|
export declare const getSolanaArchivalConnection: (chainId: string, config: IConfig) => web3.Connection;
|
|
76
77
|
export declare const getSolanaConnectionPublic: (chainId: string) => web3.Connection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/utils/solana.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,OAAO,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,IAAI,EAAE,EAA6B,OAAO,EAAuC,SAAS,EAAgE,MAAM,iBAAiB,CAAA;AAGxL,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAGnF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA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;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG"}
|
package/build/utils/solana.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.check_approve_delegate = exports.handle_create_versioned_transaction_spl = exports.estimate_withdraw_gas_cost = exports.create_versioned_transaction_solana = exports.get_token_account_info = exports.getSolanaConnectionPublic = exports.getSolanaArchivalConnection = exports.getSolanaConnection = exports.find_transfer_instruction = exports.handle_transfer_batch = exports.handle_sweep = exports.SplTransferCheckedLayout = exports.SolTransferInstructionLayout = exports.usdc_program_address = exports.solana_program_address = exports.min_solana_funding_lamports = void 0;
|
|
48
|
+
exports.check_approve_delegate = exports.handle_create_versioned_transaction_spl = exports.estimate_withdraw_gas_cost = exports.create_versioned_transaction_solana = exports.get_token_account_info = exports.getSolanaConnectionPublic = exports.getSolanaArchivalConnection = exports.getSolanaConnection = exports.find_transfer_instruction_depr = exports.find_transfer_instruction = exports.handle_transfer_batch = exports.handle_sweep = exports.SplTransferCheckedLayout = exports.SolTransferInstructionLayout = exports.usdc_program_address = exports.solana_program_address = exports.min_solana_funding_lamports = void 0;
|
|
49
49
|
const buffer_layout_utils_1 = require("@solana/buffer-layout-utils");
|
|
50
50
|
const buffer_layout_1 = require("@solana/buffer-layout");
|
|
51
51
|
const web3_js_1 = __importStar(require("@solana/web3.js"));
|
|
@@ -182,7 +182,32 @@ const handle_transfer_batch = (payloads_1, chain_id_1, token_type_1, connection_
|
|
|
182
182
|
return { status: true, signatures, success, failed };
|
|
183
183
|
});
|
|
184
184
|
exports.handle_transfer_batch = handle_transfer_batch;
|
|
185
|
-
const find_transfer_instruction = (tx) => {
|
|
185
|
+
const find_transfer_instruction = (tx, receiver) => {
|
|
186
|
+
const message = tx.transaction[0].message[0];
|
|
187
|
+
const target_instruction = message.instructions.find(i => {
|
|
188
|
+
const program = message.account_keys[parseInt(i.program_id_index)];
|
|
189
|
+
if (!token_program_addresses.some(a => a === program))
|
|
190
|
+
return false;
|
|
191
|
+
// If a receiver is specified and this is a native SOL transfer, match by
|
|
192
|
+
// the destination account (accounts[1]) to find the exact instruction for
|
|
193
|
+
// that recipient. Needed for batch sends where one tx has many transfers.
|
|
194
|
+
if (receiver && program === exports.solana_program_address) {
|
|
195
|
+
if (!i.accounts || i.accounts.length < 2)
|
|
196
|
+
return false;
|
|
197
|
+
return message.account_keys[i.accounts[1]] === receiver;
|
|
198
|
+
}
|
|
199
|
+
return true; // original behaviour: first matching program
|
|
200
|
+
});
|
|
201
|
+
if (!target_instruction)
|
|
202
|
+
throw new Error(`Cannot find program index for accepted payment tokens: ${token_program_addresses}`);
|
|
203
|
+
const program_index = target_instruction.program_id_index;
|
|
204
|
+
return {
|
|
205
|
+
instruction: target_instruction,
|
|
206
|
+
is_native: message.account_keys[parseInt(program_index)] === exports.solana_program_address
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
exports.find_transfer_instruction = find_transfer_instruction;
|
|
210
|
+
const find_transfer_instruction_depr = (tx) => {
|
|
186
211
|
const message = tx.transaction[0].message[0];
|
|
187
212
|
const target_instruction = message.instructions.find(i => token_program_addresses.some(a => a === message.account_keys[parseInt(i.program_id_index)]));
|
|
188
213
|
if (!target_instruction)
|
|
@@ -190,7 +215,7 @@ const find_transfer_instruction = (tx) => {
|
|
|
190
215
|
const program_index = target_instruction === null || target_instruction === void 0 ? void 0 : target_instruction.program_id_index;
|
|
191
216
|
return { instruction: target_instruction, is_native: tx.transaction[0].message[0].account_keys[parseInt(program_index)] === exports.solana_program_address };
|
|
192
217
|
};
|
|
193
|
-
exports.
|
|
218
|
+
exports.find_transfer_instruction_depr = find_transfer_instruction_depr;
|
|
194
219
|
const getSolanaConnection = (chainId, config) => {
|
|
195
220
|
const network = ChainManager_1.default.getInstance(config).getChainConfigForChainIdSync(parseInt(chainId));
|
|
196
221
|
if (!network)
|