Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/dataunion/Contracts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCreate2Address, isAddress } from '@ethersproject/address'
import { arrayify, hexZeroPad } from '@ethersproject/bytes'
import { Contract } from '@ethersproject/contracts'
import { Contract, ContractReceipt } from '@ethersproject/contracts'
import { keccak256 } from '@ethersproject/keccak256'
import { defaultAbiCoder } from '@ethersproject/abi'
import { verifyMessage } from '@ethersproject/wallet'
Expand Down Expand Up @@ -218,14 +218,14 @@ export class Contracts {
return trAMB
}

async payForSignatureTransport(tr: { events: any[] }, options: { pollingIntervalMs?: number, retryTimeoutMs?: number } = {}) {
async payForSignatureTransport(tr: ContractReceipt, options: { pollingIntervalMs?: number, retryTimeoutMs?: number } = {}) {
const {
pollingIntervalMs = 1000,
retryTimeoutMs = 60000,
} = options
log(`Got receipt, filtering UserRequestForSignature from ${tr.events.length} events...`)
log(`Got receipt, filtering UserRequestForSignature from ${tr.events!.length} events...`)
// event UserRequestForSignature(bytes32 indexed messageId, bytes encodedData);
const sigEventArgsArray = tr.events.filter((e: Todo) => e.event === 'UserRequestForSignature').map((e: Todo) => e.args)
const sigEventArgsArray = tr.events!.filter((e: Todo) => e.event === 'UserRequestForSignature').map((e: Todo) => e.args)
if (sigEventArgsArray.length < 1) {
throw new Error("No UserRequestForSignature events emitted from withdraw transaction, can't transport withdraw to mainnet")
}
Expand Down Expand Up @@ -309,7 +309,7 @@ export class Contracts {
duName,
ethersOptions
)
const tr = await tx.wait(confirmations)
await tx.wait(confirmations)

log(`Data Union "${duName}" (mainnet: ${duMainnetAddress}, sidechain: ${duSidechainAddress}) deployed to mainnet, waiting for side-chain...`)
await until(
Expand All @@ -320,8 +320,6 @@ export class Contracts {

const dataUnion = new Contract(duMainnetAddress, dataUnionMainnetABI, mainnetWallet)
// @ts-expect-error
dataUnion.deployTxReceipt = tr
// @ts-expect-error
dataUnion.sidechain = new Contract(duSidechainAddress, dataUnionSidechainABI, sidechainProvider)
return dataUnion

Expand Down
8 changes: 4 additions & 4 deletions src/dataunion/DataUnion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TransactionReceipt, TransactionResponse } from '@ethersproject/provider
import debug from 'debug'
import { Contracts } from './Contracts'
import StreamrClient from '../StreamrClient'
import { EthereumAddress, Todo } from '../types'
import { EthereumAddress } from '../types'
import { until, getEndpointUrl } from '../utils'
import authFetch from '../rest/authFetch'

Expand Down Expand Up @@ -296,7 +296,7 @@ export class DataUnion {
return +adminFeeBN.toString() / 1e18
}

async getAdminAddress(): Promise<Todo> {
async getAdminAddress(): Promise<EthereumAddress> {
const duMainnet = this.getContracts().getMainnetContractReadOnly(this.contractAddress)
return duMainnet.owner()
}
Expand Down Expand Up @@ -446,7 +446,7 @@ export class DataUnion {
/**
* Admin: set admin fee (between 0.0 and 1.0) for the data union
*/
async setAdminFee(newFeeFraction: number): Promise<Todo> {
async setAdminFee(newFeeFraction: number): Promise<TransactionReceipt> {
if (newFeeFraction < 0 || newFeeFraction > 1) {
throw new Error('newFeeFraction argument must be a number between 0...1, got: ' + newFeeFraction)
}
Expand Down Expand Up @@ -539,7 +539,7 @@ export class DataUnion {
// template for withdraw functions
// client could be replaced with AMB (mainnet and sidechain)
private async _executeWithdraw(
getWithdrawTxFunc: () => Promise<Todo & { events: any[] }>,
getWithdrawTxFunc: () => Promise<TransactionResponse>,
recipientAddress: EthereumAddress,
options: DataUnionWithdrawOptions = {}
): Promise<TransactionReceipt> {
Expand Down