Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function sendRunlogTransaction({
runLogAddress,
linkTokenAddress,
chainlinkUrl,
echoServerUrl,
}: Args) {
const provider = createProvider()
const signer = provider.getSigner(DEVNET_ADDRESS)
const runLogFactory = new RunLogFactory(signer)
const linkTokenFactory = new contract.LinkTokenFactory(signer)
const runLog = runLogFactory.attach(runLogAddress)
const linkToken = linkTokenFactory.attach(linkTokenAddress)
// transfer link to runlog address
const linkAmount = ethers.utils.parseEther('1000')
try {
await linkToken.transfer(runLog.address, linkAmount, {
gasLimit: 100000,
})
} catch (error) {
console.error('Error transferring link to RunLog')
throw Error(error)
}
console.log(`Transferred ${linkAmount} to RunLog at: ${runLog.address}`)
requestDigest: ethers.utils.keccak256(
ethers.utils.toUtf8Bytes(normalizedRequest),
),
}
const sig = ethers.utils.splitSignature(oracleSignature)
if (!sig.v) {
throw Error(`Could not extract v from signature`)
}
const oracleSignatures: OracleSignatures = {
vs: [sig.v],
rs: [sig.r],
ss: [sig.s],
}
const encodedSignatures = t.coordinator.encodeOracleSignatures(
oracleSignatures,
)
const said = t.coordinator.generateSAID(sa)
const encodedSA = t.coordinator.encodeServiceAgreement(sa)
const ssaid = await coordinator.getId(encodedSA)
if (said != ssaid) {
throw Error(`sAId mismatch. javascript: ${said} solidity: ${ssaid}`)
}
console.log('Initiating service agreement...')
const recoveredAddresss = ethers.utils.recoverAddress(said, sig)
console.log({
recoveredAddresss,
expectedAddress,
const sig = ethers.utils.splitSignature(oracleSignature)
if (!sig.v) {
throw Error(`Could not extract v from signature`)
}
const oracleSignatures: OracleSignatures = {
vs: [sig.v],
rs: [sig.r],
ss: [sig.s],
}
const encodedSignatures = t.coordinator.encodeOracleSignatures(
oracleSignatures,
)
const said = t.coordinator.generateSAID(sa)
const encodedSA = t.coordinator.encodeServiceAgreement(sa)
const ssaid = await coordinator.getId(encodedSA)
if (said != ssaid) {
throw Error(`sAId mismatch. javascript: ${said} solidity: ${ssaid}`)
}
console.log('Initiating service agreement...')
const recoveredAddresss = ethers.utils.recoverAddress(said, sig)
console.log({
recoveredAddresss,
expectedAddress,
oracleSignature,
...sig,
})
const tx = await coordinator.initiateServiceAgreement(
const sig = ethers.utils.splitSignature(oracleSignature)
if (!sig.v) {
throw Error(`Could not extract v from signature`)
}
const oracleSignatures: OracleSignatures = {
vs: [sig.v],
rs: [sig.r],
ss: [sig.s],
}
const encodedSignatures = t.coordinator.encodeOracleSignatures(
oracleSignatures,
)
const said = t.coordinator.generateSAID(sa)
const encodedSA = t.coordinator.encodeServiceAgreement(sa)
const ssaid = await coordinator.getId(encodedSA)
if (said != ssaid) {
throw Error(`sAId mismatch. javascript: ${said} solidity: ${ssaid}`)
}
console.log('Initiating service agreement...')
const recoveredAddresss = ethers.utils.recoverAddress(said, sig)
console.log({
recoveredAddresss,
expectedAddress,
oracleSignature,
...sig,
})
export async function deployLinkTokenContract(): Promise<
contract.Instance
> {
const provider = createProvider()
const signer = provider.getSigner(DEVNET_ADDRESS)
if (process.env.LINK_TOKEN_ADDRESS) {
console.log(
`LinkToken already deployed at: ${process.env.LINK_TOKEN_ADDRESS}, fetching contract...`,
)
const factory = new contract.LinkToken__factory(signer)
const linkToken = factory.attach(process.env.LINK_TOKEN_ADDRESS)
console.log(`Deployed LinkToken at: ${linkToken.address}`)
return linkToken
}
const linkToken = await deployContract({
Factory: contract.LinkToken__factory,
name: 'LinkToken',
signer,
})
return linkToken
}