Skip to content

Commit

Permalink
Created protected function to get vthe signer according to the sdk fr…
Browse files Browse the repository at this point in the history
…om config.
  • Loading branch information
mariacarmina committed Oct 14, 2024
1 parent 87e1f9a commit e45bad9
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 293 deletions.
21 changes: 5 additions & 16 deletions src/contracts/AccessList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { sendTx } from '../utils'
import { AbiItem, ReceiptOrEstimate } from '../@types'
import { Config } from '../config'
import { SmartContractWithAddress } from './SmartContractWithAddress'
import * as sapphire from '@oasisprotocol/sapphire-paratime'

export class AccessListContract extends SmartContractWithAddress {
public abiEnterprise: AbiItem[]
Expand Down Expand Up @@ -99,9 +98,7 @@ export class AccessListContract extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.mint,
user,
Expand All @@ -126,9 +123,7 @@ export class AccessListContract extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.batchMint,
users,
Expand All @@ -151,9 +146,7 @@ export class AccessListContract extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.burn,
tokenId
Expand All @@ -175,9 +168,7 @@ export class AccessListContract extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.transferOwnership,
newOwner
Expand All @@ -197,9 +188,7 @@ export class AccessListContract extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.renounceOwnership
)
Expand Down
9 changes: 2 additions & 7 deletions src/contracts/AccessListFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import AccessListFactory from '@oceanprotocol/contracts/artifacts/contracts/acce
import { generateDtName, sendTx, getEventFromTx, ZERO_ADDRESS } from '../utils'
import { AbiItem, ReceiptOrEstimate } from '../@types'
import { SmartContractWithAddress } from './SmartContractWithAddress'
import * as sapphire from '@oasisprotocol/sapphire-paratime'

/**
* Provides an interface for Access List Factory contract
Expand Down Expand Up @@ -71,9 +70,7 @@ export class AccesslistFactory extends SmartContractWithAddress {
try {
const tx = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.deployAccessListContract,
nameAccessList,
Expand Down Expand Up @@ -149,9 +146,7 @@ export class AccesslistFactory extends SmartContractWithAddress {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
this.contract.functions.changeTemplateAddress,
templateAddress
Expand Down
69 changes: 17 additions & 52 deletions src/contracts/Datatoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import { Nft } from './NFT'
import { Config } from '../config'
import { SmartContract } from './SmartContract'
import * as sapphire from '@oasisprotocol/sapphire-paratime'

export class Datatoken extends SmartContract {
public abiEnterprise: AbiItem[]
Expand Down Expand Up @@ -71,9 +70,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.approve,
spender,
Expand Down Expand Up @@ -126,9 +123,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.createFixedRate,
fixedRateParams.fixedRateAddress,
Expand Down Expand Up @@ -187,9 +182,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.createDispenser,
dispenserAddress,
Expand Down Expand Up @@ -232,9 +225,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.mint,
toAddress || address,
Expand Down Expand Up @@ -271,9 +262,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.addMinter,
minter
Expand Down Expand Up @@ -307,9 +296,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.removeMinter,
minter
Expand Down Expand Up @@ -343,9 +330,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.addPaymentManager,
paymentManager
Expand Down Expand Up @@ -379,9 +364,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.removePaymentManager,
paymentManager
Expand Down Expand Up @@ -423,9 +406,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.setPaymentCollector,
paymentCollector
Expand Down Expand Up @@ -486,9 +467,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.transfer,
toAddress,
Expand Down Expand Up @@ -533,9 +512,7 @@ export class Datatoken extends SmartContract {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.startOrder,
consumer,
Expand Down Expand Up @@ -568,9 +545,7 @@ export class Datatoken extends SmartContract {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.reuseOrder,
orderTxId,
Expand Down Expand Up @@ -604,9 +579,7 @@ export class Datatoken extends SmartContract {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.buyFromFreAndOrder,
orderParams,
Expand Down Expand Up @@ -638,9 +611,7 @@ export class Datatoken extends SmartContract {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.buyFromDispenserAndOrder,
orderParams,
Expand Down Expand Up @@ -676,9 +647,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.setData,
valueHex
Expand Down Expand Up @@ -709,9 +678,7 @@ export class Datatoken extends SmartContract {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.cleanPermissions
)
Expand Down Expand Up @@ -877,9 +844,7 @@ export class Datatoken extends SmartContract {
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.setPublishingMarketFee,
publishMarketFeeAddress,
Expand Down
13 changes: 3 additions & 10 deletions src/contracts/Datatoken4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AbiItem, ReceiptOrEstimate } from '../@types'
import { AccessListContract } from './AccessList'
import { Config } from '../config'
import { sendTx } from '../utils'
import * as sapphire from '@oasisprotocol/sapphire-paratime'

export class Datatoken4 extends Datatoken {
public accessList: AccessListContract
Expand Down Expand Up @@ -85,9 +84,7 @@ export class Datatoken4 extends Datatoken {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.functions.setAllowListContract,
address
Expand Down Expand Up @@ -121,9 +118,7 @@ export class Datatoken4 extends Datatoken {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.functions.setDenyListContract,
address
Expand Down Expand Up @@ -154,9 +149,7 @@ export class Datatoken4 extends Datatoken {

const trxReceipt = await sendTx(
estGas,
this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
: this.signer,
this.getSignerAccordingSdk(),
this.config?.gasFeeMultiplier,
dtContract.functions.setFilesObject,
this.fileObject
Expand Down
Loading

0 comments on commit e45bad9

Please sign in to comment.