-
Notifications
You must be signed in to change notification settings - Fork 294
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
LIVE-12087 - Fix llm prepare sign tx #6759
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"live-mobile": minor | ||
--- | ||
|
||
Standardize PrepareSignTx behavior\ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,23 +21,15 @@ describe("prepareSignTransaction", () => { | |
// Given | ||
const parentAccount = createAccount("12"); | ||
const childAccount = createTokenAccount("22", "js:2:ethereum:0x012:"); | ||
const expectedResult: EvmTransaction = { | ||
const expectedResult: Partial<EvmTransaction> = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a bit wrong to expect a partial transaction now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what the prepareSignTransaction returns |
||
amount: new BigNumber("1000"), | ||
data: Buffer.from([]), | ||
family: "evm", | ||
feesStrategy: "medium", | ||
gasPrice: new BigNumber("700000"), | ||
gasLimit: new BigNumber("1200000"), | ||
customGasLimit: new BigNumber("1200000"), | ||
mode: "send", | ||
gasPrice: new BigNumber("700000"), | ||
nonce: 8, | ||
recipient: "0x0123456", | ||
subAccountId: "js:2:ethereum:0x022:", | ||
useAllAmount: false, | ||
maxFeePerGas: undefined, | ||
maxPriorityFeePerGas: undefined, | ||
type: 1, | ||
chainId: 0, | ||
}; | ||
|
||
// When | ||
|
@@ -49,7 +41,11 @@ describe("prepareSignTransaction", () => { | |
}); | ||
|
||
// *** UTIL FUNCTIONS *** | ||
function createEtherumTransaction(): Partial<Transaction & { gasLimit: BigNumber }> { | ||
function createEtherumTransaction(): Partial< | ||
Transaction & { | ||
gasLimit: BigNumber; | ||
} | ||
> { | ||
return { | ||
family: "evm", | ||
amount: new BigNumber("1000"), | ||
|
@@ -149,9 +145,18 @@ function createTokenAccount(id = "32", parentId = "whatever"): TokenAccount { | |
pendingOperations: [], | ||
starred: false, | ||
balanceHistoryCache: { | ||
WEEK: { latestDate: null, balances: [] }, | ||
HOUR: { latestDate: null, balances: [] }, | ||
DAY: { latestDate: null, balances: [] }, | ||
WEEK: { | ||
latestDate: null, | ||
balances: [], | ||
}, | ||
HOUR: { | ||
latestDate: null, | ||
balances: [], | ||
}, | ||
DAY: { | ||
latestDate: null, | ||
balances: [], | ||
}, | ||
}, | ||
swapHistory: [], | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,15 @@ import BigNumber from "bignumber.js"; | |
|
||
export default function prepareSignTransaction( | ||
account: AccountLike, | ||
parentAccount: Account | undefined, | ||
liveTx: Partial<Transaction & { gasLimit: BigNumber }>, | ||
parentAccount: Account | null | undefined, | ||
liveTx: Partial< | ||
Transaction & { | ||
gasLimit: BigNumber; | ||
} | ||
>, | ||
): TransactionCommon { | ||
const bridge = getAccountBridge(account, parentAccount); | ||
const t = bridge.createTransaction(account); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it okay to not go through the |
||
const { recipient, ...txData } = liveTx; | ||
const t2 = bridge.updateTransaction(t, { | ||
recipient, | ||
return bridge.updateTransaction(liveTx, { | ||
subAccountId: isTokenAccount(account) ? account.id : undefined, | ||
}); | ||
|
||
return bridge.updateTransaction(t2, { | ||
customGasLimit: txData.gasLimit, | ||
type: 1, | ||
maxFeePerGas: undefined, | ||
maxPriorityFeePerGas: undefined, | ||
...txData, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that testing half of the expected result is enough.
The function is expected to return a full
Transaction
object, not a Partial one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what the prepareSignTransaction returns