Skip to content

Commit

Permalink
SERVICES-2608: fix transaction data field in failing unit tests
Browse files Browse the repository at this point in the history
- MultiESDTNFTTransfer/ESDTNFTTransfer for a single fungible becomes ESDTTransfer
- MultiESDTNFTTransfer for a single MetaESDT becomes ESDTNFTTransfer
- the length of the random part of a collection identifier needs to be exactly 6 characters (enforced in v13)
  • Loading branch information
mad2sm0key committed Sep 24, 2024
1 parent 5d39505 commit 17c3dbb
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
"resume": 200000000,
"registerFarmToken": 200000000,
"setLocalRolesFarmToken": 20000000,
"setFarmMigrationConfig": 7300000
"setFarmMigrationConfig": 7300000,
"mergeFarmTokensMultiplier": 200000000
}
},
"proxy": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('EscrowTransactionService', () => {
chainID: mxConfig.chainID,
nonce: 0,
data: encodeTransactionData(
`MultiESDTNFTTransfer@${scAddress.escrow}@01@XMEX-123456@01@1000000000000000000@lockFunds@${receiverAddress}`,
`ESDTNFTTransfer@XMEX-123456@01@1000000000000000000@${scAddress.escrow}@lockFunds@${receiverAddress}`,
),
gasPrice: 1000000000,
gasLimit: gasConfig.escrow.lockFunds,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/farm/specs/farm.transactions.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ describe('FarmService', () => {
nonce: 0,
value: '0',
receiver:
'erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu',
'erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqssfuwnk5',
sender: 'erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu',
gasPrice: 1000000000,
gasLimit: gasConfig.farms['v1.2'].enterFarm.default,
data: encodeTransactionData(
'MultiESDTNFTTransfer@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqssfuwnk5@01@EGLDMEXLP-abcdef@@1000000000000@enterFarmAndLockRewards',
'ESDTTransfer@EGLDMEXLP-abcdef@1000000000000@enterFarmAndLockRewards',
),
chainID: mxConfig.chainID,
version: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,15 @@ describe('PositionCreatorTransaction', () => {
{
nonce: 0,
value: '0',
receiver: Address.Zero().bech32(),
receiver:
'erd1qqqqqqqqqqqqqpgqh3zcutxk3wmfvevpyymaehvc3k0knyq70n4sg6qcj6',
sender: Address.Zero().bech32(),
senderUsername: undefined,
receiverUsername: undefined,
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
`MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@01@USDC-123456@@100000000000000000000@createFarmPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000021@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327`,
`ESDTTransfer@USDC-123456@100000000000000000000@createFarmPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000021@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327`,
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -704,14 +705,15 @@ describe('PositionCreatorTransaction', () => {
{
nonce: 0,
value: '0',
receiver: Address.Zero().bech32(),
receiver:
'erd1qqqqqqqqqqqqqpgqh3zcutxk3wmfvevpyymaehvc3k0knyq70n4sg6qcj6',
sender: Address.Zero().bech32(),
senderUsername: undefined,
receiverUsername: undefined,
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
`MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@01@USDC-123456@@100000000000000000000@createFarmPosFromSingleToken@1440@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327`,
`ESDTTransfer@USDC-123456@100000000000000000000@createFarmPosFromSingleToken@1440@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327`,
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -968,14 +970,15 @@ describe('PositionCreatorTransaction', () => {
{
nonce: 0,
value: '0',
receiver: Address.Zero().bech32(),
receiver:
'erd1qqqqqqqqqqqqqpgqh3zcutxk3wmfvevpyymaehvc3k0knyq70n4sg6qcj6',
sender: Address.Zero().bech32(),
senderUsername: undefined,
receiverUsername: undefined,
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@01@USDC-123456@@100000000000000000000@createMetastakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
'ESDTTransfer@USDC-123456@100000000000000000000@createMetastakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@329339339317295273252@329339339317295273252718@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -1377,14 +1380,15 @@ describe('PositionCreatorTransaction', () => {
{
nonce: 0,
value: '0',
receiver: Address.Zero().bech32(),
receiver:
'erd1qqqqqqqqqqqqqpgqh3zcutxk3wmfvevpyymaehvc3k0knyq70n4sg6qcj6',
sender: Address.Zero().bech32(),
senderUsername: undefined,
receiverUsername: undefined,
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@01@USDC-123456@@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@999999999899699097301@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
'ESDTTransfer@USDC-123456@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@999999999899699097301@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -1431,7 +1435,7 @@ describe('PositionCreatorTransaction', () => {
amount: '100000000000000000000',
}),
new EsdtTokenPayment({
tokenIdentifier: 'STAKETOK-1111',
tokenIdentifier: 'STAKETOK-111111',
tokenNonce: 1,
amount: '100000000000000000000',
}),
Expand Down Expand Up @@ -1473,7 +1477,7 @@ describe('PositionCreatorTransaction', () => {
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@02@WEGLD-123456@@100000000000000000000@STAKETOK-1111@01@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@90661089388014913158134@0000000000000000000000000000000000000000000000000000000000000012@swapTokensFixedInput@MEX-123456@89754478494134764026552',
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@02@WEGLD-123456@@100000000000000000000@STAKETOK-111111@01@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@90661089388014913158134@0000000000000000000000000000000000000000000000000000000000000012@swapTokensFixedInput@MEX-123456@89754478494134764026552',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -1515,7 +1519,7 @@ describe('PositionCreatorTransaction', () => {
amount: '100000000000000000000',
}),
new EsdtTokenPayment({
tokenIdentifier: 'STAKETOK-1111',
tokenIdentifier: 'STAKETOK-111111',
tokenNonce: 1,
amount: '100000000000000000000',
}),
Expand All @@ -1539,7 +1543,7 @@ describe('PositionCreatorTransaction', () => {
gasPrice: 1000000000,
gasLimit: gasLimit,
data: encodeTransactionData(
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@02@USDC-123456@@100000000000000000000@STAKETOK-1111@01@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@999999999899699097301@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
'MultiESDTNFTTransfer@00000000000000000500bc458e2cd68bb69665812137dcdd988d9f69901e7ceb@02@USDC-123456@@100000000000000000000@STAKETOK-111111@01@100000000000000000000@createFarmStakingPosFromSingleToken@0000000000000000000000000000000000000000000000000000000000000000@999999999899699097301@0000000000000000000000000000000000000000000000000000000000000013@swapTokensFixedInput@WEGLD-123456@989999999900702106327',
),
chainID: 'T',
version: 2,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/router/mocks/router.abi.service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class RouterAbiServiceMock implements IRouterAbiService {
address: Address.Zero().bech32(),
}),
commonTokenID: 'USDC-123456',
lockedTokenID: 'LKESDT-1234',
lockedTokenID: 'LKESDT-123456',
minLockedTokenValue: '8000000000',
minLockPeriodEpochs: 1,
});
Expand Down
10 changes: 5 additions & 5 deletions src/modules/router/specs/router.transactions.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ describe('RouterService', () => {
const transaction = await service.setSwapEnabledByUser(
Address.Zero().bech32(),
new InputTokenModel({
tokenID: 'LKESDT-1234',
tokenID: 'LKESDT-123456',
nonce: 1,
amount: '10000000000',
attributes:
Expand All @@ -563,7 +563,7 @@ describe('RouterService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.router.swapEnableByUser,
data: encodeTransactionData(
`ESDTNFTTransfer@LKESDT-1234@01@10000000000@${Address.fromHex(
`ESDTNFTTransfer@LKESDT-123456@01@10000000000@${Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000011',
).bech32()}@setSwapEnabledByUser@${Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000013',
Expand All @@ -587,7 +587,7 @@ describe('RouterService', () => {
service.setSwapEnabledByUser(
Address.Zero().bech32(),
new InputTokenModel({
tokenID: 'LKESDT-1234',
tokenID: 'LKESDT-123456',
nonce: 1,
amount: '1000000000000000000',
attributes:
Expand Down Expand Up @@ -655,7 +655,7 @@ describe('RouterService', () => {
service.setSwapEnabledByUser(
Address.Zero().bech32(),
new InputTokenModel({
tokenID: 'LKESDT-1234',
tokenID: 'LKESDT-123456',
nonce: 1,
amount: '1000000000000000000',
attributes:
Expand All @@ -678,7 +678,7 @@ describe('RouterService', () => {
service.setSwapEnabledByUser(
Address.Zero().bech32(),
new InputTokenModel({
tokenID: 'LKESDT-1234',
tokenID: 'LKESDT-123456',
nonce: 1,
amount: '1000',
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('StakingProxyTransactionService', () => {
sender: Address.Zero().bech32(),
receiver: Address.Zero().bech32(),
data: encodeTransactionData(
`MultiESDTNFTTransfer@${Address.Zero().bech32()}@01@EGLDTOK4FL-abcdef@01@1@stakeFarmTokens`,
`ESDTNFTTransfer@EGLDTOK4FL-abcdef@01@1@${Address.Zero().bech32()}@stakeFarmTokens`,
),
options: undefined,
signature: undefined,
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('StakingProxyTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stakeProxy.claimDualYield,
data: encodeTransactionData(
`MultiESDTNFTTransfer@0000000000000000000000000000000000000000000000000000000000000000@01@METASTAKE-123456@01@1000000000000000000@claimDualYield`,
`ESDTNFTTransfer@METASTAKE-123456@01@1000000000000000000@0000000000000000000000000000000000000000000000000000000000000000@claimDualYield`,
),
chainID: 'T',
version: 2,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/staking/mocks/staking.abi.service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BoostedYieldsFactors } from 'src/modules/farm/models/farm.v2.model';

export class StakingAbiServiceMock implements IStakingAbiService {
async farmTokenID(stakeAddress: string): Promise<string> {
return 'STAKETOK-1111';
return 'STAKETOK-111111';
}
async farmingTokenID(stakeAddress: string): Promise<string> {
return 'WEGLD-123456';
Expand Down
16 changes: 8 additions & 8 deletions src/modules/staking/specs/staking.transactions.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.stakeFarm.default,
data: encodeTransactionData(
'MultiESDTNFTTransfer@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@01@WEGLD-123456@@1000@stakeFarm',
'ESDTTransfer@WEGLD-123456@1000@stakeFarm',
),
chainID: mxConfig.chainID,
version: 2,
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.unstakeFarm,
data: encodeTransactionData(
'ESDTNFTTransfer@WEGLD-123456@@1000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@unstakeFarm',
'ESDTTransfer@WEGLD-123456@1000@unstakeFarm',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.unbondFarm,
data: encodeTransactionData(
'ESDTNFTTransfer@WEGLD-123456@@01000000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@unbondFarm',
'ESDTTransfer@WEGLD-123456@01000000@unbondFarm',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.claimRewards,
data: encodeTransactionData(
'ESDTNFTTransfer@WEGLD-123456@@01000000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@claimRewards',
'ESDTTransfer@WEGLD-123456@01000000@claimRewards',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.compoundRewards,
data: encodeTransactionData(
'ESDTNFTTransfer@WEGLD-123456@@01000000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@compoundRewards',
'ESDTTransfer@WEGLD-123456@01000000@compoundRewards',
),
chainID: 'T',
version: 2,
Expand Down Expand Up @@ -245,8 +245,8 @@ describe('StakingTransactionService', () => {
const mxApi = module.get<MXApiService>(MXApiService);
jest.spyOn(mxApi, 'getNftsForUser').mockResolvedValue([
{
identifier: 'STAKETOK-1111-01',
collection: 'STAKETOK-1111',
identifier: 'STAKETOK-111111-01',
collection: 'STAKETOK-111111',
attributes:
'AAAABHA3g/MAAAAAAAAACA3gtrOnZAAAYLtgEaeB64tT1h15BHRQrapGl34gI5MSlRJiwQV9EJA=',
nonce: 1,
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('StakingTransactionService', () => {
gasPrice: 1000000000,
gasLimit: gasConfig.stake.claimRewards,
data: encodeTransactionData(
'ESDTNFTTransfer@STAKETOK-1111@01@1000000000000000000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@claimRewards',
'ESDTNFTTransfer@STAKETOK-111111@01@1000000000000000000@erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu@claimRewards',
),
chainID: 'T',
version: 2,
Expand Down

0 comments on commit 17c3dbb

Please sign in to comment.