Skip to content

Commit

Permalink
Even better
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Jan 24, 2023
1 parent bdf54a6 commit 7d9a585
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
53 changes: 27 additions & 26 deletions libs/src/services/dataContracts/EntityManagerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,7 @@ export class EntityManagerClient extends ContractClient {
metadataMultihash,
nonce
)
const nethermindSignatureData =
signatureSchemas.generators.getManageEntityData(
1056800, // TODO get from chain after web3Manager uses nethermind only
nethermindContractAddress,
userId,
entityType,
entityId,
action,
metadataMultihash,
nonce
)

let sig
let nethermindSig
if (privateKey) {
sig = sigUtil.signTypedData(
SafeBuffer.from(privateKey, 'hex') as unknown as Buffer,
Expand All @@ -139,9 +126,6 @@ export class EntityManagerClient extends ContractClient {
)
} else {
sig = await this.web3Manager.signTypedData(signatureData)
nethermindSig = await this.web3Manager.signTypedData(
nethermindSignatureData
)
}
const method = await this.getMethod(
'manageEntity',
Expand All @@ -154,17 +138,34 @@ export class EntityManagerClient extends ContractClient {
sig
)

const nethermindMethod = await this.getMethod(
'manageEntity',
userId,
entityType,
entityId,
action,
metadataMultihash,
nonce,
nethermindSig
)
let nethermindMethod
if (nethermindContractAddress) {
const nethermindSignatureData =
signatureSchemas.generators.getManageEntityData(
1056800, // TODO get from chain after web3Manager uses nethermind only
nethermindContractAddress,
userId,
entityType,
entityId,
action,
metadataMultihash,
nonce
)
const nethermindSig = await this.web3Manager.signTypedData(
nethermindSignatureData
)

nethermindMethod = await this.getMethod(
'manageEntity',
userId,
entityType,
entityId,
action,
metadataMultihash,
nonce,
nethermindSig
)
}
const tx = await this.web3Manager.sendTransaction(
method,
this.contractRegistryKey,
Expand Down
2 changes: 1 addition & 1 deletion libs/src/services/identity/IdentityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class IdentityService {
gasLimit: number,
handle: string | null = null,
nethermindContractAddress: string | null | undefined,
nethermindEncodedAbi: string
nethermindEncodedAbi: string | undefined
): Promise<{ receipt: TransactionReceipt }> {
return await this._makeRequest({
url: '/relay',
Expand Down
2 changes: 1 addition & 1 deletion libs/src/services/web3Manager/Web3Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class Web3Manager {
})
} else {
const encodedABI = contractMethod.encodeABI()
const nethermindEncodedAbi = nethermindContractMethod!.encodeABI()
const nethermindEncodedAbi = nethermindContractMethod?.encodeABI()
const response = await retry(
async (bail) => {
try {
Expand Down

0 comments on commit 7d9a585

Please sign in to comment.