@glamsystems/glam-sdk 1.0.3-alpha.4 → 1.0.3-alpha.5
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/index.cjs.js +17 -4
- package/index.esm.js +17 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -29641,7 +29641,7 @@ class PriceClient {
|
|
|
29641
29641
|
...kaminoPubkeys.values()
|
|
29642
29642
|
].map((v)=>Array.from(v.pkValues())).flat();
|
|
29643
29643
|
// Dedupe keys and fetch all accounts in a single RPC call
|
|
29644
|
-
const pubkeys = Array.from(new PkSet(tokenPubkeys.concat(...driftUsers, ...driftSpotMarkets, ...kaminoObligations, ...kaminoReserves)));
|
|
29644
|
+
const pubkeys = Array.from(new PkSet(tokenPubkeys.concat(...driftUsers, ...driftSpotMarkets, ...kaminoObligations, ...kaminoReserves, web3_js.SYSVAR_CLOCK_PUBKEY)));
|
|
29645
29645
|
const { context: { slot }, value: accountsInfo } = await this.base.provider.connection.getMultipleAccountsInfoAndContext(pubkeys, commitment);
|
|
29646
29646
|
// Build a map of pubkey to account data for quick lookup
|
|
29647
29647
|
const accountsDataMap = new PkMap();
|
|
@@ -29669,7 +29669,7 @@ class PriceClient {
|
|
|
29669
29669
|
const tokenHoldings = this.getTokenHoldings(tokenPubkeys, accountsDataMap, tokenPricesMap);
|
|
29670
29670
|
const driftSpotHoldings = this.getDriftSpotHoldings(driftPubkeys.pkKeys(), driftSpotMarketsMap, accountsDataMap, tokenPricesMap);
|
|
29671
29671
|
const kaminoLendHoldings = this.getKaminoLendHoldings(kaminoPubkeys.pkKeys(), kaminoReservesMap, accountsDataMap, tokenPricesMap);
|
|
29672
|
-
const timestamp =
|
|
29672
|
+
const timestamp = accountsDataMap.get(web3_js.SYSVAR_CLOCK_PUBKEY).readUInt32LE(32);
|
|
29673
29673
|
const ret = new VaultHoldings(this.base.statePda, this.base.vaultPda, priceBaseAssetMint, slot, timestamp, commitment);
|
|
29674
29674
|
tokenHoldings.forEach((holding)=>ret.add(holding));
|
|
29675
29675
|
driftSpotHoldings.forEach((holding)=>ret.add(holding));
|
|
@@ -31443,9 +31443,15 @@ class CctpClient {
|
|
|
31443
31443
|
];
|
|
31444
31444
|
}
|
|
31445
31445
|
async buildReceiveMessageIx(sourceDomain, messageObj) {
|
|
31446
|
-
const { message, attestation, eventNonce, decodedMessage
|
|
31446
|
+
const { message, attestation, eventNonce, decodedMessage, status } = messageObj;
|
|
31447
|
+
if (status !== "complete") {
|
|
31448
|
+
throw new Error(`Attestation status is ${status}, expected "complete"`);
|
|
31449
|
+
}
|
|
31450
|
+
if (!decodedMessage || !decodedMessage?.decodedMessageBody || !decodedMessage?.decodedMessageBody?.burnToken) {
|
|
31451
|
+
throw new Error("Invalid message object: missing burnToken in decodedMessage");
|
|
31452
|
+
}
|
|
31447
31453
|
// message, attestation, eventNonce, burnToken are hex strings
|
|
31448
|
-
const pdas = await this.getReceiveMessagePdas(MESSAGE_TRANSMITTER_V2, TOKEN_MESSENGER_MINTER_V2, USDC, burnToken, sourceDomain.toString(), eventNonce);
|
|
31454
|
+
const pdas = await this.getReceiveMessagePdas(MESSAGE_TRANSMITTER_V2, TOKEN_MESSENGER_MINTER_V2, USDC, decodedMessage.decodedMessageBody.burnToken, sourceDomain.toString(), eventNonce);
|
|
31449
31455
|
// raw ix data: [discriminator][message][attestation]
|
|
31450
31456
|
const messageBuffer = Buffer.from(message.replace("0x", ""), "hex");
|
|
31451
31457
|
const attestationBuffer = Buffer.from(attestation.replace("0x", ""), "hex");
|
|
@@ -31712,7 +31718,14 @@ class CctpClient {
|
|
|
31712
31718
|
queryParams.set("transactionHash", txHash);
|
|
31713
31719
|
}
|
|
31714
31720
|
const resonse = await fetch(`https://iris-api.circle.com/v2/messages/${sourceDomain}?${queryParams}`);
|
|
31721
|
+
if (resonse.status !== 200) {
|
|
31722
|
+
const { error } = await resonse.json();
|
|
31723
|
+
throw new Error(`Failed to fetch messages from Circle API: ${resonse.status} ${error}`);
|
|
31724
|
+
}
|
|
31715
31725
|
const { messages } = await resonse.json();
|
|
31726
|
+
if (!(messages instanceof Array)) {
|
|
31727
|
+
throw new Error("Invalid response from Circle API: messages not found");
|
|
31728
|
+
}
|
|
31716
31729
|
return messages;
|
|
31717
31730
|
}
|
|
31718
31731
|
/**
|
package/index.esm.js
CHANGED
|
@@ -29621,7 +29621,7 @@ class PriceClient {
|
|
|
29621
29621
|
...kaminoPubkeys.values()
|
|
29622
29622
|
].map((v)=>Array.from(v.pkValues())).flat();
|
|
29623
29623
|
// Dedupe keys and fetch all accounts in a single RPC call
|
|
29624
|
-
const pubkeys = Array.from(new PkSet(tokenPubkeys.concat(...driftUsers, ...driftSpotMarkets, ...kaminoObligations, ...kaminoReserves)));
|
|
29624
|
+
const pubkeys = Array.from(new PkSet(tokenPubkeys.concat(...driftUsers, ...driftSpotMarkets, ...kaminoObligations, ...kaminoReserves, SYSVAR_CLOCK_PUBKEY)));
|
|
29625
29625
|
const { context: { slot }, value: accountsInfo } = await this.base.provider.connection.getMultipleAccountsInfoAndContext(pubkeys, commitment);
|
|
29626
29626
|
// Build a map of pubkey to account data for quick lookup
|
|
29627
29627
|
const accountsDataMap = new PkMap();
|
|
@@ -29649,7 +29649,7 @@ class PriceClient {
|
|
|
29649
29649
|
const tokenHoldings = this.getTokenHoldings(tokenPubkeys, accountsDataMap, tokenPricesMap);
|
|
29650
29650
|
const driftSpotHoldings = this.getDriftSpotHoldings(driftPubkeys.pkKeys(), driftSpotMarketsMap, accountsDataMap, tokenPricesMap);
|
|
29651
29651
|
const kaminoLendHoldings = this.getKaminoLendHoldings(kaminoPubkeys.pkKeys(), kaminoReservesMap, accountsDataMap, tokenPricesMap);
|
|
29652
|
-
const timestamp =
|
|
29652
|
+
const timestamp = accountsDataMap.get(SYSVAR_CLOCK_PUBKEY).readUInt32LE(32);
|
|
29653
29653
|
const ret = new VaultHoldings(this.base.statePda, this.base.vaultPda, priceBaseAssetMint, slot, timestamp, commitment);
|
|
29654
29654
|
tokenHoldings.forEach((holding)=>ret.add(holding));
|
|
29655
29655
|
driftSpotHoldings.forEach((holding)=>ret.add(holding));
|
|
@@ -31423,9 +31423,15 @@ class CctpClient {
|
|
|
31423
31423
|
];
|
|
31424
31424
|
}
|
|
31425
31425
|
async buildReceiveMessageIx(sourceDomain, messageObj) {
|
|
31426
|
-
const { message, attestation, eventNonce, decodedMessage
|
|
31426
|
+
const { message, attestation, eventNonce, decodedMessage, status } = messageObj;
|
|
31427
|
+
if (status !== "complete") {
|
|
31428
|
+
throw new Error(`Attestation status is ${status}, expected "complete"`);
|
|
31429
|
+
}
|
|
31430
|
+
if (!decodedMessage || !decodedMessage?.decodedMessageBody || !decodedMessage?.decodedMessageBody?.burnToken) {
|
|
31431
|
+
throw new Error("Invalid message object: missing burnToken in decodedMessage");
|
|
31432
|
+
}
|
|
31427
31433
|
// message, attestation, eventNonce, burnToken are hex strings
|
|
31428
|
-
const pdas = await this.getReceiveMessagePdas(MESSAGE_TRANSMITTER_V2, TOKEN_MESSENGER_MINTER_V2, USDC, burnToken, sourceDomain.toString(), eventNonce);
|
|
31434
|
+
const pdas = await this.getReceiveMessagePdas(MESSAGE_TRANSMITTER_V2, TOKEN_MESSENGER_MINTER_V2, USDC, decodedMessage.decodedMessageBody.burnToken, sourceDomain.toString(), eventNonce);
|
|
31429
31435
|
// raw ix data: [discriminator][message][attestation]
|
|
31430
31436
|
const messageBuffer = Buffer.from(message.replace("0x", ""), "hex");
|
|
31431
31437
|
const attestationBuffer = Buffer.from(attestation.replace("0x", ""), "hex");
|
|
@@ -31692,7 +31698,14 @@ class CctpClient {
|
|
|
31692
31698
|
queryParams.set("transactionHash", txHash);
|
|
31693
31699
|
}
|
|
31694
31700
|
const resonse = await fetch(`https://iris-api.circle.com/v2/messages/${sourceDomain}?${queryParams}`);
|
|
31701
|
+
if (resonse.status !== 200) {
|
|
31702
|
+
const { error } = await resonse.json();
|
|
31703
|
+
throw new Error(`Failed to fetch messages from Circle API: ${resonse.status} ${error}`);
|
|
31704
|
+
}
|
|
31695
31705
|
const { messages } = await resonse.json();
|
|
31706
|
+
if (!(messages instanceof Array)) {
|
|
31707
|
+
throw new Error("Invalid response from Circle API: messages not found");
|
|
31708
|
+
}
|
|
31696
31709
|
return messages;
|
|
31697
31710
|
}
|
|
31698
31711
|
/**
|