@interest-protocol/xswap-sdk 1.0.3 → 1.0.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.
package/dist/index.js CHANGED
@@ -6661,13 +6661,33 @@ class XSwap {
6661
6661
  txBytes,
6662
6662
  };
6663
6663
  }
6664
- async getFirstPresign({ owner, walletKey, }) {
6664
+ async getFirstPresign({ owner, walletKey }) {
6665
6665
  const caps = await this.getPresignCaps({ owner, walletKey });
6666
6666
  const first = caps[0];
6667
6667
  invariant(first, `getFirstPresign: no PresignCap found for owner ${owner} with walletKey ${walletKey}`);
6668
6668
  return first;
6669
6669
  }
6670
- async getPresignCaps({ owner, walletKey, }) {
6670
+ async getPresignData({ presignCapId }) {
6671
+ const obj = await __classPrivateFieldGet(this, _XSwap_suiClient, "f").getObject({
6672
+ id: presignCapId,
6673
+ options: { showContent: true },
6674
+ });
6675
+ invariant(obj.data?.content?.dataType === 'moveObject', `getPresignData: failed to fetch PresignCap ${presignCapId}`);
6676
+ const fields = PresignCapFieldsRawSchema.parse(obj.data.content.fields);
6677
+ const presignSessionId = fields.cap.fields.presign_id;
6678
+ const sessionObj = await __classPrivateFieldGet(this, _XSwap_suiClient, "f").getObject({
6679
+ id: presignSessionId,
6680
+ options: { showContent: true },
6681
+ });
6682
+ invariant(sessionObj.data?.content?.dataType === 'moveObject', `getPresignData: failed to fetch presign session ${presignSessionId}`);
6683
+ const sessionFields = PresignSessionFieldsRawSchema.parse(sessionObj.data.content.fields);
6684
+ invariant(sessionFields.state.fields.presign, `getPresignData: presign session ${presignSessionId} has no presign data`);
6685
+ return {
6686
+ presignCapId,
6687
+ presign: new Uint8Array(sessionFields.state.fields.presign),
6688
+ };
6689
+ }
6690
+ async getPresignCaps({ owner, walletKey }) {
6671
6691
  const ownedObjects = await __classPrivateFieldGet(this, _XSwap_suiClient, "f").getOwnedObjects({
6672
6692
  owner,
6673
6693
  filter: { StructType: PRESIGN_CAP_TYPE },