@ingocollatz/sdk-web3-adapter
Version:
65 lines • 2.95 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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.CirclesSdkWeb3Factory = void 0;
const protocol_kit_1 = __importStar(require("@safe-global/protocol-kit"));
const sdk_1 = require("@ingocollatz/sdk");
const web3abiEncoder_1 = require("./web3abiEncoder");
/**
* CirclesSdkWeb3Factory provides factory methods to create instances of the CirclesSdk.
*
* This class offers utility methods specifically tailored for use with the Web3.js library.
* It's designed to simplify the creation of CirclesSdk instances, abstracting away some
* of the setup and initialization complexities with the Web3.js library.
*/
class CirclesSdkWeb3Factory {
/**
* Creates an instance of the CirclesSdk using an existing Safe and Web3.js.
*
* This method initializes the Circles SDK using an existing Safe and the Web3.js library
* for interactions with Ethereum.
*
* @param web3 - An instance of the Web3.js library.
* @param signerAddress - Ethereum address that will be used for signing transactions
* using the Web3.js library.
* @param safeAddress - Ethereum address of an existing Safe which will be utilized
* by the Circles SDK.
*
* @returns Promise<CirclesSdk> - A promise that resolves to an initialized instance of the CirclesSdk.
*/
static async withExistingSafe(web3, signerAddress, safeAddress) {
const abiEncoder = new web3abiEncoder_1.Web3AbiEncoder(web3);
const safe = await protocol_kit_1.default.create({
ethAdapter: new protocol_kit_1.Web3Adapter({
web3: web3,
signerAddress: signerAddress,
}),
safeAddress: safeAddress,
});
return new sdk_1.CirclesSdk(safe, abiEncoder);
}
}
exports.CirclesSdkWeb3Factory = CirclesSdkWeb3Factory;
//# sourceMappingURL=web3Factory.js.map