@test-org122/hypernet-core
Version:
Hypernet Core. Represents the SDK for running the Hypernet Protocol.
36 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EthersBlockchainUtils = void 0;
const ethers_1 = require("ethers");
const neverthrow_1 = require("neverthrow");
const vector_types_1 = require("@connext/vector-types");
const vector_contracts_1 = require("@connext/vector-contracts");
class EthersBlockchainUtils {
constructor(blockchainProvider) {
this.blockchainProvider = blockchainProvider;
// The ERC20Abi from Vector does not include the name() function, so we will roll our own
this.erc20Abi = Object.assign([], vector_types_1.ERC20Abi);
this.erc20Abi.push("function name() view returns (string)");
}
verifyTypedData(domain, types, value, signature) {
return ethers_1.ethers.utils.verifyTypedData(domain, types, value, signature);
}
erc20Transfer(assetAddress, channelAddress, amount) {
return this.blockchainProvider.getSigner().andThen((signer) => {
const tokenContract = new ethers_1.Contract(assetAddress, this.erc20Abi, signer);
return neverthrow_1.ResultAsync.fromPromise(tokenContract.transfer(channelAddress, amount), (err) => {
return err;
});
});
}
mintToken(amount, to) {
return this.blockchainProvider.getSigner().andThen((signer) => {
const testTokenContract = new ethers_1.Contract("0x9FBDa871d559710256a2502A2517b794B482Db40", vector_contracts_1.artifacts.TestToken.abi, signer);
return neverthrow_1.ResultAsync.fromPromise(testTokenContract.mint(to, amount), (e) => {
return e;
});
});
}
}
exports.EthersBlockchainUtils = EthersBlockchainUtils;
//# sourceMappingURL=EthersBlockchainUtils.js.map