Skip to content
Open
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
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/lib/components/ConfirmTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export default function ConfirmTransactions(props) {
onClick={(e) => {
e.preventDefault();
setLoading(true);
near.sendTransactions(transactions).then(() => {
near.sendTransactions(transactions).then((res) => {
setLoading(false);
onHide();
onHide(res);
});
}}
>
Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ export const Widget = React.forwardRef((props, forwardedRef) => {
{transactions && (
<ConfirmTransactions
transactions={transactions}
onHide={() => setTransactions(null)}
onHide={(res) => {
setTransactions(null);
if (res) {
vm.afterConfirmTx(res);
}
}}
/>
)}
{commitRequest && (
Expand Down
17 changes: 17 additions & 0 deletions src/lib/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,13 @@ class VmStack {
);
}
return this.vm.useCache(...args);
} else if (callee === "afterConfirmTx") {
if (!(args[0] instanceof Function)) {
throw new Error(
"Method: afterConfirmTx. The first argument must be a function"
);
}
return this.vm.setTxCallback(args[0]);
} else if (callee === "parseInt") {
return parseInt(...args);
} else if (callee === "parseFloat") {
Expand Down Expand Up @@ -2012,4 +2019,14 @@ export default class VM {
}
return executionResult?.result;
}

setTxCallback(cb) {
this.txCallback = cb;
}

afterConfirmTx(res) {
if (this.txCallback instanceof Function) {
this.txCallback(res);
}
}
}