@orca-so/whirlpool-sdk
Version:
Whirlpool SDK for the Orca protocol.
50 lines (49 loc) • 2.29 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WhirlpoolContext = void 0;
const sdk = __importStar(require("@orca-so/whirlpool-client-sdk"));
const account_fetcher_1 = require("./accounts/account-fetcher");
const programs_1 = require("./constants/programs");
const public_1 = require("./constants/public");
/**
* Context object containing information applicable to Whirlpools
* of a specific program & config space.
*
* // TODO: This class, is meant to be the same as client-sdk/WhirlpoolContext.
* We'll merge the two when both SDKs when we are ready.
*/
class WhirlpoolContext {
constructor(provider, configAddress, network, // TODO: Why custom enum? Are there other networks?
programId) {
const derivedNetwork = network || public_1.defaultNetwork;
const derivedPid = programId || (0, programs_1.getWhirlpoolProgramId)(derivedNetwork);
const clientCtx = sdk.WhirlpoolContext.withProvider(provider, derivedPid);
this.connection = clientCtx.connection;
this.wallet = clientCtx.provider.wallet;
this.opts = provider.opts;
this.program = clientCtx.program;
this.provider = provider;
this.configAddress = configAddress || (0, programs_1.getWhirlpoolsConfig)(derivedNetwork);
this.accountFetcher = new account_fetcher_1.AccountFetcher(this.connection);
}
}
exports.WhirlpoolContext = WhirlpoolContext;
;