diff --git a/src/blockchain/wallet.js b/src/blockchain/wallet.js index f77700f..0194421 100644 --- a/src/blockchain/wallet.js +++ b/src/blockchain/wallet.js @@ -278,16 +278,17 @@ export const PendingOrderState = { export async function pendOrder(order) { - console.log('order', JSON.stringify(order)) const s = useStore() - useWalletStore().pendingOrders.splice(0,0,{ + const pend = { id: uuid(), chainId: s.chainId, placementTime: Date.now()/1000, vault: s.vaults.length ? s.vaults[0] : null, state: PendingOrderState.Submitted, order - }) + }; + useWalletStore().pendingOrders.splice(0,0, pend) + console.log('pending order', pend.id, JSON.stringify(order)) ensureVault() } @@ -322,7 +323,7 @@ export function flushOrders(vault) { if (pend.vault === null) pend.vault = vault if (pend.state === PendingOrderState.Submitted) { - console.log('pending', pend) + console.log('flushing order', pend.id) pendOrderAsTransaction(pend) pend.state = PendingOrderState.Signing needsFlush = true @@ -345,25 +346,29 @@ function pendOrderAsTransaction(pend) { pend.state = PendingOrderState.Rejected return null } - console.log('placing order', pend) + console.log('placing order', pend.id) const tx = await contract.placeDexorder(pend.order) // todo update status pend.tx = tx + pend.state = PendingOrderState.Sent + console.log(`order ${pend.id} sent transaction`, tx) tx.wait().then((txReceipt)=>{ + console.log('mined order', pend.id, txReceipt) + pend.receipt = txReceipt const ws = useWalletStore(); - ws.pendingOrders = ws.pendingOrders.filter((o)=>o!==pend) + ws.pendingOrders = ws.pendingOrders.filter((p)=>p!==pend) // remove pend since order was mined }) return tx }, (e) => { if( e.info?.error?.code === 4001 ) { - console.log(`user rejected transaction`) + console.log(`wallet refused order`, pend.id) pend.state = PendingOrderState.Rejected return true // returning true means we handled the error. any other return value will dump to console. } }) } - +0 export function pendTransaction(sender, errHandler) { const s = useStore() s.transactionSenders.push([sender,errHandler]) @@ -409,7 +414,9 @@ function doSendTransaction(sender, signer, errHandler) { sender(signer).then((tx)=>{ if (tx!==null) { console.log('sent transaction', tx) - tx.wait().then((tr)=>console.log('tx receipt',tr)) + tx.wait().then((tr)=>{ + console.log('tx receipt',tr) + }) } }).catch(async (e)=>{ let dumpErr = true diff --git a/src/components/CopyButton.vue b/src/components/CopyButton.vue index 36a0035..7ea4c6b 100644 --- a/src/components/CopyButton.vue +++ b/src/components/CopyButton.vue @@ -1,5 +1,5 @@