Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Euphoria #127

Merged
merged 12 commits into from
Sep 22, 2023
19 changes: 9 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
USE_HOROSCOPE=true

# Database
DB_HOST=
DB_PORT=
DB_USERNAME=
Expand All @@ -7,21 +10,17 @@ DB_DATABASE=
# SWAGGER
SWAGGER_PATH=/api

# simulate
SYS_MNEMONIC=

# ENVIRONMENT
NODE_ENV=development
#keybase
KEYBASE=

#DEFAULT VALIDATOR IMG
DEFAULT_VALIDATOR_IMG=

# jwt
JWT_SECRET=
# 24 hours
JWT_EXPIRATION=86400s

SYS_MNEMONIC=

PREFIX_NETWORK=

INDEXER_URL=
REDIS_URL=
REDIS_PORT=
REDIS_DB=
2 changes: 2 additions & 0 deletions docs/CustomTransactionSample.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ This document contains the raw message samples for different transaction types.
"value": "Uint8Array TextProposal"
}
}
}
]
```

Expand All @@ -279,6 +280,7 @@ This document contains the raw message samples for different transaction types.
"proposalId": "5",
"voter": "aura1yukgemvxtr8fv6899ntd65qfyhwgx25d2nhvj6",
}
}
]
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pyxis-safe-api",
"version": "0.6.0",
"version": "0.7.0",
"description": "Pyxis Safe Backend API",
"author": {
"name": "Aura Network",
Expand Down
37 changes: 37 additions & 0 deletions src/chains/chain.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import {
IMessage,
IMsgMultiSend,
IDecodedMessage,
ICw20Msg,
} from '../modules/multisig-transaction/interfaces';
import { UserInfoDto } from '../modules/auth/dto';
import { Chain } from '../modules/chain/entities/chain.entity';
import { CustomError } from '../common/custom-error';
import { ErrorMap } from '../common/error.map';
import { ChainGateway } from './chain.gateway';
import { IMessageUnknown } from '../interfaces';
import { MultisigTransaction } from '../modules/multisig-transaction/entities/multisig-transaction.entity';

export class ChainHelper {
constructor(public chain: Chain) {}
Expand Down Expand Up @@ -249,4 +251,39 @@ export class ChainHelper {
}
return total;
}

getDataFromTx(
transaction: MultisigTransaction,
decodedMsgs: IMessageUnknown[],
aminoMsgs: AminoMsg[],
): {
amount: number;
contractAddress?: string;
} {
if (
transaction.typeUrl === TxTypeUrl.EXECUTE_CONTRACT &&
transaction.toAddress !== '' &&
!(decodedMsgs[0].value instanceof Uint8Array) &&
decodedMsgs[0].value.msg instanceof Uint8Array
) {
const contractAddress = decodedMsgs[0].value.contract;
const decodedMsg = fromUtf8(decodedMsgs[0].value.msg);
const objectMsg = JSON.parse(decodedMsg) as ICw20Msg;
if (objectMsg.transfer.recipient !== transaction.toAddress) {
throw new CustomError(
ErrorMap.TRANSACTION_NOT_VALID,
'recipient address is not match with address in msg',
);
}

return {
amount: Number(objectMsg.transfer.amount),
contractAddress,
};
}

return {
amount: this.calculateAmount(aminoMsgs),
};
}
}
7 changes: 7 additions & 0 deletions src/interfaces/contract-info.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface IContractAddress {
smart_contract: {
cw20_contract: {
symbol: string;
};
}[];
}
2 changes: 1 addition & 1 deletion src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './validator.interface';
export * from './validators.interface';
export * from './keybase-identity.interface';
export * from './network-status.interface';
export * from './account-info.interface';
export * from './account-unbound.interface';
Expand All @@ -10,3 +9,4 @@ export * from './message.interface';
export * from './votes.interface';
export * from './token-info.interface';
export * from './indexer-v2.interface';
export * from './contract-info.interface';
11 changes: 0 additions & 11 deletions src/interfaces/keybase-identity.interface.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/modules/multisig-transaction/dto/request/send-tx.req.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,4 @@ export class SendTransactionRequestDto {
example: 14,
})
transactionId: number;

@IsNumber()
@Type(() => Number)
@ApiProperty({
description: 'Offchain Chain Id',
example: 4,
})
@Type(() => Number)
internalChainId: number;
}
Loading