diff --git a/package.json b/package.json index 5b21b65..d8a2075 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tonomy-communication", - "version": "1.5.0-development.2", + "version": "1.6.0", "description": "", "author": "Rebal Alhaqash", "private": true, @@ -31,7 +31,8 @@ "@nestjs/platform-socket.io": "^10.2.3", "@nestjs/swagger": "^7.1.10", "@nestjs/websockets": "^10.2.3", - "@tonomy/tonomy-id-sdk": "0.37.0-development.1", + "@safe-global/sdk-starter-kit": "^3.0.2", + "@tonomy/tonomy-id-sdk": "0.37.0-development.2", "axios": "1.9.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", diff --git a/src/baseTransferMonitor/baseTransferMonitor.service.ts b/src/baseTransferMonitor/baseTransferMonitor.service.ts index dda9bb5..15d1e0d 100644 --- a/src/baseTransferMonitor/baseTransferMonitor.service.ts +++ b/src/baseTransferMonitor/baseTransferMonitor.service.ts @@ -41,7 +41,17 @@ export class BaseTokenTransferMonitorService try { const txHash: string = event.log.transactionHash; - if (to !== settings.config.baseMintBurnAddress) { + this.logger.debug( + `Event transaction hash: tx ${txHash}, to ${to} from ${from} amount ${amount} baseMintBurnAddress ${settings.config.baseMintBurnAddress} ${ + to.toLowerCase() !== + settings.config.baseMintBurnAddress?.toLowerCase() + } `, + ); + + if ( + to.toLowerCase() !== + settings.config.baseMintBurnAddress?.toLowerCase() + ) { return; } diff --git a/src/communication/communication.service.ts b/src/communication/communication.service.ts index bc94dcb..ea1efc4 100644 --- a/src/communication/communication.service.ts +++ b/src/communication/communication.service.ts @@ -19,16 +19,18 @@ import { randomString, waitForEvmTrxFinalization, waitForTonomyTrxFinalization, - sendSafeWalletTransfer, + prepareSafeWalletTransfer, createAntelopeDid, FaucetTokenMessage, assetToDecimal, + getSigner, } from '@tonomy/tonomy-id-sdk'; import { tonomySigner } from '../signer'; import { ethers } from 'ethers'; import settings from '../settings'; import { Decimal } from 'decimal.js'; import Debug from 'debug'; +import { createSafeClient } from '@safe-global/sdk-starter-kit'; const debug = Debug('tonomy-communication:communication.service'); @@ -196,10 +198,18 @@ export class CommunicationService { if (settings.env === 'production') { // Need to do a more complicated DAO transaction... - const safeClientResult = await sendSafeWalletTransfer( + const transactions = await prepareSafeWalletTransfer( baseAddress, ethAmount, ); + const safeClient = await createSafeClient({ + provider: getSettings().baseRpcUrl, + signer: getSettings().basePrivateKey, + safeAddress: getSettings().baseMintBurnAddress, // This is a nested safe in production + apiKey: getSettings().safeApiKey, + }); + + const safeClientResult = await safeClient.send({ transactions }); const trxHash = safeClientResult.transactions?.ethereumTxHash; if (!trxHash) { @@ -215,7 +225,8 @@ export class CommunicationService { `[Swap T->B: ${loggerId}]: Safe wallet transfer to Base address ${baseAddress} submitted with transaction hash ${trxHash}`, ); } else { - const mintTrx = await getBaseTokenContract().transfer( + const signer = getSigner(); + const mintTrx = await getBaseTokenContract(signer).transfer( baseAddress, ethAmount, ); diff --git a/src/main.ts b/src/main.ts index a1657cf..f6c4e92 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,8 @@ setSettings({ baseNetwork: settings.config.baseNetwork, baseRpcUrl: settings.config.baseRpcUrl, baseTokenAddress: settings.config.baseTokenAddress, + baseMintBurnAddress: settings.config.baseMintBurnAddress, + safeApiKey: settings.secrets.safeApiKey, }); async function bootstrap() { diff --git a/yarn.lock b/yarn.lock index a21e669..88e12d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3730,12 +3730,11 @@ __metadata: languageName: node linkType: hard -"@tonomy/tonomy-id-sdk@npm:0.37.0-development.1": - version: 0.37.0-development.1 - resolution: "@tonomy/tonomy-id-sdk@npm:0.37.0-development.1" +"@tonomy/tonomy-id-sdk@npm:0.37.0-development.2": + version: 0.37.0-development.2 + resolution: "@tonomy/tonomy-id-sdk@npm:0.37.0-development.2" dependencies: "@consento/sync-randombytes": "npm:^1.0.5" - "@safe-global/sdk-starter-kit": "npm:^3.0.2" "@tonomy/antelope-did-resolver": "npm:^0.10.0" "@veramo/core": "npm:^6.0.0" "@veramo/credential-w3c": "npm:^6.0.0" @@ -3761,7 +3760,7 @@ __metadata: typeorm: "npm:0.3.22" universal-base64url: "npm:^1.1.0" web-did-resolver: "npm:^2.0.27" - checksum: 10c0/d57e8bae046e9a573a56b5e4b36dca2d3bb5afd33f105b1509ec143af7672499f36c05f94e7adbdf1d796edec61e12ba6506f20c15b8fd35f97c238d9a0c4d17 + checksum: 10c0/9aeb510ac542e34b3631e7a7a3ff8e5173bb9810b232053f9d32c0c1f5434a8ec49b3407f2709b06aea0174bb6497473da185231831901967232688f4620df4b languageName: node linkType: hard @@ -13789,8 +13788,9 @@ __metadata: "@nestjs/swagger": "npm:^7.1.10" "@nestjs/testing": "npm:^10.2.3" "@nestjs/websockets": "npm:^10.2.3" + "@safe-global/sdk-starter-kit": "npm:^3.0.2" "@semantic-release/git": "npm:^10.0.1" - "@tonomy/tonomy-id-sdk": "npm:0.37.0-development.1" + "@tonomy/tonomy-id-sdk": "npm:0.37.0-development.2" "@types/eslint__js": "npm:^8.42.3" "@types/express": "npm:^4.17.13" "@types/jest": "npm:^29.5.14"