import { C as c, ah as p, bf as H, au as Z } from "./platform-Cil_UtAQ.mjs";
import { k as j, l as Q, m as X, n as Y, o as J, S as $, c as ee, d as te } from "./index-CN7M4gwf.mjs";
import { deriveWrappedMetaKey as E, deriveTokenBridgeConfigKey as W, deriveAuthoritySignerKey as ne, deriveSenderAccountKey as ie, deriveMintAuthorityKey as se, deriveEndpointKey as ae } from "./index-Ap7250Gf.mjs";
import { P as i, L as l, S as re, T as oe, j as ce, B as x, aC as K, d as N, b as de, M as v, V as G, l as ue, _ as me } from "./unsignedTransaction-DCDxTFq8.mjs";
import { P as ge } from "./index-BU35GfG0.mjs";
import { p as L, u as fe, b as le } from "./web3-CUwFm9Lx.mjs";
const pe = {
  version: "0.1.0",
  name: "wormhole_gateway",
  instructions: [
    {
      name: "initialize",
      accounts: [
        {
          name: "authority",
          isMut: !0,
          isSigner: !0
        },
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tbtcMint",
          isMut: !1,
          isSigner: !1,
          docs: [
            "TBTC Program's mint PDA address bump is saved in this program's config. Ordinarily, we would",
            "not have to deserialize this account. But we do in this case to make sure the TBTC program",
            "has been initialized before this program."
          ]
        },
        {
          name: "wrappedTbtcMint",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "wrappedTbtcToken",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tokenBridgeSender",
          isMut: !1,
          isSigner: !1,
          docs: [
            "sign for transferring via Token Bridge program with a message."
          ]
        },
        {
          name: "systemProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "mintingLimit",
          type: "u64"
        }
      ]
    },
    {
      name: "changeAuthority",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "authority",
          isMut: !1,
          isSigner: !0
        },
        {
          name: "newAuthority",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: []
    },
    {
      name: "cancelAuthorityChange",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "authority",
          isMut: !1,
          isSigner: !0
        }
      ],
      args: []
    },
    {
      name: "takeAuthority",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "pendingAuthority",
          isMut: !1,
          isSigner: !0
        }
      ],
      args: []
    },
    {
      name: "updateGatewayAddress",
      accounts: [
        {
          name: "custodian",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "gatewayInfo",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "authority",
          isMut: !0,
          isSigner: !0
        },
        {
          name: "systemProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "args",
          type: {
            defined: "UpdateGatewayAddressArgs"
          }
        }
      ]
    },
    {
      name: "updateMintingLimit",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "authority",
          isMut: !1,
          isSigner: !0
        }
      ],
      args: [
        {
          name: "newLimit",
          type: "u64"
        }
      ]
    },
    {
      name: "receiveTbtc",
      accounts: [
        {
          name: "payer",
          isMut: !0,
          isSigner: !0
        },
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "postedVaa",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeClaim",
          isMut: !0,
          isSigner: !1,
          docs: [
            "transfer. By checking whether this account exists is a short-circuit way of bailing out",
            "early if this transfer has already been redeemed (as opposed to letting the Token Bridge",
            "instruction fail)."
          ]
        },
        {
          name: "wrappedTbtcToken",
          isMut: !0,
          isSigner: !1,
          docs: ["Custody account."]
        },
        {
          name: "wrappedTbtcMint",
          isMut: !0,
          isSigner: !1,
          docs: [
            "This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the",
            "custodian account."
          ]
        },
        {
          name: "tbtcMint",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "recipientToken",
          isMut: !0,
          isSigner: !1,
          docs: [
            "Token account for minted tBTC.",
            "",
            "NOTE: Because the recipient is encoded in the transfer message payload, we can check the",
            "authority from the deserialized VAA. But we should still check whether the authority is the",
            "zero address in access control."
          ]
        },
        {
          name: "recipient",
          isMut: !1,
          isSigner: !1,
          docs: ["be created for him."]
        },
        {
          name: "recipientWrappedToken",
          isMut: !0,
          isSigner: !1,
          docs: [
            "The gateway will create an associated token account for the recipient if it doesn't exist.",
            "",
            "NOTE: When the minting limit increases, the recipient can use this token account to mint",
            "tBTC using the deposit_wormhole_tbtc instruction."
          ]
        },
        {
          name: "tbtcConfig",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tbtcMinterInfo",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeConfig",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeRegisteredEmitter",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeWrappedAsset",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeMintAuthority",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "rent",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tbtcProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "associatedTokenProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "systemProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "messageHash",
          type: {
            array: ["u8", 32]
          }
        }
      ]
    },
    {
      name: "sendTbtcGateway",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "gatewayInfo",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "wrappedTbtcToken",
          isMut: !0,
          isSigner: !1,
          docs: ["Custody account."]
        },
        {
          name: "wrappedTbtcMint",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tbtcMint",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "senderToken",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "sender",
          isMut: !0,
          isSigner: !0
        },
        {
          name: "tokenBridgeConfig",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeWrappedAsset",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeTransferAuthority",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreBridgeData",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "coreMessage",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tokenBridgeCoreEmitter",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreEmitterSequence",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "coreFeeCollector",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "clock",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeSender",
          isMut: !1,
          isSigner: !1,
          docs: [
            "sign for transferring via Token Bridge program with a message."
          ]
        },
        {
          name: "rent",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "systemProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "args",
          type: {
            defined: "SendTbtcGatewayArgs"
          }
        }
      ]
    },
    {
      name: "sendTbtcWrapped",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "wrappedTbtcToken",
          isMut: !0,
          isSigner: !1,
          docs: ["Custody account."]
        },
        {
          name: "wrappedTbtcMint",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tbtcMint",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "senderToken",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "sender",
          isMut: !0,
          isSigner: !0
        },
        {
          name: "tokenBridgeConfig",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeWrappedAsset",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeTransferAuthority",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreBridgeData",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "coreMessage",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "tokenBridgeCoreEmitter",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreEmitterSequence",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "coreFeeCollector",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "clock",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "rent",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "coreBridgeProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "systemProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "args",
          type: {
            defined: "SendTbtcWrappedArgs"
          }
        }
      ]
    },
    {
      name: "depositWormholeTbtc",
      accounts: [
        {
          name: "custodian",
          isMut: !0,
          isSigner: !1,
          docs: [
            "NOTE: This account also acts as a minter for the TBTC program."
          ]
        },
        {
          name: "wrappedTbtcToken",
          isMut: !0,
          isSigner: !1,
          docs: [
            "This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA",
            "address is stored in the custodian account."
          ]
        },
        {
          name: "wrappedTbtcMint",
          isMut: !1,
          isSigner: !1,
          docs: [
            "This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the",
            "custodian account."
          ]
        },
        {
          name: "tbtcMint",
          isMut: !0,
          isSigner: !1,
          docs: [
            "This mint is owned by the TBTC program. This PDA address is stored in the custodian account."
          ]
        },
        {
          name: "recipientWrappedToken",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "recipientToken",
          isMut: !0,
          isSigner: !1
        },
        {
          name: "recipient",
          isMut: !1,
          isSigner: !0,
          docs: [
            "This program requires that the owner of the TBTC token account sign for TBTC being minted",
            "into his account."
          ]
        },
        {
          name: "tbtcConfig",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tbtcMinterInfo",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tokenProgram",
          isMut: !1,
          isSigner: !1
        },
        {
          name: "tbtcProgram",
          isMut: !1,
          isSigner: !1
        }
      ],
      args: [
        {
          name: "amount",
          type: "u64"
        }
      ]
    }
  ],
  accounts: [
    {
      name: "custodian",
      type: {
        kind: "struct",
        fields: [
          {
            name: "bump",
            type: "u8"
          },
          {
            name: "authority",
            type: "publicKey"
          },
          {
            name: "pendingAuthority",
            type: {
              option: "publicKey"
            }
          },
          {
            name: "tbtcMint",
            type: "publicKey"
          },
          {
            name: "wrappedTbtcMint",
            type: "publicKey"
          },
          {
            name: "wrappedTbtcToken",
            type: "publicKey"
          },
          {
            name: "tokenBridgeSender",
            type: "publicKey"
          },
          {
            name: "tokenBridgeSenderBump",
            type: "u8"
          },
          {
            name: "mintingLimit",
            type: "u64"
          },
          {
            name: "mintedAmount",
            type: "u64"
          }
        ]
      }
    },
    {
      name: "GatewayInfo",
      type: {
        kind: "struct",
        fields: [
          {
            name: "bump",
            type: "u8"
          },
          {
            name: "address",
            type: {
              array: ["u8", 32]
            }
          }
        ]
      }
    }
  ],
  types: [
    {
      name: "UpdateGatewayAddressArgs",
      type: {
        kind: "struct",
        fields: [
          {
            name: "chain",
            type: "u16"
          },
          {
            name: "address",
            type: {
              array: ["u8", 32]
            }
          }
        ]
      }
    },
    {
      name: "SendTbtcGatewayArgs",
      type: {
        kind: "struct",
        fields: [
          {
            name: "amount",
            type: "u64"
          },
          {
            name: "recipientChain",
            type: "u16"
          },
          {
            name: "recipient",
            type: {
              array: ["u8", 32]
            }
          },
          {
            name: "nonce",
            type: "u32"
          }
        ]
      }
    },
    {
      name: "SendTbtcWrappedArgs",
      type: {
        kind: "struct",
        fields: [
          {
            name: "amount",
            type: "u64"
          },
          {
            name: "recipientChain",
            type: "u16"
          },
          {
            name: "recipient",
            type: {
              array: ["u8", 32]
            }
          },
          {
            name: "arbiterFee",
            type: "u64"
          },
          {
            name: "nonce",
            type: "u32"
          }
        ]
      }
    }
  ],
  events: [
    {
      name: "WormholeTbtcReceived",
      fields: [
        {
          name: "receiver",
          type: "publicKey",
          index: !1
        },
        {
          name: "amount",
          type: "u64",
          index: !1
        }
      ]
    },
    {
      name: "WormholeTbtcSent",
      fields: [
        {
          name: "amount",
          type: "u64",
          index: !1
        },
        {
          name: "recipientChain",
          type: "u16",
          index: !1
        },
        {
          name: "gateway",
          type: {
            array: ["u8", 32]
          },
          index: !1
        },
        {
          name: "recipient",
          type: {
            array: ["u8", 32]
          },
          index: !1
        },
        {
          name: "arbiterFee",
          type: "u64",
          index: !1
        },
        {
          name: "nonce",
          type: "u32",
          index: !1
        }
      ]
    },
    {
      name: "WormholeTbtcDeposited",
      fields: [
        {
          name: "depositor",
          type: "publicKey",
          index: !1
        },
        {
          name: "amount",
          type: "u64",
          index: !1
        }
      ]
    },
    {
      name: "GatewayAddressUpdated",
      fields: [
        {
          name: "chain",
          type: "u16",
          index: !1
        },
        {
          name: "gateway",
          type: {
            array: ["u8", 32]
          },
          index: !1
        }
      ]
    },
    {
      name: "MintingLimitUpdated",
      fields: [
        {
          name: "mintingLimit",
          type: "u64",
          index: !1
        }
      ]
    }
  ],
  errors: [
    {
      code: 6016,
      name: "MintingLimitExceeded",
      msg: "Cannot mint more than the minting limit"
    },
    {
      code: 6032,
      name: "IsNotAuthority",
      msg: "Only custodian authority is permitted for this action"
    },
    {
      code: 6034,
      name: "IsNotPendingAuthority",
      msg: "Not valid pending authority to take authority"
    },
    {
      code: 6036,
      name: "NoPendingAuthorityChange",
      msg: "No pending authority"
    },
    {
      code: 6048,
      name: "ZeroRecipient",
      msg: "0x0 recipient not allowed"
    },
    {
      code: 6064,
      name: "NotEnoughWrappedTbtc",
      msg: "Not enough wormhole tBTC in the gateway to bridge"
    },
    {
      code: 6080,
      name: "ZeroAmount",
      msg: "Amount must not be 0"
    },
    {
      code: 6112,
      name: "TransferAlreadyRedeemed",
      msg: "Token Bridge transfer already redeemed"
    },
    {
      code: 6128,
      name: "InvalidEthereumTbtc",
      msg: "Token chain and address do not match Ethereum's tBTC"
    },
    {
      code: 6144,
      name: "NoTbtcTransferred",
      msg: "No tBTC transferred"
    },
    {
      code: 6160,
      name: "RecipientZeroAddress",
      msg: "0x0 receiver not allowed"
    },
    {
      code: 6176,
      name: "MintedAmountUnderflow",
      msg: "Not enough minted by the gateway to satisfy sending tBTC"
    },
    {
      code: 6178,
      name: "MintedAmountOverflow",
      msg: "Minted amount after deposit exceeds u64"
    }
  ]
};
function O(a) {
  return i.findProgramAddressSync([c.from("redeemer")], new i(a))[0];
}
function he(a, t) {
  const e = c.alloc(8);
  return e.writeBigUInt64LE(t), i.findProgramAddressSync([c.from("msg"), e], new i(a))[0];
}
function ye(a, t) {
  const e = c.alloc(2);
  return e.writeUInt16LE(p(t)), i.findProgramAddressSync([c.from("gateway-info"), e], new i(a))[0];
}
const T = new i("Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV");
function we() {
  return i.findProgramAddressSync([c.from("config")], T)[0];
}
function Se(a) {
  return i.findProgramAddressSync([c.from("minter-info"), a.toBuffer()], T)[0];
}
const B = new i("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
new i("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
const b = new i("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
new i("So11111111111111111111111111111111111111112");
new i("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");
class ke extends Error {
  constructor(t) {
    super(t);
  }
}
class Me extends ke {
  constructor() {
    super(...arguments), this.name = "TokenOwnerOffCurveError";
  }
}
const Te = l.struct([
  l.u32("mintAuthorityOption"),
  L("mintAuthority"),
  fe("supply"),
  l.u8("decimals"),
  le("isInitialized"),
  l.u32("freezeAuthorityOption"),
  L("freezeAuthority")
]);
Te.span;
async function M(a, t, e = !1, r = B, n = b) {
  if (!e && !i.isOnCurve(t.toBuffer()))
    throw new Me();
  const [s] = await i.findProgramAddress([t.toBuffer(), r.toBuffer(), a.toBuffer()], n);
  return s;
}
function Be(a, t, e, r, n = B, s = b) {
  return be(a, t, e, r, c.alloc(0), n, s);
}
function be(a, t, e, r, n, s = B, o = b) {
  const d = [
    { pubkey: a, isSigner: !0, isWritable: !0 },
    { pubkey: t, isSigner: !1, isWritable: !0 },
    { pubkey: e, isSigner: !1, isWritable: !1 },
    { pubkey: r, isSigner: !1, isWritable: !1 },
    { pubkey: re.programId, isSigner: !1, isWritable: !1 },
    { pubkey: s, isSigner: !1, isWritable: !1 }
  ];
  return new oe({
    keys: d,
    programId: o,
    data: n
  });
}
class A {
  network;
  chain;
  connection;
  contracts;
  gateway;
  tokenBridgeId;
  coreBridgeId;
  constructor(t, e, r, n) {
    if (this.network = t, this.chain = e, this.connection = r, this.contracts = n, this.network !== "Mainnet")
      throw new Error("TBTC is only supported on Mainnet");
    if (!this.contracts.tbtc)
      throw new Error("TBTC contract address is required");
    if (!this.contracts.tokenBridge)
      throw new Error("TokenBridge contract address is required");
    if (!this.contracts.coreBridge)
      throw new Error("CoreBridge contract address is required");
    this.gateway = new ge(pe, this.contracts.tbtc, {
      connection: r
    }), this.tokenBridgeId = new i(this.contracts.tokenBridge), this.coreBridgeId = new i(this.contracts.coreBridge);
  }
  static async fromRpc(t, e) {
    const [r, n] = await ce.chainFromRpc(t), s = e[n];
    if (s.network !== r)
      throw new Error(`Network mismatch: ${s.network} != ${r}`);
    return new A(r, n, t, s.contracts);
  }
  async *transfer(t, e, r) {
    const n = new x(t).unwrap(), s = O(this.gateway.programId), { tbtcMint: o, wrappedTbtcToken: d, wrappedTbtcMint: u } = await this.gateway.account.custodian.fetch(s), h = E(this.tokenBridgeId, u), m = W(this.tokenBridgeId), g = ne(this.tokenBridgeId), C = j(this.coreBridgeId), { sequence: y } = await Q(this.connection, this.tokenBridgeId, this.coreBridgeId), w = he(this.gateway.programId, y), S = X(this.coreBridgeId), f = Y(this.tokenBridgeId), k = J(f, this.coreBridgeId), R = ye(this.gateway.programId, e.chain), U = ie(this.gateway.programId), P = {
      amount: new K.BN(r.toString()),
      recipientChain: p(e.chain),
      recipient: [...e.address.toUniversalAddress().toUint8Array()],
      nonce: 0
    }, V = await M(o, n), D = H.get(this.network, e.chain), I = {
      custodian: s,
      wrappedTbtcToken: d,
      wrappedTbtcMint: u,
      tbtcMint: o,
      senderToken: V,
      sender: n,
      tokenBridgeConfig: m,
      tokenBridgeWrappedAsset: h,
      tokenBridgeTransferAuthority: g,
      coreBridgeData: S,
      coreMessage: w,
      tokenBridgeCoreEmitter: f,
      coreEmitterSequence: k,
      coreFeeCollector: C,
      clock: de,
      rent: N,
      tokenBridgeProgram: this.tokenBridgeId,
      coreBridgeProgram: this.coreBridgeId
    }, q = D ? await this.gateway.methods.sendTbtcGateway({ ...P }).accounts({
      ...I,
      gatewayInfo: R,
      tokenBridgeSender: U
    }).instruction() : await this.gateway.methods.sendTbtcWrapped({
      ...P,
      arbiterFee: new K.BN(0)
    }).accounts(I).instruction(), { blockhash: _ } = await this.connection.getLatestBlockhash(), F = v.compile({
      instructions: [q],
      payerKey: n,
      recentBlockhash: _
    }), z = new G(F);
    yield this.createUnsignedTransaction({ transaction: z }, "TBTCBridge.Send");
  }
  async *redeem(t, e) {
    if (e.payloadName !== "GatewayTransfer")
      throw new Error("Invalid VAA payload");
    yield* new $(this.network, this.chain, this.connection, this.contracts).postVaa(t, e);
    const n = [], s = new x(t).unwrap(), o = e.payload.payload.recipient.toNative(this.chain).unwrap(), d = O(this.gateway.programId), { tbtcMint: u, wrappedTbtcToken: h, wrappedTbtcMint: m } = await this.gateway.account.custodian.fetch(d), g = await M(u, o);
    await this.connection.getAccountInfo(g) || n.push(Be(s, g, o, u));
    const y = E(this.tokenBridgeId, m), w = await M(m, o);
    n.push(await this.gateway.methods.receiveTbtc([...e.hash]).accounts({
      payer: s,
      custodian: d,
      postedVaa: te(this.coreBridgeId, c.from(e.hash)),
      tokenBridgeClaim: ee(this.tokenBridgeId, e.emitterAddress.toUint8Array(), p(e.emitterChain), e.sequence),
      wrappedTbtcToken: h,
      wrappedTbtcMint: m,
      tbtcMint: u,
      recipientToken: g,
      recipient: o,
      recipientWrappedToken: w,
      tbtcConfig: we(),
      tbtcMinterInfo: Se(d),
      tokenBridgeConfig: W(this.tokenBridgeId),
      tokenBridgeRegisteredEmitter: ae(this.tokenBridgeId, p(e.emitterChain), e.emitterAddress.toUint8Array()),
      tokenBridgeWrappedAsset: y,
      tokenBridgeMintAuthority: se(this.tokenBridgeId),
      rent: N,
      tbtcProgram: T,
      tokenBridgeProgram: this.tokenBridgeId,
      coreBridgeProgram: this.coreBridgeId
    }).instruction());
    const { blockhash: S } = await this.connection.getLatestBlockhash(), f = v.compile({
      instructions: n,
      payerKey: s,
      recentBlockhash: S
    }), k = new G(f);
    yield this.createUnsignedTransaction({ transaction: k }, "TBTCBridge.Send");
  }
  createUnsignedTransaction(t, e) {
    return new ue(t, this.network, this.chain, e, !1);
  }
}
Z(me, "TBTCBridge", A);
export {
  A as SolanaTBTCBridge
};
