Skip to content

Commit

Permalink
Add transfer and module transaction ids (safe-global#312)
Browse files Browse the repository at this point in the history
Related to
safe-global/safe-transaction-service#1365

This PR adds the new fields (`transferId`, `moduleTransactionId`) for
Transfers and Module Transactions into the associated entities,
validation schemas, and test instance builders.
  • Loading branch information
hectorgomezv authored May 8, 2023
1 parent ef4e69e commit f17d5aa
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/domain/safe/entities/__tests__/erc20-transfer.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function erc20TransferBuilder(): IBuilder<ERC20Transfer> {
.with('to', faker.finance.ethereumAddress())
.with('transactionHash', faker.datatype.hexadecimal())
.with('tokenAddress', faker.finance.ethereumAddress())
.with('value', faker.datatype.hexadecimal());
.with('value', faker.datatype.hexadecimal())
.with('transferId', faker.datatype.string());
}

export function toJson(erc20Transfer: ERC20Transfer): unknown {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function erc721TransferBuilder(): IBuilder<ERC721Transfer> {
.with('to', faker.finance.ethereumAddress())
.with('transactionHash', faker.datatype.hexadecimal())
.with('tokenAddress', faker.finance.ethereumAddress())
.with('tokenId', faker.datatype.string());
.with('tokenId', faker.datatype.string())
.with('transferId', faker.datatype.string());
}

export function toJson(erc721Transfer: ERC721Transfer): unknown {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function moduleTransactionBuilder(): IBuilder<ModuleTransaction> {
.with('safe', faker.finance.ethereumAddress())
.with('to', faker.finance.ethereumAddress())
.with('transactionHash', faker.datatype.hexadecimal())
.with('value', faker.datatype.hexadecimal());
.with('value', faker.datatype.hexadecimal())
.with('moduleTransactionId', faker.datatype.string());
}

export function toJson(moduleTransaction: ModuleTransaction): unknown {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export function nativeTokenTransferBuilder(): IBuilder<NativeTokenTransfer> {
.with('from', faker.finance.ethereumAddress())
.with('to', faker.finance.ethereumAddress())
.with('transactionHash', faker.datatype.hexadecimal())
.with('value', faker.datatype.hexadecimal());
.with('value', faker.datatype.hexadecimal())
.with('transferId', faker.datatype.string());
}

export function toJson(nativeTokenTransfer: NativeTokenTransfer): unknown {
Expand Down
1 change: 1 addition & 0 deletions src/domain/safe/entities/module-transaction.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ModuleTransaction {
executionDate: Date;
isSuccessful: boolean;
module: string;
moduleTransactionId: string;
operation: Operation;
safe: string;
to: string;
Expand Down
2 changes: 2 additions & 0 deletions src/domain/safe/entities/schemas/erc20-transfer.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const erc20TransferSchema: Schema = {
from: { type: 'string' },
value: { type: 'string' },
tokenAddress: { type: 'string', nullable: true, default: null },
transferId: { type: 'string' },
},
required: [
'type',
Expand All @@ -24,5 +25,6 @@ export const erc20TransferSchema: Schema = {
'to',
'from',
'value',
'transferId',
],
};
2 changes: 2 additions & 0 deletions src/domain/safe/entities/schemas/erc721-transfer.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const erc721TransferSchema: Schema = {
from: { type: 'string' },
tokenId: { type: 'string' },
tokenAddress: { type: 'string', nullable: true, default: null },
transferId: { type: 'string' },
},
required: [
'type',
Expand All @@ -24,5 +25,6 @@ export const erc721TransferSchema: Schema = {
'to',
'from',
'tokenId',
'transferId',
],
};
2 changes: 2 additions & 0 deletions src/domain/safe/entities/schemas/module-transaction.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const moduleTransactionSchema: Schema = {
isSuccessful: { type: 'boolean' },
transactionHash: { type: 'string' },
module: { type: 'string' },
moduleTransactionId: { type: 'string' },
},
required: [
'safe',
Expand All @@ -34,5 +35,6 @@ export const moduleTransactionSchema: Schema = {
'isSuccessful',
'transactionHash',
'module',
'moduleTransactionId',
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const nativeTokenTransferSchema: Schema = {
to: { type: 'string' },
from: { type: 'string' },
value: { type: 'string' },
transferId: { type: 'string' },
},
required: [
'type',
Expand All @@ -20,5 +21,6 @@ export const nativeTokenTransferSchema: Schema = {
'to',
'from',
'value',
'transferId',
],
};
1 change: 1 addition & 0 deletions src/domain/safe/entities/transfer.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Transfer {
from: string;
to: string;
transactionHash: string;
transferId: string;
}

export interface ERC20Transfer extends Transfer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"decimals": 18,
"logoUri": "https://safe-transaction-assets.safe.global/tokens/logos/0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60.png"
},
"from": "0x4127839cdf4F73d9fC9a2C2861d8d1799e9DF40C"
"from": "0x4127839cdf4F73d9fC9a2C2861d8d1799e9DF40C",
"transferId": "e1015fc6905859c6957ab918abc19840f035e3da0c9fc9fa9df075d5c72dcfd31167"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"decimals": null,
"logoUri": "https://safe-transaction-assets.safe.global/tokens/logos/ENS.png"
},
"from": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5"
"from": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"transferId": "e1015fc6905859c6957ab918abc19840f035e3da0c9fc9fa9df075d5c72dcfd31167"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"tokenId": null,
"tokenAddress": null,
"tokenInfo": null,
"from": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5"
"from": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"transferId": "e1015fc6905859c6957ab918abc19840f035e3da0c9fc9fa9df075d5c72dcfd31167"
}
]
}

0 comments on commit f17d5aa

Please sign in to comment.