@haven-fi/solauto-sdk 1.0.369 → 1.0.371
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,GACnB,SAAS,CAEX;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CAEb;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,+DAS1E;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,aAcrB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,aAU1E"}
|
@@ -24,10 +24,12 @@ function getTokenAccount(wallet, tokenMint) {
|
|
24
24
|
return (0, spl_token_1.getAssociatedTokenAddressSync)(tokenMint, wallet, true);
|
25
25
|
}
|
26
26
|
function getTokenAccounts(wallet, tokenMints) {
|
27
|
-
return tokenMints.map(x => getTokenAccount(wallet, x));
|
27
|
+
return tokenMints.map((x) => getTokenAccount(wallet, x));
|
28
28
|
}
|
29
29
|
async function getTokenAccountData(umi, tokenAccount) {
|
30
|
-
const resp = await umi.rpc.getAccount((0, umi_1.publicKey)(tokenAccount), {
|
30
|
+
const resp = await umi.rpc.getAccount((0, umi_1.publicKey)(tokenAccount), {
|
31
|
+
commitment: "confirmed",
|
32
|
+
});
|
31
33
|
if (resp.exists) {
|
32
34
|
return spl_token_1.AccountLayout.decode(resp.data);
|
33
35
|
}
|
@@ -36,7 +38,13 @@ async function getTokenAccountData(umi, tokenAccount) {
|
|
36
38
|
}
|
37
39
|
}
|
38
40
|
function getSolautoPositionAccount(authority, positionId, programId) {
|
39
|
-
const
|
41
|
+
const fakePosition = positionId >= 256;
|
42
|
+
const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([
|
43
|
+
fakePosition
|
44
|
+
? bufferFromU64(BigInt(positionId))
|
45
|
+
: bufferFromU8(positionId),
|
46
|
+
authority.toBuffer(),
|
47
|
+
], programId);
|
40
48
|
return positionAccount;
|
41
49
|
}
|
42
50
|
function getReferralState(authority, programId) {
|
package/dist/utils/priceUtils.js
CHANGED
package/package.json
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
AccountLayout as SplTokenAccountLayout,
|
4
|
+
getAssociatedTokenAddressSync,
|
5
|
+
} from "@solana/spl-token";
|
3
6
|
import { publicKey, Umi } from "@metaplex-foundation/umi";
|
4
7
|
|
5
8
|
export function bufferFromU8(num: number): Buffer {
|
@@ -14,20 +17,24 @@ export function bufferFromU64(num: bigint): Buffer {
|
|
14
17
|
return buffer;
|
15
18
|
}
|
16
19
|
|
17
|
-
export function getTokenAccount(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
);
|
20
|
+
export function getTokenAccount(
|
21
|
+
wallet: PublicKey,
|
22
|
+
tokenMint: PublicKey
|
23
|
+
): PublicKey {
|
24
|
+
return getAssociatedTokenAddressSync(tokenMint, wallet, true);
|
23
25
|
}
|
24
26
|
|
25
|
-
export function getTokenAccounts(
|
26
|
-
|
27
|
+
export function getTokenAccounts(
|
28
|
+
wallet: PublicKey,
|
29
|
+
tokenMints: PublicKey[]
|
30
|
+
): PublicKey[] {
|
31
|
+
return tokenMints.map((x) => getTokenAccount(wallet, x));
|
27
32
|
}
|
28
33
|
|
29
34
|
export async function getTokenAccountData(umi: Umi, tokenAccount: PublicKey) {
|
30
|
-
const resp = await umi.rpc.getAccount(publicKey(tokenAccount), {
|
35
|
+
const resp = await umi.rpc.getAccount(publicKey(tokenAccount), {
|
36
|
+
commitment: "confirmed",
|
37
|
+
});
|
31
38
|
if (resp.exists) {
|
32
39
|
return SplTokenAccountLayout.decode(resp.data);
|
33
40
|
} else {
|
@@ -40,8 +47,14 @@ export function getSolautoPositionAccount(
|
|
40
47
|
positionId: number,
|
41
48
|
programId: PublicKey
|
42
49
|
) {
|
50
|
+
const fakePosition = positionId >= 256;
|
43
51
|
const [positionAccount, _] = PublicKey.findProgramAddressSync(
|
44
|
-
[
|
52
|
+
[
|
53
|
+
fakePosition
|
54
|
+
? bufferFromU64(BigInt(positionId))
|
55
|
+
: bufferFromU8(positionId),
|
56
|
+
authority.toBuffer(),
|
57
|
+
],
|
45
58
|
programId
|
46
59
|
);
|
47
60
|
|
@@ -58,4 +71,4 @@ export function getReferralState(authority: PublicKey, programId: PublicKey) {
|
|
58
71
|
);
|
59
72
|
|
60
73
|
return ReferralState;
|
61
|
-
}
|
74
|
+
}
|
package/src/utils/priceUtils.ts
CHANGED