@nomad-xyz/sdk-bridge
Version:
98 lines • 3.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BridgeContracts = void 0;
const multi_provider_1 = require("@nomad-xyz/multi-provider");
const contracts_bridge_1 = require("@nomad-xyz/contracts-bridge");
class BridgeContracts extends multi_provider_1.Contracts {
constructor(context, domain, conf) {
super(context, domain, conf);
this.conf = conf;
}
get deployHeight() {
return this.conf.deployHeight;
}
/**
* Get the BridgeRouter associated with this bridge.
*
* WARNING: do not hold references to this contract, as it will not be
* reconnected in the event the chain connection changes.
*
* @throws if there is no connection for this network
*/
get bridgeRouter() {
if (!this.connection)
throw new multi_provider_1.NoProviderError(this.context, this.domain);
return contracts_bridge_1.BridgeRouter__factory.connect(this.conf.bridgeRouter.proxy, this.connection);
}
/**
* Get the TokenRegistry associated with this bridge.
*
* WARNING: do not hold references to this contract, as it will not be
* reconnected in the event the chain connection changes.
*
* @throws if there is no connection for this network
*/
get tokenRegistry() {
if (!this.connection)
throw new multi_provider_1.NoProviderError(this.context, this.domain);
return contracts_bridge_1.TokenRegistry__factory.connect(this.conf.tokenRegistry.proxy, this.connection);
}
/**
* Get the EthHelper associated with this bridge (if any).
*
* WARNING: do not hold references to this contract, as it will not be
* reconnected in the event the chain connection changes.
*
* @throws if there is no connection for this network
*/
get ethHelper() {
if (!this.connection)
throw new multi_provider_1.NoProviderError(this.context, this.domain);
if (!this.conf.ethHelper)
return;
return contracts_bridge_1.ETHHelper__factory.connect(this.conf.ethHelper, this.connection);
}
/**
* Get the Accountant associated with this bridge (if any).
*
* WARNING: do not hold references to this contract, as it will not be
* reconnected in the event the chain connection changes.
*
* @throws if there is no connection for this network
*/
get accountant() {
if (!this.connection)
throw new multi_provider_1.NoProviderError(this.context, this.domain);
if (!this.conf.accountant)
return;
return contracts_bridge_1.NftAccountant__factory.connect(this.conf.accountant.proxy, this.connection);
}
/**
* Get the info associated with the NFT ID, if any.
*
* @param id The numerical NFT ID
* @throws if there is no connection for this network
*/
async nftInfo(id) {
const info = await this.accountant?.info(id);
if (!info || info._originalAmount.isZero()) {
return;
}
return info;
}
/**
* Get the info associated with the NFT ID, if any.
*
* @param token The numerical NFT ID
* @throws if there is no connection for this network
*/
async assetInfo(token) {
const info = await this.accountant?.assetInfo(token);
if (!info || info._totalAffected.isZero()) {
return;
}
return info;
}
}
exports.BridgeContracts = BridgeContracts;
//# sourceMappingURL=BridgeContracts.js.map