Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions packages/chain-adapters/src/near/NearChainAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type NearFullTxResult = {
receipts_outcome: {
id: string
outcome: {
executor_id?: string
tokens_burnt: string
logs: string[]
}
Expand Down Expand Up @@ -760,25 +761,13 @@ export class ChainAdapter implements IChainAdapter<KnownChainIds.NearMainnet> {
value: string
}[] = []

let tokenContractId = result.transaction.receiver_id
for (const action of result.transaction.actions) {
if ('FunctionCall' in action) {
const method = action.FunctionCall.method_name
if (method === 'ft_transfer' || method === 'ft_transfer_call') {
break
}
}
if ('Delegate' in action) {
const delegateAction = action.Delegate as {
delegate_action?: { receiver_id?: string; actions?: unknown[] }
}
if (delegateAction.delegate_action?.receiver_id) {
tokenContractId = delegateAction.delegate_action.receiver_id
}
}
}

for (const receipt of result.receipts_outcome) {
// The nep141 event is emitted by the token contract executing the receipt, so the
// executor is the authoritative contract for every event in it - the transaction's
// receiver is whatever contract was called first (e.g. intents.near for swap settlements)
const tokenContractId = receipt.outcome.executor_id
if (!tokenContractId) continue

for (const log of receipt.outcome.logs) {
if (!log.startsWith('EVENT_JSON:')) continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ export const nearIntentsApi: SwapperApi = {

// Extract buyTxHash from destination chain transactions
const buyTxHash = statusResponse.swapDetails?.destinationChainTxHashes?.[0]?.hash
const actualBuyAmountCryptoBaseUnit = statusResponse.swapDetails?.amountOut

// amountOut is only meaningful destination-denominated on terminal success - in-flight and
// refund states may carry settlement-internal or refund values
const actualBuyAmountCryptoBaseUnit =
statusResponse.status === 'SUCCESS' ? statusResponse.swapDetails?.amountOut : undefined

return {
status: txStatus,
Expand Down
Loading