@hawksightco/hawk-sdk 1.3.2 → 1.3.4
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.
|
@@ -7,7 +7,14 @@ type AccountInfoInternal = {
|
|
|
7
7
|
type _AccountCache = Record<string, AccountInfoInternal>;
|
|
8
8
|
export declare abstract class AccountCache {
|
|
9
9
|
protected connection: web3.Connection;
|
|
10
|
+
/**
|
|
11
|
+
* Cache of accounts.
|
|
12
|
+
*/
|
|
10
13
|
protected accounts: _AccountCache;
|
|
14
|
+
/**
|
|
15
|
+
* Promise that resolves when the accounts are fetched.
|
|
16
|
+
* This is used to wait for the accounts to be fetched before using them.
|
|
17
|
+
*/
|
|
11
18
|
protected pending: Promise<void> | null;
|
|
12
19
|
/**
|
|
13
20
|
* Instantiate the AccountCache class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountCache.d.ts","sourceRoot":"","sources":["../../../../src/classes/account-cache/AccountCache.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC,CAAA;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEzD,8BAAsB,YAAY;
|
|
1
|
+
{"version":3,"file":"AccountCache.d.ts","sourceRoot":"","sources":["../../../../src/classes/account-cache/AccountCache.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC,CAAA;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEzD,8BAAsB,YAAY;IAmB9B,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAjBvC;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAM;IAEvC;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAE/C;;;;OAIG;gBAES,UAAU,EAAE,IAAI,CAAC,UAAU;IAGvC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,yBAAyB,IAAI,IAAI,CAAC,SAAS,EAAE;IAEhE;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,OAAO;IAE5C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI;IAOxC;;;;;;OAMG;IACH,8BAA8B,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,UAAU,GAAE,IAAI,CAAC,UAAwB,GAAG,IAAI;IAuCpG,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;CAM9C"}
|
|
@@ -18,7 +18,14 @@ class AccountCache {
|
|
|
18
18
|
*/
|
|
19
19
|
constructor(connection) {
|
|
20
20
|
this.connection = connection;
|
|
21
|
+
/**
|
|
22
|
+
* Cache of accounts.
|
|
23
|
+
*/
|
|
21
24
|
this.accounts = {};
|
|
25
|
+
/**
|
|
26
|
+
* Promise that resolves when the accounts are fetched.
|
|
27
|
+
* This is used to wait for the accounts to be fetched before using them.
|
|
28
|
+
*/
|
|
22
29
|
this.pending = null;
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
@@ -39,7 +46,13 @@ class AccountCache {
|
|
|
39
46
|
*/
|
|
40
47
|
getBatchedMultipleAccountsInfo(pubkeys, commitment = "confirmed") {
|
|
41
48
|
// Check first if account is already fetched. Skips accounts that are marked to be refetched.
|
|
42
|
-
const pubkeysToFetch = pubkeys.filter(pubkey =>
|
|
49
|
+
const pubkeysToFetch = pubkeys.filter(pubkey => {
|
|
50
|
+
const cache = this.accounts[pubkey.toString()];
|
|
51
|
+
if (cache) {
|
|
52
|
+
return cache.refetch;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
43
56
|
const batchSize = 100;
|
|
44
57
|
const batches = [];
|
|
45
58
|
for (let i = 0; i < pubkeysToFetch.length; i += batchSize) {
|
|
@@ -494,7 +494,7 @@ class IyfMainIxGenerator {
|
|
|
494
494
|
hsFeeOwner: addresses_1.SITE_FEE_OWNER,
|
|
495
495
|
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
496
496
|
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
497
|
-
|
|
497
|
+
tokenProgram2022: addresses_1.TOKEN_2022_PROGRAM_ID,
|
|
498
498
|
systemProgram: web3.SystemProgram.programId,
|
|
499
499
|
})
|
|
500
500
|
.remainingAccounts(remainingAccounts)
|
|
@@ -563,7 +563,7 @@ class IyfMainIxGenerator {
|
|
|
563
563
|
hsFeeOwner: addresses_1.SITE_FEE_OWNER,
|
|
564
564
|
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
565
565
|
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
566
|
-
|
|
566
|
+
tokenProgram2022: addresses_1.TOKEN_2022_PROGRAM_ID,
|
|
567
567
|
systemProgram: web3.SystemProgram.programId,
|
|
568
568
|
})
|
|
569
569
|
.remainingAccounts(remainingAccounts)
|