it('should return a contract deployment type when to is falsy and there is data',asyncfunction(){
constresult=awaitdetermineTransactionType(
{
to:'',
data:'0xabd',
},
query,
);
expect(result).toMatchObject({
type:TRANSACTION_TYPES.DEPLOY_CONTRACT,
getCodeResponse:undefined,
});
});
it('should return a simple send type with a 0x getCodeResponse when there is data and but the to address is not a contract address',asyncfunction(){
constresult=awaitdetermineTransactionType(
{
to:'0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data:'0xabd',
},
query,
);
expect(result).toMatchObject({
type:TRANSACTION_TYPES.SIMPLE_SEND,
getCodeResponse:'0x',
});
});
it('should return a simple send type with a null getCodeResponse when to is truthy and there is data and but getCode returns an error',asyncfunction(){
constresult=awaitdetermineTransactionType(
{
to:'0xabc',
data:'0xabd',
},
query,
);
expect(result).toMatchObject({
type:TRANSACTION_TYPES.SIMPLE_SEND,
getCodeResponse:null,
});
});
it('should return a contract interaction type with the correct getCodeResponse when to is truthy and there is data and it is not a token transaction',asyncfunction(){
const_providerResultStub={
// 1 gwei
eth_gasPrice:'0x0de0b6b3a7640000',
// by default, all accounts are external accounts (not contracts)
eth_getCode:'0xa',
};
const_provider=createTestProviderTools({
scaffold:_providerResultStub,
}).provider;
constresult=awaitdetermineTransactionType(
{
to:'0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data:'abd',
},
newEthQuery(_provider),
);
expect(result).toMatchObject({
type:TRANSACTION_TYPES.CONTRACT_INTERACTION,
getCodeResponse:'0x0a',
});
});
it('should return a contract interaction type with the correct getCodeResponse when to is a contract address and data is falsy',asyncfunction(){
const_providerResultStub={
// 1 gwei
eth_gasPrice:'0x0de0b6b3a7640000',
// by default, all accounts are external accounts (not contracts)